@@ -140,6 +140,7 @@ struct EmcalCorrectionTask {
140140 Configurable<bool > applyGainCalibShift{" applyGainCalibShift" , false , " Apply shift for cell gain calibration to use values before cell format change (Sept. 2023)" };
141141 Configurable<bool > applySoftwareTriggerSelection{" applySoftwareTriggerSelection" , false , " Apply software trigger selection" };
142142 Configurable<std::string> softwareTriggerSelection{" softwareTriggerSelection" , " fGammaHighPtEMCAL,fGammaHighPtDCAL" , " Default: fGammaHighPtEMCAL,fGammaHighPtDCAL" };
143+ Configurable<bool > storePerDFInfo{" storePerDFInfo" , false , " store addition information per DF." };
143144 // cross talk emulation configs
144145 EmcCrossTalkConf emcCrossTalkConf;
145146
@@ -198,6 +199,11 @@ struct EmcalCorrectionTask {
198199 static constexpr float TrackNotOnEMCal = -900 .f;
199200 static constexpr int kMaxMatchesPerCluster = 20 ; // Maximum number of tracks to match per cluster
200201
202+ // cluster size
203+ size_t nCluster = 0 ;
204+ size_t nClusterAmb = 0 ;
205+ size_t nCells = 0 ;
206+
201207 void init (InitContext const &)
202208 {
203209 LOG (debug) << " Start init!" ;
@@ -305,6 +311,7 @@ struct EmcalCorrectionTask {
305311 sigmaLongAxis{100 , 0 ., 1.0 , " #sigma^{2}_{long}" },
306312 sigmaShortAxis{100 , 0 ., 1.0 , " #sigma^{2}_{short}" },
307313 nCellAxis{60 , -0.5 , 59.5 , " #it{n}_{cells}" },
314+ nClusterAxis{10001 , -0.5 , 10000.5 , " #it{N}_{cluster}" },
308315 energyDenseAxis = {7000 , 0 .f , 70 .f , " #it{E}_{cell} (GeV)" };
309316 o2::framework::AxisSpec axisDeltaEta{400 , -0.2 , 0.2 , " #Delta#eta" };
310317 o2::framework::AxisSpec axisDeltaPhi{400 , -0.2 , 0.2 , " #Delta#varphi (rad)" };
@@ -379,6 +386,12 @@ struct EmcalCorrectionTask {
379386 mExtraTimeShiftRunRanges .emplace_back (536565 , 536590 ); // Commisioning-LHC23r
380387 mExtraTimeShiftRunRanges .emplace_back (542280 , 543854 ); // LHC23zv-LHC23zy
381388 mExtraTimeShiftRunRanges .emplace_back (559544 , 559856 ); // PbPb 2024
389+
390+ if (storePerDFInfo.value ) {
391+ mHistManager .add (" hNClusterDF" , " hNClusterDF" , O2HistType::kTH1D , {nClusterAxis});
392+ mHistManager .add (" hNClusterAmbigousDF" , " hNClusterAmbigousDF" , O2HistType::kTH1D , {nClusterAxis});
393+ mHistManager .add (" hNCellDF" , " hNCellDF" , O2HistType::kTH1D , {nClusterAxis});
394+ }
382395 }
383396
384397 template <typename BCType>
@@ -404,6 +417,9 @@ struct EmcalCorrectionTask {
404417 int nCellsProcessed = 0 ;
405418 std::unordered_map<uint64_t , int > numberCollsInBC; // Number of collisions mapped to the global BC index of all BCs
406419 std::unordered_map<uint64_t , int > numberCellsInBC; // Number of cells mapped to the global BC index of all BCs to check whether EMCal was readout
420+ nCluster = 0 ;
421+ nClusterAmb = 0 ;
422+ nCells = 0 ;
407423 for (const auto & bc : bcs) {
408424 LOG (debug) << " Next BC" ;
409425
@@ -539,6 +555,11 @@ struct EmcalCorrectionTask {
539555 } // end of collision loop
540556
541557 LOG (detail) << " Processed " << nBCsProcessed << " BCs with " << nCellsProcessed << " cells" ;
558+ if (storePerDFInfo) {
559+ mHistManager .fill (HIST (" hNClusterDF" ), nCluster);
560+ mHistManager .fill (HIST (" hNClusterAmbigousDF" ), nClusterAmb);
561+ mHistManager .fill (HIST (" hNCellDF" ), nCells);
562+ }
542563 }
543564 PROCESS_SWITCH (EmcalCorrectionTask, processFull, " run full analysis" , true );
544565
@@ -551,6 +572,10 @@ struct EmcalCorrectionTask {
551572 int nCellsProcessed = 0 ;
552573 std::unordered_map<uint64_t , int > numberCollsInBC; // Number of collisions mapped to the global BC index of all BCs
553574 std::unordered_map<uint64_t , int > numberCellsInBC; // Number of cells mapped to the global BC index of all BCs to check whether EMCal was readout
575+
576+ nCluster = 0 ;
577+ nClusterAmb = 0 ;
578+ nCells = 0 ;
554579 for (const auto & bc : bcs) {
555580 LOG (debug) << " Next BC" ;
556581
@@ -690,6 +715,11 @@ struct EmcalCorrectionTask {
690715 } // end of collision loop
691716
692717 LOG (detail) << " Processed " << nBCsProcessed << " BCs with " << nCellsProcessed << " cells" ;
718+ if (storePerDFInfo) {
719+ mHistManager .fill (HIST (" hNClusterDF" ), nCluster);
720+ mHistManager .fill (HIST (" hNClusterAmbigousDF" ), nClusterAmb);
721+ mHistManager .fill (HIST (" hNCellDF" ), nCells);
722+ }
693723 }
694724 PROCESS_SWITCH (EmcalCorrectionTask, processWithSecondaries, " run full analysis with secondary track matching" , false );
695725
@@ -702,6 +732,11 @@ struct EmcalCorrectionTask {
702732 int nCellsProcessed = 0 ;
703733 std::unordered_map<uint64_t , int > numberCollsInBC; // Number of collisions mapped to the global BC index of all BCs
704734 std::unordered_map<uint64_t , int > numberCellsInBC; // Number of cells mapped to the global BC index of all BCs to check whether EMCal was readout
735+
736+ nCluster = 0 ;
737+ nClusterAmb = 0 ;
738+ nCells = 0 ;
739+
705740 for (const auto & bc : bcs) {
706741 LOG (debug) << " Next BC" ;
707742 // Convert aod::Calo to o2::emcal::Cell which can be used with the clusterizer.
@@ -868,6 +903,11 @@ struct EmcalCorrectionTask {
868903 } // end of collision loop
869904
870905 LOG (detail) << " Processed " << nBCsProcessed << " BCs with " << nCellsProcessed << " cells" ;
906+ if (storePerDFInfo) {
907+ mHistManager .fill (HIST (" hNClusterDF" ), nCluster);
908+ mHistManager .fill (HIST (" hNClusterAmbigousDF" ), nClusterAmb);
909+ mHistManager .fill (HIST (" hNCellDF" ), nCells);
910+ }
871911 }
872912 PROCESS_SWITCH (EmcalCorrectionTask, processMCFull, " run full analysis with MC info" , false );
873913
@@ -880,6 +920,10 @@ struct EmcalCorrectionTask {
880920 int nCellsProcessed = 0 ;
881921 std::unordered_map<uint64_t , int > numberCollsInBC; // Number of collisions mapped to the global BC index of all BCs
882922 std::unordered_map<uint64_t , int > numberCellsInBC; // Number of cells mapped to the global BC index of all BCs to check whether EMCal was readout
923+
924+ nCluster = 0 ;
925+ nClusterAmb = 0 ;
926+ nCells = 0 ;
883927 for (const auto & bc : bcs) {
884928 LOG (debug) << " Next BC" ;
885929 // Convert aod::Calo to o2::emcal::Cell which can be used with the clusterizer.
@@ -1049,6 +1093,11 @@ struct EmcalCorrectionTask {
10491093 } // end of collision loop
10501094
10511095 LOG (detail) << " Processed " << nBCsProcessed << " BCs with " << nCellsProcessed << " cells" ;
1096+ if (storePerDFInfo) {
1097+ mHistManager .fill (HIST (" hNClusterDF" ), nCluster);
1098+ mHistManager .fill (HIST (" hNClusterAmbigousDF" ), nClusterAmb);
1099+ mHistManager .fill (HIST (" hNCellDF" ), nCells);
1100+ }
10521101 }
10531102 PROCESS_SWITCH (EmcalCorrectionTask, processMCWithSecondaries, " run full analysis with MC info" , false );
10541103
@@ -1059,6 +1108,10 @@ struct EmcalCorrectionTask {
10591108 int nBCsProcessed = 0 ;
10601109 int nCellsProcessed = 0 ;
10611110
1111+ nCluster = 0 ;
1112+ nClusterAmb = 0 ;
1113+ nCells = 0 ;
1114+
10621115 for (const auto & bc : bcs) {
10631116 LOG (debug) << " Next BC" ;
10641117 // Convert aod::Calo to o2::emcal::Cell which can be used with the clusterizer.
@@ -1165,6 +1218,11 @@ struct EmcalCorrectionTask {
11651218 nBCsProcessed++;
11661219 } // end of bc loop
11671220 LOG (debug) << " Done with process BC." ;
1221+ if (storePerDFInfo) {
1222+ mHistManager .fill (HIST (" hNClusterDF" ), nCluster);
1223+ mHistManager .fill (HIST (" hNClusterAmbigousDF" ), nClusterAmb);
1224+ mHistManager .fill (HIST (" hNCellDF" ), nCells);
1225+ }
11681226 }
11691227 PROCESS_SWITCH (EmcalCorrectionTask, processStandalone, " run stand alone analysis" , false );
11701228
@@ -1210,13 +1268,14 @@ struct EmcalCorrectionTask {
12101268 void fillClusterTable (Collision const & col, math_utils::Point3D<float > const & vertexPos, size_t iClusterizer, const gsl::span<int64_t > cellIndicesBC, MatchResult* indexMapPair = nullptr , const std::vector<int64_t >* trackGlobalIndex = nullptr , MatchResult* indexMapPairSecondaries = nullptr , const std::vector<int64_t >* secondariesGlobalIndex = nullptr )
12111269 {
12121270 // average number of cells per cluster, only used the reseve a reasonable amount for the clustercells table
1213- const size_t nAvgNcells = 3 ;
1271+ // const size_t nAvgNcells = 3;
12141272 // we found a collision, put the clusters into the none ambiguous table
1215- clusters.reserve (mAnalysisClusters .size ());
1273+ clusters.reserve (nCluster + mAnalysisClusters .size ());
12161274 if (!mClusterLabels .empty ()) {
1217- mcclusters.reserve (mClusterLabels .size ());
1275+ mcclusters.reserve (nCluster + mClusterLabels .size ());
12181276 }
1219- clustercells.reserve (mAnalysisClusters .size () * nAvgNcells);
1277+ // Since reserve triggers a fatal when its too small, it is not save for cells to use it unless we use a really large buffer...
1278+ // clustercells.reserve(mAnalysisClusters.size() * nAvgNcells);
12201279
12211280 // get the clusterType once
12221281 const auto clusterType = static_cast <int >(mClusterDefinitions [iClusterizer]);
@@ -1253,6 +1312,7 @@ struct EmcalCorrectionTask {
12531312 cluster.getClusterTime (), cluster.getIsExotic (),
12541313 cluster.getDistanceToBadChannel (), cluster.getNExMax (),
12551314 clusterType);
1315+ ++nCluster;
12561316 if (!mClusterLabels .empty ()) {
12571317 mcclusters (mClusterLabels [iCluster].getLabels (), mClusterLabels [iCluster].getEnergyFractions ());
12581318 }
@@ -1262,6 +1322,7 @@ struct EmcalCorrectionTask {
12621322 LOG (debug) << " trying to find cell index " << cellindex << " in map" ;
12631323 if (cellIndicesBC[cellindex] >= 0 ) {
12641324 clustercells (clusters.lastIndex (), cellIndicesBC[cellindex]);
1325+ ++nCells;
12651326 }
12661327 } // end of cells of cluser loop
12671328 // fill histograms
@@ -1305,13 +1366,13 @@ struct EmcalCorrectionTask {
13051366 void fillAmbigousClusterTable (BC const & bc, size_t iClusterizer, const gsl::span<int64_t > cellIndicesBC, bool hasCollision)
13061367 {
13071368 // average number of cells per cluster, only used the reseve a reasonable amount for the clustercells table
1308- const size_t nAvgNcells = 3 ;
1369+ // const size_t nAvgNcells = 3;
13091370 int cellindex = -1 ;
1310- clustersAmbiguous.reserve (mAnalysisClusters .size ());
1371+ clustersAmbiguous.reserve (mAnalysisClusters .size () + nClusterAmb );
13111372 if (mClusterLabels .size () > 0 ) {
1312- mcclustersAmbiguous.reserve (mClusterLabels .size ());
1373+ mcclustersAmbiguous.reserve (mClusterLabels .size () + nClusterAmb );
13131374 }
1314- clustercellsambiguous.reserve (mAnalysisClusters .size () * nAvgNcells);
1375+ // clustercellsambiguous.reserve(mAnalysisClusters.size() * nAvgNcells);
13151376 unsigned int iCluster = 0 ;
13161377 float energy = 0 .f ;
13171378 for (const auto & cluster : mAnalysisClusters ) {
@@ -1343,6 +1404,7 @@ struct EmcalCorrectionTask {
13431404 cluster.getM20 (), cluster.getNCells (), cluster.getClusterTime (),
13441405 cluster.getIsExotic (), cluster.getDistanceToBadChannel (),
13451406 cluster.getNExMax (), static_cast <int >(mClusterDefinitions .at (iClusterizer)));
1407+ ++nClusterAmb;
13461408 if (mClusterLabels .size () > 0 ) {
13471409 mcclustersAmbiguous (mClusterLabels [iCluster].getLabels (), mClusterLabels [iCluster].getEnergyFractions ());
13481410 }
0 commit comments