1313//
1414// Author: Jochen Klein, Nima Zardoshti, Raymond Ehlers
1515
16- #include " Framework/AnalysisTask.h"
17- #include " Framework/AnalysisDataModel.h"
18- #include " Framework/ASoA.h"
19- #include " Framework/O2DatabasePDGPlugin.h"
20-
21- #include " Common/Core/TrackSelection.h"
22- #include " Common/Core/TrackSelectionDefaults.h"
23- #include " Common/DataModel/EventSelection.h"
24- #include " Common/DataModel/TrackSelectionTables.h"
25- #include " Common/Core/RecoDecay.h"
26- #include " PWGJE/DataModel/EMCALClusters.h"
27-
28- #include " PWGJE/DataModel/Jet.h"
29- #include " PWGJE/Core/JetFinder.h"
30- #include " PWGJE/Core/FastJetUtilities.h"
16+ #include " PWGJE/TableProducer/jetfinder.h"
3117
3218using namespace o2 ;
3319using namespace o2 ::framework;
@@ -50,11 +36,6 @@ struct JetFinderTask {
5036 OutputObj<TH1F > hJetNTracks{" h_jet_ntracks" };
5137
5238 Service<O2DatabasePDG> pdg;
53- TrackSelection globalTracks;
54-
55- std::vector<fastjet::PseudoJet> jets;
56- std::vector<fastjet::PseudoJet> inputParticles;
57- JetFinder jetFinder;
5839
5940 // event level configurables
6041 Configurable<float > vertexZCut{" vertexZCut" , 10 .0f , " Accepted z-vertex range" };
@@ -94,10 +75,14 @@ struct JetFinderTask {
9475
9576 void init (InitContext const &)
9677 {
97- if (static_cast <std::string>(trackSelections) == " globalTracks" ) {
98- globalTracks = getGlobalTrackSelection ();
99- globalTracks.SetEtaRange (trackEtaMin, trackEtaMax);
100- }
78+ // variables passed to the common header
79+ trackEtaMin_ = static_cast <float >(trackEtaMin);
80+ trackEtaMax_ = static_cast <float >(trackEtaMax);
81+ jetRadius_ = static_cast <std::vector<double >>(jetRadius);
82+ DoConstSub_ = static_cast <bool >(DoConstSub);
83+
84+ trackSelection = static_cast <std::string>(trackSelections);
85+ jetTypeParticleLevelCheck = jetTypeParticleLevel;
10186
10287 h2JetPt.setObject (new TH2F (" h2_jet_pt" , " jet p_{T};p_{T} (GeV/#it{c})" ,
10388 100 , 0 ., 100 ., 10 , 0.05 , 1.05 ));
@@ -142,119 +127,43 @@ struct JetFinderTask {
142127 Filter trackCuts = (aod::track::pt >= trackPtMin && aod::track::pt < trackPtMax && aod::track::eta > trackEtaMin && aod::track::eta < trackEtaMax && aod::track::phi >= trackPhiMin && aod::track::phi <= trackPhiMax); // do we need eta cut both here and in globalselection?
143128 Filter partCuts = (aod::mcparticle::pt >= trackPtMin && aod::mcparticle::pt < trackPtMax);
144129 Filter clusterFilter = (o2::aod::emcalcluster::definition == static_cast <int >(clusterDefinition) && aod::emcalcluster::eta > clusterEtaMin && aod::emcalcluster::eta < clusterEtaMax && aod::emcalcluster::phi >= clusterPhiMin && aod::emcalcluster::phi <= clusterPhiMax && aod::emcalcluster::energy >= clusterEnergyMin && aod::emcalcluster::time > clusterTimeMin && aod::emcalcluster::time < clusterTimeMax && (clusterRejectExotics && aod::emcalcluster::isExotic != true ));
145- using JetTracks = soa::Filtered<soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection>>;
146- using JetClusters = o2::soa::Filtered<o2::aod::EMCALClusters>;
147-
148- // function that performs track selections on each track
149- template <typename T>
150- bool processTrackSelection (T const & track)
151- {
152- if (static_cast <std::string>(trackSelections) == " globalTracks" && !globalTracks.IsSelected (track)) {
153- return false ;
154- } else if (static_cast <std::string>(trackSelections) == " QualityTracks" && !track.isQualityTrack ()) {
155- return false ;
156- } else {
157- return true ;
158- }
159- }
160-
161- // function that adds tracks to the fastjet list
162- template <typename T>
163- void processTracks (T const & tracks)
164- {
165- for (auto & track : tracks) {
166- if (!processTrackSelection (track)) {
167- continue ;
168- }
169- FastJetUtilities::fillTracks (track, inputParticles, track.globalIndex ());
170- }
171- }
172-
173- // function that adds clusters to the fastjet list
174- template <typename T>
175- void processClusters (T const & clusters)
176- {
177- for (auto & cluster : *clusters) {
178- // add cluster selections
179- FastJetUtilities::fillClusters (cluster, inputParticles, cluster.globalIndex ());
180- }
181- }
182-
183- // function that calls the jet finding and fills the relevant tables
184- template <typename T>
185- void jetFinding (T const & collision)
186- {
187- auto jetRValues = static_cast <std::vector<double >>(jetRadius);
188- for (auto R : jetRValues) {
189- jetFinder.jetR = R;
190- jets.clear ();
191- fastjet::ClusterSequenceArea clusterSeq (jetFinder.findJets (inputParticles, jets));
192- for (const auto & jet : jets) {
193- std::vector<int > trackconst;
194- std::vector<int > clusterconst;
195- jetsTable (collision, jet.pt (), jet.eta (), jet.phi (),
196- jet.E (), jet.m (), jet.area (), std::round (R * 100 ));
197- for (const auto & constituent : sorted_by_pt (jet.constituents ())) {
198- // need to add seperate thing for constituent subtraction
199- if (DoConstSub) { // FIXME: needs to be addressed in Haadi's PR
200- constituentsSubTable (jetsTable.lastIndex (), constituent.pt (), constituent.eta (), constituent.phi (),
201- constituent.E (), constituent.m (), constituent.user_index ());
202- }
203-
204- if (constituent.template user_info <FastJetUtilities::fastjet_user_info>().getStatus () == static_cast <int >(JetConstituentStatus::track)) {
205- trackconst.push_back (constituent.template user_info <FastJetUtilities::fastjet_user_info>().getIndex ());
206- }
207- if (constituent.template user_info <FastJetUtilities::fastjet_user_info>().getStatus () == static_cast <int >(JetConstituentStatus::cluster)) {
208- clusterconst.push_back (constituent.template user_info <FastJetUtilities::fastjet_user_info>().getIndex ());
209- }
210- }
211- constituentsTable (jetsTable.lastIndex (), trackconst, clusterconst, std::vector<int >());
212- h2JetPt->Fill (jet.pt (), R);
213- h2JetPhi->Fill (jet.phi (), R);
214- h2JetEta->Fill (jet.rap (), R);
215- h2JetNTracks->Fill (jet.constituents ().size (), R);
216- hJetPt->Fill (jet.pt ());
217- hJetPhi->Fill (jet.phi ());
218- hJetEta->Fill (jet.rap ());
219- hJetNTracks->Fill (jet.constituents ().size ());
220- }
221- }
222- }
223130
224131 void processDummy (aod::Collisions const & collision)
225132 {
226133 }
227134
228135 PROCESS_SWITCH (JetFinderTask, processDummy, " Dummy process function turned on by default" , true );
229136
230- void processDataCharged (soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const & collision,
137+ void processChargedJets (soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const & collision,
231138 JetTracks const & tracks)
232139 {
233- if (!collision. sel8 ( )) {
140+ if (!selectCollision (collision )) {
234141 return ;
235142 }
143+
236144 LOG (debug) << " Process data charged!" ;
237145 inputParticles.clear ();
238- processTracks (tracks);
239- jetFinding (collision);
146+ using ArgType = std::decay_t <decltype (tracks)>;
147+ analyseTracks<ArgType, typename ArgType::iterator>(tracks);
148+ findJets (collision, jetsTable, constituentsTable, constituentsSubTable);
240149 }
241150
242- PROCESS_SWITCH (JetFinderTask, processDataCharged , " Data jet finding for charged jets" , false );
151+ PROCESS_SWITCH (JetFinderTask, processChargedJets , " Data jet finding for charged jets" , false );
243152
244- void processDataNeutral (soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const & collision,
153+ void processNeutralJets (soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const & collision,
245154 JetClusters const & clusters)
246155 {
247156 if (!collision.alias ()[kTVXinEMC ]) {
248157 return ;
249158 }
250159 LOG (debug) << " Process data neutral!" ;
251160 inputParticles.clear ();
252- processClusters (&clusters);
253- jetFinding (collision);
161+ analyseClusters (&clusters);
162+ findJets (collision, jetsTable, constituentsTable, constituentsSubTable );
254163 }
255- PROCESS_SWITCH (JetFinderTask, processDataNeutral , " Data jet finding for neutral jets" , false );
164+ PROCESS_SWITCH (JetFinderTask, processNeutralJets , " Data jet finding for neutral jets" , false );
256165
257- void processDataFull (soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const & collision,
166+ void processFullJets (soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const & collision,
258167 JetTracks const & tracks,
259168 JetClusters const & clusters)
260169 {
@@ -263,56 +172,44 @@ struct JetFinderTask {
263172 }
264173 LOG (debug) << " Process data full!" ;
265174 inputParticles.clear ();
266- processTracks (tracks);
267- processClusters (&clusters);
268- jetFinding (collision);
175+ using ArgType = std::decay_t <decltype (tracks)>;
176+ analyseTracks<ArgType, typename ArgType::iterator>(tracks);
177+ analyseClusters (&clusters);
178+ findJets (collision, jetsTable, constituentsTable, constituentsSubTable);
269179 }
270180
271- PROCESS_SWITCH (JetFinderTask, processDataFull , " Data jet finding for full and neutral jets" , false );
181+ PROCESS_SWITCH (JetFinderTask, processFullJets , " Data jet finding for full and neutral jets" , false );
272182
273- void processParticleLevel (aod::McCollision const & collision, aod::McParticles const & particles)
183+ void processParticleLevelJets (aod::McCollision const & collision, aod::McParticles const & particles)
274184 {
275185 // TODO: MC event selection?
276- inputParticles.clear ();
277- for (auto & particle : particles) {
278- if (particle.getGenStatusCode () != 1 ) {
279- continue ;
280- }
281- auto pdgParticle = pdg->GetParticle (particle.pdgCode ());
282- auto pdgCharge = pdgParticle ? std::abs (pdgParticle->Charge ()) : -1.0 ;
283- if (jetTypeParticleLevel == static_cast <int >(JetType::charged) && pdgCharge < 3.0 ) { // pdg charge is in increments of 1/3
284- continue ;
285- }
286- if (jetTypeParticleLevel == static_cast <int >(JetType::neutral) && pdgCharge != 0.0 ) {
287- continue ;
288- }
289- FastJetUtilities::fillTracks (particle, inputParticles, particle.globalIndex (), static_cast <int >(JetConstituentStatus::track), RecoDecay::getMassPDG (particle.pdgCode ()));
290- }
291- jetFinding (collision);
186+ using ArgType = std::decay_t <decltype (particles)>;
187+ analyseParticles<ArgType, typename ArgType::iterator>(particles, pdg->Instance ());
188+ findJets (collision, jetsTable, constituentsTable, constituentsSubTable);
292189 }
293190
294- PROCESS_SWITCH (JetFinderTask, processParticleLevel , " Particle level jet finding" , false );
191+ PROCESS_SWITCH (JetFinderTask, processParticleLevelJets , " Particle level jet finding" , false );
295192};
296193
297- using JetFinderData = JetFinderTask<o2::aod::Jets, o2::aod::JetConstituents, o2::aod::JetConstituentsSub>;
194+ using JetFinderDataCharged = JetFinderTask<o2::aod::Jets, o2::aod::JetConstituents, o2::aod::JetConstituentsSub>;
298195using JetFinderDataFull = JetFinderTask<o2::aod::FullJets, o2::aod::FullJetConstituents, o2::aod::FullJetConstituentsSub>;
299196using JetFinderDataNeutral = JetFinderTask<o2::aod::NeutralJets, o2::aod::NeutralJetConstituents, o2::aod::NeutralJetConstituentsSub>;
300- using JetFinderMCDetectorLevel = JetFinderTask<o2::aod::MCDetectorLevelJets, o2::aod::MCDetectorLevelJetConstituents, o2::aod::MCDetectorLevelJetConstituentsSub>;
197+ using JetFinderMCDetectorLevelCharged = JetFinderTask<o2::aod::MCDetectorLevelJets, o2::aod::MCDetectorLevelJetConstituents, o2::aod::MCDetectorLevelJetConstituentsSub>;
301198using JetFinderMCDetectorLevelFull = JetFinderTask<o2::aod::MCDetectorLevelFullJets, o2::aod::MCDetectorLevelFullJetConstituents, o2::aod::MCDetectorLevelFullJetConstituentsSub>;
302199using JetFinderMCDetectorLevelNeutral = JetFinderTask<o2::aod::MCDetectorLevelNeutralJets, o2::aod::MCDetectorLevelNeutralJetConstituents, o2::aod::MCDetectorLevelNeutralJetConstituentsSub>;
303- using JetFinderMCParticleLevel = JetFinderTask<o2::aod::MCParticleLevelJets, o2::aod::MCParticleLevelJetConstituents, o2::aod::MCParticleLevelJetConstituentsSub>;
200+ using JetFinderMCParticleLevelCharged = JetFinderTask<o2::aod::MCParticleLevelJets, o2::aod::MCParticleLevelJetConstituents, o2::aod::MCParticleLevelJetConstituentsSub>;
304201using JetFinderMCParticleLevelFull = JetFinderTask<o2::aod::MCParticleLevelFullJets, o2::aod::MCParticleLevelFullJetConstituents, o2::aod::MCParticleLevelFullJetConstituentsSub>;
305202using JetFinderMCParticleLevelNeutral = JetFinderTask<o2::aod::MCParticleLevelNeutralJets, o2::aod::MCParticleLevelNeutralJetConstituents, o2::aod::MCParticleLevelNeutralJetConstituentsSub>;
306- using JetFinderHybridIntermediate = JetFinderTask<o2::aod::HybridIntermediateJets, o2::aod::HybridIntermediateJetConstituents, o2::aod::HybridIntermediateJetConstituentsSub>;
203+ // using JetFinderHybridIntermediate = JetFinderTask<o2::aod::HybridIntermediateJets, o2::aod::HybridIntermediateJetConstituents, o2::aod::HybridIntermediateJetConstituentsSub>;
307204
308205WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
309206{
310207
311208 std::vector<o2::framework::DataProcessorSpec> tasks;
312209
313210 tasks.emplace_back (
314- adaptAnalysisTask<JetFinderData >(cfgc,
315- SetDefaultProcesses{}, TaskName{" jet-finder-data" }));
211+ adaptAnalysisTask<JetFinderDataCharged >(cfgc,
212+ SetDefaultProcesses{}, TaskName{" jet-finder-data-charged " }));
316213
317214 tasks.emplace_back (
318215 adaptAnalysisTask<JetFinderDataFull>(cfgc,
@@ -323,8 +220,8 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
323220 SetDefaultProcesses{}, TaskName{" jet-finder-data-neutral" }));
324221
325222 tasks.emplace_back (
326- adaptAnalysisTask<JetFinderMCDetectorLevel >(cfgc,
327- SetDefaultProcesses{}, TaskName{" jet-finder-mcd" }));
223+ adaptAnalysisTask<JetFinderMCDetectorLevelCharged >(cfgc,
224+ SetDefaultProcesses{}, TaskName{" jet-finder-mcd-charged " }));
328225
329226 tasks.emplace_back (
330227 adaptAnalysisTask<JetFinderMCDetectorLevelFull>(cfgc,
@@ -334,13 +231,13 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
334231 adaptAnalysisTask<JetFinderMCDetectorLevelNeutral>(cfgc,
335232 SetDefaultProcesses{}, TaskName{" jet-finder-mcd-neutral" }));
336233
337- tasks.emplace_back (
338- adaptAnalysisTask<JetFinderHybridIntermediate>(cfgc,
339- SetDefaultProcesses{}, TaskName{" jet-finder-hybrid-intermedaite-full" }));
234+ // tasks.emplace_back(
235+ // adaptAnalysisTask<JetFinderHybridIntermediate>(cfgc,
236+ // SetDefaultProcesses{}, TaskName{"jet-finder-hybrid-intermedaite-full"}));
340237
341238 tasks.emplace_back (
342- adaptAnalysisTask<JetFinderMCParticleLevel >(cfgc,
343- SetDefaultProcesses{}, TaskName{" jet-finder-mcp" }));
239+ adaptAnalysisTask<JetFinderMCParticleLevelCharged >(cfgc,
240+ SetDefaultProcesses{}, TaskName{" jet-finder-mcp-charged " }));
344241
345242 tasks.emplace_back (
346243 adaptAnalysisTask<JetFinderMCParticleLevelFull>(cfgc,
0 commit comments