ATLAS Offline Software
StepInfo.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef LARG4GENSHOWERLIB_STEPINFO_H
6 #define LARG4GENSHOWERLIB_STEPINFO_H
7 
8 // STL includes
9 #include <iostream>
10 
11 // CLHEP include for Hep3Vector
12 #include "CLHEP/Vector/ThreeVector.h"
13 
14 
16 namespace ShowerLib
17 {
18 
34  class StepInfo
35  {
36 
37  public:
38 
40  StepInfo(): m_dep(0.), m_time(0.), m_valid(true) {}
41 
42  StepInfo(const StepInfo& first, const StepInfo& second);
43 
44  /* access functions */
45 
47  inline void setP(const CLHEP::Hep3Vector& p) { m_pos = p; }
49  inline void setX(const double x) { return m_pos.setX(x); }
51  inline void setY(const double y) { return m_pos.setY(y); }
53  inline void setZ(const double z) { return m_pos.setZ(z); }
55  inline void setE(const double t) { m_dep = t; }
57  inline void setTime(const double t) { m_time = t; }
59  inline void setValid(const bool flag) { m_valid = flag; }
60 
62  inline CLHEP::Hep3Vector position() const { return m_pos; }
64  inline double x() const { return m_pos.x(); }
66  inline double y() const { return m_pos.y(); }
68  inline double z() const { return m_pos.z(); }
70  inline double dep() const { return m_dep; }
72  inline double time() const { return m_time; }
74  inline bool valid() const { return m_valid; }
75 
76  /* helper functions */
77 
79  double diff2(const StepInfo& other) const;
80 
83 
84  private:
85 
86  // data members
87  CLHEP::Hep3Vector m_pos;
88  double m_dep;
89  double m_time;
90  bool m_valid;
91 
92  };
93 
94 
95  // INLINE DEFINITIONS
97  {
98  double esum = first.m_dep + second.m_dep;
99  double w1 = 0;
100  double w2 = 0;
101 
102  if (esum > 0) {
103  w1 = first.m_dep/esum;
104  w2 = second.m_dep/esum;
105  }
106 
107  m_pos = w1*first.m_pos + w2*second.m_pos;
108  m_time = w1*first.m_time + w2*second.m_time;
109  m_dep = esum;
110  m_valid = true;
111  }
112 
113  inline double StepInfo::diff2(const StepInfo& other) const
114  {
115  return (this->position().diff2(other.position()));
116  }
117 
119  {
120  double esum = m_dep + other.m_dep;
121  double w1 = 0;
122  double w2 = 0;
123 
124  if (esum > 0) {
125  w1 = m_dep/esum;
126  w2 = other.m_dep/esum;
127  } else {
128  std::cout << "Error: hit combination: sum of deposited energy is zero!" << std::endl;
129  }
130 
131  m_pos = w1*m_pos + w2*other.m_pos;
132  m_dep += other.m_dep;
133 
134  return *this;
135  }
136 
137 } // namespace ShowerLib
138 
139 #endif // LARG4GENSHOWERLIB_STEPINFO_H
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ShowerLib::StepInfo::setTime
void setTime(const double t)
set time
Definition: StepInfo.h:57
ShowerLib::StepInfo::operator+=
StepInfo & operator+=(const StepInfo &other)
energy weighted sum
Definition: StepInfo.h:118
ShowerLib::StepInfo::setValid
void setValid(const bool flag)
set validity
Definition: StepInfo.h:59
ShowerLib::StepInfo::position
CLHEP::Hep3Vector position() const
return spacial position
Definition: StepInfo.h:62
ShowerLib::StepInfo::m_dep
double m_dep
deposited energy
Definition: StepInfo.h:88
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ShowerLib::StepInfo::time
double time() const
return time of hit
Definition: StepInfo.h:72
ShowerLib::StepInfo::setP
void setP(const CLHEP::Hep3Vector &p)
set position
Definition: StepInfo.h:47
ShowerLib::StepInfo::setX
void setX(const double x)
set x position
Definition: StepInfo.h:49
ShowerLib::StepInfo::m_pos
CLHEP::Hep3Vector m_pos
spatial position
Definition: StepInfo.h:87
ShowerLib::StepInfo::setZ
void setZ(const double z)
set z position
Definition: StepInfo.h:53
ShowerLib::StepInfo::m_valid
bool m_valid
flag, if hit is valid
Definition: StepInfo.h:90
ShowerLib::StepInfo::y
double y() const
return y position
Definition: StepInfo.h:66
ShowerLib::StepInfo::valid
bool valid() const
return validity flag
Definition: StepInfo.h:74
master.flag
bool flag
Definition: master.py:29
ShowerLib::StepInfo::StepInfo
StepInfo()
empty default constructor
Definition: StepInfo.h:40
ShowerLib::StepInfo::x
double x() const
return x position
Definition: StepInfo.h:64
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
DeMoScan.first
bool first
Definition: DeMoScan.py:534
ShowerLib::StepInfo::diff2
double diff2(const StepInfo &other) const
return spactial distance squared
Definition: StepInfo.h:113
ShowerLib::StepInfo::setE
void setE(const double t)
set depoisted energy
Definition: StepInfo.h:55
ShowerLib
Namespace for the ShowerLib related classes.
Definition: LArG4GenShowerLib.h:19
ShowerLib::StepInfo::z
double z() const
return z position
Definition: StepInfo.h:68
ShowerLib::StepInfo::m_time
double m_time
time
Definition: StepInfo.h:89
ShowerLib::StepInfo
Class to collect information about G4 steps.
Definition: StepInfo.h:35
ShowerLib::StepInfo::dep
double dep() const
return deposited energy
Definition: StepInfo.h:70
ShowerLib::StepInfo::setY
void setY(const double y)
set y position
Definition: StepInfo.h:51