Skip to content

Commit 5b5c065

Browse files
nstrangmNicolas Strangmann
andauthored
[PWGEM/PhotonMeson] Add pile-up and centrality dependence to pi0 task (#11130)
Co-authored-by: Nicolas Strangmann <nicolas.strangmann@.cern.ch>
1 parent ed6f45e commit 5b5c065

File tree

4 files changed

+153
-111
lines changed

4 files changed

+153
-111
lines changed

PWGEM/PhotonMeson/DataModel/bcWiseTables.h

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace o2::aod
2828

2929
namespace emdownscaling
3030
{
31-
enum Observables {
31+
enum Observable {
3232
kDefinition,
3333
kEnergy,
3434
kEta,
@@ -40,6 +40,7 @@ enum Observables {
4040
kZVtx,
4141
kFT0Amp,
4242
kpT,
43+
kMu,
4344
nObservables
4445
};
4546

@@ -55,7 +56,8 @@ const float downscalingFactors[nObservables]{
5556
2E0, // FT0M centrality
5657
1E3, // Z-vertex position
5758
1E-1, // FT0M amplitude
58-
1E3}; // MC pi0 pt
59+
1E3, // MC pi0 pt
60+
1E5}; // Mu
5961
} // namespace emdownscaling
6062

6163
namespace bcwisebc
@@ -65,13 +67,17 @@ DECLARE_SOA_COLUMN(HasTVX, hasTVX, bool); //! has
6567
DECLARE_SOA_COLUMN(HaskTVXinEMC, haskTVXinEMC, bool); //! kTVXinEMC
6668
DECLARE_SOA_COLUMN(HasEMCCell, hasEMCCell, bool); //! at least one EMCal cell in the BC
6769
DECLARE_SOA_COLUMN(HasNoTFROFBorder, hasNoTFROFBorder, bool); //! not in the TF border or ITS ROF border region
70+
DECLARE_SOA_COLUMN(StoredCentrality, storedCentrality, uint8_t); //! FT0M centrality (0-100) (x2)
6871
DECLARE_SOA_COLUMN(StoredFT0MAmplitude, storedFT0MAmplitude, uint16_t); //! ft0a+c amplitude
72+
DECLARE_SOA_COLUMN(StoredMu, storedMu, uint16_t); //! probability of TVX collision per BC (x1000)
6973

70-
DECLARE_SOA_DYNAMIC_COLUMN(FT0MAmplitude, ft0Amplitude, [](uint16_t storedFT0MAmplitude) -> float { return storedFT0MAmplitude / emdownscaling::downscalingFactors[emdownscaling::kFT0Amp]; }); //! FT0M amplitude
74+
DECLARE_SOA_DYNAMIC_COLUMN(Centrality, centrality, [](uint8_t storedcentrality) -> float { return std::nextafter(storedcentrality / emdownscaling::downscalingFactors[emdownscaling::kFT0MCent], std::numeric_limits<float>::infinity()); }); //! Centrality (0-100)
75+
DECLARE_SOA_DYNAMIC_COLUMN(FT0MAmplitude, ft0Amplitude, [](uint16_t storedFT0MAmplitude) -> float { return std::nextafter(storedFT0MAmplitude / emdownscaling::downscalingFactors[emdownscaling::kFT0Amp], std::numeric_limits<float>::infinity()); }); //! FT0M amplitude
76+
DECLARE_SOA_DYNAMIC_COLUMN(Mu, mu, [](uint16_t storedMu) -> float { return std::nextafter(storedMu / emdownscaling::downscalingFactors[emdownscaling::kMu], std::numeric_limits<float>::infinity()); }); //! probability of TVX collision per BC
7177
} // namespace bcwisebc
7278
DECLARE_SOA_TABLE(BCWiseBCs, "AOD", "BCWISEBC", //! table of bc wise centrality estimation and event selection input
73-
o2::soa::Index<>, bcwisebc::HasFT0, bcwisebc::HasTVX, bcwisebc::HaskTVXinEMC, bcwisebc::HasEMCCell, bcwisebc::HasNoTFROFBorder,
74-
bcwisebc::StoredFT0MAmplitude, bcwisebc::FT0MAmplitude<bcwisebc::StoredFT0MAmplitude>);
79+
o2::soa::Index<>, bcwisebc::HasFT0, bcwisebc::HasTVX, bcwisebc::HaskTVXinEMC, bcwisebc::HasEMCCell, bcwisebc::HasNoTFROFBorder, bcwisebc::StoredCentrality,
80+
bcwisebc::StoredFT0MAmplitude, bcwisebc::StoredMu, bcwisebc::Centrality<bcwisebc::StoredCentrality>, bcwisebc::FT0MAmplitude<bcwisebc::StoredFT0MAmplitude>, bcwisebc::Mu<bcwisebc::StoredMu>);
7581

7682
DECLARE_SOA_INDEX_COLUMN(BCWiseBC, bcWiseBC); //! bunch crossing ID used as index
7783

@@ -80,8 +86,8 @@ namespace bcwisecollision
8086
DECLARE_SOA_COLUMN(StoredCentrality, storedCentrality, uint8_t); //! FT0M centrality (0-100) (x2)
8187
DECLARE_SOA_COLUMN(StoredZVtx, storedZVtx, int16_t); //! Z-vertex position (x1000)
8288

83-
DECLARE_SOA_DYNAMIC_COLUMN(Centrality, centrality, [](uint8_t storedcentrality) -> float { return storedcentrality / emdownscaling::downscalingFactors[emdownscaling::kFT0MCent]; }); //! Centrality (0-100)
84-
DECLARE_SOA_DYNAMIC_COLUMN(ZVtx, zVtx, [](int16_t storedzvtx) -> float { return storedzvtx / emdownscaling::downscalingFactors[emdownscaling::kZVtx]; }); //! Centrality (0-100)
89+
DECLARE_SOA_DYNAMIC_COLUMN(Centrality, centrality, [](uint8_t storedcentrality) -> float { return std::nextafter(storedcentrality / emdownscaling::downscalingFactors[emdownscaling::kFT0MCent], std::numeric_limits<float>::infinity()); }); //! Centrality (0-100)
90+
DECLARE_SOA_DYNAMIC_COLUMN(ZVtx, zVtx, [](int16_t storedzvtx) -> float { return storedzvtx / emdownscaling::downscalingFactors[emdownscaling::kZVtx]; }); //! Centrality (0-100)
8591
} // namespace bcwisecollision
8692
DECLARE_SOA_TABLE(BCWiseCollisions, "AOD", "BCWISECOLL", //! table of skimmed EMCal clusters
8793
o2::soa::Index<>, BCWiseBCId, bcwisecollision::StoredCentrality, bcwisecollision::StoredZVtx,
@@ -98,14 +104,14 @@ DECLARE_SOA_COLUMN(StoredM02, storedM02, int16_t); //! shower shape
98104
DECLARE_SOA_COLUMN(StoredTime, storedTime, int16_t); //! cluster time (10 ps resolution)
99105
DECLARE_SOA_COLUMN(StoredIsExotic, storedIsExotic, bool); //! flag to mark cluster as exotic
100106

101-
DECLARE_SOA_DYNAMIC_COLUMN(Definition, definition, [](int8_t storedDefinition) -> int8_t { return storedDefinition; }); //! cluster definition, see EMCALClusterDefinition.h
102-
DECLARE_SOA_DYNAMIC_COLUMN(E, e, [](int16_t storedE) -> float { return storedE / emdownscaling::downscalingFactors[emdownscaling::kEnergy] + std::numeric_limits<float>::epsilon(); }); //! cluster energy (GeV)
103-
DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, [](int16_t storedEta) -> float { return storedEta / emdownscaling::downscalingFactors[emdownscaling::kEta] + std::numeric_limits<float>::epsilon(); }); //! cluster pseudorapidity
104-
DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, [](uint16_t storedPhi) -> float { return storedPhi / emdownscaling::downscalingFactors[emdownscaling::kPhi] + std::numeric_limits<float>::epsilon(); }); //! cluster azimuthal angle (0 to 2pi)
105-
DECLARE_SOA_DYNAMIC_COLUMN(NCells, nCells, [](int16_t storedNCells) -> int16_t { return storedNCells; }); //! number of cells in cluster
106-
DECLARE_SOA_DYNAMIC_COLUMN(M02, m02, [](int16_t storedM02) -> float { return storedM02 / emdownscaling::downscalingFactors[emdownscaling::kM02] + std::numeric_limits<float>::epsilon(); }); //! shower shape long axis
107-
DECLARE_SOA_DYNAMIC_COLUMN(Time, time, [](int16_t storedTime) -> float { return storedTime / emdownscaling::downscalingFactors[emdownscaling::kTime] + std::numeric_limits<float>::epsilon(); }); //! cluster time (ns)
108-
DECLARE_SOA_DYNAMIC_COLUMN(IsExotic, isExotic, [](bool storedIsExotic) -> bool { return storedIsExotic; }); //! flag to mark cluster as exotic
107+
DECLARE_SOA_DYNAMIC_COLUMN(Definition, definition, [](int8_t storedDefinition) -> int8_t { return storedDefinition; }); //! cluster definition, see EMCALClusterDefinition.h
108+
DECLARE_SOA_DYNAMIC_COLUMN(E, e, [](int16_t storedE) -> float { return std::nextafter(storedE / emdownscaling::downscalingFactors[emdownscaling::kEnergy], std::numeric_limits<float>::infinity()); }); //! cluster energy (GeV)
109+
DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, [](int16_t storedEta) -> float { return std::nextafter(storedEta / emdownscaling::downscalingFactors[emdownscaling::kEta], std::numeric_limits<float>::infinity()); }); //! cluster pseudorapidity
110+
DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, [](uint16_t storedPhi) -> float { return std::nextafter(storedPhi / emdownscaling::downscalingFactors[emdownscaling::kPhi], std::numeric_limits<float>::infinity()); }); //! cluster azimuthal angle (0 to 2pi)
111+
DECLARE_SOA_DYNAMIC_COLUMN(NCells, nCells, [](int16_t storedNCells) -> int16_t { return storedNCells; }); //! number of cells in cluster
112+
DECLARE_SOA_DYNAMIC_COLUMN(M02, m02, [](int16_t storedM02) -> float { return std::nextafter(storedM02 / emdownscaling::downscalingFactors[emdownscaling::kM02], std::numeric_limits<float>::infinity()); }); //! shower shape long axis
113+
DECLARE_SOA_DYNAMIC_COLUMN(Time, time, [](int16_t storedTime) -> float { return std::nextafter(storedTime / emdownscaling::downscalingFactors[emdownscaling::kTime], std::numeric_limits<float>::infinity()); }); //! cluster time (ns)
114+
DECLARE_SOA_DYNAMIC_COLUMN(IsExotic, isExotic, [](bool storedIsExotic) -> bool { return storedIsExotic; }); //! flag to mark cluster as exotic
109115

110116
DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float storedE, float storedEta) -> float { return storedE / emdownscaling::downscalingFactors[emdownscaling::kEnergy] / std::cosh(storedEta / emdownscaling::downscalingFactors[emdownscaling::kEta]); }); //! cluster pt, assuming m=0 (photons)
111117
} // namespace bcwisecluster
@@ -122,7 +128,7 @@ DECLARE_SOA_COLUMN(IsAccepted, isAccepted, bool); //! Both decay photons are wit
122128
DECLARE_SOA_COLUMN(IsPrimary, isPrimary, bool); //! mcParticle.isPhysicalPrimary() || mcParticle.producedByGenerator()
123129
DECLARE_SOA_COLUMN(IsFromWD, isFromWD, bool); //! Pi0 from a weak decay according to pwgem::photonmeson::utils::mcutil::IsFromWD
124130

125-
DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](uint16_t storedpt) -> float { return storedpt / emdownscaling::downscalingFactors[emdownscaling::kpT] + std::numeric_limits<float>::epsilon(); }); //! pT of pi0 (GeV)
131+
DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](uint16_t storedpt) -> float { return std::nextafter(storedpt / emdownscaling::downscalingFactors[emdownscaling::kpT], std::numeric_limits<float>::infinity()); }); //! pT of pi0 (GeV)
126132
} // namespace bcwisemcpi0s
127133

128134
DECLARE_SOA_TABLE(BCWiseMCPi0s, "AOD", "BCWISEMCPI0", //! table of pi0s on MC level
@@ -134,7 +140,7 @@ namespace bcwisemccluster
134140
DECLARE_SOA_COLUMN(Pi0ID, pi0ID, int32_t); //! Index of the mother pi0 (-1 if not from pi0)
135141
DECLARE_SOA_COLUMN(StoredTrueE, storedTrueE, uint16_t); //! energy of cluster inducing particle (1 MeV -> Maximum cluster energy of ~65 GeV)
136142

137-
DECLARE_SOA_DYNAMIC_COLUMN(TrueE, trueE, [](uint16_t storedTrueE) -> float { return storedTrueE / emdownscaling::downscalingFactors[emdownscaling::kEnergy] + std::numeric_limits<float>::epsilon(); }); //! energy of cluster inducing particle (GeV)
143+
DECLARE_SOA_DYNAMIC_COLUMN(TrueE, trueE, [](uint16_t storedTrueE) -> float { return std::nextafter(storedTrueE / emdownscaling::downscalingFactors[emdownscaling::kEnergy], std::numeric_limits<float>::infinity()); }); //! energy of cluster inducing particle (GeV)
138144
} // namespace bcwisemccluster
139145

140146
DECLARE_SOA_TABLE(BCWiseMCClusters, "AOD", "BCWISEMCCLS", //! table of MC information for clusters -> To be joined with the cluster table

PWGEM/PhotonMeson/TableProducer/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ o2physics_add_dpl_workflow(skimmer-gamma-calo
4646

4747
o2physics_add_dpl_workflow(bc-wise-cluster-skimmer
4848
SOURCES bcWiseClusterSkimmer.cxx
49-
PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2Physics::AnalysisCore
49+
PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2Physics::AnalysisCCDB O2Physics::AnalysisCore
5050
COMPONENT_NAME Analysis)
5151

5252
o2physics_add_dpl_workflow(skimmer-phos

PWGEM/PhotonMeson/TableProducer/bcWiseClusterSkimmer.cxx

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <limits>
2020
#include <vector>
2121
#include <map>
22+
#include <string>
2223

2324
#include "Framework/runDataProcessing.h"
2425
#include "Framework/AnalysisTask.h"
@@ -28,6 +29,9 @@
2829

2930
#include "Common/DataModel/EventSelection.h"
3031
#include "Common/DataModel/Centrality.h"
32+
#include "Common/CCDB/ctpRateFetcher.h"
33+
#include "CCDB/BasicCCDBManager.h"
34+
#include "DataFormatsParameters/GRPLHCIFData.h"
3135
#include "PWGJE/DataModel/EMCALClusters.h"
3236
#include "PWGEM/PhotonMeson/Utils/MCUtilities.h"
3337
#include "PWGEM/PhotonMeson/DataModel/bcWiseTables.h"
@@ -39,7 +43,7 @@ using namespace o2::framework::expressions;
3943

4044
using MyCollisions = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Ms>;
4145
using MyMCCollisions = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Ms, aod::McCollisionLabels>;
42-
using MyBCs = soa::Join<aod::BCs, aod::BcSels>;
46+
using MyBCs = soa::Join<aod::BCs, aod::BcSels, aod::Timestamps>;
4347

4448
using SelectedUniqueClusters = soa::Filtered<aod::EMCALClusters>; // Clusters from collisions with only one collision in the BC
4549
using SelectedUniqueMCClusters = soa::Filtered<soa::Join<aod::EMCALClusters, aod::EMCALMCClusters>>; // Clusters from collisions with only one collision in the BC
@@ -70,8 +74,12 @@ struct bcWiseClusterSkimmer {
7074

7175
Configurable<bool> cfgRequirekTVXinEMC{"cfgRequirekTVXinEMC", false, "Only store kTVXinEMC triggered BCs"};
7276
Configurable<bool> cfgRequireGoodRCTQuality{"cfgRequireGoodRCTQuality", false, "Only store BCs with good quality of T0 and EMC in RCT"};
77+
Configurable<bool> cfgStoreMu{"cfgStoreMu", false, "Calculate and store mu (probablity of a TVX collision in the BC) per BC. Otherwise fill with 0"};
7378

7479
aod::rctsel::RCTFlagsChecker isFT0EMCGoodRCTChecker{aod::rctsel::kFT0Bad, aod::rctsel::kEMCBad};
80+
parameters::GRPLHCIFData* mLHCIFdata = nullptr;
81+
int mRunNumber = -1;
82+
ctpRateFetcher mRateFetcher;
7583

7684
Filter energyFilter = (aod::emcalcluster::energy > cfgMinClusterEnergy && aod::emcalcluster::energy < cfgMaxClusterEnergy);
7785
Filter m02Filter = (aod::emcalcluster::nCells == 1 || (aod::emcalcluster::m02 > cfgMinM02 && aod::emcalcluster::m02 < cfgMaxM02));
@@ -82,7 +90,7 @@ struct bcWiseClusterSkimmer {
8290

8391
std::map<int32_t, int32_t> fMapPi0Index; // Map to connect the MC index of the pi0 to the one saved in the derived table
8492

85-
void init(framework::InitContext&)
93+
void init(o2::framework::InitContext&)
8694
{
8795
const int nEventBins = 6;
8896
mHistManager.add("nBCs", "Number of BCs;;#bf{#it{N}_{BCs}}", HistType::kTH1F, {{nEventBins, -0.5, 5.5}});
@@ -105,9 +113,9 @@ struct bcWiseClusterSkimmer {
105113

106114
/// \brief Process EMCAL clusters (either ambigous or unique)
107115
template <typename OutputType, typename InputType>
108-
OutputType convertForStorage(InputType const& valueIn, Observables observable)
116+
OutputType convertForStorage(InputType const& valueIn, Observable observable)
109117
{
110-
double valueToBeChecked = std::round(valueIn * downscalingFactors[observable]);
118+
double valueToBeChecked = valueIn * downscalingFactors[observable];
111119
if (valueToBeChecked < std::numeric_limits<OutputType>::lowest()) {
112120
LOG(warning) << "Value " << valueToBeChecked << " of observable " << observable << " below lowest possible value of " << typeid(OutputType).name() << ": " << static_cast<float>(std::numeric_limits<OutputType>::lowest());
113121
valueToBeChecked = static_cast<float>(std::numeric_limits<OutputType>::lowest());
@@ -173,6 +181,33 @@ struct bcWiseClusterSkimmer {
173181
return true;
174182
}
175183

184+
double calculateMu(const auto& bc)
185+
{
186+
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
187+
uint64_t timeStamp = bc.timestamp();
188+
189+
if (mRunNumber != bc.runNumber()) {
190+
std::map<std::string, std::string> metadata;
191+
mLHCIFdata = ccdbMgr.getSpecific<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", timeStamp, metadata);
192+
if (mLHCIFdata == nullptr)
193+
LOG(fatal) << "GRPLHCIFData not in database, timestamp:" << timeStamp;
194+
mRunNumber = bc.runNumber();
195+
LOG(info) << "LHCIF data fetched for run " << mRunNumber << " and timestamp " << timeStamp;
196+
}
197+
198+
auto bfilling = mLHCIFdata->getBunchFilling();
199+
double nbc = bfilling.getFilledBCs().size();
200+
201+
double tvxRate = mRateFetcher.fetch(&ccdbMgr, timeStamp, bc.runNumber(), "T0VTX");
202+
203+
double nTriggersPerFilledBC = tvxRate / nbc / o2::constants::lhc::LHCRevFreq;
204+
double mu = -std::log(1 - nTriggersPerFilledBC);
205+
206+
// LOG(info) << "Time stamp: " << timeStamp << " Run number: " << bc.runNumber() << " Number of filled BCs: " << nbc << " Trigger rate: " << tvxRate << " Mu: " << mu;
207+
208+
return mu;
209+
}
210+
176211
void processEventProperties(const auto& bc, const auto& collisionsInBC, const auto& cellsInBC)
177212
{
178213
bool hasFT0 = bc.has_foundFT0();
@@ -192,13 +227,16 @@ struct bcWiseClusterSkimmer {
192227
if (hasNoTFROFBorder)
193228
mHistManager.fill(HIST("nBCs"), 5);
194229

230+
double mu = cfgStoreMu ? calculateMu(bc) : 0.;
195231
float ft0Amp = hasFT0 ? bc.foundFT0().sumAmpA() + bc.foundFT0().sumAmpC() : 0.;
232+
double centrality = 101.5;
233+
if (collisionsInBC.size() > 0)
234+
centrality = collisionsInBC.iteratorAt(0).centFT0M();
196235

197-
bcTable(hasFT0, hasTVX, haskTVXinEMC, hasEMCCell, hasNoTFROFBorder, convertForStorage<uint16_t>(ft0Amp, kFT0Amp));
236+
bcTable(hasFT0, hasTVX, haskTVXinEMC, hasEMCCell, hasNoTFROFBorder, convertForStorage<uint8_t>(centrality, kFT0MCent), convertForStorage<uint16_t>(ft0Amp, kFT0Amp), convertForStorage<uint16_t>(mu, kMu));
198237

199-
for (const auto& collision : collisionsInBC) {
238+
for (const auto& collision : collisionsInBC)
200239
collisionTable(bcTable.lastIndex(), convertForStorage<uint8_t>(collision.centFT0M(), kFT0MCent), convertForStorage<int16_t>(collision.posZ(), kZVtx));
201-
}
202240
}
203241

204242
template <typename TMCParticle, typename TMCParticles>

0 commit comments

Comments
 (0)