LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
opdet::FlashHypothesis Class Reference

#include "FlashHypothesis.h"

Public Member Functions

 FlashHypothesis ()
 
 FlashHypothesis (size_t s)
 
 FlashHypothesis (std::vector< float > const &vector, std::vector< float > const &vector_error=std::vector< float >())
 
std::vector< float > const & GetHypothesisVector () const
 
std::vector< float > const & GetHypothesisErrorVector () const
 
void SetHypothesisVector (std::vector< float > v)
 
void SetHypothesisErrorVector (std::vector< float > v)
 
void SetHypothesisVectorAndErrorVector (std::vector< float > v, std::vector< float > err=std::vector< float >(0))
 
float const & GetHypothesis (size_t i_opdet) const
 
float const & GetHypothesisError (size_t i_opdet) const
 
void SetHypothesis (size_t i_opdet, float pe)
 
void SetHypothesisError (size_t i_opdet, float err)
 
void SetHypothesisAndError (size_t i_opdet, float pe, float err=-999)
 
float GetTotalPEs () const
 
float GetTotalPEsError () const
 
size_t GetVectorSize () const
 
void Normalize (float const &totalPE_target)
 
void Print ()
 
FlashHypothesis operator+ (const FlashHypothesis &fh)
 

Private Attributes

std::vector< float > _NPEs_Vector
 
std::vector< float > _NPEs_ErrorVector
 

Detailed Description

Definition at line 18 of file FlashHypothesis.h.

Constructor & Destructor Documentation

opdet::FlashHypothesis::FlashHypothesis ( )
inline

Definition at line 21 of file FlashHypothesis.h.

Referenced by opdet::FlashHypothesisCollection::FlashHypothesisCollection().

21 {}
opdet::FlashHypothesis::FlashHypothesis ( size_t  s)
inline

Definition at line 22 of file FlashHypothesis.h.

References _NPEs_ErrorVector, and _NPEs_Vector.

23  {
24  _NPEs_Vector = std::vector<float>(s, 0.0);
25  _NPEs_ErrorVector = std::vector<float>(s, 0.0);
26  }
std::vector< float > _NPEs_ErrorVector
std::vector< float > _NPEs_Vector
opdet::FlashHypothesis::FlashHypothesis ( std::vector< float > const &  vector,
std::vector< float > const &  vector_error = std::vector<float>() 
)
inline

Definition at line 27 of file FlashHypothesis.h.

References SetHypothesisVectorAndErrorVector().

29  {
30  SetHypothesisVectorAndErrorVector(vector, vector_error);
31  }
void SetHypothesisVectorAndErrorVector(std::vector< float > v, std::vector< float > err=std::vector< float >(0))

Member Function Documentation

float const& opdet::FlashHypothesis::GetHypothesis ( size_t  i_opdet) const
inline

Definition at line 48 of file FlashHypothesis.h.

References _NPEs_Vector.

Referenced by opdet::FlashHypothesisComparison::FillFlashHypothesisInfo(), and Print().

48 { return _NPEs_Vector.at(i_opdet); }
std::vector< float > _NPEs_Vector
float const& opdet::FlashHypothesis::GetHypothesisError ( size_t  i_opdet) const
inline

Definition at line 49 of file FlashHypothesis.h.

References _NPEs_ErrorVector.

Referenced by Print().

49 { return _NPEs_ErrorVector.at(i_opdet); }
std::vector< float > _NPEs_ErrorVector
std::vector<float> const& opdet::FlashHypothesis::GetHypothesisErrorVector ( ) const
inline

Definition at line 34 of file FlashHypothesis.h.

References _NPEs_ErrorVector.

Referenced by opdet::FlashUtilities::CompareByError().

34 { return _NPEs_ErrorVector; }
std::vector< float > _NPEs_ErrorVector
std::vector<float> const& opdet::FlashHypothesis::GetHypothesisVector ( ) const
inline
float opdet::FlashHypothesis::GetTotalPEs ( ) const
inline
float opdet::FlashHypothesis::GetTotalPEsError ( ) const
inline

Definition at line 59 of file FlashHypothesis.h.

References _NPEs_ErrorVector.

Referenced by opdet::FlashUtilities::CompareByError(), opdet::FlashHypothesisComparison::FillFlashHypothesisInfo(), and Print().

60  {
61  return std::sqrt(std::inner_product(
62  _NPEs_ErrorVector.begin(), _NPEs_ErrorVector.end(), _NPEs_ErrorVector.begin(), 0.0));
63  }
std::vector< float > _NPEs_ErrorVector
size_t opdet::FlashHypothesis::GetVectorSize ( ) const
inline
void opdet::FlashHypothesis::Normalize ( float const &  totalPE_target)

Definition at line 32 of file FlashHypothesis.cxx.

References _NPEs_ErrorVector, _NPEs_Vector, and GetTotalPEs().

Referenced by opdet::FlashHypothesisCollection::GetTotalHypothesis(), GetVectorSize(), opdet::FlashHypothesisCollection::SetPromptHypAndPromptFraction(), and opdet::FlashHypothesisCollection::SetTotalHypAndPromptFraction().

33 {
34 
35  if (GetTotalPEs() < std::numeric_limits<float>::epsilon()) return;
36 
37  const float PE_ratio = totalPE_target / GetTotalPEs();
38  for (size_t i_opdet = 0; i_opdet < _NPEs_Vector.size(); i_opdet++) {
39  _NPEs_Vector[i_opdet] *= PE_ratio;
40  _NPEs_ErrorVector[i_opdet] = std::sqrt(_NPEs_Vector[i_opdet]);
41  }
42 }
std::vector< float > _NPEs_ErrorVector
float GetTotalPEs() const
std::vector< float > _NPEs_Vector
FlashHypothesis opdet::FlashHypothesis::operator+ ( const FlashHypothesis fh)
inline

Definition at line 71 of file FlashHypothesis.h.

References _NPEs_ErrorVector, _NPEs_Vector, and GetVectorSize().

72  {
73 
74  if (_NPEs_Vector.size() != fh.GetVectorSize())
75  throw std::runtime_error(
76  "ERROR in FlashHypothesisAddition: Cannot add hypothesis of different size");
77 
78  FlashHypothesis flashhyp(_NPEs_Vector.size());
79  for (size_t i = 0; i < _NPEs_Vector.size(); i++) {
80  flashhyp._NPEs_Vector[i] = _NPEs_Vector[i] + fh._NPEs_Vector[i];
81  flashhyp._NPEs_ErrorVector[i] =
82  std::sqrt(this->_NPEs_ErrorVector[i] * this->_NPEs_ErrorVector[i] +
83  fh._NPEs_ErrorVector[i] * fh._NPEs_ErrorVector[i]);
84  }
85  return flashhyp;
86  }
std::vector< float > _NPEs_ErrorVector
std::vector< float > _NPEs_Vector
void opdet::FlashHypothesis::Print ( )

Definition at line 44 of file FlashHypothesis.cxx.

References GetHypothesis(), GetHypothesisError(), GetTotalPEs(), GetTotalPEsError(), and GetVectorSize().

Referenced by opdet::FlashHypothesisCollection::GetTotalHypothesis(), and GetVectorSize().

45 {
46  std::cout << "TotalPEs: " << GetTotalPEs() << " +/- " << GetTotalPEsError() << std::endl;
47  std::cout << "Vector size: " << GetVectorSize() << std::endl;
48  for (size_t i = 0; i < GetVectorSize(); i++)
49  std::cout << "\t" << i << ": " << GetHypothesis(i) << " +/- " << GetHypothesisError(i)
50  << std::endl;
51 }
size_t GetVectorSize() const
float GetTotalPEsError() const
float GetTotalPEs() const
float const & GetHypothesisError(size_t i_opdet) const
float const & GetHypothesis(size_t i_opdet) const
void opdet::FlashHypothesis::SetHypothesis ( size_t  i_opdet,
float  pe 
)
inline

Definition at line 50 of file FlashHypothesis.h.

References _NPEs_Vector.

Referenced by SetHypothesisAndError().

50 { _NPEs_Vector.at(i_opdet) = pe; }
std::vector< float > _NPEs_Vector
void opdet::FlashHypothesis::SetHypothesisAndError ( size_t  i_opdet,
float  pe,
float  err = -999 
)

Definition at line 23 of file FlashHypothesis.cxx.

References SetHypothesis(), and SetHypothesisError().

Referenced by opdet::FlashHypothesisCalculator::FillFlashHypothesis(), and SetHypothesisError().

24 {
25  SetHypothesis(i_opdet, pe);
26  if (err > 0)
27  SetHypothesisError(i_opdet, err);
28  else
29  SetHypothesisError(i_opdet, std::sqrt(pe));
30 }
void SetHypothesisError(size_t i_opdet, float err)
void SetHypothesis(size_t i_opdet, float pe)
void opdet::FlashHypothesis::SetHypothesisError ( size_t  i_opdet,
float  err 
)
inline

Definition at line 51 of file FlashHypothesis.h.

References _NPEs_ErrorVector, and SetHypothesisAndError().

Referenced by SetHypothesisAndError().

51 { _NPEs_ErrorVector.at(i_opdet) = err; }
std::vector< float > _NPEs_ErrorVector
void opdet::FlashHypothesis::SetHypothesisErrorVector ( std::vector< float >  v)
inline

Definition at line 40 of file FlashHypothesis.h.

References _NPEs_ErrorVector, _NPEs_Vector, and SetHypothesisVectorAndErrorVector().

41  {
43  _NPEs_Vector.resize(v.size());
44  }
std::vector< float > _NPEs_ErrorVector
std::vector< float > _NPEs_Vector
void opdet::FlashHypothesis::SetHypothesisVector ( std::vector< float >  v)
inline

Definition at line 35 of file FlashHypothesis.h.

References _NPEs_ErrorVector, and _NPEs_Vector.

36  {
37  _NPEs_Vector = v;
38  _NPEs_ErrorVector.resize(v.size());
39  }
std::vector< float > _NPEs_ErrorVector
std::vector< float > _NPEs_Vector
void opdet::FlashHypothesis::SetHypothesisVectorAndErrorVector ( std::vector< float >  v,
std::vector< float >  err = std::vector<float>(0) 
)

Definition at line 6 of file FlashHypothesis.cxx.

References _NPEs_ErrorVector, and _NPEs_Vector.

Referenced by FlashHypothesis(), and SetHypothesisErrorVector().

8 {
9  if (err.size() != 0 && err.size() != v.size())
10  throw std::runtime_error("ERROR in FlashHypothesisVectorSetter: Vector sizes not equal");
11 
12  _NPEs_Vector = v;
13  if (err.size() == 0) {
14  _NPEs_Vector = v;
15  _NPEs_ErrorVector.resize(v.size());
16  for (size_t i = 0; i < _NPEs_Vector.size(); i++)
17  _NPEs_ErrorVector[i] = std::sqrt(_NPEs_Vector[i]);
18  }
19  else
20  _NPEs_ErrorVector = err;
21 }
std::vector< float > _NPEs_ErrorVector
std::vector< float > _NPEs_Vector

Member Data Documentation


The documentation for this class was generated from the following files: