ATLAS Offline Software
Loading...
Searching...
No Matches
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
16namespace ShowerLib
17{
18
33
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
82 StepInfo& operator+=(const StepInfo& other );
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
96 inline StepInfo::StepInfo(const StepInfo& first, const StepInfo& second)
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
Class to collect information about G4 steps.
Definition StepInfo.h:35
CLHEP::Hep3Vector m_pos
spatial position
Definition StepInfo.h:87
StepInfo & operator+=(const StepInfo &other)
energy weighted sum
Definition StepInfo.h:118
void setTime(const double t)
set time
Definition StepInfo.h:57
double diff2(const StepInfo &other) const
return spactial distance squared
Definition StepInfo.h:113
void setY(const double y)
set y position
Definition StepInfo.h:51
CLHEP::Hep3Vector position() const
return spacial position
Definition StepInfo.h:62
double z() const
return z position
Definition StepInfo.h:68
double y() const
return y position
Definition StepInfo.h:66
void setZ(const double z)
set z position
Definition StepInfo.h:53
void setP(const CLHEP::Hep3Vector &p)
set position
Definition StepInfo.h:47
double m_dep
deposited energy
Definition StepInfo.h:88
StepInfo()
empty default constructor
Definition StepInfo.h:40
bool valid() const
return validity flag
Definition StepInfo.h:74
double x() const
return x position
Definition StepInfo.h:64
void setValid(const bool flag)
set validity
Definition StepInfo.h:59
double time() const
return time of hit
Definition StepInfo.h:72
double dep() const
return deposited energy
Definition StepInfo.h:70
bool m_valid
flag, if hit is valid
Definition StepInfo.h:90
double m_time
time
Definition StepInfo.h:89
void setE(const double t)
set depoisted energy
Definition StepInfo.h:55
void setX(const double x)
set x position
Definition StepInfo.h:49
Namespace for the ShowerLib related classes.
Definition StepInfo.h:17