void ProcEvent(Int_t event, Int_t px, Int_t py, TObject *sel) { // print event type and current cursor position TCanvas *c = (TCanvas *) gTQSender; TPad *pad = (TPad *) c->GetSelectedPad(); if(!pad) return; gROOT->SetEditHistograms(kFALSE); //printf("event=%d, px=%d, py=%d\n", event, px, py); //Float_t x = pad->AbsPixeltoX(px); //Float_t y = pad->AbsPixeltoY(py); //x = pad->PadtoX(x); //y = pad->PadtoY(y); //printf("x=%.3g, y=%.3g\n",x,y); if(event==kButton1Double){ pad->Pop(); //printf("%s %d\n",pad->GetName(),pad->GetNumber()); pad->cd(); TCanvas *c_blow; TIter next(pad->GetListOfPrimitives()); if((TCanvas*)gROOT->GetListOfCanvases()->FindObject("c_blow")){ c_blow=(TCanvas*)gROOT->GetListOfCanvases()->FindObject("c_blow"); c_blow->Clear(); //printf("show %d\n",c_blow->GetUniqueID()); //c_blow->GetCanvasImp()->Show(); //c_blow->RaiseWindow(); //c_blow->GetCanvasImp()->RaiseWindow(); //c_blow->Flush(); //gVirtualX->RaiseWindow(c_blow->GetUniqueID()); //c_blow->Show(); } else{ // c_blow = new TCanvas("c_blow","blowup",750,0,743,525); c_blow = new TCanvas("c_blow","blowup",100,50,600,600); c_blow->SetFillColor(10); //white //c_blow->ToggleEventStatus(); //c_blow->SetCrosshair(); c_blow->Draw(); } c_blow->cd(); gROOT->SetSelectedPad((TPad*)c_blow); TPad *clone =(TPad*)pad->Clone(); clone->SetPad(0,0,1,1); clone->Draw(); clone->Modified(); clone->Update(); c_blow->Show(); } }
// draws the decay vertices of the Lambda_s void genDisplay(std::string fullPath, int iGen, int iReco = -1, bool savePdf = false) { const int fVerbose(0); setTDRStyle(); //gStyle->SetOptStat(112211); gStyle->SetOptStat(0); gStyle->SetPalette(1); // Canvases crz = new TCanvas("crz","crz",1000,600); TPad* padrz = (TPad*)crz->cd(1); setPadMargins(padrz, 0.02, 0.05, 0.02, 0.05); crphi = new TCanvas("crphi","crphi",600,600); TPad* padrphi = (TPad*)crphi->cd(1); setPadMargins(padrphi, 0.02, 0.05, 0.02, 0.05); // Open file TFile *f = TFile::Open(fullPath.c_str()); if (f==0) { cout << "File " << fullPath << " not found -- exiting" << endl; return; } if(fVerbose>0) cout << "Succesfully opened file " << fullPath << endl; // Get TTree with GenEvents TTree* tgen = (TTree*) f->Get("genevents"); if(fVerbose>0) cout << "Got TTree with " << tgen->GetEntries() << " entries" << endl; // Do a cut, if needed tgen->Draw(">>lst","ptmu1>3&&ptmu2>3&&TMath::Abs(etamu1)<2.5&&TMath::Abs(etamu2)<2.5"); TEventList *lst; lst = (TEventList*)gDirectory->Get("lst"); tgen->SetEventList(lst); // Get TTree with iRecoEvents TTree* treco = (TTree*) f->Get("events"); if(fVerbose>0) cout << "Got TTree with " << treco->GetEntries() << " entries" << endl; // Do plots const int nbins(30); const double rangeR(30), rangeZ(100); // standard //const double rangeR(60), rangeZ(200); // zoomed out //const double rangeR(100), rangeZ(200); // zoomed in //const double rangeR(12), rangeZ(30); // zoomed further in padrz->cd(); TH2F *hrz = new TH2F("hdisp","", nbins,-rangeZ,rangeZ,nbins,-rangeR,rangeR); hrz->Draw(); padrphi->cd(); TH2F *hrphi = new TH2F("hdisp","", nbins,-rangeR,rangeR,nbins,-rangeR,rangeR); hrphi->Draw(); // add tracker padrz->Modified(); padrz->Update(); drawTrackerRZ(padrz); padrphi->Modified(); padrphi->Update(); drawTrackerRPhi(padrphi); // set branch addresses for gentree double vrl0,vxl0,vyl0,vzl0,vrlb,vxlb,vylb,vzlb; double pmu1,phimu1,etamu1,pmu2,phimu2,etamu2; double ppr,ppi,phipr,phipi,etapr,etapi; tgen->SetBranchAddress("vrl0",&vrl0); tgen->SetBranchAddress("vxl0",&vxl0); tgen->SetBranchAddress("vyl0",&vyl0); tgen->SetBranchAddress("vzl0",&vzl0); tgen->SetBranchAddress("vrlb",&vrlb); tgen->SetBranchAddress("vxlb",&vxlb); tgen->SetBranchAddress("vylb",&vylb); tgen->SetBranchAddress("vzlb",&vzlb); tgen->SetBranchAddress("pmu1",&pmu1); tgen->SetBranchAddress("etamu1",&etamu1); tgen->SetBranchAddress("phimu1",&phimu1); tgen->SetBranchAddress("pmu2",&pmu2); tgen->SetBranchAddress("etamu2",&etamu2); tgen->SetBranchAddress("phimu2",&phimu2); tgen->SetBranchAddress("ppr",&ppr); tgen->SetBranchAddress("etapr",&etapr); tgen->SetBranchAddress("phipr",&phipr); tgen->SetBranchAddress("ppi",&ppi); tgen->SetBranchAddress("etapi",&etapi); tgen->SetBranchAddress("phipi",&phipi); int genrun, genls, genevt; tgen->SetBranchAddress("run",&genrun); tgen->SetBranchAddress("LS",&genls); tgen->SetBranchAddress("event",&genevt); // set branch addresses for recotree double rvrl0,rvxl0,rvyl0,rvzl0,rvrlb,rvxlb,rvylb,rvzlb; double rpmu1,retamu1,rphimu1,rpmu2,retamu2,rphimu2; double rppr,rppi,retapr,retapi,rphipr,rphipi; treco->SetBranchAddress("vrl0",&rvrl0); treco->SetBranchAddress("vxl0",&rvxl0); treco->SetBranchAddress("vyl0",&rvyl0); treco->SetBranchAddress("vzl0",&rvzl0); treco->SetBranchAddress("vrlb",&rvrlb); treco->SetBranchAddress("vxlb",&rvxlb); treco->SetBranchAddress("vylb",&rvylb); treco->SetBranchAddress("vzlb",&rvzlb); treco->SetBranchAddress("rpt1m",&rpmu1); treco->SetBranchAddress("reta1m",&retamu1); treco->SetBranchAddress("rphi1m",&rphimu1); treco->SetBranchAddress("rpt2m",&rpmu2); treco->SetBranchAddress("reta2m",&retamu2); treco->SetBranchAddress("rphi2m",&rphimu2); treco->SetBranchAddress("rptpr",&rppr); treco->SetBranchAddress("retapr",&retapr); treco->SetBranchAddress("rphipr",&rphipr); treco->SetBranchAddress("rptpi",&rppi); treco->SetBranchAddress("retapi",&retapi); treco->SetBranchAddress("rphipi",&rphipi); drawArrowLegend(padrz); drawArrowLegend(padrphi,.8); // write the event indices writeLatex(padrz,.1,.9,("iGen: " + toString(iGen)).c_str()); writeLatex(padrphi,.1,.9,("iGen: " + toString(iGen)).c_str()); if (iReco >= 0) { writeLatex(padrz,.1,.85,("iReco: " + toString(iReco)).c_str()); writeLatex(padrphi,.1,.85,("iReco: " + toString(iReco)).c_str()); } if (iGen<0) return; if (iGen>tgen->GetEntries()) return; if (iReco>treco->GetEntries()) return; tgen->GetEntry(iGen); cout << "iGen: " << iGen << " - " << genrun << " " << genls << " " << genevt << endl; padrz->cd(); drawEventZR(vrlb, vzlb, vrl0, vzl0, pmu1, etamu1, pmu2, etamu2, ppr, etapr, ppi, etapi, 0); padrphi->cd(); drawEventRPhi(vxlb, vylb, vxl0, vyl0, pmu1, phimu1, pmu2, phimu2, ppr, phipr, ppi, phipi, 0); if(iReco>=0) { treco->GetEntry(iReco); cout << "iReco: " << iReco << endl; padrz->cd(); drawEventZR(rvrlb, rvzlb, rvrl0, rvzl0, rpmu1, retamu1, rpmu2, retamu2, rppr, retapr, rppi, retapi, 1); padrphi->cd(); drawEventRPhi(rvxlb, rvylb, rvxl0, rvyl0, rpmu1, rphimu1, rpmu2, rphimu2, rppr, rphipr, rppi, rphipi, 1); cout << phimu1 << " " << rphimu1 << endl; } if(savePdf) { padrz->Update(); padrphi->Update(); std::string filename = "genDisplay_" + toString(iGen); if(iReco >= 0) filename += "_" + toString(iReco); crz->SaveAs((filename+"_rz.pdf").c_str()); crphi->SaveAs((filename+"_rphi.png").c_str()); // weiss der Geier warum auf PDF die Kreise und die Skala fehlen... } return; }
int makeInvMassHistosNoBGKK(){ //Set global style stuff gROOT->Reset(); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetCanvasColor(kWhite); gStyle->SetCanvasBorderMode(0); gStyle->SetPadBorderMode(0); gStyle->SetTitleBorderSize(0); gStyle->SetOptStat(0); gStyle->SetOptFit(1); gStyle->SetErrorX(0); gStyle->SetTitleW(0.9); gStyle->SetTitleSize(0.05, "xyz"); gStyle->SetTitleSize(0.06, "h"); int NUM_PT_BINS = 20; int NUM_MASS_BINS = 1000; double MASS_LOW = 0.0; double MASS_HIGH = 2.0; string particles [8]; particles[0] = "K*^{+} + K*^{0}"; particles[1] = "K*^{-} + #bar{K}*^{0}"; particles[2] = "K*^{+}"; particles[3] = "K*^{-}"; particles[4] = "K*^{0}"; particles[5] = "#bar{K}*^{0}"; particles[6] = "K*^{0} + #bar{K}*^{0}"; particles[7] = "K*^{+} + K*^{-}"; //at decay point // string folder = "/Users/jtblair/Downloads/kstar_data/decayed/pt02/"; //reconstructed string folder = "/Users/jtblair/Downloads/kstar_data/reconstructed/pt02/"; string files[20]; files[0] = "invm_[0.0,0.2].dat"; files[1] = "invm_[0.2,0.4].dat"; files[2] = "invm_[0.4,0.6].dat"; files[3] = "invm_[0.6,0.8].dat"; files[4] = "invm_[0.8,1.0].dat"; files[5] = "invm_[1.0,1.2].dat"; files[6] = "invm_[1.2,1.4].dat"; files[7] = "invm_[1.4,1.6].dat"; files[8] = "invm_[1.6,1.8].dat"; files[9] = "invm_[1.8,2.0].dat"; files[10] = "invm_[2.0,2.2].dat"; files[11] = "invm_[2.2,2.4].dat"; files[12] = "invm_[2.4,2.6].dat"; files[13] = "invm_[2.6,2.8].dat"; files[14] = "invm_[2.8,3.0].dat"; files[15] = "invm_[3.0,3.2].dat"; files[16] = "invm_[3.2,3.4].dat"; files[17] = "invm_[3.4,3.6].dat"; files[18] = "invm_[3.6,3.8].dat"; files[19] = "invm_[3.8,4.0].dat"; /* string files[8]; files[0] = "invm_[0.0,0.5].dat"; files[1] = "invm_[0.5,1.0].dat"; files[2] = "invm_[1.0,1.5].dat"; files[3] = "invm_[1.5,2.0].dat"; files[4] = "invm_[2.0,2.5].dat"; files[5] = "invm_[2.5,3.0].dat"; files[6] = "invm_[3.0,3.5].dat"; files[7] = "invm_[3.5,4.0].dat"; */ Int_t PARTICLE_NUM = 5; TFile *output = new TFile("20170721_KKbarAdded2_fixedwidth42_recon_pf100_scaled_error05.root", "RECREATE"); TH1D *kstar0mass = new TH1D("kstar0mass", Form("Fit value of M*_{0} vs. p_{T} for %s", particles[PARTICLE_NUM].c_str()), NUM_PT_BINS, 0.0, 4.0); TH1D *kstar0width = new TH1D("kstar0width", Form("#Gamma_{tot}(M=M*_{0}) vs p_{T} for %s", particles[PARTICLE_NUM].c_str()), NUM_PT_BINS, 0.0, 4.0); TH1D *kstar0collWidth = new TH1D("kstar0collWidth", Form("Fit value of #Gamma_{coll} component vs. p_{T} for %s", particles[PARTICLE_NUM].c_str()), NUM_PT_BINS,0.0, 4.0); TH1D *kstar0decWidth = new TH1D("kstar0decWidth", Form("#Gamma_{dec}(M=M*_{0}) component vs. p_{T} for %s;p_{T} (GeV/c);Width (GeV/c^2)", particles[PARTICLE_NUM].c_str()), NUM_PT_BINS,0.0, 4.0); kstar0mass->GetXaxis()->SetTitle("p_{T} (GeV/c)"); kstar0mass->GetYaxis()->SetTitle("Mass (GeV/c^{2})"); kstar0width->GetXaxis()->SetTitle("p_{T} (GeV/c)"); kstar0width->GetYaxis()->SetTitle("Width (GeV/c^2)"); kstar0collWidth->GetXaxis()->SetTitle("p_{T} (GeV/c)"); kstar0collWidth->GetYaxis()->SetTitle("Width (GeV/c^2)"); kstar0mass->SetStats(kFALSE); kstar0width->SetStats(kFALSE); kstar0collWidth->SetStats(kFALSE); kstar0decWidth->SetStats(kFALSE); TF1 *massline = new TF1("massline", "[0]", 0.0, 4.0); massline->SetParameter(0, 0.892); massline->SetLineColor(2); massline->SetLineStyle(7); TF1 *widthline = new TF1("widthline", "[0]", 0.0, 4.0); widthline->SetParameter(0, 0.042); double mass = 0.0, width = 0.0, collWidth = 0.0, massBG=0.0; double massError = 0.0, widthError= 0.0, collWidthError = 0.0, massBGError=0.0; TCanvas *canvas[9]; TCanvas *diffCanvas[9]; TPaveStats *st; TPad *pad; //ofstream integrals; //integrals.open("kstarbar_integrals.txt"); for(int nfile = 0; nfile < NUM_PT_BINS; nfile++){ double meanPT = (double)(nfile*2+1)/10.0; string filename = folder+files[nfile]; string ptLower = filename.substr(filename.find("[")+1, 3); string ptHigher = filename.substr(filename.find(",")+1, 3); TH1D* histos[8]; TH1D* newHistos[8]; TH1D* diffHistos[8]; TH1D* bg[8]; for(int i=0; i<8; i++){ if(nfile<5){ histos[i] = new TH1D(Form("ptbin0%dparticle%d",nfile*2+1, i), Form("Invariant Mass for (%s), %s < p_{T} < %s",particles[i].c_str(), ptLower.c_str(), ptHigher.c_str()), NUM_MASS_BINS, MASS_LOW, MASS_HIGH); newHistos[i] = new TH1D(Form("newptbin0%dparticle%d",nfile*2+1, i), Form("Invariant Mass for (%s), %s < p_{T} < %s",particles[i].c_str(), ptLower.c_str(), ptHigher.c_str()), 250, MASS_LOW, MASS_HIGH); }else{ histos[i] = new TH1D(Form("ptbin%dparticle%d",nfile*2+1, i), Form("Invariant Mass for (%s), %s < p_{T} < %s",particles[i].c_str(), ptLower.c_str(), ptHigher.c_str()), NUM_MASS_BINS, MASS_LOW, MASS_HIGH); newHistos[i] = new TH1D(Form("newptbin%dparticle%d",nfile*2+1, i), Form("Invariant Mass for (%s), %s < p_{T} < %s",particles[i].c_str(), ptLower.c_str(), ptHigher.c_str()), 250, MASS_LOW, MASS_HIGH); } histos[i]->GetXaxis()->SetTitle("Invariant Mass (GeV/c^{2})"); histos[i]->GetYaxis()->SetTitle("Counts"); } ifstream input; input.open(filename.c_str()); string line = ""; if(input.good()){ getline(input, line); } double massBin=0.0; double invMass[8]; for(int i=0; i<8; i++){ invMass[i] = 0.0; } int lineNumber = 1; while(1){ input >> massBin >> invMass[0] >> invMass[1] >> invMass[2] >> invMass[3] >> invMass[4] >> invMass[5] >> invMass[6] >> invMass[7]; if(!input.good())break; for(int i =0; i<8; i++){ histos[i]->SetBinContent(lineNumber, invMass[i]/500.0); } if(lineNumber > 440 && lineNumber < 460 && nfile==6){ // printf("mass: %.12f invMass[6]: %.12f\n", massBin, invMass[6]); } lineNumber++; } printf("****** Fits for file: %s ******\n", filename.c_str()); for(int i=PARTICLE_NUM; i<PARTICLE_NUM+1; i++){ //add the K*0 distribution to the K*0bar (K*0 = 4 for decay, K*0 = 3 for reconstructed) histos[i]->Add(histos[3]); if(nfile==0){ canvas[i] = new TCanvas(Form("c%i", i),Form("c%i", i), 0,0,900,900); canvas[i]->Divide(5,4); diffCanvas[i] = new TCanvas(Form("diffC%i", i),Form("diffC%i", i), 0,0,900,900); diffCanvas[i]->Divide(5,4); } //rebin //histos[i]->Sumw2(); histos[i]->Rebin(4); //Fixing the errors to a percentage of the signal region: for(int ibin=1; ibin < histos[i]->GetNbinsX(); ibin++){ histos[i]->SetBinError(ibin, histos[i]->GetBinContent((int)(0.892*(250.0/2.0)))*0.05); newHistos[i]->SetBinContent(ibin, histos[i]->GetBinContent(ibin)); newHistos[i]->SetBinError(ibin, histos[i]->GetBinError(ibin)); } pad = (TPad*)canvas[i]->cd(nfile+1); histos[i]->SetLineColor(1); histos[i]->SetLineWidth(1); histos[i]->GetXaxis()->SetRangeUser(0.7, 1.2); histos[i]->GetYaxis()->SetRangeUser(0, 1.5*histos[i]->GetBinContent(histos[i]->GetMaximumBin())); //histos[i]->SetStats(kFALSE); //histos[i]->Draw("HIST"); printf("mean PT: %f\n", meanPT); TF1 *fit = new TF1(Form("fitPTbin%d00particle%d", nfile*2+1, i), FitFunRelBW, 0.68, 1.05, 5); //TF1 *fit = new TF1(Form("fitPTbin%d00particle%d", nfile*2+1, i), "gaus(0)", 0.86, 0.92); fit->SetParNames("BW Area", "Mass", "Width", "PT", "Temp"); fit->SetParameters(TMath::Power(10.0, (float)(nfile)/1.7), 0.89, 0.1, 0.5, 0.130); //fit->SetParNames("BW Area", "Mass", "Width"); //fit->SetParameters(100, 0.89, 0.0474); //fit->SetParLimits(0, -10, 1.5e9); Float_t max = histos[i]->GetXaxis()->GetBinCenter(histos[i]->GetMaximumBin()); //if(max < 0.91 && max > 0.892){ // fit->SetParLimits(1, max-0.001, max+0.001); //}else{ fit->SetParLimits(1, 0.82, 0.98); //} //fit->SetParLimits(2, 0.005, 0.15); fit->FixParameter(2, 0.042); fit->FixParameter(3, meanPT); //fit->SetParLimits(4, 0.05, 0.2); fit->FixParameter(4, 0.100001); fit->SetLineColor(2); printf("%s\n", fit->GetName()); histos[i]->Fit(Form("fitPTbin%d00particle%d", nfile*2+1, i), "BRIM", "SAME"); TVirtualFitter *fitter = TVirtualFitter::GetFitter(); histos[i]->SetStats(1); histos[i]->Draw(); gPad->Update(); pad->Update(); st = (TPaveStats*)histos[i]->FindObject("stats"); st->SetX1NDC(0.524); st->SetY1NDC(0.680); st->SetX2NDC(0.884); st->SetY2NDC(0.876); //fit->Draw("SAME"); //histos[i]->Draw(); gPad->Update(); pad->Update(); printf("\n"); diffHistos[i] = (TH1D*)histos[i]->Clone(Form("diffPTbin%d00particl%d", nfile*2+1, i)); diffHistos[i]->Add(fit, -1); diffCanvas[i]->cd(nfile+1); diffHistos[i]->Draw("HIST E"); diffHistos[i]->Write(); //counting bins Float_t integral = histos[i]->Integral(1, 500)*500.0; //integrals << integral <<" \n"; histos[i]->Write(); fit->Write(); //Do mass and width vs. pT plots just for K*0 if(i==PARTICLE_NUM){ mass = fit->GetParameter(1); massError = fit->GetParError(1); collWidth = fit->GetParameter(2); collWidthError = fit->GetParError(2); width = Gamma(mass, collWidth); kstar0mass->SetBinContent(nfile+1, mass); kstar0mass->SetBinError(nfile+1, massError); kstar0width->SetBinContent(nfile+1, width); Double_t widthError = TMath::Sqrt((GammaDerivative(mass)**2)*fitter->GetCovarianceMatrixElement(1,1) + fitter->GetCovarianceMatrixElement(2,2) + 2.0*GammaDerivative(mass)*fitter->GetCovarianceMatrixElement(1,2)); kstar0width->SetBinError(nfile+1, widthError); kstar0collWidth->SetBinContent(nfile+1, collWidth); kstar0collWidth->SetBinError(nfile+1, collWidthError); kstar0decWidth->SetBinContent(nfile+1, width - collWidth); Double_t decWidthError = TMath::Sqrt((GammaDerivative(mass)**2)*fitter->GetCovarianceMatrixElement(1,1)); kstar0decWidth->SetBinError(nfile+1, decWidthError); if(nfile==4){ TCanvas *singlecanvas = new TCanvas("singlecanvas", "singlecanvas", 0,0,600,600); singlecanvas->cd(); printf("Got here! \n"); histos[i]->Draw("HIST E SAME"); fit->SetLineColor(8); fit->SetLineStyle(1); fit->Draw("SAME"); if(fitter){ printf("sig11: %f, sig12: %f, sig21: %f, sig22: %f GammaDer(0.8): %f GammaDer(0.85): %f GammaDer(0.9): %f\n", TMath::Sqrt(fitter->GetCovarianceMatrixElement(1,1)), fitter->GetCovarianceMatrixElement(2,1), fitter->GetCovarianceMatrixElement(1,2), TMath::Sqrt(fitter->GetCovarianceMatrixElement(2,2)), GammaDerivative(0.8), GammaDerivative(0.85), GammaDerivative(0.9)); } } } } printf("************************************************************\n"); } //integrals.close(); /* TH2D *gammaPlot = new TH2D("gammaPlot", "#Gamma_{tot}(M_{0}*);M_{0}*;#Gamma_{coll};#Gamma_{tot}", 100, 0.82, 0.9, 100, 0.0, 0.08); for(int im = 0; im<100; im++){ for(int ig = 0; ig < 100; ig++){ gammaPlot->SetBinContent(im+1, ig+1, Gamma(((0.9-0.82)/(100.0))*((double)(im)) + 0.82, ((0.08)/100.0)*((double)(ig)))); } } TH1D *gammaMassDpnd = gammaPlot->ProjectionX("gammaMassDpnd"); */ TCanvas *masscanvas = new TCanvas("masscanvas", "masscanvas", 50,50, 600, 600); masscanvas->cd(); kstar0mass->Draw(); massline->Draw("SAME"); masscanvas->Write(); for(int i=PARTICLE_NUM; i<PARTICLE_NUM+1; i++){ canvas[i]->Write(); } kstar0mass->Write(); kstar0collWidth->Write(); kstar0decWidth->Write(); kstar0width->Write(); // gammaPlot->Write(); // gammaMassDpnd->Write(); }
void composeTrackAnalysisbyAssociator(string FileListName, int FileNumber) { if(debug) cout << FileListName << endl; string theFileName; ifstream composeFileList; composeFileList.open(FileListName.c_str()); string OutputPlotNamepreFix = FileListName + "_"; string OutputPlotNameFix = ".png"; unsigned int EventNumber; unsigned int trackingParticleMatch; double recTrackPurity; double recTrackrefMomentum; double recTrackrefPhi; double recTrackrefEta; double recTrackinnerMomentum; double recTrackinnerPhi; double recTrackinnerEta; unsigned int recTrackinnerValid; double recTrackouterMomentum; double recTrackouterPhi; double recTrackouterEta; unsigned int recTrackouterValid; double simTrackinnerMomentum; double simTrackinnerPhi; double simTrackinnerEta; unsigned int simTrackinnerMatch; double simTrackouterMomentum; double simTrackouterPhi; double simTrackouterEta; unsigned int simTrackouterMatch; double recTrackinnerMomentumofTSOS; double recTrackinnerPhiofTSOS; double recTrackinnerEtaofTSOS; unsigned int recTrackinnerValidofTSOS; double recTrackouterMomentumofTSOS; double recTrackouterPhiofTSOS; double recTrackouterEtaofTSOS; unsigned int recTrackouterValidofTSOS; double recTrackimpactMomentumofTSOS; double recTrackimpactPhiofTSOS; double recTrackimpactEtaofTSOS; unsigned int recTrackimpactValidofTSOS; int recTrackCharge; double simTrackMomentumPt; double simTrackPhi; double simTrackEta; int simTrackCharge; TObjArray* myEfficiencyHist = new TObjArray(); TObjArray* myParticleHist = new TObjArray(); TObjArray* mySTAHist = new TObjArray(); TObjArray* myChargeCheckHist = new TObjArray(); TObjArray* myDeltaPtHist = new TObjArray(); TObjArray* myDeltaPhiHist = new TObjArray(); TObjArray* myDeltaEtaHist = new TObjArray(); vector<string> TypeName; TypeName.clear(); for(int Index = 0; Index < FileNumber; Index++) { getline(composeFileList, theFileName); TypeName.push_back(theFileName); string fullFileName = "data/"+ theFileName + ".root"; if(debug) cout << theFileName << endl; TFile* RootFile = TFile::Open(fullFileName.c_str()); TTree* T1 = (TTree*)RootFile->Get("ExTree"); T1->SetBranchAddress("EventNumber", &EventNumber); T1->SetBranchAddress("trackingParticleMatch", &trackingParticleMatch); T1->SetBranchAddress("recTrackPurity", &recTrackPurity); T1->SetBranchAddress("recTrackrefMomentum", &recTrackrefMomentum); T1->SetBranchAddress("recTrackrefPhi", &recTrackrefPhi); T1->SetBranchAddress("recTrackrefEta", &recTrackrefEta); T1->SetBranchAddress("recTrackinnerMomentum", &recTrackinnerMomentum); T1->SetBranchAddress("recTrackinnerPhi", &recTrackinnerPhi); T1->SetBranchAddress("recTrackinnerEta", &recTrackinnerEta); T1->SetBranchAddress("recTrackinnerValid", &recTrackinnerValid); T1->SetBranchAddress("recTrackouterMomentum", &recTrackouterMomentum); T1->SetBranchAddress("recTrackouterPhi", &recTrackouterPhi); T1->SetBranchAddress("recTrackouterEta", &recTrackouterEta); T1->SetBranchAddress("recTrackouterValid", &recTrackouterValid); T1->SetBranchAddress("simTrackinnerMomentum", &simTrackinnerMomentum); T1->SetBranchAddress("simTrackinnerPhi", &simTrackinnerPhi); T1->SetBranchAddress("simTrackinnerEta", &simTrackinnerEta); T1->SetBranchAddress("simTrackinnerMatch", &simTrackinnerMatch); T1->SetBranchAddress("simTrackouterMomentum", &simTrackouterMomentum); T1->SetBranchAddress("simTrackouterPhi", &simTrackouterPhi); T1->SetBranchAddress("simTrackouterEta", &simTrackouterEta); T1->SetBranchAddress("simTrackouterMatch", &simTrackouterMatch); T1->SetBranchAddress("recTrackinnerMomentumofTSOS", &recTrackinnerMomentumofTSOS); T1->SetBranchAddress("recTrackinnerPhiofTSOS", &recTrackinnerPhiofTSOS); T1->SetBranchAddress("recTrackinnerEtaofTSOS", &recTrackinnerEtaofTSOS); T1->SetBranchAddress("recTrackinnerValidofTSOS", &recTrackinnerValidofTSOS); T1->SetBranchAddress("recTrackouterMomentumofTSOS", &recTrackouterMomentumofTSOS); T1->SetBranchAddress("recTrackouterPhiofTSOS", &recTrackouterPhiofTSOS); T1->SetBranchAddress("recTrackouterEtaofTSOS", &recTrackouterEtaofTSOS); T1->SetBranchAddress("recTrackouterValidofTSOS", &recTrackouterValidofTSOS); T1->SetBranchAddress("recTrackimpactMomentumofTSOS", &recTrackimpactMomentumofTSOS); T1->SetBranchAddress("recTrackimpactPhiofTSOS", &recTrackimpactPhiofTSOS); T1->SetBranchAddress("recTrackimpactEtaofTSOS", &recTrackimpactEtaofTSOS); T1->SetBranchAddress("recTrackimpactValidofTSOS", &recTrackimpactValidofTSOS); T1->SetBranchAddress("recTrackCharge", &recTrackCharge); T1->SetBranchAddress("simTrackMomentumPt", &simTrackMomentumPt); T1->SetBranchAddress("simTrackPhi", &simTrackPhi); T1->SetBranchAddress("simTrackEta", &simTrackEta); T1->SetBranchAddress("simTrackCharge", &simTrackCharge); string TempHistName; TempHistName = theFileName + "_Efficiency2simPt"; TH1D* Efficiency2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_Particle2simPt"; TH1D* Particle2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_STA2simPt"; TH1D* STA2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_InverseChargeRato2simPt"; TH1D* InverseChargeRato2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_DeltaPt2simPt"; TH1D* DeltaPt2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_DeltaPhi2simPt"; TH1D* DeltaPhi2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_DeltaEta2simPt"; TH1D* DeltaEta2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_MaxPurity2simPt"; TH2D* MaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 6, 0., 1.2); TempHistName = theFileName + "_Multiplicity2simPt"; TH2D* Multiplicity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 10, 0., 10.); TempHistName = theFileName + "_ChargeCheck2simPt"; TH2D* ChargeCheck2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 5, -2.5, 2.5); TempHistName = theFileName + "_simTrackMomentumPtmaxPurity2simPt"; TH2D* simTrackMomentumPtmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, 0, PtScale); TempHistName = theFileName + "_simTrackPhimaxPurity2simPt"; TH2D* simTrackPhimaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI); TempHistName = theFileName + "_simTrackEtamaxPurity2simPt"; TH2D* simTrackEtamaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 400, -2.0, 2.0); TempHistName = theFileName + "_recTrackimpactMomentumofTSOSmaxPurity2simPt"; TH2D* recTrackimpactMomentumofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, 0, PtScale); TempHistName = theFileName + "_recTrackimpactPhiofTSOSmaxPurity2simPt"; TH2D* recTrackimpactPhiofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI); TempHistName = theFileName + "_recTrackimpactEtaofTSOSmaxPurity2simPt"; TH2D* recTrackimpactEtaofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 600, -3.0, 3.0); TempHistName = theFileName + "_recTrackimpactValidofTSOSmaxPurity2simPt"; TH2D* recTrackimpactValidofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 2, 0., 2.); TempHistName = theFileName + "_DeltaPtmaxPurity2simPt"; TH2D* DeltaPtmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, -1.*PtScale, PtScale); TempHistName = theFileName + "_DeltaPhimaxPurity2simPt"; TH2D* DeltaPhimaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI); TempHistName = theFileName + "_DeltaEtamaxPurity2simPt"; TH2D* DeltaEtamaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 400, -2.0, 2.0); unsigned int trackingParticleMatch_temp; unsigned int efficiency_temp; double recTrackPurity_temp; double recTrackrefMomentum_temp; double recTrackrefPhi_temp; double recTrackrefEta_temp; double recTrackinnerMomentum_temp; double recTrackinnerPhi_temp; double recTrackinnerEta_temp; unsigned int recTrackinnerValid_temp; double recTrackouterMomentum_temp; double recTrackouterPhi_temp; double recTrackouterEta_temp; unsigned int recTrackouterValid_temp; double simTrackinnerMomentum_temp; double simTrackinnerPhi_temp; double simTrackinnerEta_temp; unsigned int simTrackinnerMatch_temp; double simTrackouterMomentum_temp; double simTrackouterPhi_temp; double simTrackouterEta_temp; unsigned int simTrackouterMatch_temp; double recTrackinnerMomentumofTSOS_temp; double recTrackinnerPhiofTSOS_temp; double recTrackinnerEtaofTSOS_temp; unsigned int recTrackinnerValidofTSOS_temp; double recTrackouterMomentumofTSOS_temp; double recTrackouterPhiofTSOS_temp; double recTrackouterEtaofTSOS_temp; unsigned int recTrackouterValidofTSOS_temp; double recTrackimpactMomentumofTSOS_temp; double recTrackimpactPhiofTSOS_temp; double recTrackimpactEtaofTSOS_temp; unsigned int recTrackimpactValidofTSOS_temp; int recTrackCharge_temp; double simTrackMomentumPt_temp; double simTrackPhi_temp; double simTrackEta_temp; int simTrackCharge_temp; int Nentries = T1->GetEntries(); for(int i = 0; i < Nentries; i++) { T1->GetEntry(i); if(trackingParticleMatch == 0) { MaxPurity2simPtHist->Fill(simTrackMomentumPt, 0); Multiplicity2simPtHist->Fill(simTrackMomentumPt, 0); int tempParticleBinNumber = Particle2simPtHist->FindBin(simTrackMomentumPt); double tempParticleBinValue = Particle2simPtHist->GetBinContent(tempParticleBinNumber); tempParticleBinValue += 1.; Particle2simPtHist->SetBinContent(tempParticleBinNumber, tempParticleBinValue); } else { efficiency_temp = 1; trackingParticleMatch_temp = trackingParticleMatch; recTrackPurity_temp = recTrackPurity; recTrackrefMomentum_temp = recTrackrefMomentum; recTrackrefPhi_temp = recTrackrefPhi; recTrackrefEta_temp = recTrackrefEta; recTrackinnerMomentum_temp = recTrackinnerMomentum; recTrackinnerPhi_temp = recTrackinnerPhi; recTrackinnerEta_temp = recTrackinnerEta; recTrackinnerValid_temp = recTrackinnerValid; recTrackouterMomentum_temp = recTrackouterMomentum; recTrackouterPhi_temp = recTrackouterPhi; recTrackouterEta_temp = recTrackouterEta; recTrackouterValid_temp = recTrackouterValid; simTrackinnerMomentum_temp = simTrackinnerMomentum; simTrackinnerPhi_temp = simTrackinnerPhi; simTrackinnerEta_temp = simTrackinnerEta; simTrackinnerMatch_temp = simTrackinnerMatch; simTrackouterMomentum_temp = simTrackouterMomentum; simTrackouterPhi_temp = simTrackouterPhi; simTrackouterEta_temp = simTrackouterEta; simTrackouterMatch_temp = simTrackouterMatch; recTrackinnerMomentumofTSOS_temp = recTrackinnerMomentumofTSOS; recTrackinnerPhiofTSOS_temp = recTrackinnerPhiofTSOS; recTrackinnerEtaofTSOS_temp = recTrackinnerEtaofTSOS; recTrackinnerValidofTSOS_temp = recTrackinnerValidofTSOS; recTrackouterMomentumofTSOS_temp = recTrackouterMomentumofTSOS; recTrackouterPhiofTSOS_temp = recTrackouterPhiofTSOS; recTrackouterEtaofTSOS_temp = recTrackouterEtaofTSOS; recTrackouterValidofTSOS_temp = recTrackouterValidofTSOS; recTrackimpactMomentumofTSOS_temp = recTrackimpactMomentumofTSOS; recTrackimpactPhiofTSOS_temp = recTrackimpactPhiofTSOS; recTrackimpactEtaofTSOS_temp = recTrackimpactEtaofTSOS; recTrackimpactValidofTSOS_temp = recTrackimpactValidofTSOS; recTrackCharge_temp = recTrackCharge; simTrackMomentumPt_temp = simTrackMomentumPt; simTrackPhi_temp = simTrackPhi; simTrackEta_temp = simTrackEta; simTrackCharge_temp = simTrackCharge; bool nextStep = true; while(nextStep) { i++; T1->GetEntry(i); if(trackingParticleMatch <= trackingParticleMatch_temp) nextStep = false; else trackingParticleMatch_temp = trackingParticleMatch; if(nextStep == true && recTrackPurity_temp < recTrackPurity) { if(debug) cout << "step another match, trackingParticleMatch_temp: " << trackingParticleMatch_temp << endl; //trackingParticleMatch_temp = trackingParticleMatch; recTrackPurity_temp = recTrackPurity; recTrackrefMomentum_temp = recTrackrefMomentum; recTrackrefPhi_temp = recTrackrefPhi; recTrackrefEta_temp = recTrackrefEta; recTrackinnerMomentum_temp = recTrackinnerMomentum; recTrackinnerPhi_temp = recTrackinnerPhi; recTrackinnerEta_temp = recTrackinnerEta; recTrackinnerValid_temp = recTrackinnerValid; recTrackouterMomentum_temp = recTrackouterMomentum; recTrackouterPhi_temp = recTrackouterPhi; recTrackouterEta_temp = recTrackouterEta; recTrackouterValid_temp = recTrackouterValid; simTrackinnerMomentum_temp = simTrackinnerMomentum; simTrackinnerPhi_temp = simTrackinnerPhi; simTrackinnerEta_temp = simTrackinnerEta; simTrackinnerMatch_temp = simTrackinnerMatch; simTrackouterMomentum_temp = simTrackouterMomentum; simTrackouterPhi_temp = simTrackouterPhi; simTrackouterEta_temp = simTrackouterEta; simTrackouterMatch_temp = simTrackouterMatch; recTrackinnerMomentumofTSOS_temp = recTrackinnerMomentumofTSOS; recTrackinnerPhiofTSOS_temp = recTrackinnerPhiofTSOS; recTrackinnerEtaofTSOS_temp = recTrackinnerEtaofTSOS; recTrackinnerValidofTSOS_temp = recTrackinnerValidofTSOS; recTrackouterMomentumofTSOS_temp = recTrackouterMomentumofTSOS; recTrackouterPhiofTSOS_temp = recTrackouterPhiofTSOS; recTrackouterEtaofTSOS_temp = recTrackouterEtaofTSOS; recTrackouterValidofTSOS_temp = recTrackouterValidofTSOS; recTrackimpactMomentumofTSOS_temp = recTrackimpactMomentumofTSOS; recTrackimpactPhiofTSOS_temp = recTrackimpactPhiofTSOS; recTrackimpactEtaofTSOS_temp = recTrackimpactEtaofTSOS; recTrackimpactValidofTSOS_temp = recTrackimpactValidofTSOS; recTrackCharge_temp = recTrackCharge; simTrackMomentumPt_temp = simTrackMomentumPt; simTrackPhi_temp = simTrackPhi; simTrackEta_temp = simTrackEta; simTrackCharge_temp = simTrackCharge; } } i--; //if(debug) cout << "Filling Multiplicity " << trackingParticleMatch_temp << endl; MaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackPurity_temp); Multiplicity2simPtHist->Fill(simTrackMomentumPt_temp, trackingParticleMatch_temp); ChargeCheck2simPtHist->Fill(simTrackMomentumPt_temp, simTrackCharge_temp*recTrackCharge_temp); simTrackMomentumPtmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackMomentumPt_temp); simTrackPhimaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackPhi_temp); simTrackEtamaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackEta_temp); recTrackimpactMomentumofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactMomentumofTSOS_temp); recTrackimpactPhiofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactPhiofTSOS_temp); recTrackimpactEtaofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactEtaofTSOS_temp); recTrackimpactValidofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactValidofTSOS_temp); DeltaPtmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, (recTrackimpactMomentumofTSOS_temp-simTrackMomentumPt_temp)/simTrackMomentumPt_temp); DeltaPhimaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactPhiofTSOS_temp-simTrackPhi_temp); DeltaEtamaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactEtaofTSOS_temp-simTrackEta_temp); int tempParticleBinNumber = STA2simPtHist->FindBin(simTrackMomentumPt_temp); double tempParticleBinValue = Particle2simPtHist->GetBinContent(tempParticleBinNumber); tempParticleBinValue += 1.; Particle2simPtHist->SetBinContent(tempParticleBinNumber, tempParticleBinValue); double tempSTABinValue = STA2simPtHist->GetBinContent(tempParticleBinNumber); tempSTABinValue += 1.; STA2simPtHist->SetBinContent(tempParticleBinNumber, tempSTABinValue); } } for(int PtIndex = 1; PtIndex <= (int)(PtScale/2); PtIndex++) { double ParticleBinValue = Particle2simPtHist->GetBinContent(PtIndex); double STABinValue = STA2simPtHist->GetBinContent(PtIndex); if(ParticleBinValue == 0.) ParticleBinValue += 1.; double EfficiencyBinValue = STABinValue / ParticleBinValue * 100.; double EfficiencyBinError = sqrt(EfficiencyBinValue * (100. - EfficiencyBinValue) / ParticleBinValue); cout << ParticleBinValue << ", " << STABinValue << ", " << EfficiencyBinValue << endl; Efficiency2simPtHist->SetBinContent(PtIndex, EfficiencyBinValue); Efficiency2simPtHist->SetBinError(PtIndex, EfficiencyBinError); TH1D* ChargeCheckHist = ChargeCheck2simPtHist->ProjectionY("ChargeCheck", PtIndex, PtIndex, "o"); double ReverseChargeBinValue = ChargeCheckHist->GetBinContent(2); double CoverseChargeBinValue = ChargeCheckHist->GetBinContent(4); double TotalChargeBinValue = ReverseChargeBinValue + CoverseChargeBinValue; if(TotalChargeBinValue == 0.); TotalChargeBinValue += 1.; double ReverseChargeRato = ReverseChargeBinValue / TotalChargeBinValue; InverseChargeRato2simPtHist->SetBinContent(PtIndex, ReverseChargeRato); TH1D* DeltaPtHist = DeltaPtmaxPurity2simPtHist->ProjectionY("DeltaPt", PtIndex, PtIndex, "o"); double DeltaPtMean = DeltaPtHist->GetMean(); double DeltaPtRMS = DeltaPtHist->GetRMS(); DeltaPt2simPtHist->SetBinContent(PtIndex, DeltaPtMean); DeltaPt2simPtHist->SetBinError(PtIndex, DeltaPtRMS); TH1D* DeltaPhiHist = DeltaPhimaxPurity2simPtHist->ProjectionY("DeltaPhi", PtIndex, PtIndex, "o"); double DeltaPhiMean = DeltaPhiHist->GetMean(); double DeltaPhiRMS = DeltaPhiHist->GetRMS(); DeltaPhi2simPtHist->SetBinContent(PtIndex, DeltaPhiMean); DeltaPhi2simPtHist->SetBinError(PtIndex, DeltaPhiRMS); TH1D* DeltaEtaHist = DeltaEtamaxPurity2simPtHist->ProjectionY("DeltaEta", PtIndex, PtIndex, "o"); double DeltaEtaMean = DeltaEtaHist->GetMean(); double DeltaEtaRMS = DeltaEtaHist->GetRMS(); DeltaEta2simPtHist->SetBinContent(PtIndex, DeltaEtaMean); DeltaEta2simPtHist->SetBinError(PtIndex, DeltaEtaRMS); } myEfficiencyHist->AddLast(Efficiency2simPtHist); myParticleHist->AddLast(Particle2simPtHist); mySTAHist->AddLast(STA2simPtHist); myChargeCheckHist->AddLast(InverseChargeRato2simPtHist); myDeltaPtHist->AddLast(DeltaPt2simPtHist); } double minX = 0; double minY = 0; double maxX = 110; double maxY = 40; TCanvas* myCanvas = new TCanvas("Canvas", "Canvas", 800, 600); myCanvas->cd(); TPad* myPad = new TPad("Pad", "Pad", 0, 0, 1, 1); myPad->Draw(); myPad->cd(); ((TH1D*)(myParticleHist->At(0)))->SetStats(0); ((TH1D*)(myParticleHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev"); ((TH1D*)(myParticleHist->At(0)))->GetXaxis()->CenterTitle(1); ((TH1D*)(myParticleHist->At(0)))->Draw(); for(int Index = 0; Index < FileNumber; Index++) { ((TH1D*)(mySTAHist->At(Index)))->SetStats(0); ((TH1D*)(mySTAHist->At(Index)))->SetLineColor(kRed+Index); ((TH1D*)(mySTAHist->At(Index)))->Draw("same"); } TLegend *STALeg = new TLegend(0.6,0.1,0.9,0.3); STALeg->SetBorderSize(1); TString LegKey = "ParticleTrack"; STALeg->AddEntry(myParticleHist->At(0), LegKey, "lpf"); for(int Index = 0; Index < FileNumber; Index++) { LegKey = TypeName[Index]; STALeg->AddEntry(mySTAHist->At(Index), LegKey, "lpf"); } STALeg->Draw(); string SaveName = OutputPlotNamepreFix + "_STA2simPt" + OutputPlotNameFix; myCanvas->SaveAs(SaveName.c_str()); myPad->Clear(); myPad->Update(); double YScale = myPad->GetUymax() / 110.; ((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev"); ((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->CenterTitle(1); ((TH1D*)(myEfficiencyHist->At(0)))->SetStats(0); ((TH1D*)(myEfficiencyHist->At(0)))->Scale(YScale); ((TH1D*)(myEfficiencyHist->At(0)))->SetLineColor(kRed); ((TH1D*)(myEfficiencyHist->At(0)))->Draw("same,ah"); for(int Index = 1; Index < FileNumber; Index++) { ((TH1D*)(myEfficiencyHist->At(Index)))->SetStats(0); ((TH1D*)(myEfficiencyHist->At(Index)))->Scale(YScale); ((TH1D*)(myEfficiencyHist->At(Index)))->SetLineColor(kRed+Index); ((TH1D*)(myEfficiencyHist->At(Index)))->Draw("same,ah"); } myPad->Update(); if(debug) cout << "Y: " << myPad->GetUymax() << endl; double YAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmin(); double YAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmax(); int YAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetNbins(); TGaxis* YAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmin(), myPad->GetUymax(), 0, 110, 510, "-R"); YAxis->SetLineColor(kGreen); YAxis->SetLabelColor(kGreen); YAxis->SetTitle("Efficiency of STA for simPts"); YAxis->CenterTitle(1); YAxis->Draw(); double XAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmin(); double XAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmax(); int XAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetNbins(); TGaxis* XAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmax(), myPad->GetUymin(), XAxisMinValue, XAxisMaxValue, 510, "+L"); XAxis->SetTitle("simPt/Gev"); XAxis->CenterTitle(1); XAxis->Draw(); TLegend *EffLeg = new TLegend(0.1,0.9,0.4,1.0); EffLeg->SetBorderSize(1); for(int Index = 0; Index < FileNumber; Index++) { TString LegKey = TypeName[Index]; EffLeg->AddEntry(myEfficiencyHist->At(Index), LegKey, "lpf"); } EffLeg->Draw(); string SaveName = OutputPlotNamepreFix + "_Eff2simPt" + OutputPlotNameFix; myCanvas->SaveAs(SaveName.c_str()); ((TH1D*)(myDeltaPtHist->At(0)))->SetStats(0); ((TH1D*)(myDeltaPtHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev"); ((TH1D*)(myDeltaPtHist->At(0)))->GetXaxis()->CenterTitle(1); ((TH1D*)(myDeltaPtHist->At(0)))->GetYaxis()->SetTitle("deltPt/simPt"); ((TH1D*)(myDeltaPtHist->At(0)))->GetYaxis()->CenterTitle(1); ((TH1D*)(myDeltaPtHist->At(0)))->SetLineColor(kRed); ((TH1D*)(myDeltaPtHist->At(0)))->Draw(""); for(int Index = 1; Index < FileNumber; Index++) { ((TH1D*)(myDeltaPtHist->At(Index)))->SetStats(0); //((TH1D*)(myDeltaPtHist->At(Index)))->GetXaxis()->SetTitle("simPt/Gev"); //((TH1D*)(myDeltaPtHist->At(Index)))->GetXaxis()->CenterTitle(1); //((TH1D*)(myDeltaPtHist->At(Index)))->GetYaxis()->SetTitle("deltPt/simPt"); //((TH1D*)(myDeltaPtHist->At(Index)))->GetYaxis()->CenterTitle(1); ((TH1D*)(myDeltaPtHist->At(Index)))->SetLineColor(kRed+Index); ((TH1D*)(myDeltaPtHist->At(Index)))->Draw("same"); //SaveName = OutputPlotNamepreFix + TypeName[Index] + "DeltaPt" + OutputPlotNameFix; //myCanvas->SaveAs(SaveName.c_str()); } TLegend *PtLeg = new TLegend(0.6,0.8,0.9,0.9); PtLeg->SetBorderSize(1); for(int Index = 0; Index < FileNumber; Index++) { TString LegKey = TypeName[Index]; PtLeg->AddEntry(myDeltaPtHist->At(Index), LegKey, "lpf"); } PtLeg->Draw(); SaveName = OutputPlotNamepreFix + "_DeltaPt" + OutputPlotNameFix; myCanvas->SaveAs(SaveName.c_str()); }
void t1pfmetPhiwithCorr(double pt1min, double pt2min, double METmin, double DPHImin){ gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); int i = 0; TLegend* leg = new TLegend(0.35,0.65,0.87,0.87); leg->SetNColumns(2); leg->SetBorderSize(0); leg->SetFillStyle(0); TCanvas *canvas = new TCanvas("c1n","",500,600); TPad *mainPad = new TPad("mainPad","",0,0.3,1,1); TPad *smallPad = new TPad("smallPad","",0,0.05,1,0.3); mainPad->SetBottomMargin(0.015); smallPad->SetTopMargin(0.05); smallPad->SetBottomMargin(0.25); canvas->cd(); mainPad->Draw(); mainPad->cd(); // gPad->SetLogy(); TCut mggmax = "mgg<180"; TCut mggmin = "mgg>100"; TCut pt1Cut = Form("pt1/mgg>%lf",pt1min); TCut pt2Cut = Form("pt2/mgg>%lf",pt2min); // TCut METCut = Form("t1pfmetCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0)>%lf",METmin); TCut METCut = ""; TCut DPHICut = Form("Delta(pt1,eta1,phi1,pt2,eta2,phi2,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>%lf",DPHImin); TCut eveto1 = "eleveto1 == 1"; TCut eveto2 = "eleveto2 == 1"; TCut eveto = eveto1 && eveto2; TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))"; TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))"; TCut NegWeight = "weight>0."; /* TFile *M1 = TFile::Open("./50ns_betaV3/NewWeightDMHtoGG_M1.root","READ"); TFile *M10 = TFile::Open("./50ns_betaV3/NewWeightDMHtoGG_M10.root","READ"); TFile *M100 = TFile::Open("./50ns_betaV3/NewWeightDMHtoGG_M100.root","READ"); TFile *M1000 = TFile::Open("./50ns_betaV3/NewWeightDMHtoGG_M1000.root","READ"); */ TFile *data = TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ"); TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ"); TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ"); TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ"); TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ"); TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ"); TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ"); TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ"); /* TFile *bkg1 = TFile::Open("./50ns_betaV3/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./50ns_betaV3/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./50ns_betaV3/GJets.root","READ"); TFile *bkg4 = TFile::Open("./50ns_betaV3/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./50ns_betaV3/QCD.root","READ"); TFile *bkg6 = TFile::Open("./50ns_betaV3/VH.root","READ"); */ TFile *bkg1 = TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./25ns_2246inv_v3/GJets.root","READ"); TFile *bkg4 = TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./25ns_2246inv_v3/QCD.root","READ"); TFile *bkg6 = TFile::Open("./25ns_2246inv_v3/VH.root","READ"); TFile *bkg7 = TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ"); TFile *bkg8 = TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ"); TFile *bkg9 = TFile::Open("./25ns_2246inv_v3/TGJets.root","READ"); TFile *bkg10 = TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ"); TFile *bkg11 = TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ"); TFile *bkg12 = TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ"); /* TTree *tree_M1 = (TTree*) M1->Get("DiPhotonTree"); TTree *tree_M10 = (TTree*) M10->Get("DiPhotonTree"); TTree *tree_M100 = (TTree*) M100->Get("DiPhotonTree"); TTree *tree_M1000 = (TTree*) M1000->Get("DiPhotonTree"); */ TTree *tree_data = (TTree*) data->Get("DiPhotonTree"); TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree"); TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree"); TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree"); TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree"); TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree"); TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree"); TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree"); TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree"); TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree"); TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree"); TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree"); TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree"); TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree"); TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree"); TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree"); TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree"); TTree *tree_bkg10 = (TTree*) bkg10->Get("DiPhotonTree"); TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree"); TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree"); /* tree_M1->Draw("(t1pfmet)>>h1(30,100,200)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_M10->Draw("(t1pfmet)>>h2(30,100,200)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_M100->Draw("(t1pfmet)>>h3(30,100,200)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_M1000->Draw("(t1pfmet)>>h4(30,100,200)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); */ tree_data->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1))>>hdata(10,-4,4)","(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && eveto && METCut && metF&& DPHICut )); TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata"); tree_sig1->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h1(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h2(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h3(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h4(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h5(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); tree_sig6->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h6(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6"); tree_sig7->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h7(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7"); tree_bkg1->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg1(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg2(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg3(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && genmatch && DPHICut)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg4(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4"); tree_bkg5->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg5(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && genmatch && DPHICut)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg6(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6"); tree_bkg7->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg7(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7"); tree_bkg8->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg8(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8"); tree_bkg9->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg9(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9"); tree_bkg10->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg10(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10"); tree_bkg11->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg11(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11"); tree_bkg12->Draw("(t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg12(10,-4,4)","weight*(mgg<115||mgg>135)"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && DPHICut)); TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12"); hdata->SetMarkerColor(kBlack); hdata->SetLineColor(kBlack); hdata->SetMarkerStyle(20); h1->SetLineColor(kRed+3); h2->SetLineColor(kRed+1); h3->SetLineColor(kRed); h4->SetLineColor(kPink+2); h5->SetLineColor(kPink+4); h6->SetLineColor(kPink+7); h7->SetLineColor(kMagenta+2); h1->SetLineWidth(2); h2->SetLineWidth(2); h3->SetLineWidth(2); h4->SetLineWidth(2); h5->SetLineWidth(2); h6->SetLineWidth(2); h7->SetLineWidth(2); THStack *hs=new THStack("hs",""); hbkg7->SetFillColor(kGreen+2); hbkg6->SetFillColor(kGreen); hbkg8->SetFillColor(kYellow); hbkg4->SetFillColor(kOrange); hbkg9->SetFillColor(kOrange+7); hbkg10->SetFillColor(kOrange+4); hbkg11->SetFillColor(kCyan); hbkg12->SetFillColor(kCyan+1); hbkg5->SetFillColor(kBlue+2); hbkg2->SetFillColor(kBlue); hbkg3->SetFillColor(kMagenta-2); hbkg1->SetFillColor(kViolet); hbkg1->SetLineColor(kBlack); hbkg2->SetLineColor(kBlack); hbkg3->SetLineColor(kBlack); hbkg4->SetLineColor(kBlack); hbkg5->SetLineColor(kBlack); hbkg6->SetLineColor(kBlack); hbkg7->SetLineColor(kBlack); hbkg8->SetLineColor(kBlack); hbkg9->SetLineColor(kBlack); hbkg10->SetLineColor(kBlack); hbkg11->SetLineColor(kBlack); hbkg12->SetLineColor(kBlack); hs->Add(hbkg7); hs->Add(hbkg6); hs->Add(hbkg8); hs->Add(hbkg4); hs->Add(hbkg9); hs->Add(hbkg10); hs->Add(hbkg11); hs->Add(hbkg12); hs->Add(hbkg2); hs->Add(hbkg5); hs->Add(hbkg3); hs->Add(hbkg1); TH1F *hsum = (TH1F*)hbkg1->Clone("hsum"); hsum->Add(hbkg2); hsum->Add(hbkg3); hsum->Add(hbkg4); hsum->Add(hbkg5); hsum->Add(hbkg6); hsum->Add(hbkg7); hsum->Add(hbkg8); hsum->Add(hbkg9); hsum->Add(hbkg10); hsum->Add(hbkg11); hsum->Add(hbkg12); canvas->SetLeftMargin(0.12); // hs->SetMinimum(0.01); hs->SetMaximum(5700); hs->SetTitle(""); hs->Draw("HIST"); hsum->SetMarkerStyle(1); hsum->SetFillColor(kGray+3); hsum->SetFillStyle(3002); hsum->Draw("same e2"); // h2->Draw("same hist"); // h3->Draw("same hist"); // h4->Draw("same hist"); // h1->Draw("same hist"); //h5->Draw("same hist"); //only for 25ns samples //h7->Draw("same hist"); //only for 25ns samples // h6->Draw("same hist"); //only for 25ns samples hdata->Draw("same E1"); hs->GetXaxis()->SetLabelOffset(999); hs->GetYaxis()->SetTitleOffset(1.5); hs->GetYaxis()->SetTitle("Events/0.8"); //int iPos = 11; // CMS_lumi(canvas,true,iPos,false); gPad->Modified(); leg->AddEntry(hdata,"Data","elp"); /*leg->AddEntry(h1,"m_{#chi} = 1 GeV","l"); leg->AddEntry(h2,"m_{#chi} = 10 GeV","l"); leg->AddEntry(h3,"m_{#chi} = 100 GeV","l"); leg->AddEntry(h4,"m_{#chi} = 1000 GeV","l");*/ // leg->AddEntry(h1,"m_{Z'} = 600 GeV","l"); leg->AddEntry(hbkg1,"#gamma #gamma","f"); // leg->AddEntry(h2,"m_{Z'} = 800 GeV","l"); leg->AddEntry(hbkg2,"Drell Yann","f"); // leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); leg->AddEntry(hbkg3,"#gamma + Jets","f"); // leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); leg->AddEntry(hbkg5,"QCD","f"); // leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples leg->AddEntry(hbkg4,"ggH","f"); //leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); //only for 25ns samples leg->AddEntry(hbkg6,"VH","f"); // leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples leg->AddEntry(hbkg7,"ttH","f"); leg->AddEntry(hbkg8,"VBF H","f"); leg->AddEntry(hbkg9,"t + #gamma + Jets","f"); leg->AddEntry(hbkg10,"tt + #gamma +Jets","f"); leg->AddEntry(hbkg11,"#gamma+W","f"); leg->AddEntry(hbkg12,"#gamma+Z","f"); leg->AddEntry(hsum,"Bkg uncertainty","f"); leg->Draw("same"); gStyle->SetOptStat(0); canvas->cd(); smallPad->Draw(); smallPad->cd(); TGraphErrors *gr = new TGraphErrors(0); double integralData=hdata->Integral(); double integralBKG=hsum->Integral(); double error, ratio; for(int w=1; w<20; w++){ if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){ gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w))); ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w)); error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w)); std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl; gr->SetPointError(w, hdata->GetBinWidth(w)/2,error); }else{ gr->SetPoint(w, hdata->GetBinCenter(w),10); } } gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); gr->GetHistogram()->SetMaximum(2); gr->GetHistogram()->SetMinimum(0.1); gStyle->SetTextSize(14); gROOT->ForceStyle(); gr->GetXaxis()->SetLabelFont(43); gr->GetXaxis()->SetLabelSize(15); gr->GetYaxis()->SetLabelFont(43); gr->GetYaxis()->SetLabelSize(15); gr->GetXaxis()->SetLimits(-4,4); gPad->SetGrid(); gStyle->SetStripDecimals(kTRUE); gr->SetMarkerStyle(20); gr->SetMarkerSize(0.7); gr->Draw("AZP"); gr->GetXaxis()->SetTitle("#phi_{MET}^{corr}"); gr->GetXaxis()->SetTitleSize(0.1); gr->GetYaxis()->SetTitleSize(0.1); gr->GetYaxis()->SetNdivisions(505); gr->GetXaxis()->SetTitleOffset(1); gr->GetYaxis()->SetTitle("Data/MC"); gr->GetYaxis()->SetTitleOffset(0.4); gr->SetTitle(""); smallPad->Update(); TF1* line = new TF1("line","1",-4,4); line->SetLineColor(kRed); line->SetLineWidth(2); line->Draw("L same"); gr->Draw("ZP SAME"); canvas->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/metphicorr_MET%.0lf.pdf",METmin)); canvas->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/metphicorr_MET%.0lf.png",METmin)); }
bool createPlot(TString hname, TString dirname, TFile *V1file, TString runstring1, TString relstring1, TFile *V2file, TString runstring2, TString relstring2, TCanvas *canvas, int scale) { setTDRStyle(); int SetScale = scale; //IF =0 --> No scale applied ('direct' comparison) //IF =1 --> Scale INDIVIDUALLY (scale histograms individually) //IF =2 --> Scale all GLOBALLY (scale all histograms to #tracks=1) //IF =3 --> Scale all GLOBALLY nEVENTS (scale all histos to nEntries in nTracks per Event) bool DrawRatio = true; canvas->cd(); TPad* mainpad = new TPad("mainpad","mainpad",0.0,0.0,1.0,0.8); mainpad->Draw(); mainpad->cd(); // ************ Get name of histos and get histos ************* // if (dirname.Contains("GeneralProperties/GoodTracks",TString::kExact)){ if ((hname != "FractionOfGoodTracks") && (hname != "NumberOfGoodTracks")){ hname.Prepend("GoodTrack"); } } TString basename1 = "DQMData/Run "; basename1.Append(runstring1); TString hnameV1 = basename1; hnameV1.Append(dirname+"/"); hnameV1.Append(hname); if (hname != "vtxNbr"){ hnameV1.Append("_GenTk"); } TH1F * hBinTempV1 = (TH1F*)V1file->Get(hnameV1); if ( hBinTempV1 == (TH1F*) NULL ) { cout << "histV1 failed on " << hnameV1 << endl << " for file " << V1file->GetName() << endl; exit(1); } TString basename2 = "DQMData/Run "; basename2.Append(runstring2); TString hnameV2 = basename2; hnameV2.Append(dirname+"/"); hnameV2.Append(hname); if (hname != "vtxNbr"){ hnameV2.Append("_GenTk"); } TH1F * hBinTempV2 = (TH1F*)V2file->Get(hnameV2); if ( hBinTempV2 == (TH1F*) NULL ) { cout << "histV2 failed on " << hnameV2 << endl << " for file " << V2file->GetName() << endl; exit(1); } // Check that bins match for ratio plot TH1F * histV1 = 0; TH1F * histV2 = 0; Double_t h1_xlow = hBinTempV1->GetXaxis()->GetBinLowEdge(hBinTempV1->GetXaxis()->GetFirst()); Double_t h2_xlow = hBinTempV2->GetXaxis()->GetBinLowEdge(hBinTempV2->GetXaxis()->GetFirst()); Double_t h1_xup = hBinTempV1->GetXaxis()->GetBinUpEdge(hBinTempV1->GetXaxis()->GetLast()); Double_t h2_xup = hBinTempV2->GetXaxis()->GetBinUpEdge(hBinTempV2->GetXaxis()->GetLast()); Int_t h1_nbins = hBinTempV1->GetNbinsX(); Int_t h2_nbins = hBinTempV2->GetNbinsX(); Double_t h1_binWidth = (h1_xup - h1_xlow) / (Double_t)h1_nbins; Double_t h2_binWidth = (h2_xup - h2_xlow) / (Double_t)h2_nbins; if ((h1_xlow == h2_xlow) && (h1_xup == h2_xup) && (h1_binWidth == h2_binWidth)){ histV1 = (TH1F*)V1file->Get(hnameV1); histV2 = (TH1F*)V2file->Get(hnameV2); } else if((h1_xlow == h2_xlow) && (h1_xup < h2_xup) && (h1_binWidth == h2_binWidth)){ // Fill h1 from h1xlow to h1high with h1 info, and up to h2high, fill zero histV2 = (TH1F*)V2file->Get(hnameV2); // copy histV2 histV1 = new TH1F(hBinTempV1->GetName(),hBinTempV1->GetTitle(),h2_nbins,h2_xlow,h2_xup); histV1->SetXTitle(hBinTempV1->GetXaxis()->GetTitle()); histV1->SetYTitle(hBinTempV1->GetYaxis()->GetTitle()); for (Int_t ibin = 1; ibin <= h2_nbins; ibin++){ if (ibin <= h1_nbins){ histV1->SetBinContent(ibin,hBinTempV1->GetBinContent(ibin)); } else if (ibin > h1_nbins){ histV1->SetBinContent(ibin,0.0); } } } else if((h1_xlow == h2_xlow) && (h1_xup > h2_xup) && (h1_binWidth == h2_binWidth)){ // Fill h1 from h1xlow to h1high with h1 info, and up to h2high, fill zero histV1 = (TH1F*)V1file->Get(hnameV1); // copy histV1 histV2 = new TH1F(hBinTempV2->GetName(),hBinTempV2->GetTitle(),h1_nbins,h1_xlow,h1_xup); histV2->SetXTitle(hBinTempV2->GetXaxis()->GetTitle()); histV2->SetYTitle(hBinTempV2->GetYaxis()->GetTitle()); for (Int_t ibin = 1; ibin <= h1_nbins; ibin++){ if (ibin <= h2_nbins){ histV2->SetBinContent(ibin,hBinTempV2->GetBinContent(ibin)); } else if (ibin > h2_nbins){ histV2->SetBinContent(ibin,0.0); } } } else{ cout << "Bin Check Failed... here's what happened: " << endl; cout << "histV1 failed on " << hnameV1 << endl << " for file " << V1file->GetName() << endl; cout << " bin info: " << h1_xlow << " " << h1_xup << " " << h1_nbins << endl; cout << "histV2 failed on " << hnameV2 << endl << " for file " << V2file->GetName() << endl; cout << " bin info: " << h2_xlow << " " << h2_xup << " " << h2_nbins << endl; exit(1); } // Don't look at zero bin -- > Also could use this for truncation and bin setting -->Range is binlower to upper // Int_t range_upper = histV1->GetXaxis()->GetLast(); // histV1->GetXaxis()->SetRangeUser(1,range_upper); // histV2->GetXaxis()->SetRangeUser(1,range_upper); //******************* Get histo integrals ***********************// double V1_integral = 1.0; double V2_integral = 1.0; TH1F * hNormTempV1 = 0; TH1F * hNormTempV2 = 0; if (SetScale==1){ V1_integral = histV1->Integral(); V2_integral = histV2->Integral(); } else if ( (SetScale==2) || (SetScale==3) ){ if (hname != "NumberOfTracks"){ TString hTempNameV1 = basename1; hTempNameV1.Append("/Tracking/Run summary/TrackParameters/GeneralProperties/NumberOfTracks_GenTk"); hNormTempV1 = (TH1F*)V1file->Get(hTempNameV1); TString hTempNameV2 = basename2; hTempNameV2.Append("/Tracking/Run summary/TrackParameters/GeneralProperties/NumberOfTracks_GenTk"); hNormTempV2 = (TH1F*)V2file->Get(hTempNameV2); } else{ hNormTempV1 = (TH1F*)histV1->Clone("hNormTempV1"); hNormTempV2 = (TH1F*)histV2->Clone("hNormTempV2"); } if (SetScale==2){ V1_integral = hNormTempV1->GetBinContent(2); V2_integral = hNormTempV2->GetBinContent(2); std::cout << "The number of single tracks for V1 is " << V1_integral << std::endl; std::cout << "The number of single tracks for V2 is " << V2_integral << std::endl; } else if (SetScale==3){ V1_integral = hNormTempV1->GetEntries(); V2_integral = hNormTempV2->GetEntries(); std::cout << "The number of events for V1 is " << V1_integral << std::endl; std::cout << "The number of events for V2 is " << V2_integral << std::endl; } } //*****NORMALIZING V1-V2**************************************** if(V1_integral>V2_integral) { histV1->Scale(V2_integral / V1_integral); histV2->Scale(1); } else if(V2_integral>V1_integral){ histV1->Scale(1); histV2->Scale(V1_integral / V2_integral); } //*****NORMALIZING V1-V2*end*************************************** //***Name the files under comparison*** TString V1_V1run = "Run "+runstring1+" ("+relstring1+")"; TString V2_V2run = "Run "+runstring2+" ("+relstring2+")"; histV1->SetName(V1_V1run); histV2->SetName(V2_V2run); double max = 0; double V1max = histV1->GetBinContent(histV1->GetMaximumBin()); double V2max = histV2->GetBinContent(histV2->GetMaximumBin()); max = (V1max>V2max) ? V1max : V2max; histV1->Draw(); histV1->SetLineStyle(1); histV1->GetYaxis()->SetLabelSize(0.038); histV1->SetLineWidth(5); histV1->SetLineColor(kRed); histV1->SetMaximum(max*(1.1)); histV2->Draw(); histV2->SetLineWidth(3); histV2->SetLineStyle(1); histV2->SetLineColor(kBlue); if( hname.Contains("NumberOfTracks",TString::kExact) || hname.Contains("NumberOfGoodTracks",TString::kExact) || hname.Contains("TrackPt",TString::kExact) || hname.Contains("Chi2Prob",TString::kExact) ){ mainpad->SetLogy(1); } else{ mainpad->SetLogy(0); } if (hname.Contains("NumberOfTracks",TString::kExact)){ histV1->GetXaxis()->SetRangeUser(0,500); histV2->GetXaxis()->SetRangeUser(0,500); } if (hname.Contains("NumberOfGoodTracks",TString::kExact)) { histV1->GetXaxis()->SetRangeUser(0,200); histV2->GetXaxis()->SetRangeUser(0,200); } if (hname.Contains("Chi2oNDF",TString::kExact)) { histV1->GetXaxis()->SetRangeUser(0,10); histV2->GetXaxis()->SetRangeUser(0,10); } if (hname.Contains("vtxNbr")){ histV1->GetXaxis()->SetTitle("Number of Primary Vertices per Event"); histV1->GetYaxis()->SetTitle("Number of Events"); } histV1->Draw(); // Draw old histo first, ratio is new/old histV2->Draw("sames"); mainpad->Update(); TPaveStats *st1 = (TPaveStats*)(histV1->GetListOfFunctions()->FindObject("stats")); st1->SetX1NDC(0.77); st1->SetY1NDC(0.80); st1->SetX2NDC(0.98); st1->SetY2NDC(0.97); Double_t defaulth = st1->GetY2NDC() - st1->GetY1NDC(); Double_t gaph = 0.02; TPaveStats *st2 = (TPaveStats*)(histV2->GetListOfFunctions()->FindObject("stats")); st2->SetX1NDC(0.77); st2->SetY1NDC(st1->GetY1NDC() - 1.0*defaulth - gaph); st2->SetX2NDC(0.98); st2->SetY2NDC(st1->GetY1NDC() - gaph); TLegend *leg = new TLegend(0.32,0.86,0.76,0.97); leg->SetTextSize(0.042); leg->SetTextFont(42); leg->SetFillColor(10); leg->SetBorderSize(1); // no frame, no shadow leg->AddEntry(histV1, V1_V1run, "L" ); leg->AddEntry(histV2, V2_V2run, "L" ); leg->Draw("SAME"); // Draw ratio histogram if (DrawRatio){ canvas->cd(); TPad* respad = new TPad("respad","respad",0.0,0.78,1.0,0.95); respad->SetTopMargin(1.05); respad->Draw(); respad->cd(); TH1F* hratio = (TH1F*) histV2->Clone("hratio"); hratio->Divide(histV1); hratio->SetMaximum(hratio->GetMaximum()*1.1); hratio->SetMinimum(hratio->GetMinimum()/1.1); //if (hratio->GetMinimum()==0.0) hratio->SetMinimum(1.0/hratio->GetMaximum()); // hratio->SetMinimum(1.0/hratio->GetMaximum()); hratio->GetYaxis()->SetLabelSize(0.1); // hratio->GetYaxis()->SetRangeUser(0,2); hratio->GetXaxis()->SetLabelSize(0); hratio->GetXaxis()->SetTitleSize(0); hratio->GetYaxis()->SetTitleSize(0.22); hratio->GetYaxis()->SetTitleOffset(0.26); hratio->GetYaxis()->SetLabelSize(0.2); hratio->GetYaxis()->SetNdivisions(5); hratio->GetYaxis()->SetTitle("NEW/REF"); hratio->Draw(); } // Compare parameters of histograms double Entries1 = histV1->GetEntries(); double Entries2 = histV2->GetEntries(); if (Entries1 != Entries2) { std::cout<<" Difference in # of ENTRIES for " <<hname<< std::endl; std::cout<<"\t Entries1 = " << Entries1 << "\t Entries2 = " << Entries2 << std::endl; } double Mean1 = histV1->GetMean(); double Mean2 = histV2->GetMean(); if (Mean1 != Mean2) { std::cout<<" Difference in MEANS for " <<hname<< std::endl; std::cout<<"\t Mean1 = " << Mean1 << "\t Mean2 = " << Mean2 << std::endl; } double RMS1 = histV1->GetRMS(); double RMS2 = histV2->GetRMS(); if (RMS1 != RMS2) { std::cout<<" Difference in RMS for " <<hname<< std::endl; std::cout<<"\t RMS1 = " << RMS1 << "\t RMS2 = " << RMS2 << std::endl; } TString filename = hname; if (hname.Contains("vtxNbr")){ filename = "NumberOfPrimaryVertices"; } if (dirname.Contains("GeneralProperties/GoodTracks",TString::kExact)) filename.Prepend("RunComparison/GoodTracks_"); else filename.Prepend("RunComparison/"); filename.Append(".png"); canvas->Print(filename); if ( histV1 ) {histV1->Delete();} if ( histV2 ) {histV2->Delete();} if ( hNormTempV1 ) {hNormTempV1->Delete();} if ( hNormTempV2 ) {hNormTempV2->Delete();} // if ( hBinTempV1 ) {hBinTempV1->Delete();} // why cant this work?! // if ( hBinTempV2 ) {hBinTempV2->Delete();} return true; }
void rulevisHists( TDirectory *rfdir, TDirectory *vardir, TDirectory *corrdir, TMVAGlob::TypeOfPlot type) { // if (rfdir==0) return; if (vardir==0) return; if (corrdir==0) return; // const TString rfName = rfdir->GetName(); const TString maintitle = rfName + " : Rule Importance"; const TString rfNameOpt = "_RF2D_"; const TString outfname[TMVAGlob::kNumOfMethods] = { "rulevisHists", "rulevisHists_decorr", "rulevisCorr_pca", "rulevisCorr_gaussdecorr" }; const TString outputName = outfname[type]+"_"+rfdir->GetName(); // TIter rfnext(rfdir->GetListOfKeys()); TKey *rfkey; Double_t rfmax; Double_t rfmin; Bool_t allEmpty=kTRUE; Bool_t first=kTRUE; while ((rfkey = (TKey*)rfnext())) { // make sure, that we only look at histograms TClass *cl = gROOT->GetClass(rfkey->GetClassName()); if (!cl->InheritsFrom("TH2F")) continue; TH2F *hrf = (TH2F*)rfkey->ReadObj(); TString hname= hrf->GetName(); if (hname.Contains("__RF_")){ // found a new RF plot Double_t valmin = hrf->GetMinimum(); Double_t valmax = hrf->GetMaximum(); if (first) { rfmin=valmin; rfmax=valmax; first = kFALSE; } else { if (valmax>rfmax) rfmax=valmax; if (valmin<rfmin) rfmin=valmin; } if (hrf->GetEntries()>0) allEmpty=kFALSE; } } if (first) { cout << "ERROR: no RF plots found..." << endl; return; } const Int_t nContours = 100; Double_t contourLevels[nContours]; Double_t dcl = (rfmax-rfmin)/Double_t(nContours-1); // for (Int_t i=0; i<nContours; i++) { contourLevels[i] = rfmin+dcl*Double_t(i); } /////////////////////////// vardir->cd(); // how many plots are in the directory? Int_t noPlots = ((vardir->GetListOfKeys())->GetEntries()) / 2; // define Canvas layout here! // default setting Int_t xPad; // no of plots in x Int_t yPad; // no of plots in y Int_t width; // size of canvas Int_t height; switch (noPlots) { case 1: xPad = 1; yPad = 1; width = 500; height = 0.7*width; break; case 2: xPad = 2; yPad = 1; width = 600; height = 0.7*width; break; case 3: xPad = 3; yPad = 1; width = 900; height = 0.4*width; break; case 4: xPad = 2; yPad = 2; width = 600; height = width; break; default: xPad = 3; yPad = 2; width = 800; height = 0.7*width; break; } Int_t noPad = xPad * yPad ; // this defines how many canvases we need const Int_t noCanvas = 1 + (Int_t)((noPlots - 0.001)/noPad); TCanvas **c = new TCanvas*[noCanvas]; for (Int_t ic=0; ic<noCanvas; ic++) c[ic] = 0; // counter variables Int_t countCanvas = 0; Int_t countPad = 1; // loop over all objects in directory TIter next(vardir->GetListOfKeys()); TKey *key; TH1F *sigCpy=0; TH1F *bgdCpy=0; // Bool_t first = kTRUE; while ((key = (TKey*)next())) { // make sure, that we only look at histograms TClass *cl = gROOT->GetClass(key->GetClassName()); if (!cl->InheritsFrom("TH1")) continue; sig = (TH1F*)key->ReadObj(); TString hname= sig->GetName(); // check for all signal histograms if (hname.Contains("__S")){ // found a new signal plot // sigCpy = new TH1F(*sig); // create new canvas if ((c[countCanvas]==NULL) || (countPad>noPad)) { char cn[20]; sprintf( cn, "rulehist%d_", countCanvas+1 ); TString cname(cn); cname += rfdir->GetName(); c[countCanvas] = new TCanvas( cname, maintitle, countCanvas*50+200, countCanvas*20, width, height ); // style c[countCanvas]->Divide(xPad,yPad); countPad = 1; } // save canvas to file TPad *cPad = (TPad *)(c[countCanvas]->GetPad(countPad)); c[countCanvas]->cd(countPad); countPad++; // find the corredponding background histo TString bgname = hname; bgname.ReplaceAll("__S","__B"); hkey = vardir->GetKey(bgname); bgd = (TH1F*)hkey->ReadObj(); if (bgd == NULL) { cout << "ERROR!!! couldn't find backgroung histo for" << hname << endl; exit; } TString rfname = hname; rfname.ReplaceAll("__S","__RF"); TKey *hrfkey = rfdir->GetKey(rfname); TH2F *hrf = (TH2F*)hrfkey->ReadObj(); Double_t wv = hrf->GetMaximum(); // if (rfmax>0.0) // hrf->Scale(1.0/rfmax); hrf->SetMinimum(rfmin); // make sure it's zero -> for palette axis hrf->SetMaximum(rfmax); // make sure max is 1.0 -> idem hrf->SetContour(nContours,&contourLevels[0]); // this is set but not stored during plot creation in MVA_Factory // TMVAGlob::SetSignalAndBackgroundStyle( sigK, bgd ); sig->SetFillStyle(3002); sig->SetFillColor(1); sig->SetLineColor(1); sig->SetLineWidth(2); bgd->SetFillStyle(3554); bgd->SetFillColor(1); bgd->SetLineColor(1); bgd->SetLineWidth(2); // chop off "signal" TString title(hrf->GetTitle()); title.ReplaceAll("signal",""); // finally plot and overlay Float_t sc = 1.1; if (countPad==2) sc = 1.3; sig->SetMaximum( TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*sc ); Double_t smax = sig->GetMaximum(); if (first) { hrf->SetTitle( maintitle ); first = kFALSE; } else { hrf->SetTitle( "" ); } hrf->Draw("colz ah"); TMVAGlob::SetFrameStyle( hrf, 1.2 ); sig->Draw("same ah"); bgd->Draw("same ah"); // draw axis using range [0,smax] hrf->GetXaxis()->SetTitle( title ); hrf->GetYaxis()->SetTitleOffset( 1.30 ); hrf->GetYaxis()->SetTitle("Events"); hrf->GetYaxis()->SetLimits(0,smax); hrf->Draw("same axis"); cPad->SetRightMargin(0.13); cPad->Update(); // Draw legend if (countPad==2){ TLegend *legend= new TLegend( cPad->GetLeftMargin(), 1-cPad->GetTopMargin()-.18, cPad->GetLeftMargin()+.4, 1-cPad->GetTopMargin() ); legend->AddEntry(sig,"Signal","F"); legend->AddEntry(bgd,"Background","F"); legend->Draw("same"); legend->SetBorderSize(1); legend->SetMargin( 0.3 ); legend->SetFillColor(19); legend->SetFillStyle(1); } // save canvas to file if (countPad > noPad) { c[countCanvas]->Update(); TString fname = Form( "plots/%s_c%i", outputName.Data(), countCanvas+1 ); TMVAGlob::imgconv( c[countCanvas], fname ); // TMVAGlob::plot_logo(); // don't understand why this doesn't work ... :-( countCanvas++; } } } if (countPad <= noPad) { c[countCanvas]->Update(); TString fname = Form( "plots/%s_c%i", outputName.Data(), countCanvas+1 ); TMVAGlob::imgconv( c[countCanvas], fname ); } }
void genPlotsRatio0102(std::string fullPath, bool custBinning = false) { genPlots01(fullPath, 0, custBinning); TH2F *h1 = (TH2F*)gDirectory->GetList()->FindObject("hrzL0vtx"); genPlots02(fullPath, 0, custBinning); TH2F *h2 = (TH2F*)gDirectory->GetList()->FindObject("hrzL0vtxreco"); if (0==h1) { cout << "Histo hrzL0vtx not present" << endl; return; } if (0==h2) { cout << "Histo hrzL0vtxreco not present" << endl; return; } TH2F *hratio; if (custBinning) { double newbinsX[]={0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}; const int newbinsX_size = sizeof(newbinsX)/sizeof(double); double newbinsY[]={0,0.5,1,2,4,8,16,32}; const int newbinsY_size = sizeof(newbinsY)/sizeof(double); hratio = new TH2F("hratio","hratio",newbinsX_size-1,newbinsX,newbinsY_size-1,newbinsY); } else { hratio = new TH2F("hratio","hratio",30,0,50,30,0,30); } c = new TCanvas("c3","c3",1000,600); const unsigned int nPadX = 1; const unsigned int nPadY = 1; c->Divide(nPadX,nPadY); const unsigned int nPads=nPadX*nPadY; for(unsigned int i=1; i<=nPads; i++) { TPad* pad= (TPad*)c->cd(i); pad->SetTopMargin(0.10); pad->SetRightMargin(0.20); pad->SetLeftMargin(0.15); //pad->SetLogy(); } for(int i=1; i<=h1->GetNbinsX(); i++) for(int j=1; j<=h1->GetNbinsY(); j++) { if (h1->GetBinContent(i,j) != 0.) hratio->SetBinContent(i,j,h2->GetBinContent(i,j) / h1->GetBinContent(i,j)); else hratio->SetBinContent(i,j,0); } hratio->Draw("COLZ"); // add tracker TPad* pad; pad = (TPad*)c->cd(1); pad->Modified(); pad->Update(); repositionPalette("hratio"); pad->Update(); drawTracker(pad); }
// draw the same thing but after reco void genPlots02(std::string fullPath, int nOverlay = 500, bool custBinning = false) { const int fVerbose(1); setTDRStyle(); gStyle->SetOptStat(112211); gStyle->SetPalette(1); // Canvas c = new TCanvas("c2","c2",1000,600); const unsigned int nPadX = 1; const unsigned int nPadY = 1; c->Divide(nPadX,nPadY); const unsigned int nPads=nPadX*nPadY; for(unsigned int i=1; i<=nPads; i++) { TPad* pad= (TPad*)c->cd(i); pad->SetTopMargin(0.10); pad->SetRightMargin(0.20); pad->SetLeftMargin(0.15); } // Open file TFile *f = TFile::Open(fullPath.c_str()); if (f==0) { cout << "File " << fullPath << " not found -- exiting" << endl; return; } if(fVerbose>0) cout << "Succesfully opened file " << fullPath << endl; // Get TTree TTree* t = (TTree*) f->Get("events"); if(fVerbose>0) cout << "Got TTree with " << t->GetEntries() << " entries" << endl; // Do a cut, if needed //t->Draw(">>lst","chi2lb>.1&&mlb>5.61&&mlb<5.63"); //t->Draw(">>lst","chi2lb>.1&&isSig==1"); t->Draw(">>lst","(rid1m&4)==4&&(rid2m&4)==4&&mjp>2.895&&mjp<3.295&&prob1m>0.1&&prob2m>0.1&&ptjp>2&&probjp>0.005&&ml0>1.101&&ml0<1.129&&probpr>0.02&&probpi>0.02&&rptpr>rptpi&&ptl0>3&&rptpr>1&&rptpi>0.5&&probl0>0.02&&alphal0<0.3&&d3l0>1&&d3l0/d3El0>10&&problb>0.001&&alphalb<0.3"); TEventList *lst; lst = (TEventList*)gDirectory->Get("lst"); t->SetEventList(lst); if(fVerbose>0) cout << "Got TTree with " << t->GetEntries() << " entries" << endl; // Do plots c->cd(1); //doPlot2d(t,"hrzL0vtx", "vrl0:TMath::Abs(vzl0)",30,0,300,30,0,120,"Tit","|z|","r","cm","cm"); if (custBinning) { double newbinsX[]={0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}; const int newbinsX_size = sizeof(newbinsX)/sizeof(double); std::vector<double> binvecX(newbinsX,newbinsX+newbinsX_size); //double newbinsY[]={0,1,2,3,4,5,6,7,8,9,10}; double newbinsY[]={0,0.5,1,2,4,8,16,32}; const int newbinsY_size = sizeof(newbinsY)/sizeof(double); std::vector<double> binvecY(newbinsY,newbinsY+newbinsY_size); doPlot2d(t,"hrzL0vtxreco", "vrl0:TMath::Abs(vzl0)",binvecX, binvecY,"#Lambda vertices","|z|","r","cm","cm"); } else { doPlot2d(t,"hrzL0vtxreco", "vrl0:TMath::Abs(vzl0)",30,0,50,30,0,30,"#Lambda vertices","|z|","r","cm","cm"); } // add tracker TPad* pad; pad = (TPad*)c->cd(1); pad->Modified(); pad->Update(); repositionPalette("hrzL0vtxreco"); pad->Update(); pad->SetLogz(); drawTracker(pad); if (nOverlay<=0) return; int maxN = nOverlay; if (maxN > t->GetEntries()) maxN = t->GetEntries(); double vrl0,vzl0,ppr,ppi,etapr,etapi; t->SetBranchAddress("vrl0",&vrl0); t->SetBranchAddress("vzl0",&vzl0); t->SetBranchAddress("ppr",&ppr); t->SetBranchAddress("etapr",&etapr); t->SetBranchAddress("ppi",&ppi); t->SetBranchAddress("etapi",&etapi); double scalepr = 4; double scalepi = 8; { // reference indicator const double x1pr = 0; const double y1pr = -3; const double x2pr = scalepr; const double y2pr = y1pr; const double versatz = 14; const double x1pi = x1pr+versatz; const double y1pi = -3; const double x2pi = x2pr+versatz+scalepi; const double y2pi = y1pi; TArrow *a; a = new TArrow(x1pr,y1pr,x2pr,y2pr,.01,">"); a->SetLineColor(24); a->Draw(); TLatex tl; tl.SetTextSize(20); tl.SetTextFont(4); tl.DrawLatex(x1pr,y2pr-1.2,"p(p) / 1 GeV"); a = new TArrow(x1pi,y1pi,x2pi,y2pi,.01,">"); a->SetLineColor(20); a->Draw(); tl.SetTextSize(20); tl.SetTextFont(4); tl.DrawLatex(x1pi,y2pi-1.2,"p(#pi) / 1 GeV"); } for (int i = 0; i!=maxN; i++) { t->GetEntry(i); const double thetapr = 2*TMath::ATan(TMath::Exp(-TMath::Abs(etapr))); const double thetapi = 2*TMath::ATan(TMath::Exp(-TMath::Abs(etapi))); const double x1=TMath::Abs(vzl0); const double y1=vrl0; const double x2pr=x1+scalepr*ppr*TMath::Cos(thetapr); const double y2pr=y1+scalepr*ppr*TMath::Sin(thetapr); const double x2pi=x1+scalepi*ppi*TMath::Cos(thetapi); const double y2pi=y1+scalepi*ppi*TMath::Sin(thetapi); TArrow *a; a = new TArrow(x1,y1,x2pr,y2pr,.01,">"); a->SetLineColor(24); a->Draw(); a = new TArrow(x1,y1,x2pi,y2pi,.01,">"); a->SetLineColor(20); a->Draw(); TMarker *m = new TMarker(x1,y1,7); m->SetMarkerColor(28); m->Draw(); } }
bool createPlot(TString hname, TString dirname, TFile *V1file, TString relstring1, TFile *V2file, TString relstring2, TCanvas *canvas, int scale) { setTDRStyle(); // don't look at non-zero bin Int_t range_upper = histV1->GetXaxis()->GetLast(); histV1->GetXaxis()->SetRangeUser(1,range_upper); histV2->GetXaxis()->SetRangeUser(1,range_upper); int SetScale = scale; //IF =0 --> No scale applied ('direct' comparison) //IF =1 --> Scale INDIVIDUALLY (scale histograms individually) //IF =2 --> Scale all GLOBALLY (scale all histograms to #tracks=1) //IF =3 --> Scale all GLOBALLY nEVENTS (scale all histos to nEntries in nTracks per Event) bool DrawRatio = true; canvas->cd(); TPad* mainpad = new TPad("mainpad","mainpad",0.0,0.0,1.0,0.8); mainpad->Draw(); mainpad->cd(); // ************ Get name of histos and get histos ************* // TString basename1 = "DQMData/Run "; basename1.Append("1"); TString hnameV1 = basename1; hnameV1.Append(dirname+"/"); hnameV1.Append(hname); if (hname != "vtxNbr"){ hnameV1.Append("_GenTk"); } TH1F * histV1 = (TH1F*)V1file->Get(hnameV1); if ( histV1 == (TH1F*) NULL ) { cout << "histV1 failed on " << hnameV1 << endl << " for file " << V1file->GetName() << endl; exit(1); } TString basename2 = "DQMData/Run "; basename2.Append("1"); TString hnameV2 = basename2; hnameV2.Append(dirname+"/"); hnameV2.Append(hname); if (hname != "vtxNbr"){ hnameV2.Append("_GenTk"); } TH1F * histV2 = (TH1F*)V2file->Get(hnameV2); if ( histV2 == (TH1F*) NULL ) { cout << "histV2 failed on " << hnameV2 << endl << " for file " << V2file->GetName() << endl; exit(1); } //******************* Get histo integrals ***********************// double V1_integral = 1.0; double V2_integral = 1.0; TH1F * hTempV1 = 0; TH1F * hTempV2 = 0; if (SetScale==1){ V1_integral = histV1->Integral(); V2_integral = histV2->Integral(); } else if ( (SetScale==2) || (SetScale==3) ){ if (hname != "NumberOfTracks"){ TString hTempNameV1 = basename1; hTempNameV1.Append("/Tracking/Run summary/TrackParameters/generalTracks/GeneralProperties/NumberOfTracks_GenTk"); hTempV1 = (TH1F*)V1file->Get(hTempNameV1); TString hTempNameV2 = basename2; hTempNameV2.Append("/Tracking/Run summary/TrackParameters/generalTracks/GeneralProperties/NumberOfTracks_GenTk"); hTempV2 = (TH1F*)V2file->Get(hTempNameV2); } else{ hTempV1 = (TH1F*)histV1->Clone("hTempV1"); hTempV2 = (TH1F*)histV2->Clone("hTempV2"); } if (SetScale==2){ V1_integral = hTempV1->GetBinContent(2); V2_integral = hTempV2->GetBinContent(2); std::cout << "The number of single tracks for V1 is " << V1_integral << std::endl; std::cout << "The number of single tracks for V2 is " << V2_integral << std::endl; } else if (SetScale==3){ V1_integral = hTempV1->GetEntries(); V2_integral = hTempV2->GetEntries(); std::cout << "The number of events for V1 is " << V1_integral << std::endl; std::cout << "The number of events for V2 is " << V2_integral << std::endl; } } //*****NORMALIZING V1-V2**************************************** if(V1_integral>V2_integral) { histV1->Scale(V2_integral / V1_integral); histV2->Scale(1); } else if(V2_integral>V1_integral){ histV1->Scale(1); histV2->Scale(V1_integral / V2_integral); } //*****NORMALIZING V1-V2*end*************************************** //***Name the files under comparison*** TString V1_V1run = "Run 1 ("+relstring1+")"; TString V2_V2run = "Run 1 ("+relstring2+")"; histV1->SetName(V1_V1run); histV2->SetName(V2_V2run); TString x_title = ""; if( hname.Contains("vtxNbr")) x_title="Number of Primary Vertices per Event"; histV1->SetLineWidth(5); histV1->SetLineStyle(1); histV1->SetLineColor(kRed); histV1->GetYaxis()->SetLabelSize(0.038); histV2->SetLineWidth(3); histV2->SetLineStyle(1); histV2->SetLineColor(kBlue); if ( hname.Contains("NumberOfTracks",TString::kExact) || hname.Contains("NumberOfGoodTracks",TString::kExact) || hname.Contains("TrackPt",TString::kExact) || hname.Contains("Chi2Prob",TString::kExact) ){ mainpad->SetLogy(1); } else { mainpad->SetLogy(0); } if (hname.Contains("NumberOfGoodTracks",TString::kExact)) { histV1->GetXaxis()->SetRangeUser(0,200); histV2->GetXaxis()->SetRangeUser(0,200); } if (hname.Contains("Chi2oNDF",TString::kExact)) { histV1->GetXaxis()->SetRangeUser(0,10); histV2->GetXaxis()->SetRangeUser(0,10); } if (hname.Contains("vtxNbr")){ histV1->GetXaxis()->SetTitle(x_title); histV1->GetYaxis()->SetTitle("Number of Events"); } if ( hname.Contains("NumberOfTracks",TString::kExact)){ histV1->GetXaxis()->SetRangeUser(125,range_upper); histV2->GetXaxis()->SetRangeUser(125,range_upper); } double max = 0; double V1max = histV1->GetBinContent(histV1->GetMaximumBin()); double V2max = histV2->GetBinContent(histV2->GetMaximumBin()); max = (V1max>V2max) ? V1max : V2max; histV1->SetMaximum(max*(1.1)); histV1->Draw(); histV2->Draw("sames"); mainpad->Update(); TPaveStats *st1 = (TPaveStats*)(histV1->GetListOfFunctions()->FindObject("stats")); st1->SetX1NDC(0.77); st1->SetY1NDC(0.80); st1->SetX2NDC(0.98); st1->SetY2NDC(0.97); Double_t defaulth = st1->GetY2NDC() - st1->GetY1NDC(); Double_t gaph = 0.02; TPaveStats *st2 = (TPaveStats*)(histV2->GetListOfFunctions()->FindObject("stats")); st2->SetX1NDC(0.77); st2->SetY1NDC(st1->GetY1NDC() - 1.0*defaulth - gaph); st2->SetX2NDC(0.98); st2->SetY2NDC(st1->GetY1NDC() - gaph); TLegend *leg = new TLegend(0.32,0.86,0.76,0.97); leg->SetTextSize(0.042); leg->SetTextFont(42); leg->SetFillColor(10); leg->SetBorderSize(1); // no frame, no shadow leg->AddEntry(histV1, V1_V1run, "L" ); leg->AddEntry(histV2, V2_V2run, "L" ); leg->Draw("SAME"); // Draw ratio histogram if (DrawRatio){ canvas->cd(); TPad* respad = new TPad("respad","respad",0.0,0.78,1.0,0.95); respad->SetTopMargin(1.05); respad->Draw(); respad->cd(); TH1F* hratio = (TH1F*) histV2->Clone("hratio"); hratio->Divide(histV1); hratio->SetMaximum(hratio->GetMaximum()*1.01); //if (hratio->GetMinimum()==0.0) hratio->SetMinimum(1.0/hratio->GetMaximum()); hratio->SetMinimum(1.0/hratio->GetMaximum()); hratio->GetYaxis()->SetLabelSize(0.1); hratio->GetYaxis()->SetRangeUser(0,2); hratio->GetXaxis()->SetLabelSize(0); hratio->GetXaxis()->SetTitleSize(0); hratio->GetYaxis()->SetTitleSize(0.22); hratio->GetYaxis()->SetTitleOffset(0.26); hratio->GetYaxis()->SetLabelSize(0.2); hratio->GetYaxis()->SetNdivisions(5); hratio->GetYaxis()->SetTitle("PM/SM"); hratio->Draw(); } // Compare parameters of histograms double Entries1 = histV1->GetEntries(); double Entries2 = histV2->GetEntries(); if (Entries1 != Entries2) { std::cout<<" Difference in # of ENTRIES for " <<hname<< std::endl; std::cout<<"\t Entries1 = " << Entries1 << "\t Entries2 = " << Entries2 << std::endl; } double Mean1 = histV1->GetMean(); double Mean2 = histV2->GetMean(); if (Mean1 != Mean2) { std::cout<<" Difference in MEANS for " <<hname<< std::endl; std::cout<<"\t Mean1 = " << Mean1 << "\t Mean2 = " << Mean2 << std::endl; } double RMS1 = histV1->GetRMS(); double RMS2 = histV2->GetRMS(); if (RMS1 != RMS2) { std::cout<<" Difference in RMS for " <<hname<< std::endl; std::cout<<"\t RMS1 = " << RMS1 << "\t RMS2 = " << RMS2 << std::endl; } TString filename = hname; if (hname.Contains("vtxNbr")){ filename = "NumberOfPrimaryVertices"; } if (dirname.Contains("highPurityTracks/pt_1/GeneralProperties",TString::kExact)) filename.Prepend("RunComparison/GoodTracks_"); else filename.Prepend("RunComparison/"); filename.Append(".png"); canvas->Print(filename); if ( histV1 ) {histV1->Delete();} if ( histV2 ) {histV2->Delete();} if ( hTempV1 ) {hTempV1->Delete();} if ( hTempV2 ) {hTempV2->Delete();} return true; }
void phi2(double pt1min, double pt2min, double METmin){ TLegend* leg = new TLegend(0.13,0.6,0.87,0.87); leg->SetNColumns(3); leg->SetBorderSize(0); leg->SetFillStyle(0); gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); TFile *data = TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ"); TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ"); TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ"); TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ"); TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ"); TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ"); TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ"); TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ"); TFile *bkg1 = TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./25ns_2246inv_v3/GJets.root","READ"); TFile *bkg4 = TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./25ns_2246inv_v3/QCD.root","READ"); TFile *bkg6 = TFile::Open("./25ns_2246inv_v3/VH.root","READ"); TFile *bkg7 = TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ"); TFile *bkg8 = TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ"); TFile *bkg9 = TFile::Open("./25ns_2246inv_v3/TGJets.root","READ"); TFile *bkg10 = TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ"); TFile *bkg11 = TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ"); TFile *bkg12 = TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ"); TTree *tree_data = (TTree*) data->Get("DiPhotonTree"); TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree"); TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree"); TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree"); TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree"); TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree"); TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree"); TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree"); TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree"); TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree"); TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree"); TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree"); TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree"); TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree"); TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree"); TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree"); TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree"); TTree *tree_bkg10 = (TTree*) bkg10->Get("DiPhotonTree"); TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree"); TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree"); TCanvas *c1 = new TCanvas("c1","",500,600); TPad *mainPad = new TPad("mainPad","",0,0.3,1,1); TPad *smallPad = new TPad("smallPad","",0,0.05,1,0.3); mainPad->SetBottomMargin(0.015); smallPad->SetTopMargin(0.05); smallPad->SetBottomMargin(0.25); c1->cd(); mainPad->Draw(); mainPad->cd(); gPad->SetLogy(); TCut mggmax = "mgg<180"; TCut mggmin = "mgg>100"; TCut pt1Cut = Form("pt1/mgg>%lf",pt1min); TCut pt2Cut = Form("pt2/mgg>%lf",pt2min); TCut METCut = Form("t1pfmet>%lf",METmin); TCut eveto1 = "eleveto1 == 1"; TCut eveto2 = "eleveto2 == 1"; TCut eveto = eveto1 && eveto2; TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))"; TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))"; tree_data->Draw("(phi2)>>hdata(20,-4,4)",(mggmax && mggmin && metF&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata"); tree_sig1->Draw("(phi2)>>h1(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("(phi2)>>h2(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("(phi2)>>h3(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("(phi2)>>h4(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("(phi2)>>h5(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); tree_sig6->Draw("(phi2)>>h6(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6"); tree_sig7->Draw("(phi2)>>h7(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7"); tree_bkg1->Draw("(phi2)>>hbkg1(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("(phi2)>>hbkg2(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("(phi2)>>hbkg3(20,-4,4)","weight"*(mggmin && mggmax && genmatch&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("(phi2)>>hbkg4(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); //weight also on BR = 0.002 if using the 50ns samples TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4"); tree_bkg5->Draw("(phi2)>>hbkg5(20,-4,4)","weight"*(mggmin && mggmax && genmatch&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("(phi2)>>hbkg6(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6"); tree_bkg7->Draw("(phi2)>>hbkg7(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7"); tree_bkg8->Draw("(phi2)>>hbkg8(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8"); tree_bkg9->Draw("(phi2)>>hbkg9(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9"); tree_bkg10->Draw("(phi2)>>hbkg10(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10"); tree_bkg11->Draw("(phi2)>>hbkg11(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11"); tree_bkg12->Draw("(phi2)>>hbkg12(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12"); hdata->SetMarkerColor(kBlack); hdata->SetMarkerStyle(20); hdata->SetLineColor(kBlack); h1->SetLineColor(kRed+3); h2->SetLineColor(kRed+1); h3->SetLineColor(kRed); h4->SetLineColor(kPink+2); h5->SetLineColor(kPink+4); h6->SetLineColor(kPink+7); h7->SetLineColor(kMagenta+2); h1->SetLineWidth(2); h2->SetLineWidth(2); h3->SetLineWidth(2); h4->SetLineWidth(2); h5->SetLineWidth(2); h6->SetLineWidth(2); h7->SetLineWidth(2); THStack *hs= new THStack("hs",""); hbkg7->SetFillColor(kGreen+2); hbkg6->SetFillColor(kGreen); hbkg8->SetFillColor(kYellow); hbkg4->SetFillColor(kOrange); hbkg9->SetFillColor(kOrange+7); hbkg10->SetFillColor(kOrange+4); hbkg11->SetFillColor(kCyan); hbkg12->SetFillColor(kCyan+1); hbkg5->SetFillColor(kBlue+2); hbkg2->SetFillColor(kBlue); hbkg3->SetFillColor(kMagenta-2); hbkg1->SetFillColor(kViolet); hbkg1->SetLineColor(kBlack); hbkg2->SetLineColor(kBlack); hbkg3->SetLineColor(kBlack); hbkg4->SetLineColor(kBlack); hbkg5->SetLineColor(kBlack); hbkg6->SetLineColor(kBlack); hbkg7->SetLineColor(kBlack); hbkg8->SetLineColor(kBlack); hbkg9->SetLineColor(kBlack); hbkg10->SetLineColor(kBlack); hbkg11->SetLineColor(kBlack); hbkg12->SetLineColor(kBlack); hs->Add(hbkg7); hs->Add(hbkg6); hs->Add(hbkg8); hs->Add(hbkg4); hs->Add(hbkg9); hs->Add(hbkg10); hs->Add(hbkg11); hs->Add(hbkg12); hs->Add(hbkg2); hs->Add(hbkg5); hs->Add(hbkg3); hs->Add(hbkg1); TH1F *hsum = (TH1F*)hbkg1->Clone("hsum"); hsum->Add(hbkg2); hsum->Add(hbkg3); hsum->Add(hbkg4); hsum->Add(hbkg5); hsum->Add(hbkg6); hsum->Add(hbkg7); hsum->Add(hbkg8); hsum->Add(hbkg9); hsum->Add(hbkg10); hsum->Add(hbkg11); hsum->Add(hbkg12); hs->SetMaximum(1000000); hs->SetMinimum(0.1); hs->SetTitle(""); hs->Draw("HIST"); hsum->SetMarkerStyle(1); hsum->SetFillColor(kGray+3); hsum->SetFillStyle(3002); hsum->Draw("same e2"); h2->Draw("same hist"); h3->Draw("same hist"); h4->Draw("same hist"); h1->Draw("same hist"); h5->Draw("same hist"); h6->Draw("same hist"); h7->Draw("same hist"); hdata->Draw("same E1"); hs->GetXaxis()->SetLabelOffset(999); hs->GetYaxis()->SetTitle("Events/0.4"); hs->GetYaxis()->SetTitleOffset(1.2); gPad->Modified(); leg->AddEntry(hdata,"Data","lep"); leg->AddEntry(hbkg1,"#gamma #gamma","f"); leg->AddEntry(h1,"m_{Z'} = 600 GeV","l"); leg->AddEntry(hbkg2,"Drell Yann","f"); leg->AddEntry(hbkg3,"#gamma + Jets","f"); leg->AddEntry(h2,"m_{Z'} = 800 GeV","l"); leg->AddEntry(hbkg5,"QCD","f"); leg->AddEntry(hbkg4,"ggH","f"); leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); leg->AddEntry(hbkg6,"VH","f"); leg->AddEntry(hbkg7,"ttH","f"); leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); leg->AddEntry(hbkg8,"VBF H","f"); leg->AddEntry(hbkg9,"t + #gamma + Jets","f"); leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); leg->AddEntry(hbkg10,"tt + #gamma +Jets","f"); leg->AddEntry(hbkg11,"#gamma+W","f"); leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); leg->AddEntry(hbkg12,"#gamma+Z","f"); leg->AddEntry(hsum,"Bkg uncertainty","f"); leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); leg->Draw("same"); c1->cd(); smallPad->Draw(); smallPad->cd(); TGraphErrors *gr = new TGraphErrors(0); double integralData=hdata->Integral(); double integralBKG=hsum->Integral(); double error, ratio; for(int w=1; w<20; w++){ if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){ gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w))); ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w)); error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w)); std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl; gr->SetPointError(w, hdata->GetBinWidth(w)/2,error); }else{ gr->SetPoint(w, hdata->GetBinCenter(w),10); } } gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); gr->GetHistogram()->SetMaximum(2); gr->GetHistogram()->SetMinimum(0.1); gStyle->SetTextSize(14); gROOT->ForceStyle(); gr->GetXaxis()->SetLabelFont(43); gr->GetXaxis()->SetLabelSize(15); gr->GetYaxis()->SetLabelFont(43); gr->GetYaxis()->SetLabelSize(15); gr->GetXaxis()->SetLimits(-4,4); gPad->SetGrid(); gStyle->SetStripDecimals(kTRUE); gr->SetMarkerStyle(20); gr->SetMarkerSize(0.7); gr->Draw("AZP"); gr->GetXaxis()->SetTitle("#phi_{2}"); gr->GetXaxis()->SetTitleSize(0.1); gr->GetYaxis()->SetTitleSize(0.1); gr->GetYaxis()->SetNdivisions(505); gr->GetXaxis()->SetTitleOffset(1); gr->GetYaxis()->SetTitle("Data/MC"); gr->GetYaxis()->SetTitleOffset(0.4); gr->SetTitle(""); smallPad->Update(); TF1* line = new TF1("line","1",-4,4); line->SetLineColor(kRed); line->SetLineWidth(2); line->Draw("L same"); gr->Draw("ZP SAME"); if(pt1min==0 && pt2min == 0 && METmin == 0){ c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/phi2.png"); c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/phi2.pdf"); } if(pt1min==0.65 && pt2min == 0.25){ c1->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/phi2_optcuts_MET%.0lf.png",METmin)); c1->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/phi2_optcuts_MET%.0lf.pdf",METmin)); } }
void DeltaPhi(double pt1_cutIN,double pt2_cutIN,double MET_cutIN, double DPHI_cutIN){ cout<<"#### DeltaPhi(MET,H) #####"<<endl; gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); TLegend* leg = new TLegend(0.13,0.6,0.67,0.87); leg->SetNColumns(2); leg->SetBorderSize(0); leg->SetFillStyle(0); TLegend* leg_norm = new TLegend(0.20,0.5,0.74,0.87); leg_norm->SetNColumns(2); leg_norm->SetBorderSize(0); leg_norm->SetFillStyle(0); TCanvas *c1 = new TCanvas("c1","",500,600); TPad *mainPad = new TPad("mainPad","",0,0.3,1,1); TPad *smallPad = new TPad("smallPad","",0,0.05,1,0.3); mainPad->SetBottomMargin(0.015); smallPad->SetTopMargin(0.05); smallPad->SetBottomMargin(0.25); c1->cd(); mainPad->Draw(); mainPad->cd(); TCut mggmax = "mgg<180"; TCut mggmin = "mgg>100"; TCut mggblind = "((mgg<115)||(mgg>135))"; TCut eveto1 = "eleveto1 == 1"; TCut eveto2 = "eleveto2 == 1"; TCut eveto = eveto1 && eveto2; TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))"; TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))"; TCut pt1cut = Form("pt1/mgg>%lf",pt1_cutIN); TCut pt2cut = Form("pt2/mgg>%lf",pt2_cutIN); TCut METcutD = Form("t1pfmetCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1)>%lf",MET_cutIN); TCut METcut = Form("t1pfmetCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0)>%lf",MET_cutIN); TCut DPHIcut = Form("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>%lf",DPHI_cutIN); TCut DPHIcutD = Form("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1))>%lf",DPHI_cutIN); TFile *data = TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ"); TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ"); TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ"); TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ"); TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ"); TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ"); TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ"); TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ"); TFile *bkg1 = TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./25ns_2246inv_v3/GJets.root","READ"); TFile *bkg4 = TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./25ns_2246inv_v3/QCD.root","READ"); TFile *bkg6 = TFile::Open("./25ns_2246inv_v3/VH.root","READ"); TFile *bkg7 = TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ"); TFile *bkg8 = TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ"); TFile *bkg9 = TFile::Open("./25ns_2246inv_v3/TGJets.root","READ"); TFile *bkg10 = TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ"); TFile *bkg11 = TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ"); TFile *bkg12 = TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ"); cout<<"check1"<<endl; TTree *tree_data = (TTree*) data->Get("DiPhotonTree"); TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree"); TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree"); TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree"); TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree"); TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree"); TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree"); TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree"); TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree"); TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree"); TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree"); TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree"); TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree"); TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree"); TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree"); TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree"); TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree"); TTree *tree_bkg10= (TTree*) bkg10->Get("DiPhotonTree"); TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree"); TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree"); cout<<"check2"<<endl; tree_data->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1))>>hdata(15,0,3.5)",(mggmax && mggmin && metF && eveto && pt1cut && pt2cut && METcutD&& DPHIcutD)); TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata"); hdata->SetMarkerColor(kBlack); hdata->SetMarkerStyle(20); hdata->SetLineColor(kBlack); tree_sig1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h1(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h2(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h3(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h4(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h5(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); tree_sig6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h6(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6"); tree_sig7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h7(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7"); tree_bkg1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg1(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg2(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg3(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg4(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4"); tree_bkg5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg5(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg6(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6"); tree_bkg7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg7(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7"); tree_bkg8->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg8(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8"); tree_bkg9->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg9(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9"); tree_bkg10->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg10(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10"); tree_bkg11->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg11(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11"); tree_bkg12->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg12(15,0,3.5)","weight*(weight>0.)"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12"); cout<<"check3"<<endl; /* h1->Scale(0.00009338); h2->Scale(0.00010348); h3->Scale(0.00008394); h4->Scale(0.00006352); h5->Scale(0.00004712); h6->Scale(0.00003020); h7->Scale(0.00000972); */ h1->SetLineColor(kRed+3); h2->SetLineColor(kRed+1); h3->SetLineColor(kRed); h4->SetLineColor(kPink+2); h5->SetLineColor(kPink+4); //only for 15ns samples h6->SetLineColor(kPink+7); //only for 15ns samples h7->SetLineColor(kMagenta+2); //only for 15ns samples h1->SetLineWidth(2); h2->SetLineWidth(2); h3->SetLineWidth(2); h4->SetLineWidth(2); h5->SetLineWidth(2); //only for 15ns samples h6->SetLineWidth(2); //only for 15ns samples h7->SetLineWidth(2); //only for 15ns samples THStack *hs=new THStack("hs",""); hbkg7->SetFillColor(kGreen+2); hbkg6->SetFillColor(kGreen); hbkg8->SetFillColor(kYellow); hbkg4->SetFillColor(kOrange); hbkg9->SetFillColor(kOrange+7); hbkg10->SetFillColor(kOrange+4); hbkg11->SetFillColor(kCyan); hbkg12->SetFillColor(kCyan+1); hbkg5->SetFillColor(kBlue+2); hbkg2->SetFillColor(kBlue); hbkg3->SetFillColor(kMagenta-2); hbkg1->SetFillColor(kViolet); hbkg1->SetLineColor(kBlack); hbkg2->SetLineColor(kBlack); hbkg3->SetLineColor(kBlack); hbkg4->SetLineColor(kBlack); hbkg5->SetLineColor(kBlack); hbkg6->SetLineColor(kBlack); hbkg7->SetLineColor(kBlack); hbkg8->SetLineColor(kBlack); hbkg9->SetLineColor(kBlack); hbkg10->SetLineColor(kBlack); hbkg11->SetLineColor(kBlack); hbkg12->SetLineColor(kBlack); hs->Add(hbkg7); hs->Add(hbkg6); hs->Add(hbkg8); hs->Add(hbkg4); hs->Add(hbkg9); hs->Add(hbkg10); hs->Add(hbkg11); hs->Add(hbkg12); hs->Add(hbkg2); hs->Add(hbkg5); hs->Add(hbkg3); hs->Add(hbkg1); cout<<"check4"<<endl; TH1F *hsum = (TH1F*)hbkg1->Clone("hsum"); hsum->Add(hbkg2); hsum->Add(hbkg3); hsum->Add(hbkg4); hsum->Add(hbkg9); hsum->Add(hbkg10); hsum->Add(hbkg11); hsum->Add(hbkg12); hsum->Add(hbkg5); hsum->Add(hbkg6); hsum->Add(hbkg7); hsum->Add(hbkg8); hdata->SetMaximum(5000); // hs->SetMinimum(0.0001); hdata->SetTitle(""); hdata->Draw("e1"); hsum->SetMarkerStyle(1); hsum->SetFillColor(kGray+3); hsum->SetFillStyle(3002); hs->Draw("same hist"); hsum->Draw("same e2"); h2->Draw("same hist"); h3->Draw("same hist"); h4->Draw("same hist"); h1->Draw("same hist"); h5->Draw("same hist"); //only for 15ns samples h6->Draw("same hist"); //only for 15ns samples h7->Draw("same hist"); //only for 15ns samples hdata->Draw("same e1"); hdata->GetXaxis()->SetLabelOffset(999); hdata->GetYaxis()->SetTitle("Events/0.4"); hdata->GetYaxis()->SetTitleOffset(1.6); hdata->GetYaxis()->SetTitle("Events/0.23 GeV"); gPad->Modified(); /*leg->AddEntry(h1,"m_{#chi} = 1 GeV","l"); leg->AddEntry(h2,"m_{#chi} = 10 GeV","l"); leg->AddEntry(h3,"m_{#chi} = 100 GeV","l"); leg->AddEntry(h4,"m_{#chi} = 1000 GeV","l");*/ leg->AddEntry(hdata,"Data","elp"); // leg->AddEntry(h1,"m_{Z'} = 600 GeV","l"); leg->AddEntry(hbkg1,"#gamma #gamma","f"); // leg->AddEntry(h2,"m_{Z'} = 800 GeV","l"); leg->AddEntry(hbkg2,"Drell Yann","f"); // leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); leg->AddEntry(hbkg3,"#gamma + Jets","f"); // leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); leg->AddEntry(hbkg5,"QCD","f"); // leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 15ns samples leg->AddEntry(hbkg4,"ggH","f"); // leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); //only for 15ns samples leg->AddEntry(hbkg6,"VH","f"); // leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples leg->AddEntry(hbkg7,"ttH","f"); leg->AddEntry(hbkg8,"VBF H","f"); leg->AddEntry(hbkg9,"t + #gamma + Jets","f"); leg->AddEntry(hbkg10,"tt + #gamma +Jets","f"); leg->AddEntry(hbkg11,"#gamma+W","f"); leg->AddEntry(hbkg12,"#gamma+Z","f"); leg->AddEntry(hsum,"Bkg uncertainty","f"); leg->Draw("same"); cout<<"check5"<<endl; gStyle->SetOptStat(0); c1->cd(); smallPad->Draw(); smallPad->cd(); TGraphErrors *gr = new TGraphErrors(0); double integralData=hdata->Integral(); double integralBKG=hsum->Integral(); double error, ratio; for(int w=1; w<15; w++){ if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){ gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w))); ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w)); error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w)); std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl; gr->SetPointError(w, hdata->GetBinWidth(w)/2,error); }else{ gr->SetPoint(w, hdata->GetBinCenter(w),10); } } gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); gr->GetHistogram()->SetMaximum(2); gr->GetHistogram()->SetMinimum(0.1); gStyle->SetTextSize(14); gROOT->ForceStyle(); gr->GetXaxis()->SetLabelFont(43); gr->GetXaxis()->SetLabelSize(15); gr->GetYaxis()->SetLabelFont(43); gr->GetYaxis()->SetLabelSize(15); gr->GetXaxis()->SetLimits(0,3.5); gPad->SetGrid(); gStyle->SetStripDecimals(kTRUE); gr->SetMarkerStyle(20); gr->SetMarkerSize(0.7); gr->Draw("AZP"); gr->GetXaxis()->SetTitle("|#Delta#phi(#gamma#gamma,E^{miss}_{T})|"); gr->GetXaxis()->SetTitleSize(0.1); gr->GetYaxis()->SetTitleSize(0.1); gr->GetYaxis()->SetNdivisions(505); gr->GetXaxis()->SetTitleOffset(1); gr->GetYaxis()->SetTitle("Data/MC"); gr->GetYaxis()->SetTitleOffset(0.4); gr->SetTitle(""); smallPad->Update(); TF1* line = new TF1("line","1",0,3.5); line->SetLineColor(kRed); line->SetLineWidth(2); line->Draw("L same"); gr->Draw("ZP SAME"); TCanvas *c2 = new TCanvas("c2","",500,500); tree_sig1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h1_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h1_norm =(TH1F*)gPad->GetPrimitive("h1_norm"); tree_sig2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h2_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h2_norm =(TH1F*)gPad->GetPrimitive("h2_norm"); tree_sig3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h3_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h3_norm =(TH1F*)gPad->GetPrimitive("h3_norm"); tree_sig4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h4_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h4_norm =(TH1F*)gPad->GetPrimitive("h4_norm"); tree_sig5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h5_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h5_norm =(TH1F*)gPad->GetPrimitive("h5_norm"); tree_sig6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h6_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h6_norm =(TH1F*)gPad->GetPrimitive("h6_norm"); tree_sig7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h7_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h7_norm =(TH1F*)gPad->GetPrimitive("h7_norm"); tree_bkg1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg1_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg1_norm =(TH1F*)gPad->GetPrimitive("hbkg1_norm"); tree_bkg2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg2_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg2_norm =(TH1F*)gPad->GetPrimitive("hbkg2_norm"); tree_bkg3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg3_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg3_norm =(TH1F*)gPad->GetPrimitive("hbkg3_norm"); tree_bkg4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg4_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg4_norm =(TH1F*)gPad->GetPrimitive("hbkg4_norm"); tree_bkg5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg5_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg5_norm =(TH1F*)gPad->GetPrimitive("hbkg5_norm"); tree_bkg6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg6_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg6_norm =(TH1F*)gPad->GetPrimitive("hbkg6_norm"); tree_bkg7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg7_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg7_norm =(TH1F*)gPad->GetPrimitive("hbkg7_norm"); tree_bkg8->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg8_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg8_norm =(TH1F*)gPad->GetPrimitive("hbkg8_norm"); tree_bkg9->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg9_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg9_norm =(TH1F*)gPad->GetPrimitive("hbkg9_norm"); tree_bkg10->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg10_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg10_norm =(TH1F*)gPad->GetPrimitive("hbkg10_norm"); tree_bkg11->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg11_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg11_norm =(TH1F*)gPad->GetPrimitive("hbkg11_norm"); tree_bkg12->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg12_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg12_norm =(TH1F*)gPad->GetPrimitive("hbkg12_norm"); for(int i = 0; i<26;i++){ if(hbkg1_norm->GetBinContent(i) < 0.) hbkg1_norm->SetBinContent(i,0.); if(hbkg2_norm->GetBinContent(i) < 0.) hbkg2_norm->SetBinContent(i,0.); if(hbkg3_norm->GetBinContent(i) < 0.) hbkg3_norm->SetBinContent(i,0.); if(hbkg4_norm->GetBinContent(i) < 0.) hbkg4_norm->SetBinContent(i,0.); if(hbkg5_norm->GetBinContent(i) < 0.) hbkg5_norm->SetBinContent(i,0.); if(hbkg6_norm->GetBinContent(i) < 0.) hbkg6_norm->SetBinContent(i,0.); if(hbkg7_norm->GetBinContent(i) < 0.) hbkg7_norm->SetBinContent(i,0.); if(hbkg8_norm->GetBinContent(i) < 0.) hbkg8_norm->SetBinContent(i,0.); if(hbkg9_norm->GetBinContent(i) < 0.) hbkg9_norm->SetBinContent(i,0.); if(hbkg10_norm->GetBinContent(i) < 0.) hbkg10_norm->SetBinContent(i,0.); if(hbkg11_norm->GetBinContent(i) < 0.) hbkg11_norm->SetBinContent(i,0.); if(hbkg12_norm->GetBinContent(i) < 0.) hbkg12_norm->SetBinContent(i,0.); } double norm = 1./h1_norm->Integral(); h1_norm->Scale(norm); norm = 1./h2_norm->Integral(); h2_norm->Scale(norm); norm = 1./h3_norm->Integral(); h3_norm->Scale(norm); norm = 1./h4_norm->Integral(); h4_norm->Scale(norm); norm = 1./h5_norm->Integral(); //only for 50ns samples h5_norm->Scale(norm); //only for 50ns samples norm = 1./h6_norm->Integral(); //only for 50ns samples h6_norm->Scale(norm); //only for 50ns samples norm = 1./h7_norm->Integral(); //only for 50ns samples h7_norm->Scale(norm); //only for 50ns samples norm = 1./hbkg1_norm->Integral(); hbkg1_norm->Scale(norm); norm = 1./hbkg2_norm->Integral(); hbkg2_norm->Scale(norm); norm = 1./hbkg3_norm->Integral(); hbkg3_norm->Scale(norm); norm = 1./hbkg4_norm->Integral(); hbkg4_norm->Scale(norm); norm = 1./hbkg5_norm->Integral(); hbkg5_norm->Scale(norm); norm = 1./hbkg6_norm->Integral(); hbkg6_norm->Scale(norm); norm = 1./hbkg7_norm->Integral(); hbkg7_norm->Scale(norm); norm = 1./hbkg8_norm->Integral(); hbkg8_norm->Scale(norm); norm = 1./hbkg9_norm->Integral(); hbkg9_norm->Scale(norm); norm = 1./hbkg10_norm->Integral(); hbkg10_norm->Scale(norm); norm = 1./hbkg11_norm->Integral(); hbkg11_norm->Scale(norm); norm = 1./hbkg12_norm->Integral(); hbkg12_norm->Scale(norm); h1_norm->SetLineColor(kRed+3); h2_norm->SetLineColor(kRed+1); h3_norm->SetLineColor(kRed); h4_norm->SetLineColor(kPink+2); h5_norm->SetLineColor(kPink+4); //only for 25ns samples h6_norm->SetLineColor(kPink+7); //only for 25ns samples h7_norm->SetLineColor(kMagenta+2); //only for 25ns samples h1_norm->SetLineWidth(2); h2_norm->SetLineWidth(2); h3_norm->SetLineWidth(2); h4_norm->SetLineWidth(2); h5_norm->SetLineWidth(2); //only for 25ns samples h6_norm->SetLineWidth(2); //only for 25ns samples h7_norm->SetLineWidth(2); //only for 25ns samples hbkg7_norm->SetLineColor(kGreen+2); hbkg6_norm->SetLineColor(kGreen); hbkg8_norm->SetLineColor(kYellow); hbkg4_norm->SetLineColor(kOrange); hbkg9_norm->SetLineColor(kOrange+7); hbkg10_norm->SetLineColor(kOrange+4); hbkg11_norm->SetLineColor(kCyan); hbkg12_norm->SetLineColor(kCyan+1); hbkg5_norm->SetLineColor(kBlue+3); hbkg2_norm->SetLineColor(kBlue); hbkg3_norm->SetLineColor(kMagenta-2); hbkg1_norm->SetLineColor(kViolet); hbkg1_norm->SetFillStyle(0); hbkg2_norm->SetFillStyle(0); hbkg3_norm->SetFillStyle(0); hbkg4_norm->SetFillStyle(0); hbkg5_norm->SetFillStyle(0); hbkg6_norm->SetFillStyle(0); hbkg7_norm->SetFillStyle(0); hbkg8_norm->SetFillStyle(0); hbkg9_norm->SetFillStyle(0); hbkg10_norm->SetFillStyle(0); hbkg11_norm->SetFillStyle(0); hbkg12_norm->SetFillStyle(0); h1_norm->SetTitle(""); h1_norm->SetMaximum(1); h1_norm->SetMinimum(0.001); h1_norm->Draw("HIST"); hbkg1_norm->Draw("same HIST"); hbkg2_norm->Draw("same HIST"); hbkg3_norm->Draw("same HIST"); hbkg5_norm->Draw("same HIST"); hbkg4_norm->Draw("same HIST"); hbkg6_norm->Draw("same HIST"); hbkg7_norm->Draw("same HIST"); hbkg8_norm->Draw("same HIST"); hbkg9_norm->Draw("same HIST"); hbkg10_norm->Draw("same HIST"); hbkg11_norm->Draw("same HIST"); hbkg12_norm->Draw("same HIST"); h1_norm->Draw("same hist"); h2_norm->Draw("same hist"); h3_norm->Draw("same hist"); h4_norm->Draw("same hist"); h5_norm->Draw("same hist"); h6_norm->Draw("same hist"); h7_norm->Draw("same hist"); h1_norm->GetXaxis()->SetTitle("|#Delta#phi(#gamma#gamma,E_{T}^{miss})|"); h1_norm->GetYaxis()->SetTitle("Normalized events"); h1_norm->GetYaxis()->SetTitleOffset(1.2); gPad->Modified(); gStyle->SetOptStat(0); //int iPos =0; // CMS_lumi(p1,true,iPos,true); // CMS_lumi(p2,true,iPos,true); leg_norm->AddEntry(h1_norm,"m_{Z'} = 600 GeV","l"); leg_norm->AddEntry(hbkg1_norm,"#gamma #gamma","l"); leg_norm->AddEntry(h2_norm,"m_{Z'} = 800 GeV","l"); leg_norm->AddEntry(hbkg2_norm,"Drell Yann","l"); leg_norm->AddEntry(h3_norm,"m_{Z'} = 1000 GeV","l"); leg_norm->AddEntry(hbkg3_norm,"#gamma + Jets","l"); leg_norm->AddEntry(h4_norm,"m_{Z'} = 1200 GeV","l"); leg_norm->AddEntry(hbkg5_norm,"QCD","l"); leg_norm->AddEntry(h5_norm,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples leg_norm->AddEntry(hbkg4_norm,"ggH","l"); leg_norm->AddEntry(h6_norm,"m_{Z'} = 1700 GeV","l"); //only for 25ns samples leg_norm->AddEntry(hbkg6_norm,"VH","l"); leg_norm->AddEntry(h7_norm,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples leg_norm->AddEntry(hbkg7_norm,"ttH","l"); leg_norm->AddEntry(hbkg8_norm,"VBF H","l"); leg_norm->AddEntry(hbkg9_norm,"t + #gamma + Jets","l"); leg_norm->AddEntry(hbkg10_norm,"tt + #gamma +Jets","l"); leg_norm->AddEntry(hbkg11_norm,"#gamma+W","l"); leg_norm->AddEntry(hbkg12_norm,"#gamma+Z","l"); leg_norm->Draw("same"); if(pt1_cutIN==0. && pt2_cutIN == 0. && MET_cutIN == 0.){ c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0.png"); c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0.pdf"); c2->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0_norm.png"); c2->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0_norm.pdf"); } }
void plotFinalEnergy() { gStyle->SetStatH(0.3); gStyle->SetStatY(0.88); gStyle->SetStatW(0.3); char canTitle[180]; sprintf(canTitle,"Energy at Terminal Interaction (10000 tries)"); TCanvas *canFinalEnergy = new TCanvas("canFinalEnergy","Final Energy",800,800); TPaveLabel *pl = new TPaveLabel(0.1,0.96,0.9,0.99,canTitle,"br NDC"); pl->SetBorderSize(0); pl->SetFillColor(0); pl->SetFillStyle(0); pl->Draw(); TPad *subCanFinalEnergy = new TPad("subCanFinalEnergy","",0,0,1,0.95); subCanFinalEnergy->Draw(); subCanFinalEnergy->cd(); subCanFinalEnergy->Divide(2,4); subCanFinalEnergy->Update(); // gStyle->SetOptStat(0); char fileName[80]; char histTitle[80]; char theEnergies[4][5]={"1e9","1e10","1e11","1e12"}; int theColours[2][3]={{50,42,46},{40,30,38}}; for(int isATau=0;isATau<=1;isATau++) { for(int i=0;i<4;i++) { sprintf(fileName, "newest%sFile%sIce.root",getParticleNameCaps(isATau),theEnergies[i]); sprintf(histTitle,"%s -- %s GeV",getParticleNameCaps(isATau),theEnergies[i]); TFile *fp = new TFile(fileName); TH1F *histEnergy = new TH1F("histEnergy",histTitle,100,7.5,12.5); TH1F *histEnergy2 = new TH1F("histEnergy2","Last Energy",100,7.5,12.5); TH1F *histEnergy3 = new TH1F("histEnergy3","Last Energy",100,7.5,12.5); TTree *theTree = (TTree*) fp->Get("theTree"); cout << theTree->GetEntries() << endl; subCanFinalEnergy->cd((2*i)+isATau+1); gPad->SetTopMargin(0.12); // gPad->SetBottomMargin(0.2); histEnergy->SetLineWidth(3); histEnergy->SetLineColor(theColours[isATau][0]); histEnergy2->SetLineWidth(3); histEnergy2->SetLineColor(theColours[isATau][1]); histEnergy3->SetLineWidth(3); histEnergy3->SetLineColor(theColours[isATau][2]); theTree->Draw("log10(stepIntEnergy)>>histEnergy","stepIntType>=4"); // histEnergy->GetXaxis()->SetTitle("IntType (#mus)"); // histEnergy->GetXaxis()->SetBinLabel(2,"Bremsstrahlung"); // histEnergy->GetXaxis()->SetBinLabel(3,"Pair Production"); // histEnergy->GetXaxis()->SetBinLabel(4,"Photonuclear"); // histEnergy->GetXaxis()->SetLabelSize(0.09); // histEnergy->GetXaxis()->SetLabelOffset(0.02); theTree->Draw("log10(stepIntEnergy)>>histEnergy2","stepIntType==4"); theTree->Draw("log10(stepIntEnergy)>>histEnergy3","stepIntType==5"); histEnergy->DrawCopy(); if(histEnergy2->GetEntries()) histEnergy2->DrawCopy("same"); if(histEnergy3->GetEntries()) histEnergy3->DrawCopy("same"); if(histEnergy->GetEntries()) gPad->SetLogy(); if(i==0) { TLegend *leg = new TLegend(0.7,0.2,0.9,0.6); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->AddEntry(histEnergy2,"Decay","l"); leg->AddEntry(histEnergy3,"Weak (CC)","l"); leg->AddEntry(histEnergy,"Either","l"); leg->Draw("same"); } } } for(int i=0;i<8;i++) { // cout << "Doing title "<< i+1 << endl; subCanFinalEnergy->cd(i+1); sortOutTitle(0.07); } // gStyle->SetOptStat(1110); }
//----------------------------------------// // Plot ZHS and G4 on same figure //----------------------------------------// void plotWithRatio(vector<TString> f_zhs, vector<TString> f_g4, TString p_zhs, TString p_g4, vector<TString> savenames) { // Make canvas TCanvas* c = makeCanvas("c"); //c->SetLogy(); // Make a legend TLegend* leg = makeLegend(0.15,0.3,0.79,0.92); leg->SetTextSize(0.055); // Titles TString xtitle = "time [ns]"; TString ytitle = "A [Vs/m]"; // Loop and get plots TProfile* prof_Z = NULL; TProfile* prof_G = NULL; TH1D* h_resetZ = NULL; for(unsigned int i=0; i<f_zhs.size(); ++i){ // Load ZHS profile TFile* file_Z = new TFile(f_zhs.at(i).Data()); prof_Z = getProfile(file_Z, p_zhs, xtitle, ytitle, kBlue, 20); prof_Z->SetDirectory(0); file_Z->Close(); leg->AddEntry(prof_Z,"ZHS","lep"); // Load Geant profile TFile* file_G = new TFile(f_g4.at(i).Data()); prof_G = getProfile(file_G, p_g4, xtitle, ytitle, kRed, 20); prof_G->SetDirectory(0); file_G->Close(); leg->AddEntry(prof_G,"Geant4","lep"); // Scale Geant4 profile up by factor of R //prof_G->Scale(m_R); // reset the zhs timing info //prof_Z = resetZHS(prof_Z, prof_G, kBlue, m_R); h_resetZ = resetZHS(prof_Z, prof_G, kBlue, m_R); //prof_Z->Scale(1/m_R); // Get maximum float maximum = prof_G->GetMaximum(); if( maximum < h_resetZ->GetMaximum() ) maximum = h_resetZ->GetMaximum(); prof_G->SetMaximum(maximum*5); prof_G->SetMinimum(maximum*1e-5); // Make two pads TPad* top = NULL; TPad* bot = NULL; makePads(c, top, bot); // Set some attributes prof_G->GetYaxis()->SetLabelSize(0.05); prof_G->GetYaxis()->SetTitleSize(0.05); prof_G->GetYaxis()->SetTitleOffset(1.0); prof_G->GetXaxis()->SetLabelSize(0); // Draw top plots c->cd(); top->Draw(); top->cd(); top->SetLogy(); prof_G->Draw(); //prof_Z->Draw("sameep"); h_resetZ->Draw("sameep"); leg->Draw("same"); top->Update(); // Draw bot ratio c->cd(); bot->Draw(); bot->cd(); //TProfile* prof = prof_G->Clone("ratio"); TH1D* prof = prof_G->ProjectionX("ratio"); prof->SetLineColor(prof_G->GetLineColor()); prof->SetMarkerColor(prof_G->GetMarkerColor()); prof->SetStats(0); //prof->Divide(prof_Z); prof->Divide(h_resetZ); prof->GetYaxis()->SetTitle("G4/ZHS"); prof->SetMinimum(0); //prof->SetMaximum(50); prof->SetMaximum(2); prof->GetXaxis()->SetLabelSize(0.1); prof->GetYaxis()->SetLabelSize(0.1); prof->GetXaxis()->SetTitleSize(0.12); prof->GetYaxis()->SetTitleSize(0.12); prof->GetYaxis()->SetTitleOffset(0.4); prof->GetYaxis()->SetNdivisions(405); prof->Draw(); bot->Update(); if(m_save){ //TString save = m_savedir + p_g4 + "_ZHSCherAngle.png"; //TString save = m_savedir + savenames.at(i) + "_ratio.png"; TString save = m_savedir + savenames.at(i) + "_ratio_fixed.png"; c->SaveAs(save.Data()); } }// end loop over files }