2020#include " Common/DataModel/Multiplicity.h"
2121#include " Common/DataModel/EventSelection.h"
2222#include " Common/DataModel/TrackSelectionTables.h"
23+ #include " Common/Core/TrackSelection.h"
2324#include " Framework/HistogramRegistry.h"
2425#include " Framework/StaticFor.h"
26+ #include " TDatabasePDG.h"
2527#include < TH1F.h>
2628#include < TH2F.h>
2729#include < TF1.h>
@@ -37,13 +39,16 @@ using namespace o2::framework::expressions;
3739
3840struct ueCharged {
3941
40- float DeltaPhi ( float phia, float phib, float rangeMin, float rangeMax );
42+ TrackSelection myTrackSelection ( );
4143
44+ Service<TDatabasePDG> pdg;
45+ float DeltaPhi (float phia, float phib, float rangeMin, float rangeMax);
46+ Configurable<bool > isRun3{" isRun3" , true , " is Run3 dataset" };
4247 // acceptance cuts
43- Configurable<float > cfgTrkEtaCut{" cfgTrkEtaCut" , 1 . 5f , " Eta range for tracks" };
48+ Configurable<float > cfgTrkEtaCut{" cfgTrkEtaCut" , 0 . 8f , " Eta range for tracks" };
4449 Configurable<float > cfgTrkLowPtCut{" cfgTrkLowPtCut" , 0 .15f , " Minimum constituent pT" };
4550
46- HistogramRegistry ue; // {"ue", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
51+ HistogramRegistry ue;
4752 static constexpr std::string_view pNumDenMeasuredPS[3 ] = {" pNumDenMeasuredPS_NS" , " pNumDenMeasuredPS_AS" , " pNumDenMeasuredPS_TS" };
4853 static constexpr std::string_view pSumPtMeasuredPS[3 ] = {" pSumPtMeasuredPS_NS" , " pSumPtMeasuredPS_AS" , " pSumPtMeasuredPS_TS" };
4954 static constexpr std::string_view hPhi[3 ] = {" hPhi_NS" , " hPhi_AS" , " hPhi_TS" };
@@ -62,6 +67,9 @@ struct ueCharged {
6267 template <bool IS_MC , typename C, typename T>
6368 void processMeas (const C& collision, const T& tracks);
6469
70+ template <typename C, typename P>
71+ void processTrue (const C& collision, const P& particles);
72+
6573 Filter trackFilter = (nabs(aod::track::eta) < cfgTrkEtaCut) && (aod::track::pt > cfgTrkLowPtCut);
6674
6775 using CollisionTableData = soa::Join<aod::Collisions, aod::EvSels>;
@@ -70,11 +78,11 @@ struct ueCharged {
7078 PROCESS_SWITCH (ueCharged, processData, " process data" , false );
7179
7280 using CollisionTableMCTrue = aod::McCollisions;
73- using CollisionTableMC = soa::Join<aod::Collisions, aod::EvSels>;
81+ using CollisionTableMC = soa::SmallGroups<soa:: Join<aod::McCollisionLabels, aod:: Collisions, aod::EvSels> >;
7482 using TrackTableMC = soa::Filtered<soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::McTrackLabels, aod::TrackSelection>>;
7583 using ParticleTableMC = aod::McParticles;
7684 Preslice<TrackTableMC> perCollision = aod::track::collisionId;
77- void processMC (CollisionTableMC ::iterator const & collision, TrackTableMC const & tracks);
85+ void processMC (CollisionTableMCTrue ::iterator const & mcCollision, CollisionTableMC const & collisions, TrackTableMC const & tracks, ParticleTableMC const & particles );
7886 PROCESS_SWITCH (ueCharged, processMC, " process mc" , false );
7987};
8088WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
@@ -120,6 +128,17 @@ void ueCharged::init(InitContext const&)
120128
121129 f_Eff.setObject (new TF1 (" fpara" , " (x<0.22)*((-0.770334)+(6.32178)*x)+(x>=0.22&&x<0.4)*((0.310721)+(2.02610)*x+(-2.25005)*x*x)+(x>=0.4&&x<1.0)*((1.21232)+(-1.27511)*x+(0.588435)*x*x)+(x>=1.0&&x<5.5)*((0.502911)+(0.0416893)*x)+(x>=5.5)*(0.709143)" , 0.15 , 50.0 ));
122130
131+ if (doprocessMC) {
132+ ue.add (" hPtOut" , " pT all rec; pT; Nch" , HistType::kTH1D , {ptAxis});
133+ ue.add (" hPtInPrim" , " pT mc prim; pT; Nch" , HistType::kTH1D , {ptAxis});
134+ ue.add (" hPtOutPrim" , " pT rec prim; pT; Nch" , HistType::kTH1D , {ptAxis});
135+ ue.add (" hPtOutSec" , " pT rec sec; pT; Nch" , HistType::kTH1D , {ptAxis});
136+ ue.add (" hPtDCAall" , " all MC; DCA_xy; Nch" , HistType::kTH2D , {{ptAxis}, {121 , -3.025 , 3.025 , " #it{DCA}_{xy} (cm)" }});
137+ ue.add (" hPtDCAPrimary" , " primary; DCA_xy; Nch" , HistType::kTH2D , {{ptAxis}, {121 , -3.025 , 3.025 , " #it{DCA}_{xy} (cm)" }});
138+ ue.add (" hPtDCAWeak" , " Weak decays; DCA_xy; Nch" , HistType::kTH2D , {{ptAxis}, {121 , -3.025 , 3.025 , " #it{DCA}_{xy} (cm)" }});
139+ ue.add (" hPtDCAMat" , " Material; DCA_xy; Nch" , HistType::kTH2D , {{ptAxis}, {121 , -3.025 , 3.025 , " #it{DCA}_{xy} (cm)" }});
140+ }
141+
123142 ue.add (" hStat" , " TotalEvents" , HistType::kTH1F , {{1 , 0.5 , 1.5 , " " }});
124143 ue.add (" hdNdeta" , " dNdeta" , HistType::kTH1F , {{50 , -2.5 , 2.5 , " " }});
125144 ue.add (" vtxZEta" , " ;#eta;vtxZ" , HistType::kTH2F , {{50 , -2.5 , 2.5 , " " }, {60 , -30 , 30 , " " }});
@@ -151,27 +170,81 @@ void ueCharged::init(InitContext const&)
151170 ue.add (" hPTVsDCAData" , " " , HistType::kTH2D , {{ptAxis}, {121 , -3.025 , 3.025 , " #it{DCA}_{xy} (cm)" }});
152171}
153172
154- void ueCharged::processMC (CollisionTableMC ::iterator const & collision, TrackTableMC const & tracks)
173+ void ueCharged::processMC (CollisionTableMCTrue ::iterator const & mcCollision, CollisionTableMC const & collisions, TrackTableMC const & tracks, ParticleTableMC const & particles )
155174{
156- processMeas<true >(collision, tracks);
175+ if (collisions.size () != 0 ) {
176+ for (auto & collision : collisions) {
177+ auto curTracks = tracks.sliceBy (perCollision, collision.globalIndex ());
178+ processMeas<true >(collision, curTracks);
179+ break ; // for now look only at first collision...
180+ }
181+ }
182+ processTrue (mcCollision, particles);
157183}
158184
159185void ueCharged::processData (CollisionTableData::iterator const & collision, TrackTableData const & tracks)
160186{
161187 processMeas<false >(collision, tracks);
162188}
189+ template <typename C, typename P>
190+ void ueCharged::processTrue (const C& collision, const P& particles)
191+ {
192+
193+ int multTrue = 0 ;
194+ for (auto & particle : particles) {
195+ auto pdgParticle = pdg->GetParticle (particle.pdgCode ());
196+ if (!pdgParticle || pdgParticle->Charge () == 0 .) {
197+ continue ;
198+ }
199+ if (!particle.isPhysicalPrimary ()) {
200+ continue ;
201+ }
202+ if (std::abs (particle.eta ()) >= cfgTrkEtaCut) {
203+ continue ;
204+ }
205+
206+ multTrue++;
207+ }
208+ if (!((std::abs (collision.posZ ()) < 10 .f ) && (multTrue > 0 ))) {
209+ return ;
210+ }
211+
212+ for (auto & particle : particles) {
213+ auto pdgParticle = pdg->GetParticle (particle.pdgCode ());
214+ if (!pdgParticle || pdgParticle->Charge () == 0 .) {
215+ continue ;
216+ }
217+ if (!particle.isPhysicalPrimary ()) {
218+ continue ;
219+ }
220+ if (std::abs (particle.eta ()) >= cfgTrkEtaCut) {
221+ continue ;
222+ }
223+ ue.fill (HIST (" hPtInPrim" ), particle.pt ());
224+ }
225+ }
226+
163227template <bool IS_MC , typename C, typename T>
164228void ueCharged::processMeas (const C& collision, const T& tracks)
165229{
166230
167231 ue.fill (HIST (" hCounter" ), 0 );
168232
169- ue.fill (HIST (" hCounter" ), 1 );
233+ bool isAcceptedEvent = false ;
234+ if (std::abs (collision.posZ ()) < 10 .f ) {
235+ ue.fill (HIST (" hCounter" ), 1 );
236+ if (isRun3 ? collision.sel8 () : collision.sel7 ()) {
237+ if ((isRun3 || doprocessMC) ? true : collision.alias ()[kINT7 ]) {
238+ isAcceptedEvent = true ;
239+ }
240+ }
241+ }
170242
171- ue.fill (HIST (" hStat" ), collision.size ());
172- if (TMath::Abs (collision.posZ ()) > 10.0 ) {
243+ if (!isAcceptedEvent) {
173244 return ;
174245 }
246+
247+ ue.fill (HIST (" hStat" ), collision.size ());
175248 auto vtxZ = collision.posZ ();
176249
177250 ue.fill (HIST (" hCounter" ), 2 );
@@ -211,13 +284,41 @@ void ueCharged::processMeas(const C& collision, const T& tracks)
211284
212285 for (auto & track : tracks) {
213286
214- if (track. isGlobalTrack ( )) { // TODO: set cuts w/o DCA cut
287+ if (myTrackSelection (). IsSelected (track )) { // TODO: set cuts w/o DCA cut
215288 ue.fill (HIST (" hPTVsDCAData" ), track.pt (), track.dcaXY ());
216289 }
217- if (!track.isGlobalTrack ()) {
218- continue ;
290+ if constexpr (IS_MC ) {
291+ if (track.has_mcParticle ()) {
292+ if (track.isGlobalTrack ()) {
293+ ue.fill (HIST (" hPtOut" ), track.pt ());
294+ }
295+ if (myTrackSelection ().IsSelected (track)) {
296+ ue.fill (HIST (" hPtDCAall" ), track.pt (), track.dcaXY ());
297+ }
298+ const auto & particle = track.template mcParticle_as <aod::McParticles>();
299+ if (particle.isPhysicalPrimary ()) {
300+
301+ if (track.isGlobalTrack ()) {
302+ ue.fill (HIST (" hPtOutPrim" ), track.pt ());
303+ }
304+ if (myTrackSelection ().IsSelected (track)) {
305+ ue.fill (HIST (" hPtDCAPrimary" ), track.pt (), track.dcaXY ());
306+ }
307+ // LOGP(info, "this track has MC particle {}", 1);
308+ } else {
309+ if (track.isGlobalTrack ()) {
310+ ue.fill (HIST (" hPtOutSec" ), track.pt ());
311+ }
312+ if (myTrackSelection ().IsSelected (track)) {
313+ if (particle.getGenStatusCode () >= 0 ) { // i guess these are decays
314+ ue.fill (HIST (" hPtDCAWeak" ), track.pt (), track.dcaXY ());
315+ } else { // i guess these are from material
316+ ue.fill (HIST (" hPtDCAMat" ), track.pt (), track.dcaXY ());
317+ }
318+ }
319+ }
320+ }
219321 }
220-
221322 // applying the efficiency twice for the misrec of leading particle
222323 if (f_Eff->Eval (track.pt ()) > gRandom ->Uniform (0 , 1 )) {
223324 ptArray.push_back (track.pt ());
@@ -336,3 +437,20 @@ void ueCharged::processMeas(const C& collision, const T& tracks)
336437 phiArray.clear ();
337438 indexArray.clear ();
338439}
440+ TrackSelection ueCharged::myTrackSelection ()
441+ {
442+ TrackSelection selectedTracks;
443+ selectedTracks.SetPtRange (0 .1f , 1e10f);
444+ selectedTracks.SetEtaRange (-0 .8f , 0 .8f );
445+ selectedTracks.SetRequireITSRefit (true );
446+ selectedTracks.SetRequireTPCRefit (true );
447+ selectedTracks.SetRequireGoldenChi2 (false );
448+ selectedTracks.SetMinNCrossedRowsTPC (70 );
449+ selectedTracks.SetMinNCrossedRowsOverFindableClustersTPC (0 .8f );
450+ selectedTracks.SetMaxChi2PerClusterTPC (4 .f );
451+ selectedTracks.SetRequireHitsInITSLayers (1 , {0 , 1 }); // one hit in any SPD layer
452+ selectedTracks.SetMaxChi2PerClusterITS (36 .f );
453+ selectedTracks.SetMaxDcaXY (10 .f );
454+ selectedTracks.SetMaxDcaZ (10 .f );
455+ return selectedTracks;
456+ }
0 commit comments