Skip to content

Commit c461cd2

Browse files
authored
[PWGCF] Add interaction rate and occupancy selection for MC (#16508)
1 parent 5eda34c commit c461cd2

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

PWGCF/Flow/Tasks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ o2physics_add_dpl_workflow(flow-runby-run
2626

2727
o2physics_add_dpl_workflow(flow-mc
2828
SOURCES flowMc.cxx
29-
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore
29+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::GFWCore
3030
COMPONENT_NAME Analysis)
3131

3232
o2physics_add_dpl_workflow(flow-qa

PWGCF/Flow/Tasks/flowMc.cxx

Lines changed: 45 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"
@@ -59,6 +60,7 @@
5960
#include <cstdint>
6061
#include <cstdlib>
6162
#include <string>
63+
#include <unordered_map>
6264
#include <vector>
6365

6466
using namespace o2;
@@ -118,6 +120,13 @@ struct FlowMc {
118120
O2_DEFINE_CONFIGURABLE(cfgRecoEvSelkNoCollInRofStandard, bool, false, "no other collisions in this Readout Frame with per-collision multiplicity above threshold")
119121
O2_DEFINE_CONFIGURABLE(cfgRecoEvSelkNoHighMultCollInPrevRof, bool, false, "veto an event if FT0C amplitude in previous ITS ROF is above threshold")
120122
O2_DEFINE_CONFIGURABLE(cfgEvSelRCTflags, std::string, "", "keep empty to disable, usage: 'CentralBarrelTracking', 'CBT_hadronPID' ")
123+
O2_DEFINE_CONFIGURABLE(cfgIRFetch, bool, false, "Get interaction rate from CCDB")
124+
O2_DEFINE_CONFIGURABLE(cfgIRCutEnabled, bool, false, "Use events with low interaction rate")
125+
O2_DEFINE_CONFIGURABLE(cfgIRMax, float, 50.0f, "maximum interaction rate (kHz)")
126+
O2_DEFINE_CONFIGURABLE(cfgIRMin, float, 0.0f, "minimum interaction rate (kHz)")
127+
O2_DEFINE_CONFIGURABLE(cfgOccupancyEnabled, bool, true, "Occupancy cut")
128+
O2_DEFINE_CONFIGURABLE(cfgOccupancyMax, int, 2000, "High cut on TPC occupancy")
129+
O2_DEFINE_CONFIGURABLE(cfgOccupancyMin, int, 0, "Low cut on TPC occupancy")
121130

122131
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"};
123132
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 +190,12 @@ struct FlowMc {
181190
std::vector<GFW::CorrConfig> corrconfigsReco;
182191
TRandom3* fRndm = new TRandom3(0);
183192
double epsilon = 1e-6;
184-
193+
int mRunNumber{-1};
194+
uint64_t mSOR{0};
195+
double mMinSeconds{-1.};
196+
std::unordered_map<int, TH2*> gHadronicRate;
197+
ctpRateFetcher mRateFetcher;
198+
TH2* gCurrentHadronicRate;
185199
RCTFlagsChecker rctChecker{"CBT"};
186200

187201
void init(InitContext&)
@@ -442,6 +456,23 @@ struct FlowMc {
442456
}
443457
}
444458

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

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

0 commit comments

Comments
 (0)