Skip to content

Commit 14acbfd

Browse files
authored
[PWGDQ]: update Zorro (#8095)
1 parent 9649dea commit 14acbfd

6 files changed

Lines changed: 163 additions & 66 deletions

File tree

EventFiltering/Zorro.cxx

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,68 @@ void Zorro::populateHistRegistry(o2::framework::HistogramRegistry& histRegistry,
9292
mRunNumberHistos.push_back(runNumber);
9393
}
9494

95+
void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto)
96+
{
97+
// x-axis is run number, y-axis is same as ZorroSummary
98+
int runId{-1};
99+
for (size_t i{0}; i < mRunNumberHistos.size(); ++i) {
100+
if (mRunNumberHistos[i] == runNumber) {
101+
runId = i;
102+
break;
103+
}
104+
}
105+
if (runId > -1) {
106+
return;
107+
}
108+
// if the summary histogram is not set, create a new one
109+
if (!ZorroHisto) {
110+
LOGF(info, "Summary histogram not set, creating a new one");
111+
ZorroHisto = new TH2D("Zorro", "Zorro", 1, -0.5, 0.5, 1 + mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5);
112+
ZorroHisto->SetBit(TH1::kIsAverage);
113+
}
114+
if (!ToiHisto) {
115+
LOGF(info, "TOI histogram not set, creating a new one");
116+
ToiHisto = new TH2D("TOI", "TOI", 1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5);
117+
}
118+
// if it is the first run, initialize the histogram
119+
if (mRunNumberHistos.size() == 0) {
120+
ZorroHisto->SetBins(1, -0.5, 0.5, 1 + mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5);
121+
ZorroHisto->SetBit(TH1::kIsAverage);
122+
ZorroHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber));
123+
ZorroHisto->GetYaxis()->SetBinLabel(1, "inspected TVX");
124+
for (size_t i{0}; i < mTOIs.size(); ++i) {
125+
ZorroHisto->GetYaxis()->SetBinLabel(i + 2, Form("%s selections", mTOIs[i].data()));
126+
ZorroHisto->GetYaxis()->SetBinLabel(i + 2 + mTOIs.size(), Form("%s scalers", mTOIs[i].data()));
127+
}
128+
// TOI histogram
129+
ToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5);
130+
ToiHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber));
131+
for (size_t i{0}; i < mTOIs.size(); ++i) {
132+
ToiHisto->GetYaxis()->SetBinLabel(i + 1, mTOIs[i].data());
133+
}
134+
}
135+
if (mInspectedTVX) {
136+
ZorroHisto->Fill(Form("%d", runNumber), "inspected TVX", mInspectedTVX->GetBinContent(1));
137+
ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, 1, mInspectedTVX->GetBinError(1));
138+
}
139+
if (mSelections) {
140+
for (size_t i{0}; i < mTOIs.size(); ++i) {
141+
int bin = findBin(mSelections, mTOIs[i]);
142+
ZorroHisto->Fill(Form("%d", runNumber), Form("%s selections", mTOIs[i].data()), mSelections->GetBinContent(bin));
143+
ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, i + 2, mSelections->GetBinError(bin));
144+
}
145+
}
146+
if (mScalers) {
147+
for (size_t i{0}; i < mTOIs.size(); ++i) {
148+
int bin = findBin(mScalers, mTOIs[i]);
149+
ZorroHisto->Fill(Form("%d", runNumber), Form("%s scalers", mTOIs[i].data()), mScalers->GetBinContent(bin));
150+
ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, i + 2 + mTOIs.size(), mScalers->GetBinError(bin));
151+
}
152+
}
153+
154+
mRunNumberHistos.push_back(runNumber);
155+
}
156+
95157
std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, std::string tois, int bcRange)
96158
{
97159
if (mRunNumber == runNumber) {
@@ -177,7 +239,7 @@ std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance)
177239
return mLastResult;
178240
}
179241

180-
bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance)
242+
bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance, TH2* ToiHisto)
181243
{
182244
uint64_t lastSelectedIdx = mLastSelectedIdx;
183245
fetch(bcGlobalId, tolerance);
@@ -191,6 +253,9 @@ bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance)
191253
mAnalysedTriggersOfInterest->Fill(i);
192254
mZorroSummary.increaseTOIcounter(mRunNumber, i);
193255
}
256+
if (ToiHisto && lastSelectedIdx != mLastSelectedIdx) {
257+
ToiHisto->Fill(Form("%d", mRunNumber), Form("%s", mTOIs[i].data()), 1);
258+
}
194259
retVal = true;
195260
}
196261
}

EventFiltering/Zorro.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <vector>
2222

2323
#include "TH1D.h"
24+
#include "TH2D.h"
2425
#include "CommonDataFormat/IRFrame.h"
2526
#include "Framework/HistogramRegistry.h"
2627
#include "ZorroHelper.h"
@@ -40,10 +41,11 @@ class Zorro
4041
Zorro() = default;
4142
std::vector<int> initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, std::string tois, int bcTolerance = 500);
4243
std::bitset<128> fetch(uint64_t bcGlobalId, uint64_t tolerance = 100);
43-
bool isSelected(uint64_t bcGlobalId, uint64_t tolerance = 100);
44+
bool isSelected(uint64_t bcGlobalId, uint64_t tolerance = 100, TH2* toiHisto = nullptr);
4445
bool isNotSelectedByAny(uint64_t bcGlobalId, uint64_t tolerance = 100);
4546

4647
void populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, int runNumber, std::string folderName = "Zorro");
48+
void populateExternalHists(int runNumber, TH2* zorroHisto = nullptr, TH2* toiHisto = nullptr);
4749

4850
TH1D* getScalers() const { return mScalers; }
4951
TH1D* getSelections() const { return mSelections; }

PWGDQ/TableProducer/tableMaker.cxx

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#include "DetectorsBase/Propagator.h"
5757
#include "DetectorsBase/GeometryManager.h"
5858
#include "EventFiltering/Zorro.h"
59-
#include "Framework/HistogramRegistry.h"
6059

6160
using std::cout;
6261
using std::endl;
@@ -182,12 +181,13 @@ struct TableMaker {
182181
struct : ConfigurableGroup {
183182
Configurable<bool> fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"};
184183
Configurable<string> fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"};
184+
Configurable<bool> fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"};
185185
} useZorro;
186186

187187
struct : ConfigurableGroup {
188188
Configurable<string> fConfigCcdbUrl{"useCCDBConfigurations.ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
189189
Configurable<string> fConfigCcdbPathTPC{"useCCDBConfigurations.ccdb-path-tpc", "Users/z/zhxiong/TPCPID/PostCalib", "base path to the ccdb object"};
190-
Configurable<string> fConfigCcdbPathZorro{"useCCDBConfigurations.ccdb-path-zorro", "Users/r/rlietava/EventFiltering/OTS/", "base path to the ccdb object for zorro"};
190+
Configurable<string> fConfigCcdbPathZorro{"useCCDBConfigurations.ccdb-path-zorro", "/Users/m/mpuccio/EventFiltering/OTS/", "base path to the ccdb object for zorro"};
191191
} useCCDBConfigurations;
192192

193193
Configurable<int64_t> fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"};
@@ -223,8 +223,6 @@ struct TableMaker {
223223
bool fDoDetailedQA = false; // Bool to set detailed QA true, if QA is set true
224224
int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc.
225225

226-
HistogramRegistry registry{"registry"};
227-
228226
// TODO: filter on TPC dedx used temporarily until electron PID will be improved
229227
Filter barrelSelectedTracks = ifnode(fIsRun2.node() == true, aod::track::trackType == uint8_t(aod::track::Run2Track), aod::track::trackType == uint8_t(aod::track::Track)) && o2::aod::track::pt >= fConfigBarrelTrackPtLow && nabs(o2::aod::track::eta) <= fConfigBarrelTrackMaxAbsEta && o2::aod::track::tpcSignal >= fConfigMinTpcSignal && o2::aod::track::tpcSignal <= fConfigMaxTpcSignal && o2::aod::track::tpcChi2NCl < 4.0f && o2::aod::track::itsChi2NCl < 36.0f;
230228

@@ -448,12 +446,14 @@ struct TableMaker {
448446
if (useZorro.fConfigRunZorro) {
449447
zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value);
450448
zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), useZorro.fConfigZorroTrigMask.value);
451-
452-
zorro.populateHistRegistry(registry, fCurrentRun);
453-
454-
if (zorro.isSelected(bc.globalBC())) {
449+
zorro.populateExternalHists(fCurrentRun, reinterpret_cast<TH2D*>(fStatsList->At(3)), reinterpret_cast<TH2D*>(fStatsList->At(4)));
450+
bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast<TH2D*>(fStatsList->At(4)));
451+
if (zorroSel) {
455452
tag |= (static_cast<uint64_t>(true) << 56); // the same bit is used for this zorro selections from ccdb
456453
}
454+
if (useZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) {
455+
return;
456+
}
457457
} else {
458458
if (!fEventCut->IsSelected(VarManager::fgValues)) {
459459
return;
@@ -826,7 +826,7 @@ struct TableMaker {
826826
}
827827
}
828828
} // end if constexpr (TMuonFillMap)
829-
} // end fullSkimming()
829+
} // end fullSkimming()
830830

831831
// Templated function instantianed for all of the process functions
832832
template <uint32_t TEventFillMap, uint32_t TTrackFillMap, uint32_t TMuonFillMap, typename TEvent, typename TTracks, typename TMuons, typename AssocTracks, typename AssocMuons>
@@ -909,12 +909,14 @@ struct TableMaker {
909909
if (useZorro.fConfigRunZorro) {
910910
zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value);
911911
zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), useZorro.fConfigZorroTrigMask.value);
912-
913-
zorro.populateHistRegistry(registry, fCurrentRun);
914-
915-
if (zorro.isSelected(bc.globalBC())) {
912+
zorro.populateExternalHists(fCurrentRun, reinterpret_cast<TH2D*>(fStatsList->At(3)), reinterpret_cast<TH2D*>(fStatsList->At(4)));
913+
bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast<TH2D*>(fStatsList->At(4)));
914+
if (zorroSel) {
916915
tag |= (static_cast<uint64_t>(true) << 56); // the same bit is used for this zorro selections from ccdb
917916
}
917+
if (useZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) {
918+
return;
919+
}
918920
} else {
919921
if (!fEventCut->IsSelected(VarManager::fgValues)) {
920922
return;
@@ -1187,22 +1189,22 @@ struct TableMaker {
11871189
muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(),
11881190
muon.midBoards(), muon.trackType(), VarManager::fgValues[VarManager::kMuonDCAx], VarManager::fgValues[VarManager::kMuonDCAy],
11891191
muon.trackTime(), muon.trackTimeRes());
1190-
} else {
1191-
muonExtra(muon.nClusters(), muon.pDca(), muon.rAtAbsorberEnd(),
1192-
muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(),
1193-
muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(),
1194-
muon.midBoards(), muon.trackType(), muon.fwdDcaX(), muon.fwdDcaY(),
1195-
muon.trackTime(), muon.trackTimeRes());
1196-
}
1192+
} else {
1193+
muonExtra(muon.nClusters(), muon.pDca(), muon.rAtAbsorberEnd(),
1194+
muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(),
1195+
muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(),
1196+
muon.midBoards(), muon.trackType(), muon.fwdDcaX(), muon.fwdDcaY(),
1197+
muon.trackTime(), muon.trackTimeRes());
1198+
}
11971199

1198-
muonCov(VarManager::fgValues[VarManager::kX], VarManager::fgValues[VarManager::kY], VarManager::fgValues[VarManager::kZ], VarManager::fgValues[VarManager::kPhi], VarManager::fgValues[VarManager::kTgl], muon.sign() / VarManager::fgValues[VarManager::kPt],
1199-
VarManager::fgValues[VarManager::kMuonCXX], VarManager::fgValues[VarManager::kMuonCXY], VarManager::fgValues[VarManager::kMuonCYY], VarManager::fgValues[VarManager::kMuonCPhiX], VarManager::fgValues[VarManager::kMuonCPhiY], VarManager::fgValues[VarManager::kMuonCPhiPhi],
1200-
VarManager::fgValues[VarManager::kMuonCTglX], VarManager::fgValues[VarManager::kMuonCTglY], VarManager::fgValues[VarManager::kMuonCTglPhi], VarManager::fgValues[VarManager::kMuonCTglTgl], VarManager::fgValues[VarManager::kMuonC1Pt2X], VarManager::fgValues[VarManager::kMuonC1Pt2Y],
1201-
VarManager::fgValues[VarManager::kMuonC1Pt2Phi], VarManager::fgValues[VarManager::kMuonC1Pt2Tgl], VarManager::fgValues[VarManager::kMuonC1Pt21Pt2]);
1200+
muonCov(VarManager::fgValues[VarManager::kX], VarManager::fgValues[VarManager::kY], VarManager::fgValues[VarManager::kZ], VarManager::fgValues[VarManager::kPhi], VarManager::fgValues[VarManager::kTgl], muon.sign() / VarManager::fgValues[VarManager::kPt],
1201+
VarManager::fgValues[VarManager::kMuonCXX], VarManager::fgValues[VarManager::kMuonCXY], VarManager::fgValues[VarManager::kMuonCYY], VarManager::fgValues[VarManager::kMuonCPhiX], VarManager::fgValues[VarManager::kMuonCPhiY], VarManager::fgValues[VarManager::kMuonCPhiPhi],
1202+
VarManager::fgValues[VarManager::kMuonCTglX], VarManager::fgValues[VarManager::kMuonCTglY], VarManager::fgValues[VarManager::kMuonCTglPhi], VarManager::fgValues[VarManager::kMuonCTglTgl], VarManager::fgValues[VarManager::kMuonC1Pt2X], VarManager::fgValues[VarManager::kMuonC1Pt2Y],
1203+
VarManager::fgValues[VarManager::kMuonC1Pt2Phi], VarManager::fgValues[VarManager::kMuonC1Pt2Tgl], VarManager::fgValues[VarManager::kMuonC1Pt21Pt2]);
12021204
}
12031205
}
12041206
} // end if constexpr (TMuonFillMap)
1205-
} // end fullSkimming()
1207+
} // end fullSkimming()
12061208

12071209
void DefineHistograms(TString histClasses)
12081210
{
@@ -1287,6 +1289,13 @@ struct TableMaker {
12871289
histMuons->GetXaxis()->SetBinLabel(ib, (*cut).GetName());
12881290
}
12891291
fStatsList->Add(histMuons);
1292+
1293+
if (useZorro.fConfigRunZorro) {
1294+
TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5);
1295+
fStatsList->Add(histZorroInfo);
1296+
TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5);
1297+
fStatsList->Add(histZorroSel);
1298+
}
12901299
}
12911300

12921301
// Produce barrel + muon tables -------------------------------------------------------------------------------------------------------------

PWGDQ/TableProducer/tableMaker_withAssoc.cxx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ struct TableMaker {
164164
Configurable<std::string> fConfigTrackCuts{"cfgBarrelTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"};
165165
Configurable<std::string> fConfigMuonCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"};
166166
Configurable<bool> fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"};
167-
Configurable<string> fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"};
167+
Configurable<std::string> fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"};
168+
Configurable<bool> fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"};
168169

169170
// Steer QA output
170171
Configurable<bool> fConfigQA{"cfgQA", false, "If true, fill QA histograms"};
@@ -187,7 +188,7 @@ struct TableMaker {
187188
// CCDB connection configurables
188189
Configurable<string> fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
189190
Configurable<string> fConfigCcdbPathTPC{"ccdb-path-tpc", "Users/z/zhxiong/TPCPID/PostCalib", "base path to the ccdb object"};
190-
Configurable<string> fConfigCcdbPathZorro{"ccdb-path-zorro", "Users/r/rlietava/EventFiltering/OTS/", "base path to the ccdb object for zorro"};
191+
Configurable<string> fConfigCcdbPathZorro{"ccdb-path-zorro", "/Users/m/mpuccio/EventFiltering/OTS/", "base path to the ccdb object for zorro"};
191192
Configurable<int64_t> fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"};
192193
Configurable<std::string> geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
193194
Configurable<std::string> grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
@@ -438,6 +439,13 @@ struct TableMaker {
438439
histMuons->GetXaxis()->SetBinLabel(ib, (*cut).GetName());
439440
}
440441
fStatsList->Add(histMuons);
442+
443+
if (fConfigRunZorro) {
444+
TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5);
445+
fStatsList->Add(histZorroInfo);
446+
TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5);
447+
fStatsList->Add(histZorroSel);
448+
}
441449
}
442450

443451
template <uint32_t TEventFillMap, uint32_t TTrackFillMap, typename TEvents, typename TBCs, typename TZdcs, typename TTrackAssoc, typename TTracks>
@@ -520,9 +528,14 @@ struct TableMaker {
520528
if (fConfigRunZorro) {
521529
zorro.setBaseCCDBPath(fConfigCcdbPathZorro.value);
522530
zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), fConfigZorroTrigMask.value);
523-
if (zorro.isSelected(bc.globalBC())) {
531+
zorro.populateExternalHists(fCurrentRun, reinterpret_cast<TH2D*>(fStatsList->At(3)), reinterpret_cast<TH2D*>(fStatsList->At(4)));
532+
bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast<TH2D*>(fStatsList->At(4)));
533+
if (zorroSel) {
524534
tag |= (static_cast<uint64_t>(true) << 56); // the same bit is used for this zorro selections from ccdb
525535
}
536+
if (fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) {
537+
continue;
538+
}
526539
} else {
527540
if (!fEventCut->IsSelected(VarManager::fgValues)) {
528541
continue;
@@ -709,7 +722,7 @@ struct TableMaker {
709722
// write the skimmed collision - track association
710723
trackBarrelAssoc(fCollIndexMap[collision.globalIndex()], fTrackIndexMap[track.globalIndex()]);
711724
} // end loop over associations
712-
} // end skimTracks
725+
} // end skimTracks
713726

714727
template <uint32_t TMFTFillMap, typename TEvent, typename TBCs>
715728
void skimMFT(TEvent const& collision, TBCs const& /*bcs*/, MFTTracks const& /*mfts*/, MFTTrackAssoc const& mftAssocs)
@@ -865,7 +878,7 @@ struct TableMaker {
865878
VarManager::fgValues[VarManager::kMuonC1Pt2Phi], VarManager::fgValues[VarManager::kMuonC1Pt2Tgl], VarManager::fgValues[VarManager::kMuonC1Pt21Pt2]);
866879
}
867880
} // end loop over selected muons
868-
} // end skimMuons
881+
} // end skimMuons
869882

870883
// Produce standard barrel + muon tables with event filter (typically for pp and p-Pb) ------------------------------------------------------
871884
template <uint32_t TEventFillMap, uint32_t TTrackFillMap, uint32_t TMuonFillMap, uint32_t TMFTFillMap,

0 commit comments

Comments
 (0)