Skip to content

Commit 3fa50ea

Browse files
authored
[DPG] tpcSkimsTableCreator: read IR source and sqrtSNN from CCDB; fix nclPID definition (#16740)
1 parent bf4676f commit 3fa50ea

2 files changed

Lines changed: 49 additions & 8 deletions

File tree

DPG/Tasks/TPC/tpcSkimsTableCreator.cxx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,11 @@ struct TreeWriterTpcV0 {
8888
Configurable<float> nClNorm{"nClNorm", 152., "Number of cluster normalization. Run 2: 159, Run 3 152"};
8989
Configurable<int> applyEvSel{"applyEvSel", 2, "Flag to apply rapidity cut: 0 -> no event selection, 1 -> Run 2 event selection, 2 -> Run 3 event selection"};
9090
Configurable<int> trackSelection{"trackSelection", 0, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"};
91-
Configurable<std::string> irSource{"irSource", "T0VTX", "Estimator of the interaction rate (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)"};
9291
/// Configurables downsampling
9392
Configurable<double> dwnSmplFactorPi{"dwnSmplFactorPi", 1., "downsampling factor for pions, default fraction to keep is 1."};
9493
Configurable<double> dwnSmplFactorPr{"dwnSmplFactorPr", 1., "downsampling factor for protons, default fraction to keep is 1."};
9594
Configurable<double> dwnSmplFactorEl{"dwnSmplFactorEl", 1., "downsampling factor for electrons, default fraction to keep is 1."};
9695
Configurable<double> dwnSmplFactorKa{"dwnSmplFactorKa", 1., "downsampling factor for kaons, default fraction to keep is 1."};
97-
Configurable<float> sqrtSNN{"sqrtSNN", 5360., "sqrt(s_NN), used for downsampling with the Tsallis distribution"};
9896
Configurable<float> downsamplingTsalisPions{"downsamplingTsalisPions", -1., "Downsampling factor to reduce the number of pions"};
9997
Configurable<float> downsamplingTsalisProtons{"downsamplingTsalisProtons", -1., "Downsampling factor to reduce the number of protons"};
10098
Configurable<float> downsamplingTsalisElectrons{"downsamplingTsalisElectrons", -1., "Downsampling factor to reduce the number of electrons"};
@@ -108,6 +106,8 @@ struct TreeWriterTpcV0 {
108106
Configurable<bool> checkZdc{"checkZdc", false, "set ZDC flag for PbPb"};
109107
Configurable<bool> treatLimitedAcceptanceAsBad{"treatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"};
110108
Configurable<bool> requireGoodRct{"requireGoodRct", false, "require good detector flag in run condtion table"};
109+
// Configurable for the path of CCDB General Run Parameters LHC Interface information
110+
Configurable<std::string> ccdbPathGrpLhcIf{"ccdbPathGrpLhcIf", "GLO/Config/GRPLHCIF", "Path on the CCDB for the GRPLHCIF object"};
111111

112112
// an arbitrary value of N sigma TOF assigned by TOF task to tracks which are not matched to TOF hits
113113
constexpr static float NSigmaTofUnmatched{o2::aod::v0data::kNoTOFValue};
@@ -263,7 +263,7 @@ struct TreeWriterTpcV0 {
263263
void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const OccupancyValues& occValues, const bool isGoodRctEvent)
264264
{
265265
const double ncl = track.tpcNClsFound();
266-
const double nclPID = track.tpcNClsFindableMinusPID();
266+
const double nclPID = track.tpcNClsPID();
267267
const double p = track.tpcInnerParam();
268268
const double mass = o2::track::pid_constants::sMasses[id];
269269
const double bg = p / mass;
@@ -422,6 +422,9 @@ struct TreeWriterTpcV0 {
422422
aod::pidits::ITSNSigmaEl, aod::pidits::ITSNSigmaPi,
423423
aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr>(myTracks);
424424

425+
std::string irSource{};
426+
float sqrtSNN{};
427+
bool isFirstCollision{true};
425428
for (const auto& collision : collisions) {
426429
if (!isEventSelected(collision, applyEvSel)) {
427430
continue;
@@ -434,8 +437,12 @@ struct TreeWriterTpcV0 {
434437
const auto v0s = myV0s.sliceBy(perCollisionV0s, static_cast<int>(collision.globalIndex()));
435438
const auto cascs = myCascs.sliceBy(perCollisionCascs, static_cast<int>(collision.globalIndex()));
436439
const auto bc = collision.bc_as<BCType>();
440+
if (isFirstCollision) {
441+
evaluateIrSourceAndSqrtSnn(ccdb, ccdbPathGrpLhcIf, bc.timestamp(), irSource, sqrtSNN);
442+
}
443+
isFirstCollision = false;
437444
const int runnumber = bc.runNumber();
438-
const auto hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo;
445+
const auto hadronicRate = !irSource.empty() ? mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo : 0.;
439446
const int bcGlobalIndex = bc.globalIndex();
440447
int bcTimeFrameId{}, bcBcInTimeFrame{};
441448
if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) {
@@ -591,7 +598,6 @@ struct TreeWriterTpcTof {
591598
Configurable<float> nClNorm{"nClNorm", 152., "Number of cluster normalization. Run 2: 159, Run 3 152"};
592599
Configurable<int> applyEvSel{"applyEvSel", 2, "Flag to apply rapidity cut: 0 -> no event selection, 1 -> Run 2 event selection, 2 -> Run 3 event selection"};
593600
Configurable<int> trackSelection{"trackSelection", 1, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"};
594-
Configurable<std::string> irSource{"irSource", "T0VTX", "Estimator of the interaction rate (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)"};
595601
/// Triton
596602
Configurable<float> maxMomTPCOnlyTr{"maxMomTPCOnlyTr", 1.5, "Maximum momentum for TPC only cut triton"};
597603
Configurable<float> maxMomHardCutOnlyTr{"maxMomHardCutOnlyTr", 50, "Maximum TPC inner momentum for triton"};
@@ -626,7 +632,6 @@ struct TreeWriterTpcTof {
626632
Configurable<float> nSigmaTofTpctofPi{"nSigmaTofTpctofPi", 4., "number of sigma for TOF cut for TPC and TOF combined pion"};
627633
Configurable<double> dwnSmplFactorPi{"dwnSmplFactorPi", 1., "downsampling factor for pions, default fraction to keep is 1."};
628634
/// pT dependent downsampling
629-
Configurable<float> sqrtSNN{"sqrtSNN", 5360., "sqrt(s_NN), used for downsampling with the Tsallis distribution"};
630635
Configurable<float> downsamplingTsalisTritons{"downsamplingTsalisTritons", -1., "Downsampling factor to reduce the number of tritons"};
631636
Configurable<float> downsamplingTsalisDeuterons{"downsamplingTsalisDeuterons", -1., "Downsampling factor to reduce the number of deuterons"};
632637
Configurable<float> downsamplingTsalisProtons{"downsamplingTsalisProtons", -1., "Downsampling factor to reduce the number of protons"};
@@ -637,6 +642,8 @@ struct TreeWriterTpcTof {
637642
Configurable<bool> checkZdc{"checkZdc", false, "set ZDC flag for PbPb"};
638643
Configurable<bool> treatLimitedAcceptanceAsBad{"treatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"};
639644
Configurable<bool> requireGoodRct{"requireGoodRct", false, "require good detector flag in run condtion table"};
645+
// Configurable for the path of CCDB General Run Parameters LHC Interface information
646+
Configurable<std::string> ccdbPathGrpLhcIf{"ccdbPathGrpLhcIf", "GLO/Config/GRPLHCIF", "Path on the CCDB for the GRPLHCIF object"};
640647

641648
struct TofTrack {
642649
bool isApplyHardCutOnly;
@@ -698,7 +705,7 @@ struct TreeWriterTpcTof {
698705
void fillSkimmedTpcTofTable(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const OccupancyValues& occValues, const bool isGoodRctEvent)
699706
{
700707
const double ncl = track.tpcNClsFound();
701-
const double nclPID = track.tpcNClsFindableMinusPID();
708+
const double nclPID = track.tpcNClsPID();
702709
const double p = track.tpcInnerParam();
703710
const double mass = o2::track::pid_constants::sMasses[id];
704711
const double bg = p / mass;
@@ -803,6 +810,9 @@ struct TreeWriterTpcTof {
803810
labelTrack2TrackQA.at(trackId) = trackQA.globalIndex();
804811
}
805812
}
813+
std::string irSource{};
814+
float sqrtSNN{};
815+
bool isFirstCollision{true};
806816
for (const auto& collision : collisions) {
807817
const auto tracks = myTracks.sliceBy(perCollisionTracksType, collision.globalIndex());
808818
if (!isEventSelected(collision, applyEvSel)) {
@@ -822,8 +832,12 @@ struct TreeWriterTpcTof {
822832
}
823833

824834
const auto bc = collision.bc_as<BCType>();
835+
if (isFirstCollision) {
836+
evaluateIrSourceAndSqrtSnn(ccdb, ccdbPathGrpLhcIf, bc.timestamp(), irSource, sqrtSNN);
837+
}
838+
isFirstCollision = false;
825839
const int runnumber = bc.runNumber();
826-
const auto hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo;
840+
const auto hadronicRate = !irSource.empty() ? mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo : 0.;
827841
const int bcGlobalIndex = bc.globalIndex();
828842
int bcTimeFrameId{}, bcBcInTimeFrame{};
829843
if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) {

DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,19 @@
2222

2323
#include "tpcSkimsTableCreator.h"
2424

25+
#include "Common/Core/CollisionTypeHelper.h"
2526
#include "Common/DataModel/OccupancyTables.h"
2627

28+
#include <CCDB/BasicCCDBManager.h>
29+
#include <DataFormatsParameters/GRPLHCIFData.h>
2730
#include <Framework/ASoA.h>
31+
#include <Framework/AnalysisHelpers.h>
32+
#include <Framework/Logger.h>
2833

2934
#include <TRandom3.h>
3035

3136
#include <cmath>
37+
#include <string>
3238

3339
namespace o2::dpg_tpcskimstablecreator
3440
{
@@ -112,6 +118,27 @@ double tpcSignalGeneric(const TrkType& track)
112118
}
113119
}
114120

121+
/// Determine interaction rate source and sqrtSNN from CCDB
122+
void evaluateIrSourceAndSqrtSnn(const o2::framework::Service<o2::ccdb::BasicCCDBManager>& ccdb, const std::string& ccdbPathGrpLhcIf, const uint64_t timestamp, std::string& irSource, float& sqrtSNN)
123+
{
124+
o2::parameters::GRPLHCIFData* genRunParams = ccdb->template getForTimeStamp<o2::parameters::GRPLHCIFData>(ccdbPathGrpLhcIf, timestamp);
125+
if (genRunParams != nullptr) {
126+
const auto collSys = CollisionSystemType::getCollisionTypeFromGrp(genRunParams);
127+
if (collSys == CollisionSystemType::kCollSyspp) {
128+
irSource = "T0VTX";
129+
} else {
130+
irSource = "ZNC hadronic";
131+
}
132+
sqrtSNN = genRunParams->getSqrtS();
133+
LOG(info) << "irSource determined from General Run Parameters: " << irSource;
134+
LOG(info) << "sqrtSNN determined from General Run Parameters: " << sqrtSNN << " GeV";
135+
} else {
136+
irSource = "";
137+
sqrtSNN = 5360.f;
138+
LOG(warning) << "No General Run Parameters object found. irSource will remain undefined, sqrtSNN defaulted to 5360 GeV";
139+
}
140+
}
141+
115142
struct OccupancyValues {
116143
float tmoPrimUnfm80{UndefValueFloat};
117144
float tmoFV0AUnfm80{UndefValueFloat};

0 commit comments

Comments
 (0)