1+ #include " PWGJE/Core/JetDerivedDataUtilities.h"
2+ #include " PWGJE/DataModel/Jet.h"
3+ #include " PWGJE/DataModel/JetReducedData.h"
4+
5+ #include < Framework/AnalysisTask.h>
6+ #include < Framework/Configurable.h>
7+ #include < Framework/runDataProcessing.h>
8+ #include " Framework/O2DatabasePDGPlugin.h"
9+
10+ #include < vector>
11+ #include < cmath>
12+
13+ using namespace o2 ;
14+ using namespace o2 ::framework;
15+ using namespace o2 ::framework::expressions;
16+
17+ namespace o2 ::aod
18+ {
19+ namespace tree
20+ {
21+ DECLARE_SOA_COLUMN (ZVTX , zvtx, float );
22+ DECLARE_SOA_COLUMN (WEIGHT , weight, float );
23+ DECLARE_SOA_COLUMN (PTHAT , ptHat, float );
24+ DECLARE_SOA_COLUMN (MULTIPLICITY , multiplicity, float );
25+
26+ DECLARE_SOA_COLUMN (DETPt, detPt, std::vector<float >);
27+ DECLARE_SOA_COLUMN (DETEta, detEta, std::vector<float >);
28+ DECLARE_SOA_COLUMN (DETPhi, detPhi, std::vector<float >);
29+ DECLARE_SOA_COLUMN (DETCharge, detCharge, std::vector<int >);
30+
31+ DECLARE_SOA_COLUMN (TruthPt, truthPt, std::vector<float >);
32+ DECLARE_SOA_COLUMN (TruthEta, truthEta, std::vector<float >);
33+ DECLARE_SOA_COLUMN (TruthPhi, truthPhi, std::vector<float >);
34+ DECLARE_SOA_COLUMN (TruthE, truthE, std::vector<float >);
35+ DECLARE_SOA_COLUMN (PDG , pdg, std::vector<int >);
36+ }
37+
38+ DECLARE_SOA_TABLE (TREE , " AOD" , " TREE" ,
39+ tree::ZVTX ,
40+ tree::WEIGHT ,
41+ tree::PTHAT ,
42+ tree::MULTIPLICITY ,
43+ tree::DETPt,
44+ tree::DETEta,
45+ tree::DETPhi,
46+ tree::DETCharge,
47+ tree::TruthPt,
48+ tree::TruthEta,
49+ tree::TruthPhi,
50+ tree::TruthE,
51+ tree::PDG );
52+ }
53+
54+ struct EECTreeCreatorTask
55+ {
56+ Service<o2::framework::O2DatabasePDG> pdg;
57+
58+ Configurable<float > vertexZCut{" vertexZCut" , 10 .0f , " vertex Z cut" };
59+
60+ Configurable<std::string> eventSelections{" eventSelections" , " sel8" , " " };
61+ Configurable<std::string> trackSelections{" trackSelections" , " globalTracks" , " " };
62+
63+ Produces<aod::TREE > tree;
64+
65+ std::vector<int > eventSelectionBits;
66+ int trackSelection = -1 ;
67+
68+ Preslice<aod::JMcParticles> particlesPerMcCollision = aod::jmcparticle::mcCollisionId;
69+
70+ bool isChargedParticle (int code)
71+ {
72+ const float chargeUnit = 3 .;
73+ auto p = pdg->GetParticle (code);
74+ auto charge = 0 .;
75+ if (p != nullptr ) {
76+ charge = p->Charge ();
77+ }
78+ return std::abs (charge) >= chargeUnit;
79+ }
80+
81+ void init (InitContext const &)
82+ {
83+ eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits (eventSelections);
84+ trackSelection = jetderiveddatautilities::initialiseTrackSelection (trackSelections);
85+ }
86+
87+ void processMC (aod::JetCollisionsMCD::iterator const & collision, aod::JetTracks const & tracks, aod::JMcParticles const & mcParticles,aod::JetMcCollisions const &)
88+ {
89+ if (!jetderiveddatautilities::selectCollision (collision, eventSelectionBits)) return ;
90+ if (std::abs (collision.posZ ()) > vertexZCut) return ;
91+
92+ float w = collision.has_mcCollision () ? collision.mcCollision ().weight () : 1 .f ;
93+ float pthard = collision.has_mcCollision () ? collision.mcCollision ().ptHard () : 1 .f ;
94+
95+ std::vector<float > detPt, detEta, detPhi;
96+ std::vector<int > detCharge;
97+
98+ std::vector<float > truthPt, truthEta, truthPhi, truthE;
99+ std::vector<int > pdg;
100+
101+ for (auto const & track : tracks)
102+ {
103+ if (!jetderiveddatautilities::selectTrack (track, trackSelection)) continue ;
104+
105+ if ( fabs (track.eta ()) > 0.9 ) continue ;
106+ if ( track.pt () < 0.15 ) continue ;
107+
108+ detPt.push_back (track.pt ());
109+ detEta.push_back (track.eta ());
110+ detPhi.push_back (track.phi ());
111+ detCharge.push_back (track.sign ());
112+
113+ }
114+
115+ int mcId = collision.has_mcCollision () ? collision.mcCollisionId () : -1 ;
116+
117+ if (mcId >= 0 )
118+ {
119+ auto particles = mcParticles.sliceBy (particlesPerMcCollision, mcId);
120+
121+ for (auto const & p : particles)
122+ {
123+ if ( !p.isPhysicalPrimary ()) continue ;
124+ if ( fabs (p.eta ()) > 0.9 ) continue ;
125+ if ( p.pt () < 0.15 ) continue ;
126+ if ( !isChargedParticle (p.pdgCode ())) continue ;
127+
128+ truthPt.push_back (p.pt ());
129+ truthEta.push_back (p.eta ());
130+ truthPhi.push_back (p.phi ());
131+ truthE.push_back (p.e ());
132+ pdg.push_back (p.pdgCode ());
133+ }
134+ }
135+
136+ tree ( collision.posZ (), w, pthard, collision.multFT0C (), detPt, detEta, detPhi, detCharge, truthPt, truthEta, truthPhi, truthE, pdg);}
137+
138+ PROCESS_SWITCH (EECTreeCreatorTask, processMC, " MC processing" , true );
139+ };
140+
141+ WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
142+ {
143+ return WorkflowSpec{ adaptAnalysisTask<EECTreeCreatorTask>(cfgc, TaskName{" eec-tree-creator-mc" })};
144+ }
0 commit comments