Skip to content

Commit 502e54f

Browse files
lhusovaLucia Anna Tarasovicova
andauthored
CTP: trending (#2341)
* trending update - configurable names * fix * add the ccdb name as configurable --------- Co-authored-by: Lucia Anna Tarasovicova <lucia.anna.husova@cern.ch>
1 parent a286b87 commit 502e54f

5 files changed

Lines changed: 260 additions & 98 deletions

File tree

Modules/CTP/include/CTP/CTPTrendingTask.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,15 @@ class CTPTrendingTask : public PostProcessingInterface
6464
MetaData mMetaData;
6565
UInt_t mTime;
6666

67-
std::string mInputNames[5] = { "MTVX", "MVBA", "0DMC", "0EMC", "0PH0" };
68-
std::string mClassNames[5] = { "CMTVX-B-NOPF", "CMVBA-B-NOPF", "CTVXDMC-B-NOPF-EMC", "CTVXEMC-B-NOPF-EMC", "CTVXPH0-B-NOPF-PHSCPV" };
67+
std::string mInputNamesDefault[5] = { "TVX", "VBA", "DMC", "EMC", "PH0" };
68+
std::string ctpinputs[49] = { " T0A", " T0C", " TVX", " TSC", " TCE", " VBA", " VOR", " VIR", " VNC", " VCH", "11", "12", " UCE", "DMC", " USC", " UVX", " U0C", " U0A", "COS", "LAS", "EMC", " PH0", "23", "24", "ZED", "ZNC", "PHL", "PHH", "PHM", "30", "31", "32", "33", "34", "35", "36", "EJ1", "EJ2", "EG1", "EG2", "DJ1", "DG1", "DJ2", "DG2", "45", "46", "47", "48", "49" };
69+
std::string mClassNamesDefault[5] = { "CMTVX-B-NOPF", "CMVBA-B-NOPF", "CTVXDMC-B-NOPF-EMC", "CTVXEMC-B-NOPF-EMC", "CTVXPH0-B-NOPF-PHSCPV" };
70+
std::string mClassNames[5] = { "", "", "", "", "" };
71+
std::string mInputNames[5] = { "", "", "", "", "" };
6972
const int mNumOfClasses = 5;
73+
const int mNumOfInputs = 5;
7074
int mClassIndex[5] = { 65, 65, 65, 65, 65 };
75+
int mInputIndex[5] = { 49, 49, 49, 49, 49 };
7176

7277
std::map<std::string, TObject*> mPlots;
7378

Modules/CTP/include/CTP/TH1ctpReductor.h

Lines changed: 76 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,45 +33,100 @@ class TH1ctpReductor : public quality_control::postprocessing::ReductorTObject
3333
void* getBranchAddress() override;
3434
const char* getBranchLeafList() override;
3535
void update(TObject* obj) override;
36-
void SetMTVXIndex(int in)
36+
37+
void SetClassIndexes(int inMB1, int inMB2, int inDMC, int inEMC, int inPHO)
38+
{
39+
mMinBias1ClassIndex = inMB1;
40+
mMinBias2ClassIndex = inMB2;
41+
mPH0ClassIndex = inPHO;
42+
mDMCClassIndex = inDMC;
43+
mEMCClassIndex = inEMC;
44+
}
45+
void SetInputIndexes(int inMB1, int inMB2, int inDMC, int inEMC, int inPHO)
46+
{
47+
mMinBias1InputIndex = inMB1;
48+
mMinBias2InputIndex = inMB2;
49+
mPH0ClassIndex = inPHO;
50+
mDMCInputIndex = inDMC;
51+
mEMCInputIndex = inEMC;
52+
}
53+
void SetMinBias1ClassIndex(int in)
54+
{
55+
mMinBias1ClassIndex = in;
56+
}
57+
void SetMinBias2ClassIndex(int in)
58+
{
59+
mMinBias2ClassIndex = in;
60+
}
61+
void SetDMCClassIndex(int in)
62+
{
63+
mDMCClassIndex = in;
64+
}
65+
void SetPHOClassIndex(int in)
66+
{
67+
mPH0ClassIndex = in;
68+
}
69+
void SetEMCClassIndex(int in)
70+
{
71+
mEMCClassIndex = in;
72+
}
73+
void SetMinBias1InputIndex(int in)
3774
{
38-
mMTVXIndex = in;
75+
mMinBias1InputIndex = in;
3976
}
40-
void SetMVBAIndex(int in)
77+
void SetMinBias2InputIndex(int in)
4178
{
42-
mMVBAIndex = in;
79+
mMinBias2InputIndex = in;
4380
}
44-
void SetTVXDCMIndex(int in)
81+
void SetDMCInputIndex(int in)
4582
{
46-
mTVXDCMIndex = in;
83+
mDMCInputIndex = in;
4784
}
48-
void SetTVXPHOIndex(int in)
85+
void SetPHOInputIndex(int in)
86+
{
87+
mPHOInputIndex = in;
88+
}
89+
void SetEMCInputIndex(int in)
90+
{
91+
mEMCInputIndex = in;
92+
}
93+
94+
int GetMinBias1ClassIndex()
4995
{
50-
mTVXPHOIndex = in;
96+
return mMinBias1ClassIndex;
5197
}
52-
void SetTVXEMCIndex(int in)
98+
int GetMinBias1InputIndex()
5399
{
54-
mTVXEMCIndex = in;
100+
return mMinBias1InputIndex;
55101
}
56102

57103
private:
58104
static constexpr int nInputs = 48;
59-
int mMTVXIndex = 65;
60-
int mMVBAIndex = 65;
61-
int mTVXDCMIndex = 65;
62-
int mTVXPHOIndex = 65;
63-
int mTVXEMCIndex = 65;
105+
int mMinBias1ClassIndex = 65;
106+
int mMinBias2ClassIndex = 65;
107+
int mDMCClassIndex = 65;
108+
int mEMCClassIndex = 65;
109+
int mPH0ClassIndex = 65;
110+
int mMinBias1InputIndex = 49;
111+
int mMinBias2InputIndex = 49;
112+
int mDMCInputIndex = 49;
113+
int mEMCInputIndex = 49;
114+
int mPHOInputIndex = 49;
64115

65116
struct {
66117
Double_t mean;
67118
Double_t stddev;
68119
Double_t entries;
69-
Double_t inputs[nInputs];
70-
Double_t classContentMTVX;
71-
Double_t classContentMVBA;
72-
Double_t classContentTVXDMC;
73-
Double_t classContentTVXEMC;
74-
Double_t classContentTVXPHO;
120+
Double_t classContentMinBias1;
121+
Double_t classContentMinBias2;
122+
Double_t classContentDMC;
123+
Double_t classContentEMC;
124+
Double_t classContentPHO;
125+
Double_t inputContentMinBias1;
126+
Double_t inputContentMinBias2;
127+
Double_t inputContentDMC;
128+
Double_t inputContentEMC;
129+
Double_t inputContentPHO;
75130
} mStats;
76131
};
77132

Modules/CTP/src/CTPTrendingTask.cxx

Lines changed: 93 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ void CTPTrendingTask::initCTP(Trigger& t)
4646
std::string run = std::to_string(t.activity.mId);
4747
// CTPRunManager::setCCDBHost("https://alice-ccdb.cern.ch");
4848
// mCTPconfig = CTPRunManager::getConfigFromCCDB(t.timestamp, run);
49-
std::string CCDBHost = "https://alice-ccdb.cern.ch";
49+
std::string CCDBHost;
50+
try {
51+
CCDBHost = std::stof(mCustomParameters.at("ccdbName", "default"));
52+
} catch (const std::exception& e) {
53+
CCDBHost = "https://alice-ccdb.cern.ch";
54+
}
55+
5056
auto& mgr = o2::ccdb::BasicCCDBManager::instance();
5157
mgr.setURL(CCDBHost);
5258
map<string, string> metadata; // can be empty
@@ -56,6 +62,67 @@ void CTPTrendingTask::initCTP(Trigger& t)
5662
ILOG(Warning, Support) << "CTP Config not found for run:" << run << " timesamp " << t.timestamp << ENDM;
5763
return;
5864
}
65+
66+
try {
67+
mClassNames[0] = std::stof(mCustomParameters.at("minBias1Class", "default"));
68+
} catch (const std::exception& e) {
69+
mClassNames[0] = mClassNamesDefault[0];
70+
}
71+
72+
try {
73+
mClassNames[1] = std::stof(mCustomParameters.at("minBias2Class", "default"));
74+
} catch (const std::exception& e) {
75+
mClassNames[1] = mClassNamesDefault[1];
76+
}
77+
78+
try {
79+
mClassNames[2] = std::stof(mCustomParameters.at("minBisDMCclass", "default"));
80+
} catch (const std::exception& e) {
81+
mClassNames[2] = mClassNamesDefault[2];
82+
}
83+
84+
try {
85+
mClassNames[3] = std::stof(mCustomParameters.at("minBiasEMCclass", "default"));
86+
} catch (const std::exception& e) {
87+
mClassNames[3] = mClassNamesDefault[3];
88+
}
89+
90+
try {
91+
mClassNames[4] = std::stof(mCustomParameters.at("minBiasPHOclass", "default"));
92+
} catch (const std::exception& e) {
93+
mClassNames[4] = mClassNamesDefault[4];
94+
}
95+
96+
try {
97+
mInputNames[0] = std::stof(mCustomParameters.at("minBias1Input", "default"));
98+
} catch (const std::exception& e) {
99+
mInputNames[0] = mInputNamesDefault[0];
100+
}
101+
102+
try {
103+
mInputNames[1] = std::stof(mCustomParameters.at("minBias2Input", "default"));
104+
} catch (const std::exception& e) {
105+
mInputNames[1] = mInputNamesDefault[1];
106+
}
107+
108+
try {
109+
mInputNames[2] = std::stof(mCustomParameters.at("minBisDMCInput", "default"));
110+
} catch (const std::exception& e) {
111+
mInputNames[2] = mInputNamesDefault[2];
112+
}
113+
114+
try {
115+
mInputNames[3] = std::stof(mCustomParameters.at("minBiasEMCInput", "default"));
116+
} catch (const std::exception& e) {
117+
mInputNames[3] = mInputNamesDefault[3];
118+
}
119+
120+
try {
121+
mInputNames[4] = std::stof(mCustomParameters.at("minBiasPHOInput", "default"));
122+
} catch (const std::exception& e) {
123+
mInputNames[4] = mInputNamesDefault[4];
124+
}
125+
59126
// get the indeces of the classes we want to trend
60127
std::vector<ctp::CTPClass> ctpcls = mCTPconfig->getCTPClasses();
61128
std::vector<int> clslist = mCTPconfig->getTriggerClassList();
@@ -68,6 +135,15 @@ void CTPTrendingTask::initCTP(Trigger& t)
68135
}
69136
}
70137

138+
for (size_t i = 0; i < sizeof(ctpinputs) / sizeof(std::string); i++) {
139+
for (size_t j = 0; j < mNumOfInputs; j++) {
140+
if (ctpinputs[i].find(mInputNames[j]) != std::string::npos) {
141+
mInputIndex[j] = i + 1;
142+
break;
143+
}
144+
}
145+
}
146+
71147
// Preparing data structure of TTree
72148
for (const auto& source : mConfig.dataSources) {
73149
mReductors.emplace(source.name, root_class_factory::create<o2::quality_control_modules::ctp::TH1ctpReductor>(source.moduleName, source.reductorName));
@@ -77,20 +153,18 @@ void CTPTrendingTask::initCTP(Trigger& t)
77153
mTrend->Branch("runNumber", &mMetaData.runNumber);
78154
mTrend->Branch("time", &mTime);
79155
for (const auto& [sourceName, reductor] : mReductors) {
80-
reductor->SetMTVXIndex(mClassIndex[0]);
81-
reductor->SetMVBAIndex(mClassIndex[1]);
82-
reductor->SetTVXDCMIndex(mClassIndex[2]);
83-
reductor->SetTVXEMCIndex(mClassIndex[3]);
84-
reductor->SetTVXPHOIndex(mClassIndex[4]);
156+
reductor->SetClassIndexes(mClassIndex[0], mClassIndex[1], mClassIndex[2], mClassIndex[3], mClassIndex[4]);
157+
reductor->SetInputIndexes(mInputIndex[0], mInputIndex[1], mInputIndex[2], mInputIndex[3], mInputIndex[4]);
85158
mTrend->Branch(sourceName.c_str(), reductor->getBranchAddress(), reductor->getBranchLeafList());
86159
}
160+
87161
getObjectsManager()->startPublishing(mTrend.get());
88162
ILOG(Debug, Devel) << "Trending run : " << run << ENDM;
89163
}
90164
void CTPTrendingTask::initialize(Trigger t, framework::ServiceRegistryRef services)
91165
{
92166
// // read out the CTPConfiguration
93-
// initCCTP(); - too eraly here ?
167+
// initCTP(t); //- too eraly here ?
94168
}
95169

96170
void CTPTrendingTask::update(Trigger t, framework::ServiceRegistryRef services)
@@ -169,12 +243,24 @@ void CTPTrendingTask::generatePlots()
169243
mPlots[plot.name] = nullptr;
170244
}
171245

246+
if (index < 5 && mInputIndex[index] == 49) { // if the class index == 65, this class is not defined in the config, so it won't be trended
247+
ILOG(Info, Support) << "Input " << mInputNames[index] << " is not trended." << ENDM;
248+
index++;
249+
continue;
250+
}
251+
172252
if (index > 4 && index < 10 && mClassIndex[index - 5] == 65) { // if the class index == 65, this class is not defined in the config, so it won't be trended
173253
ILOG(Info, Support) << "Class " << mClassNames[index - 5] << " is not trended." << ENDM;
174254
index++;
175255
continue;
176256
}
177257

258+
if (index > 9 && index < 14 && (mInputIndex[index - 9] == 49 || mInputIndex[0] == 49)) { // if the class index == 65, this class is not defined in the config, so it won't be trended
259+
ILOG(Info, Support) << "Input ratio " << mInputNames[index - 13] << " / " << mInputNames[0] << " is not trended." << ENDM;
260+
index++;
261+
continue;
262+
}
263+
178264
if (index > 13 && (mClassIndex[index - 13] == 65 || mClassIndex[0] == 65)) { // if the class index == 65, this class is not defined in the config, so it won't be trended
179265
ILOG(Info, Support) << "Class ratio " << mClassNames[index - 13] << " / " << mClassNames[0] << " is not trended." << ENDM;
180266
index++;

Modules/CTP/src/TH1ctpReductor.cxx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void* TH1ctpReductor::getBranchAddress()
2727

2828
const char* TH1ctpReductor::getBranchLeafList()
2929
{
30-
return Form("mean/D:stddev:entries:inputs[%i]:classContentMTVX:classContentMVBA:classContentTVXDMC:classContentTVXEMC:classContentTVXPHO", nInputs);
30+
return "mean/D:stddev:entries:classContentMinBias1:classContentMinBias2:classContentDMC:classContentEMC:classContentPHO:inputContentMinBias1:inputContentMinBias2:inputContentDMC:inputContentEMC:inputContentPHO";
3131
}
3232

3333
void TH1ctpReductor::update(TObject* obj)
@@ -38,14 +38,18 @@ void TH1ctpReductor::update(TObject* obj)
3838
mStats.entries = histo->GetEntries();
3939
mStats.stddev = histo->GetStdDev();
4040
mStats.mean = histo->GetMean();
41-
for (int i = 1; i < nInputs + 1; i++) {
42-
mStats.inputs[i - 1] = histo->GetBinContent(i);
43-
}
44-
mStats.classContentMTVX = histo->GetBinContent(mMTVXIndex);
45-
mStats.classContentMVBA = histo->GetBinContent(mMVBAIndex);
46-
mStats.classContentTVXDMC = histo->GetBinContent(mTVXDCMIndex);
47-
mStats.classContentTVXEMC = histo->GetBinContent(mTVXEMCIndex);
48-
mStats.classContentTVXPHO = histo->GetBinContent(mTVXPHOIndex);
41+
42+
mStats.classContentMinBias1 = histo->GetBinContent(mMinBias1ClassIndex);
43+
mStats.classContentMinBias2 = histo->GetBinContent(mMinBias2ClassIndex);
44+
mStats.classContentDMC = histo->GetBinContent(mDMCClassIndex);
45+
mStats.classContentEMC = histo->GetBinContent(mEMCClassIndex);
46+
mStats.classContentPHO = histo->GetBinContent(mPH0ClassIndex);
47+
48+
mStats.inputContentMinBias1 = histo->GetBinContent(mMinBias1InputIndex);
49+
mStats.inputContentMinBias2 = histo->GetBinContent(mMinBias2InputIndex);
50+
mStats.inputContentDMC = histo->GetBinContent(mDMCInputIndex);
51+
mStats.inputContentEMC = histo->GetBinContent(mEMCInputIndex);
52+
mStats.inputContentPHO = histo->GetBinContent(mPHOInputIndex);
4953
}
5054
}
5155
} // namespace o2::quality_control_modules::ctp

0 commit comments

Comments
 (0)