@@ -75,7 +75,8 @@ struct PseudorapidityDensityMFT {
7575 Configurable<long > nolaterthan{" ccdb-no-later-than" , std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count (), " latest acceptable timestamp of creation for the object" };
7676
7777 // the histogram has been previously stored in the CCDB
78- TH2F* histoReweight = nullptr ;
78+ TH1D* histoReweight = nullptr ;
79+ std::vector<long long unsigned > ambTrackIds;
7980 // ------
8081
8182 HistogramRegistry registry{
@@ -134,7 +135,7 @@ struct PseudorapidityDensityMFT {
134135 // This avoids that users can replace objects **while** a train is running
135136 ccdb->setCreatedNotAfter (nolaterthan.value );
136137 LOGF (info, " Getting object %s" , path.value .data ());
137- histoReweight = ccdb->getForTimeStamp <TH2F >(path.value , nolaterthan.value );
138+ histoReweight = ccdb->getForTimeStamp <TH1D >(path.value , nolaterthan.value );
138139 if (!histoReweight) {
139140 LOGF (fatal, " object not found!" );
140141 }
@@ -179,6 +180,7 @@ struct PseudorapidityDensityMFT {
179180
180181 void processMult (soa::Join<aod::Collisions, aod::EvSels>::iterator const & collision, aod::MFTTracks const & tracks, soa::SmallGroups<soa::Join<aod::AmbiguousMFTTracks, aod::BestCollisionsFwd>> const & atracks)
181182 {
183+ ambTrackIds.clear ();
182184 if (tracks.size () == 0 ) {
183185 return ;
184186 }
@@ -190,7 +192,23 @@ struct PseudorapidityDensityMFT {
190192 auto Ntrk = perCollisionSample.size () + atracks.size ();
191193
192194 registry.fill (HIST (" EventsNtrkZvtx" ), Ntrk, z);
195+ for (auto & track : atracks) {
196+ registry.fill (HIST (" TracksEtaZvtx" ), track.etas (), z);
197+ float phi = track.phis ();
198+ o2::math_utils::bringTo02Pi (phi);
199+ registry.fill (HIST (" TracksPhiEta" ), phi, track.etas ());
200+ registry.fill (HIST (" TracksPhiZvtx" ), phi, z);
201+ registry.fill (HIST (" TracksPtEta" ), track.pts (), track.etas ());
202+ auto mfttrack = track.mfttrack ();
203+ if (mfttrack.has_collision ()) {
204+ ambTrackIds.push_back (track.mfttrackId ());
205+ }
206+ }
207+
193208 for (auto & track : tracks) {
209+ if (find (ambTrackIds.begin (), ambTrackIds.end (), track.globalIndex ()) != ambTrackIds.end ()) {
210+ continue ; // this track has already been reassigned to bestcollision, don't double count
211+ }
194212 registry.fill (HIST (" TracksEtaZvtx" ), track.eta (), z);
195213 float phi = track.phi ();
196214 o2::math_utils::bringTo02Pi (phi);
@@ -200,14 +218,7 @@ struct PseudorapidityDensityMFT {
200218 registry.fill (HIST (" TracksPhiZvtx" ), phi, z);
201219 }
202220 }
203- for (auto & track : atracks) {
204- registry.fill (HIST (" TracksEtaZvtx" ), track.etas (), z);
205- float phi = track.phis ();
206- o2::math_utils::bringTo02Pi (phi);
207- registry.fill (HIST (" TracksPhiEta" ), phi, track.etas ());
208- registry.fill (HIST (" TracksPhiZvtx" ), phi, z);
209- registry.fill (HIST (" TracksPtEta" ), track.pts (), track.etas ());
210- }
221+
211222 } else {
212223 registry.fill (HIST (" EventSelection" ), 4 .);
213224 }
@@ -216,6 +227,7 @@ struct PseudorapidityDensityMFT {
216227
217228 void processMultReweight (soa::Join<aod::Collisions, aod::EvSels>::iterator const & collision, aod::MFTTracks const & tracks, soa::SmallGroups<soa::Join<aod::AmbiguousMFTTracks, aod::BestCollisionsFwd>> const & atracks)
218229 {
230+ ambTrackIds.clear ();
219231 if (!doprocessGen) {
220232 LOGP (debug, " You can't enable processMultReweight if not analysing MC" );
221233 return ;
@@ -230,20 +242,9 @@ struct PseudorapidityDensityMFT {
230242 auto perCollisionSample = sample->sliceByCached (o2::aod::fwdtrack::collisionId, collision.globalIndex ());
231243 auto Ntrk = perCollisionSample.size () + atracks.size ();
232244 float weight = 1 .;
245+ weight = histoReweight->GetBinContent (histoReweight->FindBin (z));
233246
234- registry.fill (HIST (" EventsNtrkZvtx" ), Ntrk, z);
235- for (auto & track : tracks) {
236-
237- float phi = track.phi ();
238- o2::math_utils::bringTo02Pi (phi);
239- weight = histoReweight->GetBinContent (histoReweight->FindBin (phi, z));
240- registry.fill (HIST (" TracksEtaZvtx" ), track.eta (), z, weight);
241- registry.fill (HIST (" TracksPhiEta" ), phi, track.eta (), weight);
242- registry.fill (HIST (" TracksPtEta" ), track.pt (), track.eta (), weight);
243- if ((track.eta () < -2 .0f ) && (track.eta () > -3 .9f )) {
244- registry.fill (HIST (" TracksPhiZvtx" ), phi, z, weight);
245- }
246- }
247+ registry.fill (HIST (" EventsNtrkZvtx" ), Ntrk, z, weight);
247248 for (auto & track : atracks) {
248249
249250 float phi = track.phis ();
@@ -254,7 +255,26 @@ struct PseudorapidityDensityMFT {
254255 registry.fill (HIST (" TracksPhiEta" ), phi, track.etas (), weight);
255256 registry.fill (HIST (" TracksPhiZvtx" ), phi, z, weight);
256257 registry.fill (HIST (" TracksPtEta" ), track.pts (), track.etas (), weight);
258+ auto mfttrack = track.mfttrack ();
259+ if (mfttrack.has_collision ()) {
260+ ambTrackIds.push_back (track.mfttrackId ());
261+ }
257262 }
263+
264+ for (auto & track : tracks) {
265+ if (find (ambTrackIds.begin (), ambTrackIds.end (), track.globalIndex ()) != ambTrackIds.end ()) {
266+ continue ; // this track has already been reassigned to bestcollision, don't double count
267+ }
268+ float phi = track.phi ();
269+ o2::math_utils::bringTo02Pi (phi);
270+ registry.fill (HIST (" TracksEtaZvtx" ), track.eta (), z, weight);
271+ registry.fill (HIST (" TracksPhiEta" ), phi, track.eta (), weight);
272+ registry.fill (HIST (" TracksPtEta" ), track.pt (), track.eta (), weight);
273+ if ((track.eta () < -2 .0f ) && (track.eta () > -3 .9f )) {
274+ registry.fill (HIST (" TracksPhiZvtx" ), phi, z, weight);
275+ }
276+ }
277+
258278 } else {
259279 registry.fill (HIST (" EventSelection" ), 4 .);
260280 }
0 commit comments