void getResV(){ //------------------------Deal with the number and get the output stored in txt files and root files string SumorProd = getenv("SUMORPROD"); double Vmax[nbin], eps[nbin]; for(int ibin=0; ibin<nbin ;ibin++){ Vmax[ibin]=0.12*(trkbin[ibin]+50); eps[ibin]=0.00045*(trkbin[ibin]+50); } ofstream fstrV; double theta[ntheta]; TVectorD Gmod2[nbin][ntheta]; TVectorD sigma2[nbin],deltaV[nbin]; TVectorD r[nbin]; TVectorD r0[nbin], r01[nbin], V[nbin], chi[nbin]; TVectorD GRe[nbin][ntheta]; TVectorD* GRe_t[nbin][ntheta]; TVectorD GIm[nbin][ntheta]; TVectorD* GIm_t[nbin][ntheta]; TComplex G[nbin][ntheta][nstepr]; if(SumorProd=="Sum") fstrV.open("V_Sum.txt"); else fstrV.open("V_Prod.txt"); TFile *f[nFileAll]; for(int ibin=0; ibin<nbin; ibin++){ r[ibin].ResizeTo(nstepr); for(int ir=0; ir<nstepr; ir++){ if(isSimple==0) r[ibin][ir]=j01/(Vmax[ibin]-eps[ibin]*ir); else r[ibin][ir]=0.00025*20*(ir+1); } } TVectorD Nevent; Nevent.ResizeTo(nbin); Nevent.Zero(); TVectorD totmultall; totmultall.ResizeTo(nbin); totmultall.Zero(); TVectorD avgmultall; avgmultall.ResizeTo(nbin); avgmultall.Zero(); TVectorD tottrk; tottrk.ResizeTo(nbin); tottrk.Zero(); TVectorD totptall; totptall.ResizeTo(nbin); totptall.Zero(); TVectorD totetaall; totetaall.ResizeTo(nbin); totetaall.Zero(); TVectorD avgtrk; avgtrk.ResizeTo(nbin); avgtrk.Zero(); TVectorD avgmult; avgmult.ResizeTo(nbin); TVectorD deltaVmean; deltaVmean.ResizeTo(nbin); TVectorD Vmean; Vmean.ResizeTo(nbin); TVectorD avgpt; avgpt.ResizeTo(nbin); TVectorD avgeta; avgeta.ResizeTo(nbin); TVectorD Qx1; Qx1.ResizeTo(nbin); Qx1.Zero(); TVectorD Qy1; Qy1.ResizeTo(nbin); Qy1.Zero(); TVectorD Q2; Q2.ResizeTo(nbin); Q2.Zero(); TVectorD sigma2_; sigma2_.ResizeTo(nbin); sigma2_.Zero(); TVectorD chi_; chi_.ResizeTo(nbin); chi_.Zero(); for(int itheta=0;itheta<ntheta;itheta++) theta[itheta]=itheta*TMath::Pi()/ntheta/nn; for(int ibin=0;ibin<nbin;ibin++){ r0[ibin].ResizeTo(ntheta); r01[ibin].ResizeTo(ntheta); sigma2[ibin].ResizeTo(ntheta); V[ibin].ResizeTo(ntheta); deltaV[ibin].ResizeTo(ntheta); chi[ibin].ResizeTo(ntheta); for(int itheta=0;itheta<ntheta;itheta++){ Gmod2[ibin][itheta].ResizeTo(nstepr); GRe[ibin][itheta].ResizeTo(nstepr); GRe[ibin][itheta].Zero(); GIm[ibin][itheta].ResizeTo(nstepr); GIm[ibin][itheta].Zero(); } } for(int ifile=0; ifile<nFileAll; ifile++){ if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/PbPb2011MB/trackzvtxs/AnaV_Sum_%d.root",ifile)); else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/PbPb2011MB/trackzvtxs/AnaV_Prod_%d.root",ifile)); TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get(Form("Nevent")); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get(Form("totmultall")); TVectorD* tottrk_t = (TVectorD*)f[ifile]->Get(Form("tottrk")); TVectorD* totptall_t = (TVectorD*)f[ifile]->Get(Form("totptall")); TVectorD* totetaall_t = (TVectorD*)f[ifile]->Get(Form("totetaall")); TVectorD* Qx1_t = (TVectorD*)f[ifile]->Get(Form("Qx1")); TVectorD* Qy1_t = (TVectorD*)f[ifile]->Get(Form("Qy1")); TVectorD* Q2_t = (TVectorD*)f[ifile]->Get(Form("Q2")); for(int ibin=0;ibin<nbin;ibin++){ for(int itheta=0;itheta<ntheta;itheta++){ GRe_t[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("GRe_%d_%d",ibin,itheta)); GIm_t[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("GIm_%d_%d",ibin,itheta)); for(ir=0; ir<nstepr; ir++){ GRe[ibin][itheta][ir] += (*GRe_t[ibin][itheta])[ir]; GIm[ibin][itheta][ir] += (*GIm_t[ibin][itheta])[ir]; } } Qx1[ibin] += (*Qx1_t)[ibin]; Qy1[ibin] += (*Qy1_t)[ibin]; Q2[ibin] += (*Q2_t)[ibin]; totptall[ibin] += (*totptall_t)[ibin]; totetaall[ibin] += (*totetaall_t)[ibin]; Nevent[ibin] += (*Nevent_t)[ibin]; totmultall[ibin] += (*totmultall_t)[ibin]; tottrk[ibin] += (*tottrk_t)[ibin]; } f[ifile]->Close(); } fstrV<<setprecision(4)<<fixed; fstrV<<"ibin"<<"\t"<<"itheta"<<"\t"<<"r0"<<"\t"<<"V"<<"\t"<<"sigma2"<<"\t"<<"chi"<<"\t"<<"Vn Errors"<<endl; for(int ibin=0;ibin<nbin;ibin++){ avgmultall[ibin]=totmultall[ibin]/Nevent[ibin]; avgtrk[ibin]=tottrk[ibin]/Nevent[ibin]; for(int itheta=0;itheta<ntheta;itheta++){ for(ir=0; ir<nstepr; ir++){ G[ibin][itheta][ir]=TComplex(GRe[ibin][itheta][ir],GIm[ibin][itheta][ir]); G[ibin][itheta][ir]/=Nevent[ibin]; Gmod2[ibin][itheta][ir]=TMath::Power(TComplex::Abs(G[ibin][itheta][ir]),2); } for(ir=0; ir<nstepr-1; ir++) if(ir!=0 && Gmod2[ibin][itheta][ir]<=Gmod2[ibin][itheta][ir-1] && Gmod2[ibin][itheta][ir]<=Gmod2[ibin][itheta][ir+1]) break; if(ir!=0 && ir<nstepr-1) r01[ibin][itheta]=r[ibin][ir]; else if(ir==0) {cout<<"ibin="<<ibin<<"\t"<<"itheta="<<itheta<<"\tminimum lies on ir = 0, please select proper range!"<<endl; continue;} else {cout<<"ibin="<<ibin<<"\t"<<"itheta="<<itheta<<"\tminimum lies on ir = maximum "<<nstepr-1<<", please select proper range!"<<endl; continue;} avgmult[ibin]=1.0*totmultall[ibin]/Nevent[ibin]; avgpt[ibin]=1.0*totptall[ibin]/totmultall[ibin]; avgeta[ibin]=1.0*totetaall[ibin]/totmultall[ibin]; if(isSimple==0) V[ibin][itheta]=Vmax[ibin]-ir*eps[ibin]+eps[ibin]*(Gmod2[ibin][itheta][ir+1]-Gmod2[ibin][itheta][ir-1])/2./(Gmod2[ibin][itheta][ir-1]-2*Gmod2[ibin][itheta][ir]+Gmod2[ibin][itheta][ir+1]); else V[ibin][itheta]=j01/r0[ibin][itheta]; //simple method r0[ibin][itheta]=j01/V[ibin][itheta]; V[ibin][itheta]/=avgmult[ibin]; sigma2[ibin][itheta]=Q2[ibin]/Nevent[ibin]-(Qx1[ibin]/Nevent[ibin])*(Qx1[ibin]/Nevent[ibin])-(Qy1[ibin]/Nevent[ibin])*(Qy1[ibin]/Nevent[ibin]); sigma2_[ibin]+=sigma2[ibin][itheta]; Vmean[ibin]+=V[ibin][itheta]; chi[ibin][itheta]=V[ibin][itheta]*avgmult[ibin]/TMath::Sqrt(sigma2[ibin][itheta]); } //deltaVmean[ibin]+=TMath::Exp(j01*j01/2./chi[ibin][itheta]/chi[ibin][itheta]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Exp(-j01*j01/2./chi[ibin][itheta]/chi[ibin][itheta]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)); sigma2_[ibin]/=ntheta; Vmean[ibin]/=ntheta; sigma2_[ibin]-=TMath::Power(Vmean[ibin]*avgmult[ibin],2); chi_[ibin]=Vmean[ibin]*avgmult[ibin]/TMath::Sqrt(sigma2_[ibin]); for(int itheta=0;itheta<ntheta;itheta++){ deltaV[ibin][itheta]=V[ibin][itheta]/j01/TMath::BesselJ1(j01)*TMath::Sqrt((TMath::Exp(j01*j01/2./chi_[ibin]/chi_[ibin])+TMath::Exp(-j01*j01/2./chi_[ibin]/chi_[ibin])*TMath::BesselJ0(2*j01))/2./Nevent[ibin]); deltaVmean[ibin]+=TMath::Exp(j01*j01/2./chi_[ibin]/chi_[ibin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Exp(-j01*j01/2./chi_[ibin]/chi_[ibin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)); fstrV <<ibin<<"\t"<<itheta<<"\t"<<r0[ibin][itheta]<<"\t"<<V[ibin][itheta]<<"\t"<<sigma2[ibin][itheta]<<"\t"<<chi[ibin][itheta]<<"\t"<<deltaV[ibin][itheta]<<endl; } fstrV<<"\t\t\t\t\t"<<sigma2_[ibin]<<"\t"<<chi_[ibin]<<endl; deltaVmean[ibin]=Vmean[ibin]/j01/TMath::BesselJ1(j01)*TMath::Sqrt(deltaVmean[ibin]/ntheta/2./Nevent[ibin]); fstrV<<endl; } fstrV<<"ibin"<<"\t"<<"avgmult"<<"\t"<<"avgpt"<<"\t"<<"avgeta"<<"\t"<<"Vn mean"<<"\t"<<"Vn mean Error"<<endl; for(int ibin=0;ibin<nbin;ibin++){ fstrV<<ibin<<"\t"<<avgmult[ibin]<<"\t"<<avgpt[ibin]<<"\t"<<avgeta[ibin]<<"\t"<<Vmean[ibin]<<"\t"<<deltaVmean[ibin]<<endl; fstrV<<endl; } fstrV<<"ibin"<<"\t"<<"Nevent"<<"\t"<<"totmultall"<<"\t"<<"avgmultall"<<"\t"<<"avgtrk"<<endl; for(int ibin=0;ibin<nbin;ibin++){ fstrV<<ibin<<"\t"<<Nevent[ibin]<<"\t"<<totmultall[ibin]<<"\t"<<avgmultall[ibin]<<"\t"<<avgtrk[ibin]<<endl; fstrV<<endl; } if(SumorProd=="Sum") TString outname = "mergedV_Sum.root"; else TString outname="mergedV_Prod.root"; TFile *outf = new TFile(outname,"Recreate"); Nevent.Write("Nevent"); totmultall.Write("totmultall"); avgmultall.Write("avgmultall"); tottrk.Write("tottrk"); avgtrk.Write("avgtrk"); Qx1.Write("Qx1"); Qy1.Write("Qy1"); Q2.Write("Q2"); avgmult.Write("avgmult"); avgpt.Write("avgpt"); avgeta.Write("avgeta"); Vmean.Write("Vmean"); deltaVmean.Write("deltaVmean"); chi_.Write("chi"); sigma2_.Write("sigma2"); for(int ibin=0;ibin<nbin;ibin++){ TDirectory *dir0 = outf->mkdir(Form("D_%d",ibin));dir0->cd(); r[ibin].Write("r"); sigma2[ibin].Write("sigma2"); chi[ibin].Write("chi0"); deltaV[ibin].Write("deltaV"); r0[ibin].Write("r0"); r01[ibin].Write("r01"); V[ibin].Write("V"); for(int itheta=0;itheta<ntheta;itheta++){ TDirectory *dir1 = dir0->mkdir(Form("D_%d",itheta));dir1->cd(); GRe[ibin][itheta].Write(Form("GRe")); GIm[ibin][itheta].Write(Form("GIm")); Gmod2[ibin][itheta].Write(Form("G2")); } } outf->Close(); }
void CompareVz(){ gStyle->SetOptStat(kFALSE); gStyle->SetErrorX(0); TString coll="PbP"; bool Save=kTRUE; TF1 * fVz = new TF1("fVx","[0]+[1]*x+[2]*TMath::Power(x,2)+[3]*TMath::Power(x,3)+[4]*TMath::Power(x,4)", -15., 15.); if(coll=="PPb"){ fVz->SetParameters(1.47442e+00, -2.83100e-03, -1.19295e-02, 1.10312e-05, 2.64814e-05); //! new official MC >QM14 //fVz->SetParameters(1.60182e+00,1.08425e-03,-1.29156e-02,-7.24899e-06,2.80750e-05); //fVz->SetParameters(1.66731e+00,-2.43367e-03,-1.42488e-02,7.40147e-06,3.22477e-05); TH1F* histodata=(TH1F*)fDataPPb->Get("Vz"); TH1F* histo1=(TH1F*)fMCPPb->Get("Vz"); TH1F* histo2=(TH1F*)fMCPPb->Get("VzW"); TString data="Pb going positive side"; } else if(coll=="PbP"){ //fVz->SetParameters(1.54398e+00, -8.56155e-03, -1.40026e-02, 4.01020e-05, 3.47683e-05); //latest parameterization fVz->SetParameters(1.49736e+00, -6.93060e-03, -1.26864e-02, 2.98693e-05, 2.89538e-05); //! new official MC after QM14 TH1F* histodata=(TH1F*)fDataPbP->Get("Vz"); TH1F* histo1=(TH1F*)fMCPbP->Get("Vz"); TH1F* histo2=(TH1F*)fMCPbP->Get("VzW"); //TH1F* histo2=(TH1F*)fNMCPbP->Get("Vz"); TString data="Proton going positive side"; } else fVz->SetParameters(1.,0,0,0,0); histo1->SetName(Form("%sNewMC_unweighted",coll.Data())); histo2->SetName(Form("%sNewMC_weighted",coll.Data())); histodata->SetName(Form("%sData",coll.Data())); histo1->Rebin(5); histo2->Rebin(5); histodata->Rebin(5); //histo1=(TH1F*)histo1->Rebin(Nbin_vz,"histo1",binbound_vz); //histo2=(TH1F*)histo2->Rebin(Nbin_vz,"histo2",binbound_vz); histo1->Scale(1/histo1->Integral()); histo2->Scale(1/histo2->Integral()); histodata->Scale(1/histodata->Integral()); histo1->SetMarkerStyle(24); histo1->SetMarkerSize(1.2); histo1->SetMarkerColor(4); histo1->SetLineColor(4); histo2->SetMarkerStyle(0); histo2->SetMarkerColor(0); histo2->SetMarkerSize(0); histo2->SetFillStyle(3004); histo2->SetFillColor(2); histo2->SetLineColor(2); //histo2->SetMarkerColor(0); //histo2->SetMarkerColor(4); histodata->SetMarkerStyle(20); histodata->SetMarkerSize(1.2); histodata->SetMarkerColor(1); histodata->SetLineColor(1); TCanvas* c1 = new TCanvas("c1"," ",500,500); TCanvas* c2 = new TCanvas("c2"," ",500,500); makeMultiPanelCanvas(c1,1,1,-0.16,0,0.16,0.14,0.03); makeMultiPanelCanvas(c2,1,1,-0.16,0,0.16,0.14,0.03); TH1F* hFrame=new TH1F("","",400,-20,20); fixedFontHist(hFrame,1.1,1.7); hFrame->SetTitle(""); hFrame->GetXaxis()->SetTitleSize(0.05); hFrame->GetYaxis()->SetTitleSize(0.05); hFrame->GetXaxis()->SetTitle("Vz (cm)"); hFrame->GetYaxis()->SetTitle("Event Fraction"); hFrame->GetXaxis()->SetLimits(-15,15); //hFrame->GetXaxis()->SetLimits(-3,3); hFrame->GetYaxis()->SetRangeUser(0,5e-2); c1->cd(1); hFrame->DrawCopy(); histodata->Draw("same"); histo1->Draw("same"); histo2->Draw("HIST same"); TLegend *leg1=new TLegend(0.30,0.80,0.85,0.92); TLegend *leg2=new TLegend(0.30,0.85,0.85,0.95); leg1->SetBorderSize(0); leg2->SetBorderSize(0); leg1->SetFillColor(0); leg2->SetFillColor(0); leg1->SetTextSize(0.04); leg2->SetTextSize(0.04); leg1->AddEntry(histo1,"Before Vz weighting","lp"); leg1->AddEntry(histo2,"After Vz weighting","lpf"); //leg1->AddEntry(histo2,"New MC Before Vz weighting","lp"); leg1->AddEntry(histodata,data,"lp"); leg1->Draw("same"); TLatex *T1=new TLatex(0.25,0.92,""); T1->SetNDC(); T1->SetTextAlign(12); T1->SetTextSize(0.05); T1->SetTextColor(1); T1->SetTextFont(42); T1->Draw("same"); c2->cd(1); hFrame->GetYaxis()->SetTitle("Data/MC"); hFrame->GetXaxis()->SetLimits(-15,15); hFrame->GetYaxis()->SetRangeUser(0,2); hFrame->DrawCopy(); TH1F* ratio = (TH1F*)histodata->Clone(Form("%sratio",coll.Data())); //ratio->SetName("ratio"); ratio->Divide(histo1); /*ratio->Fit(fCen); cout<<fCen->GetNDF()<<endl; cout<<fCen->GetChisquare()<<endl; for(int icent=0;icent<=6;icent++) cout<<fCen->GetParameter(icent)<<","; cout<<endl;*/ ratio->DrawCopy("same"); fVz->SetLineColor(2); fVz->Draw("same"); leg2->AddEntry(ratio,data,"lp"); leg2->AddEntry(fVz,"reweighting function","lp"); leg2->Draw("same"); if(Save){ TFile *fout = new TFile("VzandcentCompare.root","Update"); fout->cd(); ratio->Write("",TObject::kOverwrite); histo1->Write("",TObject::kOverwrite); histo2->Write("",TObject::kOverwrite); histodata->Write("",TObject::kOverwrite); fout->Close(); c2->Print(Form("ratio_Vz_%s.png",coll.Data())); c1->Print(Form("VzCompare_Data%s.gif",coll.Data())); c1->Print(Form("VzCompare_Data%s.pdf",coll.Data())); } }
void Loop::myLoop() { // Correction factors: double cA[8] = {0.8567,0.8567,0.8700,0.8610,0.8567,0.8550,0.8630,0.8567}; double cOff[8] = {0.034,0.049,0.049,0.037,0.045,0.049,0.057,0.057}; // Dummy correction factors: // double cA[8] = {1,1,1,1,1,1,1,1}; // double cOff[8] = {0,0,0,0,0,0,0,0}; TFile *outfile = new TFile("output.root","recreate"); TTree *nt = new TTree("data","ADC readout data"); adcCorrectedData myData; myData.nch=8; nt->Branch("nch",&myData.nch,"nch/I"); nt->Branch("run",&myData.run,"run/I"); nt->Branch("evt",&myData.evt,"evt/I"); nt->Branch("evtSecond",&myData.evtSecond,"evtSecond/I"); nt->Branch("evtTime",&myData.evtTime,"evtTime/I"); nt->Branch("pedestal",myData.pedestal,"nch/I"); nt->SetMarkerStyle(20); for (int i=0;i<8;i++){ nt->Branch(Form("dSize%d",i),&myData.dataSize[i],Form("dSize%d/I",i)); nt->Branch(Form("data%d",i),myData.data[i],Form("data%d[dSize%d]/F",i,i)); nt->Branch(Form("time%d",i),myData.time[i],Form("time%d[dSize%d]/F",i,i)); } nt->Branch("min",myData.min,"min[8]/F"); nt->Branch("mintime",myData.mintime,"mintime[8]/F"); nt->Branch("mintime08",myData.mintime08,"mintime08[8]/F"); nt->Branch("mintime02",myData.mintime02,"mintime02[8]/F"); nt->Branch("mintime04",myData.mintime04,"mintime04[8]/F"); nt->Branch("mintime0802",myData.mintime0802,"mintime0802[8]/F"); nt->Branch("mintime0804",myData.mintime0804,"mintime0804[8]/F"); //nt->Branch("minSB",myData.minSB,"minSB[8]/F"); //nt->Branch("minSBtime",myData.minSBtime,"minSBtime[8]/F"); char ch; unsigned long dSize, dummy, trgTime; unsigned long nbr=0, evt=0; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { if (jentry % 1000 == 0 ) cout <<jentry<<" / "<<nentries<<" "<<setprecision(2)<<(double)jentry/nentries*100<<"% \r"; Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; Float_t min[8]; Float_t mintime[8]; Float_t minSB[8]; Float_t minSBtime[8]; for (int i=0;i<8;i++) { myData.min[i]=10e-10; // myData.minSB[i]=10e-10; myData.mintime[i]=-100; // myData.minSBtime[i]=-100; myData.dataSize[i]=0; } nbr=0; int flag=0; int minIt[8]; for (int i=0;i<8;i++) { myData.dataSize[i] = 0; myData.pedestal[i] = pedestal[i]; minIt[i]=-1; for (int j=0;j<data[i].size();j++) { double pulseHeight = data[i][j]-pedestal[i]; //(((double)data[i][j])/255.-0.5 - cOff[i])/cA[i]; double mytime = time[i][j]; myData.data[i][myData.dataSize[i]] = pulseHeight; myData.time[i][myData.dataSize[i]] = mytime; myData.dataSize[i]++; // fill signal region if (pulseHeight<myData.min[i]) { myData.min[i]=pulseHeight; myData.mintime[i]=mytime; minIt[i]=myData.dataSize[i]-1; } /* // fill sideband region if (pulseHeight<myData.minSB[i]) { if (i!=0) { if (fabs(mytime-myData.minSBtime[0])>400&&fabs(mytime-myData.minSBtime[0])<500){ myData.minSB[i]=pulseHeight; myData.minSBtime[i]=mytime; } } else { // channel 0 myData.minSB[i]=pulseHeight; myData.minSBtime[i]=mytime; } } */ } if (myData.min[i]<-1) {flag+=1;} // cout <<endl<<"minIt = "<<minIt[i]<<" "<<myData.dataSize[i]<<endl; int flag08=0; int flag04=0; int flag02=0; myData.mintime08[i]=-1; myData.mintime04[i]=-1; myData.mintime02[i]=-1; myData.mintime0802[i]=-1; myData.mintime0804[i]=-1; for (int j=minIt[i];j>=1;j--){ if (myData.data[i][j]<0.8*myData.min[i]&&myData.data[i][j-1]>0.8*myData.min[i]){ if ((myData.time[i][j]-myData.time[i][j-1])==2) { myData.mintime08[i]=myData.time[i][j-1]+2*(0.8*myData.min[i]-myData.data[i][j-1])/(myData.data[i][j]-myData.data[i][j-1]); flag08=1; } else { myData.mintime08[i]=myData.time[i][j]-2+2*(0.8*myData.min[i])/(myData.data[i][j]); } } if (myData.data[i][j]<0.2*myData.min[i]&&myData.data[i][j-1]>0.2*myData.min[i]){ if ((myData.time[i][j]-myData.time[i][j-1])==2) { myData.mintime02[i]=myData.time[i][j-1]+2*(0.2*myData.min[i]-myData.data[i][j-1])/(myData.data[i][j]-myData.data[i][j-1]); flag02=1; } else { myData.mintime02[i]=myData.time[i][j]-2+2*(0.2*myData.min[i])/(myData.data[i][j]); } } if (myData.data[i][j]<0.4*myData.min[i]&&myData.data[i][j-1]>0.4*myData.min[i]){ if ((myData.time[i][j]-myData.time[i][j-1])==2) { myData.mintime04[i]=myData.time[i][j-1]+2*(0.4*myData.min[i]-myData.data[i][j-1])/(myData.data[i][j]-myData.data[i][j-1]); flag04=1; } else { myData.mintime04[i]=myData.time[i][j]-2+2*(0.2*myData.min[i])/(myData.data[i][j]); } } } if (flag08==0&&minIt[i]!=-1) { // myData.mintime08[i]=myData.time[i][0]-2+2*(1-0.8)*myData.min[i]/(myData.data[i][0]); } if (flag02==0&&minIt[i]!=-1) { myData.mintime02[i]=myData.time[i][0]-2+2*(0.2)*myData.min[i]/(myData.data[i][0]); } if (flag08!=0&&flag04!=0) { myData.mintime0804[i]=myData.mintime04[i]-0.4*(myData.mintime08[i]-myData.mintime04[i])/0.4; } if (flag08!=0&&flag02!=0) { myData.mintime0802[i]=myData.mintime02[i]-0.2*(myData.mintime08[i]-myData.mintime02[i])/0.6; } } myData.evt = evt; myData.evtSecond = evtSecond; myData.evtTime = evtTime; if (flag>=1) nt->Fill(); } outfile->Write(); outfile->Close(); }
// examples macro void mutauAfterFit_novbf(bool scaled = true, bool log = true) { // defining the common canvas, axes pad styles SetStyle(); // open example histogram file TFile* exampleFile = new TFile("root/muTau_sm.root"); //load example histograms TH1F* data = (TH1F*)exampleFile->Get("muTau_SM0/data_obs"); if(data) {InitHist(data, "#bf{m_{vis} [GeV]}", "#bf{Events}"); InitData(data);} else{std::cout << "can't find hitogram " << "muTau_SM0/data_obs" << std::endl;} TH1F* Fakes = refill((TH1F*)exampleFile->Get("muTau_SM0/QCD")) ; InitHist(Fakes, "", "", kMagenta-10, 1001); TH1F* EWK1 = refill((TH1F*)exampleFile->Get("muTau_SM0/W" )) ; InitHist(EWK1 , "", "", kRed + 2, 1001); TH1F* EWK2 = refill((TH1F*)exampleFile->Get("muTau_SM0/ZJ" )) ; InitHist(EWK2 , "", "", kRed + 2, 1001); TH1F* EWK3 = refill((TH1F*)exampleFile->Get("muTau_SM0/ZL" )) ; InitHist(EWK3 , "", "", kRed + 2, 1001); TH1F* EWK = refill((TH1F*)exampleFile->Get("muTau_SM0/VV" )) ; InitHist(EWK , "", "", kRed + 2, 1001); TH1F* ttbar = refill((TH1F*)exampleFile->Get("muTau_SM0/TT" )) ; InitHist(ttbar, "", "", kBlue - 8, 1001); TH1F* Ztt = refill((TH1F*)exampleFile->Get("muTau_SM0/ZTT")) ; InitHist(Ztt , "", "", kOrange - 4, 1001); TH1F* ggH = refill((TH1F*)exampleFile->Get("muTau_SM0/SM120" )) ; InitSignal(ggH); ggH ->Scale(10*1); TH1F* qqH = refill((TH1F*)exampleFile->Get("muTau_SM0/VBF120")) ; InitSignal(qqH); qqH ->Scale(10*1); if(scaled){ rescale(Fakes, 2); rescale(EWK1 , 3); rescale(EWK2 , 4); rescale(EWK3 , 5); rescale(EWK , 7); rescale(ttbar, 6); rescale(Ztt , 1); rescale(ggH , 8); rescale(qqH , 9); } if(log){ qqH ->Add(ggH ); Fakes->Add(qqH ); EWK1 ->Add(Fakes); EWK2 ->Add(EWK1 ); EWK3 ->Add(EWK2 ); EWK ->Add(EWK3 ); ttbar->Add(EWK ); Ztt ->Add(ttbar); } else{ EWK1 ->Add(Fakes); EWK2 ->Add(EWK1 ); EWK3 ->Add(EWK2 ); EWK ->Add(EWK3 ); ttbar->Add(EWK ); Ztt ->Add(ttbar); ggH ->Add(Ztt ); qqH ->Add(ggH ); } // define canvas TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600); canv->cd(); if(log){ canv->SetLogy(1); data->SetMinimum(5.0); data->SetMaximum(10000000.); } else{ data->SetMaximum(14000.); } data->SetNdivisions(505); data->Draw("e"); if(log){ Ztt->Draw("same"); ttbar->Draw("same"); EWK->Draw("same"); Fakes->Draw("same"); qqH->Draw("same"); } else{ qqH->Draw("same"); Ztt->Draw("same"); ttbar->Draw("same"); EWK->Draw("same"); Fakes->Draw("same"); } data->Draw("esame"); canv->RedrawAxis(); CMSPrelim("#tau_{#mu}#tau_{h}", 0.45, 0.75); TLegend* leg = new TLegend(0.45, 0.45, 0.9, 0.75); SetLegendStyle(leg); leg->AddEntry(qqH , "(10x) H#rightarrow#tau#tau" , "L" ); leg->AddEntry(data , "Observed" , "LP"); leg->AddEntry(Ztt , "Z#rightarrow#tau#tau" , "F" ); leg->AddEntry(ttbar, "t#bar{t}" , "F" ); leg->AddEntry(EWK , "Electroweak" , "F" ); leg->AddEntry(Fakes, "QCD" , "F" ); leg->Draw(); TPaveText* mssm = new TPaveText(0.78, 0.70, 0.90, 0.74, "NDC"); mssm->SetBorderSize( 0 ); mssm->SetFillStyle( 0 ); mssm->SetTextAlign( 12 ); mssm->SetTextSize ( 0.04 ); mssm->SetTextColor( 1 ); mssm->SetTextFont ( 62 ); mssm->AddText("m_{H}=120"); mssm->Draw(); if(log){ if(scaled) canv->Print("mutau_rescaled_novbf_LOG.pdf"); else canv->Print("mutau_unscaled_novbf_LOG.pdf"); if(scaled) canv->Print("mutau_rescaled_novbf_LOG.png"); else canv->Print("mutau_unscaled_novbf_LOG.png"); } else{ if(scaled) canv->Print("mutau_rescaled_novbf.pdf"); else canv->Print("mutau_unscaled_novbf.pdf"); if(scaled) canv->Print("mutau_rescaled_novbf.png"); else canv->Print("mutau_unscaled_novbf.png"); } }
void calibraPlastico(char* filename, int channel=4) { FILE *outfile[2]; outfile[0] = fopen("Chi2_511","w"); outfile[1] = fopen("Chi2_1275","w"); Int_t number_of_loop=0; Int_t i, j, k, i_sm, rsen[2]; Float_t r, alpha, energia; Int_t b_altezza; // energies Float_t E_peak[NUMENERGIES]; Float_t E_compton[NUMENERGIES]; E_peak[0] = 511.; E_peak[1] = 1275.; for (i=0; i<NUMENERGIES; i++) { E_compton[i] = 2*E_peak[i]*E_peak[i]/(511+2*E_peak[i]); printf("E_compton[%d] = %f;\n",i,E_compton[i]); } TTimer *timer = new TTimer("gSystem->ProcessEvents();", 50, kFALSE); TCanvas *c0 = new TCanvas("c0"); c0->cd(); h_ideal = new TH1F("h_ideal","Compton ideale",NBINS,0,MAXHISTONRG); // check file existance f_smearings = new TFile("smearings.root","UPDATE"); // check smearing samples existance for(i=0; i<NUMENERGIES; i++) { sprintf(smoothName,"smooth_%.1f_%d;1",E_peak[i],NSMEARINGS-2); if (!f_smearings->Get(smoothName)) { cout << smoothName << " " << f_smearings->FindObject(smoothName) << endl; // smearing for that energy do not exist printf("Non esistono.\n"); // ideal compton histogram for (j=0; j<NBINS; j++) { if (j>h_ideal->FindBin(50) && j<h_ideal->FindBin(E_compton[i])) { r = h_ideal->GetBinCenter(j)/E_peak[i]; alpha = E_peak[i]/511.0; energia = KN_NORM * (2+r*r/(alpha*alpha*(1-r)*(1-r))+r/(1-r) * (r-2/alpha)); h_ideal->SetBinContent(j,energia); } else { h_ideal->SetBinContent(j,0); } } h_ideal->Draw(); c0->Update(); timer->TurnOn(); timer->Reset(); timer->TurnOff(); // creazione spettri smussati for (i_sm=1; i_sm<NSMEARINGS; i_sm++) { sprintf(smoothName,"smooth_%.1f_%d",E_peak[i],i_sm); printf("Creo '%s': ",smoothName); h_smooth = new TH1F(smoothName,"Smooth",NBINS,0,MAXHISTONRG); // istogramma in energia for (j=1; j<h_ideal->FindBin(E_compton[i]); j++) { b_altezza = h_ideal->GetBinContent(j); for (k=1; k<b_altezza; k++){ h_smooth->Fill(gRandom->Gaus(h_ideal->GetBinCenter(j),i_sm)); } printf("."); } printf("\n"); h_smooth->Write(); } } } // ok, we've got the smearings! f_smearings->Close(); f_smearings = new TFile("smearings.root","READ"); // ---------------------------------- // retrieving "raw" histogram // ---------------------------------- TFile *infile = new TFile(filename); TTree *tree= (TTree*)infile->Get("acq_tree_0"); TBranch *branch = tree->GetBranch(Form("acq_ch%d",channel)); branch->SetAddress(&inc_data.timetag); TH1F *h_raw = new TH1F("h_raw","Acquisizione",NBINS,0,MAXHISTOCHN); UInt_t toentry=branch->GetEntries(); printf("getHistoFromFile: There are %d entries in the branch\n",toentry); for(i=0; i<toentry; i++) { branch->GetEntry(i); h_raw->Fill(inc_data.qlong); } h_raw->Draw(); TSpectrum *s = new TSpectrum(10); Int_t e, nPeaks, bTemp, bFirstPeak = 9999; Float_t *xPeaks; // trovo il primo picco nPeaks = s->Search(h_raw->Rebin(2, "h_raw_rebinned")); if (nPeaks>0) { xPeaks = s->GetPositionX(); // loop sui picchi per trovare il primo for (i=0;i<nPeaks;i++) { bTemp = h_raw->GetXaxis()->FindBin(xPeaks[i]); if (bTemp<bFirstPeak) { bFirstPeak = bTemp; } } } else { bFirstPeak = 0; } // sottraggo il fondo Compton Float_t *bgBins = new Float_t[NBINS]; TH1F *h_filtered = new TH1F("h_filtered","Picchi",NBINS,0,MAXHISTOCHN); /*for (i = 0; i < bFirstPeak; i++) { bgBins[i]=h_raw->GetBinContent(i+1); } s->Background(bgBins,bFirstPeak,20,TSpectrum::kBackDecreasingWindow,TSpectrum::kBackOrder2,kFALSE,TSpectrum::kBackSmoothing15,kFALSE); for (i = 0; i < bFirstPeak; i++) { h_filtered->SetBinContent(i+1, (h_raw->GetBinContent(i+1)-bgBins[i])); } for (i = 0; i < NBINS-bFirstPeak; i++) { bgBins[i]=h_raw->GetBinContent(bFirstPeak+i+1); } s->Background(bgBins,NBINS-bFirstPeak,20,TSpectrum::kBackDecreasingWindow,TSpectrum::kBackOrder2,kFALSE,TSpectrum::kBackSmoothing15,kFALSE); for (i = bFirstPeak; i < NBINS; i++) { h_filtered->SetBinContent(i+1, (h_raw->GetBinContent(i+1)-bgBins[i-bFirstPeak])); } //TCanvas * background = new TCanvas("background","Estimation of bg",10,10,1000,700);*/ for (i = 0; i < NBINS; i++) { bgBins[i]=h_raw->GetBinContent(i+1); } s->Background(bgBins, NBINS, 20, TSpectrum::kBackDecreasingWindow, TSpectrum::kBackOrder2, kFALSE, TSpectrum::kBackSmoothing15, kFALSE); for (i = 0; i < NBINS; i++) { h_filtered->SetBinContent(i+1, (h_raw->GetBinContent(i+1)-bgBins[i])); } h_raw->Draw("L"); h_filtered->SetLineColor(kRed); h_filtered->Draw("SAME L"); c0->Update(); // trovo i picchi e calibro nPeaks = s->Search(h_filtered->Rebin(2, "h_filtered_rebinned"),2,"",0.05); xPeaks = s->GetPositionX(); // sigma_fall[0] = 100; timer->TurnOn(); timer->Reset(); timer->TurnOff(); if (nPeaks<NUMENERGIES) { // trovati troppi pochi picchi printf("EPIC FAIL while calibrating - too few peaks!\n"); } else { // possiamo calibrare TGraphErrors *graphErr; TF1 *fitMeasPeaks, *fitfun; Float_t nrg[NUMENERGIES], shift[NUMENERGIES], sigma_fall[NUMENERGIES], a, b, bPeak, cPeak, nrgPeak, chi2, fondo, xmin, xmax, chi2min; // fitto i due picchi, mi servono le sigma... for (e=0; e<NUMENERGIES; e++) { xmin = xPeaks[e] - (0.5*xPeaks[e]); // fit left margin xmax = xPeaks[e] + (0.5*xPeaks[e]); // fit right margin fitMeasPeaks = new TF1("fitMeasPeaks","gaus",xmin,xmax); fitMeasPeaks->SetNpx(1000); fitMeasPeaks->SetParameters(1,xPeaks[e]); h_filtered->Fit("fitMeasPeaks","QNO","",xmin,xmax); sigma_fall[e] = fitMeasPeaks->GetParameter(2); printf("%f - %f - %f Sigma_fall[%d]: %f\n",xmin,xPeaks[e],xmax,e,sigma_fall[e]); // inizializzazione shift[e]=0; nrg[e]=E_compton[e]; } fitfun = new TF1("calfitfun","pol1",xPeaks[0],xPeaks[NUMENERGIES-1]); // costruiamo uno spettro sperimentale calibrato h_calib = (TH1F*)h_raw->Clone(); h_calib->SetNameTitle("h_calib","Acquisiz. calibrata"); Int_t debug = 0; Int_t loop_flag = 1; // do..while shift begin while(loop_flag) { number_of_loop++; loop_flag = 0; for (e=0; e<NUMENERGIES; e++) { // energie aggiornate nrg[e] = nrg[e]-shift[e]; printf("xPeaks[%d] = %f\tshift[%d] = %f\tnrg[%d] = %f\n",e,xPeaks[e],e,shift[e],e,nrg[e]); } // calibrazione fitfun->SetParLimits(0,-100,100); fitfun->SetParLimits(1,0.,1.); graphErr = new TGraphErrors(NUMENERGIES,xPeaks,nrg); graphErr->Fit(fitfun,"RN"); a = fitfun->GetParameter(1); b = fitfun->GetParameter(0);// graphErr->Delete(); printf("intercetta=%f pendenza=%f\n",b,a); h_calib->GetXaxis()->SetLimits(b,h_raw->GetBinCenter(NBINS)*a+b); h_calib->Draw(); c0->Update(); timer->TurnOn(); timer->Reset(); timer->TurnOff(); for (e=0; e<NUMENERGIES; e++) { chi2min = 9999999; printf("Looppo sull'energia %.1f\n",nrg[e]); // loop on smearings for (i_sm=19; i_sm<NSMEARINGS; i_sm++) { sprintf(smoothName,"smooth_%.1f_%d",E_peak[e],i_sm); h_smooth = (TH1F*)f_smearings->Get(smoothName); if (debug) printf("Recupero l'histo %s\n",smoothName); //h_smooth->Draw(); // momentaneamente assumiamo che il CE sia: bPeak = h_smooth->GetMaximumBin(); if (debug) printf("bPeak = %f\n",bPeak); nrgPeak = bPeak*MAXHISTONRG/NBINS; if (debug) printf("nrgPeak = %f\n",nrgPeak); t_shift = nrg[e]-nrgPeak; if (debug) printf("t_shift = %f\n",t_shift); cPeak = h_calib->FindBin(a*xPeaks[e]+b); if (debug) printf("peak calib: %.1f\n",cPeak); max_calib = h_calib->GetBinContent(cPeak); if (debug) printf("max_calib = %f\n",max_calib); max_smooth = h_smooth->GetBinContent(bPeak); if (debug) printf("max_smooth = %f\n",max_smooth); if (debug) printf("sigma_fall[%d] = %f\n",e,sigma_fall[e]); if (debug) printf("a*sigma_fall[%d] = %f\n",e,a*sigma_fall[e]); // definisco la funzione per il fit TF1 *f_smear_profile = new TF1("f_smear_profile",f_profile,nrgPeak-a*sigma_fall[e],nrgPeak+a*sigma_fall[e]*3,1); f_smear_profile->SetParameters(0,300); h_calib->Fit("f_smear_profile","QON","",a*xPeaks[e]+b-a*sigma_fall[e],a*xPeaks[e]+b+a*sigma_fall[e]*3); chi2 = f_smear_profile->GetChisquare(); if (debug) printf("i_sm: %i\tchiquadro: %f\n",i_sm,chi2); fondo = f_smear_profile->GetParameter(0); if (debug) printf("fondo = %f\n",fondo); if (debug) printf("i_sm: %d\tchi2min vs. chi2: %f %f\n",i_sm,chi2min,chi2); if (number_of_loop==1) {fprintf(outfile[e],"%i\t%f\t%f\n",i_sm,chi2, fondo);} if (chi2<chi2min) { chi2min = chi2; shift[e] = t_shift; rsen[e]=i_sm;} } // loop on smearings ends here if (debug) printf("shift[%d]: %f\n",e,t_shift); if (shift[e]>THRSHIFT) { loop_flag++; } if (number_of_loop==1) {fclose(outfile[e]);} } // end loop on energies } // while shift ends here printf("Esco con shift[0]=%.1f e shift[1]=%.1f\n",shift[0],shift[1]); cout << "Esco con risoluzione[0] = " << rsen[0] << " keV (" << rsen[0]*100/E_compton[0] << "%)"; cout << " e risoluzione[1] = " << rsen[1] << " keV (" << rsen[1]*100/E_compton[1] << "%)" << endl; printf("\nRESULTS: nrg1 = %f\tnrg2 = %f\n",nrg[0],nrg[1]); printf("RESULTS: m = %f\t q = %f\n",a,b); } // end if enough peaks infile->Close(); //f_smearings->Close(); }
void drawPlanaconCellPlots() { TFile* inFile = TFile::Open("plots/plots_studyPlanaconCells_test.root","READ"); TCanvas* c1; TLatex* latex; gStyle -> SetPadRightMargin(0.15); c1 = new TCanvas("c_beamPosition_TDC","c_beamPosition_TDC"); TH2F* h2_beamPosition_TDC = (TH2F*)( inFile->Get("h2_beamPosition_TDC") ); h2_beamPosition_TDC -> Draw("COLZ"); h2_beamPosition_TDC -> SetTitle(";beam x_{TDC} (mm);beam y_{TDC} (mm)"); h2_beamPosition_TDC -> GetZaxis() -> SetRangeUser(0.,100.); latex = new TLatex(0.13,0.96,Form("eff: %.1f%%",100.*h2_beamPosition_TDC->Integral()/h2_beamPosition_TDC->GetEntries())); latex -> SetNDC(); latex -> SetTextFont(42); latex -> SetTextSize(0.04); latex -> Draw("same"); c1 -> Print("c_beamPosition_TDC.png","png"); c1 = new TCanvas("c_beamPosition_hodo12","c_beamPosition_hodo12"); TH2F* h2_beamPosition_hodo12 = (TH2F*)( inFile->Get("h2_beamPosition_hodo12") ); h2_beamPosition_hodo12 -> Draw("COLZ"); h2_beamPosition_hodo12 -> SetTitle(";beam x_{hodo1} (mm);beam y_{hodo2} (mm)"); h2_beamPosition_hodo12 -> GetZaxis() -> SetRangeUser(0.,30.); latex = new TLatex(0.13,0.96,Form("eff: %.1f%%",100.*h2_beamPosition_hodo12->Integral()/h2_beamPosition_TDC->GetEntries())); latex -> SetNDC(); latex -> SetTextFont(42); latex -> SetTextSize(0.04); latex -> Draw("same"); c1 -> Print("c_beamPosition_hodo12.png","png"); c1 = new TCanvas("c_cellPosition_TDC","c_cellPosition_TDC"); TProfile2D* p2_cellPosition_TDC = (TProfile2D*)( inFile->Get("p2_cellPosition_TDC") ); p2_cellPosition_TDC -> Draw("COLZ"); p2_cellPosition_TDC -> SetTitle(";beam x_{TDC} (mm);beam y_{TDC} (mm)"); p2_cellPosition_TDC -> GetZaxis() -> SetRangeUser(0.,30.); p2_cellPosition_TDC -> GetYaxis() -> SetRangeUser(-145.,-55.); c1 -> Print("c_cellPosition_TDC.png","png"); c1 = new TCanvas("c_cellPosition_hodo12","c_cellPosition_hodo12"); TProfile2D* p2_cellPosition_hodo12 = (TProfile2D*)( inFile->Get("p2_cellPosition_hodo12") ); p2_cellPosition_hodo12 -> Draw("COLZ"); p2_cellPosition_hodo12 -> SetTitle(";beam x_{hodo1} (mm);beam y_{hodo2} (mm)"); p2_cellPosition_hodo12 -> GetZaxis() -> SetRangeUser(0.,30.); c1 -> Print("c_cellPosition_hodo12.png","png"); c1 = new TCanvas("c_cellProfileX_hodo12","c_cellProfileX_hodo12"); TProfile* p_cell16ProfileX_hodo12 = (TProfile*)( inFile->Get("p_cell16ProfileX_hodo12") ); p_cell16ProfileX_hodo12 -> SetMarkerColor(kBlack); p_cell16ProfileX_hodo12 -> SetLineColor(kBlack); p_cell16ProfileX_hodo12 -> GetYaxis() -> SetRangeUser(0.,400.); p_cell16ProfileX_hodo12 -> Draw(); p_cell16ProfileX_hodo12 -> Draw("hist,same"); p_cell16ProfileX_hodo12 -> SetTitle(";beam x_{hodo1} (mm);"); TProfile* p_cell17ProfileX_hodo12 = (TProfile*)( inFile->Get("p_cell17ProfileX_hodo12") ); p_cell17ProfileX_hodo12 -> SetMarkerColor(kRed+3); p_cell17ProfileX_hodo12 -> SetLineColor(kRed+3); p_cell17ProfileX_hodo12 -> Draw("same"); p_cell17ProfileX_hodo12 -> Draw("hist,same"); TProfile* p_cell18ProfileX_hodo12 = (TProfile*)( inFile->Get("p_cell18ProfileX_hodo12") ); p_cell18ProfileX_hodo12 -> SetMarkerColor(kRed+2); p_cell18ProfileX_hodo12 -> SetLineColor(kRed+2); p_cell18ProfileX_hodo12 -> Draw("same"); p_cell18ProfileX_hodo12 -> Draw("hist,same"); TProfile* p_cell19ProfileX_hodo12 = (TProfile*)( inFile->Get("p_cell19ProfileX_hodo12") ); p_cell19ProfileX_hodo12 -> SetMarkerColor(kRed+1); p_cell19ProfileX_hodo12 -> SetLineColor(kRed+1); p_cell19ProfileX_hodo12 -> Draw("same"); p_cell19ProfileX_hodo12 -> Draw("hist,same"); TProfile* p_cell20ProfileX_hodo12 = (TProfile*)( inFile->Get("p_cell20ProfileX_hodo12") ); p_cell20ProfileX_hodo12 -> SetMarkerColor(kRed); p_cell20ProfileX_hodo12 -> SetLineColor(kRed); p_cell20ProfileX_hodo12 -> Draw("same"); p_cell20ProfileX_hodo12 -> Draw("hist,same"); TProfile* p_cell21ProfileX_hodo12 = (TProfile*)( inFile->Get("p_cell21ProfileX_hodo12") ); p_cell21ProfileX_hodo12 -> SetMarkerColor(kRed-7); p_cell21ProfileX_hodo12 -> SetLineColor(kRed-7); p_cell21ProfileX_hodo12 -> Draw("same"); p_cell21ProfileX_hodo12 -> Draw("hist,same"); c1 -> Print("c_cellProfileX_hodo12.png","png"); c1 = new TCanvas("c_cellProfileY_hodo12","c_cellProfileY_hodo12"); TProfile* p_cell03ProfileY_hodo12 = (TProfile*)( inFile->Get("p_cell03ProfileY_hodo12") ); p_cell03ProfileY_hodo12 -> SetMarkerColor(kBlack); p_cell03ProfileY_hodo12 -> SetLineColor(kBlack); p_cell03ProfileY_hodo12 -> GetYaxis() -> SetRangeUser(0.,400.); p_cell03ProfileY_hodo12 -> Draw(); p_cell03ProfileY_hodo12 -> Draw("hist,same"); p_cell03ProfileY_hodo12 -> SetTitle(";beam y_{hodo2} (mm);"); TProfile* p_cell08ProfileY_hodo12 = (TProfile*)( inFile->Get("p_cell08ProfileY_hodo12") ); p_cell08ProfileY_hodo12 -> SetMarkerColor(kRed+3); p_cell08ProfileY_hodo12 -> SetLineColor(kRed+3); p_cell08ProfileY_hodo12 -> Draw("same"); p_cell08ProfileY_hodo12 -> Draw("hist,same"); TProfile* p_cell13ProfileY_hodo12 = (TProfile*)( inFile->Get("p_cell13ProfileY_hodo12") ); p_cell13ProfileY_hodo12 -> SetMarkerColor(kRed+2); p_cell13ProfileY_hodo12 -> SetLineColor(kRed+2); p_cell13ProfileY_hodo12 -> Draw("same"); p_cell13ProfileY_hodo12 -> Draw("hist,same"); TProfile* p_cell19ProfileY_hodo12 = (TProfile*)( inFile->Get("p_cell19ProfileY_hodo12") ); p_cell19ProfileY_hodo12 -> SetMarkerColor(kRed+1); p_cell19ProfileY_hodo12 -> SetLineColor(kRed+1); p_cell19ProfileY_hodo12 -> Draw("same"); p_cell19ProfileY_hodo12 -> Draw("hist,same"); TProfile* p_cell24ProfileY_hodo12 = (TProfile*)( inFile->Get("p_cell24ProfileY_hodo12") ); p_cell24ProfileY_hodo12 -> SetMarkerColor(kRed); p_cell24ProfileY_hodo12 -> SetLineColor(kRed); p_cell24ProfileY_hodo12 -> Draw("same"); p_cell24ProfileY_hodo12 -> Draw("hist,same"); TProfile* p_cell29ProfileY_hodo12 = (TProfile*)( inFile->Get("p_cell29ProfileY_hodo12") ); p_cell29ProfileY_hodo12 -> SetMarkerColor(kRed-7); p_cell29ProfileY_hodo12 -> SetLineColor(kRed-7); p_cell29ProfileY_hodo12 -> Draw("same"); p_cell29ProfileY_hodo12 -> Draw("hist,same"); c1 -> Print("c_cellProfileY_hodo12.png","png"); double x[32]; for(int iCh = 0; iCh < 32; ++iCh) { std::cout << ">>> Fitting x for channel " << iCh << std::endl; //c1 = new TCanvas(Form("c_cell%02dProfileX_hodo12",iCh),Form("c_cell%02dProfileX_hodo12",iCh)); TProfile* p_cellProfileX_hodo12 = (TProfile*)( inFile->Get(Form("p_cell%02dProfileX_hodo12",iCh)) ); p_cellProfileX_hodo12 -> GetYaxis() -> SetRangeUser(0.,400.); //p_cellProfileX_hodo12 -> Draw(); //p_cellProfileX_hodo12 -> Draw("hist,same"); p_cellProfileX_hodo12 -> SetTitle(";beam x_{hodo1} (mm);"); TF1* fitFunc = new TF1("fitFunc",gausBkg,-205.,-140.,6); fitFunc -> SetNpx(10000); fitFunc -> SetParameters(25.,-0.01,-170.,100.,-195+6.*GetChannelX(iCh),5.); fitHisto = (TH1F*)(p_cellProfileX_hodo12); fitHisto -> Fit("fitFunc","QNRS+"); //fitFunc -> Draw("same"); x[iCh] = fitFunc->GetParameter(4); } double y[32]; for(int iCh = 0; iCh < 32; ++iCh) { std::cout << ">>> Fitting y for channel " << iCh << std::endl; //c1 = new TCanvas(Form("c_cell%02dProfileY_hodo12",iCh),Form("c_cell%02dProfileY_hodo12",iCh)); TProfile* p_cellProfileY_hodo12 = (TProfile*)( inFile->Get(Form("p_cell%02dProfileY_hodo12",iCh)) ); p_cellProfileY_hodo12 -> GetYaxis() -> SetRangeUser(0.,400.); //p_cellProfileY_hodo12 -> Draw(); //p_cellProfileY_hodo12 -> Draw("hist,same"); p_cellProfileY_hodo12 -> SetTitle(";beam y_{hodo2} (mm);"); TF1* fitFunc = new TF1("fitFunc",gausBkg,-150.,-80.,6); fitFunc -> SetNpx(10000); fitFunc -> SetParameters(25.,-0.01,-120.,100.,-138+6.*GetChannelY(iCh),5.); fitHisto = (TH1F*)(p_cellProfileY_hodo12); fitHisto -> Fit("fitFunc","QNRS+"); //fitFunc -> Draw("same"); y[iCh] = fitFunc->GetParameter(4); } c1 = new TCanvas("c_cellXY_hodo12","c_cellXY_hodo12",1800,600); c1 -> Divide(3,1); TGraph* g_xy = new TGraph(); TGraph* g_x = new TGraph(); TGraph* g_y = new TGraph(); for(int iCh = 0; iCh < 32; ++iCh) { g_xy -> SetPoint(iCh,x[iCh],y[iCh]); g_x -> SetPoint(iCh,GetChannelX(iCh),x[iCh]); g_y -> SetPoint(iCh,GetChannelY(iCh),y[iCh]); } c1 -> cd(1); g_x -> Draw("AP"); g_x -> SetTitle(";iX;beam x_{hodo1}"); TF1* linFitX = new TF1("linFitX","[0]+[1]*x",-1.,8.); g_x -> Fit("linFitX","QNS+","",-1.,5.5); linFitX -> SetLineColor(kRed); linFitX -> SetLineWidth(2); linFitX -> Draw("same"); latex = new TLatex(0.20,0.80,Form("x_{0} = %.2f",linFitX->GetParameter(0))); latex -> SetNDC(); latex -> SetTextFont(42); latex -> SetTextSize(0.04); latex -> Draw("same"); latex = new TLatex(0.20,0.70,Form("#Deltax = %.2f",linFitX->GetParameter(1))); latex -> SetNDC(); latex -> SetTextFont(42); latex -> SetTextSize(0.04); latex -> Draw("same"); c1 -> cd(2); g_y -> Draw("AP"); g_y -> SetTitle(";iY;beam y_{hodo2}"); TF1* linFitY = new TF1("linFitY","[0]+[1]*x",-1.,8.); g_y -> Fit("linFitY","QNRS+"); linFitY -> SetLineColor(kRed); linFitY -> SetLineWidth(2); linFitY -> Draw("same"); latex = new TLatex(0.20,0.80,Form("y_{0} = %.2f",linFitY->GetParameter(0))); latex -> SetNDC(); latex -> SetTextFont(42); latex -> SetTextSize(0.04); latex -> Draw("same"); latex = new TLatex(0.20,0.70,Form("#Deltay = %.2f",linFitY->GetParameter(1))); latex -> SetNDC(); latex -> SetTextFont(42); latex -> SetTextSize(0.04); latex -> Draw("same"); c1 -> cd(3); g_xy -> SetTitle(";beam x_{hodo1};beam y_{hodo2}"); g_xy -> Draw("AP"); for(int iCh = 0; iCh < 32; ++iCh) { double x0 = linFitX->GetParameter(0) + GetChannelX(iCh)*linFitX->GetParameter(1); double y0 = linFitY->GetParameter(0) + GetChannelY(iCh)*linFitY->GetParameter(1); double x1 = x0 - 0.5*linFitX->GetParameter(1); double x2 = x0 + 0.5*linFitX->GetParameter(1); double y1 = y0 - 0.5*linFitY->GetParameter(1); double y2 = y0 + 0.5*linFitY->GetParameter(1); TBox* box = new TBox(x1,y1,x2,y2); box -> SetLineColor(kRed); box -> SetLineWidth(2); box -> SetFillStyle(0); box -> Draw("same"); } c1 -> Print("c_cellXY_hodo12.png","png"); }
int process(TString nameChain, TString file, int iFile, int nEntries, TString dirOut, TString dirIn, ofstream& outlog, int iJson, TString RunPhase, bool debug) { // OUTPUT FILE // ostringstream ossi(""); ossi << iFile ; TString name = dirIn; name +="elepairs_"; name +=ossi.str(); name +=".root"; //TString name=(TString)(dirIn+"elepairs_"+ossi.str()+".root"); TFile *outfile = new TFile(name,"RECREATE"); ossi.str(""); // INPUT TREE // TChain * myChain = new TChain(nameChain); myChain->Add(file); cout<<"test1"<<endl; int nEvent, nRun, nLumi ; // Vertices // int _vtx_N; double _vtx_x[200], _vtx_y[200], _vtx_z[200]; double _vtx_normalizedChi2[200], _vtx_ndof[200], _vtx_nTracks[200], _vtx_d0[200]; // Trigger Paths // int trig_hltInfo[250]; int _trig_isEleHLTpath; int trig_HLT_path[4]; // unbias, EG5, EG8, EG12 char trig_fired_names[5000]; // vector<string> m_HLT_pathsV; vector<string> m_HLT_triggered; vector<int> m_HLT_pathsV_check; // m_HLT_pathsV.clear(); // m_HLT_pathsV_check.clear(); // for(int iP=0 ; iP<(int)HLT_paths_.size() ; iP++) { // m_HLT_pathsV.push_back( HLT_paths_[iP]); // m_HLT_pathsV_check.push_back(0); // } // Electrons TClonesArray * electrons = new TClonesArray ("TLorentzVector"); int ele_N, sc_hybrid_N; int ele_outOfTimeSeed[10],ele_severityLevelSeed[10]; double ele_he[10], ele_sigmaietaieta[10]; double ele_hcalDepth1TowerSumEt_dr03[10], ele_hcalDepth2TowerSumEt_dr03[10]; double ele_ecalRecHitSumEt_dr03[10], ele_tkSumPt_dr03[10]; double ele_sclEta[10], ele_sclEt[10]; //double ecalIsoRel03,hcalIsoRel03,trackIsoRel03; double ele_deltaphiin[10], ele_deltaetain[10]; double ele_conv_dist[10], ele_conv_dcot[10]; double ele_fbrem[10]; int ele_expected_inner_hits[10]; //int ele_ambiguousGsfTracks[10]; int ele_isConversion[10]; int ele_echarge[10]; // int ele_RCTeta[10], ele_RCTphi[10], ele_RCTL1iso[10], ele_RCTL1noniso[10], ele_RCTL1iso_M[10], ele_RCTL1noniso_M[10]; int ele_TTetaVect[10][50], ele_TTphiVect[10][50]; double ele_TTetVect[10][50]; int ele_RCTetaVect[10][10], ele_RCTphiVect[10][10], ele_RCTL1isoVect[10][10], ele_RCTL1nonisoVect[10][10],ele_RCTL1isoVect_M[10][10], ele_RCTL1nonisoVect_M[10][10]; double ele_RCTetVect[10][10]; // TP info const int nTow = 4032; int trig_tower_N,trig_tower_ieta[nTow],trig_tower_iphi[nTow],trig_tower_adc[nTow],trig_tower_sFGVB[nTow]; int trig_tower_N_M,trig_tower_ieta_M[nTow],trig_tower_iphi_M[nTow],trig_tower_adc_M[nTow],trig_tower_sFGVB_M[nTow]; int trig_tower_N_E,trig_tower_ieta_E[nTow],trig_tower_iphi_E[nTow],trig_tower_adc_E[nTow][5],trig_tower_sFGVB_E[nTow][5]; // HCAL TP int trig_tower_hcal_N, trig_tower_hcal_ieta[4032], trig_tower_hcal_iphi[4032], trig_tower_hcal_FG[4032],trig_tower_hcal_et[4032]; int trig_L1emIso_N, trig_L1emNonIso_N, trig_L1emIso_N_M, trig_L1emNonIso_N_M; // L1 candidates info int trig_L1emIso_ieta[4], trig_L1emIso_iphi[4], trig_L1emIso_rank[4]; int trig_L1emNonIso_ieta[4], trig_L1emNonIso_iphi[4], trig_L1emNonIso_rank[4]; int trig_L1emIso_ieta_M[4], trig_L1emIso_iphi_M[4], trig_L1emIso_rank_M[4]; int trig_L1emNonIso_ieta_M[4], trig_L1emNonIso_iphi_M[4], trig_L1emNonIso_rank_M[4]; // L1 prefiring int trig_preL1emIso_N; int trig_preL1emNonIso_N; int trig_preL1emIso_ieta[4], trig_preL1emIso_iphi[4], trig_preL1emIso_rank[4]; int trig_preL1emNonIso_ieta[4], trig_preL1emNonIso_iphi[4],trig_preL1emNonIso_rank[4]; // L1 postfiring int trig_postL1emIso_N; int trig_postL1emNonIso_N; int trig_postL1emIso_ieta[4], trig_postL1emIso_iphi[4], trig_postL1emIso_rank[4]; int trig_postL1emNonIso_ieta[4], trig_postL1emNonIso_iphi[4],trig_postL1emNonIso_rank[4]; // Masking int trig_nMaskedRCT, trig_nMaskedCh; int trig_iMaskedRCTeta[100], trig_iMaskedRCTphi[100], trig_iMaskedRCTcrate[100], trig_iMaskedTTeta[100], trig_iMaskedTTphi[100]; int trig_strip_mask_N; int trig_strip_mask_TTieta[1000], trig_strip_mask_TTiphi[1000], trig_strip_mask_status[1000], trig_strip_mask_StripID[1000], trig_strip_mask_PseudoStripID[1000], trig_strip_mask_TccID[1000], trig_strip_mask_CCU[1000], trig_strip_mask_xtal_ix[1000][5], trig_strip_mask_xtal_iy[1000][5], trig_strip_mask_xtal_iz[1000][5]; int trig_xtal_mask_N; // [EB+EE] int trig_xtal_mask_ieta[1000],trig_xtal_mask_iphi[1000], // for EE : xtal ieta->ix ; iphi -> iy trig_xtal_mask_TTieta[1000],trig_xtal_mask_TTiphi[1000], // but for EE towers, still ieta, iphi... trig_xtal_mask_Rieta[1000],trig_xtal_mask_Riphi[1000], trig_xtal_mask_status[1000], trig_xtal_mask_EBEE[1000]; // EBEE = {0,1} => 0=EB ; 1=EE //double trig_xtal_mask_eT[1000]; cout<<"test2"<<endl; // INITIALIZATION // // // Global nEvent = 0; nRun = 0; nLumi = 0; // // Vertices _vtx_N = 0; for(int iv=0;iv<200;iv++) { _vtx_normalizedChi2[iv] = 0.; _vtx_ndof[iv] = 0.; _vtx_nTracks[iv] = 0.; _vtx_d0[iv] = 0.; _vtx_x[iv] = 0.; _vtx_y[iv] = 0.; _vtx_z[iv] = 0.; } // // L1 candidates trig_L1emIso_N = 0; trig_L1emNonIso_N = 0; trig_preL1emIso_N = 0; trig_preL1emNonIso_N = 0; trig_postL1emIso_N = 0; trig_postL1emNonIso_N = 0; // for(int il1=0 ; il1<4 ; il1++) { trig_L1emIso_ieta[il1] = 0; trig_L1emIso_iphi[il1] = 0; trig_L1emIso_rank[il1] = 0; trig_L1emNonIso_ieta[il1] = 0; trig_L1emNonIso_iphi[il1] = 0; trig_L1emNonIso_rank[il1] = 0; trig_preL1emIso_ieta[il1] = 0; trig_preL1emIso_iphi[il1] = 0; trig_preL1emIso_rank[il1] = 0; trig_preL1emNonIso_ieta[il1] = 0; trig_preL1emNonIso_iphi[il1] = 0; trig_preL1emNonIso_rank[il1] = 0; trig_postL1emIso_ieta[il1] = 0; trig_postL1emIso_iphi[il1] = 0; trig_postL1emIso_rank[il1] = 0; trig_postL1emNonIso_ieta[il1] = 0; trig_postL1emNonIso_iphi[il1] = 0; trig_postL1emNonIso_rank[il1] = 0; } // // Trigger towers trig_tower_N = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta[iTow] = trig_tower_iphi[iTow] = -999; trig_tower_adc[iTow] = trig_tower_sFGVB[iTow] = -999; } trig_tower_N_M = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta_M[iTow] = trig_tower_iphi_M[iTow] = -999; trig_tower_adc_M[iTow] = trig_tower_sFGVB_M[iTow] = -999; } trig_tower_N_E = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta_E[iTow] = trig_tower_iphi_E[iTow] = -999; for(int i=0 ; i<5 ; i++) trig_tower_adc_E[iTow][i] = trig_tower_sFGVB_E[iTow][i] = -999; } trig_tower_hcal_N = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_hcal_ieta[iTow] = trig_tower_hcal_iphi[iTow] = -999; trig_tower_hcal_FG[iTow] = trig_tower_hcal_et[iTow] = -999; } // // Masked Towers trig_nMaskedRCT=0; trig_nMaskedCh=0; // for (int ii=0;ii<100;ii++) { trig_iMaskedRCTeta[ii] = -999; trig_iMaskedRCTphi[ii] = -999; trig_iMaskedRCTcrate[ii] = -999; trig_iMaskedTTeta[ii] = -999; trig_iMaskedTTphi[ii] = -999; } // // Masked strip/xtals trig_strip_mask_N = 0; trig_xtal_mask_N = 0; // for(int i=0 ; i<1000 ; i++) { trig_strip_mask_TTieta[i] = -999; trig_strip_mask_TTiphi[i] = -999; trig_strip_mask_status[i] = -999; trig_strip_mask_StripID[i] = -999; trig_strip_mask_PseudoStripID[i] = -999; trig_strip_mask_TccID[i] = -999; trig_strip_mask_CCU[i] = -999; // for(int j=0 ; j<5 ; j++) { trig_strip_mask_xtal_ix[i][j] = -999; trig_strip_mask_xtal_iy[i][j] = -999; trig_strip_mask_xtal_iz[i][j] = -999; } trig_xtal_mask_ieta[i] = -999; trig_xtal_mask_iphi[i] = -999; trig_xtal_mask_TTieta[i] = -999; trig_xtal_mask_TTiphi[i] = -999; trig_xtal_mask_Rieta[i] = -999; trig_xtal_mask_Riphi[i] = -999; trig_xtal_mask_status[i] = -999; trig_xtal_mask_EBEE[i] = -999; } cout<<"test3"<<endl; // Disable useless branches //myChain->SetBranchStatus("spike_*",0); //myChain->SetBranchStatus("vtx_*",0); //myChain->SetBranchStatus("skim_*",0); //myChain->SetBranchStatus("trig_pre*",0); //myChain->SetBranchStatus("trig_post*",0); //myChain->SetBranchStatus("trig_HLT*",0); //myChain->SetBranchStatus("BS*",0); //myChain->SetBranchStatus("MC_*",0); //myChain->SetBranchStatus("ele_MC*",0); ////myChain->SetBranchStatus("ele_eid*",0); ////myChain->SetBranchStatus("ele_Seed*",0); //myChain->SetBranchStatus("ele_charge*",0); //myChain->SetBranchStatus("met_*",0); //myChain->SetBranchStatus("muons*",0); //myChain->SetBranchStatus("jets*",0); myChain->SetBranchStatus("sc*",0); //myChain->SetBranchStatus("sc_hybrid_N",1); //myChain->SetBranchStatus("",0); // Global myChain->SetBranchAddress("nEvent",&nEvent); myChain->SetBranchAddress("nRun",&nRun); myChain->SetBranchAddress("nLumi",&nLumi); // Trigger // myChain->SetBranchAddress ("trig_HLT_triggered", &m_HLT_triggered); // myChain->SetBranchAddress ("trig_HLT_pathsV", &m_HLT_pathsV); // myChain->SetBranchAddress ("trig_HLT_pathsV_check", &m_HLT_pathsV_check); // myChain->SetBranchAddress("trig_HLT_path",&trig_HLT_path); // unbias, EG5, EG8, EG12 // myChain->SetBranchAddress("trig_fired_names",&trig_fired_names); myChain->SetBranchAddress("trig_hltInfo",&trig_hltInfo); // SC //myChain->SetBranchAddress("sc_hybrid_N", &sc_hybrid_N); // Electrons myChain->SetBranchAddress("ele_N", &ele_N); myChain->SetBranchAddress("electrons",&electrons); myChain->SetBranchAddress("ele_severityLevelSeed", &ele_severityLevelSeed); myChain->SetBranchAddress("ele_he",&ele_he); myChain->SetBranchAddress("ele_sigmaietaieta",&ele_sigmaietaieta); myChain->SetBranchAddress("ele_hcalDepth1TowerSumEt_dr03", &ele_hcalDepth1TowerSumEt_dr03); myChain->SetBranchAddress("ele_hcalDepth2TowerSumEt_dr03", &ele_hcalDepth2TowerSumEt_dr03); myChain->SetBranchAddress("ele_ecalRecHitSumEt_dr03", &ele_ecalRecHitSumEt_dr03); myChain->SetBranchAddress("ele_tkSumPt_dr03",&ele_tkSumPt_dr03); myChain->SetBranchAddress("ele_sclEta",&ele_sclEta); myChain->SetBranchAddress("ele_sclEt",&ele_sclEt); myChain->SetBranchAddress("ele_expected_inner_hits",&ele_expected_inner_hits); myChain->SetBranchAddress("ele_deltaphiin",&ele_deltaphiin); myChain->SetBranchAddress("ele_deltaetain",&ele_deltaetain); myChain->SetBranchAddress("ele_conv_dist",&ele_conv_dist); myChain->SetBranchAddress("ele_conv_dcot",&ele_conv_dcot); myChain->SetBranchAddress("ele_fbrem",&ele_fbrem); //myChain->SetBranchAddress("ele_ambiguousGsfTracks", &ele_ambiguousGsfTracks); myChain->SetBranchAddress("ele_isConversion",&ele_isConversion); myChain->SetBranchAddress("ele_echarge",&ele_echarge); // L1 electron informations myChain->SetBranchAddress("ele_TTetaVect", &ele_TTetaVect); myChain->SetBranchAddress("ele_TTphiVect", &ele_TTphiVect); myChain->SetBranchAddress("ele_TTetVect", &ele_TTetVect); // myChain->SetBranchAddress("ele_RCTeta", &ele_RCTeta); myChain->SetBranchAddress("ele_RCTphi", &ele_RCTphi); myChain->SetBranchAddress("ele_RCTL1iso", &ele_RCTL1iso); myChain->SetBranchAddress("ele_RCTL1noniso", &ele_RCTL1noniso); myChain->SetBranchAddress("ele_RCTL1iso_M", &ele_RCTL1iso_M); myChain->SetBranchAddress("ele_RCTL1noniso_M", &ele_RCTL1noniso_M); myChain->SetBranchAddress("ele_RCTetaVect", &ele_RCTetaVect); myChain->SetBranchAddress("ele_RCTphiVect", &ele_RCTphiVect); myChain->SetBranchAddress("ele_RCTetVect", &ele_RCTetVect); myChain->SetBranchAddress("ele_RCTL1isoVect", &ele_RCTL1isoVect); myChain->SetBranchAddress("ele_RCTL1nonisoVect", &ele_RCTL1nonisoVect); myChain->SetBranchAddress("ele_RCTL1isoVect_M", &ele_RCTL1isoVect_M); myChain->SetBranchAddress("ele_RCTL1nonisoVect_M", &ele_RCTL1nonisoVect_M); // L1 candidates myChain->SetBranchAddress("trig_L1emIso_N", &trig_L1emIso_N); myChain->SetBranchAddress("trig_L1emIso_ieta", &trig_L1emIso_ieta); myChain->SetBranchAddress("trig_L1emIso_iphi", &trig_L1emIso_iphi); myChain->SetBranchAddress("trig_L1emIso_rank", &trig_L1emIso_rank); myChain->SetBranchAddress("trig_L1emNonIso_N", &trig_L1emNonIso_N); myChain->SetBranchAddress("trig_L1emNonIso_ieta", &trig_L1emNonIso_ieta); myChain->SetBranchAddress("trig_L1emNonIso_iphi", &trig_L1emNonIso_iphi); myChain->SetBranchAddress("trig_L1emNonIso_rank", &trig_L1emNonIso_rank); myChain->SetBranchAddress("trig_L1emIso_N_M", &trig_L1emIso_N_M); myChain->SetBranchAddress("trig_L1emIso_ieta_M", &trig_L1emIso_ieta_M); myChain->SetBranchAddress("trig_L1emIso_iphi_M", &trig_L1emIso_iphi_M); myChain->SetBranchAddress("trig_L1emIso_rank_M", &trig_L1emIso_rank_M); myChain->SetBranchAddress("trig_L1emNonIso_N_M", &trig_L1emNonIso_N_M); myChain->SetBranchAddress("trig_L1emNonIso_ieta_M", &trig_L1emNonIso_ieta_M); myChain->SetBranchAddress("trig_L1emNonIso_iphi_M", &trig_L1emNonIso_iphi_M); myChain->SetBranchAddress("trig_L1emNonIso_rank_M", &trig_L1emNonIso_rank_M); // Pre/post - firing L1 candidates myChain->SetBranchAddress("trig_preL1emIso_N", &trig_preL1emIso_N); myChain->SetBranchAddress("trig_preL1emIso_ieta", &trig_preL1emIso_ieta); myChain->SetBranchAddress("trig_preL1emIso_iphi", &trig_preL1emIso_iphi); myChain->SetBranchAddress("trig_preL1emIso_rank", &trig_preL1emIso_rank); // myChain->SetBranchAddress("trig_preL1emNonIso_N", &trig_preL1emNonIso_N); myChain->SetBranchAddress("trig_preL1emNonIso_ieta", &trig_preL1emNonIso_ieta); myChain->SetBranchAddress("trig_preL1emNonIso_iphi", &trig_preL1emNonIso_iphi); myChain->SetBranchAddress("trig_preL1emNonIso_rank", &trig_preL1emNonIso_rank); // myChain->SetBranchAddress("trig_postL1emIso_N", &trig_postL1emIso_N); myChain->SetBranchAddress("trig_postL1emIso_ieta", &trig_postL1emIso_ieta); myChain->SetBranchAddress("trig_postL1emIso_iphi", &trig_postL1emIso_iphi); myChain->SetBranchAddress("trig_postL1emIso_rank", &trig_postL1emIso_rank); // myChain->SetBranchAddress("trig_postL1emNonIso_N", &trig_postL1emNonIso_N); myChain->SetBranchAddress("trig_postL1emNonIso_ieta", &trig_postL1emNonIso_ieta); myChain->SetBranchAddress("trig_postL1emNonIso_iphi", &trig_postL1emNonIso_iphi); myChain->SetBranchAddress("trig_postL1emNonIso_rank", &trig_postL1emNonIso_rank); // Trigger Towers // normal collection myChain->SetBranchAddress("trig_tower_N", &trig_tower_N); myChain->SetBranchAddress("trig_tower_ieta", &trig_tower_ieta); myChain->SetBranchAddress("trig_tower_iphi", &trig_tower_iphi); myChain->SetBranchAddress("trig_tower_adc", &trig_tower_adc); myChain->SetBranchAddress("trig_tower_sFGVB", &trig_tower_sFGVB); // modified collection myChain->SetBranchAddress("trig_tower_N_M", &trig_tower_N_M); myChain->SetBranchAddress("trig_tower_ieta_M", &trig_tower_ieta_M); myChain->SetBranchAddress("trig_tower_iphi_M", &trig_tower_iphi_M); myChain->SetBranchAddress("trig_tower_adc_M", &trig_tower_adc_M); myChain->SetBranchAddress("trig_tower_sFGVB_M", &trig_tower_sFGVB_M); myChain->SetBranchAddress("trig_tower_N_E", &trig_tower_N_E); myChain->SetBranchAddress("trig_tower_ieta_E", &trig_tower_ieta_E); myChain->SetBranchAddress("trig_tower_iphi_E", &trig_tower_iphi_E); myChain->SetBranchAddress("trig_tower_adc_E", &trig_tower_adc_E); myChain->SetBranchAddress("trig_tower_sFGVB_E", &trig_tower_sFGVB_E); // HCAL TP myChain->SetBranchAddress("trig_tower_hcal_N", &trig_tower_hcal_N); myChain->SetBranchAddress("trig_tower_hcal_ieta", &trig_tower_hcal_ieta); myChain->SetBranchAddress("trig_tower_hcal_iphi", &trig_tower_hcal_iphi); myChain->SetBranchAddress("trig_tower_hcal_et", &trig_tower_hcal_et); myChain->SetBranchAddress("trig_tower_hcal_FG", &trig_tower_hcal_FG); // Strip masking myChain->SetBranchAddress("trig_strip_mask_N", &trig_strip_mask_N); myChain->SetBranchAddress("trig_strip_mask_TTieta", &trig_strip_mask_TTieta); myChain->SetBranchAddress("trig_strip_mask_TTiphi", &trig_strip_mask_TTiphi); myChain->SetBranchAddress("trig_strip_mask_StripID", &trig_strip_mask_StripID); myChain->SetBranchAddress("trig_strip_mask_PseudoStripID", &trig_strip_mask_PseudoStripID); myChain->SetBranchAddress("trig_strip_mask_TccID", &trig_strip_mask_TccID); myChain->SetBranchAddress("trig_strip_mask_CCU", &trig_strip_mask_CCU); myChain->SetBranchAddress("trig_strip_mask_xtal_ix", &trig_strip_mask_xtal_ix); myChain->SetBranchAddress("trig_strip_mask_xtal_iy", &trig_strip_mask_xtal_iy); myChain->SetBranchAddress("trig_strip_mask_xtal_iz", &trig_strip_mask_xtal_iz); // // Crystal masking myChain->SetBranchAddress("trig_xtal_mask_N", &trig_xtal_mask_N); myChain->SetBranchAddress("trig_xtal_mask_ieta", &trig_xtal_mask_ieta); myChain->SetBranchAddress("trig_xtal_mask_iphi", &trig_xtal_mask_iphi); myChain->SetBranchAddress("trig_xtal_mask_TTieta", &trig_xtal_mask_TTieta); myChain->SetBranchAddress("trig_xtal_mask_TTiphi", &trig_xtal_mask_TTiphi); myChain->SetBranchAddress("trig_xtal_mask_Rieta", &trig_xtal_mask_Rieta); myChain->SetBranchAddress("trig_xtal_mask_Riphi", &trig_xtal_mask_Riphi); myChain->SetBranchAddress("trig_xtal_mask_status", &trig_xtal_mask_status); myChain->SetBranchAddress("trig_xtal_mask_EBEE", &trig_xtal_mask_EBEE); // Masking myChain->SetBranchAddress("trig_nMaskedRCT", &trig_nMaskedRCT); myChain->SetBranchAddress("trig_iMaskedRCTeta", &trig_iMaskedRCTeta); myChain->SetBranchAddress("trig_iMaskedRCTcrate", &trig_iMaskedRCTcrate); myChain->SetBranchAddress("trig_iMaskedRCTphi", &trig_iMaskedRCTphi); myChain->SetBranchAddress("trig_nMaskedCh", &trig_nMaskedCh); myChain->SetBranchAddress("trig_iMaskedTTeta", &trig_iMaskedTTeta); myChain->SetBranchAddress("trig_iMaskedTTphi", &trig_iMaskedTTphi); if(debug) cout << "got the input tree, start to define output tree" << endl; // OUTPUT TREE // TTree * outtree = new TTree("ElePairs","ElePairs"); // General informations outtree->Branch("nRun",&nRun,"nRun/I"); outtree->Branch("nLumi",&nLumi,"nLumi/I"); outtree->Branch("nEvent",&nEvent,"nEvent/I"); // Vertices outtree->Branch("vtx_N",&_vtx_N,"vtx_N/I"); outtree->Branch("vtx_normalizedChi2",&_vtx_normalizedChi2,"vtx_normalizedChi2[200]/D"); outtree->Branch("vtx_ndof",&_vtx_ndof,"vtx_ndof[200]/D"); outtree->Branch("vtx_nTracks",&_vtx_nTracks,"vtx_nTracks[200]/D"); outtree->Branch("vtx_d0",&_vtx_d0,"vtx_d0[200]/D"); outtree->Branch("vtx_x",&_vtx_x,"vtx_x[200]/D"); outtree->Branch("vtx_y",&_vtx_y,"vtx_y[200]/D"); outtree->Branch("vtx_z",&_vtx_z,"vtx_z[200]/D"); // HLT informations // outtree->Branch ("trig_HLT_triggered", &m_HLT_triggered, 256000,0); // outtree->Branch ("trig_HLT_pathsV", &m_HLT_pathsV, 256000,0); // outtree->Branch ("trig_HLT_pathsV_check", &m_HLT_pathsV_check, 256000,0); // outtree->Branch("trig_HLT_path",&trig_HLT_path,"trig_HLT_path[4]/I"); // unbias, EG5, EG8, EG12 // outtree->Branch("trig_fired_names",&trig_fired_names,"trig_fired_names[5000]/C"); outtree->Branch("trig_hltInfo",&trig_hltInfo,"trig_hltInfo[250]/I"); // Trigger towers outtree->Branch("trig_tower_N",&trig_tower_N,"trig_tower_N/I"); outtree->Branch("trig_tower_ieta",&trig_tower_ieta,"trig_tower_ieta[4032]/I"); outtree->Branch("trig_tower_iphi",&trig_tower_iphi,"trig_tower_iphi[4032]/I"); outtree->Branch("trig_tower_adc",&trig_tower_adc,"trig_tower_adc[4032]/I"); outtree->Branch("trig_tower_sFGVB",&trig_tower_sFGVB,"trig_tower_sFGVB[4032]/I"); // outtree->Branch("trig_tower_N_M",&trig_tower_N_M,"trig_tower_N_M/I"); outtree->Branch("trig_tower_ieta_M",&trig_tower_ieta_M,"trig_tower_ieta_M[4032]/I"); outtree->Branch("trig_tower_iphi_M",&trig_tower_iphi_M,"trig_tower_iphi_M[4032]/I"); outtree->Branch("trig_tower_adc_M",&trig_tower_adc_M,"trig_tower_adc_M[4032]/I"); outtree->Branch("trig_tower_sFGVB_M",&trig_tower_sFGVB_M,"trig_tower_sFGVB_M[4032]/I"); // outtree->Branch("trig_tower_N_E",&trig_tower_N_E,"trig_tower_N_E/I"); outtree->Branch("trig_tower_ieta_E",&trig_tower_ieta_E,"trig_tower_ieta_E[4032]/I"); outtree->Branch("trig_tower_iphi_E",&trig_tower_iphi_E,"trig_tower_iphi_E[4032]/I"); outtree->Branch("trig_tower_adc_E",&trig_tower_adc_E,"trig_tower_adc_E[4032][5]/I"); outtree->Branch("trig_tower_sFGVB_E",&trig_tower_sFGVB_E,"trig_tower_sFGVB_E[4032][5]/I"); // HCAL TP outtree->Branch("trig_tower_hcal_N", &trig_tower_hcal_N, "trig_tower_hcal_N/I"); outtree->Branch("trig_tower_hcal_ieta", &trig_tower_hcal_ieta, "trig_tower_hcal_ieta[trig_tower_N]/I"); outtree->Branch("trig_tower_hcal_iphi", &trig_tower_hcal_iphi, "trig_tower_hcal_iphi[trig_tower_N]/I"); outtree->Branch("trig_tower_hcal_et", &trig_tower_hcal_et, "trig_tower_hcal_et[trig_tower_N]/I"); outtree->Branch("trig_tower_hcal_FG", &trig_tower_hcal_FG, "trig_tower_hcal_FG[trig_tower_N]/I"); // Strip masking outtree->Branch("trig_strip_mask_N", &trig_strip_mask_N, "trig_strip_mask_N/I"); outtree->Branch("trig_strip_mask_TTieta", &trig_strip_mask_TTieta, "trig_strip_mask_TTieta[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_TTiphi", &trig_strip_mask_TTiphi, "trig_strip_mask_TTiphi[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_StripID", &trig_strip_mask_StripID, "trig_strip_mask_StripID[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_PseudoStripID", &trig_strip_mask_PseudoStripID, "trig_strip_mask_PseudoStripID[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_TccID", &trig_strip_mask_TccID, "trig_strip_mask_TccID[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_CCU", &trig_strip_mask_CCU, "trig_strip_mask_CCU[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_xtal_ix", &trig_strip_mask_xtal_ix, "trig_strip_mask_xtal_ix[trig_strip_mask_N][5]/I"); outtree->Branch("trig_strip_mask_xtal_iy", &trig_strip_mask_xtal_iy, "trig_strip_mask_xtal_iy[trig_strip_mask_N][5]/I"); outtree->Branch("trig_strip_mask_xtal_iz", &trig_strip_mask_xtal_iz, "trig_strip_mask_xtal_iz[trig_strip_mask_N][5]/I"); // // Crystal masking outtree->Branch("trig_xtal_mask_N", &trig_xtal_mask_N, "trig_xtal_mask_N/I"); outtree->Branch("trig_xtal_mask_ieta", &trig_xtal_mask_ieta, "trig_xtal_mask_ieta[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_iphi", &trig_xtal_mask_iphi, "trig_xtal_mask_iphi[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_TTieta", &trig_xtal_mask_TTieta, "trig_xtal_mask_TTieta[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_TTiphi", &trig_xtal_mask_TTiphi, "trig_xtal_mask_TTiphi[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_Rieta", &trig_xtal_mask_Rieta, "trig_xtal_mask_Rieta[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_Riphi", &trig_xtal_mask_Riphi, "trig_xtal_mask_Riphi[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_status", &trig_xtal_mask_status, "trig_xtal_mask_status[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_EBEE", &trig_xtal_mask_EBEE, "trig_xtal_mask_EBEE[trig_xtal_mask_N]/I"); // L1 candidates outtree->Branch("trig_L1emIso_N", &trig_L1emIso_N, "trig_L1emIso_N/I"); outtree->Branch("trig_L1emIso_ieta", &trig_L1emIso_ieta, "trig_L1emIso_ieta[4]/I"); outtree->Branch("trig_L1emIso_iphi", &trig_L1emIso_iphi, "trig_L1emIso_iphi[4]/I"); outtree->Branch("trig_L1emIso_rank", &trig_L1emIso_rank, "trig_L1emIso_rank[4]/I"); //outtree->Branch("trig_L1emIso_eta", &trig_L1emIso_eta, "trig_L1emIso_eta[4]/D"); //outtree->Branch("trig_L1emIso_phi", &trig_L1emIso_phi, "trig_L1emIso_phi[4]/D"); // outtree->Branch("trig_L1emIso_energy",&trig_L1emIso_energy,"trig_L1emIso_energy[4]/D"); // outtree->Branch("trig_L1emIso_et", &trig_L1emIso_et, "trig_L1emIso_et[4]/D"); // outtree->Branch("trig_L1emNonIso_N", &trig_L1emNonIso_N, "trig_L1emNonIso_N/I"); outtree->Branch("trig_L1emNonIso_ieta", &trig_L1emNonIso_ieta, "trig_L1emNonIso_ieta[4]/I"); outtree->Branch("trig_L1emNonIso_iphi", &trig_L1emNonIso_iphi, "trig_L1emNonIso_iphi[4]/I"); outtree->Branch("trig_L1emNonIso_rank", &trig_L1emNonIso_rank, "trig_L1emNonIso_rank[4]/I"); // outtree->Branch("trig_L1emNonIso_eta", &trig_L1emNonIso_eta, "trig_L1emNonIso_eta[4]/D"); // outtree->Branch("trig_L1emNonIso_phi", &trig_L1emNonIso_phi, "trig_L1emNonIso_phi[4]/D"); // outtree->Branch("trig_L1emNonIso_energy",&trig_L1emNonIso_energy,"trig_L1emNonIso_energy[4]/D"); // outtree->Branch("trig_L1emNonIso_et", &trig_L1emNonIso_et, "trig_L1emNonIso_et[4]/D"); // outtree->Branch("trig_L1emIso_N_M", &trig_L1emIso_N_M, "trig_L1emIso_N_M/I"); outtree->Branch("trig_L1emIso_ieta_M", &trig_L1emIso_ieta_M, "trig_L1emIso_ieta_M[4]/I"); outtree->Branch("trig_L1emIso_iphi_M", &trig_L1emIso_iphi_M, "trig_L1emIso_iphi_M[4]/I"); outtree->Branch("trig_L1emIso_rank_M", &trig_L1emIso_rank_M, "trig_L1emIso_rank_M[4]/I"); // outtree->Branch("trig_L1emIso_eta_M", &trig_L1emIso_eta_M, "trig_L1emIso_eta_M[4]/D"); // outtree->Branch("trig_L1emIso_phi_M", &trig_L1emIso_phi_M, "trig_L1emIso_phi_M[4]/D"); // outtree->Branch("trig_L1emIso_energy_M",&trig_L1emIso_energy_M,"trig_L1emIso_energy_M[4]/D"); // outtree->Branch("trig_L1emIso_et_M", &trig_L1emIso_et_M, "trig_L1emIso_et_M[4]/D"); // outtree->Branch("trig_L1emNonIso_N_M", &trig_L1emNonIso_N_M, "trig_L1emNonIso_N_M/I"); outtree->Branch("trig_L1emNonIso_ieta_M", &trig_L1emNonIso_ieta_M, "trig_L1emNonIso_ieta_M[4]/I"); outtree->Branch("trig_L1emNonIso_iphi_M", &trig_L1emNonIso_iphi_M, "trig_L1emNonIso_iphi_M[4]/I"); outtree->Branch("trig_L1emNonIso_rank_M", &trig_L1emNonIso_rank_M, "trig_L1emNonIso_rank_M[4]/I"); // outtree->Branch("trig_L1emNonIso_eta_M", &trig_L1emNonIso_eta_M, "trig_L1emNonIso_eta_M[4]/D"); // outtree->Branch("trig_L1emNonIso_phi_M", &trig_L1emNonIso_phi_M, "trig_L1emNonIso_phi_M[4]/D"); // outtree->Branch("trig_L1emNonIso_energy_M",&trig_L1emNonIso_energy_M,"trig_L1emNonIso_energy_M[4]/D"); // outtree->Branch("trig_L1emNonIso_et_M", &trig_L1emNonIso_et_M, "trig_L1emNonIso_et_M[4]/D"); // pre-post firing L1 candidates outtree->Branch("trig_preL1emIso_N", &trig_preL1emIso_N, "trig_preL1emIso_N/I"); outtree->Branch("trig_preL1emIso_ieta", &trig_preL1emIso_ieta, "trig_preL1emIso_ieta[4]/I"); outtree->Branch("trig_preL1emIso_iphi", &trig_preL1emIso_iphi, "trig_preL1emIso_iphi[4]/I"); outtree->Branch("trig_preL1emIso_rank", &trig_preL1emIso_rank, "trig_preL1emIso_rank[4]/I"); // outtree->Branch("trig_preL1emNonIso_N", &trig_preL1emNonIso_N, "trig_preL1emNonIso_N/I"); outtree->Branch("trig_preL1emNonIso_ieta", &trig_preL1emNonIso_ieta, "trig_preL1emNonIso_ieta[4]/I"); outtree->Branch("trig_preL1emNonIso_iphi", &trig_preL1emNonIso_iphi, "trig_preL1emNonIso_iphi[4]/I"); outtree->Branch("trig_preL1emNonIso_rank", &trig_preL1emNonIso_rank, "trig_preL1emNonIso_rank[4]/I"); // outtree->Branch("trig_postL1emIso_N", &trig_postL1emIso_N, "trig_postL1emIso_N/I"); outtree->Branch("trig_postL1emIso_ieta", &trig_postL1emIso_ieta, "trig_postL1emIso_ieta[4]/I"); outtree->Branch("trig_postL1emIso_iphi", &trig_postL1emIso_iphi, "trig_postL1emIso_iphi[4]/I"); outtree->Branch("trig_postL1emIso_rank", &trig_postL1emIso_rank, "trig_postL1emIso_rank[4]/I"); // outtree->Branch("trig_postL1emNonIso_N", &trig_postL1emNonIso_N, "trig_postL1emNonIso_N/I"); outtree->Branch("trig_postL1emNonIso_ieta", &trig_postL1emNonIso_ieta, "trig_postL1emNonIso_ieta[4]/I"); outtree->Branch("trig_postL1emNonIso_iphi", &trig_postL1emNonIso_iphi, "trig_postL1emNonIso_iphi[4]/I"); outtree->Branch("trig_postL1emNonIso_rank", &trig_postL1emNonIso_rank, "trig_postL1emNonIso_rank[4]/I"); // outtree->Branch("trig_nMaskedRCT", &trig_nMaskedRCT, "trig_nMaskedRCT/I"); outtree->Branch("trig_iMaskedRCTeta", &trig_iMaskedRCTeta, "trig_iMaskedRCTeta[trig_nMaskedRCT]/I"); outtree->Branch("trig_iMaskedRCTcrate", &trig_iMaskedRCTcrate,"trig_iMaskedRCTcrate[trig_nMaskedRCT]/I"); outtree->Branch("trig_iMaskedRCTphi", &trig_iMaskedRCTphi, "trig_iMaskedRCTphi[trig_nMaskedRCT]/I"); outtree->Branch("trig_nMaskedCh", &trig_nMaskedCh, "trig_nMaskedCh/I"); outtree->Branch("trig_iMaskedTTeta", &trig_iMaskedTTeta, "trig_iMaskedTTeta[trig_nMaskedCh]/I"); outtree->Branch("trig_iMaskedTTphi", &trig_iMaskedTTphi, "trig_iMaskedTTphi[trig_nMaskedCh]/I"); // Pairs informations double pair_M; double pair_eta[2], pair_sclEta[2], pair_sclEt[2], pair_phi[2], pair_pT[2], pair_eT[2], pair_E[2]; int pair_cuts[2], pair_HLT_Ele27_cut[2], pair_fidu[2], pair_charge[2], pair_RCTeta[2], pair_RCTphi[2], pair_L1iso[2], pair_L1noniso[2], pair_L1iso_M[2], pair_L1noniso_M[2]; int pair_RCTetaVect[2][10], pair_RCTphiVect[2][10], pair_L1isoVect[2][10], pair_L1nonisoVect[2][10],pair_L1isoVect_M[2][10], pair_L1nonisoVect_M[2][10]; double pair_RCTetVect[2][10]; int pair_TTetaVect[2][50], pair_TTphiVect[2][50]; double pair_TTetVect[2][50]; // outtree->Branch("pair_M",&pair_M,"pair_M/D"); // outtree->Branch("pair_cuts",&pair_cuts,"pair_cuts[2]/I"); // 0 : noCut | 1 : VBTF 95 | 2 : VBTF 80 | 3 : VBTF 60 outtree->Branch("pair_HLT_Ele27_cut",&pair_HLT_Ele27_cut,"pair_HLT_Ele27_cut[2]/I"); outtree->Branch("pair_fidu",&pair_fidu,"pair_fidu[2]/I"); // outtree->Branch("pair_eta",&pair_eta,"pair_eta[2]/D"); outtree->Branch("pair_sclEta",&pair_sclEta,"pair_sclEta[2]/D"); outtree->Branch("pair_phi",&pair_phi,"pair_phi[2]/D"); outtree->Branch("pair_RCTeta",&pair_RCTeta,"pair_RCTeta[2]/I"); outtree->Branch("pair_RCTphi",&pair_RCTphi,"pair_RCTphi[2]/I"); // outtree->Branch("pair_charge",&pair_charge,"pair_charge[2]/I"); outtree->Branch("pair_pT",&pair_pT,"pair_pT[2]/D"); outtree->Branch("pair_eT",&pair_eT,"pair_eT[2]/D"); outtree->Branch("pair_sclEt",&pair_sclEt,"pair_sclEt[2]/D"); outtree->Branch("pair_E",&pair_E,"pair_E[2]/D"); outtree->Branch("pair_TTetaVect", &pair_TTetaVect,"pair_TTetaVect[2][50]/I"); outtree->Branch("pair_TTphiVect", &pair_TTphiVect,"pair_TTphiVect[2][50]/I"); outtree->Branch("pair_TTetVect", &pair_TTetVect,"pair_TTetVect[2][50]/D"); outtree->Branch("pair_L1iso",&pair_L1iso,"pair_L1iso[2]/I"); outtree->Branch("pair_L1noniso",&pair_L1noniso,"pair_L1noniso[2]/I"); outtree->Branch("pair_L1iso_M",&pair_L1iso_M,"pair_L1iso_M[2]/I"); outtree->Branch("pair_L1noniso_M",&pair_L1noniso_M,"pair_L1noniso_M[2]/I"); // outtree->Branch("pair_RCTetVect",&pair_RCTetVect,"pair_RCTetVect[2][10]/D"); outtree->Branch("pair_RCTetaVect",&pair_RCTetaVect,"pair_RCTetaVect[2][10]/I"); outtree->Branch("pair_RCTphiVect",&pair_RCTphiVect,"pair_RCTphiVect[2][10]/I"); outtree->Branch("pair_L1isoVect",&pair_L1isoVect,"pair_L1isoVect[2][10]/I"); outtree->Branch("pair_L1nonisoVect",&pair_L1nonisoVect,"pair_L1nonisoVect[2][10]/I"); outtree->Branch("pair_L1isoVect_M",&pair_L1isoVect_M,"pair_L1isoVect_M[2][10]/I"); outtree->Branch("pair_L1nonisoVect_M",&pair_L1nonisoVect_M,"pair_L1nonisoVect_M[2][10]/I"); if(debug) cout << "output tree defined" << endl; cout<<"test4"<<endl; // USEFUL VARIABLES // vector<int> pairIdx; int cutEle[2], fidu[2]; bool cut_HLT_Ele27[2]; TLorentzVector* cand[2]; TLorentzVector total; bool isGoodRun; TString filename; // JSON FILE READER // string jsonDir = "/data_CMS/cms/ndaci/" ; const int nJson = 10; string jsonFile[nJson]; // 2010B, May10, Aug05, Prompt map<int, vector<pair<int, int> > > jsonMap[nJson] ; jsonFile[0] = jsonDir + "ndaci_2011A/JSON/goodrunlist_json.txt" ; jsonFile[1] = jsonDir + "ndaci_2011A/JSON/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt" ; jsonFile[2] = jsonDir + "ndaci_2011A/JSON/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON_v3.txt" ; jsonFile[3] = jsonDir + "ndaci_2011A/JSON/Cert_160404-180252_7TeV_PromptReco_Collisions11_JSON.txt" ; jsonFile[4] = jsonDir + "ndaci_2011A/JSON/Cert_160404-180252_7TeV_ReRecoNov08_Collisions11_JSON.txt" ; // 2012 jsonFile[5] = jsonDir + "ndaci_2012/JSON/Cert_190456-203002_8TeV_PromptReco_Collisions12_JSON.txt"; jsonFile[6] = jsonDir + "ndaci_2012/JSON/Cert_190456-196531_8TeV_13Jul2012ReReco_Collisions12_JSON_v2.txt"; jsonFile[7] = jsonDir + "ndaci_2012/JSON/Cert_190782-190949_8TeV_06Aug2012ReReco_Collisions12_JSON.txt"; jsonFile[8] = jsonDir + "ndaci_2012/JSON/Cert_198022-198523_8TeV_24Aug2012ReReco_Collisions12_JSON.txt"; jsonFile[9] = jsonDir + "ndaci_2012/JSON/Cert_190456-208357_8TeV_PromptReco_Collisions12_JSON.txt"; cout<<"test5"<<endl; /** for(int i=0 ; i<nJson ; i++) jsonMap[i] = readJSONFile(jsonFile[i]); if(debug) cout << "JSON defined" << endl;**/ // ------------------------------------------------------------------------------- // LOOP OVER EVENTS // ------------------------------------------------------------------------------- if(debug) cout << "gonna loop over events" << endl; cout<< "begining loop over events"<<endl; int numEntries = myChain->GetEntries () ; int nProcess = numEntries; if(nEntries>=0 && nEntries<numEntries) nProcess = nEntries; int nCurrentRun = -999; outlog << "will process " << nProcess << "/" << numEntries << "entries" << endl; for (int iEvent = 0 ; iEvent < nProcess ; iEvent++ ) { // HLT information for(int i=0 ; i<4 ; i++) trig_HLT_path[i]=0; for(int i=0 ; i<250 ; i++) trig_hltInfo[i]=0; // TP Initialization trig_tower_N = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta[iTow] = trig_tower_iphi[iTow] = -999; trig_tower_adc[iTow] = trig_tower_sFGVB[iTow] = -999; } trig_tower_N_M = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta_M[iTow] = trig_tower_iphi_M[iTow] = -999; trig_tower_adc_M[iTow] = trig_tower_sFGVB_M[iTow] = -999; } trig_tower_N_E = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta_E[iTow] = trig_tower_iphi_E[iTow] = -999; for(int i=0 ; i<5 ; i++) trig_tower_adc_E[iTow][i] = trig_tower_sFGVB_E[iTow][i] = -999; } myChain->GetEntry (iEvent) ; // show processed file if(iEvent==0) { filename = myChain->GetFile()->GetName() ; outlog << "File : " << filename << endl << endl; } else if( filename != myChain->GetFile()->GetName() ) { filename = myChain->GetFile()->GetName() ; outlog << "File : " << myChain->GetFile()->GetName() << endl << endl; } // show current run/iCat processed if(iEvent==0) { nCurrentRun = nRun ; outlog << "nRun=" << nRun << endl; } else if(nRun!=nCurrentRun) { nCurrentRun=nRun ; outlog << "nRun=" << nRun << endl; } // run selection (using both json files) //int iJson = detJson(nRun); //int iJson = 4; if(debug) cout << "iJson = " << iJson << endl; outlog << "iJson = " << iJson << endl; if( iJson>-1 && iJson<9) { isGoodRun = AcceptEventByRunAndLumiSection(nRun, nLumi, jsonMap[iJson]); if(!isGoodRun) { outlog << "failed JSON" << endl; continue; } } else { outlog << "no proper JSON file" << endl; //continue; } // at least 2 electrons if(ele_N<2) continue; else outlog << "ele_N=" << ele_N << endl; // LOOP OVER ELECTRONS // if(debug) cout << "<-- ele_N=" << ele_N << endl << "--- electrons.size=" << electrons->GetSize() << endl; for( int iEle1=0 ; iEle1<ele_N ; iEle1++ ) { if(debug) cout << "--- get ele #" << iEle1 << endl; cand[0] = (TLorentzVector*) (electrons->At (iEle1)) ; if(debug) cout << "--- got it" << endl; // severity selection if( ele_severityLevelSeed[iEle1] >= 3 ) continue; // check whether electrons of the pair pass HLT_Ele27 Id/Iso cuts if(debug) cout << "--- checks VBTF cuts" << endl; cut_HLT_Ele27[0] = VBTFcuts( "HLT_Ele27", RunPhase, cand[0]->Pt(), cand[0]->Et(), ele_sclEta[iEle1], cand[0]->Eta(), ele_tkSumPt_dr03[iEle1], ele_ecalRecHitSumEt_dr03[iEle1], ele_hcalDepth1TowerSumEt_dr03[iEle1], ele_hcalDepth2TowerSumEt_dr03[iEle1], ele_expected_inner_hits[iEle1], ele_deltaphiin[iEle1], ele_deltaetain[iEle1], ele_he[iEle1], ele_sigmaietaieta[iEle1], ele_conv_dist[iEle1], ele_conv_dcot[iEle1], ele_fbrem[iEle1], ele_isConversion[iEle1] ) ; // check if ele is a good tag candidate : pass VBTF 95 and has pT>5 GeV cutEle[0] = 0; cutEle[0] = whichCuts( RunPhase, cand[0]->Pt(), cand[0]->Et(), ele_sclEta[iEle1], cand[0]->Eta(), ele_tkSumPt_dr03[iEle1], ele_ecalRecHitSumEt_dr03[iEle1], ele_hcalDepth1TowerSumEt_dr03[iEle1], ele_hcalDepth2TowerSumEt_dr03[iEle1], ele_expected_inner_hits[iEle1], ele_deltaphiin[iEle1], ele_deltaetain[iEle1], ele_he[iEle1], ele_sigmaietaieta[iEle1], ele_conv_dist[iEle1], ele_conv_dcot[iEle1], ele_fbrem[iEle1], ele_isConversion[iEle1] ) ; fidu[0] = 0; if ( fabs(ele_sclEta[iEle1]) < 2.5 && ( fabs(ele_sclEta[iEle1]) > 1.566 || fabs(ele_sclEta[iEle1])<1.4442 ) ) fidu[0] = 1 ; if( cutEle[0]>0 && cand[0]->Et()>=5. ) { if(debug) cout << "--- ele #" << iEle1 << " is a good tag candidate" << endl; // loop to find probe candidates for( int iEle2=0 ; iEle2<ele_N ; iEle2++ ) { if(debug) cout << "----- looks Ele #" << iEle2 << endl; cand[1] = (TLorentzVector*) (electrons->At (iEle2)) ; // severity if( ele_severityLevelSeed[iEle2] >= 3 ) continue; // check HLT_Ele27 cuts cut_HLT_Ele27[1] = VBTFcuts( "HLT_Ele27", RunPhase, cand[1]->Pt(), cand[1]->Et(), ele_sclEta[iEle1], cand[1]->Eta(), ele_tkSumPt_dr03[iEle1], ele_ecalRecHitSumEt_dr03[iEle1], ele_hcalDepth1TowerSumEt_dr03[iEle1], ele_hcalDepth2TowerSumEt_dr03[iEle1], ele_expected_inner_hits[iEle1], ele_deltaphiin[iEle1], ele_deltaetain[iEle1], ele_he[iEle1], ele_sigmaietaieta[iEle1], ele_conv_dist[iEle1], ele_conv_dcot[iEle1], ele_fbrem[iEle1], ele_isConversion[iEle1] ) ; // check cuts passed by probe candidate cutEle[1] = whichCuts( RunPhase, cand[1]->Pt(), cand[0]->Et(), ele_sclEta[iEle2], cand[1]->Eta(), ele_tkSumPt_dr03[iEle2], ele_ecalRecHitSumEt_dr03[iEle2], ele_hcalDepth1TowerSumEt_dr03[iEle2], ele_hcalDepth2TowerSumEt_dr03[iEle2], ele_expected_inner_hits[iEle2], ele_deltaphiin[iEle2], ele_deltaetain[iEle2], ele_he[iEle2], ele_sigmaietaieta[iEle2], ele_conv_dist[iEle2], ele_conv_dcot[iEle2], ele_fbrem[iEle2], ele_isConversion[iEle2] ) ; fidu[1] = 0; if ( fabs(ele_sclEta[iEle2]) < 2.5 && ( fabs(ele_sclEta[iEle2]) > 1.566 || fabs(ele_sclEta[iEle2])<1.4442 ) ) fidu[1] = 1 ; if( cutEle[1]>0 && iEle2<=iEle1 ) continue; // prevents to create several times the same pair if(debug) cout << "---> OK to form a pre-selected pair <--" << endl; // get the pair informations total = (*cand[0]) + (*cand[1]) ; // keep only pairs with Mee > 30 GeV if( total.M() < 30. ) continue; pair_M = total.M() ; pairIdx.clear(); pairIdx.push_back(iEle1); pairIdx.push_back(iEle2); for(int iP=0 ; iP<2 ; iP++) { pair_cuts[iP] = cutEle[iP]; pair_fidu[iP] = fidu[iP]; pair_HLT_Ele27_cut[iP] = cut_HLT_Ele27[iP]; // pair_eta[iP] = cand[iP]->Eta(); pair_sclEta[iP] = ele_sclEta[pairIdx[iP]]; pair_phi[iP] = cand[iP]->Phi(); pair_RCTeta[iP] = ele_RCTeta[pairIdx[iP]]; pair_RCTphi[iP] = ele_RCTphi[pairIdx[iP]]; // pair_charge[iP] = ele_echarge[pairIdx[iP]]; pair_pT[iP] = cand[iP]->Pt(); pair_eT[iP] = cand[iP]->Et(); pair_sclEt[iP] = ele_sclEt[pairIdx[iP]]; pair_E[iP] = cand[iP]->E(); // pair_L1iso[iP] = ele_RCTL1iso[pairIdx[iP]]; pair_L1noniso[iP] = ele_RCTL1noniso[pairIdx[iP]]; pair_L1iso_M[iP] = ele_RCTL1iso_M[pairIdx[iP]]; pair_L1noniso_M[iP] = ele_RCTL1noniso_M[pairIdx[iP]]; // for(int iV=0 ; iV<10 ; iV++) { pair_RCTetVect[iP][iV] = ele_RCTetVect[pairIdx[iP]][iV]; pair_RCTetaVect[iP][iV] = ele_RCTetaVect[pairIdx[iP]][iV]; pair_RCTphiVect[iP][iV] = ele_RCTphiVect[pairIdx[iP]][iV]; pair_L1isoVect[iP][iV] = ele_RCTL1isoVect[pairIdx[iP]][iV]; pair_L1nonisoVect[iP][iV] = ele_RCTL1nonisoVect[pairIdx[iP]][iV]; pair_L1isoVect_M[iP][iV] = ele_RCTL1isoVect_M[pairIdx[iP]][iV]; pair_L1nonisoVect_M[iP][iV] = ele_RCTL1nonisoVect_M[pairIdx[iP]][iV]; } // for(int iV=0 ; iV<50 ; iV++) { pair_TTetaVect[iP][iV] = ele_TTetaVect[pairIdx[iP]][iV]; pair_TTphiVect[iP][iV] = ele_TTphiVect[pairIdx[iP]][iV]; pair_TTetVect[iP][iV] = ele_TTetVect[pairIdx[iP]][iV]; } } if(debug) cout << "outtree->Fill();" << endl; outtree->Fill(); } // loop for probe } // endif ele1 is good tag candidate } // loop over electrons }//loop over events if(debug) cout << "End loop events" << endl; outlog << "End loop events" << endl; // Record tree if(debug) cout << "recording tree..." << endl; outlog << "recording tree..." << endl; outtree->Write(); if(debug) cout << "recorded !" << endl; outlog << "recorded !" << endl; outfile->Close(); if(debug) cout << "file closed." << endl; outlog << "file closed." << endl; return 1; }
void listMismatchedEvents(TString inputFile = "L1UnpackedPureEmulator.root", testObject type = Jets) { TFile *inFile = TFile::Open(inputFile); TTree *emulatorResults = (TTree*)inFile->Get("EmulatorResults/L1UpgradeTree"); TTree *unpackerResults = (TTree*)inFile->Get("UnpackerResults/L1UpgradeTree"); int event, run, lumi; emulatorResults->SetBranchAddress("event",&event); emulatorResults->SetBranchAddress("run",&run); emulatorResults->SetBranchAddress("lumi",&lumi); std::vector<int> *e_hwPt =0; std::vector<int> *e_hwEta =0; std::vector<int> *e_hwPhi =0; std::vector<int> *e_bx =0; int e_N; std::vector<int> *u_hwPt =0; std::vector<int> *u_hwEta =0; std::vector<int> *u_hwPhi =0; std::vector<int> *u_bx =0; int u_N; TString prefix; TString nPrefix; switch(type) { case Jets: prefix = "jet"; nPrefix = "Jet"; break; case EGammas: prefix = "egamma"; nPrefix = "Egamma"; break; case Taus: prefix = "tau"; nPrefix = "Tau"; break; case Centrality: prefix = "hfring"; nPrefix = "Hfring"; break; default: prefix = "jet"; nPrefix = "Jet"; break; } emulatorResults->SetBranchAddress(prefix + "_hwPt",&e_hwPt); emulatorResults->SetBranchAddress(prefix + "_hwEta",&e_hwEta); emulatorResults->SetBranchAddress(prefix + "_hwPhi",&e_hwPhi); emulatorResults->SetBranchAddress(prefix + "_bx",&e_bx); emulatorResults->SetBranchAddress("n"+nPrefix,&e_N); unpackerResults->SetBranchAddress(prefix + "_hwPt",&u_hwPt); unpackerResults->SetBranchAddress(prefix + "_hwEta",&u_hwEta); unpackerResults->SetBranchAddress(prefix + "_hwPhi",&u_hwPhi); unpackerResults->SetBranchAddress(prefix + "_bx",&u_bx); unpackerResults->SetBranchAddress("n"+nPrefix,&u_N); long misses = 0; long entries = emulatorResults->GetEntries(); for(long i = 0; i < entries; i++) { emulatorResults->GetEntry(i); unpackerResults->GetEntry(i); int e_offset = 0; int u_offset = 0; // e_offset will always be 0, but make sure that we are not one of the // 1/100 events with multiple RCT BX. // there are 4 taus per event, 8 jets, 8 egammas, and 1 centrality if(e_N == 4) { e_offset = 0; } else if (e_N == 8) { e_offset = 0; } else if (e_N == 1) { e_offset = 0; } else { // there are multiple BX here and I don't know the alignment // skip the event continue; } // there are 20 taus per events, 40 jets, 40 egammas, and 5 centralities because of extra BX if (u_N == 5) { u_offset = 2; } else if (u_N == 20) { u_offset = 8; } else if (u_N == 40) { u_offset = 16; } else { std::cout << "ERROR, UNKNOWN BX" << std::endl; std::cout << "Event: " << event << std::endl; continue; } for(int j = 0; j < e_N; j++) { //if(e_hwPt[e_offset+j] > 0) { if((((*e_hwPt)[e_offset+j])) != (((*u_hwPt)[u_offset+j]))) { std::cout << std::dec << "" << run << ":" << lumi << ":" << event << "" << std::endl; //std::cout << std::dec << (*e_hwPt)[e_offset+j] << " " << (*u_hwPt)[u_offset+j] << std::endl; misses++; break; } //} } } std::cout << "Misses: " << misses << std::endl; }
int main(int argc, char** argv) { // Input parameters std::cout << "\n*******************************************************************************************************************" << std::endl; std::cout << "arcg: " << argc << std::endl; //Check if all nedeed arguments to parse are there if(argc != 2) { std::cerr << ">>>>> Analyses::usage: " << argv[0] << " configFileName " << std::endl ; return 1; } /// Parse the config file parseConfigFile (argv[1]) ; std::string inputDir = gConfigParser -> readStringOption("Input::inputDir"); std::string outputName = gConfigParser -> readStringOption("Output::outputName"); system(("ls "+inputDir+" | grep root | awk '{print}' > inputFileAdd.dat").c_str() ); std::map<int, TFile*> Files; std::map<int, std::map<int, TH2F*> > Histos; std::map<int, TH2F* > FinalHistos; std::map<int,std::string> FileName; std::map<int,std::string> HistoName; char file[1000]; FILE *f_file; f_file = fopen("inputFileAdd.dat","r"); int file_pos = 0; int file_tot = 0; int histo_tot = 0; while(fscanf(f_file,"%s \n", file) !=EOF ){ std::string FILE = std::string(file); if(FILE.find("#") != std::string::npos) continue; std::cout << "\nReading File: " << file << std::endl; Files[file_pos] = TFile::Open((inputDir+"/"+file).c_str()); file_pos++; } file_tot = file_pos; HistoName[0] = std::string("h2_BTaggingEff_Denom_b_L"); HistoName[1] = std::string("h2_BTaggingEff_Num_b_L"); HistoName[2] = std::string("h2_BTaggingEff_Denom_b_M"); HistoName[3] = std::string("h2_BTaggingEff_Num_b_M"); HistoName[4] = std::string("h2_BTaggingEff_Denom_b_T"); HistoName[5] = std::string("h2_BTaggingEff_Num_b_T"); HistoName[6] = std::string("h2_BTaggingEff_Denom_c_L"); HistoName[7] = std::string("h2_BTaggingEff_Num_c_L"); HistoName[8] = std::string("h2_BTaggingEff_Denom_c_M"); HistoName[9] = std::string("h2_BTaggingEff_Num_c_M"); HistoName[10] = std::string("h2_BTaggingEff_Denom_c_T"); HistoName[11] = std::string("h2_BTaggingEff_Num_c_T"); HistoName[12] = std::string("h2_BTaggingEff_Denom_udsg_L"); HistoName[13] = std::string("h2_BTaggingEff_Num_udsg_L"); HistoName[14] = std::string("h2_BTaggingEff_Denom_udsg_M"); HistoName[15] = std::string("h2_BTaggingEff_Num_udsg_M"); HistoName[16] = std::string("h2_BTaggingEff_Denom_udsg_T"); HistoName[17] = std::string("h2_BTaggingEff_Num_udsg_T"); histo_tot = 18; float ptmin[21] = {20., 30., 40., 50., 60., 70., 80., 100., 120., 160., 210., 260., 320., 400., 500., 600., 800.,900.,1000.,1200.,1500.}; float etamin[8] = {0.,0.5,1.,1.5,2.,2.5,3.,3.5}; TH2F* h2_BTaggingEff_b_L = new TH2F("h2_BTaggingEff_b_L","h2_BTaggingEff_b_L",20, ptmin, 7,etamin); TH2F* h2_BTaggingEff_b_M = new TH2F("h2_BTaggingEff_b_M","h2_BTaggingEff_b_M",20, ptmin, 7,etamin); TH2F* h2_BTaggingEff_b_T = new TH2F("h2_BTaggingEff_b_T","h2_BTaggingEff_b_T",20, ptmin, 7,etamin); TH2F* h2_BTaggingEff_c_L = new TH2F("h2_BTaggingEff_c_L","h2_BTaggingEff_c_L",20, ptmin, 7,etamin); TH2F* h2_BTaggingEff_c_M = new TH2F("h2_BTaggingEff_c_M","h2_BTaggingEff_c_M",20, ptmin, 7,etamin); TH2F* h2_BTaggingEff_c_T = new TH2F("h2_BTaggingEff_c_T","h2_BTaggingEff_c_T",20, ptmin, 7,etamin); TH2F* h2_BTaggingEff_udsg_L = new TH2F("h2_BTaggingEff_udsg_L","h2_BTaggingEff_udsg_L",20, ptmin, 7,etamin); TH2F* h2_BTaggingEff_udsg_M = new TH2F("h2_BTaggingEff_udsg_M","h2_BTaggingEff_udsg_M",20, ptmin, 7,etamin); TH2F* h2_BTaggingEff_udsg_T = new TH2F("h2_BTaggingEff_udsg_T","h2_BTaggingEff_udsg_T",20, ptmin, 7,etamin); if (file_tot == 0 ) { std::cout << "Error: give at least one file!" << std::endl; return -1; } for(int ii = 0; ii < file_tot; ii++) for(int jj = 0; jj < histo_tot; jj++) Histos[ii][jj] = (TH2F*)Files[ii]->Get(HistoName[jj].c_str()); for(int jj = 0; jj < histo_tot; jj++){ FinalHistos[jj] = (TH2F*)Histos[0][jj]->Clone((HistoName[jj]).c_str()); //FinalHistos[jj]->Sumw2(); for(int ii = 1; ii < file_tot; ii++) FinalHistos[jj]->Add(Histos[ii][jj]); } h2_BTaggingEff_b_L->Divide(FinalHistos[1],FinalHistos[0],1,1,"B"); h2_BTaggingEff_b_M->Divide(FinalHistos[3],FinalHistos[2],1,1,"B"); h2_BTaggingEff_b_T->Divide(FinalHistos[5],FinalHistos[4],1,1,"B"); h2_BTaggingEff_c_L->Divide(FinalHistos[7],FinalHistos[6],1,1,"B"); h2_BTaggingEff_c_M->Divide(FinalHistos[9],FinalHistos[8],1,1,"B"); h2_BTaggingEff_c_T->Divide(FinalHistos[11],FinalHistos[10],1,1,"B"); h2_BTaggingEff_udsg_L->Divide(FinalHistos[13],FinalHistos[12],1,1,"B"); h2_BTaggingEff_udsg_M->Divide(FinalHistos[15],FinalHistos[14],1,1,"B"); h2_BTaggingEff_udsg_T->Divide(FinalHistos[17],FinalHistos[16],1,1,"B"); TFile* outputFile = new TFile((outputName).c_str(), "RECREATE"); outputFile->cd(); for(int ii = 0; ii < histo_tot; ii++) FinalHistos[ii]->Write(); h2_BTaggingEff_b_L->Write(); h2_BTaggingEff_b_M->Write(); h2_BTaggingEff_b_T->Write(); h2_BTaggingEff_c_L->Write(); h2_BTaggingEff_c_M->Write(); h2_BTaggingEff_c_T->Write(); h2_BTaggingEff_udsg_L->Write(); h2_BTaggingEff_udsg_M->Write(); h2_BTaggingEff_udsg_T->Write(); outputFile->Close(); system("rm inputFileAdd.dat"); }
void Wpt_ZmassCompEtaBins_Gaus(const TString Mode,//Channel - Muon or Electron const TString corrName, const TString outputDir ) { TString plotTitle; TString mu_etaRange[6]; mu_etaRange[0] = "-2.1 #geq eta < -1.4"; mu_etaRange[1] = "-1.4 #geq eta < -0.7"; mu_etaRange[2] = "-0.7 #geq eta < 0"; mu_etaRange[3] = "0 #geq eta < 0.7"; mu_etaRange[4] = "0.7 #geq eta < 1.4"; mu_etaRange[5] = "1.4 #geq eta < 2.1"; TH1D* makeDiffHist(TH1D* h1, TH1D* h2, const TString name); const TString format("png"); Int_t ratioColor = kGray+2; TFile *fname_MC; TFile *fname_RD; gSystem->mkdir(outputDir,kTRUE); CPlot::sOutDir = outputDir; fname_MC = new TFile("Muon2012LoPU/Muon_DYToMuMu_S8.root"); fname_RD = new TFile("Muon2012LoPU/Muon_RD_LowPU.root"); if(Mode=="Electron") { fname_MC = new TFile("Electron2012LoPU/Ele_DYToEE_S8.root"); fname_RD = new TFile("Electron2012LoPU/Ele_RD_LowPU.root"); } CPlot *plotMllEtaBinP; CPlot *plotMllEtaBinM; CPlot *plotMllEtameanP; CPlot *plotMllEtameanM; CPlot *plotMllEtawidthP; CPlot *plotMllEtawidthM; TH1D *hMCetaBinP[ScaleBins]; TH1D *hRDetaBinP[ScaleBins]; TH1D *hMCetaBinM[ScaleBins]; TH1D *hRDetaBinM[ScaleBins]; RooDataHist *h1_MCetaBinP; RooDataHist *h1_RDetaBinP; RooDataHist *h1_MCetaBinM; RooDataHist *h1_RDetaBinM; TH1D *hMCmeanp = new TH1D("hMCmeanp","hMCmeanp",ScaleBins,-2.1,2.1);hMCmeanp->Sumw2(); TH1D *hRDmeanp = new TH1D("hRDmeanp","hRDmeanp",ScaleBins,-2.1,2.1);hRDmeanp->Sumw2(); TH1D *hMCmeanm = new TH1D("hMCmeanm","hMCmeanm",ScaleBins,-2.1,2.1);hMCmeanm->Sumw2(); TH1D *hRDmeanm = new TH1D("hRDmeanm","hRDmeanm",ScaleBins,-2.1,2.1);hRDmeanm->Sumw2(); TH1D *hMCwidthp = new TH1D("hMCwidthp","hMCwidthp",ScaleBins,-2.1,2.1);hMCwidthp->Sumw2(); TH1D *hRDwidthp = new TH1D("hRDwidthp","hRDwidthp",ScaleBins,-2.1,2.1);hRDwidthp->Sumw2(); TH1D *hMCwidthm = new TH1D("hMCwidthm","hMCwidthm",ScaleBins,-2.1,2.1);hMCwidthm->Sumw2(); TH1D *hRDwidthm = new TH1D("hRDwidthm","hRDwidthm",ScaleBins,-2.1,2.1);hRDwidthm->Sumw2(); char histName[50]; char tmpName[50]; TCanvas *myCan; myCan = MakeCanvas("myCan","myCan",800,600); myCan->SetPad(0,0,1.0,1.0); myCan->SetTopMargin(0.11); myCan->SetBottomMargin(0.15); myCan->SetLeftMargin(0.15); myCan->SetRightMargin(0.05); myCan->SetTickx(1); myCan->SetTicky(1); //============================= //Read Zmass histograms for each pt bin //============================= for(int i(0);i<ScaleBins;i++){ sprintf(tmpName,"h1_Zmass_muEtaP_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_muEtaP_%d",i); if(outputDir=="Wpt_ZmassPlotsEtaBins_noOverLap_Gaus") { sprintf(tmpName,"h1_Zmass_noOverLap_muEtaP_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_noOverLap_muEtaP_%d",i); } if(outputDir=="Wpt_ZmassPlotsEtaBins_LeadingLept_noOverLap_Gaus") { sprintf(tmpName,"h1_Zmass_LeadingLept_noOverLap_muEtaP_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_LeadingLept_noOverLap_muEtaP_%d",i); } if(outputDir=="Wpt_ZmassPlotsEtaBins_LeadingLept_Gaus") { sprintf(tmpName,"h1_Zmass_LeadingLept_muEtaP_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_LeadingLept_muEtaP_%d",i); } if(outputDir=="Wpt_ZmassPlotsEtaBins_TrailingLept_noOverLap_Gaus") { sprintf(tmpName,"h1_Zmass_TrailingLept_noOverLap_muEtaP_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_TrailingLept_noOverLap_muEtaP_%d",i); } if(outputDir=="Wpt_ZmassPlotsEtaBins_TrailingLept_Gaus") { sprintf(tmpName,"h1_Zmass_TrailingLept_muEtaP_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_TrailingLept_muEtaP_%d",i); } sprintf(histName,"hMCetaBinP_%d",i); hMCetaBinP[i]= (TH1D*)fname_MC->Get(tmpName)->Clone(histName); hMCetaBinP[i]->Sumw2(); sprintf(histName,"hRDetaBinP_%d",i); hRDetaBinP[i]= (TH1D*)fname_RD->Get(tmpName)->Clone(histName); hRDetaBinP[i]->Sumw2(); sprintf(tmpName,"h1_Zmass_muEtaM_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_muEtaM_%d",i); if(outputDir=="Wpt_ZmassPlotsEtaBins_noOverLap_Gaus") { sprintf(tmpName,"h1_Zmass_noOverLap_muEtaM_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_noOverLap_muEtaM_%d",i); } if(outputDir=="Wpt_ZmassPlotsEtaBins_LeadingLept_noOverLap_Gaus") { sprintf(tmpName,"h1_Zmass_LeadingLept_noOverLap_muEtaM_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_LeadingLept_noOverLap_muEtaM_%d",i); } if(outputDir=="Wpt_ZmassPlotsEtaBins_LeadingLept_Gaus") { sprintf(tmpName,"h1_Zmass_LeadingLept_muEtaM_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_LeadingLept_muEtaM_%d",i); } if(outputDir=="Wpt_ZmassPlotsEtaBins_TrailingLept_noOverLap_Gaus") { sprintf(tmpName,"h1_Zmass_TrailingLept_noOverLap_muEtaM_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_TrailingLept_noOverLap_muEtaM_%d",i); } if(outputDir=="Wpt_ZmassPlotsEtaBins_TrailingLept_Gaus") { sprintf(tmpName,"h1_Zmass_TrailingLept_muEtaM_%d",i); if(corrName=="CorrTotalRegion") sprintf(tmpName,"h1_ZmassCorr_TrailingLept_muEtaM_%d",i); } sprintf(histName,"hMCetaBinM_%d",i); hMCetaBinM[i]= (TH1D*)fname_MC->Get(tmpName)->Clone(histName); hMCetaBinM[i]->Sumw2(); sprintf(histName,"hRDetaBinM_%d",i); hRDetaBinM[i]= (TH1D*)fname_RD->Get(tmpName)->Clone(histName); hRDetaBinM[i]->Sumw2(); hMCetaBinP[i] -> SetMarkerSize(0.9); hMCetaBinP[i] -> SetMarkerColor(kRed); hMCetaBinP[i] -> SetLineColor(kRed); hRDetaBinP[i] -> SetMarkerSize(0.9); hRDetaBinP[i] -> SetMarkerColor(kBlack); hRDetaBinP[i] -> SetLineColor(kBlack); hMCetaBinM[i] -> SetMarkerSize(0.9); hMCetaBinM[i] -> SetMarkerColor(kRed); hMCetaBinM[i] -> SetLineColor(kRed); hRDetaBinM[i] -> SetMarkerSize(0.9); hRDetaBinM[i] -> SetMarkerColor(kBlack); hRDetaBinM[i] -> SetLineColor(kBlack); RooRealVar x("x", "x",80,100); x.setBins(40); x.setRange("R0",86,96); h1_MCetaBinP = new RooDataHist("h1_MCetaBinP","h1_MCetaBinP",RooArgSet(x),hMCetaBinP[i]); h1_MCetaBinM = new RooDataHist("h1_MCetaBinM","h1_MCetaBinM",RooArgSet(x),hMCetaBinM[i]); h1_RDetaBinP = new RooDataHist("h1_RDetaBinP","h1_RDetaBinP",RooArgSet(x),hRDetaBinP[i]); h1_RDetaBinM = new RooDataHist("h1_RDetaBinM","h1_RDetaBinM",RooArgSet(x),hRDetaBinM[i]); //============================= //Gauss function //============================= RooRealVar meanMCp("meanMCp","",91.2,80,100); RooRealVar meanRDp("meanRDp","",91.2,80,100); RooRealVar meanMCm("meanMCm","",91.2,80,100); RooRealVar meanRDm("meanRDm","",91.2,80,100); RooRealVar sigmaMCp("sigmaMCp","",5,-50.,50.); RooRealVar sigmaRDp("sigmaRDp","",5,-50.,50.); RooRealVar sigmaMCm("sigmaMCm","",5,-50.,50.); RooRealVar sigmaRDm("sigmaRDm","",5,-50.,50.); RooGaussian mcModelp("mcModelp", "",x,meanMCp,sigmaMCp); RooGaussian mcModelm("mcModelm", "",x,meanMCm,sigmaMCm); RooGaussian dataModelp("dataModelp", "",x,meanRDp,sigmaRDp); RooGaussian dataModelm("dataModelm", "",x,meanRDm,sigmaRDm); //================================== //Fit Zmass distribution with Gaussian function //============================= mcModelp.fitTo(*h1_MCetaBinP,Range("R0")); mcModelm.fitTo(*h1_MCetaBinM,Range("R0")); dataModelp.fitTo(*h1_RDetaBinP,Range("R0")); dataModelm.fitTo(*h1_RDetaBinM,Range("R0")); //================================== //Fill 2D plots: etaBins and mean values //============================= hMCmeanp->SetBinContent(i+1,meanMCp.getVal()); hRDmeanp->SetBinContent(i+1,meanRDp.getVal()); hMCmeanm->SetBinContent(i+1,meanMCm.getVal()); hRDmeanm->SetBinContent(i+1,meanRDm.getVal()); hMCmeanp->SetBinError(i+1,meanMCp.getError()); hRDmeanp->SetBinError(i+1,meanRDp.getError()); hMCmeanm->SetBinError(i+1,meanMCm.getError()); hRDmeanm->SetBinError(i+1,meanRDm.getError()); hMCwidthp->SetBinContent(i+1,sigmaMCp.getVal()); hRDwidthp->SetBinContent(i+1,sigmaRDp.getVal()); hMCwidthm->SetBinContent(i+1,sigmaMCm.getVal()); hRDwidthm->SetBinContent(i+1,sigmaRDm.getVal()); hMCwidthp->SetBinError(i+1,sigmaMCp.getError()); hRDwidthp->SetBinError(i+1,sigmaRDp.getError()); hMCwidthm->SetBinError(i+1,sigmaMCm.getError()); hRDwidthm->SetBinError(i+1,sigmaRDm.getError()); cout<<meanMCp.getVal()<<"\t"<<meanMCm.getVal()<<"\t"<<meanRDp.getVal()<<"\t"<<meanRDm.getVal()<<endl; RooPlot* pframe = x.frame(Bins(40)); RooPlot* mframe = x.frame(Bins(40)); //================================== //Draw muon plus //================================== sprintf(tmpName,"pFit_etaBin%d_noCorr",i); plotTitle = "Wpt: " + mu_etaRange[i] + " of #mu^{+}, before correction"; if(corrName=="CorrTotalRegion") { sprintf(tmpName,"pFit_etaBin%d_Corr",i); plotTitle = "Wpt: " + mu_etaRange[i] + " of #mu^{+}, after correction"; } sprintf(histName,"Events / %.1f",hMCetaBinP[i]->GetBinWidth(1)); plotMllEtaBinP = new CPlot(tmpName,pframe,plotTitle,"M_{#mu#mu} [GeV]",histName); plotMllEtaBinP->setOutDir(CPlot::sOutDir); plotMllEtaBinP->SetLegend(0.7,0.7,0.88,0.82); h1_MCetaBinP->plotOn(pframe,LineColor(kRed),MarkerColor(kRed),MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP"),DataError(RooAbsData::SumW2)); mcModelp.plotOn(pframe,LineColor(kRed)); h1_RDetaBinP->plotOn(pframe,LineColor(kBlack),MarkerColor(kBlack),MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP"),DataError(RooAbsData::SumW2)); dataModelp.plotOn(pframe,LineColor(kBlack)); plotMllEtaBinP->GetLegend()->AddEntry(hMCetaBinP[i],"Z #rightarrow #mu#mu","pl"); plotMllEtaBinP->GetLegend()->AddEntry(hRDetaBinP[i],"Data","pl"); sprintf(tmpName,"MC: #mu=%.2f #pm %.2f, #sigma=%.2f #pm %.2f",meanMCp.getVal(),meanMCp.getError(),sigmaMCp.getVal(),sigmaMCp.getError()); plotMllEtaBinP->AddTextBox(tmpName,0.20,0.83,0.6,0.88,0); sprintf(tmpName,"Data: #mu=%.2f #pm %.2f, #sigma=%.2f #pm %.2f",meanRDp.getVal(),meanRDp.getError(),sigmaRDp.getVal(),sigmaRDp.getError()); plotMllEtaBinP->AddTextBox(tmpName,0.20,0.78,0.6,0.83,0); plotMllEtaBinP->SetYRange(0.,1.4*TMath::Max(hRDetaBinP[i]->GetMaximum(),hMCetaBinP[i]->GetMaximum())); plotMllEtaBinP->Draw(myCan,kTRUE,"png"); //================================== //Draw muon minus //============================= sprintf(tmpName,"mFit_etaBin%d_noCorr",i); plotTitle = "Wpt: " + mu_etaRange[i] + " of #mu^{-}, before correction"; if(corrName=="CorrTotalRegion") { sprintf(tmpName,"mFit_etaBin%d_Corr",i); plotTitle = "Wpt: " + mu_etaRange[i] + " of #mu^{-}, after correction"; } sprintf(histName,"Events / %.1f",hMCetaBinM[i]->GetBinWidth(1)); plotMllEtaBinM = new CPlot(tmpName,mframe,plotTitle,"M_{#mu#mu} [GeV]",histName); plotMllEtaBinM->setOutDir(CPlot::sOutDir); plotMllEtaBinM->SetLegend(0.7,0.7,0.88,0.82); h1_MCetaBinM->plotOn(mframe,LineColor(kRed),MarkerColor(kRed),MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP"),DataError(RooAbsData::SumW2)); mcModelm.plotOn(mframe,LineColor(kRed)); h1_RDetaBinM->plotOn(mframe,LineColor(kBlack),MarkerColor(kBlack),MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP"),DataError(RooAbsData::SumW2)); dataModelm.plotOn(mframe,LineColor(kBlack)); plotMllEtaBinM->GetLegend()->AddEntry(hMCetaBinM[i],"Z #rightarrow #mu#mu","pl"); plotMllEtaBinM->GetLegend()->AddEntry(hRDetaBinM[i],"Data","pl"); sprintf(tmpName,"MC: #mu=%.2f #pm %.2f, #sigma=%.2f #pm %.2f",meanMCm.getVal(),meanMCm.getError(),sigmaMCm.getVal(),sigmaMCm.getError()); plotMllEtaBinM->AddTextBox(tmpName,0.20,0.83,0.6,0.88,0); sprintf(tmpName,"Data: #mu=%.2f #pm %.2f, #sigma=%.2f #pm %.2f",meanRDm.getVal(),meanRDm.getError(),sigmaRDm.getVal(),sigmaRDm.getError()); plotMllEtaBinM->AddTextBox(tmpName,0.20,0.78,0.6,0.83,0); plotMllEtaBinM->SetYRange(0.,1.4*TMath::Max(hRDetaBinM[i]->GetMaximum(),hMCetaBinM[i]->GetMaximum())); plotMllEtaBinM->Draw(myCan,kTRUE,"png"); } //================================== //Save Mean and Width histograms to root file //================================== TString filename = outputDir + "/Wpt_MeanWidth_Gaus_" + corrName + ".root"; TFile *outfile = new TFile(filename,"RECREATE"); hMCmeanp ->Write(); hMCmeanm ->Write(); hMCwidthp->Write(); hMCwidthm->Write(); hRDmeanp ->Write(); hRDmeanm ->Write(); hRDwidthp->Write(); hRDwidthm->Write(); outfile->Close(); //================================== //Draw 2D plots //================================== TString histoName = "plusMean_" + corrName; plotTitle = "Wpt: mean at #eta of #mu^{+}, before correction"; if(corrName=="CorrTotalRegion") plotTitle = "Wpt: mean at #eta of #mu^{+}, after correction"; plotMllEtameanP= new CPlot(histoName,plotTitle,"#eta of #mu^{+}","Mean of M(#mu^{+}#mu^{-})"); plotMllEtameanP->setOutDir(CPlot::sOutDir); plotMllEtameanP->AddHist1D(hMCmeanp,"Z#rightarrow #mu#mu","E1",kRed); plotMllEtameanP->AddHist1D(hRDmeanp,"Data","E1",kBlack); plotMllEtameanP->SetLegend(0.7,0.7,0.88,0.82); plotMllEtameanP->SetYRange(90,92); plotMllEtameanP->Draw(myCan,kTRUE,format); histoName = "minusMean_" + corrName; plotTitle = "Wpt: mean at #eta of #mu^{-}, before correction"; if(corrName=="CorrTotalRegion") plotTitle = "Wpt: mean at #eta of #mu^{-}, after correction"; plotMllEtameanM= new CPlot(histoName,plotTitle,"#eta of #mu^{-}","Mean of M(#mu^{+}#mu^{-})"); plotMllEtameanM->setOutDir(CPlot::sOutDir); plotMllEtameanM->AddHist1D(hMCmeanm,"Z#rightarrow #mu#mu","E1",kRed); plotMllEtameanM->AddHist1D(hRDmeanm,"Data","E1",kBlack); plotMllEtameanM->SetLegend(0.7,0.7,0.88,0.82); plotMllEtameanM->SetYRange(90,92); plotMllEtameanM->Draw(myCan,kTRUE,format); histoName = "plusWidth_" + corrName; plotTitle = "Wpt: width at #eta of #mu^{+}, before correction"; if(corrName=="CorrTotalRegion") plotTitle = "Wpt: width at #eta of #mu^{+}, after correction"; plotMllEtawidthP= new CPlot(histoName,plotTitle,"#eta of #mu^{+}","Width of M(#mu^{+}#mu^{-})"); plotMllEtawidthP->setOutDir(CPlot::sOutDir); plotMllEtawidthP->AddHist1D(hMCwidthp,"Z#rightarrow #mu#mu","E1",kRed); plotMllEtawidthP->AddHist1D(hRDwidthp,"Data","E1",kBlack); plotMllEtawidthP->SetLegend(0.7,0.7,0.88,0.82); plotMllEtawidthP->SetYRange(1.5,3); plotMllEtawidthP->Draw(myCan,kTRUE,format); histoName = "minusWidth_" + corrName; plotTitle = "Wpt: width at #eta of #mu^{-}, before correction"; if(corrName=="CorrTotalRegion") plotTitle = "Wpt: width at #eta of #mu^{-}, after correction"; plotMllEtawidthM= new CPlot(histoName,plotTitle,"#eta of #mu^{-}","Width of M(#mu^{+}#mu^{-})"); plotMllEtawidthM->setOutDir(CPlot::sOutDir); plotMllEtawidthM->AddHist1D(hMCwidthm,"Z#rightarrow #mu#mu","E1",kRed); plotMllEtawidthM->AddHist1D(hRDwidthm,"Data","E1",kBlack); plotMllEtawidthM->SetLegend(0.7,0.7,0.88,0.82); plotMllEtawidthM->SetYRange(1.5,3); plotMllEtawidthM->Draw(myCan,kTRUE,format); }
void comp_RpPb_rap_Overlay(bool isPoint=true, bool isSmoothened=false) { gROOT->Macro("./tdrstyle_kyo.C"); int isPA = 10; // 0:pp, 1:pPb, 10 : pp & pPb together for RpPb plot int iPos=33; bool isPrompt=true; const Double_t pp_lumi_relerr = 0.023; // 2.3 % const Double_t pPb_lumi_relerr = 0.035; // 3.5 % const Double_t glb_err = TMath::Sqrt(pp_lumi_relerr*pp_lumi_relerr+pPb_lumi_relerr*pPb_lumi_relerr); //cout << "glb_err = " << glb_err << endl; /////////////////////////////////////////////////// const int nRap = 8; const int nRapTmp = nRap + 1; const int nRapRpPb = 7; const int nRapRpPbTheory = 6; //Ramona.. //const int nPtRpPb = 49; const int nPtRpPb = 2; Double_t theory_px[nPtRpPb][nRapRpPbTheory]; Double_t theory_py[nPtRpPb][nRapRpPbTheory]; //Double_t theory_exlow_tmp[nPtRpPb][nRapRpPbTheory]; //Double_t theory_exhigh_tmp[nPtRpPb][nRapRpPbTheory]; Double_t theory_exlow[nPtRpPb][nRapRpPbTheory]; Double_t theory_exhigh[nPtRpPb][nRapRpPbTheory]; Double_t theory_eylow_tmp[nPtRpPb][nRapRpPbTheory]; Double_t theory_eyhigh_tmp[nPtRpPb][nRapRpPbTheory]; Double_t theory_eylow[nPtRpPb][nRapRpPbTheory]; Double_t theory_eyhigh[nPtRpPb][nRapRpPbTheory]; //// 1) y_CM array (from forward to backward) Double_t rapArrNumFB[nRapTmp] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93, -2.4, -2.87};// for pt dist. //Double_t rapArrNumBF[nRapTmp] = {-2.87, -2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist. //// array string TString rapArr[nRap]; for (Int_t iy=0; iy<nRap; iy++) { formRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapArr[iy]); cout << iy <<"th rapArr = " << rapArr[iy] << endl; } /////////////////////////////////////////////////// //////// experimental points TFile *inFile = new TFile("../DrawFinalPlot/plot_RpPb/RpPb_rap_isPrompt1.root"); TGraphAsymmErrors* g_RpPb_sys[nRapRpPb]; TGraphAsymmErrors* g_RpPb_sys_line[nRapRpPb]; TGraphAsymmErrors* g_RpPb[nRapRpPb]; g_RpPb_sys[0] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_sys_lowpt"); g_RpPb_sys_line[0] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_sys_lowpt_line"); g_RpPb[0] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_lowpt"); g_RpPb_sys[1] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_sys_highpt"); g_RpPb_sys_line[1] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_sys_highpt_line"); g_RpPb[1] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_highpt"); g_RpPb_sys[0]->SetName("g_RpPb_sys_lowpt"); g_RpPb_sys_line[0]->SetName("g_RpPb_sys_lowpt_line"); g_RpPb_sys[1]->SetName("g_RpPb_sys_highpt"); g_RpPb_sys_line[1]->SetName("g_RpPb_sys_highpt_line"); //g_RpPb_sys[0]->SetFillColorAlpha(kRed-10,0.5); //g_RpPb_sys_line[0]->SetFillColorAlpha(kRed-10,0.); //g_RpPb_sys_line[0]->SetLineColor(kPink-6); //g_RpPb_sys[1]->SetFillColorAlpha(kGreen-10,0.5); //g_RpPb_sys_line[1]->SetFillColorAlpha(kGreen-10,0.); //g_RpPb_sys_line[1]->SetLineColor(kGreen+3); g_RpPb_sys_line[0]->SetFillColorAlpha(kRed-10,0.); g_RpPb_sys_line[1]->SetFillColorAlpha(kRed-10,0.); for (int ipt = 0 ; ipt < nPtRpPb; ipt ++ ) { if (isPoint) { g_RpPb_sys[ipt]->SetFillColorAlpha(kRed-10,0.5); g_RpPb_sys[ipt]->SetLineColor(kPink-6); } else { g_RpPb_sys[ipt]->SetFillColor(kWhite); g_RpPb_sys[ipt]->SetLineColor(kWhite); } g_RpPb[ipt]->SetMarkerColor(kPink-6); g_RpPb[ipt]->SetLineColor(kPink-6); g_RpPb[ipt]->SetMarkerStyle(kFullCircle); g_RpPb[ipt]->SetMarkerSize(1.4); } /////////////////////////////////////////////////// //////// theory curves // const int nTheory = 4; const int nTheory = 3; TFile *inFileTh[nTheory]; inFileTh[0]= new TFile("./plot_theory/comp_RpPb_rap_isSmoothened0_Vogt.root","READ"); inFileTh[1]= new TFile("./plot_theory/comp_RpPb_rap_isSmoothened0_Lansberg_EPS09NLO.root","READ"); inFileTh[2]= new TFile("./plot_theory/comp_RpPb_rap_isSmoothened0_Lansberg_nCTEQ15.root","READ"); TGraphAsymmErrors* g_RpPb_theory[nTheory][nPtRpPb]; TGraphAsymmErrors* g_RpPb_theory_line[nTheory][nPtRpPb]; for (int ith = 0 ; ith < nTheory; ith ++ ) { for (int ipt = 0 ; ipt < nPtRpPb; ipt ++ ) { g_RpPb_theory[ith][ipt] = (TGraphAsymmErrors*)inFileTh[ith]->Get(Form("g_RpPb_theory_%d",ipt)); g_RpPb_theory[ith][ipt]->SetName(Form("g_RpPb_theory_%d_%d",ith,ipt)); g_RpPb_theory_line[ith][ipt] = (TGraphAsymmErrors*)inFileTh[ith]->Get(Form("g_RpPb_theory_%d",ipt)); g_RpPb_theory_line[ith][ipt]->SetName(Form("g_RpPb_theory_line_%d_%d",ith,ipt)); } } //// color for (int ipt = 0 ; ipt < nPtRpPb; ipt ++ ) { g_RpPb_theory[0][ipt]->SetFillColorAlpha(kAzure+1,0.5); g_RpPb_theory[0][ipt]->SetLineColor(kAzure+1); g_RpPb_theory[0][ipt]->SetFillStyle(1001); g_RpPb_theory_line[0][ipt]->SetFillColorAlpha(kAzure+5,0.0); g_RpPb_theory_line[0][ipt]->SetLineColor(kAzure+5); g_RpPb_theory_line[0][ipt]->SetFillStyle(1001); g_RpPb_theory[1][ipt]->SetFillColor(kOrange+2); g_RpPb_theory[1][ipt]->SetLineColor(kOrange+2); g_RpPb_theory[1][ipt]->SetFillStyle(3345); //g_RpPb_theory[1][ipt]->SetFillStyle(3004); g_RpPb_theory_line[1][ipt]->SetFillColorAlpha(kOrange+2,0.); g_RpPb_theory_line[1][ipt]->SetLineColor(kOrange+2); g_RpPb_theory_line[1][ipt]->SetFillStyle(1001); g_RpPb_theory[2][ipt]->SetFillColor(kGreen+2); g_RpPb_theory[2][ipt]->SetLineColor(kGreen+2); g_RpPb_theory[2][ipt]->SetFillStyle(3454); //g_RpPb_theory[2][ipt]->SetFillStyle(3005); g_RpPb_theory_line[2][ipt]->SetFillColorAlpha(kGreen+2,0.); g_RpPb_theory_line[2][ipt]->SetLineColor(kGreen+2); g_RpPb_theory_line[2][ipt]->SetFillStyle(1001); } /////////////////////////////////////////////////// //// Draw /////////////////////////////////////////////////// //TLegend *legBL1 = new TLegend(0.195, 0.168, 0.38, 0.333); TLegend *legBL1 = new TLegend(0.195, 0.168, 0.38, 0.388); SetLegendStyle(legBL1); //legBL1->SetTextSize(0.05); legBL1->SetTextSize(0.037); TLatex* globtex = new TLatex(); globtex->SetNDC(); globtex->SetTextAlign(12); //1:left, 2:vertical center //globtex->SetTextAlign(32); //3:right 2:vertical center globtex->SetTextFont(42); globtex->SetTextSize(0.075); //// global uncertainty from lumi TBox * globbox_pp = new TBox(-3.0, 1-pp_lumi_relerr, -2.8, 1+pp_lumi_relerr); globbox_pp->SetFillColorAlpha(kGray+2,0.5); globbox_pp->SetLineColor(kBlack); TBox * globbox_pa = new TBox(-2.8, 1-pPb_lumi_relerr, -2.6, 1+pPb_lumi_relerr); globbox_pa->SetFillColorAlpha(kWhite,0.5); globbox_pa->SetLineColor(kBlack); TBox * globbox_all = new TBox(-2.7, 1-glb_err, -2.5, 1+glb_err); globbox_all->SetFillColorAlpha(kGray+2,0.5); globbox_all->SetLineColor(kBlack); TCanvas* c1 = new TCanvas("c1","c1",600,600); c1->cd(); g_RpPb_sys[0]->Draw("A5"); for (int ith = 0 ; ith < nTheory; ith ++ ) { if (ith==0){ g_RpPb_theory[ith][0]->Draw("5"); g_RpPb_theory_line[ith][0]->Draw("5"); } } // if (isPoint) { g_RpPb_sys[0]->Draw("5"); } globbox_all->Draw("lf"); solidLine(-2.7,1.,2.1,1.,1,1); for (int ith = 0 ; ith < nTheory; ith ++ ) { if (ith!=0){ g_RpPb_theory[ith][0]->Draw("5"); } g_RpPb_theory_line[ith][0]->Draw("5"); } if (isPoint) { g_RpPb_sys_line[0]->Draw("5"); g_RpPb[0]->Draw("p"); } globtex->SetTextAlign(12); globtex->SetTextSize(0.045); globtex->SetTextFont(42); globtex->DrawLatex(0.21, 0.84, "6.5 < p_{T} < 10 GeV/c"); TLegendEntry *ent_data=legBL1->AddEntry("ent_data"," Data","pf"); ent_data->SetFillColorAlpha(kRed-10,0.5); ent_data->SetLineColor(kPink-6); ent_data->SetMarkerColor(kPink-6); ent_data->SetMarkerStyle(kFullCircle); ent_data->SetLineWidth(1); // ent_data->SetMarkerSize(1.9); ent_data->SetFillStyle(1001); TLegendEntry *ent1_thr=legBL1->AddEntry("ent1_thr"," EPS09 NLO (Vogt)","f"); ent1_thr->SetFillColorAlpha(kAzure+1,0.5); ent1_thr->SetLineColor(kAzure+5); ent1_thr->SetFillStyle(1001); TLegendEntry *ent2_thr=legBL1->AddEntry("ent2_thr"," EPS09 NLO (Lansberg-Shao)","f"); ent2_thr->SetFillColor(kOrange+2); ent2_thr->SetLineColor(kOrange+2); ent2_thr->SetFillStyle(3345); TLegendEntry *ent3_thr=legBL1->AddEntry("ent3_thr"," nCTEQ15 NLO (Lansberg-Shao)","f"); ent3_thr->SetFillColor(kGreen+2); ent3_thr->SetLineColor(kGreen+2); ent3_thr->SetFillStyle(3454); // TLegendEntry *ent5_thr=legBL1->AddEntry("ent5_thr","(Lansberg-Shao)","f"); // ent5_thr->SetFillColor(kWhite); // ent5_thr->SetLineColor(kWhite); // ent5_thr->SetFillStyle(1001); legBL1->Draw(); globtex->SetTextAlign(32); //3:right 2:vertical center globtex->SetTextSize(0.048); globtex->SetTextFont(42); if (isPrompt) globtex->DrawLatex(0.92, 0.77, "Prompt J/#psi"); else globtex->DrawLatex(0.92, 0.77, "Non-prompt J/#psi"); CMS_lumi( c1, isPA, iPos ); c1->SaveAs(Form("plot_theory/comp_RpPb_rap_pt1_isSmoothened%d_Overlay.pdf",(int)isSmoothened)); c1->SaveAs(Form("plot_theory/comp_RpPb_rap_pt1_isSmoothened%d_Overlay.png",(int)isSmoothened)); TCanvas* c2 = new TCanvas("c2","c2",600,600); c2->cd(); g_RpPb_sys[1]->Draw("A5"); for (int ith = 0 ; ith < nTheory; ith ++ ) { if (ith==0){ g_RpPb_theory[ith][1]->Draw("5"); g_RpPb_theory_line[ith][1]->Draw("5"); } } // if (isPoint) { g_RpPb_sys[1]->Draw("5"); } globbox_all->Draw("lf"); solidLine(-2.7,1.,2.1,1.,1,1); for (int ith = 0 ; ith < nTheory; ith ++ ) { if (ith!=0){ g_RpPb_theory[ith][1]->Draw("5"); } g_RpPb_theory_line[ith][1]->Draw("5"); } if (isPoint) { g_RpPb_sys_line[1]->Draw("5"); g_RpPb[1]->Draw("p"); } globtex->SetTextAlign(12); globtex->SetTextSize(0.045); globtex->SetTextFont(42); globtex->DrawLatex(0.21, 0.84, "10 < p_{T} < 30 GeV/c"); legBL1->Draw(); globtex->SetTextAlign(32); //3:right 2:vertical center globtex->SetTextSize(0.048); globtex->SetTextFont(42); if (isPrompt) globtex->DrawLatex(0.92, 0.77, "Prompt J/#psi"); else globtex->DrawLatex(0.92, 0.77, "Non-prompt J/#psi"); CMS_lumi( c2, isPA, iPos ); c2->SaveAs(Form("plot_theory/comp_RpPb_rap_pt2_isSmoothened%d_Overlay.pdf",(int)isSmoothened)); c2->SaveAs(Form("plot_theory/comp_RpPb_rap_pt2_isSmoothened%d_Overlay.png",(int)isSmoothened)); /////////////////////////////////////////////////////////////////// // save as a root file // TFile* outFile = new TFile(Form("plot_theory/comp_RpPb_rap_isSmoothened%d_Overlay.root",(int)isSmoothened),"RECREATE"); // outFile->cd(); // for (int ipt = 0 ; ipt < nPtRpPb; ipt ++ ) { // g_RpPb_theory[ipt]->Write(); // } return; }
//// runCode // 0=merged, 1=1stRun, 2=2ndRun void draw_1D_RFB_ETHF_tworange(char* dirName = "6rap3pt", int runCode=0, bool isPrompt=false) { gROOT->Macro("./tdrstyle_kyo.C"); gStyle->SetTitleSize(0.046, "XYZ"); gStyle->SetEndErrorSize(0); gStyle->SetOptTitle(0); gStyle->SetPadTopMargin(0.075); gStyle->SetPadBottomMargin(0.13); //KYO gStyle->SetPadLeftMargin(0.13); //KYO gStyle->SetPadRightMargin(0.075); gStyle->SetTitleXOffset(1.15); gStyle->SetTitleYOffset(1.22); writeExtraText = true; extraText = "Preliminary"; lumi_502TeV = "34.6 nb^{-1}"; int iPeriod = 0; int iPos=0; //double pxshift = 0.5; double pxshift = 1.; // set info. const Double_t br = 0.0593 ; const Double_t brErr = 0.0006; Double_t lumi_nb; Double_t lumi_nb_err; Double_t lumi_mub; Double_t lumi_mub_err; string runstring; string lumistring; string cmsstring = "CMS preliminary"; string beamstring = "pPb #sqrt{s_{NN}} = 5.02 TeV"; if (runCode ==0) { runstring = "All"; lumi_nb =34.622; lumi_nb_err=1.2; } else if (runCode == 1) { runstring = "Pbp"; //1stRun lumi_nb =20.7; lumi_nb_err=0.7; } else if (runCode == 2) { runstring = "pPb"; //2ndRun lumi_nb = 14.0; lumi_nb_err=0.5; } else { cout << " *** Error!!! choose runCode 0, 1, or 2 " << endl; return ; } lumistring = Form("L_{int} = %.1f nb^{ -1}", lumi_nb); lumi_mub = lumi_nb * 1000; // (nb)^{-1} -> {#mub}^{-1} lumi_mub_err = lumi_nb_err * 1000; // (nb)^{-1} -> {#mub}^{-1} ///////////////////////////////////////////////////////////////////////// // bin center & systematic uncertainties by hand //inh=0 : pT 5-6.5, rap 1.5-1.93 //inh=1 : pT 6.5-30, rap 1.5-1.93 //inh=2 : pT 6.5-30, rap 0.9-1.5 //inh=3 : pT 6.5-30, rap 0.0-0.9 const int nRap = 6; const int nRapTmp = nRap+1; const int nPt = 3; const int nPtTmp = nPt+1; const int nEt = 3; const int nEtTmp = nEt+1; const int nHist = 4; const int nHistTmp = nHist+1; Double_t pxtmp[nHist][nEt]; //x point to fill temp Double_t pytmp[nHist][nEt]; //y point to fill temp Double_t eytmp[nHist][nEt]; //y stat error to fill temp Double_t px[nEt] = {9.4, 24.3, 37.2}; // x point Double_t ex[nEt] = {0.,0.,0.}; // x stat error Double_t exsys[nEt] = {0.5, 0.5, 0.5};; //x sys error Double_t eysys[nHist][nEt]; //absolute y sys error Double_t eysysrel[nHist][nEt]; //relative y sys error Double_t eysysrelPR[nHist][nEt] = { {0.05299,0.06155,0.06715}, //1.5-1.93 low {0.05088,0.05442,0.05913}, //1.5-1.93 {0.03741,0.04958,0.04227}, //0.9-1.5 {0.04425,0.04528,0.05314} //0.0-0.9 }; Double_t eysysrelNP[nHist][nEt] = { {0.04971,0.06138,0.06459}, // 1.5-1.93 low {0.05188,0.05442,0.05999}, //0.5-1.93 {0.03694,0.04952,0.04221}, //0.9-1.5 {0.04242,0.04349,0.05162} //0.0-0.9 }; for (int inh = 0; inh < nHist; inh++ ) { for (int iet = 0; iet < nEt; iet++ ) { if (isPrompt) eysysrel[inh][iet] = eysysrelPR[inh][iet]; else eysysrel[inh][iet] = eysysrelNP[inh][iet]; } } //rap array in yCM (from forward to backward) Double_t rapArrNumFB[nRapTmp] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93};// for pt dist. //Double_t rapArrNumBF[nRapTmp] = {-1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist. Double_t rapBinW[nRap]; for (Int_t iy=0; iy<nRap; iy++) { rapBinW[iy] = rapArrNumFB[iy]-rapArrNumFB[iy+1]; cout << iy <<"th rapBinW = " << rapBinW[iy] <<endl; } //pt array Double_t ptArrNum[nPtTmp] = {5.0, 6.5, 10., 30.}; //6rap3pt Double_t ptBinW[nPt]; for (Int_t ipt=0; ipt<nPt; ipt++) { ptBinW[ipt] = ptArrNum[ipt+1]-ptArrNum[ipt]; cout << ipt <<"th ptBinW = " << ptBinW[ipt] <<endl; } //ethf array Double_t etArrNum[nEtTmp] = {0.0, 20.0, 30.0, 120.0}; // array string string rapArr[nRap]; for (Int_t iy=0; iy<nRap; iy++) { formRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapArr[iy]); cout << iy <<"th rapArr = " << rapArr[iy] << endl; } string ptArr[nPt]; for (Int_t ipt=0; ipt<nPt; ipt++) { formPtArr(ptArrNum[ipt], ptArrNum[ipt+1], &ptArr[ipt]); cout << ipt <<"th ptArr = " << ptArr[ipt] << endl; } string etArr[nEt]; for (Int_t i=0; i<nEt; i++) { formEtArr(etArrNum[i], etArrNum[i+1], &etArr[i]); cout << "etArr["<<i<<"] = "<< etArr[i].c_str() << endl; } // --- read-in file TFile * f2D = new TFile(Form("../fittingResult/total2Dhist_%s.root",dirName)); cout << "dirName = " << dirName << endl; cout << "runCode = " << runCode << ", runstring = " << runstring.c_str() << endl; // --- read-in 2D hist for corrected yield TH2D* h2D_corrY_Pbp[nEt]; TH2D* h2D_corrY_pPb[nEt]; for (int iet=0; iet<nEt; iet++) { if (isPrompt) { h2D_corrY_Pbp[iet] = (TH2D*)f2D->Get(Form("h2D_corrY_PR_Pbp_%d",iet)); h2D_corrY_pPb[iet] = (TH2D*)f2D->Get(Form("h2D_corrY_PR_pPb_%d",iet)); } else { h2D_corrY_Pbp[iet] = (TH2D*)f2D->Get(Form("h2D_corrY_NP_Pbp_%d",iet)); h2D_corrY_pPb[iet] = (TH2D*)f2D->Get(Form("h2D_corrY_NP_pPb_%d",iet)); } cout << iet << "th h2D_corrY_Pbp = " << h2D_corrY_Pbp[iet] << endl; cout << iet << "th h2D_corrY_pPb = " << h2D_corrY_pPb[iet] << endl; } const int nbinsX = h2D_corrY_Pbp[0]->GetNbinsX(); const int nbinsY = h2D_corrY_Pbp[0]->GetNbinsY(); cout << "nbinsX = " << nbinsX << endl; cout << "nbinsY = " << nbinsY << endl; if (nbinsX != nRap) { cout << " *** Error!!! nbinsX != nRap"; return; }; if (nbinsY != nPt) { cout << " *** Error!!! nbinsY != nPt"; return; }; // --- projection to 1D hist TH1D* h1D_corrY_Pbp[nEt][nbinsX]; TH1D* h1D_corrY_pPb[nEt][nbinsX]; // iy=0 refers to forwards !!! (ordering here) for (Int_t iet=0; iet<nEt; iet++) { for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_corrY_Pbp[iet][iy] = h2D_corrY_Pbp[iet]->ProjectionY(Form("h1D_corrY_Pbp_%d_%d",iet,iy),iy+1,iy+1); h1D_corrY_Pbp[iet][iy]->SetName(Form("h1D_corrY_Pbp_%d_%d",iet,iy)); //for 2nd run h1D_corrY_pPb[iet][iy] = h2D_corrY_pPb[iet]->ProjectionY(Form("h1D_corrY_pPb_%d_%d",iet,iy),nbinsX-iy,nbinsX-iy); h1D_corrY_pPb[iet][iy]->SetName(Form("h1D_corrY_pPb_%d_%d",iet,iy)); } } ////////////////////////////////////////////////////////////////////////////////////// // 1) merge Pbp+pPb corrected yield TH1D* h1D_corrY_tot[nEt][nbinsX]; for (Int_t iet=0; iet<nEt; iet++) { for (Int_t iy = 0; iy < nbinsX; iy++) { if (runCode ==0) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_Pbp[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); h1D_corrY_tot[iet][iy]->Add(h1D_corrY_pPb[iet][iy]); } else if (runCode ==1) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_Pbp[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); } else if (runCode ==2) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_pPb[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); } } } ////////////////////////////////////////////////////////////////// /////////// calculate RFB const int nRapRFB = 3; TH1D* h1D_RFB_tmp[nEt][nbinsX]; // corrYield with merged pT TH1D* h1D_RFB[nEt][nRapRFB]; // actual RFB vs pt // bin settingg string rapAbsArr[nRap]; for (Int_t iy=0; iy<nRapRFB; iy++) { formAbsRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapAbsArr[iy]); cout << iy <<"th rapAbsArr = " << rapAbsArr[iy] << endl; } Double_t ptArrRFBNum[] = {5.0, 6.5, 30.}; const Int_t nPtRFB = sizeof(ptArrRFBNum)/sizeof(Double_t)-1; cout << "nPtRFB = " << nPtRFB << endl; // merging pT bins (KYO - byHand) double tmpPRval01, tmpPRerr01, tmpPRval02, tmpPRerr02; double actPRval01, actPRerr01, actPRval02, actPRerr02; for (int iet=0; iet<nEt; iet++) { for (int iy=0; iy<nRapRFB*2; iy++) { h1D_RFB_tmp[iet][iy]= new TH1D(Form("h1D_RFB_tmp_%d_%d",iet,iy),Form("h1D_RFB_tmp_%d_%d",iet,iy),nPtRFB,ptArrRFBNum); h1D_RFB_tmp[iet][iy]->Sumw2(); actPRval01=0; actPRval02=0; actPRerr01=0; actPRerr02=0; // 1) pT 5-6.5 GeV tmpPRval01=0; tmpPRval02=0; tmpPRerr01=0; tmpPRerr02=0; if (iy==0 || iy==nRapRFB*2-1) { actPRval01=h1D_corrY_tot[iet][iy]->GetBinContent(1); actPRerr01=h1D_corrY_tot[iet][iy]->GetBinError(1); h1D_RFB_tmp[iet][iy]->SetBinContent(1,actPRval01); h1D_RFB_tmp[iet][iy]->SetBinError(1,actPRerr01); } else { h1D_RFB_tmp[iet][iy]->SetBinContent(1,0.); h1D_RFB_tmp[iet][iy]->SetBinError(1,0.); } // 2) pT 6.5-30. GeV tmpPRval01=0; tmpPRval02=0; tmpPRerr01=0; tmpPRerr02=0; tmpPRval01=h1D_corrY_tot[iet][iy]->GetBinContent(2); tmpPRerr01=h1D_corrY_tot[iet][iy]->GetBinError(2); tmpPRval02=h1D_corrY_tot[iet][iy]->GetBinContent(3); tmpPRerr02=h1D_corrY_tot[iet][iy]->GetBinError(3); actPRval02=tmpPRval01+tmpPRval02; actPRerr02=TMath::Sqrt( TMath::Power(tmpPRerr01,2) + TMath::Power(tmpPRerr02,2) ); h1D_RFB_tmp[iet][iy]->SetBinContent(2,actPRval02); h1D_RFB_tmp[iet][iy]->SetBinError(2,actPRerr02); } } // actual RFB calculation vs pT!! for (int iet=0; iet<nEt; iet++) { for (int iy=0; iy<nRapRFB; iy++) { h1D_RFB[iet][iy] = (TH1D*)h1D_RFB_tmp[iet][iy]->Clone(Form("h1D_RFB_%d_%d",iet,iy)); h1D_RFB[iet][iy]->Divide(h1D_RFB_tmp[iet][2*nRapRFB-iy-1]); cout << iet<<"th, "<<iy<<"th h1D_RFB = "<<h1D_RFB[iet][iy]<<endl; } } /////////////////////////////////////////////// //////// --- RFB vs ETHF : 4 histograms //inh=0 : pT 5-6.5, rap 1.5-1.93 //inh=1 : pT 6.5-30, rap 1.5-1.93 //inh=2 : pT 6.5-30, rap 0.9-1.5 //inh=3 : pT 6.5-30, rap 0.0-0.9 double tmpRFBval01, tmpRFBerr01, tmpRFBval02, tmpRFBerr02, tmpRFBval03, tmpRFBerr03; TH1D* h1D_RFB_ETHF[nHist]; for (int inh=0; inh< nHist; inh++) { h1D_RFB_ETHF[inh]= new TH1D(Form("h1D_RFB_ETHF_%d",inh),Form("h1D_RFB_ETHF_%d",inh),nEt,etArrNum); h1D_RFB_ETHF[inh]->Sumw2(); tmpRFBval01=0; tmpRFBerr01=0; tmpRFBval02=0; tmpRFBerr02=0; tmpRFBval03=0; tmpRFBerr03=0; for (int iet=0; iet<nEt; iet++) { if (inh==0) { tmpRFBval01=h1D_RFB[iet][0]->GetBinContent(1); tmpRFBerr01=h1D_RFB[iet][0]->GetBinError(1); h1D_RFB_ETHF[inh]->SetBinContent(iet+1,tmpRFBval01); h1D_RFB_ETHF[inh]->SetBinError(iet+1,tmpRFBerr01); } else { tmpRFBval01=h1D_RFB[iet][inh-1]->GetBinContent(2); tmpRFBerr01=h1D_RFB[iet][inh-1]->GetBinError(2); h1D_RFB_ETHF[inh]->SetBinContent(iet+1,tmpRFBval01); h1D_RFB_ETHF[inh]->SetBinError(iet+1,tmpRFBerr01); } } } ////////////////////////////////////////////////////////////////// /////////// samey ////////////////////////////////////////////////////////////////// TCanvas* c1 = new TCanvas("c1","c1",600,600); c1->cd(); // TLegend *legBL = new TLegend(0.16, 0.16, 0.43, 0.41); //bottom left TLegend *legBL = new TLegend(0.16, 0.16, 0.40, 0.36); //bottom left TLegend *legBL2 = new TLegend(0.16, 0.16, 0.40, 0.40); //bottom left // TLegend *legUR = new TLegend(0.36, 0.77, 0.89, 0.95); //upper left TLegend *legUR = new TLegend(0.34, 0.71, 0.89, 0.88); //upper left SetLegendStyle(legBL); SetLegendStyle(legBL2); //legBL->SetTextSize(0.032); legBL->SetTextSize(0.037); legBL2->SetTextSize(0.037); //globtex box for beam, rapidity, pT info TLatex* globtex = new TLatex(); globtex->SetNDC(); //globtex->SetTextAlign(12); //1:left, 2:vertical center globtex->SetTextAlign(32); //3:right 2:vertical center globtex->SetTextFont(42); globtex->SetTextSize(0.04); // convert to TGraphAsymErrors //RFB TGraphAsymmErrors*gRFB[nHist]; for (int inh=0; inh< nHist; inh++) { gRFB[inh] = new TGraphAsymmErrors(h1D_RFB_ETHF[inh]); gRFB[inh]->SetName(Form("gRFB_%d",inh)); for (int iet=0; iet<nEt; iet++) { gRFB[inh]->GetPoint(iet, pxtmp[inh][iet], pytmp[inh][iet]); eytmp[inh][iet] = gRFB[inh] -> GetErrorY(iet); // gRFB[inh]->SetPoint(iet, px[iet], pytmp[inh][iet]); gRFB[inh]->SetPoint(iet, px[iet]+pxshift*inh, pytmp[inh][iet]); gRFB[inh]->SetPointEXlow(iet, ex[inh]); gRFB[inh]->SetPointEXhigh(iet, ex[inh]); } } //sys TGraphAsymmErrors* gRFB_sys[nHist]; for (int inh=0; inh< nHist; inh++) { gRFB_sys[inh] = new TGraphAsymmErrors(h1D_RFB_ETHF[inh]); gRFB_sys[inh]->SetName(Form("gRFB_sys_%d",inh)); for (int iet=0; iet<nEt; iet++) { gRFB_sys[inh]->GetPoint(iet, pxtmp[inh][iet], pytmp[inh][iet]); //abs err calcul. eysys[inh][iet] = eysysrel[inh][iet]*pytmp[inh][iet]; //gRFB_sys[inh]->SetPoint(iet, px[iet], pytmp[inh][iet]); gRFB_sys[inh]->SetPoint(iet, px[iet]+pxshift*inh, pytmp[inh][iet]); gRFB_sys[inh]->SetPointError(iet, exsys[iet], exsys[iet], eysys[inh][iet], eysys[inh][iet]); cout << "" << endl; cout << "pytmp["<<inh<<"]["<<iet<<"] = " << pytmp[inh][iet]<<endl; cout << "eytmp["<<inh<<"]["<<iet<<"] = " << eytmp[inh][iet]<<endl; cout << "eysys["<<inh<<"]["<<iet<<"] = " << eysys[inh][iet]<<endl; } } gRFB_sys[0]->GetXaxis()->SetTitle("E_{T}^{HF |#eta|>4} [GeV]"); gRFB_sys[0]->GetXaxis()->CenterTitle(); gRFB_sys[0]->GetYaxis()->SetTitle("R_{FB}"); gRFB_sys[0]->GetXaxis()->SetLimits(0.,50.0); gRFB_sys[0]->SetMinimum(0.5); gRFB_sys[0]->SetMaximum(1.15); gRFB_sys[0]->SetFillColor(kViolet-9); gRFB_sys[0]->Draw("A2"); gRFB_sys[1]->SetFillColor(kTeal-9); gRFB_sys[1]->Draw("2"); gRFB_sys[2]->SetFillColor(kRed-9); // gRFB_sys[2]->Draw("2"); gRFB_sys[3]->SetFillColor(kAzure-9); // gRFB_sys[3]->Draw("2"); SetGraphStyle(gRFB[0], 8, 2); //1.5-1.93 low SetGraphStyle(gRFB[1], 0, 5); //1.5-1.93 SetGraphStyle(gRFB[2], 1, 3); //0.9-1.5 SetGraphStyle(gRFB[3], 2, 0); //0-0.9 gRFB[0]->SetMarkerSize(1.6); gRFB[0]->Draw("P"); gRFB[1]->SetMarkerSize(2.1); gRFB[1]->Draw("P"); dashedLine(0.,1.,50.,1.,1,1); legBL -> SetHeader ("1.5 < |y_{CM}| < 1.93"); legBL -> AddEntry(gRFB[0],"5 < p_{T} < 6.5 GeV/c","lp"); legBL -> AddEntry(gRFB[1],"6.5 < p_{T} < 30 GeV/c","lp"); // legBL -> AddEntry(gRFB[0],"1.5 < |y_{CM}| < 1.93, 5 < p_{T} < 6.5 GeV/c","lp"); // legBL -> AddEntry(gRFB[1],"1.5 < |y_{CM}| < 1.93, 6.5 < p_{T} < 30 GeV/c","lp"); // legBL -> AddEntry(gRFB[2],"0.9 < |y_{CM}| < 1.5, 6.5 < p_{T} < 30 GeV/c","lp"); // legBL -> AddEntry(gRFB[3],"0.0 < |y_{CM}| < 0.9, 6.5 < p_{T} < 30 GeV/c","lp"); legBL->Draw(); globtex->SetTextSize(0.045); globtex->SetTextFont(62); if (isPrompt) globtex->DrawLatex(0.88, 0.86, "Prompt J/#psi"); else globtex->DrawLatex(0.88, 0.86, "Non-prompt J/#psi"); CMS_lumi( c1, iPeriod, iPos ); c1->Update(); c1->SaveAs(Form("RFB_%s/RFB_ETHF_samey_isPrompt%d_%s.pdf",dirName,(int)isPrompt,runstring.c_str())); c1->SaveAs(Form("RFB_%s/RFB_ETHF_samey_isPrompt%d_%s.png",dirName,(int)isPrompt,runstring.c_str())); legBL->Clear(); ////////////////////////////////////////////////////////////////// /////////// samept ////////////////////////////////////////////////////////////////// TCanvas* c2 = new TCanvas("c2","c2",600,600); c2->cd(); for (int inh=1; inh< nHist; inh++) { for (int iet=0; iet<nEt; iet++) { gRFB[inh]->GetPoint(iet, pxtmp[inh][iet], pytmp[inh][iet]); eytmp[inh][iet] = gRFB[inh] -> GetErrorY(iet); gRFB[inh]->SetPoint(iet, px[iet]+pxshift*(nHist-1-inh), pytmp[inh][iet]); //sys gRFB_sys[inh]->GetPoint(iet, pxtmp[inh][iet], pytmp[inh][iet]); gRFB_sys[inh]->SetPoint(iet, px[iet]+pxshift*(nHist-1-inh), pytmp[inh][iet]); } } gRFB_sys[0]->GetXaxis()->SetTitle("E_{T}^{HF |#eta|>4} [GeV]"); gRFB_sys[0]->GetXaxis()->CenterTitle(); gRFB_sys[0]->GetYaxis()->SetTitle("R_{FB}"); gRFB_sys[0]->GetXaxis()->SetLimits(0.,50.0); gRFB_sys[0]->SetMinimum(0.5); gRFB_sys[0]->SetMaximum(1.15); gRFB_sys[0]->SetFillColor(kViolet-9); gRFB_sys[0]->Draw("A2"); gRFB_sys[1]->SetFillColor(kTeal-9); gRFB_sys[1]->Draw("2"); gRFB_sys[2]->SetFillColor(kRed-9); // gRFB_sys[2]->Draw("2"); gRFB_sys[3]->SetFillColor(kAzure-9); // gRFB_sys[3]->Draw("2"); SetGraphStyle(gRFB[0], 8, 2); //1.5-1.93 low SetGraphStyle(gRFB[1], 0, 5); //1.5-1.93 SetGraphStyle(gRFB[2], 1, 3); //0.9-1.5 SetGraphStyle(gRFB[3], 2, 0); //0-0.9 gRFB[0]->SetMarkerSize(1.6); gRFB[0]->Draw("P"); gRFB[1]->SetMarkerSize(2.1); gRFB[1]->Draw("P"); // just for drawing gRFB_sys[0]->SetFillColor(kWhite); gRFB_sys[0]->Draw("A2"); gRFB_sys[1]->Draw("2"); gRFB_sys[2]->Draw("2"); gRFB_sys[3]->Draw("2"); gRFB[1]->Draw("P"); gRFB[2]->Draw("P"); gRFB[3]->Draw("P"); dashedLine(0.,1.,50.,1.,1,1); legBL2 -> SetHeader ("6.5 < p_{T} < 30 GeV/c"); legBL2 -> AddEntry(gRFB[3],"0.0 < |y_{CM}| < 0.9","lp"); legBL2 -> AddEntry(gRFB[2],"0.9 < |y_{CM}| < 1.5","lp"); legBL2 -> AddEntry(gRFB[1],"1.5 < |y_{CM}| < 1.93","lp"); legBL2 ->Draw(); globtex->SetTextSize(0.045); globtex->SetTextFont(62); if (isPrompt) globtex->DrawLatex(0.88, 0.86, "Prompt J/#psi"); else globtex->DrawLatex(0.88, 0.86, "Non-prompt J/#psi"); CMS_lumi( c2, iPeriod, iPos ); c2->Update(); c2->SaveAs(Form("RFB_%s/RFB_ETHF_samept_isPrompt%d_%s.pdf",dirName,(int)isPrompt,runstring.c_str())); c2->SaveAs(Form("RFB_%s/RFB_ETHF_samept_isPrompt%d_%s.png",dirName,(int)isPrompt,runstring.c_str())); #if 0 /////////////////////////////////////////////////////////////////// // save as a root file TFile *outFile = new TFile(Form("RFB_%s/RFB_ETHF_FWonly_isPrompt%d.root",dirName,(int)isPrompt),"RECREATE"); outFile->cd(); for (int inh=0; inh< nHist; inh++) { gRFB_sys[inh]->Write(); gRFB[inh]->Write(); } outFile->Close(); #endif return; } // end of main func.
void produce_txt_ROOT_for_cuts( const int N_cut_points, double lowest_cut, double scan_width ){ // basic definition TString variable_name = "Ele_1st_pt" ; cout<<"variable_name: " << variable_name << endl; // const int N_cut_points = 10; const int N_signal_mass_points = 11; const int N_DYJetsHTbin_background_points = 4; double luminosity = 3000; // in pb^-1 // define cuts int cut_point[N_cut_points]; // double lowest_cut=115 ; // double scan_width = 100; for(int i=0;i<N_cut_points;i++){ cut_point[i] = lowest_cut + scan_width*i; cout<<"cut_point[i]: "<< cut_point[i] << endl; } // define mass points int Zprime_mass[N_signal_mass_points]={800,1000,1200,1400,1600,1800,2000,2500,3000,3500,4000}; // define the total number double total_number_signal[N_signal_mass_points]; double total_number_DYJetHT[N_DYJetsHTbin_background_points]; // --------------------------------------------------- // define signal histogram for cuts TH1D* h_Zprime_mass_of_signal_sample_and_cut[N_signal_mass_points][N_cut_points]; TString signal_histo_name[N_signal_mass_points][N_cut_points]; double histo_start = 0, histo_end = 5000; double histo_width = 50; int Nbins = (histo_end - histo_start)/ histo_width; cout<<"histo_start: "<< histo_start << endl; cout<<"histo_end: " << histo_end << endl; cout<<"Nbins: " << Nbins << endl; for(int signal_index=0;signal_index<N_signal_mass_points; signal_index++){ for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ signal_histo_name[signal_index][cut_index] = Form("h_Zprime_mass_in_signal_%d_cut_index_%d_for_", Zprime_mass[signal_index],cut_index); signal_histo_name[signal_index][cut_index] = signal_histo_name[signal_index][cut_index] + variable_name; // cout<< signal_histo_name[signal_index][cut_index] << endl; h_Zprime_mass_of_signal_sample_and_cut[signal_index][cut_index] = new TH1D(signal_histo_name[signal_index][cut_index],"",Nbins,histo_start,histo_end); // h_Zprime_mass_of_signal_sample_and_cut[signal_index][cut_index] = new TH1D(signal_histo_name[signal_index][cut_index],"",200,0,5000); } } // define background DYJet HT histogram for cuts TH1D* h_Zprime_mass_of_DYJetHT_sample_and_cut[N_DYJetsHTbin_background_points][N_cut_points]; TString DYJetHT_histo_name[N_DYJetsHTbin_background_points][N_cut_points]; for(int DYJetHT_index=0;DYJetHT_index<N_DYJetsHTbin_background_points; DYJetHT_index++){ for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ DYJetHT_histo_name[DYJetHT_index][cut_index] = Form("h_Zprime_mass_in_DYJetHT_%d_cut_index_%d_for_", DYJetHT_index,cut_index); DYJetHT_histo_name[DYJetHT_index][cut_index] = DYJetHT_histo_name[DYJetHT_index][cut_index] + variable_name; h_Zprime_mass_of_DYJetHT_sample_and_cut[DYJetHT_index][cut_index] = new TH1D(DYJetHT_histo_name[DYJetHT_index][cut_index],"",Nbins,histo_start,histo_end); } } // --------------------------------------------------- // define the input files TString path = "../step1_apply_PreSelection_save_TTree/plot/"; // signal TString inputFile_signal[N_signal_mass_points]; for(int signal_index=0;signal_index<N_signal_mass_points; signal_index++){ inputFile_signal[signal_index] = Form("signal_shape_in_Zprime_M-%d.root",Zprime_mass[signal_index]); inputFile_signal[signal_index] = path + inputFile_signal[signal_index]; // cout<< inputFile_signal[signal_index] << endl; } // DYJet HT bins background TString inputFile_DYJetHT[N_DYJetsHTbin_background_points]; for(int DYJetHT_index=0;DYJetHT_index<N_DYJetsHTbin_background_points; DYJetHT_index++){ inputFile_DYJetHT[DYJetHT_index] = "background_shape_DYJets_HT"; TString DYJetHT_middle_name; if(DYJetHT_index==0){DYJetHT_middle_name = "100to200";} if(DYJetHT_index==1){DYJetHT_middle_name = "200to400";} if(DYJetHT_index==2){DYJetHT_middle_name = "400to600";} if(DYJetHT_index==3){DYJetHT_middle_name = "600toInf";} TString DYJetHT_last_name = "_in_Zprime_M-600.root"; inputFile_DYJetHT[DYJetHT_index] = inputFile_DYJetHT[DYJetHT_index] + DYJetHT_middle_name + DYJetHT_last_name; inputFile_DYJetHT[DYJetHT_index] = path + inputFile_DYJetHT[DYJetHT_index]; // cout<< inputFile_DYJetHT[DYJetHT_index] << endl; } //------------------- open TTree and save events in histograms of each cuts --------------------- // open TTree for signal for(int signal_index=0;signal_index<N_signal_mass_points; signal_index++){ // if(signal_index>1)continue; cout<<" read ROOT file:"<< inputFile_signal[signal_index]<< endl; // input files TString inputFile = inputFile_signal[signal_index]; TreeReader data(inputFile.Data()); // Event loop for(Long64_t jEntry=0; jEntry<data.GetEntriesFast() ;jEntry++){ if (jEntry % 50000 == 0) fprintf(stderr, "Processing event %lli of %lli\n", jEntry + 1, data.GetEntriesFast()); data.GetEntry(jEntry); Float_t the_variable = data.GetFloat(variable_name); Float_t Zprime_mass = data.GetFloat("Zprime_mass"); // fill histogram for each cut points for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ if(the_variable > cut_point[cut_index]) {h_Zprime_mass_of_signal_sample_and_cut[signal_index][cut_index]->Fill(Zprime_mass);} }// end cut_index }// end event loop // test for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ // cout<<"cut point: "<< cut_point[cut_index] << endl; // cout<<"histo total #: " << h_Zprime_mass_of_signal_sample_and_cut[signal_index][cut_index]->Integral()<<endl; }// end cut_index // get total event TFile *file = new TFile (inputFile ); TH1D *h_eventWeight = (TH1D*) file -> Get("h_eventWeight"); total_number_signal[signal_index] = h_eventWeight->Integral(); delete h_eventWeight; file->Close(); delete file; cout<<"total #:" << total_number_signal[signal_index] << endl; }// end signal_index // open TTree for DYJetHT for(int DYJetHT_index=0;DYJetHT_index<N_DYJetsHTbin_background_points; DYJetHT_index++){ // if(DYJetHT_index>1)continue; cout<<" read ROOT file:"<< inputFile_DYJetHT[DYJetHT_index]<< endl; // input files TString inputFile = inputFile_DYJetHT[DYJetHT_index]; TreeReader data(inputFile.Data()); // Event loop for(Long64_t jEntry=0; jEntry<data.GetEntriesFast() ;jEntry++){ if (jEntry % 50000 == 0) fprintf(stderr, "Processing event %lli of %lli\n", jEntry + 1, data.GetEntriesFast()); data.GetEntry(jEntry); Float_t the_variable = data.GetFloat(variable_name); Float_t Zprime_mass = data.GetFloat("Zprime_mass"); // fill histogram for each cut points for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ if(the_variable > cut_point[cut_index]) {h_Zprime_mass_of_DYJetHT_sample_and_cut[DYJetHT_index][cut_index]->Fill(Zprime_mass);} }// end cut_index }// end event loop // test for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ // cout<<"cut point: "<< cut_point[cut_index] << endl; // cout<<"histo total #: " << h_Zprime_mass_of_DYJetHT_sample_and_cut[DYJetHT_index][cut_index]->Integral()<<endl; }// end cut_index // get total event TFile *file = new TFile (inputFile ); TH1D *h_eventWeight = (TH1D*) file -> Get("h_eventWeight"); total_number_DYJetHT[DYJetHT_index] = h_eventWeight->Integral(); delete h_eventWeight; file->Close(); delete file; cout<<"total #:" << total_number_DYJetHT[DYJetHT_index] << endl; }// end DYJetHT_index // --------------------------------------------------------------------- // input the cross section text file // signal // string xsect_file_th = "./xsec_Zprime.txt"; string xsect_file_th = "./13TeV_xsec_Zhllbb.txt"; ifstream xsect_file(xsect_file_th.c_str(), ios::in); if (! xsect_file.is_open()) { // cout << "Failed to open file with xsections: " << xsect_file_th << endl; } float mZprime, CS; vector<float> v_mZprime, v_xs; int loop_counter =1; while (xsect_file.good()) { if(loop_counter>N_signal_mass_points)break; xsect_file >> mZprime >> CS; v_mZprime.push_back(mZprime); v_xs.push_back(CS); loop_counter = loop_counter +1; } cout << "Size of theory Zprime xsects vector " << v_mZprime.size() << endl; xsect_file.close(); // test for(int i=0;i<v_mZprime.size();i++){ // cout<< v_mZprime[i] <<" "<< v_xs[i]<<endl; } // DYJetHT background // xsect_file_th = "./xsec_DYJetHT.txt"; xsect_file_th = "./13TeV_xsec_DYJetHT.txt"; ifstream xsect_file2(xsect_file_th.c_str(), ios::in); if (! xsect_file2.is_open()) { cout << "Failed to open file with xsections: " << xsect_file_th << endl; } string HT_range; vector<string> v_DYJetHT_range; vector<float> v_xs_DYJetHT; loop_counter =1; while (xsect_file2.good()) { if(loop_counter> N_DYJetsHTbin_background_points)break; xsect_file2 >> HT_range >> CS; v_DYJetHT_range.push_back(HT_range); v_xs_DYJetHT.push_back(CS); loop_counter = loop_counter +1; } cout << "Size of theory DYJetHT xsects vector " << v_DYJetHT_range.size() << endl; xsect_file2.close(); // test and apply k-factor to correct the DYJet xsec double k_factor = 1.23; for(int i=0;i<v_DYJetHT_range.size();i++){ v_xs_DYJetHT[i] = v_xs_DYJetHT[i] * k_factor; // cout<< v_DYJetHT_range[i] <<" "<< v_xs_DYJetHT[i]<<endl; } // --------------------------------------------------- // calcualte the weight double weight_signal[N_signal_mass_points]; double weight_DYJetHT[N_DYJetsHTbin_background_points]; // signal for(int signal_index=0;signal_index<N_signal_mass_points; signal_index++){ weight_signal[signal_index] = v_xs[signal_index]/total_number_signal[signal_index]; weight_signal[signal_index] = weight_signal[signal_index] * luminosity; // cout<< weight_signal[signal_index] << endl; } // DYJetHt for(int DYJetHT_index=0;DYJetHT_index<N_DYJetsHTbin_background_points; DYJetHT_index++){ weight_DYJetHT[DYJetHT_index] = v_xs_DYJetHT[DYJetHT_index]/total_number_DYJetHT[DYJetHT_index]; weight_DYJetHT[DYJetHT_index] = weight_DYJetHT[DYJetHT_index] * luminosity; // cout<< weight_DYJetHT[DYJetHT_index] << endl; } // --------------------------------------------------- // get the event yield and shape in corresponding luminosity // signal double Event_yield_signal_sample_and_cut[N_signal_mass_points][N_cut_points]; for(int signal_index=0;signal_index<N_signal_mass_points; signal_index++){ for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ h_Zprime_mass_of_signal_sample_and_cut[signal_index][cut_index]->Sumw2(); h_Zprime_mass_of_signal_sample_and_cut[signal_index][cut_index]->Scale( weight_signal[signal_index] ); double temp = h_Zprime_mass_of_signal_sample_and_cut[signal_index][cut_index]->Integral(); Event_yield_signal_sample_and_cut[signal_index][cut_index] = temp; } // test // cout<< Event_yield_signal_sample_and_cut[signal_index][0] << endl; } // DYJetHT double Event_yield_DYJetHT_sample_and_cut[N_DYJetsHTbin_background_points][N_cut_points]; double Event_yield_DYJetHT_and_cut[N_cut_points];// = {0}; for(int i=0;i<N_cut_points;i++){Event_yield_DYJetHT_and_cut[i]=0;} TH1D* h_Zprime_mass_of_DYJetHT_and_cut[N_cut_points]; TString DYJetHT_histo_name_combine[N_cut_points]; for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ // the order of two loop is different to signal DYJetHT_histo_name_combine[cut_index] = Form("DYJetHT_cut_index_%d",cut_index); h_Zprime_mass_of_DYJetHT_and_cut[cut_index] = new TH1D(DYJetHT_histo_name_combine[cut_index],"",Nbins,histo_start,histo_end); h_Zprime_mass_of_DYJetHT_and_cut[cut_index]->Sumw2(); for(int DYJetHT_index=0;DYJetHT_index<N_DYJetsHTbin_background_points; DYJetHT_index++){ h_Zprime_mass_of_DYJetHT_sample_and_cut[DYJetHT_index][cut_index]->Sumw2(); h_Zprime_mass_of_DYJetHT_sample_and_cut[DYJetHT_index][cut_index]->Scale( weight_DYJetHT[DYJetHT_index] ); double temp = h_Zprime_mass_of_DYJetHT_sample_and_cut[DYJetHT_index][cut_index]->Integral(); Event_yield_DYJetHT_sample_and_cut[DYJetHT_index][cut_index] = temp; h_Zprime_mass_of_DYJetHT_and_cut[cut_index]->Add( h_Zprime_mass_of_DYJetHT_sample_and_cut[DYJetHT_index][cut_index]); Event_yield_DYJetHT_and_cut[cut_index] = Event_yield_DYJetHT_and_cut[cut_index] + Event_yield_DYJetHT_sample_and_cut[DYJetHT_index][cut_index]; } // test // cout<<"cut: "<< cut_point[cut_index] << endl; // cout<< Event_yield_DYJetHT_and_cut[cut_index] << endl; // cout<< h_Zprime_mass_of_DYJetHT_and_cut[cut_index]->Integral() << endl; } // data double Event_yield_data = Event_yield_DYJetHT_and_cut[0] + 2; // cout<< Event_yield_data << endl; TH1D *h_data = (TH1D*) h_Zprime_mass_of_DYJetHT_and_cut[0] ->Clone("data_obs"); h_data->Sumw2(); h_data->Scale( Event_yield_data / h_data->Integral() ); // cout<< h_data->Integral() << endl; // --------------------------------------------------- // save the text file and the ROOT file TString save_dir = "text_and_ROOT_files/"; TString data_name = "DATA"; TString background_DYJets_name = "DYJETS"; //ROOT file TString ROOT_name[N_cut_points]; TString histo_name_signal[N_signal_mass_points]; for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ ROOT_name[cut_index] = Form("_cut_%d",cut_point[cut_index]); ROOT_name[cut_index] = save_dir + "Zprime_shape_" + variable_name + ROOT_name[cut_index] +".root"; ////// cout<< ROOT_name[cut_index] <<endl; TFile *myFile = new TFile(ROOT_name[cut_index],"recreate"); // data h_data-> SetName("data_obs"); h_data->Write(); // signal for(int signal_index=0;signal_index<N_signal_mass_points; signal_index++){ histo_name_signal[signal_index] = Form("M%d",Zprime_mass[signal_index] ); TString histo_name_signal_final = "SIG_" + histo_name_signal[signal_index] ; h_Zprime_mass_of_signal_sample_and_cut[signal_index][cut_index] -> SetName(histo_name_signal_final ); h_Zprime_mass_of_signal_sample_and_cut[signal_index][cut_index] ->Write(); } // DYJetsHT background h_Zprime_mass_of_DYJetHT_and_cut[cut_index]-> SetName(background_DYJets_name); h_Zprime_mass_of_DYJetHT_and_cut[cut_index]-> Write(); myFile->Close(); delete myFile; } // text files TString text_name[N_cut_points]; for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ text_name[cut_index] = Form("_cut_%d",cut_point[cut_index]); text_name[cut_index] = save_dir + "YuHsiang_DY_" + variable_name + text_name[cut_index] + ".txt"; // cout<< text_name[cut_index] << endl; // write text ofstream fout; fout.open( text_name[cut_index] ); cout << endl << text_name[cut_index] << endl<<endl; cout << data_name << " " << Event_yield_data << endl; fout << data_name << " " << Event_yield_data << endl; cout << background_DYJets_name << " " << Event_yield_DYJetHT_and_cut[cut_index] << endl; fout << background_DYJets_name << " " << Event_yield_DYJetHT_and_cut[cut_index] << endl; for(int signal_index=0;signal_index<N_signal_mass_points; signal_index++){ cout << histo_name_signal[signal_index] << " " << Event_yield_signal_sample_and_cut[signal_index][cut_index] << endl; fout << histo_name_signal[signal_index] << " " << Event_yield_signal_sample_and_cut[signal_index][cut_index] << endl; } fout.close(); } // control plot_mass.C to plot Z' mass and save pdf // signal and background in certain cut for(int cut_index=0;cut_index<N_cut_points; cut_index++ ){ plot_mass( variable_name , cut_point[cut_index] ); } // control plot_mass2.C to plot Z' mass and save pdf // signal or background in different cuts TString histo_name_to_open; histo_name_to_open = "DYJETS"; //histo_name_to_open = "SIG_M1000"; //histo_name_to_open = "SIG_M2000"; //histo_name_to_open = "SIG_M3000"; plot_mass2( variable_name, histo_name_to_open ,N_cut_points, lowest_cut ,scan_width ); }// end codes
void presentationPlot(){ TH1::SetDefaultSumw2(); gStyle->SetOptStat(0); bool log =true; // if true both plots will be log scale // gStyle->SetTitleSize(.1,"x"); TFile * f1 = TFile::Open("ROOT/Jewel/med1_weights.root"); TFile * f8 = TFile::Open("ROOT/Jewel/med8_weights.root"); TFile * fP = TFile::Open("ROOT/Jewel/Pythia_weights.root"); TFile *f = TFile::Open(Form("MCadded.root")); TCanvas * cJR = new TCanvas("cJR","",600,600); TH2D *h0_JR = new TH2D("h0_JR","",10,10,1000,2000,0,1.2); TLegend *leg_JR = new TLegend(0.50,0.1,0.87,0.45); leg_JR->SetFillStyle(0); leg_JR->SetBorderSize(0); h0_JR->SetXTitle("H_{T} (GeV/c)"); h0_JR->SetYTitle("3-Jet / 2-Jet ratio"); h0_JR->GetYaxis()->SetTitleOffset(1.5); h0_JR->GetXaxis()->CenterTitle(); cJR->cd(); if(log) cJR->SetLogy(); TH1D * JR2_m1 = (TH1D*)f1->Get("med1_Jet2_hT_HI"); TH1D * JR3_m1 = (TH1D*)f1->Get("med1_Jet3_hT_HI"); TH1D * ratio1_hT = new TH1D("","",100,0,1000); ratio1_hT->Add(JR3_m1); ratio1_hT->Divide(JR2_m1); ratio1_hT->SetMarkerStyle(20); ratio1_hT->SetMarkerColor(kBlack); TH1D * JR2_m8 = (TH1D*)f8->Get("med8_Jet2_hT_HI"); TH1D * JR3_m8 = (TH1D*)f8->Get("med8_Jet3_hT_HI"); TH1D * ratio8_hT = new TH1D("","",100,0,1000); ratio8_hT->Add(JR3_m8); ratio8_hT->Divide(JR2_m8); ratio8_hT->SetMarkerStyle(20); ratio8_hT->SetMarkerColor(kBlue); /* TH1D * JR2_P = (TH1D*)fP->Get("Pythia_Jet2_hT_HI"); TH1D * JR3_P = (TH1D*)fP->Get("Pythia_Jet3_hT_HI"); TH1D * ratioP_hT = new TH1D("","",100,0,1000); ratioP_hT->Add(JR3_P); ratioP_hT->Divide(JR2_P); ratioP_hT->SetMarkerStyle(20); ratioP_hT->SetMarkerColor(kGreen); */ TH1D * Jet2_hT = (TH1D*)f->Get("Jet2_hT_pp"); TH1D * Jet3_hT = (TH1D*)f->Get("Jet3_hT_pp"); TH1D * ratio_hT = new TH1D("","",100,0,1000); ratio_hT->Add(Jet3_hT); ratio_hT->Divide(Jet2_hT); ratio_hT->SetMarkerStyle(20); ratio_hT->SetMarkerColor(kRed); h0_JR->Draw(); ratio1_hT->Draw("same"); ratio8_hT->Draw("same"); //ratioP_hT->Draw("same"); ratio_hT->Draw("same"); leg_JR->SetHeader("#splitline{#sqrt{s} =2.76 TeV}{anti-K_{T} R= .3}"); leg_JR->AddEntry(ratio1_hT,"Jewel: 0-10%"); leg_JR->AddEntry(ratio8_hT,"Jewel: 80-90%"); //leg_JR->AddEntry(ratioP_hT,"Pythia"); leg_JR->AddEntry(ratio_hT,"Pythia"); leg_JR->Draw(); cJR->SaveAs("PNG/PRESENTATION_JR.png","RECREATE"); //==========================AJ============================ TH1D*AJ_m1 = (TH1D*)f1->Get("med1_Aj_MC"); TH1D*AJ_m8 = (TH1D*)f8->Get("med8_Aj_MC"); TH1D*AJ_P = (TH1D*)fP->Get("Pythia_Aj_MC"); TH1D*AJ_Po = (TH1D*)f ->Get(""); TH2D *h0_Aj = new TH2D("h0_Aj",";A_{J}",20,0,1,200,0,0.4); TCanvas *cAj = new TCanvas("cAj","",600,600); TLegend *leg_AJ = new TLegend(0.60,0.5,0.87,0.87); leg_AJ->SetFillStyle(0); leg_AJ->SetBorderSize(0); cAj->cd(); if(log) cAj->SetLogy(); h0_Aj->SetYTitle("Event Fraction"); h0_Aj->GetYaxis()->SetTitleOffset(1.5); h0_Aj->GetXaxis()->CenterTitle(); AJ_m1->SetMarkerStyle(20); AJ_m1->SetMarkerColor(kBlack); AJ_m8->SetMarkerStyle(20); AJ_m8->SetMarkerColor(kBlue); AJ_P ->SetMarkerStyle(20); AJ_P ->SetMarkerColor(kRed); h0_Aj->Draw(); AJ_m1->Draw("same"); AJ_m8->Draw("same"); AJ_P ->Draw("same"); leg_AJ->SetHeader("#splitline{#sqrt{s} =2.76 TeV}{anti-K_{T} R= .3}"); leg_AJ->AddEntry(AJ_m1,"Jewel: 0-10"); leg_AJ->AddEntry(AJ_m8,"Jewel: 80-90"); leg_AJ->AddEntry(AJ_P ,"Pythia"); leg_AJ->Draw(); cAj->SaveAs("PNG/PRESENTATION_AJ.png","RECREATE"); }
int main() { // this loads the library TMVA::Tools::Instance(); //--------------------------------------------------------------- // default MVA methods to be trained + tested std::map<std::string,int> Use; Use["Cuts"] =1; Use["BDT"] =1; // --------------------------------------------------------------- std::cout << std::endl; std::cout << "==> Start TMVAClassification" << std::endl; // Create a new root output file. TString outfileName( "TMVA_output.root" ); TFile* outputFile = TFile::Open( outfileName, "RECREATE" ); TMVA::Factory *factory = new TMVA::Factory( "TMVAClassification", outputFile, "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D" ); // Add the variables you want to consider //factory->AddVariable( "MT := MT", 'F' ); //factory->AddVariable( "nJets := nJets", 'F' ); factory->AddVariable( "MET := MET", 'F' ); factory->AddVariable( "MT2W := MT2W", 'F' ); factory->AddVariable( "dPhiMETjet := dPhiMETjet", 'F' ); factory->AddVariable( "HTratio := HTratio", 'F' ); factory->AddVariable( "HadronicChi2 := HadronicChi2", 'F' ); factory->AddVariable( "nWTag := nWTag", 'I' ); // Open samples TFile* f_signal = TFile::Open((string(MICROTUPLES_FOLDER)+"signal.root").c_str()); TFile* f_ttbar = TFile::Open((string(MICROTUPLES_FOLDER)+"ttbar.root" ).c_str()); //TFile* f_W2Jets = TFile::Open((string(MICROTUPLES_FOLDER)+"W2Jets.root").c_str()); //TFile* f_W3Jets = TFile::Open((string(MICROTUPLES_FOLDER)+"W3Jets.root").c_str()); //TFile* f_W4Jets = TFile::Open((string(MICROTUPLES_FOLDER)+"W4Jets.root").c_str()); TTree* signal = (TTree*) f_signal->Get("microTuple"); TTree* ttbar = (TTree*) f_ttbar ->Get("microTuple"); //TTree* W2Jets = (TTree*) f_W2Jets->Get("microTuple"); //TTree* W3Jets = (TTree*) f_W3Jets->Get("microTuple"); //TTree* W4Jets = (TTree*) f_W4Jets->Get("microTuple"); // Register the trees // float weightSignal = 1.0 * 20000.0 / getNumberOfEvent(signal); // float weightBackground = 225.2 * 20000.0 / getNumberOfEvent(ttbar); float weightSignal = 1.0; float weightBackground = 1.0; factory->AddSignalTree ( signal, weightSignal ); factory->AddBackgroundTree( ttbar, weightBackground); /* cout << " signal ; w = " << 1.0 * 20000.0 / getNumberOfEvent(signal) << endl; factory->AddSignalTree ( signal, 1.0 * 20000.0 / getNumberOfEvent(signal)); cout << " ttbar ; w = " << 225.2 * 20000.0 / getNumberOfEvent(ttbar) << endl; factory->AddBackgroundTree( ttbar, 234.0 * 20000.0 / getNumberOfEvent(ttbar)); cout << " W2Jets ; w = " << 2159 * 20000.0 / getNumberOfEvent(W2Jets) << endl; factory->AddBackgroundTree( W2Jets, 2159 * 20000.0 / getNumberOfEvent(W2Jets)); cout << " W3Jets ; w = " << 640 * 20000.0 / getNumberOfEvent(W3Jets) << endl; factory->AddBackgroundTree( W3Jets, 640 * 20000.0 / getNumberOfEvent(W3Jets)); cout << " W4Jets ; w = " << 264 * 20000.0 / getNumberOfEvent(W4Jets) << endl; factory->AddBackgroundTree( W4Jets, 264 * 20000.0 / getNumberOfEvent(W4Jets)); */ // Add preselection cuts std::string preselectionCutsSig("nJets > 4 && MET > 80 && MT > 100"); std::string preselectionCutsBkg("nJets > 4 && MET > 80 && MT > 100"); // Prepare the training factory->PrepareTrainingAndTestTree( preselectionCutsSig.c_str(), preselectionCutsBkg.c_str(), "nTrain_Signal=40000:nTrain_Background=300000:nTest_Signal=40000:nTest_Background=300000:SplitMode=Random:NormMode=EqualNumEvents:!V" ); // Cut optimisation //if (Use["Cuts"]) factory->BookMethod( TMVA::Types::kCuts, "Cuts", // "!H:!V:FitMethod=MC:EffSel:SampleSize=200000:VarProp=FSmart" ); if (Use["BDT"]) factory->BookMethod( TMVA::Types::kBDT, "BDT", "!H:!V:NTrees=400:nEventsMin=400:MaxDepth=3:BoostType=AdaBoost:SeparationType=GiniIndex:nCuts=20:PruneMethod=NoPruning"); // -------------------------------------------------------------- // Train MVAs using the set of training events factory->TrainAllMethodsForClassification(); // Evaluate all MVAs using the set of test events factory->TestAllMethods(); // Evaluate and compare performance of all configured MVAs factory->EvaluateAllMethods(); // -------------------------------------------------------------- // Save the output outputFile->Close(); std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl; std::cout << "==> TMVAClassification is done!" << std::endl; delete factory; // Launch the GUI for the root macros //if (!gROOT->IsBatch()) TMVAGui( outfileName ); }
void getSyst(){ TFile *output = new TFile("sysforshape.root","recreate"); const int Nsys = 10; TH1F *hSumSys[Ncate][Nregion]; for(int irg = 0; irg < Nregion ; irg ++){ loadTemplates(RegionsName[irg]); for(int icate=0;icate<Ncate;icate++){ sprintf(buffer_,"SumSys_cate%i%s",icate,RegionsName[irg].c_str()); hSumSys[icate][irg] = new TH1F(buffer_,"", htemplates[icate][Normal]->GetXaxis()->GetNbins(), htemplates[icate][Normal]->GetXaxis()->GetXmin(), htemplates[icate][Normal]->GetXaxis()->GetXmax()); TH1F *hUncs[Nsys]; printf("[ Cate %i loop]\n", icate); hUncs[0] = hdiff("XsecUnc", htemplates[icate][Normal], htemplates[icate][UncXsecPlus], htemplates[icate][UncXsecMinus]); hUncs[1] = hdiff("PUUnc", htemplates[icate][Normal], htemplates[icate][UncPUPlus], htemplates[icate][UncPUMinus]); hUncs[2] = hdiff("JESUnc", htemplates[icate][Normal], htemplates[icate][UncJESPlus], htemplates[icate][UncJESMinus]); hUncs[3] = hdiff("JERUnc", htemplates[icate][Normal], htemplates[icate][UncJERPlus], htemplates[icate][UncJERMinus]); hUncs[4] = hdiff("TrigUnc", htemplates[icate][Normal], htemplates[icate][UncTrigPlus], htemplates[icate][UncTrigMinus]); hUncs[5] = hdiff("PhoIDUnc", htemplates[icate][Normal], htemplates[icate][UncPhoIDPlus], htemplates[icate][UncPhoIDMinus]); hUncs[6] = hdiff("LepIDUnc", htemplates[icate][Normal], htemplates[icate][UncLepIDPlus], htemplates[icate][UncLepIDMinus]); hUncs[7] = hdiff("TopPtUnc", htemplates[icate][Normal], htemplates[icate][UncTopPtPlus], htemplates[icate][UncTopPtMinus]); hUncs[8] = hdiff("QsquareUnc", htemplates[icate][Normal], htemplates[icate][UncQsquarePlus], htemplates[icate][UncQsquareMinus]); hUncs[9] = hdiff("MatchingUnc", htemplates[icate][Normal], htemplates[icate][UncMatchingPlus], htemplates[icate][UncMatchingMinus]); getallsys(hSumSys[icate][irg], Nsys, hUncs, irg); TCanvas *c1 = new TCanvas("c1","",640,640); c1->Divide(5,2); for(int iu = 0;iu < Nsys;iu++){ c1->cd(iu+1); hUncs[iu]->Draw(); } sprintf(buffer_,"Merge%i%s_sys.pdf",icate,RegionsName[irg].c_str()); c1->SaveAs(buffer_); delete c1; } TCanvas *c1 = new TCanvas("c1","",640,640); c1->Divide(3,2); for(int icate=0;icate < Ncate;icate++){ c1->cd(icate + 1); hSumSys[icate][irg]->Draw(); output->cd(); hSumSys[icate][irg]->Write(); } sprintf(buffer_,"SumSys%s.pdf", RegionsName[irg].c_str()); c1->SaveAs(buffer_); } output->Close(); }
int main (int argc, char **argv) { TFile *tf = TFile::Open("root/AnalysisOut.root"); TTree *tree = (TTree*)tf->Get("AnalysisTree"); RooWorkspace *w = new RooWorkspace("w","w"); // tree variables Double_t t_mass; Double_t t_KST1_m; Double_t t_KST2_m; int t_itype; ULong64_t t_eventNumber; Bool_t t_pass_bdt; Bool_t t_pass_pid; TString *t_evname = 0; // tree branches tree->SetBranchAddress("B_s0_DTF_B_s0_M", &t_mass ); tree->SetBranchAddress("B_s0_DTF_KST1_M", &t_KST1_m ); tree->SetBranchAddress("B_s0_DTF_KST2_M", &t_KST2_m ); tree->SetBranchAddress("itype", &t_itype ); tree->SetBranchAddress("eventNumber", &t_eventNumber ); tree->SetBranchAddress("pass_bdt", &t_pass_bdt ); tree->SetBranchAddress("pass_pid", &t_pass_pid ); tree->SetBranchAddress("evname", &t_evname ); // observables RooRealVar *mass = new RooRealVar("B_s0_DTF_B_s0_M", "m(K#piK#pi)", 5000., 5800.); RooRealVar *KST1_mass = new RooRealVar("B_s0_DTF_KST1_M", "m(K#pi)" , 750, 1700 ); RooRealVar *KST2_mass = new RooRealVar("B_s0_DTF_KST2_M", "m(K#pi)" , 750, 1700 ); RooRealVar *itype = new RooRealVar("itype","itype",-10,10); itype->removeRange(); RooRealVar *eventNumber = new RooRealVar("eventNumber","eventNumber",0,10e10); // map to store datasets map<int, RooDataSet*> dsets; for ( int ev=0; ev<tree->GetEntries(); ev++ ) { tree->GetEntry(ev); if ( t_itype >= 0 && !t_pass_bdt ) continue; if ( t_itype >= 0 && !t_pass_pid ) continue; // if entry not in map then add it if ( dsets.find( t_itype ) == dsets.end() ) { dsets[t_itype] = new RooDataSet( *t_evname, *t_evname, RooArgSet(*mass,*KST1_mass,*KST2_mass,*itype,*eventNumber) ); } // add to dataset mass->setVal( t_mass ); KST1_mass->setVal( t_KST1_m ); KST2_mass->setVal( t_KST2_m ); itype->setVal( t_itype ); eventNumber->setVal( t_eventNumber ); dsets[t_itype]->add( RooArgSet(*mass,*KST1_mass,*KST2_mass,*itype,*eventNumber) ); if ( ev%10000==0 ) { cout << ev << "/" << tree->GetEntries() << endl; cout << "\t" << t_itype << " " << *t_evname << " " << t_eventNumber << " " << t_mass << endl; } } for ( map<int, RooDataSet*>::iterator it = dsets.begin(); it != dsets.end(); it++ ) { cout << "\t" << it->first << " " << it->second->GetName() << " " << it->second->numEntries() << endl; w->import(*it->second); } tf->Close(); delete t_evname; w->writeToFile("tmp/DataSets.root"); return 0; }
void macroMuonZNormXSec(TString sys="sysNo", bool output=true, bool append=false) { // detailed output for debugging int verbose=1; applySystematicVariations(sys); fillXSecTTbarIncl_(); if(verbose) std::cout<<"systematic variation: " <<sys<< "; lumi="<<luminosity<<"; effSF="<<effSFAB<<std::endl; // ------------------------------------------------------------------------------------ // open efficiency input files, get efficiencies and correct with effSF // ------------------------------------------------------------------------------------ // file with efficiency histos TFile *effFile = new TFile(folderResults+whichFile+"_efficiencyHistos.root"); // map of doubles as container for individual efficiencies std::map< TString, double> efficiencies_; // name of efficiencies TString effNames_[] = {"effRecoVisibleMad","effRecoInclMad","effRecoInclPow"}; unsigned int NEff = sizeof(effNames_)/sizeof(TString); std::cout << "size of effPlots_ array: " << NEff << std::endl; // loop over efficiencies except Powheg for(unsigned int iEff=0; iEff<NEff-1; iEff++) { // get efficiencies from histo efficiencies_[effNames_[iEff]] = ((TH1F*)effFile->Get(effNames_[iEff]))->GetBinContent(1); if(verbose) std::cout<<"Before SF correction: "<<effNames_[iEff]<<": "<<efficiencies_[effNames_[iEff]]<<std::endl; // correct efficiencies with effSF efficiencies_[effNames_[iEff]] *= effSFAB; if(verbose) std::cout<<"After SF correction: "<<effNames_[iEff]<<": "<<efficiencies_[effNames_[iEff]]<<std::endl; } // calculate total efficiency corrected by Powheg acceptance efficiencies_["effRecoInclPow"] = efficiencies_["effRecoInclMad"]*effAccRatioPowOverMad; if(verbose) std::cout<<"effRecoInclPow"<<": "<<efficiencies_["effRecoInclPow"]<<std::endl; // histo with acceptance for Madgraph (not needed, just to save) double effAccKinMad = ((TH1F*)effFile->Get("effAccKinMad"))->GetBinContent(1); if(verbose) std::cout<<"effAccKinMad: "<<effAccKinMad<<std::endl; // ------------------------------------------------------------------------------------ // open yield input files and get yields // ------------------------------------------------------------------------------------ // file with yield histos TFile *yieldFile = new TFile(folderResults+whichFile+"_lumiweightedAndAddedHistos.root"); // map of doubles as container for individual efficiencies std::map< int, double> yields_; // yield map entry for the summed background (arbitrary number 86) yields_[86] = 0; for(int idx=kZMuMu; idx<=kData; idx++) { // get yield from the muon multiplicity bin 2 (i.e. bin #3) yields_[idx] = ((TH1F*)yieldFile->Get(sampleEnum(idx)+"_"+"tightMuonPair2ZRes_nMu"))->GetBinContent(3); // sum up background if(idx!=kZMuMu && idx!= kData) yields_[86] +=yields_[idx]; if(verbose) std::cout<<"yield("<<sampleEnum(idx)<<") = "<<yields_[idx]<<std::endl; } if(verbose) std::cout<<"yield(background) = "<<yields_[86]<<std::endl; // ------------------------------------------------------------------------------------ // calculate cross sections from yields and efficiencies // ------------------------------------------------------------------------------------ // map of doubles as container for cross sections and cross section ratios std::map< TString, double> xSecZ_; std::map< TString, double> xSecZRatioMeasOverTheo_; std::map< TString, double> xSecRatioTTbarInclOverZ_; std::map< TString, double> xSecRatioTTbarVisOverZ_; std::map< TString, double> xSecTTbarNorm_; double xSecStatErr = 0.; // name of efficiencies TString xSecNames_[] = {"xSecVisibleMad","xSecInclMad","xSecInclPow"}; unsigned int NxSec = sizeof(xSecNames_)/sizeof(TString); std::cout << "size of xSecPlots_ array: " << NxSec << std::endl; for(unsigned int iEff=0; iEff<NxSec; iEff++) { // calculate the Z cross section with the master formula xSecZ_[ xSecNames_[iEff]] = (yields_[kData] - yields_[86]) / (efficiencies_[effNames_[iEff]] * luminosity); if(verbose) std::cout<<"Z cross section ("<<xSecNames_[iEff]<<") = "<<xSecZ_[ xSecNames_[iEff]]<<std::endl; // calculate the ratio between measured and theoretical Z cross section xSecZRatioMeasOverTheo_[ xSecNames_[iEff]] = xSecZ_[ xSecNames_[iEff]] / xSecZTheo; if(verbose) std::cout<<"Z cross section ratio (meas/theo) ("<<xSecNames_[iEff]<<") = "<<xSecZRatioMeasOverTheo_[ xSecNames_[iEff]]<<std::endl; // calculate the ratio between ttbar (inclusive) and Z cross section xSecRatioTTbarInclOverZ_[ xSecNames_[iEff]] = xSecTTbarIncl_[sys] / xSecZ_[ xSecNames_[iEff]]; if(verbose) std::cout<<"Cross section ratio (ttbar inclusive/Z) ("<<xSecNames_[iEff]<<") = "<<xSecRatioTTbarInclOverZ_[ xSecNames_[iEff]]<<std::endl; // calculate the ratio between ttbar (visible) and Z cross section xSecRatioTTbarVisOverZ_[ xSecNames_[iEff]] = xSecTTbarVisible / xSecZ_[ xSecNames_[iEff]]; if(verbose) std::cout<<"Cross section ratio (ttbar visible/Z) ("<<xSecNames_[iEff]<<") = "<<xSecRatioTTbarVisOverZ_[ xSecNames_[iEff]]<<std::endl; // calculate ttbar cross section by normalization to Z cross section if(xSecNames_[iEff]!="xSecVisibleMad") { xSecTTbarNorm_[ xSecNames_[iEff]] = xSecRatioTTbarInclOverZ_[ xSecNames_[iEff]] * xSecZTheo; if(verbose) std::cout<<"***** Normalized ttbar cross section (ttbar meas/Z meas * Z theo) ("<<xSecNames_[iEff]<<") = "<<xSecTTbarNorm_[ xSecNames_[iEff]]<<std::endl; } } // calculate statistical cross section error in % xSecStatErr = TMath::Sqrt(yields_[kData]) / (yields_[kData] - yields_[86]); if(verbose) std::cout << "Statistical xSec Err= " << xSecStatErr << std::endl; // ------------------------------------------------------------------------------------ // write and save output // ------------------------------------------------------------------------------------ // saves the most important output parameters into text files: // fXSec -> _xSecResults.txt : cross section values // fEffYield -> _effYieldResults.txt : efficiencies and yields if(output) { std::ofstream fXSec, fEffYield; if(append) { fXSec.open(folderResults+whichFile+"_xSecResults.txt", ios::app); fEffYield.open(folderResults+whichFile+"_effYieldResults.txt", ios::app); } else { fXSec.open(folderResults+whichFile+"_xSecResults.txt"); fEffYield.open(folderResults+whichFile+"_effYieldResults.txt"); // writing headlines at the beginning fXSec << "sysVariation" <<tab<< "xSecZVisMad" <<tab<< "xSecZInclMad" <<tab<< "xSecZInclPow" <<tab<< "xSecStatErr[%]" <<tab<< "ttbarVis(noVar)" <<tab<< "ttbarIncl" <<tab<< "ttbarOverZMad vis" <<tab<< "ttbarOverZMad incl" <<tab<< "ttbarOverZPow incl" <<tab<< "ZmeasOverTheoMad" <<tab<< "ZmeasOverTheoPow" <<tab<< "ttbarNormMad" <<tab<< "ttbarNormPow" << std::endl; fEffYield << "sysVariation" <<tab<< "effRecoVisMad" <<tab<< "effAccKinMad" <<tab<< "effRecoInclMad" <<tab<< "effRecoInclPow" <<tab<< "NData" <<tab<< "NZMuMu" <<tab<< "NBg" <<tab<< "NZTauTau" <<tab<< "NTTbar" <<tab << "NWjets" <<tab<< "NQCD" <<tab<< "NSTop" <<tab<< "NDiBos" << std::endl; } fXSec << sys // Z cross section <<tab<< xSecZ_["xSecVisibleMad"] <<tab<< xSecZ_["xSecInclMad"] <<tab<< xSecZ_["xSecInclPow"] // statistical Z cross section error [%] <<tab<< xSecStatErr // ttbar cross section (visible without sysVar, inclusive with sysVar) <<tab<< xSecTTbarVisible <<tab<< xSecTTbarIncl_[sys] // ttbar / Z cross section <<tab<< xSecRatioTTbarVisOverZ_["xSecVisibleMad"] <<tab<< xSecRatioTTbarInclOverZ_["xSecInclMad"] <<tab<< xSecRatioTTbarInclOverZ_["xSecInclPow"] // Z_meas / Z_theo cross section <<tab<< xSecZRatioMeasOverTheo_["xSecInclMad"] <<tab<< xSecZRatioMeasOverTheo_["xSecInclPow"] // normalized ttbar cross section <<tab<< xSecTTbarNorm_["xSecInclMad"] <<tab<< xSecTTbarNorm_["xSecInclPow"] <<std::endl; fEffYield << sys // efficiencies <<tab<< efficiencies_["effRecoVisibleMad"] <<tab<< effAccKinMad <<tab<< efficiencies_["effRecoInclMad"] <<tab<< efficiencies_["effRecoInclPow"] // yields <<tab<< yields_[kData] <<tab<< yields_[kZMuMu] <<tab<< yields_[86] <<tab<< yields_[kZTauTau] <<tab<< yields_[kTTbar] <<tab<< yields_[kWjets] <<tab<< yields_[kQCD] <<tab<< yields_[kSTop] <<tab<< yields_[kDiBos] <<std::endl; fXSec.close(); fEffYield.close(); std::cout << "Output files " << folderResults+whichFile+"_xSecResults.txt" << " and _effYieldResults.txt written" << std::endl; } else std::cout << "No output file written" << std::endl; }
void clusterDFSReso() { TFile* file = new TFile("complete.root"); TTree* tree = (TTree *)file->Get("Signal"); int nEvents = tree->GetEntries(); double addresses[121] = {}; for (int k=0; k<121; k++){ std::stringstream ss2; ss2 << k; string str = "Crystal_"+ss2.str(); const char* charstr = str.c_str(); tree->SetBranchAddress(charstr, &addresses[k]); } TH1D* energyResoD = new TH1D("energyResoD", "DFS_Energy_Resolution", gammaEnergy/5, -1*gammaEnergy, gammaEnergy); TH1D* posResoDX = new TH1D("posResoD", "DFS_PosX_Resolution", 1000, -5, 5); TH1D* posResoDY = new TH1D("posResoD", "DFS_PosY_Resolution", 1000, -5, 5); double energyThresHi = 50.; //set energy threshold to start looking for bumps double energyThresLo = .5; //energy lower bound //Going through each scan of the calorimeter for (int k=0; k<nEvents; k++) { tree->GetEntry(k); cout << "Event number: " << k << endl; pair<int, double> bump(0, 0.); vector<pair<int, double> > geant; vector<pair<int, double> > hitMap; for(int i=0; i<121; i++) { pair<int, double> hit(i, addresses[i]); geant.push_back(hit); if (addresses[i] > energyThresHi) { hitMap.push_back(hit);} if (hit.second>bump.second) { bump = hit;} } // hitMap now stores the <ID, energy> of each crystal with energy // over a certain threshold, geant now contains all crystal information std::vector<std::vector<std::pair<int, double> > > detector; std::vector<std::pair<int, double> > shower; detector.push_back(DFS(bump, energyThresLo, shower, addresses)); //detector = uncluster(detector, hitMap); // no longer counts two showers if bumps are next to each other int num = 9; // number of crystals considered for (VVP_iterator=detector.begin(); VVP_iterator!=detector.end(); ++VVP_iterator) { energyResoD->Fill(reconstruct(detector[0]).first-gammaEnergy); posResoDX->Fill(reconstruct(detector[0]).second.first); posResoDY->Fill(reconstruct(detector[0]).second.second); } } //end of event TCanvas* canvas = new TCanvas("canvas", "canvas", 700,700); canvas->Divide(2, 2); TF1* g1dX = new TF1("g1dX", "gaus", -5, 5); posResoDX->Fit(g1dX); canvas->cd(1); posResoDX->Draw(); TF1* g1dY = new TF1("g1dY", "gaus", -5, 5); posResoDY->Fit(g1dY); canvas->cd(2); posResoDY->Draw(); TF1* g1d = new TF1("g1d", "gaus", -10, 10); energyResoD->Fit(g1d); canvas->cd(3); energyResoD->Draw(); }
int main( int argc, char* argv[] ) { DrawTools::setStyle(); std::string tag = "V00"; std::string config = "SiPM2015Config"; if( argc>1 ) { std::string tag_str(argv[1]); tag = tag_str; if( argc>2 ) { std::string config_str(argv[2]); config=config_str; } } else { std::cout << "Usage:" << std::endl; std::cout << "./timingStudies ([tag]) ([config])" << std::endl; exit(12345); } std::cout<<config<<std::endl; theConfiguration_=readConfiguration(config); std::vector<float> energies; std::vector<int> wp_channel; std::vector<int> wp_fibre; std::vector<int> runs; for (int i=0;i<theConfiguration_.energies.size();++i){ energies.push_back(theConfiguration_.energies[i]); wp_channel.push_back(theConfiguration_.wp_channel[i]); wp_fibre.push_back(theConfiguration_.wp_fibre[i]); runs.push_back(theConfiguration_.runs[i]); } std::string constDirName = "plots_timing_"; constDirName+=theConfiguration_.setup; system(Form("mkdir -p %s", constDirName.c_str())); TString dir(constDirName); TGraphErrors* resVsEnergy_channel = new TGraphErrors(0); TGraphErrors* resVsEnergy_fibre = new TGraphErrors(0); std::vector<TGraphErrors*> resVsAmplitude; for (int i=0;i<runs.size();++i){ TString run; run.Form("%d",runs[i]); resVsAmplitude.push_back(new TGraphErrors(0)); TFile* file = TFile::Open(dir+"/timingStudiesSiPM_"+tag+"_"+run+".root"); if( file==0 ) { std::cout << "ERROR! Din't find file for run" << runs[i] << std::endl; std::cout << "Exiting." << std::endl; exit(11); } //channel TVectorD* resValueTime_channel=(TVectorD*)file->Get("resValueTime_channel"); TVectorD* resErrValueTime_channel=(TVectorD*)file->Get("resErrValueTime_channel"); TVectorD* resValueAmplitude_channel=(TVectorD*)file->Get("resValueAmplitude_channel"); TVectorD* resErrValueAmplitude_channel=(TVectorD*)file->Get("resErrValueAmplitude_channel"); TVectorD* resErrRelativeValueTime_channel=(TVectorD*)file->Get("resErrRelativeValueTime_channel"); TVectorD* nEntriesTime_channel=(TVectorD*)file->Get("nEntriesTime_channel"); //fibre TVectorD* resValueTime_fibre=(TVectorD*)file->Get("resValueTime_fibre"); TVectorD* resErrValueTime_fibre=(TVectorD*)file->Get("resErrValueTime_fibre"); // resVsEnergy->SetPoint( i, energies[i],(*resValueTime)[wp_100[i]] ); //FIXME resVsEnergy->SetPointError( i, 0, (*resErrValueTime)[wp_100[i]]); resVsEnergy_channel->SetPoint( i, energies[i], (*resValueTime_channel)[wp_channel[i]]); resVsEnergy_channel->SetPointError( i, 0,(*resErrValueTime_channel)[wp_channel[i]] ); resVsEnergy_fibre->SetPoint( i, energies[i], (*resValueTime_fibre)[wp_fibre[i]]); resVsEnergy_fibre->SetPointError( i, 0,(*resErrValueTime_fibre)[wp_fibre[i]] ); for (int j=0;j<resValueTime_channel->GetNoElements();j++){ // std::cout<<j<<" "<<(*resValueAmplitude_channel)[j]<<std::endl; if ((*resValueAmplitude_channel)[j]<10)continue; resVsAmplitude[i]->SetPoint(j,(20+j*10),(*resValueAmplitude_channel)[j]); resVsAmplitude[i]->SetPointError(j,0,(*resErrValueAmplitude_channel)[j]); } } TFile * outFile = new TFile(dir+"/plotsTimingStudiesSiPM_"+tag+".root","recreate"); TCanvas* c1 = new TCanvas( "c1", "", 600, 600 ); float yup=1.1*(resVsAmplitude[2]->GetY())[0]; if((resVsAmplitude[2]->GetY())[0]<10) yup = 1.1*(resVsAmplitude[1]->GetY())[0]; float xlow=(resVsAmplitude[2]->GetX())[0]-10; if(xlow<10)xlow = (resVsAmplitude[1]->GetX())[0]-10; float xup=(resVsAmplitude[2]->GetX())[resVsAmplitude[2]->GetN()-1]+10; if(xup<10)xup = (resVsAmplitude[2]->GetX())[resVsAmplitude[2]->GetN()-1]+10; TH2D* h2_axes_2 = new TH2D( "axes_2", "", 100, xlow,xup , 110, 0., yup); // std::cout<<(resVsEnergy_channel->GetY())[0]+(resVsEnergy_channel->GetErrorY(0))<<std::endl; TH2D* h2_axes_3 = new TH2D( "axes_1", "", 100, -0.0, 250. , 110, 60., 1.1*((resVsEnergy_channel->GetY())[0]+(resVsEnergy_channel->GetErrorY(0)))); h2_axes_3->SetXTitle("Beam Energy [GeV]"); h2_axes_3->SetYTitle("time_{Fibre}-time_{mcp} [ps]"); TH2D* h2_axes_4 = new TH2D( "axes_1", "", 100, -0.0, 250. , 110, 60., 1.1*((resVsEnergy_fibre->GetY())[0]+(resVsEnergy_fibre->GetErrorY(0)))); h2_axes_4->SetXTitle("Beam Energy [GeV]"); h2_axes_4->SetYTitle("time_{Fibre}-time_{mcp} [ps]"); //resolution vs energy //channel TF1* f_ene= new TF1("fun_ene","[1]/x+[0]",(resVsEnergy_channel->GetX())[0]-10,(resVsEnergy_channel->GetX())[resVsEnergy_channel->GetN()-1] +10); h2_axes_3->Draw(""); resVsEnergy_channel->Fit("fun_ene"); TLegend* lego_2 = new TLegend(0.47, 0.7, 0.8, 0.92); lego_2->SetTextSize(0.038); lego_2->AddEntry( (TObject*)0 ,"f(x) = p0 + p1/x", ""); lego_2->AddEntry( (TObject*)0 ,Form("p0 = %.0f #pm %.0f", f_ene->GetParameter(0), f_ene->GetParError(0) ), ""); lego_2->AddEntry( (TObject*)0 ,Form("p1 = %.0f #pm %.0f", f_ene->GetParameter(1), f_ene->GetParError(1) ), ""); lego_2->SetFillColor(0); lego_2->Draw("same"); resVsEnergy_channel->SetMarkerStyle(20); resVsEnergy_channel->SetMarkerSize(1.6); resVsEnergy_channel->SetMarkerColor(kBlue); resVsEnergy_channel->Draw("p same"); resVsEnergy_channel->SetName("resVsEnergy_channel"); resVsEnergy_channel->Write(); c1->SaveAs(dir+"/timingResolutionVsEnergySiPM_channel.png"); c1->SaveAs(dir+"/timingResolutionVsEnergySiPM_channel.pdf"); //fibre h2_axes_4->Draw(""); resVsEnergy_fibre->Fit("fun_ene"); lego_2->Clear(); lego_2->SetTextSize(0.038); lego_2->AddEntry( (TObject*)0 ,"f(x) = p0 + p1/x", ""); lego_2->AddEntry( (TObject*)0 ,Form("p0 = %.0f #pm %.0f", f_ene->GetParameter(0), f_ene->GetParError(0) ), ""); lego_2->AddEntry( (TObject*)0 ,Form("p1 = %.0f #pm %.0f", f_ene->GetParameter(1), f_ene->GetParError(1) ), ""); lego_2->SetFillColor(0); lego_2->Draw("same"); resVsEnergy_fibre->SetMarkerStyle(20); resVsEnergy_fibre->SetMarkerSize(1.6); resVsEnergy_fibre->SetMarkerColor(kBlue); resVsEnergy_fibre->Draw("p same"); resVsEnergy_fibre->SetName("resVsEnergy_fibre"); resVsEnergy_fibre->Write(); c1->SaveAs(dir+"/timingResolutionVsEnergySiPM_fibre.png"); c1->SaveAs(dir+"/timingResolutionVsEnergySiPM_fibre.pdf"); for(int i=0;i<runs.size();++i){ TString ene; ene.Form("%.0f",energies[i]); std::string energy(Form("%.0f", energies[i])); h2_axes_2->SetYTitle("#sigma_{t} [ps]"); h2_axes_2->GetXaxis()->SetTitle("Amplitude [ADC]"); h2_axes_2->Draw(""); TF1* f= new TF1("fun","[1]/x+[0]",(resVsAmplitude[i]->GetX())[0]-10,(resVsAmplitude[i]->GetX())[resVsAmplitude[i]->GetN()-1] +10); resVsAmplitude[i]->Fit("fun"); resVsAmplitude[i]->SetName("resVsAmplitude_"+ene); resVsAmplitude[i]->SetMarkerStyle(20); resVsAmplitude[i]->SetMarkerSize(1.6); resVsAmplitude[i]->SetMarkerColor(kBlue); resVsAmplitude[i]->Draw("p same"); TPaveText* pave = DrawTools::getLabelTop_expOnXaxis(energy+" GeV Electron Beam"); pave->Draw("same"); TLegend* lego = new TLegend(0.47, 0.7, 0.8, 0.92); lego->SetTextSize(0.038); lego->AddEntry( (TObject*)0 ,"f(x) = p0 + p1/x", ""); lego->AddEntry( (TObject*)0 ,Form("p0 = %.0f #pm %.0f", f->GetParameter(0), f->GetParError(0) ), ""); lego->AddEntry( (TObject*)0 ,Form("p1 = %.0f #pm %.0f", f->GetParameter(1), f->GetParError(1) ), ""); lego->SetFillColor(0); lego->Draw("same"); c1->SaveAs(dir+"/timingResolutionVsAmplitudeSiPM_"+ene+"GeV.png"); c1->SaveAs(dir+"/timingResolutionVsAmplitudeSiPM_"+ene+"GeV.pdf"); resVsAmplitude[i]->Write(); } outFile->Write(); outFile->Close(); return 0; }
void MakeSnapshot(Int_t run, const char* defStorage, TMap* specStorages, const char* snapshotFileName) { AliCDBManager *cdb = AliCDBManager::Instance(); cdb->SetDefaultStorage(defStorage); cdb->SetRun(run); TIter iter(specStorages->GetTable()); TPair *pair = 0; while((pair = dynamic_cast<TPair*> (iter.Next()))){ TObjString* caltype = dynamic_cast<TObjString*> (pair->Key()); TObjString* specstor= dynamic_cast<TObjString*> (pair->Value()); if (caltype && specstor) //TString calType = caltype->GetString(); //TString specStor = specstor->GetString(); //cdb->SetSpecificStorage(calType.Data(),specStor.Data()); cdb->SetSpecificStorage(caltype->GetString().Data(),specstor->GetString().Data()); else //AliFatal("Error reading info for specific storage") Printf("Error reading info for specific storage"); } // ********************************** GRP ****************************************** cdb->Get("GRP/CTP/Config"); cdb->Get("GRP/Calib/LHCClockPhase"); cdb->Get("GRP/GRP/Data"); cdb->Get("GRP/Align/Data"); cdb->Get("GRP/Calib/MeanVertexSPD"); cdb->Get("GRP/Calib/MeanVertex"); cdb->Get("GRP/Calib/MeanVertexTPC"); cdb->Get("GRP/Calib/CosmicTriggers"); cdb->Get("GRP/CTP/Scalers"); cdb->Get("GRP/CTP/CTPtiming"); cdb->Get("GRP/CTP/TimeAlign"); cdb->Get("GRP/GRP/LHCData"); cdb->Get("GRP/Calib/RecoParam"); // ********************************** ALL ****************************************** TString detStr = ("ITS TPC TRD TOF PHOS HMPID EMCAL MUON ZDC PMD T0 VZERO"); //TString detStr = ("ITS MUON TPC"); TObjArray *arr = detStr.Tokenize(' '); for (Int_t iDet=0; iDet<arr->GetEntries(); iDet++) { TObjString *detOStr = dynamic_cast<TObjString*>(arr->At(iDet)); AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",detOStr->GetString().Data())); AliCDBManager::Instance()->Get(Form("%s/Align/Data",detOStr->GetString().Data())); } // ******************************** TRIGGER **************************************** // Temporary fix - one has to define the correct policy in order // to load the trigger OCDB entries only for the detectors that // in the trigger or that are needed in order to put correct // information in ESD AliCDBManager::Instance()->GetAll("TRIGGER/*/*"); // ********************************** HLT ****************************************** // cdb->Get("HLT/ConfigHLT/esdLayout"); // cdb->Get("HLT/Calib/StreamerInfo"); TMap* entriesMap = const_cast<TMap*>(cdb->GetEntryCache()); Printf("\nentriesMap has %d entries!\n", entriesMap->GetEntries()); TList* entriesList = const_cast<TList*>(cdb->GetRetrievedIds()); Printf("\nentriesList has %d entries!\n", entriesList->GetEntries()); //TString filename(TString::Format("CDBsnapshot_Run%d.root",run)); TString filename(snapshotFileName); TFile *f = new TFile(filename.Data(),"recreate"); f->cd(); f->WriteObject(entriesMap,"entriesMap"); f->WriteObject(entriesList,"entriesList"); f->Close(); entriesMap->SetOwnerKeyValue(kFALSE,kFALSE); entriesList->SetOwner(kFALSE); }
void TnPEffTrkDraw_etabin3_1st_for_B () { gROOT->Macro("rootlogon.C"); // input your tnp_Ana_*.root files instead of "_input_file_" char *files[maxFile_] = { "tnp_pPb_Ana_MuTrketabin3_2GpP4_1st_Run_All_for_B_test.root", // "tnp_pPb_Ana_MuTrketabin3_2GpP4_MC_All_for_B_test.root", }; TString outname_in, outname_mid, outname_out; TString middle_name, middle_name2; TString leg_title; int Mode = 0; TFile *outfile = new TFile(outfile_,"RECREATE"); for(int l = 0; l < maxFile_; l++){ char *infile = files[l]; TFile *f = new TFile(infile); Mode = l; if(Mode == 0){ middle_name = "All"; middle_name2 = "MinBias"; }else if(Mode == 1){ middle_name = "0005"; middle_name2 = "0 - 5 %"; }else if(Mode == 2){ middle_name = "0510"; middle_name2 = "5 - 10 %"; }else if(Mode == 3){ middle_name = "1020"; middle_name2 = "10 - 20 %"; }else if(Mode == 4){ middle_name = "2030"; middle_name2 = "20 - 30 %"; }else if(Mode == 5){ middle_name = "3040"; middle_name2 = "30 - 40 %"; }else if(Mode == 6){ middle_name = "5050"; middle_name2 = "40 - 50 %"; }else if(Mode == 7){ middle_name = "5060"; middle_name2 = "50 - 60 %"; }else if(Mode == 8){ middle_name = "60100"; middle_name2 = "60 - 100 %"; } gROOT->SetStyle("Plain"); gStyle->SetOptStat(0); gStyle->SetTitle(0); // if you have only one file, should change the number 4 -> 1 TString mid_title = "Centrality : (" + middle_name2 + ")"; if(!MC_) leg_title = "Data Inner Tracking Efficiency (" + middle_name2 + ")"; if(MC_) leg_title = "MC Inner Tracking Efficiency (" + middle_name2 + ")"; TCanvas *c1 = new TCanvas("c1","",120,20,800,600); f->cd(); RooDataSet *daTrkEta1bin = (RooDataSet*)f->Get("MuonTrketabin3/isTrk_1bin_pt_eta/fit_eff"); TGraphAsymmErrors *Trk_1bin_pt_eta = plotEffEta(daTrkEta1bin, 1); double Trk[4]; Trk_1bin_pt_eta->GetPoint(0,Trk[0],Trk[1]); Trk[2] = Trk_1bin_pt_eta->GetErrorYhigh(0); Trk[3] = Trk_1bin_pt_eta->GetErrorYlow(0); RooDataSet *daTrkPt = (RooDataSet*)f->Get("MuonTrketabin3/isTrk_pt/fit_eff"); TGraphAsymmErrors *Trk_pt = plotEffPt(daTrkPt, 1); /* RooDataSet *daTrk2D = (RooDataSet*)f->Get("MuonTrk/is_Trk_pt_eta/fit_eff"); TString twoDName1 = "Trk_2d"; TH2F *Trk_2d = plotEff2D(daTrk2D, twoDName1); */ char legs[512]; TString pic_name_png, pic_name_pdf; Trk_pt->GetXaxis()->SetLabelSize(0.05); Trk_pt->GetYaxis()->SetLabelSize(0.05); Trk_pt->GetXaxis()->SetTitleSize(0.05); Trk_pt->GetYaxis()->SetTitleSize(0.05); Trk_pt->GetXaxis()->SetTitleOffset(0.9); Trk_pt->GetYaxis()->SetTitleOffset(0.8); Trk_pt->SetMarkerColor(kRed+2); Trk_pt->Draw("apz"); TLegend *leg2 = new TLegend(0.3454774,0.2167832,0.5429648,0.4458042,NULL,"brNDC"); leg2->SetFillStyle(0); leg2->SetFillColor(0); leg2->SetBorderSize(0); leg2->SetTextSize(0.04); leg2->SetHeader(leg_title); sprintf(legs,"Inner Tracking Efficiency: %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[1],Trk[2],Trk[3]); leg2->AddEntry(Trk_pt,legs,"pl"); leg2->Draw("same"); if(MC_){ pic_name_png = "Jpsi_pPb_MC_Trketabin3_" + middle_name + "_pt_for_B_test.png"; pic_name_pdf = "Jpsi_pPb_MC_Trketabin3_" + middle_name + "_pt_for_B_test.pdf"; }else{ pic_name_png = "Jpsi_pPb_RD_Trketabin3_1st_run_" + middle_name + "_pt_for_B_test.png"; pic_name_pdf = "Jpsi_pPb_RD_Trketabin3_1st_run_" + middle_name + "_pt_for_B_test.pdf"; } c1->SaveAs(pic_name_png); c1->SaveAs(pic_name_pdf); /* Trk_2d->Draw(); pic_name_png = "Jpsi_pPb_MC_Trk_" + middle_name + "_2d.png"; pic_name_pdf = "Jpsi_pPb_MC_Trk_" + middle_name + "_2d.pdf"; c1->SaveAs(pic_name_png); c1->SaveAs(pic_name_pdf); c1->Print("Jpsi_pPb_MC_Trk_Eff_total.ps"); */ TString Trkna1, Trkna2, Trkna3, Trkna4; Trkna1 = "Trk_eta_" + middle_name; Trkna2 = "Trk_1bin_pt_eta_" + middle_name; Trkna3 = "Trk_pt_" + middle_name; Trkna4 = "Trk_2d_" + middle_name; Trk_1bin_pt_eta->SetName(Trkna2); Trk_pt->SetName(Trkna3); //Trk_2d->SetName(Trkna4); outfile->cd(); Trk_pt->Write(); Trk_1bin_pt_eta->Write(); //Trk_2d->Write(); } // Comparing Plots as the Centralities TH1F *hPadEta = new TH1F("hPadEta","",15,-2.4,2.4); TH1F *hPadPt = new TH1F("hPadPt","",12,0,30); TCanvas *c2 = new TCanvas("c2","",120,20,800,600); //c2->cd(); TGraphAsymmErrors *gTrk[maxFile_]; TGraphAsymmErrors *gTrkPt[maxFile_]; double Trk[maxFile_][4]; for(int i = 0; i < maxFile_; i++){ TFile finput(files[i]); finput.cd(); RooDataSet *dataTrkPt = (RooDataSet*)finput.Get("MuonTrketabin3/isTrk_pt/fit_eff"); gTrkPt[i] = plotEffPt(dataTrkPt, 0); } TGraphAsymmErrors *pCNT = new TGraphAsymmErrors(3); TGraphAsymmErrors *pMBCNT = new TGraphAsymmErrors(); if(Cent_){ pCNT->SetPoint(0,10,Trk[1][1]); pCNT->SetPointError(0,0,0,Trk[1][3],Trk[1][2]); pCNT->SetPoint(1,20,Trk[2][1]); pCNT->SetPointError(1,0,0,Trk[2][3],Trk[2][2]); pCNT->SetPoint(2,30,Trk[3][1]); pCNT->SetPointError(2,0,0,Trk[3][3],Trk[3][2]); pCNT->SetPoint(3,40,Trk[4][1]); pCNT->SetPointError(3,0,0,Trk[4][3],Trk[4][2]); pCNT->SetPoint(4,50,Trk[5][1]); pCNT->SetPointError(4,0,0,Trk[5][3],Trk[5][2]); pCNT->SetPoint(5,60,Trk[6][1]); pCNT->SetPointError(5,0,0,Trk[6][3],Trk[6][2]); pCNT->SetPoint(6,70,Trk[7][1]); pCNT->SetPointError(6,0,0,Trk[7][3],Trk[7][2]); pCNT->SetPoint(7,80,Trk[8][1]); pCNT->SetPointError(7,0,0,Trk[8][3],Trk[8][2]); pCNT->SetMarkerColor(kRed+2); pCNT->SetMarkerStyle(20); } pMBCNT->SetPoint(0,113.0528,Trk[0][1]); pMBCNT->SetPointError(0,0,0,Trk[0][3],Trk[0][2]); pMBCNT->SetMarkerColor(kRed+2); pMBCNT->SetMarkerStyle(24); gStyle->SetOptStat(0); TH1F *hPad = new TH1F("hPad","",40,0,40); hPad->SetTitle(""); formatTH1F(hPad,1,1,4); hPad->Draw(); hPad->GetYaxis()->SetTitle("Efficiency"); hPad->GetXaxis()->SetTitle("Centrality bin"); if(Cent_) pCNT->Draw("pz same"); pMBCNT->Draw("pz same"); char legs[512]; TLegend *leg1 = new TLegend(0.369849,0.1853147,0.6809045,0.4527972,NULL,"brNDC"); // Size 0.03 leg1->SetFillStyle(0); leg1->SetFillColor(0); leg1->SetBorderSize(0); leg1->SetTextSize(0.03); leg1->SetHeader(leg_title); if(Cent_) leg1->AddEntry(pCNT,"Inner Tracking Efficiency","pl"); sprintf(legs,"Inner Tracking Efficiency: %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[0][1],Trk[0][2],Trk[0][3]); leg1->AddEntry(pMBCNT,legs,"pl"); leg1->Draw("same"); if(MC_){ /* c2->SaveAs("Jpsi_pPb_for_B_MC_Trk_CNT.png"); c2->SaveAs("Jpsi_pPb_for_B_MC_Trk_CNT.pdf"); */ }else{ /* c2->SaveAs("Jpsi_pPb_RD_Trketabin3_1st_run_CNT_test.png"); c2->SaveAs("Jpsi_pPb_RD_Trketabin3_1st_run_CNT_test.pdf"); */ /* c2->SaveAs("Jpsi_pPb_RD_Trketabin2_1st_run_CNT_test.png"); c2->SaveAs("Jpsi_pPb_RD_Trketabin2_1st_run_CNT_test.pdf"); */ /* c2->SaveAs("Jpsi_pPb_RD_Trketabin3_1st_run_CNT_test.png"); c2->SaveAs("Jpsi_pPb_RD_Trketabin3_1st_run_CNT_test.pdf"); */ } if(Cent_) { gTrkPt[1]->SetMarkerStyle(20); gTrkPt[1]->SetMarkerColor(634); gTrkPt[1]->GetXaxis()->SetTitle("p_{T} [GeV/c]");; gTrkPt[1]->GetXaxis()->CenterTitle();; gTrkPt[2]->SetMarkerStyle(23); gTrkPt[2]->SetMarkerColor(602); gTrkPt[3]->SetMarkerStyle(24); gTrkPt[3]->SetMarkerColor(618); gTrkPt[4]->SetMarkerStyle(25); gTrkPt[4]->SetMarkerColor(620); gTrkPt[5]->SetMarkerStyle(26); gTrkPt[5]->SetMarkerColor(621); gTrkPt[6]->SetMarkerStyle(27); gTrkPt[6]->SetMarkerColor(622); gTrkPt[7]->SetMarkerStyle(28); gTrkPt[7]->SetMarkerColor(623); gTrkPt[8]->SetMarkerStyle(29); gTrkPt[8]->SetMarkerColor(624); gTrkPt[0]->SetMarkerStyle(21); gTrkPt[0]->SetMarkerColor(802); formatTH1F(hPadPt,1,1,1); hPadPt->Draw(); gTrkPt[1]->SetMinimum(0.5); gTrkPt[1]->SetMaximum(1.05); gTrkPt[1]->Draw("pz same"); gTrkPt[2]->Draw("pz same"); gTrkPt[3]->Draw("pz same"); gTrkPt[4]->Draw("pz same"); gTrkPt[5]->Draw("pz same"); gTrkPt[6]->Draw("pz same"); gTrkPt[7]->Draw("pz same"); gTrkPt[8]->Draw("pz same"); gTrkPt[0]->Draw("pz same"); TLegend *leg3 = new TLegend(0.4899497,0.1678322,0.7876884,0.4947552,NULL,"brNDC"); // Size 0.03 leg3->SetFillStyle(0); leg3->SetFillColor(0); leg3->SetBorderSize(0); leg3->SetTextSize(0.04); leg3->SetHeader(leg_title); sprintf(legs,"0 - 5 %% : %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[1][1],Trk[1][2],Trk[1][3]); leg3->AddEntry(gTrkPt[1],legs,"pl"); sprintf(legs,"5 - 10 %% : %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[2][1],Trk[2][2],Trk[2][3]); leg3->AddEntry(gTrkPt[2],legs,"pl"); sprintf(legs,"10 - 20 %% : %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[3][1],Trk[3][2],Trk[3][3]); leg3->AddEntry(gTrkPt[3],legs,"pl"); sprintf(legs,"20 - 30 %% : %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[4][1],Trk[4][2],Trk[4][3]); leg3->AddEntry(gTrkPt[4],legs,"pl"); sprintf(legs,"30 - 40 %% : %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[5][1],Trk[5][2],Trk[5][3]); leg3->AddEntry(gTrkPt[5],legs,"pl"); sprintf(legs,"40 - 50 %% : %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[6][1],Trk[6][2],Trk[6][3]); leg3->AddEntry(gTrkPt[6],legs,"pl"); sprintf(legs,"50 - 60 %% : %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[7][1],Trk[7][2],Trk[7][3]); leg3->AddEntry(gTrkPt[7],legs,"pl"); sprintf(legs,"60 - 100 %% : %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[8][1],Trk[8][2],Trk[8][3]); leg3->AddEntry(gTrkPt[8],legs,"pl"); sprintf(legs,"MinBias : %0.3f^{ +%0.4f}_{ -%0.4f}",Trk[0][1],Trk[0][2],Trk[0][3]); leg3->AddEntry(gTrkPt[0],legs,"pl"); leg3->Draw("same"); if(MC_){ /* c2->SaveAs("Jpsi_pPb_for_B_MC_Trk_pt_CNT.png"); c2->SaveAs("Jpsi_pPb_for_B_MC_Trk_pt_CNT.pdf"); */ }else{ /* c2->SaveAs("Jpsi_pPb_RD_Trketabin3_1st_run_pt_CNT_test.png"); c2->SaveAs("Jpsi_pPb_RD_Trketabin3_1st_run_pt_CNT_test.pdf"); */ /* c2->SaveAs("Jpsi_pPb_RD_Trketabin2_1st_run_pt_CNT_test.png"); c2->SaveAs("Jpsi_pPb_RD_Trketabin2_1st_run_pt_CNT_test.pdf"); */ /* c2->SaveAs("Jpsi_pPb_RD_Trketabin3_1st_run_pt_CNT_test.png"); c2->SaveAs("Jpsi_pPb_RD_Trketabin3_1st_run_pt_CNT_test.pdf"); */ } } outfile->cd(); if(Cent_){ gTrkPt[1]->SetName("gTrk0005Pt"); gTrkPt[2]->SetName("gTrk0510Pt"); gTrkPt[3]->SetName("gTrk1020Pt"); gTrkPt[4]->SetName("gTrk2030Pt"); gTrkPt[5]->SetName("gTrk3040Pt"); gTrkPt[6]->SetName("gTrk4050Pt"); gTrkPt[7]->SetName("gTrk5060Pt"); gTrkPt[8]->SetName("gTrk60100Pt"); gTrkPt[1]->Write(); gTrkPt[2]->Write(); gTrkPt[3]->Write(); gTrkPt[4]->Write(); gTrkPt[5]->Write(); gTrkPt[6]->Write(); gTrkPt[7]->Write(); gTrkPt[8]->Write(); } gTrkPt[0]->SetName("gMBTrkPt"); pCNT->SetName("pCNT"); pMBCNT->SetName("pMBCNT"); gTrkPt[0]->Write(); pCNT->Write(); pMBCNT->Write(); outfile->Close(); //f->Close(); //files->Close(); }
void make_Event_QA_plots() { RooPlotLib rpl; Reporter rp( "rqa.pdf", 500, 500 ); TFile * f = new TFile( "setA_qa.root", "READ" ); rpl.style( (TH1*)f->Get( "event_cuts" ) ) .set( "title", "Event Cuts" ) .set( "logy", 0 ).draw(); rp.savePage(); // TODO: same bins as corr RefMult for comparison // rpl.style( (TH1*)f->Get( "event_refMult" ) ) // .set( "logy", 1 ) // .set( "yr", 1, 1e4 ) // .set( "title", "Raw refMult" ).draw(); // rp.savePage(); rpl.style( (TH1*)f->Get( "event_corrRefMult" ) ) .set( "logy", 1 ) .set( "xr", 0, 400 ) .set( "yr", 1, 1e4 ) .set( "title", "Corrected refMult" ).draw(); rp.savePage(); rpl.style( (TH1*)f->Get( "event_refMultBins" ) ) .set( "logy", 0 ) .set( "title", "StRefMultCorr bin9" ).draw(); rp.savePage(); rpl.style( (TH2*)f->Get( "event_vX_vY" ) ) .set( "title", "vX vs. vY; vX [cm]; vY[cm]" ) .set( "draw", "col" ) .draw(); rp.savePage(); rpl.style( (TH1*)f->Get( "event_vR" ) ) .set( "yto", 1.3 ) .set( "xto", 0.9 ) .set( "title", "Radial Vertex; (vX^{2} + vY^{2})^{1/2} [cm]; dN/dvR" ) .set( "logy", 1 ) .set( "draw", "" ) .draw(); rp.savePage(); rpl.style( (TH1*)f->Get( "event_nTofMatchA" ) ) .set( "yto", 1.3 ) .set( "xto", 0.9 ) .set( "title", "# TOF Matched Tracks; #TOF Matched Tracks; dN/dTOFMatch" ) .set( "logy", 1 ) .set( "draw", "" ) .draw(); rp.savePage(); rpl.style( (TH2*)f->Get( "event_nTofMatchA_corrRefMult" ) ) .set( "yto", 1.3 ) .set( "xto", 0.9 ) .set( "title", "# TOF Matched Tracks vs. Corrected RefMult; #TOF Matched Tracks; Corrected RefMult" ) .set( "logy", 1 ) .set( "logx", 1 ) .set( "draw", "col" ) .draw(); rp.savePage(); }
int main(int argc, char *argv[]) { gotsignal = 0; signal(SIGINT, breakhandler); signal(SIGPIPE, breakhandler); TString inputFile1, inputFile2, outputFile; Bool_t haveFile1=0, haveFile2=0, haveOutput=0; Int_t file1zipped = -1; Int_t file2zipped = -1; Int_t file1Events=0, file2Events=0; Int_t dataWritten1=0, dataWritten2=0; TFile *mOut = new TFile("merge.root", "RECREATE"); TH1F *tac = new TH1F("tac", "tac", 1000, -500, 500); if (argc < 7) { printf("\nMinimum usage: %s -f1 <Filename1> -f2 <Filename2> -fOut <OutputFilename>\n", argv[0]); exit(1); } else if ((strcmp(argv[1], "-h") == 0)) { printf("\nMinimum usage: %s -f1 <Filename1> -f2 <Filename2> -fOut <OutputFilename>\n", argv[0]); exit(1); } else { Int_t i=1; while( i<argc ) { if (strcmp(argv[i], "-f1") == 0) { haveFile1 = 1; i++; inputFile1 = argv[i]; i++; file1zipped = 0; } else if (strcmp(argv[i], "-f1zip") == 0) { haveFile1 = 1; i++; inputFile1 = argv[i]; i++; file1zipped = 1; } else if (strcmp(argv[i], "-f2") == 0) { haveFile2 = 1; i++; inputFile2 = argv[i]; i++; file2zipped = 0; } else if (strcmp(argv[i], "-f2zip") == 0) { haveFile2 = 1; i++; inputFile2 = argv[i]; i++; file2zipped = 1; } else if (strcmp(argv[i], "-fOut") == 0) { haveOutput = 1; i++; outputFile = argv[i]; i++; } else if (strcmp(argv[i], "-f1ExcludeCrysID") == 0) { i++; nFile1Exclude = atoi(argv[i]); i++; for (Int_t n=0; n<nFile1Exclude; n++) { file1Exclude[n] = atoi(argv[i]); i++; } } else if (strcmp(argv[i], "-h") == 0) { printf("\nMinimum usage: %s -f1 <Filename1> -f2 <Filename2> -fOut <OutputFilename>\n", argv[0]); printf(" Option flags: -f1ExcludeCrysID <N> <Value1> ... <ValueN>\n"); printf(" This excludes certain mode2 crystal_id values in File1 from\n"); printf(" being included in the merged output.\n"); printf("\n"); exit(1); } } } TStopwatch timer; timer.Start(); if ( !haveFile1 || !haveFile2 || !haveOutput ) { cout << "Problem: we don't have all the file information required." << endl; printf("Minimum usage: %s -f1 <Filename1> -f2 <Filename2> -fOut <OutputFilename>", argv[0]); exit(1); } /***********************************************************/ /* MERGED OUTPUT FILE NAME */ /***********************************************************/ int pipeFlag = 0; /* Set-up merged output file */ FILE *mergeOutFile; if (!strcmp(outputFile.Data(), "pipe")) { mergeOutFile = stdout; pipeFlag = 1; } else { mergeOutFile = fopen64(outputFile.Data(), "w"); } if (!mergeOutFile) { printf("Cannot open \"%s\" for reading\n", outputFile.Data()); exit(3); } else { if (!pipeFlag) printf("Output file \"%s\" opened\n", outputFile.Data()); } /***********************************************************/ /* INPUT FILE #1 FOR MERGING */ /***********************************************************/ if (file1zipped) { inputFile1 = "./GEB_HFC -z -p " + inputFile1; } else { inputFile1 = "./GEB_HFC -p " + inputFile1; } inFile1 = popen(inputFile1.Data(), "r"); if (!inFile1) { printf("Cannot open %s for reading\n", inputFile1.Data()); exit(2); } else { if (!pipeFlag) printf("File #1 -- \"%s\" opened for reading\n", inputFile1.Data()); } /***********************************************************/ /* INPUT FILE #2 FOR MERGING */ /***********************************************************/ if (file2zipped) { inputFile2 = "./GEB_HFC -z -p " + inputFile2; } else { inputFile2 = "./GEB_HFC -p " + inputFile2; } inFile2 = popen(inputFile2.Data(), "r"); if (!inFile2) { printf("Cannot open %s for reading\n", inputFile2.Data()); exit(2); } else { if (!pipeFlag) printf("File #2 -- \"%s\" opened for reading\n", inputFile2.Data()); } /***********************************************************/ /* Loop and merge files... */ /***********************************************************/ long long int lastTS = 0; int lastTSfile = 0; while ( !doneFile2 && ! gotsignal) { GetNextEvent2(dataWritten2); if ( !doneFile1 ) { while ( GetNextEvent1(dataWritten1) && !doneFile1 && !gotsignal) { if ((fileBuf1.header.timestamp) < (fileBuf2.header.timestamp)) { //cout << fileBuf1.header.timestamp << " " << fileBuf2.header.timestamp << " -- 1 lower " << endl; if (fileBuf1.header.timestamp - lastTS < 1000) { if (lastTSfile == 2) {tac->Fill(fileBuf1.header.timestamp - lastTS);} } else { lastTS = fileBuf1.header.timestamp; lastTSfile = 1; } /* Write the file 1 event to disk, it's go the lower TS. */ fwrite(&fileBuf1, fileBuf1.header.length + sizeof(struct globalHeader), 1, mergeOutFile); file1Events++; dataWritten1 = 1; dataWritten2 = 0; } else { //cout << fileBuf1.header.timestamp << " " << fileBuf2.header.timestamp << " -- 2 lower " << endl; //cin.get(); /* Write the file 2 event to disk, it's go the lower TS. */ fwrite(&fileBuf2, fileBuf2.header.length + sizeof(struct globalHeader), 1, mergeOutFile); file2Events++; dataWritten1 = 0; dataWritten2 = 1; break; } } } else { /* if (doneFile1) */ /* File 1 is done, just empty out file 2 now */ fwrite(&fileBuf2, fileBuf2.header.length + sizeof(struct globalHeader), 1, mergeOutFile); file2Events++; dataWritten2 = 1; } } fclose(inFile2); if (!doneFile1) { /* Out of file2 events, dump the remaining file1 events, if any */ while ( GetNextEvent1(dataWritten1) && !doneFile1) { fwrite(&fileBuf1, fileBuf1.header.length + sizeof(struct globalHeader), 1, mergeOutFile); file1Events++; dataWritten1 = 1; } } if (!pipeFlag) cout << "File 1 events " << file1Events << " " << "File 2 events " << file2Events << endl; fclose(mergeOutFile); tac->Write(); mOut->Write(); mOut->Close(); return 0; }
void fitB0(TString infname="",bool doweight = 1) { if (doweight==0) weight="1"; if (infname=="") infname=inputdata.Data(); TFile *inf = new TFile(infname.Data()); TTree *nt = (TTree*) inf->Get("ntKstar"); TFile *infMC = new TFile(inputmc.Data()); TTree *ntGen = (TTree*)infMC->Get("ntGen"); TTree *ntMC = (TTree*)infMC->Get("ntKstar"); ntGen->AddFriend(ntMC); //const int nBins = 3; //double ptBins[nBins+1] = {10,15,20,60}; const int nBins = 1; double ptBins[nBins+1] = {10,60}; TH1D *hPt = new TH1D("hPt","",nBins,ptBins); TH1D *hRecoTruth = new TH1D("hRecoTruth","",nBins,ptBins); TH1D *hPtMC = new TH1D("hPtMC","",nBins,ptBins); TH1D *hPtGen = new TH1D("hPtGen","",nBins,ptBins); for (int i=0;i<nBins;i++) { TF1 *f = fit(nt,ntMC,ptBins[i],ptBins[i+1]); double yield = f->Integral(5,6)/0.03; double yieldErr = f->Integral(5,6)/0.03*f->GetParError(0)/f->GetParameter(0); hPt->SetBinContent(i+1,yield/(ptBins[i+1]-ptBins[i])); hPt->SetBinError(i+1,yieldErr/(ptBins[i+1]-ptBins[i])); } /* TCanvas *c= new TCanvas("cResult","",600,600); hPt->SetXTitle("B^{0} p_{T} (GeV/c)"); hPt->SetYTitle("Uncorrected B^{0} dN/dp_{T}"); hPt->Sumw2(); hPt->Draw(); ntMC->Project("hPtMC","pt",TCut(weight)*(TCut(seldata_2y_kpi.Data())&&"(gen==23333||gen==41000)")); nt->Project("hRecoTruth","pt",TCut(seldata_2y_kpi.Data())&&"(gen==23333||gen==41000)"); ntGen->Project("hPtGen","pt",TCut(weight)*(selmcgen.Data())); divideBinWidth(hRecoTruth); hRecoTruth->Draw("same hist"); divideBinWidth(hPtMC); divideBinWidth(hPtGen); hPtMC->Sumw2(); TH1D *hEff = (TH1D*)hPtMC->Clone("hEff"); hPtMC->Sumw2(); hEff->Divide(hPtGen); TH1D *hPtCor = (TH1D*)hPt->Clone("hPtCor"); hPtCor->Divide(hEff); TCanvas *cCor= new TCanvas("cCorResult","",600,600); hPtCor->SetYTitle("Correctd B^{0} dN/dp_{T}"); hPtCor->Draw(); hPtGen->Draw("same hist"); TH1D *hPtSigma= (TH1D*)hPtCor->Clone("hPtSigma"); // B0->J/psi K*0(892) = 1.34 +- 0.06 x 10^-3 // J/psi -> mumu = 5.93 +- 0.06 x 10^-2 // K*0(892) -> K+ pi- = 66% double BRchain=5.244e-5; hPtSigma->Scale(1./(2*luminosity*BRchain)); hPtSigma->SetYTitle("d#sigma/dp_{T} (B^{0}) "); TCanvas *cSigma= new TCanvas("cSigma","",600,600); hPtSigma->Draw(); TFile *outf = new TFile("../ResultsBzero/SigmaBzero.root","recreate"); outf->cd(); hPt->Write(); hEff->Write(); hPtCor->Write(); hPtSigma->Write(); outf->Close(); delete outf; */ }
double GetEntries(TString fname){ TFile * in = TFile::Open(fname); return (((TH1D*)in->Get("DefaultTrue_allW/DefaultTrue_allWcosTheta2D"))->Integral()+((TH1D*)in->Get("DefaultTrue_allW/DefaultTrue_allWcosTheta"))->Integral()); }
void plotSignals_4mu(int channel = 1) { gSystem->AddIncludePath("-I$ROOFITSYS/include"); gROOT->ProcessLine(".L ~/tdrstyle.C"); setTDRStyle(); //gSystem->Load("PDFs/RooRelBW1_cxx.so"); //gSystem->Load("PDFs/RooRelBW2_cxx.so"); gSystem->Load("../PDFs/HZZ4LRooPdfs_cc.so"); string schannel; if (channel == 1) schannel = "4mu"; if (channel == 2) schannel = "4e"; if (channel == 3) schannel = "2mu2e"; std::cout << "schannel = " << schannel << std::endl; const int nPoints = 17.; int masses[nPoints] = {120,130,140,150,160,170,180,190,200,250,300,350,400,450,500,550,600}; double mHVal[nPoints] = {120,130,140,150,160,170,180,190,200,250,300,350,400,450,500,550,600}; double widths[nPoints] = {3.48e-03,4.88e-03,8.14e-03,1.73e-02,8.30e-02,3.80e-01,6.31e-01,1.04e+00,1.43e+00,4.04e+00,8.43e+00,1.52e+01,2.92e+01,46.95,6.80e+01,93.15,1.23e+02}; // R e a d w o r k s p a c e f r o m f i l e // ----------------------------------------------- double a_meanBW[nPoints]; double a_gammaBW[nPoints]; double a_meanCB[nPoints]; double a_sigmaCB[nPoints]; double a_alphaCB[nPoints]; double a_nCB[nPoints]; //for (int i = 0; i < nPoints; i++){ for (int i = 0; i < (nPoints-3); i++){ // Open input file with workspace (generated by rf14_wspacewrite) char infile[192]; sprintf(infile,"/scratch/hep/ntran/dataFiles/HZZ4L/datasets/datasets_baseline/%s/ZZAnalysisTree_H%i%s.root",schannel.c_str(),masses[i],schannel.c_str()); TFile *f = new TFile(infile) ; char outfile[192]; sprintf( outfile, "figs/pdf_%s_bkg_highmass.eps", schannel.c_str() ); //f->ls(); double windowVal = max( widths[i], 1. ); if (mHVal[i] >= 275){ lowside = 180.; } else { lowside = 100.; } double low_M = max( (mHVal[i] - 20.*windowVal), lowside) ; //double high_M = min( (mHVal[i] + 15.*windowVal), 900.) ; double high_M = min( (mHVal[i] + 15.*windowVal), 600.) ; std::cout << "lowM = " << low_M << ", highM = " << high_M << std::endl; RooDataSet* set = (RooDataSet*) f->Get("data"); RooArgSet* obs = set->get() ; obs->Print(); RooRealVar* CMS_zz4l_mass = (RooRealVar*) obs->find("CMS_zz4l_mass") ; CMS_zz4l_mass->setRange(low_M,high_M); for (int a=0 ; a<set->numEntries() ; a++) { set->get(a) ; //cout << CMS_zz4l_mass->getVal() << " = " << set->weight() << endl ; } // constraining parameters... double l_sigmaCB = 0., s_sigmaCB = 3.; if (mHVal[i] >= 500.){ l_sigmaCB = 10.; s_sigmaCB = 12.; } double h_alpha_CB = 1.15; if (mHVal[i] >= 500.){ h_alpha_CB = 0.99; } double s_alpha_CB = 1.2 + (-0.4/590)*(mHVal[i]-110.); RooRealVar mean_CB("mean_CB","mean_CB",0.,-25.,25); RooRealVar sigma_CB("sigma_CB","sigma_CB",s_sigmaCB,l_sigmaCB,30.); //RooRealVar alpha_CB("alpha_CB","alpha_CB",0.9,0.7,h_alpha_CB); RooRealVar alpha_CB("alpha_CB","alpha_CB",s_alpha_CB); RooRealVar n_CB("n_CB","n_CB",1.7,1.5,2.4); RooCBShape signalCB("signalCB","signalCB",*CMS_zz4l_mass,mean_CB,sigma_CB,alpha_CB,n_CB); RooRealVar mean_BW("mean_BW","mean_BW", mHVal[i] ,100.,1000.); RooRealVar gamma_BW("gamma_BW","gamma_BW",widths[i],0.,200.); //RooBreitWigner signalBW("signalBW", "signalBW",*CMS_zz4l_mass,mean_BW,gamma_BW); //RooRelBW1 signalBW("signalBW", "signalBW",*CMS_zz4l_mass,mean_BW,gamma_BW); RooRelBWUF signalBW("signalBW", "signalBW",*CMS_zz4l_mass,mean_BW); //RooRelBW1 signalBW("signalBW", "signalBW",*CMS_zz4l_mass,mean_BW,gamma_BW); RooBreitWigner signalBW1("signalBW1", "signalBW1",*CMS_zz4l_mass,mean_BW,gamma_BW); RooRelBW1 signalBW2("signalBW2", "signalBW2",*CMS_zz4l_mass,mean_BW,gamma_BW); RooRealVar x("x","x",1.); RooRelBWUFParam signalBW3("signalBW3", "signalBW3",*CMS_zz4l_mass,mean_BW,x); RooRealVar y("y","y",0.33333); RooRelBWUFParam signalBW4("signalBW4", "signalBW4",*CMS_zz4l_mass,mean_BW,y); //Set #bins to be used for FFT sampling to 10000 CMS_zz4l_mass->setBins(100000,"fft") ; //Construct BW (x) CB RooFFTConvPdf* sig_ggH = new RooFFTConvPdf("sig_ggH","BW (X) CB",*CMS_zz4l_mass,signalBW,signalCB, 2); // Buffer fraction for cyclical behavior sig_ggH->setBufferFraction(0.2); mean_BW.setConstant(kTRUE); gamma_BW.setConstant(kTRUE); n_CB.setConstant(kTRUE); //alpha_CB.setConstant(kTRUE); RooFitResult *r = sig_ggH.fitTo( *set, SumW2Error(kTRUE) );//, Save(kTRUE), SumW2Error(kTRUE)) ; a_meanBW[i] = mean_BW.getVal(); a_gammaBW[i] = gamma_BW.getVal(); a_meanCB[i] = mean_CB.getVal(); a_sigmaCB[i] = sigma_CB.getVal();; a_alphaCB[i] = alpha_CB.getVal();; a_nCB[i] = n_CB.getVal();; /////////////////////////////////////////////////// // P l o t t i n g int iLineColor = 1; string lab = "blah"; if (channel == 1) { iLineColor = 2; lab = "4#mu"; } if (channel == 3) { iLineColor = 4; lab = "2e2#mu"; } if (channel == 2) { iLineColor = 6; lab = "4e"; } double separation = 0.5; if (mHVal[i] >= 300.) separation = 2; double nbins = (high_M-low_M); nbins /= separation; char yname[192]; sprintf(yname,"Events / %1.1f GeV/c^{2}", separation); char lname[192]; sprintf(lname,"M_{H} = %i [GeV/c^{2}]", (int) mHVal[i] ); char lname2[192]; sprintf(lname2,"Shape Model, %s", lab.c_str() ); RooPlot* frameM4l = CMS_zz4l_mass->frame(Bins( (int) nbins )) ; set->plotOn(frameM4l) ; sig_ggH->plotOn(frameM4l, LineColor(iLineColor)) ; // dummy! TF1* dummyF = new TF1("dummyF","1",0.,1.); TH1F* dummyH = new TH1F("dummyG","dummyG",1, 0.,1.); dummyF->SetLineColor( iLineColor ); //dummyH->SetLineColor( kBlue ); TLegend * box2 = new TLegend(0.17,0.70,0.52,0.90); box2->SetFillColor(0); box2->SetBorderSize(0); box2->AddEntry(dummyH,"Simulation (Powheg + CMS) ","pe"); box2->AddEntry(dummyH,lname,""); box2->AddEntry(dummyF,lname2,"l"); TPaveText *pt = new TPaveText(0.15,0.955,0.4,0.99,"NDC"); pt->SetFillColor(0); pt->SetBorderSize(0); pt->AddText("CMS Preliminary 2011"); TPaveText *pt2 = new TPaveText(0.83,0.955,0.99,0.99,"NDC"); pt2->SetFillColor(0); pt2->SetBorderSize(0); pt2->AddText("#sqrt{s} = 7 TeV"); frameM4l->SetTitle(""); frameM4l->GetXaxis()->SetTitle("M_{4l} [GeV/c^{2}]"); frameM4l->GetYaxis()->SetTitleOffset(1.2); frameM4l->GetYaxis()->SetTitle(yname); TCanvas *c = new TCanvas("c","c",800,600); c->cd(); frameM4l->Draw(); box2->Draw(); pt->Draw(); pt2->Draw(); char plotName[192]; sprintf(plotName,"sigFigs/m%i.eps",masses[i]); c->SaveAs(plotName); /////////////////////////////////////////////////// RooPlot* testFrame = CMS_zz4l_mass->frame(Title("M4L"),Bins(100)) ; signalBW.plotOn(testFrame) ; signalBW1.plotOn(testFrame, LineColor(kBlack)) ; signalBW2.plotOn(testFrame, LineColor(kRed)) ; TCanvas *c3 = new TCanvas("c3","c3",800,600); c3->cd(); testFrame->Draw(); //char plotName[192]; sprintf(plotName,"sigFigs/shape%i.eps",masses[i]); c3->SaveAs(plotName); /////////////////////////////////////////////////// delete f; delete set; delete c; } TGraph* gr_meanBW = new TGraph( nPoints, mHVal, a_meanBW ); TGraph* gr_gammaBW = new TGraph( nPoints, mHVal, a_gammaBW ); TGraph* gr_meanCB = new TGraph( nPoints, mHVal, a_meanCB ); TGraph* gr_sigmaCB = new TGraph( nPoints, mHVal, a_sigmaCB ); TGraph* gr_alphaCB = new TGraph( nPoints, mHVal, a_alphaCB ); TGraph* gr_nCB = new TGraph( nPoints, mHVal, a_nCB ); TF1 *polyFunc1= new TF1("polyFunc1","[0]+[1]*x+[2]*(x-[3])*(x-[3])+[4]*x*x*x*x", 120., 600.); polyFunc1->SetParameters(1., 1., 1., 100.,0.1); TF1 *polyFunc2= new TF1("polyFunc2","[0]+[1]*x+[2]*(x-[3])*(x-[3])+[4]*x*x*x*x", 120., 600.); polyFunc2->SetParameters(1., 1., 1., 100.,0.1); TCanvas *c = new TCanvas("c","c",1200,800); c->Divide(3,2); //c->SetGrid(); //TH1F *hr = c->DrawFrame(0.,0.,610.,1.); c->cd(1); gr_meanBW->Draw("alp"); gr_meanBW->GetXaxis()->SetTitle("mean BW"); c->cd(2); gr_gammaBW->Draw("alp"); gr_gammaBW->GetXaxis()->SetTitle("gamma BW"); c->cd(3); gr_meanCB->Fit(polyFunc1,"Rt"); gr_meanCB->Draw("alp"); gr_meanCB->GetXaxis()->SetTitle("mean CB"); c->cd(4); gr_sigmaCB->Fit(polyFunc2,"Rt"); gr_sigmaCB->Draw("alp"); gr_sigmaCB->GetXaxis()->SetTitle("sigma CB"); c->cd(5); gr_alphaCB->Draw("alp"); gr_alphaCB->GetXaxis()->SetTitle("alpha CB"); c->cd(6); gr_nCB->Draw("alp"); gr_nCB->GetXaxis()->SetTitle("n CB"); c->SaveAs("sigFigs/params.eps"); std::cout << "mean_CB = " << polyFunc1->GetParameter(0) << " + " << polyFunc1->GetParameter(1) << "*m + " << polyFunc1->GetParameter(2) << "*(m - " << polyFunc1->GetParameter(3) << ")*(m - " << polyFunc1->GetParameter(3); std::cout << ") + " << polyFunc1->GetParameter(4) << "*m*m*m*m;" << std::endl; std::cout << "sigma_CB = " << polyFunc2->GetParameter(0) << " + " << polyFunc2->GetParameter(1) << "*m + " << polyFunc2->GetParameter(2) << "*(m - " << polyFunc2->GetParameter(3) << ")*(m - " << polyFunc2->GetParameter(3); std::cout << ") + " << polyFunc2->GetParameter(4) << "*m*m*m*m;" << std::endl; // calculate sysetmatic errors from interpolation... double sum_meanCB = 0; double sum_sigmaCB = 0; for (int i = 0; i < nPoints; i++){ double tmp_meanCB = (polyFunc1->Eval(mHVal[i]) - a_meanCB[i]); sum_meanCB += (tmp_meanCB*tmp_meanCB); double tmp_sigmaCB = (polyFunc2->Eval(mHVal[i]) - a_sigmaCB[i])/a_sigmaCB[i]; sum_sigmaCB += (tmp_sigmaCB*tmp_sigmaCB); std::cout << "mean: " << tmp_meanCB << ", sigma: " << tmp_sigmaCB << std::endl; } double rms_meanCB = sqrt( sum_meanCB/( (double) nPoints) ); double rms_sigmaCB = sqrt( sum_sigmaCB/( (double) nPoints) ); std::cout << "err (meanCB) = " << rms_meanCB << ", err (sigmaCB) = " << rms_sigmaCB << std::endl; }
void Draw_Event_L1seed() { TH1::SetDefaultSumw2(); gStyle->SetOptFit(0); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); TFile * input = new TFile("./openHLT_HF_HLTHeavyFlavour_MVA_V13_Pyquen_D0tokaonpion_D0pt15p0_Pthat15_tketa2p0_1019_MBseed_fix.root"); TTree * hlttree = ( TTree * ) input->Get("hltbitanalysis/HltTree"); TTree * gentree = ( TTree * ) input->Get("HiGenParticleAna/hi"); gentree->AddFriend(hlttree); hlttree->AddFriend(gentree); TH1D * eventfired_Dpt20_MBseed = new TH1D("eventfired_Dpt20_MBseed","eventfired_Dpt20_MBseed",2,0,2); TH1D * eventfired_Dpt20_S1Jet8seed = new TH1D("eventfired_Dpt20_S1Jet8seed","eventfired_Dpt20_S1Jet8seed",2,0,2); TH1D * eventfired_Dpt20_S1Jet16seed = new TH1D("eventfired_Dpt20_S1Jet16seed","eventfired_Dpt20_S1Jet16seed",2,0,2); TH1D * eventfired_Dpt20_S1Jet28seed = new TH1D("eventfired_Dpt20_S1Jet28seed","eventfired_Dpt20_S1Jet28seed",2,0,2); TH1D * eventfired_Dpt20_S1Jet40seed = new TH1D("eventfired_Dpt20_S1Jet40seed","eventfired_Dpt20_S1Jet40seed",2,0,2); TH1D * eventfired_Dpt20_S1Jet44seed = new TH1D("eventfired_Dpt20_S1Jet44seed","eventfired_Dpt20_S1Jet44seed",2,0,2); TH1D * eventfired_Dpt20_S1Jet56seed = new TH1D("eventfired_Dpt20_S1Jet56seed","eventfired_Dpt20_S1Jet56seed",2,0,2); TH1D * eventfired_Dpt20_S1Jet92seed = new TH1D("eventfired_Dpt20_S1Jet92seed","eventfired_Dpt20_S1Jet92seed",2,0,2); eventfired_Dpt20_MBseed->SetLineWidth(2.0); eventfired_Dpt20_S1Jet8seed->SetLineWidth(2.0); eventfired_Dpt20_S1Jet16seed->SetLineWidth(2.0); eventfired_Dpt20_S1Jet28seed->SetLineWidth(2.0); eventfired_Dpt20_S1Jet40seed->SetLineWidth(2.0); eventfired_Dpt20_S1Jet44seed->SetLineWidth(2.0); eventfired_Dpt20_S1Jet56seed->SetLineWidth(2.0); eventfired_Dpt20_S1Jet92seed->SetLineWidth(2.0); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt20_v1>>eventfired_Dpt20_MBseed","HLT_DmesonTrackingGlobalPt8_Dpt20_v1","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt20_v1>>eventfired_Dpt20_S1Jet8seed","HLT_DmesonTrackingGlobalPt8_Dpt20_v1&&L1_SingleS1Jet8_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt20_v1>>eventfired_Dpt20_S1Jet16seed","HLT_DmesonTrackingGlobalPt8_Dpt20_v1&&L1_SingleS1Jet16_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt20_v1>>eventfired_Dpt20_S1Jet28seed","HLT_DmesonTrackingGlobalPt8_Dpt20_v1&&L1_SingleS1Jet28_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt20_v1>>eventfired_Dpt20_S1Jet40seed","HLT_DmesonTrackingGlobalPt8_Dpt20_v1&&L1_SingleS1Jet40_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt20_v1>>eventfired_Dpt20_S1Jet44seed","HLT_DmesonTrackingGlobalPt8_Dpt20_v1&&L1_SingleJet44_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt20_v1>>eventfired_Dpt20_S1Jet56seed","HLT_DmesonTrackingGlobalPt8_Dpt20_v1&&L1_SingleS1Jet56_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt20_v1>>eventfired_Dpt20_S1Jet92seed","HLT_DmesonTrackingGlobalPt8_Dpt20_v1&&L1_SingleJet92_BptxAND","goff"); TH1D * Events_Dpt20_MBseed = new TH1D( "Events_Dpt20_MBseed", "Events_Dpt20_MBseed", 8, 0, 8); TH1D * fraction_Events_Dpt20_L1Jetseed = new TH1D( "fraction_Events_Dpt20_L1Jetseed","fraction_Events_Dpt20_L1Jetseed", 8, 0, 8); fraction_Events_Dpt20_L1Jetseed->SetLineWidth(2.0); cout << "Dpt 20 fired events: " << eventfired_Dpt20_MBseed->GetEntries() << endl; for( int i = 0; i < 8; i++ ) { Events_Dpt20_MBseed->SetBinContent( i+1, eventfired_Dpt20_MBseed->GetEntries()); Events_Dpt20_MBseed->SetBinError( i+1, TMath::Sqrt(eventfired_Dpt20_MBseed->GetEntries())); } fraction_Events_Dpt20_L1Jetseed->SetBinContent(1, eventfired_Dpt20_MBseed->GetEntries()); fraction_Events_Dpt20_L1Jetseed->SetBinError( 1, TMath::Sqrt(eventfired_Dpt20_MBseed->GetEntries())); fraction_Events_Dpt20_L1Jetseed->SetBinContent( 2, eventfired_Dpt20_S1Jet8seed->GetEntries()); fraction_Events_Dpt20_L1Jetseed->SetBinError( 2, TMath::Sqrt(eventfired_Dpt20_S1Jet8seed->GetEntries())); fraction_Events_Dpt20_L1Jetseed->SetBinContent( 3, eventfired_Dpt20_S1Jet16seed->GetEntries()); fraction_Events_Dpt20_L1Jetseed->SetBinError( 3, TMath::Sqrt(eventfired_Dpt20_S1Jet16seed->GetEntries())); fraction_Events_Dpt20_L1Jetseed->SetBinContent( 4, eventfired_Dpt20_S1Jet28seed->GetEntries()); fraction_Events_Dpt20_L1Jetseed->SetBinError( 4, TMath::Sqrt(eventfired_Dpt20_S1Jet28seed->GetEntries())); fraction_Events_Dpt20_L1Jetseed->SetBinContent( 5, eventfired_Dpt20_S1Jet40seed->GetEntries()); fraction_Events_Dpt20_L1Jetseed->SetBinError( 5, TMath::Sqrt(eventfired_Dpt20_S1Jet40seed->GetEntries())); fraction_Events_Dpt20_L1Jetseed->SetBinContent( 6, eventfired_Dpt20_S1Jet44seed->GetEntries()); fraction_Events_Dpt20_L1Jetseed->SetBinError( 6, TMath::Sqrt(eventfired_Dpt20_S1Jet44seed->GetEntries())); fraction_Events_Dpt20_L1Jetseed->SetBinContent( 7, eventfired_Dpt20_S1Jet56seed->GetEntries()); fraction_Events_Dpt20_L1Jetseed->SetBinError( 7, TMath::Sqrt(eventfired_Dpt20_S1Jet56seed->GetEntries())); fraction_Events_Dpt20_L1Jetseed->SetBinContent( 8, eventfired_Dpt20_S1Jet92seed->GetEntries()); fraction_Events_Dpt20_L1Jetseed->SetBinError( 8, TMath::Sqrt(eventfired_Dpt20_S1Jet92seed->GetEntries())); for( int i = 0; i < 8; i++ ) cout << " bin content: " << fraction_Events_Dpt20_L1Jetseed->GetBinContent( i+1 ) << endl; fraction_Events_Dpt20_L1Jetseed->Divide( fraction_Events_Dpt20_L1Jetseed, Events_Dpt20_MBseed, 1.0, 1.0, "B"); fraction_Events_Dpt20_L1Jetseed->SetLineColor(2.0); TCanvas * cfg_evtfraction_Dpt20_L1seed = new TCanvas("cfg_evtfraction_Dpt20_L1seed","cfg_evtfraction_Dpt20_L1seed",600,600); cfg_evtfraction_Dpt20_L1seed->SetGridx(); cfg_evtfraction_Dpt20_L1seed->SetGridy(); cfg_evtfraction_Dpt20_L1seed->SetGrid(); fraction_Events_Dpt20_L1Jetseed->GetXaxis()->SetTitle("L1Jet* seed"); fraction_Events_Dpt20_L1Jetseed->GetYaxis()->SetTitle("Event fraction: L1Jet* seed/MB seed"); fraction_Events_Dpt20_L1Jetseed->GetYaxis()->SetRangeUser(0.,1.2); fraction_Events_Dpt20_L1Jetseed->Draw(); for( int i = 0; i < 8; i++ ) cout << " fraction: " << fraction_Events_Dpt20_L1Jetseed->GetBinContent( i+1 ) << " +/- " << fraction_Events_Dpt20_L1Jetseed->GetBinError( i+1 ) << endl; cfg_evtfraction_Dpt20_L1seed->SaveAs("plots/cfg_evtfraction_Dpt20_L1seed_AllMB_D0pt15p0_Pthat15.png"); cfg_evtfraction_Dpt20_L1seed->SaveAs("plots/cfg_evtfraction_Dpt20_L1seed_AllMB_D0pt15p0_Pthat15.pdf"); TH1D * eventfired_Dpt30_MBseed = new TH1D("eventfired_Dpt30_MBseed","eventfired_Dpt30_MBseed",2,0,2); TH1D * eventfired_Dpt30_S1Jet8seed = new TH1D("eventfired_Dpt30_S1Jet8seed","eventfired_Dpt30_S1Jet8seed",2,0,2); TH1D * eventfired_Dpt30_S1Jet16seed = new TH1D("eventfired_Dpt30_S1Jet16seed","eventfired_Dpt30_S1Jet16seed",2,0,2); TH1D * eventfired_Dpt30_S1Jet28seed = new TH1D("eventfired_Dpt30_S1Jet28seed","eventfired_Dpt30_S1Jet28seed",2,0,2); TH1D * eventfired_Dpt30_S1Jet40seed = new TH1D("eventfired_Dpt30_S1Jet40seed","eventfired_Dpt30_S1Jet40seed",2,0,2); TH1D * eventfired_Dpt30_S1Jet44seed = new TH1D("eventfired_Dpt30_S1Jet44seed","eventfired_Dpt30_S1Jet44seed",2,0,2); TH1D * eventfired_Dpt30_S1Jet56seed = new TH1D("eventfired_Dpt30_S1Jet56seed","eventfired_Dpt30_S1Jet56seed",2,0,2); TH1D * eventfired_Dpt30_S1Jet92seed = new TH1D("eventfired_Dpt30_S1Jet92seed","eventfired_Dpt30_S1Jet92seed",2,0,2); eventfired_Dpt30_MBseed->SetLineWidth(2.0); eventfired_Dpt30_S1Jet8seed->SetLineWidth(2.0); eventfired_Dpt30_S1Jet16seed->SetLineWidth(2.0); eventfired_Dpt30_S1Jet28seed->SetLineWidth(2.0); eventfired_Dpt30_S1Jet40seed->SetLineWidth(2.0); eventfired_Dpt30_S1Jet44seed->SetLineWidth(2.0); eventfired_Dpt30_S1Jet56seed->SetLineWidth(2.0); eventfired_Dpt30_S1Jet92seed->SetLineWidth(2.0); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt30_v1>>eventfired_Dpt30_MBseed","HLT_DmesonTrackingGlobalPt8_Dpt30_v1","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt30_v1>>eventfired_Dpt30_S1Jet8seed","HLT_DmesonTrackingGlobalPt8_Dpt30_v1&&L1_SingleS1Jet8_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt30_v1>>eventfired_Dpt30_S1Jet16seed","HLT_DmesonTrackingGlobalPt8_Dpt30_v1&&L1_SingleS1Jet16_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt30_v1>>eventfired_Dpt30_S1Jet28seed","HLT_DmesonTrackingGlobalPt8_Dpt30_v1&&L1_SingleS1Jet28_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt30_v1>>eventfired_Dpt30_S1Jet40seed","HLT_DmesonTrackingGlobalPt8_Dpt30_v1&&L1_SingleS1Jet40_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt30_v1>>eventfired_Dpt30_S1Jet44seed","HLT_DmesonTrackingGlobalPt8_Dpt30_v1&&L1_SingleJet44_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt30_v1>>eventfired_Dpt30_S1Jet56seed","HLT_DmesonTrackingGlobalPt8_Dpt30_v1&&L1_SingleS1Jet56_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt30_v1>>eventfired_Dpt30_S1Jet92seed","HLT_DmesonTrackingGlobalPt8_Dpt30_v1&&L1_SingleJet92_BptxAND","goff"); TH1D * Events_Dpt30_MBseed = new TH1D( "Events_Dpt30_MBseed", "Events_Dpt30_MBseed", 8, 0, 8); TH1D * fraction_Events_Dpt30_L1Jetseed = new TH1D( "fraction_Events_Dpt30_L1Jetseed","fraction_Events_Dpt30_L1Jetseed", 8, 0, 8); fraction_Events_Dpt30_L1Jetseed->SetLineWidth(2.0); cout << "Dpt 20 fired events: " << eventfired_Dpt30_MBseed->GetEntries() << endl; for( int i = 0; i < 8; i++ ) { Events_Dpt30_MBseed->SetBinContent( i+1, eventfired_Dpt30_MBseed->GetEntries()); Events_Dpt30_MBseed->SetBinError( i+1, TMath::Sqrt(eventfired_Dpt30_MBseed->GetEntries())); } fraction_Events_Dpt30_L1Jetseed->SetBinContent(1, eventfired_Dpt30_MBseed->GetEntries()); fraction_Events_Dpt30_L1Jetseed->SetBinError( 1, TMath::Sqrt(eventfired_Dpt30_MBseed->GetEntries())); fraction_Events_Dpt30_L1Jetseed->SetBinContent( 2, eventfired_Dpt30_S1Jet8seed->GetEntries()); fraction_Events_Dpt30_L1Jetseed->SetBinError( 2, TMath::Sqrt(eventfired_Dpt30_S1Jet8seed->GetEntries())); fraction_Events_Dpt30_L1Jetseed->SetBinContent( 3, eventfired_Dpt30_S1Jet16seed->GetEntries()); fraction_Events_Dpt30_L1Jetseed->SetBinError( 3, TMath::Sqrt(eventfired_Dpt30_S1Jet16seed->GetEntries())); fraction_Events_Dpt30_L1Jetseed->SetBinContent( 4, eventfired_Dpt30_S1Jet28seed->GetEntries()); fraction_Events_Dpt30_L1Jetseed->SetBinError( 4, TMath::Sqrt(eventfired_Dpt30_S1Jet28seed->GetEntries())); fraction_Events_Dpt30_L1Jetseed->SetBinContent( 5, eventfired_Dpt30_S1Jet40seed->GetEntries()); fraction_Events_Dpt30_L1Jetseed->SetBinError( 5, TMath::Sqrt(eventfired_Dpt30_S1Jet40seed->GetEntries())); fraction_Events_Dpt30_L1Jetseed->SetBinContent( 6, eventfired_Dpt30_S1Jet44seed->GetEntries()); fraction_Events_Dpt30_L1Jetseed->SetBinError( 6, TMath::Sqrt(eventfired_Dpt30_S1Jet44seed->GetEntries())); fraction_Events_Dpt30_L1Jetseed->SetBinContent( 7, eventfired_Dpt30_S1Jet56seed->GetEntries()); fraction_Events_Dpt30_L1Jetseed->SetBinError( 7, TMath::Sqrt(eventfired_Dpt30_S1Jet56seed->GetEntries())); fraction_Events_Dpt30_L1Jetseed->SetBinContent( 8, eventfired_Dpt30_S1Jet92seed->GetEntries()); fraction_Events_Dpt30_L1Jetseed->SetBinError( 8, TMath::Sqrt(eventfired_Dpt30_S1Jet92seed->GetEntries())); for( int i = 0; i < 8; i++ ) cout << " bin content: " << fraction_Events_Dpt30_L1Jetseed->GetBinContent( i+1 ) << endl; fraction_Events_Dpt30_L1Jetseed->Divide( fraction_Events_Dpt30_L1Jetseed, Events_Dpt30_MBseed, 1.0, 1.0, "B"); fraction_Events_Dpt30_L1Jetseed->SetLineColor(2.0); TCanvas * cfg_evtfraction_Dpt30_L1seed = new TCanvas("cfg_evtfraction_Dpt30_L1seed","cfg_evtfraction_Dpt30_L1seed",600,600); cfg_evtfraction_Dpt30_L1seed->SetGridx(); cfg_evtfraction_Dpt30_L1seed->SetGridy(); cfg_evtfraction_Dpt30_L1seed->SetGrid(); fraction_Events_Dpt30_L1Jetseed->GetXaxis()->SetTitle("L1Jet* seed"); fraction_Events_Dpt30_L1Jetseed->GetYaxis()->SetTitle("Event fraction: L1Jet* seed/MB seed"); fraction_Events_Dpt30_L1Jetseed->GetYaxis()->SetRangeUser(0.,1.2); fraction_Events_Dpt30_L1Jetseed->Draw(); for( int i = 0; i < 8; i++ ) cout << " fraction: " << fraction_Events_Dpt30_L1Jetseed->GetBinContent( i+1 ) << " +/- " << fraction_Events_Dpt30_L1Jetseed->GetBinError( i+1 ) << endl; cfg_evtfraction_Dpt30_L1seed->SaveAs("plots/cfg_evtfraction_Dpt30_L1seed_AllMB_D0pt15p0_Pthat15.png"); cfg_evtfraction_Dpt30_L1seed->SaveAs("plots/cfg_evtfraction_Dpt30_L1seed_AllMB_D0pt15p0_Pthat15.pdf"); TH1D * eventfired_Dpt40_MBseed = new TH1D("eventfired_Dpt40_MBseed","eventfired_Dpt40_MBseed",2,0,2); TH1D * eventfired_Dpt40_S1Jet8seed = new TH1D("eventfired_Dpt40_S1Jet8seed","eventfired_Dpt40_S1Jet8seed",2,0,2); TH1D * eventfired_Dpt40_S1Jet16seed = new TH1D("eventfired_Dpt40_S1Jet16seed","eventfired_Dpt40_S1Jet16seed",2,0,2); TH1D * eventfired_Dpt40_S1Jet28seed = new TH1D("eventfired_Dpt40_S1Jet28seed","eventfired_Dpt40_S1Jet28seed",2,0,2); TH1D * eventfired_Dpt40_S1Jet40seed = new TH1D("eventfired_Dpt40_S1Jet40seed","eventfired_Dpt40_S1Jet40seed",2,0,2); TH1D * eventfired_Dpt40_S1Jet44seed = new TH1D("eventfired_Dpt40_S1Jet44seed","eventfired_Dpt40_S1Jet44seed",2,0,2); TH1D * eventfired_Dpt40_S1Jet56seed = new TH1D("eventfired_Dpt40_S1Jet56seed","eventfired_Dpt40_S1Jet56seed",2,0,2); TH1D * eventfired_Dpt40_S1Jet92seed = new TH1D("eventfired_Dpt40_S1Jet92seed","eventfired_Dpt40_S1Jet92seed",2,0,2); eventfired_Dpt40_MBseed->SetLineWidth(2.0); eventfired_Dpt40_S1Jet8seed->SetLineWidth(2.0); eventfired_Dpt40_S1Jet16seed->SetLineWidth(2.0); eventfired_Dpt40_S1Jet28seed->SetLineWidth(2.0); eventfired_Dpt40_S1Jet40seed->SetLineWidth(2.0); eventfired_Dpt40_S1Jet44seed->SetLineWidth(2.0); eventfired_Dpt40_S1Jet56seed->SetLineWidth(2.0); eventfired_Dpt40_S1Jet92seed->SetLineWidth(2.0); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt40_v1>>eventfired_Dpt40_MBseed","HLT_DmesonTrackingGlobalPt8_Dpt40_v1","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt40_v1>>eventfired_Dpt40_S1Jet8seed","HLT_DmesonTrackingGlobalPt8_Dpt40_v1&&L1_SingleS1Jet8_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt40_v1>>eventfired_Dpt40_S1Jet16seed","HLT_DmesonTrackingGlobalPt8_Dpt40_v1&&L1_SingleS1Jet16_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt40_v1>>eventfired_Dpt40_S1Jet28seed","HLT_DmesonTrackingGlobalPt8_Dpt40_v1&&L1_SingleS1Jet28_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt40_v1>>eventfired_Dpt40_S1Jet40seed","HLT_DmesonTrackingGlobalPt8_Dpt40_v1&&L1_SingleS1Jet40_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt40_v1>>eventfired_Dpt40_S1Jet44seed","HLT_DmesonTrackingGlobalPt8_Dpt40_v1&&L1_SingleJet44_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt40_v1>>eventfired_Dpt40_S1Jet56seed","HLT_DmesonTrackingGlobalPt8_Dpt40_v1&&L1_SingleS1Jet56_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt40_v1>>eventfired_Dpt40_S1Jet92seed","HLT_DmesonTrackingGlobalPt8_Dpt40_v1&&L1_SingleJet92_BptxAND","goff"); TH1D * Events_Dpt40_MBseed = new TH1D( "Events_Dpt40_MBseed", "Events_Dpt40_MBseed", 8, 0, 8); TH1D * fraction_Events_Dpt40_L1Jetseed = new TH1D( "fraction_Events_Dpt40_L1Jetseed","fraction_Events_Dpt40_L1Jetseed", 8, 0, 8); fraction_Events_Dpt40_L1Jetseed->SetLineWidth(2.0); cout << "Dpt 20 fired events: " << eventfired_Dpt40_MBseed->GetEntries() << endl; for( int i = 0; i < 8; i++ ) { Events_Dpt40_MBseed->SetBinContent( i+1, eventfired_Dpt40_MBseed->GetEntries()); Events_Dpt40_MBseed->SetBinError( i+1, TMath::Sqrt(eventfired_Dpt40_MBseed->GetEntries())); } fraction_Events_Dpt40_L1Jetseed->SetBinContent(1, eventfired_Dpt40_MBseed->GetEntries()); fraction_Events_Dpt40_L1Jetseed->SetBinError( 1, TMath::Sqrt(eventfired_Dpt40_MBseed->GetEntries())); fraction_Events_Dpt40_L1Jetseed->SetBinContent( 2, eventfired_Dpt40_S1Jet8seed->GetEntries()); fraction_Events_Dpt40_L1Jetseed->SetBinError( 2, TMath::Sqrt(eventfired_Dpt40_S1Jet8seed->GetEntries())); fraction_Events_Dpt40_L1Jetseed->SetBinContent( 3, eventfired_Dpt40_S1Jet16seed->GetEntries()); fraction_Events_Dpt40_L1Jetseed->SetBinError( 3, TMath::Sqrt(eventfired_Dpt40_S1Jet16seed->GetEntries())); fraction_Events_Dpt40_L1Jetseed->SetBinContent( 4, eventfired_Dpt40_S1Jet28seed->GetEntries()); fraction_Events_Dpt40_L1Jetseed->SetBinError( 4, TMath::Sqrt(eventfired_Dpt40_S1Jet28seed->GetEntries())); fraction_Events_Dpt40_L1Jetseed->SetBinContent( 5, eventfired_Dpt40_S1Jet40seed->GetEntries()); fraction_Events_Dpt40_L1Jetseed->SetBinError( 5, TMath::Sqrt(eventfired_Dpt40_S1Jet40seed->GetEntries())); fraction_Events_Dpt40_L1Jetseed->SetBinContent( 6, eventfired_Dpt40_S1Jet44seed->GetEntries()); fraction_Events_Dpt40_L1Jetseed->SetBinError( 6, TMath::Sqrt(eventfired_Dpt40_S1Jet44seed->GetEntries())); fraction_Events_Dpt40_L1Jetseed->SetBinContent( 7, eventfired_Dpt40_S1Jet56seed->GetEntries()); fraction_Events_Dpt40_L1Jetseed->SetBinError( 7, TMath::Sqrt(eventfired_Dpt40_S1Jet56seed->GetEntries())); fraction_Events_Dpt40_L1Jetseed->SetBinContent( 8, eventfired_Dpt40_S1Jet92seed->GetEntries()); fraction_Events_Dpt40_L1Jetseed->SetBinError( 8, TMath::Sqrt(eventfired_Dpt40_S1Jet92seed->GetEntries())); for( int i = 0; i < 8; i++ ) cout << " bin content: " << fraction_Events_Dpt40_L1Jetseed->GetBinContent( i+1 ) << endl; fraction_Events_Dpt40_L1Jetseed->Divide( fraction_Events_Dpt40_L1Jetseed, Events_Dpt40_MBseed, 1.0, 1.0, "B"); fraction_Events_Dpt40_L1Jetseed->SetLineColor(2.0); TCanvas * cfg_evtfraction_Dpt40_L1seed = new TCanvas("cfg_evtfraction_Dpt40_L1seed","cfg_evtfraction_Dpt40_L1seed",600,600); cfg_evtfraction_Dpt40_L1seed->SetGridx(); cfg_evtfraction_Dpt40_L1seed->SetGridy(); cfg_evtfraction_Dpt40_L1seed->SetGrid(); fraction_Events_Dpt40_L1Jetseed->GetXaxis()->SetTitle("L1Jet* seed"); fraction_Events_Dpt40_L1Jetseed->GetYaxis()->SetTitle("Event fraction: L1Jet* seed/MB seed"); fraction_Events_Dpt40_L1Jetseed->GetYaxis()->SetRangeUser(0.,1.2); fraction_Events_Dpt40_L1Jetseed->Draw(); for( int i = 0; i < 8; i++ ) cout << " fraction: " << fraction_Events_Dpt40_L1Jetseed->GetBinContent( i+1 ) << " +/- " << fraction_Events_Dpt40_L1Jetseed->GetBinError( i+1 ) << endl; cfg_evtfraction_Dpt40_L1seed->SaveAs("plots/cfg_evtfraction_Dpt40_L1seed_AllMB_D0pt15p0_Pthat15.png"); cfg_evtfraction_Dpt40_L1seed->SaveAs("plots/cfg_evtfraction_Dpt40_L1seed_AllMB_D0pt15p0_Pthat15.pdf"); TH1D * eventfired_Dpt60_MBseed = new TH1D("eventfired_Dpt60_MBseed","eventfired_Dpt60_MBseed",2,0,2); TH1D * eventfired_Dpt60_S1Jet8seed = new TH1D("eventfired_Dpt60_S1Jet8seed","eventfired_Dpt60_S1Jet8seed",2,0,2); TH1D * eventfired_Dpt60_S1Jet16seed = new TH1D("eventfired_Dpt60_S1Jet16seed","eventfired_Dpt60_S1Jet16seed",2,0,2); TH1D * eventfired_Dpt60_S1Jet28seed = new TH1D("eventfired_Dpt60_S1Jet28seed","eventfired_Dpt60_S1Jet28seed",2,0,2); TH1D * eventfired_Dpt60_S1Jet40seed = new TH1D("eventfired_Dpt60_S1Jet40seed","eventfired_Dpt60_S1Jet40seed",2,0,2); TH1D * eventfired_Dpt60_S1Jet44seed = new TH1D("eventfired_Dpt60_S1Jet44seed","eventfired_Dpt60_S1Jet44seed",2,0,2); TH1D * eventfired_Dpt60_S1Jet56seed = new TH1D("eventfired_Dpt60_S1Jet56seed","eventfired_Dpt60_S1Jet56seed",2,0,2); TH1D * eventfired_Dpt60_S1Jet92seed = new TH1D("eventfired_Dpt60_S1Jet92seed","eventfired_Dpt60_S1Jet92seed",2,0,2); eventfired_Dpt60_MBseed->SetLineWidth(2.0); eventfired_Dpt60_S1Jet8seed->SetLineWidth(2.0); eventfired_Dpt60_S1Jet16seed->SetLineWidth(2.0); eventfired_Dpt60_S1Jet28seed->SetLineWidth(2.0); eventfired_Dpt60_S1Jet40seed->SetLineWidth(2.0); eventfired_Dpt60_S1Jet44seed->SetLineWidth(2.0); eventfired_Dpt60_S1Jet56seed->SetLineWidth(2.0); eventfired_Dpt60_S1Jet92seed->SetLineWidth(2.0); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt60_v1>>eventfired_Dpt60_MBseed","HLT_DmesonTrackingGlobalPt8_Dpt60_v1","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt60_v1>>eventfired_Dpt60_S1Jet8seed","HLT_DmesonTrackingGlobalPt8_Dpt60_v1&&L1_SingleS1Jet8_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt60_v1>>eventfired_Dpt60_S1Jet16seed","HLT_DmesonTrackingGlobalPt8_Dpt60_v1&&L1_SingleS1Jet16_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt60_v1>>eventfired_Dpt60_S1Jet28seed","HLT_DmesonTrackingGlobalPt8_Dpt60_v1&&L1_SingleS1Jet28_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt60_v1>>eventfired_Dpt60_S1Jet40seed","HLT_DmesonTrackingGlobalPt8_Dpt60_v1&&L1_SingleS1Jet40_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt60_v1>>eventfired_Dpt60_S1Jet44seed","HLT_DmesonTrackingGlobalPt8_Dpt60_v1&&L1_SingleJet44_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt60_v1>>eventfired_Dpt60_S1Jet56seed","HLT_DmesonTrackingGlobalPt8_Dpt60_v1&&L1_SingleS1Jet56_BptxAND","goff"); gentree->Draw("HLT_DmesonTrackingGlobalPt8_Dpt60_v1>>eventfired_Dpt60_S1Jet92seed","HLT_DmesonTrackingGlobalPt8_Dpt60_v1&&L1_SingleJet92_BptxAND","goff"); TH1D * Events_Dpt60_MBseed = new TH1D( "Events_Dpt60_MBseed", "Events_Dpt60_MBseed", 8, 0, 8); TH1D * fraction_Events_Dpt60_L1Jetseed = new TH1D( "fraction_Events_Dpt60_L1Jetseed","fraction_Events_Dpt60_L1Jetseed", 8, 0, 8); fraction_Events_Dpt60_L1Jetseed->SetLineWidth(2.0); cout << "Dpt 20 fired events: " << eventfired_Dpt60_MBseed->GetEntries() << endl; for( int i = 0; i < 8; i++ ) { Events_Dpt60_MBseed->SetBinContent( i+1, eventfired_Dpt60_MBseed->GetEntries()); Events_Dpt60_MBseed->SetBinError( i+1, TMath::Sqrt(eventfired_Dpt60_MBseed->GetEntries())); } fraction_Events_Dpt60_L1Jetseed->SetBinContent(1, eventfired_Dpt60_MBseed->GetEntries()); fraction_Events_Dpt60_L1Jetseed->SetBinError( 1, TMath::Sqrt(eventfired_Dpt60_MBseed->GetEntries())); fraction_Events_Dpt60_L1Jetseed->SetBinContent( 2, eventfired_Dpt60_S1Jet8seed->GetEntries()); fraction_Events_Dpt60_L1Jetseed->SetBinError( 2, TMath::Sqrt(eventfired_Dpt60_S1Jet8seed->GetEntries())); fraction_Events_Dpt60_L1Jetseed->SetBinContent( 3, eventfired_Dpt60_S1Jet16seed->GetEntries()); fraction_Events_Dpt60_L1Jetseed->SetBinError( 3, TMath::Sqrt(eventfired_Dpt60_S1Jet16seed->GetEntries())); fraction_Events_Dpt60_L1Jetseed->SetBinContent( 4, eventfired_Dpt60_S1Jet28seed->GetEntries()); fraction_Events_Dpt60_L1Jetseed->SetBinError( 4, TMath::Sqrt(eventfired_Dpt60_S1Jet28seed->GetEntries())); fraction_Events_Dpt60_L1Jetseed->SetBinContent( 5, eventfired_Dpt60_S1Jet40seed->GetEntries()); fraction_Events_Dpt60_L1Jetseed->SetBinError( 5, TMath::Sqrt(eventfired_Dpt60_S1Jet40seed->GetEntries())); fraction_Events_Dpt60_L1Jetseed->SetBinContent( 6, eventfired_Dpt60_S1Jet44seed->GetEntries()); fraction_Events_Dpt60_L1Jetseed->SetBinError( 6, TMath::Sqrt(eventfired_Dpt60_S1Jet44seed->GetEntries())); fraction_Events_Dpt60_L1Jetseed->SetBinContent( 7, eventfired_Dpt60_S1Jet56seed->GetEntries()); fraction_Events_Dpt60_L1Jetseed->SetBinError( 7, TMath::Sqrt(eventfired_Dpt60_S1Jet56seed->GetEntries())); fraction_Events_Dpt60_L1Jetseed->SetBinContent( 8, eventfired_Dpt60_S1Jet92seed->GetEntries()); fraction_Events_Dpt60_L1Jetseed->SetBinError( 8, TMath::Sqrt(eventfired_Dpt60_S1Jet92seed->GetEntries())); for( int i = 0; i < 8; i++ ) cout << " bin content: " << fraction_Events_Dpt60_L1Jetseed->GetBinContent( i+1 ) << endl; fraction_Events_Dpt60_L1Jetseed->Divide( fraction_Events_Dpt60_L1Jetseed, Events_Dpt60_MBseed, 1.0, 1.0, "B"); fraction_Events_Dpt60_L1Jetseed->SetLineColor(2.0); TCanvas * cfg_evtfraction_Dpt60_L1seed = new TCanvas("cfg_evtfraction_Dpt60_L1seed","cfg_evtfraction_Dpt60_L1seed",600,600); cfg_evtfraction_Dpt60_L1seed->SetGridx(); cfg_evtfraction_Dpt60_L1seed->SetGridy(); cfg_evtfraction_Dpt60_L1seed->SetGrid(); fraction_Events_Dpt60_L1Jetseed->GetXaxis()->SetTitle("L1Jet* seed"); fraction_Events_Dpt60_L1Jetseed->GetYaxis()->SetTitle("Event fraction: L1Jet* seed/MB seed"); fraction_Events_Dpt60_L1Jetseed->GetYaxis()->SetRangeUser(0.,1.2); fraction_Events_Dpt60_L1Jetseed->Draw(); for( int i = 0; i < 8; i++ ) cout << " fraction: " << fraction_Events_Dpt60_L1Jetseed->GetBinContent( i+1 ) << " +/- " << fraction_Events_Dpt60_L1Jetseed->GetBinError( i+1 ) << endl; cfg_evtfraction_Dpt60_L1seed->SaveAs("plots/cfg_evtfraction_Dpt60_L1seed_AllMB_D0pt15p0_Pthat15.png"); cfg_evtfraction_Dpt60_L1seed->SaveAs("plots/cfg_evtfraction_Dpt60_L1seed_AllMB_D0pt15p0_Pthat15.pdf"); }
int main(int argc, char **argv) { bool gotHistoBinning(false); char * binningFileName(0); char * variableName(0); bool gotVarName = false; char c; while ((c = getopt (argc, argv, "v:H:")) != -1) switch (c) { case 'v': gotVarName = true; variableName = new char[strlen(optarg)+1]; strcpy(variableName,optarg); break; case 'H': gotHistoBinning = true; binningFileName = new char[strlen(optarg)+1]; strcpy(binningFileName,optarg); break; default: std::cout << "usage: -r responseFile [-d <dataFile>] \n"; abort (); } string variable; string syst_type; if (gotVarName) { variable = variableName; } else { variable = "LeadingJetPt"; } std::ostringstream outName; outName<<"sysResults/systematics_"<<variable<<".root"; // TFile * fout = new TFile("systematics.root", "RECREATE"); TFile * fout = new TFile(outName.str().c_str(), "RECREATE"); if (gotHistoBinning) { UnfoldingHistogramFactory * histoFac = UnfoldingHistogramFactory::GetInstance(); histoFac->SetBinning(binningFileName); } double WZbr[4]={0.03363*0.1075,0.03363*0.1057,0.03366*0.1075,0.03366*0.1057}; const int nChannels(4); TH1D * h_qcdScale[nChannels]; TH1D * h_PDFSys[nChannels]; TH1D * h_DataDrivenSys[nChannels]; TH1D * h_DataDrivenSys_el[nChannels]; TH1D * h_DataDrivenSys_mu[nChannels]; TH1D * h_unf_syst[nChannels]; TH1D * h_leptTrgEff_el[nChannels]; TH1D * h_leptTrgEff_mu[nChannels]; TH1D * h_Etsys[nChannels]; TH1D * h_lumi[nChannels]; TH1D * h_bckgSys[nChannels]; TH1D * h_crossSection[nChannels]; TH1D * h_crossSection_diff[nChannels]; TH1D * h_crossSection_inclusive[nChannels]; TH1D * h_crossSection_incl_diff[nChannels]; TH1D * h_met_nominal[nChannels]; TH1D * h_kterm[nChannels]; TH1D* h_sys[nChannels][26]; TMatrixD* covariance_unfolding[nChannels]; std::vector<TString>types; types.push_back("pu_syst"); types.push_back("ele_scale_syst"); types.push_back("mu_scale_syst"); types.push_back("ele_SF"); types.push_back("mu_SF"); types.push_back("JER"); types.push_back("JES"); types.push_back("ZZ"); types.push_back("Zgamma"); types.push_back("WV"); types.push_back("WZZJets"); types.push_back("ZZZJets"); types.push_back("WWZJets"); types.push_back("WWWJets"); types.push_back("TTWJets"); types.push_back("TTZJets"); types.push_back("TTWWJets"); types.push_back("TTGJets"); types.push_back("WWGJets"); types.push_back("met_elEn"); types.push_back("met_jetEn"); types.push_back("met_jetRes"); types.push_back("met_muEn"); types.push_back("met_tauEn"); types.push_back("met_unEn"); types.push_back("UnfoldingStat"); // types.push_back("met_nominal"); for (int hist=0; hist<nChannels; hist++){ std::ostringstream qcdScaleName,PDFsysName,leptTrgEffName_el, leptTrgEffName_mu,EtsysName, muMomScaleName, elEnScaleName, pileupSysName, ZZxsName, ZgammaxsName, dataDrivenName, bckgSysName, xsNameIncl, xsNameInclDiff, JESsysName, JERsysName, eleSFname, muSFname, unfStatName; std::ostringstream WVname, WZZname, ZZZname, WWZname, WWWname, TTWname, TTZname, TTWWname, TTGname, WWGname, systName, lumiName; std::ostringstream metElEnName, metJetEnName, metJetResName, metMuEnName, metTauEnName, metUnEnName, metNominalName; std::ostringstream dataDriven_elName, dataDriven_muName, unfSystName; qcdScaleName<<"h_qcdScale_"<<hist; PDFsysName<<"h_PDFsys_"<<hist; leptTrgEffName_el<<"h_leptTrgEff_el_"<<hist; leptTrgEffName_mu<<"h_leptTrgEff_mu_"<<hist; EtsysName<<"h_Etsys_"<<hist; lumiName<<"h_lumi_"<<hist; muMomScaleName<<"h_muMomScale_"<<hist; elEnScaleName<<"h_elEnScale_"<<hist; pileupSysName<<"h_pileupSys_"<<hist; eleSFname<<"ele_SF_"<<hist; muSFname<<"mu_SF_"<<hist; unfStatName << "h_unfoldingStat_" << hist; ZZxsName<<"h_ZZxs_"<<hist; ZgammaxsName<<"h_Zgammaxs_"<<hist; dataDrivenName<<"h_dataDrivensys_"<<hist; dataDriven_elName<<"h_dataDrivenElsys_"<<hist; dataDriven_muName<<"h_dataDrivenMusys_"<<hist; bckgSysName<<"h_bckgSys_"<<hist; xsNameIncl<<"h_crossSection_inclusive"<<hist; xsNameInclDiff<<"h_crossSection_inclusive_diff"<<hist; JESsysName<<"h_JESsys_"<<hist; JERsysName<<"h_JERsys_"<<hist; WVname<<"h_WVJets_"<<hist; WZZname<<"h_WZZJets_"<<hist; ZZZname<<"h_ZZZJets_"<<hist; WWZname<<"h_WWZJets_"<<hist; WWWname<<"h_WWWJets_"<<hist; TTWname<<"h_TTWJets_"<<hist; TTZname<<"h_TTZJets_"<<hist; TTWWname<<"h_TTWWJets_"<<hist; TTGname<<"h_TTGJets_"<<hist; WWGname<<"h_WWGJets_"<<hist; systName<<"h_syst"<<hist; metElEnName<<"h_met_elEn_"<<hist; metJetEnName<<"h_met_jetEn_"<<hist; metJetResName<<"h_met_jetRes_"<<hist; metMuEnName<<"h_met_muEn_"<<hist; metTauEnName<<"h_met_tauEn_"<<hist; metUnEnName<<"h_met_unEn_"<<hist; metNominalName<<"h_metNominal_"<<hist; unfSystName<<"h_unfSyst_"<<hist; h_qcdScale[hist] = GetTheorySystematics("qcd",variable, qcdScaleName.str().c_str(), qcdScaleName.str().c_str()); h_PDFSys[hist] = GetTheorySystematics("pdf",variable, PDFsysName.str().c_str(), PDFsysName.str().c_str()); h_sys[hist][25] = UnfoldingHistogramFactory::createHistogramForVar(variable, unfStatName.str().c_str(), unfStatName.str().c_str()); std::cout << "Unfolding stat histo : " << unfStatName.str().c_str() << std::endl; if (variable=="Njets"){ // h_qcdScale[hist]=UnfoldingHistogramFactory::createNjetsHistogram(qcdScaleName.str().c_str(), qcdScaleName.str().c_str()); // h_PDFSys[hist]= UnfoldingHistogramFactory::createNjetsHistogram(PDFsysName.str().c_str(), PDFsysName.str().c_str()); h_leptTrgEff_el[hist]=UnfoldingHistogramFactory::createNjetsHistogram(leptTrgEffName_el.str().c_str(), leptTrgEffName_el.str().c_str()); h_leptTrgEff_mu[hist]=UnfoldingHistogramFactory::createNjetsHistogram(leptTrgEffName_mu.str().c_str(), leptTrgEffName_mu.str().c_str()); h_Etsys[hist]=UnfoldingHistogramFactory::createNjetsHistogram(EtsysName.str().c_str(), EtsysName.str().c_str()); h_lumi[hist]=UnfoldingHistogramFactory::createNjetsHistogram(lumiName.str().c_str(), lumiName.str().c_str()); h_DataDrivenSys[hist]=UnfoldingHistogramFactory::createNjetsHistogram(dataDrivenName.str().c_str(), dataDrivenName.str().c_str()); h_DataDrivenSys_el[hist]=UnfoldingHistogramFactory::createNjetsHistogram(dataDriven_elName.str().c_str(), dataDriven_elName.str().c_str()); h_DataDrivenSys_mu[hist]=UnfoldingHistogramFactory::createNjetsHistogram(dataDriven_muName.str().c_str(), dataDriven_muName.str().c_str()); h_unf_syst[hist]=UnfoldingHistogramFactory::createNjetsHistogram(unfSystName.str().c_str(), unfSystName.str().c_str()); h_bckgSys[hist]=UnfoldingHistogramFactory::createNjetsHistogram(bckgSysName.str().c_str(), bckgSysName.str().c_str()); h_crossSection_inclusive[hist]=UnfoldingHistogramFactory::createNjetsHistogram(xsNameIncl.str().c_str(), xsNameIncl.str().c_str()); h_crossSection_incl_diff[hist]=UnfoldingHistogramFactory::createNjetsHistogram(xsNameInclDiff.str().c_str(), xsNameInclDiff.str().c_str()); h_met_nominal[hist]=UnfoldingHistogramFactory::createNjetsHistogram(metNominalName.str().c_str(), metNominalName.str().c_str()); h_sys[hist][0] =UnfoldingHistogramFactory::createNjetsHistogram(pileupSysName.str().c_str(), pileupSysName.str().c_str()); h_sys[hist][1] =UnfoldingHistogramFactory::createNjetsHistogram(elEnScaleName.str().c_str(), elEnScaleName.str().c_str()); h_sys[hist][2] =UnfoldingHistogramFactory::createNjetsHistogram(muMomScaleName.str().c_str(), muMomScaleName.str().c_str()); h_sys[hist][3] =UnfoldingHistogramFactory::createNjetsHistogram(eleSFname.str().c_str(), eleSFname.str().c_str()); h_sys[hist][4] =UnfoldingHistogramFactory::createNjetsHistogram(muSFname.str().c_str(), muSFname.str().c_str()); h_sys[hist][5] =UnfoldingHistogramFactory::createNjetsHistogram(JERsysName.str().c_str(), JERsysName.str().c_str()); h_sys[hist][6] =UnfoldingHistogramFactory::createNjetsHistogram(JESsysName.str().c_str(), JESsysName.str().c_str()); h_sys[hist][7] =UnfoldingHistogramFactory::createNjetsHistogram(ZZxsName.str().c_str(), ZZxsName.str().c_str()); h_sys[hist][8] =UnfoldingHistogramFactory::createNjetsHistogram(ZgammaxsName.str().c_str(), ZgammaxsName.str().c_str()); h_sys[hist][9] =UnfoldingHistogramFactory::createNjetsHistogram(WVname.str().c_str(), WVname.str().c_str()); h_sys[hist][10]=UnfoldingHistogramFactory::createNjetsHistogram(WZZname.str().c_str(), WZZname.str().c_str()); h_sys[hist][11]=UnfoldingHistogramFactory::createNjetsHistogram(ZZZname.str().c_str(), ZZZname.str().c_str()); h_sys[hist][12]=UnfoldingHistogramFactory::createNjetsHistogram(WWZname.str().c_str(), WWZname.str().c_str()); h_sys[hist][13]=UnfoldingHistogramFactory::createNjetsHistogram(WWWname.str().c_str(), WWWname.str().c_str()); h_sys[hist][14]=UnfoldingHistogramFactory::createNjetsHistogram(TTWname.str().c_str(), TTWname.str().c_str()); h_sys[hist][15]=UnfoldingHistogramFactory::createNjetsHistogram(TTZname.str().c_str(), TTZname.str().c_str()); h_sys[hist][16]=UnfoldingHistogramFactory::createNjetsHistogram(TTWWname.str().c_str(), TTWWname.str().c_str()); h_sys[hist][17]=UnfoldingHistogramFactory::createNjetsHistogram(TTGname.str().c_str(), TTGname.str().c_str()); h_sys[hist][18]=UnfoldingHistogramFactory::createNjetsHistogram(WWGname.str().c_str(), WWGname.str().c_str()); h_sys[hist][19]=UnfoldingHistogramFactory::createNjetsHistogram(metElEnName.str().c_str(), metElEnName.str().c_str()); h_sys[hist][20]=UnfoldingHistogramFactory::createNjetsHistogram(metJetEnName.str().c_str(), metJetEnName.str().c_str()); h_sys[hist][21]=UnfoldingHistogramFactory::createNjetsHistogram(metJetResName.str().c_str(), metJetResName.str().c_str()); h_sys[hist][22]=UnfoldingHistogramFactory::createNjetsHistogram(metMuEnName.str().c_str(), metMuEnName.str().c_str()); h_sys[hist][23]=UnfoldingHistogramFactory::createNjetsHistogram(metTauEnName.str().c_str(), metTauEnName.str().c_str()); h_sys[hist][24]=UnfoldingHistogramFactory::createNjetsHistogram(metUnEnName.str().c_str(), metUnEnName.str().c_str()); } if (variable=="Zpt"){ // h_qcdScale[hist]=UnfoldingHistogramFactory::createZPtHistogram(qcdScaleName.str().c_str(), qcdScaleName.str().c_str()); // h_PDFSys[hist]= UnfoldingHistogramFactory::createZPtHistogram(PDFsysName.str().c_str(), PDFsysName.str().c_str()); h_leptTrgEff_el[hist]=UnfoldingHistogramFactory::createZPtHistogram(leptTrgEffName_el.str().c_str(), leptTrgEffName_el.str().c_str()); h_leptTrgEff_mu[hist]=UnfoldingHistogramFactory::createZPtHistogram(leptTrgEffName_mu.str().c_str(), leptTrgEffName_mu.str().c_str()); h_Etsys[hist]=UnfoldingHistogramFactory::createZPtHistogram(EtsysName.str().c_str(), EtsysName.str().c_str()); h_lumi[hist]=UnfoldingHistogramFactory::createZPtHistogram(lumiName.str().c_str(), lumiName.str().c_str()); h_DataDrivenSys[hist]=UnfoldingHistogramFactory::createZPtHistogram(dataDrivenName.str().c_str(), dataDrivenName.str().c_str()); h_DataDrivenSys_el[hist]=UnfoldingHistogramFactory::createZPtHistogram(dataDriven_elName.str().c_str(), dataDriven_elName.str().c_str()); h_DataDrivenSys_mu[hist]=UnfoldingHistogramFactory::createZPtHistogram(dataDriven_muName.str().c_str(), dataDriven_muName.str().c_str()); h_unf_syst[hist]=UnfoldingHistogramFactory::createZPtHistogram(unfSystName.str().c_str(), unfSystName.str().c_str()); h_bckgSys[hist]=UnfoldingHistogramFactory::createZPtHistogram(bckgSysName.str().c_str(), bckgSysName.str().c_str()); h_crossSection_inclusive[hist]=UnfoldingHistogramFactory::createZPtHistogram(xsNameIncl.str().c_str(), xsNameIncl.str().c_str()); h_crossSection_incl_diff[hist]=UnfoldingHistogramFactory::createZPtHistogram(xsNameInclDiff.str().c_str(), xsNameInclDiff.str().c_str()); h_met_nominal[hist]=UnfoldingHistogramFactory::createZPtHistogram(metNominalName.str().c_str(), metNominalName.str().c_str()); h_sys[hist][0] =UnfoldingHistogramFactory::createZPtHistogram(pileupSysName.str().c_str(), pileupSysName.str().c_str()); h_sys[hist][1] =UnfoldingHistogramFactory::createZPtHistogram(elEnScaleName.str().c_str(), elEnScaleName.str().c_str()); h_sys[hist][2] =UnfoldingHistogramFactory::createZPtHistogram(muMomScaleName.str().c_str(), muMomScaleName.str().c_str()); h_sys[hist][3] =UnfoldingHistogramFactory::createZPtHistogram(eleSFname.str().c_str(), eleSFname.str().c_str()); h_sys[hist][4] =UnfoldingHistogramFactory::createZPtHistogram(muSFname.str().c_str(), muSFname.str().c_str()); h_sys[hist][5] =UnfoldingHistogramFactory::createZPtHistogram(JERsysName.str().c_str(), JERsysName.str().c_str()); h_sys[hist][6] =UnfoldingHistogramFactory::createZPtHistogram(JESsysName.str().c_str(), JESsysName.str().c_str()); h_sys[hist][7] =UnfoldingHistogramFactory::createZPtHistogram(ZZxsName.str().c_str(), ZZxsName.str().c_str()); h_sys[hist][8] =UnfoldingHistogramFactory::createZPtHistogram(ZgammaxsName.str().c_str(), ZgammaxsName.str().c_str()); h_sys[hist][9] =UnfoldingHistogramFactory::createZPtHistogram(WVname.str().c_str(), WVname.str().c_str()); h_sys[hist][10]=UnfoldingHistogramFactory::createZPtHistogram(WZZname.str().c_str(), WZZname.str().c_str()); h_sys[hist][11]=UnfoldingHistogramFactory::createZPtHistogram(ZZZname.str().c_str(), ZZZname.str().c_str()); h_sys[hist][12]=UnfoldingHistogramFactory::createZPtHistogram(WWZname.str().c_str(), WWZname.str().c_str()); h_sys[hist][13]=UnfoldingHistogramFactory::createZPtHistogram(WWWname.str().c_str(), WWWname.str().c_str()); h_sys[hist][14]=UnfoldingHistogramFactory::createZPtHistogram(TTWname.str().c_str(), TTWname.str().c_str()); h_sys[hist][15]=UnfoldingHistogramFactory::createZPtHistogram(TTZname.str().c_str(), TTZname.str().c_str()); h_sys[hist][16]=UnfoldingHistogramFactory::createZPtHistogram(TTWWname.str().c_str(), TTWWname.str().c_str()); h_sys[hist][17]=UnfoldingHistogramFactory::createZPtHistogram(TTGname.str().c_str(), TTGname.str().c_str()); h_sys[hist][18]=UnfoldingHistogramFactory::createZPtHistogram(WWGname.str().c_str(), WWGname.str().c_str()); h_sys[hist][19]=UnfoldingHistogramFactory::createZPtHistogram(metElEnName.str().c_str(), metElEnName.str().c_str()); h_sys[hist][20]=UnfoldingHistogramFactory::createZPtHistogram(metJetEnName.str().c_str(), metJetEnName.str().c_str()); h_sys[hist][21]=UnfoldingHistogramFactory::createZPtHistogram(metJetResName.str().c_str(), metJetResName.str().c_str()); h_sys[hist][22]=UnfoldingHistogramFactory::createZPtHistogram(metMuEnName.str().c_str(), metMuEnName.str().c_str()); h_sys[hist][23]=UnfoldingHistogramFactory::createZPtHistogram(metTauEnName.str().c_str(), metTauEnName.str().c_str()); h_sys[hist][24]=UnfoldingHistogramFactory::createZPtHistogram(metUnEnName.str().c_str(), metUnEnName.str().c_str()); } if (variable=="LeadingJetPt"){ // h_qcdScale[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(qcdScaleName.str().c_str(), qcdScaleName.str().c_str()); // h_PDFSys[hist]= UnfoldingHistogramFactory::createLeadingJetHistogram(PDFsysName.str().c_str(), PDFsysName.str().c_str()); h_leptTrgEff_el[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(leptTrgEffName_el.str().c_str(), leptTrgEffName_el.str().c_str()); h_leptTrgEff_mu[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(leptTrgEffName_mu.str().c_str(), leptTrgEffName_mu.str().c_str()); h_Etsys[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(EtsysName.str().c_str(), EtsysName.str().c_str()); h_lumi[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(lumiName.str().c_str(), lumiName.str().c_str()); h_DataDrivenSys[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(dataDrivenName.str().c_str(), dataDrivenName.str().c_str()); h_DataDrivenSys_el[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(dataDriven_elName.str().c_str(), dataDriven_elName.str().c_str()); h_DataDrivenSys_mu[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(dataDriven_muName.str().c_str(), dataDriven_muName.str().c_str()); h_unf_syst[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(unfSystName.str().c_str(), unfSystName.str().c_str()); h_bckgSys[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(bckgSysName.str().c_str(), bckgSysName.str().c_str()); h_crossSection_inclusive[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(xsNameIncl.str().c_str(), xsNameIncl.str().c_str()); h_crossSection_incl_diff[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(xsNameInclDiff.str().c_str(), xsNameInclDiff.str().c_str()); h_met_nominal[hist]=UnfoldingHistogramFactory::createLeadingJetHistogram(metNominalName.str().c_str(), metNominalName.str().c_str()); h_sys[hist][0] =UnfoldingHistogramFactory::createLeadingJetHistogram(pileupSysName.str().c_str(), pileupSysName.str().c_str()); h_sys[hist][1] =UnfoldingHistogramFactory::createLeadingJetHistogram(elEnScaleName.str().c_str(), elEnScaleName.str().c_str()); h_sys[hist][2] =UnfoldingHistogramFactory::createLeadingJetHistogram(muMomScaleName.str().c_str(), muMomScaleName.str().c_str()); h_sys[hist][3] =UnfoldingHistogramFactory::createLeadingJetHistogram(eleSFname.str().c_str(), eleSFname.str().c_str()); h_sys[hist][4] =UnfoldingHistogramFactory::createLeadingJetHistogram(muSFname.str().c_str(), muSFname.str().c_str()); h_sys[hist][5] =UnfoldingHistogramFactory::createLeadingJetHistogram(JERsysName.str().c_str(), JERsysName.str().c_str()); h_sys[hist][6] =UnfoldingHistogramFactory::createLeadingJetHistogram(JESsysName.str().c_str(), JESsysName.str().c_str()); h_sys[hist][7] =UnfoldingHistogramFactory::createLeadingJetHistogram(ZZxsName.str().c_str(), ZZxsName.str().c_str()); h_sys[hist][8] =UnfoldingHistogramFactory::createLeadingJetHistogram(ZgammaxsName.str().c_str(), ZgammaxsName.str().c_str()); h_sys[hist][9] =UnfoldingHistogramFactory::createLeadingJetHistogram(WVname.str().c_str(), WVname.str().c_str()); h_sys[hist][10]=UnfoldingHistogramFactory::createLeadingJetHistogram(WZZname.str().c_str(), WZZname.str().c_str()); h_sys[hist][11]=UnfoldingHistogramFactory::createLeadingJetHistogram(ZZZname.str().c_str(), ZZZname.str().c_str()); h_sys[hist][12]=UnfoldingHistogramFactory::createLeadingJetHistogram(WWZname.str().c_str(), WWZname.str().c_str()); h_sys[hist][13]=UnfoldingHistogramFactory::createLeadingJetHistogram(WWWname.str().c_str(), WWWname.str().c_str()); h_sys[hist][14]=UnfoldingHistogramFactory::createLeadingJetHistogram(TTWname.str().c_str(), TTWname.str().c_str()); h_sys[hist][15]=UnfoldingHistogramFactory::createLeadingJetHistogram(TTZname.str().c_str(), TTZname.str().c_str()); h_sys[hist][16]=UnfoldingHistogramFactory::createLeadingJetHistogram(TTWWname.str().c_str(), TTWWname.str().c_str()); h_sys[hist][17]=UnfoldingHistogramFactory::createLeadingJetHistogram(TTGname.str().c_str(), TTGname.str().c_str()); h_sys[hist][18]=UnfoldingHistogramFactory::createLeadingJetHistogram(WWGname.str().c_str(), WWGname.str().c_str()); h_sys[hist][19]=UnfoldingHistogramFactory::createLeadingJetHistogram(metElEnName.str().c_str(), metElEnName.str().c_str()); h_sys[hist][20]=UnfoldingHistogramFactory::createLeadingJetHistogram(metJetEnName.str().c_str(), metJetEnName.str().c_str()); h_sys[hist][21]=UnfoldingHistogramFactory::createLeadingJetHistogram(metJetResName.str().c_str(), metJetResName.str().c_str()); h_sys[hist][22]=UnfoldingHistogramFactory::createLeadingJetHistogram(metMuEnName.str().c_str(), metMuEnName.str().c_str()); h_sys[hist][23]=UnfoldingHistogramFactory::createLeadingJetHistogram(metTauEnName.str().c_str(), metTauEnName.str().c_str()); h_sys[hist][24]=UnfoldingHistogramFactory::createLeadingJetHistogram(metUnEnName.str().c_str(), metUnEnName.str().c_str()); } } std::ostringstream nominalName, nominalNameMet; nominalName<<"sysResults/unfolding_nominal_"<<variable<<".root"; nominalNameMet<<"sysResults/unfolding_met_nominal_"<<variable<<".root"; std::cout<<nominalName.str().c_str()<<std::endl; for (int i=0; i<types.size(); i++){ std::ostringstream fileNameUp, fileNameDown; fileNameUp<<"sysResults/unfolding_"<<types[i]<<"_"<<variable<<"_UP.root"; fileNameDown<<"sysResults/unfolding_"<<types[i]<<"_"<<variable<<"_DOWN.root"; TFile * fUP= TFile::Open(fileNameUp.str().c_str()); TFile * fDOWN= TFile::Open(fileNameDown.str().c_str()); TFile* fnominal; std::cout<<"Nominal name MET: "<<nominalNameMet.str().c_str()<<std::endl;; if (i>=19 && i<25){ fnominal= TFile::Open(nominalNameMet.str().c_str()); } else if (i==25) { fnominal = fUP; } else fnominal= TFile::Open(nominalName.str().c_str()); for (int compute=0; compute<nChannels; compute++){ std::ostringstream histName, histNameNewUp, histNameNewDown, fileNameNominal; histName<<"hdsigma"<<variable<<"_"<<(compute+1); histNameNewUp<<"hdsigma"<<variable<<"_UP_"<<compute; histNameNewDown<<"hdsigma"<<variable<<"_DOWN_"<<compute; TH1D * h_up= (TH1D*) (fUP->Get(histName.str().c_str())->Clone(histNameNewUp.str().c_str())); TH1D * h_down= (TH1D*) (fDOWN->Get(histName.str().c_str())->Clone(histNameNewDown.str().c_str())); TH1D * h_nominal= (TH1D*) (fnominal->Get(histName.str().c_str())->Clone(histName.str().c_str())); for (int bin=0; bin< (h_nominal->GetNbinsX()+1); bin++){ double up_value=h_up->GetBinContent(bin); double down_value=h_down->GetBinContent(bin); double nominal_value=h_nominal->GetBinContent(bin); double maxDiff=std::max(fabs(up_value-nominal_value), fabs(down_value-nominal_value)); double syst_value=0; //double syst_value= maxDiff/nominal_value; if (nominal_value!=0.0){ syst_value= maxDiff/nominal_value; } if ((i==24) && (compute==2)){ std::cout<<types[i]<<std::endl; std::cout<<"up: "<<up_value<<" down: "<<down_value<<" nominal: "<<nominal_value<<std::endl; std::cout<<"sys: "<<syst_value<<std::endl; } h_sys[compute][i]->SetBinContent(bin, syst_value); } delete h_nominal; delete h_up; delete h_down; } } // Unfolding Statistics: make an average of the variation for each bin and // apply it to all TH1D * h_unfoldStatSys_all = UnfoldingHistogramFactory::createHistogramForVar(variable ,"h_unfoldingStat_mean" ,"Mean unfolding stat. sys"); for (int ichan=0; ichan<nChannels; ichan++) { h_unfoldStatSys_all->Add(h_sys[ichan][25]); } // factors: // 4 for average // sqrt(2) for going from difference between elments to sigma // sqrt(2) as stat. of full sample two times larger h_unfoldStatSys_all->Scale(1/8.); // Copy this for all 4 channels TH1D * unfStatHistos[4]; for (int ichan=0; ichan<nChannels; ichan++) { std::ostringstream key; key << "h_unfStat_" << ichan; unfStatHistos[ichan] = (TH1D*) h_unfoldStatSys_all->Clone(key.str().c_str()); } std::ostringstream dataDrivenName, dataDrivenName_el, dataDrivenName_mu, ktermName_up, ktermName_down; dataDrivenName_el<<"sysResults/unfolding_dataDriven_el_"<<variable<<".root"; dataDrivenName_mu<<"sysResults/unfolding_dataDriven_mu_"<<variable<<".root"; ktermName_up<<"sysResults/unfolding_kterm_up_"<<variable<<".root"; ktermName_down<<"sysResults/unfolding_kterm_down_"<<variable<<".root"; TFile * fDataDriven_el=TFile::Open(dataDrivenName_el.str().c_str()); TFile * fDataDriven_mu=TFile::Open(dataDrivenName_mu.str().c_str()); TFile * fkTerm_up= TFile::Open(ktermName_up.str().c_str()); TFile * fkTerm_down=TFile::Open(ktermName_down.str().c_str()); for (int other=0; other<nChannels; other++){ TFile * fnominal= TFile::Open(nominalName.str().c_str()); //cross section std::ostringstream crossSect, crossSect2, dataDrivSys, xsName, xsName2; crossSect<<"hdsigma"<<variable<<"_"<<(other+1); xsName<<"h_crossSection_"<<other; h_crossSection[other]= (TH1D*) (fnominal)->Get(crossSect.str().c_str())->Clone(xsName.str().c_str()); // Adding Covariance matrix reading std::ostringstream covarianceInName; std::ostringstream covarianceOutName; covarianceInName << "Covariance_hresult" << variable << "_" << other+1; covariance_unfolding[other] = (TMatrixD*) (fnominal)->Get(covarianceInName.str().c_str())->Clone(covarianceOutName.str().c_str()); // h_crossSection[other]= (TH1D*) (fnominal)->Get(crossSect.str().c_str())->Clone(crossSect.str().c_str()); std::cout<<"Integral: "<<h_crossSection[other]->Integral()<<std::endl; TH1D * h_dataDrivenUp_el=(TH1D*)(fDataDriven_el)->Get(crossSect.str().c_str())->Clone(); TH1D * h_dataDrivenUp_mu=(TH1D*)(fDataDriven_mu)->Get(crossSect.str().c_str())->Clone(); TH1D * h_kterm_down=(TH1D*)(fkTerm_up)->Get(crossSect.str().c_str())->Clone(); TH1D * h_kterm_up= (TH1D*)(fkTerm_down)->Get(crossSect.str().c_str())->Clone(); for (int bin1=0; bin1<(h_crossSection[other]->GetNbinsX()+1);bin1++){ double xs=(h_crossSection[other]->GetBinContent(bin1))/WZbr[other]; h_crossSection_inclusive[other]->SetBinContent(bin1, xs); double back2=0; for (int b=9; b<19; b++){ back2+=pow(h_sys[other][b]->GetBinContent(bin1),2); } h_bckgSys[other]->SetBinContent(bin1, sqrt(back2)); double met2=0; for (int m=19; m<=24; m++){ met2+=pow(h_sys[other][m]->GetBinContent(bin1),2); } h_Etsys[other]->SetBinContent(bin1,sqrt(met2)); double ltrig=sqrt(pow(h_sys[other][3]->GetBinContent(bin1),2)+pow(h_sys[other][4]->GetBinContent(bin1),2)); // h_leptTrgEff_el[other]->SetBinContent(bin1, ltrig); // ORIGINAL VALUE // h_qcdScale[other]->SetBinContent(bin1, 0.03); // NEW // h_qcdScale[other]->SetBinContent(bin1, 0.05); h_lumi[other]->SetBinContent(bin1, 0.026); // h_PDFSys[other]->SetBinContent(bin1, 0.014); double dataDrivenSyst_el=fabs(h_crossSection[other]->GetBinContent(bin1)-h_dataDrivenUp_el->GetBinContent(bin1))/(h_crossSection[other]->GetBinContent(bin1)); double dataDrivenSyst_mu=fabs(h_crossSection[other]->GetBinContent(bin1)-h_dataDrivenUp_mu->GetBinContent(bin1))/(h_crossSection[other]->GetBinContent(bin1)); h_DataDrivenSys_el[other]->SetBinContent(bin1, dataDrivenSyst_el); h_DataDrivenSys_mu[other]->SetBinContent(bin1, dataDrivenSyst_mu); double unf_syst_max=std::max(fabs(h_crossSection[other]->GetBinContent(bin1)-h_kterm_up->GetBinContent(bin1)), fabs(h_crossSection[other]->GetBinContent(bin1)-h_kterm_down->GetBinContent(bin1))); std::cout<<h_kterm_up->GetBinContent(bin1)<<" , "<<h_kterm_down->GetBinContent(bin1)<<std::endl; double unf_syst=unf_syst_max/(h_crossSection[other]->GetBinContent(bin1)); h_unf_syst[other]->SetBinContent(bin1, unf_syst); } } fout->cd(); h_crossSection[0]->Write(); h_crossSection[1]->Write(); h_crossSection[2]->Write(); h_crossSection[3]->Write(); h_crossSection_inclusive[0]->Write(); h_crossSection_inclusive[1]->Write(); h_crossSection_inclusive[2]->Write(); h_crossSection_inclusive[3]->Write(); for (int ich=0; ich<nChannels; ich++) { std::ostringstream matrixName; matrixName << "unfolding_covariance_" << variable << "_ch" << ich; covariance_unfolding[ich]->Write(matrixName.str().c_str()); // covariance_unfolding[0]->Write("covariance_unfolding_0"); // covariance_unfolding[1]->Write("covariance_unfolding_1"); // covariance_unfolding[2]->Write("covariance_unfolding_2"); // covariance_unfolding[3]->Write("covariance_unfolding_3"); } h_unfoldStatSys_all->Write(); for (int i=0; i<nChannels; i++) unfStatHistos[i]->Write(); fout->Write(); fout->Close(); }
//================================================ void subtraction(const Int_t save = 1) { Double_t pt1_cut = 1.0, pt2_cut = 1.0; //Double_t pt1_cut = 2.0, pt2_cut = 1.2; TFile *fdata = TFile::Open(Form("~/Work/STAR/analysis/output/jpsi.AuAu200.Run14.%s.root",run_config),"read"); const char *hName[3] = {"hJpsiInfo","hBkgLSPos","hBkgLSNeg"}; THnSparseF *hnInvMass[3]; TH1F *hInvMass[3]; for(Int_t j=0; j<3; j++) { hnInvMass[j] = (THnSparseF*)fdata->Get(Form("%s_%s",hName[j],trigName[kTrigType])); hnInvMass[j]->GetAxis(4)->SetRangeUser(pt1_cut+0.01,100); hnInvMass[j]->GetAxis(5)->SetRangeUser(pt2_cut+0.01,100); hInvMass[j] = (TH1F*)hnInvMass[j]->Projection(0); hInvMass[j]->SetName(Form("%s_%s_InvMass_WithCut",hName[j],trigName[kTrigType])); hInvMass[j]->Sumw2(); hnInvMass[j]->GetAxis(4)->SetRange(0,-1); hnInvMass[j]->GetAxis(5)->SetRange(0,-1); } hInvMass[1]->Add(hInvMass[2]); hInvMass[0]->SetMarkerStyle(20); hInvMass[0]->SetMarkerColor(2); hInvMass[0]->SetLineColor(2); hInvMass[0]->SetYTitle("Counts"); TH1F *hMixUS = (TH1F*)f->Get(Form("US_InvMass_pt1_%1.1f_pt2_%1.1f_%s",pt1_cut,pt2_cut,trigName[kTrigType])); TH1F *hMixLS = (TH1F*)f->Get(Form("LS_InvMass_pt1_%1.1f_pt2_%1.1f_%s",pt1_cut,pt2_cut,trigName[kTrigType])); Double_t scale = hInvMass[1]->Integral()/hMixLS->Integral(); hMixLS->Scale(scale); TList *list = new TList; TString legName[2] = {"Data: like sign","Mixed event: like sign"}; list->Add(hInvMass[1]); list->Add(hMixLS); c = sysCompare(list,Form("EventMixing_pt1_%1.1f_pt2_%1.1f",pt1_cut,pt2_cut),Form("Au+Au %s: invariant mass of dimuon pairs",trigName[kTrigType]),"(Mixed event)/Data",kFALSE,0,15,kFALSE,0.1,10,kTRUE,0,2,kTRUE,kTRUE,legName,kTRUE,"",0.5,0.7,0.7,0.85,kFALSE); if(save) c->SaveAs(Form("~/Work/STAR/analysis/Plots/ana_EventMixing/%s.Compare_LS_pt1_%1.1f_pt2_%1.1f.png",run_config,pt1_cut,pt2_cut)); c = draw1D(hInvMass[0],Form("Au+Au %s: invariant mass of di-muon pairs;M_{#mu#mu} (GeV/c^{2})",trigName[kTrigType]),kTRUE); hInvMass[1]->Draw("HIST sames"); hMixUS->SetLineColor(4); hMixUS->SetLineWidth(2); hMixUS->Scale(scale); hMixUS->Draw("sames HIST"); leg = new TLegend(0.45,0.65,0.55,0.88); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.04); leg->SetHeader(Form("p_{T,1} > %1.1f, p_{T,2} > %1.1f GeV/c",pt1_cut,pt2_cut)); leg->AddEntry(hInvMass[0],"Data: Unlike sign","PLE"); leg->AddEntry(hInvMass[1],"Data: Like sign (++)+(--)","L"); leg->AddEntry(hMixUS,"Mixed event: Like sign (++)+(--)","L"); leg->Draw(); if(save) c->SaveAs(Form("~/Work/STAR/analysis/Plots/ana_EventMixing/%s.Compare_US_pt1_%1.1f_pt2_%1.1f.png",run_config,pt1_cut,pt2_cut)); hInvMass[0]->GetXaxis()->SetRangeUser(2.5,3.5); hInvMass[0]->SetName(Form("%s_zoom",hInvMass[0]->GetName())); c = draw1D(hInvMass[0],Form("Au+Au %s: invariant mass of di-muon pairs;M_{#mu#mu} (GeV/c^{2})",trigName[kTrigType]),kFALSE); hInvMass[1]->Draw("HIST sames"); hMixUS->Draw("sames HIST"); leg = new TLegend(0.15,0.65,0.3,0.88); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.04); leg->SetHeader(Form("p_{T,1} > %1.1f, p_{T,2} > %1.1f GeV/c",pt1_cut,pt2_cut)); leg->AddEntry(hInvMass[0],"Data: Unlike sign","PLE"); leg->AddEntry(hInvMass[1],"Data: Like sign (++)+(--)","L"); leg->AddEntry(hMixUS,"Mixed event: Like sign (++)+(--)","L"); leg->Draw(); if(save) c->SaveAs(Form("~/Work/STAR/analysis/Plots/ana_EventMixing/%s.Compare_US_jpsi_pt1_%1.1f_pt2_%1.1f.png",run_config,pt1_cut,pt2_cut)); Double_t low_mass = 3.0, high_mass = 3.2; Int_t low_bin = hInvMass[0]->GetXaxis()->FindFixBin(low_mass); Int_t high_bin = hInvMass[0]->GetXaxis()->FindFixBin(high_mass); Double_t nBackground = hMixUS->Integral(low_bin,high_bin); Double_t nSignal = hInvMass[0]->Integral(low_bin,high_bin) - nBackground; TPaveText *signif = GetPaveText(0.15,0.45,0.12,0.25); signif->AddText(Form("[%1.1f,%1.1f] GeV/c^{2}",low_mass,high_mass)); signif->AddText(Form("S/B = %1.0f/%1.0f = %1.2e:1",nSignal,nBackground,nSignal/nBackground)); TH1F *hdiff_jpsi = (TH1F*)hInvMass[0]->Clone(Form("US-LS_jpsi")); hdiff_jpsi->Add(hMixUS,-1); hdiff_jpsi->GetXaxis()->SetRangeUser(3.05,3.15); c = draw1D(hdiff_jpsi,Form("Au+Au %s: invariant mass of di-muon pairs;M_{#mu#mu} (GeV/c^{2});US_{Data}-US_{mixing}",trigName[kTrigType]),kFALSE); gPad->SetGridy(); TPaveText *t1 = GetPaveText(0.2,0.4,0.8,0.85,0.04); t1->AddText(Form("p_{T,1} > %1.1f, p_{T,2} > %1.1f GeV/c",pt1_cut,pt2_cut)); t1->Draw(); if(save) c->SaveAs(Form("~/Work/STAR/analysis/Plots/ana_EventMixing/%s.Data-EventMixing_jpsi_pt1_%1.1f_pt2_%1.1f.png",run_config,pt1_cut,pt2_cut)); hdiff_jpsi->SetName(Form("%s_rebin4",hdiff_jpsi->GetName())); hdiff_jpsi->Rebin(4); hdiff_jpsi->GetXaxis()->SetRangeUser(2.5,3.5); c = draw1D(hdiff_jpsi,Form("Au+Au %s: invariant mass of di-muon pairs;M_{#mu#mu} (GeV/c^{2});US_{Data}-US_{mixing}",trigName[kTrigType]),kFALSE); gPad->SetGridy(); t1->Draw(); signif->Draw(); if(save) c->SaveAs(Form("~/Work/STAR/analysis/Plots/ana_EventMixing/%s.Data-EventMixing_jpsi_pt1_%1.1f_pt2_%1.1f_rebin4.png",run_config,pt1_cut,pt2_cut)); }