ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B0TrackFastSimEval.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file B0TrackFastSimEval.cc
1 
7 #include "B0TrackFastSimEval.h"
8 
12 #include <trackbase_historic/SvtxVertex.h> // for SvtxVertex
14 
15 #include <g4main/PHG4Hit.h>
17 #include <g4main/PHG4Particle.h>
19 #include <g4main/PHG4VtxPoint.h>
20 
21 #include <pdbcalbase/PdbParameterMap.h>
22 #include <phparameter/PHParameters.h>
23 
25 #include <fun4all/PHTFileServer.h>
26 #include <fun4all/SubsysReco.h> // for SubsysReco
27 
28 #include <phool/getClass.h>
29 #include <phool/phool.h>
30 
31 #include <TH2.h>
32 #include <TSystem.h>
33 #include <TTree.h>
34 #include <TVector3.h>
35 
36 #include <cassert>
37 #include <cmath>
38 #include <iostream>
39 #include <map> // for _Rb_tree_const_ite...
40 #include <utility> // for pair
41 
42 #define LogDebug(exp) std::cout << "DEBUG: " << __FILE__ << ": " << __LINE__ << ": " << exp << "\n"
43 #define LogError(exp) std::cout << "ERROR: " << __FILE__ << ": " << __LINE__ << ": " << exp << "\n"
44 #define LogWarning(exp) std::cout << "WARNING: " << __FILE__ << ": " << __LINE__ << ": " << exp << "\n"
45 
46 const std::string xyzt[] = {"x", "y", "z", "t"};
47 
48 //----------------------------------------------------------------------------//
49 //-- Constructor:
50 //-- simple initialization
51 //----------------------------------------------------------------------------//
52 B0TrackFastSimEval::B0TrackFastSimEval(const std::string &name, const std::string &filename, const std::string &trackmapname)
53  : SubsysReco(name)
54  , m_TruthInfoContainer(nullptr)
55  , m_TrackMap(nullptr)
56  , m_VertexMap(nullptr)
57  , m_TracksEvalTree(nullptr)
58  , m_VertexEvalTree(nullptr)
59  , m_H2D_DeltaMomVsTruthMom(nullptr)
60  , m_H2D_DeltaMomVsTruthEta(nullptr)
61  , m_EventCounter(0)
62  , m_TTree_Event(0)
63  , m_TTree_gTrackID(0)
64  , m_TTree_gFlavor(0)
65  , m_TTree_gpx(0)
66  , m_TTree_gpy(0)
67  , m_TTree_gpz(0)
68  , m_TTree_gvx(0)
69  , m_TTree_gvy(0)
70  , m_TTree_gvz(0)
71  , m_TTree_gvt(0)
72  , m_TTree_TrackID(0)
73  , m_TTree_Charge(0)
74  , m_TTree_nHits(0)
75  , m_TTree_px(0)
76  , m_TTree_py(0)
77  , m_TTree_pz(0)
78  , m_TTree_pcax(0)
79  , m_TTree_pcay(0)
80  , m_TTree_pcaz(0)
81  , m_TTree_dca2d(0)
82  , m_TTree_layer{0,0,0}
83  , m_TTree_vx(0)
84  , m_TTree_vy(0)
85  , m_TTree_vz(0)
86  , m_TTree_DeltaVx(0)
87  , m_TTree_DeltaVy(0)
88  , m_TTree_DeltaVz(0)
89  , m_TTree_nTracks(0)
92  , m_TrackMapName(trackmapname)
93 {
94  // reset_variables();
95 }
96 
97 //----------------------------------------------------------------------------//
98 //-- Init():
99 //-- Intialize all histograms, trees, and ntuples
100 //----------------------------------------------------------------------------//
102 {
104 }
105 
106 //----------------------------------------------------------------------------//
107 //-- InitRun():
108 //-- add related hit object
109 //----------------------------------------------------------------------------//
111 {
112  if (Verbosity())
113  std::cout << PHWHERE << " Openning file " << m_OutFileName << std::endl;
114  PHTFileServer::get().open(m_OutFileName, "RECREATE");
115 
116  // create TTree
117  m_TracksEvalTree = new TTree("tracks", "FastSim Eval => tracks");
118  m_TracksEvalTree->Branch("event", &m_TTree_Event, "event/I");
119  m_TracksEvalTree->Branch("gtrackID", &m_TTree_gTrackID, "gtrackID/I");
120  m_TracksEvalTree->Branch("gflavor", &m_TTree_gFlavor, "gflavor/I");
121  m_TracksEvalTree->Branch("gpx", &m_TTree_gpx, "gpx/F");
122  m_TracksEvalTree->Branch("gpy", &m_TTree_gpy, "gpy/F");
123  m_TracksEvalTree->Branch("gpz", &m_TTree_gpz, "gpz/F");
124  m_TracksEvalTree->Branch("gvx", &m_TTree_gvx, "gvx/F");
125  m_TracksEvalTree->Branch("gvy", &m_TTree_gvy, "gvy/F");
126  m_TracksEvalTree->Branch("gvz", &m_TTree_gvz, "gvz/F");
127  m_TracksEvalTree->Branch("gvt", &m_TTree_gvt, "gvt/F");
128  m_TracksEvalTree->Branch("trackID", &m_TTree_TrackID, "trackID/I");
129  m_TracksEvalTree->Branch("charge", &m_TTree_Charge, "charge/I");
130  m_TracksEvalTree->Branch("nhits", &m_TTree_nHits, "nhits/I");
131  m_TracksEvalTree->Branch("px", &m_TTree_px, "px/F");
132  m_TracksEvalTree->Branch("py", &m_TTree_py, "py/F");
133  m_TracksEvalTree->Branch("pz", &m_TTree_pz, "pz/F");
134  m_TracksEvalTree->Branch("pcax", &m_TTree_pcax, "pcax/F");
135  m_TracksEvalTree->Branch("pcay", &m_TTree_pcay, "pcay/F");
136  m_TracksEvalTree->Branch("pcaz", &m_TTree_pcaz, "pcaz/F");
137  m_TracksEvalTree->Branch("dca2d", &m_TTree_dca2d, "dca2d/F");
138  m_TracksEvalTree->Branch("layer", &m_TTree_layer, "layer/I");
139 
140  // next a stat. on hits
141  PHParameters B0TrackFastSim_Parameter("B0TrackFastSim");
142 
143  PdbParameterMap *nodeparams = findNode::getClass<PdbParameterMap>(topNode,
144  "B0TrackFastSim_Parameter");
145  if (not nodeparams)
146  {
147  std::cout << __PRETTY_FUNCTION__ << " : Warning, missing B0TrackFastSim_Parameter node and skip saving hits"
148  << std::endl;
149  }
150  else
151  {
152  B0TrackFastSim_Parameter.FillFrom(nodeparams);
153  if (Verbosity())
154  {
155  std::cout << __PRETTY_FUNCTION__ << " B0TrackFastSim_Parameter : ";
156  B0TrackFastSim_Parameter.Print();
157  }
158 
159  auto range = B0TrackFastSim_Parameter.get_all_int_params();
160  for (auto iter = range.first; iter != range.second; ++iter)
161  {
162  const std::string &phg4hit_node_name = iter->first;
163  const int &phg4hit_node_id = iter->second;
164 
165  std::cout << __PRETTY_FUNCTION__ << " Prepare PHG4Hit node name " << phg4hit_node_name
166  << " with ID = " << phg4hit_node_id << std::endl;
167 
168  std::string branch_name = std::string("nHit_") + phg4hit_node_name;
169  m_TracksEvalTree->Branch(branch_name.c_str(),
170  &m_TTree_HitContainerID_nHits_map[phg4hit_node_id],
171  (branch_name + "/I").c_str());
172  }
173  }
174 
175  m_H2D_DeltaMomVsTruthEta = new TH2D("DeltaMomVsTruthEta",
176  "#frac{#Delta p}{truth p} vs. truth #eta", 54, -4.5, +4.5, 1000, -1,
177  1);
178 
179  m_H2D_DeltaMomVsTruthMom = new TH2D("DeltaMomVsTruthMom",
180  "#frac{#Delta p}{truth p} vs. truth p", 41, -0.5, 40.5, 1000, -1,
181  1);
182 
183  // create TTree - vertex
184  m_VertexEvalTree = new TTree("vertex", "FastSim Eval => vertces");
185  m_VertexEvalTree->Branch("event", &m_TTree_Event, "event/I");
186  m_VertexEvalTree->Branch("gvx", &m_TTree_gvx, "gvx/F");
187  m_VertexEvalTree->Branch("gvy", &m_TTree_gvy, "gvy/F");
188  m_VertexEvalTree->Branch("gvz", &m_TTree_gvz, "gvz/F");
189  m_VertexEvalTree->Branch("gvt", &m_TTree_gvt, "gvt/F");
190  m_VertexEvalTree->Branch("vx", &m_TTree_vx, "vx/F");
191  m_VertexEvalTree->Branch("vy", &m_TTree_vy, "vy/F");
192  m_VertexEvalTree->Branch("vz", &m_TTree_vz, "vz/F");
193  m_VertexEvalTree->Branch("deltavx", &m_TTree_DeltaVx, "deltavx/F");
194  m_VertexEvalTree->Branch("deltavy", &m_TTree_DeltaVy, "deltavy/F");
195  m_VertexEvalTree->Branch("deltavz", &m_TTree_DeltaVz, "deltavz/F");
196  m_VertexEvalTree->Branch("gID", &m_TTree_gTrackID, "gID/I");
197  m_VertexEvalTree->Branch("ID", &m_TTree_TrackID, "ID/I");
198  m_VertexEvalTree->Branch("ntracks", &m_TTree_nTracks, "ntracks/I");
199  m_VertexEvalTree->Branch("n_from_truth", &m_TTree_nFromTruth, "n_from_truth/I");
200 
201  for (std::map<std::string, unsigned int>::const_iterator iter = m_ProjectionNameMap.begin(); iter != m_ProjectionNameMap.end(); ++iter)
202  {
203  for (int i = 0; i < 4; i++)
204  {
205  std::string bname = iter->first + "_proj_" + xyzt[i];
206  std::string bdef = bname + "/F";
207 
208  // fourth element is the path length
209  if (i == 3)
210  {
211  bdef = iter->first + "_proj_path_length" + "/F";
212  }
213 
214  m_TracksEvalTree->Branch(bname.c_str(), &m_TTree_proj_vec[iter->second][i], bdef.c_str());
215  }
216 
217  for (int i = 0; i < 3; i++)
218  {
219  std::string bname = iter->first + "_proj_p" + xyzt[i];
220  std::string bdef = bname + "/F";
221  m_TracksEvalTree->Branch(bname.c_str(), &m_TTree_proj_p_vec[iter->second][i], bdef.c_str());
222  }
223  std::string nodename = "G4HIT_" + iter->first;
224  PHG4HitContainer *hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
225  if (hits)
226  {
227  for (int i = 0; i < 4; i++)
228  {
229  std::string bname = iter->first + "_" + xyzt[i];
230  std::string bdef = bname + "/F";
231  m_TracksEvalTree->Branch(bname.c_str(), &m_TTree_ref_vec[iter->second][i], bdef.c_str());
232  }
233  for (int i = 0; i < 3; i++)
234  {
235  std::string bname = iter->first + "_p" + xyzt[i];
236  std::string bdef = bname + "/F";
237 
238  m_TracksEvalTree->Branch(bname.c_str(), &m_TTree_ref_p_vec[iter->second][i], bdef.c_str());
239  }
240  }
241  if (!hits && Verbosity() > 0)
242  {
243  std::cout << "InitRun: could not find " << nodename << std::endl;
244  }
245  }
246 
248 }
249 
250 //----------------------------------------------------------------------------//
251 //-- process_event():
252 //-- Call user instructions for every event.
253 //-- This function contains the analysis structure.
254 //----------------------------------------------------------------------------//
256 {
257  m_EventCounter++;
258  if (Verbosity() >= 2 and m_EventCounter % 1000 == 0)
259  std::cout << PHWHERE << "Events processed: " << m_EventCounter << std::endl;
260 
261  //std::cout << "Opening nodes" << std::endl;
262  GetNodes(topNode);
263 
264  //std::cout << "Filling trees" << std::endl;
265  fill_track_tree(topNode);
266  fill_vertex_tree(topNode);
267  //std::cout << "DONE" << std::endl;
268 
270 }
271 
272 //----------------------------------------------------------------------------//
273 //-- End():
274 //-- End method, wrap everything up
275 //----------------------------------------------------------------------------//
277 {
279 
280  m_TracksEvalTree->Write();
281  m_VertexEvalTree->Write();
282 
283  m_H2D_DeltaMomVsTruthEta->Write();
284  m_H2D_DeltaMomVsTruthMom->Write();
285 
286  //PHTFileServer::get().close();
287 
289 }
290 
291 //----------------------------------------------------------------------------//
292 //-- fill_tree():
293 //-- Fill the trees with truth, track fit, and cluster information
294 //----------------------------------------------------------------------------//
296 {
297  // Make sure to reset all the TTree variables before trying to set them.
298 
300  {
301  LogError("m_TruthInfoContainer not found!");
302  return;
303  }
304 
305  if (!m_TrackMap)
306  {
307  LogError("m_TrackMap not found!");
308  return;
309  }
310 
313  for (PHG4TruthInfoContainer::ConstIterator truth_itr = range.first;
314  truth_itr != range.second; ++truth_itr)
315  {
316  reset_variables();
318 
319  PHG4Particle *g4particle = truth_itr->second;
320  if (!g4particle)
321  {
322  LogDebug("");
323  continue;
324  }
325 
326  SvtxTrack_FastSim *track = nullptr;
327 
328  if (Verbosity()) std::cout << __PRETTY_FUNCTION__ << "TRACKmap size " << m_TrackMap->size() << std::endl;
329  for (SvtxTrackMap::ConstIter track_itr = m_TrackMap->begin();
330  track_itr != m_TrackMap->end();
331  track_itr++)
332  {
333  //std::cout << "TRACK * " << track_itr->first << std::endl;
334  SvtxTrack_FastSim *temp = dynamic_cast<SvtxTrack_FastSim *>(track_itr->second);
335  if (!temp)
336  {
337  if (Verbosity())
338  {
339  std::cout << "B0TrackFastSimEval::fill_track_tree - ignore track that is not a SvtxTrack_FastSim:";
340  track_itr->second->identify();
341  }
342  continue;
343  }
344  if (Verbosity()) std::cout << __PRETTY_FUNCTION__ << " PARTICLE!" << std::endl;
345 
346  if ((temp->get_truth_track_id() - g4particle->get_track_id()) == 0)
347  {
348  track = temp;
349  }
350  }
351 
352  //std::cout << "B2" << std::endl;
353  m_TTree_gTrackID = g4particle->get_track_id();
354  m_TTree_gFlavor = g4particle->get_pid();
355 
356  m_TTree_gpx = g4particle->get_px();
357  m_TTree_gpy = g4particle->get_py();
358  m_TTree_gpz = g4particle->get_pz();
359 
360  m_TTree_gvx = NAN;
361  m_TTree_gvy = NAN;
362  m_TTree_gvz = NAN;
363  m_TTree_gvt = NAN;
364  PHG4VtxPoint *vtx = m_TruthInfoContainer->GetVtx(g4particle->get_vtx_id());
365  if (vtx)
366  {
367  m_TTree_gvx = vtx->get_x();
368  m_TTree_gvy = vtx->get_y();
369  m_TTree_gvz = vtx->get_z();
370  m_TTree_gvt = vtx->get_t();
371  }
372 
373  if (track)
374  {
375  //std::cout << "C1" << std::endl;
376  m_TTree_TrackID = track->get_id();
377  m_TTree_Charge = track->get_charge();
378  m_TTree_nHits = track->size_clusters();
379 
380  m_TTree_px = track->get_px();
381  m_TTree_py = track->get_py();
382  m_TTree_pz = track->get_pz();
383  m_TTree_pcax = track->get_x();
384  m_TTree_pcay = track->get_y();
385  m_TTree_pcaz = track->get_z();
386  m_TTree_dca2d = track->get_dca2d();
387  m_TTree_layer[0] = 0;
388  m_TTree_layer[1] = 0;
389  m_TTree_layer[2] = 0;
390  m_TTree_layer[3] = 0;
391  TVector3 truth_mom(m_TTree_gpx, m_TTree_gpy, m_TTree_gpz);
392  TVector3 reco_mom(m_TTree_px, m_TTree_py, m_TTree_pz);
393  //std::cout << "C2" << std::endl;
394 
395  m_H2D_DeltaMomVsTruthMom->Fill(truth_mom.Mag(), (reco_mom.Mag() - truth_mom.Mag()) / truth_mom.Mag());
396  m_H2D_DeltaMomVsTruthEta->Fill(truth_mom.Eta(), (reco_mom.Mag() - truth_mom.Mag()) / truth_mom.Mag());
397  // find projections
398  for (SvtxTrack::ConstStateIter trkstates = track->begin_states();
399  trkstates != track->end_states();
400  ++trkstates)
401  {
402  if (Verbosity()) std::cout << __PRETTY_FUNCTION__ << " checking " << trkstates->second->get_name() << std::endl;
403  std::map<std::string, unsigned int>::const_iterator iter = m_ProjectionNameMap.find(trkstates->second->get_name());
404  if (iter != m_ProjectionNameMap.end())
405  {
406  if (Verbosity())
407  std::cout << __PRETTY_FUNCTION__ << " found " << trkstates->second->get_name() << std::endl;
408  // setting the projection (xyz and pxpypz)
409  for (int i = 0; i < 3; i++)
410  {
411  m_TTree_proj_vec[iter->second][i] = trkstates->second->get_pos(i);
412  m_TTree_proj_p_vec[iter->second][i] = trkstates->second->get_mom(i);
413  }
414  // fourth element is the path length
415  m_TTree_proj_vec[iter->second][3] = trkstates->first;
416 
417  std::string nodename = "G4HIT_" + trkstates->second->get_name();
418  if (nodename.find("b0Truth_0") != std::string::npos) m_TTree_layer[0] = 1;
419  if (nodename.find("b0Truth_1") != std::string::npos) m_TTree_layer[1] = 1;
420  if (nodename.find("b0Truth_2") != std::string::npos) m_TTree_layer[2] = 1;
421  if (nodename.find("b0Truth_3") != std::string::npos) m_TTree_layer[3] = 1;
422  PHG4HitContainer *hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
423  if (!hits)
424  {
425  if (Verbosity()) std::cout << __PRETTY_FUNCTION__ << " could not find " << nodename << std::endl;
426  continue;
427  }
428  if (Verbosity()) std::cout << __PRETTY_FUNCTION__ << " number of hits: " << hits->size() << std::endl;
429  PHG4HitContainer::ConstRange hit_range = hits->getHits();
430  for (PHG4HitContainer::ConstIterator hit_iter = hit_range.first; hit_iter != hit_range.second; hit_iter++)
431  {
432  if (Verbosity()) std::cout << __PRETTY_FUNCTION__ << " checking hit id " << hit_iter->second->get_trkid() << " against " << track->get_truth_track_id() << std::endl;
433  if (hit_iter->second->get_trkid() - track->get_truth_track_id() == 0)
434  {
435  if (Verbosity()) std::cout << __PRETTY_FUNCTION__ << " found hit with id " << hit_iter->second->get_trkid() << std::endl;
436  if (iter->second > m_ProjectionNameMap.size())
437  {
438  std::cout << "bad index: " << iter->second << std::endl;
439  gSystem->Exit(1);
440  }
441  m_TTree_ref_vec[iter->second][0] = hit_iter->second->get_x(0);
442  m_TTree_ref_vec[iter->second][1] = hit_iter->second->get_y(0);
443  m_TTree_ref_vec[iter->second][2] = hit_iter->second->get_z(0);
444  m_TTree_ref_vec[iter->second][3] = hit_iter->second->get_t(0);
445 
446  m_TTree_ref_p_vec[iter->second][0] = hit_iter->second->get_px(0);
447  m_TTree_ref_p_vec[iter->second][1] = hit_iter->second->get_py(0);
448  m_TTree_ref_p_vec[iter->second][2] = hit_iter->second->get_pz(0);
449  }
450  }
451  }
452  } // find projections
453 
454  // find number of hits
455  for (const auto &g4hit_id_hitset : track->g4hit_ids())
456  {
457  const int &g4hit_id = g4hit_id_hitset.first;
458  const std::set<PHG4HitDefs::keytype> &g4hit_set = g4hit_id_hitset.second;
459  //
460  auto nhit_iter = m_TTree_HitContainerID_nHits_map.find(g4hit_id);
461  assert(nhit_iter != m_TTree_HitContainerID_nHits_map.end());
462  //
463  nhit_iter->second = g4hit_set.size();
464  }
465 
466  } // if (track)
467 
468  m_TracksEvalTree->Fill();
469  } // PHG4TruthInfoContainer::ConstRange range = m_TruthInfoContainer->GetPrimaryParticleRange();
470 
471  return;
472 }
473 
474 //----------------------------------------------------------------------------//
475 //-- fill_tree():
476 //-- Fill the trees with truth, track fit, and cluster information
477 //----------------------------------------------------------------------------//
479 {
481  {
482  LogError("m_TruthInfoContainer not found!");
483  return;
484  }
485 
486  if (!m_TrackMap)
487  {
488  LogError("m_TrackMap not found!");
489  return;
490  }
491 
492  if (!m_VertexMap)
493  {
494  return;
495  }
496 
497  for (SvtxVertexMap::Iter iter = m_VertexMap->begin();
498  iter != m_VertexMap->end();
499  ++iter)
500  {
501  SvtxVertex *vertex = iter->second;
502 
503  // Make sure to reset all the TTree variables before trying to set them.
504  reset_variables();
505  //std::cout << "A1" << std::endl;
507 
508  if (!vertex)
509  {
510  LogDebug("");
511  continue;
512  }
513 
514  //std::cout << "C1" << std::endl;
515  m_TTree_TrackID = vertex->get_id();
516  m_TTree_nTracks = vertex->size_tracks();
517 
518  m_TTree_vx = vertex->get_x();
519  m_TTree_vy = vertex->get_y();
520  m_TTree_vz = vertex->get_z();
521  m_TTree_DeltaVx = sqrt(vertex->get_error(1, 1));
522  m_TTree_DeltaVy = sqrt(vertex->get_error(2, 2));
523  m_TTree_DeltaVz = sqrt(vertex->get_error(3, 3));
524 
525  // best matched vertex
526  PHG4VtxPoint *best_vtx = nullptr;
527  int best_n_match = -1;
528  std::map<PHG4VtxPoint *, int> vertex_match_map;
529  for (auto iter_2 = vertex->begin_tracks(); iter_2 != vertex->end_tracks(); ++iter_2)
530  {
531  const auto &trackid = *iter_2;
532  const auto trackIter = m_TrackMap->find(trackid);
533 
534  if (trackIter == m_TrackMap->end()) continue;
535 
536  SvtxTrack_FastSim *temp = dynamic_cast<SvtxTrack_FastSim *>(trackIter->second);
537 
538  if (!temp) continue;
539 
540  const auto g4trackID = temp->get_truth_track_id();
541  const PHG4Particle *g4particle = m_TruthInfoContainer->GetParticle(g4trackID);
542  assert(g4particle);
543  PHG4VtxPoint *vtx = m_TruthInfoContainer->GetVtx(g4particle->get_vtx_id());
544 
545  int n_match = ++vertex_match_map[vtx];
546 
547  if (n_match > best_n_match)
548  {
549  best_n_match = n_match;
550  best_vtx = vtx;
551  }
552  }
553  if (best_vtx)
554  {
555  m_TTree_gvx = best_vtx->get_x();
556  m_TTree_gvy = best_vtx->get_y();
557  m_TTree_gvz = best_vtx->get_z();
558  m_TTree_gvt = best_vtx->get_t();
559 
560  m_TTree_nFromTruth = best_n_match;
561  m_TTree_gTrackID = best_vtx->get_id();
562  }
563  m_VertexEvalTree->Fill();
564  }
565  //std::cout << "B3" << std::endl;
566 
567  return;
568 }
569 
570 //----------------------------------------------------------------------------//
571 //-- reset_variables():
572 //-- Reset all the tree variables to their default values.
573 //-- Needs to be called at the start of every event
574 //----------------------------------------------------------------------------//
576 {
577  m_TTree_Event = -9999;
578 
579  //-- truth
580  m_TTree_gTrackID = -9999;
581  m_TTree_gFlavor = -9999;
582  m_TTree_gpx = NAN;
583  m_TTree_gpy = NAN;
584  m_TTree_gpz = NAN;
585 
586  m_TTree_gvx = NAN;
587  m_TTree_gvy = NAN;
588  m_TTree_gvz = NAN;
589  m_TTree_gvt = NAN;
590 
591  //-- reco
592  m_TTree_TrackID = -9999;
593  m_TTree_Charge = -9999;
594  m_TTree_nHits = -9999;
595  m_TTree_px = NAN;
596  m_TTree_py = NAN;
597  m_TTree_pz = NAN;
598  m_TTree_pcax = NAN;
599  m_TTree_pcay = NAN;
600  m_TTree_pcaz = NAN;
601  m_TTree_dca2d = NAN;
602 
603  m_TTree_vx = NAN;
604  m_TTree_vy = NAN;
605  m_TTree_vz = NAN;
606  m_TTree_DeltaVx = NAN;
607  m_TTree_DeltaVy = NAN;
608  m_TTree_DeltaVz = NAN;
609  m_TTree_nTracks = -9999;
610  m_TTree_nFromTruth = -9999;
611  for (auto &elem : m_TTree_proj_vec) std::fill(elem.begin(), elem.end(), -9999);
612  for (auto &elem : m_TTree_proj_p_vec) std::fill(elem.begin(), elem.end(), -9999);
613  for (auto &elem : m_TTree_ref_vec) std::fill(elem.begin(), elem.end(), -9999);
614  for (auto &elem : m_TTree_ref_p_vec) std::fill(elem.begin(), elem.end(), -9999);
615  for (auto &pair : m_TTree_HitContainerID_nHits_map) pair.second = 0;
616 }
617 
618 //----------------------------------------------------------------------------//
619 //-- GetNodes():
620 //-- Get all the all the required nodes off the node tree
621 //----------------------------------------------------------------------------//
623 {
624  //DST objects
625  //Truth container
626  m_TruthInfoContainer = findNode::getClass<PHG4TruthInfoContainer>(topNode,
627  "G4TruthInfo");
629  {
630  std::cout << PHWHERE << " PHG4TruthInfoContainer node not found on node tree"
631  << std::endl;
633  }
634 
635  m_TrackMap = findNode::getClass<SvtxTrackMap>(topNode,
637  //std::cout << m_TrackMapName << std::endl;
638  if (!m_TrackMap)
639  {
640  std::cout << PHWHERE << "SvtxTrackMap node with name "
641  << m_TrackMapName
642  << " not found on node tree"
643  << std::endl;
645  }
646 
647  m_VertexMap = findNode::getClass<SvtxVertexMap>(topNode, "SvtxVertexMap");
648  if (!m_VertexMap && Verbosity())
649  {
650  std::cout << PHWHERE << "SvtxTrackMap node with name SvtxVertexMap not found on node tree. Will not build the vertex eval tree"
651  << std::endl;
652  }
653 
655 }
656 
657 void B0TrackFastSimEval::AddProjection(const std::string &name)
658 {
659  if (Verbosity() > 0) std::cout << "B0TrackFastSimEval::AddProjection: Adding " << name << std::endl;
660  std::vector<float> floatvec{-9999, -9999, -9999, -9999};
661  m_TTree_proj_vec.push_back(floatvec);
662  m_TTree_proj_p_vec.push_back(floatvec);
663  m_TTree_ref_vec.push_back(floatvec);
664  m_TTree_ref_p_vec.push_back(floatvec);
665  // using m_ProjectionNameMap.size() makes sure it starts with 0 and then increments by 1
666  // for each additional projection
667  m_ProjectionNameMap.insert(make_pair(name, m_ProjectionNameMap.size()));
668  //cout <<"Projection name size: "<<m_ProjectionNameMap.size()<<endl;
669  return;
670 }