@@ -57,24 +57,28 @@ struct HmpidTableProducer {
5757
5858 Produces<aod::HmpidAnalysis> hmpidAnalysis;
5959
60- // using TrackCandidates = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection>;
60+ // configurable for quality requirements
61+ Configurable<bool > requireITS{" requireITS" , true , " Require ITS track" };
62+ Configurable<bool > requireTPC{" requireTPC" , true , " Require TPC track" };
63+ Configurable<bool > requireTOF{" requireTOF" , true , " Require TOF track" };
6164
62- using CollisionCandidates = o2::soa::Join<o2:: aod::Collisions, o2:: aod::EvSels >;
65+ using CollisionCandidates = o2::soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFV0As >;
6366
6467 using TrackCandidates = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection,
6568 aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, aod::pidTPCFullDe,
6669 aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr, aod::pidTOFFullDe>;
6770
68- // using CentralityClass = o2::soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFV0As>;
69-
7071 void init (o2::framework::InitContext&)
7172 {
7273 // Configure CCDB
7374 ccdb->setURL (ccdbConfig.ccdbUrl );
7475 ccdb->setCaching (true );
7576 ccdb->setLocalObjectValidityChecking ();
77+ ccdb->setFatalWhenNull (false );
7678
7779 histos.add (" eventCounter" , " eventCounter" , kTH1F , {axisEvtCounter});
80+ histos.add (" goodEventCounter" , " goodEventCounter" , kTH1F , {axisEvtCounter});
81+ histos.add (" eventsHmpid" , " eventsWithHmpid" , kTH1F , {axisEvtCounter});
7882 }
7983
8084 // function to manage ccdb
@@ -87,50 +91,75 @@ struct HmpidTableProducer {
8791 mCCDBRunNumber = bc.runNumber ();
8892 }
8993
90- void process (soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFV0As>::iterator const & col,
91- const aod::HMPIDs& hmpids,
92- TrackCandidates const &,
93- aod::BCsWithTimestamps const &)
94+ void processEvent (CollisionCandidates::iterator const & col,
95+ aod::BCsWithTimestamps const &)
9496 {
9597 histos.fill (HIST (" eventCounter" ), 0.5 );
98+ if (col.sel8 ()) {
99+ histos.fill (HIST (" goodEventCounter" ), 0.5 );
100+ }
96101
102+ // initialize CCDB for current BC
97103 initCCDB (col.bc_as <aod::BCsWithTimestamps>());
104+ }
105+ PROCESS_SWITCH (HmpidTableProducer, processEvent, " Process event level - collisions" , true );
106+
107+ void processHmpid (
108+ aod::HMPIDs const & hmpids,
109+ TrackCandidates const &,
110+ CollisionCandidates const &,
111+ aod::BCsWithTimestamps const &)
112+ {
113+ // --- Static set to track unique collisions with HMPID tracks ---
114+ static std::unordered_set<uint32_t > collisionsWithHmpid;
98115
99- for (const auto & t : hmpids) {
116+ for (auto const & t : hmpids) {
100117
101- // global tracks associated to hmpid tracks
118+ // Access the global track associated to the HMPID track
102119 const auto & globalTrack = t.track_as <TrackCandidates>();
103- if (!globalTrack.isGlobalTrack ())
104- continue ;
105- if (!globalTrack.hasITS () || !globalTrack.hasTPC () || !globalTrack.hasTOF ())
120+
121+ if (!globalTrack.has_collision ())
106122 continue ;
107123
108- // verify accessible collision
109- if (!globalTrack.has_collision ()) {
124+ // Access the associated collision
125+ const auto & col = globalTrack.collision_as <CollisionCandidates>();
126+ initCCDB (col.bc_as <aod::BCsWithTimestamps>());
127+ uint32_t collId = col.globalIndex ();
128+
129+ // --- Track quality selection ---
130+ if ((requireITS && !globalTrack.hasITS ()) ||
131+ (requireTPC && !globalTrack.hasTPC ()) ||
132+ (requireTOF && !globalTrack.hasTOF ())) {
110133 continue ;
111134 }
112135
136+ // Count collisions with at least one valid HMPID track
137+ if (collisionsWithHmpid.insert (collId).second ) {
138+ histos.fill (HIST (" eventsHmpid" ), 0.5 );
139+ }
140+
141+ float centrality = col.centFV0A ();
142+
113143 float hmpidPhotsCharge2[o2::aod::kDimPhotonsCharge ];
114144
115145 for (int i = 0 ; i < o2::aod::kDimPhotonsCharge ; i++) {
116146 hmpidPhotsCharge2[i] = t.hmpidPhotsCharge ()[i];
117147 }
118148
119- float centrality = col.centFV0A ();
120-
121- // ///FILL TABLE
122- hmpidAnalysis (
123- t.hmpidSignal (), globalTrack.phi (), globalTrack.eta (), t.hmpidMom (),
124- globalTrack.p (), t.hmpidXTrack (), t.hmpidYTrack (), t.hmpidXMip (),
125- t.hmpidYMip (), t.hmpidNPhotons (), t.hmpidQMip (), (t.hmpidClusSize () % 1000000 ) / 1000 ,
126- t.hmpidClusSize () / 1000000 , hmpidPhotsCharge2, globalTrack.eta (), globalTrack.phi (),
127- globalTrack.px (), globalTrack.py (), globalTrack.pz (), globalTrack.itsNCls (),
128- globalTrack.tpcNClsFound (), globalTrack.tpcNClsCrossedRows (), globalTrack.tpcChi2NCl (), globalTrack.itsChi2NCl (),
129- globalTrack.dcaXY (), globalTrack.dcaZ (), globalTrack.tpcNSigmaPi (), globalTrack.tofNSigmaPi (),
130- globalTrack.tpcNSigmaKa (), globalTrack.tofNSigmaKa (), globalTrack.tpcNSigmaPr (), globalTrack.tofNSigmaPr (),
131- globalTrack.tpcNSigmaDe (), globalTrack.tofNSigmaDe (), centrality);
132- }
149+ // ///FILL HMPID CUSTOM TABLE
150+ hmpidAnalysis (t.hmpidSignal (), t.hmpidMom (),
151+ globalTrack.p (), t.hmpidXTrack (), t.hmpidYTrack (), t.hmpidXMip (),
152+ t.hmpidYMip (), t.hmpidNPhotons (), t.hmpidQMip (), (t.hmpidClusSize () % 1000000 ) / 1000 ,
153+ t.hmpidClusSize () / 1000000 , hmpidPhotsCharge2, globalTrack.eta (), globalTrack.phi (),
154+ globalTrack.px (), globalTrack.py (), globalTrack.pz (), globalTrack.itsNCls (),
155+ globalTrack.tpcNClsFound (), globalTrack.tpcNClsCrossedRows (), globalTrack.tpcChi2NCl (), globalTrack.itsChi2NCl (),
156+ globalTrack.dcaXY (), globalTrack.dcaZ (), globalTrack.tpcNSigmaPi (), globalTrack.tofNSigmaPi (),
157+ globalTrack.tpcNSigmaKa (), globalTrack.tofNSigmaKa (), globalTrack.tpcNSigmaPr (), globalTrack.tofNSigmaPr (),
158+ globalTrack.tpcNSigmaDe (), globalTrack.tofNSigmaDe (), centrality);
159+ } // end loop on hmpid table entries
133160 }
161+
162+ PROCESS_SWITCH (HmpidTableProducer, processHmpid, " Process hmpid entries - tracks" , true );
134163};
135164
136165WorkflowSpec defineDataProcessing (ConfigContext const & cfg) { return WorkflowSpec{adaptAnalysisTask<HmpidTableProducer>(cfg)}; }
0 commit comments