Skip to content

Commit d5baa03

Browse files
author
Nicolas Strangmann
committed
[PWGEM/PhotonMeson] Add MC functionality to BC wise pi0 task
1 parent 22f76f4 commit d5baa03

File tree

3 files changed

+187
-79
lines changed

3 files changed

+187
-79
lines changed

PWGEM/PhotonMeson/DataModel/bcWiseTables.h

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ enum Observables {
3737
kFT0MCent,
3838
kZVtx,
3939
kFT0Amp,
40-
kCellAmpSum,
4140
kpT,
4241
nObservables
4342
};
@@ -53,25 +52,24 @@ const float downscalingFactors[nObservables]{
5352
1E2, // Cluster time
5453
2E0, // FT0M centrality
5554
1E3, // Z-vertex position
56-
1E0, // FT0M amplitude
57-
1E0, // Cell energy
55+
1E-1, // FT0M amplitude
5856
1E3}; // MC pi0 pt
5957
} // namespace emdownscaling
6058

6159
namespace bcwisebc
6260
{
63-
DECLARE_SOA_COLUMN(HasFT0, hasFT0, bool); //! has_foundFT0()
64-
DECLARE_SOA_COLUMN(HasTVX, hasTVX, bool); //! has the TVX trigger flag
65-
DECLARE_SOA_COLUMN(HaskTVXinEMC, haskTVXinEMC, bool); //! kTVXinEMC
66-
DECLARE_SOA_COLUMN(HasEMCCell, hasEMCCell, bool); //! at least one EMCal cell in the BC
67-
DECLARE_SOA_COLUMN(HasNoTFROFBorder, hasNoTFROFBorder, bool); //! not in the TF border or ITS ROF border region
68-
DECLARE_SOA_COLUMN(StoredFT0MAmplitude, storedFT0MAmplitude, unsigned int); //! ft0a+c amplitude
69-
DECLARE_SOA_COLUMN(StoredEMCalnCells, storedEMCalnCells, unsigned int); //! number of emcal cells
70-
DECLARE_SOA_COLUMN(StoredEMCalCellEnergy, storedEMCalCellEnergy, float); //! sum of energy in emcal cells
61+
DECLARE_SOA_COLUMN(HasFT0, hasFT0, bool); //! has_foundFT0()
62+
DECLARE_SOA_COLUMN(HasTVX, hasTVX, bool); //! has the TVX trigger flag
63+
DECLARE_SOA_COLUMN(HaskTVXinEMC, haskTVXinEMC, bool); //! kTVXinEMC
64+
DECLARE_SOA_COLUMN(HasEMCCell, hasEMCCell, bool); //! at least one EMCal cell in the BC
65+
DECLARE_SOA_COLUMN(HasNoTFROFBorder, hasNoTFROFBorder, bool); //! not in the TF border or ITS ROF border region
66+
DECLARE_SOA_COLUMN(StoredFT0MAmplitude, storedFT0MAmplitude, uint16_t); //! ft0a+c amplitude
67+
68+
DECLARE_SOA_DYNAMIC_COLUMN(FT0MAmplitude, ft0Amplitude, [](uint16_t storedFT0MAmplitude) -> float { return storedFT0MAmplitude / emdownscaling::downscalingFactors[emdownscaling::kFT0Amp]; }); //! FT0M amplitude
7169
} // namespace bcwisebc
7270
DECLARE_SOA_TABLE(BCWiseBCs, "AOD", "BCWISEBC", //! table of bc wise centrality estimation and event selection input
7371
o2::soa::Index<>, bcwisebc::HasFT0, bcwisebc::HasTVX, bcwisebc::HaskTVXinEMC, bcwisebc::HasEMCCell, bcwisebc::HasNoTFROFBorder,
74-
bcwisebc::StoredFT0MAmplitude, bcwisebc::StoredEMCalnCells, bcwisebc::StoredEMCalCellEnergy);
72+
bcwisebc::StoredFT0MAmplitude, bcwisebc::FT0MAmplitude<bcwisebc::StoredFT0MAmplitude>);
7573

7674
DECLARE_SOA_INDEX_COLUMN(BCWiseBC, bcWiseBC); //! bunch crossing ID used as index
7775

@@ -117,29 +115,29 @@ DECLARE_SOA_TABLE(BCWiseClusters, "AOD", "BCWISECLUSTER", //! table of skimmed E
117115

118116
namespace bcwisemcpi0s
119117
{
120-
DECLARE_SOA_COLUMN(ParticleIdPi0, particleIdPi0, int); //! ID of the pi0 in the MC stack
121-
DECLARE_SOA_COLUMN(StoredPt, storedPt, uint16_t); //! Transverse momentum of generated pi0 (10 MeV)
122-
DECLARE_SOA_COLUMN(IsAccepted, isAccepted, bool); //! Both decay photons are within the EMCal acceptance
123-
DECLARE_SOA_COLUMN(IsPrimary, isPrimary, bool); //! mcParticle.isPhysicalPrimary() || mcParticle.producedByGenerator()
124-
DECLARE_SOA_COLUMN(IsFromWD, isFromWD, bool); //! Pi0 from a weak decay according to pwgem::photonmeson::utils::mcutil::IsFromWD
118+
DECLARE_SOA_COLUMN(StoredPt, storedPt, uint16_t); //! Transverse momentum of generated pi0 (1 MeV -> Maximum pi0 pT of ~65 GeV)
119+
DECLARE_SOA_COLUMN(IsAccepted, isAccepted, bool); //! Both decay photons are within the EMCal acceptance
120+
DECLARE_SOA_COLUMN(IsPrimary, isPrimary, bool); //! mcParticle.isPhysicalPrimary() || mcParticle.producedByGenerator()
121+
DECLARE_SOA_COLUMN(IsFromWD, isFromWD, bool); //! Pi0 from a weak decay according to pwgem::photonmeson::utils::mcutil::IsFromWD
125122

126123
DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](uint16_t storedpt) -> float { return storedpt / emdownscaling::downscalingFactors[emdownscaling::kpT]; }); //! pT of pi0 (GeV)
127124
} // namespace bcwisemcpi0s
128125

129126
DECLARE_SOA_TABLE(BCWiseMCPi0s, "AOD", "BCWISEMCPI0", //! table of pi0s on MC level
130-
o2::soa::Index<>, BCWiseBCId, bcwisemcpi0s::ParticleIdPi0, bcwisemcpi0s::StoredPt, bcwisemcpi0s::IsAccepted, bcwisemcpi0s::IsPrimary, bcwisemcpi0s::IsFromWD,
127+
o2::soa::Index<>, BCWiseBCId, bcwisemcpi0s::StoredPt, bcwisemcpi0s::IsAccepted, bcwisemcpi0s::IsPrimary, bcwisemcpi0s::IsFromWD,
131128
bcwisemcpi0s::Pt<bcwisemcpi0s::StoredPt>);
132129

133130
namespace bcwisemccluster
134131
{
135-
DECLARE_SOA_COLUMN(StoredE, storedE, uint16_t); //! energy of cluster inducing particle (1 MeV precision)
132+
DECLARE_SOA_COLUMN(Pi0ID, pi0ID, int32_t); //! Index of the mother pi0 (-1 if not from pi0)
133+
DECLARE_SOA_COLUMN(StoredTrueE, storedTrueE, uint16_t); //! energy of cluster inducing particle (1 MeV -> Maximum cluster energy of ~65 GeV)
136134

137-
DECLARE_SOA_DYNAMIC_COLUMN(E, e, [](uint16_t storedE) -> float { return storedE / emdownscaling::downscalingFactors[emdownscaling::kEnergy]; }); //! energy of cluster inducing particle (GeV)
135+
DECLARE_SOA_DYNAMIC_COLUMN(TrueE, trueE, [](uint16_t storedTrueE) -> float { return storedTrueE / emdownscaling::downscalingFactors[emdownscaling::kEnergy]; }); //! energy of cluster inducing particle (GeV)
138136
} // namespace bcwisemccluster
139137

140138
DECLARE_SOA_TABLE(BCWiseMCClusters, "AOD", "BCWISEMCCLS", //! table of MC information for clusters -> To be joined with the cluster table
141-
o2::soa::Index<>, BCWiseBCId, bcwisemccluster::StoredE, bcwisemcpi0s::ParticleIdPi0,
142-
bcwisemccluster::E<bcwisemccluster::StoredE>);
139+
o2::soa::Index<>, BCWiseBCId, bcwisemccluster::Pi0ID, bcwisemccluster::StoredTrueE,
140+
bcwisemccluster::TrueE<bcwisemccluster::StoredTrueE>);
143141

144142
} // namespace o2::aod
145143

PWGEM/PhotonMeson/TableProducer/bcWiseClusterSkimmer.cxx

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ struct bcWiseClusterSkimmer {
6363
Configurable<float> cfgMinTime{"cfgMinTime", -25, "Minimum time of selected clusters (ns)"};
6464
Configurable<float> cfgMaxTime{"cfgMaxTime", 25, "Maximum time of selected clusters (ns)"};
6565
Configurable<float> cfgRapidityCut{"cfgRapidityCut", 0.8f, "Maximum absolute rapidity of counted generated particles"};
66+
// Configurable<float> cfgMinPtGenPi0{"cfgMinPtGenPi0", 0., "Minimum pT for stored generated pi0s (reduce disk space of derived data)"};
67+
68+
Configurable<bool> cfgRequirekTVXinEMC{"cfgRequirekTVXinEMC", false, "Only store kTVXinEMC triggered BCs"};
69+
Configurable<bool> cfgRequireGoodRCTQuality{"cfgRequireGoodRCTQuality", false, "Only store BCs with good quality of T0 and EMC in RCT"};
70+
71+
aod::rctsel::RCTFlagsChecker isFT0EMCGoodRCTChecker{aod::rctsel::kFT0Bad, aod::rctsel::kEMCBad};
6672

6773
expressions::Filter energyFilter = aod::emcalcluster::energy > cfgMinClusterEnergy;
6874
expressions::Filter m02Filter = (aod::emcalcluster::nCells == 1 || (aod::emcalcluster::m02 > cfgMinM02 && aod::emcalcluster::m02 < cfgMaxM02));
@@ -71,6 +77,8 @@ struct bcWiseClusterSkimmer {
7177

7278
HistogramRegistry mHistManager{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false};
7379

80+
std::map<int32_t, int32_t> fMapPi0Index; // Map to connect the MC index of the pi0 to the one saved in the derived table
81+
7482
void init(framework::InitContext&)
7583
{
7684
const int nEventBins = 6;
@@ -79,15 +87,13 @@ struct bcWiseClusterSkimmer {
7987
for (int iBin = 0; iBin < nEventBins; iBin++)
8088
mHistManager.get<TH1>(HIST("nBCs"))->GetXaxis()->SetBinLabel(iBin + 1, binLabels[iBin]);
8189

82-
mHistManager.add("hAmplitudeVsCentrality", "FT0M AmplitudeVsCentrality;FT0M Centrality;FT0M Amplitude", HistType::kTH2F, {{105, 0, 105}, {400, 0, 200000}});
83-
mHistManager.add("sumAmp", "Sum Amplitude", HistType::kTH1F, {{1000, 0., 10.}});
84-
mHistManager.add("nCells", "Number of EMCal cells", HistType::kTH1F, {{5000, -0.5, 5000.5}});
85-
8690
LOG(info) << "| Timing cut: " << cfgMinTime << " < t < " << cfgMaxTime;
8791
LOG(info) << "| M02 cut: " << cfgMinM02 << " < M02 < " << cfgMaxM02;
8892
LOG(info) << "| E cut: E > " << cfgMinClusterEnergy;
8993

9094
o2::emcal::Geometry::GetInstanceFromRunNumber(300000);
95+
if (cfgRequireGoodRCTQuality)
96+
isFT0EMCGoodRCTChecker.init({aod::rctsel::kFT0Bad, aod::rctsel::kEMCBad});
9197
}
9298

9399
/// \brief Process EMCAL clusters (either ambigous or unique)
@@ -129,28 +135,32 @@ struct bcWiseClusterSkimmer {
129135
{
130136
for (const auto& cluster : clusters) {
131137
float clusterInducerEnergy = 0.;
132-
int pi0MCIndex = -1;
138+
int32_t pi0MCIndex = -1;
133139
if (cluster.amplitudeA().size() > 0) {
134140
int clusterInducerId = cluster.mcParticleIds()[0];
135141
auto clusterInducer = mcParticles.iteratorAt(clusterInducerId);
136142
clusterInducerEnergy = clusterInducer.e();
137143
int daughterId = aod::pwgem::photonmeson::utils::mcutil::FindMotherInChain(clusterInducer, mcParticles, std::vector<int>{111});
138-
if (daughterId > 0) {
144+
if (daughterId > 0)
139145
pi0MCIndex = mcParticles.iteratorAt(daughterId).mothersIds()[0];
140-
}
141146
}
142-
mcclusterTable(bcID, convertForStorage<uint16_t>(clusterInducerEnergy, kEnergy), pi0MCIndex);
147+
if (pi0MCIndex > 0)
148+
pi0MCIndex = fMapPi0Index[pi0MCIndex];
149+
mcclusterTable(bcID, pi0MCIndex, convertForStorage<uint16_t>(clusterInducerEnergy, kEnergy));
143150
}
144151
}
145152

146-
void processEventProperties(const auto& bc, const auto& collisionsInBC, const auto& cellsInBC)
153+
bool isBCSelected(const auto& bc)
147154
{
148-
float sumAmp = 0.;
149-
for (const auto& cell : cellsInBC)
150-
sumAmp += cell.amplitude();
151-
mHistManager.fill(HIST("sumAmp"), sumAmp);
152-
mHistManager.fill(HIST("nCells"), cellsInBC.size());
155+
if (cfgRequirekTVXinEMC && !bc.selection_bit(aod::evsel::kIsTriggerTVX))
156+
return false;
157+
if (cfgRequireGoodRCTQuality && !isFT0EMCGoodRCTChecker(bc))
158+
return false;
159+
return true;
160+
}
153161

162+
void processEventProperties(const auto& bc, const auto& collisionsInBC, const auto& cellsInBC)
163+
{
154164
bool hasFT0 = bc.has_foundFT0();
155165
bool hasTVX = bc.selection_bit(aod::evsel::kIsTriggerTVX);
156166
bool haskTVXinEMC = bc.alias_bit(kTVXinEMC);
@@ -170,15 +180,11 @@ struct bcWiseClusterSkimmer {
170180

171181
float ft0Amp = hasFT0 ? bc.foundFT0().sumAmpA() + bc.foundFT0().sumAmpC() : 0.;
172182

173-
bcTable(hasFT0, hasTVX, haskTVXinEMC, hasEMCCell, hasNoTFROFBorder, convertForStorage<unsigned int>(ft0Amp, kFT0Amp), convertForStorage<unsigned int>(cellsInBC.size(), kNCells), convertForStorage<float>(sumAmp, kCellAmpSum));
183+
bcTable(hasFT0, hasTVX, haskTVXinEMC, hasEMCCell, hasNoTFROFBorder, convertForStorage<uint16_t>(ft0Amp, kFT0Amp));
174184

175185
for (const auto& collision : collisionsInBC) {
176186
collisionTable(bcTable.lastIndex(), convertForStorage<uint8_t>(collision.centFT0M(), kFT0MCent), convertForStorage<int16_t>(collision.posZ(), kZVtx));
177-
mHistManager.fill(HIST("hAmplitudeVsCentrality"), collision.centFT0M(), ft0Amp);
178187
}
179-
180-
if (collisionsInBC.size() == 0)
181-
mHistManager.fill(HIST("hAmplitudeVsCentrality"), 103, ft0Amp);
182188
}
183189

184190
template <typename TMCParticle, typename TMCParticles>
@@ -218,6 +224,8 @@ struct bcWiseClusterSkimmer {
218224
void processData(MyBCs const& bcs, MyCollisions const& collisions, aod::FT0s const&, SelectedCells const& cells, SelectedUniqueClusters const& uClusters, SelectedAmbiguousClusters const& aClusters)
219225
{
220226
for (const auto& bc : bcs) {
227+
if (!isBCSelected(bc))
228+
continue;
221229
auto collisionsInBC = collisions.sliceBy(perFoundBC, bc.globalIndex());
222230
auto cellsInBC = cells.sliceBy(cellsPerBC, bc.globalIndex());
223231

@@ -240,6 +248,8 @@ struct bcWiseClusterSkimmer {
240248
void processMC(MyBCs const& bcs, MyMCCollisions const& collisions, aod::McCollisions const& mcCollisions, aod::FT0s const&, SelectedCells const& cells, SelectedUniqueMCClusters const& uClusters, SelectedAmbiguousMCClusters const& aClusters, aod::McParticles const& mcParticles)
241249
{
242250
for (const auto& bc : bcs) {
251+
if (!isBCSelected(bc))
252+
continue;
243253
auto collisionsInBC = collisions.sliceBy(perFoundBC, bc.globalIndex());
244254
auto cellsInBC = cells.sliceBy(cellsPerBC, bc.globalIndex());
245255

@@ -253,7 +263,8 @@ struct bcWiseClusterSkimmer {
253263
continue;
254264
bool isPrimary = mcParticle.isPhysicalPrimary() || mcParticle.producedByGenerator();
255265
bool isFromWD = (aod::pwgem::photonmeson::utils::mcutil::IsFromWD(mcCollision, mcParticle, mcParticles)) > 0;
256-
mcpi0Table(bc.globalIndex(), mcParticle.globalIndex(), convertForStorage<uint16_t>(mcParticle.pt(), kpT), isAccepted(mcParticle, mcParticles), isPrimary, isFromWD);
266+
mcpi0Table(bc.globalIndex(), convertForStorage<uint16_t>(mcParticle.pt(), kpT), isAccepted(mcParticle, mcParticles), isPrimary, isFromWD);
267+
fMapPi0Index[mcParticle.globalIndex()] = static_cast<int32_t>(mcpi0Table.lastIndex());
257268
}
258269
}
259270

@@ -266,6 +277,7 @@ struct bcWiseClusterSkimmer {
266277
processClusters(clustersInBC, bcTable.lastIndex());
267278
processClusterMCInfo(clustersInBC, bc.globalIndex(), mcParticles);
268279
}
280+
fMapPi0Index.clear();
269281
}
270282
}
271283
PROCESS_SWITCH(bcWiseClusterSkimmer, processMC, "Run skimming for MC", false);

0 commit comments

Comments
 (0)