8 #include "common/Name.cc"
9 #include "commonmacro/histutil.h"
11 char* inrootname=
"~/wrk/real/links/P01hi.minbias.2000.hist/hispectra_cut2100.hist.root";
12 char* correctname=
"~/wrk/assoc/links/P01hi.central.HighpT_piminus_101.hist/momcorrection_cut2100.hist.root";
13 char* bkgname =
"~/afs/real/background_test.hist.root";
14 char* outrootname=
"~/wrk/real/links/temp.hist/finish_test.root";
15 char* textdir =
"TEXT";
17 void finish(
const char* inRootName=inrootname,
18 const char* correctionName=correctname,
19 const char* backgroundName=bkgname,
20 const char* outRootName=outrootname,
21 const char* textDir=textdir,
26 cout <<
"In file : " << inRootName << endl
27 <<
"mom correct : " << correctionName << endl
28 <<
"bkg : " << backgroundName << endl
29 <<
"out file : " << outRootName << endl
30 <<
"text dir : " << textDir << endl
31 <<
"cut : " << cut << endl
32 <<
"iter : " << iter << endl
33 <<
"offset type : " << offSetType << endl
34 <<
"fit high : " << fitHighPt << endl
35 <<
"cor high : " << corHighPt << endl;
38 int doMomCorrection = (iter>0);
40 gSystem->Load(
"StHiMicroAnalysis");
41 Cut::SetCut(cut); Cut::ShowCuts();
43 char *trigger =
"test";
47 initTextFiles(textDir,cut,iter);
49 *ofVal <<
">>>>>>>>>>" << endl;
50 *ofVal <<
"Doing momentum correction? " << doMomCorrection << endl;
51 cout <<
">>>>>>>>>>>" << endl;
52 cout <<
"Doing momentum correction? " << doMomCorrection << endl;
57 if(doMomCorrection) getCorrectionHistograms(correctionName);
63 getBackgroundHistograms(backgroundName);
69 getHistograms(inRootName);
79 outRoot =
new TFile(outRootName,
"RECREATE");
106 cout <<
"wrong type";
return;
127 writeHistograms(outRootName);
135 void initTextFiles(
const char* textDir,
int cut,
int iter)
138 sprintf(name,
"%s/corValues_cut%d_iter%d.txt",textDir,cut,iter);
139 cout <<
"correction values : " << name << endl;
140 ofCor =
new ofstream(name);
141 if(!ofCor) { cout <<
"cannot create " << name << endl;}
146 sprintf(name,
"%s/values_cut%d_iter%d.txt",textDir,cut,iter);
147 cout <<
"values : " << name << endl;
148 ofVal =
new ofstream(name);
157 void getCorrectionHistograms(
const char* correctionName)
159 cout <<
"\t**getCorrectionHistograms**" << endl;
165 TFile* corRoot =
new TFile(correctionName);
167 if(!corRoot)
return 1;
169 for(Int_t iBin=0; iBin<nVarBin; iBin++){
171 setName(name,
"h1PtDCrRatio",iBin);
172 correction[iBin].crip.h1PtDCrRatio = (TH1D*) corRoot->Get(name);
173 if(!correction[iBin].crip.h1PtDCrRatio) {
174 cout <<
"no " << name << endl; exit(1);
176 showHistogramValues(correction[iBin].crip.h1PtDCrRatio,
177 "MOMENTUM CORRECTIONS");
180 setName(name,
"fCorrected",iBin);
181 correction[iBin].crip.fCorrected = (TF1*)corRoot->Get(name);
182 if(!correction[iBin].crip.fCorrected){
183 cout <<
"no " << name << endl; exit(1);
185 for(Int_t iCharge=0; iCharge<2; iCharge++){
187 setName(name,
"h1PtDCrRatio",iBin,sPM[iCharge].Data());
188 correction[iBin].cripPM[iCharge].h1PtDCrRatio = (TH1D*)corRoot->Get(name);
189 showHistogramValues(correction[iBin].cripPM[iCharge].h1PtDCrRatio,
190 "MOMENTUM CORRECTIONS");
192 if(!correction[iBin].cripPM[iCharge].h1PtDCrRatio) {
193 cout <<
"no " << name << endl; exit(1);
195 setName(name,
"fCorrected",iBin,sPM[iCharge].Data());
196 correction[iBin].cripPM[iCharge].fCorrected = (TF1*)corRoot->Get(name);
197 if(!correction[iBin].cripPM[iCharge].fCorrected){
198 cout <<
"no " << name << endl; exit(1);
210 cout <<
"Momentum correction used weights ..." << endl;
212 for(Int_t iBin=0; iBin<nVarBin; iBin++){
213 cout <<
"Bin " << iBin << endl;
214 cout <<
"\tBoth charges"
216 <<correction[iBin].crip.fCorrected->GetParameter(0)
218 <<correction[iBin].crip.fCorrected->GetParameter(1)
221 for(Int_t iCharge=0; iCharge<2; iCharge++){
222 cout <<
"\t"<< sPM[iCharge].Data()
224 <<correction[iBin].cripPM[iCharge].fCorrected->GetParameter(0)
226 <<correction[iBin].cripPM[iCharge].fCorrected->GetParameter(1)
238 void getBackgroundHistograms(
const char* backgroundName)
240 cout <<
"\t**getBackgroundHistograms()**" << endl;
242 TFile* bkgRoot =
new TFile(backgroundName);
247 strcpy(name,
"h1BackGround");
249 char* dcaType =
"DcaGl";
251 for(
int iBin=0; iBin<nVarBin; iBin++){
252 setName(name,
"h1Background",iBin);
253 sprintf(name,
"%s%s",name,dcaType);
254 correction[iBin].bkg.h1Background=(TH1D*) bkgRoot->Get(name);
256 if(!correction[iBin].bkg.h1Background){
257 cout <<
"Cannot find " << name <<
" in "
258 << backgroundName << endl; exit(1);
260 showHistogramValues(correction[iBin].bkg.h1Background,
"");
262 for(
int ic=0; ic<2; ic++){
263 setName(name,
"h1Background",iBin,sPM[ic].Data());
264 sprintf(name,
"%s%s",name,dcaType);
265 correction[iBin].bkgPM[ic].h1Background=(TH1D*) bkgRoot->Get(name);
267 if(!correction[iBin].bkg.h1Background){
268 cout <<
"Cannot find " << name <<
" in "
269 << backgroundName << endl; exit(1);
271 showHistogramValues(correction[iBin].bkgPM[ic].h1Background,
"");
278 void getHistograms(
const char* inRootName)
280 cout <<
"\t**getHistograms()**" << endl;
283 TFile* inRoot =
new TFile(inRootName);
284 if(!inRoot || !inRoot->IsOpen()){
285 cout <<
"cannot open " << inRootName << endl; exit(1);
290 h1VertexZCut = (TH1D*)inRoot->Get(
"h1VertexZCut");
294 h1NEvent = (TH1D*) inRoot->Get(
"h1NEvent");
295 h1EtaCut = (TH1D*) inRoot->Get(
"h1EtaCut");
298 nEvent = h1NEvent->GetBinContent(1);
299 etaCut[0] = h1EtaCut->GetBinContent(1);
300 etaCut[1] = h1EtaCut->GetBinContent(2);
301 scale = (1./nEvent)*(1./(etaCut[1]-etaCut[0]));
303 cout <<
"n event : " << nEvent << endl;
304 cout <<
"eta cut : " << etaCut[0] <<
", " << etaCut[1] << endl;
305 cout <<
"scale : " << scale << endl;
307 *ofVal <<
"n event : " << nEvent << endl
308 <<
"eta cut : " << etaCut[0] <<
", " << etaCut[1] << endl
309 <<
"scale : " << scale << endl;
311 for(Int_t iBin=0; iBin<nVarBin; iBin++){
313 setName(name,
"h1OneOverPt",iBin);
314 varBin[iBin].mean.h1OneOverPt = (TH1D*)inRoot->Get(name);
316 setName(name,
"h1WeightedMean",iBin);
317 varBin[iBin].mean.h1WeightedMean = (TH1D*)inRoot->Get(name);
321 setName(name,
"h1Raw",iBin);
322 varBin[iBin].spec.h1Raw = (TH1D*) inRoot->Get(name);
324 showHistogramValues(varBin[iBin].spec.h1Raw,
"YIELDS");
329 setName(name,
"h1EffCorrected",iBin);
330 varBin[iBin].spec.h1EffCorrected = (TH1D*) inRoot->Get(name);
331 showHistogramValues(varBin[iBin].spec.h1EffCorrected,
"YIELDS");
336 setName(name,
"h1Corrected",iBin);
337 varBin[iBin].spec.h1Corrected = (TH1D*) inRoot->Get(name);
338 showHistogramValues(varBin[iBin].spec.h1Corrected,
"YIELDS");
343 for(Int_t iCharge=0; iCharge<2; iCharge++){
347 setName(name,
"h1OneOverPt",iBin,sPM[iCharge].Data());
348 varBin[iBin].meanPM[iCharge].h1OneOverPt = (TH1D*)inRoot->Get(name);
350 setName(name,
"h1WeightedMean",iBin,sPM[iCharge].Data());
351 varBin[iBin].meanPM[iCharge].h1WeightedMean = (TH1D*)inRoot->Get(name);
356 setName(name,
"h1Raw",iBin,sPM[iCharge].Data());
357 varBin[iBin].specPM[iCharge].h1Raw =
358 (TH1D*) inRoot->Get(name);
359 showHistogramValues(varBin[iBin].specPM[iCharge].h1Raw,
"YIELDS");
363 setName(name,
"h1EffCorrected",iBin,sPM[iCharge].Data());
364 varBin[iBin].specPM[iCharge].h1EffCorrected =
365 (TH1D*) inRoot->Get(name);
366 showHistogramValues(varBin[iBin].specPM[iCharge].h1EffCorrected,
"YIELDS");
371 setName(name,
"h1Corrected",iBin,sPM[iCharge].Data());
372 varBin[iBin].specPM[iCharge].h1Corrected =
373 (TH1D*) inRoot->Get(name);
374 showHistogramValues(varBin[iBin].specPM[iCharge].h1Corrected,
"YIELDS");
379 setName(name,
"h1RawRatio",iBin);
380 varBin[iBin].h1RawRatio = (TH1D*) inRoot->Get(name);
382 setName(name,
"h1CorrectedRatio",iBin);
383 varBin[iBin].h1CorrectedRatio = (TH1D*) inRoot->Get(name);
390 void doBothChargeSigns()
392 cout <<
"\t**doBothChargsSigns()**" << endl;
398 for(Int_t iBin=0; iBin<nVarBin; iBin++){
399 varBin[iBin].spec.h1Raw->Scale(0.5);
402 varBin[iBin].spec.h1EffCorrected->Scale(0.5);
405 varBin[iBin].spec.h1Corrected->Scale(0.5);
415 cout <<
"\t**doCorrections()**" << endl;
419 for(Int_t iBin=0; iBin<nVarBin; iBin++){
421 computeCorrection(varBin[iBin].spec.h1EffCorrected,
422 correction[iBin].crip.h1PtDCrRatio,
423 correction[iBin].bkg.h1Background,
424 varBin[iBin].spec.h1Corrected);
426 showHistogramValues(varBin[iBin].spec.h1Corrected,
"CORRECTED");
428 for(Int_t iCharge=0; iCharge<2; iCharge++){
430 computeCorrection(varBin[iBin].specPM[iCharge].h1EffCorrected,
431 correction[iBin].cripPM[iCharge].h1PtDCrRatio,
432 correction[iBin].bkgPM[iCharge].h1Background,
433 varBin[iBin].specPM[iCharge].h1Corrected);
434 showHistogramValues(varBin[iBin].specPM[iCharge].h1Corrected,
443 for(Int_t iBin=0; iBin<nVarBin; iBin++){
444 varBin[iBin].spec.h1Raw->Scale(scale);
445 varBin[iBin].spec.h1Corrected->Scale(scale);
446 varBin[iBin].spec.h1EffCorrected->Scale(scale);
447 for(Int_t iCharge=0; iCharge<2; iCharge++){
448 varBin[iBin].specPM[iCharge].h1Raw->Scale(scale);
449 varBin[iBin].specPM[iCharge].h1Corrected->Scale(scale);
450 varBin[iBin].specPM[iCharge].h1EffCorrected->Scale(scale);
458 for(Int_t iBin=0; iBin<nVarBin; iBin++){
459 computePtBin(varBin[iBin].spec.h1Raw);
460 computePtBin(varBin[iBin].spec.h1EffCorrected);
461 computePtBin(varBin[iBin].spec.h1Corrected);
463 for(Int_t iCharge=0; iCharge<2; iCharge++){
464 computePtBin(varBin[iBin].specPM[iCharge].h1Raw);
465 computePtBin(varBin[iBin].specPM[iCharge].h1EffCorrected);
466 computePtBin(varBin[iBin].specPM[iCharge].h1Corrected);
476 cout <<
"\tinitFit()" << endl;
479 fDist =
new TF1(
"fDist",dist,fitLowPt,fitHighPt);
480 fMean =
new TF1(
"fMean",mean,fitLowPt,fitHighPt);
484 fDist->SetParameters(2.0,13.,p2);
485 fMean->SetParameters(2.0,13.,p2);
486 const int nParam = 3;
488 Double_t param[nParam];
489 fDist->GetParameters(param);
505 cout <<
"\t**fit histograms**" << endl;
510 TCanvas* dummy =
new TCanvas(
"dummy",
"dummy",100,100,500,500);
514 for(Int_t iBin=0; iBin<nVarBin; iBin++){
515 varBin[iBin].spec.fRawTmp =
516 fit(varBin[iBin].spec.h1Raw);
518 varBin[iBin].spec.fEffCorrectedTmp =
519 fit(varBin[iBin].spec.h1EffCorrected);
521 varBin[iBin].spec.fCorrectedTmp =
522 fit(varBin[iBin].spec.h1Corrected);
524 for(Int_t iCharge=0; iCharge<2; iCharge++){
525 varBin[iBin].specPM[iCharge].fRawTmp =
526 fit(varBin[iBin].specPM[iCharge].h1Raw);
528 varBin[iBin].specPM[iCharge].fEffCorrectedTmp =
529 fit(varBin[iBin].specPM[iCharge].h1EffCorrected);
531 varBin[iBin].specPM[iCharge].fCorrectedTmp =
532 fit(varBin[iBin].specPM[iCharge].h1Corrected);
547 cout <<
"\tfitting " << h1->GetName() << endl;
553 TH1* hClone=(TH1*)h1->Clone();
554 hClone->Fit(
"fDist",
"QR");
555 f = hClone->GetFunction(
"fDist");
557 f->GetParameters(param);
558 fDist->SetParameters(param);
561 hClone->Fit(
"fDist",
"QR");
562 f = hClone->GetFunction(
"fDist");
570 TString sName = h1->GetName();
572 Ssiz_t last = findLast(sName,
".");
574 sName.Replace(last,2,
"fTmp");
576 f->SetName(sName.Data());
577 f->SetTitle(sName.Data());
587 TF1* fit(TGraphAsymmErrors* g)
589 cout <<
"\tfitting " << g->GetName() << endl;
595 TGraphAsymmErrors* gClone=(TGraphAsymmErrors*)g->Clone();
596 gClone->Fit(
"fDist",
"QR");
597 f = gClone->GetFunction(
"fDist");
599 f->GetParameters(param);
600 fDist->SetParameters(param);
603 gClone->Fit(
"fDist",
"QR");
604 f = gClone->GetFunction(
"fDist");
606 cout <<
"\t\tparams : "
607 <<
"p0=" << f->GetParameter(0)
608 <<
",p1=" << f->GetParameter(1)
609 <<
",p2=" << f->GetParameter(2)
612 TString sName = g->GetName();
614 Ssiz_t last = findLast(sName,
".");
616 sName.Replace(last,1,
"f");
617 f->SetName(sName.Data());
618 f->SetTitle(sName.Data());
620 cout <<
"\t\t fcn name " << f->GetName() << endl;
628 Double_t getWeightedMean(TF1* f,Double_t lowEdge, Double_t upEdge)
632 f->GetParameters(param);
637 fMean->SetParameters(param);
639 return fMean->Integral(lowEdge,upEdge)/f->Integral(lowEdge,upEdge);
649 graphOffset(TH1D* h1,TF1* f,TH1* hMean,Int_t type)
652 Int_t lowBin = h1->GetXaxis()->FindBin(fitLowPt);
653 Int_t highBin = h1->GetXaxis()->FindBin(fitHighPt-.0001);
654 Int_t nBin = highBin-lowBin+1;
656 TArrayD yErrorAry(nBin), yValueAry(nBin), xValueAry(nBin),
657 xLowErrorAry(nBin), xHighErrorAry(nBin);
665 for(Int_t iBin=lowBin; iBin<=highBin; iBin++,binAry++){
670 Double_t lowEdge = h1->GetXaxis()->GetBinLowEdge(iBin);
671 Double_t upEdge = h1->GetXaxis()->GetBinUpEdge(iBin);
676 mean = getWeightedMean(f,lowEdge,upEdge);
break;
678 mean = h1Mean->GetBinContent(h1Mean->GetXaxis()->FindBin((lowEdge+upEdge)/2));
break;
680 mean = getWeightedMean(f,lowEdge,upEdge);
683 xLowErrorAry.AddAt(fabs(mean-lowEdge),binAry);
684 xHighErrorAry.AddAt(fabs(mean-upEdge),binAry);
686 xValueAry.AddAt(mean,binAry);
688 yErrorAry.AddAt(h1->GetBinError(iBin),binAry);
690 yValueAry.AddAt(h1->GetBinContent(iBin),binAry);
698 TGraphAsymmErrors* g =
new TGraphAsymmErrors(nBin,
699 xValueAry.GetArray(),
700 yValueAry.GetArray(),
701 xLowErrorAry.GetArray(),
702 xHighErrorAry.GetArray(),
703 yErrorAry.GetArray(),
704 yErrorAry.GetArray());
706 TString sName = h1->GetName();
707 Ssiz_t last = findLast(sName,
".");
709 sName.Replace(last,2,
"g");
711 g->SetName(sName.Data());
712 g->SetTitle(sName.Data());
719 graphSpectra(TGraphAsymmErrors* g)
722 const Int_t nBin = g->GetN();
724 Double_t* x = g->GetX();
725 Double_t* y = g->GetY();
726 Double_t* eXlow = g->GetEXlow();
727 Double_t* eXhigh = g->GetEXhigh();
728 Double_t* eYlow = g->GetEYlow();
730 TArrayD yErrorAry(nBin), yValueAry(nBin);
736 for(Int_t i=0; i<nBin; i++){
737 Double_t mean = x[i];
739 yErrorAry.AddAt(eYlow[i]/mean,i);
740 yValueAry.AddAt(y[i]/mean,i);
744 TGraphAsymmErrors* gSpec
745 =
new TGraphAsymmErrors(nBin,x,yValueAry.GetArray(),eXlow,eXhigh,
746 yErrorAry.GetArray(),yErrorAry.GetArray());
748 TString sName = g->GetName();
749 Ssiz_t last = findLast(sName,
".");
751 sName.Replace(last,1,
"gSpec");
753 gSpec->SetName(sName.Data());
754 gSpec->SetTitle(sName.Data());
765 void doOffSetGraphs(Int_t type)
768 for(Int_t iBin=0; iBin<nVarBin; iBin++){
770 varBin[iBin].spec.gRaw =
771 graphOffset(varBin[iBin].spec.h1Raw,
772 varBin[iBin].spec.fRawTmp,
773 varBin[iBin].mean.h1WeightedMean,type);
775 varBin[iBin].spec.gEffCorrected =
776 graphOffset(varBin[iBin].spec.h1EffCorrected,
777 varBin[iBin].spec.fEffCorrectedTmp,
778 varBin[iBin].mean.h1WeightedMean,type);
780 varBin[iBin].spec.gCorrected =
781 graphOffset(varBin[iBin].spec.h1Corrected,
782 varBin[iBin].spec.fCorrectedTmp,
783 varBin[iBin].mean.h1WeightedMean,type);
786 for(Int_t iCharge=0; iCharge<2; iCharge++){
788 varBin[iBin].specPM[iCharge].gRaw =
789 graphOffset(varBin[iBin].specPM[iCharge].h1Raw,
790 varBin[iBin].specPM[iCharge].fRawTmp,
791 varBin[iBin].mean.h1WeightedMean,type);
794 varBin[iBin].specPM[iCharge].gEffCorrected =
795 graphOffset(varBin[iBin].specPM[iCharge].h1EffCorrected,
796 varBin[iBin].specPM[iCharge].fEffCorrectedTmp,
797 varBin[iBin].meanPM[iCharge].h1WeightedMean,type);
799 varBin[iBin].specPM[iCharge].gCorrected =
800 graphOffset(varBin[iBin].specPM[iCharge].h1Corrected,
801 varBin[iBin].specPM[iCharge].fCorrectedTmp,
802 varBin[iBin].meanPM[iCharge].h1WeightedMean,type);
817 cout <<
"\t**fitGraphs()**" << endl;
822 TCanvas* dummy =
new TCanvas(
"dummy",
"dummy",100,100,500,500);
825 for(Int_t iBin=0; iBin<nVarBin; iBin++){
827 varBin[iBin].spec.fEffCorrected =
828 fit(varBin[iBin].spec.gEffCorrected);
830 varBin[iBin].spec.fCorrected =
831 fit(varBin[iBin].spec.gCorrected);
833 for(Int_t iCharge=0; iCharge<2; iCharge++){
835 varBin[iBin].specPM[iCharge].fEffCorrected =
836 fit(varBin[iBin].specPM[iCharge].gEffCorrected);
838 varBin[iBin].specPM[iCharge].fCorrected =
839 fit(varBin[iBin].specPM[iCharge].gCorrected);
848 void doSpectraGraphs()
850 cout <<
"\t**doSpectraGraphs()**" << endl;
852 for(Int_t iBin=0; iBin<nVarBin; iBin++){
853 varBin[iBin].spec.gSpecCorrected =
854 graphSpectra(varBin[iBin].spec.gCorrected);
856 for(Int_t iCharge=0; iCharge<2; iCharge++){
858 varBin[iBin].specPM[iCharge].gSpecCorrected =
859 graphSpectra(varBin[iBin].specPM[iCharge].gCorrected);
871 void draw(
const char* psDir,
const char* trigger,
const char* cut)
882 void computeCorrection(TH1D* hRc, TH1D* hDCrOverRc,
883 TH1D* hBkg, TH1D* hCorrected)
886 Stat_t rc, dCr, rcError, dCrError, error, corrected, bkgCorrected,
887 bkgCorrectedError, center, bkg, bkgError;
890 Int_t nBin = hRc->GetNbinsX();
891 Int_t maxBkgBin = hBkg->GetNbinsX();
893 *ofCor <<
"******************************************************" << endl;
894 *ofCor <<
"## computeCorrection ##" << endl;
895 *ofCor <<
"## corrected=" << hCorrected->GetName() << endl
896 <<
" rc=" << hRc->GetName() << endl
897 <<
" bkg=" << hBkg->GetName() << endl;
899 int firstCorBin=hRc->GetXaxis()->FindBin(corLowPt);
900 *ofCor <<
"First correction bin is " << firstCorBin << endl;
901 for(Int_t iBin=1; iBin<=nBin; iBin++){
903 rc = hRc->GetBinContent(iBin);
906 dCr = (hDCrOverRc) ? hDCrOverRc->GetBinContent(iBin) :0;
909 center = hRc->GetXaxis()->GetBinCenter(iBin);
910 bin = hBkg->GetXaxis()->FindBin(center);
911 if(bin==0 || bin>maxBkgBin){
915 bkg = hBkg->GetBinContent(bin);
920 bkgCorrected = rc*(1-bkg);
922 rcError = hRc->GetBinError(iBin);
928 = TMath::Sqrt(rcError*rcError*(1+bkg*bkg) + rc*rc*bkgError*bkgError);
932 if(iBin>=firstCorBin){
933 corrected = bkgCorrected*(1-dCr);
936 *ofCor <<
"\tskipping momentum correction for this bin" << endl;
937 corrected = bkgCorrected;
941 error = bkgCorrectedError;
943 hCorrected->SetBinContent(iBin,corrected);
944 hCorrected->SetBinError(iBin,error);
946 float fracError = (rc>0) ? ((error/rc)*100) : 0;
947 float fracRcError = (rc>0) ? ((rcError/rc)*100) : 0;
950 *ofCor <<
" rc : " << hRc->GetXaxis()->GetBinLowEdge(iBin) <<
"-"
951 << hRc->GetXaxis()->GetBinUpEdge(iBin)
952 <<
"\trc bin content : " << rc
953 <<
", crippled : " << dCr
954 <<
", background : " << bkg << endl
955 <<
"\tbkg corrected : " << bkgCorrected << endl
956 <<
"\tcorrected : " << corrected << endl;
957 *ofCor <<
"\t rc error : " << rcError
958 <<
"(" << fracRcError <<
" %)"
959 <<
", dCrError : " << dCrError
960 <<
", bkg error: " << bkgError
962 <<
"\tbkg cor error : " << bkgCorrectedError << endl
963 <<
"\ttotal error : " << error << endl
964 <<
"\ttotal err % : " << fracError << endl;
972 void ptDivide(TH1* h1)
974 Int_t nBin=h1->GetNbinsX();
975 for(
int iBin=1; iBin<=nBin; iBin++){
976 double content= h1->GetBinContent(iBin);
977 double center = h1->GetBinCenter(iBin);
978 double error = h1->GetBinError(iBin);
979 if(content) h1->SetBinContent(iBin,content/center);
980 if(error)h1->SetBinError(iBin,error/center);
986 void computePtBin(TH1* h1)
993 Int_t nBin = h1->GetNbinsX();
994 for(Int_t iBin=1; iBin<=nBin; iBin++){
995 binWidth = h1->GetBinWidth(iBin);
996 binContent= h1->GetBinContent(iBin);
997 if(binContent>0) binContent /= binWidth;
998 binError = h1->GetBinError(iBin);
999 if(binError!=0) binError /= binWidth;
1001 h1->SetBinContent(iBin,binContent);
1002 h1->SetBinError(iBin,binError);
1011 void writeHistograms(
const char* outRootName)
1013 cout <<
"writeHistograms() : " << outRootName << endl;
1017 for(Int_t iBin=0; iBin<nVarBin; iBin++){
1019 varBin[iBin].spec.h1Raw->Write();
1020 varBin[iBin].spec.h1EffCorrected->Write();
1021 varBin[iBin].spec.h1Corrected->Write();
1022 varBin[iBin].spec.gRaw->Write();
1023 varBin[iBin].spec.gEffCorrected->Write();
1024 varBin[iBin].spec.gCorrected->Write();
1025 varBin[iBin].spec.gSpecCorrected->Write();
1026 varBin[iBin].spec.fCorrected->Write();
1028 showHistogramValues(varBin[iBin].spec.h1Raw,
"FINAL");
1029 showHistogramValues(varBin[iBin].spec.h1EffCorrected,
"FINAL");
1030 showHistogramValues(varBin[iBin].spec.h1Corrected,
"FINAL");
1032 showTGraphValues(varBin[iBin].spec.gRaw,
"FINAL");
1033 showTGraphValues(varBin[iBin].spec.gEffCorrected,
"FINAL");
1034 showTGraphValues(varBin[iBin].spec.gCorrected,
"FINAL");
1035 showTGraphValues(varBin[iBin].spec.gSpecCorrected,
"FINAL");
1037 for(Int_t iCharge=0; iCharge<2; iCharge++){
1043 varBin[iBin].specPM[iCharge].h1Raw->Write();
1044 varBin[iBin].specPM[iCharge].h1EffCorrected->Write();
1045 varBin[iBin].specPM[iCharge].h1Corrected->Write();
1046 varBin[iBin].specPM[iCharge].gEffCorrected->Write();
1047 varBin[iBin].specPM[iCharge].gCorrected->Write();
1048 varBin[iBin].specPM[iCharge].gSpecCorrected->Write();
1049 varBin[iBin].specPM[iCharge].fCorrected->Write();
1051 showHistogramValues(varBin[iBin].specPM[iCharge].h1Raw,
"FINAL");
1052 showHistogramValues(varBin[iBin].specPM[iCharge].h1EffCorrected,
"FINAL");
1053 showHistogramValues(varBin[iBin].specPM[iCharge].h1Corrected,
"FINAL");
1055 showTGraphValues(varBin[iBin].specPM[iCharge].gRaw,
"FINAL");
1056 showTGraphValues(varBin[iBin].specPM[iCharge].gEffCorrected,
"FINAL");
1057 showTGraphValues(varBin[iBin].specPM[iCharge].gCorrected,
"FINAL");
1058 showTGraphValues(varBin[iBin].specPM[iCharge].gSpecCorrected,
"FINAL");
1071 Ssiz_t findLast(TString temp,
const char* a)
1076 Ssiz_t pos = temp.First(a);