1313// / it is meant to be a blank page for further developments.
1414// / \author everyone
1515
16- #include " Framework/runDataProcessing.h"
17- #include " Framework/AnalysisTask.h"
1816#include " Common/DataModel/TrackSelectionTables.h"
17+
1918#include " Framework/ASoAHelpers.h"
19+ #include " Framework/AnalysisTask.h"
20+ #include " Framework/runDataProcessing.h"
2021
2122#include < TPDGCode.h> // for PDG codes
2223
@@ -34,7 +35,7 @@ struct myExampleTask {
3435
3536 Filter trackDCA = nabs(aod::track::dcaXY) < maxDCAxy;
3637
37- // This is an example of a convenient declaration of "using"
38+ // This is an example of a convenient declaration of "using"
3839 using myCompleteTracksMC = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::McTrackLabels>;
3940 using myCompleteTracks = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA>;
4041 using myFilteredTracksMC = soa::Filtered<myCompleteTracksMC>;
@@ -62,29 +63,34 @@ struct myExampleTask {
6263 histos.add (" ptGeneratedKaon" , " ptGeneratedKaon" , kTH1F , {axisPt});
6364 histos.add (" ptGeneratedProton" , " ptGeneratedProton" , kTH1F , {axisPt});
6465
65- histos.add (" numberOfRecoCollisions" , " numberOfRecoCollisions" , kTH1F , {{10 ,-0 .5f , 9 .5f }});
66- histos.add (" multiplicityCorrelation" , " multiplicityCorrelations" , kTH2F , {{100 , -0 .5f , 99 .5f }, {100 ,-0 .5f , 99 .5f }});
66+ histos.add (" numberOfRecoCollisions" , " numberOfRecoCollisions" , kTH1F , {{10 , -0 .5f , 9 .5f }});
67+ histos.add (" multiplicityCorrelation" , " multiplicityCorrelations" , kTH2F , {{100 , -0 .5f , 99 .5f }, {100 , -0 .5f , 99 .5f }});
6768 }
6869
6970 template <bool fillResolution = true , typename TCollision, typename TTracks>
70- void processStuff (TCollision const & collision, TTracks const & tracks) {
71+ void processStuff (TCollision const & collision, TTracks const & tracks)
72+ {
7173 histos.fill (HIST (" eventCounter" ), 0 .5f );
7274 for (const auto & track : tracks) {
73- if ( track.tpcNClsCrossedRows () < minTPCCrossedRows ) continue ; // badly tracked
75+ if (track.tpcNClsCrossedRows () < minTPCCrossedRows)
76+ continue ; // badly tracked
7477 histos.fill (HIST (" etaHistogram" ), track.eta ());
7578 histos.fill (HIST (" ptHistogram" ), track.pt ());
7679
7780 // this part only done if dealing with MC
78- if constexpr (requires { track.has_mcParticle (); }) { // does the getter exist?
79- if (track.has_mcParticle ()){ // is the return 'true'? -> N.B. different question!
80- auto mcParticle = track.mcParticle ();
81- if constexpr (fillResolution){ // compile-time check
81+ if constexpr (requires { track.has_mcParticle (); }) { // does the getter exist?
82+ if (track.has_mcParticle ()) { // is the return 'true'? -> N.B. different question!
83+ auto mcParticle = track.mcParticle ();
84+ if constexpr (fillResolution) { // compile-time check
8285 histos.fill (HIST (" ptResolution" ), track.pt (), track.pt () - mcParticle.pt ());
8386 }
84- if (mcParticle.isPhysicalPrimary () && fabs (mcParticle.y ())<0.5 ){ // do this in the context of the track ! (context matters!!!)
85- if (abs (mcParticle.pdgCode ())==kPiPlus ) histos.fill (HIST (" ptHistogramPion" ), mcParticle.pt ());
86- if (abs (mcParticle.pdgCode ())==kKPlus ) histos.fill (HIST (" ptHistogramKaon" ), mcParticle.pt ());
87- if (abs (mcParticle.pdgCode ())==kProton ) histos.fill (HIST (" ptHistogramProton" ), mcParticle.pt ());
87+ if (mcParticle.isPhysicalPrimary () && fabs (mcParticle.y ()) < 0.5 ) { // do this in the context of the track ! (context matters!!!)
88+ if (abs (mcParticle.pdgCode ()) == kPiPlus )
89+ histos.fill (HIST (" ptHistogramPion" ), mcParticle.pt ());
90+ if (abs (mcParticle.pdgCode ()) == kKPlus )
91+ histos.fill (HIST (" ptHistogramKaon" ), mcParticle.pt ());
92+ if (abs (mcParticle.pdgCode ()) == kProton )
93+ histos.fill (HIST (" ptHistogramProton" ), mcParticle.pt ());
8894 }
8995 }
9096 }
@@ -93,35 +99,39 @@ struct myExampleTask {
9399
94100 void processRecoInData (aod::Collision const & collision, myFilteredTracks const & tracks)
95101 {
96- processStuff (collision, tracks);
102+ processStuff (collision, tracks);
97103 }
98104 PROCESS_SWITCH (myExampleTask, processRecoInData, " process reconstructed information" , true );
99105
100106 void processRecoInSim (aod::Collision const & collision, myFilteredTracksMC const & tracks, aod::McParticles const &)
101107 {
102- processStuff (collision, tracks);
108+ processStuff (collision, tracks);
103109 }
104110 PROCESS_SWITCH (myExampleTask, processRecoInSim, " process reconstructed information" , false );
105111
106112 void processSim (aod::McCollision const & mcCollision, soa::SmallGroups<soa::Join<aod::McCollisionLabels, aod::Collisions>> const & collisions, aod::McParticles const & mcParticles, myFilteredTracksMC const & tracks)
107113 {
108114 histos.fill (HIST (" numberOfRecoCollisions" ), collisions.size ()); // number of times coll was reco-ed
109115
110- // Now loop over each time this collision has been reconstructed and aggregate tracks
116+ // Now loop over each time this collision has been reconstructed and aggregate tracks
111117 std::vector<int > numberOfTracks;
112118 for (auto & collision : collisions) {
113119 auto groupedTracks = tracks.sliceBy (perCollision, collision.globalIndex ());
114120 // size of grouped tracks may help in understanding why event was split!
115121 numberOfTracks.emplace_back (groupedTracks.size ());
116122 }
117- if ( collisions.size () == 2 ) histos.fill (HIST (" multiplicityCorrelation" ), numberOfTracks[0 ], numberOfTracks[1 ]);
123+ if (collisions.size () == 2 )
124+ histos.fill (HIST (" multiplicityCorrelation" ), numberOfTracks[0 ], numberOfTracks[1 ]);
118125
119- // Loop over particles in this mcCollision (first argument of process: iterator)
126+ // Loop over particles in this mcCollision (first argument of process: iterator)
120127 for (const auto & mcParticle : mcParticles) {
121- if (mcParticle.isPhysicalPrimary () && fabs (mcParticle.y ())<0.5 ){ // do this in the context of the MC loop ! (context matters!!!)
122- if (abs (mcParticle.pdgCode ())==kPiPlus ) histos.fill (HIST (" ptGeneratedPion" ), mcParticle.pt ());
123- if (abs (mcParticle.pdgCode ())==kKPlus ) histos.fill (HIST (" ptGeneratedKaon" ), mcParticle.pt ());
124- if (abs (mcParticle.pdgCode ())==kProton ) histos.fill (HIST (" ptGeneratedProton" ), mcParticle.pt ());
128+ if (mcParticle.isPhysicalPrimary () && fabs (mcParticle.y ()) < 0.5 ) { // do this in the context of the MC loop ! (context matters!!!)
129+ if (abs (mcParticle.pdgCode ()) == kPiPlus )
130+ histos.fill (HIST (" ptGeneratedPion" ), mcParticle.pt ());
131+ if (abs (mcParticle.pdgCode ()) == kKPlus )
132+ histos.fill (HIST (" ptGeneratedKaon" ), mcParticle.pt ());
133+ if (abs (mcParticle.pdgCode ()) == kProton )
134+ histos.fill (HIST (" ptGeneratedProton" ), mcParticle.pt ());
125135 }
126136 }
127137 }
@@ -132,4 +142,4 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
132142{
133143 return WorkflowSpec{
134144 adaptAnalysisTask<myExampleTask>(cfgc)};
135- }
145+ }
0 commit comments