Int_t DrawTrendingTOFQA(TString mergedTrendFile = "trending.root", // trending tree file Bool_t displayAll = kFALSE) //set to kTRUE to display trending for expert plots { // //reads merged trending.root file and draws trending plots from tree // if (!mergedTrendFile) { Printf("Cannot open merged trend file with TOF QA"); return 1; } char outfilename[200]= "ProductionQA.hist.root"; TString plotDir("."); // TString plotDir(Form("PlotsTrending")); // gSystem->Exec(Form("mkdir %s",plotDir.Data())); Int_t runNumber=0; Double_t avTime=0., peakTime=0., spreadTime=0., peakTimeErr=0., spreadTimeErr=0.,negTimeRatio=0., avRawTime=0., peakRawTime=0., spreadRawTime=0., peakRawTimeErr=0., spreadRawTimeErr=0., avTot=0., peakTot=0.,spreadTot=0., peakTotErr=0.,spreadTotErr=0., meanResTOF=0., spreadResTOF=0., meanResTOFerr=0., spreadResTOFerr=0., orphansRatio=0., avL=0., negLratio=0., matchEffIntegratedErr=-9999., matchEffIntegrated=-9999., matchEffLinFit1Gev=0.,matchEffLinFit1GevErr=0.; Double_t avDiffTime=0.,peakDiffTime=0., spreadDiffTime=0.,peakDiffTimeErr=0., spreadDiffTimeErr=0.,avT0fillRes=0.; Double_t avT0A=0.,peakT0A=0., spreadT0A=0.,peakT0AErr=0., spreadT0AErr=0.; Double_t avT0C=0.,peakT0C=0., spreadT0C=0.,peakT0CErr=0., spreadT0CErr=0.; Double_t avT0AC=0.,peakT0AC=0., spreadT0AC=0.,peakT0ACErr=0., spreadT0ACErr=0.; Double_t avT0res=0.,peakT0res=0., spreadT0res=0.,peakT0resErr=0., spreadT0resErr=0.; Double_t StartTime_pBestT0 = 0.0, StartTime_pBestT0Err = 0.0, StartTime_pFillT0 = 0.0, StartTime_pFillT0Err = 0.0, StartTime_pTOFT0 = 0.0, StartTime_pTOFT0Err = 0.0, StartTime_pT0ACT0 = 0.0, StartTime_pT0ACT0Err = 0.0, StartTime_pT0AT0 = 0.0, StartTime_pT0AT0Err = 0.0, StartTime_pT0CT0 = 0.0, StartTime_pT0CT0Err = 0.0; Double_t StartTime_pBestT0_Res = 0.0, StartTime_pFillT0_Res = 0.0, StartTime_pTOFT0_Res = 0.0, StartTime_pT0ACT0_Res = 0.0, StartTime_pT0AT0_Res = 0.0, StartTime_pT0CT0_Res = 0.0; Float_t avMulti=0; Float_t fractionEventsWHits=0.0; Double_t goodChannelRatio=0.0; Double_t goodChannelRatioInAcc=0.0; TFile * fin = TFile::Open(mergedTrendFile.Data()); TTree * ttree = (TTree*) fin->Get("trending"); if (!ttree){ fin->ls(); Printf("Invalid trending tree."); return 2; } ttree->SetBranchAddress("run",&runNumber); ttree->SetBranchAddress("avMulti",&avMulti); ttree->SetBranchAddress("goodChannelsRatio",&goodChannelRatio); ttree->SetBranchAddress("goodChannelsRatioInAcc",&goodChannelRatioInAcc); ttree->SetBranchAddress("avTime",&avTime); //mean time ttree->SetBranchAddress("peakTime",&peakTime); //main peak time after fit ttree->SetBranchAddress("spreadTime",&spreadTime); //spread of main peak of time after fit ttree->SetBranchAddress("peakTimeErr",&peakTimeErr); //main peak time after fit error ttree->SetBranchAddress("spreadTimeErr",&spreadTimeErr); //spread of main peak of time after fit error ttree->SetBranchAddress("negTimeRatio",&negTimeRatio); //negative time ratio ttree->SetBranchAddress("avRawTime",&avRawTime); //mean raw time ttree->SetBranchAddress("peakRawTime",&peakRawTime); //mean peak of raw time after fit ttree->SetBranchAddress("spreadRawTime",&spreadRawTime); //spread of main peak of raw time after fit ttree->SetBranchAddress("peakRawTimeErr",&peakRawTimeErr); //main peak raw time after fit error ttree->SetBranchAddress("spreadRawTimeErr",&spreadRawTimeErr); //spread of raw main peak of time after fit error ttree->SetBranchAddress("avTot",&avTot); //main peak tot ttree->SetBranchAddress("peakTot",&peakTot); // main peak of tot after fit ttree->SetBranchAddress("spreadTot",&spreadTot); //spread of main peak of tot after fit ttree->SetBranchAddress("peakTotErr",&peakTotErr); // main peak of tot after fit ttree->SetBranchAddress("spreadTotErr",&spreadTotErr); //spread of main peak of tot after fit ttree->SetBranchAddress("orphansRatio",&orphansRatio); //orphans ratio ttree->SetBranchAddress("avL",&avL); //mean track length ttree->SetBranchAddress("negLratio",&negLratio);//ratio of tracks with track length <350 cm if(0 != ttree->SetBranchAddress("matchEffIntegrated",&matchEffIntegrated)) //matching eff integrated in pt (1-10GeV/c) matchEffIntegrated = 0; if(0 != ttree->SetBranchAddress("matchEffIntegratedErr",&matchEffIntegratedErr)) //matching eff integrated in pt (1-10GeV/c) matchEffIntegratedErr = 0; ttree->SetBranchAddress("matchEffLinFit1Gev",&matchEffLinFit1Gev);//matching eff fit param ttree->SetBranchAddress("matchEffLinFit1GevErr",&matchEffLinFit1GevErr);////matching eff fit param error ttree->SetBranchAddress("avPiDiffTime",&avDiffTime); //mean t-texp ttree->SetBranchAddress("peakPiDiffTime",&peakDiffTime); //main peak t-texp after fit ttree->SetBranchAddress("spreadPiDiffTime",&spreadDiffTime); //spread of main peak t-texp after fit ttree->SetBranchAddress("peakPiDiffTimeErr",&peakDiffTimeErr); //main peak t-texp after fit error ttree->SetBranchAddress("spreadPiDiffTimeErr",&spreadDiffTimeErr); //spread of main peak of t-texp after fit error ttree->SetBranchAddress("meanResTOF",&meanResTOF); //mean of t-texp_pi-t0_TOF ttree->SetBranchAddress("spreadResTOF",&spreadResTOF); //spread of t-texp_pi-t0_TOF, ie. resolution ttree->SetBranchAddress("meanResTOFerr",&meanResTOFerr); //error on mean of t-texp_pi-t0_TOF ttree->SetBranchAddress("spreadResTOFerr",&spreadResTOFerr); //error on the spread of t-texp_pi-t0_TOF ttree->SetBranchAddress("avT0A",&avT0A); //main peak t0A ttree->SetBranchAddress("peakT0A",&peakT0A); // main peak of t0A after fit ttree->SetBranchAddress("spreadT0A",&spreadT0A); //spread of main peak of t0A after fit ttree->SetBranchAddress("peakT0AErr",&peakT0AErr); // main peak of t0A after fit ttree->SetBranchAddress("spreadT0AErr",&spreadT0AErr); //spread of main peak of t0A after fit ttree->SetBranchAddress("avT0C",&avT0C); //main peak t0C ttree->SetBranchAddress("peakT0C",&peakT0C); // main peak of t0C after fit ttree->SetBranchAddress("spreadT0C",&spreadT0C); //spread of main peak of t0C after fit ttree->SetBranchAddress("peakT0CErr",&peakT0CErr); // main peak of t0C after fit ttree->SetBranchAddress("spreadT0CErr",&spreadT0CErr); //spread of main peak of t0C after fit ttree->SetBranchAddress("avT0AC",&avT0AC); //main peak t0AC ttree->SetBranchAddress("peakT0AC",&peakT0AC); // main peak of t0AC after fit ttree->SetBranchAddress("spreadT0AC",&spreadT0AC); //spread of main peak of t0AC after fit ttree->SetBranchAddress("peakT0ACErr",&peakT0ACErr); // main peak of t0AC after fit ttree->SetBranchAddress("spreadT0ACErr",&spreadT0ACErr); //spread of main peak of t0AC after fit ttree->SetBranchAddress("avT0res",&avT0res); //main peak t0AC ttree->SetBranchAddress("peakT0res",&peakT0res); // main peak of t0AC after fit ttree->SetBranchAddress("spreadT0res",&spreadT0res); //spread of main peak of t0AC after fit ttree->SetBranchAddress("peakT0resErr",&peakT0resErr); // main peak of t0AC after fit ttree->SetBranchAddress("spreadT0resErr",&spreadT0resErr); //spread of main peak of t0AC after fit ttree->SetBranchAddress("avT0fillRes",&avT0fillRes); //t0 fill res ttree->SetBranchAddress("StartTime_pBestT0",&StartTime_pBestT0); //T0Best ttree->SetBranchAddress("StartTime_pFillT0",&StartTime_pFillT0); //T0Fill ttree->SetBranchAddress("StartTime_pTOFT0",&StartTime_pTOFT0); //T0TOF ttree->SetBranchAddress("StartTime_pT0ACT0",&StartTime_pT0ACT0); //T0AC ttree->SetBranchAddress("StartTime_pT0AT0",&StartTime_pT0AT0); //T0A ttree->SetBranchAddress("StartTime_pT0CT0",&StartTime_pT0CT0); //T0C ttree->SetBranchAddress("StartTime_pBestT0_Res",&StartTime_pBestT0_Res); //T0Best ttree->SetBranchAddress("StartTime_pFillT0_Res",&StartTime_pFillT0_Res); //T0Fill res ttree->SetBranchAddress("StartTime_pTOFT0_Res",&StartTime_pTOFT0_Res); //T0TOF res ttree->SetBranchAddress("StartTime_pT0ACT0_Res",&StartTime_pT0ACT0_Res); //T0AC res ttree->SetBranchAddress("StartTime_pT0AT0_Res",&StartTime_pT0AT0_Res); //T0A res ttree->SetBranchAddress("StartTime_pT0CT0_Res",&StartTime_pT0CT0_Res); //T0C res ttree->SetBranchAddress("StartTime_pBestT0Err",&StartTime_pBestT0Err); //T0Best ttree->SetBranchAddress("StartTime_pFillT0Err",&StartTime_pFillT0Err); //T0Fill ttree->SetBranchAddress("StartTime_pTOFT0Err",&StartTime_pTOFT0Err); //T0TOF ttree->SetBranchAddress("StartTime_pT0ACT0Err",&StartTime_pT0ACT0Err); //T0AC ttree->SetBranchAddress("StartTime_pT0AT0Err",&StartTime_pT0AT0Err); //T0A ttree->SetBranchAddress("StartTime_pT0CT0Err",&StartTime_pT0CT0Err); //T0C //Fetch period-integrated PID plots //Pions TH2F * hDiffTimePi=(TH2F*)fin->Get("hExpTimePiVsP_all"); hDiffTimePi->SetTitle("PIONS t-t_{exp,#pi} (from tracking) vs. P"); //Kaon TH2F * hDiffTimeKa=(TH2F*)fin->Get("hExpTimeKaVsP_all"); hDiffTimeKa->SetTitle("KAONS t-t_{exp,K} (from tracking) vs. P"); //Protons TH2F * hDiffTimePro=(TH2F*)fin->Get("hExpTimeProVsP_all"); hDiffTimePro->SetTitle("PROTONS t-t_{exp,p} (from tracking) vs. P"); //Create trending plots Int_t nRuns=ttree->GetEntries(); TList lista; TH1F * hAvMulti=new TH1F("hAvMulti","Average multiplicity of matched tracks <N_{TOF}>;; <N_{TOF}>", nRuns,0., nRuns);//, 600, 0. , 600.); hAvMulti->SetDrawOption("E1"); hAvMulti->SetMarkerStyle(20); hAvMulti->SetMarkerColor(kBlue); TH1F * hAvDiffTimeVsRun=new TH1F("hAvDiffTimeVsRun","Mean t-t_{exp} (no fit);run;<t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//, 600, 0. , 600.); hAvDiffTimeVsRun->SetDrawOption("E1"); hAvDiffTimeVsRun->SetMarkerStyle(20); hAvDiffTimeVsRun->SetMarkerColor(kBlue); // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0); TH1F * hPeakDiffTimeVsRun=new TH1F("hPeakDiffTimeVsRun","t-t_{exp} (gaussian fit) ;; <t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//,600, 0. , 600. ); hPeakDiffTimeVsRun->SetDrawOption("E1"); hPeakDiffTimeVsRun->SetMarkerStyle(20); hPeakDiffTimeVsRun->SetMarkerColor(kBlue); TH1F * hSpreadDiffTimeVsRun=new TH1F("hSpreadDiffTimeVsRun","#sigma(t-t_{exp}) (gaussian fit);; #sigma(t^{TOF}-t_{exp,#pi}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.); hSpreadDiffTimeVsRun->SetDrawOption("E1"); hSpreadDiffTimeVsRun->SetMarkerStyle(20); hSpreadDiffTimeVsRun->SetMarkerColor(kBlue); TH1F * hMeanTOFResVsRun=new TH1F("hMeanTOFResVsRun","Mean value of t-t_{exp,#pi}-t0_{TOF} (ps);;<t^{TOF}-t_{exp,#pi}-t_{0,TOF}> (ps)",nRuns,0., nRuns); hMeanTOFResVsRun->SetDrawOption("E1"); hMeanTOFResVsRun->SetMarkerStyle(20); hMeanTOFResVsRun->SetMarkerColor(kBlue); TH1F * hSigmaTOFResVsRun=new TH1F("hSigmaTOFResVsRun","Spread of t-t_{exp,#pi}-t0_{TOF} (ps);;#sigma(t^{TOF}-t_{exp,#pi}-t_{0,TOF}) (ps)",nRuns,0., nRuns); hSigmaTOFResVsRun->SetDrawOption("E1"); hSigmaTOFResVsRun->SetMarkerStyle(20); hSigmaTOFResVsRun->SetMarkerColor(kBlue); TH1F * hAvTimeVsRun=new TH1F("hAvTimeVsRun","<t^{TOF}>;;<t^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.); hAvTimeVsRun->SetDrawOption("E1"); hAvTimeVsRun->SetMarkerStyle(20); hAvTimeVsRun->SetMarkerColor(kBlue); // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0); TH1F * hPeakTimeVsRun=new TH1F("hPeakTimeVsRun","Peak value of t^{TOF} (landau fit);;t_{peak}^{TOF} (ns)",nRuns,0., nRuns);//,600, 0. , 600. ); hPeakTimeVsRun->SetDrawOption("E1"); hPeakTimeVsRun->SetMarkerStyle(20); hPeakTimeVsRun->SetMarkerColor(kBlue); TH1F * hSpreadTimeVsRun=new TH1F("hSpreadTimeVsRun","Spread of t^{TOF} (landau fit);; #sigma(t^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.); hSpreadTimeVsRun->SetDrawOption("E1"); hSpreadTimeVsRun->SetMarkerStyle(20); hSpreadTimeVsRun->SetMarkerColor(kBlue); TH1F * hAvRawTimeVsRun=new TH1F("hAvRawTimeVsRun","Peak value of raw t^{TOF};;<t_{raw}^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.); hAvRawTimeVsRun->SetDrawOption("E1"); hAvRawTimeVsRun->SetMarkerStyle(21); hAvRawTimeVsRun->SetMarkerColor(kGreen); TH1F * hPeakRawTimeVsRun=new TH1F("hPeakRawTimeVsRun","Peak value of raw t^{TOF} (landau fit);;t_{peak,raw}^{TOF} (ns)",nRuns,0., nRuns);//, 600, 0. , 600.); hPeakRawTimeVsRun->SetDrawOption("E1"); hPeakRawTimeVsRun->SetMarkerStyle(21); hPeakRawTimeVsRun->SetMarkerColor(kGreen); TH1F * hSpreadRawTimeVsRun=new TH1F("hSpreadRawTimeVsRun","Spread of raw t^{TOF} (landau fit);;#sigma(t_{raw}^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.); hSpreadRawTimeVsRun->SetDrawOption("E1"); hSpreadRawTimeVsRun->SetMarkerStyle(21); hSpreadRawTimeVsRun->SetMarkerColor(kGreen); TH1F * hAvTotVsRun=new TH1F("hAvTotVsRun","<ToT> (no fit);run;<ToT> (ns)",nRuns,0., nRuns);//, 50, 0. , 50.); hAvTotVsRun->SetDrawOption("E1"); hAvTotVsRun->SetMarkerStyle(22); TH1F * hPeakTotVsRun=new TH1F("hPeakTotVsRun","<ToT> (gaussian fit);;ToT_{peak} (ns)",nRuns,0., nRuns);//, 50, 0. , 50.); hPeakTotVsRun->SetDrawOption("E1"); hPeakTotVsRun->SetMarkerStyle(22); TH1F * hSpreadTotVsRun=new TH1F("hSpreadTotVsRun","#sigma(ToT) (gaussian fit);#sigma(ToT) (ns)",nRuns,0., nRuns);//, 50, 0. , 50.); hSpreadTotVsRun->SetDrawOption("E1"); hSpreadTotVsRun->SetMarkerStyle(22); TH1F * hNegTimeRatioVsRun=new TH1F("hNegTimeRatioVsRun","Ratio of tracks with t^{TOF}<12.5 ns; ; ratio of tracks with t^{TOF}<12.5 ns (%)",nRuns, 0., nRuns);//, 100, 0. , 100.); hNegTimeRatioVsRun->SetDrawOption("E"); TH1F * hOrphansRatioVsRun=new TH1F("hOrphansRatioVsRun","Ratio of orphans (hits with ToT=0); ; ratio of orphans (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.); hOrphansRatioVsRun->SetDrawOption("E"); TH1F * hMeanLVsRun=new TH1F("hMeanLVsRun","Average track length;; <L> (cm)",nRuns, 0., nRuns);//, 350, 350. , 700.); hMeanLVsRun->SetDrawOption("E"); TH1F * hNegLRatioVsRun=new TH1F("hNegLRatioVsRun","Ratio of tracks with L<350 cm;; ratio of tracks with L<350 cm (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.); hNegLRatioVsRun->SetDrawOption("E"); TH1F * hMatchEffVsRun=new TH1F("hMatchEffVsRun","#epsilon_{match} (linear fit for p_{T}>1.0 GeV/c);;#epsilon_{match} (p_{T}>1.0 GeV/c)",nRuns, 0., nRuns);//, 100, 0. , 1.); hMatchEffVsRun->SetDrawOption("E"); TH1F * hMatchEffVsRunNormToGoodCh=new TH1F("hMatchEffVsRunNormToGoodCh","#epsilon_{match} normalized to percentage of TOF good channels;;#epsilon_{match}(p_{T}>1.0 GeV/c,|#eta|<0.8)/f_{all good}",nRuns, 0., nRuns);//, 100, 0. , 1.); hMatchEffVsRunNormToGoodCh->SetDrawOption("E"); TH1F * hMatchEffVsRunNormToGoodChInAcc=new TH1F("hMatchEffVsRunNormToGoodChInAcc","#epsilon_{match} normalized to TOF good channels in |#eta|<0.8;;#epsilon_{match}(p_{T}>1.0 GeV/c,|#eta|<0.8/f_{good}(|#eta|<0.8)",nRuns, 0., nRuns);//, 100, 0. , 1.); hMatchEffVsRunNormToGoodChInAcc->SetDrawOption("E"); TH1F * hMatchEffIntegratedVsRun=new TH1F("hMatchEffVsRun1hMatchEffIntegratedVsRun","#it{p}_{T} integrated #epsilon_{match}; ; #epsilon_{match} (1 < p_{T} < 10 GeV/c)",nRuns, 0., nRuns); hMatchEffIntegratedVsRun->SetDrawOption("E"); TH1F * hPeakT0AVsRun=new TH1F("hPeakT0AVsRun","Peak value of T0A (gaussian fit);;t0A (ps)",nRuns,0., nRuns); TH1F * hPeakT0CVsRun=new TH1F("hPeakT0CVsRun","Peak value of T0C (gaussian fit);;t0AC (ps)",nRuns,0., nRuns); TH1F * hPeakT0ACVsRun=new TH1F("hPeakT0ACVsRun","Peak value of T0AC (gaussian fit);;t0AC (ps)",nRuns,0., nRuns); TH1F * hT0fillResVsRun=new TH1F("hT0fillResVsRun","t0_fill spread;;t0_spread (ps)",nRuns,0., nRuns); TH1F * hT0BestVsRun=new TH1F("hT0BestVsRun","start time by best_t0;;t0 Best (ps)",nRuns,0., nRuns); hT0BestVsRun->SetDrawOption("E1"); hT0BestVsRun->SetLineColor(kOrange); hT0BestVsRun->SetLineWidth(2); hT0BestVsRun->SetMarkerStyle(20); hT0BestVsRun->SetMarkerColor(kOrange); TH1F * hT0FillVsRun=new TH1F("hT0FillVsRun","start time by fill_t0;;t0 Fill (ps)",nRuns,0., nRuns); hT0FillVsRun->SetDrawOption("E1"); hT0FillVsRun->SetLineColor(kBlue); hT0FillVsRun->SetLineWidth(2); hT0FillVsRun->SetMarkerStyle(20); hT0FillVsRun->SetMarkerColor(kBlue); TH1F * hT0TOFVsRun=new TH1F("hT0TOFVsRun","start time by TOF_t0;;t0 TOF (ps)",nRuns,0., nRuns); hT0TOFVsRun->SetDrawOption("E1"); hT0TOFVsRun->SetLineColor(kBlue); hT0TOFVsRun->SetLineWidth(2); hT0TOFVsRun->SetMarkerStyle(20); hT0TOFVsRun->SetMarkerColor(kBlue); TH1F * hT0T0ACVsRun=new TH1F("hT0T0ACVsRun","start time by T0AC;;t0 T0AC (ps)",nRuns,0., nRuns); hT0T0ACVsRun->SetDrawOption("E1"); hT0T0ACVsRun->SetLineColor(kRed); hT0T0ACVsRun->SetLineWidth(2); hT0T0ACVsRun->SetMarkerStyle(20); hT0T0ACVsRun->SetMarkerColor(kRed); TH1F * hT0T0AVsRun=new TH1F("hT0T0AtVsRun","start time by T0A;;t0 T0A (ps)",nRuns,0., nRuns); hT0T0AVsRun->SetDrawOption("E1"); hT0T0AVsRun->SetLineColor(kGreen+2); hT0T0AVsRun->SetLineWidth(2); hT0T0AVsRun->SetMarkerStyle(20); hT0T0AVsRun->SetMarkerColor(kGreen+2); TH1F * hT0T0CVsRun=new TH1F("hT0T0CVsRun","start time by T0C;;t0 T0C (ps)",nRuns,0., nRuns); hT0T0CVsRun->SetDrawOption("E1"); hT0T0CVsRun->SetLineColor(kMagenta); hT0T0CVsRun->SetLineWidth(2); hT0T0CVsRun->SetMarkerStyle(20); hT0T0CVsRun->SetMarkerColor(kMagenta); TH1F * hT0BestVsRunRes=new TH1F("hT0BestVsRunRes","#sigma of best_t0;; #sigma t0 Best (ps)",nRuns,0., nRuns); hT0BestVsRunRes->SetDrawOption("E1"); hT0BestVsRunRes->SetLineColor(kOrange); hT0BestVsRunRes->SetLineWidth(2); hT0BestVsRunRes->SetMarkerStyle(20); hT0BestVsRunRes->SetMarkerColor(kOrange); TH1F * hT0FillVsRunRes=new TH1F("hT0FillVsRunRes","fill_t0;; #sigmat0 Fill (ps)",nRuns,0., nRuns); hT0FillVsRunRes->SetDrawOption("E1"); hT0FillVsRunRes->SetLineColor(kBlue); hT0FillVsRunRes->SetLineWidth(2); hT0FillVsRunRes->SetMarkerStyle(20); hT0FillVsRunRes->SetMarkerColor(kBlue); TH1F * hT0TOFVsRunRes=new TH1F("hT0T0FVsRunRes","TOF_t0;; #sigma t0 TOF (ps)",nRuns,0., nRuns); hT0TOFVsRunRes->SetDrawOption("E1"); hT0TOFVsRunRes->SetLineColor(kBlue); hT0TOFVsRunRes->SetLineWidth(2); hT0TOFVsRunRes->SetMarkerStyle(20); hT0TOFVsRunRes->SetMarkerColor(kBlue); TH1F * hT0T0ACVsRunRes=new TH1F("hT0T0ACVsRunRes","T0AC_t0;; #sigma t0 T0AC (ps)",nRuns,0., nRuns); hT0T0ACVsRunRes->SetDrawOption("E1"); hT0T0ACVsRunRes->SetLineColor(kRed); hT0T0ACVsRunRes->SetLineWidth(2); hT0T0ACVsRunRes->SetMarkerStyle(20); hT0T0ACVsRunRes->SetMarkerColor(kRed); TH1F * hT0T0AVsRunRes=new TH1F("hT0T0AVsRunRes","T0A_t0;; #sigma t0 T0A (ps)",nRuns,0., nRuns); hT0T0AVsRunRes->SetDrawOption("E1"); hT0T0AVsRunRes->SetLineColor(kGreen+2); hT0T0AVsRunRes->SetLineWidth(2); hT0T0AVsRunRes->SetMarkerStyle(20); hT0T0AVsRunRes->SetMarkerColor(kGreen+2); TH1F * hT0T0CVsRunRes=new TH1F("hT0T0CVsRunRes","T0C_t0;; #sigma t0 T0C (ps)",nRuns,0., nRuns); hT0T0CVsRunRes->SetDrawOption("E1"); hT0T0CVsRunRes->SetLineColor(kMagenta); hT0T0CVsRunRes->SetLineWidth(2); hT0T0CVsRunRes->SetMarkerStyle(20); hT0T0CVsRunRes->SetMarkerColor(kMagenta); TH1F * hGoodChannelsRatio=new TH1F("hGoodChannelsRatio","Fraction of TOF good channels;;fraction of good channels",nRuns, 0., nRuns);//, 100, 0. , 1.); hGoodChannelsRatio->SetDrawOption("E"); TH1F * hGoodChannelsRatioInAcc=new TH1F("hGoodChannelsRatioInAcc","Fraction of TOF good channels in |#eta|<0.8;;fraction of good channels in |#eta|<0.8",nRuns, 0., nRuns);//, 100, 0. , 1.); hGoodChannelsRatioInAcc->SetDrawOption("E"); lista.Add(hAvMulti); lista.Add(hAvDiffTimeVsRun); lista.Add(hPeakDiffTimeVsRun); lista.Add(hSpreadDiffTimeVsRun); lista.Add(hAvTimeVsRun); lista.Add(hPeakTimeVsRun); lista.Add(hMeanTOFResVsRun); lista.Add(hSigmaTOFResVsRun); lista.Add(hSpreadTimeVsRun); lista.Add(hAvRawTimeVsRun); lista.Add(hPeakRawTimeVsRun); lista.Add(hSpreadRawTimeVsRun); lista.Add(hAvTotVsRun); lista.Add(hPeakTotVsRun); lista.Add(hSpreadTotVsRun); lista.Add(hNegTimeRatioVsRun); lista.Add(hOrphansRatioVsRun); lista.Add(hMeanLVsRun); lista.Add(hNegLRatioVsRun); lista.Add(hMatchEffVsRun); lista.Add(hMatchEffVsRunNormToGoodCh); lista.Add(hMatchEffVsRunNormToGoodChInAcc); lista.Add(hPeakT0AVsRun); lista.Add(hPeakT0CVsRun); lista.Add(hPeakT0ACVsRun); lista.Add(hT0fillResVsRun); lista.Add(hGoodChannelsRatio); lista.Add(hGoodChannelsRatioInAcc); lista.Add(hT0BestVsRun); lista.Add(hT0FillVsRun); lista.Add(hT0TOFVsRun); lista.Add(hT0T0ACVsRun); lista.Add(hT0T0AVsRun); lista.Add(hT0T0CVsRun); lista.Add(hT0BestVsRunRes); lista.Add(hT0FillVsRunRes); lista.Add(hT0TOFVsRunRes); lista.Add(hT0T0ACVsRunRes); lista.Add(hT0T0AVsRunRes); lista.Add(hT0T0CVsRunRes); char runlabel[6]; for (Int_t irun=0;irun<nRuns;irun++){ ttree->GetEntry(irun); sprintf(runlabel,"%i",runNumber); hAvMulti->SetBinContent(irun+1, avMulti); hAvMulti->GetXaxis()->SetBinLabel(irun+1,runlabel); hAvDiffTimeVsRun->SetBinContent(irun+1, avDiffTime); hAvDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakDiffTimeVsRun->SetBinContent(irun+1,peakDiffTime); hPeakDiffTimeVsRun->SetBinError(irun+1,peakDiffTimeErr); hPeakDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hSpreadDiffTimeVsRun->SetBinContent(irun+1,spreadDiffTime); hSpreadDiffTimeVsRun->SetBinError(irun+1,spreadDiffTimeErr); hSpreadDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hMeanTOFResVsRun->SetBinContent(irun+1,meanResTOF); hMeanTOFResVsRun->SetBinError(irun+1,meanResTOFerr); hMeanTOFResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hSigmaTOFResVsRun->SetBinContent(irun+1,spreadResTOF); hSigmaTOFResVsRun->SetBinError(irun+1,spreadResTOFerr); hSigmaTOFResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hAvTimeVsRun->SetBinContent(irun+1, avTime); hAvTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakTimeVsRun->SetBinContent(irun+1,peakTime); hPeakTimeVsRun->SetBinError(irun+1,peakTimeErr); hPeakTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hSpreadTimeVsRun->SetBinContent(irun+1,spreadTime); hSpreadTimeVsRun->SetBinError(irun+1,spreadTimeErr); hSpreadTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hAvRawTimeVsRun->SetBinContent(irun+1, avRawTime); hAvRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakRawTimeVsRun->SetBinContent(irun+1,peakRawTime); hPeakRawTimeVsRun->SetBinError(irun+1,peakRawTimeErr); hPeakRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hSpreadRawTimeVsRun->SetBinContent(irun+1,spreadRawTime); hSpreadRawTimeVsRun->SetBinError(irun+1,spreadRawTimeErr); hSpreadRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hAvTotVsRun->SetBinContent(irun+1,avTot); hAvTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakTotVsRun->SetBinContent(irun+1,peakTot); hPeakTotVsRun->SetBinError(irun+1,peakTotErr); hPeakTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hSpreadTotVsRun->SetBinContent(irun+1,spreadTot); hSpreadTotVsRun->SetBinError(irun+1,spreadTotErr); hSpreadTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hNegTimeRatioVsRun->SetBinContent(irun+1,negTimeRatio); hNegTimeRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hOrphansRatioVsRun->SetBinContent(irun+1,orphansRatio); hOrphansRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hMeanLVsRun->SetBinContent(irun+1,avL); hMeanLVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hNegLRatioVsRun->SetBinContent(irun+1,negLratio); hNegLRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hMatchEffVsRun->SetBinContent(irun+1,matchEffLinFit1Gev); hMatchEffVsRun->SetBinError(irun+1,matchEffLinFit1GevErr); hMatchEffVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hMatchEffVsRun->SetLineColor(kRed); hMatchEffVsRun->SetLineWidth(2); hMatchEffIntegratedVsRun->SetBinContent(irun+1, matchEffIntegrated); hMatchEffIntegratedVsRun->SetBinError(irun+1, matchEffIntegratedErr); hMatchEffIntegratedVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hMatchEffIntegratedVsRun->SetLineColor(kOrange); hMatchEffIntegratedVsRun->SetLineStyle(7); hMatchEffIntegratedVsRun->SetLineWidth(2); if (goodChannelRatio>0) hMatchEffVsRunNormToGoodCh->SetBinContent(irun+1,matchEffLinFit1Gev/goodChannelRatio); else hMatchEffVsRunNormToGoodCh->SetBinContent(irun+1, 0.0); hMatchEffVsRunNormToGoodCh->SetBinError(irun+1,matchEffLinFit1GevErr); hMatchEffVsRunNormToGoodCh->GetXaxis()->SetBinLabel(irun+1,runlabel); hMatchEffVsRunNormToGoodCh->SetLineColor(kCyan+2); hMatchEffVsRunNormToGoodCh->SetLineWidth(2); hGoodChannelsRatio->SetBinContent(irun+1, goodChannelRatio); hGoodChannelsRatio->SetLineColor(kCyan-1); hGoodChannelsRatio->SetLineWidth(2); hGoodChannelsRatio->GetXaxis()->SetBinLabel(irun+1,runlabel); if (goodChannelRatioInAcc>0) hMatchEffVsRunNormToGoodChInAcc->SetBinContent(irun+1,matchEffLinFit1Gev/goodChannelRatioInAcc); else hMatchEffVsRunNormToGoodChInAcc->SetBinContent(irun+1, 0.0); hMatchEffVsRunNormToGoodChInAcc->SetBinError(irun+1,matchEffLinFit1GevErr); hMatchEffVsRunNormToGoodChInAcc->GetXaxis()->SetBinLabel(irun+1,runlabel); hMatchEffVsRunNormToGoodChInAcc->SetLineColor(kBlue); hMatchEffVsRunNormToGoodChInAcc->SetLineWidth(2); hGoodChannelsRatioInAcc->SetBinContent(irun+1, goodChannelRatioInAcc); hGoodChannelsRatioInAcc->SetLineColor(kBlue+2); hGoodChannelsRatioInAcc->SetLineWidth(2); hGoodChannelsRatioInAcc->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakT0AVsRun->SetBinContent(irun+1,peakT0A); hPeakT0AVsRun->SetBinError(irun+1,spreadT0A); hPeakT0AVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakT0CVsRun->SetBinContent(irun+1,peakT0C); hPeakT0CVsRun->SetBinError(irun+1,spreadT0C); hPeakT0CVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakT0ACVsRun->SetBinContent(irun+1,peakT0AC); hPeakT0ACVsRun->SetBinError(irun+1,spreadT0AC); hPeakT0ACVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0fillResVsRun->SetBinContent(irun+1,avT0fillRes); hT0fillResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0BestVsRun->SetBinContent(irun+1,StartTime_pBestT0); hT0BestVsRun->SetBinError(irun+1,StartTime_pBestT0Err); hT0BestVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0FillVsRun->SetBinContent(irun+1,StartTime_pFillT0); hT0FillVsRun->SetBinError(irun+1,StartTime_pFillT0Err); hT0FillVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0TOFVsRun->SetBinContent(irun+1,StartTime_pTOFT0); hT0TOFVsRun->SetBinError(irun+1,StartTime_pTOFT0Err); hT0TOFVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0ACVsRun->SetBinContent(irun+1,StartTime_pT0ACT0); hT0T0ACVsRun->SetBinError(irun+1,StartTime_pT0ACT0Err); hT0T0ACVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0AVsRun->SetBinContent(irun+1,StartTime_pT0AT0); hT0T0AVsRun->SetBinError(irun+1,StartTime_pT0AT0Err); hT0T0AVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0CVsRun->SetBinContent(irun+1,StartTime_pT0CT0); hT0T0CVsRun->SetBinError(irun+1,StartTime_pT0CT0Err); hT0T0CVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0BestVsRunRes->SetBinContent(irun+1,StartTime_pBestT0_Res); hT0BestVsRunRes->SetBinError(irun+1, 1.e-5); hT0BestVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0FillVsRunRes->SetBinContent(irun+1,StartTime_pFillT0_Res); hT0FillVsRunRes->SetBinError(irun+1, 1.e-5); hT0FillVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0TOFVsRunRes->SetBinContent(irun+1,StartTime_pTOFT0_Res); hT0TOFVsRunRes->SetBinError(irun+1, 1.e-5); hT0TOFVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0ACVsRunRes->SetBinContent(irun+1,StartTime_pT0ACT0_Res); hT0T0ACVsRunRes->SetBinError(irun+1, 1.e-5); hT0T0ACVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0AVsRunRes->SetBinContent(irun+1,StartTime_pT0AT0_Res); hT0T0AVsRunRes->SetBinError(irun+1, 1.e-5); hT0T0AVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0CVsRunRes->SetBinContent(irun+1,StartTime_pT0CT0_Res); hT0T0CVsRunRes->SetBinError(irun+1, 1.e-5); hT0T0CVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); } TFile * fout=new TFile(outfilename,"recreate"); fout->cd(); lista.Write(); fout->Close(); gStyle->SetOptStat(10); TString plotext = "png"; const TString desiredext = gSystem->Getenv("TOFQAPLOTEXTENSION"); if(desiredext.EqualTo("pdf") || desiredext.EqualTo("root")) plotext = desiredext; else if(!desiredext.IsNull()) cout<<"Unrecognized extension: '"<<desiredext<<"'"<<endl; //Plot t-texp trend TCanvas* cPeakDiffTimeVsRun = new TCanvas("cPeakDiffTimeVsRun","cPeakDiffTimeVsRun", 50,50,1050, 550); hPeakDiffTimeVsRun->GetYaxis()->SetRangeUser(-50.,50.); hPeakDiffTimeVsRun->Draw(); cPeakDiffTimeVsRun->Print(Form("%s/cPeakDiffTimeVsRun.%s", plotDir.Data(), plotext.Data())); TCanvas* cSpreadDiffTimeVsRun = new TCanvas("cSpreadDiffTimeVsRun","cSpreadDiffTimeVsRun", 50,50,1050, 550); hSpreadDiffTimeVsRun->GetYaxis()->SetRangeUser(0.,400.); hSpreadDiffTimeVsRun->Draw(); cSpreadDiffTimeVsRun->Print(Form("%s/cSpreadDiffTimeVsRun.%s", plotDir.Data(), plotext.Data())); //Plot average of t-texp-t0tof and resolution trend TCanvas* cMeanTOFResVsRun = new TCanvas("cMeanTOFResVsRun","cMeanTOFResVsRun", 50,50,1050, 550); hMeanTOFResVsRun->GetYaxis()->SetRangeUser(-50.,50.); hMeanTOFResVsRun->Draw(); cMeanTOFResVsRun->Print(Form("%s/cMeanTOFResVsRun.%s", plotDir.Data(), plotext.Data())); TCanvas* cSigmaTOFResVsRun = new TCanvas("cSigmaTOFResVsRun","cSigmaTOFResVsRun", 50,50,1050, 550); hSigmaTOFResVsRun->GetYaxis()->SetRangeUser(0.,200.); hSigmaTOFResVsRun->Draw(); cSigmaTOFResVsRun->Print(Form("%s/cSigmaTOFResVsRun.%s", plotDir.Data(), plotext.Data())); //Plot matching efficiency trend TCanvas* cMatchEffVsRun = new TCanvas("cMatchEffVsRun","cMatchEffVsRun",50, 50, 1050, 550); hMatchEffVsRun->GetYaxis()->SetRangeUser(0.,1.); hMatchEffVsRun->Draw(); hMatchEffIntegratedVsRun->Draw("same"); cMatchEffVsRun->Print(Form("%s/cMatchEffVsRun.%s", plotDir.Data(), plotext.Data())); TCanvas* cMatchEffNormToGoodChInAcc = new TCanvas("cMatchEffNormToGoodChInAcc","cMatchEffNormToGoodChInAcc",50, 50,1050, 550); hMatchEffVsRunNormToGoodChInAcc->GetYaxis()->SetRangeUser(0.,1.); hMatchEffVsRunNormToGoodChInAcc->Draw(); cMatchEffNormToGoodChInAcc->Print(Form("%s/cMatchEffNormToGoodChInAcc.%s", plotDir.Data(), plotext.Data())); TCanvas* cMatchEffNormToGoodCh = new TCanvas("cMatchEffNormToGoodCh","cMatchEffNormToGoodCh",50, 50,1050, 550); hMatchEffVsRunNormToGoodCh->GetYaxis()->SetRangeUser(0.,1.); hMatchEffVsRunNormToGoodCh->Draw(); cMatchEffNormToGoodCh->Print(Form("%s/cMatchEffNormToGoodCh.%s", plotDir.Data(), plotext.Data())); TLegend *leg = new TLegend(0.5095602,0.1206897,0.8891013,0.3314176,NULL,"brNDC"); leg->SetBorderSize(1); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("hMatchEffVsRun","#epsilon_{match} (linear fit for p_{T}>1.0 GeV/c)","lpf"); entry->SetFillStyle(1001); Int_t ci = TColor::GetColor("#ff0000"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(1); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("hMatchEffVsRunNormToGoodCh","#epsilon_{match} norm. to fraction of TOF good channels","lpf"); entry->SetFillStyle(1001); ci = TColor::GetColor("#009999"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(1); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("hMatchEffVsRunNormToGoodChInAcc","#epsilon_{match} norm. to fraction of TOF good channels in |#eta|<0.8","lpf"); entry->SetFillStyle(1001); ci = TColor::GetColor("#0000ff"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(1); entry->SetMarkerSize(1); entry->SetTextFont(42); TCanvas* cMatchEffSummary = new TCanvas("cMatchEffSummary","cMatchEffSummary",50, 50,1050, 550); hMatchEffVsRun->GetYaxis()->SetRangeUser(0.4,0.8); hMatchEffVsRun->Draw(); hMatchEffVsRunNormToGoodCh->Draw("same"); hMatchEffVsRunNormToGoodChInAcc->Draw("same"); leg->Draw("same"); cMatchEffSummary->Print(Form("%s/cMatchEffSummary.%s", plotDir.Data(), plotext.Data())); //Plot start time trend TCanvas* cStartTimeSummary = new TCanvas("cStartTimeSummary","cStartTimeSummary",50, 50,1050, 550); hT0TOFVsRun->GetYaxis()->SetRangeUser(-100.,100.); hT0TOFVsRun->GetYaxis()->SetTitle("Start Time (ps)"); hT0TOFVsRun->Draw(); hT0T0ACVsRun->Draw("same"); hT0T0AVsRun->Draw("same"); hT0T0CVsRun->Draw("same"); hT0BestVsRun->Draw("same"); gPad->SetGridy(); gPad->SetTitle("Start Time by different methods"); TLegend * cLegSTS = new TLegend(0.6,0.7,0.9,0.9); cLegSTS->SetFillStyle(1001); cLegSTS->SetFillColor(kWhite); cLegSTS->SetNColumns(2); cLegSTS->SetBorderSize(1); cLegSTS->AddEntry(hT0TOFVsRun,"TOF_T0","lp"); cLegSTS->AddEntry(hT0T0ACVsRun,"T0AC_T0","lp"); cLegSTS->AddEntry(hT0T0AVsRun,"T0A_T0","lp"); cLegSTS->AddEntry(hT0T0CVsRun,"T0C_T0","lp"); cLegSTS->AddEntry(hT0BestVsRun, "Best_T0","lp"); cLegSTS->Draw(); cStartTimeSummary->Print(Form("%s/cStartTimeSummary.%s", plotDir.Data(), plotext.Data())); TCanvas* cStartTimeResolutionSummary = new TCanvas("cStartTimeResolutionSummary","cStartTimeResolutionSummary",50, 50,1050, 550); hT0TOFVsRunRes->GetYaxis()->SetRangeUser(0.,200.); hT0TOFVsRunRes->GetYaxis()->SetTitle("#sigma Start Time (ps)"); hT0TOFVsRunRes->Draw(); hT0T0ACVsRunRes->Draw("same"); hT0T0AVsRunRes->Draw("same"); hT0T0CVsRunRes->Draw("same"); hT0BestVsRunRes->Draw("same"); TLegend * cLegSTRS = new TLegend(0.6,0.7,0.9,0.9); cLegSTRS->SetFillStyle(1001); cLegSTRS->SetFillColor(kWhite); cLegSTRS->SetNColumns(2); cLegSTRS->SetBorderSize(1); cLegSTRS->AddEntry(hT0TOFVsRunRes,"TOF_T0 res.","lp"); cLegSTRS->AddEntry(hT0T0ACVsRunRes,"T0AC_T0 res.","lp"); cLegSTRS->AddEntry(hT0T0AVsRunRes,"T0A_T0 res.","lp"); cLegSTRS->AddEntry(hT0T0CVsRunRes,"T0C_T0 res.","lp"); cLegSTRS->AddEntry(hT0BestVsRunRes, "Best_T0 res.","lp"); cLegSTRS->Draw(); cStartTimeResolutionSummary->Print(Form("%s/cStartTimeResolutionSummary.%s", plotDir.Data(), plotext.Data())); TCanvas* cGoodCh = new TCanvas("cGoodCh","cGoodCh",50, 50,1050, 550); hGoodChannelsRatio->GetYaxis()->SetRangeUser(0.75,1.); hGoodChannelsRatio->Draw(); cGoodCh->Print(Form("%s/cGoodCh.%s", plotDir.Data(), plotext.Data())); TCanvas* cGoodChInAcc = new TCanvas("cGoodChInAcc","cGoodChInAcc",50, 50,1050, 550); hGoodChannelsRatioInAcc->GetYaxis()->SetRangeUser(0.75,1.); hGoodChannelsRatioInAcc->Draw(); cGoodChInAcc->Print(Form("%s/cGoodChInAcc.%s", plotDir.Data(), plotext.Data())); TCanvas* cPidPerformance= new TCanvas("cPidPerformance","summary of PID performance", 1200, 500); cPidPerformance->Divide(3,1); cPidPerformance->cd(1); gPad->SetLogz(); hDiffTimePi->Draw("colz"); cPidPerformance->cd(2); gPad->SetLogz(); hDiffTimeKa->Draw("colz"); cPidPerformance->cd(3); gPad->SetLogz(); hDiffTimePro->Draw("colz"); cPidPerformance->Print(Form("%s/cPIDExpTimes.%s", plotDir.Data(), plotext.Data())); if (displayAll) { TCanvas* cPeakT0AVsRun = new TCanvas("cPeakT0AVsRun","cPeakT0AVsRun", 50,50,1050, 550); hPeakT0AVsRun->Draw(); cPeakT0AVsRun->Print(Form("%s/cPeakT0AVsRun.png",plotDir.Data())); TCanvas* cPeakT0CVsRun = new TCanvas("cPeakT0CVsRun","cPeakT0CVsRun", 50,50,1050, 550); hPeakT0CVsRun->Draw(); cPeakT0CVsRun->Print(Form("%s/cPeakT0CVsRun.png",plotDir.Data())); TCanvas* cPeakT0ACVsRun = new TCanvas("cPeakT0ACVsRun","cPeakT0ACVsRun", 50,50,1050, 550); hPeakT0ACVsRun->Draw(); cPeakT0ACVsRun->Print(Form("%s/cPeakT0ACVsRun.png",plotDir.Data())); TCanvas* cT0fillResVsRun = new TCanvas("cT0fillResVsRun","cT0fillResVsRun", 50,50,1050, 550); hT0fillResVsRun->Draw(); cT0fillResVsRun->Print(Form("%s/cT0fillResVsRun.png",plotDir.Data())); //Plot TOF signal trend TCanvas* cAvDiffTimeVsRun = new TCanvas("cAvDiffTimeVsRun","cAvDiffTimeVsRun",50,50,1050, 550); gPad->SetGridx(); gPad->SetGridy(); hAvDiffTimeVsRun->Draw(); cAvDiffTimeVsRun->Print(Form("%s/cAvDiffTimeVsRun.png",plotDir.Data())); TCanvas* cAvTimeVsRun = new TCanvas("cAvTimeVsRun","cAvTimeVsRun", 50,50,1050, 550); hAvTimeVsRun->Draw(); cAvTimeVsRun->Print(Form("%s/cAvTimeVsRun.png",plotDir.Data())); TCanvas* cPeakTimeVsRun = new TCanvas("cPeakTimeVsRun","cPeakTimeVsRun", 50,50,1050, 550); hPeakTimeVsRun->Draw(); cPeakTimeVsRun->Print(Form("%s/cPeakTimeVsRun.png",plotDir.Data())); TCanvas* cSpreadTimeVsRun = new TCanvas("cSpreadTimeVsRun","cSpreadTimeVsRun", 50,50,1050, 550); hSpreadTimeVsRun->Draw(); cSpreadTimeVsRun->Print(Form("%s/cSpreadTimeVsRun.png",plotDir.Data())); TCanvas* cAvRawTimeVsRun = new TCanvas("cAvRawTimeVsRun","cAvRawTimeVsRun", 50,50,1050, 550); hAvRawTimeVsRun->Draw(); cAvRawTimeVsRun->Print(Form("%s/cAvRawTimeVsRun.png",plotDir.Data())); TCanvas* cPeakRawTimeVsRun = new TCanvas("cPeakRawTimeVsRun","cPeakRawTimeVsRun", 50,50,1050, 550); hPeakRawTimeVsRun->Draw(); cPeakRawTimeVsRun->Print(Form("%s/cPeakRawTimeVsRun.png",plotDir.Data())); TCanvas* cSpreadRawTimeVsRun = new TCanvas("cSpreadRawTimeVsRun","cSpreadRawTimeVsRun", 50,50,1050, 550); hSpreadRawTimeVsRun->Draw(); cSpreadRawTimeVsRun->Print(Form("%s/cSpreadRawTimeVsRun.png",plotDir.Data())); TCanvas* cAvTotVsRun = new TCanvas("cAvTotVsRun","cAvTotVsRun", 50,50,1050, 550); hAvTotVsRun->Draw(); cAvTotVsRun->Print(Form("%s/cAvTotVsRun.png",plotDir.Data())); TCanvas* cPeakTotVsRun = new TCanvas("cPeakTotVsRun","cPeakTotVsRun", 50,50,1050, 550); hPeakTotVsRun->Draw(); cPeakTotVsRun->Print(Form("%s/cPeakTotVsRun.png",plotDir.Data())); TCanvas* cSpreadTotVsRun = new TCanvas("cSpreadTotVsRun","cSpreadTotVsRun", 50,50,1050, 550); hSpreadTotVsRun->Draw(); cSpreadTotVsRun->Print(Form("%s/cSpreadTotVsRun.png",plotDir.Data())); TCanvas* cNegTimeRatioVsRun = new TCanvas("cNegTimeRatioVsRun","cNegTimeRatioVsRun", 50,50,1050, 550); hNegTimeRatioVsRun->Draw(); cNegTimeRatioVsRun->Print(Form("%s/cNegTimeRatioVsRun.png",plotDir.Data())); TCanvas* cOrphansRatioVsRun = new TCanvas("cOrphansRatioVsRun","cOrphansRatioVsRun", 50,50,1050, 550); hOrphansRatioVsRun->Draw(); cOrphansRatioVsRun->Print(Form("%s/cOrphansRatioVsRun.png",plotDir.Data())); TCanvas* cMeanLVsRun = new TCanvas("cMeanLVsRun","cMeanLVsRun", 50,50,1050, 550); hMeanLVsRun->Draw(); cMeanLVsRun->Print(Form("%s/cMeanLVsRun.png",plotDir.Data())); TCanvas* cNegLRatioVsRun = new TCanvas("cNegLRatioVsRun","cNegLRatioVsRun", 50,50,1050, 550); hNegLRatioVsRun->Draw(); cNegLRatioVsRun->Print(Form("%s/cNegLRatioVsRun.png",plotDir.Data())); } return 0; }
void DeltaPhiPhoMETMax(double pt1_cutIN,double pt2_cutIN,double MET_cutIN, double DPHI_cutIN){ cout<<"#### Max[DeltaPhi(MET,pho1),DeltaPhi(MET,pho2)] #####"<<endl; gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); TLegend* leg = new TLegend(0.13,0.55,0.68,0.87); leg->SetNColumns(2); leg->SetBorderSize(0); leg->SetFillStyle(0); TLegend* leg_norm = new TLegend(0.13,0.5,0.7,0.87); leg_norm->SetNColumns(2); leg_norm->SetBorderSize(0); leg_norm->SetFillStyle(0); TCanvas *canvas = new TCanvas("c1n","",1100,500); canvas->Divide(2,1); canvas->cd(1); 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 METcut = Form("t1pfmet>%lf",MET_cutIN); TCut DPHIcut = Form("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhi)>%lf",DPHI_cutIN); TCut NegWeight = "weight>0."; 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"); tree_data->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hdata(25,0,3.5)",(mggblind && mggmax && mggmin && metF && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata"); hdata->SetMarkerColor(kBlack); hdata->SetMarkerStyle(20); hdata->SetLineColor(kBlack); tree_sig1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h1(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h2(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h3(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h4(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h5(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); tree_sig6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h6(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6"); tree_sig7->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h7(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7"); tree_bkg1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg1(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg2(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg3(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg4(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg5(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg6(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg7(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg8(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg9(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut && NegWeight)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9"); tree_bkg10->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg10(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg11(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg12(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12"); /* 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 25ns samples h6->SetLineColor(kPink+7); //only for 25ns samples h7->SetLineColor(kMagenta+2); //only for 25ns samples h1->SetLineWidth(2); h2->SetLineWidth(2); h3->SetLineWidth(2); h4->SetLineWidth(2); h5->SetLineWidth(2); //only for 25ns samples h6->SetLineWidth(2); //only for 25ns samples h7->SetLineWidth(2); //only for 25ns 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+3); 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(700); // hs->SetMinimum(0.0001); hdata->SetTitle(""); hdata->Draw("e1"); hsum->SetMarkerStyle(1); hsum->SetFillColor(kGray+3); hsum->SetFillStyle(3001); 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 25ns samples h6->Draw("same hist"); //only for 25ns samples h7->Draw("same hist"); //only for 25ns samples hdata->Draw("same e1"); hdata->GetXaxis()->SetTitle("max[|#Delta#phi(#gamma_{1},MET)|,|#Delta#phi(#gamma_{2},MET)|]"); hdata->GetYaxis()->SetTitleOffset(1.2); hdata->GetYaxis()->SetTitle("Events/0.1 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 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); tree_data->Scan("event:lumi:run:t1pfmet",(mggblind && METcut && metF && pt1cut && pt2cut)*"max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>2.5"); canvas->cd(2); tree_sig1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h1_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h1_norm =(TH1F*)gPad->GetPrimitive("h1_norm"); tree_sig2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h2_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h2_norm =(TH1F*)gPad->GetPrimitive("h2_norm"); tree_sig3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h3_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h3_norm =(TH1F*)gPad->GetPrimitive("h3_norm"); tree_sig4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h4_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h4_norm =(TH1F*)gPad->GetPrimitive("h4_norm"); tree_sig5->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h5_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h5_norm =(TH1F*)gPad->GetPrimitive("h5_norm"); tree_sig6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h6_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h6_norm =(TH1F*)gPad->GetPrimitive("h6_norm"); tree_sig7->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h7_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h7_norm =(TH1F*)gPad->GetPrimitive("h7_norm"); tree_bkg1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg1_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg1_norm =(TH1F*)gPad->GetPrimitive("hbkg1_norm"); tree_bkg2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg2_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg2_norm =(TH1F*)gPad->GetPrimitive("hbkg2_norm"); tree_bkg3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg3_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg3_norm =(TH1F*)gPad->GetPrimitive("hbkg3_norm"); tree_bkg4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg4_norm(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg5_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg5_norm =(TH1F*)gPad->GetPrimitive("hbkg5_norm"); tree_bkg6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg6_norm(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg7_norm(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg8_norm(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg9_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut && NegWeight)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg9_norm =(TH1F*)gPad->GetPrimitive("hbkg9_norm"); tree_bkg10->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg10_norm(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg11_norm(25,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("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg12_norm(25,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"); 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("max[|#Delta#phi(#gamma_{1},MET)|,|#Delta#phi(#gamma_{2},MET)|]"); h1_norm->GetYaxis()->SetTitle("Normalized events"); h1_norm->GetYaxis()->SetTitleOffset(1.2); gPad->Modified(); gStyle->SetOptStat(0); 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"); TPad *p1 = ((TPad*)(canvas->GetPad(1))); TPad *p2 = ((TPad*)(canvas->GetPad(2))); // int iPos =0; // CMS_lumi(p1,true,iPos,true); //CMS_lumi(p2,true,iPos,true); if(pt1_cutIN==0 && pt2_cutIN == 0 && MET_cutIN == 0){ canvas->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET.png"); canvas->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET.pdf"); } if(pt1_cutIN==0.65 && pt2_cutIN == 0.25){ canvas->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET_optcuts_MET%.0lf.png",MET_cutIN)); canvas->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET_optcuts_MET%.0lf.pdf",MET_cutIN)); } }
void printYieldPlot(const string origName="../../../WprimeWZ.root"){ TFile *fOrig = TFile::Open(origName.c_str(), "read"); assert(fOrig); map<string, TH1F*> hists[nch]; vector<string> bkgSamples = BkgSamples(); for(int iBkg=0; iBkg<(int)bkgSamples.size(); ++iBkg){ for(int ch=0; ch<nch; ++ch){ hists[ch][bkgSamples[iBkg]] = new TH1F(Form("%s_ch%i", bkgSamples[iBkg].c_str(), ch), "", 40, 0, 2000); for(int mass=0; mass<=2000; mass+=50){ //cout<<bkgSamples[iBkg]<<" "<<ch<<" "<<mass<<endl; string cuts = Form("weight*(%s)*(EvtType == %i)", AnalysisCuts(mass).c_str(), ch); Value origYield = GetNEvtsAndError(fOrig, bkgSamples[iBkg], "tEvts_MET", cuts); hists[ch][bkgSamples[iBkg]]->Fill(mass, origYield.val); } } } //Data for(int ch=0; ch<nch; ++ch){ hists[ch]["data"] = new TH1F(Form("%s_ch%i", "data", ch), "", 40, 0, 2000); for(int mass=0; mass<=2000; mass+=50){ //cout<<"data"<<" "<<ch<<" "<<mass<<endl; string cuts = Form("weight*(%s)*(EvtType == %i)", AnalysisCuts(mass).c_str(), ch); Value origYield = GetNEvtsAndError(fOrig, "data", "tEvts_MET", cuts); hists[ch]["data"]->Fill(mass, origYield.val); } } TCanvas* c = new TCanvas("c", ""); c->Divide(2,2); TLegend *leg = new TLegend(0.5, 0.55,0.9, 0.89,""); prepLegend(leg); leg->SetNColumns(2); leg->SetColumnSeparation(0.05); THStack* stacks[nch]; for(int ch=0; ch<nch; ++ch){ c->cd(1+ch)->SetLogy(); stacks[ch] = new THStack(Form("BkgCh%i", ch), Form("Background Yield By Mass Point (%s)", binLatex(ch).c_str())); for(int iBkg=bkgSamples.size()-1; iBkg>=0; --iBkg){ int fillColor; if(iBkg==0) fillColor = kOrange-2; if(iBkg==1) fillColor = kOrange+7; if(iBkg==2) fillColor = kViolet+2; if(iBkg==3) fillColor = kGray; if(iBkg==4) fillColor = kOrange+3; string legName; if(iBkg==0) legName = "WZ"; if(iBkg==1) legName = "Z+Jets"; if(iBkg==2) legName = "t\\bar{t}"; if(iBkg==3) legName = "Z#gamma"; if(iBkg==4) legName = "ZZ"; hists[ch][bkgSamples[iBkg]]->SetFillColor(fillColor); //hists[ch][bkgSamples[iBkg]]->SetLineColor(fillColor); stacks[ch]->Add(hists[ch][bkgSamples[iBkg]]); if(ch==0) leg->AddEntry(hists[ch][bkgSamples[iBkg]], legName.c_str(), "F"); } //Data hists[ch]["data"]->SetMarkerStyle(20); //hists[ch]["data"]->SetLineColor(fillColor); if(ch==0) leg->AddEntry(hists[ch]["data"], "Data", "PE"); stacks[ch]->Draw("hist"); stacks[ch]->SetMaximum(50); stacks[ch]->SetMinimum(1e-2); hists[ch]["data"]->Draw("E SAME"); leg->Draw(); } c->SaveAs("BkgYieldByMassPoint.png"); }
//This program takes 4 inputs: the half range of the fixed position, the min and max of the varying position, and the step size of the slice examined //This program is easier to understand after reading resolutionChain.cpp int main(int argc, char *argv[]){ const float FIXMAX = atof(argv[1]), VARMIN = atof(argv[2]), VARMAX = atof(argv[3]), STEP = atof(argv[4]); //Assigning inputs TCanvas *c = new TCanvas("c", "c", 1800, 600); c->Divide(3,1); //Creating multigraphs for final output TMultiGraph *mgX = new TMultiGraph("mgX", "Normalized Calibration Constant on X"); TMultiGraph *mgY = new TMultiGraph("mgY", "Normalized Calibration Constant on Y"); TMultiGraph *mgXY = new TMultiGraph("mgXY", "Ratio of Normalized Calibration Constants for Y/X"); TString filename; TFile *file; int range = (int) (VARMAX - VARMIN); //Number of graphs for each multigraph range++; //Adding one to account for the edge. This is separate just to remember that it has to happen vector<TGraphErrors*> graphs(range*3); //Vector of TGraphErrors, for each graph of the 3 multigraphs //Loop to get each of the graphs created by resolutionChain.cpp. Also sets line color, marker color, and line style. For color, different shades of blue are used for comparison for(int i = 0; i < range; i++){ filename.Form("./ResolutionX/%g_%g_%g/resolutionX_%g_%g_%g.root", FIXMAX, VARMIN+i, STEP, FIXMAX, VARMIN+i, STEP); file = TFile::Open(filename.Data()); graphs.at(i) = (TGraphErrors*) file->Get("gr"); graphs.at(i)->SetLineColor(kBlue+3*(i-3)); graphs.at(i)->SetMarkerColor(kBlue+3*(i-3)); graphs.at(i)->SetMarkerStyle(20+i); filename.Form("./ResolutionY/%g_%g_%g/resolutionY_%g_%g_%g.root", FIXMAX, VARMIN+i, STEP, FIXMAX, VARMIN+i, STEP); file = TFile::Open(filename.Data()); graphs.at(i+range) = (TGraphErrors*) file->Get("gr"); graphs.at(i+range)->SetLineColor(kBlue+3*(i-3)); graphs.at(i+range)->SetMarkerColor(kBlue+3*(i-3)); graphs.at(i+range)->SetMarkerStyle(20+i); } ///////////////////////// Normalizing the X and Y Plots ///////////////////////// float max1 = 0, max2 = 0; int N = (int) graphs.at(0)->GetN(); int numPts = 2*(3-(-3))/STEP; //Number of points between -3 and 3 - just makes it clear where the number comes from. Normalization is done within this range. if(numPts > N) numPts = N; //If the range is less than -3 to 3, sets the number of points to the max possible int startPt = (N - numPts)/2; int endPt = startPt + numPts; //Finding the maximum value in the range of all graphs for(int pt = startPt; pt < endPt; pt++){ for(int grs = 0; grs < range; grs++){ if(max1 < graphs.at(grs)->GetY()[pt]) max1 = graphs.at(grs)->GetY()[pt]; if(max2 < graphs.at(grs+range)->GetY()[pt]) max2 = graphs.at(grs+range)->GetY()[pt]; } } //Scales each point in each graph by the appropriate normalization factor. Also, creates the ratio graphs, propagates error, and adds each graph to the proper multigraph for(int grs = 0; grs < range; grs++){ double ratio[2*N]; double errRatioX[2*N]; double errRatioY[2*N]; double eX1, eX2, eY1, eY2, ptX, ptY; for(int i = 0; i < graphs.at(grs)->GetN(); i++){ graphs.at(grs)->GetY()[i] = (graphs.at(grs)->GetY()[i])/max1; graphs.at(grs+range)->GetY()[i] = (graphs.at(grs+range)->GetY()[i])/max2; graphs.at(grs)->GetEY()[i] = (graphs.at(grs)->GetEY()[i])/max1; graphs.at(grs+range)->GetEY()[i] = (graphs.at(grs+range)->GetEY()[i])/max2; ptX = graphs.at(grs)->GetY()[i]; ptY = graphs.at(grs+range)->GetY()[i]; ratio[i] = ptY/ptX; eX1 = graphs.at(grs)->GetEX()[i]; eY1 = graphs.at(grs)->GetEY()[i]; eX2 = graphs.at(grs+range)->GetEX()[i]; eY2 = graphs.at(grs+range)->GetEY()[i]; errRatioX[i] = eX1; errRatioY[i] = ratio[i]*sqrt((eY1*eY1)/(ptY*ptY) + (eY2*eY2)/(ptY*ptY)); } mgX->Add(graphs.at(grs)); mgY->Add(graphs.at(grs+range)); graphs.at(grs+2*range) = new TGraphErrors(graphs.at(grs)->GetN(), graphs.at(grs)->GetX(), ratio, errRatioX, errRatioY); graphs.at(grs+2*range)->SetLineColor(kBlue+3*(grs-3)); graphs.at(grs+2*range)->SetMarkerColor(kBlue+3*(grs-3)); graphs.at(grs+2*range)->SetMarkerStyle(20+grs); mgXY->Add(graphs.at(grs+2*range)); } //Used to fit stuff, but it wasn't all that necessary // TF1 *p1 = new TF1("p1", "[0]*(x-[1])*(x-[2]) + [3]", -1*FIXMAX, FIXMAX); // TF1 *p2 = new TF1("p2", "[0]*(x-[1])*(x-[2]) + [3]", -1*FIXMAX, FIXMAX); // // p1->SetParameters(-1, 0, 0, 1); // p2->SetParameters(-1, 0, 0, 1); // // graphs.at(range-1)->Fit(p1, "RQME"); // graphs.at(2*range-1)->Fit(p2, "RQME"); // // float fitmax1 = p1->GetParameter(1); // float fitmax2 = p2->GetParameter(1); // // float fitDiff = fitmax1 - fitmax2; // // cout << "X Center: " << fitmax1 << " Y Center: " << fitmax2 << " Difference: " << fitDiff << endl; ///////////////////////// Drawing the X Graph ///////////////////////// c->cd(1); mgX->Draw("apl"); mgX->GetXaxis()->SetTitle("Hodoscope X Position (mm)"); mgX->GetYaxis()->SetTitle("m2/m1"); mgX->GetYaxis()->SetTitleOffset(1.75); mgX->GetYaxis()->SetRangeUser(.9, 1.05); c->SetLeftMargin(0.15); TLegend* legX = new TLegend(0.1,0.1,0.5,0.3); legX->SetNColumns(2); TString entryName; for(int i = 0; i < range; i++){ entryName.Form("Y in [-%g,%g]", (VARMIN+i)/2, (VARMIN+i)/2); legX->AddEntry(graphs.at(i),entryName.Data(),"lp"); } legX->Draw(); //p1->Draw("same"); ///////////////////////// Drawing the Y Graph ///////////////////////// c->cd(2); mgY->Draw("apl"); mgY->GetXaxis()->SetTitle("Hodoscope Y Position (mm)"); mgY->GetYaxis()->SetTitle("m2/m1"); mgY->GetYaxis()->SetTitleOffset(1.75); mgY->GetYaxis()->SetRangeUser(.9, 1.05); c->SetLeftMargin(0.15); TLegend* legY = new TLegend(0.1,0.1,0.5,0.3); legY->SetNColumns(2); for(int i = 0; i < range; i++){ entryName.Form("X in [-%g,%g]", (VARMIN+i)/2, (VARMIN+i)/2); legY->AddEntry(graphs.at(i+range), entryName.Data(), "lp"); } legY->Draw(); //p2->Draw("same"); ///////////////////////// Drawing the Ratio ///////////////////////// c->cd(3); mgXY->Draw("apl"); mgXY->GetXaxis()->SetTitle("Hodoscope Position (mm)"); mgXY->GetYaxis()->SetTitle("(my2/my1)/(mx2/mx1)"); mgXY->GetYaxis()->SetTitleOffset(1.75); mgXY->GetYaxis()->SetRangeUser(.95, 1.05); c->SetLeftMargin(0.15); TLegend* legXY = new TLegend(0.1,0.1,0.5,0.3); legXY->SetNColumns(2); for(int i = 0; i < range; i++){ entryName.Form("Range in [-%g,%g]", (VARMIN+i)/2, (VARMIN+i)/2); legXY->AddEntry(graphs.at(i+2*range),entryName.Data(),"lp"); } legXY->Draw(); ///////////////////////// Saving ///////////////////////// TString saveName; saveName.Form("Resolution Comparison %g_%g-%g_%g.png", FIXMAX, VARMIN, VARMAX, STEP); c->SaveAs(saveName.Data()); saveName.Form("Resolution Comparison %g_%g-%g_%g.root", FIXMAX, VARMIN, VARMAX, STEP); c->SaveAs(saveName.Data()); return 1; }
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)); }
void makePlots_hltEleHT_TTcr( bool printPDF_ = false, int useSample_ = 0 ){ TH1::SetDefaultSumw2(); int NumSamples = 3; TFile* file[NumSamples]; file[0] = new TFile("HistoFiles/hltEleHT_treeReader_TTcr_TT_13TeV_Spring15_Asympt25ns_histo.root"); file[1] = new TFile("HistoFiles/hltEleHT_treeReader_TTcr_ttHTobb_M125_13TeV_powheg_pythia8_Spring15_Asympt25ns_histo.root"); file[2] = new TFile("HistoFiles/hltEleHT_treeReader_TTcr_SingleElectron_Run2015D_PromptReco_254231_258158_histo.root"); std::vector<TString> histLabels(NumSamples); histLabels[0] = "TTJets"; histLabels[1] = "ttHTobb"; histLabels[2] = "Data"; Color_t color[5]; color[0] = kBlack; color[1] = kBlue; color[2] = kRed; color[3] = kGreen+1; // color[2] = kBlack; // color[3] = kGreen+1; // color[4] = kMagenta+2; // color[5] = kRed+1; // color[6] = kGreen-5; // color[7] = kRed+3; std::vector<std::vector<int> > projection_start_bins; std::vector<std::vector<int> > projection_end_bins; std::vector<std::vector<TString> > projection_labels; // elePt std::vector<int> proj_elePt_start_bins; proj_elePt_start_bins.push_back(1); proj_elePt_start_bins.push_back(4); proj_elePt_start_bins.push_back(6); proj_elePt_start_bins.push_back(7); std::vector<int> proj_elePt_end_bins; proj_elePt_end_bins.push_back(12); proj_elePt_end_bins.push_back(5); proj_elePt_end_bins.push_back(8); proj_elePt_end_bins.push_back(12); std::vector<TString> proj_elePt_labels; proj_elePt_labels.push_back("elePt30toInf"); proj_elePt_labels.push_back("elePt30to50"); proj_elePt_labels.push_back("elePt50to80"); proj_elePt_labels.push_back("elePt80toInf"); // numJet std::vector<int> proj_numJet_start_bins; proj_numJet_start_bins.push_back(1); proj_numJet_start_bins.push_back(1); proj_numJet_start_bins.push_back(4); proj_numJet_start_bins.push_back(5); std::vector<int> proj_numJet_end_bins; proj_numJet_end_bins.push_back(8); proj_numJet_end_bins.push_back(3); proj_numJet_end_bins.push_back(4); proj_numJet_end_bins.push_back(8); std::vector<TString> proj_numJet_labels; proj_numJet_labels.push_back("numJet0toInf"); proj_numJet_labels.push_back("numJet0to2"); proj_numJet_labels.push_back("numJet3to3"); proj_numJet_labels.push_back("numJet4toInf"); projection_start_bins.push_back(proj_elePt_start_bins); projection_end_bins.push_back(proj_elePt_end_bins); projection_labels.push_back(proj_elePt_labels); projection_start_bins.push_back(proj_numJet_start_bins); projection_end_bins.push_back(proj_numJet_end_bins); projection_labels.push_back(proj_numJet_labels); projection_start_bins.push_back(proj_elePt_start_bins); projection_end_bins.push_back(proj_elePt_end_bins); projection_labels.push_back(proj_elePt_labels); projection_start_bins.push_back(proj_elePt_start_bins); projection_end_bins.push_back(proj_elePt_end_bins); projection_labels.push_back(proj_elePt_labels); std::vector<int> NumProjBins; NumProjBins.push_back( int(proj_elePt_labels.size()) ); NumProjBins.push_back( int(proj_numJet_labels.size()) ); NumProjBins.push_back( int(proj_elePt_labels.size()) ); NumProjBins.push_back( int(proj_elePt_labels.size()) ); TString dirprefix = "Images/Images_2015_10_13_hltEleHT_TTcr_" + histLabels[useSample_] + "/"; struct stat st; if( stat(dirprefix.Data(),&st) != 0 ) mkdir(dirprefix.Data(),0777); ///////////////////////////////////////////////////////////////////////////////////////////////////////////// std::vector<std::string> histoname1; std::vector<std::string> histoname2; std::vector<std::string> histoname3; histoname1.push_back("h_HT30"); histoname1.push_back("h_HT30er"); histoname1.push_back("h_HT30_4j"); histoname2.push_back("elePt"); histoname2.push_back("numJet"); histoname2.push_back("eleEBPt"); histoname2.push_back("eleEEPt"); histoname3.push_back("h_event_selection"); ///////////////////////////////////////////////////////////////////////////////////////////////////////////// TGaxis::SetMaxDigits(3); TString lumiinfo = "553 pb^{-1} (13 TeV)"; TLatex LumiInfoLatex(0.65, 0.94, lumiinfo); LumiInfoLatex.SetNDC(); LumiInfoLatex.SetTextFont(42); LumiInfoLatex.SetTextSize(0.04); //TString cmsinfo = "CMS Preliminary"; TString cmsinfo = "CMS"; TLatex CMSInfoLatex(0.13, 0.94, cmsinfo); CMSInfoLatex.SetNDC(); CMSInfoLatex.SetTextFont(42); CMSInfoLatex.SetTextFont(61); CMSInfoLatex.SetTextSize(0.055); //SBOUTLE std::string publishinfo = "Preliminary"; //DPUIGH TLatex PublishInfoLatex(0.26, 0.94, publishinfo.c_str()); //SBOUTLE PublishInfoLatex.SetNDC(); PublishInfoLatex.SetTextFont(52); PublishInfoLatex.SetTextSize(0.045); //SBOUTLE TString plotname; TCanvas* c1 = new TCanvas("c1", "c1", 600,700); TH2D* h_L1HTT_elePt = (TH2D*)file[useSample_]->Get("h_L1HTT_elePt"); TH2D* h_HT30_HT30er = (TH2D*)file[useSample_]->Get("h_HT30_HT30er"); TH2D* h_HT30_L1HTT = (TH2D*)file[useSample_]->Get("h_HT30_L1HTT"); TProfile* p_L1HTT_elePt = (TProfile*)h_L1HTT_elePt->ProfileX("p_L1HTT_elePt"); // TProfile* p_HT30_HT30er = (TProfile*)h_HT30_HT30er->ProfileX("p_HT30_HT30er"); // TProfile* p_HT30_L1HTT = (TProfile*)h_HT30_L1HTT->ProfileX("p_HT30_L1HTT"); p_L1HTT_elePt->SetMarkerStyle(20); h_L1HTT_elePt->Draw("colz"); p_L1HTT_elePt->Draw("pe1same"); plotname = dirprefix + "h_L1HTT_elePt" + "_2D_colz.png"; c1->Print(plotname); h_HT30_HT30er->Draw("colz"); //p_HT30_HT30er->Draw("pe1same"); plotname = dirprefix + "h_HT30_HT30er" + "_2D_colz.png"; c1->Print(plotname); h_HT30_L1HTT->Draw("colz"); //p_HT30_L1HTT->Draw("pe1same"); plotname = dirprefix + "h_HT30_L1HTT" + "_2D_colz.png"; c1->Print(plotname); for( int i=0; i<int(histoname1.size()); i++ ){ for( int j=0; j<int(histoname2.size()); j++ ){ for( int k=0; k<2; k++ ){ TString temp = histoname1[i]; TString suffix = histoname2[j]; TString l1suffix = ( k==0 ) ? "125" : "100"; if( temp!="h_HT30" && suffix!="elePt" ) continue; TString temp_L1 = temp + "_L1HTT" + l1suffix + "_" + suffix; TString temp_HLT = temp + "_L1HTT" + l1suffix + "_passHLTEle27HT200_" + suffix; TString temp_mh = temp; temp_mh.ReplaceAll("h_",""); temp = temp + "_" + suffix; //TLegend *legend = new TLegend(0.2,0.83,0.9,0.89); TLegend *legend = new TLegend(0.2,0.85,0.9,0.91); legend->SetFillColor(kWhite); legend->SetLineColor(kWhite); legend->SetShadowColor(kWhite); legend->SetTextFont(42); legend->SetTextSize(0.04); legend->SetNColumns(2); int rebin = ( useSample_==2 ) ? 25 : 10; TH2D* h_all = (TH2D*)file[useSample_]->Get(temp)->Clone(temp+"_"+suffix+"_"+l1suffix); TH2D* h_l1t = (TH2D*)file[useSample_]->Get(temp_L1)->Clone(temp_L1+"_"+suffix+"_"+l1suffix); TH2D* h_hlt = (TH2D*)file[useSample_]->Get(temp_HLT)->Clone(temp_HLT+"_"+suffix+"_"+l1suffix); TH2D* h_temp_hlt_all = (TH2D*)h_all->Clone("h_temp_hlt_all_"+suffix+"_"+l1suffix); TH2D* h_temp_l1t_all = (TH2D*)h_all->Clone("h_temp_l1t_all_"+suffix+"_"+l1suffix); TH2D* h_temp_hlt_l1t = (TH2D*)h_l1t->Clone("h_temp_hlt_l1t_"+suffix+"_"+l1suffix); TH2D* h_ratio_hlt_all = (TH2D*)h_hlt->Clone("h_ratio_hlt_all_"+suffix+"_"+l1suffix); TH2D* h_ratio_l1t_all = (TH2D*)h_l1t->Clone("h_ratio_l1t_all_"+suffix+"_"+l1suffix); TH2D* h_ratio_hlt_l1t = (TH2D*)h_hlt->Clone("h_ratio_hlt_l1t_"+suffix+"_"+l1suffix); h_temp_hlt_all->RebinY(rebin); h_temp_l1t_all->RebinY(rebin); h_temp_hlt_l1t->RebinY(rebin); h_ratio_hlt_all->RebinY(rebin); h_ratio_l1t_all->RebinY(rebin); h_ratio_hlt_l1t->RebinY(rebin); h_ratio_hlt_all->Divide(h_temp_hlt_all); h_ratio_l1t_all->Divide(h_temp_l1t_all); h_ratio_hlt_l1t->Divide(h_temp_hlt_l1t); TProfile* p_all = (TProfile*)h_all->ProfileX("p_all"); TProfile* p_l1t = (TProfile*)h_l1t->ProfileX("p_l1t"); TProfile* p_hlt = (TProfile*)h_hlt->ProfileX("p_hlt"); p_all->SetMarkerStyle(20); p_l1t->SetMarkerStyle(20); p_hlt->SetMarkerStyle(20); h_all->Draw("colz"); p_all->Draw("pe1same"); plotname = dirprefix + temp + "_2D_colz.png"; c1->Print(plotname); h_l1t->Draw("colz"); p_l1t->Draw("pe1same"); plotname = dirprefix + temp_L1 + "_2D_colz.png"; c1->Print(plotname); h_hlt->Draw("colz"); p_hlt->Draw("pe1same"); plotname = dirprefix + temp_HLT + "_2D_colz.png"; c1->Print(plotname); h_ratio_hlt_all->SetStats(0); h_ratio_hlt_all->GetYaxis()->SetRangeUser(0.,400.); h_ratio_hlt_all->Draw("colz"); plotname = dirprefix + "h_ratio_hlt_all" + "_2D_colz.png"; c1->Print(plotname); h_ratio_l1t_all->SetStats(0); h_ratio_l1t_all->GetYaxis()->SetRangeUser(0.,400.); h_ratio_l1t_all->Draw("colz"); plotname = dirprefix + "h_ratio_l1t_all" + "_2D_colz.png"; c1->Print(plotname); h_ratio_hlt_l1t->SetStats(0); h_ratio_hlt_l1t->GetYaxis()->SetRangeUser(0.,400.); h_ratio_hlt_l1t->Draw("colz"); plotname = dirprefix + "h_ratio_hlt_l1t" + "_2D_colz.png"; c1->Print(plotname); int numProjBin = NumProjBins[j]; TH1D* h_py_all[numProjBin]; TH1D* h_py_l1t[numProjBin]; TH1D* h_py_hlt[numProjBin]; TEfficiency* eff_hlt_all[numProjBin]; TEfficiency* eff_l1t_all[numProjBin]; TEfficiency* eff_hlt_l1t[numProjBin]; for( int iBin=0; iBin<numProjBin; iBin++ ){ int bin_start = projection_start_bins[j][iBin]; int bin_end = projection_end_bins[j][iBin]; h_py_all[iBin] = (TH1D*)h_all->ProjectionY(Form("h_py_all_%d",iBin),bin_start,bin_end); h_py_l1t[iBin] = (TH1D*)h_l1t->ProjectionY(Form("h_py_l1t_%d",iBin),bin_start,bin_end); h_py_hlt[iBin] = (TH1D*)h_hlt->ProjectionY(Form("h_py_hlt_%d",iBin),bin_start,bin_end); h_py_all[iBin]->Rebin(rebin); h_py_l1t[iBin]->Rebin(rebin); h_py_hlt[iBin]->Rebin(rebin); eff_l1t_all[iBin] = makeEfficiency(h_py_l1t[iBin], h_py_all[iBin]); eff_hlt_l1t[iBin] = makeEfficiency(h_py_hlt[iBin], h_py_l1t[iBin]); eff_hlt_all[iBin] = makeEfficiency(h_py_hlt[iBin], h_py_all[iBin]); eff_l1t_all[iBin]->SetLineColor(color[iBin]); eff_l1t_all[iBin]->SetMarkerColor(color[iBin]); eff_l1t_all[iBin]->SetMarkerStyle(20); eff_hlt_l1t[iBin]->SetLineColor(color[iBin]); eff_hlt_l1t[iBin]->SetMarkerColor(color[iBin]); eff_hlt_l1t[iBin]->SetMarkerStyle(20); eff_hlt_all[iBin]->SetLineColor(color[iBin]); eff_hlt_all[iBin]->SetMarkerColor(color[iBin]); eff_hlt_all[iBin]->SetMarkerStyle(20); legend->AddEntry(eff_l1t_all[iBin], projection_labels[j][iBin],"pe1"); } h_py_all[0]->SetStats(0); h_py_all[0]->GetYaxis()->SetTitle("Efficiency"); h_py_all[0]->GetYaxis()->SetRangeUser(0.,1.15); h_py_all[0]->GetXaxis()->SetRangeUser(0.,600.); // h_data_all->SetStats(0); c1->SetTopMargin(.07); c1->SetRightMargin(.05); // h_data_all->GetYaxis()->SetTitleOffset(1.0); // h_data_all->GetYaxis()->SetTitleSize(0.05); // h_data_all->GetYaxis()->SetRangeUser(0.,1.15); // if( temp.Contains("_pt") ){ // h_data_all->GetXaxis()->SetRangeUser(0.,150.); // myRatio->GetXaxis()->SetRangeUser(0.,150.); // } //// l1t_all h_py_all[0]->Draw("axis"); for( int iBin=0; iBin<numProjBin; iBin++ ) eff_l1t_all[iBin]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_"+suffix+"_l1t" + l1suffix + "_all_lin.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_"+suffix+"_l1t" + l1suffix + "_all_lin.pdf"; if( printPDF_ ) c1->Print(plotname); //// hlt_all h_py_all[0]->Draw("axis"); for( int iBin=0; iBin<numProjBin; iBin++ ) eff_hlt_all[iBin]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_"+suffix+"_hlt_l1t" + l1suffix + "_all_lin.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_"+suffix+"_hlt_l1t" + l1suffix + "_all_lin.pdf"; if( printPDF_ ) c1->Print(plotname); //// hlt_l1t h_py_all[0]->Draw("axis"); for( int iBin=0; iBin<numProjBin; iBin++ ) eff_hlt_l1t[iBin]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_"+suffix+"_hlt_l1t" + l1suffix + "_lin.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_"+suffix+"_hlt_l1t" + l1suffix + "_lin.pdf"; if( printPDF_ ) c1->Print(plotname); h_py_all[0]->GetYaxis()->SetRangeUser(0.85,1.15); //// l1t_all h_py_all[0]->Draw("axis"); for( int iBin=0; iBin<numProjBin; iBin++ ) eff_l1t_all[iBin]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_"+suffix+"_l1t" + l1suffix + "_all_lin_zoom.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_"+suffix+"_l1t" + l1suffix + "_all_lin_zoom.pdf"; if( printPDF_ ) c1->Print(plotname); //// hlt_all h_py_all[0]->Draw("axis"); for( int iBin=0; iBin<numProjBin; iBin++ ) eff_hlt_all[iBin]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_"+suffix+"_hlt_l1t" + l1suffix + "_all_lin_zoom.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_"+suffix+"_hlt_l1t" + l1suffix + "_all_lin_zoom.png"; if( printPDF_ ) c1->Print(plotname); //// hlt_l1t h_py_all[0]->Draw("axis"); for( int iBin=0; iBin<numProjBin; iBin++ ) eff_hlt_l1t[iBin]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_"+suffix+"_hlt_l1t" + l1suffix + "_lin_zoom.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_"+suffix+"_hlt_l1t" + l1suffix + "_lin_zoom.pdf"; if( printPDF_ ) c1->Print(plotname); delete legend; } // end loop on hists } } if( true ){ TString temp = "h_HT30"; TString temp_L1 = temp + "_L1HTT125"; TString temp_HLT = temp + "_L1HTT125_passHLTEle27HT200"; TString temp_mh = temp; temp_mh.ReplaceAll("h_",""); //TLegend *legend = new TLegend(0.2,0.83,0.9,0.89); TLegend *legend = new TLegend(0.2,0.87,0.85,0.91); legend->SetFillColor(kWhite); legend->SetLineColor(kWhite); legend->SetShadowColor(kWhite); legend->SetTextFont(42); legend->SetTextSize(0.04); legend->SetNColumns(3); int rebin = 25; TH1D* h_all[NumSamples]; TH1D* h_l1t[NumSamples]; TH1D* h_hlt[NumSamples]; TEfficiency* eff_hlt_all[NumSamples]; TEfficiency* eff_l1t_all[NumSamples]; TEfficiency* eff_hlt_l1t[NumSamples]; for( int iSample=0; iSample<NumSamples; iSample++ ){ h_all[iSample] = (TH1D*)file[iSample]->Get(temp.Data())->Clone(Form("%s_%s",temp.Data(),histLabels[iSample].Data())); h_l1t[iSample] = (TH1D*)file[iSample]->Get(temp_L1.Data())->Clone(Form("%s_%s",temp.Data(),histLabels[iSample].Data())); h_hlt[iSample] = (TH1D*)file[iSample]->Get(temp_HLT.Data())->Clone(Form("%s_%s",temp.Data(),histLabels[iSample].Data())); h_all[iSample]->Rebin(rebin); h_l1t[iSample]->Rebin(rebin); h_hlt[iSample]->Rebin(rebin); eff_l1t_all[iSample] = makeEfficiency(h_l1t[iSample], h_all[iSample]); eff_hlt_l1t[iSample] = makeEfficiency(h_hlt[iSample], h_l1t[iSample]); eff_hlt_all[iSample] = makeEfficiency(h_hlt[iSample], h_all[iSample]); eff_l1t_all[iSample]->SetLineColor(color[iSample]); eff_l1t_all[iSample]->SetMarkerColor(color[iSample]); eff_l1t_all[iSample]->SetMarkerStyle(20); eff_hlt_l1t[iSample]->SetLineColor(color[iSample]); eff_hlt_l1t[iSample]->SetMarkerColor(color[iSample]); eff_hlt_l1t[iSample]->SetMarkerStyle(20); eff_hlt_all[iSample]->SetLineColor(color[iSample]); eff_hlt_all[iSample]->SetMarkerColor(color[iSample]); eff_hlt_all[iSample]->SetMarkerStyle(20); legend->AddEntry(eff_l1t_all[iSample], histLabels[iSample],"pl"); } h_all[0]->SetStats(0); h_all[0]->GetYaxis()->SetTitle("Efficiency"); h_all[0]->GetYaxis()->SetRangeUser(0.,1.15); h_all[0]->GetXaxis()->SetRangeUser(0.,600.); //// l1t_all h_all[0]->Draw("axis"); for( int iSample=0; iSample<NumSamples; iSample++ ) eff_l1t_all[iSample]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_compareSamples_l1t_all_lin.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_compareSamples_l1t_all_lin.pdf"; if( printPDF_ ) c1->Print(plotname); //// hlt_all h_all[0]->Draw("axis"); for( int iSample=0; iSample<NumSamples; iSample++ ) eff_hlt_all[iSample]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_compareSamples_hlt_all_lin.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_compareSamples_hlt_all_lin.pdf"; if( printPDF_ ) c1->Print(plotname); //// hlt_l1t h_all[0]->Draw("axis"); for( int iSample=0; iSample<NumSamples; iSample++ ) eff_hlt_l1t[iSample]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_compareSamples_hlt_l1t_lin.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_compareSamples_hlt_l1t_lin.pdf"; if( printPDF_ ) c1->Print(plotname); h_all[0]->GetYaxis()->SetRangeUser(0.85,1.15); //// l1t_all h_all[0]->Draw("axis"); for( int iSample=0; iSample<NumSamples; iSample++ ) eff_l1t_all[iSample]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_compareSamples_l1t_all_lin_zoom.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_compareSamples_l1t_all_lin_zoom.pdf"; if( printPDF_ ) c1->Print(plotname); //// hlt_all h_all[0]->Draw("axis"); for( int iSample=0; iSample<NumSamples; iSample++ ) eff_hlt_all[iSample]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_compareSamples_hlt_all_lin_zoom.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_compareSamples_hlt_all_lin_zoom.pdf"; if( printPDF_ ) c1->Print(plotname); //// hlt_l1t h_all[0]->Draw("axis"); for( int iSample=0; iSample<NumSamples; iSample++ ) eff_hlt_l1t[iSample]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_compareSamples_hlt_l1t_lin_zoom.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_compareSamples_hlt_l1t_lin_zoom.pdf"; if( printPDF_ ) c1->Print(plotname); delete legend; } if( true ){ TString temp = "h_HT30"; std::vector<TString> useL1Name; useL1Name.push_back(temp + "_L1HTT125"); useL1Name.push_back(temp + "_L1HTT100"); std::vector<TString> labelL1Name; labelL1Name.push_back("L1_HTT125"); labelL1Name.push_back("L1_HTT100"); std::vector<Color_t> useColor; useColor.push_back(kBlack); useColor.push_back(kRed); TString temp_mh = temp; temp_mh.ReplaceAll("h_",""); //TLegend *legend = new TLegend(0.2,0.83,0.9,0.89); TLegend *legend = new TLegend(0.15,0.83,0.85,0.89); legend->SetFillColor(kWhite); legend->SetLineColor(kWhite); legend->SetShadowColor(kWhite); legend->SetTextFont(42); legend->SetTextSize(0.04); legend->SetNColumns(2); int rebin = 25; int NumL1Samples = int(useL1Name.size()); TH1D* h_all[NumL1Samples]; TH1D* h_l1t[NumL1Samples]; TEfficiency* eff_l1t_all[NumL1Samples]; for( int iSample=0; iSample<NumL1Samples; iSample++ ){ h_all[iSample] = (TH1D*)file[useSample_]->Get(temp)->Clone(Form("%s_%s",temp.Data(),labelL1Name[iSample].Data())); h_l1t[iSample] = (TH1D*)file[useSample_]->Get(useL1Name[iSample])->Clone(Form("%s_%s",useL1Name[iSample].Data(),labelL1Name[iSample].Data())); h_all[iSample]->Rebin(rebin); h_l1t[iSample]->Rebin(rebin); eff_l1t_all[iSample] = makeEfficiency(h_l1t[iSample], h_all[iSample]); eff_l1t_all[iSample]->SetLineColor(useColor[iSample]); eff_l1t_all[iSample]->SetMarkerColor(useColor[iSample]); eff_l1t_all[iSample]->SetMarkerStyle(20); legend->AddEntry(eff_l1t_all[iSample], labelL1Name[iSample],"pl"); } h_all[0]->SetStats(0); h_all[0]->GetYaxis()->SetTitle("Efficiency"); h_all[0]->GetYaxis()->SetRangeUser(0.,1.15); h_all[0]->GetXaxis()->SetRangeUser(0.,600.); //// l1t_all h_all[0]->Draw("axis"); for( int iSample=0; iSample<NumL1Samples; iSample++ ) eff_l1t_all[iSample]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_compareL1_l1t_all_lin.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_compareL1_l1t_all_lin.pdf"; if( printPDF_ ) c1->Print(plotname); h_all[0]->GetYaxis()->SetRangeUser(0.85,1.15); //// l1t_all h_all[0]->Draw("axis"); for( int iSample=0; iSample<NumL1Samples; iSample++ ) eff_l1t_all[iSample]->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); plotname = dirprefix + temp_mh + "_compareL1_l1t_all_lin_zoom.png"; c1->Print(plotname); plotname = dirprefix + temp_mh + "_compareL1_l1t_all_lin_zoom.pdf"; if( printPDF_ ) c1->Print(plotname); delete legend; } //////////////////////////////////////////////////////////////////////////// TCanvas* myC1 = new TCanvas("myC1", "myC1", 600,700); gStyle->SetPadBorderMode(0); gStyle->SetFrameBorderMode(0); Float_t small = 1.e-5; myC1->Divide(1,2,small,small); const float padding=1e-5; const float ydivide=0.3; myC1->GetPad(1)->SetPad( padding, ydivide + padding , 1-padding, 1-padding); myC1->GetPad(2)->SetPad( padding, padding, 1-padding, ydivide-padding); myC1->GetPad(1)->SetLeftMargin(.11); myC1->GetPad(2)->SetLeftMargin(.11); myC1->GetPad(1)->SetRightMargin(.05); myC1->GetPad(2)->SetRightMargin(.05); myC1->GetPad(1)->SetBottomMargin(.3); myC1->GetPad(2)->SetBottomMargin(.3); myC1->GetPad(1)->Modified(); myC1->GetPad(2)->Modified(); myC1->cd(1); gPad->SetBottomMargin(small); gPad->Modified(); for( int i=0; i<int(histoname3.size()); i++ ){ TString temp = histoname3[i]; TString temp_mh = temp; temp_mh.ReplaceAll("h_",""); //TLegend *legend = new TLegend(0.1,0.91,0.9,0.99); TLegend *legend = new TLegend(0.2,0.83,0.88,0.89); legend->SetFillColor(kWhite); legend->SetLineColor(kWhite); legend->SetShadowColor(kWhite); legend->SetTextFont(42); legend->SetTextSize(0.04); legend->SetNColumns(2); int rebin = 1; if( temp.Contains("_mass") ) rebin = 2; if( temp.Contains("_L1HTT") ) rebin = 2; if( temp.Contains("_met") ) rebin = 5; if( temp.Contains("_jet_") && temp.Contains("_pt") ) rebin = 10; if( temp.Contains("_jet_") && temp.Contains("_eta") ) rebin = 4; if( temp.Contains("_jet_") && temp.Contains("_phi") ) rebin = 4; if( temp.Contains("_csv") ) rebin = 8; if( temp.Contains("_diele_mass_closestZmass") ) rebin = 5; TH1D* h_data = (TH1D*)file[2]->Get(temp.Data()); TH1D* h_mc = (TH1D*)file[0]->Get(temp.Data()); h_data->Rebin(rebin); h_mc->Rebin(rebin); if( temp.Contains("_numPV") ){ h_mc->Scale( h_data->Integral() / h_mc->Integral() ); } h_data->SetLineColor(color[0]); h_mc->SetLineColor(color[2]); h_data->SetMarkerColor(color[0]); h_mc->SetMarkerColor(color[2]); h_data->SetMarkerStyle(20); h_mc->SetMarkerStyle(20); legend->AddEntry(h_data,histLabels[2],"p"); legend->AddEntry(h_mc,histLabels[0],"p"); //c3->SetTopMargin(.05); //c1->SetRightMargin(.05); double ratioMax = 1.6; double ratioMin = 0.5; int nbins = h_data->GetNbinsX(); double xmin = h_data->GetBinLowEdge(1); double xmax = h_data->GetBinLowEdge(nbins) + h_data->GetBinWidth(nbins); TH1D* myRatio = new TH1D("ratio", "", nbins, xmin, xmax ); myRatio->SetStats(0); myRatio->Sumw2(); myRatio->SetLineColor(kBlack); myRatio->SetMarkerColor(kBlack); myRatio->Divide(h_data,h_mc); myRatio->SetMinimum(ratioMin); myRatio->SetMaximum(ratioMax); //myRatio->GetYaxis()->SetNdivisions(50000+404); myRatio->GetYaxis()->SetNdivisions(50000+204); myRatio->GetYaxis()->SetLabelSize(0.1); //make y label bigger myRatio->GetXaxis()->SetLabelSize(0.1); //make y label bigger myRatio->GetXaxis()->SetTitleOffset(1.1); myRatio->GetXaxis()->SetTitle(h_data->GetXaxis()->GetTitle()); //make y label bigger myRatio->GetXaxis()->SetLabelSize(0.12); myRatio->GetXaxis()->SetLabelOffset(0.04); myRatio->GetXaxis()->SetTitleSize(0.12); myRatio->GetYaxis()->SetTitle("Data/MC"); myRatio->GetYaxis()->SetTitleSize(0.09); myRatio->GetYaxis()->SetTitleOffset(.55); myC1->cd(2); gPad->SetTopMargin(small); gPad->SetTickx(); gPad->Modified(); myRatio->GetYaxis()->CenterTitle(kTRUE); if( temp.Contains("_selection") ){ for( int iBin=0; iBin<nbins; iBin++ ) myRatio->GetXaxis()->SetBinLabel(iBin+1,h_data->GetXaxis()->GetBinLabel(iBin+1)); myC1->GetPad(2)->SetBottomMargin(.4); myC1->GetPad(1)->SetRightMargin(.10); myC1->GetPad(2)->SetRightMargin(.10); myRatio->GetXaxis()->SetTitle(""); } else{ myC1->GetPad(2)->SetBottomMargin(.3); myC1->GetPad(1)->SetRightMargin(.05); myC1->GetPad(2)->SetRightMargin(.05); } h_data->SetStats(0); h_data->GetYaxis()->SetTitleOffset(1.0); h_data->GetYaxis()->SetTitleSize(0.05); h_data->GetYaxis()->SetTitle("Number of Events"); int max_bin_data = h_data->GetMaximumBin(); double max_data = h_data->GetBinContent(max_bin_data) + h_data->GetBinError(max_bin_data); int max_bin_mc = h_mc->GetMaximumBin(); double max_mc = h_mc->GetBinContent(max_bin_mc) + h_mc->GetBinError(max_bin_mc); double max_content = std::max(max_data, max_mc); h_data->GetYaxis()->SetRangeUser(0.,1.2 * max_content); if( temp.Contains("_mass") ){ h_data->GetXaxis()->SetRangeUser(40.,140.); myRatio->GetXaxis()->SetRangeUser(40.,140.); } if( temp.Contains("_met") ){ h_data->GetXaxis()->SetRangeUser(0.,150.); myRatio->GetXaxis()->SetRangeUser(0.,150.); } // if( temp.Contains("_eta") ) h_all->GetYaxis()->SetRangeUser(0.4,1.1); // if( temp.Contains("_numGenPVs") ) h_all->GetYaxis()->SetRangeUser(0.4,1.1); // if( temp.Contains("_numJets") ) h_all->GetYaxis()->SetRangeUser(0.4,1.1); TLine* myLine; if( temp.Contains("_mass") ) myLine = new TLine(40, 1, 140, 1); else if( temp.Contains("_met") ) myLine = new TLine(0, 1, 150, 1); else myLine = new TLine(h_data->GetXaxis()->GetXmin(), 1, h_data->GetXaxis()->GetXmax(), 1); // HLT myC1->cd(1); h_data->Draw("pe1"); h_mc->Draw("pe1same"); legend->Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); myC1->cd(2); myRatio->SetLineWidth(2); myRatio->Draw("pe1"); myLine->Draw(); plotname = dirprefix + temp_mh + "_data2mc_lin.png"; myC1->Print(plotname); plotname = dirprefix + temp_mh + "_data2mc_lin.pdf"; if( printPDF_ ) myC1->Print(plotname); // log h_data->GetYaxis()->SetRangeUser(0.4,12 * max_content); if( temp.Contains("_selection") ){ h_data->GetYaxis()->SetRangeUser(400,12 * max_content); } myC1->cd(1); gPad->SetLogy(1); plotname = dirprefix + temp_mh + "_data2mc_log.png"; myC1->Print(plotname); plotname = dirprefix + temp_mh + "_data2mc_log.pdf"; if( printPDF_ ) myC1->Print(plotname); gPad->SetLogy(0); delete myRatio; delete myLine; delete legend; } // end loop on hists //////////////////////////////////////////////////////////////////////////// // Close the file for( int iFile=0; iFile<NumSamples; iFile++ ) file[iFile]->Close(); std::cout << " Done! " << std::endl; }
void makePlots_csvSF_13TeV( TString inputFileName = "infile.root", bool isHF = true, bool isCSV = true, TString dirPostFix = "", bool compareIterations = false ) { compareIterations = true; TString taggerName = "CSVv2"; if(!isCSV) taggerName = "cMVAv2"; TH1::SetDefaultSumw2(); TFile *histFile = TFile::Open(inputFileName); if( compareIterations ) dirPostFix = dirPostFix + "Comparison"; TString dirprefix = taggerName +"_SFPlots_2016_7_8_13TeV" + dirPostFix + "/"; struct stat st; if( stat(dirprefix.Data(),&st) != 0 ) mkdir(dirprefix.Data(),0777); // single jet specific plots int nPt = 5;//6; int nEta = 1; TString flavor = "HF"; if ( !isHF ){ nPt = 4; nEta = 3; flavor = "LF"; } ////// TH1D* h_Data_jet_csv[nPt][nEta]; TH1D* h_MC_b_jet_csv[nPt][nEta]; TH1D* h_MC_nonb_jet_csv[nPt][nEta]; ///// // int nCSVBins = 18; //Number of bins // // double xBins_hf[19] = {-0.04, 0.0, 0.122, 0.244, 0.331, 0.418, 0.505, 0.592, 0.679, 0.7228, 0.7666, 0.8104, 0.8542, 0.898, 0.9184, 0.9388, 0.9592, 0.9796, 1.01}; // double xBins_hf[19] = {-0.04, 0.0, 0.3025, 0.605, 0.662, 0.719, 0.776, 0.833, 0.890, 0.906, 0.922, 0.938, 0.954, 0.970, 0.976, 0.982, 0.988, 0.994, 1.01}; int nCSVBins = 22; //Number of bins // double xBins_hf[19] = {-10.0, 0.0, 0.122, 0.244, 0.331, 0.418, 0.505, 0.592, 0.679, 0.7228, 0.7666, 0.8104, 0.8542, 0.898, 0.9184, 0.9388, 0.9592, 0.9796, 1.01}; double xBins_hf[23] = {-0.04, 0.0, 0.101, 0.202, 0.303, 0.404, 0.505, 0.605, 0.662, 0.719, 0.776, 0.833, 0.890, 0.906, 0.922, 0.938, 0.954, 0.970, 0.976, 0.982, 0.988, 0.994, 1.01}; double xBins_hf_cMVA[23] = {-1.01, -0.9525, -0.905, -0.8575, -0.81, -0.7625, -0.715, -0.565, -0.415, -0.265, -0.115, 0.035, 0.185, 0.323, 0.461, 0.599, 0.737, 0.875, 0.902, 0.929, 0.956, 0.983, 1.01}; if(!isHF) nCSVBins = 21; // double xBins_lf[22] = {-0.04, 0.0, 0.04, 0.08, 0.12, 0.16, 0.2, 0.244, 0.331, 0.418, 0.505, 0.592, 0.679, 0.752, 0.825, 0.898, 0.915, 0.932, 0.949, 0.966, 0.983, 1.01}; double xBins_lf[22] = {-0.04, 0.0, 0.101, 0.202, 0.303, 0.404, 0.505, 0.605, 0.662, 0.719, 0.776, 0.833, 0.890, 0.917, 0.944, 0.970, 0.975, 0.980, 0.985, 0.990, 0.995, 1.01}; double xBins_lf_cMVA[22] = {-1.01, -0.9525, -0.905, -0.8575, -0.81, -0.7625, -0.715, -0.565, -0.415, -0.265, -0.115, 0.035, 0.185, 0.415, 0.645, 0.875, 0.8975, 0.92, 0.9425, 0.965, 0.9875, 1.01}; //TCanvas* c1 = new TCanvas("c1","c1",600,500); TCanvas* c1 = new TCanvas("c1","c1"); c1->SetTopMargin(0.08); c1->SetRightMargin(0.08); // gPad->SetTickx(1); // gPad->SetTicky(1); TString flavor_file = flavor; flavor_file.ToLower(); /// TString lumiinfo = "2.6 fb^{-1} (13 TeV, 25ns)"; TLatex LumiInfoLatex(0.65, 0.93, lumiinfo); LumiInfoLatex.SetNDC(); LumiInfoLatex.SetTextFont(42); LumiInfoLatex.SetTextSize(0.04); //TString cmsinfo = "CMS Preliminary"; TString cmsinfo = "CMS"; // TLatex CMSInfoLatex(0.155, 0.93, cmsinfo); TLatex CMSInfoLatex(0.155, 0.85, cmsinfo); CMSInfoLatex.SetNDC(); CMSInfoLatex.SetTextFont(42); CMSInfoLatex.SetTextFont(61); CMSInfoLatex.SetTextSize(0.055); //SBOUTLE std::string publishinfo = "Preliminary"; //DPUIGH // TLatex PublishInfoLatex(0.25, 0.93, publishinfo.c_str()); //SBOUTLE TLatex PublishInfoLatex(0.155, 0.80, publishinfo.c_str()); //SBOUTLE PublishInfoLatex.SetNDC(); PublishInfoLatex.SetTextFont(52); PublishInfoLatex.SetTextSize(0.045); //SBOUTLE /// std::vector<TString> label_ptbin; std::vector<TString> label_etabin; TString plotName; int iHist = -1; int minPt = 1; for ( int iPt=minPt; iPt<nPt; iPt++){ for ( int iEta=0; iEta<nEta; iEta++){ iHist++; if(isHF){ if( iPt==0 ) label_ptbin.push_back("20 < p_{T} < 30 GeV"); else if( iPt==1 ) label_ptbin.push_back("30 < p_{T} < 40 GeV"); else if( iPt==2 ) label_ptbin.push_back("40 < p_{T} < 60 GeV"); else if( iPt==3 ) label_ptbin.push_back("60 < p_{T} < 100 GeV"); else if( iPt==4 ) label_ptbin.push_back("p_{T} > 100 GeV"); label_etabin.push_back("|#eta| < 2.4"); } else{ if( iPt==0 ) label_ptbin.push_back("20 < p_{T} < 30 GeV"); else if( iPt==1 ) label_ptbin.push_back("30 < p_{T} < 40 GeV"); else if( iPt==2 ) label_ptbin.push_back("40 < p_{T} < 60 GeV"); else if( iPt==3 ) label_ptbin.push_back("p_{T} > 60 GeV"); if( iEta==0 ) label_etabin.push_back("|#eta| < 0.8"); else if( iEta==1 ) label_etabin.push_back("0.8 < |#eta| < 1.6"); else if( iEta==2 ) label_etabin.push_back("1.6 < |#eta| < 2.4"); } if(!compareIterations){ TString h_Data_Name = Form("h_csv_Data_Pt%i_Eta%i",iPt,iEta); TString h_b_Name = Form("h_csv_MC_bjets_Pt%i_Eta%i",iPt,iEta); TString h_nonb_Name = Form("h_csv_MC_nonbjets_Pt%i_Eta%i",iPt,iEta); h_Data_jet_csv[iPt][iEta] = (TH1D*)histFile->Get(h_Data_Name.Data()); h_MC_b_jet_csv[iPt][iEta] = (TH1D*)histFile->Get(h_b_Name.Data()); h_MC_nonb_jet_csv[iPt][iEta] = (TH1D*)histFile->Get(h_nonb_Name.Data()); // rebin TH1D* h_csv_data = NULL; TH1D* h_csv_mc_b = NULL; TH1D* h_csv_mc_nonb = NULL; h_csv_data = (TH1D*)h_Data_jet_csv[iPt][iEta]; h_csv_mc_b = (TH1D*)h_MC_b_jet_csv[iPt][iEta]; h_csv_mc_nonb = (TH1D*)h_MC_nonb_jet_csv[iPt][iEta]; // if( isHF ){ // h_csv_data = (TH1D*)h_Data_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_hf ); // h_csv_mc_b = (TH1D*)h_MC_b_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_hf ); // h_csv_mc_nonb = (TH1D*)h_MC_nonb_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_hf ); // } // else{ // h_csv_data = (TH1D*)h_Data_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_lf ); // h_csv_mc_b = (TH1D*)h_MC_b_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_lf ); // h_csv_mc_nonb = (TH1D*)h_MC_nonb_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_lf ); // } // //// first and last bin; underflow/overflow // h_csv_data->SetBinContent(1,h_Data_jet_csv[iPt][iEta]->GetBinContent(1)); // h_csv_data->SetBinError(1,h_Data_jet_csv[iPt][iEta]->GetBinError(1)); // h_csv_mc_b->SetBinContent(1,h_MC_b_jet_csv[iPt][iEta]->GetBinContent(1)); // h_csv_mc_b->SetBinError(1,h_MC_b_jet_csv[iPt][iEta]->GetBinError(1)); // h_csv_mc_nonb->SetBinContent(1,h_MC_nonb_jet_csv[iPt][iEta]->GetBinContent(1)); // h_csv_mc_nonb->SetBinError(1,h_MC_nonb_jet_csv[iPt][iEta]->GetBinError(1)); // h_csv_data->SetBinContent(nCSVBins,h_Data_jet_csv[iPt][iEta]->GetBinContent(nCSVBins) + h_Data_jet_csv[iPt][iEta]->GetBinContent(nCSVBins+1)); // h_csv_data->SetBinError(nCSVBins,sqrt(pow(h_Data_jet_csv[iPt][iEta]->GetBinError(nCSVBins),2) + pow(h_Data_jet_csv[iPt][iEta]->GetBinError(nCSVBins+1),2))); // h_csv_mc_b->SetBinContent(nCSVBins,h_MC_b_jet_csv[iPt][iEta]->GetBinContent(nCSVBins) + h_MC_b_jet_csv[iPt][iEta]->GetBinContent(nCSVBins+1)); // h_csv_mc_b->SetBinError(nCSVBins,sqrt(pow(h_MC_b_jet_csv[iPt][iEta]->GetBinError(nCSVBins),2) + pow(h_MC_b_jet_csv[iPt][iEta]->GetBinError(nCSVBins+1),2))); // h_csv_mc_nonb->SetBinContent(nCSVBins,h_MC_nonb_jet_csv[iPt][iEta]->GetBinContent(nCSVBins) + h_MC_nonb_jet_csv[iPt][iEta]->GetBinContent(nCSVBins+1)); // h_csv_mc_nonb->SetBinError(nCSVBins,sqrt(pow(h_MC_nonb_jet_csv[iPt][iEta]->GetBinError(nCSVBins),2) + pow(h_MC_nonb_jet_csv[iPt][iEta]->GetBinError(nCSVBins+1),2))); // //// normalize MC to data // double norm_mc_b = h_csv_mc_b->Integral(); // double norm_mc_nonb = h_csv_mc_nonb->Integral(); // h_csv_mc_b->Scale(h_csv_data->Integral() / (norm_mc_b + norm_mc_nonb)); // h_csv_mc_nonb->Scale(h_csv_data->Integral() / (norm_mc_b + norm_mc_nonb)); //// h_csv_data->SetStats(0); //h_csv_data->GetXaxis()->SetRangeUser(0.0001, 1.001); h_csv_data->SetTitle(";"+taggerName+" Discriminator;Jets / bin"); // h_csv_data->SetTitle(";"+taggerName); h_csv_data->SetMarkerStyle(20); h_csv_mc_b->SetFillColor(kRed); h_csv_mc_nonb->SetFillColor(kBlue); // h_csv_mc_nonb->SetFillColor(kGreen+1); h_csv_mc_b->SetLineColor(kRed); h_csv_mc_nonb->SetLineColor(kBlue); // h_csv_mc_nonb->SetLineColor(kGreen+1); h_csv_data->SetLineWidth(2); h_csv_mc_b->SetLineWidth(2); h_csv_mc_nonb->SetLineWidth(2); /// TString ptselectioninfo = label_ptbin[iHist]; TLatex PTSELECTIONInfoLatex(0.57, 0.85, ptselectioninfo); PTSELECTIONInfoLatex.SetNDC(); PTSELECTIONInfoLatex.SetTextFont(42); PTSELECTIONInfoLatex.SetTextSize(0.04); TString etaselectioninfo = label_etabin[iHist]; TLatex ETASELECTIONInfoLatex(0.57, 0.8, etaselectioninfo); ETASELECTIONInfoLatex.SetNDC(); ETASELECTIONInfoLatex.SetTextFont(42); ETASELECTIONInfoLatex.SetTextSize(0.04); /// // TLegend *legend = new TLegend(0.14,0.85,0.9,0.9); TLegend *legend = new TLegend(0.57,0.57,0.87,0.77); legend->SetFillColor(kWhite); legend->SetLineColor(kWhite); legend->SetShadowColor(kWhite); legend->SetTextFont(42); legend->SetTextSize(0.05); legend->SetNColumns(1); legend->AddEntry(h_csv_data," Data","pe"); if( isHF ){ legend->AddEntry(h_csv_mc_b," b","f"); legend->AddEntry(h_csv_mc_nonb," udsg + c","f"); } else{ legend->AddEntry(h_csv_mc_b," b + c","f"); legend->AddEntry(h_csv_mc_nonb," udsg","f"); } TH1D* h_diff = (TH1D*) h_csv_data->Clone( Form("csv_diff_Pt%i_Eta%i",iPt,iEta) ); THStack *hs = new THStack("hs",""); if( isHF ){ hs->Add(h_csv_mc_b); hs->Add(h_csv_mc_nonb); h_diff->Add(h_csv_mc_nonb,-1); } else{ hs->Add(h_csv_mc_nonb); hs->Add(h_csv_mc_b); h_diff->Add(h_csv_mc_b,-1); } TH1D* h_ratio = (TH1D*) h_diff->Clone( Form("csv_ratio_Pt%i_Eta%i",iPt,iEta) ); if( isHF ) h_ratio->Divide( h_csv_mc_b ); else h_ratio->Divide( h_csv_mc_nonb ); TString title = Form("%s SF Pt%i Eta%i",flavor.Data(),iPt,iEta); TLatex BinInfoLatex(0.6, 0.81, title.Data());//(0.6, 0.86, title.Data()); BinInfoLatex.SetNDC(); BinInfoLatex.SetTextFont(42); BinInfoLatex.SetTextSize(0.04); h_csv_data->GetYaxis()->SetTitleOffset(1.2); // h_csv_data->GetXaxis()->SetRangeUser(-0.041,0.9489); h_csv_data->SetMaximum(1.3*TMath::Max(h_csv_data->GetMaximum(), hs->GetMaximum())); h_csv_data->Draw("pe1"); hs->Draw("histsame"); h_csv_data->Draw("pe1same"); legend->Draw(); // BinInfoLatex.Draw(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); ETASELECTIONInfoLatex.Draw(); PTSELECTIONInfoLatex.Draw(); c1->RedrawAxis(); plotName = dirprefix + Form("%s_%s_SF_Pt%i_Eta%i_astack",taggerName.Data(),flavor.Data(),iPt,iEta) + ".pdf"; c1->Print(plotName.Data()); // TLegend *legend_diff = new TLegend(0.14,0.85,0.9,0.9);//new TLegend(0.14,0.93,0.9,0.98); TLegend *legend_diff = new TLegend(0.57,0.57,0.87,0.77); legend_diff->SetFillColor(kWhite); legend_diff->SetLineColor(kWhite); legend_diff->SetShadowColor(kWhite); legend_diff->SetTextFont(42); legend_diff->SetTextSize(0.05); legend_diff->SetNColumns(1); if( isHF ){ legend_diff->AddEntry(h_diff,"(Data - c, udsg)","pe"); legend_diff->AddEntry(h_csv_mc_b,"b","l"); h_diff->SetMaximum(1.3*TMath::Max(h_diff->GetMaximum(), h_csv_mc_b->GetMaximum())); } else{ legend_diff->AddEntry(h_diff,"(Data - b, c)","pe"); legend_diff->AddEntry(h_csv_mc_nonb,"udsg","l"); h_diff->SetMaximum(1.3*TMath::Max(h_diff->GetMaximum(), h_csv_mc_nonb->GetMaximum())); } h_diff->GetYaxis()->SetTitleOffset(1.2); // h_diff->GetXaxis()->SetRangeUser(-0.041,0.9489); h_diff->Draw("pe1"); if( isHF ) h_csv_mc_b->Draw("pe1same"); else h_csv_mc_nonb->Draw("pe1same"); h_diff->Draw("pe1same"); legend_diff->Draw(); // BinInfoLatex.Draw(); c1->RedrawAxis(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); ETASELECTIONInfoLatex.Draw(); PTSELECTIONInfoLatex.Draw(); plotName = dirprefix + Form("%s_%s_SF_Pt%i_Eta%i_bdiff",taggerName.Data(),flavor.Data(),iPt,iEta) + ".pdf"; c1->Print(plotName.Data()); h_ratio->GetYaxis()->SetRangeUser(0.,2.); h_ratio->SetTitle(";"+taggerName+" Discriminator;Data/MC SF"); h_ratio->Draw("pe1"); // BinInfoLatex.Draw(); c1->RedrawAxis(); LumiInfoLatex.Draw(); CMSInfoLatex.Draw(); PublishInfoLatex.Draw(); ETASELECTIONInfoLatex.Draw(); PTSELECTIONInfoLatex.Draw(); plotName = dirprefix + Form("%s_%s_SF_Pt%i_Eta%i_cratio",taggerName.Data(),flavor.Data(),iPt,iEta) + ".png"; c1->Print(plotName.Data()); } if( compareIterations ){ TFile *fitFile_iter0 = TFile::Open("../data/csvSFs/csv_rwt_fit_" + flavor_file + "_v2.root"); TFile *fitFile_iter1 = TFile::Open("../data/csv_rwt_fit_" + flavor_file + "_v2.root"); TFile *fitFile_iter2 = TFile::Open("../data/csvSFs/csv_rwt_fit_" + flavor_file + "_v2.root"); TString h_iter_Data_Name = Form("h_csv_Data_Pt%i_Eta%i",iPt,iEta); TString h_iter_b_Name = Form("h_csv_MC_bjets_Pt%i_Eta%i",iPt,iEta); TString h_iter_nonb_Name = Form("h_csv_MC_nonbjets_Pt%i_Eta%i",iPt,iEta); TString h_iter_csv_ratio_Name = Form("temp_csv_ratio_Pt%i_Eta%i",iPt,iEta); TH1D* h_iter_Data_jet_csv_iter0 = (TH1D*)fitFile_iter0->Get(h_iter_Data_Name.Data())->Clone(h_iter_Data_Name+"v0"); TH1D* h_iter_MC_b_jet_csv_iter0 = (TH1D*)fitFile_iter0->Get(h_iter_b_Name.Data())->Clone(h_iter_b_Name+"v0"); TH1D* h_iter_MC_nonb_jet_csv_iter0 = (TH1D*)fitFile_iter0->Get(h_iter_nonb_Name.Data())->Clone(h_iter_nonb_Name+"v0"); TH1D* h_iter_Data_jet_csv_iter1 = (TH1D*)fitFile_iter1->Get(h_iter_Data_Name.Data())->Clone(h_iter_Data_Name+"v1"); TH1D* h_iter_MC_b_jet_csv_iter1 = (TH1D*)fitFile_iter1->Get(h_iter_b_Name.Data())->Clone(h_iter_b_Name+"v1"); TH1D* h_iter_MC_nonb_jet_csv_iter1 = (TH1D*)fitFile_iter1->Get(h_iter_nonb_Name.Data())->Clone(h_iter_nonb_Name+"v1"); TH1D* h_iter_Data_jet_csv_iter2 = (TH1D*)fitFile_iter2->Get(h_iter_Data_Name.Data())->Clone(h_iter_Data_Name+"v2"); TH1D* h_iter_MC_b_jet_csv_iter2 = (TH1D*)fitFile_iter2->Get(h_iter_b_Name.Data())->Clone(h_iter_b_Name+"v2"); TH1D* h_iter_MC_nonb_jet_csv_iter2 = (TH1D*)fitFile_iter2->Get(h_iter_nonb_Name.Data())->Clone(h_iter_nonb_Name+"v2"); TH1D* h_iter0 = (TH1D*)h_iter_Data_jet_csv_iter0->Clone(h_iter_csv_ratio_Name+"v0"); TH1D* h_iter1 = (TH1D*)h_iter_Data_jet_csv_iter1->Clone(h_iter_csv_ratio_Name+"v1"); TH1D* h_iter2 = (TH1D*)h_iter_Data_jet_csv_iter2->Clone(h_iter_csv_ratio_Name+"v2"); if( isHF ){ h_iter0->Add(h_iter_MC_nonb_jet_csv_iter0, -1); h_iter0->Divide(h_iter_MC_b_jet_csv_iter0); h_iter1->Add(h_iter_MC_nonb_jet_csv_iter1, -1); h_iter1->Divide(h_iter_MC_b_jet_csv_iter1); h_iter2->Add(h_iter_MC_nonb_jet_csv_iter2, -1); h_iter2->Divide(h_iter_MC_b_jet_csv_iter2); } else { h_iter0->Add(h_iter_MC_b_jet_csv_iter0, -1); h_iter0->Divide(h_iter_MC_nonb_jet_csv_iter0); h_iter1->Add(h_iter_MC_b_jet_csv_iter1, -1); h_iter1->Divide(h_iter_MC_nonb_jet_csv_iter1); h_iter2->Add(h_iter_MC_b_jet_csv_iter2, -1); h_iter2->Divide(h_iter_MC_nonb_jet_csv_iter2); } TString iter_fit_histo_name = Form("csv_ratio_Pt%d_Eta%d_final",iPt,iEta); //TString iter_histo_name = Form("h_csv_ratio_%d",iHist); TH1D* h_fit_iter0 = (TH1D*)fitFile_iter0->Get(iter_fit_histo_name)->Clone(iter_fit_histo_name+"v0"); TH1D* h_fit_iter1 = (TH1D*)fitFile_iter1->Get(iter_fit_histo_name)->Clone(iter_fit_histo_name+"v1"); TH1D* h_fit_iter2 = (TH1D*)fitFile_iter2->Get(iter_fit_histo_name)->Clone(iter_fit_histo_name+"v2"); h_fit_iter0->SetLineColor(kRed); h_fit_iter1->SetLineColor(kGreen+1); h_fit_iter2->SetLineColor(kBlue); h_fit_iter0->SetLineWidth(2); h_fit_iter1->SetLineWidth(2); h_fit_iter2->SetLineWidth(2); h_iter0->SetLineColor(kRed); h_iter1->SetLineColor(kGreen+1); h_iter2->SetLineColor(kBlue); h_iter0->SetLineWidth(2); h_iter1->SetLineWidth(2); h_iter2->SetLineWidth(2); h_fit_iter0->SetStats(0); h_fit_iter0->GetYaxis()->SetRangeUser(0.,2.); h_fit_iter0->GetXaxis()->SetRangeUser(-0.04,1.01); /// change HF range // h_fit_iter0->GetXaxis()->SetRangeUser(0.890,1.01); /// change HF range h_fit_iter0->SetTitle(";"+taggerName+";Data/MC SF"); h_fit_iter0->Draw("hist"); h_iter0->Draw("pe1same"); h_fit_iter1->Draw("histsame"); h_iter1->Draw("pe1same"); // h_fit_iter2->Draw("histsame"); // h_iter2->Draw("pe1same"); c1->RedrawAxis(); ///------- TString title = Form("%s SF Pt%i Eta%i",flavor.Data(),iPt,iEta); TLatex BinInfoLatex(0.6, 0.86, title.Data()); BinInfoLatex.SetNDC(); BinInfoLatex.SetTextFont(42); BinInfoLatex.SetTextSize(0.04); ///------- TLegend *legend_iter = new TLegend(0.14,0.93,0.9,0.98); legend_iter->SetFillColor(kWhite); legend_iter->SetLineColor(kWhite); legend_iter->SetShadowColor(kWhite); legend_iter->SetTextFont(42); legend_iter->SetTextSize(0.05); legend_iter->SetNColumns(3); legend_iter->AddEntry(h_iter0,"jetPt20","f"); legend_iter->AddEntry(h_iter1,"jetPt30","f"); // legend_iter->AddEntry(h_iter2,"mumu","f"); // legend_iter->AddEntry(h_iter0,"Iter0","f"); // legend_iter->AddEntry(h_iter1,"Iter1","f"); // legend_iter->AddEntry(h_iter2,"Iter2","f"); legend_iter->Draw(); BinInfoLatex.Draw(); c1->RedrawAxis(); plotName = dirprefix + Form("%s_%s_SF_Pt%i_Eta%i_diters",taggerName.Data(),flavor.Data(),iPt,iEta) + ".png"; c1->Print(plotName.Data()); } } } std::cout << "Done." << std::endl; }
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"); } }
TCanvas *trackSplitPlot(Int_t nFiles,TString *files,TString *names,TString xvar,TString yvar, Bool_t relative = kFALSE,Bool_t logscale = kFALSE,Bool_t resolution = kFALSE,Bool_t pull = kFALSE, TString saveas = "") { cout << xvar << " " << yvar << endl; if (xvar == "" && yvar == "") return 0; PlotType type; if (xvar == "") type = Histogram; else if (yvar == "") type = OrgHistogram; else if (resolution) type = Resolution; else if (nFiles < 1) type = ScatterPlot; else type = Profile; if (nFiles < 1) nFiles = 1; const Int_t n = nFiles; TStyle *tdrStyle = setTDRStyle(); tdrStyle->SetOptStat(0); if ((type == Histogram || type == OrgHistogram) && nFiles == 1) tdrStyle->SetOptStat(1110); if (type == ScatterPlot || (type == Histogram && !pull) || xvar == "runNumber") { tdrStyle->SetCanvasDefW(678); tdrStyle->SetPadRightMargin(0.115); } Bool_t nHits = (xvar[0] == 'n' && xvar[1] == 'H' && xvar[2] == 'i' && xvar[3] == 't' && xvar[4] == 's'); Int_t nBinsScatterPlotx = binsScatterPlotx; Int_t nBinsScatterPloty = binsScatterPloty; Int_t nBinsHistogram = binsHistogram; Int_t nBinsProfileResolution = binsProfileResolution; if (xvar == "runNumber") { nBinsProfileResolution = runNumberBins; nBinsHistogram = runNumberBins; } if (nHits) { nBinsHistogram = (int)(findMax(nFiles,files,xvar,'x') - findMin(nFiles,files,xvar,'x') + 1.1); //in case it's .99999 nBinsScatterPlotx = nBinsHistogram; nBinsProfileResolution = nBinsHistogram; } TH1 **p = new TH1*[n]; Int_t lengths[n]; stringstream sx,sy,srel,ssigma1,ssigma2,ssigmaorg; sx << xvar << "_org"; TString xvariable = sx.str(); TString xvariable2 = ""; if (xvar == "runNumber") xvariable = "runNumber"; if (nHits) { xvariable = xvar; xvariable2 = xvar; xvariable.Append("1_spl"); xvariable2.Append("2_spl"); } sy << "Delta_" << yvar; TString yvariable = sy.str(); TString relvariable = "1"; if (relative) { srel << yvar << "_org"; relvariable = srel.str(); } TString sigma1variable = "",sigma2variable = ""; if (pull) { ssigma1 << yvar << "1Err_spl"; ssigma2 << yvar << "2Err_spl"; } sigma1variable = ssigma1.str(); sigma2variable = ssigma2.str(); TString sigmaorgvariable = ""; if (pull && relative) ssigmaorg << yvar << "Err_org"; sigmaorgvariable = ssigmaorg.str(); Double_t xmin = -1,xmax = 1,ymin = -1,ymax = 1; if (type == Profile || type == ScatterPlot || type == OrgHistogram || type == Resolution) axislimits(nFiles,files,xvar,'x',relative,pull,xmin,xmax); if (type == Profile || type == ScatterPlot || type == Histogram || type == Resolution) axislimits(nFiles,files,yvar,'y',relative,pull,ymin,ymax); TString meansrmss[n]; for (Int_t i = 0; i < n; i++) { TFile *f = TFile::Open(files[i]); TTree *tree = (TTree*)f->Get("splitterTree"); stringstream sid; sid << "p" << i; TString id = sid.str(); TH1F **q = new TH1F*[nBinsProfileResolution]; if (type == ScatterPlot) p[i] = new TH2F(id,"",nBinsScatterPlotx,xmin,xmax,nBinsScatterPloty,ymin,ymax); if (type == Histogram) p[i] = new TH1F(id,"",nBinsHistogram,ymin,ymax); if (type == OrgHistogram) p[i] = new TH1F(id,"",nBinsHistogram,xmin,xmax); if (type == Resolution || type == Profile) { p[i] = new TH1F(id,"",nBinsProfileResolution,xmin,xmax); for (Int_t j = 0; j < nBinsProfileResolution; j++) { stringstream sid2; sid2 << "q" << j; TString id2 = sid2.str(); q[j] = new TH1F(id2,"",nBinsHistogram,ymin,ymax); } } p[i]->SetDirectory(0); lengths[i] = tree->GetEntries(); if (files[i].Contains("MC") && xvar == "runNumber") { p[i]->SetLineColor(kWhite); p[i]->SetMarkerColor(kWhite); f->Close(); continue; } Double_t x = 0, y = 0, rel = 1, sigma1 = 1, sigma2 = 1, //if !pull, we want to divide by sqrt(2) because we want the error from 1 track sigmaorg = 0; Int_t xint = 0, xint2 = 0; Int_t runNumber = 0; if (!relative && !pull && (yvar == "dz" || yvar == "dxy")) rel = 1e-4; //it's in cm but we want it in um, so divide by 1e-4 tree->SetBranchAddress("runNumber",&runNumber); if (type == Profile || type == ScatterPlot || type == Resolution || type == OrgHistogram) { if (xvar == "runNumber") tree->SetBranchAddress(xvariable,&xint); else if (nHits) { tree->SetBranchAddress(xvariable,&xint); tree->SetBranchAddress(xvariable2,&xint2); } else tree->SetBranchAddress(xvariable,&x); } if (type == Profile || type == ScatterPlot || type == Resolution || type == Histogram) tree->SetBranchAddress(yvariable,&y); if (relative && xvar != yvar) //if xvar == yvar, setting the branch here will undo setting it to x 2 lines earlier tree->SetBranchAddress(relvariable,&rel); if (pull) { tree->SetBranchAddress(sigma1variable,&sigma1); tree->SetBranchAddress(sigma2variable,&sigma2); } if (relative && pull) tree->SetBranchAddress(sigmaorgvariable,&sigmaorg); Int_t notincluded = 0; for (Int_t j = 0; j<lengths[i]; j++) { tree->GetEntry(j); if (xvar == "runNumber" || nHits) x = xint; if (xvar == "runNumber") runNumber = x; if (runNumber < minrun || (runNumber > maxrun && maxrun > 0)) { notincluded++; continue; } if (relative && xvar == yvar) { rel = x; } Double_t error = 0; if (relative && pull) error = sqrt((sigma1/rel)*(sigma1/rel) + (sigma2/rel)*(sigma2/rel) + (sigmaorg*y/(rel*rel))*(sigmaorg*x/(rel*rel))); else error = sqrt(sigma1 * sigma1 + sigma2 * sigma2); // = sqrt(2) if !pull, to get the error in 1 track y /= (rel * error); if (logscale) y = fabs(y); if (ymin <= y && y < ymax && xmin <= x && x < xmax) { if (type == Histogram) p[i]->Fill(y); if (type == ScatterPlot) p[i]->Fill(x,y); if (type == Resolution || type == Profile) { int which = (p[i]->Fill(x,0)) - 1; if (which >= 0) q[which]->Fill(y); //get which q[j] by filling p[i] (with nothing), which returns the bin number } if (type == OrgHistogram) p[i]->Fill(x); } if (nHits) { x = xint2; if (ymin <= y && y < ymax && xmin <= x && x < xmax) { if (type == Histogram) p[i]->Fill(y); if (type == ScatterPlot) p[i]->Fill(x,y); if (type == Resolution || type == Profile) { int which = (p[i]->Fill(x,0)) - 1; if (which >= 0) q[which]->Fill(y); //get which q[j] by filling p[i] (with nothing), which returns the bin number } if (type == OrgHistogram) p[i]->Fill(x); } } if (((j+1)/(int)(pow(10,(int)(log10(lengths[i]))-1)))*(int)(pow(10,(int)(log10(lengths[i]))-1)) == j + 1 || j + 1 == lengths[i]) { cout << j + 1 << "/" << lengths[i] << ": "; if (type == Profile || type == ScatterPlot || type == Resolution) cout << x << ", " << y << endl; if (type == OrgHistogram) cout << x << endl; if (type == Histogram) cout << y << endl; } } lengths[i] -= notincluded; meansrmss[i] = ""; if (type == Histogram || type == OrgHistogram) { cout << "Average = " << p[i]->GetMean() << endl; cout << "RMS = " << p[i]->GetRMS() << endl; stringstream meanrms; meanrms.precision(3); meanrms << "#mu=" << p[i]->GetMean() << ", #sigma=" << p[i]->GetRMS(); meansrmss[i] = meanrms.str(); } if (type == Resolution) { for (Int_t j = 0; j < nBinsProfileResolution; j++) { p[i]->SetBinContent(j+1,q[j]->GetRMS()); p[i]->SetBinError (j+1,q[j]->GetRMSError()); delete q[j]; } } if (type == Profile) { for (Int_t j = 0; j < nBinsProfileResolution; j++) { p[i]->SetBinContent(j+1,q[j]->GetMean()); p[i]->SetBinError (j+1,q[j]->GetMeanError()); delete q[j]; } } delete[] q; setAxisLabels(p[i],type,xvar,yvar,relative,pull); p[i]->SetLineColor(colors[i]); if (type == Resolution || type == Profile) { p[i]->SetMarkerColor(colors[i]); p[i]->SetMarkerStyle(20+i); } else { p[i]->SetMarkerStyle(1); } f->Close(); } TCanvas *c1 = TCanvas::MakeDefCanvas(); if (type == ScatterPlot || type == Profile || type == Resolution || type == OrgHistogram) c1->SetLogy((Bool_t)(logscale)); if (type == Histogram) c1->SetLogx((Bool_t)(logscale)); TH1 *maxp = p[0]; TGraphErrors *g[n]; TMultiGraph *list = new TMultiGraph(); if (type == ScatterPlot) p[0]->Draw("COLZ"); else if (type == Resolution || type == Profile) { for (Int_t i = 0; i < n; i++) { if (files[i].Contains("MC") && xvar == "runNumber") continue; g[i] = new TGraphErrors(p[i]); for (Int_t j = 0; j < g[i]->GetN(); j++) { if (g[i]->GetY()[j] == 0 && g[i]->GetEY()[j] == 0) { g[i]->RemovePoint(j); j--; } } list->Add(g[i]); } list->Draw("AP"); Double_t yaxismax = list->GetYaxis()->GetXmax(); Double_t yaxismin = list->GetYaxis()->GetXmin(); if (yaxismin > 0) { yaxismax += yaxismin; yaxismin = 0; } p[0]->GetYaxis()->SetRangeUser(yaxismin,yaxismax); p[0]->Draw("P"); } else if (type == Histogram || type == OrgHistogram) { Bool_t allthesame = true; for (Int_t i = 1; i < n && allthesame; i++) { if (lengths[i] != lengths[0]) allthesame = false; } if (!allthesame && xvar != "runNumber") for (Int_t i = 0; i < n; i++) { p[i]->Scale(1.0/lengths[i]); } maxp = (TH1F*)p[0]->Clone("maxp"); maxp->SetLineColor(kWhite); for (Int_t i = 1; i <= maxp->GetNbinsX(); i++) { for (Int_t j = 0; j < n; j++) { if (files[j].Contains("MC") && xvar == "runNumber") continue; maxp->SetBinContent(i,TMath::Max(maxp->GetBinContent(i),p[j]->GetBinContent(i))); } } maxp->Draw(); p[0]->Draw("same"); } TLegend *legend = new TLegend(.6,.7,.9,.9,"","br"); if (n == 1 && files[0].Contains("MC") && xvar == "runNumber") { placeholder(saveas,yvar == ""); return 0; } if (n>=2) { if (!(files[0].Contains("MC") && xvar == "runNumber") && files[0] != "") { if (type == Resolution || type == Profile) legend->AddEntry(p[0],names[0],"pl"); else if (type == Histogram || type == OrgHistogram) { legend->AddEntry(p[0],names[0],"l"); legend->AddEntry((TObject*)0,meansrmss[0],""); } } for (Int_t i = 1; i < n; i++) { if (files[i].Contains("MC") && xvar == "runNumber") continue; if (type == Resolution || type == Profile) { p[i]->Draw("same P"); legend->AddEntry(p[i],names[i],"pl"); } else if (type == Histogram || type == OrgHistogram) { p[i]->Draw("same"); legend->AddEntry(p[i],names[i],"l"); legend->AddEntry((TObject*)0,meansrmss[i],""); } } if (legend->GetListOfPrimitives()->At(0) == 0) { delete legend; placeholder(saveas,yvar == ""); return 0; } c1->Update(); Double_t x1min = .98*gPad->GetUxmin() + .02*gPad->GetUxmax(); Double_t x2max = .02*gPad->GetUxmin() + .98*gPad->GetUxmax(); Double_t y1min = .98*gPad->GetUymin() + .02*gPad->GetUymax(); Double_t y2max = .02*gPad->GetUymin() + .98*gPad->GetUymax(); Double_t width = .4*(x2max-x1min); Double_t height = (1./20)*legend->GetListOfPrimitives()->GetEntries()*(y2max-y1min); if (type == Histogram || type == OrgHistogram) { width *= 2; height /= 2; legend->SetNColumns(2); } Double_t newy2max = placeLegend(legend,width,height,x1min,y1min,x2max,y2max); maxp->GetYaxis()->SetRangeUser(gPad->GetUymin(),(newy2max-.02*gPad->GetUymin())/.98); legend->SetFillStyle(0); legend->Draw(); } if (saveas != "") { saveplot(c1,saveas); for (int i = 0; i < n; i++) { //delete p[i]; //delete g[i]; } //delete list; //delete maxp; //delete legend; } return c1; }
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- int main (int argc, char ** argv) { // check number of inpt parameters if(argc < 2){ cerr<<"Forgot to parse the cfg file --> exit "<<endl; return -1; } // Set Root style from global enviroment path string ROOTStyle; if(getenv ("ROOTStyle")!=NULL){ ROOTStyle = getenv ("ROOTStyle"); gROOT->ProcessLine((".x "+ROOTStyle+"/setTDRStyle.C").c_str()); } gStyle->SetOptStat(0); gStyle->SetPadTopMargin(0.09); gStyle->SetPadLeftMargin(0.13); gStyle->SetErrorX(0.5); // parse config file parameter if (gConfigParser) return 1 ; gConfigParser = new ConfigParser(); TString config ; config.Form("%s",argv[1]); if(!(gConfigParser->init(config))){ cout << ">>> parseConfigFile::Could not open configuration file " << config << endl; return -1; } // import base directory where samples are located and txt file with the directory name + other info string InputBaseDirectory = gConfigParser -> readStringOption("Input::InputBaseDirectory"); // import from cfg file the cross section value for this sample float CrossSection = gConfigParser -> readFloatOption("Input::CrossSection"); // total number of events int maxEventNumber = gConfigParser -> readFloatOption("Input::EventsNumber"); // treeName string treeName = gConfigParser -> readStringOption("Input::TreeName"); // take the cut list string InputCutList = gConfigParser -> readStringOption("Input::InputCutList"); // Read the cut file vector <cutContainer> CutList; if(ReadInputCutFile(InputCutList,CutList) <= 0){ cerr<<" Empty Cut List File or not Exisisting --> Exit "<<endl; return -1;} // take the variable list to be plotted string InputVariableList = gConfigParser -> readStringOption("Input::InputVariableList"); vector<variableContainer> variableList; if(ReadInputVariableFile(InputVariableList,variableList) <= 0 ){ cerr<<" Empty Variable List File or not Exisisting --> Exit "<<endl; return -1;} // take lumi and other parameters float lumi = gConfigParser -> readFloatOption("Option::Lumi"); // fb^(-1) lumi *= 1000. ; // transform into pb^(-1) finalStateString = gConfigParser -> readStringOption("Option::finalStateString"); matchingCone = gConfigParser -> readFloatOption("Option::matchingCone"); minLeptonCleaningPt = gConfigParser -> readFloatOption("Option::minLeptonCleaningPt"); minLeptonCutPt = gConfigParser -> readFloatOption("Option::minLeptonCutPt"); minJetCutPt = gConfigParser -> readFloatOption("Option::minJetCutPt"); usePuppiAsDefault = gConfigParser -> readBoolOption("Option::usePuppiAsDefault"); leptonIsoCut_mu = gConfigParser -> readFloatOption("Option::leptonIsoCutMu"); leptonIsoCut_el = gConfigParser -> readFloatOption("Option::leptonIsoCutEl"); leptonIsoCutLoose = gConfigParser -> readFloatOption("Option::leptonIsoCutLoose"); // output directory string outputPlotDirectory = gConfigParser -> readStringOption("Output::outputPlotDirectory"); system(("mkdir -p output/"+outputPlotDirectory).c_str()); system(("rm -r output/"+outputPlotDirectory+"/*").c_str()); system(("mkdir -p output/"+outputPlotDirectory+"/xs").c_str()); system(("mkdir -p output/"+outputPlotDirectory+"/norm").c_str()); ///// Start the analysis map<string,TH1F*> histoCutEff ; TChain* chain = new TChain (treeName.c_str()) ; chain->Add ((InputBaseDirectory+"/*.root").c_str()) ; int totEvent = chain->GetEntries(); readTree* reader = new readTree((TTree*)(chain)); cout<<"Lumi (fb-1) "<<lumi/1000<<" entries before "<<totEvent<<" cross section "<<CrossSection<<" Nevents before selections "<<lumi*CrossSection<<" weight "<<lumi*CrossSection/float(totEvent)<<endl; float weight = 1.0*lumi*CrossSection/float(totEvent) ; // make the plot container vector<histoContainer> plotVector; for(size_t iCut = 0; iCut < CutList.size(); iCut++){ histoCutEff["WW_EWK_pos_"+to_string(iCut)+"_"+CutList.at(iCut).cutLayerName] = new TH1F(("WW_EWK_pos_"+to_string(iCut)+"_"+CutList.at(iCut).cutLayerName).c_str(),"",15,0,15); for(size_t iVar = 0; iVar < variableList.size(); iVar++){ plotVector.push_back(histoContainer(CutList.at(iCut).cutLayerName,variableList.at(iVar))); } } int passingLHEFilter = 0 ; int maximumEvents = chain->GetEntries () ; if (maxEventNumber > 0 && maxEventNumber < maximumEvents) maximumEvents = maxEventNumber ; // Loop on the events for(int iEvent = 0; iEvent < maximumEvents ; iEvent++){ reader->fChain->GetEntry(iEvent) ; if (iEvent % 100000 == 0) cout << "reading event " << iEvent << "\n" ; // filter LHE level leptons if(TString(finalStateString).Contains("UU")){ if(fabs(reader->leptonLHEpid1) != 13 or fabs(reader->leptonLHEpid2) != 13) continue; } else if(TString(finalStateString).Contains("EE")){ if(fabs(reader->leptonLHEpid1) != 11 or fabs(reader->leptonLHEpid2) != 11) continue; } else if(TString(finalStateString).Contains("EU")){ if(fabs(reader->leptonLHEpid1) != 11 or fabs(reader->leptonLHEpid2) !=13) continue ; } else if(TString(finalStateString).Contains("UE")){ if(fabs(reader->leptonLHEpid1) != 13 or fabs(reader->leptonLHEpid2) !=11) continue ; } else{ cerr<<"problem with lhe level filter definition --> skip event"<<endl; continue; } passingLHEFilter++; // if an event pass the cut, fill the associated map leptonContainer lepton1,lepton2,parton1,parton2,neutrino1,neutrino2,vboson1,vboson2; lepton1.lepton4V_.SetPtEtaPhiM(reader->leptonLHEpt1,reader->leptonLHEeta1,reader->leptonLHEphi1,reader->leptonLHEm1); lepton1.charge_ = reader->leptonLHEch1; lepton1.flavour_ = reader->leptonLHEpid1; lepton2.lepton4V_.SetPtEtaPhiM(reader->leptonLHEpt2,reader->leptonLHEeta2,reader->leptonLHEphi2,reader->leptonLHEm2); lepton2.charge_ = reader->leptonLHEch2; lepton2.flavour_ = reader->leptonLHEpid2; parton1.lepton4V_.SetPtEtaPhiM(reader->jetLHEPartonpt1,reader->jetLHEPartoneta1,reader->jetLHEPartonphi1,0.); parton2.lepton4V_.SetPtEtaPhiM(reader->jetLHEPartonpt2,reader->jetLHEPartoneta2,reader->jetLHEPartonphi2,0.); neutrino1.lepton4V_.SetPtEtaPhiM(reader->neutrinoLHEpt1,reader->neutrinoLHEeta1,reader->neutrinoLHEphi1,0.); neutrino1.charge_ = 0.; neutrino1.flavour_ = reader->neutrinoLHEpid1; neutrino2.lepton4V_.SetPtEtaPhiM(reader->neutrinoLHEpt2,reader->neutrinoLHEeta2,reader->neutrinoLHEphi2,0.); neutrino2.charge_ = 0.; neutrino2.flavour_ = reader->neutrinoLHEpid2; vboson1.lepton4V_.SetPtEtaPhiM(reader->vbosonLHEpt1,reader->vbosonLHEeta1,reader->vbosonLHEphi1,reader->vbosonLHEm1); vboson1.charge_ = reader->vbosonLHEch1; vboson1.flavour_ = reader->vbosonLHEpid1; vboson2.lepton4V_.SetPtEtaPhiM(reader->vbosonLHEpt2,reader->vbosonLHEeta2,reader->vbosonLHEphi2,reader->vbosonLHEm2); vboson2.charge_ = reader->vbosonLHEch2; vboson2.flavour_ = reader->vbosonLHEpid2; float minDR_1 = 999; float minDR_2 = 999; vector<leptonContainer> lepton, neutrino; lepton.push_back(lepton1); lepton.push_back(lepton2); neutrino.push_back(neutrino1); neutrino.push_back(neutrino2); leptonContainer leptFromV1, leptFromV2, neuFromV1, neuFromV2; for(size_t iLep= 0; iLep < lepton.size(); iLep++){ for(size_t iNeu = 0; iNeu < neutrino.size(); iNeu++){ if((lepton.at(iLep).lepton4V_+neutrino.at(iNeu).lepton4V_).DeltaR(vboson1.lepton4V_) < minDR_1 ){ minDR_1 = (lepton.at(iLep).lepton4V_+neutrino.at(iNeu).lepton4V_).DeltaR(vboson1.lepton4V_); leptFromV1 = lepton.at(iLep); neuFromV1 = neutrino.at(iNeu); } if((lepton.at(iLep).lepton4V_+neutrino.at(iNeu).lepton4V_).DeltaR(vboson2.lepton4V_) < minDR_2){ minDR_2 = (lepton.at(iLep).lepton4V_+neutrino.at(iNeu).lepton4V_).DeltaR(vboson2.lepton4V_); leptFromV2 = lepton.at(iLep); neuFromV2 = neutrino.at(iNeu); } } } if(leptFromV1.lepton4V_ == leptFromV2.lepton4V_ or neuFromV1.lepton4V_ == neuFromV2.lepton4V_){ cerr<<" bad matching with gen W "<<endl; continue; } double costheta1 = 0; double costheta2 = 0; double Phi = 0; double costhetastar = 0; double Phi1 = 0; double costheta1_vbf = 0; double costheta2_vbf = 0; double Phi_vbf = 0; double costhetastar_vbf = 0; double Phi1_vbf = 0; TLorentzVector VV = vboson1.lepton4V_ + vboson2.lepton4V_; if(leptFromV1.charge_ > 0 and leptFromV2.charge_ > 0){ computeAnglesResonance(VV,vboson1.lepton4V_,neuFromV1.lepton4V_,leptFromV1.lepton4V_,vboson2.lepton4V_,neuFromV2.lepton4V_,leptFromV2.lepton4V_, costheta1,costheta2,Phi,costhetastar,Phi1); computeAnglesVBF(VV,vboson1.lepton4V_,neuFromV1.lepton4V_,leptFromV1.lepton4V_,vboson2.lepton4V_,neuFromV2.lepton4V_,leptFromV2.lepton4V_,parton1.lepton4V_, parton2.lepton4V_,costheta1_vbf,costheta2_vbf,Phi_vbf,costhetastar_vbf,Phi1_vbf); } else if(leptFromV1.charge_ < 0 and leptFromV2.charge_ < 0){ computeAnglesResonance(VV,vboson1.lepton4V_,leptFromV1.lepton4V_,neuFromV1.lepton4V_,vboson2.lepton4V_,leptFromV2.lepton4V_,neuFromV2.lepton4V_, costheta1,costheta2,Phi,costhetastar,Phi1); computeAnglesVBF(VV,vboson1.lepton4V_,leptFromV1.lepton4V_,neuFromV1.lepton4V_,vboson2.lepton4V_,leptFromV2.lepton4V_,neuFromV2.lepton4V_,parton1.lepton4V_, parton2.lepton4V_,costheta1_vbf,costheta2_vbf,Phi_vbf,costhetastar_vbf,Phi1_vbf); } else if(leptFromV1.charge_ < 0 and leptFromV2.charge_ > 0){ computeAnglesResonance(VV,vboson1.lepton4V_,leptFromV1.lepton4V_,neuFromV1.lepton4V_,vboson2.lepton4V_,neuFromV2.lepton4V_,leptFromV2.lepton4V_, costheta1,costheta2,Phi,costhetastar,Phi1); computeAnglesVBF(VV,vboson1.lepton4V_,leptFromV1.lepton4V_,neuFromV1.lepton4V_,vboson2.lepton4V_,neuFromV2.lepton4V_,leptFromV2.lepton4V_,parton1.lepton4V_, parton2.lepton4V_,costheta1_vbf,costheta2_vbf,Phi_vbf,costhetastar_vbf,Phi1_vbf); } else if(leptFromV1.charge_ > 0 and leptFromV2.charge_ < 0){ computeAnglesResonance(VV,vboson1.lepton4V_,neuFromV1.lepton4V_,leptFromV1.lepton4V_,vboson2.lepton4V_,leptFromV2.lepton4V_,neuFromV2.lepton4V_, costheta1,costheta2,Phi,costhetastar,Phi1); computeAnglesVBF(VV,vboson1.lepton4V_,neuFromV1.lepton4V_,leptFromV1.lepton4V_,vboson2.lepton4V_,leptFromV2.lepton4V_,neuFromV2.lepton4V_,parton1.lepton4V_, parton2.lepton4V_,costheta1_vbf,costheta2_vbf,Phi_vbf,costhetastar_vbf,Phi1_vbf); } else{ cerr<<" wrong charge composition "<<endl; continue; } float mTR = 0; float mR = 0; TLorentzVector L_met ,L_dijet, L_dilepton, L_LLmet; L_met = neutrino1.lepton4V_ + neutrino2.lepton4V_; L_dijet = parton1.lepton4V_ + parton2.lepton4V_; L_dilepton = lepton1.lepton4V_ + lepton2.lepton4V_; L_LLmet = L_dilepton + L_met ; computeRazor(lepton1.lepton4V_,lepton2.lepton4V_,L_met,mTR,mR); if(lepton1.lepton4V_.Pt() < minLeptonCutPt or lepton2.lepton4V_.Pt() < minLeptonCutPt) continue; // Loop on the cut list --> one cut for each polarization for(size_t iCut = 0; iCut < CutList.size(); iCut++){ // cut the events string name = "WW_EWK"; if(!passCutContainerSelection(reader, CutList.at(iCut), name, int(iCut), usePuppiAsDefault, minLeptonCutPt, minLeptonCleaningPt, leptonIsoCut_mu, leptonIsoCut_el, leptonIsoCutLoose, matchingCone, minJetCutPt, histoCutEff, finalStateString)) continue; float asimL = (lepton1.lepton4V_.Pt()-lepton2.lepton4V_.Pt())/(lepton1.lepton4V_.Pt()+lepton2.lepton4V_.Pt()) ; float asimJ = (parton1.lepton4V_.Pt()-parton2.lepton4V_.Pt())/(parton1.lepton4V_.Pt()+parton2.lepton4V_.Pt()) ; float Rvar = (lepton1.lepton4V_.Pt()*lepton2.lepton4V_.Pt())/(parton1.lepton4V_.Pt()*parton2.lepton4V_.Pt()) ; // loop on variables for(size_t iVar = 0; iVar < variableList.size(); iVar++){ histoContainer tmpPlot; tmpPlot.cutName = CutList.at(iCut).cutLayerName; tmpPlot.varName = variableList.at(iVar).variableName; vector<histoContainer>::iterator itVec ; itVec = find(plotVector.begin(),plotVector.end(),tmpPlot); if(itVec == plotVector.end()){ cerr<<"Problem -->plot not found for "<<CutList.at(iCut).cutLayerName<<" "<<variableList.at(iVar).variableName<<endl; continue ; } // vector boson info if(variableList.at(iVar).variableName == "ptV1"){ itVec->histogram->Fill(vboson1.lepton4V_.Pt(),1.*weight) ; } else if(variableList.at(iVar).variableName == "ptV2"){ itVec->histogram->Fill(vboson2.lepton4V_.Pt(),weight) ; } else if(variableList.at(iVar).variableName == "etaV1"){ itVec->histogram->Fill(vboson1.lepton4V_.Eta(),weight) ; } else if(variableList.at(iVar).variableName == "etaV2"){ itVec->histogram->Fill(vboson2.lepton4V_.Eta(),weight) ; } else if(variableList.at(iVar).variableName == "ptVV"){ itVec->histogram->Fill(L_dijet.Pt(),weight) ; } else if(variableList.at(iVar).variableName == "mVV"){ itVec->histogram->Fill(L_dijet.M(),weight) ; } // decay information if(variableList.at(iVar).variableName == "costheta1"){ itVec->histogram->Fill(fabs(costheta1),1.*weight) ; } else if(variableList.at(iVar).variableName == "costheta2"){ itVec->histogram->Fill(fabs(costheta2),weight) ; } if(variableList.at(iVar).variableName == "costheta1_vbf"){ itVec->histogram->Fill(fabs(costheta1_vbf),1.*weight) ; } else if(variableList.at(iVar).variableName == "costheta2_vbf"){ itVec->histogram->Fill(fabs(costheta2_vbf),weight) ; } if(variableList.at(iVar).variableName == "Phi"){ itVec->histogram->Fill(fabs(Phi),1.*weight) ; } else if(variableList.at(iVar).variableName == "Phi1"){ itVec->histogram->Fill(fabs(Phi1),weight) ; } if(variableList.at(iVar).variableName == "Phi_vbf"){ itVec->histogram->Fill(fabs(Phi_vbf),1.*weight) ; } else if(variableList.at(iVar).variableName == "Phi1_vbf"){ itVec->histogram->Fill(fabs(Phi1_vbf),weight) ; } else if(variableList.at(iVar).variableName == "costhetastar"){ itVec->histogram->Fill(fabs(costhetastar),weight) ; } else if(variableList.at(iVar).variableName == "costhetastar_vbf"){ itVec->histogram->Fill(fabs(costhetastar_vbf),weight) ; } else if(variableList.at(iVar).variableName == "mTR"){ itVec->histogram->Fill(mTR,weight) ; } else if(variableList.at(iVar).variableName == "mR"){ itVec->histogram->Fill(mR,weight) ; } // jet info if(variableList.at(iVar).variableName == "ptj1"){ itVec->histogram->Fill(parton1.lepton4V_.Pt(),1.*weight) ; } else if(variableList.at(iVar).variableName == "ptj2"){ itVec->histogram->Fill(parton2.lepton4V_.Pt(),weight) ; } else if(variableList.at(iVar).variableName == "etaj1"){ itVec->histogram->Fill(parton1.lepton4V_.Eta(),weight) ; } else if(variableList.at(iVar).variableName == "etaj2"){ itVec->histogram->Fill(parton2.lepton4V_.Eta(),weight) ; } else if(variableList.at(iVar).variableName == "detajj"){ itVec->histogram->Fill(fabs(parton1.lepton4V_.Eta()-parton2.lepton4V_.Eta()),weight) ; } else if(variableList.at(iVar).variableName == "ptjj"){ itVec->histogram->Fill(L_dijet.Pt(),weight) ; } else if(variableList.at(iVar).variableName == "mjj"){ itVec->histogram->Fill(L_dijet.M(),weight) ; } else if(variableList.at(iVar).variableName == "Asim_j"){ itVec->histogram->Fill(asimJ,weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_JJ"){ itVec->histogram->Fill(fabs(parton1.lepton4V_.DeltaPhi(parton2.lepton4V_)),weight) ; } else if(variableList.at(iVar).variableName == "ptl1"){ itVec->histogram->Fill(lepton1.lepton4V_.Pt(),weight) ; } else if(variableList.at(iVar).variableName == "ptl2"){ itVec->histogram->Fill(lepton2.lepton4V_.Pt(),weight) ; } else if(variableList.at(iVar).variableName == "etal1"){ itVec->histogram->Fill(lepton1.lepton4V_.Eta(),weight) ; } else if(variableList.at(iVar).variableName == "etal2"){ itVec->histogram->Fill(lepton2.lepton4V_.Eta(),weight) ; } else if(variableList.at(iVar).variableName == "mll"){ itVec->histogram->Fill(L_dilepton.M(),weight) ; } else if(variableList.at(iVar).variableName == "ptll"){ itVec->histogram->Fill(L_dilepton.Pt(),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_LL"){ itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(lepton2.lepton4V_)),weight) ; } else if(variableList.at(iVar).variableName == "Asim_l"){ itVec->histogram->Fill(asimL,weight) ; } else if(variableList.at(iVar).variableName == "met"){ itVec->histogram->Fill(L_met.Pt(),weight) ; } else if(variableList.at(iVar).variableName == "R"){ itVec->histogram->Fill(Rvar,weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_LMet"){ itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(L_met)),weight) ; } else if(variableList.at(iVar).variableName == "ptLMet"){ itVec->histogram->Fill((lepton1.lepton4V_ + L_met).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_TLMet"){ itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(L_met)),weight) ; } else if(variableList.at(iVar).variableName == "ptTLMet"){ itVec->histogram->Fill((lepton2.lepton4V_ + L_met).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_LLMet"){ itVec->histogram->Fill(fabs(L_dilepton.DeltaPhi(L_met)),weight) ; } else if(variableList.at(iVar).variableName == "ptLLMet"){ itVec->histogram->Fill((L_dilepton + L_met).Pt(),weight) ; } /// else if(variableList.at(iVar).variableName == "DeltaPhi_LJL"){ itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(parton1.lepton4V_)),weight) ; } else if(variableList.at(iVar).variableName == "ptLJL"){ itVec->histogram->Fill((lepton1.lepton4V_+parton1.lepton4V_).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_TJL"){ itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(parton2.lepton4V_)),weight) ; } else if(variableList.at(iVar).variableName == "ptTJL"){ itVec->histogram->Fill((lepton1.lepton4V_+parton2.lepton4V_).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_JJL"){ itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(L_dijet)),weight) ; } else if(variableList.at(iVar).variableName == "ptJJL"){ itVec->histogram->Fill((lepton1.lepton4V_+L_dijet).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_LJTL"){ itVec->histogram->Fill(fabs(lepton2.lepton4V_.DeltaPhi(parton1.lepton4V_)),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_TJTL"){ itVec->histogram->Fill(fabs(lepton2.lepton4V_.DeltaPhi(parton2.lepton4V_)),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_JJTL"){ itVec->histogram->Fill(fabs(lepton2.lepton4V_.DeltaPhi(L_dijet)),weight) ; } else if(variableList.at(iVar).variableName == "ptLJTL"){ itVec->histogram->Fill((lepton2.lepton4V_+parton1.lepton4V_).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "ptTJTL"){ itVec->histogram->Fill((lepton2.lepton4V_+parton2.lepton4V_).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "ptJJTL"){ itVec->histogram->Fill((lepton2.lepton4V_+L_dijet).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_LJLL"){ itVec->histogram->Fill(fabs(L_dilepton.DeltaPhi(parton1.lepton4V_)),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_TJLL"){ itVec->histogram->Fill(fabs(L_dilepton.DeltaPhi(parton2.lepton4V_)),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_JJLL"){ itVec->histogram->Fill(fabs(L_dilepton.DeltaPhi(L_dijet)),weight) ; } else if(variableList.at(iVar).variableName == "ptLJLL"){ itVec->histogram->Fill((L_dilepton+parton1.lepton4V_).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "ptTJLL"){ itVec->histogram->Fill((L_dilepton+parton2.lepton4V_).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "ptJJLL"){ itVec->histogram->Fill((L_dilepton+L_dijet).Pt(),weight) ; } /// else if(variableList.at(iVar).variableName == "DeltaPhi_JJMet"){ itVec->histogram->Fill(fabs(L_dijet.DeltaPhi(L_met)),weight) ; } else if(variableList.at(iVar).variableName == "ptJJMet"){ itVec->histogram->Fill((L_dijet+L_met).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_LJMet"){ itVec->histogram->Fill(fabs(parton1.lepton4V_.DeltaPhi(L_met)),weight) ; } else if(variableList.at(iVar).variableName == "ptLJMet"){ itVec->histogram->Fill((parton1.lepton4V_+L_met).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "DeltaPhi_TJMet"){ itVec->histogram->Fill(fabs(parton2.lepton4V_.DeltaPhi(L_met)),weight) ; } else if(variableList.at(iVar).variableName == "ptTJMet"){ itVec->histogram->Fill((parton2.lepton4V_+L_met).Pt(),weight) ; } else if(variableList.at(iVar).variableName == "mlljj"){ itVec->histogram->Fill((L_dilepton+L_dijet).M(),weight) ; } else if(variableList.at(iVar).variableName == "mlljjmet"){ itVec->histogram->Fill((L_dilepton+L_dijet+L_met).M(),weight) ; } else if(variableList.at(iVar).variableName == "mTH"){ itVec->histogram->Fill(sqrt(2*L_dilepton.Pt()*L_met.Pt()*(1-TMath::Cos(L_dilepton.DeltaPhi(L_met)))),weight) ; } } // loop on variables } // Loop on the cut list } // Loop on the events TFile* outputEfficiency = new TFile(("output/"+outputPlotDirectory+"/outputEfficiency.root").c_str(),"RECREATE"); for(map<string,TH1F*>::const_iterator itMap = histoCutEff.begin(); itMap != histoCutEff.end(); itMap++){ itMap->second->Scale(1./itMap->second->GetBinContent(1)); itMap->second->Write(); } outputEfficiency->Close(); // make the canvas and basic banners TCanvas *cCanvas = new TCanvas("cCanvas","",1,52,550,550); cCanvas->SetTicks(); cCanvas->SetFillColor(0); cCanvas->SetBorderMode(0); cCanvas->SetBorderSize(2); cCanvas->SetTickx(1); cCanvas->SetTicky(1); cCanvas->SetRightMargin(0.05); cCanvas->SetBottomMargin(0.12); cCanvas->SetFrameBorderMode(0); cCanvas->cd(); TPad* upperPad = new TPad("upperPad", "upperPad", .005, .180, .995, .980); TPad* lowerPad = new TPad("lowerPad", "lowerPad", .005, .005, .995, .18); lowerPad->SetGridx(); lowerPad->SetGridy(); upperPad->SetLeftMargin(0.12); upperPad->SetRightMargin(0.1); lowerPad->SetLeftMargin(0.12); lowerPad->SetRightMargin(0.1); lowerPad->SetTopMargin(0.002); lowerPad->Draw(); upperPad->Draw(); TCanvas *cCanvasNorm = new TCanvas("cCanvasNorm","",1,52,550,550); cCanvasNorm->SetTicks(); cCanvasNorm->SetFillColor(0); cCanvasNorm->SetBorderMode(0); cCanvasNorm->SetBorderSize(2); cCanvasNorm->SetTickx(1); cCanvasNorm->SetTicky(1); cCanvasNorm->SetRightMargin(0.05); cCanvasNorm->SetBottomMargin(0.12); cCanvasNorm->SetFrameBorderMode(0); TLatex * tex = new TLatex(0.88,0.92," 14 TeV"); tex->SetNDC(); tex->SetTextAlign(31); tex->SetTextFont(42); tex->SetTextSize(0.045); tex->SetLineWidth(2); TLatex * tex2 = new TLatex(0.14,0.92,"Delphes"); tex2->SetNDC(); tex2->SetTextFont(61); tex2->SetTextSize(0.045); tex2->SetLineWidth(2); TLatex * tex3 = new TLatex(0.295,0.92,"Simulation Preliminary"); tex3->SetNDC(); tex3->SetTextFont(52); tex3->SetTextSize(0.04); tex3->SetLineWidth(2); TLegend* legend = new TLegend(0.55,0.75,0.85,0.89); legend->SetBorderSize(0); legend->SetFillColor(0); legend->SetFillStyle(0); legend->SetTextSize(0.04); legend->SetTextFont(42); legend->SetNColumns (3) ; // make the plot on the same canvas for each variable (legend entry is the cut layer name) vector<TH1F*> numerator ; vector<TH1F*> denominator ; for(size_t iVar = 0; iVar < variableList.size(); iVar++){ // loop on var numerator.clear(); denominator.clear(); for(size_t iCut = 0; iCut < CutList.size(); iCut++){ // loop on cuts histoContainer tmpPlot; tmpPlot.cutName = CutList.at(iCut).cutLayerName; tmpPlot.varName = variableList.at(iVar).variableName; vector<histoContainer>::iterator itVec ; itVec = find(plotVector.begin(),plotVector.end(),tmpPlot); if(itVec == plotVector.end()){ cerr<<"Problem -->plot not found for "<<CutList.at(iCut).cutLayerName<<" "<<variableList.at(iVar).variableName<<endl; } itVec->histogram->GetXaxis()->SetTitleSize(0.04); itVec->histogram->GetXaxis()->SetTitleOffset(1.16); itVec->histogram->GetXaxis()->SetLabelSize(0.04); itVec->histogram->GetYaxis()->SetRangeUser(0.001,itVec->histogram->GetMaximum()*1.25); itVec->histogram->GetYaxis()->SetTitleSize(0.05); itVec->histogram->GetYaxis()->SetTitleOffset(1.20); itVec->histogram->GetYaxis()->SetLabelSize(0.04); itVec->histogram->SetLineColor(iCut+1); if(iCut %2 == 0) itVec->histogram->SetLineStyle(1); else itVec->histogram->SetLineStyle(2); itVec->histogram->SetLineWidth(2); itVec->histogram->GetYaxis()->SetTitle("#sigma x lumi"); upperPad->cd(); if(iCut == 0) itVec->histogram->Draw("hist"); else itVec->histogram->Draw("hist same"); legend->AddEntry(itVec->histogram,CutList.at(iCut).cutLayerName.c_str(),"l"); if(itVec->findCutByLabel("LL")) numerator.push_back(itVec->histogram); denominator.push_back(itVec->histogram); cCanvasNorm->cd(); TH1F* htempNorm = (TH1F*) itVec->histogram->Clone((string(itVec->histogram->GetName())+"_norm").c_str()); htempNorm->Scale(1./itVec->histogram->Integral()); htempNorm->GetYaxis()->SetRangeUser(0.,htempNorm->GetMaximum()*1.5); if(iCut == 0) htempNorm->Draw("hist"); else htempNorm->Draw("hist same"); } // make ratio plot lowerPad->cd(); TH1F* numTotal = 0; TH1F* denTotal = 0; TH1F* ratio = 0; TH1F* ratioW = 0; for(size_t itNum = 0; itNum < numerator.size(); itNum ++){ if(itNum == 0 and ratio == 0) numTotal = (TH1F*) numerator.at(itNum)->Clone(("Num_"+string(numerator.at(itNum)->GetName())).c_str()); else if(ratio !=0) numTotal->Add(numerator.at(itNum)); } for(size_t itDen = 0; itDen < denominator.size(); itDen ++){ if(itDen == 0 and denTotal == 0 ) { denTotal = (TH1F*) denominator.at(itDen)->Clone(("Den_"+string(denominator.at(itDen)->GetName())).c_str()); } else if(denTotal !=0){ denTotal->Add(denominator.at(itDen)); } } ratio = new TH1F(("Ratio_"+string(denominator.at(0)->GetName())).c_str(),"",numTotal->GetNbinsX(),numTotal->GetBinLowEdge(1),numTotal->GetBinLowEdge(numTotal->GetNbinsX()+1)); ratio->GetYaxis()->SetTitle("S/(#sqrt{S+B})"); ratio->SetMarkerSize(1.1); ratioW = new TH1F(("ratioW_"+string(denominator.at(0)->GetName())).c_str(),"",numTotal->GetNbinsX(),numTotal->GetBinLowEdge(1),numTotal->GetBinLowEdge(numTotal->GetNbinsX()+1)); ratioW->GetYaxis()->SetTitle("weighted S/(#sqrt{S+B})"); ratioW->SetMarkerSize(1.1); TString name = "norm_" ; name += denTotal->GetName () ; TH1F * norm_denTotal = (TH1F *) denTotal->Clone (name) ; norm_denTotal->Scale (1. / norm_denTotal->GetMaximum ()) ; // weight the S/sqrt (B) by the shape of the total, // so that only bins with a lot of stats become visibly significant for(int iBin = 0; iBin < ratio->GetNbinsX()+1; iBin++){ if(denTotal->GetBinContent(iBin) !=0){ ratioW->SetBinContent(iBin, norm_denTotal->GetBinContent (iBin) * numTotal->GetBinContent(iBin) / sqrt(denTotal->GetBinContent(iBin))); ratio->SetBinContent(iBin, numTotal->GetBinContent(iBin) / sqrt(denTotal->GetBinContent(iBin))); } else ratio->SetBinContent(iBin,0.); } ratio->GetXaxis()->SetTitle(""); ratio->SetLineColor(kBlue); ratio->SetLineStyle(2); ratio->SetLineWidth(2); ratio->GetXaxis()->SetLabelOffset(999); ratio->GetXaxis()->SetLabelSize(0); ratio->GetYaxis()->SetLabelSize(0.15); ratio->GetYaxis()->SetTitleSize(0.15); ratio->GetYaxis()->SetTitleOffset(0.30); ratio->GetYaxis()->SetNdivisions(504); ratioW->GetXaxis()->SetTitle(""); ratioW->SetLineColor(kBlack); ratioW->SetLineWidth(2); ratioW->GetXaxis()->SetLabelOffset(999); ratioW->GetXaxis()->SetLabelSize(0); ratioW->GetYaxis()->SetLabelSize(0.15); ratioW->GetYaxis()->SetTitleSize(0.15); ratioW->GetYaxis()->SetTitleOffset(0.30); ratioW->GetYaxis()->SetNdivisions(504); ratio->GetYaxis()->SetRange(min(ratio->GetMinimum(),ratioW->GetMinimum())*0.9,max(ratio->GetMaximum(),ratioW->GetMaximum())*1.1); TH1F * frame = lowerPad->DrawFrame (ratio->GetXaxis ()->GetXmin (), 0., ratio->GetXaxis ()->GetXmax (), 2.) ; frame->GetXaxis()->SetTitle (ratio->GetXaxis ()->GetTitle ()) ; frame->GetYaxis()->SetTitle (ratio->GetYaxis ()->GetTitle ()) ; frame->GetXaxis()->SetLabelOffset(999); frame->GetXaxis()->SetLabelSize(0); frame->GetYaxis()->SetLabelSize(0.15); frame->GetYaxis()->SetTitleSize(0.15); frame->GetYaxis()->SetTitleOffset(0.30); frame->GetYaxis()->SetNdivisions(504); ratio->Draw("P"); ratioW->Draw("Lsame"); upperPad->cd(); tex->Draw("same"); tex2->Draw("same"); tex3->Draw("same"); legend->Draw("same"); cCanvas->SaveAs(string("output/"+outputPlotDirectory+"/xs/"+variableList.at(iVar).variableName+".pdf").c_str(),"pdf"); cCanvas->SaveAs(string("output/"+outputPlotDirectory+"/xs/"+variableList.at(iVar).variableName+".png").c_str(),"png"); cCanvas->SaveAs(string("output/"+outputPlotDirectory+"/xs/"+variableList.at(iVar).variableName+".root").c_str(),"root"); cCanvasNorm->cd(); tex->Draw("same"); tex2->Draw("same"); tex3->Draw("same"); legend->Draw("same"); cCanvasNorm->SaveAs(string("output/"+outputPlotDirectory+"/norm/"+variableList.at(iVar).variableName+".pdf").c_str(),"pdf"); cCanvasNorm->SaveAs(string("output/"+outputPlotDirectory+"/norm/"+variableList.at(iVar).variableName+".png").c_str(),"png"); cCanvasNorm->SaveAs(string("output/"+outputPlotDirectory+"/norm/"+variableList.at(iVar).variableName+".root").c_str(),"root"); legend->Clear(); } // loop on var cout<<"LHE filter efficiency : "<<passingLHEFilter<<" totEvent "<<totEvent<<" efficiency "<<float(passingLHEFilter)/float(totEvent)*100<<" % "<<endl; //Normalize histograms for(size_t ihisto = 0; ihisto < plotVector.size(); ihisto++){ if(plotVector.at(ihisto).varName == "DeltaPhi_LL") cout<<"Events Histo "<<plotVector.at(ihisto).histogram->GetName()<<" unweighted "<<plotVector.at(ihisto).histogram->GetEntries()<<" weighted "<<plotVector.at(ihisto).histogram->Integral(0,plotVector.at(ihisto).histogram->GetNbinsX()+1)<<endl; } return 0 ; }
int main (int argc, char **argv) { const int SUBSET = 0 ; const string NAME = "cteq6l1" ; //"cteq6l1" LHAPDF::PDF * pdf = LHAPDF::mkPDF (NAME, 0) ; gROOT->SetStyle ("Plain") ; // float commonScale = 125. ; // float commonScale = 0. ; // each one with its own scale float commonScale = -1. ; // dynamic scale of phantom // int N_PH_tot = 480000 ; int N_PH_tot = 80000 ; float PH_xs = 32.58 ; // fb map<string, TH1F *> hmap_PH = readSample ("/Users/govoni/data/TP/WZ/Phantom_QCD/total.lhe", "PH", pdf, commonScale, N_PH_tot) ; // int N_MG_tot = 400000 ; int N_MG_tot = 80000 ; float MG_xs = 287.59 ; // fb map<string, TH1F *> hmap_MG = readSample ("/Users/govoni/data/TP/WZ/Madgraph_QCD/total.lhe", "MG", pdf, commonScale, N_MG_tot) ; // compare shapes only // PH_xs = 1. ; // MG_xs = 1. ; TFile outfile ("testWZ01.root", "recreate") ; savemap (hmap_PH, outfile, PH_xs / N_PH_tot) ; savemap (hmap_MG, outfile, MG_xs / N_MG_tot) ; gStyle->SetStatStyle (0) ; gStyle->SetTitleStyle (0) ; gStyle->SetCanvasBorderSize (0) ; gStyle->SetFrameBorderSize (0) ; gStyle->SetLegendBorderSize (0) ; gStyle->SetStatBorderSize (0) ; gStyle->SetTitleBorderSize (0) ; gStyle->SetTitleYOffset (2) ; TCanvas c1 ; c1.SetLeftMargin (0.17) ; c1.SetTopMargin (0.1) ; string outFolderName = "testWZ01_plots/"; system (Form ("mkdir -p %s", outFolderName.c_str ())) ; // plotting map<string, TH1F *>::iterator iMap_MG = hmap_MG.begin () ; for (map<string, TH1F *>::iterator iMap_PH = hmap_PH.begin () ; iMap_PH != hmap_PH.end () ; ++iMap_PH) { iMap_PH->second->SetStats (0) ; iMap_MG->second->SetStats (0) ; iMap_PH->second->SetTitle ("") ; iMap_MG->second->SetTitle ("") ; iMap_PH->second->SetLineWidth (2) ; iMap_MG->second->SetLineWidth (2) ; iMap_PH->second->SetLineColor (30) ; iMap_MG->second->SetLineColor (9) ; iMap_PH->second->SetFillColor (30) ; TLegend leg (0.3, 0.9, 0.8, 1) ; leg.SetNColumns (3) ; leg.SetLineStyle (0) ; leg.SetFillStyle (0) ; leg.AddEntry (iMap_PH->second, "PH", "fl") ; leg.AddEntry (iMap_MG->second, "MG", "fl") ; iMap_PH->second->GetXaxis ()->SetTitle (iMap_PH->first.c_str ()) ; iMap_MG->second->GetXaxis ()->SetTitle (iMap_MG->first.c_str ()) ; iMap_MG->second->Draw () ; iMap_PH->second->Draw ("histsame") ; iMap_MG->second->SetFillStyle (3001) ; iMap_MG->second->SetFillColor (9) ; iMap_MG->second->DrawCopy ("E2same") ; iMap_MG->second->SetFillStyle (0) ; iMap_MG->second->SetFillColor (0) ; iMap_MG->second->Draw ("same") ; leg.Draw () ; c1.Print ((outFolderName + iMap_PH->first + ".png").c_str (), "png") ; ++iMap_MG ; } return 0 ; }
void compareFourVersions(TimeInfoAllSteps TIAS_1,TimeInfoAllSteps TIAS_2,TimeInfoAllSteps TIAS_3,TimeInfoAllSteps TIAS_4,TString file_postfix) { gStyle->SetOptStat(0); TH1F *htime_iter_1 = new TH1F("time_iter_1"+file_postfix,"time_iter_1",8,0,8); timingTestPerIter(TIAS_1,htime_iter_1); htime_iter_1->SetLineStyle(TIAS_1.style()); htime_iter_1->SetLineColor(TIAS_1.color()); TH1F *htime_iter_2 = new TH1F("time_iter_2"+file_postfix,"time_iter_2",8,0,8); timingTestPerIter(TIAS_2,htime_iter_2); htime_iter_2->SetLineStyle(TIAS_2.style()); htime_iter_2->SetLineColor(TIAS_2.color()); TH1F *htime_iter_3 = new TH1F("time_iter_3"+file_postfix,"time_iter_3",8,0,8); timingTestPerIter(TIAS_3,htime_iter_3); htime_iter_3->SetLineStyle(TIAS_3.style()); htime_iter_3->SetLineColor(TIAS_3.color()); TH1F *htime_iter_4 = new TH1F("time_iter_4"+file_postfix,"time_iter_4",8,0,8); timingTestPerIter(TIAS_4,htime_iter_4); htime_iter_4->SetLineStyle(TIAS_4.style()); htime_iter_4->SetLineColor(TIAS_4.color()); htime_iter_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_iter_1->GetBinContent(htime_iter_1->GetMaximumBin()),TMath::Max(htime_iter_2->GetBinContent(htime_iter_2->GetMaximumBin()),TMath::Max(htime_iter_3->GetBinContent(htime_iter_3->GetMaximumBin()),htime_iter_4->GetBinContent(htime_iter_4->GetMaximumBin()))))); TLegend* leg = new TLegend(0.1,0.91,0.9,0.99); leg->SetNColumns(4); leg->SetFillColor(kWhite); leg->SetLineColor(kWhite); leg->AddEntry(htime_iter_1,TIAS_1.legend(),"L"); leg->AddEntry(htime_iter_2,TIAS_2.legend(),"L"); leg->AddEntry(htime_iter_3,TIAS_3.legend(),"L"); leg->AddEntry(htime_iter_4,TIAS_4.legend(),"L"); TCanvas c0; c0.SetTicks(1,1); htime_iter_1->Draw("H"); htime_iter_2->Draw("H,same"); htime_iter_3->Draw("H,same"); htime_iter_4->Draw("H,same"); leg->Draw(); c0.SetGridy(); c0.SaveAs("timingNew_iter_"+file_postfix+".png"); TH1F *htime_step_1 = new TH1F("time_step_1"+file_postfix,"time_step_1",5,0,5); timingTestPerStep(TIAS_1,htime_step_1); htime_step_1->SetLineStyle(TIAS_1.style()); htime_step_1->SetLineColor(TIAS_1.color()); htime_step_1->GetYaxis()->SetTitle("time [s]"); TH1F *htime_step_2 = new TH1F("time_step_2"+file_postfix,"time_step_2",5,0,5); timingTestPerStep(TIAS_2,htime_step_2); htime_step_2->SetLineStyle(TIAS_2.style()); htime_step_2->SetLineColor(TIAS_2.color()); TH1F *htime_step_3 = new TH1F("time_step_3"+file_postfix,"time_step_3",5,0,5); timingTestPerStep(TIAS_3,htime_step_3); htime_step_3->SetLineStyle(TIAS_3.style()); htime_step_3->SetLineColor(TIAS_3.color()); TH1F *htime_step_4 = new TH1F("time_step_4"+file_postfix,"time_step_4",5,0,5); timingTestPerStep(TIAS_4,htime_step_4); htime_step_4->SetLineStyle(TIAS_4.style()); htime_step_4->SetLineColor(TIAS_4.color()); TCanvas c1; c1.SetTicks(1,1); //htime_step_1->Scale(1./htime_step_1->Integral()); //htime_step_2->Scale(1./htime_step_2->Integral()); //htime_step_3->Scale(1./htime_step_3->Integral()); //htime_step_4->Scale(1./htime_step_4->Integral()); htime_step_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_step_1->GetBinContent(htime_step_1->GetMaximumBin()),TMath::Max(htime_step_2->GetBinContent(htime_step_2->GetMaximumBin()),TMath::Max(htime_step_3->GetBinContent(htime_step_3->GetMaximumBin()),htime_step_4->GetBinContent(htime_step_4->GetMaximumBin()))))); htime_step_1->Draw("H"); htime_step_2->Draw("H,same"); htime_step_3->Draw("H,same"); htime_step_4->Draw("H,same"); leg->Draw(); c1.SetGridy(); c1.SaveAs("timingNew_step_"+file_postfix+".png"); TH1F *htime_track_1 = (TH1F*) htime_iter_1->Clone("time_track_1"+file_postfix); htime_track_1->Reset(); makeTimePerTrackPlot(htime_track_1,htime_iter_1,TIAS_1.mtvfile()); TH1F *htime_track_2 = (TH1F*) htime_iter_2->Clone("time_track_2"+file_postfix); htime_track_2->Reset(); makeTimePerTrackPlot(htime_track_2,htime_iter_2,TIAS_2.mtvfile()); TH1F *htime_track_3 = (TH1F*) htime_iter_3->Clone("time_track_3"+file_postfix); htime_track_3->Reset(); makeTimePerTrackPlot(htime_track_3,htime_iter_3,TIAS_3.mtvfile()); TH1F *htime_track_4 = (TH1F*) htime_iter_4->Clone("time_track_4"+file_postfix); htime_track_4->Reset(); makeTimePerTrackPlot(htime_track_4,htime_iter_4,TIAS_4.mtvfile()); htime_track_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_track_1->GetBinContent(htime_track_1->GetMaximumBin()),TMath::Max(htime_track_2->GetBinContent(htime_track_2->GetMaximumBin()),TMath::Max(htime_track_3->GetBinContent(htime_track_3->GetMaximumBin()),htime_track_4->GetBinContent(htime_track_4->GetMaximumBin()))))); htime_track_1->GetYaxis()->SetTitle("time/HP track [s]"); htime_track_1->GetYaxis()->SetTitleOffset(1.25); TCanvas c2; c2.SetTicks(1,1); htime_track_1->Draw("H"); htime_track_2->Draw("H,same"); htime_track_3->Draw("H,same"); htime_track_4->Draw("H,same"); leg->Draw(); c2.SetGridy(); c2.SaveAs("timingNew_track_"+file_postfix+".png"); }
void compareThreeVersions(TimeInfoAllSteps TIAS_1,TimeInfoAllSteps TIAS_2,TimeInfoAllSteps TIAS_3,TString file_postfix) { gStyle->SetOptStat(0); TPaveText* labelcms = new TPaveText(0.20,0.79,0.54,0.92,"NDCBR"); labelcms->SetTextAlign(12); labelcms->SetTextSize(0.04); labelcms->SetFillColor(kWhite); labelcms->AddText("CMS Preliminary Simulation"); //labelcms->AddText("CMS Preliminary"); //labelcms->AddText("Simulation"); labelcms->AddText("#sqrt{s} = 8 TeV, t#bar{t}+PU"); labelcms->SetBorderSize(0); labelcms->SetTextFont(42); labelcms->SetLineWidth(2); TH1F *htime_iter_1 = new TH1F("time_iter_1"+file_postfix,"time_iter_1",8,0,8); timingTestPerIter(TIAS_1,htime_iter_1); htime_iter_1->SetLineStyle(TIAS_1.style()); htime_iter_1->SetLineColor(TIAS_1.color()); TH1F *htime_iter_2 = new TH1F("time_iter_2"+file_postfix,"time_iter_2",8,0,8); timingTestPerIter(TIAS_2,htime_iter_2); htime_iter_2->SetLineStyle(TIAS_2.style()); htime_iter_2->SetLineColor(TIAS_2.color()); TH1F *htime_iter_3 = new TH1F("time_iter_3"+file_postfix,"time_iter_3",8,0,8); timingTestPerIter(TIAS_3,htime_iter_3); htime_iter_3->SetLineStyle(TIAS_3.style()); htime_iter_3->SetLineColor(TIAS_3.color()); float iter_Iter0PU20 = htime_iter_1->GetBinContent(1); htime_iter_1->Scale(1./iter_Iter0PU20); htime_iter_2->Scale(1./iter_Iter0PU20); htime_iter_3->Scale(1./iter_Iter0PU20); htime_iter_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_iter_1->GetBinContent(htime_iter_1->GetMaximumBin()),TMath::Max(htime_iter_2->GetBinContent(htime_iter_2->GetMaximumBin()),htime_iter_3->GetBinContent(htime_iter_3->GetMaximumBin())))); TLegend* leg = new TLegend(0.2,0.59,0.45,0.79); leg->SetNColumns(1); leg->SetFillColor(kWhite); leg->SetLineColor(kWhite); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->AddEntry(htime_iter_1,TIAS_1.legend(),"L"); leg->AddEntry(htime_iter_2,TIAS_2.legend(),"L"); leg->AddEntry(htime_iter_3,TIAS_3.legend(),"L"); htime_iter_1->GetYaxis()->SetTitleOffset(1.2); htime_iter_1->GetXaxis()->SetRangeUser(0,7); htime_iter_1->GetYaxis()->SetTitle("time [1/iter0@<PU>=20]"); htime_iter_1->GetYaxis()->SetTitleSize(0.04); htime_iter_1->GetXaxis()->SetTitleSize(0.04); htime_iter_1->GetYaxis()->SetLabelSize(0.04); TCanvas c0; c0.SetTicks(1,1); htime_iter_1->Draw("H"); htime_iter_2->Draw("H,same"); htime_iter_3->Draw("H,same"); leg->Draw(); labelcms->Draw(); c0.SetGridy(); c0.SaveAs("timingNew_iter_"+file_postfix+".png"); TH1F *htime_step_1 = new TH1F("time_step_1"+file_postfix,"time_step_1",5,0,5); timingTestPerStep(TIAS_1,htime_step_1); htime_step_1->SetLineStyle(TIAS_1.style()); htime_step_1->SetLineColor(TIAS_1.color()); htime_step_1->GetYaxis()->SetTitle("time [1/building@<PU>=20]"); TH1F *htime_step_2 = new TH1F("time_step_2"+file_postfix,"time_step_2",5,0,5); timingTestPerStep(TIAS_2,htime_step_2); htime_step_2->SetLineStyle(TIAS_2.style()); htime_step_2->SetLineColor(TIAS_2.color()); TH1F *htime_step_3 = new TH1F("time_step_3"+file_postfix,"time_step_3",5,0,5); timingTestPerStep(TIAS_3,htime_step_3); htime_step_3->SetLineStyle(TIAS_3.style()); htime_step_3->SetLineColor(TIAS_3.color()); float step_BuildPU20 = htime_step_1->GetBinContent(3); htime_step_1->Scale(1./step_BuildPU20); htime_step_2->Scale(1./step_BuildPU20); htime_step_3->Scale(1./step_BuildPU20); htime_step_1->GetYaxis()->SetTitleOffset(1.2); htime_step_1->GetXaxis()->SetRangeUser(0,7); htime_step_1->GetYaxis()->SetTitleSize(0.04); htime_step_1->GetXaxis()->SetTitleSize(0.04); htime_step_1->GetYaxis()->SetLabelSize(0.04); TCanvas c1; c1.SetTicks(1,1); //htime_step_1->Scale(1./htime_step_1->Integral()); //htime_step_2->Scale(1./htime_step_2->Integral()); //htime_step_3->Scale(1./htime_step_3->Integral()); htime_step_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_step_1->GetBinContent(htime_step_1->GetMaximumBin()),TMath::Max(htime_step_2->GetBinContent(htime_step_2->GetMaximumBin()),htime_step_3->GetBinContent(htime_step_3->GetMaximumBin())))); htime_step_1->GetXaxis()->SetRangeUser(1,5); htime_step_1->Draw("H"); htime_step_2->Draw("H,same"); htime_step_3->Draw("H,same"); leg->SetX1NDC(0.60); leg->SetX2NDC(0.85); labelcms->SetX1NDC(0.60); labelcms->SetX2NDC(0.94); leg->Draw(); labelcms->Draw(); c1.SetGridy(); c1.SaveAs("timingNew_step_"+file_postfix+".png"); TH1F *htime_track_1 = (TH1F*) htime_iter_1->Clone("time_track_1"+file_postfix); htime_track_1->Reset(); makeTimePerTrackPlot(htime_track_1,htime_iter_1,TIAS_1.mtvfile()); TH1F *htime_track_2 = (TH1F*) htime_iter_2->Clone("time_track_2"+file_postfix); htime_track_2->Reset(); makeTimePerTrackPlot(htime_track_2,htime_iter_2,TIAS_2.mtvfile()); TH1F *htime_track_3 = (TH1F*) htime_iter_3->Clone("time_track_3"+file_postfix); htime_track_3->Reset(); makeTimePerTrackPlot(htime_track_3,htime_iter_3,TIAS_3.mtvfile()); float track_Iter0PU20 = htime_track_1->GetBinContent(1); htime_track_1->Scale(1./track_Iter0PU20); htime_track_2->Scale(1./track_Iter0PU20); htime_track_3->Scale(1./track_Iter0PU20); htime_track_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_track_1->GetBinContent(htime_track_1->GetMaximumBin()),TMath::Max(htime_track_2->GetBinContent(htime_track_2->GetMaximumBin()),htime_track_3->GetBinContent(htime_track_3->GetMaximumBin())))); TCanvas c2; c2.SetTicks(1,1); htime_track_1->GetYaxis()->SetTitleOffset(1.2); htime_track_1->GetXaxis()->SetRangeUser(0,7); htime_track_1->GetYaxis()->SetTitle("time/track [1/iter0@<PU>=20]"); htime_track_1->GetYaxis()->SetTitleSize(0.04); htime_track_1->GetXaxis()->SetTitleSize(0.04); htime_track_1->GetYaxis()->SetLabelSize(0.04); htime_track_1->Draw("H"); htime_track_2->Draw("H,same"); htime_track_3->Draw("H,same"); leg->SetX1NDC(0.2); leg->SetX2NDC(0.45); labelcms->SetX1NDC(0.2); labelcms->SetX2NDC(0.54); leg->Draw(); labelcms->Draw(); c2.SetGridy(); c2.SaveAs("timingNew_track_"+file_postfix+".png"); }
void compareTwoVersions(TimeInfoAllSteps TIAS_old, TimeInfoAllSteps TIAS_new,TString file_postfix) { gStyle->SetOptStat(0); TH1F *htime_iter_old = new TH1F("time_iter_old"+file_postfix,"time_iter_old",8,0,8); timingTestPerIter(TIAS_old,htime_iter_old); htime_iter_old->SetLineStyle(TIAS_old.style()); htime_iter_old->SetLineColor(TIAS_old.color()); TH1F *htime_iter_new = new TH1F("time_iter_new"+file_postfix,"time_iter_new",8,0,8); timingTestPerIter(TIAS_new,htime_iter_new); htime_iter_new->SetLineStyle(TIAS_new.style()); htime_iter_new->SetLineColor(TIAS_new.color()); htime_iter_old->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_iter_old->GetBinContent(htime_iter_old->GetMaximumBin()),htime_iter_new->GetBinContent(htime_iter_new->GetMaximumBin()))); TLegend* leg = new TLegend(0.1,0.91,0.9,0.99); leg->SetNColumns(2); leg->SetFillColor(kWhite); leg->SetLineColor(kWhite); leg->AddEntry(htime_iter_old,TIAS_old.legend(),"L"); leg->AddEntry(htime_iter_new,TIAS_new.legend(),"L"); TCanvas c0; c0.SetTicks(1,1); htime_iter_old->Draw("H"); htime_iter_new->Draw("H,same"); leg->Draw(); c0.SetGridy(); c0.SaveAs("timingNew_iter_"+file_postfix+".png"); TH1F *htime_step_old = new TH1F("time_step_old"+file_postfix,"time_step_old",5,0,5); timingTestPerStep(TIAS_old,htime_step_old); htime_step_old->SetLineStyle(TIAS_old.style()); htime_step_old->SetLineColor(TIAS_old.color()); htime_step_old->GetYaxis()->SetTitle("time [s]"); TH1F *htime_step_new = new TH1F("time_step_new"+file_postfix,"time_step_new",5,0,5); timingTestPerStep(TIAS_new,htime_step_new); htime_step_new->SetLineStyle(TIAS_new.style()); htime_step_new->SetLineColor(TIAS_new.color()); TCanvas c1; c1.SetTicks(1,1); //htime_step_old->Scale(1./htime_step_old->Integral()); //htime_step_new->Scale(1./htime_step_new->Integral()); htime_step_old->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_step_old->GetBinContent(htime_step_old->GetMaximumBin()),htime_step_new->GetBinContent(htime_step_new->GetMaximumBin()))); htime_step_old->Draw("H"); htime_step_new->Draw("H,same"); leg->Draw(); c1.SetGridy(); c1.SaveAs("timingNew_step_"+file_postfix+".png"); TH1F *htime_track_old = (TH1F*) htime_iter_old->Clone("time_track_old"+file_postfix); htime_track_old->Reset(); makeTimePerTrackPlot(htime_track_old,htime_iter_old,TIAS_old.mtvfile()); TH1F *htime_track_new = (TH1F*) htime_iter_new->Clone("time_track_new"+file_postfix); htime_track_new->Reset(); makeTimePerTrackPlot(htime_track_new,htime_iter_new,TIAS_new.mtvfile()); htime_track_old->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_track_old->GetBinContent(htime_track_old->GetMaximumBin()),htime_track_new->GetBinContent(htime_track_new->GetMaximumBin()))); htime_track_old->GetYaxis()->SetTitle("time/HP track [s]"); htime_track_old->GetYaxis()->SetTitleOffset(1.25); TCanvas c2; c2.SetTicks(1,1); htime_track_old->Draw("H"); htime_track_new->Draw("H,same"); leg->Draw(); c2.SetGridy(); c2.SaveAs("timingNew_track_"+file_postfix+".png"); }
void OneDYPlot(vector<TGraphAsymmErrors*> g_data, vector<TGraphAsymmErrors*> g_mg, vector<TGraphAsymmErrors*> g_ph, vector<TGraphAsymmErrors*> g_re, vector<TGraphAsymmErrors*> g_ANlo, vector<TGraphAsymmErrors*> g_Pyth8) { TGraphAsymmErrors* g_data_Y = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_mg_Y = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_ph_Y = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_re_Y = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_ANlo_Y = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_Pyh8_Y = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_Data_Y_ratio = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_mg_Y_ratio = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_ph_Y_ratio = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_re_Y_ratio = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_ANlo_Y_ratio = new TGraphAsymmErrors(ny); TGraphAsymmErrors* g_Pyh8_Y_ratio = new TGraphAsymmErrors(ny); for (size_t i = 0; i < ny; i++) { cout << "our error for the first bin is " << g_data[i]->GetErrorYhigh(0) << endl; } double YError = 0; size_t YBin = 5; for (size_t i = 0; i < nphistar; i++) { double BinSizeSquared = (phistarBins[i + 1] - phistarBins[i])*(phistarBins[i + 1] - phistarBins[i]); double x, y; g_data[YBin]->GetPoint(i, x, y); cout << "Error For Phistar bin " << i << " is: " << sqrt(g_data[YBin]->GetErrorYhigh(i) * g_data[YBin]->GetErrorYhigh(i)) << endl; YError = sqrt(YError * YError + g_data[YBin]->GetErrorYhigh(i) * g_data[YBin]->GetErrorYhigh(i) * BinSizeSquared); } cout << "OOOKAy our int value is " << IntValue(g_data[YBin]) << endl; cout << "And our error is " << YError << endl; for (int i = 0; i < (int) ny; i++) { g_data_Y->SetPoint(i, .2 + .4 * i, IntValue(g_data[i])); g_mg_Y->SetPoint(i, .2 + .4 * i, IntValue(g_mg[i])); g_ph_Y->SetPoint(i, .2 + .4 * i, IntValue(g_ph[i])); g_re_Y->SetPoint(i, .2 + .4 * i, IntValue(g_re[i])); g_ANlo_Y->SetPoint(i, .2 + .4 * i, IntValue(g_ANlo[i])); g_Pyh8_Y->SetPoint(i, .2 + .4 * i, IntValue(g_Pyth8[i])); g_data_Y->SetPointError(i, 0, 0, YErrorValue(g_data[i]), YErrorValue(g_data[i])); g_mg_Y->SetPointError(i, 0, 0, YErrorValue(g_mg[i]), YErrorValue(g_mg[i])); g_ph_Y->SetPointError(i, 0, 0, YErrorValue(g_ph[i]), YErrorValue(g_ph[i])); g_re_Y->SetPointError(i, 0, 0, YErrorValue(g_re[i]), YErrorValue(g_re[i])); g_ANlo_Y->SetPointError(i, 0, 0, YErrorValue(g_ANlo[i]), YErrorValue(g_ANlo[i])); g_Pyh8_Y->SetPointError(i, 0, 0, YErrorValue(g_Pyth8[i]), YErrorValue(g_Pyth8[i])); } RatioValue(g_Data_Y_ratio, g_data_Y, g_data_Y); RatioValue(g_mg_Y_ratio, g_data_Y, g_mg_Y); RatioValue(g_ph_Y_ratio, g_data_Y, g_ph_Y); RatioValue(g_re_Y_ratio, g_data_Y, g_re_Y); RatioValue(g_ANlo_Y_ratio, g_data_Y, g_ANlo_Y); RatioValue(g_Pyh8_Y_ratio, g_data_Y, g_Pyh8_Y); TCanvas* FinalPhiTot = new TCanvas("FinalPhiTot", "FinalPhiTot", 800, 900); FinalPhiTot->Divide(1, 2); FinalPhiTot->cd(1); gPad->SetPad("p1", "p1", 0, 2.5 / 9.0, 1, 1, kWhite, 0, 0); gPad->SetBottomMargin(0.01); gPad->SetTopMargin(0.06); gPad->SetLeftMargin(0.15); gPad->SetRightMargin(0.06); //gPad->SetLogy(1); g_data_Y->SetTitle(""); g_data_Y->GetYaxis()->SetTitle("1/#sigma^{fid} #bullet d#sigma^{fid}/dy"); g_data_Y->GetYaxis()->SetTitleSize(.065); g_data_Y->GetYaxis()->SetTitleOffset(1.); g_data_Y->GetYaxis()->CenterTitle(); g_data_Y->GetYaxis()->SetLabelSize(0.05); g_data_Y->GetXaxis()->SetRangeUser(0.0, 2.4); g_data_Y->GetXaxis()->SetLabelSize(.0); g_data_Y->SetFillColor(kGray); if (doNorm) g_data_Y->GetYaxis()->SetRangeUser(.01, .8); else g_data_Y->GetYaxis()->SetRangeUser(1000, 400000.0); g_data_Y->Draw("A2"); int Color1 = kBlue; int Color2 = kRed; g_mg_Y->SetMarkerColor(Color1); g_mg_Y->SetLineColor(Color1); g_mg_Y->SetMarkerSize(1); g_mg_Y->SetLineWidth(2); g_mg_Y->SetMarkerStyle(4); g_mg_Y->Draw("PEsame"); g_ph_Y->SetMarkerColor(Color2); g_ph_Y->SetLineColor(Color2); g_ph_Y->SetMarkerSize(1); g_ph_Y->SetLineWidth(2); g_ph_Y->SetMarkerStyle(20); g_ph_Y->Draw("PEsame"); int ColorError = kYellow; g_data_Y->SetFillColor(ColorError); g_data_Y->SetMarkerSize(1); g_data_Y->SetLineWidth(2); g_data_Y->SetMarkerStyle(20); g_data_Y->Draw("PEsame"); g_data_Y->SetFillColor(ColorError); TLegend* leg = new TLegend(0.23, 0.76, 0.95, 0.94); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetLineWidth(1); leg->SetNColumns(1); leg->SetTextFont(42); leg->AddEntry(g_data_Y, "2012 data", "PEF"); leg->AddEntry(g_mg_Y, "Z #rightarrow ee MadGraph+Pythia6 (Z2star)", "P"); leg->AddEntry(g_ph_Y, "Z #rightarrow ee POWHEG+Pythia6 (Z2star)", "P"); leg->Draw(); TLatex mark; // mark.SetTextSize(0.05); mark.SetTextSize(0.035); mark.SetNDC(true); mark.DrawLatex(0.745, 0.95, "19.7 fb^{-1} (8 TeV)"); mark.DrawLatex(0.19, 0.955, "CMS Preliminary"); //if (Type == "elec") { mark.DrawLatex(0.19, 0.20, "|#eta^{l_{0}}| < 2.1, |#eta^{l_{1}}| < 2.4"); mark.DrawLatex(0.19, 0.13, "p_{T}^{l_{0}} > 30 GeV, p_{T}^{l_{1}} > 20 GeV"); mark.DrawLatex(0.19, 0.06, "60 GeV < M_{ll} < 120 GeV"); //} FinalPhiTot->cd(2); gPad->SetPad("p2", "p2", 0, 0, 1, 2.5 / 9.0, kWhite, 0, 0); gPad->SetBottomMargin(0.37); gPad->SetTopMargin(0.01); gPad->SetLeftMargin(0.15); gPad->SetRightMargin(0.06); g_Data_Y_ratio->SetTitle(""); g_Data_Y_ratio->GetYaxis()->SetTitle("MC/Data "); g_Data_Y_ratio->GetYaxis()->SetTitleOffset(0.4); g_Data_Y_ratio->GetYaxis()->SetTitleSize(.15); g_Data_Y_ratio->SetFillColor(kYellow); g_Data_Y_ratio->GetYaxis()->SetRangeUser(0.9, 1.1); g_Data_Y_ratio->GetYaxis()->SetLabelSize(0.04); g_Data_Y_ratio->GetXaxis()->SetLabelSize(0.13); g_Data_Y_ratio->GetXaxis()->SetLabelOffset(0.02); g_Data_Y_ratio->GetXaxis()->SetRangeUser(0, 2.4); g_Data_Y_ratio->GetXaxis()->SetNdivisions(510); g_Data_Y_ratio->GetXaxis()->SetTitle("y_{ll}"); g_Data_Y_ratio->GetXaxis()->SetTitleSize(0.15); g_Data_Y_ratio->GetXaxis()->SetTitleOffset(1); g_Data_Y_ratio->GetXaxis()->CenterTitle(); g_Data_Y_ratio->GetYaxis()->SetNdivisions(505); g_Data_Y_ratio->GetYaxis()->SetLabelSize(0.13); g_Data_Y_ratio->Draw("AE2"); g_mg_Y_ratio->SetMarkerSize(1); g_mg_Y_ratio->SetLineWidth(2); g_mg_Y_ratio->SetMarkerStyle(4); g_mg_Y_ratio->SetMarkerColor(Color1); g_mg_Y_ratio->SetLineColor(Color1); g_mg_Y_ratio->Draw("PEsame"); g_ph_Y_ratio->SetMarkerSize(1); g_ph_Y_ratio->SetLineWidth(2); g_ph_Y_ratio->SetMarkerStyle(20); g_ph_Y_ratio->SetMarkerColor(Color2); g_ph_Y_ratio->SetLineColor(Color2); g_ph_Y_ratio->Draw("PEsame"); std::string plotname = "Plots/YFull"; if (!doMG) plotname += "PH_"; if (doNorm) plotname += "Norm_"; else plotname += "Abs_"; if (elec == 0)plotname += "Dressed."; if (elec == 1)plotname += "Born."; if (elec == 2)plotname += "Naked."; FinalPhiTot->SaveAs((plotname + "pdf").c_str()); FinalPhiTot->SaveAs((plotname + "png").c_str()); FinalPhiTot->SaveAs((plotname + "C").c_str()); //RatioPlotStart TCanvas* FinalPhiRatio = new TCanvas("FinalPhiRatio", "FinalPhiRatio", 800, 900); FinalPhiRatio->cd(); g_Data_Y_ratio->SetTitle(""); g_Data_Y_ratio->GetYaxis()->SetTitle("MC/Data"); g_Data_Y_ratio->GetYaxis()->CenterTitle(); g_Data_Y_ratio->SetFillColor(kYellow); g_Data_Y_ratio->GetYaxis()->SetRangeUser(0.5, 1.25); g_Data_Y_ratio->GetYaxis()->SetTitleOffset(1.2); g_Data_Y_ratio->GetYaxis()->SetTitleSize(0.04); g_Data_Y_ratio->GetYaxis()->SetLabelSize(0.04); g_Data_Y_ratio->GetXaxis()->SetRangeUser(0.0, 2.4); g_Data_Y_ratio->GetXaxis()->SetTitleSize(0.043); g_Data_Y_ratio->GetXaxis()->SetLabelSize(0.04); g_Data_Y_ratio->GetXaxis()->SetLabelOffset(0.012); g_Data_Y_ratio->Draw("AE2"); g_mg_Y_ratio->SetMarkerStyle(kFullTriangleUp); g_mg_Y_ratio->SetMarkerColor(kBlue - 7); g_mg_Y_ratio->SetLineColor(kBlue - 7); g_ph_Y_ratio->SetMarkerSize(1); g_ph_Y_ratio->SetLineWidth(2); g_ph_Y_ratio->SetMarkerStyle(kFullSquare); g_ph_Y_ratio->SetMarkerColor(kRed); g_ph_Y_ratio->SetLineColor(kRed); g_ph_Y_ratio->Draw("PEsame"); g_mg_Y_ratio->Draw("PEsame"); g_re_Y_ratio->SetMarkerColor(kGreen + 1); g_re_Y_ratio->SetLineColor(kGreen + 1); g_re_Y_ratio->SetMarkerSize(1); g_re_Y_ratio->SetLineWidth(2); g_re_Y_ratio->SetMarkerStyle(kStar); g_re_Y_ratio->Draw("PEsame"); g_ANlo_Y_ratio->SetMarkerSize(1); g_ANlo_Y_ratio->SetLineWidth(2); g_ANlo_Y_ratio->SetMarkerStyle(kOpenCircle); g_ANlo_Y_ratio->SetMarkerColor(kCyan + 2); g_ANlo_Y_ratio->SetLineColor(kCyan + 2); g_ANlo_Y_ratio->Draw("PEsame"); g_Pyh8_Y_ratio->SetMarkerSize(1); g_Pyh8_Y_ratio->SetLineWidth(2); g_Pyh8_Y_ratio->SetMarkerStyle(kOpenSquare); g_Pyh8_Y_ratio->SetMarkerColor(kRed); g_Pyh8_Y_ratio->SetLineColor(kRed); g_Pyh8_Y_ratio->Draw("PEsame"); //r_data_WO->Draw("PEsame"); mark.SetTextSize(0.03); mark.DrawLatex(0.7, 0.907, "19.7 fb^{-1} (8 TeV)"); mark.DrawLatex(0.19, 0.907, "CMS Preliminary"); if (Type == "elec") { mark.DrawLatex(0.15, 0.25, "|#eta^{l_{0}}| < 2.1, |#eta^{l_{1}}| < 2.4"); mark.DrawLatex(0.15, 0.20, "p_{T}^{l_{0}} > 30 GeV, p_{T}^{l_{1}} > 20 GeV"); mark.DrawLatex(0.15, 0.15, "60 GeV < M_{ll} < 120 GeV"); } TLegend* leg2 = new TLegend(0.13, 0.72, 0.7, 0.9); leg2->SetFillStyle(0); leg2->SetBorderSize(0); leg2->SetLineWidth(1); leg2->SetNColumns(1); leg2->SetTextFont(22); leg2->AddEntry(g_Data_Y_ratio, "2012 data", "F"); if (Type == "elec") { leg2->AddEntry(g_mg_Y_ratio, " MadGraph+Pythia6 (Z2*)", "P"); leg2->AddEntry(g_ph_Y_ratio, "POWHEG+Pythia6 (Z2*)", "P"); leg2->AddEntry(g_re_Y_ratio, "Resbos", "P"); leg2->AddEntry(g_ANlo_Y_ratio, "AMC@nlo+Pythia8(CUETP8M1)", "P"); leg2->AddEntry(g_Pyh8_Y_ratio, "POWHEG+Pythia8 (CT10)", "P"); } leg2->Draw(); plotname = "Plots/Ratio_YRatio"; plotname += Tag; //if (isPlot2 && Type == "combined")plotname += "MuEl"; //else if (isPlot2 && Type == "elec")plotname += "PHMG"; plotname += Type; plotname += "_"; if ((Type == "elec") && !doMG) plotname += "PH_"; if ((Type == "elec") && doMG) plotname += "MG_"; if (doNorm) plotname += "Norm_"; else plotname += "Abs_"; if (elec == 0)plotname += "Dressed."; if (elec == 1)plotname += "Born."; if (elec == 2)plotname += "Naked."; FinalPhiRatio->RedrawAxis(); FinalPhiRatio->SaveAs((plotname + "pdf").c_str()); FinalPhiRatio->SaveAs((plotname + "png").c_str()); FinalPhiRatio->SaveAs((plotname + "C").c_str()); }
void plotShape(string var, string title, int nBins, float min, float max, string label, int tags, int nsub){ gROOT->SetBatch(0); TFile *file1 = new TFile("Dec3_QCD_300_Inclusive_all.root"); TFile *file2 = new TFile("Dec3_QCD_470_Inclusive_all.root"); TFile *file3 = new TFile("Dec3_QCD_600_Inclusive_all.root"); TFile *file4 = new TFile("Dec3_QCD_800_Inclusive_all.root"); TFile *file5 = new TFile("Dec3_QCD_1000_Inclusive_all.root"); TFile *file6 = new TFile("Dec3_QCD_1400_Inclusive_all.root"); //TFile *data = new TFile("trees/data_all_mistag.root"); TChain *ttbar10 = new TChain("treeVars"); TChain *ttbar7 = new TChain("treeVars"); TChain *signal = new TChain("treeVars"); TChain *signal1 = new TChain("treeVars"); TChain *signal15 = new TChain("treeVars"); TChain *signal3 = new TChain("treeVars"); TTree *tree1 = (TTree *) file1->Get("treeVars"); TTree *tree2 = (TTree *) file2->Get("treeVars"); TTree *tree3 = (TTree *) file3->Get("treeVars"); TTree *tree4 = (TTree *) file4->Get("treeVars"); TTree *tree5 = (TTree *) file5->Get("treeVars"); TTree *tree6 = (TTree *) file6->Get("treeVars"); ttbar10->Add("Jan13_ttjets10_ptw.root"); ttbar7->Add("Jan13_ttjets7_ptw.root"); signal->Add("Aug19_Zp20_sec0_ttpair__TriggernoWeight.root"); signal1->Add("Aug19_Zp10_sec0_ttpair__TriggernoWeight.root"); signal15->Add("Aug19_Zp15_sec0_ttpair__TriggernoWeight.root"); signal3->Add("Aug19_Zp30_sec0_ttpair__TriggernoWeight.root"); //TTree *treeD = data->Get("treeVars"); string qcdvar = var; if (var == "mttMass") qcdvar = "mttMassPred"; string btag = " "; string btag0 = " && jet1SubjetMaxBDisc < 0.679 && jet2SubjetMaxBDisc < 0.679";// && jet1SubjetMaxBDisc > 0 && jet2SubjetMaxBDisc > 0"; string btag1 = " && (jet1SubjetMaxBDisc < 0.679 || jet2SubjetMaxBDisc < 0.679) && (jet1SubjetMaxBDisc > 0.679 || jet2SubjetMaxBDisc > 0.679)";// && jet1SubjetMaxBDisc > 0 && jet2SubjetMaxBDisc > 0"; string btag2 = " && jet1SubjetMaxBDisc > 0.679 && jet2SubjetMaxBDisc > 0.679";// && jet1SubjetMaxBDisc > 0 && jet2SubjetMaxBDisc > 0"; string nsub_sel = " "; if (tags == 0) btag = btag0; else if (tags == 1) btag = btag1; else if (tags == 2) btag = btag2; else btag = " "; if (nsub == 1) nsub_sel = " && jet1tau32 < 0.7 && jet2tau32 < 0.7"; string sel = "(index == 0 && cutflow == 4 && abs(deltaY) < 1.0" + btag + nsub_sel + ")"; string qcdsel = "(mistagWt)*(index == 1 && abs(deltaY) < 1.0" + btag +")"; if (nsub == 1) qcdsel = "(mistagWt)*(index == 1 && abs(deltaY) < 1.0" + btag + " && (jet1tau32 < 0.7 && jet2tau32 < 0.7) )"; string ttbarsel = sel+"*(ptReweight)"; TString btag_string = "0+1+2 b-tags"; if (tags == 0) btag_string = "0 b-tags"; if (tags == 1) btag_string = "1 b-tags"; if (tags == 2) btag_string = "2 b-tags"; TH1F *qcd1H = new TH1F("qcd1H", "qcd1H", nBins, min, max); TH1F *qcd2H = new TH1F("qcd2H", "qcd2H", nBins, min, max); TH1F *qcd3H = new TH1F("qcd3H", "qcd3H", nBins, min, max); TH1F *qcd4H = new TH1F("qcd4H", "qcd4H", nBins, min, max); TH1F *qcd5H = new TH1F("qcd5H", "qcd5H", nBins, min, max); TH1F *qcd6H = new TH1F("qcd6H", "qcd6H", nBins, min, max); TH1F *qcd1predH = new TH1F("qcd1predH", "qcd1predH", nBins, min, max); TH1F *qcd2predH = new TH1F("qcd2predH", "qcd2predH", nBins, min, max); TH1F *qcd3predH = new TH1F("qcd3predH", "qcd3predH", nBins, min, max); TH1F *qcd4predH = new TH1F("qcd4predH", "qcd4predH", nBins, min, max); TH1F *qcd5predH = new TH1F("qcd5predH", "qcd5predH", nBins, min, max); TH1F *qcd6predH = new TH1F("qcd6predH", "qcd6predH", nBins, min, max); TH1F *ttbar10H = new TH1F("ttbar10H", "ttbar10H", nBins,min,max); TH1F *ttbar7H = new TH1F("ttbar7H", "ttbar7H", nBins,min,max); TH1F *signalH = new TH1F("signalH", "signalH", nBins,min,max); TH1F *signal1H = new TH1F("signal1H", "signal1H", nBins,min,max); TH1F *signal15H = new TH1F("signal15H", "signal15H", nBins,min,max); TH1F *signal3H = new TH1F("signal3H", "signal3H", nBins,min,max); cout << "VARIABLE: " << var << endl; tree1->Draw(Form("%s>>qcd1H", var.c_str()), sel.c_str(), "goff"); tree2->Draw(Form("%s>>qcd2H", var.c_str()), sel.c_str(), "goff"); tree3->Draw(Form("%s>>qcd3H", var.c_str()), sel.c_str(), "goff"); tree4->Draw(Form("%s>>qcd4H", var.c_str()), sel.c_str(), "goff"); tree5->Draw(Form("%s>>qcd5H", var.c_str()), sel.c_str(), "goff"); tree6->Draw(Form("%s>>qcd6H", var.c_str()), sel.c_str(), "goff"); ttbar10->Draw(Form("%s>>ttbar10H", var.c_str()), ttbarsel.c_str()); ttbar7->Draw(Form("%s>>ttbar7H", var.c_str()), ttbarsel.c_str()); signal->Draw(Form("%s>>signalH", var.c_str()), sel.c_str()); signal1->Draw(Form("%s>>signal1H", var.c_str()), sel.c_str()); signal15->Draw(Form("%s>>signal15H", var.c_str()), sel.c_str()); signal3->Draw(Form("%s>>signal3H", var.c_str()), sel.c_str()); tree1->Draw(Form("%s>>qcd1predH", qcdvar.c_str()), qcdsel.c_str(), "goff"); tree2->Draw(Form("%s>>qcd2predH", qcdvar.c_str()), qcdsel.c_str(), "goff"); tree3->Draw(Form("%s>>qcd3predH", qcdvar.c_str()), qcdsel.c_str(), "goff"); tree4->Draw(Form("%s>>qcd4predH", qcdvar.c_str()), qcdsel.c_str(), "goff"); tree5->Draw(Form("%s>>qcd5predH", qcdvar.c_str()), qcdsel.c_str(), "goff"); tree6->Draw(Form("%s>>qcd6predH", qcdvar.c_str()), qcdsel.c_str(), "goff"); //treeD->Draw(Form("%s>>dataH%s", variable.c_str(), binning.c_str()), cut.c_str(), "goff"); cout << "HEREEEEEEEEEEEEE" << endl; //dataH->Sumw2(); qcd1predH->Sumw2(); qcd2predH->Sumw2(); qcd3predH->Sumw2(); qcd4predH->Sumw2(); qcd5predH->Sumw2(); qcd6predH->Sumw2(); qcd1H->Sumw2(); qcd2H->Sumw2(); qcd3H->Sumw2(); qcd4H->Sumw2(); qcd5H->Sumw2(); qcd6H->Sumw2(); double lumi = 19400; double k = 1.0; qcd1H->Scale( k*1759.6*lumi / 5927300. ); qcd2H->Scale( k*113.9*lumi / 3994848. ); qcd3H->Scale( k*27.0*lumi / 3992760. ); qcd4H->Scale( k*3.57*lumi / 3978569. ); qcd5H->Scale( k*0.738*lumi / 1964086. ); qcd6H->Scale( k*0.0335*lumi / 2000062. ); qcd1predH->Scale( k*1759.6*lumi / 5927300. ); qcd2predH->Scale( k*113.9*lumi / 3994848. ); qcd3predH->Scale( k*27.0*lumi / 3992760. ); qcd4predH->Scale( k*3.57*lumi / 3978569. ); qcd5predH->Scale( k*0.738*lumi / 1964086. ); qcd6predH->Scale( k*0.0335*lumi / 2000062. ); ttbar7H->Scale(245. * lumi * 0.074 / 3082812.); ttbar10H->Scale(245. * lumi * 0.014 / 1249111.); signalH->Scale(1. * lumi / 90778. ); signal1H->Scale(1. * lumi / 101697. ); signal15H->Scale(1. * lumi / 20757. ); signal3H->Scale(1. * lumi / 91209. ); TH1F *totalH = qcd1H->Clone("totalH"); TH1F *totalPredH = qcd1predH->Clone("totalPredH"); totalH->Add(qcd2H); totalH->Add(qcd3H); totalH->Add(qcd4H); totalH->Add(qcd5H); totalH->Add(qcd6H); totalPredH->Add(qcd2predH); totalPredH->Add(qcd3predH); totalPredH->Add(qcd4predH); totalPredH->Add(qcd5predH); totalPredH->Add(qcd6predH); TCanvas *c1 = new TCanvas("c1", "c1",0,0,600,400); c1->Range(0,0,1,1); c1->Draw(); /* TPad *c1_1 = new TPad("c1_1", "newpad",0.01,0.01,0.99,0.32); c1_1->Draw(); TPad *c1_2 = new TPad("c1_2", "newpad",0.01,0.33,0.99,0.99); c1_2->Draw(); c1->cd(); c1_2->cd(); c1_2->SetTopMargin(0.1); c1_2->SetBottomMargin(0.01); c1_2->SetRightMargin(0.05); c1_2->SetLeftMargin(0.1); c1_2->SetFillStyle(0); c1->SetLogy(1); */ TH1F *ttbarH = (TH1F *) ttbar7H->Clone("ttbarH"); ttbarH->Add(ttbar10H); totalH->SetLineColor(kBlue); totalH->SetLineWidth(2); //totalH->DrawNormalized("hist"); //totalPredH->Draw("hist same"); qcd1predH->SetLineColor(kBlue); qcd2predH->SetLineColor(kRed); qcd3predH->SetLineColor(kGreen); qcd4predH->SetLineColor(kOrange); qcd5predH->SetLineColor(kViolet); qcd6predH->SetLineColor(kCyan); //qcd1predH->Draw("hist same"); //qcd2predH->Draw("hist same"); //qcd3predH->Draw("hist same"); //qcd4predH->Draw("hist same"); //qcd5predH->Draw("hist same"); //qcd6predH->Draw("hist same"); totalH->SetMarkerSize(0); totalH->SetLineWidth(3); totalH->SetLineColor(kBlack); totalH->GetXaxis()->SetTitle(title.c_str()); totalH->GetYaxis()->SetTitle("Fraction of Events"); totalH->GetYaxis()->SetTitleOffset(1.25); totalH->DrawNormalized("hist"); ttbarH->SetLineColor(kRed - 1); ttbarH->SetLineWidth(3); ttbarH->DrawNormalized("hist same"); signal1H->SetLineColor(kGreen + 1); signal1H->SetLineWidth(2); signal1H->DrawNormalized("hist same"); signalH->SetLineColor(kViolet); signalH->SetLineWidth(2); signalH->DrawNormalized("hist same"); signal3H->SetLineColor(kCyan + 2); signal3H->SetLineWidth(2); signal3H->DrawNormalized("hist same"); TLegend *leg = new TLegend(0.1,0.9,0.9,0.99); leg->SetNColumns(3); leg->AddEntry(totalH, btag_string, ""); leg->AddEntry(totalH, "QCD", "l"); leg->AddEntry(ttbarH, "t#bar{t}", "l"); leg->AddEntry(signal1H, "Narrow Z' (1 TeV)", "l"); leg->AddEntry(signalH, "Narrow Z' (2 TeV)", "l"); leg->AddEntry(signal3H, "Narrow Z' (3 TeV)", "l"); leg->SetFillColor(0); leg->Draw("same"); TLatex *cmsLabel = new TLatex(); cmsLabel->SetNDC(); //cmsLabel.DrawLatex(0.1,0.9, "CMS Preliminary, #sqrt{s} = 8 TeV, 19.7 fb^{-1}"); //cmsLabel->DrawLatex(0.8, 0.9, label.c_str()); //qcd1H->Draw("same"); //qcd2H->Draw("same"); //qcd3H->Draw("same"); //qcd4H->Draw("same"); //qcd5H->Draw("same"); //qcd6H->Draw("same"); //dataH->DrawNormalized("E same"); c1->cd(); //c1->SetTopMargin(0.01); //c1->SetBottomMargin(0.3); //c1->SetRightMargin(0.05); //c1->SetLeftMargin(0.1); c1->SetFillStyle(0); TH1F *ratioH = new TH1F(); ratioH->Sumw2(); ratioH = (TH1F *) totalH->Clone("ratioH"); ratioH->Divide(totalPredH); ratioH->GetYaxis()->SetRangeUser(0.,2.); ratioH->GetYaxis()->SetTitle("Data / BG Ratio"); ratioH->GetYaxis()->SetTitleOffset(0.4); ratioH->GetYaxis()->SetTitleSize(0.11); ratioH->GetXaxis()->SetLabelSize(0.11); ratioH->GetXaxis()->SetTitleSize(0.11); ratioH->GetXaxis()->SetTitle( "Dijet Invariant Mass"); //ratioH->Draw("E"); TF1 *line = new TF1("line", "1", 0, 5000); line->SetLineColor(kBlack); //line->Draw("same"); c1->SaveAs(Form("closureTest_%d_%d.pdf", tags, nsub)); }
void PlotFinal(TGraphAsymmErrors* g_data_final, TGraphAsymmErrors* g_mg_final, TGraphAsymmErrors* g_ph_final, TGraphAsymmErrors* g_ratio_phistar, TGraphAsymmErrors* g_ratio_mg_phistar, TGraphAsymmErrors* g_ratio_ph_phistar, bool isPlot2 = 0, TGraphAsymmErrors* g_re_final = 0, TGraphAsymmErrors* g_ratio_re_phistar = 0) { vector<TGraphAsymmErrors*> g_data = SplitGraph(g_data_final); vector<TGraphAsymmErrors*> g_mg = SplitGraph(g_mg_final); vector<TGraphAsymmErrors*> g_ph = SplitGraph(g_ph_final); vector<TGraphAsymmErrors*> r_data = SplitGraph(g_ratio_phistar, 1); vector<TGraphAsymmErrors*> r_mg = SplitGraph(g_ratio_mg_phistar); vector<TGraphAsymmErrors*> r_ph = SplitGraph(g_ratio_ph_phistar); vector<TGraphAsymmErrors*> g_re = SplitGraph(g_re_final); vector<TGraphAsymmErrors*> r_re = SplitGraph(g_ratio_re_phistar); //New Graphs TGraphAsymmErrors* g_ANlo_final = ResbosFromRaj(2); TGraphAsymmErrors* r_ANlo_Ratio_final = CreateRatio(g_data_final, g_ANlo_final, 0); TGraphAsymmErrors* g_PowPyth8_final = ResbosFromRaj(1); TGraphAsymmErrors* r_PowPyth8_Ratio_final = CreateRatio(g_data_final, g_PowPyth8_final, 0); vector<TGraphAsymmErrors*> g_ANlo = SplitGraph(g_ANlo_final); vector<TGraphAsymmErrors*> r_ANlo = SplitGraph(r_ANlo_Ratio_final); vector<TGraphAsymmErrors*> g_Pyth8 = SplitGraph(g_PowPyth8_final); vector<TGraphAsymmErrors*> r_Pyth8 = SplitGraph(r_PowPyth8_Ratio_final); vector<TGraphAsymmErrors*> g_dummy = CreateDummy(g_data); OneDYPlot(g_data, g_mg, g_ph, g_re, g_ANlo, g_Pyth8); for (uint i = 0; i < ny; i++) { // for (uint i=0; i<5; i++){ std::ostringstream strs; strs << i; //TO HERE std::string Canvasname = "EventEff_Bin" + strs.str(); TCanvas* FinalPhiTot = new TCanvas(Canvasname.c_str(), Canvasname.c_str(), 800, 900); FinalPhiTot->Divide(1, 2); FinalPhiTot->cd(1); gPad->SetPad("p1", "p1", 0, 2.5 / 9.0, 1, 1, kWhite, 0, 0); gPad->SetBottomMargin(0.01); gPad->SetTopMargin(0.06); gPad->SetLeftMargin(0.15); gPad->SetRightMargin(0.06); gPad->SetLogx(1); gPad->SetLogy(1); g_dummy[i]->GetXaxis()->SetRangeUser(0.001, 10.0); if (doNorm) g_dummy[i]->GetYaxis()->SetRangeUser(0.00000005, 1000.0); else g_dummy[i]->GetYaxis()->SetRangeUser(0.00005, 1000000.0); g_dummy[i]->GetXaxis()->CenterTitle(); g_dummy[i]->GetYaxis()->CenterTitle(); g_dummy[i]->Draw("A2"); g_mg[i]->SetMarkerColor(kBlue - 7); g_mg[i]->SetLineColor(kBlue - 7); g_mg[i]->SetMarkerSize(1); g_mg[i]->SetLineWidth(2); g_mg[i]->SetMarkerStyle(21); g_mg[i]->Draw("PEsame"); g_ph[i]->SetMarkerColor(kRed); g_ph[i]->SetLineColor(kRed); g_ph[i]->SetMarkerSize(1); g_ph[i]->SetLineWidth(2); g_ph[i]->SetMarkerStyle(22); g_ph[i]->Draw("PEsame"); if (!isPlot2 && elec == 1 && g_re_final) { g_re[i]->SetMarkerColor(kGreen + 1); g_re[i]->SetLineColor(kGreen + 1); g_re[i]->SetMarkerSize(1); g_re[i]->SetLineWidth(2); g_re[i]->SetMarkerStyle(23); g_re[i]->Draw("PEsame"); } g_data[i]->SetFillColor(kYellow); g_data[i]->SetMarkerSize(1); g_data[i]->SetLineWidth(2); g_data[i]->SetMarkerStyle(20); g_data[i]->Draw("PEsame"); g_data[i]->SetFillColor(kYellow); TLegend* leg; if (isPlot2) leg = new TLegend(0.15, 0.06, 0.80, 0.27); else leg = new TLegend(0.15, 0.06, 0.80, 0.31); //TLegend(0.45,0.73,0.94,0.93);//.19 0.06 leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetLineWidth(1); leg->SetNColumns(1); leg->SetTextFont(42); if (!isPlot2) { leg->AddEntry(g_data[i], "2012 data", "PEF"); if (Type == "elec") { leg->AddEntry(g_mg[i], "#gamma*/Z #rightarrow ee (MadGraph+Pythia6 Z2*)", "P"); leg->AddEntry(g_ph[i], "#gamma*/Z #rightarrow ee (Powheg+Pythia6 Z2*)", "P"); //ToDo AMCAt decisions //if (elec == 1 && g_re_final) leg->AddEntry(g_re[i], "#gamma*/Z #rightarrow ee (Resbos)", "P"); if (elec == 1 && g_re_final) leg->AddEntry(g_re[i], "#gamma*/Z #rightarrow ee (POWHEG+Pythia8)", "P"); } if (Type == "muon") { leg->AddEntry(g_mg[i], "#gamma*/Z #rightarrow #mu#mu (MadGraph+Pythia6 Z2*)", "P"); leg->AddEntry(g_ph[i], "#gamma*/Z #rightarrow #mu#mu (Powheg+Pythia6 Z2*)", "P"); if (elec == 1 && g_re_final) leg->AddEntry(g_re[i], "#gamma*/Z #rightarrow #mu#mu (Resbos)", "P"); //if (elec == 1 && g_re_final) leg->AddEntry(g_re[i], "#gamma*/Z #rightarrow #mu#mu (POWHEG+Pythia8 CUETP8M1)", "P"); } if (Type == "combined") { leg->AddEntry(g_mg[i], "#gamma*/Z #rightarrow ll (MadGraph+Pythia6 Z2*)", "P"); leg->AddEntry(g_ph[i], "#gamma*/Z #rightarrow ll (Powheg+Pythia6 Z2*)", "P"); if (elec == 1 && g_re_final) leg->AddEntry(g_re[i], "#gamma*/Z #rightarrow ll (Resbos)", "P"); //if (elec == 1 && g_re_final) leg->AddEntry(g_re[i], "#gamma*/Z #rightarrow ll (POWHEG+Pythia8 CUETP8M1)", "P"); } } else { if (Type == "combined") { leg->AddEntry(g_mg[i], "#gamma*/Z #rightarrow ee (2012 data)", "P"); leg->AddEntry(g_ph[i], "#gamma*/Z #rightarrow #mu#mu (2012 data)", "P"); if (doMG)leg->AddEntry(g_data[i], "#gamma*/Z #rightarrow ll (MadGraph+Pythia6 Z2*)", "PEF"); else leg->AddEntry(g_data[i], "#gamma*/Z #rightarrow ll (Powheg+Pythia6 Z2*)", "PEF"); } if (Type == "elec") { leg->AddEntry(g_mg[i], "data (unfolded with Powheg)", "P"); leg->AddEntry(g_ph[i], "data (unfolded with MadGraph)", "P"); if (doMG)leg->AddEntry(g_data[i], "#gamma*/Z #rightarrow ll (MadGraph+Pythia6 Z2*)", "PEF"); else leg->AddEntry(g_data[i], "#gamma*/Z #rightarrow ll (Powheg+Pythia6 Z2*)", "PEF"); } } leg->Draw(); TLatex mark3; mark3.SetTextSize(0.043); mark3.SetTextFont(42); mark3.SetNDC(true); mark3.DrawLatex(0.71, 0.955, "19.7 fb^{-1} (8 TeV)"); TLatex mark; mark.SetTextSize(0.043); mark.SetTextFont(42); mark.SetNDC(true); if (Type == "elec" && !isPlot2) { mark.DrawLatex(0.53, 0.88, "|#eta^{e_{0}}| < 2.1, |#eta^{e_{1}}| < 2.4"); mark.DrawLatex(0.53, 0.81, "p_{T}^{e_{0}} > 30 GeV, p_{T}^{e_{1}} > 20 GeV"); mark.DrawLatex(0.53, 0.74, "60 GeV < M_{ee} < 120 GeV"); } if (Type == "combined" || isPlot2) { mark.DrawLatex(0.53, 0.88, "|#eta^{l_{0}}| < 2.1, |#eta^{l_{1}}| < 2.4"); mark.DrawLatex(0.53, 0.81, "p_{T}^{l_{0}} > 30 GeV, p_{T}^{l_{1}} > 20 GeV"); mark.DrawLatex(0.53, 0.74, "60 GeV < M_{ll} < 120 GeV"); } if (i == 0) mark.DrawLatex(0.2, 0.88, "0.0 < |y_{ee}| < 0.4"); if (i == 1) mark.DrawLatex(0.2, 0.88, "0.4 < |y_{ee}| < 0.8"); if (i == 2) mark.DrawLatex(0.2, 0.88, "0.8 < |y_{ee}| < 1.2"); if (i == 3) mark.DrawLatex(0.2, 0.88, "1.2 < |y_{ee}| < 1.6"); if (i == 4) mark.DrawLatex(0.2, 0.88, "1.6 < |y_{ee}| < 2.0"); if (i == 5) mark.DrawLatex(0.2, 0.88, "2.0 < |y_{ee}| < 2.4"); FinalPhiTot->cd(2); gPad->SetPad("p2", "p2", 0, 0, 1, 2.5 / 9.0, kWhite, 0, 0); gPad->SetBottomMargin(0.37); gPad->SetTopMargin(0.01); gPad->SetLeftMargin(0.15); gPad->SetRightMargin(0.06); gPad->SetLogx(1); r_data[i]->SetLineWidth(2); r_data[i]->GetXaxis()->SetRangeUser(0.001, 10); r_data[i]->GetXaxis()->SetTitle("#phi*"); r_data[i]->GetXaxis()->SetTitleOffset(1.05); r_data[i]->GetXaxis()->SetTitleSize(0.12); r_data[i]->GetXaxis()->SetLabelSize(0.12); r_data[i]->GetYaxis()->SetTitle("MC/Data "); // r_data[i]->GetYaxis()->SetRangeUser(0.8,1.2); r_data[i]->GetYaxis()->SetTitleOffset(0.32); r_data[i]->GetYaxis()->SetTitleSize(0.12); r_data[i]->GetYaxis()->SetLabelSize(0.12); r_data[i]->SetTitle(0); if (isPlot2) r_data[i]->GetYaxis()->SetTitle("Data/MC "); else r_data[i]->GetYaxis()->SetTitle("MC/Data "); r_data[i]->GetYaxis()->SetRangeUser(0.5, 1.5); r_data[i]->GetYaxis()->SetNdivisions(2, 5, 0); if (isPlot2) r_data[i]->GetYaxis()->SetRangeUser(0.3, 1.35); if (isPlot2 && (!doNorm)) r_data[i]->GetYaxis()->SetRangeUser(0.7, 1.3); r_data[i]->GetYaxis()->SetNdivisions(2, 5, 0); r_data[i]->GetYaxis()->SetTitleOffset(0.45); r_data[i]->SetFillColor(kYellow); r_data[i]->GetXaxis()->SetTitleSize(0.15); r_data[i]->GetXaxis()->CenterTitle(); r_data[i]->GetYaxis()->CenterTitle(); r_data[i]->Draw("APE2"); r_mg[i]->SetMarkerSize(1); r_mg[i]->SetLineWidth(2); r_mg[i]->SetMarkerStyle(21); r_mg[i]->SetMarkerColor(kBlue - 7); r_mg[i]->SetLineColor(kBlue - 7); r_mg[i]->Draw("PEsame"); r_ph[i]->SetMarkerSize(1); r_ph[i]->SetLineWidth(2); r_ph[i]->SetMarkerStyle(22); r_ph[i]->SetMarkerColor(kRed); r_ph[i]->SetLineColor(kRed); r_ph[i]->Draw("PEsame"); r_re[i]->SetMarkerSize(1); r_re[i]->SetLineWidth(2); r_re[i]->SetMarkerStyle(23); r_re[i]->SetMarkerColor(kGreen + 1); r_re[i]->SetLineColor(kGreen + 1); r_re[i]->Draw("PEsame"); std::string plotname = "Plots/ZShape_2D_"; plotname += "Bin" + strs.str() + "_"; plotname += Tag; if (isPlot2 && Type == "combined")plotname += "MuEl"; else if (isPlot2 && Type == "elec")plotname += "PHMG"; else plotname += Type; plotname += "_"; if ((Type == "elec" || isPlot2) && !doMG) plotname += "PH_"; if ((Type == "elec" || isPlot2) && doMG) plotname += "MG_"; if (doNorm) plotname += "Norm_"; else plotname += "Abs_"; if (elec == 0)plotname += "Dressed."; if (elec == 1)plotname += "Born."; if (elec == 2)plotname += "Naked."; //FinalPhiTot->SaveAs((plotname + OutType).c_str()); delete FinalPhiTot; //TO HERE ZACH TCanvas* FinalPhiRatio = new TCanvas("FinalPhiRatio", "FinalPhiRatio", 800, 900); FinalPhiRatio->cd(); FinalPhiRatio->SetLogx(); r_data[i]->GetYaxis()->SetTitle("MC/Data"); r_data[i]->SetFillColor(kYellow); r_data[i]->GetYaxis()->SetRangeUser(0.5, 1.5); r_data[i]->GetYaxis()->SetTitleOffset(1.2); r_data[i]->GetYaxis()->SetTitleSize(0.04); r_data[i]->GetYaxis()->SetLabelSize(0.04); r_data[i]->GetXaxis()->SetTitleSize(0.04); r_data[i]->GetXaxis()->SetLabelSize(0.04); r_data[i]->GetXaxis()->SetLabelOffset(-0.01); r_data[i]->Draw("AE2"); r_mg[i]->SetMarkerStyle(kFullTriangleUp); r_mg[i]->SetMarkerColor(kBlue - 7); r_mg[i]->SetLineColor(kBlue - 7); r_ph[i]->SetMarkerSize(1); r_ph[i]->SetLineWidth(2); r_ph[i]->SetMarkerStyle(kFullSquare); r_ph[i]->SetMarkerColor(kRed); r_ph[i]->SetLineColor(kRed); r_ph[i]->Draw("PEsame"); r_mg[i]->Draw("PEsame"); r_re[i]->SetMarkerColor(kGreen + 1); r_re[i]->SetLineColor(kGreen + 1); r_re[i]->SetMarkerSize(1); r_re[i]->SetLineWidth(2); r_re[i]->SetMarkerStyle(kStar); r_re[i]->Draw("PEsame"); r_ANlo[i]->SetMarkerSize(1); r_ANlo[i]->SetLineWidth(2); r_ANlo[i]->SetMarkerStyle(kOpenCircle); r_ANlo[i]->SetMarkerColor(kCyan + 2); r_ANlo[i]->SetLineColor(kCyan + 2); r_ANlo[i]->Draw("PEsame"); r_Pyth8[i]->SetMarkerSize(1); r_Pyth8[i]->SetLineWidth(2); r_Pyth8[i]->SetMarkerStyle(kOpenSquare); r_Pyth8[i]->SetMarkerColor(kRed); r_Pyth8[i]->SetLineColor(kRed); r_Pyth8[i]->Draw("PEsame"); //r_data[i]->Draw("PEsame"); mark.SetTextSize(0.03); mark.DrawLatex(0.7, 0.907, "19.7 fb^{-1} (8 TeV)"); mark.DrawLatex(0.19, 0.907, "CMS Preliminary"); if (i == 0) mark.DrawLatex(0.15, 0.3, "0.0 < |y_{ll}| < 0.4"); if (i == 1) mark.DrawLatex(0.15, 0.3, "0.4 < |y_{ll}| < 0.8"); if (i == 2) mark.DrawLatex(0.15, 0.3, "0.8 < |y_{ll}| < 1.2"); if (i == 3) mark.DrawLatex(0.15, 0.3, "1.2 < |y_{ll}| < 1.6"); if (i == 4) mark.DrawLatex(0.15, 0.3, "1.6 < |y_{ll}| < 2.0"); if (i == 5) mark.DrawLatex(0.15, 0.35, "2.0 < |y_{ll}| < 2.4"); if (Type == "elec" && !isPlot2) { mark.DrawLatex(0.15, 0.25, "|#eta^{l_{0}}| < 2.1, |#eta^{l_{1}}| < 2.4"); mark.DrawLatex(0.15, 0.20, "p_{T}^{l_{0}} > 30 GeV, p_{T}^{l_{1}} > 20 GeV"); if (i != 5)mark.DrawLatex(0.15, 0.15, "60 GeV < M_{ll} < 120 GeV"); else mark.DrawLatex(0.15, 0.30, "60 GeV < M_{ll} < 120 GeV"); } if (Type == "muon" && !isPlot2) { mark.DrawLatex(0.15, 0.25, "|#eta^{#mu_{0}}| < 2.1, |#eta^{#mu_{1}}| < 2.4"); mark.DrawLatex(0.15, 0.20, "p_{T}^{#mu_{0}} > 30 GeV, p_{T}^{#mu_{1}} > 20 GeV"); mark.DrawLatex(0.15, 0.15, "60 GeV < M_{#mu#mu} < 120 GeV"); } if (Type == "combined" || isPlot2) { mark.DrawLatex(0.15, 0.25, "|#eta^{l_{0}}| < 2.1, |#eta^{l_{1}}| < 2.4"); mark.DrawLatex(0.15, 0.20, "p_{T}^{l_{0}} > 30 GeV, p_{T}^{l_{1}} > 20 GeV"); mark.DrawLatex(0.15, 0.15, "60 GeV < M_{ll} < 120 GeV"); } TLegend* leg2 = new TLegend(0.13, 0.72, 0.7, 0.9); leg2->SetFillStyle(0); leg2->SetBorderSize(0); leg2->SetLineWidth(1); leg2->SetNColumns(1); leg2->SetTextFont(22); leg2->AddEntry(r_data[i], "2012 data", "F"); if (Type == "elec") { leg2->AddEntry(r_mg[i], " MadGraph+Pythia6 (Z2*)", "P"); leg2->AddEntry(r_ph[i], "POWHEG+Pythia6 (Z2*)", "P"); leg2->AddEntry(r_re[i], "Resbos", "P"); leg2->AddEntry(r_ANlo[i], "AMC@nlo+Pythia8(CUETP8M1)", "P"); leg2->AddEntry(r_Pyth8[i], "POWHEG+Pythia8 (CT10)", "P"); } if (Type == "muon") { leg2->AddEntry(r_mg[i], "Z #rightarrow #mu#mu MadGraph", "P"); leg2->AddEntry(r_ph[i], "Z #rightarrow #mu#mu Powheg", "P"); } if (Type == "combined") { leg2->AddEntry(r_mg[i], "Z #rightarrow ll MadGraph", "P"); leg2->AddEntry(r_ph[i], "Z #rightarrow ll Powheg", "P"); } leg2->Draw(); plotname = "ZShape_Ratio"; plotname += Tag; if (isPlot2)plotname += "MuEl"; else plotname += Type; plotname = "Plots/Ratio_ZShape_2D_"; plotname += "Bin" + strs.str() + "_"; plotname += Tag; //if (isPlot2 && Type == "combined")plotname += "MuEl"; //else if (isPlot2 && Type == "elec")plotname += "PHMG"; plotname += Type; plotname += "_"; if ((Type == "elec" || isPlot2) && !doMG) plotname += "PH_"; if ((Type == "elec" || isPlot2) && doMG) plotname += "MG_"; if (doNorm) plotname += "Norm_"; else plotname += "Abs_"; if (elec == 0)plotname += "Dressed."; if (elec == 1)plotname += "Born."; if (elec == 2)plotname += "Naked."; FinalPhiRatio->RedrawAxis(); FinalPhiRatio->SaveAs((plotname + "pdf").c_str()); FinalPhiRatio->SaveAs((plotname + "png").c_str()); FinalPhiRatio->SaveAs((plotname + "C").c_str()); } //TOTAL PLOT FROM HERE TCanvas* FinalPhiRatio = new TCanvas("FinalPhiRatio", "FinalPhiRatio", 800, 900); FinalPhiRatio->SetBottomMargin(0.1); TPad* Info = new TPad("p1", "p1", 0, .03, 1, .9); Info->Draw(); Info->cd(); Info->Divide(1, 6, 0, 0); for (uint i = 0; i < ny; i++) { Info->cd(i + 1); std::ostringstream strs; strs << i; std::string gPadName = "p" + strs.str(); //gPad->SetPad(gPadName.c_str(), gPadName.c_str(), 0, i / 6, 1, (1 + i) / 6, kWhite, 0, 0); //gPad->SetLeftMargin(0.15); //gPad->SetRightMargin(0.06); if (i == 5)gPad->SetBottomMargin(0.2); gPad->SetLogx(1); if (i == 0)r_data[i]->SetTitle(""); else r_data[i]->SetTitle(""); if (i == 0)r_data[i]->GetYaxis()->SetTitle(""); else if (i == 1)r_data[i]->GetYaxis()->SetTitle(""); else if (i == 2)r_data[i]->GetYaxis()->SetTitle("MC/Data"); else if (i == 3)r_data[i]->GetYaxis()->SetTitle(""); else if (i == 4)r_data[i]->GetYaxis()->SetTitle(""); else if (i == 5)r_data[i]->GetYaxis()->SetTitle(""); r_data[i]->GetYaxis()->CenterTitle(); r_data[i]->SetFillColor(kYellow); r_data[i]->GetYaxis()->SetNdivisions(503); r_data[i]->GetYaxis()->SetRangeUser(0.865, 1.135); if (i == 4)r_data[i]->GetYaxis()->SetRangeUser(0.77, 1.23); if (i == 5)r_data[i]->GetYaxis()->SetRangeUser(0.4, 1.6); r_data[i]->GetYaxis()->SetTitleOffset(0.2); //OFFSET r_data[i]->GetYaxis()->SetTitleSize(0.2); //Y TITLE SIZE r_data[i]->GetYaxis()->SetLabelSize(0.15); r_data[i]->GetXaxis()->SetTitleSize(0); r_data[i]->GetXaxis()->SetLabelSize(0); r_data[i]->GetXaxis()->SetTitle(""); r_data[i]->GetXaxis()->CenterTitle(); if (i == ny - 1) { r_data[i]->GetXaxis()->SetTitleOffset(0.42); //OFFSET r_data[i]->GetXaxis()->SetTitleSize(0.2); //X TITLE SIZE r_data[i]->GetXaxis()->SetLabelSize(0.15); r_data[i]->GetXaxis()->SetLabelOffset(-0.01); r_data[i]->GetXaxis()->SetTitle("#phi*"); r_data[i]->GetXaxis()->CenterTitle(); } r_data[i]->GetXaxis()->SetRangeUser(.015, 1.95); r_data[i]->Draw("AE2"); r_mg[i]->SetMarkerStyle(kFullTriangleUp); r_mg[i]->SetMarkerColor(kBlue - 7); r_mg[i]->SetLineColor(kBlue - 7); r_ph[i]->SetMarkerSize(1); r_ph[i]->SetLineWidth(2); r_ph[i]->SetMarkerStyle(kFullSquare); r_ph[i]->SetMarkerColor(kRed); r_ph[i]->SetLineColor(kRed); r_ph[i]->Draw("PEsame"); r_mg[i]->Draw("PEsame"); r_re[i]->SetMarkerColor(kGreen + 1); r_re[i]->SetLineColor(kGreen + 1); r_re[i]->SetMarkerSize(1); r_re[i]->SetLineWidth(2); r_re[i]->SetMarkerStyle(kStar); r_re[i]->Draw("PEsame"); r_ANlo[i]->SetMarkerSize(1); r_ANlo[i]->SetLineWidth(2); r_ANlo[i]->SetMarkerStyle(kOpenCircle); r_ANlo[i]->SetMarkerColor(kCyan + 2); r_ANlo[i]->SetLineColor(kCyan + 2); r_ANlo[i]->Draw("PEsame"); r_Pyth8[i]->SetMarkerSize(1); r_Pyth8[i]->SetLineWidth(2); r_Pyth8[i]->SetMarkerStyle(kOpenSquare); r_Pyth8[i]->SetMarkerColor(kRed); r_Pyth8[i]->SetLineColor(kRed); r_Pyth8[i]->Draw("PEsame"); } //r_data_WO->Draw("PEsame"); FinalPhiRatio->cd(0); TLatex mark; mark.SetTextSize(0.02); mark.SetNDC(kTRUE); mark.DrawLatex(.75, .95, "19.7 fb^{-1} (8 TeV)"); mark.DrawLatex(0.1, .95, "CMS Preliminary"); TLatex mark2; mark2.SetTextSize(0.02); mark2.SetNDC(kTRUE); mark2.DrawLatex(.12, .84, "0.0 < |y_{ll}| < 0.4"); mark2.DrawLatex(.12, .7, "0.4 < |y_{ll}| < 0.8"); mark2.DrawLatex(.12, .55, "0.8 < |y_{ll}| < 1.2"); mark2.DrawLatex(.12, .42, "1.2 < |y_{ll}| < 1.6"); mark2.DrawLatex(.12, .28, "1.6 < |y_{ll}| < 2.0"); mark2.DrawLatex(.12, .15, "2.0 < |y_{ll}| < 2.4"); //mark.DrawLatex(-0.15, 0.25, "|#eta^{l_{0}}| < 2.1, |#eta^{l_{1}}| < 2.4"); //mark.DrawLatex(0.15, 0.20, "p_{T}^{l_{0}} > 30 GeV, p_{T}^{l_{1}} > 20 GeV"); //if (i != 5)mark.DrawLatex(0.15, 0.15, "60 GeV < M_{ll} < 120 GeV"); //else mark.DrawLatex(0.15, 0.30, "60 GeV < M_{ll} < 120 GeV"); FinalPhiRatio->cd(1); TLegend* leg2 = new TLegend(0.09, 0.888, 0.9, 0.94); leg2->SetNColumns(3); leg2->SetFillStyle(0); //leg2->SetBorderSize(1); leg2->SetLineWidth(1); leg2->SetTextFont(22); leg2->AddEntry(r_data[1], "2012 data", "F"); leg2->AddEntry(r_mg[1], " MadGraph+Pythia6 (Z2*)", "P"); leg2->AddEntry(r_ph[1], "POWHEG+Pythia6 (Z2*)", "P"); leg2->AddEntry(r_re[1], "Resbos", "P"); leg2->AddEntry(r_ANlo[1], "AMC@nlo+Pythia8(CUETP8M1)", "P"); leg2->AddEntry(r_Pyth8[1], "POWHEG+Pythia8 (CT10)", "P"); leg2->Draw(); std::string plotname = "Plots/Ratio_ZShape_2D_ALL"; plotname += Tag; //if (isPlot2 && Type == "combined")plotname += "MuEl"; //else if (isPlot2 && Type == "elec")plotname += "PHMG"; plotname += Type; plotname += "_"; if ((Type == "elec" || isPlot2) && !doMG) plotname += "PH_"; if (doNorm) plotname += "Norm_"; else plotname += "Abs_"; if (elec == 0)plotname += "Dressed."; if (elec == 1)plotname += "Born."; if (elec == 2)plotname += "Naked."; FinalPhiRatio->RedrawAxis(); FinalPhiRatio->SaveAs((plotname + "pdf").c_str()); FinalPhiRatio->SaveAs((plotname + "png").c_str()); FinalPhiRatio->SaveAs((plotname + "C").c_str()); //TO HEREs }
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 met_norm(double pt1min, double pt2min, double METmin){ TLegend* leg = new TLegend(0.4,0.45,0.87,0.87); leg->SetNColumns(2); 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,500); 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))"; TCut DPHICut = "FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>2.1"; TCut maxDPHIJetcut = "MAX(ptJetLead,phiJetLead,ptJetSubLead,phiJetSubLead,ptJet3,phiJet3,ptJet4,phiJet4,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))<2.7"; TCut minDPHIJetcut = "myMIN(ptJetLead,phiJetLead,ptJetSubLead,phiJetSubLead,ptJet3,phiJet3,ptJet4,phiJet4,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>0.5"; TCut DPHICutD = "FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1))>2.1"; TCut maxDPHIJetcutD = "MAX(ptJetLead,phiJetLead,ptJetSubLead,phiJetSubLead,ptJet3,phiJet3,ptJet4,phiJet4,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1))<2.7"; TCut minDPHIJetcutD = "myMIN(ptJetLead,phiJetLead,ptJetSubLead,phiJetSubLead,ptJet3,phiJet3,ptJet4,phiJet4,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1))>0.5"; tree_data->Draw("(t1pfmet)>>hdata(20,0,1000)",(mggmax && mggmin && metF&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICutD && minDPHIJetcutD && maxDPHIJetcutD)); TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata"); tree_sig1->Draw("(t1pfmet)>>h1(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("(t1pfmet)>>h2(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("(t1pfmet)>>h3(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("(t1pfmet)>>h4(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("(t1pfmet)>>h5(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); tree_sig6->Draw("(t1pfmet)>>h6(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6"); tree_sig7->Draw("(t1pfmet)>>h7(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7"); tree_bkg1->Draw("(t1pfmet)>>hbkg1(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("(t1pfmet)>>hbkg2(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("(t1pfmet)>>hbkg3(20,0,1000)","weight"*(mggmin && mggmax && genmatch&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("(t1pfmet)>>hbkg4(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); //weight also on BR = 0.002 if using the 50ns samples TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4"); tree_bkg5->Draw("(t1pfmet)>>hbkg5(20,0,1000)","weight"*(mggmin && mggmax && genmatch&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("(t1pfmet)>>hbkg6(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6"); tree_bkg7->Draw("(t1pfmet)>>hbkg7(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7"); tree_bkg8->Draw("(t1pfmet)>>hbkg8(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8"); tree_bkg9->Draw("(t1pfmet)>>hbkg9(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9"); tree_bkg10->Draw("(t1pfmet)>>hbkg10(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10"); tree_bkg11->Draw("(t1pfmet)>>hbkg11(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11"); tree_bkg12->Draw("(t1pfmet)>>hbkg12(20,0,1000)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto && DPHICut && minDPHIJetcut && maxDPHIJetcut)); TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12"); for(int i = 0; i<21;i++){ if(hbkg1->GetBinContent(i) < 0) hbkg1->SetBinContent(i,0); if(hbkg2->GetBinContent(i) < 0) hbkg2->SetBinContent(i,0); if(hbkg3->GetBinContent(i) < 0) hbkg3->SetBinContent(i,0); if(hbkg4->GetBinContent(i) < 0) hbkg4->SetBinContent(i,0); if(hbkg5->GetBinContent(i) < 0) hbkg5->SetBinContent(i,0); if(hbkg6->GetBinContent(i) < 0) hbkg6->SetBinContent(i,0); if(hbkg7->GetBinContent(i) < 0) hbkg7->SetBinContent(i,0); if(hbkg8->GetBinContent(i) < 0) hbkg8->SetBinContent(i,0); if(hbkg9->GetBinContent(i) < 0) hbkg9->SetBinContent(i,0); if(hbkg10->GetBinContent(i) < 0) hbkg10->SetBinContent(i,0); if(hbkg11->GetBinContent(i) < 0) hbkg11->SetBinContent(i,0); if(hbkg12->GetBinContent(i) < 0) hbkg12->SetBinContent(i,0); } 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); hbkg7->SetLineColor(kGreen+2); hbkg6->SetLineColor(kGreen); hbkg8->SetLineColor(kYellow); hbkg4->SetLineColor(kOrange); hbkg9->SetLineColor(kOrange+7); hbkg10->SetLineColor(kOrange+4); hbkg11->SetLineColor(kCyan); hbkg12->SetLineColor(kCyan+1); hbkg5->SetLineColor(kBlue+2); hbkg2->SetLineColor(kBlue); hbkg3->SetLineColor(kMagenta-2); hbkg1->SetLineColor(kViolet); double norm = 0.; norm = 1./hbkg1->Integral(); hbkg1->Scale(norm); norm = 1./hbkg2->Integral(); hbkg2->Scale(norm); norm = 1./hbkg3->Integral(); hbkg3->Scale(norm); norm = 1./hbkg4->Integral(); hbkg4->Scale(norm); norm = 1./hbkg5->Integral(); hbkg5->Scale(norm); norm = 1./hbkg6->Integral(); hbkg6->Scale(norm); norm = 1./hbkg7->Integral(); hbkg7->Scale(norm); norm = 1./hbkg8->Integral(); hbkg8->Scale(norm); norm = 1./hbkg9->Integral(); hbkg9->Scale(norm); norm = 1./hbkg10->Integral(); hbkg10->Scale(norm); norm = 1./hbkg11->Integral(); hbkg11->Scale(norm); norm = 1./hbkg12->Integral(); hbkg12->Scale(norm); norm = 1./h1->Integral(); h1->Scale(norm); norm = 1./h2->Integral(); h2->Scale(norm); norm = 1./h3->Integral(); h3->Scale(norm); norm = 1./h4->Integral(); h4->Scale(norm); norm = 1./h5->Integral(); h5->Scale(norm); norm = 1./h6->Integral(); h6->Scale(norm); norm = 1./h7->Integral(); h7->Scale(norm); hbkg1->Draw("hist"); hbkg2->Draw("hist same"); hbkg3->Draw("hist same"); hbkg4->Draw("hist same"); hbkg5->Draw("hist same"); hbkg6->Draw("hist same"); hbkg7->Draw("hist same"); hbkg8->Draw("hist same"); hbkg9->Draw("hist same"); hbkg10->Draw("hist same"); hbkg11->Draw("hist same"); hbkg12->Draw("hist same"); 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"); hbkg1->SetTitle(""); hbkg1->GetXaxis()->SetTitle("E_{T}^{miss} [GeV]"); hbkg1->SetMaximum(1); hbkg1->GetYaxis()->SetTitle("Normalized events"); hbkg1->GetYaxis()->SetTitleOffset(1.4); gPad->Modified(); gStyle->SetOptStat(0); leg->AddEntry(h1,"m_{Z'} = 600 GeV","l"); leg->AddEntry(hbkg1,"#gamma #gamma","l"); leg->AddEntry(h2,"m_{Z'} = 800 GeV","l"); leg->AddEntry(hbkg2,"Drell Yann","l"); leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); leg->AddEntry(hbkg3,"#gamma + Jets","l"); leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); leg->AddEntry(hbkg5,"QCD","l"); leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); leg->AddEntry(hbkg4,"ggH","l"); leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); leg->AddEntry(hbkg6,"VH","l"); leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); leg->AddEntry(hbkg7,"ttH","l"); leg->AddEntry(hbkg8,"VBF H","l"); leg->AddEntry(hbkg9,"t + #gamma + Jets","l"); leg->AddEntry(hbkg10,"tt + #gamma +Jets","l"); leg->AddEntry(hbkg11,"#gamma+W","l"); leg->AddEntry(hbkg12,"#gamma+Z","l"); leg->Draw("same"); if(pt1min==0 && pt2min == 0 && METmin == 0){ c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/met_norm.png"); c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/met_norm.pdf"); } }
void roo_fitWH() { TString poscharge = "Plus"; TString negcharge = "Minus"; std::vector<TString> charge(2); charge.at(0) = poscharge; charge.at(1) = negcharge; TString canvas_name_plus = "muon_MC_WHelicityFramePlots_PlusICVar"; TCanvas *c0 = new TCanvas(canvas_name_plus,"",450,400); TString canvas_name_minus = "muon_MC_WHelicityFramePlots_MinusICVar"; TCanvas *c1 = new TCanvas(canvas_name_minus,"",450,400); // Run both for + and - charges for(unsigned int j=0; j<charge.size(); j++) { // if (j==1) break; // do only + charge fit if (realData) { sfactor=36; } // Nominal values are taken from a fit to the MC W data (scaled to 100pb-1) RooRealVar *fLnom, *fRnom, *f0nom; if (j==0) { fLnom=new RooRealVar("fL_nom","fLnom",0.556); fRnom=new RooRealVar("fR_nom","fRnom",0.234); f0nom=new RooRealVar("f0_nom","f0nom",0.210); } else { fLnom=new RooRealVar("fL_nom","fLnom",0.523); fRnom=new RooRealVar("fR_nom","fRnom",0.265); f0nom=new RooRealVar("f0_nom","f0nom",0.212); } TString Hist1 = "RECO_PolPlots_50toinf/RECO_ICVarPF"+ charge.at(j) + "_LH"; TString Hist2 = "RECO_PolPlots_50toinf/RECO_ICVarPF"+ charge.at(j) + "_RH"; TString Hist3 = "RECO_PolPlots_50toinf/RECO_ICVarPF"+ charge.at(j) + "_LO"; TString Hist_data1 = "RECO_PolPlots_50toinf/RECO_ICVarPF"+ charge.at(j); TH1D *mc1 = (TH1D*)sigfile->Get(Hist1); TH1D *mc2 = (TH1D*)sigfile->Get(Hist2); TH1D *mc3 = (TH1D*)sigfile->Get(Hist3); TH1D *sighist = (TH1D*)sigfile->Get(Hist_data1); // W signal histogram TH1D *bkghist=(TH1D*)bkgfile->Get(Hist_data1); // Bkg histogram TH1D *hdata=(TH1D*)datafile->Get(Hist_data1); // Real data histogram // //we are only fitting for fL and fR // double accFactor1 = refTempHist1->Integral() / mc1->Integral(); // double accFactor2 = refTempHist2->Integral() / mc2->Integral(); // double accFactor3 = refTempHist3->Integral() / mc3->Integral(); // double normFactor = (mc1->Integral() + mc2->Integral() + mc3->Integral()) / (refTempHist1->Integral() + refTempHist2->Integral() + refTempHist3->Integral()); mc1->Rebin(rbin); mc2->Rebin(rbin); mc3->Rebin(rbin); sighist->Rebin(rbin); bkghist->Rebin(rbin); hdata->Rebin(rbin); // Scale to sfactor/pb if MC //if (!realData) { if (toyMC) sfactor=400; sighist->Scale(sfactor); bkghist->Scale(sfactor); // } //datahist->Scale(invWeightW);//to get MC errors - otherwise comment out Double_t nbkg=0; TH1D *datahist; if (realData) { datahist=hdata; } else { datahist=(TH1D*)sighist->Clone(); if (addbkg) {datahist->Add(bkghist); } } if (addbkg) { //nbkg=bkghist->Integral(); nbkg=bkghist->Integral(bkghist->FindBin(xmin+quanta),bkghist->FindBin(xmax-quanta)); } //Double_t istat=datahist->Integral(); //Double_t f_sig=(sighist->Integral())/istat; // signal fraction Double_t istat=datahist->Integral(datahist->FindBin(xmin+quanta),datahist->FindBin(xmax-quanta)); Double_t f_sig=(sighist->Integral(sighist->FindBin(xmin+quanta),sighist->FindBin(xmax-quanta)))/istat; Double_t f_bkg=nbkg/istat; // bkg fraction // Start RooFit session RooRealVar x("x","LP",xmin,xmax); // Import binned Data RooDataHist data1("data1","dataset with WHICVarPlus",x,mc1); RooDataHist data2("data2","dataset with WHICVarPlus",x,mc2); RooDataHist data3("data3","dataset with WHICVarPlus",x,mc3); RooDataHist test("data","dataset with WHICVarPlus",x,datahist); RooDataHist data_bkg("data4","dataset with ICVar",x,bkghist); // Relative fractions - allow them to float to negative values too if needs be // if (fitMode==0) { RooRealVar f1("fL","fL fraction",fLnom->getVal(),0.,1.); RooRealVar f2("fR","fR fraction", fRnom->getVal(),0.,1.); RooFormulaVar f3("f0","1-fL-fR",RooArgList(f1,f2)); if (fitMode) { f1.setVal((fLnom->getVal()-fRnom->getVal())); f1.setRange(-1.,1.); f1.setPlotLabel("f_{L}-f_{R}"); f2.setVal(f0nom->getVal()); f2.setPlotLabel("f_{0}"); } // } else { // RooRealVar f1("fL","fL fraction",(fLnom->getVal()-fRnom->getVal()),-1.,1.); // RooRealVar f2("fR","fR fraction", (fLnom->getVal()+fRnom->getVal()),-1.,1.); // RooFormulaVar f3("f0","1-fL-fR",RooArgList(f1,f2)); // } RooRealVar fsub("fsub","fsub par",(fLnom->getVal()-fRnom->getVal()),-1.,1.); RooRealVar fsum("fsum","fsum par",(fLnom->getVal()+fRnom->getVal()), -1.,1.); // Background template RooHistPdf *bkg = new RooHistPdf("bkg","bkg",x,data_bkg); // Bkg fraction RooRealVar fbkg("f_{bkg}","f_bkg fraction",f_bkg); // Templates RooHistPdf h1("h1","h1",x,data1); // left-handed template histogram RooHistPdf h2("h2","h2",x,data2); // right-handed template histo RooHistPdf h3("h3","h3",x,data3); // longitudinal template histo // Construct model PDF RooAbsPdf *sig, *model; if (charge.at(j) == "Plus") { // plus charge PDFs if (addParameter) { sig = new RooWPlusExtended("sigmodel","model",x,f1,f2,fsub); } else { sig = new RooWPlus("sigmodel","model",x,f1,f2); } } else if (charge.at(j) == "Minus") { // minus charge PDFs if (addParameter) { sig = new RooWMinusExtended("sigmodel","model",x,f1,f2,fsub); } else { sig = new RooWMinus("sigmodel","model",x,f1,f2); } } if (addbkg) { model = new RooAddPdf("model","model",RooArgList(*bkg,*sig),fbkg); } else { model = sig; } // Set the Fit Range x.setRange("fitrange",-0.0,1.3); // Construct likelihood ( + penalty term) RooNLLVar nll("nll","nll",*model,test,Range("fitrange")); RooRealVar pen("pen","penalty term",(0.5*1./(0.01*0.01))); RooFormulaVar nllPen("nllPen","nll+pen*fsub^2",RooArgList(nll,pen,fsub)); // Fitting RooMinuit *m; if (!addParameter) { m = new RooMinuit(nll); } else { m = new RooMinuit(nllPen);} if (!toyMC) { m->migrad(); m->hesse(); } RooFitResult *res1 = m->save(); // Re-diced data // Int_t nevt=static_cast<int>(istat); // RooDataSet *gtest = model->generate(x,nevt); // Fitting // RooFitResult * res1 = model.fitTo(test,Minos(kFALSE), Save()); // res1->Print(); if(makePlots) { // Temp PDF for plotting purposes // RooAddPdf temp("temp","component 1",RooArgList(*h1,*h2,*h3),RooArgList(*f1,*f2)) ; // Plotting gROOT->SetStyle("Plain"); gStyle->SetOptFit(0); gStyle->SetOptTitle(0); gStyle->SetOptStat(0); //gStyle->SetCanvasDefH(600); //Height of canvas //gStyle->SetCanvasDefW(600); //Width of canvas if(charge.at(j) == "Plus") { c0->cd(); //c0->Divide(2,1);c0->cd(1); } if(charge.at(j) == "Minus") { c1->cd(); //c1->Divide(2,1);c1->cd(1); } //RooPlot* frame = new RooPlot(0.0,1.3,0,800); RooPlot* frame = x.frame(); test.plotOn(frame,Name("data")); model->plotOn(frame,Name("model")); // model->paramOn(frame);//, Format("NELU", AutoPrecision(2)), Layout(0.1,0.5,0.9)); // h1.plotOn(frame); // h2.plotOn(frame); // h3.plotOn(frame); // model->plotOn(frame, Components(h1),LineColor(kRed),LineStyle(kDashed)); // temp->plotOn(frame, Components(h2),LineColor(kGreen),LineStyle(kDashed)); // temp->plotOn(frame, Components(h3),LineColor(kYellow),LineStyle(kDashed)); if (addbkg) { // model->plotOn(frame, Components(h1),FillColor(5),DrawOption("F")); //model->plotOn(frame,Components(*bkg),FillColor(5),DrawOption("")); } hdata->GetYaxis()->SetTitle("Events / 0.1"); if(charge.at(j) == "Plus") { hdata->GetXaxis()->SetTitle("#it{L_{P}}(#mu^{+})");} if(charge.at(j) == "Minus") {hdata->GetXaxis()->SetTitle("#it{L_{P}}(#mu^{-})");} hdata->GetXaxis()->SetTitleSize(0.06); hdata->GetXaxis()->SetTitleOffset(1.); hdata->GetYaxis()->SetTitleSize(0.06); hdata->GetYaxis()->SetTitleOffset(1.2); hdata->GetXaxis()->SetLabelSize(0.055); hdata->GetYaxis()->SetLabelSize(0.055); hdata->GetXaxis()->SetRangeUser(0.0,1.29); hdata->GetYaxis()->SetRangeUser(0.0,600); hdata->SetMarkerStyle(20); // mc1->Draw("same"); // Goodness-of-fit Double_t chi2= frame->chiSquare("model","data",3); Double_t nllmin=res1->minNll(); cout << "" << endl; cout << "Printing out the goodness-of-fit measure:" << endl; cout << "chi2 = " << chi2 << "\t" << "min NLL = " << nllmin << endl; res1->Print(); // TCanvas* testt = new TCanvas ("testt","hj"); cout <<"intetral: "<< hdata->Integral()<<endl; hdata->GetXaxis()->SetRangeUser(0.0,1.29); cout << hdata->Integral()<<endl; hdata->Draw(""); // frame->Draw("same"); mc1->GetXaxis()->SetRangeUser(0.0,1.29); float f_l_a = mc1->Integral(); mc2->GetXaxis()->SetRangeUser(0.0,1.29); float f_r_a = mc2->Integral(); mc3->GetXaxis()->SetRangeUser(0.0,1.29); float f_0_a = mc3->Integral(); float allData = hdata->Integral(); float EWKBkg = allData*(f_bkg); float WData = allData*(1-f_bkg); float f_l = 0.5*(1-f2.getVal()+f1.getVal()); float f_r = 0.5*(1-f2.getVal()-f1.getVal()); float f_0 = f2.getVal(); cout << "f_l: "<< f_l<< ",f_r: "<< f_r<< ", f_0: "<< f_0<< " 1= "<< f_l+f_r+f_0<< endl; float allW = f_l*f_l_a+f_r*f_r_a+f_0*f_0_a; //hdata->Draw(""); // bkghist->GetXaxis()->SetRangeUser(0.0,1.3); bkghist->Scale(EWKBkg/bkghist->Integral()); bkghist->Draw("samehist"); bkghist->SetLineColor(kYellow); bkghist->SetFillColor(kYellow); mc1->Scale(f_l*WData/allW); mc2->Scale(f_r*WData/allW); mc3->Scale(f_0*WData/allW); mc1->SetLineColor(kRed); mc2->SetLineColor(kGreen); mc3->SetLineColor(kBlue); mc1->SetLineWidth(3); mc2->SetLineWidth(3); mc3->SetLineWidth(3); mc1->SetLineStyle(2); mc2->SetLineStyle(3); mc3->SetLineStyle(4); mc1->Draw("samehist"); mc2->Draw("samehist"); mc3->Draw("samehist"); TH1D* allHists = (TH1D*)mc1->Clone(); allHists->Add(mc2,1); allHists->Add(mc3,1); allHists->Add(bkghist,1); allHists->SetLineWidth(3); // frame->SetOptFit(0); frame->Draw("same"); // allHists->Draw("same"); TLegend* aleg; //if(charge.at(j) == "Minus") aleg = new TLegend(0.2,0.69,0.6,0.9,""); // if(charge.at(j) == "Plus") //aleg = new TLegend(0.5,0.6,0.7,0.9,"");//new TLegend(0.8,0.69,0.95,0.9,""); aleg = new TLegend(0.2017937,0.7419355,0.4775785,0.9193548,NULL,"brNDC"); aleg->SetNColumns(2); aleg->SetFillColor(0); aleg->SetLineColor(0); aleg->AddEntry(mc1,"f_{L}","lf"); aleg->AddEntry(mc2,"f_{R}","lf"); aleg->AddEntry(mc3,"f_{0}","lf"); aleg->AddEntry(bkghist,"EWK","lf"); TH1* dummyhist = new TH1F("", "", 1, 0, 1); dummyhist->SetLineColor(kBlue); dummyhist->SetLineWidth(3); aleg->AddEntry(dummyhist, "fit result", "lf"); aleg->AddEntry(hdata, "data","P"); aleg->Draw("same"); //TLatex* preliminary; //TLatex* text; //if(false) { //text = new TLatex(0.35,480,"#splitline{f_{L}-f_{R}=0.240#pm0.036(stat.)#pm0.031(syst.)}{f_{0}=0.183#pm0.087(stat.)#pm0.123(syst.)}"); //preliminary = new TLatex(0.35,550,"CMS preliminary: #it{L} = 36pb^{-1}@ 7 TeV"); //} //if(true){ //text = new TLatex(0.05,480,"#splitline{f_{L}-f_{R}=0.310#pm0.036(stat.)#pm0.017(syst.)}{f_{0}=0.171#pm0.085(stat.)#pm0.099(syst.)}"); //preliminary = new TLatex(0.05,550,"#splitline{CMS, #sqrt{s} = 7 TeV,}{#it{L_{int}} = 36 pb^{-1}}");} //preliminary->SetTextSize(0.043); //preliminary->Draw("same"); //text->SetTextSize(0.043); // text->Draw("same"); /* // Draw Minuit contours if(charge.at(j) == "Plus") { c0->cd(2); } else { c1->cd(2); } // RooPlot *rcont=m->contour(f1,f2,1,2); // rcont->Draw(); RooPlot *rcontour=new RooPlot(f1,f2); res1->plotOn(rcontour,f1,f2,"ME123VHB"); rcontour->Draw(); if (fitMode) { rcontour->GetXaxis()->SetTitle("f_{L}-f_{R}"); rcontour->GetYaxis()->SetTitle("f_{0}"); } else { rcontour->GetXaxis()->SetTitle("f_{L}"); rcontour->GetYaxis()->SetTitle("f_{R}"); } */ } TLatex * text = new TLatex(0.7451931,500.8655,"#splitline{CMS, #sqrt{s} = 7 TeV}{L_{ int} = 36 pb^{-1}}"); text->SetTextSize(0.043); text->SetLineWidth(2); text->Draw("same"); const TMatrixDSym& cor = res1->correlationMatrix(); const TMatrixDSym& cov = res1->covarianceMatrix(); //Print correlation, covariance matrix cout << "correlation matrix" << endl; cor.Print(); cout << "covariance matrix" << endl; cov.Print(); cout << f1 << endl; cout << f2 << endl; if (!fitMode) { cout << "f0 = " << f3 << " +/- " << f3.getPropagatedError(*res1) << endl; } } if(makePlots) { c0->Print(canvas_name_plus+".pdf"); c1->Print(canvas_name_minus+".pdf"); } if (toyMC) { // MC STudies Int_t nevt=istat; Int_t nEXP=100; RooMCStudy mgr(*model,*model,x,"","mhrv"); mgr.generateAndFit(nEXP,nevt,kTRUE); TCanvas *cp0 = new TCanvas("c0","",1200,400); cp0->Divide(3,1); cp0->cd(1); RooPlot *p1=mgr.plotParam(f1); p1->Draw(); if (fitMode) p1->SetTitle(";f_{L}-f_{R};number of toys"); cp0->cd(2); RooPlot *p2 = mgr.plotError(f1); p2->Draw(); if (fitMode) p2->SetTitle(";#delta (f_{L}-f_{R});number of toys"); cp0->cd(3); // f1 pull RooPlot* m1pframe = mgr.plotPull(f1,-3.,3.,30,kTRUE); m1pframe->Draw(); if (fitMode) { m1pframe->SetTitle(";f_{L}-f_{R};number of toys"); } TCanvas *cp02 = new TCanvas("c1","",1200,400); cp02->Divide(3,1); cp02->cd(1); RooPlot *p3=mgr.plotParam(f2); p3->Draw(); if (fitMode) p3->SetTitle(";f_{0};number of toys"); cp02->cd(2); RooPlot *p4=mgr.plotError(f2); p4->Draw(); if (fitMode) p4->SetTitle(";#delta f_{0}; number of toys"); cp02->cd(3); // f2 pull RooPlot* m2pframe = mgr.plotPull(f2,-3.,3.,30,kTRUE); m2pframe->Draw(); if (fitMode) { m2pframe->SetTitle(";f_{0};number of toys"); } TCanvas *cnll = new TCanvas("cnll",""); RooPlot* nllframe = mgr.plotNLL(); // nllframe->Draw(); } return; }
void plotter::draw_delta_comparison( TH1* total_, TH1* stat_, std::vector<TH1*> MODEL_DELTA, std::vector<TString> UncertNames, TString category, TString file_name){ TH1* total = (TH1*) total_->Clone(); TH1* stat = (TH1*) stat_->Clone(); std::vector<TH1*> delta; for(unsigned int i=0; i<MODEL_DELTA.size(); i++){ delta.push_back( (TH1*) MODEL_DELTA[i]->Clone() ); } TCanvas *c= new TCanvas("c","",600,600); gPad->SetLeftMargin(0.15); total->SetTitle(""); total->GetXaxis()->SetTitle("Leading-jet mass [GeV]"); total->GetYaxis()->SetTitle("relative uncertainty [%]"); total->GetYaxis()->SetTitleOffset(1.5); total->GetYaxis()->SetNdivisions(505); total->GetYaxis()->SetRangeUser(0, 100); total->SetFillColor(13); total->SetFillStyle(3144); total->SetLineColor(13); total->SetMarkerStyle(-1); total->Draw("HIST"); stat->SetLineColor(kBlack); stat->SetLineWidth(4); stat->SetMarkerStyle(0); stat->Draw("B SAME"); Color_t col[] = {kRed-4, kAzure+7, kGreen, 798, kBlue, kOrange-3, kMagenta, kYellow, kAzure, 14, kRed+5, kGreen-8}; int i=0; for(auto hist: delta){ gPad->SetLeftMargin(0.15); hist->SetLineColor(col[i]); hist->SetLineWidth(4); hist->SetMarkerStyle(0); hist->Draw("B SAME"); i++; } // LEGEND TLegend *leg = new TLegend(0.4,0.6,0.88,0.88); leg->SetFillStyle(0); leg->SetNColumns(2); if(category == "exp") leg->AddEntry(total, "stat #oplus exp. sys", "f"); else if(category == "model") leg->AddEntry(total, "stat #oplus model sys", "f"); leg->AddEntry(stat, "stat", "l"); for(unsigned int i=0; i<delta.size(); i++){ if (UncertNames[i] == "mass") leg->AddEntry(delta[i],"choice of m_{t}","l"); else if (UncertNames[i] == "stat") leg->AddEntry(delta[i],"statistics","l"); else if (UncertNames[i] == "b-tagging") leg->AddEntry(delta[i],"b tagging","l"); else if (UncertNames[i] == "pile-up") leg->AddEntry(delta[i],"pileup","l"); else if (UncertNames[i] == "jec") leg->AddEntry(delta[i],"jet energy scale","l"); else if (UncertNames[i] == "jer") leg->AddEntry(delta[i],"jet energy resolution","l"); else if (UncertNames[i] == "cor") leg->AddEntry(delta[i],"XCone jet correction","l"); else if (UncertNames[i] == "MuTrigger") leg->AddEntry(delta[i],"muon trigger","l"); else if (UncertNames[i] == "MuID") leg->AddEntry(delta[i],"muon ID","l"); else if (UncertNames[i] == "ElTrigger") leg->AddEntry(delta[i],"electron trigger","l"); else if (UncertNames[i] == "ElID") leg->AddEntry(delta[i],"electron ID","l"); else if (UncertNames[i] == "ElReco") leg->AddEntry(delta[i],"electron reconstruction","l"); else if (UncertNames[i] == "hdamp") leg->AddEntry(delta[i],"h_{damp}","l"); else leg->AddEntry(delta[i],UncertNames[i],"l"); } leg->Draw(); gPad->RedrawAxis(); c->SaveAs(directory + file_name + ".pdf"); delete c; }
void checkRsnPIDqa(TString filename, TString foldername, Bool_t savePng, TString plotTPCpi, TString plotTPCka, TString plotTPCpro, TString plotTTOFpi, TString plotTOFka, TString plotTOFpro) { //Open input file TFile * fin = TFile::Open(filename.Data()); if (!fin) return 0x0; //Access output of specific wagon TList * list = (TList*) fin->Get(foldername.Data()); if (!list) return 0x0; //Set range for fit Float_t RangeFitMomMin = 0.1; //range in momentum where to check the mean and pull Float_t RangeFitMomMax = 2.0; Int_t xbinFitMin = 0; Int_t xbinFitMax = -1; Float_t RangeFitNsigmaPIDmin = -2.0; //range in Nsigma where the fit is to be performed Float_t RangeFitNsigmaPIDmax = 2.0; //Set range for visualisation Float_t RangeShowTPC[2] = {0.1, 2.0}; Float_t RangeShowTOF[2] = {0.25, 2.0}; //-------------------------- // TPC PID Nsigma // fit with simple gaussian //-------------------------- //Gaussian function TF1 *fGaus = new TF1("f","gaus", -7.0, 7.0); //--- pions TH2F * hTPCsigmaPi = (TH2F*)list->FindObject(plotTPCpi.Data()); hTPCsigmaPi->RebinX(2); hTPCsigmaPi->SetTitle("TPC Pions"); MakeUpHisto(hTPCsigmaPi,"p_{TPC} (GeV/c)", "N#sigma_{TPC}", 1, kBlack, 2); hTPCsigmaPi->GetYaxis()->SetRangeUser(-5.1,5.1); hTPCsigmaPi->GetXaxis()->SetRangeUser(RangeShowTPC[0], RangeShowTPC[1]); xbinFitMin = hTPCsigmaPi->GetXaxis()->FindBin(RangeFitMomMin); xbinFitMax = hTPCsigmaPi->GetXaxis()->FindBin(RangeFitMomMax); hTPCsigmaPi->FitSlicesY(fGaus, xbinFitMin, xbinFitMax ); TH1D * hTPCsigmaPi_mean = ((TH1D*)gDirectory->FindObject(Form("%s_1", plotTPCpi.Data())))->Clone("hNsigmaTPCpi_mean"); TH1D * hTPCsigmaPi_pull = ((TH1D*)gDirectory->FindObject(Form("%s_2", plotTPCpi.Data())))->Clone("hNsigmaTPCpi_pull"); MakeUpHisto(hTPCsigmaPi_mean, "", "", 1, kBlack, 2); MakeUpHisto(hTPCsigmaPi_pull, "", "", 1, kRed+2, 2); //--- kaons TH2F * hTPCsigmaKa = (TH2F*)list->FindObject(plotTPCka.Data()); hTPCsigmaKa->RebinX(2); hTPCsigmaKa->SetTitle("TPC Kaons"); hTPCsigmaKa->GetYaxis()->SetRangeUser(-5.1,5.1); hTPCsigmaKa->GetXaxis()->SetRangeUser(RangeShowTPC[0], RangeShowTPC[1]); hTPCsigmaKa->FitSlicesY(fGaus, xbinFitMin, xbinFitMax ); MakeUpHisto(hTPCsigmaKa,"p_{TPC} (GeV/c)", "N#sigma_{TPC}", 1, kBlack, 2); TH1D * hTPCsigmaKa_mean = ((TH1D*)gDirectory->FindObject(Form("%s_1", plotTPCka.Data())))->Clone("hNsigmaTPCka_mean"); TH1D * hTPCsigmaKa_pull = ((TH1D*)gDirectory->FindObject(Form("%s_2", plotTPCka.Data())))->Clone("hNsigmaTPCka_pull"); MakeUpHisto(hTPCsigmaKa_mean, "", "", 1, kBlack, 2); MakeUpHisto(hTPCsigmaKa_pull, "", "", 1, kRed+2, 2); //--- protons TH2F * hTPCsigmaPro = (TH2F*)list->FindObject(plotTPCpro.Data()); hTPCsigmaPro->RebinX(2); hTPCsigmaPro->SetTitle("TPC Protons"); MakeUpHisto(hTPCsigmaPro,"p_{TPC} (GeV/c)", "N#sigma_{TPC}", 1, kBlack, 2); hTPCsigmaPro->GetYaxis()->SetRangeUser(-5.1,5.1); hTPCsigmaPro->GetXaxis()->SetRangeUser(RangeShowTPC[0], RangeShowTPC[1]); hTPCsigmaPro->FitSlicesY(fGaus, xbinFitMin, xbinFitMax ); TH1D * hTPCsigmaPro_mean = ((TH1D*)gDirectory->FindObject(Form("%s_1", plotTPCpro.Data())))->Clone("hNsigmaTPCpro_mean"); TH1D * hTPCsigmaPro_pull = ((TH1D*)gDirectory->FindObject(Form("%s_2", plotTPCpro.Data())))->Clone("hNsigmaTPCpro_pull"); MakeUpHisto(hTPCsigmaPro_mean, "", "", 1, kBlack, 2); MakeUpHisto(hTPCsigmaPro_pull, "", "", 1, kRed+2, 2); //--- plot TPC TLine *l11=new TLine(RangeShowTPC[0],0.,RangeShowTPC[1],0.); l11->SetLineWidth(1); l11->SetLineStyle(7); TLine *l12=new TLine(RangeShowTPC[0],1.,RangeShowTPC[1],1.); l12->SetLineWidth(1); l12->SetLineStyle(7); gStyle->SetOptStat(0); TCanvas *cPidPerformance4 = new TCanvas("cPIDperformance4","TPC PID",1200,500); cPidPerformance4->Divide(3,1); cPidPerformance4->cd(1); gPad->SetLogz(); gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy(); hTPCsigmaPi->DrawCopy("colz"); hTPCsigmaPi_mean->DrawCopy("same"); hTPCsigmaPi_pull->DrawCopy("same"); l11->Draw("same"); l12->Draw("same"); cPidPerformance4->cd(2); gPad->SetLogz(); gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy(); hTPCsigmaKa->DrawCopy("colz"); hTPCsigmaKa_mean->DrawCopy("same"); hTPCsigmaKa_pull->DrawCopy("same"); l11->Draw("same"); l12->Draw("same"); cPidPerformance4->cd(3); gPad->SetLogz(); gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy(); hTPCsigmaPro->DrawCopy("colz"); hTPCsigmaPro_mean->DrawCopy("same"); hTPCsigmaPro_pull->DrawCopy("same"); l11->Draw("same"); l12->Draw("same"); TLegend * pidLegTPC = new TLegend(0.15,0.8,0.88,0.88); pidLegTPC->SetBorderSize(0); pidLegTPC->SetFillStyle(1001); pidLegTPC->SetFillColor(kWhite); pidLegTPC->SetTextSize(0.04); pidLegTPC->SetNColumns(2); pidLegTPC->AddEntry(hTPCsigmaPro_mean,"Mean","lp"); pidLegTPC->AddEntry(hTPCsigmaPro_pull,Form("#sigma, Gaus fit (%2.1f,%2.1f)",RangeFitNsigmaPIDmin,RangeFitNsigmaPIDmax),"lp"); pidLegTPC->Draw("same"); if (savePng) cPidPerformance4->SaveAs("RsnQA_TPC_Nsigma.png"); //---------------------------------------------------- // TOF // fit with signal model = gaussian + exponential tail //---------------------------------------------------- //Signal model for TOF signal = gaus + exp tail const Int_t npars = 6; TF1 *fSignalModel = new TF1("fSignalModel", TOFsignal, -7.0, 7.0, npars); fSignalModel->SetTitle("TOF Signal"); fSignalModel->SetParameter(0, 1.); fSignalModel->SetParameter(1, 0.); fSignalModel->SetParLimits(1, -2., 1.); fSignalModel->SetParameter(2, 1.); fSignalModel->SetParLimits(2, 0.5, 2.); fSignalModel->SetParameter(3, 1.); fSignalModel->SetParLimits(3, 0.5, 1.5); fSignalModel->SetParameter(4, 1.); fSignalModel->SetParLimits(4, 0., 1.e8); fSignalModel->SetParameter(5, 0.); fSignalModel->SetParLimits(5, -10., 10.); fSignalModel->SetNpx(2000); fSignalModel->SetParNames("Norm", "Mean", "Sigma", "Tail", "Shift", "Slope"/*, "Square"*/); fSignalModel->SetLineColor(kRed+1); //results TObjArray *results[3]; for(Int_t i = 0; i < 3; i++){ results[i] = new TObjArray(10); } TH1D * par[3][npars]; //--- pions TH2F * hTOFsigmaPi = (TH2F*)list->FindObject(plotTOFpi.Data()); hTOFsigmaPi->SetTitle("TOF Pions"); hTOFsigmaPi->RebinX(2); MakeUpHisto(hTOFsigmaPi,"p (GeV/c)", "N#sigma_{TOF}", 1, kBlack, 2); hTOFsigmaPi->GetYaxis()->SetRangeUser(-5.1,5.1); hTOFsigmaPi->GetXaxis()->SetRangeUser(RangeShowTOF[0], RangeShowTOF[1]); fSignalModel->SetParLimits(4, 0., hTOFsigmaPi->GetMaximum()*0.5); fSignalModel->SetParLimits(0, 0., hTOFsigmaPi->GetMaximum()*1.2); hTOFsigmaPi->FitSlicesY(fSignalModel, xbinFitMin, xbinFitMax, 0, "QR", results[0] ); for(Int_t cc = 0; cc < npars ; cc++) { par[0][cc] = (TH1D*)gDirectory->FindObject(Form("%s_%i", plotTOFpi.Data(), cc)); } MakeUpHisto(par[0][1], "", "", 1, kBlue, 2); MakeUpHisto(par[0][2], "", "", 1, kMagenta+2, 2); //--- KAONS TH2F * hTOFsigmaKa = (TH2F*)list->FindObject(plotTOFka.Data()); hTOFsigmaKa->SetTitle("TOF Kaons"); hTOFsigmaKa->RebinX(2); MakeUpHisto(hTOFsigmaKa,"p (GeV/c)", "N#sigma_{TOF}", 1, kBlack, 2); hTOFsigmaKa->GetYaxis()->SetRangeUser(-5.1,5.1); hTOFsigmaKa->GetXaxis()->SetRangeUser(RangeShowTOF[0], RangeShowTOF[1]); fSignalModel->SetParLimits(4, 0., hTOFsigmaKa->GetMaximum()*0.5); fSignalModel->SetParLimits(0, 0., hTOFsigmaKa->GetMaximum()*1.2); hTOFsigmaKa->FitSlicesY(fSignalModel, xbinFitMin, xbinFitMax, 0, "QR", results[0] ); for(Int_t cc = 0; cc < npars ; cc++) { par[1][cc] = (TH1D*)gDirectory->FindObject(Form("%s_%i", plotTOFka.Data(), cc)); } MakeUpHisto(par[1][1], "", "", 1, kBlue, 2); MakeUpHisto(par[1][2], "", "", 1, kMagenta+2, 2); //--- protons TH2F * hTOFsigmaPro = (TH2F*)list->FindObject(plotTOFpro.Data()); hTOFsigmaPro->SetTitle("TOF Protons"); hTOFsigmaPro->RebinX(2); MakeUpHisto(hTOFsigmaPro,"p (GeV/c)", "N#sigma_{TOF}", 1, kBlack, 2); hTOFsigmaPro->GetYaxis()->SetRangeUser(-5.1,5.1); hTOFsigmaPro->GetXaxis()->SetRangeUser(RangeShowTOF[0], RangeShowTOF[1]); fSignalModel->SetParLimits(4, 0., hTOFsigmaPro->GetMaximum()*0.5); fSignalModel->SetParLimits(0, 0., hTOFsigmaPro->GetMaximum()*1.2); hTOFsigmaPro->FitSlicesY(fSignalModel, xbinFitMin, xbinFitMax, 0, "QR", results[0] ); for(Int_t cc = 0; cc < npars ; cc++) { par[2][cc] = (TH1D*)gDirectory->FindObject(Form("%s_%i", plotTOFpro.Data(), cc)); } MakeUpHisto(par[2][1], "", "", 1, kBlue, 2); MakeUpHisto(par[2][2], "", "", 1, kMagenta+2, 2); //--- plot TOF gStyle->SetOptStat(0); TCanvas *cPidPerformance3 = new TCanvas("cPidPerformance3","TOF PID performance",1200,500); cPidPerformance3->Divide(3,1); cPidPerformance3->cd(1); gPad->SetLogz(); gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy(); hTOFsigmaPi->DrawCopy("colz"); if(par[0][1]) par[0][1]->DrawCopy("same"); if(par[0][2]) par[0][2]->DrawCopy("same"); l11->Draw("same"); l12->Draw("same"); cPidPerformance3->cd(2); gPad->SetLogz(); gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy(); hTOFsigmaKa->DrawCopy("colz"); if(par[1][1]) par[1][1]->DrawCopy("same"); if(par[1][2]) par[1][2]->DrawCopy("same"); l11->Draw("same"); l12->Draw("same"); cPidPerformance3->cd(3); gPad->SetLogz(); gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy(); hTOFsigmaPro->DrawCopy("colz"); if(par[2][1]) par[2][1]->DrawCopy("same"); if(par[2][2]) par[2][2]->DrawCopy("same"); l11->Draw("same"); l12->Draw("same"); TLegend * pidLegTOF = new TLegend(0.15,0.8,0.88,0.88); pidLegTOF->SetBorderSize(0); pidLegTOF->SetFillStyle(1001); pidLegTOF->SetFillColor(kWhite); pidLegTOF->SetTextSize(0.04); pidLegTOF->SetNColumns(2); pidLegTOF->AddEntry(par[0][1],"Mean","lp"); pidLegTOF->AddEntry(par[0][2], Form("#sigma, Gaus+Tail fit (%2.1f,%2.1f)",RangeFitNsigmaPIDmin, RangeFitNsigmaPIDmax),"lp"); pidLegTOF->Draw("same"); if (savePng) cPidPerformance3->Print("RsnQA_TOF_Nsigma.png"); return; }
void mgg_cuts(int sigMass, double pt1min, double pt2min, double METmin, int jets, int DataFlag){ TLegend* leg = new TLegend(0.5,0.72,0.89,0.89); leg->SetNColumns(2); TCanvas *canvas = new TCanvas("c1n","",500,500); gPad->SetLogy(); TCut mggmax = "mgg<200"; TCut mggmin = "mgg>100"; TCut pt1Cut = Form("pt1>%lf",pt1min); TCut pt2Cut = Form("pt2>%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))"; TCut Cut_Jets = Form("nJets<%d",jets); /* TFile *M1 = TFile::Open("./50ns_betaV4/NewWeightDMHtoGG_M1.root","READ"); TFile *M10 = TFile::Open("./50ns_betaV4/NewWeightDMHtoGG_M10.root","READ"); TFile *M100 = TFile::Open("./50ns_betaV4/NewWeightDMHtoGG_M100.root","READ"); TFile *M1000 = TFile::Open("./50ns_betaV4/NewWeightDMHtoGG_M1000.root","READ"); */ TFile *data = TFile::Open("./25ns_2246inv/DoubleEG.root","READ"); TFile *sig1 = TFile::Open("./25ns_2246inv/2HDM_mZP600.root","READ"); TFile *sig2 = TFile::Open("./25ns_2246inv/2HDM_mZP800.root","READ"); TFile *sig3 = TFile::Open("./25ns_2246inv/2HDM_mZP1000.root","READ"); TFile *sig4 = TFile::Open("./25ns_2246inv/2HDM_mZP1200.root","READ"); TFile *sig5 = TFile::Open("./25ns_2246inv/2HDM_mZP1400.root","READ"); /* TFile *bkg1 = TFile::Open("./50ns_betaV4/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./50ns_betaV4/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./50ns_betaV4/GJets.root","READ"); TFile *bkg4 = TFile::Open("./50ns_betaV4/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./50ns_betaV4/QCD.root","READ"); TFile *bkg6 = TFile::Open("./50ns_betaV4/VH.root","READ"); */ TFile *bkg1 = TFile::Open("./25ns_2246inv/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./25ns_2246inv/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./25ns_2246inv/GJets.root","READ"); TFile *bkg4 = TFile::Open("./25ns_2246inv/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./25ns_2246inv/QCD.root","READ"); TFile *bkg6 = TFile::Open("./25ns_2246inv/VH.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_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"); /* tree_M1->Draw("(mgg)>>h1(30,100,180)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_M10->Draw("(mgg)>>h2(30,100,180)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_M100->Draw("(mgg)>>h3(30,100,180)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_M1000->Draw("(mgg)>>h4(30,100,180)","weight*10"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); */ tree_data->Draw("(mgg)>>hdata(30,100,180)",(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets && metF)); TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata"); tree_sig1->Draw("(mgg)>>h1(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("(mgg)>>h2(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("(mgg)>>h3(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("(mgg)>>h4(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("(mgg)>>h5(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); h1->Scale(0.00009338); h2->Scale(0.00010348); h3->Scale(0.00008394); h4->Scale(0.00006352); h5->Scale(0.00004712); tree_bkg1->Draw("(mgg)>>hbkg1(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("(mgg)>>hbkg2(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("(mgg)>>hbkg3(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets && genmatch)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("(mgg)>>hbkg4(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4"); tree_bkg5->Draw("(mgg)>>hbkg5(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets && genmatch)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("(mgg)>>hbkg6(30,100,180)","weight"*(mggmax && mggmin && pt1Cut && pt2Cut && METCut && eveto && Cut_Jets)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6"); double DeltaN = 0; double DeltaS1 = 0; double DeltaS2 = 0; double DeltaS3 = 0; double DeltaS4 = 0; double DeltaS5 = 0; double DeltaF1 = 0; double DeltaF2 = 0; double DeltaF3 = 0; double DeltaF4 = 0; double DeltaF5 = 0; double DeltaF6 = 0; double DeltaNi = 0; double DeltaS1i= 0; double DeltaS2i= 0; double DeltaS3i= 0; double DeltaS4i= 0; double DeltaS5i= 0; double DeltaF1i= 0; double DeltaF2i= 0; double DeltaF3i = 0; double DeltaF4i = 0; double DeltaF5i = 0; double DeltaF6i = 0; for(i=0; i<30; i++){ DeltaNi=hdata->GetBinError(i); DeltaS1i=h1->GetBinError(i); DeltaS2i=h2->GetBinError(i); DeltaS3i=h3->GetBinError(i); DeltaS4i=h4->GetBinError(i); DeltaS5i=h5->GetBinError(i); DeltaF1i=hbkg1->GetBinError(i); DeltaF2i= hbkg2->GetBinError(i); DeltaF3i= hbkg3->GetBinError(i); DeltaF4i= hbkg4->GetBinError(i); DeltaF5i= hbkg5->GetBinError(i); DeltaF6i= hbkg6->GetBinError(i); DeltaN += pow(DeltaNi,2); DeltaS1 += pow(DeltaS1i,2); DeltaS2 += pow(DeltaS2i,2); DeltaS3 += pow(DeltaS3i,2); DeltaS4 += pow(DeltaS4i,2); DeltaS5 += pow(DeltaS5i,2); DeltaF1 += pow(DeltaF1i,2); DeltaF2 += pow(DeltaF2i,2); DeltaF3 += pow(DeltaF3i,2); DeltaF4 += pow(DeltaF4i,2); DeltaF5 += pow(DeltaF5i,2); DeltaF6 += pow(DeltaF6i,2); } DeltaN = sqrt(DeltaN); DeltaS1 = sqrt(DeltaS1); DeltaS2 = sqrt(DeltaS2); DeltaS3 = sqrt(DeltaS3); DeltaS4 = sqrt(DeltaS4); DeltaS5 = sqrt(DeltaS5); DeltaF1 = sqrt(DeltaF1); DeltaF2 = sqrt(DeltaF2); DeltaF3 = sqrt(DeltaF3); DeltaF4 = sqrt(DeltaF4); DeltaF5 = sqrt(DeltaF5); DeltaF6 = sqrt(DeltaF6); double Ndata= hdata->Integral(); cout<<"Ndata= "<<Ndata<<" +/- "<<DeltaN<<endl; double S1= h1->Integral(); double S2= h2->Integral(); double S3= h3->Integral(); double S4= h4->Integral(); double S5= h5->Integral(); cout<<"S1= "<<S1<<" +/- "<<DeltaS1<<endl; cout<<"S2= "<<S2<<" +/- "<<DeltaS2<<endl; cout<<"S3= "<<S3<<" +/- "<<DeltaS3<<endl; cout<<"S4= "<<S4<<" +/- "<<DeltaS4<<endl; cout<<"S5= "<<S5<<" +/- "<<DeltaS5<<endl; double DiPho = hbkg1->Integral(); cout<<"diphoton = "<<DiPho<<" +/- "<<DeltaF1<<endl; double DY = hbkg2->Integral(); cout<<"DY = "<<DY<<" +/- "<<DeltaF2<<endl; double GJ = hbkg3->Integral(); cout<<"GJ = "<<GJ<<" +/- "<<DeltaF3<<endl; double GluGlu = hbkg4->Integral(); cout<<"GluGlu = "<<GluGlu<<" +/- "<<DeltaF4<<endl; double QCD = hbkg5->Integral(); cout<<"QCD = "<<QCD<<" +/- "<<DeltaF5<<endl; double VHiggs = hbkg6->Integral(); cout<<"VH = "<<VHiggs<<" +/- "<<DeltaF6<<endl; h1->SetLineColor(kRed-4); h2->SetLineColor(kRed+2); h3->SetLineColor(kPink+2); h4->SetLineColor(kPink+4); h5->SetLineColor(kMagenta+2); //only for 25ns samples h1->SetLineWidth(2); h2->SetLineWidth(2); h3->SetLineWidth(2); h4->SetLineWidth(2); h5->SetLineWidth(2); //only for 25ns samples THStack *hs=new THStack("hs",""); hbkg6->SetFillColor(kGreen+3); hbkg4->SetFillColor(kGreen+4); hbkg1->SetFillColor(kBlue); hbkg2->SetFillColor(kBlue+2); hbkg3->SetFillColor(kMagenta+4); hbkg5->SetFillColor(kMagenta+2); hbkg1->SetLineColor(kBlack); hbkg2->SetLineColor(kBlack); hbkg3->SetLineColor(kBlack); hbkg4->SetLineColor(kBlack); hbkg5->SetLineColor(kBlack); hbkg6->SetLineColor(kBlack); hs->Add(hbkg6); hs->Add(hbkg4); hs->Add(hbkg1); hs->Add(hbkg2); hs->Add(hbkg3); hs->Add(hbkg5); TH1F *hsum = (TH1F*)hbkg1->Clone("hsum"); hsum->Add(hbkg2); hsum->Add(hbkg3); hsum->Add(hbkg4); hsum->Add(hbkg5); hsum->Add(hbkg6); hs->SetMinimum(0.0001); hs->SetMaximum(100); hs->SetTitle(""); hs->Draw("HIST"); hsum->SetMarkerStyle(1); hsum->SetFillColor(kGray+3); hsum->SetFillStyle(3001); 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 if(DataFlag ==1){ hdata->Draw("same E1"); } hs->GetXaxis()->SetTitle("m_{#gamma#gamma}"); hs->GetYaxis()->SetTitleOffset(1.2); hs->GetYaxis()->SetTitle("Events/2.7 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(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(hbkg4,"ggH","f"); leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples leg->AddEntry(hbkg5,"QCD","f"); leg->AddEntry(hbkg6,"VH","f"); if(DataFlag==1){ leg->AddEntry(hdata,"Data","elp"); } leg->Draw("same"); gStyle->SetOptStat(0); /* if(jets<3){ canvas->SaveAs(Form("mgg_cuts_M%d_%djets.pdf",sigMass,(jets-1))); canvas->SaveAs(Form("mgg_cuts_M%d_%djets.png",sigMass,(jets-1))); } else{ canvas->SaveAs(Form("mgg_cuts_M%d_noJetsCut.pdf",sigMass)); canvas->SaveAs(Form("mgg_cuts_M%d_noJetsCut.png",sigMass)); }*/ }
void PlotIsjMean() { gROOT->LoadMacro("$LOCAL/include/TUntilsOpHisto.h"); gROOT->LoadMacro("$LOCAL/include/TUntilsAliFigs.h"); gROOT->LoadMacro("$LOCAL/include/TUntilsPlotStd.h"); SetStyle(); //============================================================================= TFile *file = TFile::Open("data/AnalysisOutputs_Isj.root", "READ"); TList *listPy8R4S1 = (TList*)file->Get("list_py8_JetR04_SjeR01"); TList *listPy8R4S2 = (TList*)file->Get("list_py8_JetR04_SjeR02"); TList *listPy8R4S3 = (TList*)file->Get("list_py8_JetR04_SjeR03"); TList *listPy8R5S1 = (TList*)file->Get("list_py8_JetR05_SjeR01"); TList *listPy8R5S2 = (TList*)file->Get("list_py8_JetR05_SjeR02"); TList *listPy8R5S3 = (TList*)file->Get("list_py8_JetR05_SjeR03"); TList *listPy8R5S4 = (TList*)file->Get("list_py8_JetR05_SjeR04"); TList *listVacR4S1 = (TList*)file->Get("list_vac_JetR04_SjeR01"); TList *listVacR4S2 = (TList*)file->Get("list_vac_JetR04_SjeR02"); TList *listVacR4S3 = (TList*)file->Get("list_vac_JetR04_SjeR03"); TList *listVacR5S1 = (TList*)file->Get("list_vac_JetR05_SjeR01"); TList *listVacR5S2 = (TList*)file->Get("list_vac_JetR05_SjeR02"); TList *listVacR5S3 = (TList*)file->Get("list_vac_JetR05_SjeR03"); TList *listVacR5S4 = (TList*)file->Get("list_vac_JetR05_SjeR04"); TList *listMedR4S1 = (TList*)file->Get("list_med_JetR04_SjeR01"); TList *listMedR4S2 = (TList*)file->Get("list_med_JetR04_SjeR02"); TList *listMedR4S3 = (TList*)file->Get("list_med_JetR04_SjeR03"); TList *listMedR5S1 = (TList*)file->Get("list_med_JetR05_SjeR01"); TList *listMedR5S2 = (TList*)file->Get("list_med_JetR05_SjeR02"); TList *listMedR5S3 = (TList*)file->Get("list_med_JetR05_SjeR03"); TList *listMedR5S4 = (TList*)file->Get("list_med_JetR05_SjeR04"); file->Close(); TProfile *hPy8R4S1 = (TProfile*)listPy8R4S1->FindObject("hJetIsj_mean"); hPy8R4S1->SetName("hPy8R4S1"); TProfile *hPy8R4S2 = (TProfile*)listPy8R4S2->FindObject("hJetIsj_mean"); hPy8R4S2->SetName("hPy8R4S2"); TProfile *hPy8R4S3 = (TProfile*)listPy8R4S3->FindObject("hJetIsj_mean"); hPy8R4S3->SetName("hPy8R4S3"); TProfile *hPy8R5S1 = (TProfile*)listPy8R5S1->FindObject("hJetIsj_mean"); hPy8R5S1->SetName("hPy8R5S1"); TProfile *hPy8R5S2 = (TProfile*)listPy8R5S2->FindObject("hJetIsj_mean"); hPy8R5S2->SetName("hPy8R5S2"); TProfile *hPy8R5S3 = (TProfile*)listPy8R5S3->FindObject("hJetIsj_mean"); hPy8R5S3->SetName("hPy8R5S3"); TProfile *hPy8R5S4 = (TProfile*)listPy8R5S4->FindObject("hJetIsj_mean"); hPy8R5S4->SetName("hPy8R5S4"); TProfile *hVacR4S1 = (TProfile*)listVacR4S1->FindObject("hJetIsj_mean"); hVacR4S1->SetName("hVacR4S1"); TProfile *hVacR4S2 = (TProfile*)listVacR4S2->FindObject("hJetIsj_mean"); hVacR4S2->SetName("hVacR4S2"); TProfile *hVacR4S3 = (TProfile*)listVacR4S3->FindObject("hJetIsj_mean"); hVacR4S3->SetName("hVacR4S3"); TProfile *hVacR5S1 = (TProfile*)listVacR5S1->FindObject("hJetIsj_mean"); hVacR5S1->SetName("hVacR5S1"); TProfile *hVacR5S2 = (TProfile*)listVacR5S2->FindObject("hJetIsj_mean"); hVacR5S2->SetName("hVacR5S2"); TProfile *hVacR5S3 = (TProfile*)listVacR5S3->FindObject("hJetIsj_mean"); hVacR5S3->SetName("hVacR5S3"); TProfile *hVacR5S4 = (TProfile*)listVacR5S4->FindObject("hJetIsj_mean"); hVacR5S4->SetName("hVacR5S4"); TProfile *hMedR4S1 = (TProfile*)listMedR4S1->FindObject("hJetIsj_mean"); hMedR4S1->SetName("hMedR4S1"); TProfile *hMedR4S2 = (TProfile*)listMedR4S2->FindObject("hJetIsj_mean"); hMedR4S2->SetName("hMedR4S2"); TProfile *hMedR4S3 = (TProfile*)listMedR4S3->FindObject("hJetIsj_mean"); hMedR4S3->SetName("hMedR4S3"); TProfile *hMedR5S1 = (TProfile*)listMedR5S1->FindObject("hJetIsj_mean"); hMedR5S1->SetName("hMedR5S1"); TProfile *hMedR5S2 = (TProfile*)listMedR5S2->FindObject("hJetIsj_mean"); hMedR5S2->SetName("hMedR5S2"); TProfile *hMedR5S3 = (TProfile*)listMedR5S3->FindObject("hJetIsj_mean"); hMedR5S3->SetName("hMedR5S3"); TProfile *hMedR5S4 = (TProfile*)listMedR5S4->FindObject("hJetIsj_mean"); hMedR5S4->SetName("hMedR5S4"); //============================================================================= TH1F *hfm = 0; TCanvas *can = 0; TLegend *leg = 0; TLatex *tex = 0; TLine *line = 0; const Float_t dflx = 0., dfux = 500.; const Float_t dfly = 0., dfuy = 500.; const Float_t dlsx = 0.05, dlsy = 0.05; const Float_t dtsx = 0.06, dtsy = 0.06; const Float_t dtox = 1.10, dtoy = 1.00; const TString stnx = "#it{p}_{T,jet} (GeV/#it{c})"; const TString stny = "#it{p}_{T,subjet}^{mean} (GeV/#it{c})"; TH1D *hSE = new TH1D("hSE", "", 10., 0., 10.); hSE->SetLineWidth(2); hSE->SetLineColor(wcl[0]); hSE->SetMarkerStyle(wmk[0]); hSE->SetMarkerColor(wcl[0]); TH1D *hME = new TH1D("hME", "", 10., 0., 10.); hME->SetLineWidth(2); hME->SetLineColor(wcl[0]); hME->SetMarkerStyle(wmk[2]); hME->SetMarkerColor(wcl[0]); //============================================================================= can = MakeCanvas("IsjPy8R04_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hPy8R4S1, wcl[1], wmk[0], "SAME"); DrawHisto(hPy8R4S2, wcl[3], wmk[0], "SAME"); DrawHisto(hPy8R4S3, wcl[4], wmk[0], "SAME"); leg = new TLegend(0.68, 0.66, 0.98, 0.90); SetupLegend(leg); leg->AddEntry(hPy8R4S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hPy8R4S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hPy8R4S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA 8, tune 4C, pp #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= can = MakeCanvas("IsjPy8R05_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hPy8R5S1, wcl[1], wmk[0], "SAME"); DrawHisto(hPy8R5S2, wcl[3], wmk[0], "SAME"); DrawHisto(hPy8R5S3, wcl[4], wmk[0], "SAME"); DrawHisto(hPy8R5S4, wcl[2], wmk[0], "SAME"); leg = new TLegend(0.58, 0.74, 0.98, 0.90); SetupLegend(leg); leg->SetNColumns(2); leg->AddEntry(hPy8R5S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hPy8R5S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hPy8R5S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->AddEntry(hPy8R5S4, "#it{R}_{sub}=0.4", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA 8, tune 4C, pp #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= can = MakeCanvas("IsjVacR04_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hVacR4S1, wcl[1], wmk[0], "SAME"); DrawHisto(hVacR4S2, wcl[3], wmk[0], "SAME"); DrawHisto(hVacR4S3, wcl[4], wmk[0], "SAME"); leg = new TLegend(0.68, 0.66, 0.98, 0.90); SetupLegend(leg); leg->AddEntry(hVacR4S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hVacR4S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hVacR4S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, vacuum, #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= can = MakeCanvas("IsjVacR05_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hVacR5S1, wcl[1], wmk[0], "SAME"); DrawHisto(hVacR5S2, wcl[3], wmk[0], "SAME"); DrawHisto(hVacR5S3, wcl[4], wmk[0], "SAME"); DrawHisto(hVacR5S4, wcl[2], wmk[0], "SAME"); leg = new TLegend(0.58, 0.74, 0.98, 0.90); SetupLegend(leg); leg->SetNColumns(2); leg->AddEntry(hVacR5S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hVacR5S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hVacR5S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->AddEntry(hVacR5S4, "#it{R}_{sub}=0.4", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, vacuum, #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= can = MakeCanvas("IsjMedR04_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hMedR4S1, wcl[1], wmk[0], "SAME"); DrawHisto(hMedR4S2, wcl[3], wmk[0], "SAME"); DrawHisto(hMedR4S3, wcl[4], wmk[0], "SAME"); leg = new TLegend(0.68, 0.66, 0.98, 0.90); SetupLegend(leg); leg->AddEntry(hMedR4S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hMedR4S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hMedR4S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, medium, #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= can = MakeCanvas("IsjMedR05_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy(); hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny); hfm->GetXaxis()->SetNdivisions(510); hfm->GetYaxis()->SetNdivisions(510); DrawHisto(hMedR5S1, wcl[1], wmk[0], "SAME"); DrawHisto(hMedR5S2, wcl[3], wmk[0], "SAME"); DrawHisto(hMedR5S3, wcl[4], wmk[0], "SAME"); DrawHisto(hMedR5S4, wcl[2], wmk[0], "SAME"); leg = new TLegend(0.58, 0.74, 0.98, 0.90); SetupLegend(leg); leg->SetNColumns(2); leg->AddEntry(hMedR5S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24); leg->AddEntry(hMedR5S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24); leg->AddEntry(hMedR5S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24); leg->AddEntry(hMedR5S4, "#it{R}_{sub}=0.4", "LP")->SetTextSizePixels(24); leg->Draw(); tex = new TLatex(); tex->SetNDC(); tex->SetTextSizePixels(24); tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, medium, #sqrt{#it{s}_{NN}}=2.76 TeV"); tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1"); tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}"); CanvasEnd(can); //============================================================================= return; }
void PostFitCombine(TString Plots = "fit_s", TString InpDir = "FitResults_DataCardFixbtagSysVisPhSp_hSF-PreApp-v0_Tree_LepJets_NewJEC-OldKinFit_v8-0-6_Spring16-80X_36814pb-1_2btag", TString FitDir = "OBSERVED"){ TString PlotsFileName; if(FitDir == "OBSERVED") PlotsFileName = "obs"; if(FitDir == "EXPECTED") PlotsFileName = "exp"; TString inputfile = "CombineResults/" + InpDir + "/" + FitDir + "/fitDiagnostics" + PlotsFileName + "MLF.root"; setTDRStyle(); gROOT->SetStyle("Plain"); gStyle->SetOptFit(1000); gStyle->SetOptStat("emruo"); gStyle->SetOptStat(kFALSE); gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); int col_ttbb = TColor::GetColor("#660000"); int col_ttb = TColor::GetColor("#ffcc00"); int col_ttcc = TColor::GetColor("#cc6600"); int col_ttc = TColor::GetColor("#cc6600"); int col_ttLF = TColor::GetColor("#ff0000"); int col_tt = TColor::GetColor("#FF7F7F"); int col_ttbarBkg = TColor::GetColor("#ff6565"); int col_SingleTop = TColor::GetColor("#ff00ff"); int col_WJets = TColor::GetColor("#33cc33"); int col_ZJets = TColor::GetColor("#3366ff"); int col_QCD = TColor::GetColor("#ffff00"); int col_ttbarV = TColor::GetColor("#e75c8d"); int col_ttbarH = TColor::GetColor("#e5c4f4"); int col_VV = TColor::GetColor("#ffffff"); TFile *hfile = NULL; hfile = TFile::Open(inputfile); cout << "file loaded: " << inputfile << endl; std::vector<TString> hNamefile; std::vector<int> hColor; hNamefile.push_back("ttbar_LepJetsPowhegPythiattbb"); // 0 hColor.push_back(TColor::GetColor("#660000")); hNamefile.push_back("ttbar_LepJetsPowhegPythiattbj"); // 1 hColor.push_back(TColor::GetColor("#ffcc00")); hNamefile.push_back("ttbar_LepJetsPowhegPythiattcc"); // 2 hColor.push_back(TColor::GetColor("#cc6600")); hNamefile.push_back("ttbar_LepJetsPowhegPythiattLF"); // 3 hColor.push_back(TColor::GetColor("#ff0000")); hNamefile.push_back("ttbar_PowhegPythiaBkgtt"); hColor.push_back(TColor::GetColor("#FF7F7F")); hNamefile.push_back("ttHbb_PowhegPythia"); hColor.push_back(TColor::GetColor("#e5c4f4")); hNamefile.push_back("ttV_Madgraph"); hColor.push_back(TColor::GetColor("#e75c8d")); hNamefile.push_back("WJets_aMCatNLO"); hColor.push_back(TColor::GetColor("#33cc33")); hNamefile.push_back("QCD"); hColor.push_back(TColor::GetColor("#ffff00")); hNamefile.push_back("SingleTop"); hColor.push_back(TColor::GetColor("#ff00ff")); hNamefile.push_back("VV"); hColor.push_back(TColor::GetColor("#ffffff")); hNamefile.push_back("ZJets_aMCatNLO"); hColor.push_back(TColor::GetColor("#3366ff")); hNamefile.push_back("total"); hColor.push_back(1); hNamefile.push_back("total_signal"); hColor.push_back(1); hNamefile.push_back("total_background"); hColor.push_back(1); //TString dirname[2] = {"Name1","Name2"}; //{mu,e} TString dirname[2] = {"ch1","ch2"}; //{mu,e} TString titlechname[2] = {"#mu+Jets","e+Jets"}; TString chname[2] = {"mujets","ejets"}; std::vector<TH1D*> hInput[2]; TH1D *hData[2], *hData_reg[2][20]; THStack *AllMC[2], *AllMC_reg[2][20]; THStack *AllMC_CSV1[2], *AllMC_CSV2[2]; // THStack Initialization for(int ich=0;ich<2;ich++){ AllMC[ich] = new THStack("PostFit_"+chname[ich], "CSV Distribution Post-Fit ("+titlechname[ich]+")"); for(int ireg=0;ireg<20;ireg++){ TString RegNum; RegNum.Form("%i",ireg); AllMC_reg[ich][ireg] = new THStack("PostFit_"+chname[ich]+RegNum, "CSV Distribution Post-Fit ("+titlechname[ich]+") for "+RegNum); } // for(ireg) } // for(ich) cout << "Loading histograms... " << endl; // MC Profiles for(int ich=0;ich<2;ich++){ for(int ih=0;ih<hNamefile.size();ih++){ cout << "shapes_"+Plots+"/"+dirname[ich]+"/" + hNamefile.at(ih) << endl; TH1D *htemp = (TH1D*) hfile->Get("shapes_"+Plots+"/"+dirname[ich]+"/" + hNamefile.at(ih))->Clone("c" + hNamefile.at(ih)); htemp->SetFillColor(hColor.at(ih)); htemp->SetLineColor(1); hInput[ich].push_back(htemp); cout << hNamefile.at(ih) << " = " << htemp->Integral() << endl; if(ih==0) AllMC[ich]->SetHistogram((TH1D*)htemp->Clone("FirstStack")); if (!hNamefile.at(ih).Contains("total")) AllMC[ich] -> Add(htemp); // Data // Clone Histo Structure only once if(ih==0){ hData[ich] = (TH1D *) htemp->Clone("data_"+dirname[ich]); hData[ich]->Reset(); } } // for(ih) // Data TGraph TGraphAsymmErrors *DataFull = (TGraphAsymmErrors *) hfile->Get("shapes_"+Plots+"/"+dirname[ich]+"/data")->Clone("data_"+dirname[ich]); for(int ibin=1;ibin<=hData[ich]->GetNbinsX();ibin++){ double igb, EvtBinData, EvtErrBinData; DataFull->GetPoint((ibin-1),igb,EvtBinData); hData[ich]->SetBinContent(ibin,EvtBinData); EvtErrBinData = DataFull->GetErrorY((ibin-1)); hData[ich]->SetBinError(ibin,EvtErrBinData); } // Histograms for each region for(int ih=0;ih<hNamefile.size();ih++){ TH1D *htemp = (TH1D*) hfile->Get("shapes_"+Plots+"/"+dirname[ich]+"/" + hNamefile.at(ih))->Clone("c_reg" + hNamefile.at(ih)); for(int ireg=0;ireg<20;ireg++){ TH1D *htempreg = new TH1D ("","",20,0,20); for(int ibin=1;ibin<=20;ibin++){ //if ( (ibin+20*ireg) == 181) cout << hNamefile.at(ih) << " " << ibin+20*ireg << " : " << htemp->GetBinContent(ibin+20*ireg) << " ; " << htemp->GetBinError(ibin+20*ireg) << endl; htempreg->SetBinContent(ibin,htemp->GetBinContent(ibin+20*ireg)); htempreg->SetBinError(ibin,htemp->GetBinError(ibin+20*ireg)); htempreg->SetFillColor(hColor.at(ih)); } // for(ibin) if(ih==0) AllMC_reg[ich][ireg]->SetHistogram((TH1D*)htempreg->Clone("FirstStack")); if (!hNamefile.at(ih).Contains("total")) AllMC_reg[ich][ireg] -> Add(htempreg); } // for(ireg) } // for(ih) // Data for(int ireg=0;ireg<20;ireg++){ TString RegNum; RegNum.Form("%i",ireg); hData_reg[ich][ireg] = new TH1D ("hData_"+chname[ich]+RegNum,"Data Histogram "+titlechname[ich]+" for "+RegNum,20,0,20); // Data for(int ibin=1;ibin<=20;ibin++){ double igb, EvtBinData, EvtErrBinData; DataFull->GetPoint(((ibin-1)+(20*ireg)),igb,EvtBinData); hData_reg[ich][ireg]->SetBinContent(ibin,EvtBinData); EvtErrBinData = DataFull->GetErrorY((ibin-1)); hData_reg[ich][ireg]->SetBinError(ibin,EvtErrBinData); hData_reg[ich][ireg]->SetMarkerStyle(20); hData_reg[ich][ireg]->SetMarkerSize(0.5); } // for(ibin) } // for(ireg) // Recover basic CSV plots // -- MC TH1D *GlobalCSVJet[12][2]; // 12 components AllMC_CSV1[ich] = new THStack("CSV1_"+chname[ich], "CSV-AddJet1 Distribution Post-Fit ("+titlechname[ich]+")"); AllMC_CSV2[ich] = new THStack("CSV2_"+chname[ich], "CSV-AddJet2 Distribution Post-Fit ("+titlechname[ich]+")"); for(int ih=0;ih<12;ih++){ GlobalCSVJet[ih][0] = new TH1D("GlobalCSVJet1_" + hNamefile.at(ih), "CSV distribution for AddJet-1", 20, 0.0, 1.0); GlobalCSVJet[ih][1] = new TH1D("GlobalCSVJet2_" + hNamefile.at(ih), "CSV distribution for AddJet-2", 20, 0.0, 1.0); RecoverCSVHisto (hInput[ich].at(ih), GlobalCSVJet[ih][0], GlobalCSVJet[ih][1]); GlobalCSVJet[ih][0]->SetFillColor(hColor.at(ih)); GlobalCSVJet[ih][1]->SetFillColor(hColor.at(ih)); if(ih==0) AllMC_CSV1[ich]->SetHistogram((TH1D*)GlobalCSVJet[ih][0]->Clone("FirstStack")); if(ih==0) AllMC_CSV2[ich]->SetHistogram((TH1D*)GlobalCSVJet[ih][1]->Clone("FirstStack")); AllMC_CSV1[ich] -> Add(GlobalCSVJet[ih][0]); AllMC_CSV2[ich] -> Add(GlobalCSVJet[ih][1]); } // -- Data TH1D *GlobalCSVJet_Data[2]; // 12 components GlobalCSVJet_Data[0] = new TH1D("GlobalCSVJet1_Data", "CSV distribution for AddJet-1", 20, 0.0, 1.0); GlobalCSVJet_Data[1] = new TH1D("GlobalCSVJet2_Data", "CSV distribution for AddJet-2", 20, 0.0, 1.0); RecoverCSVHisto (hData[ich], GlobalCSVJet_Data[0], GlobalCSVJet_Data[1]); // ----------- // Plotting // ----------- TH1D *hstyle = new TH1D ("","", hData[ich]->GetNbinsX(), hData[ich]->GetBinLowEdge (1), hData[ich]->GetBinLowEdge (hData[ich]->GetNbinsX()+1)); hstyle -> SetMaximum(1.1*hInput[ich].at(12)->GetMaximum()); hstyle -> GetYaxis()->SetTitleFont(42); hstyle -> GetYaxis()->SetTitleOffset(0.7); hstyle -> GetYaxis()->SetTitleSize(0.05); hstyle -> GetYaxis()->SetLabelFont(42); hstyle -> GetYaxis()->SetLabelSize(0.045); hstyle -> GetYaxis()->SetNdivisions(607); hstyle -> GetYaxis()->SetTitle("Events / unit"); hData[ich] -> SetMarkerStyle(20); hData[ich] -> SetMarkerSize(0.4); hData[ich] -> SetLineWidth(1); hData[ich] -> SetTitle(""); TCanvas *cPlots;//histos cPlots = new TCanvas("cPlots"+dirname[ich] ,"Plots"); cPlots->Divide(1,2); TPad *pad[4], *glpad[2]; // Global Pad glpad[0] = (TPad*)cPlots->GetPad(1); glpad[0]->Divide(1,2); glpad[1] = (TPad*)cPlots->GetPad(2); glpad[1]->Divide(1,2); //Plot Pad pad[0] = (TPad*)glpad[0]->GetPad(1); pad[0]->SetPad(0.01, 0.23, 0.99, 0.99); pad[0]->SetTopMargin(0.1); pad[0]->SetRightMargin(0.04); //Ratio Pad pad[1] = (TPad*)glpad[0]->GetPad(2); pad[1]->SetPad(0.01, 0.02, 0.99, 0.3); gStyle->SetGridWidth(1); gStyle->SetGridColor(14); pad[1]->SetGridx(); pad[1]->SetGridy(); pad[1]->SetTopMargin(0.05); pad[1]->SetBottomMargin(0.4); pad[1]->SetRightMargin(0.04); //Plot Pad pad[2] = (TPad*)glpad[1]->GetPad(1); pad[2]->SetPad(0.01, 0.23, 0.99, 0.99); pad[2]->SetTopMargin(0.1); pad[2]->SetRightMargin(0.04); //Ratio Pad pad[3] = (TPad*)glpad[1]->GetPad(2); pad[3]->SetPad(0.01, 0.02, 0.99, 0.3); gStyle->SetGridWidth(1); gStyle->SetGridColor(14); pad[3]->SetGridx(); pad[3]->SetGridy(); pad[3]->SetTopMargin(0.05); pad[3]->SetBottomMargin(0.4); pad[3]->SetRightMargin(0.04); pad[0]->cd(); hstyle->Draw(); AllMC[ich] -> Draw("HISTSAME"); hData[ich] -> Draw("PSAME"); TH1D *RatioFull = HistoRatio (hData[ich] , (TH1D*) AllMC[ich]->GetStack()->Last()); TGraphErrors *gRatioFull = new TGraphErrors(RatioFull); gRatioFull->SetFillStyle(1001); gRatioFull->SetFillColor(chatch); gRatioFull->SetName("gRatioFull"); TLegend *leg; float legPos[4] = {0.70, // x_o 0.40, // y_o 0.94, // x_f 0.87}; // y_f leg = new TLegend(legPos[0],legPos[1],legPos[2],legPos[3]); leg->SetFillColor(0); leg->SetLineColor(0); leg->SetLineWidth(0.0); leg->SetTextFont(62); leg->SetTextSize(0.03); leg->SetNColumns(2); leg->AddEntry(hData[ich], "Data","PL"); leg->AddEntry(hInput[ich].at(11), "Z+Jets","F"); leg->AddEntry(hInput[ich].at(10), "VV","F"); leg->AddEntry(hInput[ich].at(9), "Single t","F"); leg->AddEntry(hInput[ich].at(8), "QCD","F"); leg->AddEntry(hInput[ich].at(7), "W+Jets","F"); leg->AddEntry(hInput[ich].at(6), "t#bar{t}+V","F"); leg->AddEntry(hInput[ich].at(5), "t#bar{t}+H","F"); leg->AddEntry(hInput[ich].at(4), "t#bar{t}+other","F"); leg->AddEntry(hInput[ich].at(3), "t#bar{t}+LF","F"); leg->AddEntry(hInput[ich].at(2), "t#bar{t}+cc","F"); leg->AddEntry(hInput[ich].at(1), "t#bar{t}+bj","F"); leg->AddEntry(hInput[ich].at(0), "t#bar{t}+bb","F"); leg->AddEntry(gRatioFull, "Stat. Unc.","F"); leg->Draw("SAME"); TLatex *titlePr; titlePr = new TLatex(-20.,50.,"35.9 fb^{-1} (13TeV)"); titlePr->SetNDC(); titlePr->SetTextAlign(12); titlePr->SetX(0.78); titlePr->SetY(0.935); titlePr->SetTextFont(42); titlePr->SetTextSize(0.05); titlePr->SetTextSizePixels(24); titlePr->Draw("SAME"); TLatex *title; //title = new TLatex(-20.,50.,"CMS(2016) #sqrt{s} = 13TeV, L = 35.9 fb^{-1}"); title = new TLatex(-20.,50.,"CMS"); title->SetNDC(); title->SetTextAlign(12); title->SetX(0.13); title->SetY(0.84); title->SetTextFont(61); title->SetTextSize(0.06); title->SetTextSizePixels(24); title->Draw("SAME"); TLatex *chtitle; chtitle = new TLatex(-20.,50.,titlechname[ich]+""); chtitle->SetNDC(); chtitle->SetTextAlign(12); chtitle->SetX(0.14); chtitle->SetY(0.74); chtitle->SetTextFont(42); chtitle->SetTextSize(0.05); chtitle->SetTextSizePixels(24); chtitle->Draw("SAME"); pad[2]->cd(); pad[2]->cd()->SetLogy(); TH1D *hstyleLog = (TH1D *)hstyle->Clone(); hstyleLog -> SetMaximum(10.0*hInput[ich].at(12)->GetMaximum()); hstyleLog -> SetMinimum(0.8); hstyleLog -> Draw(); AllMC[ich] -> Draw("HISTSAME"); hData[ich] -> Draw("PSAME"); titlePr->Draw("SAME"); title->Draw("SAME"); chtitle->Draw("SAME"); pad[1]->cd(); RatioFull ->Draw("HIST"); gRatioFull->Draw("e2"); RatioFull ->Draw("HISTSAME"); pad[3]->cd(); RatioFull ->Draw("HIST"); gRatioFull->Draw("e2"); RatioFull ->Draw("HISTSAME"); TString dirfigname_pdf = "CombineResults/Figures_" + InpDir + Plots + FitDir + "/"; // make a dir if it does not exist!! gSystem->mkdir(dirfigname_pdf, kTRUE); cPlots->SaveAs(dirfigname_pdf + "FullHisto_" + dirname[ich] + "_NormLog.pdf"); // ----------------------------------------------------------------------------- // Only Log Plots // ----------------------------------------------------------------------------- TCanvas *cPlotsLog;//histos cPlotsLog = new TCanvas("cPlotsLog"+dirname[ich] ,"Plots"); cPlotsLog->Divide(1,2); TPad *padLog[2]; //Plot Pad padLog[0] = (TPad*)cPlotsLog->GetPad(1); padLog[0]->SetPad(0.01, 0.23, 0.99, 0.99); padLog[0]->SetTopMargin(0.1); padLog[0]->SetRightMargin(0.04); //Ratio Pad padLog[1] = (TPad*)cPlotsLog->GetPad(2);; padLog[1]->SetPad(0.01, 0.02, 0.99, 0.3); gStyle->SetGridWidth(1); gStyle->SetGridColor(14); padLog[1]->SetGridx(); padLog[1]->SetGridy(); padLog[1]->SetTopMargin(0.05); padLog[1]->SetBottomMargin(0.4); padLog[1]->SetRightMargin(0.04); padLog[0]->cd(); padLog[0]->cd()->SetLogy(); hstyleLog -> Draw(); AllMC[ich] -> Draw("HISTSAME"); hData[ich] -> Draw("PSAME"); titlePr->Draw("SAME"); title->Draw("SAME"); chtitle->Draw("SAME"); TLegend *legLog; legLog = new TLegend(0.70,0.60,0.94,0.87); legLog->SetFillColor(0); legLog->SetLineColor(0); legLog->SetLineWidth(0.0); legLog->SetTextFont(62); legLog->SetTextSize(0.03); legLog->SetNColumns(2); legLog->AddEntry(hData[ich], "Data","PL"); legLog->AddEntry(hInput[ich].at(11), "Z+Jets","F"); legLog->AddEntry(hInput[ich].at(10), "VV","F"); legLog->AddEntry(hInput[ich].at(9), "Single t","F"); legLog->AddEntry(hInput[ich].at(8), "QCD","F"); legLog->AddEntry(hInput[ich].at(7), "W+Jets","F"); legLog->AddEntry(hInput[ich].at(6), "t#bar{t}+V","F"); legLog->AddEntry(hInput[ich].at(5), "t#bar{t}+H","F"); legLog->AddEntry(hInput[ich].at(4), "t#bar{t}+other","F"); legLog->AddEntry(hInput[ich].at(3), "t#bar{t}+LF","F"); legLog->AddEntry(hInput[ich].at(2), "t#bar{t}+cc","F"); legLog->AddEntry(hInput[ich].at(1), "t#bar{t}+bj","F"); legLog->AddEntry(hInput[ich].at(0), "t#bar{t}+bb","F"); legLog->AddEntry(gRatioFull, "Stat. Unc.","F"); legLog->Draw("SAME"); padLog[1]->cd(); RatioFull ->Draw("HIST"); gRatioFull->Draw("e2"); RatioFull ->Draw("HISTSAME"); cPlotsLog->SaveAs(dirfigname_pdf + "FullHisto_" + dirname[ich] + "_OnlyLog.pdf"); // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // Plots by Regions // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- int ireg = 0; for(int ican=0;ican<5;ican++){ TString CanNum; CanNum.Form("%i",ican); TCanvas *cPlots_reg;//histos cPlots_reg = new TCanvas("cPlots_reg" + CanNum + dirname[ich] ,"Plots By regions"); cPlots_reg->Divide(2,2); for(int icr=1;icr<=4;icr++){ //cPlots_reg->cd(icr); TPad *glpad_reg = (TPad*)cPlots_reg->cd(icr); glpad_reg->Divide(2,1); TPad *pad_reg[2]; //Plot Pad pad_reg[0] = (TPad*)glpad_reg->GetPad(1); pad_reg[0]->SetPad(0.01, 0.23, 0.99, 0.99); pad_reg[0]->SetTopMargin(0.1); pad_reg[0]->SetRightMargin(0.04); //Ratio Pad pad_reg[1] = (TPad*)glpad_reg->GetPad(2); pad_reg[1]->SetPad(0.01, 0.02, 0.99, 0.3); gStyle->SetGridWidth(1); gStyle->SetGridColor(14); pad_reg[1]->SetGridx(); pad_reg[1]->SetGridy(); pad_reg[1]->SetTopMargin(0.05); pad_reg[1]->SetBottomMargin(0.4); pad_reg[1]->SetRightMargin(0.04); pad_reg[0]->cd(); pad_reg[0]->SetLogy(); TH1D *hstyle_reg = (TH1D*)AllMC_reg[ich][ireg]->GetHistogram(); hstyle_reg -> Reset(); hstyle_reg -> SetMaximum(10.0*hData_reg[ich][ireg]->GetMaximum()); hstyle_reg -> SetMinimum(0.7); hstyle_reg -> GetYaxis()->SetTitleOffset(0.9); hstyle_reg -> GetYaxis()->SetTitleSize(0.05); hstyle_reg -> GetYaxis()->SetLabelSize(0.05); hstyle_reg -> GetYaxis()->SetTitle("Events"); pad_reg[0]->cd(); hstyle_reg->Draw(); AllMC_reg[ich][ireg] -> Draw("HISTSAME"); hData_reg[ich][ireg] -> Draw("E1SAME"); titlePr->Draw("SAME"); title->Draw("SAME"); chtitle->Draw("SAME"); TH1D *RatioFull_reg = HistoRatio (hData_reg[ich][ireg] , (TH1D*) AllMC_reg[ich][ireg]->GetStack()->Last()); TGraphErrors *gRatioFull_reg = new TGraphErrors(RatioFull_reg); gRatioFull_reg->SetFillStyle(1001); gRatioFull_reg->SetFillColor(chatch); gRatioFull_reg->SetName("gRatioFull"); pad_reg[1]->cd(); RatioFull_reg->GetYaxis()->SetTitleOffset(0.25); RatioFull_reg->Draw("HIST"); gRatioFull_reg->Draw("e2"); RatioFull_reg->Draw("HISTSAME"); ireg++; } // for(ireg) cPlots_reg->SaveAs(dirfigname_pdf + "RegionHisto_" + CanNum + "_" + dirname[ich] + "_NormLog.pdf"); } // for(ican) TCanvas *cPlotsI; cPlotsI = new TCanvas("cPlotsI"+dirname[ich] ,"Plots"); cPlotsI->Divide(1,2); TPad *padI[4]; //Plot Pad padI[0] = (TPad*)cPlotsI->GetPad(1); padI[0]->SetPad(0.01, 0.23, 0.99, 0.99); padI[0]->SetTopMargin(0.1); padI[0]->SetRightMargin(0.04); //Ratio Pad padI[1] = (TPad*)cPlotsI->GetPad(2); padI[1]->SetPad(0.01, 0.02, 0.99, 0.3); gStyle->SetGridWidth(1); gStyle->SetGridColor(14); padI[1]->SetGridx(); padI[1]->SetGridy(); padI[1]->SetTopMargin(0.05); padI[1]->SetBottomMargin(0.4); padI[1]->SetRightMargin(0.04); TCanvas *cPlotsII; cPlotsII = new TCanvas("cPlotsII"+dirname[ich] ,"Plots"); cPlotsII->Divide(1,2); //Plot Pad padI[2] = (TPad*)cPlotsII->GetPad(1); padI[2]->SetPad(0.01, 0.23, 0.99, 0.99); padI[2]->SetTopMargin(0.1); padI[2]->SetRightMargin(0.04); //Ratio Pad padI[3] = (TPad*)cPlotsII->GetPad(2); padI[3]->SetPad(0.01, 0.02, 0.99, 0.3); gStyle->SetGridWidth(1); gStyle->SetGridColor(14); padI[3]->SetGridx(); padI[3]->SetGridy(); padI[3]->SetTopMargin(0.05); padI[3]->SetBottomMargin(0.4); padI[3]->SetRightMargin(0.04); TH1D *hstyleI = new TH1D ("hstyleI","", GlobalCSVJet_Data[1]->GetNbinsX(), GlobalCSVJet_Data[1]->GetBinLowEdge (1), GlobalCSVJet_Data[1]->GetBinLowEdge (GlobalCSVJet_Data[1]->GetNbinsX()+1)); hstyleI -> SetMaximum(1.1*GlobalCSVJet_Data[1]->GetMaximum()); hstyleI -> GetYaxis()->SetTitleOffset(0.8); hstyleI -> GetYaxis()->SetTitleSize(0.05); hstyleI -> GetYaxis()->SetLabelSize(0.05); hstyleI -> GetYaxis()->SetTitle("Events"); GlobalCSVJet_Data[0] -> SetMarkerStyle(20); GlobalCSVJet_Data[0] -> SetMarkerSize(0.4); GlobalCSVJet_Data[0] -> SetLineWidth(1); GlobalCSVJet_Data[0] -> SetTitle(""); padI[0]->cd(); padI[0]->cd()->SetLogy(); hstyleI -> SetMaximum(100.0*GlobalCSVJet_Data[0]->GetMaximum()); hstyleI -> SetMinimum(0.7); hstyleI -> Draw(); AllMC_CSV1[ich] -> Draw("HISTSAME"); GlobalCSVJet_Data[0] -> SetMarkerStyle(20); GlobalCSVJet_Data[0] -> SetMarkerSize(0.6); GlobalCSVJet_Data[0] -> SetLineWidth(1); GlobalCSVJet_Data[0] -> SetTitle(""); GlobalCSVJet_Data[0] -> Draw("SAME"); titlePr->Draw("SAME"); title->Draw("SAME"); chtitle->Draw("SAME"); TLegend *legI; legI = new TLegend(0.70,0.64,0.93,0.87); legI->SetFillColor(0); legI->SetLineColor(0); legI->SetLineWidth(0.0); legI->SetTextFont(62); legI->SetTextSize(0.03); legI->SetNColumns(2); legI->AddEntry(hData[ich], "Data","PL"); legI->AddEntry(hInput[ich].at(11), "Z+Jets","F"); legI->AddEntry(hInput[ich].at(10), "VV","F"); legI->AddEntry(hInput[ich].at(9), "Single t","F"); legI->AddEntry(hInput[ich].at(8), "QCD","F"); legI->AddEntry(hInput[ich].at(7), "W+Jets","F"); legI->AddEntry(hInput[ich].at(6), "t#bar{t}+V","F"); legI->AddEntry(hInput[ich].at(5), "t#bar{t}+H","F"); legI->AddEntry(hInput[ich].at(4), "t#bar{t}+other","F"); legI->AddEntry(hInput[ich].at(3), "t#bar{t}+LF","F"); legI->AddEntry(hInput[ich].at(2), "t#bar{t}+cc","F"); legI->AddEntry(hInput[ich].at(1), "t#bar{t}+bj","F"); legI->AddEntry(hInput[ich].at(0), "t#bar{t}+bb","F"); legI->AddEntry(gRatioFull, "Stat. Unc.","F"); legI->Draw("SAME"); TH1D *RatioFullJet1 = HistoRatio (GlobalCSVJet_Data[0] , (TH1D*) AllMC_CSV1[ich]->GetStack()->Last()); TGraphErrors *gRatioFullJet1 = new TGraphErrors(RatioFullJet1); gRatioFullJet1->SetFillStyle(1001); gRatioFullJet1->SetFillColor(chatch); gRatioFullJet1->SetName("gRatioFullJet2"); padI[1]->cd(); RatioFullJet1 ->GetYaxis()->SetTitleOffset(0.25); RatioFullJet1 ->GetXaxis()->SetTitle("CSVv2"); RatioFullJet1 ->Draw("HIST"); gRatioFullJet1->Draw("e2"); RatioFullJet1 ->Draw("HISTSAME"); padI[2]->cd(); padI[2]->cd()->SetLogy(); // No Log TH1D *hstyleII = (TH1D *)hstyleI -> Clone("StyleII"); hstyleII -> SetMaximum(100.0*GlobalCSVJet_Data[1]->GetMaximum()); hstyleII -> SetMinimum(0.7); hstyleII -> Draw(); AllMC_CSV2[ich] -> Draw("HISTSAME"); GlobalCSVJet_Data[1] -> SetMarkerStyle(20); GlobalCSVJet_Data[1] -> SetMarkerSize(0.5); GlobalCSVJet_Data[1] -> SetLineWidth(1); GlobalCSVJet_Data[1] -> SetTitle(""); GlobalCSVJet_Data[1] -> Draw("SAME"); titlePr->Draw("SAME"); title->Draw("SAME"); chtitle->Draw("SAME"); legI->Draw("SAME"); TH1D *RatioFullJet2 = HistoRatio (GlobalCSVJet_Data[1] , (TH1D*) AllMC_CSV2[ich]->GetStack()->Last()); TGraphErrors *gRatioFullJet2 = new TGraphErrors(RatioFullJet2); gRatioFullJet2->SetFillStyle(1001); gRatioFullJet2->SetFillColor(chatch); gRatioFullJet2->SetName("gRatioFullJet2"); padI[3]->cd(); RatioFullJet2 ->GetYaxis()->SetTitleOffset(0.25); RatioFullJet2 ->GetXaxis()->SetTitle("CSVv2"); RatioFullJet2 ->Draw("HIST"); gRatioFullJet2->Draw("e2"); RatioFullJet2 ->Draw("HISTSAME"); cPlotsI ->SaveAs(dirfigname_pdf + "CSVHistosJet1_" + dirname[ich] + "_Log.pdf"); cPlotsII->SaveAs(dirfigname_pdf + "CSVHistosJet2_" + dirname[ich] + "_Log.pdf"); // ttbb Shape }// for(ich) }
void gemTurnOns(int label_eff = GEM_EFF98) { // gROOT->ProcessLine(".L effFunctions.C"); TCut ok_eta = "TMath::Abs(eta)>1.64 && TMath::Abs(eta)<2.14"; const int N = 5; int pt_lbl[N] = {DPHI_PT10, DPHI_PT15, DPHI_PT20, DPHI_PT30, DPHI_PT40}; TString pt[N] = {"pt10","pt15","pt20","pt30","pt40"}; int marker_styles[5] = {24, 28, 22 , 21, 20}; TCanvas* gEff = new TCanvas("gEff","gEff",700,500); gEff->SetGridx(1); gEff->SetGridy(1); TCanvas* gEff_odd = new TCanvas("gEff_odd","gEff_odd",700,500); gEff_odd->SetGridx(1); gEff_odd->SetGridy(1); TCanvas* gEff_even = new TCanvas("gEff_even","gEff_even",700,500); gEff_even->SetGridx(1); gEff_even->SetGridy(1); TTree *t = getTree(filesDir + "gem_csc_eff_pt2pt50_pad4.root"); TH1F *ho[N], *he[N]; for (int n=0; n<N; ++n) { if (n==1) continue; TString opt = "p"; if (n>0) opt = "same p"; setDPhi(n, label_eff); gEff->cd(); ho[n] = draw_eff(gt, "Eff. for track with LCT to have matched GEM pad;p_{T}, GeV/c;Eff.", Form("h_odd%d",n), "(50,0.,50.)", "pt", ok_lct1 && ok_eta && ok_pad1, ok_dphi1, opt, kRed, marker_styles[n]); he[n] = draw_eff(gt, "Eff. for track with LCT to have matched GEM pad;p_{T}, GeV/c;Eff.", Form("h_evn%d",n), "(50,0.,50.)", "pt", ok_lct2 && ok_eta && ok_pad2, ok_dphi2, "same p", kBlue, marker_styles[n]); gEff_odd->cd(); ho[n]->Draw(opt); gEff_even->cd(); he[n]->Draw(opt); } TString pts[N] = {"10","15","20","30","40"}; TString efs[5] = {"95", "98", "99"}; TString leg_header = " #Delta#phi(LCT,GEM) is " + efs[label_eff] + "% efficient for"; gEff->cd(); TLegend *leg = new TLegend(0.50,0.17,.99,0.57, NULL, "brNDC"); leg->SetNColumns(2); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetHeader(leg_header); leg->AddEntry(ho[0], "odd chambers", ""); leg->AddEntry(he[0], "even chambers", ""); leg->AddEntry(ho[0], "at pt", ""); leg->AddEntry(he[0], "at pt", ""); for (int n=0; n<N; ++n) { if (n==1) continue; leg->AddEntry(ho[n], pts[n], "p"); leg->AddEntry(he[n], pts[n], "p"); } leg->Draw(); gEff->Print(plotDir + "gem_pad_eff_for_LCT_gemEff" + efs[label_eff] +"" + ext); gEff_odd->cd(); TLegend *leg = new TLegend(0.50,0.17,.99,0.57, NULL, "brNDC"); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetHeader(leg_header); leg->AddEntry(ho[0], "odd chambers at pt", ""); for (int n=0; n<N; ++n) { if (n==1) continue; leg->AddEntry(ho[n], pts[n], "p"); } leg->Draw(); gEff_odd->Print(plotDir + "gem_pad_eff_for_LCT_gemEff" + efs[label_eff] +"_odd" + ext); gEff_even->cd(); TLegend *leg = new TLegend(0.50,0.17,.99,0.57, NULL, "brNDC"); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetHeader(leg_header); leg->AddEntry(ho[0], "even chambers at pt", ""); for (int n=0; n<N; ++n) { if (n==1) continue; leg->AddEntry(he[n], pts[n], "p"); } leg->Draw(); gEff_even->Print(plotDir + "gem_pad_eff_for_LCT_gemEff" + efs[label_eff] +"_even" + ext); }
void create_plot( TH1D * hw, TH1D * emu, int runNo, const char * dataset, const char * xLabel, const char * exportPath, int rebin = 1, int energy = 13, long rangeLow = 0, long rangeHigh = 0 ) { // define latex container to hold the title TLatex n; n.SetNDC(); n.SetTextFont(52); n.SetTextSize(0.05); // create canvas that will hold each plot TCanvas* canv = new TCanvas("canv","canvas"); // top pad (comparison) TPad* pad1 = new TPad("mainPad","mainPad",0,0.3,1,1); // bottom (resuduals) pad TPad* pad2 = new TPad("ratioPad","ratioPad",0,0.05,1,0.3); // pad to contain trendline for hw-emu ratio of 1 TPad* overlayPad = new TPad("pInv","pInv", 0,0.05,1,0.3); overlayPad->SetFillStyle(0); // create legend that will describe appearance of data points TLegend * leg = new TLegend(0.65,0.85,0.91,1); leg->SetFillColor(0); leg->SetNColumns(2); leg->AddEntry(hw,"Hardware", "p");//"l"); leg->AddEntry(emu,"Emulator", "l"); leg->SetBorderSize(0); leg->SetFillStyle(0); // optionally reduce segmentation in x to improve visibility of some plots hw->Rebin(rebin); emu->Rebin(rebin); hw->SetMarkerStyle(21); hw->SetMarkerColor(1); hw->SetMarkerSize(0.5); emu->SetLineColor(kRed); hw->GetYaxis()->SetTitle("Number of candidates"); hw->GetYaxis()->SetTitleSize(0.062); hw->GetYaxis()->SetTitleOffset(0.80); hw->GetYaxis()->SetLabelSize(0.045); hw->GetYaxis()->SetTickSize(0.01); hw->GetXaxis()->SetLabelSize(0); emu->GetXaxis()->SetLabelSize(0); pad1->SetBottomMargin(0.02); pad1->SetGridx(); //pad1->SetLogy(); pad1->Draw(); pad1->cd(); hw->SetStats(0); emu->SetStats(0); if (emu->GetMaximum() > hw->GetMaximum()) { hw->SetMaximum(1.1*emu->GetMaximum()); } if (rangeLow != 0 || rangeHigh != 0) { emu->GetXaxis()->SetRangeUser(rangeLow, rangeHigh); hw->GetXaxis()->SetRangeUser(rangeLow, rangeHigh); } hw->DrawCopy("p"); emu->Draw("same"); if (rangeLow != 0 || rangeHigh != 0) { emu->GetXaxis()->SetRangeUser(rangeLow, rangeHigh); hw->GetXaxis()->SetRangeUser(rangeLow, rangeHigh); } leg->Draw(); stringstream caption; caption << "#bf{CMS Preliminary}: " << dataset; /* caption << "#bf{CMS Preliminary, 2016 Data}:" << ", #sqrt{s} = " << energy << " TeV "; */ n.DrawLatex(0.1, 0.915, caption.str().c_str()); canv->cd(); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.39); pad2->Draw(); pad2->cd(); pad2->SetGridy(); pad2->SetGridx(); hw->Divide(emu); hw->GetYaxis()->SetTitle("HW/EM"); hw->GetYaxis()->CenterTitle(); stringstream labelText; labelText << "Level-1 Trigger " << xLabel; hw->GetYaxis()->CenterTitle(); hw->GetXaxis()->SetTitle(labelText.str().c_str()); hw->GetYaxis()->SetTitleSize(0.15); hw->GetYaxis()->SetTitleOffset(0.3); hw->GetYaxis()->SetLabelSize(0.12); hw->GetYaxis()->SetLabelOffset(0.006); hw->GetYaxis()->SetNdivisions(40407); hw->GetXaxis()->SetTitleSize(0.15); hw->GetXaxis()->SetTitleOffset(1.1); hw->GetXaxis()->SetLabelOffset(0.04); hw->GetXaxis()->SetLabelSize(0.12); hw->SetMinimum(0.76); hw->SetMaximum(1.24); hw->Draw("p"); canv->cd(); overlayPad->Draw(); overlayPad->cd(); if (rangeLow != 0 || rangeHigh != 0) { hw->GetXaxis()->SetRangeUser(rangeLow, rangeHigh); } TLine* unity = new TLine(0.1,0.695,0.9,0.695); unity->SetLineColor(kBlue); unity->Draw(); stringstream pathStream; pathStream << "compHwEmu/" << exportPath; canv->SaveAs(pathStream.str().c_str()); delete canv; }
void misalignmentDependence(TCanvas *c1old, Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar, TF1 *function,Int_t parameter,TString parametername = "",TString functionname = "", Bool_t resolution = false, TString saveas = "") { cout << saveas << endl; if (c1old == 0) return; c1old = (TCanvas*)c1old->Clone("c1old"); if (misalignment == "" || yvar == "") return; Bool_t drawfits = (parameter < 0); if (parameter < 0) parameter = -parameter - 1; //-1 --> 0, -2 --> 1, -3 --> 2, ... TString yaxislabel = nPart(1,parametername); TString parameterunits = nPart(2,parametername); if (parameterunits != "") yaxislabel.Append(" (").Append(parameterunits).Append(")"); TList *list = c1old->GetListOfPrimitives(); int n = list->GetEntries() - 2 - (xvar == ""); setTDRStyle(); gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetFitFormat("5.4g"); gStyle->SetFuncColor(2); gStyle->SetFuncStyle(1); gStyle->SetFuncWidth(1); if (!drawfits) { gStyle->SetCanvasDefW(678); gStyle->SetPadRightMargin(0.115); } TH1 **p = new TH1*[n]; TF1 **f = new TF1*[n]; Bool_t used[n]; for (Int_t i = 0; i < n; i++) { stringstream s0; s0 << "p" << i; TString pname = s0.str(); p[i] = (TH1*)list->/*At(i+1+(xvar == ""))*/FindObject(pname); used[i] = (p[i] != 0); if (used[i]) p[i]->SetDirectory(0); if (xvar == "" && function == 0) continue; stringstream s; s << function->GetName() << i; TString newname = s.str(); f[i] = (TF1*)function->Clone(newname); stufftodelete->Add(f[i]); } Double_t *result = new Double_t[nFiles]; Double_t *error = new Double_t[nFiles]; if (xvar == "" && function == 0) { yaxislabel = axislabel(yvar,'y',resolution); for (Int_t i = 0; i < nFiles; i++) { if (!used[i]) continue; if (!resolution) { result[i] = p[i]->GetMean(); error[i] = p[i]->GetMeanError(); } else { result[i] = p[i]->GetRMS(); error[i] = p[i]->GetRMSError(); } cout << result[i] << " +/- " << error[i] << endl; } } else { for (int i = 0; i < n; i++) { if (!used[i]) continue; f[i]->SetLineColor(colors[i]); f[i]->SetLineStyle(styles[i]); f[i]->SetLineWidth(1); p[i]->SetMarkerColor(colors[i]); p[i]->SetMarkerStyle(20+i); p[i]->SetLineColor(colors[i]); p[i]->SetLineStyle(styles[i]); p[i]->Fit(f[i],"IM"); error[i] = f[i]->GetParError (parameter); if (function->GetName() == TString("sine")) { if (f[i]->GetParameter(0) < 0) { f[i]->SetParameter(0,-f[i]->GetParameter(0)); f[i]->SetParameter(2,f[i]->GetParameter(2)+pi); } while(f[i]->GetParameter(2) >= 2*pi) f[i]->SetParameter(2,f[i]->GetParameter(2)-2*pi); while(f[i]->GetParameter(2) < 0) f[i]->SetParameter(2,f[i]->GetParameter(2)+2*pi); } result[i] = f[i]->GetParameter(parameter); } } TCanvas *c1 = TCanvas::MakeDefCanvas(); if (drawfits && !(xvar == "" && function == 0) && yvar != "") { TString legendtitle = "["; legendtitle.Append(functionname); legendtitle.Append("]"); TLegend *legend = new TLegend(.7,.7,.9,.9,legendtitle,"br"); stufftodelete->Add(legend); TString drawoption = ""; TH1 *maxp = (TH1*)list->FindObject("maxp"); if (maxp != 0) { maxp->Draw(); drawoption = "same"; } for (int i = 0; i < n; i++) { if (!used[i]) continue; p[i]->Draw(drawoption); f[i]->Draw("same"); drawoption = "same"; stringstream s; s.precision(3); s << nPart(1,parametername) << " = " << result[i] << " #pm " << error[i]; if (parameterunits != "") s << " " << parameterunits; TString str = s.str(); legend->AddEntry(p[i],names[i],"pl"); legend->AddEntry(f[i],str,"l"); } c1->Update(); Double_t x1min = .98*gPad->GetUxmin() + .02*gPad->GetUxmax(); Double_t x2max = .02*gPad->GetUxmin() + .98*gPad->GetUxmax(); Double_t y1min = .98*gPad->GetUymin() + .02*gPad->GetUymax(); Double_t y2max = .02*gPad->GetUymin() + .98*gPad->GetUymax(); Double_t width = .4*(x2max-x1min); Double_t height = (1./20)*legend->GetListOfPrimitives()->GetEntries()*(y2max-y1min); width *= 2; height /= 2; legend->SetNColumns(2); Double_t newy2max = placeLegend(legend,width,height,x1min,y1min,x2max,y2max); p[0]->GetYaxis()->SetRangeUser(gPad->GetUymin(),(newy2max-.02*gPad->GetUymin())/.98); if (maxp != 0) maxp->GetYaxis()->SetRangeUser(gPad->GetUymin(),(newy2max-.02*gPad->GetUymin())/.98); legend->SetFillStyle(0); legend->Draw(); } else { if (values == 0) return; Bool_t phasesmatter = false; if (misalignment == "elliptical" || misalignment == "sagitta" || misalignment == "skew") { if (phases == 0) { cout << "This misalignment has a phase, but you didn't supply the phases!" << endl << "Can't produce plots depending on the misalignment value." << endl; return; } int firstnonzero = -1; for (Int_t i = 0; i < nFiles; i++) { if (values[i] == 0) continue; //if the amplitude is 0 the phase is arbitrary if (firstnonzero == -1) firstnonzero = i; if (phases[i] != phases[firstnonzero]) phasesmatter = true; } } if (!phasesmatter) { TGraphErrors *g = new TGraphErrors(nFiles,values,result,(Double_t*)0,error); g->SetName(""); stufftodelete->Add(g); TString xaxislabel = "#epsilon_{"; xaxislabel.Append(misalignment); xaxislabel.Append("}"); g->GetXaxis()->SetTitle(xaxislabel); if (xvar != "") { yaxislabel.Append(" ["); yaxislabel.Append(functionname); yaxislabel.Append("]"); } g->GetYaxis()->SetTitle(yaxislabel); g->SetMarkerColor(colors[0]); g->SetMarkerStyle(20); g->Draw("AP"); Double_t yaxismax = g->GetYaxis()->GetXmax(); Double_t yaxismin = g->GetYaxis()->GetXmin(); if (yaxismin > 0) { yaxismax += yaxismin; yaxismin = 0; } g->GetYaxis()->SetRangeUser(yaxismin,yaxismax); g->Draw("AP"); } else { double *xvalues = new double[nFiles]; double *yvalues = new double[nFiles]; //these are not physically x and y (except in the case of skew) for (int i = 0; i < nFiles; i++) { xvalues[i] = values[i] * cos(phases[i]); yvalues[i] = values[i] * sin(phases[i]); } TGraph2DErrors *g = new TGraph2DErrors(nFiles,xvalues,yvalues,result,(Double_t*)0,(Double_t*)0,error); g->SetName(""); stufftodelete->Add(g); delete[] xvalues; //A TGraph2DErrors has its own copy of xvalues and yvalues, so it's ok to delete these copies. delete[] yvalues; TString xaxislabel = "#epsilon_{"; xaxislabel.Append(misalignment); xaxislabel.Append("}cos(#delta)"); TString realyaxislabel = xaxislabel; realyaxislabel.ReplaceAll("cos(#delta)","sin(#delta)"); g->GetXaxis()->SetTitle(xaxislabel); g->GetYaxis()->SetTitle(realyaxislabel); TString zaxislabel = /*"fake"*/yaxislabel; //yaxislabel is defined earlier if (xvar != "") { zaxislabel.Append(" ["); zaxislabel.Append(functionname); zaxislabel.Append("]"); } g->GetZaxis()->SetTitle(zaxislabel); g->SetMarkerStyle(20); g->Draw("pcolerr"); } } if (saveas != "") { saveplot(c1,saveas); delete[] p; delete[] f; delete[] result; delete[] error; delete c1old; } }
void plotOFVZsub(TString var, int nb, float min, float max, bool norm, TString mycut, int njets, TString fs) { gROOT->Reset(); gStyle->SetOptStat(0); TString dir = "/smurf/cerati/skims/Run2012_Summer12_SmurfV9_53X/test/skim_dy/"; TChain *ph = new TChain("tree"); ph->Add(dir+"./dyll.root"); TFile *_da = TFile::Open(dir+"./data.root"); TTree* da = (TTree*) _da->Get("tree"); TFile *_zz = TFile::Open(dir+"./zz.root"); TTree* zz = (TTree*) _zz->Get("tree"); TFile *_wz = TFile::Open(dir+"./wz.root"); TTree* wz = (TTree*) _wz->Get("tree"); TFile *_hw = TFile::Open(dir+"./hww125.root"); TTree* hw = (TTree*) _hw->Get("tree"); TH1F* h_zz = new TH1F("h_zz","h_zz",nb,min,max); TH1F* h_wz = new TH1F("h_wz","h_wz",nb,min,max); TH1F* h_dy = new TH1F("h_dy","h_dy",nb,min,max); TH1F* h_da = new TH1F("h_da","h_da",nb,min,max); TH1F* h_of = new TH1F("h_of","h_of",nb,min,max); TH1F* h_hw = new TH1F("h_hw","h_hw",nb,min,max); h_dy->SetFillColor(kGreen); h_of->SetFillColor(kRed); h_zz->SetFillColor(kBlue); h_wz->SetFillColor(kBlue); h_da->SetMarkerStyle(20); h_da->SetLineWidth(2); h_hw->SetLineColor(kCyan); h_hw->SetLineWidth(2); float lumi = 11.9; float lumicorr = 1.04; float dysf = 1.0; float dyer = 1.0; if (njets==0) dysf = 10.75; if (njets==1) dysf = 7.68; if (njets==0) dyer = 0.11; if (njets==1) dyer = 0.11; TString Met20 = Form("((cuts & 4719111)==4719111)&&njets==%i&&lep1.pt()>20.&&lep2.pt()>10.&&(dstype!=0 || (cuts & 1073741824)==1073741824) && met>20 && dilep.mass()>12. && min(pmet,pTrackMet)>20. && mt>80. && dilep.pt()>45.",njets); TString cut = Met20; TString minmet = " && min(pmet,pTrackMet)>45. && (jet1.pt()<15 || dPhiDiLepJet1<165.*TMath::Pi()/180. )"; TString dymva = " && ((njets==0 && dymva>0.88) || (njets==1 && dymva>0.84))"; if (mycut.Contains("Zp")) cut+="&& abs(dilep.mass()-91)<7.5"; if (mycut.Contains("oZ")) cut+="&& abs(dilep.mass()-91)>15"; if (mycut.Contains("ptll45")) { cut+="&& dilep.pt()>45."; Met20+="&& dilep.pt()>45."; } if (mycut.Contains("DyMva")) cut+=dymva; if (mycut.Contains("MetGt45")) cut+=minmet; if (mycut.Contains("MetLt45")) cut+="&& min(pmet,pTrackMet)<45."; if (mycut.Contains("mll70")) cut+="&& dilep.mass()<70."; if (mycut.Contains("metsig25")) cut+="&& met/sqrt(sumet)<2.5"; if (mycut.Contains("Mva05")) cut+="&& dymva>0.5"; if (mycut.Contains("Mva02")) cut+="&& dymva>0.2"; if (mycut.Contains("HiPU")) cut+="&& nvtx>=10"; if (mycut.Contains("LoPU")) cut+="&& nvtx<10"; if (mycut.Contains("HWW125")) { cut+="&& lep1.pt()>23 && lep2.pt()>10 && dPhi<100.*TMath::Pi()/180. && mt>80 && mt<123"+dymva; if (njets==0) dysf = 8.40; if (njets==1) dysf = 1.0; if (njets==0) dyer = 2.87/8.40; if (njets==1) dyer = 1.0; } if (mycut.Contains("HWW145")) { cut+="&& lep1.pt()>25 && lep2.pt()>15 && dPhi<90.*TMath::Pi()/180. && mt>80 && mt<130"+dymva; if (njets==0) dysf = 7.42; if (njets==1) dysf = 3.1; if (njets==0) dyer = 1.71/7.42; if (njets==1) dyer = 0.5; } if (mycut.Contains("HWW150")) { cut+="&& lep1.pt()>27 && lep2.pt()>25 && dPhi<90.*TMath::Pi()/180. && mt>80 && mt<150"+dymva; if (njets==0) dysf = 15.78; if (njets==1) dysf = 2.8; if (njets==0) dyer = 4.20/15.78; if (njets==1) dyer = 0.5; } if (mycut.Contains("HWW160")) { cut+="&& lep1.pt()>30 && lep2.pt()>25 && dPhi<60.*TMath::Pi()/180. && mt>90 && mt<160"+dymva; if (njets==0) dysf = 11.85; if (njets==1) dysf = 3.3; if (njets==0) dyer = 4.65/11.85; if (njets==1) dyer = 0.4; } if (mycut.Contains("HWW170")) { cut+="&& lep1.pt()>34 && lep2.pt()>25 && dPhi<60.*TMath::Pi()/180. && mt>110 && mt<170"+dymva; if (njets==0) dysf = 5.50; if (njets==1) dysf = 3.8; if (njets==0) dyer = 3.62/5.50; if (njets==1) dyer = 0.4; } if (mycut.Contains("HWW180")) { cut+="&& lep1.pt()>36 && lep2.pt()>25 && dPhi<70.*TMath::Pi()/180. && mt>120 && mt<180"+dymva; if (njets==0) dysf = 1.0; if (njets==1) dysf = 5.0; if (njets==0) dyer = 1.0; if (njets==1) dyer = 0.4; } if (mycut.Contains("HWW190")) { cut+="&& lep1.pt()>38 && lep2.pt()>25 && dPhi<90.*TMath::Pi()/180. && mt>120 && mt<190"+dymva; if (njets==0) dysf = 11.78; if (njets==1) dysf = 5.2; if (njets==0) dyer = 4.12/11.78; if (njets==1) dyer = 0.4; } if (mycut.Contains("HWW200")) { cut+="&& lep1.pt()>40 && lep2.pt()>25 && dPhi<100.*TMath::Pi()/180. && mt>120 && mt<200"+dymva; if (njets==0) dysf = 10.18; if (njets==1) dysf = 4.9; if (njets==0) dyer = 3.10/10.18; if (njets==1) dyer = 0.4; } TString sf = "(type==0 || type==3)"; TString of = "(type==1 || type==2)"; if (fs=="mm") { sf = "type==0"; of = "type==1"; } else if (fs=="ee") { sf = "type==3"; of = "type==2"; } TString cutsf = "("+cut+"&&"+sf+")"; TString cutof = "("+cut+"&&"+of+")"; TString cutmc = "scale1fb*sfWeightPU*sfWeightTrig*sfWeightEff*"+cutsf; cout << cutmc << endl; TCanvas c1; //c1.SetLogy(); zz->Draw(var+">>h_zz",cutmc); wz->Draw(var+">>h_wz",cutmc); ph->Draw(var+">>h_dy",cutmc); da->Draw(var+">>h_da",cutsf); da->Draw(var+">>h_of",cutof); hw->Draw(var+">>h_hw","scale1fb*sfWeightPU*sfWeightTrig*sfWeightEff*("+Met20+"&&"+sf+")"); cout << h_dy->GetEntries() << endl; //add h_wz->Scale(lumi); h_zz->Scale(lumi); h_dy->Scale(lumi*dysf); h_of->Scale(lumicorr); h_hw->Scale(lumi); THStack hs("hs","stack"); hs.Add(h_of); hs.Add(h_zz); hs.Add(h_wz); hs.Add(h_dy); TH1F* herr = new TH1F("herr","herr",nb,min,max); for (int bin=1;bin<max+1;bin++) { herr->SetBinContent(bin, ((TH1*)(hs.GetStack()->Last()))->GetBinContent(bin) ); herr->SetBinError(bin,sqrt( pow(0.15*h_wz->GetBinContent(bin),2) + pow(0.15*h_wz->GetBinContent(bin),2) + h_of->GetBinContent(bin) + dyer*h_dy->GetBinContent(bin) ) ); } TGraphErrors* gerr = new TGraphErrors(herr); gerr->SetFillColor(kBlack); gerr->SetFillStyle(3244); var.ReplaceAll(".",""); var.ReplaceAll("(",""); var.ReplaceAll(")",""); h_da->GetYaxis()->SetRangeUser(0.05,1.2*TMath::Max(h_da->GetBinContent(h_da->GetMaximumBin()), ((TH1*)(hs.GetStack()->Last()))->GetBinContent(((TH1*)(hs.GetStack()->Last()))->GetMaximumBin()) ));//3* h_da->GetXaxis()->SetTitle(var); h_da->SetTitle(""); if (!norm) { h_da->Draw("PE"); hs.Draw("same"); h_da->Draw("PE,same"); //h_hw->Draw("same"); gerr->Draw("2"); } else { h_da->Sumw2(); h_da->DrawNormalized("PE"); hs.DrawNormalized("same"); //h_hw->DrawNormalized("same"); } TLegend* leg = new TLegend(0.1,0.91,0.9,0.96); /*if (var.Contains("dPhi")) { delete leg; leg = new TLegend(0.55,0.11,0.88,0.31); }*/ leg->SetFillColor(kWhite); leg->SetNColumns(5); leg->SetLineWidth(0); leg->SetLineColor(kWhite); leg->SetShadowColor(kWhite); leg->AddEntry(h_da,"SF data","p"); leg->AddEntry(h_dy,Form("%2.1f x DY MC",dysf),"f"); leg->AddEntry(h_of,"OF data","f"); leg->AddEntry(h_wz,"VZ MC","f"); //leg->AddEntry(h_hw,"HWW120","l"); leg->Draw(); c1.RedrawAxis(); if (var.Contains("/")) var.ReplaceAll("/",""); var = var+Form("_%ij",njets); gSystem->Exec("mkdir -p "+mycut+Form("_%ij_",njets)+fs); if (!norm) c1.SaveAs(mycut+Form("_%ij_",njets)+fs+"/"+var+".png"); else c1.SaveAs(mycut+Form("_%ij_",njets)+fs+"/"+var+"_norm.png"); }
void nMuons(double pt1_IN, double pt2_IN, double MET_IN) { TCanvas *canvasGG = new TCanvas("canvasGG","",500,500); 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 *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ"); TFile *sig6 = 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_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"); TCut mggmax = "mgg<180"; TCut mggmin = "mgg>100"; 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 pt1min = Form("pt1>%lf",pt1_IN); TCut pt2min = Form("pt2>%lf",pt2_IN); TCut METmin = Form("t1pfmet>%lf",MET_IN); tree_sig1->Draw("(nMuons)>>h1(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("(nMuons)>>h2(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("(nMuons)>>h3(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("(nMuons)>>h4(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("(nMuons)>>h5(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); tree_sig6->Draw("(nMuons)>>h6(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6"); tree_sig7->Draw("(nMuons)>>h7(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7"); tree_bkg1->Draw("(nMuons)>>hbkg1(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("(nMuons)>>hbkg2(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("(nMuons)>>hbkg3(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto && genmatch)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("(nMuons)>>hbkg4(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4"); tree_bkg5->Draw("(nMuons)>>hbkg5(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto && genmatch)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("(nMuons)>>hbkg6(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6"); tree_bkg7->Draw("(nMuons)>>hbkg7(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7"); tree_bkg8->Draw("(nMuons)>>hbkg8(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8"); tree_bkg9->Draw("(nMuons)>>hbkg9(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9"); tree_bkg10->Draw("(nMuons)>>hbkg10(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10"); tree_bkg11->Draw("(nMuons)>>hbkg11(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11"); tree_bkg12->Draw("(nMuons)>>hbkg12(5,0,5)","weight"*(mggmin && mggmax && pt1min && pt2min && METmin && eveto)); TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12"); for(int i = 0; i<6; i++) { if(hbkg1->GetBinContent(i) < 0.) hbkg1->SetBinContent(i,0.); if(hbkg2->GetBinContent(i) < 0.) hbkg2->SetBinContent(i,0.); if(hbkg3->GetBinContent(i) < 0.) hbkg3->SetBinContent(i,0.); if(hbkg4->GetBinContent(i) < 0.) hbkg4->SetBinContent(i,0.); if(hbkg5->GetBinContent(i) < 0.) hbkg5->SetBinContent(i,0.); if(hbkg6->GetBinContent(i) < 0.) hbkg6->SetBinContent(i,0.); if(hbkg7->GetBinContent(i) < 0.) hbkg7->SetBinContent(i,0.); if(hbkg8->GetBinContent(i) < 0.) hbkg8->SetBinContent(i,0.); if(hbkg9->GetBinContent(i) < 0.) hbkg9->SetBinContent(i,0.); if(hbkg10->GetBinContent(i) < 0.) hbkg10->SetBinContent(i,0.); if(hbkg11->GetBinContent(i) < 0.) hbkg11->SetBinContent(i,0.); if(hbkg12->GetBinContent(i) < 0.) hbkg12->SetBinContent(i,0.); } double norm =1./h1->Integral(); h1->Scale(norm); norm =1./h2->Integral(); h2->Scale(norm); norm =1./h3->Integral(); h3->Scale(norm); norm =1./h4->Integral(); h4->Scale(norm); norm =1./h5->Integral(); h5->Scale(norm); norm =1./h6->Integral(); h6->Scale(norm); norm =1./h7->Integral(); h7->Scale(norm); norm =1./hbkg1->Integral(); hbkg1->Scale(norm); norm =1./hbkg2->Integral(); hbkg2->Scale(norm); norm =1./hbkg3->Integral(); hbkg3->Scale(norm); norm =1./hbkg4->Integral(); hbkg4->Scale(norm); norm =1./hbkg5->Integral(); hbkg5->Scale(norm); norm =1./hbkg6->Integral(); hbkg6->Scale(norm); norm =1./hbkg7->Integral(); hbkg7->Scale(norm); norm =1./hbkg8->Integral(); hbkg8->Scale(norm); norm =1./hbkg9->Integral(); hbkg9->Scale(norm); norm =1./hbkg10->Integral(); hbkg10->Scale(norm); norm =1./hbkg11->Integral(); hbkg11->Scale(norm); norm =1./hbkg12->Integral(); hbkg12->Scale(norm); TH1F *hbkg1err = (TH1F*)hbkg1->Clone("hbkg1err"); TH1F *hbkg2err = (TH1F*)hbkg2->Clone("hbkg2err"); TH1F *hbkg3err = (TH1F*)hbkg3->Clone("hbkg3err"); TH1F *hbkg4err = (TH1F*)hbkg4->Clone("hbkg4err"); TH1F *hbkg5err = (TH1F*)hbkg5->Clone("hbkg5err"); TH1F *hbkg6err = (TH1F*)hbkg6->Clone("hbkg6err"); 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); hbkg1err->SetMarkerStyle(1); hbkg2err->SetMarkerStyle(1); hbkg3err->SetMarkerStyle(1); hbkg4err->SetMarkerStyle(1); hbkg5err->SetMarkerStyle(1); hbkg6err->SetMarkerStyle(1); hbkg1err->SetFillColor(kGray+3); hbkg2err->SetFillColor(kGray+3); hbkg3err->SetFillColor(kGray+3); hbkg4err->SetFillColor(kGray+3); hbkg5err->SetFillColor(kGray+3); hbkg6err->SetFillColor(kGray+3); hbkg1err->SetFillStyle(3001); hbkg2err->SetFillStyle(3001); hbkg3err->SetFillStyle(3001); hbkg4err->SetFillStyle(3001); hbkg5err->SetFillStyle(3001); hbkg6err->SetFillStyle(3001); hbkg7->SetLineColor(kGreen+2); hbkg6->SetLineColor(kGreen); hbkg8->SetLineColor(kYellow); hbkg4->SetLineColor(kOrange); hbkg9->SetLineColor(kGreen); hbkg10->SetLineColor(kOrange+7); hbkg11->SetLineColor(kCyan); hbkg12->SetLineColor(kBlue); hbkg5->SetLineColor(kBlue+3); hbkg2->SetLineColor(kBlue); hbkg3->SetLineColor(kMagenta-2); hbkg1->SetLineColor(kViolet); h1->SetTitle(""); h1->GetXaxis()->SetTitle("N_{#mu}"); h1->GetYaxis()->SetTitle("Normalized events"); h1->GetYaxis()->SetTitleOffset(1.2); h1->Draw("hist"); h2->Draw("same hist"); h3->Draw("same hist"); h4->Draw("same hist"); h5->Draw("same hist"); //only for 25ns samples gStyle->SetOptStat(0); hbkg1->Draw("same hist"); hbkg1err->Draw("same e2"); TLegend* legGG = new TLegend(0.60,0.65,0.89,0.89); legGG->AddEntry(h1,"m_{Z'} = 600 GeV","l"); legGG->AddEntry(h2,"m_{Z'} = 800 GeV","l"); legGG->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); legGG->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); legGG->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples legGG->AddEntry(hbkg1,"#gamma #gamma","l"); legGG->Draw("same"); TCanvas *canvasGGH = new TCanvas("canvasGGH","",500,500); h1->Draw("hist"); h2->Draw("same hist"); h3->Draw("same hist"); h4->Draw("same hist"); h5->Draw("same hist"); //only for 25ns samples gStyle->SetOptStat(0); hbkg4->Draw("same hist"); hbkg4err->Draw("same e2"); TLegend* legGGH = new TLegend(0.60,0.65,0.89,0.89); legGGH->AddEntry(h1,"m_{Z'} = 600 GeV","l"); legGGH->AddEntry(h2,"m_{Z'} = 800 GeV","l"); legGGH->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); legGGH->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); legGGH->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples legGGH->AddEntry(hbkg4,"ggH","l"); legGGH->Draw("same"); TCanvas *canvasVH = new TCanvas("canvasVH","",500,500); h1->Draw("hist"); h2->Draw("same hist"); h3->Draw("same hist"); h4->Draw("same hist"); h5->Draw("same hist"); //only for 25ns samples gStyle->SetOptStat(0); hbkg6->Draw("same hist"); hbkg6err->Draw("same e2"); TLegend* legVH = new TLegend(0.60,0.65,0.89,0.89); legVH->AddEntry(h1,"m_{Z'} = 600 GeV","l"); legVH->AddEntry(h2,"m_{Z'} = 800 GeV","l"); legVH->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); legVH->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); legVH->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples legVH->AddEntry(hbkg6,"VH","l"); legVH->Draw("same"); TCanvas *canvas = new TCanvas("canvas","",500,500); gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); int i = 0; TLegend* leg = new TLegend(0.35,0.7,0.87,0.87); leg->SetNColumns(2); leg->SetBorderSize(0); leg->SetFillStyle(0); h1->Draw("hist"); gStyle->SetOptStat(0); // hbkg1->Draw("same hist"); // hbkg2->Draw("same hist"); // hbkg3->Draw("same hist"); // hbkg4->Draw("same hist"); // hbkg5->Draw("same hist"); // hbkg6->Draw("same hist"); // hbkg7->Draw("same hist"); // hbkg8->Draw("same hist"); hbkg9->Draw("same hist"); hbkg10->Draw("same hist"); hbkg11->Draw("same hist"); hbkg12->Draw("same hist"); h1->Draw("same hist"); h2->Draw("same hist"); h3->Draw("same hist"); h4->Draw("same hist"); h5->Draw("same hist"); //only for 25ns samples h6->Draw("same hist"); //only for 25ns samples h7->Draw("same hist"); //only for 25ns samples // leg->AddEntry(hbkg1,"#gamma #gamma","l"); leg->AddEntry(h2,"m_{Z'} = 800 GeV","l"); // leg->AddEntry(hbkg2,"Drell Yann","l"); leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); // leg->AddEntry(hbkg3,"#gamma + Jets","l"); leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); //leg->AddEntry(hbkg5,"QCD","l"); leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples // leg->AddEntry(hbkg4,"ggH","l"); leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); //only for 25ns samples // leg->AddEntry(hbkg6,"VH","l"); leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples // leg->AddEntry(hbkg7,"ttH","l"); // leg->AddEntry(hbkg8,"VBF H","l"); leg->AddEntry(hbkg9,"t + #gamma + Jets","l"); leg->AddEntry(hbkg10,"tt + #gamma +Jets","l"); leg->AddEntry(hbkg11,"#gamma+W","l"); leg->AddEntry(hbkg12,"#gamma+Z","l"); leg->Draw("same"); /* canvasGG->SaveAs(Form("./25ns_2246inv/plots/kinematics/nMuons/nMuonsGG_pt1%.0lf_pt2%.0lf_MET%.0lf.pdf",pt1_IN,pt2_IN,MET_IN)); canvasGG->SaveAs(Form("./25ns_2246inv/plots/kinematics/nMuons/nMuonsGG_pt1%.0lf_pt2%.0lf_MET%.0lf.png",pt1_IN,pt2_IN,MET_IN)); canvasGGH->SaveAs(Form("./25ns_2246inv/plots/kinematics/nMuons/nMuonsGGH_pt1%.0lf_pt2%.0lf_MET%.0lf.pdf",pt1_IN,pt2_IN,MET_IN)); canvasGGH->SaveAs(Form("./25ns_2246inv/plots/kinematics/nMuons/nMuonsGGH_pt1%.0lf_pt2%.0lf_MET%.0lf.png",pt1_IN,pt2_IN,MET_IN)); canvasVH->SaveAs(Form("./25ns_2246inv/plots/kinematics/nMuons/nMuonsVH_pt1%.0lf_pt2%.0lf_MET%.0lf.pdf",pt1_IN,pt2_IN,MET_IN)); canvasVH->SaveAs(Form("./25ns_2246inv/plots/kinematics/nMuons/nMuonsVH_pt1%.0lf_pt2%.0lf_MET%.0lf.png",pt1_IN,pt2_IN,MET_IN)); */ canvas->SaveAs("./25ns_2246inv_v3/plots/kinematics/nMuons.pdf"); }