31 string name =
getName(_name, number) ;
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 ;
68 sstr << name <<
"_bin_" << number <<
"_" ;
73 double weight2 = weight*weight ;
79 m_sumwplus += weight ;
80 m_sumw2plus += weight2 ;
83 m_sumwminus += weight ;
84 m_sumw2minus += weight2 ;
89 return m_sumw > 0 ? m_t/m_sumw : 0. ;
93 return m_sumw > 0 ? m_t2/m_sumw : 0. ;
101 return sqrt(m_sumw2plus) ;
109 return sqrt(m_sumw2minus) ;
113 return m_sumw == m_sumw2 ;
117 if(nMinus() == 0. or nPlus() == 0.)
119 double numerator = nMinus() - nPlus() * R ;
120 numerator *= numerator ;
121 double denominator = m_sumw2minus + m_sumw2plus * R*R ;
122 if(denominator == 0.)
124 return numerator/denominator ;
128 return other += *
this;
173 string nameint = name +
"_int" ;
174 string nameplus = name +
"_plus" ;
175 string nameminus = name +
"_minus" ;
176 for(
unsigned iTimeBin = 0 ; iTimeBin <
nBinsTime() ; ++iTimeBin){
180 string nameplusbin =
Bin::getName(nameplus +
"_time", iTimeBin) +
"phase" ;
181 string nameminusbin =
Bin::getName(nameminus +
"_time", iTimeBin) +
"phase" ;
182 for(
unsigned iPhaseBin = 1 ; iPhaseBin <
m_phaseBinning->nBins + 1 ; ++iPhaseBin){
183 m_bins.back().push_back(
Bin(nameplusbin, iPhaseBin, fname)) ;
184 m_binsBar.back().push_back(
Bin(nameminusbin, iPhaseBin, fname)) ;
191 os << name <<
"_timeBins" ;
195 os << name <<
"_lifetime\t" <<
m_lifetime << endl ;
196 string nameint = name +
"_int" ;
197 string nameplus = name +
"_plus" ;
198 string nameminus = name +
"_minus" ;
199 for(
unsigned iTimeBin = 0 ; iTimeBin <
nBinsTime() ; ++iTimeBin){
200 m_binsInt[iTimeBin].Print(nameint, iTimeBin, os) ;
201 string nameplusbin =
Bin::getName(nameplus +
"_time", iTimeBin) +
"phase" ;
202 string nameminusbin =
Bin::getName(nameminus +
"_time", iTimeBin) +
"phase" ;
203 for(
unsigned iPhaseBin = 1 ; iPhaseBin <
m_phaseBinning->nBins + 1; ++iPhaseBin){
204 bin(iTimeBin, iPhaseBin).
Print(nameplusbin, iPhaseBin, os) ;
205 binBar(iTimeBin, iPhaseBin).
Print(nameminusbin, iPhaseBin, os) ;
213 outfile.open(fname) ;
214 Print(name, outfile) ;
223 for(
unsigned i = 0 ; i <
nBinsTime() ; ++i)
234 bool isPlus = phaseBin > 0 ;
236 _bin(timeBinNo, abs(phaseBin)).
add(t, isPlus, weight) ;
240 _binBar(timeBinNo, abs(phaseBin)).
add(t, isPlus, weight) ;
263 return m_bins.at(iTimeBin).at(iPhaseBin-1) ;
267 return m_binsBar.at(iTimeBin).at(iPhaseBin-1) ;
275 return m_bins.at(iTimeBin).at(iPhaseBin-1) ;
279 return m_binsBar.at(iTimeBin).at(iPhaseBin-1) ;
285 string name =
Bin::getName(_name +
"_" + stag.str() +
"_phase", phaseBin) ;
290 for(
unsigned i = 1 ; i <
nBinsTime()+1 ; ++i) {
291 const Bin& pbin = tag > 0 ?
bin(i-1, phaseBin) :
binBar(i-1, phaseBin) ;
292 hplus.SetBinContent(i, pbin.
nPlus()) ;
293 hplus.SetBinError(i, pbin.
nPlusErr()) ;
294 hminus.SetBinContent(i, pbin.
nMinus()) ;
295 hminus.SetBinError(i, pbin.
nMinusErr()) ;
298 hr.SetBinContent(i, r) ;
299 hr.SetBinError(i, rerr) ;
302 histos.push_back(hplus) ;
303 histos.push_back(hminus) ;
304 histos.push_back(hr) ;
309 deque<deque<TH1F> > histos ;
310 for(
unsigned iphase = 1 ; iphase <
m_phaseBinning->nBins + 1 ; ++iphase){
311 histos.push_back(deque<TH1F>()) ;
312 deque<TH1F>& binhistos = histos.back() ;
313 for(
int tag = -1 ; tag < 2 ; tag += 2){
314 deque<TH1F> taghistos =
plotVsTime(name, iphase, tag) ;
315 binhistos.insert(binhistos.end(), taghistos.begin(), taghistos.end()) ;
317 TH1F rdiff(binhistos.back()) ;
318 string rdiffname(
Bin::getName(name +
"_phase", iphase) +
"ratiodiff") ;
319 rdiff.SetName(rdiffname.c_str()) ;
320 rdiff.Add(&binhistos[2], -1.) ;
321 binhistos.push_back(rdiff) ;
329 for(
auto& binhistos : histos)
330 for(
auto& histo : binhistos)
337 double norm = exp(-tmin/lifetime) - exp(-tmax/lifetime) ;
338 double timeMoment = (pow(tmin, moment) * exp(-tmin/lifetime) - pow(tmax, moment) * exp(-tmax/lifetime))/norm ;
347 for(
unsigned ibin = 0 ; ibin <
nBinsTime() ; ++ibin){
372 return other += *
this;
392 throw std::invalid_argument(
"Attempt to combine incompatible TimeBinning instances!");
396 for(
unsigned iTimeBin = 0; iTimeBin <
nBinsTime(); ++iTimeBin){
398 for(
unsigned iPhaseBin = 0; iPhaseBin <
nBinsPhase(); ++iPhaseBin){
399 m_bins.at(iTimeBin).at(iPhaseBin) += other.
m_bins.at(iTimeBin).at(iPhaseBin);
unsigned nBinsPhase() const
int timeBin(double) const
static BinningPtr getPhaseBinning(const std::string &, const std::string &fname="")
Get the PhaseBinning type.
bool usePoissonErrs() const
Bin & _binBar(unsigned, unsigned)
std::deque< TH1F > plotVsTime(const std::string &, unsigned, int) const
void add(IDalitzEvent &, int, double, double weight=1.)
static std::string getName(const std::string &, unsigned)
const Bin & integratedBin(unsigned) const
const Bin & binBar(unsigned, unsigned) const
void Print(const std::string &, unsigned, std::ostream &os=std::cout) const
TimeBinning(const std::vector< double > &, HadronicParameters::BinningPtr, double)
void savePlotsVsTime(const std::string &, TFile &) const
TimeBinning & operator+=(const TimeBinning &)
HadronicParameters::BinningPtr m_phaseBinning
std::vector< double > m_meant2
Bin & _bin(unsigned, unsigned)
Bin & _integratedBin(unsigned)
Bin & operator+=(const Bin &)
virtual double unmixedTimeMoment(unsigned, double, int) const
void write(const std::string &, const std::string &) const
double meanUnmixedTime(unsigned) const
TimeBinning operator+(TimeBinning) const
void add(double, bool, double weight=1.)
std::vector< double > m_meant
bool isConsistent(const TimeBinning &) const
Check that two TimeBinnings use the same binning scheme.
double meanUnmixedTime2(unsigned) const
HadronicParameters::BinningPtr phaseBinning() const
double chiSquared(unsigned, unsigned, double, double) const
const Bin & bin(unsigned, unsigned) const
std::vector< double > m_timeBins
double getLifetime() const
double chiSquared(double) const
std::deque< std::deque< TH1F > > plotsVsTime(const std::string &) const
void Print(const std::string &, std::ostream &os=std::cout) const
unsigned nBinsTime() const