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