All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
CLICPfoSelectorAnalysis.cc
Go to the documentation of this file.
2 #include <iostream>
3 
4 #include <EVENT/LCCollection.h>
5 
6 #include "marlin/VerbosityLevels.h"
7 
8 #include <marlin/AIDAProcessor.h>
9 
10 using namespace lcio;
11 using namespace marlin;
12 
13 const int precision = 2;
14 const int widthFloat = 7;
15 const int widthInt = 5;
16 
17 LCRelationNavigator* m_reltrue = 0;
18 LCRelationNavigator* m_trackreltrue = 0;
19 LCRelationNavigator* m_clureltrue = 0;
20 
22 
23 CLICPfoSelectorAnalysis::CLICPfoSelectorAnalysis() : Processor("CLICPfoSelectorAnalysis") {
24  _description =
25  "CLICPfoSelectorAnalysis produces a tree and scatter plots using PFO variables defined in the CLICPfoSelector.";
26 
27  // register steering parameters: name, description, class-variable, default value
28  registerInputCollection(LCIO::RECONSTRUCTEDPARTICLE, "PFOCollectionName", "Name of the PFO collection", colNamePFOs,
29  string("PandoraPFOs"));
30 
31  registerProcessorParameter("TreeName", "Name of output tree", treeName, string("PfoTree"));
32 
33  registerProcessorParameter("CosThetaCut", "Cut on the PFO cosTheta to define central/forward region", cutCosTheta,
34  float(0.975));
35 
36  registerProcessorParameter(
37  "MinECalHitsForHadrons",
38  "Min number of Ecal hits to use clusterTime info from Ecal (for neutral and charged hadrons only)", minECalHits,
39  int(5));
40 
41  registerProcessorParameter(
42  "MinHcalEndcapHitsForHadrons",
43  "Min number of Hcal Endcap hits to use clusterTime info from Hcal Endcap (for neutral and charged hadrons only)",
44  minHcalEndcapHits, int(5));
45 
46  registerProcessorParameter("ForwardCosThetaForHighEnergyNeutralHadrons", "ForwardCosThetaForHighEnergyNeutralHadrons",
48 
49  registerProcessorParameter("ForwardHighEnergyNeutralHadronsEnergy", "ForwardHighEnergyNeutralHadronsEnergy",
51 
52  registerProcessorParameter("AnalyzePhotons", "Boolean factor to decide if perform the analysis on photons", analyzePhotons,
53  bool(true));
54 
55  registerProcessorParameter("AnalyzeChargedPfos", "Boolean factor to decide if perform the analysis on charged PFOs",
56  analyzeChargedPfos, bool(true));
57 
58  registerProcessorParameter("AnalyzeNeutralHadrons", "Boolean factor to decide if perform the analysis on neutral hadrons",
59  analyzeNeutralHadrons, bool(true));
60 
61  registerProcessorParameter("AnalyzeAll", "Boolean factor to decide if perform the analysis on all PFOs", analyzeAll,
62  bool(true));
63 
64  registerProcessorParameter("AnalyzeSignal",
65  "Boolean factor to decide if perform the analysis only on PFOs belonging to the signal",
66  analyzeSignal, bool(true));
67 
68  registerProcessorParameter("AnalyzeOverlay",
69  "Boolean factor to decide if perform the analysis on only on PFOs belonging to the overlay",
70  analyzeOverlay, bool(true));
71 
72  registerProcessorParameter("MinEnergy", "Minimum energy (needed for the energy histos)", en_min, float(0));
73 
74  registerProcessorParameter("MaxEnergy", "Maximum energy (needed for the energy histos)", en_max, float(500));
75 
76  registerInputCollection(LCIO::MCPARTICLE, "MCPhysicsParticleCollectionName",
77  "Name of the MCPhysicsParticle input collection", m_inputPhysicsParticleCollection,
78  std::string("MCPhysicsParticles"));
79 
80  registerInputCollection(LCIO::LCRELATION, "RecoMCTruthLink", "Name of the RecoMCTruthLink input collection",
81  m_recoMCTruthLink, std::string("RecoMCTruthLink"));
82 
83  registerInputCollection(LCIO::LCRELATION, "SiTracksMCTruthLink", "Name of the SiTracksMCTruthLink input collection",
84  m_SiTracksMCTruthLink, std::string("SiTracksMCTruthLink"));
85 
86  registerInputCollection(LCIO::LCRELATION, "ClusterMCTruthLink", "Name of the ClusterMCTruthLink input collection",
87  m_ClusterMCTruthLink, std::string("ClusterMCTruthLink"));
88 }
89 
91  printParameters();
92 
93  _nRun = -1;
94  _nEvt = 0;
95 
96  AIDAProcessor::histogramFactory(this);
97 
98  //initializing TTree
99  pfo_tree = new TTree(treeName.c_str(), treeName.c_str());
100  pfo_tree->Branch("eventNumber", &eventNumber, "eventNumber/I");
101  pfo_tree->Branch("runNumber", &runNumber, "runNumber/I");
102 
103  pfo_tree->Branch("type", &type, "type/I");
104  pfo_tree->Branch("p", &p, "p/D");
105  pfo_tree->Branch("px", &px, "px/D");
106  pfo_tree->Branch("py", &py, "py/D");
107  pfo_tree->Branch("pz", &pz, "pz/D");
108  pfo_tree->Branch("pT", &pT, "pT/D");
109 
110  pfo_tree->Branch("costheta", &costheta, "costhetaMC/D");
111  pfo_tree->Branch("energy", &energy, "energy/D");
112  pfo_tree->Branch("mass", &mass, "mass/D");
113  pfo_tree->Branch("charge", &charge, "charge/D");
114  pfo_tree->Branch("nTracks", &nTracks, "nTracks/I");
115  pfo_tree->Branch("nClusters", &nClusters, "nClusters/I");
116  pfo_tree->Branch("nCaloHits", &nCaloHits, "nCaloHits/I");
117  pfo_tree->Branch("nEcalHits", &nEcalHits, "nEcalHits/I");
118  pfo_tree->Branch("nHcalEndCapHits", &nHcalEndCapHits, "nHcalEndCapHits/I");
119 
120  pfo_tree->Branch("clusterTime", &clusterTime, "clusterTime/D");
121  pfo_tree->Branch("clusterTimeEcal", &clusterTimeEcal, "clusterTimeEcal/D");
122  pfo_tree->Branch("clusterTimeHcalEndcap", &clusterTimeHcalEndcap, "clusterTimeHcalEndcap/D");
123 
124  pfo_tree->Branch("trk_clu_sameMCPart", &trk_clu_sameMCPart, "trk_clu_sameMCPart/I");
125  pfo_tree->Branch("atLeastOneSignal", &atLeastOneSignal, "atLeastOneSignal/I");
126 
127  streamlog_out(DEBUG) << "CLICPfoSelectorAnalysis ---> set up ttree " << std::endl;
128 
129  //initializing TGraphs and TH1Fs
130  if (analyzePhotons) {
131  particleCategories.push_back("photons");
132  }
133  if (analyzeChargedPfos) {
134  particleCategories.push_back("chargedPfos");
135  }
136  if (analyzeNeutralHadrons) {
137  particleCategories.push_back("neutralHadrons");
138  }
139  if (analyzeAll) {
140  generationCategories.push_back("all");
141  }
142  if (analyzeSignal) {
143  generationCategories.push_back("signal");
144  }
145  if (analyzeOverlay) {
146  generationCategories.push_back("overlay");
147  }
148 
149  h_energy_tot = new TH1F("h_en_tot_all", "h_en_tot_all", 1000, en_min, en_max);
150  h_energy_tot_signal = new TH1F("h_en_tot_signal", "h_en_tot_signal", 1000, en_min, en_max);
151  h_energy_tot_background = new TH1F("h_en_tot_overlay", "h_en_tot_overlay", 1000, en_min, en_max);
152 
153  std::string graphLabel = "";
154  for (auto ipc : particleCategories) {
155  for (auto igc : generationCategories) {
156  graphLabel = ipc + "_" + igc;
157  streamlog_out(DEBUG) << "Analysing followig particle category: " << graphLabel << endl;
158  g_timeVsPt[graphLabel] = new TGraph();
159  g_timeVsPt_central[graphLabel] = new TGraph();
160  g_timeVsPt_forward[graphLabel] = new TGraph();
161  h_energy[graphLabel] =
162  new TH1F((graphLabel + "_energy").c_str(), (graphLabel + "_energy").c_str(), 1000, en_min, en_max);
163  h_energy_central[graphLabel] =
164  new TH1F((graphLabel + "_energy_central").c_str(), (graphLabel + "_energy_central").c_str(), 1000, en_min, en_max);
165  h_energy_forward[graphLabel] =
166  new TH1F((graphLabel + "_energy_forward").c_str(), (graphLabel + "_energy_forward").c_str(), 1000, en_min, en_max);
167  }
168  }
169 }
170 
172  _nRun++;
173  _nEvt = 0;
174 
175  streamlog_out(DEBUG) << std::endl;
176  streamlog_out(DEBUG) << "CLICPfoSelectorAnalysis ---> new run : run number = " << _nRun << std::endl;
177 }
178 
180  streamlog_out(DEBUG) << "CLICPfoSelectorAnalysis ---> processing run = " << _nRun << " event = " << _nEvt << std::endl;
181 
182  eventNumber = _nEvt;
183  runNumber = _nRun;
184 
185  // Get the collection of MC physics particles (signal) and store them in a vector
186  LCCollection* physicsParticleCollection = NULL;
187  try {
188  physicsParticleCollection = evt->getCollection(m_inputPhysicsParticleCollection);
189  } catch (lcio::DataNotAvailableException& e) {
190  streamlog_out(WARNING) << m_inputPhysicsParticleCollection << " collection not available" << std::endl;
191  physicsParticleCollection = NULL;
192  }
193  for (int ipart = 0; ipart < physicsParticleCollection->getNumberOfElements(); ipart++) {
194  MCParticle* signal = static_cast<MCParticle*>(physicsParticleCollection->getElementAt(ipart));
195  physicsParticles.push_back(signal);
196  }
197  streamlog_out(DEBUG) << physicsParticles.size() << " MC Particles belong to the signal." << endl;
198 
199  //Get MC Particles associated to the PFOs
200  LCCollection* rmclcol = NULL;
201  try {
202  rmclcol = evt->getCollection(m_recoMCTruthLink);
203  } catch (lcio::DataNotAvailableException& e) {
204  streamlog_out(WARNING) << m_recoMCTruthLink << " collection not available" << std::endl;
205  rmclcol = NULL;
206  }
207  if (rmclcol != NULL) {
208  m_reltrue = new LCRelationNavigator(rmclcol);
209  }
210 
211  //Get MC Particles associated to the track of the PFOs
212  LCCollection* rtrkclcol = NULL;
213  try {
214  rtrkclcol = evt->getCollection(m_SiTracksMCTruthLink);
215  } catch (lcio::DataNotAvailableException& e) {
216  streamlog_out(WARNING) << m_SiTracksMCTruthLink << " collection not available" << std::endl;
217  rtrkclcol = NULL;
218  }
219  if (rtrkclcol != NULL) {
220  m_trackreltrue = new LCRelationNavigator(rtrkclcol);
221  }
222 
223  //Get MC Particles associated to this cluster
224  LCCollection* rclulcol = NULL;
225  try {
226  rclulcol = evt->getCollection(m_ClusterMCTruthLink);
227  } catch (lcio::DataNotAvailableException& e) {
228  streamlog_out(WARNING) << m_ClusterMCTruthLink << " collection not available" << std::endl;
229  rclulcol = NULL;
230  }
231  if (rclulcol != NULL) {
232  m_clureltrue = new LCRelationNavigator(rclulcol);
233  }
234 
235  fillTree(evt, colNamePFOs);
236 
237  streamlog_out(DEBUG) << " finished event: " << evt->getEventNumber() << " in run: " << _nRun << endl;
238 
239  physicsParticles.clear();
240  _nEvt++;
241 }
242 
244  fillPlots();
245 
246  //writing TGraphs for each category
247  AIDAProcessor::histogramFactory(this);
248  std::string graphLabel = "";
249  for (auto ipc : particleCategories) {
250  for (auto igc : generationCategories) {
251  graphLabel = ipc + "_" + igc;
252  g_timeVsPt[graphLabel]->Write((graphLabel + "_timeVsPt").c_str());
253  g_timeVsPt_central[graphLabel]->Write((graphLabel + "_timeVsPt_central").c_str());
254  g_timeVsPt_forward[graphLabel]->Write((graphLabel + "_timeVsPt_forward").c_str());
255  }
256  }
257 
258  streamlog_out(DEBUG) << "CLICPfoSelectorAnalysis ---> finished " << name() << " processed " << _nEvt << " events in "
259  << _nRun << " runs " << endl;
260 }
261 
262 void CLICPfoSelectorAnalysis::fillTree(LCEvent* evt, string collName) {
263  streamlog_out(DEBUG) << "CLICPfoSelectorAnalysis ---> filling TTree " << std::endl;
264 
265  LCCollection* col = evt->getCollection(collName);
266 
267  double en_tot = 0.0;
268  double en_tot_signal = 0.0;
269  double en_tot_background = 0.0;
270 
271  std::string graphLabel = "";
272  for (auto ipc : particleCategories) {
273  for (auto igc : generationCategories) {
274  graphLabel = ipc + "_" + igc;
275  energy_tot[graphLabel] = 0.0;
276  energy_tot_central[graphLabel] = 0.0;
277  energy_tot_forward[graphLabel] = 0.0;
278  }
279  }
280 
281  // this will only be entered if the collection is available
282  if (col != NULL) {
283  int nelem = col->getNumberOfElements();
284  streamlog_out(DEBUG) << "Number of Input Pfos = " << nelem << endl;
285 
286  // loop on PFO particles
287  for (int i = 0; i < nelem; i++) {
288  streamlog_out(DEBUG) << " --- " << std::endl;
289 
290  ReconstructedParticle* pPfo = static_cast<ReconstructedParticle*>(col->getElementAt(i));
291  type = pPfo->getType();
292  px = pPfo->getMomentum()[0];
293  py = pPfo->getMomentum()[1];
294  pz = pPfo->getMomentum()[2];
295  pT = sqrt(px * px + py * py);
296  p = sqrt(pT * pT + pz * pz);
297  costheta = fabs(pz) / p;
298  energy = pPfo->getEnergy();
299  mass = pPfo->getMass();
300  charge = pPfo->getCharge();
301 
302  //MC linker to check if it belongs to the signal
303  LCObjectVec mcvec;
304  mcvec = m_reltrue->getRelatedToObjects(pPfo);
305  atLeastOneSignal = 0;
306 
307  streamlog_out(DEBUG) << " PFO with number of linked MC particles = " << mcvec.size() << endl;
308 
309  // if the PFO is associated to MC Particle, check if the MC Particle belongs to physicsParticles
310  if (mcvec.size() > 0) {
311  for (auto imcp : mcvec) {
312  MCParticle* mc_part = dynamic_cast<MCParticle*>(imcp);
313 
314  streamlog_out(DEBUG) << " MC Type PDG Energy" << endl;
315  stringstream output;
316  output << fixed;
317  output << setprecision(precision);
318  if (mc_part != NULL) {
319  FORMATTED_OUTPUT_MC(output, mc_part->getPDG(), mc_part->getEnergy());
320  streamlog_out(DEBUG) << output.str();
321  }
322 
323  if (find(physicsParticles.begin(), physicsParticles.end(), mc_part) != physicsParticles.end() &&
324  atLeastOneSignal == 0) {
325  streamlog_out(DEBUG) << " -> belongs to the PhysicsParticle (skip the others)" << std::endl;
326  atLeastOneSignal = 1;
327  } else {
328  streamlog_out(DEBUG) << "-> does not belong to the PhysicsParticle" << std::endl;
329  }
330  }
331  }
332 
333  en_tot += energy;
334  if (atLeastOneSignal) {
335  en_tot_signal += energy;
336  } else {
337  en_tot_background += energy;
338  }
339 
340  const TrackVec tracks = pPfo->getTracks();
341  const ClusterVec clusters = pPfo->getClusters();
342  nTracks = tracks.size();
343  nClusters = clusters.size();
344 
345  //get track time
346  float trackTime = numeric_limits<float>::max();
347  clusterTime = 999.;
348  clusterTimeEcal = 999.;
349  clusterTimeHcalEndcap = 999.;
350 
351  streamlog_out(DEBUG) << " PFO with number of tracks = " << tracks.size() << endl;
352  for (unsigned int trk = 0; trk < tracks.size(); trk++) {
353  const Track* track = tracks[trk];
354  float tof;
355  const float time = PfoUtil::TimeAtEcal(track, tof);
356  if (fabs(time) < trackTime) {
357  trackTime = time;
358  }
359  }
360 
361  //get clusters time
362  streamlog_out(DEBUG) << " PFO with number of clusters = " << clusters.size() << endl;
363  for (unsigned int clu = 0; clu < clusters.size(); clu++) {
364  float meanTime(999.);
365  float meanTimeEcal(999.);
366  float meanTimeHcalEndcap(999.);
367  int nEcal(0);
368  int nHcalEnd(0);
369  int nCaloHitsUsed(0);
370 
371  const Cluster* cluster = clusters[clu];
372  PfoUtil::GetClusterTimes(cluster, meanTime, nCaloHitsUsed, meanTimeEcal, nEcal, meanTimeHcalEndcap, nHcalEnd, false);
373 
374  // correct for track propagation time
375  if (!tracks.empty()) {
376  meanTime -= trackTime;
377  meanTimeEcal -= trackTime;
378  meanTimeHcalEndcap -= trackTime;
379  }
380 
381  if (fabs(meanTime) < clusterTime) {
382  clusterTime = meanTime;
383  nCaloHits = nCaloHitsUsed;
384  }
385  if (fabs(meanTimeEcal) < clusterTimeEcal) {
386  clusterTimeEcal = meanTimeEcal;
387  nEcalHits = nEcal;
388  }
389  if (fabs(meanTimeHcalEndcap) < clusterTimeHcalEndcap) {
390  clusterTimeHcalEndcap = meanTimeHcalEndcap;
391  nHcalEndCapHits = nHcalEnd;
392  }
393  }
394 
395  //check if tracks and clusters have at least one MC particle in common
396  trk_clu_sameMCPart = 0;
397  for (unsigned int it = 0; it < tracks.size(); it++) {
398  //MC linker to tracks
399  Track* track = tracks[it];
400  LCObjectVec mctrkvec;
401  mctrkvec = m_trackreltrue->getRelatedToObjects(track);
402 
403  if (mctrkvec.size() > 0) {
404  for (unsigned int ic = 0; ic < clusters.size(); ic++) {
405  //MC linker to clusters
406  Cluster* cluster = clusters[ic];
407  LCObjectVec mccluvec;
408  mccluvec = m_clureltrue->getRelatedToObjects(cluster);
409 
410  // check if MC Particle associated to the track
411  // has the same Id of at least one MC Particle associated to the cluster
412  if (mccluvec.size() > 0) {
413  for (auto imctrk : mctrkvec) {
414  if (trk_clu_sameMCPart == 1)
415  break;
416  for (auto imcclu : mccluvec) {
417  if (trk_clu_sameMCPart == 0 && imcclu->id() == imctrk->id()) {
418  streamlog_out(DEBUG) << " -> PFO track and cluster have same MCParticle" << std::endl;
419  trk_clu_sameMCPart = 1;
420  break;
421  }
422  }
423  }
424  }
425  }
426  }
427  }
428 
429  if (trk_clu_sameMCPart == 0)
430  streamlog_out(DEBUG) << " -> PFO track and cluster have NOT same MCParticle" << std::endl;
431 
432  //computing energy for signal and overlay for the particles categories
433  std::string h_label;
434  if (type == 22 &&
435  std::find(particleCategories.begin(), particleCategories.end(), "photons") != particleCategories.end()) {
436  h_label = "photons";
437  } else if (type != 22 && charge == 0 &&
438  std::find(particleCategories.begin(), particleCategories.end(), "neutralHadrons") !=
439  particleCategories.end()) {
440  h_label = "neutralHadrons";
441  } else if (charge != 0 &&
442  std::find(particleCategories.begin(), particleCategories.end(), "chargedPfos") !=
443  particleCategories.end()) {
444  h_label = "chargedPfos";
445  }
446 
447  if (std::find(generationCategories.begin(), generationCategories.end(), "all") != generationCategories.end()) {
448  energy_tot[h_label + "_all"] += energy;
449  if (costheta < cutCosTheta) {
450  energy_tot_central[h_label + "_all"] += energy;
451  } else {
452  energy_tot_forward[h_label + "_all"] += energy;
453  }
454  }
455  if (atLeastOneSignal &&
456  std::find(generationCategories.begin(), generationCategories.end(), "signal") != generationCategories.end()) {
457  energy_tot[h_label + "_signal"] += energy;
458  if (costheta < cutCosTheta) {
459  energy_tot_central[h_label + "_signal"] += energy;
460  } else {
461  energy_tot_forward[h_label + "_signal"] += energy;
462  }
463  }
464  if (!atLeastOneSignal &&
465  std::find(generationCategories.begin(), generationCategories.end(), "overlay") != generationCategories.end()) {
466  energy_tot[h_label + "_overlay"] += energy;
467  if (costheta < cutCosTheta) {
468  energy_tot_central[h_label + "_overlay"] += energy;
469  } else {
470  energy_tot_forward[h_label + "_overlay"] += energy;
471  }
472  }
473 
474  streamlog_out(DEBUG) << " Type PDG E Pt cosTheta #trk time #Clu time ecal hcal " << endl;
475 
476  stringstream output;
477  output << fixed;
478  output << setprecision(precision);
479 
480  if (clusters.size() == 0)
481  FORMATTED_OUTPUT_TRACK_CLUSTER_full(output, type, energy, pT, costheta, tracks.size(), trackTime, "-", "-", "-",
482  "-");
483  if (tracks.size() == 0)
484  FORMATTED_OUTPUT_TRACK_CLUSTER_full(output, type, energy, pT, costheta, "", "-", clusters.size(), clusterTime,
486  if (tracks.size() > 0 && clusters.size() > 0)
487  FORMATTED_OUTPUT_TRACK_CLUSTER_full(output, type, energy, pT, costheta, tracks.size(), trackTime, clusters.size(),
489 
490  streamlog_out(DEBUG) << output.str();
491 
492  pfo_tree->Fill();
493 
494  streamlog_out(DEBUG) << " " << std::endl;
495  }
496  }
497 
498  h_energy_tot->Fill(en_tot);
499  h_energy_tot_signal->Fill(en_tot_signal);
500  h_energy_tot_background->Fill(en_tot_background);
501  streamlog_out(DEBUG) << " Energy: TOTAL = " << en_tot << ", SIGNAL = " << en_tot_signal
502  << ", OVERLAY = " << en_tot_background << std::endl;
503 
504  for (auto ipc : particleCategories) {
505  for (auto igc : generationCategories) {
506  graphLabel = ipc + "_" + igc;
507  h_energy[graphLabel]->Fill(energy_tot[graphLabel]);
508  h_energy_central[graphLabel]->Fill(energy_tot_central[graphLabel]);
509  h_energy_forward[graphLabel]->Fill(energy_tot_forward[graphLabel]);
510  streamlog_out(DEBUG) << " Energy (" << graphLabel << " - all ): " << energy_tot[graphLabel] << std::endl;
511  streamlog_out(DEBUG) << " Energy (" << graphLabel << " - central): " << energy_tot_central[graphLabel] << std::endl;
512  streamlog_out(DEBUG) << " Energy (" << graphLabel << " - forward): " << energy_tot_forward[graphLabel] << std::endl;
513  }
514  }
515 }
516 
518  Int_t nEntries = pfo_tree->GetEntries();
519  streamlog_out(DEBUG) << "CLICPfoSelectorAnalysis ---> filling plots with TTree (nEntries = " << nEntries << ")"
520  << std::endl;
521 
522  for (int ie = 0; ie < nEntries; ie++) {
523  pfo_tree->GetEntry(ie);
524  double currentClusterTime = clusterTime;
525  bool useHcalTimingOnly = ((costheta > forwardCosThetaForHighEnergyNeutralHadrons) && (type == 2112) &&
527 
528  //in the case of photons, the time of ECAL clusters are used
529  if (analyzePhotons == true && type == 22) {
530  if (std::find(particleCategories.begin(), particleCategories.end(), "photons") != particleCategories.end() &&
531  std::find(generationCategories.begin(), generationCategories.end(), "all") != generationCategories.end()) {
532  currentClusterTime = clusterTimeEcal;
533  //streamlog_out( DEBUG ) << "Filling scatter plot for photon with pT and current clusterTime: " << pT << "," << currentClusterTime << endl;
534 
535  g_timeVsPt["photons_all"]->SetPoint(g_timeVsPt["photons_all"]->GetN(), pT, currentClusterTime);
536  if (costheta < cutCosTheta) {
537  g_timeVsPt_central["photons_all"]->SetPoint(g_timeVsPt_central["photons_all"]->GetN(), pT, currentClusterTime);
538  } else {
539  g_timeVsPt_forward["photons_all"]->SetPoint(g_timeVsPt_forward["photons_all"]->GetN(), pT, currentClusterTime);
540  }
541 
543  std::find(generationCategories.begin(), generationCategories.end(), "signal") != generationCategories.end()) {
544  g_timeVsPt["photons_signal"]->SetPoint(g_timeVsPt["photons_signal"]->GetN(), pT, currentClusterTime);
545  if (costheta < cutCosTheta) {
546  g_timeVsPt_central["photons_signal"]->SetPoint(g_timeVsPt_central["photons_signal"]->GetN(), pT, currentClusterTime);
547  } else {
548  g_timeVsPt_forward["photons_signal"]->SetPoint(g_timeVsPt_forward["photons_signal"]->GetN(), pT, currentClusterTime);
549  }
550  }
551 
553  std::find(generationCategories.begin(), generationCategories.end(), "overlay") != generationCategories.end()) {
554  g_timeVsPt["photons_overlay"]->SetPoint(g_timeVsPt["photons_overlay"]->GetN(), pT, currentClusterTime);
555  if (costheta < cutCosTheta) {
556  g_timeVsPt_central["photons_overlay"]->SetPoint(g_timeVsPt_central["photons_overlay"]->GetN(), pT, currentClusterTime);
557  } else {
558  g_timeVsPt_forward["photons_overlay"]->SetPoint(g_timeVsPt_forward["photons_overlay"]->GetN(), pT, currentClusterTime);
559  }
560  }
561 
562  } else {
563  streamlog_out(ERROR) << "Cannot fill scatter plots because TGraph for photons was not created. " << endl;
564  exit(0);
565  }
566  }
567 
568  if (analyzeNeutralHadrons == true && type != 22 && charge == 0) {
569  if (std::find(particleCategories.begin(), particleCategories.end(), "neutralHadrons") != particleCategories.end() &&
570  std::find(generationCategories.begin(), generationCategories.end(), "all") != generationCategories.end()) {
571  //in the case the nEcalHits is more than expected, the time computed Ecal is used
572  if (!useHcalTimingOnly && (nEcalHits > minECalHits || nEcalHits >= nCaloHits / 2.)) {
573  currentClusterTime = clusterTimeEcal;
574  //in the case the nHcalEndCapHits is more than expected, the time computed Hcal endcap is used
575  } else if ((nHcalEndCapHits >= minHcalEndcapHits) || (nHcalEndCapHits >= nCaloHits / 2.)) {
576  currentClusterTime = clusterTimeHcalEndcap;
577  }
578  //streamlog_out( DEBUG ) << "Filling scatter plot for neutralHadrons with pT and clusterTime: " << pT << "," << currentClusterTime << endl;
579 
580  g_timeVsPt["neutralHadrons_all"]->SetPoint(g_timeVsPt["neutralHadrons_all"]->GetN(), pT, currentClusterTime);
581  if (costheta < cutCosTheta)
582  g_timeVsPt_central["neutralHadrons_all"]->SetPoint(g_timeVsPt_central["neutralHadrons_all"]->GetN(), pT, currentClusterTime);
583  else
584  g_timeVsPt_forward["neutralHadrons_all"]->SetPoint(g_timeVsPt_forward["neutralHadrons_all"]->GetN(), pT, currentClusterTime);
585 
587  std::find(generationCategories.begin(), generationCategories.end(), "signal") != generationCategories.end()) {
588  g_timeVsPt["neutralHadrons_signal"]->SetPoint(g_timeVsPt["neutralHadrons_signal"]->GetN(), pT, currentClusterTime);
589  if (costheta < cutCosTheta)
590  g_timeVsPt_central["neutralHadrons_signal"]->SetPoint(g_timeVsPt_central["neutralHadrons_signal"]->GetN(), pT, currentClusterTime);
591  else
592  g_timeVsPt_forward["neutralHadrons_signal"]->SetPoint(g_timeVsPt_forward["neutralHadrons_signal"]->GetN(), pT, currentClusterTime);
593  }
594 
596  std::find(generationCategories.begin(), generationCategories.end(), "overlay") != generationCategories.end()) {
597  g_timeVsPt["neutralHadrons_overlay"]->SetPoint(g_timeVsPt["neutralHadrons_overlay"]->GetN(), pT, currentClusterTime);
598  if (costheta < cutCosTheta)
599  g_timeVsPt_central["neutralHadrons_overlay"]->SetPoint(g_timeVsPt_central["neutralHadrons_overlay"]->GetN(), pT, currentClusterTime);
600  else
601  g_timeVsPt_forward["neutralHadrons_overlay"]->SetPoint(g_timeVsPt_forward["neutralHadrons_overlay"]->GetN(), pT, currentClusterTime);
602  }
603 
604  } else {
605  streamlog_out(ERROR) << "Cannot fill scatter plots because TGraph for neutralHadrons was not created. " << endl;
606  exit(0);
607  }
608  }
609 
610  if (analyzeChargedPfos == true && charge != 0) {
611  if (std::find(particleCategories.begin(), particleCategories.end(), "chargedPfos") != particleCategories.end() &&
612  std::find(generationCategories.begin(), generationCategories.end(), "all") != generationCategories.end()) {
613  //in the case the nEcalHits is more than expected, the time computed Ecal is used
614  if ((!useHcalTimingOnly && (nEcalHits > minECalHits || nEcalHits >= nCaloHits / 2.))) {
615  currentClusterTime = clusterTimeEcal;
616  //in the case the nHcalEndCapHits is more than expected, the time computed Hcal endcap is used
617  } else if ((nHcalEndCapHits >= minHcalEndcapHits) || (nHcalEndCapHits >= nCaloHits / 2.)) {
618  currentClusterTime = clusterTimeHcalEndcap;
619  }
620  //streamlog_out( DEBUG ) << "Filling scatter plot for chargedPfos with pT and clusterTime: " << pT << "," << currentClusterTime << endl;
621 
622  g_timeVsPt["chargedPfos_all"]->SetPoint(g_timeVsPt["chargedPfos_all"]->GetN(), pT, currentClusterTime);
623  if (costheta < cutCosTheta)
624  g_timeVsPt_central["chargedPfos_all"]->SetPoint(g_timeVsPt_central["chargedPfos_all"]->GetN(), pT, currentClusterTime);
625  else
626  g_timeVsPt_forward["chargedPfos_all"]->SetPoint(g_timeVsPt_forward["chargedPfos_all"]->GetN(), pT, currentClusterTime);
627 
629  std::find(generationCategories.begin(), generationCategories.end(), "signal") != generationCategories.end()) {
630  g_timeVsPt["chargedPfos_signal"]->SetPoint(g_timeVsPt["chargedPfos_signal"]->GetN(), pT, currentClusterTime);
631  if (costheta < cutCosTheta)
632  g_timeVsPt_central["chargedPfos_signal"]->SetPoint(g_timeVsPt_central["chargedPfos_signal"]->GetN(), pT, currentClusterTime);
633  else
634  g_timeVsPt_forward["chargedPfos_signal"]->SetPoint(g_timeVsPt_forward["chargedPfos_signal"]->GetN(), pT, currentClusterTime);
635  }
636 
638  std::find(generationCategories.begin(), generationCategories.end(), "overlay") != generationCategories.end()) {
639  g_timeVsPt["chargedPfos_overlay"]->SetPoint(g_timeVsPt["chargedPfos_overlay"]->GetN(), pT, currentClusterTime);
640  if (costheta < cutCosTheta)
641  g_timeVsPt_central["chargedPfos_overlay"]->SetPoint(g_timeVsPt_central["chargedPfos_overlay"]->GetN(), pT, currentClusterTime);
642  else
643  g_timeVsPt_forward["chargedPfos_overlay"]->SetPoint(g_timeVsPt_forward["chargedPfos_overlay"]->GetN(), pT, currentClusterTime);
644  }
645 
646  } else {
647  streamlog_out(ERROR) << "Cannot fill scatter plots because TGraph for chargedPfos was not created. " << endl;
648  exit(0);
649  }
650  }
651  }
652 }
const int precision
#define FORMATTED_OUTPUT_MC(out, N1, E1)
Definition: PfoUtilities.h:43
LCRelationNavigator * m_clureltrue
virtual void processEvent(LCEvent *evt)
#define FORMATTED_OUTPUT_TRACK_CLUSTER_full(out, N1, E1, E2, E3, N2, E4, N3, E5, E6, E7)
Definition: PfoUtilities.h:21
const int widthInt
map< string, double > energy_tot_central
float TimeAtEcal(const Track *pTrack, float &tof)
Definition: PfoUtilities.cc:19
map< string, TH1F * > h_energy_central
vector< string > generationCategories
map< string, TH1F * > h_energy
void fillTree(LCEvent *evt, string collName)
map< string, double > energy_tot_forward
map< string, TH1F * > h_energy_forward
static const float e
const int widthFloat
LCRelationNavigator * m_reltrue
void GetClusterTimes(const Cluster *cluster, float &meanTime, int &nCaloHitsUsed, float &meanTimeEcal, int &nEcal, float &meanTimeHcalEndcap, int &nHcalEnd, bool correctHitTimesForTimeOfFlight)
Definition: PfoUtilities.cc:49
virtual void processRunHeader(LCRunHeader *run)
vector< MCParticle * > physicsParticles
map< string, TGraph * > g_timeVsPt
LCRelationNavigator * m_trackreltrue
map< string, double > energy_tot
map< string, TGraph * > g_timeVsPt_forward
CLICPfoSelectorAnalysis processor.
CLICPfoSelectorAnalysis aCLICPfoSelectorAnalysis
map< string, TGraph * > g_timeVsPt_central