MINT2
Histo_BW.cpp
Go to the documentation of this file.
1 #include "Mint/Histo_BW.h"
3 #include "TMath.h"
4 #include "TCanvas.h"
5 #include "TH2D.h"
6 #include "TH1D.h"
7 #include "Mint/Utils.h"
8 #include "Mint/DalitzEventList.h"
10 #include <cmath>
11 #include <complex>
12 
13 using namespace std;
14 using namespace MINT;
15 
16 std::complex<double> Histo_BW::BreitWigner(){
17  double mass2 = runningMass2();
18  std::complex<double> invBW(mass2 - mumsRecoMass2(), - mumsMass() * GofM());
19  return 1.*GeV*GeV/invBW;
20 }
21 
23  if(_runningMassHist==0)return mumsMass()*mumsMass();
24 
25  double d_m2 = _runningMassHist->Interpolate(mumsRecoMass2()/(GeV*GeV));
26  double d_m02 = _runningMassHist->Interpolate(mumsMass()*mumsMass()/(GeV*GeV));
27 
28  return mumsMass()*mumsMass() + mumsWidth()*(d_m2 - d_m02);
29 }
30 
31 double Histo_BW::GofM(){
32 
33  if(_runningWidthHist==0)return mumsWidth();
34 
35  double ps_m = _runningWidthHist->Interpolate(mumsRecoMass2()/(GeV*GeV));
36  double ps_m0 = _runningWidthHist->Interpolate(mumsMass()*mumsMass()/(GeV*GeV));
37 
38  double ps_ratio = 0.;
39  if(ps_m0>0)ps_ratio= ps_m/ps_m0 ;
40 
41  return mumsWidth() * ps_ratio;
42 }
43 
44 TH1D* Histo_BW::get_width_histo(TFile* f, const std::string& hname){
45  TH1D* h=0;
46  if(0 != f){
47  h = (TH1D*) f->Get(hname.c_str());
48  if(0 != h){
49  cout << "Found running width histogram in file " << f->GetName() << "." << endl;
50  }else{
51  cout << "ERROR: Couldn't find running width histogram in file " << f->GetName() << ". I'll return a constant width." << endl;
52  }
53  }
54  else {
55  cout << "Didn't find running width file for " << (BW_BW::resonanceProperties()->nameFromPid(abs(mumsPID())))
56  << ". I'll produce it now assuming a flat 3 body phase space." << endl;
57  h= producePhaseSpaceHist();
58  if(0 == h) cout << "ERROR: Couldn't produce running width histogram, I'll return a constant width" << endl;
59  }
60  return h;
61 }
62 
63 TH1D* Histo_BW::get_mass_histo(TFile* f, const std::string& hname){
64  TH1D* h=0;
65  if(0 != f){
66  h = (TH1D*) f->Get(hname.c_str());
67  if(0 != h){
68  cout << "Found running mass histogram in file " << f->GetName() << "." << endl;
69  }else{
70  cout << "ERROR: Couldn't find running mass histogram in file " << f->GetName() << ". I'll use a constant mass." << endl;
71  }
72  }
73  else {
74  cout << "Didn't find running mass file for " << (BW_BW::resonanceProperties()->nameFromPid(abs(mumsPID()))) << endl;
75  }
76  return h;
77 }
78 
79 Double_t phaseSpace(Double_t *x, Double_t *par){
80 
81  //x[0]: mumsRecoMass()^2
82  //par[0]: mumsMass()
83  //par[i]: final state masses (i=1,2,3)
84 
86  double ps_val = ps.getVal(sqrt(x[0])*GeV,par[1],par[2],par[3]);
87  double ps0_val = ps.getVal(par[0],par[1],par[2],par[3]);
88 
89  double ps_ratio=0.;
90  if(ps0_val>0)ps_ratio= ps_val/ps0_val;
91  //cout << ps_ratio << endl;
92 
93  return ps_ratio * par[0]/(sqrt(x[0])*GeV);
94 }
95 
97 
98  std::vector<int> asi = _theDecay.getVal().asi();
99  double min = 0.;//getEvent()->eventPattern().sijMin(asi)/(GeV*GeV)*0.75;
100  double max = mumsMass()*mumsMass()/(GeV*GeV)*5.;//getEvent()->eventPattern().sijMax(asi)/(GeV*GeV)*1.25;
101 
102  TFile* f= new TFile(("RunningWidth_"+ (BW_BW::resonanceProperties()->nameFromPid(abs(mumsPID()))) + ".root").c_str(),"RECREATE");
103  TH1D* h= new TH1D("RunningWidth","RunningWidth",1000,min,max);
104 
105  TF1 *ps = new TF1("phaseSpace",phaseSpace,0,max,4);
106  std::vector<const AssociatedDecayTreeItem*> adti = _theDecay.finalState();
107  //cout << adti[0]->mass() << " " << adti[1]->mass() << " " << adti[2]->mass() << endl;
108  ps->SetParameters(mumsMass(),adti[0]->mass(),adti[1]->mass(),adti[2]->mass());
109 
110  for (int i=1; i<= h->GetNbinsX(); i++) {
111  h->SetBinContent(i,ps->Eval(h->GetXaxis()->GetBinCenter(i)));
112  }
113 
114  h->Write();
115  f->Write();
116 
117  return h;
118 
119 }
120 
121 
122 
123 
124 //
virtual std::complex< double > BreitWigner()
Definition: Histo_BW.cpp:16
double runningMass2()
Definition: Histo_BW.cpp:22
double getVal(const DalitzEventPattern &_pat)
TH1D * producePhaseSpaceHist()
Definition: Histo_BW.cpp:96
static const double GeV
TH1D * get_mass_histo(TFile *f, const std::string &hname)
Definition: Histo_BW.cpp:63
const ResonanceProperties * resonanceProperties() const
Definition: BW_BW.cpp:403
static std::string nameFromPid(int pdg_id)
Double_t phaseSpace(Double_t *x, Double_t *par)
Definition: Histo_BW.cpp:79
virtual double GofM()
Definition: Histo_BW.cpp:31
TH1D * get_width_histo(TFile *f, const std::string &hname)
Definition: Histo_BW.cpp:44