MINT2
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
TimeBinning::Bin Class Reference

#include <TimeBinning.h>

Public Member Functions

 Bin ()
 
 Bin (const std::string &, unsigned, const std::string &fname="")
 
double t () const
 
double t2 () const
 
double nPlus () const
 
double nPlusErr () const
 
double nMinus () const
 
double nMinusErr () const
 
bool usePoissonErrs () const
 
void add (double, bool, double weight=1.)
 
void Print (const std::string &, unsigned, std::ostream &os=std::cout) const
 
double chiSquared (double) const
 
Bin operator+ (Bin) const
 
Binoperator+= (const Bin &)
 

Static Public Member Functions

static std::string getName (const std::string &, unsigned)
 

Private Attributes

double m_t
 
double m_t2
 
double m_sumw
 
double m_sumw2
 
double m_sumwplus
 
double m_sumw2plus
 
double m_sumwminus
 
double m_sumw2minus
 

Detailed Description

Definition at line 14 of file TimeBinning.h.

Constructor & Destructor Documentation

◆ Bin() [1/2]

TimeBinning::Bin::Bin ( )

Definition at line 10 of file TimeBinning.cpp.

10  :
11  m_t(0.),
12  m_t2(0.),
13  m_sumw(0.),
14  m_sumw2(0.),
15  m_sumwplus(0.),
16  m_sumw2plus(0.),
17  m_sumwminus(0.),
18  m_sumw2minus(0.)
19 {}
double m_sumwminus
Definition: TimeBinning.h:38
double m_sumw2minus
Definition: TimeBinning.h:39
double m_sumw2plus
Definition: TimeBinning.h:37

◆ Bin() [2/2]

TimeBinning::Bin::Bin ( const std::string &  ,
unsigned  ,
const std::string &  fname = "" 
)

Member Function Documentation

◆ add()

void TimeBinning::Bin::add ( double  t,
bool  isplus,
double  weight = 1. 
)

Definition at line 72 of file TimeBinning.cpp.

72  {
73  double weight2 = weight*weight ;
74  m_t += t ;
75  m_t2 += t*t ;
76  m_sumw += weight ;
77  m_sumw2 += weight2 ;
78  if(isplus){
79  m_sumwplus += weight ;
80  m_sumw2plus += weight2 ;
81  }
82  else {
83  m_sumwminus += weight ;
84  m_sumw2minus += weight2 ;
85  }
86 }
double m_sumwminus
Definition: TimeBinning.h:38
double m_sumw2minus
Definition: TimeBinning.h:39
double m_sumw2plus
Definition: TimeBinning.h:37
double t() const
Definition: TimeBinning.cpp:88

◆ chiSquared()

double TimeBinning::Bin::chiSquared ( double  R) const

Definition at line 116 of file TimeBinning.cpp.

116  {
117  if(nMinus() == 0. or nPlus() == 0.)
118  return 0. ;
119  double numerator = nMinus() - nPlus() * R ;
120  numerator *= numerator ;
121  double denominator = m_sumw2minus + m_sumw2plus * R*R ;
122  if(denominator == 0.)
123  return 0. ;
124  return numerator/denominator ;
125 }
double nMinus() const
double m_sumw2minus
Definition: TimeBinning.h:39
double m_sumw2plus
Definition: TimeBinning.h:37
double nPlus() const
Definition: TimeBinning.cpp:96

◆ getName()

string TimeBinning::Bin::getName ( const std::string &  name,
unsigned  number 
)
static

Definition at line 66 of file TimeBinning.cpp.

66  {
67  ostringstream sstr ;
68  sstr << name << "_bin_" << number << "_" ;
69  return sstr.str() ;
70 }

◆ nMinus()

double TimeBinning::Bin::nMinus ( ) const

Definition at line 104 of file TimeBinning.cpp.

104  {
105  return m_sumwminus ;
106 }
double m_sumwminus
Definition: TimeBinning.h:38

◆ nMinusErr()

double TimeBinning::Bin::nMinusErr ( ) const

Definition at line 108 of file TimeBinning.cpp.

108  {
109  return sqrt(m_sumw2minus) ;
110 }
double m_sumw2minus
Definition: TimeBinning.h:39

◆ nPlus()

double TimeBinning::Bin::nPlus ( ) const

Definition at line 96 of file TimeBinning.cpp.

96  {
97  return m_sumwplus ;
98 }

◆ nPlusErr()

double TimeBinning::Bin::nPlusErr ( ) const

Definition at line 100 of file TimeBinning.cpp.

100  {
101  return sqrt(m_sumw2plus) ;
102 }
double m_sumw2plus
Definition: TimeBinning.h:37

◆ operator+()

TimeBinning::Bin TimeBinning::Bin::operator+ ( TimeBinning::Bin  other) const

Definition at line 127 of file TimeBinning.cpp.

127  {
128  return other += *this;
129 }

◆ operator+=()

TimeBinning::Bin & TimeBinning::Bin::operator+= ( const Bin other)

Definition at line 131 of file TimeBinning.cpp.

131  {
132  m_t += other.m_t;
133  m_t2 += other.m_t2;
134  m_sumw += other.m_sumw;
135  m_sumw2 += other.m_sumw2;
136  m_sumwplus += other.m_sumwplus;
137  m_sumw2plus += other.m_sumw2plus;
138  m_sumwminus += other.m_sumwminus;
139  m_sumw2minus += other.m_sumw2minus;
140  return *this;
141 }
double m_sumwminus
Definition: TimeBinning.h:38
double m_sumw2minus
Definition: TimeBinning.h:39
double m_sumw2plus
Definition: TimeBinning.h:37

◆ Print()

void TimeBinning::Bin::Print ( const std::string &  ,
unsigned  ,
std::ostream &  os = std::cout 
) const

Definition at line 53 of file TimeBinning.cpp.

53  {
54  os.precision(16) ;
55  string name = getName(_name, number) ;
56  os << name << "t\t" << t() << endl ;
57  os << name << "t2\t" << t2() << endl ;
58  os << name << "sumw\t" << m_sumw << endl ;
59  os << name << "sumw2\t" << m_sumw2 << endl ;
60  os << name << "sumwplus\t" << m_sumwplus << endl ;
61  os << name << "sumw2plus\t" << m_sumw2plus << endl ;
62  os << name << "sumwminus\t" << m_sumwminus << endl ;
63  os << name << "sumw2minus\t" << m_sumw2minus << endl ;
64 }
static std::string getName(const std::string &, unsigned)
Definition: TimeBinning.cpp:66
double t2() const
Definition: TimeBinning.cpp:92
double m_sumwminus
Definition: TimeBinning.h:38
double m_sumw2minus
Definition: TimeBinning.h:39
double m_sumw2plus
Definition: TimeBinning.h:37
double t() const
Definition: TimeBinning.cpp:88

◆ t()

double TimeBinning::Bin::t ( ) const

Definition at line 88 of file TimeBinning.cpp.

88  {
89  return m_sumw > 0 ? m_t/m_sumw : 0. ;
90 }

◆ t2()

double TimeBinning::Bin::t2 ( ) const

Definition at line 92 of file TimeBinning.cpp.

92  {
93  return m_sumw > 0 ? m_t2/m_sumw : 0. ;
94 }

◆ usePoissonErrs()

bool TimeBinning::Bin::usePoissonErrs ( ) const

Definition at line 112 of file TimeBinning.cpp.

112  {
113  return m_sumw == m_sumw2 ;
114 }

Member Data Documentation

◆ m_sumw

double TimeBinning::Bin::m_sumw
private

Definition at line 34 of file TimeBinning.h.

◆ m_sumw2

double TimeBinning::Bin::m_sumw2
private

Definition at line 35 of file TimeBinning.h.

◆ m_sumw2minus

double TimeBinning::Bin::m_sumw2minus
private

Definition at line 39 of file TimeBinning.h.

◆ m_sumw2plus

double TimeBinning::Bin::m_sumw2plus
private

Definition at line 37 of file TimeBinning.h.

◆ m_sumwminus

double TimeBinning::Bin::m_sumwminus
private

Definition at line 38 of file TimeBinning.h.

◆ m_sumwplus

double TimeBinning::Bin::m_sumwplus
private

Definition at line 36 of file TimeBinning.h.

◆ m_t

double TimeBinning::Bin::m_t
private

Definition at line 32 of file TimeBinning.h.

◆ m_t2

double TimeBinning::Bin::m_t2
private

Definition at line 33 of file TimeBinning.h.


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