From 2dc8d4370c636e313870466d6b4e4749fe66a8f3 Mon Sep 17 00:00:00 2001 From: zjxiongOvO Date: Tue, 22 Oct 2024 21:34:32 +0800 Subject: [PATCH 1/4] update Zorro --- EventFiltering/Zorro.cxx | 65 ++++++++++++++++++++ EventFiltering/Zorro.h | 6 ++ PWGDQ/TableProducer/tableMaker.cxx | 52 +++++++++------- PWGDQ/TableProducer/tableMaker_withAssoc.cxx | 22 +++++-- PWGDQ/Tasks/tableReader.cxx | 34 +++++----- PWGDQ/Tasks/tableReader_withAssoc.cxx | 42 ++++++++----- 6 files changed, 160 insertions(+), 61 deletions(-) diff --git a/EventFiltering/Zorro.cxx b/EventFiltering/Zorro.cxx index 4bf755ced3c..0d26ca4883d 100644 --- a/EventFiltering/Zorro.cxx +++ b/EventFiltering/Zorro.cxx @@ -92,6 +92,68 @@ void Zorro::populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, mRunNumberHistos.push_back(runNumber); } +void Zorro::populateHist(int runNumber) +{ + // x-axis is run number, y-axis is same as ZorroSummary + int runId{-1}; + for (size_t i{0}; i < mRunNumberHistos.size(); ++i) { + if (mRunNumberHistos[i] == runNumber) { + runId = i; + break; + } + } + if (runId > -1) { + return; + } + // if the summary histogram is not set, create a new one + if (!mZorroHisto) { + LOGF(info, "Summary histogram not set, creating a new one"); + mZorroHisto = new TH2D("Zorro", "Zorro", 1, -0.5, 0.5, 1 + mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); + mZorroHisto->SetBit(TH1::kIsAverage); + } + if (!mToiHisto) { + LOGF(info, "TOI histogram not set, creating a new one"); + mToiHisto = new TH2D("TOI", "TOI", 1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5); + } + // if it is the first run, initialize the histogram + if (mRunNumberHistos.size() == 0) { + mZorroHisto->SetBins(1, -0.5, 0.5, 1 + mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); + mZorroHisto->SetBit(TH1::kIsAverage); + mZorroHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); + mZorroHisto->GetYaxis()->SetBinLabel(1, "inspected TVX"); + for (size_t i{0}; i < mTOIs.size(); ++i) { + mZorroHisto->GetYaxis()->SetBinLabel(i + 2, Form("%s selections", mTOIs[i].data())); + mZorroHisto->GetYaxis()->SetBinLabel(i + 2 + mTOIs.size(), Form("%s scalers", mTOIs[i].data())); + } + // TOI histogram + mToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5); + mToiHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); + for (size_t i{0}; i < mTOIs.size(); ++i) { + mToiHisto->GetYaxis()->SetBinLabel(i + 1, mTOIs[i].data()); + } + } + if (mInspectedTVX) { + mZorroHisto->Fill(Form("%d", runNumber), "inspected TVX", mInspectedTVX->GetBinContent(1)); + mZorroHisto->SetBinError(mRunNumberHistos.size() + 1, 1, mInspectedTVX->GetBinError(1)); + } + if (mSelections) { + for (size_t i{0}; i < mTOIs.size(); ++i) { + int bin = findBin(mSelections, mTOIs[i]); + mZorroHisto->Fill(Form("%d", runNumber), Form("%s selections", mTOIs[i].data()), mSelections->GetBinContent(bin)); + mZorroHisto->SetBinError(mRunNumberHistos.size() + 1, i + 2, mSelections->GetBinError(bin)); + } + } + if (mScalers) { + for (size_t i{0}; i < mTOIs.size(); ++i) { + int bin = findBin(mScalers, mTOIs[i]); + mZorroHisto->Fill(Form("%d", runNumber), Form("%s scalers", mTOIs[i].data()), mScalers->GetBinContent(bin)); + mZorroHisto->SetBinError(mRunNumberHistos.size() + 1, i + 2 + mTOIs.size(), mScalers->GetBinError(bin)); + } + } + + mRunNumberHistos.push_back(runNumber); +} + std::vector Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, std::string tois, int bcRange) { if (mRunNumber == runNumber) { @@ -191,6 +253,9 @@ bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance) mAnalysedTriggersOfInterest->Fill(i); mZorroSummary.increaseTOIcounter(mRunNumber, i); } + if (mToiHisto && lastSelectedIdx != mLastSelectedIdx) { + mToiHisto->Fill(Form("%d", mRunNumber), Form("%s", mTOIs[i].data()), 1); + } retVal = true; } } diff --git a/EventFiltering/Zorro.h b/EventFiltering/Zorro.h index f965db47ae2..55b96cefe7b 100644 --- a/EventFiltering/Zorro.h +++ b/EventFiltering/Zorro.h @@ -21,6 +21,7 @@ #include #include "TH1D.h" +#include "TH2D.h" #include "CommonDataFormat/IRFrame.h" #include "Framework/HistogramRegistry.h" #include "ZorroHelper.h" @@ -44,6 +45,11 @@ class Zorro bool isNotSelectedByAny(uint64_t bcGlobalId, uint64_t tolerance = 100); void populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, int runNumber, std::string folderName = "Zorro"); + TH2* mZorroHisto = nullptr; + TH2* mToiHisto = nullptr; + void populateHist(int runNumber); + void setZorroHisto(TH2* histo) { mZorroHisto = histo; } + void setToiHisto(TH2* histo) { mToiHisto = histo; } TH1D* getScalers() const { return mScalers; } TH1D* getSelections() const { return mSelections; } diff --git a/PWGDQ/TableProducer/tableMaker.cxx b/PWGDQ/TableProducer/tableMaker.cxx index 6eb031eb38e..cbf93ae8182 100644 --- a/PWGDQ/TableProducer/tableMaker.cxx +++ b/PWGDQ/TableProducer/tableMaker.cxx @@ -56,7 +56,6 @@ #include "DetectorsBase/Propagator.h" #include "DetectorsBase/GeometryManager.h" #include "EventFiltering/Zorro.h" -#include "Framework/HistogramRegistry.h" using std::cout; using std::endl; @@ -182,12 +181,13 @@ struct TableMaker { struct : ConfigurableGroup { Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; Configurable fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"}; + Configurable fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"}; } useZorro; struct : ConfigurableGroup { Configurable fConfigCcdbUrl{"useCCDBConfigurations.ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable fConfigCcdbPathTPC{"useCCDBConfigurations.ccdb-path-tpc", "Users/z/zhxiong/TPCPID/PostCalib", "base path to the ccdb object"}; - Configurable fConfigCcdbPathZorro{"useCCDBConfigurations.ccdb-path-zorro", "Users/r/rlietava/EventFiltering/OTS/", "base path to the ccdb object for zorro"}; + Configurable fConfigCcdbPathZorro{"useCCDBConfigurations.ccdb-path-zorro", "/Users/m/mpuccio/EventFiltering/OTS/", "base path to the ccdb object for zorro"}; } useCCDBConfigurations; Configurable fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; @@ -223,8 +223,6 @@ struct TableMaker { bool fDoDetailedQA = false; // Bool to set detailed QA true, if QA is set true int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. - HistogramRegistry registry{"registry"}; - // TODO: filter on TPC dedx used temporarily until electron PID will be improved 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; @@ -448,12 +446,13 @@ struct TableMaker { if (useZorro.fConfigRunZorro) { zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value); zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), useZorro.fConfigZorroTrigMask.value); - - zorro.populateHistRegistry(registry, fCurrentRun); - + zorro.populateHist(fCurrentRun); if (zorro.isSelected(bc.globalBC())) { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } + if (useZorro.fConfigRunZorroSel && (!zorro.isSelected(bc.globalBC()) || !fEventCut->IsSelected(VarManager::fgValues))) { + return; + } } else { if (!fEventCut->IsSelected(VarManager::fgValues)) { return; @@ -826,7 +825,7 @@ struct TableMaker { } } } // end if constexpr (TMuonFillMap) - } // end fullSkimming() + } // end fullSkimming() // Templated function instantianed for all of the process functions template @@ -909,9 +908,7 @@ struct TableMaker { if (useZorro.fConfigRunZorro) { zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value); zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), useZorro.fConfigZorroTrigMask.value); - - zorro.populateHistRegistry(registry, fCurrentRun); - + zorro.populateHist(fCurrentRun); if (zorro.isSelected(bc.globalBC())) { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } @@ -1187,22 +1184,22 @@ struct TableMaker { muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(), muon.midBoards(), muon.trackType(), VarManager::fgValues[VarManager::kMuonDCAx], VarManager::fgValues[VarManager::kMuonDCAy], muon.trackTime(), muon.trackTimeRes()); - } else { - muonExtra(muon.nClusters(), muon.pDca(), muon.rAtAbsorberEnd(), - muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), - muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(), - muon.midBoards(), muon.trackType(), muon.fwdDcaX(), muon.fwdDcaY(), - muon.trackTime(), muon.trackTimeRes()); - } + } else { + muonExtra(muon.nClusters(), muon.pDca(), muon.rAtAbsorberEnd(), + muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), + muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(), + muon.midBoards(), muon.trackType(), muon.fwdDcaX(), muon.fwdDcaY(), + muon.trackTime(), muon.trackTimeRes()); + } - 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], - VarManager::fgValues[VarManager::kMuonCXX], VarManager::fgValues[VarManager::kMuonCXY], VarManager::fgValues[VarManager::kMuonCYY], VarManager::fgValues[VarManager::kMuonCPhiX], VarManager::fgValues[VarManager::kMuonCPhiY], VarManager::fgValues[VarManager::kMuonCPhiPhi], - VarManager::fgValues[VarManager::kMuonCTglX], VarManager::fgValues[VarManager::kMuonCTglY], VarManager::fgValues[VarManager::kMuonCTglPhi], VarManager::fgValues[VarManager::kMuonCTglTgl], VarManager::fgValues[VarManager::kMuonC1Pt2X], VarManager::fgValues[VarManager::kMuonC1Pt2Y], - VarManager::fgValues[VarManager::kMuonC1Pt2Phi], VarManager::fgValues[VarManager::kMuonC1Pt2Tgl], VarManager::fgValues[VarManager::kMuonC1Pt21Pt2]); + 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], + VarManager::fgValues[VarManager::kMuonCXX], VarManager::fgValues[VarManager::kMuonCXY], VarManager::fgValues[VarManager::kMuonCYY], VarManager::fgValues[VarManager::kMuonCPhiX], VarManager::fgValues[VarManager::kMuonCPhiY], VarManager::fgValues[VarManager::kMuonCPhiPhi], + VarManager::fgValues[VarManager::kMuonCTglX], VarManager::fgValues[VarManager::kMuonCTglY], VarManager::fgValues[VarManager::kMuonCTglPhi], VarManager::fgValues[VarManager::kMuonCTglTgl], VarManager::fgValues[VarManager::kMuonC1Pt2X], VarManager::fgValues[VarManager::kMuonC1Pt2Y], + VarManager::fgValues[VarManager::kMuonC1Pt2Phi], VarManager::fgValues[VarManager::kMuonC1Pt2Tgl], VarManager::fgValues[VarManager::kMuonC1Pt21Pt2]); } } } // end if constexpr (TMuonFillMap) - } // end fullSkimming() + } // end fullSkimming() void DefineHistograms(TString histClasses) { @@ -1287,6 +1284,15 @@ struct TableMaker { histMuons->GetXaxis()->SetBinLabel(ib, (*cut).GetName()); } fStatsList->Add(histMuons); + + if (fConfigRunZorro) { + TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5); + zorro.setZorroHisto(histZorroInfo); + fStatsList->Add(histZorroInfo); + TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5); + zorro.setToiHisto(histZorroSel); + fStatsList->Add(histZorroSel); + } } // Produce barrel + muon tables ------------------------------------------------------------------------------------------------------------- diff --git a/PWGDQ/TableProducer/tableMaker_withAssoc.cxx b/PWGDQ/TableProducer/tableMaker_withAssoc.cxx index f7df4a672bc..bb05db0e282 100644 --- a/PWGDQ/TableProducer/tableMaker_withAssoc.cxx +++ b/PWGDQ/TableProducer/tableMaker_withAssoc.cxx @@ -164,7 +164,8 @@ struct TableMaker { Configurable fConfigTrackCuts{"cfgBarrelTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; Configurable fConfigMuonCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"}; Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; - Configurable fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"}; + Configurable fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"}; + Configurable fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"}; // Steer QA output Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; @@ -187,7 +188,7 @@ struct TableMaker { // CCDB connection configurables Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable fConfigCcdbPathTPC{"ccdb-path-tpc", "Users/z/zhxiong/TPCPID/PostCalib", "base path to the ccdb object"}; - Configurable fConfigCcdbPathZorro{"ccdb-path-zorro", "Users/r/rlietava/EventFiltering/OTS/", "base path to the ccdb object for zorro"}; + Configurable fConfigCcdbPathZorro{"ccdb-path-zorro", "/Users/m/mpuccio/EventFiltering/OTS/", "base path to the ccdb object for zorro"}; Configurable fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; @@ -438,6 +439,15 @@ struct TableMaker { histMuons->GetXaxis()->SetBinLabel(ib, (*cut).GetName()); } fStatsList->Add(histMuons); + + if (fConfigRunZorro) { + TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5); + zorro.setZorroHisto(histZorroInfo); + fStatsList->Add(histZorroInfo); + TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5); + zorro.setToiHisto(histZorroSel); + fStatsList->Add(histZorroSel); + } } template @@ -520,9 +530,13 @@ struct TableMaker { if (fConfigRunZorro) { zorro.setBaseCCDBPath(fConfigCcdbPathZorro.value); zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), fConfigZorroTrigMask.value); + zorro.populateHist(fCurrentRun); if (zorro.isSelected(bc.globalBC())) { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } + if (fConfigRunZorroSel && (!zorro.isSelected(bc.globalBC()) || !fEventCut->IsSelected(VarManager::fgValues))) { + continue; + } } else { if (!fEventCut->IsSelected(VarManager::fgValues)) { continue; @@ -709,7 +723,7 @@ struct TableMaker { // write the skimmed collision - track association trackBarrelAssoc(fCollIndexMap[collision.globalIndex()], fTrackIndexMap[track.globalIndex()]); } // end loop over associations - } // end skimTracks + } // end skimTracks template void skimMFT(TEvent const& collision, TBCs const& /*bcs*/, MFTTracks const& /*mfts*/, MFTTrackAssoc const& mftAssocs) @@ -865,7 +879,7 @@ struct TableMaker { VarManager::fgValues[VarManager::kMuonC1Pt2Phi], VarManager::fgValues[VarManager::kMuonC1Pt2Tgl], VarManager::fgValues[VarManager::kMuonC1Pt21Pt2]); } } // end loop over selected muons - } // end skimMuons + } // end skimMuons // Produce standard barrel + muon tables with event filter (typically for pp and p-Pb) ------------------------------------------------------ template ("processDecayToMuMuSkimmed") || context.mOptions.get("processDecayToMuMuVertexingSkimmed") || context.mOptions.get("processDecayToMuMuSkimmedWithColl") || context.mOptions.get("processVnDecayToMuMuSkimmed") || context.mOptions.get("processVnDecayToMuMuSkimmedWithWeights") || context.mOptions.get("processVnDecayToMuMuSkimmedWithWeightsAndColl") || context.mOptions.get("processVnCentrDecayToMuMuSkimmed") || context.mOptions.get("processAllSkimmed")) { @@ -1098,9 +1098,9 @@ struct AnalysisSameEventPairing { histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fMuonHistNames.push_back(names); } // end loop (pair cuts) - } // end if (pair cuts) - } // end loop (track cuts) - } // end if (track cuts) + } // end if (pair cuts) + } // end loop (track cuts) + } // end if (track cuts) } if (context.mOptions.get("processElectronMuonSkimmed") || context.mOptions.get("processAllSkimmed")) { TString cutNamesBarrel = fConfigTrackCuts.value; @@ -1131,10 +1131,10 @@ struct AnalysisSameEventPairing { histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fTrackMuonHistNames.push_back(names); } // end loop (pair cuts) - } // end if (pair cuts) - } // end loop (track cuts) - } // end if (equal number of cuts) - } // end if (track cuts) + } // end if (pair cuts) + } // end loop (track cuts) + } // end if (equal number of cuts) + } // end if (track cuts) } // Usage example of ccdb @@ -1399,12 +1399,12 @@ struct AnalysisSameEventPairing { } } } - } // end loop (pair cuts) + } // end loop (pair cuts) } else { // end if (filter bits) iCut = iCut + 1 + fPairCuts.size(); } } // end loop (cuts) - } // end loop over pairs + } // end loop over pairs } void processDecayToEESkimmed(soa::Filtered::iterator const& event, soa::Filtered const& tracks) @@ -1852,7 +1852,7 @@ struct AnalysisDileptonHadron { fHistMan->FillHistClass("DileptonHadronInvMassME", VarManager::fgValues); fHistMan->FillHistClass("DileptonHadronCorrelationME", VarManager::fgValues); } // end for (track) - } // end for (dilepton) + } // end for (dilepton) } // end event loop } @@ -2029,7 +2029,7 @@ struct AnalysisDileptonTrackTrack { } } } // check if the Ditrack cut is selected - } // loop over hadron cuts + } // loop over hadron cuts } } } diff --git a/PWGDQ/Tasks/tableReader_withAssoc.cxx b/PWGDQ/Tasks/tableReader_withAssoc.cxx index ac44ffd4657..91d09ed80c6 100644 --- a/PWGDQ/Tasks/tableReader_withAssoc.cxx +++ b/PWGDQ/Tasks/tableReader_withAssoc.cxx @@ -165,6 +165,7 @@ struct AnalysisEventSelection { Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; Configurable fConfigITSROFrameStartBorderMargin{"ITSROFrameStartBorderMargin", -1, "Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1"}; Configurable fConfigITSROFrameEndBorderMargin{"ITSROFrameEndBorderMargin", -1, "Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1"}; + Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; @@ -248,8 +249,15 @@ struct AnalysisEventSelection { bool decision = false; fHistMan->FillHistClass("Event_BeforeCuts", VarManager::fgValues); // automatically fill all the histograms in the class Event if (fEventCut->IsSelected(VarManager::fgValues)) { - fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); - decision = true; + if (fConfigRunZorro) { + if (event.tag_bit(56)) { // This is the bit used for the software trigger event selections [TO BE DONE: find a more clear way to use it] + fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); + decision = true; + } + } else { + fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); + decision = true; + } } fSelMap[event.globalIndex()] = decision; if (fBCCollMap.find(event.globalBC()) == fBCCollMap.end()) { @@ -1077,8 +1085,8 @@ struct AnalysisSameEventPairing { histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fTrackHistNames[fNCutsBarrel + icut * fNPairCuts + iPairCut] = names; } // end loop (pair cuts) - } // end if (pair cuts) - } // end if enableBarrelHistos + } // end if (pair cuts) + } // end if enableBarrelHistos } } } @@ -1128,7 +1136,7 @@ struct AnalysisSameEventPairing { histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fMuonHistNames[fNCutsMuon + icut * fNCutsMuon + iPairCut] = names; } // end loop (pair cuts) - } // end if (pair cuts) + } // end if (pair cuts) } } } @@ -1516,8 +1524,8 @@ struct AnalysisSameEventPairing { } // end loop (pair cuts) } } // end loop (cuts) - } // end loop over pairs of track associations - } // end loop over events + } // end loop over pairs of track associations + } // end loop over events } template @@ -1580,8 +1588,8 @@ struct AnalysisSameEventPairing { } } } // end for (cuts) - } // end for (track2) - } // end for (track1) + } // end for (track2) + } // end for (track1) } // barrel-barrel and muon-muon event mixing @@ -1873,7 +1881,7 @@ struct AnalysisAsymmetricPairing { fTrackHistNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut] = names; } // end loop (common cuts) } // end loop (pair cuts) - } // end if (pair cuts) + } // end if (pair cuts) } else { names = {}; std::vector pairHistPrefixes = {"PairsBarrelSEPM"}; @@ -1924,7 +1932,7 @@ struct AnalysisAsymmetricPairing { fTrackHistNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut] = names; } // end loop (common cuts) } // end loop (pair cuts) - } // end if (pair cuts) + } // end if (pair cuts) } } // Make sure the leg cuts are covered by the configured filter masks @@ -2164,8 +2172,8 @@ struct AnalysisAsymmetricPairing { if constexpr (trackHasCov && TTwoProngFitter) { ditrackExtraList(t1.globalIndex(), t2.globalIndex(), VarManager::fgValues[VarManager::kVertexingTauzProjected], VarManager::fgValues[VarManager::kVertexingLzProjected], VarManager::fgValues[VarManager::kVertexingLxyProjected]); } - } // end inner assoc loop (leg A) - } // end event loop + } // end inner assoc loop (leg A) + } // end event loop } // Template function to run same event triplets (e.g. D+->K-pi+pi+) @@ -2774,8 +2782,8 @@ struct AnalysisDileptonTrack { } } } // end for (dileptons) - } // end for (assocs) - } // end event loop + } // end for (assocs) + } // end event loop } void processMuonMixedEvent(soa::Filtered& events, @@ -2813,8 +2821,8 @@ struct AnalysisDileptonTrack { } } } // end for (dileptons) - } // end for (assocs) - } // end event loop + } // end for (assocs) + } // end event loop } void processDummy(MyEvents&) From 91e9e9867da905c68222586895914654df803fbc Mon Sep 17 00:00:00 2001 From: Zhenjun Xiong <108917659+zjxiongOvO@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:14:21 +0800 Subject: [PATCH 2/4] fix config name --- PWGDQ/TableProducer/tableMaker.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGDQ/TableProducer/tableMaker.cxx b/PWGDQ/TableProducer/tableMaker.cxx index cbf93ae8182..302887811a1 100644 --- a/PWGDQ/TableProducer/tableMaker.cxx +++ b/PWGDQ/TableProducer/tableMaker.cxx @@ -1285,7 +1285,7 @@ struct TableMaker { } fStatsList->Add(histMuons); - if (fConfigRunZorro) { + if (useZorro.fConfigRunZorro) { TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5); zorro.setZorroHisto(histZorroInfo); fStatsList->Add(histZorroInfo); From c9c655534bd042a1abf24f566f5e47dcd1a4c17a Mon Sep 17 00:00:00 2001 From: zjxiongOvO Date: Mon, 28 Oct 2024 12:31:34 +0800 Subject: [PATCH 3/4] rename and remove member function --- EventFiltering/Zorro.cxx | 48 ++++++++++---------- EventFiltering/Zorro.h | 8 +--- PWGDQ/TableProducer/tableMaker.cxx | 19 ++++---- PWGDQ/TableProducer/tableMaker_withAssoc.cxx | 9 ++-- 4 files changed, 41 insertions(+), 43 deletions(-) diff --git a/EventFiltering/Zorro.cxx b/EventFiltering/Zorro.cxx index 0d26ca4883d..9279241006c 100644 --- a/EventFiltering/Zorro.cxx +++ b/EventFiltering/Zorro.cxx @@ -92,7 +92,7 @@ void Zorro::populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, mRunNumberHistos.push_back(runNumber); } -void Zorro::populateHist(int runNumber) +void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto) { // x-axis is run number, y-axis is same as ZorroSummary int runId{-1}; @@ -106,48 +106,48 @@ void Zorro::populateHist(int runNumber) return; } // if the summary histogram is not set, create a new one - if (!mZorroHisto) { + if (!ZorroHisto) { LOGF(info, "Summary histogram not set, creating a new one"); - mZorroHisto = new TH2D("Zorro", "Zorro", 1, -0.5, 0.5, 1 + mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); - mZorroHisto->SetBit(TH1::kIsAverage); + ZorroHisto = new TH2D("Zorro", "Zorro", 1, -0.5, 0.5, 1 + mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); + ZorroHisto->SetBit(TH1::kIsAverage); } - if (!mToiHisto) { + if (!ToiHisto) { LOGF(info, "TOI histogram not set, creating a new one"); - mToiHisto = new TH2D("TOI", "TOI", 1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5); + ToiHisto = new TH2D("TOI", "TOI", 1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5); } // if it is the first run, initialize the histogram if (mRunNumberHistos.size() == 0) { - mZorroHisto->SetBins(1, -0.5, 0.5, 1 + mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); - mZorroHisto->SetBit(TH1::kIsAverage); - mZorroHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); - mZorroHisto->GetYaxis()->SetBinLabel(1, "inspected TVX"); + ZorroHisto->SetBins(1, -0.5, 0.5, 1 + mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); + ZorroHisto->SetBit(TH1::kIsAverage); + ZorroHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); + ZorroHisto->GetYaxis()->SetBinLabel(1, "inspected TVX"); for (size_t i{0}; i < mTOIs.size(); ++i) { - mZorroHisto->GetYaxis()->SetBinLabel(i + 2, Form("%s selections", mTOIs[i].data())); - mZorroHisto->GetYaxis()->SetBinLabel(i + 2 + mTOIs.size(), Form("%s scalers", mTOIs[i].data())); + ZorroHisto->GetYaxis()->SetBinLabel(i + 2, Form("%s selections", mTOIs[i].data())); + ZorroHisto->GetYaxis()->SetBinLabel(i + 2 + mTOIs.size(), Form("%s scalers", mTOIs[i].data())); } // TOI histogram - mToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5); - mToiHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); + ToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5); + ToiHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); for (size_t i{0}; i < mTOIs.size(); ++i) { - mToiHisto->GetYaxis()->SetBinLabel(i + 1, mTOIs[i].data()); + ToiHisto->GetYaxis()->SetBinLabel(i + 1, mTOIs[i].data()); } } if (mInspectedTVX) { - mZorroHisto->Fill(Form("%d", runNumber), "inspected TVX", mInspectedTVX->GetBinContent(1)); - mZorroHisto->SetBinError(mRunNumberHistos.size() + 1, 1, mInspectedTVX->GetBinError(1)); + ZorroHisto->Fill(Form("%d", runNumber), "inspected TVX", mInspectedTVX->GetBinContent(1)); + ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, 1, mInspectedTVX->GetBinError(1)); } if (mSelections) { for (size_t i{0}; i < mTOIs.size(); ++i) { int bin = findBin(mSelections, mTOIs[i]); - mZorroHisto->Fill(Form("%d", runNumber), Form("%s selections", mTOIs[i].data()), mSelections->GetBinContent(bin)); - mZorroHisto->SetBinError(mRunNumberHistos.size() + 1, i + 2, mSelections->GetBinError(bin)); + ZorroHisto->Fill(Form("%d", runNumber), Form("%s selections", mTOIs[i].data()), mSelections->GetBinContent(bin)); + ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, i + 2, mSelections->GetBinError(bin)); } } if (mScalers) { for (size_t i{0}; i < mTOIs.size(); ++i) { int bin = findBin(mScalers, mTOIs[i]); - mZorroHisto->Fill(Form("%d", runNumber), Form("%s scalers", mTOIs[i].data()), mScalers->GetBinContent(bin)); - mZorroHisto->SetBinError(mRunNumberHistos.size() + 1, i + 2 + mTOIs.size(), mScalers->GetBinError(bin)); + ZorroHisto->Fill(Form("%d", runNumber), Form("%s scalers", mTOIs[i].data()), mScalers->GetBinContent(bin)); + ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, i + 2 + mTOIs.size(), mScalers->GetBinError(bin)); } } @@ -239,7 +239,7 @@ std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance) return mLastResult; } -bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance) +bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance, TH2* ToiHisto) { uint64_t lastSelectedIdx = mLastSelectedIdx; fetch(bcGlobalId, tolerance); @@ -253,8 +253,8 @@ bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance) mAnalysedTriggersOfInterest->Fill(i); mZorroSummary.increaseTOIcounter(mRunNumber, i); } - if (mToiHisto && lastSelectedIdx != mLastSelectedIdx) { - mToiHisto->Fill(Form("%d", mRunNumber), Form("%s", mTOIs[i].data()), 1); + if (ToiHisto && lastSelectedIdx != mLastSelectedIdx) { + ToiHisto->Fill(Form("%d", mRunNumber), Form("%s", mTOIs[i].data()), 1); } retVal = true; } diff --git a/EventFiltering/Zorro.h b/EventFiltering/Zorro.h index 55b96cefe7b..a1b2dc0cb34 100644 --- a/EventFiltering/Zorro.h +++ b/EventFiltering/Zorro.h @@ -41,15 +41,11 @@ class Zorro Zorro() = default; std::vector initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, std::string tois, int bcTolerance = 500); std::bitset<128> fetch(uint64_t bcGlobalId, uint64_t tolerance = 100); - bool isSelected(uint64_t bcGlobalId, uint64_t tolerance = 100); + bool isSelected(uint64_t bcGlobalId, uint64_t tolerance = 100, TH2* toiHisto = nullptr); bool isNotSelectedByAny(uint64_t bcGlobalId, uint64_t tolerance = 100); void populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, int runNumber, std::string folderName = "Zorro"); - TH2* mZorroHisto = nullptr; - TH2* mToiHisto = nullptr; - void populateHist(int runNumber); - void setZorroHisto(TH2* histo) { mZorroHisto = histo; } - void setToiHisto(TH2* histo) { mToiHisto = histo; } + void populateExternalHists(int runNumber, TH2* zorroHisto = nullptr, TH2* toiHisto = nullptr); TH1D* getScalers() const { return mScalers; } TH1D* getSelections() const { return mSelections; } diff --git a/PWGDQ/TableProducer/tableMaker.cxx b/PWGDQ/TableProducer/tableMaker.cxx index 302887811a1..3c28ce7dc0b 100644 --- a/PWGDQ/TableProducer/tableMaker.cxx +++ b/PWGDQ/TableProducer/tableMaker.cxx @@ -446,12 +446,13 @@ struct TableMaker { if (useZorro.fConfigRunZorro) { zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value); zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), useZorro.fConfigZorroTrigMask.value); - zorro.populateHist(fCurrentRun); - if (zorro.isSelected(bc.globalBC())) { + zorro.populateExternalHists(fCurrentRun, reinterpret_cast(fStatsList->At(3)), reinterpret_cast(fStatsList->At(4))); + bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast(fStatsList->At(4))); + if (zorroSel) { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } - if (useZorro.fConfigRunZorroSel && (!zorro.isSelected(bc.globalBC()) || !fEventCut->IsSelected(VarManager::fgValues))) { - return; + if (useZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) { + continue; } } else { if (!fEventCut->IsSelected(VarManager::fgValues)) { @@ -908,10 +909,14 @@ struct TableMaker { if (useZorro.fConfigRunZorro) { zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value); zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), useZorro.fConfigZorroTrigMask.value); - zorro.populateHist(fCurrentRun); - if (zorro.isSelected(bc.globalBC())) { + zorro.populateExternalHists(fCurrentRun, reinterpret_cast(fStatsList->At(3)), reinterpret_cast(fStatsList->At(4))); + bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast(fStatsList->At(4))); + if (zorroSel) { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } + if (useZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) { + continue; + } } else { if (!fEventCut->IsSelected(VarManager::fgValues)) { return; @@ -1287,10 +1292,8 @@ struct TableMaker { if (useZorro.fConfigRunZorro) { TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5); - zorro.setZorroHisto(histZorroInfo); fStatsList->Add(histZorroInfo); TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5); - zorro.setToiHisto(histZorroSel); fStatsList->Add(histZorroSel); } } diff --git a/PWGDQ/TableProducer/tableMaker_withAssoc.cxx b/PWGDQ/TableProducer/tableMaker_withAssoc.cxx index bb05db0e282..75835ea9938 100644 --- a/PWGDQ/TableProducer/tableMaker_withAssoc.cxx +++ b/PWGDQ/TableProducer/tableMaker_withAssoc.cxx @@ -442,10 +442,8 @@ struct TableMaker { if (fConfigRunZorro) { TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5); - zorro.setZorroHisto(histZorroInfo); fStatsList->Add(histZorroInfo); TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5); - zorro.setToiHisto(histZorroSel); fStatsList->Add(histZorroSel); } } @@ -530,11 +528,12 @@ struct TableMaker { if (fConfigRunZorro) { zorro.setBaseCCDBPath(fConfigCcdbPathZorro.value); zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), fConfigZorroTrigMask.value); - zorro.populateHist(fCurrentRun); - if (zorro.isSelected(bc.globalBC())) { + zorro.populateExternalHists(fCurrentRun, reinterpret_cast(fStatsList->At(3)), reinterpret_cast(fStatsList->At(4))); + bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast(fStatsList->At(4))); + if (zorroSel) { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } - if (fConfigRunZorroSel && (!zorro.isSelected(bc.globalBC()) || !fEventCut->IsSelected(VarManager::fgValues))) { + if (fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) { continue; } } else { From 581f08d383b8b82bd3e3e932cc3b1decbd1b82bc Mon Sep 17 00:00:00 2001 From: zjxiongOvO Date: Mon, 28 Oct 2024 14:03:42 +0800 Subject: [PATCH 4/4] fix bug --- PWGDQ/TableProducer/tableMaker.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGDQ/TableProducer/tableMaker.cxx b/PWGDQ/TableProducer/tableMaker.cxx index 3c28ce7dc0b..07535286f07 100644 --- a/PWGDQ/TableProducer/tableMaker.cxx +++ b/PWGDQ/TableProducer/tableMaker.cxx @@ -452,7 +452,7 @@ struct TableMaker { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } if (useZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) { - continue; + return; } } else { if (!fEventCut->IsSelected(VarManager::fgValues)) { @@ -915,7 +915,7 @@ struct TableMaker { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } if (useZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) { - continue; + return; } } else { if (!fEventCut->IsSelected(VarManager::fgValues)) {