LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 19 of file FlashHypothesis.h.

Constructor & Destructor Documentation

opdet::FlashHypothesis::FlashHypothesis ( )
inline

Definition at line 22 of file FlashHypothesis.h.

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

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

Definition at line 23 of file FlashHypothesis.h.

References _NPEs_ErrorVector, _NPEs_Vector, and s.

24  { _NPEs_Vector = std::vector<float>(s,0.0); _NPEs_ErrorVector = std::vector<float>(s,0.0); }
Float_t s
Definition: plot.C:23
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 25 of file FlashHypothesis.h.

References SetHypothesisVectorAndErrorVector().

27  { SetHypothesisVectorAndErrorVector(vector,vector_error); }
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 35 of file FlashHypothesis.h.

References _NPEs_Vector.

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

35 { 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 36 of file FlashHypothesis.h.

References _NPEs_ErrorVector.

Referenced by Print().

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

Definition at line 30 of file FlashHypothesis.h.

References _NPEs_ErrorVector.

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

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

Definition at line 44 of file FlashHypothesis.h.

References _NPEs_ErrorVector.

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

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

Definition at line 28 of file FlashHypothesis.cxx.

References _NPEs_ErrorVector, _NPEs_Vector, and GetTotalPEs().

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

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

Definition at line 53 of file FlashHypothesis.h.

References _NPEs_ErrorVector, _NPEs_Vector, and GetVectorSize().

53  {
54 
55  if( _NPEs_Vector.size() != fh.GetVectorSize() )
56  throw std::runtime_error("ERROR in FlashHypothesisAddition: Cannot add hypothesis of different size");
57 
58  FlashHypothesis flashhyp(_NPEs_Vector.size());
59  for(size_t i=0; i<_NPEs_Vector.size(); i++){
60  flashhyp._NPEs_Vector[i] = _NPEs_Vector[i] + fh._NPEs_Vector[i];
61  flashhyp._NPEs_ErrorVector[i] =
62  std::sqrt(this->_NPEs_ErrorVector[i]*this->_NPEs_ErrorVector[i] +
63  fh._NPEs_ErrorVector[i]*fh._NPEs_ErrorVector[i]);
64  }
65  return flashhyp;
66  }
std::vector< float > _NPEs_ErrorVector
std::vector< float > _NPEs_Vector
void opdet::FlashHypothesis::Print ( )

Definition at line 40 of file FlashHypothesis.cxx.

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

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

41 {
42  std::cout << "TotalPEs: " << GetTotalPEs() << " +/- " << GetTotalPEsError() << std::endl;
43  std::cout << "Vector size: " << GetVectorSize() << std::endl;
44  for(size_t i=0; i<GetVectorSize(); i++)
45  std::cout << "\t" << i << ": " << GetHypothesis(i) << " +/- " << GetHypothesisError(i) << std::endl;
46 }
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 37 of file FlashHypothesis.h.

References _NPEs_Vector.

Referenced by SetHypothesisAndError().

37 { _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 21 of file FlashHypothesis.cxx.

References SetHypothesis(), and SetHypothesisError().

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

22 {
23  SetHypothesis(i_opdet,pe);
24  if(err>0) SetHypothesisError(i_opdet,err);
25  else SetHypothesisError(i_opdet,std::sqrt(pe));
26 }
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 38 of file FlashHypothesis.h.

References _NPEs_ErrorVector, and SetHypothesisAndError().

Referenced by SetHypothesisAndError().

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

Definition at line 32 of file FlashHypothesis.h.

References _NPEs_ErrorVector, _NPEs_Vector, and SetHypothesisVectorAndErrorVector().

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

Definition at line 31 of file FlashHypothesis.h.

References _NPEs_ErrorVector, and _NPEs_Vector.

31 { _NPEs_Vector=v; _NPEs_ErrorVector.resize(v.size()); }
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 4 of file FlashHypothesis.cxx.

References _NPEs_ErrorVector, and _NPEs_Vector.

Referenced by FlashHypothesis(), and SetHypothesisErrorVector().

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

Member Data Documentation


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