Skip to content

Commit 0b069a5

Browse files
[PWGDQ] Fixing mu calculation and moving to table reader (#18732)
Co-authored-by: Lucamicheletti92 <luca.mike93@gmail.com>
1 parent 6fe9ba4 commit 0b069a5

5 files changed

Lines changed: 25 additions & 68 deletions

File tree

‎PWGDQ/Core/HistogramsLibrary.cxx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h
5959
hm->AddHistogram(histClass, "VtxZ", "Vtx Z", false, 60, -15.0, 15.0, VarManager::kVtxZ);
6060
hm->AddHistogram(histClass, "VtxZ_Run", "Vtx Z", true, 1, -0.5, 0.5, VarManager::kRunNo, 60, -15.0, 15.0, VarManager::kVtxZ, 1, 0, 1, VarManager::kNothing, "", "", "", VarManager::kNothing, VarManager::kNothing, false, true);
6161
hm->AddHistogram(histClass, "BC", "Event per BC", false, 3564, 0.0, 3564.0, VarManager::kBCOrbit);
62+
hm->AddHistogram(histClass, "mu", "#mu distribution", false, 5000, 0.0, 0.5, VarManager::kMuPerBc);
6263
}
6364
if (subGroupStr.Contains("trigger")) {
6465
hm->AddHistogram(histClass, "IsINT7", "Is INT7", false, 2, -0.5, 1.5, VarManager::kIsINT7);

‎PWGDQ/Core/VarManager.cxx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,8 @@ void VarManager::SetDefaultVarNames()
10051005
fgVariableUnits[kDCAzNPeaksTrimmed3] = "";
10061006
fgVariableNames[kInteractionRate] = "Interaction rate";
10071007
fgVariableUnits[kInteractionRate] = "kHz";
1008+
fgVariableNames[kMuPerBc] = "#mu";
1009+
fgVariableUnits[kMuPerBc] = "";
10081010
fgVariableNames[kPt] = "p_{T}";
10091011
fgVariableUnits[kPt] = "GeV/c";
10101012
fgVariableNames[kPt1] = "p_{T1}";
@@ -2391,6 +2393,7 @@ void VarManager::SetDefaultVarNames()
23912393
fgVarNamesMap["kTwoR2EP2"] = kTwoR2EP2;
23922394
fgVarNamesMap["kNPairsPerEvent"] = kNPairsPerEvent;
23932395
fgVarNamesMap["kInteractionRate"] = kInteractionRate;
2396+
fgVarNamesMap["kMuPerBc"] = kMuPerBc;
23942397
fgVarNamesMap["kNEventWiseVariables"] = kNEventWiseVariables;
23952398
fgVarNamesMap["kX"] = kX;
23962399
fgVarNamesMap["kY"] = kY;

‎PWGDQ/Core/VarManager.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ class VarManager : public TObject
526526
kA2EPME_FT0A, // A2 of VM to FT0A event plane for ME technique
527527
kNPairsPerEvent, // number of pairs per event in same-event or mixed-event pairing
528528
kInteractionRate,
529+
kMuPerBc,
529530

530531
// Variables for event mixing with cumulant
531532
kV22m,

‎PWGDQ/TableProducer/tableMaker_withAssoc.cxx‎

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ constexpr static uint32_t gkMFTCovFillMap = VarManager::ObjTypes::TrackMFT | Var
175175
// Enum containing the ordering of statistics histograms to be written in the QA file
176176
enum SkimStatsHists {
177177
kStatsEvent = 0,
178-
kStatsBcs,
179178
kStatsTracks,
180179
kStatsMuons,
181180
kStatsOrphanTracks,
@@ -258,14 +257,12 @@ struct TableMaker {
258257
// Steer QA output
259258
struct : ConfigurableGroup {
260259
Configurable<bool> fConfigQA{"cfgQA", false, "If true, fill QA histograms"};
261-
Configurable<bool> fConfigFillBcStat{"cfgFillBcStat", false, "If true, fill QA histograms for normalization studies (for OO and Pb-Pb)"};
262260
Configurable<bool> fConfigDetailedQA{"cfgDetailedQA", false, "If true, include more QA histograms (BeforeCuts classes)"};
263261
Configurable<std::string> fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"};
264262
Configurable<std::string> fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"};
265263
Configurable<std::string> fConfigAddMuonHistogram{"cfgAddMuonHistogram", "", "Comma separated list of histograms"};
266264
Configurable<std::string> fConfigAddEMCalHistogram{"cfgAddEMCalHistogram", "emcal", "Comma separated list of histogram subgroups for the EMCal cluster classes"};
267265
Configurable<std::string> fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"};
268-
Configurable<std::string> fConfigIrEstimator{"cfgIrEstimator", "", "Estimator of the interaction rate (pp,OO --> T0VTX, Pb-Pb --> ZNC hadronic), to be used with cfgFillBcStat"};
269266
} fConfigHistOutput;
270267

271268
Configurable<bool> fIsRun2{"cfgIsRun2", false, "Whether we analyze Run-2 or Run-3 data"};
@@ -728,14 +725,6 @@ struct TableMaker {
728725
histEvents->GetYaxis()->SetBinLabel(o2::aod::evsel::kNsel + 1, "Total");
729726
fStatsList->AddAt(histEvents, kStatsEvent);
730727

731-
std::vector<TString> bcLabels{"all", "tvx", "sel8", "sel8 & Cent", "sel8 & Scent", "sel8 & (Cent | Scent)", "sel8 & (ZNA & ZNC)"};
732-
TH2D* histBcs = new TH2D("BcStats", "Bc statistics;;#mu", bcLabels.size(), -0.5, bcLabels.size() - 0.5, 3000, 0, 0.3);
733-
ib = 1;
734-
for (auto label = bcLabels.begin(); label != bcLabels.end(); label++, ib++) {
735-
histBcs->GetXaxis()->SetBinLabel(ib, (*label).Data());
736-
}
737-
fStatsList->AddAt(histBcs, kStatsBcs);
738-
739728
// Track statistics: one bin for each track selection and 5 bins for V0 tags (gamma, K0s, Lambda, anti-Lambda, Omega)
740729
TH1D* histTracks = new TH1D("TrackStats", "Track statistics", fTrackCuts.size() + 5, -0.5, fTrackCuts.size() - 0.5 + 5.0);
741730
ib = 1;
@@ -951,22 +940,6 @@ struct TableMaker {
951940
} // end loop over collisions
952941
}
953942

954-
// Function to compute the mu for pileup estimation, taken from EM code
955-
double calculateMu(const auto& bc)
956-
{
957-
uint64_t timeStamp = bc.timestamp();
958-
auto bfilling = mLHCIFdata->getBunchFilling();
959-
double nbc = bfilling.getFilledBCs().size();
960-
961-
const double tvxRate = fConfigHistOutput.fConfigIrEstimator.value.empty()
962-
? mRateFetcher.fetch(fCCDB.service, timeStamp, bc.runNumber(), "T0VTX")
963-
: mRateFetcher.fetch(fCCDB.service, timeStamp, bc.runNumber(), fConfigHistOutput.fConfigIrEstimator.value);
964-
965-
double nTriggersPerFilledBC = tvxRate / nbc / o2::constants::lhc::LHCRevFreq;
966-
double mu = -std::log(1 - nTriggersPerFilledBC);
967-
return mu;
968-
}
969-
970943
template <typename TEvents, typename TTracks>
971944
void computeCollMergingTag(TEvents const& collisions, TTracks const& tracks, Preslice<TTracks>& presliceTracks)
972945
{
@@ -1059,44 +1032,6 @@ struct TableMaker {
10591032
float centFT0A = -1.0;
10601033
float centFT0M = -1.0;
10611034

1062-
if (fConfigHistOutput.fConfigFillBcStat) {
1063-
for (const auto& bc : bcs) {
1064-
double muTVX = calculateMu(bc);
1065-
1066-
if (bc.has_ft0()) {
1067-
std::bitset<8> fT0Triggers = bc.ft0().triggerMask();
1068-
bool isTvx = fT0Triggers[o2::ft0::Triggers::bitVertex];
1069-
bool isSemiCentral = fT0Triggers[o2::ft0::Triggers::bitSCen];
1070-
bool isCentral = fT0Triggers[o2::ft0::Triggers::bitCen];
1071-
1072-
bool noBorder = bc.selection_bit(aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(aod::evsel::kNoITSROFrameBorder);
1073-
// bool isTriggerTVX = bc.selection_bit(aod::evsel::kIsTriggerTVX); // difference w.r.t fT0Triggers[o2::ft0::Triggers::bitVertex] ?
1074-
bool isTriggerZNA = bc.selection_bit(aod::evsel::kIsBBZNA);
1075-
bool isTriggerZNC = bc.selection_bit(aod::evsel::kIsBBZNC);
1076-
1077-
(dynamic_cast<TH2D*>(fStatsList->At(kStatsBcs)))->Fill(0.0, muTVX);
1078-
if (isTvx) {
1079-
(dynamic_cast<TH2D*>(fStatsList->At(kStatsBcs)))->Fill(1.0, muTVX);
1080-
if (noBorder) {
1081-
(dynamic_cast<TH2D*>(fStatsList->At(kStatsBcs)))->Fill(2.0, muTVX);
1082-
if (isCentral) {
1083-
(dynamic_cast<TH2D*>(fStatsList->At(kStatsBcs)))->Fill(3.0, muTVX);
1084-
}
1085-
if (isSemiCentral) {
1086-
(dynamic_cast<TH2D*>(fStatsList->At(kStatsBcs)))->Fill(4.0, muTVX);
1087-
}
1088-
if (isCentral || isSemiCentral) {
1089-
(dynamic_cast<TH2D*>(fStatsList->At(kStatsBcs)))->Fill(5.0, muTVX);
1090-
}
1091-
if (isTriggerZNA && isTriggerZNC) {
1092-
(dynamic_cast<TH2D*>(fStatsList->At(kStatsBcs)))->Fill(6.0, muTVX);
1093-
}
1094-
}
1095-
}
1096-
}
1097-
}
1098-
}
1099-
11001035
for (const auto& collision : collisions) {
11011036

11021037
for (int i = 0; i < o2::aod::evsel::kNsel; i++) {
@@ -1894,9 +1829,6 @@ struct TableMaker {
18941829
LOG(fatal) << "Unexpected number of shift values from CCDB: " << fFwdShift->size() << ", expected 1 (z), 3 (x, y, z) or 10 (top/bottom x,y,z + slopes)";
18951830
}
18961831
}
1897-
if (fConfigHistOutput.fConfigFillBcStat) {
1898-
mLHCIFdata = fCCDB->getSpecific<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", bcs.begin().timestamp());
1899-
}
19001832
if (fConfigVariousOptions.fPropMuon) {
19011833
VarManager::SetupMuonMagField();
19021834
}

‎PWGDQ/Tasks/tableReader_withAssoc.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,20 @@ void PrintBitMap(TMap map, int nbits)
342342
LOG(info) << bits;
343343
}
344344

345+
// Function to compute the mu for pileup estimation, taken from EM code
346+
double calculateMu(const double interactionRate, const double nbc)
347+
{
348+
// uint64_t timeStamp = bc.timestamp();
349+
// auto grpmag = fCCDB->getForTimeStamp<o2::parameters::GRPMagField>(grpmagPath, events.begin().timestamp());
350+
// auto grpo = fCCDB->getForTimeStamp<o2::parameters::GRPLHCIFData>(fConfigCCDB.GrpLhcIfPath, timestamp);
351+
// auto bfilling = grpo->getBunchFilling();
352+
// double nbc = bfilling.getFilledBCs().size();
353+
354+
double nTriggersPerFilledBC = (interactionRate * 1000) / nbc / o2::constants::lhc::LHCRevFreq;
355+
double mu = -std::log(1 - nTriggersPerFilledBC);
356+
return mu;
357+
}
358+
345359
// Analysis task that produces event decisions (analysis cut, in bunch pileup and split collision check) and the Hash table used in event mixing
346360
struct AnalysisEventSelection {
347361

@@ -551,6 +565,12 @@ struct AnalysisEventSelection {
551565
// Get the instantaneous IR from the CCDB
552566
if (fConfigFetchInteractionRate.value) {
553567
VarManager::fgValues[VarManager::kInteractionRate] = rateFetcher.fetch(fCCDB.service, event.timestamp(), fCurrentRun, fConfigIRSource.value, true) / 1000.; // kHz
568+
// Compute Mu
569+
auto grpo = fCCDB->getForTimeStamp<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", event.timestamp());
570+
auto bfilling = grpo->getBunchFilling();
571+
double nbc = bfilling.getFilledBCs().size();
572+
// IR is now in kHz, but in calcualteMu it is restored to Hz
573+
VarManager::fgValues[VarManager::kMuPerBc] = calculateMu(VarManager::fgValues[VarManager::kInteractionRate], nbc);
554574
}
555575

556576
bool decision = false;

0 commit comments

Comments
 (0)