Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion EventFiltering/Zorro.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,68 @@ void Zorro::populateHistRegistry(o2::framework::HistogramRegistry& histRegistry,
mRunNumberHistos.push_back(runNumber);
}

void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto)
{
// 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 (!ZorroHisto) {
LOGF(info, "Summary histogram not set, creating a new one");
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 (!ToiHisto) {
LOGF(info, "TOI histogram not set, creating a new one");
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) {
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) {
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
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) {
ToiHisto->GetYaxis()->SetBinLabel(i + 1, mTOIs[i].data());
}
}
if (mInspectedTVX) {
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]);
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]);
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));
}
}

mRunNumberHistos.push_back(runNumber);
}

std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, std::string tois, int bcRange)
{
if (mRunNumber == runNumber) {
Expand Down Expand Up @@ -177,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);
Expand All @@ -191,6 +253,9 @@ bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance)
mAnalysedTriggersOfInterest->Fill(i);
mZorroSummary.increaseTOIcounter(mRunNumber, i);
}
if (ToiHisto && lastSelectedIdx != mLastSelectedIdx) {
ToiHisto->Fill(Form("%d", mRunNumber), Form("%s", mTOIs[i].data()), 1);
}
retVal = true;
}
}
Expand Down
4 changes: 3 additions & 1 deletion EventFiltering/Zorro.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <vector>

#include "TH1D.h"
#include "TH2D.h"
#include "CommonDataFormat/IRFrame.h"
#include "Framework/HistogramRegistry.h"
#include "ZorroHelper.h"
Expand All @@ -40,10 +41,11 @@ class Zorro
Zorro() = default;
std::vector<int> 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");
void populateExternalHists(int runNumber, TH2* zorroHisto = nullptr, TH2* toiHisto = nullptr);

TH1D* getScalers() const { return mScalers; }
TH1D* getSelections() const { return mSelections; }
Expand Down
59 changes: 34 additions & 25 deletions PWGDQ/TableProducer/tableMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -182,12 +181,13 @@ struct TableMaker {
struct : ConfigurableGroup {
Configurable<bool> fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"};
Configurable<string> fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"};
Configurable<bool> fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"};
} useZorro;

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

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"};
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -448,12 +446,14 @@ struct TableMaker {
if (useZorro.fConfigRunZorro) {
zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value);
zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), useZorro.fConfigZorroTrigMask.value);

zorro.populateHistRegistry(registry, fCurrentRun);

if (zorro.isSelected(bc.globalBC())) {
zorro.populateExternalHists(fCurrentRun, reinterpret_cast<TH2D*>(fStatsList->At(3)), reinterpret_cast<TH2D*>(fStatsList->At(4)));
bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast<TH2D*>(fStatsList->At(4)));
if (zorroSel) {
tag |= (static_cast<uint64_t>(true) << 56); // the same bit is used for this zorro selections from ccdb
}
if (useZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) {
return;
}
} else {
if (!fEventCut->IsSelected(VarManager::fgValues)) {
return;
Expand Down Expand Up @@ -826,7 +826,7 @@ struct TableMaker {
}
}
} // end if constexpr (TMuonFillMap)
} // end fullSkimming()
} // end fullSkimming()

// Templated function instantianed for all of the process functions
template <uint32_t TEventFillMap, uint32_t TTrackFillMap, uint32_t TMuonFillMap, typename TEvent, typename TTracks, typename TMuons, typename AssocTracks, typename AssocMuons>
Expand Down Expand Up @@ -909,12 +909,14 @@ struct TableMaker {
if (useZorro.fConfigRunZorro) {
zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value);
zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), useZorro.fConfigZorroTrigMask.value);

zorro.populateHistRegistry(registry, fCurrentRun);

if (zorro.isSelected(bc.globalBC())) {
zorro.populateExternalHists(fCurrentRun, reinterpret_cast<TH2D*>(fStatsList->At(3)), reinterpret_cast<TH2D*>(fStatsList->At(4)));
bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast<TH2D*>(fStatsList->At(4)));
if (zorroSel) {
tag |= (static_cast<uint64_t>(true) << 56); // the same bit is used for this zorro selections from ccdb
}
if (useZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) {
return;
}
} else {
if (!fEventCut->IsSelected(VarManager::fgValues)) {
return;
Expand Down Expand Up @@ -1187,22 +1189,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)
{
Expand Down Expand Up @@ -1287,6 +1289,13 @@ struct TableMaker {
histMuons->GetXaxis()->SetBinLabel(ib, (*cut).GetName());
}
fStatsList->Add(histMuons);

if (useZorro.fConfigRunZorro) {
TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5);
fStatsList->Add(histZorroInfo);
TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5);
fStatsList->Add(histZorroSel);
}
}

// Produce barrel + muon tables -------------------------------------------------------------------------------------------------------------
Expand Down
23 changes: 18 additions & 5 deletions PWGDQ/TableProducer/tableMaker_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ struct TableMaker {
Configurable<std::string> fConfigTrackCuts{"cfgBarrelTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"};
Configurable<std::string> fConfigMuonCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"};
Configurable<bool> fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"};
Configurable<string> fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"};
Configurable<std::string> fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"};
Configurable<bool> fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"};

// Steer QA output
Configurable<bool> fConfigQA{"cfgQA", false, "If true, fill QA histograms"};
Expand All @@ -187,7 +188,7 @@ struct TableMaker {
// CCDB connection configurables
Configurable<string> fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
Configurable<string> fConfigCcdbPathTPC{"ccdb-path-tpc", "Users/z/zhxiong/TPCPID/PostCalib", "base path to the ccdb object"};
Configurable<string> fConfigCcdbPathZorro{"ccdb-path-zorro", "Users/r/rlietava/EventFiltering/OTS/", "base path to the ccdb object for zorro"};
Configurable<string> fConfigCcdbPathZorro{"ccdb-path-zorro", "/Users/m/mpuccio/EventFiltering/OTS/", "base path to the ccdb object for zorro"};
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"};
Configurable<std::string> geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
Configurable<std::string> grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
Expand Down Expand Up @@ -438,6 +439,13 @@ 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);
fStatsList->Add(histZorroInfo);
TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5);
fStatsList->Add(histZorroSel);
}
}

template <uint32_t TEventFillMap, uint32_t TTrackFillMap, typename TEvents, typename TBCs, typename TZdcs, typename TTrackAssoc, typename TTracks>
Expand Down Expand Up @@ -520,9 +528,14 @@ struct TableMaker {
if (fConfigRunZorro) {
zorro.setBaseCCDBPath(fConfigCcdbPathZorro.value);
zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), fConfigZorroTrigMask.value);
if (zorro.isSelected(bc.globalBC())) {
zorro.populateExternalHists(fCurrentRun, reinterpret_cast<TH2D*>(fStatsList->At(3)), reinterpret_cast<TH2D*>(fStatsList->At(4)));
bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast<TH2D*>(fStatsList->At(4)));
if (zorroSel) {
tag |= (static_cast<uint64_t>(true) << 56); // the same bit is used for this zorro selections from ccdb
}
if (fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) {
continue;
}
} else {
if (!fEventCut->IsSelected(VarManager::fgValues)) {
continue;
Expand Down Expand Up @@ -709,7 +722,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 <uint32_t TMFTFillMap, typename TEvent, typename TBCs>
void skimMFT(TEvent const& collision, TBCs const& /*bcs*/, MFTTracks const& /*mfts*/, MFTTrackAssoc const& mftAssocs)
Expand Down Expand Up @@ -865,7 +878,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 <uint32_t TEventFillMap, uint32_t TTrackFillMap, uint32_t TMuonFillMap, uint32_t TMFTFillMap,
Expand Down
Loading