Skip to content

Commit ada15f4

Browse files
authored
QC-1290 Possibility to have evenly-spaced trends against run numbers (#2567)
This commits adds runNumberStr branch to trends in TrendingTask and SliceTrendingTask to allow for creating trends with evenly-spaced data points, where run rumbers work as labels.
1 parent 5181f55 commit ada15f4

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed

Framework/include/QualityControl/SliceTrendingTask.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ class SliceTrendingTask : public PostProcessingInterface
6565
void finalize(Trigger, framework::ServiceRegistryRef) final;
6666

6767
private:
68+
static constexpr size_t MaxRunNumberStringLength = 6;
6869
struct MetaData {
70+
// we store run numbers both as an integer and as a string to allow users to select whether they need
71+
// a trend in integer or label domain (the latter will contain evenly-spaced data points)
6972
Int_t runNumber = 0;
73+
char runNumberStr[MaxRunNumberStringLength + 1] = { 0 }; // 6 characters + null terminator
7074
};
7175
struct TitleSettings {
7276
std::string observableX;

Framework/include/QualityControl/TrendingTask.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ class TrendingTask : public PostProcessingInterface
5656
void finalize(Trigger, framework::ServiceRegistryRef) override;
5757

5858
private:
59+
static constexpr size_t MaxRunNumberStringLength = 6;
5960
struct {
61+
// we store run numbers both as an integer and as a string to allow users to select whether they need
62+
// a trend in integer or label domain (the latter will contain evenly-spaced data points)
6063
Long64_t runNumber = 0;
64+
char runNumberStr[MaxRunNumberStringLength + 1] = { 0 }; // 6 characters + null terminator
6165
static const char* getBranchLeafList()
6266
{
63-
return "runNumber/L";
67+
return "runNumber/L:runNumberStr/C";
6468
}
6569
} mMetaData;
6670

Framework/src/SliceTrendingTask.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ void SliceTrendingTask::trendValues(const Trigger& t,
145145
mTime = t.activity.mValidity.getMax() / 1000;
146146
}
147147
mMetaData.runNumber = t.activity.mId;
148+
std::snprintf(mMetaData.runNumberStr, MaxRunNumberStringLength + 1, "%d", t.activity.mId);
149+
148150
for (auto& dataSource : mConfig.dataSources) {
149151
mNumberPads[dataSource.name] = 0;
150152
mSources[dataSource.name]->clear();

Framework/src/TrendingTask.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ bool TrendingTask::trendValues(const Trigger& t, repository::DatabaseInterface&
184184
mTime = t.activity.mValidity.getMax() / 1000;
185185
}
186186
mMetaData.runNumber = t.activity.mId;
187-
bool wereAllSourcesInvoked = true;
187+
std::snprintf(mMetaData.runNumberStr, MaxRunNumberStringLength + 1, "%d", t.activity.mId);
188188

189+
bool wereAllSourcesInvoked = true;
189190
for (auto& dataSource : mConfig.dataSources) {
190191
if (!reductor_helpers::updateReductor(mReductors[dataSource.name].get(), t, dataSource, qcdb, *this)) {
191192
wereAllSourcesInvoked = false;

Modules/Common/src/TH1SliceReductor.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ void TH1SliceReductor::GetTH1StatsY(TH1* hist, float stats[3],
134134

135135
// Safety measures.
136136
if (lowerBin <= 0 || upperBin <= 0) {
137-
ILOG(Error, Support) << "Error: Negative bin in TH1ReducterTPC::GetTH1StatsY" << ENDM;
137+
ILOG(Error, Support) << "Error: Negative bin in TH1SliceReductor::GetTH1StatsY" << ENDM;
138138
exit(0);
139139
}
140140
if (upperBin < lowerBin) {
141-
ILOG(Error, Support) << "Error: Upper bin smaller than lower bin in TH1ReducterTPC::GetTH1StatsY" << ENDM;
141+
ILOG(Error, Support) << "Error: Upper bin smaller than lower bin in TH1SliceReductor::GetTH1StatsY" << ENDM;
142142
exit(0);
143143
}
144144
if (nTotalBins < iterateBins) {
145-
ILOG(Error, Support) << "Error: Bin region bigger than total amount of bins TH1ReducterTPC::GetTH1StatsY" << ENDM;
145+
ILOG(Error, Support) << "Error: Bin region bigger than total amount of bins TH1SliceReductor::GetTH1StatsY" << ENDM;
146146
exit(0);
147147
}
148148

doc/PostProcessing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ In such case, to reduce a Monitor Object or Quality Object, one has to inherit R
287287

288288
All the values are stored in a **TTree**.
289289
Each data source forms a separate branch, with its leaves being the individual values.
290-
Additionally added columns include a `time` branch and a `metadata` branch (now consisting only of `runNumber`).
290+
Additionally added columns include a `time` branch and a `metadata` branch, consisting of `runNumber` (integer) and `runNumberStr` (string/label).
291291

292292
The TTree is stored back to the **QC database** each time it is updated.
293293
In addition, the class exposes the [`TTree::Draw`](https://root.cern/doc/master/classTTree.html#a73450649dc6e54b5b94516c468523e45) interface, which allows to instantaneously generate **plots** with trends, correlations or histograms that are also sent to the QC database.

0 commit comments

Comments
 (0)