@@ -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