Skip to content

Commit 1860a2e

Browse files
authored
Add interaction rate and occupancy selection
1 parent 168c4f5 commit 1860a2e

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

PWGCF/Flow/Tasks/flowMc.cxx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "Common/CCDB/EventSelectionParams.h"
2323
#include "Common/CCDB/RCTSelectionFlags.h"
24+
#include "Common/CCDB/ctpRateFetcher.h"
2425
#include "Common/Core/RecoDecay.h"
2526
#include "Common/Core/TrackSelection.h"
2627
#include "Common/Core/TrackSelectionDefaults.h"
@@ -118,6 +119,13 @@ struct FlowMc {
118119
O2_DEFINE_CONFIGURABLE(cfgRecoEvSelkNoCollInRofStandard, bool, false, "no other collisions in this Readout Frame with per-collision multiplicity above threshold")
119120
O2_DEFINE_CONFIGURABLE(cfgRecoEvSelkNoHighMultCollInPrevRof, bool, false, "veto an event if FT0C amplitude in previous ITS ROF is above threshold")
120121
O2_DEFINE_CONFIGURABLE(cfgEvSelRCTflags, std::string, "", "keep empty to disable, usage: 'CentralBarrelTracking', 'CBT_hadronPID' ")
122+
O2_DEFINE_CONFIGURABLE(cfgIRFetch, bool, false, "Get interaction rate from CCDB")
123+
O2_DEFINE_CONFIGURABLE(cfgIRCutEnabled, bool, false, "Use events with low interaction rate")
124+
O2_DEFINE_CONFIGURABLE(cfgIRMax, float, 50.0f, "maximum interaction rate (kHz)")
125+
O2_DEFINE_CONFIGURABLE(cfgIRMin, float, 0.0f, "minimum interaction rate (kHz)")
126+
O2_DEFINE_CONFIGURABLE(cfgOccupancyEnabled, bool, true, "Occupancy cut")
127+
O2_DEFINE_CONFIGURABLE(cfgOccupancyMax, int, 2000, "High cut on TPC occupancy")
128+
O2_DEFINE_CONFIGURABLE(cfgOccupancyMin, int, 0, "Low cut on TPC occupancy")
121129

122130
Configurable<std::vector<double>> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector<double>{0.6003720411, 0.6152630970, 0.6288860646, 0.6360694031, 0.6409494798, 0.6450540203, 0.6482117301, 0.6512592056, 0.6640008690, 0.6862631416, 0.7005738691, 0.7106567432, 0.7170728333}, "parameter 0 for track density efficiency correction"};
123131
Configurable<std::vector<double>> cfgTrackDensityP1{"cfgTrackDensityP1", std::vector<double>{-1.007592e-05, -8.932635e-06, -9.114538e-06, -1.054818e-05, -1.220212e-05, -1.312304e-05, -1.376433e-05, -1.412813e-05, -1.289562e-05, -1.050065e-05, -8.635725e-06, -7.380821e-06, -6.201250e-06}, "parameter 1 for track density efficiency correction"};
@@ -181,7 +189,12 @@ struct FlowMc {
181189
std::vector<GFW::CorrConfig> corrconfigsReco;
182190
TRandom3* fRndm = new TRandom3(0);
183191
double epsilon = 1e-6;
184-
192+
int mRunNumber{-1};
193+
uint64_t mSOR{0};
194+
double mMinSeconds{-1.};
195+
std::unordered_map<int, TH2*> gHadronicRate;
196+
ctpRateFetcher mRateFetcher;
197+
TH2* gCurrentHadronicRate;
185198
RCTFlagsChecker rctChecker{"CBT"};
186199

187200
void init(InitContext&)
@@ -442,6 +455,23 @@ struct FlowMc {
442455
}
443456
}
444457

458+
void initHadronicRate(aod::BCsWithTimestamps::iterator const& bc)
459+
{
460+
if (mRunNumber == bc.runNumber()) {
461+
return;
462+
}
463+
mRunNumber = bc.runNumber();
464+
if (gHadronicRate.find(mRunNumber) == gHadronicRate.end()) {
465+
auto runDuration = ccdb->getRunDuration(mRunNumber);
466+
mSOR = runDuration.first;
467+
mMinSeconds = std::floor(mSOR * 1.e-3); /// round tsSOR to the highest integer lower than tsSOR
468+
double maxSec = std::ceil(runDuration.second * 1.e-3); /// round tsEOR to the lowest integer higher than tsEOR
469+
const AxisSpec axisSeconds{static_cast<int>((maxSec - mMinSeconds) / 20.f), 0, maxSec - mMinSeconds, "Seconds since SOR"};
470+
gHadronicRate[mRunNumber] = histos.add<TH2>(Form("HadronicRate/%i", mRunNumber), ";Time since SOR (s);Hadronic rate (kHz)", kTH2D, {axisSeconds, {510, 0., 51.}}).get();
471+
}
472+
gCurrentHadronicRate = gHadronicRate[mRunNumber];
473+
}
474+
445475
template <typename TCollision>
446476
bool eventSelected(TCollision collision)
447477
{
@@ -451,6 +481,11 @@ struct FlowMc {
451481
if (cfgRecoEvSel8 && !collision.sel8()) {
452482
return 0;
453483
}
484+
if (cfgOccupancyEnabled) {
485+
auto occupancy = collision.trackOccupancyInTimeRange();
486+
if (occupancy < cfgOccupancyMin || occupancy > cfgOccupancyMax)
487+
return 0;
488+
}
454489
if (!cfgEvSelRCTflags.value.empty() && !rctChecker(*collision))
455490
return 0;
456491
if (cfgRecoEvkNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) {
@@ -519,6 +554,14 @@ struct FlowMc {
519554
float wacc = 1.;
520555
auto bc = mcCollision.bc_as<aod::BCsWithTimestamps>();
521556
loadCorrections(bc.timestamp());
557+
if (cfgIRFetch) {
558+
initHadronicRate(bc);
559+
double hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), mRunNumber, "ZNC hadronic") * 1.e-3; //
560+
double seconds = bc.timestamp() * 1.e-3 - mMinSeconds;
561+
if (cfgIRCutEnabled && (hadronicRate < cfgIRMin || hadronicRate > cfgIRMax)) // cut on hadronic rate
562+
return;
563+
gCurrentHadronicRate->Fill(seconds, hadronicRate);
564+
}
522565

523566
if (collisions.size() > -1) {
524567
histos.fill(HIST("numberOfRecoCollisions"), collisions.size()); // number of times coll was reco-ed

0 commit comments

Comments
 (0)