Utils.cpp
Go to the documentation of this file.
1 #include "Utils.h"
2 
4 : _seed(0), _rando(new TRandom3(0))
5 {
6  _origin[0] = 0.;
7  _origin[1] = 0.;
8  _origin[2] = 0.;
9 }
10 
12 {
13  delete _rando;
14 }
15 
16 void Utils::SetSeed(int seed)
17 {
18  _seed = seed;
19  _rando->SetSeed(_seed);
20 }
21 
22 void Utils::SetOrigin(double *origin)
23 {
24  _origin[0] = origin[0];
25  _origin[1] = origin[1];
26  _origin[2] = origin[2];
27 }
28 
29 bool Utils::PointInFiducial(const TVector3 &point)
30 {
31  //TPC Fiducial volume defined as
32  //R < 260 cm
33  //|X| < 250 cm
34  bool isInFiducial = true;
35 
36  float r_point = std::sqrt( point.Y()*point.Y() + point.Z()*point.Z() );
37  if( r_point > _TPCFidRadius ) isInFiducial = false;
38  if( r_point < _TPCFidRadius && std::abs(point.X()) > _TPCFidLength ) isInFiducial = false;
39 
40  return isInFiducial;
41 }
42 
43 bool Utils::PointInTPC(const TVector3 &point)
44 {
45  //TPC volume defined as
46  //R < 260 cm
47  //|X| < 250 cm
48  if(PointInFiducial(point)) return true;
49  bool isInTPC = true;
50 
51  float r_point = std::sqrt( point.Y()*point.Y() + point.Z()*point.Z() );
52  if( r_point > _TPCRadius ) isInTPC = false;
53  if( r_point < _TPCRadius && std::abs(point.X()) > _TPCLength ) isInTPC = false;
54 
55  return isInTPC;
56 }
57 
58 bool Utils::PointInCalo(const TVector3 &point)
59 {
60  //Barrel Radius 278 cm
61  //Endcap starts at 364 cm
62  bool isInCalo = false;
63  float r_point = std::sqrt( point.Y()*point.Y() + point.Z()*point.Z() );
64  //in the Barrel
65  if( r_point > _ECALInnerRadius && r_point < _ECALOuterRadius && std::abs(point.X()) < _ECALStartX ) isInCalo = true;
66  //in the Endcap
67  if( r_point < _ECALInnerRadius && std::abs(point.X()) > _ECALStartX && std::abs(point.X()) < _ECALEndX ) isInCalo = true;
68 
69  return isInCalo;
70 }
71 
72 bool Utils::PointStopBetween(const TVector3 &point)
73 {
74  //Barrel Radius 278 cm
75  //Endcap starts at 364 cm
76  bool isStopBetween = false;
77  float r_point = std::sqrt( point.Y()*point.Y() + point.Z()*point.Z() );
78  //in the Barrel
79  if( r_point < _ECALInnerRadius && r_point > _TPCRadius && std::abs(point.X()) < _TPCLength ) isStopBetween = true;
80  //in the Endcap
81  if( r_point < _ECALInnerRadius && std::abs(point.X()) > _TPCLength && std::abs(point.X()) < _ECALStartX ) isStopBetween = true;
82 
83  return isStopBetween;
84 }
85 
86 bool Utils::isThroughCalo(const TVector3 &point)
87 {
88  return !PointInTPC(point) && !PointStopBetween(point) && !PointInCalo(point);
89 }
90 
91 bool Utils::hasDecayedInCalo(const TVector3 &point)
92 {
93  return PointInCalo(point);
94 }
95 
96 bool Utils::isBarrel(const TVector3 &point)
97 {
98  bool isBarrel = false;
99  float theta = std::atan(_ECALInnerRadius / std::abs(_ECALStartX) ); //angle for barrel/endcap transition
100  float r_point = std::sqrt( point.Y()*point.Y() + point.Z()*point.Z() );
101  float theta_point = std::atan(r_point / std::abs(point.X()) ); //angle for barrel/endcap transition for the point
102 
103  if( theta_point > theta ) isBarrel = true;
104  return isBarrel;
105 }
106 
107 bool Utils::isEndcap(const TVector3 &point)
108 {
109  bool isEndcap = false;
110  if( !isBarrel(point) ) isEndcap = true;
111  return isEndcap;
112 }
113 
114 bool Utils::isBackscatter(const TVector3 &spoint, const TVector3 &epoint)
115 {
116  bool isBackscatter = false;
117 
118  //check if started in the ECAL but made it to the tracker
119  float r_spoint = std::sqrt( spoint.Y()*spoint.Y() + spoint.Z()*spoint.Z() );
120  float r_epoint = std::sqrt( epoint.Y()*epoint.Y() + epoint.Z()*epoint.Z() );
121 
122  //in the Barrel
123  if( r_spoint > _ECALInnerRadius && r_epoint < _TPCRadius ) isBackscatter = true;
124  //in the Endcap
125  if( (r_spoint < _ECALInnerRadius && r_epoint < _TPCRadius) && ( std::abs(spoint.X()) > _ECALStartX && std::abs(epoint.X()) < _TPCLength ) ) isBackscatter = true;
126 
127  return isBackscatter;
128 }
129 
130 bool Utils::isBremsstrahlung(const TVector3 &spoint, const int& pdg, const int& motherpdg)
131 {
132  bool isBremsstrahlung = false;
133 
134  //Check if it has origin in the tracker and that the pdg is photon and mother is electron/positron (most probable)
135  if(PointInFiducial(spoint) && pdg == 22 && std::abs(motherpdg) == 11) isBremsstrahlung = true;
136 
137  return isBremsstrahlung;
138 }
bool isBarrel(const TVector3 &point)
Definition: Utils.cpp:96
double _TPCRadius
Definition: Utils.h:80
bool isBremsstrahlung(const TVector3 &spoint, const int &pdg, const int &motherpdg)
Definition: Utils.cpp:130
double _TPCLength
Definition: Utils.h:81
double _ECALStartX
Definition: Utils.h:85
~Utils()
Definition: Utils.cpp:11
Utils()
Definition: Utils.cpp:3
TRandom3 * _rando
random generator
Definition: Utils.h:65
double _ECALEndX
Definition: Utils.h:84
bool hasDecayedInCalo(const TVector3 &point)
Definition: Utils.cpp:91
T abs(T value)
bool PointInTPC(const TVector3 &point)
Definition: Utils.cpp:43
unsigned long int _seed
seed
Definition: Utils.h:64
bool isThroughCalo(const TVector3 &point)
Definition: Utils.cpp:86
double _ECALOuterRadius
Definition: Utils.h:83
void SetOrigin(double *origin)
Definition: Utils.cpp:22
bool isBackscatter(const TVector3 &spoint, const TVector3 &epoint)
Definition: Utils.cpp:114
bool PointInCalo(const TVector3 &point)
Definition: Utils.cpp:58
void SetSeed(int seed)
Definition: Utils.cpp:16
double _ECALInnerRadius
Definition: Utils.h:82
double _TPCFidRadius
Definition: Utils.h:78
bool PointInFiducial(const TVector3 &point)
Definition: Utils.cpp:29
double _TPCFidLength
Definition: Utils.h:79
bool isEndcap(const TVector3 &point)
Definition: Utils.cpp:107
bool PointStopBetween(const TVector3 &point)
Definition: Utils.cpp:72
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
double _origin[3]
coordinates of the origin
Definition: Utils.h:63