1818
1919#include < limits>
2020#include < vector>
21+ #include < map>
2122
2223#include " Framework/runDataProcessing.h"
2324#include " Framework/AnalysisTask.h"
@@ -63,6 +64,12 @@ struct bcWiseClusterSkimmer {
6364 Configurable<float > cfgMinTime{" cfgMinTime" , -25 , " Minimum time of selected clusters (ns)" };
6465 Configurable<float > cfgMaxTime{" cfgMaxTime" , 25 , " Maximum time of selected clusters (ns)" };
6566 Configurable<float > cfgRapidityCut{" cfgRapidityCut" , 0 .8f , " Maximum absolute rapidity of counted generated particles" };
67+ // Configurable<float> cfgMinPtGenPi0{"cfgMinPtGenPi0", 0., "Minimum pT for stored generated pi0s (reduce disk space of derived data)"};
68+
69+ Configurable<bool > cfgRequirekTVXinEMC{" cfgRequirekTVXinEMC" , false , " Only store kTVXinEMC triggered BCs" };
70+ Configurable<bool > cfgRequireGoodRCTQuality{" cfgRequireGoodRCTQuality" , false , " Only store BCs with good quality of T0 and EMC in RCT" };
71+
72+ aod::rctsel::RCTFlagsChecker isFT0EMCGoodRCTChecker{aod::rctsel::kFT0Bad , aod::rctsel::kEMCBad };
6673
6774 expressions::Filter energyFilter = aod::emcalcluster::energy > cfgMinClusterEnergy;
6875 expressions::Filter m02Filter = (aod::emcalcluster::nCells == 1 || (aod::emcalcluster::m02 > cfgMinM02 && aod::emcalcluster::m02 < cfgMaxM02));
@@ -71,6 +78,8 @@ struct bcWiseClusterSkimmer {
7178
7279 HistogramRegistry mHistManager {" output" , {}, OutputObjHandlingPolicy::AnalysisObject, false , false };
7380
81+ std::map<int32_t , int32_t > fMapPi0Index ; // Map to connect the MC index of the pi0 to the one saved in the derived table
82+
7483 void init (framework::InitContext&)
7584 {
7685 const int nEventBins = 6 ;
@@ -79,15 +88,13 @@ struct bcWiseClusterSkimmer {
7988 for (int iBin = 0 ; iBin < nEventBins; iBin++)
8089 mHistManager .get <TH1>(HIST (" nBCs" ))->GetXaxis ()->SetBinLabel (iBin + 1 , binLabels[iBin]);
8190
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-
8691 LOG (info) << " | Timing cut: " << cfgMinTime << " < t < " << cfgMaxTime;
8792 LOG (info) << " | M02 cut: " << cfgMinM02 << " < M02 < " << cfgMaxM02;
8893 LOG (info) << " | E cut: E > " << cfgMinClusterEnergy;
8994
9095 o2::emcal::Geometry::GetInstanceFromRunNumber (300000 );
96+ if (cfgRequireGoodRCTQuality)
97+ isFT0EMCGoodRCTChecker.init ({aod::rctsel::kFT0Bad , aod::rctsel::kEMCBad });
9198 }
9299
93100 // / \brief Process EMCAL clusters (either ambigous or unique)
@@ -129,28 +136,32 @@ struct bcWiseClusterSkimmer {
129136 {
130137 for (const auto & cluster : clusters) {
131138 float clusterInducerEnergy = 0 .;
132- int pi0MCIndex = -1 ;
139+ int32_t pi0MCIndex = -1 ;
133140 if (cluster.amplitudeA ().size () > 0 ) {
134141 int clusterInducerId = cluster.mcParticleIds ()[0 ];
135142 auto clusterInducer = mcParticles.iteratorAt (clusterInducerId);
136143 clusterInducerEnergy = clusterInducer.e ();
137144 int daughterId = aod::pwgem::photonmeson::utils::mcutil::FindMotherInChain (clusterInducer, mcParticles, std::vector<int >{111 });
138- if (daughterId > 0 ) {
145+ if (daughterId > 0 )
139146 pi0MCIndex = mcParticles.iteratorAt (daughterId).mothersIds ()[0 ];
140- }
141147 }
142- mcclusterTable (bcID, convertForStorage<uint16_t >(clusterInducerEnergy, kEnergy ), pi0MCIndex);
148+ if (pi0MCIndex > 0 )
149+ pi0MCIndex = fMapPi0Index [pi0MCIndex];
150+ mcclusterTable (bcID, pi0MCIndex, convertForStorage<uint16_t >(clusterInducerEnergy, kEnergy ));
143151 }
144152 }
145153
146- void processEventProperties (const auto & bc, const auto & collisionsInBC, const auto & cellsInBC )
154+ bool isBCSelected (const auto & bc)
147155 {
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 ());
156+ if (cfgRequirekTVXinEMC && !bc.selection_bit (aod::evsel::kIsTriggerTVX ))
157+ return false ;
158+ if (cfgRequireGoodRCTQuality && !isFT0EMCGoodRCTChecker (bc))
159+ return false ;
160+ return true ;
161+ }
153162
163+ void processEventProperties (const auto & bc, const auto & collisionsInBC, const auto & cellsInBC)
164+ {
154165 bool hasFT0 = bc.has_foundFT0 ();
155166 bool hasTVX = bc.selection_bit (aod::evsel::kIsTriggerTVX );
156167 bool haskTVXinEMC = bc.alias_bit (kTVXinEMC );
@@ -170,15 +181,11 @@ struct bcWiseClusterSkimmer {
170181
171182 float ft0Amp = hasFT0 ? bc.foundFT0 ().sumAmpA () + bc.foundFT0 ().sumAmpC () : 0 .;
172183
173- bcTable (hasFT0, hasTVX, haskTVXinEMC, hasEMCCell, hasNoTFROFBorder, convertForStorage<unsigned int >(ft0Amp, kFT0Amp ), convertForStorage< unsigned int >(cellsInBC. size (), kNCells ), convertForStorage< float >(sumAmp, kCellAmpSum ));
184+ bcTable (hasFT0, hasTVX, haskTVXinEMC, hasEMCCell, hasNoTFROFBorder, convertForStorage<uint16_t >(ft0Amp, kFT0Amp ));
174185
175186 for (const auto & collision : collisionsInBC) {
176187 collisionTable (bcTable.lastIndex (), convertForStorage<uint8_t >(collision.centFT0M (), kFT0MCent ), convertForStorage<int16_t >(collision.posZ (), kZVtx ));
177- mHistManager .fill (HIST (" hAmplitudeVsCentrality" ), collision.centFT0M (), ft0Amp);
178188 }
179-
180- if (collisionsInBC.size () == 0 )
181- mHistManager .fill (HIST (" hAmplitudeVsCentrality" ), 103 , ft0Amp);
182189 }
183190
184191 template <typename TMCParticle, typename TMCParticles>
@@ -218,6 +225,8 @@ struct bcWiseClusterSkimmer {
218225 void processData (MyBCs const & bcs, MyCollisions const & collisions, aod::FT0s const &, SelectedCells const & cells, SelectedUniqueClusters const & uClusters, SelectedAmbiguousClusters const & aClusters)
219226 {
220227 for (const auto & bc : bcs) {
228+ if (!isBCSelected (bc))
229+ continue ;
221230 auto collisionsInBC = collisions.sliceBy (perFoundBC, bc.globalIndex ());
222231 auto cellsInBC = cells.sliceBy (cellsPerBC, bc.globalIndex ());
223232
@@ -240,6 +249,8 @@ struct bcWiseClusterSkimmer {
240249 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)
241250 {
242251 for (const auto & bc : bcs) {
252+ if (!isBCSelected (bc))
253+ continue ;
243254 auto collisionsInBC = collisions.sliceBy (perFoundBC, bc.globalIndex ());
244255 auto cellsInBC = cells.sliceBy (cellsPerBC, bc.globalIndex ());
245256
@@ -249,11 +260,12 @@ struct bcWiseClusterSkimmer {
249260 for (const auto & mcCollision : mcCollisionsBC) {
250261 auto mcParticlesInColl = mcParticles.sliceBy (perMcCollision, mcCollision.globalIndex ());
251262 for (const auto & mcParticle : mcParticlesInColl) {
252- if (mcParticle.pdgCode () != 111 || fabs (mcParticle.y ()) > cfgRapidityCut || !isGammaGammaDecay (mcParticle, mcParticles))
263+ if (mcParticle.pdgCode () != 111 || std::abs (mcParticle.y ()) > cfgRapidityCut || !isGammaGammaDecay (mcParticle, mcParticles))
253264 continue ;
254265 bool isPrimary = mcParticle.isPhysicalPrimary () || mcParticle.producedByGenerator ();
255266 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);
267+ mcpi0Table (bc.globalIndex (), convertForStorage<uint16_t >(mcParticle.pt (), kpT), isAccepted (mcParticle, mcParticles), isPrimary, isFromWD);
268+ fMapPi0Index [mcParticle.globalIndex ()] = static_cast <int32_t >(mcpi0Table.lastIndex ());
257269 }
258270 }
259271
@@ -266,6 +278,7 @@ struct bcWiseClusterSkimmer {
266278 processClusters (clustersInBC, bcTable.lastIndex ());
267279 processClusterMCInfo (clustersInBC, bc.globalIndex (), mcParticles);
268280 }
281+ fMapPi0Index .clear ();
269282 }
270283 }
271284 PROCESS_SWITCH (bcWiseClusterSkimmer, processMC, " Run skimming for MC" , false );
0 commit comments