1 #include "commonmacro/common.h"
2 #include "common/Name.cc"
3 #include "commonmacro/histutil.h"
5 void dirtyBack(
const char* inName=
6 "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
7 const char* psDir=
"ps",
9 const char* outDir=
"./",
10 const char* more =
"west",
13 cout <<
"--------------------------" << endl;
14 cout <<
"in name=" << inName << endl
15 <<
"ps dir=" << psDir << endl
16 <<
"cut=" << cut << endl;
17 cout <<
"--------------------------" << endl;
19 inRoot =
new TFile(inName);
21 gSystem->Load(
"StHiMicroAnalysis");
23 cout <<
"cannot find the infile" << endl;
27 TString outName=outDir;
28 sprintf(name,
"/background_cut%d.hist.root",cut);
31 TFile* outRoot=
new TFile(outName.Data(),
"RECREATE");
32 double badBkgFrac[]={.56,.70,.70,.80,.80};
33 double sigBkgOverBadBkg[] = {6.5,3.9,1.4,.5,.2};
35 float ptary[]={1.5,2,3,4,5,6};
39 TH2* h2=(TH2*)inRoot->Get(
"Minus.h2SDcaGlPtPr");
41 TH1D* hBack=
new TH1D(
"h1BackGround",
"h1BackGround",
44 for(
int ipt=0;ipt<npt;ipt++){
45 TH1* h1=(TH2*)HistSlice(h2,
"",
"",0,ptary[ipt],ptary[ipt+1],
"x");
46 lowBin=h1->FindBin(-3);
47 upBin=h1->FindBin(-1.99999);
48 double badAll=h1->Integral(lowBin,upBin);
49 double sigBkg=badAll*badBkgFrac[ipt]*sigBkgOverBadBkg[ipt];
50 lowBin=h1->FindBin(Cut::mSDcaGl[0]);
51 upBin=h1->FindBin(Cut::mSDcaGl[1]-.00001);
52 double sig=h1->Integral(lowBin,upBin);
53 double bkgFrac = sigBkg/sig;
54 cout << h1->GetTitle()
" : " << bkgFrac << endl;
55 hBack->SetBinContent(ipt+1,bkgFrac);
57 cout <<
"writing " << outName << endl;