3737
3838#include " Math/Vector4D.h"
3939
40+ #include < map>
4041#include < string>
4142#include < unordered_map>
4243#include < utility>
@@ -104,6 +105,7 @@ struct skimmerPrimaryElectron {
104105 Configurable<float > maxpt_itssa{" maxpt_itssa" , 0.15 , " max pt for ITSsa track" };
105106 Configurable<float > maxMeanITSClusterSize{" maxMeanITSClusterSize" , 16 , " max <ITS cluster size> x cos(lambda)" };
106107 Configurable<bool > storeOnlyTrueElectronMC{" storeOnlyTrueElectronMC" , false , " Flag to store only true electron in MC" };
108+ Configurable<int > minNelectron{" minNelectron" , 0 , " min number of electron candidates per collision" };
107109
108110 // configuration for PID ML
109111 Configurable<bool > usePIDML{" usePIDML" , false , " Flag to use PID ML" };
@@ -176,6 +178,7 @@ struct skimmerPrimaryElectron {
176178 fRegistry .add (" Track/hMeanClusterSizeITSib" , " mean cluster size ITSib;p_{pv} (GeV/c);<ITSib cluster size> #times cos(#lambda)" , kTH2F , {{1000 , 0 , 10 }, {150 , 0 , 15 }}, false );
177179 fRegistry .add (" Track/hMeanClusterSizeITSob" , " mean cluster size ITSob;p_{pv} (GeV/c);<ITSob cluster size> #times cos(#lambda)" , kTH2F , {{1000 , 0 , 10 }, {150 , 0 , 15 }}, false );
178180 fRegistry .add (" Track/hProbElBDT" , " probability to be e from BDT;p_{in} (GeV/c);BDT score;" , kTH2F , {{1000 , 0 , 10 }, {100 , 0 , 1 }}, false );
181+ fRegistry .add (" Track/hNe" , " electron counts;N_{e} per collision" , kTH1F , {{51 , -0.5 , 50.5 }}, false );
179182 }
180183
181184 if (usePIDML) {
@@ -498,7 +501,6 @@ struct skimmerPrimaryElectron {
498501 track.beta (), track.tofNSigmaEl (), /* track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(),*/
499502 track.itsClusterSizes (),
500503 track.itsChi2NCl (), track.tofChi2 (), track.detectorMap (),
501- // trackParCov.getTgl(),
502504 isAssociatedToMPC, false , probaEl, mcTunedTPCSignal);
503505
504506 emprimaryelectronscov (
@@ -601,6 +603,9 @@ struct skimmerPrimaryElectron {
601603 Partition<MyFilteredTracks> posTracks = o2::aod::track::signed1Pt > 0 .f;
602604 Partition<MyFilteredTracks> negTracks = o2::aod::track::signed1Pt < 0 .f;
603605
606+ std::map<std::pair<int , int >, float > mapProbEl; // map pair(collisionId, trackId) -> probaEl
607+ std::unordered_multimap<int , int > multiMapTracksPerCollision; // collisionId -> trackIds
608+
604609 // ---------- for data ----------
605610
606611 void processRec_SA (MyCollisions const & collisions, aod::BCsWithTimestamps const &, MyFilteredTracks const & tracks)
@@ -624,12 +629,26 @@ struct skimmerPrimaryElectron {
624629 if (!isElectron (collision, track, probaEl)) {
625630 continue ;
626631 }
627-
628- fillTrackTable< false >( collision, track, probaEl );
632+ mapProbEl[ std::make_pair (collision. globalIndex (), track. globalIndex ())] = probaEl;
633+ multiMapTracksPerCollision. insert ( std::make_pair ( collision. globalIndex () , track. globalIndex ()) );
629634 }
635+ } // end of collision loop
630636
637+ for (const auto & collision : collisions) {
638+ int count_electrons = multiMapTracksPerCollision.count (collision.globalIndex ());
639+ fRegistry .fill (HIST (" Track/hNe" ), count_electrons);
640+
641+ if (count_electrons >= minNelectron) {
642+ auto range_electrons = multiMapTracksPerCollision.equal_range (collision.globalIndex ());
643+ for (auto it = range_electrons.first ; it != range_electrons.second ; it++) {
644+ auto track = tracks.rawIteratorAt (it->second );
645+ fillTrackTable<false >(collision, track, mapProbEl[std::make_pair (collision.globalIndex (), track.globalIndex ())]);
646+ }
647+ }
631648 } // end of collision loop
632649
650+ mapProbEl.clear ();
651+ multiMapTracksPerCollision.clear ();
633652 stored_trackIds.clear ();
634653 stored_trackIds.shrink_to_fit ();
635654 }
@@ -658,10 +677,25 @@ struct skimmerPrimaryElectron {
658677 if (!isElectron (collision, track, probaEl)) {
659678 continue ;
660679 }
661- fillTrackTable<false >(collision, track, probaEl);
680+ mapProbEl[std::make_pair (collision.globalIndex (), track.globalIndex ())] = probaEl;
681+ }
682+ } // end of collision loop
683+
684+ for (const auto & collision : collisions) {
685+ int count_electrons = multiMapTracksPerCollision.count (collision.globalIndex ());
686+ fRegistry .fill (HIST (" Track/hNe" ), count_electrons);
687+
688+ if (count_electrons >= minNelectron) {
689+ auto range_electrons = multiMapTracksPerCollision.equal_range (collision.globalIndex ());
690+ for (auto it = range_electrons.first ; it != range_electrons.second ; it++) {
691+ auto track = tracks.rawIteratorAt (it->second );
692+ fillTrackTable<false >(collision, track, mapProbEl[std::make_pair (collision.globalIndex (), track.globalIndex ())]);
693+ }
662694 }
663695 } // end of collision loop
664696
697+ mapProbEl.clear ();
698+ multiMapTracksPerCollision.clear ();
665699 stored_trackIds.clear ();
666700 stored_trackIds.shrink_to_fit ();
667701 }
@@ -692,11 +726,26 @@ struct skimmerPrimaryElectron {
692726 if (!isElectron (collision, track, probaEl)) {
693727 continue ;
694728 }
695- fillTrackTable< false > (collision, track, probaEl) ;
729+ mapProbEl[ std::make_pair (collision. globalIndex () , track. globalIndex ())] = probaEl;
696730 }
697731
698732 } // end of collision loop
699733
734+ for (const auto & collision : collisions) {
735+ int count_electrons = multiMapTracksPerCollision.count (collision.globalIndex ());
736+ fRegistry .fill (HIST (" Track/hNe" ), count_electrons);
737+
738+ if (count_electrons >= minNelectron) {
739+ auto range_electrons = multiMapTracksPerCollision.equal_range (collision.globalIndex ());
740+ for (auto it = range_electrons.first ; it != range_electrons.second ; it++) {
741+ auto track = tracks.rawIteratorAt (it->second );
742+ fillTrackTable<false >(collision, track, mapProbEl[std::make_pair (collision.globalIndex (), track.globalIndex ())]);
743+ }
744+ }
745+ } // end of collision loop
746+
747+ mapProbEl.clear ();
748+ multiMapTracksPerCollision.clear ();
700749 stored_trackIds.clear ();
701750 stored_trackIds.shrink_to_fit ();
702751 }
@@ -728,10 +777,25 @@ struct skimmerPrimaryElectron {
728777 if (!isElectron (collision, track, probaEl)) {
729778 continue ;
730779 }
731- fillTrackTable< false > (collision, track, probaEl) ;
780+ mapProbEl[ std::make_pair (collision. globalIndex () , track. globalIndex ())] = probaEl;
732781 }
733782 } // end of collision loop
734783
784+ for (const auto & collision : collisions) {
785+ int count_electrons = multiMapTracksPerCollision.count (collision.globalIndex ());
786+ fRegistry .fill (HIST (" Track/hNe" ), count_electrons);
787+
788+ if (count_electrons >= minNelectron) {
789+ auto range_electrons = multiMapTracksPerCollision.equal_range (collision.globalIndex ());
790+ for (auto it = range_electrons.first ; it != range_electrons.second ; it++) {
791+ auto track = tracks.rawIteratorAt (it->second );
792+ fillTrackTable<false >(collision, track, mapProbEl[std::make_pair (collision.globalIndex (), track.globalIndex ())]);
793+ }
794+ }
795+ } // end of collision loop
796+
797+ mapProbEl.clear ();
798+ multiMapTracksPerCollision.clear ();
735799 stored_trackIds.clear ();
736800 stored_trackIds.shrink_to_fit ();
737801 }
@@ -766,10 +830,25 @@ struct skimmerPrimaryElectron {
766830 if (!isElectron (collision, track, probaEl)) {
767831 continue ;
768832 }
769- fillTrackTable< true > (collision, track, probaEl) ;
833+ mapProbEl[ std::make_pair (collision. globalIndex () , track. globalIndex ())] = probaEl;
770834 }
771835 } // end of collision loop
772836
837+ for (const auto & collision : collisions) {
838+ int count_electrons = multiMapTracksPerCollision.count (collision.globalIndex ());
839+ fRegistry .fill (HIST (" Track/hNe" ), count_electrons);
840+
841+ if (count_electrons >= minNelectron) {
842+ auto range_electrons = multiMapTracksPerCollision.equal_range (collision.globalIndex ());
843+ for (auto it = range_electrons.first ; it != range_electrons.second ; it++) {
844+ auto track = tracks.rawIteratorAt (it->second );
845+ fillTrackTable<true >(collision, track, mapProbEl[std::make_pair (collision.globalIndex (), track.globalIndex ())]);
846+ }
847+ }
848+ } // end of collision loop
849+
850+ mapProbEl.clear ();
851+ multiMapTracksPerCollision.clear ();
773852 stored_trackIds.clear ();
774853 stored_trackIds.shrink_to_fit ();
775854 }
@@ -801,10 +880,25 @@ struct skimmerPrimaryElectron {
801880 if (!isElectron (collision, track, probaEl)) {
802881 continue ;
803882 }
804- fillTrackTable<true >(collision, track, probaEl);
883+ mapProbEl[std::make_pair (collision.globalIndex (), track.globalIndex ())] = probaEl;
884+ }
885+ } // end of collision loop
886+
887+ for (const auto & collision : collisions) {
888+ int count_electrons = multiMapTracksPerCollision.count (collision.globalIndex ());
889+ fRegistry .fill (HIST (" Track/hNe" ), count_electrons);
890+
891+ if (count_electrons >= minNelectron) {
892+ auto range_electrons = multiMapTracksPerCollision.equal_range (collision.globalIndex ());
893+ for (auto it = range_electrons.first ; it != range_electrons.second ; it++) {
894+ auto track = tracks.rawIteratorAt (it->second );
895+ fillTrackTable<true >(collision, track, mapProbEl[std::make_pair (collision.globalIndex (), track.globalIndex ())]);
896+ }
805897 }
806898 } // end of collision loop
807899
900+ mapProbEl.clear ();
901+ multiMapTracksPerCollision.clear ();
808902 stored_trackIds.clear ();
809903 stored_trackIds.shrink_to_fit ();
810904 }
@@ -882,7 +976,7 @@ struct prefilterPrimaryElectron {
882976 fRegistry .add (" Track/hEtaPhi" , " #eta vs. #varphi;#varphi (rad.);#eta" , kTH2F , {{90 , 0 , 2 * M_PI}, {80 , -2 .0f , 2 .0f }}, false );
883977 fRegistry .add (" Track/hTPCNsigmaEl" , " loose track TPC PID" , kTH2F , {{1000 , 0 .f , 10 }, {100 , -5 , +5 }});
884978 fRegistry .add (" Pair/before/uls/hMvsPt" , " mass vs. pT;m_{ee} (GeV/c^{2});p_{T,ee} (GeV/c)" , kTH2F , {{500 , 0 , 0.5 }, {100 , 0 , 1 }});
885- fRegistry .add (" Pair/before/uls/hMvsPhiV" , " mass vs. phiv;#varphi_{V} (rad.);m_{ee} (GeV/c^{2})" , kTH2F , {{90 , 0 .f , M_PI}, {100 , 0 , 1.0 }});
979+ fRegistry .add (" Pair/before/uls/hMvsPhiV" , " mass vs. phiv;#varphi_{V} (rad.);m_{ee} (GeV/c^{2})" , kTH2F , {{90 , 0 .f , M_PI}, {100 , 0 , 0.1 }});
886980 fRegistry .addClone (" Pair/before/uls/" , " Pair/before/lspp/" );
887981 fRegistry .addClone (" Pair/before/uls/" , " Pair/before/lsmm/" );
888982 fRegistry .addClone (" Pair/before/" , " Pair/after/" );
0 commit comments