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

#include "FlashHypothesis.h"

Public Member Functions

 FlashHypothesisCollection ()
 
 FlashHypothesisCollection (size_t s)
 
 FlashHypothesisCollection (const FlashHypothesis &prompt, const FlashHypothesis &late)
 
void SetPromptAndLateHyp (const FlashHypothesis &prompt, const FlashHypothesis &late)
 
void SetTotalHypAndPromptFraction (const FlashHypothesis &total, float frac)
 
void SetPromptHypAndPromptFraction (const FlashHypothesis &prompt, float frac)
 
size_t GetVectorSize () const
 
float GetPromptFraction () const
 
float GetLateFraction () const
 
const FlashHypothesisGetPromptHypothesis () const
 
const FlashHypothesisGetLateHypothesis () const
 
const FlashHypothesisGetTotalHypothesis () const
 
void Normalize (float totalPEs)
 
void Print ()
 
FlashHypothesisCollection operator+ (const FlashHypothesisCollection &fhc)
 

Private Member Functions

void CheckFrac (float f)
 
void UpdateTotalHyp ()
 

Private Attributes

FlashHypothesis _prompt_hyp
 
FlashHypothesis _late_hyp
 
FlashHypothesis _total_hyp
 
float _prompt_frac
 

Detailed Description

Definition at line 93 of file FlashHypothesis.h.

Constructor & Destructor Documentation

opdet::FlashHypothesisCollection::FlashHypothesisCollection ( )
inline

Definition at line 96 of file FlashHypothesis.h.

96 {}
opdet::FlashHypothesisCollection::FlashHypothesisCollection ( size_t  s)
inline

Definition at line 97 of file FlashHypothesis.h.

References opdet::FlashHypothesis::FlashHypothesis().

98  {
99  _prompt_hyp = FlashHypothesis(s);
100  _late_hyp = FlashHypothesis(s);
101  UpdateTotalHyp();
102  }
opdet::FlashHypothesisCollection::FlashHypothesisCollection ( const FlashHypothesis prompt,
const FlashHypothesis late 
)
inline

Definition at line 103 of file FlashHypothesis.h.

104  {
105  SetPromptAndLateHyp(prompt, late);
106  }
void SetPromptAndLateHyp(const FlashHypothesis &prompt, const FlashHypothesis &late)

Member Function Documentation

void opdet::FlashHypothesisCollection::CheckFrac ( float  f)
private

Definition at line 83 of file FlashHypothesis.cxx.

References util::abs().

84 {
85  if (std::abs(f - 0.0) < std::numeric_limits<float>::epsilon() ||
86  std::abs(f - 1.0) < std::numeric_limits<float>::epsilon() || (f > 0.0 && f < 1.0))
87  return;
88 
89  throw std::runtime_error(
90  "ERROR in FlashHypothesisCollection: Input fraction is not in valid range.");
91 }
constexpr auto abs(T v)
Returns the absolute value of the argument.
TFile f
Definition: plotHisto.C:6
float opdet::FlashHypothesisCollection::GetLateFraction ( ) const
inline

Definition at line 120 of file FlashHypothesis.h.

120 { return 1. - _prompt_frac; }
const FlashHypothesis& opdet::FlashHypothesisCollection::GetLateHypothesis ( ) const
inline
float opdet::FlashHypothesisCollection::GetPromptFraction ( ) const
inline

Definition at line 119 of file FlashHypothesis.h.

const FlashHypothesis& opdet::FlashHypothesisCollection::GetPromptHypothesis ( ) const
inline
const FlashHypothesis& opdet::FlashHypothesisCollection::GetTotalHypothesis ( ) const
inline
size_t opdet::FlashHypothesisCollection::GetVectorSize ( ) const
inline
void opdet::FlashHypothesisCollection::Normalize ( float  totalPEs)

Definition at line 76 of file FlashHypothesis.cxx.

77 {
78  _prompt_hyp.Normalize(totalPE_target * _prompt_frac);
79  _late_hyp.Normalize(totalPE_target * (1. - _prompt_frac));
81 }
void Normalize(float const &totalPE_target)
FlashHypothesisCollection opdet::FlashHypothesisCollection::operator+ ( const FlashHypothesisCollection fhc)
inline

Definition at line 130 of file FlashHypothesis.h.

References GetLateHypothesis(), GetPromptHypothesis(), opdet::FlashHypothesis::GetVectorSize(), and GetVectorSize().

131  {
132 
133  if (this->GetVectorSize() != fhc.GetVectorSize())
134  throw std::runtime_error(
135  "ERROR in FlashHypothesisCollectionAddition: Cannot add hypothesis of different size");
136 
137  FlashHypothesis ph = this->GetPromptHypothesis();
138  ph = ph + fhc.GetPromptHypothesis();
139  FlashHypothesis lh = this->GetLateHypothesis();
140  lh = lh + fhc.GetLateHypothesis();
141 
142  return (FlashHypothesisCollection(ph, lh));
143  }
const FlashHypothesis & GetLateHypothesis() const
const FlashHypothesis & GetPromptHypothesis() const
void opdet::FlashHypothesisCollection::Print ( )

Definition at line 103 of file FlashHypothesis.cxx.

104 {
105  std::cout << "PromptHyp:" << std::endl;
106  _prompt_hyp.Print();
107  std::cout << "LateHyp:" << std::endl;
108  _late_hyp.Print();
109  std::cout << "TotalHyp:" << std::endl;
110  _total_hyp.Print();
111  std::cout << "PromptFraction: " << _prompt_frac << std::endl;
112 }
void opdet::FlashHypothesisCollection::SetPromptAndLateHyp ( const FlashHypothesis prompt,
const FlashHypothesis late 
)
inline

Definition at line 108 of file FlashHypothesis.h.

109  {
110  _prompt_hyp = prompt;
111  _late_hyp = late;
112  UpdateTotalHyp();
113  }
void opdet::FlashHypothesisCollection::SetPromptHypAndPromptFraction ( const FlashHypothesis prompt,
float  frac 
)

Definition at line 65 of file FlashHypothesis.cxx.

References opdet::FlashHypothesis::GetTotalPEs(), and opdet::FlashHypothesis::Normalize().

Referenced by opdet::FlashHypothesisCreator::CreateFlashHypothesesFromSegment().

67 {
68  CheckFrac(frac);
69  _prompt_hyp = prompt;
70  _prompt_frac = frac;
71  _late_hyp = prompt;
72  _late_hyp.Normalize((1 / frac - 1.) * prompt.GetTotalPEs());
74 }
void Normalize(float const &totalPE_target)
void opdet::FlashHypothesisCollection::SetTotalHypAndPromptFraction ( const FlashHypothesis total,
float  frac 
)

Definition at line 53 of file FlashHypothesis.cxx.

References opdet::FlashHypothesis::GetTotalPEs(), and opdet::FlashHypothesis::Normalize().

55 {
56  CheckFrac(frac);
57  _total_hyp = total;
58  _prompt_frac = frac;
59  _prompt_hyp = total;
60  _prompt_hyp.Normalize(frac * total.GetTotalPEs());
61  _late_hyp = total;
62  _late_hyp.Normalize((1. - frac) * total.GetTotalPEs());
63 }
void Normalize(float const &totalPE_target)
void opdet::FlashHypothesisCollection::UpdateTotalHyp ( )
private

Definition at line 93 of file FlashHypothesis.cxx.

94 {
96  const float total_pe = _total_hyp.GetTotalPEs();
97  if (total_pe > std::numeric_limits<float>::epsilon())
98  _prompt_frac = _prompt_hyp.GetTotalPEs() / total_pe;
99  else
100  _prompt_frac = 1.;
101 }
float GetTotalPEs() const

Member Data Documentation

FlashHypothesis opdet::FlashHypothesisCollection::_late_hyp
private

Definition at line 147 of file FlashHypothesis.h.

float opdet::FlashHypothesisCollection::_prompt_frac
private

Definition at line 149 of file FlashHypothesis.h.

FlashHypothesis opdet::FlashHypothesisCollection::_prompt_hyp
private

Definition at line 146 of file FlashHypothesis.h.

FlashHypothesis opdet::FlashHypothesisCollection::_total_hyp
private

Definition at line 148 of file FlashHypothesis.h.


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