Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4ConsistencyCheck.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4ConsistencyCheck.cc
1 #include "PHG4ConsistencyCheck.h"
2 
3 #include "PHG4HitContainer.h"
5 #include "PHG4Hit.h"
6 #include "PHG4Particle.h"
7 
8 #include <phool/getClass.h>
9 
10 #include <iostream> // for operator<<, basic_ostream::opera...
11 #include <map> // for _Rb_tree_const_iterator, map<>::...
12 #include <set> // for set
13 #include <utility> // for pair
14 
15 class PHCompositeNode;
16 
17 using namespace std;
18 
20  SubsysReco(name),
21  errorcnt(0)
22 {}
23 
24 int
26 {
27 
28  return 0;
29 }
30 
31 int
33 {
34  PHG4TruthInfoContainer *truthcont = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo");
35  if (!truthcont)
36  {
37  return 0;
38  }
41  int imax = 1000000;
42  for (titer = trange.first; titer != trange.second; ++titer)
43  {
44  if (titer->first < imax)
45  {
46  imax = titer->first;
47  }
48  }
49  cout << "min index: " << imax << endl;
50  std::pair< std::map<int,int>::const_iterator, std::map<int,int>::const_iterator > embtrk_b_e = truthcont->GetEmbeddedTrkIds();
51  std::map<int,int>::const_iterator embiter;
52  for (embiter = embtrk_b_e.first; embiter != embtrk_b_e.second; ++embiter)
53  {
54  cout << "embedded trkid: " << embiter->first << endl;
55  }
56  PHG4HitContainer *ghit = findNode::getClass<PHG4HitContainer>(topNode, "G4HIT_CEMC_E");
57  if (ghit)
58  {
60  PHG4HitContainer::ConstRange hit_begin_end = ghit->getHits();
61  set<int> printpart;
62  for (hit = hit_begin_end.first; hit != hit_begin_end.second; ++hit)
63  {
64 
65  int trkid = hit->second->get_trkid();
66  PHG4Particle* part = truthcont->GetParticle(trkid);
67  if (!part)
68  {
69  hit->second->identify();
70  cout << "could not locate geant particle " << trkid << " in G4HIT_CEMC_E" << endl;
71  errorcnt++;
72  }
73  else
74  {
75  int primary_id = part->get_primary_id();
76  if (truthcont->isEmbeded(primary_id)>0)
77  {
78  if (printpart.find(primary_id) == printpart.end())
79  {
80  cout << "primary id " << primary_id << " is embedded" << endl;
81  printpart.insert(primary_id);
82  PHG4Particle* parta = truthcont->GetParticle(primary_id);
83  parta->identify();
84  }
85  }
86  }
87  }
88  }
89  ghit = findNode::getClass<PHG4HitContainer>(topNode, "G4HIT_SVTX");
90  if (ghit)
91  {
93  PHG4HitContainer::ConstRange hit_begin_end = ghit->getHits();
94  for (hit = hit_begin_end.first; hit != hit_begin_end.second; ++hit)
95  {
96  int trkid = hit->second->get_trkid();
97  PHG4Particle* part = truthcont->GetParticle(trkid);
98  if (!part)
99  {
100  cout << "could not locate geant particle " << trkid << " in G4HIT_SVTX" << endl;
101  errorcnt++;
102  }
103  }
104  }
105 
106  return 0;
107 }