ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EICPIDParticle.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EICPIDParticle.cc
1 #include "EICPIDParticle.h"
2 
3 #include <TSystem.h> // for gSystem
4 
5 #include <cassert>
6 #include <cstdlib>
7 #include <type_traits>
8 
9 using namespace std;
10 
11 const std::map<EICPIDParticle::PROPERTY,
12  std::pair<const std::string, EICPIDParticle::PROPERTY_TYPE> >
14  {Truth_PID, {"Truth PID", type_int}},
15  {Truth_momentum, {"Truth Momentum", type_float}},
16  {Truth_eta, {"Truth eta", type_float}},
17  {CTTL_beta, {"Beta on CTTL", type_float}},
18  {ETTL_beta, {"Beta on ETTL", type_float}},
19  {FTTL_beta, {"Beta on FTTL", type_float}} //
20 };
21 
23 {
24  const EICPIDParticle* src = dynamic_cast<const EICPIDParticle*>(phobj);
25  assert(src);
26  set_id(src->get_id());
27  // This is a generic copy of ALL properties a hit has
28  // do not add explicit copies, they will be added to
29  // the new hits with their default value increasing memory use
30  for (unsigned char ic = 0; ic < UCHAR_MAX; ic++)
31  {
32  PROPERTY prop_id = static_cast<EICPIDParticle::PROPERTY>(ic);
33  if (src->has_property(prop_id))
34  {
35  set_property_nocheck(prop_id, src->get_property_nocheck(prop_id));
36  }
37  }
38 }
39 
40 void EICPIDParticle::identify(ostream& os) const
41 {
42  os << "Class " << this->ClassName() << endl;
43  return;
44 }
45 
47 {
48  cout << "Reset not implemented by daughter class" << endl;
49  return;
50 }
51 
52 std::pair<const std::string, EICPIDParticle::PROPERTY_TYPE>
54 {
55  const auto iter = m_propertyInfo.find(prop_id);
56 
57  if (iter == m_propertyInfo.end())
58  {
59  cout << "EICPIDParticle::get_property_info - Fatal Error - unknown index " << prop_id << endl;
60  gSystem->Exit(1);
61  exit(1);
62  }
63  else
64  {
65  return iter->second;
66  }
67 }
68 
69 bool EICPIDParticle::check_property(const PROPERTY prop_id, const PROPERTY_TYPE prop_type)
70 {
71  pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
72  if (property_info.second != prop_type)
73  {
74  return false;
75  }
76  return true;
77 }
78 
79 string
81 {
82  switch (prop_type)
83  {
84  case type_int:
85  return "int";
86  case type_uint:
87  return "unsigned int";
88  case type_float:
89  return "float";
90  default:
91  return "unkown";
92  }
93 }