Skip to content

Commit 00d60fd

Browse files
authored
Update dndetaMFTPbPb.cxx
Modified method for cutting on interaction rate
1 parent 8daae28 commit 00d60fd

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

PWGMM/Mult/Tasks/dndetaMFTPbPb.cxx

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct DndetaMFTPbPb {
8585
true};
8686

8787
Configurable<bool> cfgDoIR{"cfgDoIR", false, "Flag to retrieve Interaction rate from CCDB"};
88+
Configurable<bool> cfgUseIRCut{"cfgUseIRCut", false, "Flag to cut on IR rate"};
8889
Configurable<bool> cfgIRCrashOnNull{"cfgIRCrashOnNull", false, "Flag to avoid CTP RateFetcher crash"};
8990
Configurable<std::string> cfgIRSource{"cfgIRSource", "T0VTX", "Estimator of the interaction rate (Pb-Pb: ZNC hadronic)"};
9091

@@ -159,7 +160,13 @@ struct DndetaMFTPbPb {
159160
"latest acceptable timestamp of creation for the object"};
160161
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch",
161162
"url of the ccdb repository"};
163+
164+
int mRunNumber{-1};
165+
uint64_t mSOR{0};
166+
double mMinSeconds{-1.};
167+
std::unordered_map<int, TH2*> gHadronicRate;
162168
ctpRateFetcher rateFetcher;
169+
TH2* gCurrentHadronicRate;
163170

164171
/// @brief init function, definition of histograms
165172
void init(InitContext&)
@@ -226,7 +233,7 @@ struct DndetaMFTPbPb {
226233
}
227234

228235
auto hev = registry.add<TH1>("hEvtSel", "hEvtSel", HistType::kTH1F,
229-
{{16, -0.5f, +15.5f}});
236+
{{14, -0.5f, +13.5f}});
230237
hev->GetXaxis()->SetBinLabel(1, "All collisions");
231238
hev->GetXaxis()->SetBinLabel(2, "Ev. sel.");
232239
hev->GetXaxis()->SetBinLabel(3, "kIsGoodZvtxFT0vsPV");
@@ -240,8 +247,6 @@ struct DndetaMFTPbPb {
240247
hev->GetXaxis()->SetBinLabel(11, "kNoHighMultCollInPrevRof");
241248
hev->GetXaxis()->SetBinLabel(12, "Below min occup.");
242249
hev->GetXaxis()->SetBinLabel(13, "Above max occup.");
243-
hev->GetXaxis()->SetBinLabel(14, "Below min IR (kHz)");
244-
hev->GetXaxis()->SetBinLabel(15, "Above max IR (kHz)");
245250

246251
auto hBcSel = registry.add<TH1>("hBcSel", "hBcSel", HistType::kTH1F,
247252
{{3, -0.5f, +2.5f}});
@@ -262,11 +267,6 @@ struct DndetaMFTPbPb {
262267
x->SetBinLabel(1, "All");
263268
x->SetBinLabel(2, "Selected");
264269

265-
if (cfgDoIR) {
266-
qaregistry.add("hOccIRate", "hOccIRate", HistType::kTH2F,
267-
{occupancyAxis, irBins});
268-
}
269-
270270
registry.add({"Events/NtrkZvtx",
271271
"; N_{trk}; Z_{vtx} (cm); occupancy",
272272
{HistType::kTHnSparseF, {multAxis, zAxis, occupancyAxis}}});
@@ -350,11 +350,6 @@ struct DndetaMFTPbPb {
350350
hstat->GetAxis(0)->SetBinLabel(1, "All");
351351
hstat->GetAxis(0)->SetBinLabel(2, "Selected");
352352

353-
if (cfgDoIR) {
354-
qaregistry.add("hCentOccIRate", "hCentOccIRate", HistType::kTHnSparseF,
355-
{centralityAxis, occupancyAxis, irBins});
356-
}
357-
358353
qaregistry.add({"Events/Centrality/hCent",
359354
"; centrality; occupancy",
360355
{HistType::kTH2F, {centAxis, occupancyAxis}},
@@ -917,6 +912,24 @@ struct DndetaMFTPbPb {
917912
return -1.f;
918913
}
919914

915+
void initHadronicRate(CollBCs::iterator const& bc)
916+
{
917+
if (mRunNumber == bc.runNumber()) {
918+
return;
919+
}
920+
mRunNumber = bc.runNumber();
921+
if (gHadronicRate.find(mRunNumber) == gHadronicRate.end()) {
922+
auto runDuration = ccdb->getRunDuration(mRunNumber);
923+
mSOR = runDuration.first;
924+
mMinSeconds = std::floor(mSOR * 1.e-3); /// round tsSOR to the highest integer lower than tsSOR
925+
double maxSec = std::ceil(runDuration.second * 1.e-3); /// round tsEOR to the lowest integer higher than tsEOR
926+
const AxisSpec axisSeconds{static_cast<int>((maxSec - mMinSeconds) / 20.f), 0, maxSec - mMinSeconds, "Seconds since SOR"};
927+
int hadronicRateBins = static_cast<int>(eventCuts.maxIR - eventCuts.minIR);
928+
gHadronicRate[mRunNumber] = registry.add<TH2>(Form("HadronicRate/%i", mRunNumber), ";Time since SOR (s);Hadronic rate (kHz)", kTH2D, {axisSeconds, {hadronicRateBins, eventCuts.minIR, eventCuts.maxIR}}).get();
929+
}
930+
gCurrentHadronicRate = gHadronicRate[mRunNumber];
931+
}
932+
920933
template <bool fillHis = false, typename C>
921934
bool isGoodEvent(C const& collision)
922935
{
@@ -1001,19 +1014,6 @@ struct DndetaMFTPbPb {
10011014
if constexpr (fillHis) {
10021015
registry.fill(HIST("hEvtSel"), 12);
10031016
}
1004-
double ir = (eventCuts.minIR >= 0 || eventCuts.maxIR >= 0) ? rateFetcher.fetch(ccdb.service, collision.timestamp(), collision.runNumber(), cfgIRSource, cfgIRCrashOnNull) * 1.e-3 : -1;
1005-
if (eventCuts.minIR >= 0 && ir < eventCuts.minIR) {
1006-
return false;
1007-
}
1008-
if (fillHis) {
1009-
registry.fill(HIST("hEvtSel"), 13);
1010-
}
1011-
if (eventCuts.maxIR >= 0 && ir > eventCuts.maxIR) {
1012-
return false;
1013-
}
1014-
if (fillHis) {
1015-
registry.fill(HIST("hEvtSel"), 14);
1016-
}
10171017
return true;
10181018
}
10191019

@@ -1112,10 +1112,6 @@ struct DndetaMFTPbPb {
11121112
auto occ = getOccupancy(collision, eventCuts.occupancyEstimator);
11131113
float c = getRecoCent(collision);
11141114
auto bc = collision.template foundBC_as<CollBCs>();
1115-
float ir = -1;
1116-
if (cfgDoIR) {
1117-
ir = rateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), cfgIRSource, cfgIRCrashOnNull) * 1.e-3;
1118-
}
11191115
if constexpr (has_reco_cent<C>) {
11201116
registry.fill(HIST("Events/Centrality/Selection"), 1., c, occ);
11211117
} else {
@@ -1126,18 +1122,22 @@ struct DndetaMFTPbPb {
11261122
return;
11271123
}
11281124

1125+
if (cfgDoIR) {
1126+
initHadronicRate(bc);
1127+
double ir = rateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), cfgIRSource, cfgIRCrashOnNull) * 1.e-3;
1128+
double seconds = bc.timestamp() * 1.e-3 - mMinSeconds;
1129+
if (cfgUseIRCut && (ir < eventCuts.minIR || ir > eventCuts.maxIR)) { // cut on hadronic rate
1130+
return;
1131+
}
1132+
gCurrentHadronicRate->Fill(seconds, ir);
1133+
}
1134+
11291135
auto z = collision.posZ();
11301136
if constexpr (has_reco_cent<C>) {
11311137
registry.fill(HIST("Events/Centrality/Selection"), 2., c, occ);
11321138
qaregistry.fill(HIST("Events/Centrality/hZvtxCent"), z, c, occ);
11331139
qaregistry.fill(HIST("Events/Centrality/hCent"), c, occ);
1134-
if (cfgDoIR) {
1135-
qaregistry.fill(HIST("hCentOccIRate"), c, occ, ir);
1136-
}
11371140
} else {
1138-
if (cfgDoIR) {
1139-
qaregistry.fill(HIST("hOccIRate"), occ, ir);
1140-
}
11411141
registry.fill(HIST("Events/Selection"), 2., occ);
11421142
}
11431143

@@ -1160,10 +1160,6 @@ struct DndetaMFTPbPb {
11601160
auto occ = getOccupancy(collision, eventCuts.occupancyEstimator);
11611161
float c = getRecoCent(collision);
11621162
auto bc = collision.template foundBC_as<CollBCs>();
1163-
float ir = -1;
1164-
if (cfgDoIR) {
1165-
ir = rateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), cfgIRSource, cfgIRCrashOnNull) * 1.e-3;
1166-
}
11671163
if constexpr (has_reco_cent<C>) {
11681164
registry.fill(HIST("Events/Centrality/Selection"), 1., c, occ);
11691165
} else {
@@ -1174,17 +1170,21 @@ struct DndetaMFTPbPb {
11741170
return;
11751171
}
11761172

1173+
if (cfgDoIR) {
1174+
initHadronicRate(bc);
1175+
double ir = rateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), cfgIRSource, cfgIRCrashOnNull) * 1.e-3;
1176+
double seconds = bc.timestamp() * 1.e-3 - mMinSeconds;
1177+
if (cfgUseIRCut && (ir < eventCuts.minIR || ir > eventCuts.maxIR)) { // cut on hadronic rate
1178+
return;
1179+
}
1180+
gCurrentHadronicRate->Fill(seconds, ir);
1181+
}
1182+
11771183
auto z = collision.posZ();
11781184
if constexpr (has_reco_cent<C>) {
11791185
registry.fill(HIST("Events/Centrality/Selection"), 2., c, occ);
1180-
if (cfgDoIR) {
1181-
qaregistry.fill(HIST("hCentOccIRate"), c, occ, ir);
1182-
}
11831186
} else {
11841187
registry.fill(HIST("Events/Selection"), 2., occ);
1185-
if (cfgDoIR) {
1186-
qaregistry.fill(HIST("hOccIRate"), occ, ir);
1187-
}
11881188
}
11891189

11901190
auto nBestTrks = countBestTracks<C, true>(tracks, besttracks, z, c, occ);

0 commit comments

Comments
 (0)