BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtHis2F Class Reference

#include <EvtHis2F.hh>

+ Inheritance diagram for EvtHis2F:

Public Member Functions

 EvtHis2F ()
 
virtual ~EvtHis2F ()
 
void init ()
 
void setFile (const char *dtfile)
 
void setHTitle (const char *htitle)
 
const char * getFile ()
 
const char * getHTitle ()
 
void HFill (double xmass2, double ymass2)
 
double getZvalue (double m12_square, double m13_square)
 
void HReweight ()
 
bool AR (double xmass2, double ymass2)
 
bool AR (double xmass2, double ymass2, double zmax, TH2F *h2)
 
void setZmax ()
 
void setZmax (TH2F *H2)
 
double getZmax ()
 
void setHmc (TH2F *H2)
 
void setHdt (TH2F *H2)
 
void setHwt (TH2F *H2)
 
TH2F * getHmc ()
 
TH2F * getHdt ()
 
TH2F * getHwt ()
 
void setBINSx (int bx)
 
void setBINSy (int by)
 
void setXlow (double xl)
 
void setXup (double xu)
 
void setYlow (double yl)
 
void setYup (double yu)
 
void setBins (TH2F *h2)
 
int getBINSx ()
 
int getBINSy ()
 
double getXlow ()
 
double getYlow ()
 
double getXup ()
 
double getYup ()
 
void show (TH2F *h2)
 
void showFrame (TH2F *h2)
 
void init (TH2F *hmc, TH2F *hdt, TH2F *hwt)
 

Detailed Description

Definition at line 29 of file EvtHis2F.hh.

Constructor & Destructor Documentation

◆ EvtHis2F()

EvtHis2F::EvtHis2F ( )
inline

Definition at line 33 of file EvtHis2F.hh.

33{}

◆ ~EvtHis2F()

EvtHis2F::~EvtHis2F ( )
virtual

Definition at line 25 of file EvtHis2F.cc.

25{}

Member Function Documentation

◆ AR() [1/2]

bool EvtHis2F::AR ( double xmass2,
double ymass2 )

Definition at line 205 of file EvtHis2F.cc.

205 {//accept: true. reject: false
206 //call this function after initiation and filling MC histogram HMC
207 bool accept;
208 accept=false;
209 if(xmass2<xlow || xmass2>xup || ymass2<ylow || ymass2>yup) {return accept;}
210 double zvalue=getZvalue(xmass2,ymass2);
211 double ratio=zvalue/zmax;
212 double rndm=EvtRandom::Flat(0.0, 1.0);
213 // std::cout<<"zvalue, zmax , rndm "<<zvalue<<" "<<zmax<<" "<<rndm<<std::endl;
214 if(ratio > rndm){accept=true;} else {accept=false;}
215 return accept;
216}
double getZvalue(double m12_square, double m13_square)
Definition EvtHis2F.cc:196
static double Flat()
Definition EvtRandom.cc:74

Referenced by EvtNT3::AR1(), EvtNT3::AR2(), and EvtNT3::AR3().

◆ AR() [2/2]

bool EvtHis2F::AR ( double xmass2,
double ymass2,
double zmax,
TH2F * h2 )

Definition at line 218 of file EvtHis2F.cc.

218 {//accept: true. reject: false
219 //call this function after initiation and filling MC histogram HMC
220 bool accept;
221 accept=false;
222 setBins(h2);
223 if(xmass2<xlow || xmass2>xup || ymass2<ylow || ymass2>yup) {return accept;}
224 int xbin = h2->GetXaxis()->FindBin(xmass2);
225 int ybin = h2->GetYaxis()->FindBin(ymass2);
226 int xybin= h2->GetBin(xbin,ybin);
227 double zvalue=h2->GetBinContent(xybin);
228
229 double ratio=zvalue/zmax;
230 double rndm=EvtRandom::Flat(0.0, 1.0);
231 // std::cout<<"zvalue, zmax , rndm "<<zvalue<<" "<<zmax<<" "<<rndm<<std::endl;
232 if(ratio > rndm){accept=true;} else {accept=false;}
233 return accept;
234}
void setBins(TH2F *h2)
Definition EvtHis2F.cc:152

◆ getBINSx()

int EvtHis2F::getBINSx ( )
inline

Definition at line 64 of file EvtHis2F.hh.

64{return BINSx;}

◆ getBINSy()

int EvtHis2F::getBINSy ( )
inline

Definition at line 65 of file EvtHis2F.hh.

65{return BINSy;}

◆ getFile()

const char * EvtHis2F::getFile ( )

Definition at line 27 of file EvtHis2F.cc.

27 {
28 return datafile;
29}

Referenced by init().

◆ getHdt()

TH2F * EvtHis2F::getHdt ( )

Definition at line 59 of file EvtHis2F.cc.

59 {
60 return HDATA;
61}

◆ getHmc()

TH2F * EvtHis2F::getHmc ( )

Definition at line 55 of file EvtHis2F.cc.

55 {
56 return HMC;
57}

◆ getHTitle()

const char * EvtHis2F::getHTitle ( )

Definition at line 31 of file EvtHis2F.cc.

31 {
32 return datatitle;
33}

Referenced by init().

◆ getHwt()

TH2F * EvtHis2F::getHwt ( )

Definition at line 63 of file EvtHis2F.cc.

63 {
64 return HWT;
65}

Referenced by EvtNT3::init().

◆ getXlow()

double EvtHis2F::getXlow ( )
inline

Definition at line 66 of file EvtHis2F.hh.

66{return xlow;}

◆ getXup()

double EvtHis2F::getXup ( )
inline

Definition at line 68 of file EvtHis2F.hh.

68{return xup;}

◆ getYlow()

double EvtHis2F::getYlow ( )
inline

Definition at line 67 of file EvtHis2F.hh.

67{return ylow;}

◆ getYup()

double EvtHis2F::getYup ( )
inline

Definition at line 69 of file EvtHis2F.hh.

69{return yup;}

◆ getZmax()

double EvtHis2F::getZmax ( )

Definition at line 192 of file EvtHis2F.cc.

192 {
193 return zmax;
194}

Referenced by EvtNT3::init().

◆ getZvalue()

double EvtHis2F::getZvalue ( double m12_square,
double m13_square )

Definition at line 196 of file EvtHis2F.cc.

196 {
197 int xbin = HWT->GetXaxis()->FindBin(xmass2);
198 int ybin = HWT->GetYaxis()->FindBin(ymass2);
199 int xybin= HWT->GetBin(xbin,ybin);
200 double zvalue=HWT->GetBinContent(xybin);
201// std::cout<<"xmass, ymass, zvalue "<<xmass2<<" "<<ymass2<<" "<<zvalue<<std::endl;
202 return zvalue;
203}

Referenced by AR().

◆ HFill()

void EvtHis2F::HFill ( double xmass2,
double ymass2 )

Definition at line 129 of file EvtHis2F.cc.

129 {
130 HMC->Fill(m12s,m13s,1.0);
131 icount++;
132 // if(icount==100000)show(HMC);
133 if(icount==100000) showFrame(HMC);
134 return;
135}
void showFrame(TH2F *h2)
Definition EvtHis2F.cc:83

◆ HReweight()

void EvtHis2F::HReweight ( )

Definition at line 137 of file EvtHis2F.cc.

137 { //reweight Dalitz Plot after get HDATA and HMC
138 std::cout<<"Now I reweight the MC to the data Dalitz Plot"<<std::endl;
139 double ndata=HDATA->Integral();
140 std::cout<<"Number events in Dalitz plot = "<<ndata<<std::endl;
141 double nmc=HMC->Integral();
142 std::cout<<"Number of events in HMC reweight= "<<nmc<<std::endl;
143 HWT->Divide(HDATA,HMC);
144 ndata=HWT->Integral();
145 std::cout<<"Number of events after reweight= "<<ndata<<std::endl;
146 double norm=nmc/ndata;
147 HWT->Scale(norm);
148 nmc=HMC->Integral();
149 std::cout<<"Number of events in HMC after scale= "<<nmc<<std::endl;
150}

Referenced by init().

◆ init() [1/2]

void EvtHis2F::init ( )

Definition at line 98 of file EvtHis2F.cc.

98 {
99 const char* dtfile =getFile(); // get data root file as input
100 const char* htitle =getHTitle(); // get Dalitz plot title
101
102 TFile dataf(dtfile);
103 HDATA = (TH2F*)dataf.Get(htitle);
104
105 double ndata=HDATA->Integral();
106 std::cout<<"Number events in HDATA= "<<ndata<<std::endl;
107
108 TAxis* Xaxis=HDATA->GetXaxis();
109 TAxis* Yaxis=HDATA->GetYaxis();
110
111 BINSx =Xaxis->GetLast();
112 BINSy =Yaxis->GetLast();
113
114 xlow=Xaxis->GetBinLowEdge(1);
115 ylow=Yaxis->GetBinLowEdge(1);
116 xup =Xaxis->GetBinUpEdge(BINSx);
117 yup =Yaxis->GetBinUpEdge(BINSy);
118
119 std::cout<<"BINSx,xlow,xup,BINSy,ylow,yup: "<<BINSx<<" ,"<<xlow<<", "<<xup<<", "<<BINSy<<", "<<ylow<<", "<<yup<<std::endl;
120 HMC = new TH2F("myHMC","",BINSx,xlow,xup,BINSy,ylow,yup);
121 HWT = new TH2F("myHWT","",BINSx,xlow,xup,BINSy,ylow,yup);
122 HMC ->SetDirectory(0);
123 HWT ->SetDirectory(0);
124 HDATA->SetDirectory(0);
125 icount=0;
126 return;
127}
const char * getHTitle()
Definition EvtHis2F.cc:31
const char * getFile()
Definition EvtHis2F.cc:27

Referenced by EvtNT3::init(), and EvtDecay::initialize().

◆ init() [2/2]

void EvtHis2F::init ( TH2F * hmc,
TH2F * hdt,
TH2F * hwt )

Definition at line 236 of file EvtHis2F.cc.

236 {
237 setHmc(hmc);
238 setHdt(hdt);
239 setHwt(hwt);
240 HReweight();
241 setZmax();
242}
void HReweight()
Definition EvtHis2F.cc:137
void setHwt(TH2F *H2)
Definition EvtHis2F.hh:50
void setHdt(TH2F *H2)
Definition EvtHis2F.cc:50
void setHmc(TH2F *H2)
Definition EvtHis2F.cc:45
void setZmax()
Definition EvtHis2F.cc:177

◆ setBins()

void EvtHis2F::setBins ( TH2F * h2)

Definition at line 152 of file EvtHis2F.cc.

152 {
153 TAxis* Xaxis=h2->GetXaxis();
154 TAxis* Yaxis=h2->GetYaxis();
155 BINSx =Xaxis->GetLast();
156 BINSy =Yaxis->GetLast();
157 xlow=Xaxis->GetBinLowEdge(1);
158 ylow=Yaxis->GetBinLowEdge(1);
159 xup =Xaxis->GetBinUpEdge(BINSx);
160 yup =Yaxis->GetBinUpEdge(BINSy);
161}

Referenced by AR(), setZmax(), and setZmax().

◆ setBINSx()

void EvtHis2F::setBINSx ( int bx)
inline

Definition at line 56 of file EvtHis2F.hh.

56{BINSx=bx;}

◆ setBINSy()

void EvtHis2F::setBINSy ( int by)
inline

Definition at line 57 of file EvtHis2F.hh.

57{BINSy=by;}

◆ setFile()

void EvtHis2F::setFile ( const char * dtfile)

Definition at line 35 of file EvtHis2F.cc.

35 {
36 datafile=dtfile;
37 return;
38}

Referenced by EvtDecay::initialize().

◆ setHdt()

void EvtHis2F::setHdt ( TH2F * H2)

Definition at line 50 of file EvtHis2F.cc.

50 {
51 HDATA=(TH2F*) H2->Clone("HDATA");
52 return;
53}

Referenced by init().

◆ setHmc()

void EvtHis2F::setHmc ( TH2F * H2)

Definition at line 45 of file EvtHis2F.cc.

45 {
46 HMC=(TH2F*) H2->Clone("HMC");
47 return;
48}

Referenced by init().

◆ setHTitle()

void EvtHis2F::setHTitle ( const char * htitle)

Definition at line 40 of file EvtHis2F.cc.

40 {
41 datatitle=htitle;
42 return;
43}

Referenced by EvtDecay::initialize().

◆ setHwt()

void EvtHis2F::setHwt ( TH2F * H2)
inline

Definition at line 50 of file EvtHis2F.hh.

50{ HWT=(TH2F*) H2->Clone("HWT");}

Referenced by init().

◆ setXlow()

void EvtHis2F::setXlow ( double xl)
inline

Definition at line 58 of file EvtHis2F.hh.

58{xlow=xl;}

◆ setXup()

void EvtHis2F::setXup ( double xu)
inline

Definition at line 59 of file EvtHis2F.hh.

59{xup=xu;}

◆ setYlow()

void EvtHis2F::setYlow ( double yl)
inline

Definition at line 60 of file EvtHis2F.hh.

60{ylow=yl;}

◆ setYup()

void EvtHis2F::setYup ( double yu)
inline

Definition at line 61 of file EvtHis2F.hh.

61{yup=yu;}

◆ setZmax() [1/2]

void EvtHis2F::setZmax ( )

Definition at line 177 of file EvtHis2F.cc.

177 {
178 double ymax=0;
179 setBins(HWT);
180
181 for(int dx=1;dx <= BINSx;dx++){
182 for(int dy=1;dy <= BINSy;dy++){
183 int nxy=HWT->GetBin(dx,dy);
184 double ncell=HWT->GetBinContent(nxy);
185 if(ncell<=0) continue;
186 if(ncell>ymax){ymax=ncell;}
187 }
188 }
189 zmax=ymax;
190}

Referenced by init().

◆ setZmax() [2/2]

void EvtHis2F::setZmax ( TH2F * H2)

Definition at line 162 of file EvtHis2F.cc.

162 {
163 double ymax=0;
164 setBins(hwt);
165
166 for(int dx=1;dx <= BINSx;dx++){
167 for(int dy=1;dy <= BINSy;dy++){
168 int nxy=hwt->GetBin(dx,dy);
169 double ncell=hwt->GetBinContent(nxy);
170 if(ncell<=0) continue;
171 if(ncell>ymax){ymax=ncell;}
172 }
173 }
174 zmax=ymax;
175}

◆ show()

void EvtHis2F::show ( TH2F * h2)

Definition at line 67 of file EvtHis2F.cc.

67 {
68 TAxis* Xaxis=h2->GetXaxis();
69 TAxis* Yaxis=h2->GetYaxis();
70
71 int bx =Xaxis->GetLast();
72 int by =Yaxis->GetLast();
73
74 for(int i=1;i<bx+1;i++){
75 for(int j=1;j<by+1;j++){
76 int ij=h2->GetBin(i,j);
77 double xij=h2->GetBinContent(ij);
78 std::cout<<"i,j,cell,value "<<i<<" "<<j<<" "<<ij<<" "<<xij<<std::endl;
79 }
80 }
81}

◆ showFrame()

void EvtHis2F::showFrame ( TH2F * h2)

Definition at line 83 of file EvtHis2F.cc.

83 {
84 TAxis* Xaxis=h2->GetXaxis();
85 TAxis* Yaxis=h2->GetYaxis();
86
87 int bx =Xaxis->GetLast();
88 int by =Yaxis->GetLast();
89
90 double x1 =Xaxis->GetBinLowEdge(1);
91 double y1 =Yaxis->GetBinLowEdge(1);
92 double x2 =Xaxis->GetBinUpEdge(bx);
93 double y2 =Yaxis->GetBinUpEdge(by);
94 std::cout<<"N_x, x_low, x_up; N_y, y_low, y_up "
95 <<bx<<" "<<x1<<" "<<x2<<" "<<by<<" "<<y1<<" "<<y2<<std::endl;
96}

Referenced by HFill().


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