Shower.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 //
3 // \brief Definition of shower object for LArSoft
4 //
5 // \author brebel@fnal.gov, modifications by andrzej.szelc@yale.edu and yuntse@slac.stanford.edu
6 //
7 ////////////////////////////////////////////////////////////////////////////
8 #ifndef SHOWER_H
9 #define SHOWER_H
10 
11 #include <iosfwd>
12 #include <limits> // std::numeric_limits<>
14 
15 #include "TVector3.h"
16 
17 namespace recob {
18 
19  class Shower {
20 
21  public:
22 
23  Shower(); ///Default constructor
24 
25  private:
26 
27  int fID;
28  TVector3 fDCosStart; ///< direction cosines at start of shower
29  TVector3 fSigmaDCosStart; ///< uncertainty on initial direction cosines
30  TVector3 fXYZstart; ///< direction cosines at start of shower
31  TVector3 fSigmaXYZstart; ///< uncertainty on initial direction cosines
32  std::vector< double > fTotalEnergy; ///< Calculated Energy per each plane
33  std::vector< double > fSigmaTotalEnergy; ///< Calculated Energy per each plane
34  std::vector< double > fdEdx; ///< Calculated dE/dx per each plane
35  std::vector< double > fSigmadEdx; ///< Calculated dE/dx per each plane
36 
37  std::vector< double > fTotalMIPEnergy; ///< Calculated Energy per each plane
38  std::vector< double > fSigmaTotalMIPEnergy; ///< Calculated Energy per each plane
40  /**
41  * @brief Shower length [cm].
42  *
43  * The length of a shower, and should be greater than 0.
44  * The characteristic depends on shower reconstruction algorithms.
45  * For example, in PCAShowerParticleBuildingAlgorithm (larpandora),
46  * it is defined as the three standard deviations of the spacepoint
47  * distribution along the principal axis.
48  *
49  */
50  double fLength;
51 
52  /**
53  * @brief Opening angle [rad].
54  *
55  * The angle is defined in the @f$ [ 0, \pi/2 ] @f$ range.
56  * It is defined as the angle of the shower cone.
57  * The characteristic depends on shower reconstruction algorithms.
58  * For example, in PCAShowerParticleBuildingAlgorithm (larpandora),
59  * it is defined as the ratio of the standard deviation of the
60  * spacepoint distribution along the principal axis to that along
61  * the secondary axis.
62  *
63  */
64  double fOpenAngle;
65 
66  /**
67  * @brief The magic constant indicating the invalidity of the
68  * shower length variable
69  *
70  * This internal constant represents invalid shower length.
71  * It is how the function has_length() determines the validity
72  * of fLength.
73  *
74  */
75  static constexpr double InvalidLength
76  = std::numeric_limits<double>::lowest();
77 
78  /**
79  * @brief The magic constant indicating the invalidity of the
80  * opening angle variable
81  *
82  * This internal constant represents invalid opening angle.
83  * It is how the function has_open_angle() determines the validity
84  * of fOpenAngle.
85  *
86  */
87  static constexpr double InvalidOpeningAngle
88  = std::numeric_limits<double>::lowest();
89 
90  public:
91 
92  Shower(TVector3 const& dcosVtx,
93  TVector3 const& dcosVtxErr,
94  TVector3 const& xyz,
95  TVector3 const& xyzErr,
96  std::vector< double > TotalEnergy,
97  std::vector< double > TotalEnergyErr,
98  std::vector< double > dEdx,
99  std::vector< double > dEdxErr,
100  int bestplane,
101  int id,
102  double length,
103  double openAngle);
104 
105  /// Legacy constructor (with no length and no opening angle).
106  /// @deprecated Use the complete constructor instead!
107  Shower(TVector3 const& dcosVtx,
108  TVector3 const& dcosVtxErr,
109  TVector3 const& xyz,
110  TVector3 const& xyzErr,
111  std::vector< double > TotalEnergy,
112  std::vector< double > TotalEnergyErr,
113  std::vector< double > dEdx,
114  std::vector< double > dEdxErr,
115  int bestplane,
116  int id=util::kBogusI)
117  :
118  Shower(
119  dcosVtx, dcosVtxErr, xyz, xyzErr, TotalEnergy, TotalEnergyErr, dEdx, dEdxErr,
120  bestplane, id,
122  )
123  {}
124 
125 
126 
127  //set methods
128  void set_id (const int id) { fID = id; }
129  void set_total_energy (const std::vector< double >& q) { fTotalEnergy = q; }
130  void set_total_energy_err (const std::vector< double >& q) { fSigmaTotalEnergy = q; }
131  void set_total_MIPenergy (const std::vector< double >& q) { fTotalMIPEnergy = q; }
132  void set_total_MIPenergy_err (const std::vector< double >& q) { fSigmaTotalMIPEnergy = q; }
133  void set_total_best_plane (const int q) { fBestPlane = q; }
134 
135  void set_direction (const TVector3& dir) { fDCosStart = dir; }
136  void set_direction_err (const TVector3& dir_e) { fSigmaDCosStart = dir_e; }
137  void set_start_point (const TVector3& xyz) { fXYZstart = xyz; }
138  void set_start_point_err (const TVector3& xyz_e) { fSigmaXYZstart = xyz_e; }
139  void set_dedx (const std::vector< double >& q) { fdEdx = q; }
140  void set_dedx_err (const std::vector< double >& q) { fSigmadEdx = q; }
141  void set_length(const double& l) { fLength = l; }
142  void set_open_angle( const double& a ) { fOpenAngle = a; }
143 
144 
145  int ID() const;
146 
147  const TVector3& Direction() const;
148  const TVector3& DirectionErr() const;
149 
150  const TVector3& ShowerStart() const;
151  const TVector3& ShowerStartErr() const;
152 
153  const std::vector< double >& Energy() const;
154  const std::vector< double >& EnergyErr() const;
155 
156  const std::vector< double >& MIPEnergy() const;
157  const std::vector< double >& MIPEnergyErr() const;
158  int best_plane() const;
159  double Length() const;
160  double OpenAngle() const;
161  const std::vector< double >& dEdx() const;
162  const std::vector< double >& dEdxErr() const;
163 
164  //
165  // being floating point numbers, equality is a risky comparison;
166  // we use anything negative to denote that the following items are not valid
167  //
168 
169  /// Returns whether the shower has a valid opening angle.
170  bool has_open_angle() const;
171 
172  /// Returns whether the shower has a valid length.
173  bool has_length() const;
174 
175 
176  friend std::ostream& operator << (std::ostream& stream, Shower const& a);
177 
178  friend bool operator < (const Shower & a, const Shower & b);
179 
180  static_assert(InvalidLength < 0.0f, "Invalid length must be negative!");
181  static_assert
182  (InvalidOpeningAngle < 0.0f, "Invalid opening angle must be negative!");
183 
184  }; // recob::Shower
185 }
186 
187  inline int recob::Shower::ID() const { return fID; }
188 
189  inline const TVector3& recob::Shower::Direction() const { return fDCosStart; }
190  inline const TVector3& recob::Shower::DirectionErr() const { return fSigmaDCosStart; }
191 
192  inline const TVector3& recob::Shower::ShowerStart() const { return fXYZstart; }
193  inline const TVector3& recob::Shower::ShowerStartErr() const { return fSigmaXYZstart; }
194 
195  inline const std::vector< double >& recob::Shower::Energy() const { return fTotalEnergy; }
196  inline const std::vector< double >& recob::Shower::EnergyErr() const { return fSigmaTotalEnergy; }
197 
198  inline const std::vector< double >& recob::Shower::MIPEnergy() const { return fTotalMIPEnergy; }
199  inline const std::vector< double >& recob::Shower::MIPEnergyErr() const { return fSigmaTotalMIPEnergy; }
200  inline int recob::Shower::best_plane() const { return fBestPlane; }
201  inline double recob::Shower::Length() const { return fLength; }
202  inline double recob::Shower::OpenAngle() const { return fOpenAngle; }
203  inline const std::vector< double >& recob::Shower::dEdx() const { return fdEdx; }
204  inline const std::vector< double >& recob::Shower::dEdxErr() const { return fSigmadEdx; }
205 
206  //
207  // being floating point numbers, equality is a risky comparison;
208  // we use anything negative to denote that the following items are not valid
209  //
210  inline bool recob::Shower::has_open_angle() const { return fOpenAngle >= 0.0; }
211  inline bool recob::Shower::has_length() const { return fLength >= 0.0; }
212 
213 
214 
215 
216 
217 #endif // SHOWER_H
int best_plane() const
Definition: Shower.h:200
const std::vector< double > & dEdxErr() const
Definition: Shower.h:204
void set_start_point_err(const TVector3 &xyz_e)
Definition: Shower.h:138
const TVector3 & ShowerStart() const
Definition: Shower.h:192
void set_dedx_err(const std::vector< double > &q)
Definition: Shower.h:140
void set_direction_err(const TVector3 &dir_e)
Definition: Shower.h:136
std::vector< double > fTotalEnergy
Calculated Energy per each plane.
Definition: Shower.h:32
Reconstruction base classes.
bool has_length() const
Returns whether the shower has a valid length.
Definition: Shower.h:211
double Length() const
Definition: Shower.h:201
const std::vector< double > & EnergyErr() const
Definition: Shower.h:196
std::vector< double > fSigmaTotalMIPEnergy
Calculated Energy per each plane.
Definition: Shower.h:38
std::vector< double > fSigmadEdx
Calculated dE/dx per each plane.
Definition: Shower.h:35
TVector3 fSigmaXYZstart
uncertainty on initial direction cosines
Definition: Shower.h:31
const std::vector< double > & Energy() const
Definition: Shower.h:195
void set_total_energy(const std::vector< double > &q)
Definition: Shower.h:129
friend bool operator<(const Shower &a, const Shower &b)
Definition: Shower.cxx:66
const TVector3 & ShowerStartErr() const
Definition: Shower.h:193
constexpr int kBogusI
obviously bogus integer value
std::vector< double > fTotalMIPEnergy
Calculated Energy per each plane.
Definition: Shower.h:37
void set_total_MIPenergy_err(const std::vector< double > &q)
Definition: Shower.h:132
string dir
static QStrList * l
Definition: config.cpp:1044
void set_total_energy_err(const std::vector< double > &q)
Definition: Shower.h:130
bool has_open_angle() const
Returns whether the shower has a valid opening angle.
Definition: Shower.h:210
static constexpr double InvalidLength
The magic constant indicating the invalidity of the shower length variable.
Definition: Shower.h:76
void set_id(const int id)
Definition: Shower.h:128
const std::vector< double > & MIPEnergyErr() const
Definition: Shower.h:199
void set_direction(const TVector3 &dir)
Definition: Shower.h:135
const std::vector< double > & dEdx() const
Definition: Shower.h:203
const std::vector< double > & MIPEnergy() const
Definition: Shower.h:198
static constexpr double InvalidOpeningAngle
The magic constant indicating the invalidity of the opening angle variable.
Definition: Shower.h:88
const double a
void set_length(const double &l)
Definition: Shower.h:141
double OpenAngle() const
Definition: Shower.h:202
void set_open_angle(const double &a)
Definition: Shower.h:142
TVector3 fDCosStart
direction cosines at start of shower
Definition: Shower.h:28
const TVector3 & DirectionErr() const
Definition: Shower.h:190
int fID
Default constructor.
Definition: Shower.h:27
TVector3 fSigmaDCosStart
uncertainty on initial direction cosines
Definition: Shower.h:29
const TVector3 & Direction() const
Definition: Shower.h:189
std::vector< double > fdEdx
Calculated dE/dx per each plane.
Definition: Shower.h:34
void set_total_best_plane(const int q)
Definition: Shower.h:133
void set_total_MIPenergy(const std::vector< double > &q)
Definition: Shower.h:131
double fOpenAngle
Opening angle [rad].
Definition: Shower.h:64
double fLength
Shower length [cm].
Definition: Shower.h:50
int fBestPlane
Definition: Shower.h:39
static bool * b
Definition: config.cpp:1043
friend std::ostream & operator<<(std::ostream &stream, Shower const &a)
Definition: Shower.cxx:54
TVector3 fXYZstart
direction cosines at start of shower
Definition: Shower.h:30
void set_start_point(const TVector3 &xyz)
Definition: Shower.h:137
Collection of Physical constants used in LArSoft.
Shower(TVector3 const &dcosVtx, TVector3 const &dcosVtxErr, TVector3 const &xyz, TVector3 const &xyzErr, std::vector< double > TotalEnergy, std::vector< double > TotalEnergyErr, std::vector< double > dEdx, std::vector< double > dEdxErr, int bestplane, int id=util::kBogusI)
Definition: Shower.h:107
int ID() const
Definition: Shower.h:187
std::vector< double > fSigmaTotalEnergy
Calculated Energy per each plane.
Definition: Shower.h:33
void set_dedx(const std::vector< double > &q)
Definition: Shower.h:139