void ExtractOutputHistos(Bool_t onlyPrims=0,Bool_t onlyPion=0,Int_t plotFlag=0) { // gROOT->SetStyle("Plain"); gStyle->SetPalette(1); const Int_t nbins=20; Double_t ptmin=0.06;//04; Double_t ptmax=2.0;//GeV Double_t logxmin = TMath::Log10(ptmin); Double_t logxmax = TMath::Log10(ptmax); Double_t binwidth = (logxmax-logxmin)/(nbins+1); enum {nb=nbins+1}; Double_t xbins[nb]; xbins[0] = ptmin; for (Int_t i=1;i<=nbins;i++) { xbins[i] = ptmin + TMath::Power(10,logxmin+(i)*binwidth); // cout<<xbins[i]<<endl; } // TH1F *h = new TH1F("h","hist with log x axis",nbins,xbins); TH1F *hMultCount = new TH1F("mult","averaged multiplicity (charg. prim)",80,-4.,4.); hMultCount->GetXaxis()->SetTitle("eta"); hMultCount->GetYaxis()->SetTitle("N/d#eta"); TH1F *hAllMC = new TH1F("allMC","All Tracks MC primaries",nbins,xbins); TH1F *hAllFound = new TH1F("allFound","All Tracks found",nbins,xbins); TH1F *hImperfect = new TH1F("imperfect","Imperfect tracks",nbins,xbins); TH1F *hPerfect = new TH1F("perfect","Perfect tracks",nbins,xbins); TH1F *hEff = new TH1F("efficiency","Efficiency (Perfect tracks in \"ALL MC\")",nbins,xbins); TH1F *hFake = new TH1F("fake","Fake tracks (Inperfect tracks in \"ALL MC\")",nbins,xbins); TH1F *hPurity = new TH1F("purity","Purity (Perfect tracks in \"All Found\")",nbins,xbins); TH1F *hAnna = new TH1F("annaEff","AnnalisaEff ",nbins,xbins); TH1F *hNoMCTrack = new TH1F("noMCtrack","noMCtrack ",nbins,xbins); TH1F *hEta = new TH1F("","",50,-2,2); // TH1F *hEtaMC = new TH1F("","",50,-2,2); TH2D *h2Ddca = new TH2D("dca2D","DCAvsPt2D",nbins,xbins,50,-0.05,0.05); TH2D *h2Dpt = new TH2D("dPt2D","dPtdvsPt2D",nbins,xbins,50,-25,25); // open run loader and load gAlice, kinematics and header AliRunLoader* runLoader = AliRunLoader::Open("galice.root"); if (!runLoader) { Error("Check kine", "getting run loader from file %s failed", "galice.root"); return; } runLoader->LoadgAlice(); gAlice = runLoader->GetAliRun(); if (!gAlice) { Error("Check kine", "no galice object found"); return; } runLoader->LoadHeader(); runLoader->LoadKinematics(); TFile* esdFile = TFile::Open("AliESDs.root"); if (!esdFile || !esdFile->IsOpen()) { Error("CheckESD", "opening ESD file %s failed", "AliESDs.root"); return; } AliESDEvent *esd = new AliESDEvent(); TTree* tree = (TTree*) esdFile->Get("esdTree"); if (!tree) { Error("CheckESD", "no ESD tree found"); return; } esd->ReadFromTree(tree); Int_t nTrackTotalMC = 0; Int_t nTrackFound = 0; Int_t nTrackImperfect = 0; Int_t nTrackPerfect = 0; Int_t nNoMCTrack = 0; for(Int_t iEv =0; iEv<tree->GetEntries(); iEv++){ tree->GetEvent(iEv); runLoader->GetEvent(iEv); printf("+++ event %i (of %lld) +++++++++++++++++++++++ # ESDtracks: %d \n",iEv,tree->GetEntries()-1,esd->GetNumberOfTracks()); Int_t nESDtracks = esd->GetNumberOfTracks(); for (Int_t iTrack = 0; iTrack < nESDtracks; iTrack++) { AliESDtrack* track = esd->GetTrack(iTrack); if (!(iTrack%1000)) printf("event %i: ESD track count %d (of %d)\n",iEv,iTrack,nESDtracks); Int_t label = track->GetLabel(); Int_t idx[12]; // Int_t ncl = track->GetITSclusters(idx); if(label<0) { // cout<< " ESD track label " << label; // cout<<" ---> imperfect track (label "<<label<<"<0) !! -> track Pt: "<< track->Pt() << endl; } AliStack* stack = runLoader->Stack(); // nTrackTotalMC += stack->GetNprimary(); TParticle* particle = stack->Particle(TMath::Abs(label)); Double_t pt = track->Pt(); if(particle) { if (TMath::Abs(particle->Eta())>etaCut) continue; Double_t ptMC = particle->Pt(); // Efficiencies if (onlyPion && TMath::Abs(particle->GetPdgCode())!=211) continue; if ( (!onlyPrims) || stack->IsPhysicalPrimary(TMath::Abs(label))) { // cout<<" # clusters "<<ncl<<endl; nTrackFound++; hAllFound->Fill(ptMC); hEta->Fill(track->Eta()); if (label<0) { nTrackImperfect++; hImperfect->Fill(ptMC); } else { nTrackPerfect++; hPerfect->Fill(ptMC); } } // following only for "true tracks, pions if(particle->Pt() < 0.001)continue; if (TMath::Abs(particle->GetPdgCode())!=211) continue; if (label>0) { // Impact parameters for Pions only Double_t dca = track->GetD(0,0,0.5); h2Ddca->Fill(ptMC,dca); // Pt resolution for Pions only Double_t dPt = (pt-ptMC)/ptMC*100; h2Dpt->Fill(ptMC,dPt); } } else { nNoMCTrackFound++; hNoMCTrack->Fill(pt); cout<<" according MC particle not found"<<endl; } } //entries track esd }//entries tree runLoader->UnloadHeader(); runLoader->UnloadKinematics(); delete runLoader; // Count trackable MC tracks CountTrackableMCs(hAllMC, onlyPrims, onlyPion); // Count trackable MC tracks CountPrimaries(hMultCount); // Get Errors right hMultCount->Sumw2(); hAllMC->Sumw2(); hAllFound->Sumw2(); hPerfect->Sumw2(); hImperfect->Sumw2(); h2Dpt->Sumw2(); h2Ddca->Sumw2(); // -- Global efficienies nTrackTotalMC = hAllMC->GetEntries(); Double_t eff = ((Double_t)nTrackPerfect)/nTrackTotalMC; printf("-> Total number of events: %lld -> MCtracks %d -> nPerfect %d -> Eff: %3.2lf \n", tree->GetEntries(),nTrackTotalMC,nTrackPerfect,eff); Double_t purity = ((Double_t)nTrackPerfect)/nTrackFound; printf("-> Total number of events: %lld -> FoundTracks %d -> nPerfect %d -> Purity: %3.2lf \n", tree->GetEntries(),nTrackFound,nTrackPerfect,purity); // Efficiencies - and normalize to 100% TF1 f1("f1","100+x*0",0.,1.e3); hPurity->Divide(hPerfect,hAllFound,1,1,"b"); hPurity->Multiply(&f1); hPurity->SetMarkerColor(kGreen); hPurity->SetMarkerStyle(21); hPurity->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hPurity->SetStats(0); hPurity->GetYaxis()->SetRangeUser(0,100); hPurity->SetTitle("Efficiency & Purity"); hEff->Divide(hPerfect,hAllMC,1,1,"b"); hEff->Multiply(&f1); hEff->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hEff->SetMarkerColor(kBlue); hEff->SetMarkerStyle(21); hEff->SetStats(0); hFake->Divide(hImperfect,hAllMC,1,1,"b"); hFake->Multiply(&f1); hFake->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hFake->SetMarkerColor(kRed); hFake->SetMarkerStyle(21); hFake->SetStats(0); hAnna->Divide(hAllFound,hAllMC,1,1,"b"); hAnna->Multiply(&f1); hAnna->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hAnna->SetMarkerColor(kBlack); hAnna->SetMarkerStyle(21); hAnna->SetStats(0); TCanvas *c1 = new TCanvas("c1","NoMCTrackFound");//,200,10,900,900); TVirtualPad *pad = c1->cd(); pad->SetGridx(); pad->SetGridy(); hNoMCTrack->Draw(); TCanvas *c2 = new TCanvas("c2","Eff&Purity");//,200,10,900,900); TVirtualPad *pad = c2->cd(); pad->SetGridx(); pad->SetGridy(); // pad->SetLogx(); hPurity->Draw("E"); hEff->Draw("Same E"); hFake->Draw("Same E"); hAnna->Draw("Same E"); TLegend *leg = new TLegend(0.1,0.8,0.6,0.9);leg->SetFillColor(0); leg->AddEntry(hPurity,"Purity (\"Perfect tracks\" within \"Found Tracks\")","PE"); leg->AddEntry(hEff,"Efficiency (\"Perfect tracks\" within \"MC findable Tracks\")","PE"); leg->AddEntry(hFake,"Fake (\"Inperfect tracks\" within \"MC findable Tracks\")","PE"); leg->AddEntry(hAnna,"AnnaLisa - Efficiency (\"Found tracks\" within \"MC findable Tracks\")","PE"); leg->Draw(); if (plotFlag==1){ hAllMC->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hAllMC->Draw(); // MC pt distribution hAllFound->SetLineColor(2); hAllFound->Draw("same"); // MC pt distribution } /* .L ~/ITSupgrade/BuildDetector/DetectorK.cxx+ // All NEW DetectorK its("ALICE","ITS"); its.MakeAliceAllNew(0); its.SetMaxRadiusOfSlowDetectors(0.01); its.SolveViaBilloir(0); TGraph *c = its.GetGraphRecoEfficiency(0,3,2); c->Draw("C"); // Current DetectorK its("ALICE","ITS"); its.MakeAliceCurrent(0,0); its.SetMaxRadiusOfSlowDetectors(0.01); its.SolveViaBilloir(0); TGraph *c = its.GetGraphRecoEfficiency(0,4,2); c->Draw("C"); */ TCanvas *c3 = new TCanvas("c3","impact");//,200,10,900,900); c3->Divide(2,1); c3->cd(1); // Impact parameter // Impact parameter resolution --------------- h2Ddca->Draw("colz"); h2Ddca->FitSlicesY() ; TH2D *dcaM = (TH2D*)gDirectory->Get("dca2D_1"); dcaM->Draw("same"); TH2D *dcaRMS = (TH2D*)gDirectory->Get("dca2D_2"); //dcaRMS->Draw(); TGraphErrors *d0 = new TGraphErrors(); for (Int_t ibin =1; ibin<=dcaRMS->GetXaxis()->GetNbins(); ibin++) { d0->SetPoint( ibin-1,dcaRMS->GetBinCenter(ibin),dcaRMS->GetBinContent(ibin)*1e4); // microns d0->SetPointError(ibin-1,0,dcaRMS->GetBinError(ibin)*1e4); // microns } d0->SetMarkerStyle(21); d0->SetMaximum(200); d0->SetMinimum(0); d0->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); d0->GetYaxis()->SetTitle("R-#phi Pointing Resolution (#mum)"); d0->SetName("dca"); d0->SetTitle("DCAvsPt"); c3->cd(1); h2Ddca->Draw("surf2"); c3->cd(2); d0->Draw("APE"); // PT RESOLUTION ------------ TCanvas *c4 = new TCanvas("c4","pt resolution");//,200,10,900,900); c4->Divide(2,1); c4->cd(1); // Impact parameter h2Dpt->Draw("colz"); h2Dpt->FitSlicesY() ; TH2D *dPtM = (TH2D*)gDirectory->Get("dPt2D_1"); dPtM->Draw("same"); TH2D *dPtRMS = (TH2D*)gDirectory->Get("dPt2D_2"); // dPtRMS->Draw(""); TGraphErrors *gPt = new TGraphErrors(); for (Int_t ibin =1; ibin<=dPtRMS->GetXaxis()->GetNbins(); ibin++) { gPt->SetPoint( ibin-1,dPtRMS->GetBinCenter(ibin),dPtRMS->GetBinContent(ibin)); gPt->SetPointError(ibin-1,0,dPtRMS->GetBinError(ibin)); } gPt->SetMarkerStyle(21); gPt->SetMaximum(20); gPt->SetMinimum(0); gPt->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); gPt->GetYaxis()->SetTitle("relative momentum resolution (%)"); gPt->SetName("dPt"); gPt->SetTitle("DPTvsPt"); c4->cd(1); h2Dpt->Draw("surf2"); c4->cd(2); gPt->Draw("APE"); // EXPORT -------- TFile f("histos.root","RECREATE"); hMultCount->Write(); hAllMC->Write(); hAllFound->Write(); hImperfect->Write(); hPerfect->Write(); hNoMCTrack->Write(); hPurity->Write(); hEff->Write(); hFake->Write(); hAnna->Write(); h2Ddca->Write(); d0->Write(); h2Dpt->Write(); gPt->Write(); f.Close(); return; }
void make1DLimitHH(TString combine_dir,bool blind=true){ //TString combine_dir = "test_runSusyHgg/signalInj_sms_ChiHH_0_175/"; TGraph obser( (275-125)/25 ); TGraph graph( (275-125)/25 ); TGraphAsymmErrors error( (275-125)/25 ); for(int m=125;m<501;m+=25) { int i=(m-125)/25; TFile limit_file(Form("%s/higgsCombineChiHH_0_%d.Asymptotic.mH120.root",combine_dir.Data(),m) ); TTree *limit_tree = (TTree*)limit_file.Get("limit"); TTreeFormula limit_form("get_limit","limit",limit_tree); limit_tree->GetEntry(1); float down = limit_form.EvalInstance(); limit_tree->GetEntry(2); float exp = limit_form.EvalInstance(); limit_tree->GetEntry(3); float up = limit_form.EvalInstance(); limit_tree->GetEntry(5); float obs = limit_form.EvalInstance(); graph.SetPoint(i,float(m),exp); error.SetPoint(i,float(m),exp); error.SetPointError(i,0,0,exp-down,up-exp); obser.SetPoint(i,float(m),obs); } TGraphErrors* theo = getTheoXSec("/home/amott/HggApp/SusyHgg/xsecs/Higgsino.txt"); TCanvas cv; cv.SetLogy(); theo->SetMaximum(1e2); theo->SetMinimum(1e-2); theo->GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)"); theo->GetXaxis()->SetTitle("m_{chargino}"); theo->SetFillColor(kBlue); theo->SetLineStyle(kDotted); theo->SetLineWidth(2.0); error.SetMaximum(1e2); error.SetMinimum(1e-2); error.GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)"); error.GetXaxis()->SetTitle("m_{chargino}"); error.SetFillColor(kGreen); error.Draw("A3"); theo->Draw("3C"); graph.SetLineStyle(kDashed); graph.SetLineWidth(2); graph.Draw("C"); obser.SetLineStyle(1); obser.SetLineWidth(2); if(!blind) obser.Draw("C"); TLegend leg(0.7,0.7,0.85,0.85); leg.SetFillColor(0); leg.SetBorderSize(0); leg.AddEntry(&graph,"expected","l"); leg.AddEntry(&error,"expected #pm1#sigma","F"); leg.AddEntry(theo,"theoretical","f"); if(!blind) leg.AddEntry(&obser,"observed","l"); leg.Draw("SAME"); TLatex prelim(0.65,0.96,"CMS Preliminary"); prelim.SetNDC(); prelim.SetTextSize(0.045); prelim.Draw(); TLatex lbl(0.5,0.86,"#sqrt{s} = 8 TeV #int L dt = 19.78 fb^{-1}"); lbl.SetNDC(); lbl.SetTextSize(0.045); lbl.Draw(); cv.SaveAs(combine_dir+"expected_exclusion_HH_1D.png"); }
int plotResoVsIC(){ SetTdrStyle(); const unsigned nIC = 10; const unsigned ICval[nIC] = {0,1,2,3,4,5,10,15,20,50}; std::ostringstream label; TFile *fcalib[nIC]; TGraphErrors *constant = new TGraphErrors(); constant->SetName("constant"); constant->SetTitle(";intercalib. smearing"); constant->SetMarkerStyle(20); constant->SetMarkerColor(1); constant->SetLineColor(1); TGraphErrors *constantSR7 = new TGraphErrors(); constantSR7->SetName("constantSR7"); constantSR7->SetTitle(";intercalib. smearing"); constantSR7->SetMarkerStyle(23); constantSR7->SetMarkerColor(2); constantSR7->SetLineColor(2); TGraphErrors *noise = (TGraphErrors *) constant->Clone("noise"); TGraphErrors *sampling = (TGraphErrors *) constant->Clone("sampling"); TGraphErrors *samplingSR7 = (TGraphErrors *) constantSR7->Clone("samplingSR7"); TCanvas *mycReso = new TCanvas("mycReso","mycReso",1500,1000); mycReso->Divide(2,5); TCanvas *mycR = new TCanvas("mycR","Sampling",1500,1000); TCanvas *mycC = new TCanvas("mycC","Constant",1500,1000); TCanvas *mycN = new TCanvas("mycN","Noise",1500,1000); gStyle->SetOptFit(1111); gStyle->SetOptStat(0); gStyle->SetStatW(0.2); gStyle->SetStatH(0.5); TLatex lat; char buf[500]; TGraphErrors *gr[nIC][2]; double x0,y0; double x0_7,y0_7; for (unsigned ic(0);ic<nIC;++ic){//loop on intercalib label.str(""); label << "PLOTS/CalibReso"; label << "_vsE"; label << "_IC" << ICval[ic]; label << ".root"; fcalib[ic] = TFile::Open(label.str().c_str()); if (!fcalib[ic]) { std::cout << " -- failed to open file: " << label.str() << std::endl; continue; } else { std::cout << " -- file " << label.str() << " successfully opened." << std::endl; } fcalib[ic]->cd("SR2"); gr[ic][0] = (TGraphErrors *)gDirectory->Get("resoRecoFit2eta21pu1"); fcalib[ic]->cd("SR7"); gr[ic][1] = (TGraphErrors *)gDirectory->Get("resoRecoFit7eta21pu1"); TF1 *fit = gr[ic][0]->GetFunction("reso"); TF1 *fit7 = gr[ic][1]->GetFunction("reso"); mycReso->cd(ic+1); gr[ic][0]->Draw("APE"); fit->SetLineColor(6); fit->Draw("same"); lat.SetTextSize(0.1); sprintf(buf,"Single #gamma, #eta=2.1, 3#times3 cm^{2}"); lat.DrawLatexNDC(0.2,0.8,buf); sprintf(buf,"ICsmear = %d %%",ICval[ic]); lat.DrawLatexNDC(0.2,0.7,buf); double cval = sqrt(pow(fit->GetParameter(1),2)-pow(y0,2)); constant->SetPoint(ic,ICval[ic]/100.,cval); constant->SetPointError(ic,0,fit->GetParameter(1)*fit->GetParError(1)/cval); noise->SetPoint(ic,ICval[ic]/100.,fit->GetParameter(2)); noise->SetPointError(ic,0,fit->GetParError(2)); sampling->SetPoint(ic,ICval[ic]/100.,fit->GetParameter(0)); sampling->SetPointError(ic,0,fit->GetParError(0)); cval = sqrt(pow(fit7->GetParameter(1),2)-pow(y0_7,2)); constantSR7->SetPoint(ic,ICval[ic]/100.,cval); constantSR7->SetPointError(ic,0,fit7->GetParameter(1)*fit7->GetParError(1)/cval); //constantSR7->SetPoint(ic,ICval[ic]/100.,fit7->GetParameter(1)); //constantSR7->SetPointError(ic,0,fit7->GetParError(1)); samplingSR7->SetPoint(ic,ICval[ic]/100.,fit7->GetParameter(0)); samplingSR7->SetPointError(ic,0,fit7->GetParError(0)); if (ic==0) { constant->GetPoint(0,x0,y0); constantSR7->GetPoint(0,x0_7,y0_7); cval = sqrt(pow(fit->GetParameter(1),2)-pow(y0,2)); constant->SetPoint(ic,ICval[ic]/100.,cval); constant->SetPointError(ic,0,fit->GetParameter(1)*fit->GetParError(1)/cval); cval = sqrt(pow(fit7->GetParameter(1),2)-pow(y0_7,2)); constantSR7->SetPoint(ic,ICval[ic]/100.,cval); constantSR7->SetPointError(ic,0,fit7->GetParameter(1)*fit7->GetParError(1)/cval); } } mycReso->Update(); mycReso->Print("PLOTS/ResolutionFitvsIC.pdf"); TLegend *leg = new TLegend(0.6,0.6,0.8,0.8); leg->SetFillColor(10); leg->AddEntry(sampling,"3#times3 cm^{2}","P"); leg->AddEntry(samplingSR7,"All detector","P"); mycR->cd(); gPad->SetGridy(1); sampling->GetYaxis()->SetTitle("Sampling term (GeV^{1/2})"); sampling->SetMinimum(0.2); sampling->SetMaximum(0.3); sampling->Draw("APE"); samplingSR7->Draw("PEsame"); lat.SetTextSize(0.04); sprintf(buf,"Single #gamma, #eta=2.1"); lat.DrawLatexNDC(0.2,0.87,buf); lat.DrawLatexNDC(0.01,0.01,"HGCAL G4 standalone"); leg->Draw("same"); mycR->Update(); mycR->Print("PLOTS/SamplingvsIC.pdf"); mycC->cd(); gPad->SetLogx(1); gPad->SetGridy(1); gStyle->SetOptFit(0); //gStyle->SetStatH(0.1); //gStyle->SetStatW(0.2); constant->GetYaxis()->SetTitle("Constant from intercalib."); constant->SetMinimum(0); constant->SetMaximum(0.08); constant->Draw("APE"); //constantSR7->Draw("PEsame"); sprintf(buf,"Single #gamma, #eta=2.1"); lat.DrawLatexNDC(0.2,0.87,buf); lat.DrawLatexNDC(0.01,0.01,"HGCAL G4 standalone"); TF1 *BE = new TF1("BE","sqrt([0]*[0] + pow(x*1/sqrt([1]),2))",0,1); BE->SetParameters(0,30); // BE->SetParLimits(0,1,1); BE->FixParameter(0,0); BE->SetLineColor(1); constant->Fit("BE","BI"); lat.SetTextColor(1); //sprintf(buf,"c #propto c_{0} #oplus #frac{x}{#sqrt{n}}, n=%3.1f #pm %3.1f",BE->GetParameter(1),BE->GetParError(1)); sprintf(buf,"c_{ic}=#frac{x}{#sqrt{n}}, n=%3.1f #pm %3.1f",BE->GetParameter(1),BE->GetParError(1)); lat.DrawLatexNDC(0.2,0.77,"c=c_{0} #oplus c_{ic}"); lat.DrawLatexNDC(0.2,0.67,buf); //BE->SetParameter(0,y0_7); //constantSR7->Fit("BE","BI","same"); //BE->SetLineColor(2); //BE->Draw("same"); //lat.SetTextColor(2); //sprintf(buf,"c #propto c_{0} #oplus #frac{x}{#sqrt{n}}, n=%3.1f #pm %3.1f",BE->GetParameter(1),BE->GetParError(1)); //lat.DrawLatexNDC(0.2,0.6,buf); //lat.SetTextColor(1); //leg->Draw("same"); mycC->Update(); mycC->Print("PLOTS/ConstantvsIC.pdf"); mycN->cd(); noise->GetYaxis()->SetTitle("Noise term (GeV)"); noise->Draw("APE"); sprintf(buf,"Single #gamma, #eta=2.1, 3#times3 cm^{2}"); lat.DrawLatexNDC(0.2,0.87,buf); lat.DrawLatexNDC(0.01,0.01,"HGCAL G4 standalone"); mycN->Print("PLOTS/NoisevsIC.pdf"); return 0; }//main
void plotMerged(Bool_t onlyPlot=0) { gStyle->SetPalette(1); TFile f("histoSum.root","UPDATE"); TH1F* hAllMC = f.Get("allMC"); TH1F* hAllFound= f.Get("allFound"); TH1F* hImperfect= f.Get("imperfect"); TH1F* hPerfect= f.Get("perfect"); TH1F* hNoMCTrack= f.Get("noMCtrack"); // have to be recalculated TH1F* hPurity = f.Get("purity"); TH1F* hEff= f.Get("efficiency"); TH1F* hFake= f.Get("fake"); TH1F* hAnna= f.Get("annaEff"); TH2D* h2Ddca= f.Get("dca2D"); TGraphErrors *d0= f.Get("dca"); TH2D* h2Dpt= f.Get("dPt2D"); TGraphErrors *gPt= f.Get("dPt"); if (!onlyPlot) { /* // Get Errors right hAllMC->Sumw2(); hAllFound->Sumw2(); hPerfect->Sumw2(); hImperfect->Sumw2(); h2Dpt->Sumw2(); h2Ddca->Sumw2(); */ // Efficiencies - and normalize to 100% TF1 f1("f1","100+x*0",0.,1.e3); hPurity->Divide(hPerfect,hAllFound,1,1,"b"); hPurity->Multiply(&f1); hPurity->SetMarkerColor(kGreen); hPurity->SetMarkerStyle(21); hPurity->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hPurity->SetStats(0); hPurity->GetYaxis()->SetRangeUser(0,100); hPurity->SetTitle("Efficiency & Purity"); hEff->Divide(hPerfect,hAllMC,1,1,"b"); hEff->Multiply(&f1); hEff->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hEff->SetMarkerColor(kBlue); hEff->SetMarkerStyle(21); hEff->SetStats(0); hFake->Divide(hImperfect,hAllMC,1,1,"b"); hFake->Multiply(&f1); hFake->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hFake->SetMarkerColor(kRed); hFake->SetMarkerStyle(21); hFake->SetStats(0); hAnna->Divide(hAllFound,hAllMC,1,1,"b"); hAnna->Multiply(&f1); hAnna->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hAnna->SetMarkerColor(kBlack); hAnna->SetMarkerStyle(21); hAnna->SetStats(0); // Impact parameter resolution --------------- TCanvas *c3 = new TCanvas("c3","impact");//,200,10,900,900); c3->Divide(2,1); c3->cd(1); h2Ddca->DrawCopy("colz"); h2Ddca->FitSlicesY() ; TH2D *dcaM = (TH2D*)gDirectory->Get("dca2D_1"); dcaM->Draw("same"); TH2D *dcaRMS = (TH2D*)gDirectory->Get("dca2D_2"); //dcaRMS->Draw(); TGraphErrors *d0 = new TGraphErrors(); for (Int_t ibin =1; ibin<=dcaRMS->GetXaxis()->GetNbins(); ibin++) { d0->SetPoint( ibin-1,dcaRMS->GetBinCenter(ibin),dcaRMS->GetBinContent(ibin)*1e4); // microns d0->SetPointError(ibin-1,0,dcaRMS->GetBinError(ibin)*1e4); // microns } d0->SetMarkerStyle(21); d0->SetMaximum(200); d0->SetMinimum(0); d0->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); d0->GetYaxis()->SetTitle("R-#phi Pointing Resolution (#mum)"); d0->SetName("dca"); d0->SetTitle("DCAvsPt"); // c3->cd(1); h2Ddca->Draw("surf2"); c3->cd(2); d0->Draw("APE"); // PT RESOLUTION ------------ TCanvas *c4 = new TCanvas("c4","pt resolution");//,200,10,900,900); c4->Divide(2,1); c4->cd(1); h2Dpt->DrawCopy("colz"); h2Dpt->FitSlicesY() ; TH2D *dPtM = (TH2D*)gDirectory->Get("dPt2D_1"); dPtM->Draw("same"); TH2D *dPtRMS = (TH2D*)gDirectory->Get("dPt2D_2"); // dPtRMS->Draw(""); TGraphErrors *gPt = new TGraphErrors(); for (Int_t ibin =1; ibin<=dPtRMS->GetXaxis()->GetNbins(); ibin++) { gPt->SetPoint( ibin-1,dPtRMS->GetBinCenter(ibin),dPtRMS->GetBinContent(ibin)); gPt->SetPointError(ibin-1,0,dPtRMS->GetBinError(ibin)); } gPt->SetMarkerStyle(21); gPt->SetMaximum(20); gPt->SetMinimum(0); gPt->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); gPt->GetYaxis()->SetTitle("relative momentum resolution (%)"); gPt->SetName("dPt"); gPt->SetTitle("DPTvsPt"); // c4->cd(1); h2Dpt->Draw("surf2"); c4->cd(2); gPt->Draw("APE"); // overwrite with normalized graphs hPurity->Write(); hEff->Write(); hFake->Write(); hAnna->Write(); h2Ddca->Write(); d0->Write(); h2Dpt->Write(); gPt->Write(); } // Plots TCanvas *c2 = new TCanvas("c2","Eff&Purity");//,200,10,900,900); TVirtualPad *pad = c2->cd(); pad->SetGridx(); pad->SetGridy(); // pad->SetLogx(); TLegend *leg = new TLegend(0.1,0.8,0.6,0.9);leg->SetFillColor(0); leg->AddEntry(hPurity,"Purity (\"Perfect tracks\" within \"Found Tracks\")","PE"); leg->AddEntry(hEff,"Efficiency (\"Perfect tracks\" within \"MC findable Tracks\")","PE"); leg->AddEntry(hFake,"Fake (\"Inperfect tracks\" within \"MC findable Tracks\")","PE"); leg->AddEntry(hAnna,"AnnaLisa - Efficiency (\"Found tracks\" within \"MC findable Tracks\")","PE"); hPurity->DrawCopy("E"); hEff->DrawCopy("Same E"); hFake->DrawCopy("Same E"); hAnna->DrawCopy("Same E"); leg->Draw(); c2->SaveAs("EffPlot.png"); f.Close(); }
void cetaflatHFP12(int nIterN=1, double Ethr1=10, double Ethr2=150) { gStyle->SetOptLogz(0); gStyle->SetMarkerSize(0.7); gStyle->SetMarkerStyle(20); gStyle->SetPadGridX(0); gStyle->SetPadGridY(0); gStyle->SetTitleOffset(1.7,"Y"); gStyle->SetTitleOffset(0.9,"X"); //gStyle->SetPadRightMargin(0.12); gStyle->SetPadRightMargin(0.03); gStyle->SetPadLeftMargin(0.18); //gStyle->SetNdivisions(516); gStyle->SetStatH(0.025); gStyle->SetStatW(0.3); gStyle->SetTitleW(0.4); gStyle->SetTitleX(0.28); gStyle->SetOptStat(0); gROOT->ForceStyle(); char ctit[245],ftit[245]; float etaBounds[14] = {2.853,2.964,3.139,3.314,3.489,3.664,3.839,4.013,4.191,4.363,4.538,4.716,4.889,5.205}; // ------Histos input: spectra of all channels----------------------------------- //sprintf(ftit,"%s","phi43val2012A"); //sprintf(ftit,"%s","phi2012A_May"); //sprintf(ftit,"%s","phiSym524_2012AB"); //sprintf(ftit,"%s","phiSym524newGain_2012AB"); //sprintf(ftit,"%s","phiSym524newGain_2012ABC"); //sprintf(ftit,"%s","phisymNewCond2012Cval"); //sprintf(ftit,"%s","phisymOldCond2012Cval"); //sprintf(ftit,"%s","phiSym533Gain507_2012D"); sprintf(ftit,"%s","phiSym533Corr45Gain507_2012D"); sprintf(ctit,"/home/vodib/beam12/intercal/%s.root",ftit); TFile *fila = new TFile (ctit); cout<<"File= "<<ctit<<endl; TH1F *hcounter = new TH1F(*((TH1F*)fila->Get("phaseHF/hcounter"))); cout<<"Stat= "<<hcounter->GetBinContent(2)<<endl; cout<<"E within: "<<Ethr1<<" - "<<Ethr2<<endl; TH2F* hLmapP = new TH2F("hLmapP","E L HFP;i#eta;i#phi",13,28.5,41.5,36,0,72); TH2F* hSmapP = new TH2F("hSmapP","E S HFP;i#eta;i#phi",13,28.5,41.5,36,0,72); TH2F* hLmapP0 = new TH2F("hLmapP0","E0 L HFP;i#eta;i#phi",13,28.5,41.5,36,0,72); TH2F* hSmapP0 = new TH2F("hSmapP0","E0 S HFP;i#eta;i#phi",13,28.5,41.5,36,0,72); TH2F* hLmapPc = new TH2F("hLmapPc","corr L HFP;i#eta;i#phi",13,28.5,41.5,36,0,72); TH2F* hSmapPc = new TH2F("hSmapPc","corr S HFP;i#eta;i#phi",13,28.5,41.5,36,0,72); hLmapPc->Sumw2(); hSmapPc->Sumw2(); //TH1F *hLcorr1D = new TH1F("hLcorr1D","Corr L",300,0.5,2); //TH1F *hScorr1D = new TH1F("hScorr1D","Corr S",300,0.5,2); TH1F *hLcorr1D = new TH1F("hLcorr1D","Corr L",180,0.7,1.5); TH1F *hScorr1D = new TH1F("hScorr1D","Corr S",180,0.7,1.5); TH1F *hLdatP[13][36], *hSdatP[13][36], *hLdatPx[13][36], *hSdatPx[13][36]; for (int ii=0;ii<13;ii++) for (int jj=0;jj<36;jj++) { sprintf(ctit,"hL%d_%d",ii+29,2*jj+1); hLdatP[ii][jj] = new TH1F(ctit,ctit,8000,0,250); sprintf(ctit,"hS%d_%d",ii+29,2*jj+1); hSdatP[ii][jj] = new TH1F(ctit,ctit,8000,0,250); } TH1F *htL = new TH1F("htL","htL",20000,0,7e8/3.); TH1F *htS = new TH1F("htS","htS",20000,0,5e8/3.); //TH1F *htL = new TH1F("htL","htL",20000,0,4e8/40); //TH1F *htS = new TH1F("htS","htS",20000,0,2e8/40); TH1F *hLdatPx[13][36], *hSdatPx[13][36]; TCanvas *cLx[200],*cSx[200]; TSpline5 *ttL,*ttS; Double_t x,y,rPL,rPS,drPL,drPS,mLE,mSE,ermean,rms; Double_t xxL[1000],yyL[1000]; Double_t xxS[1000],yyS[1000]; Int_t nELP, nESP, nIter=0; Double_t mcorrL,scorrL,mcorrS,scorrS,erLP,erSP,rLP,drLP,rSP,drSP,corrL,corrS,dcorrL,dcorrS; double mLEphi[13],mSEphi[13],dmLEphi[13],dmSEphi[13]; TCanvas *ccxx = new TCanvas("ccxx","ccxx",100,300,900,500); ccxx->Divide(2,1); for (int ii=0;ii<13;ii++) { //for (int ii=1;ii<2;ii++) { int ieta=ii+29; mLE=mSE=0; // ------------------for initial condition int nmLE=0, nmSE=0; htL->Reset(); htS->Reset(); for (int ll=1;ll<=72;ll+=2) { int iphi=ll; if (abs(ieta)>39 && (iphi-1)%4==0) continue; hSmapPc->SetBinContent(ii+1,ll/2+1,1); hLmapPc->SetBinContent(ii+1,ll/2+1,1); hSmapPc->SetBinError(ii+1,ll/2+1,1.e-6); hLmapPc->SetBinError(ii+1,ll/2+1,1.e-6); sprintf(ctit,"phaseHF/espec/E_+%d_%d_1",ieta,iphi); hLdatPx[ii][ll/2] = new TH1F(*((TH1F*)fila->Get(ctit))); hLdatPx[ii][ll/2]->SetAxisRange(Ethr1,Ethr2); rLP = hLdatPx[ii][ll/2]->Integral()*hLdatPx[ii][ll/2]->GetMean(); hLmapP0->SetBinContent(ii+1,ll/2+1,rLP); sprintf(ctit,"phaseHF/espec/E_+%d_%d_2",ieta,iphi); hSdatPx[ii][ll/2] = new TH1F(*((TH1F*)fila->Get(ctit))); hSdatPx[ii][ll/2]->SetAxisRange(Ethr1,Ethr2); rSP = hSdatPx[ii][ll/2]->Integral()*hSdatPx[ii][ll/2]->GetMean(); hSmapP0->SetBinContent(ii+1,ll/2+1,rSP); if (ieta<=32 && iphi==67) continue; if (rLP>0) { htL->Fill(rLP); mLE += rLP; nmLE++; } if (rSP>0) { htS->Fill(rSP); mSE += rSP; nmSE++; } } if (nmLE>0) mLE /= nmLE; else continue; if (nmSE>0) mSE /= nmSE; else continue; ccxx->cd(1); htL->Draw("hist"); ccxx->cd(2); htS->Draw("hist"); ccxx->Update(); //histspec(htL,mLE,ermean,rms,4,3); //histspec(htS,mSE,ermean,rms,4,3); mLEphi[ii]=mLE; mSEphi[ii]=mSE; dmLEphi[ii]=htL->GetRMS(); dmSEphi[ii]=htS->GetRMS(); printf("ieta %2d : <E>L= %8.1f (%6.1f) x %d <E>S= %8.1f (%6.1f) x %d \n", ieta,mLE,dmLEphi[ii],nmLE,mSE,dmSEphi[ii],nmSE); for (int jj=1;jj<=72;jj+=2) { int iphi=jj; if (abs(ieta)>39 && (iphi-1)%4==0) continue; if (ieta<=32 && iphi==67) { hLmapP->SetBinContent(ii+1,jj/2+1,hLmapP0->GetBinContent(ii+1,jj/2+1)); hSmapP->SetBinContent(ii+1,jj/2+1,hSmapP0->GetBinContent(ii+1,jj/2+1)); continue; } for (nIter=1;nIter<nIterN;nIter++) { //cout<<nIter<<" | "; corrL=hLmapPc->GetBinContent(ii+1,jj/2+1); hLdatP[ii][jj/2]->Reset(); for (int kk=1;kk<=hLdatPx[ii][jj/2]->GetNbinsX();kk++) { xxL[kk-1]=hLdatPx[ii][jj/2]->GetBinCenter(kk); yyL[kk-1]=hLdatPx[ii][jj/2]->GetBinContent(kk); } ttL = new TSpline5("tt",xxL,yyL,1000,"",10,20); for (int kk=1;kk<=hLdatP[ii][jj/2]->GetNbinsX();kk++) { x=hLdatP[ii][jj/2]->GetBinCenter(kk); y=hLdatP[ii][jj/2]->GetBinContent(kk); hLdatP[ii][jj/2]->Fill(x*corrL,ttL->Eval(x)/8.0); } ttL->Delete(); hLdatP[ii][jj/2]->SetAxisRange(Ethr1,Ethr2); rLP = hLdatP[ii][jj/2]->Integral()*hLdatP[ii][jj/2]->GetMean(); dcorrL=(rLP-mLE)/mLE; if (rLP>0) drLP= sqrt(pow(hLdatP[ii][jj/2]->GetMeanError()/hLdatP[ii][jj/2]->GetMean(),2)+ 1.f/hLdatP[ii][jj/2]->Integral()+ pow(dcorrL/(1.0+sqrt((float) nIter)),2)); else drLP=1.e-6; if (fabs(dcorrL)>0.001) { corrL*=1-dcorrL/(1.0+sqrt((float) nIter)); //printf("%2d : %2d / %2d / 1 %7.3f %7.3f\n",nIter,ieta,iphi,dcorrL,corrL); hLmapPc->SetBinContent(ii+1,jj/2+1,corrL); hLmapPc->SetBinError(ii+1,jj/2+1,corrL*drLP); hLmapP->SetBinContent(ii+1,jj/2+1,rLP); } else { printf("%2d : %2d / %2d / 1 %7.3f %8.4f %8.4f\n",nIter,ieta,iphi,dcorrL,corrL,corrL*drLP); hLmapP->SetBinContent(ii+1,jj/2+1,rLP); hLmapPc->SetBinError(ii+1,jj/2+1,corrL*drLP); break; } if (nIter==nIterN-1) { printf("%2d : %2d / %2d / 1 %7.3f %8.4f %8.4f\n",nIter,ieta,iphi,dcorrL,corrL,corrL*drLP); } } for (nIter=1;nIter<nIterN;nIter++) { //cout<<nIter<<" | "; corrS=hSmapPc->GetBinContent(ii+1,jj/2+1); hSdatP[ii][jj/2]->Reset(); for (int kk=1;kk<=hSdatPx[ii][jj/2]->GetNbinsX();kk++) { xxS[kk-1]=hSdatPx[ii][jj/2]->GetBinCenter(kk); yyS[kk-1]=hSdatPx[ii][jj/2]->GetBinContent(kk); } ttS = new TSpline5("tt",xxS,yyS,1000,"",10,20); for (int kk=1;kk<=hSdatP[ii][jj/2]->GetNbinsX();kk++) { x=hSdatP[ii][jj/2]->GetBinCenter(kk); y=hSdatP[ii][jj/2]->GetBinContent(kk); hSdatP[ii][jj/2]->Fill(x*corrS,ttS->Eval(x)/8.0); } ttS->Delete(); hSdatP[ii][jj/2]->SetAxisRange(Ethr1,Ethr2); rSP = hSdatP[ii][jj/2]->Integral()*hSdatP[ii][jj/2]->GetMean(); dcorrS=(rSP-mSE)/mSE; if (rSP>0) drSP=sqrt(pow(hSdatP[ii][jj/2]->GetMeanError()/hSdatP[ii][jj/2]->GetMean(),2)+ 1.f/hSdatP[ii][jj/2]->Integral()+ pow(dcorrS/(1.0+sqrt((float) nIter)),2)); else drSP=1.e-6; if (fabs(dcorrS)>0.001) { corrS*=1-dcorrS/(1.0+sqrt((float) nIter)); //printf("%2d : %2d / %2d / 1 %7.3f %7.3f\n",nIter,ieta,iphi,dcorrS,corrS); hSmapPc->SetBinContent(ii+1,jj/2+1,corrS); hSmapPc->SetBinError(ii+1,jj/2+1,corrS*drSP); hSmapP->SetBinContent(ii+1,jj/2+1,rSP); } else { printf("%2d : %2d / %2d / 2 %7.3f %8.4f %8.4f\n",nIter,ieta,iphi,dcorrS,corrS,corrS*drSP); hSmapP->SetBinContent(ii+1,jj/2+1,rSP); hSmapPc->SetBinError(ii+1,jj/2+1,corrS*drSP); break; } if (nIter==nIterN-1) { printf("%2d : %2d / %2d / 2 %7.3f %8.4f %8.4f\n",nIter,ieta,iphi,dcorrS,corrS,corrS*drSP); } } } } //fila->Close(); cout<<endl<<"Rings : "<<endl; cout<<" E L "<<"E S "<<"eta "<<"delta eta"<<endl; double xeta[13], weta[13], reta[13]; for (int i=29;i<=41;i++) { xeta[i-29]=(etaBounds[i-28]+etaBounds[i-29])/2; weta[i-29]=(etaBounds[i-28]-etaBounds[i-29]); mLEphi[i-29]=mLEphi[i-29]*36/weta[i-29]; mSEphi[i-29]=mSEphi[i-29]*36/weta[i-29]; dmLEphi[i-29]=dmLEphi[i-29]*36/weta[i-29]; dmSEphi[i-29]=dmSEphi[i-29]*36/weta[i-29]; if (i>39) { mLEphi[i-29]/=2; mSEphi[i-29]/=2; dmLEphi[i-29]/=2; dmSEphi[i-29]/=2; } reta[i-29] = mSEphi[i-29]/mLEphi[i-29]; cout<<i<<" : "<<mLEphi[i-29]<<" "<<mSEphi[i-29]<<" "<<xeta[i-29]<<" "<<weta[i-29]<<endl; } TCanvas *cgL = new TCanvas("cgL","cgL",300,300,600,600); TGraphErrors *grL = new TGraphErrors(13,xeta,mLEphi,0,dmLEphi); grL->SetTitle("HFP L;#eta;E_{Ring} / #Delta#eta_{Ring} , GeV"); grL->SetMinimum(0); grL->SetMarkerStyle(20); grL->Draw("1+PAl"); cgL->Print("pictHFplot/etaProfHFPL.gif"); mSEphi[12]/=2; mSEphi[11]/=2; TCanvas *cgS = new TCanvas("cgS","cgS",300,300,600,600); TGraphErrors *grS = new TGraphErrors(13,xeta,mSEphi,0,dmSEphi); grS->SetTitle("HFP S;#eta;E_{Ring} / #Delta#eta_{Ring} , GeV"); grS->SetMinimum(0); grS->SetMarkerStyle(20); grS->Draw("1+PAl"); cgS->Print("pictHFplot/etaProfHFPS.gif"); TCanvas *crg = new TCanvas("crg","crg",300,300,600,600); TGraphErrors *rg = new TGraphErrors(13,xeta,reta,0,0); rg->SetTitle("HFP;#eta;E(S) / E(L)"); rg->SetMinimum(0); rg->Draw("1+PAl"); crg->Print("pictHFplot/SoverLetaHFP.gif"); TCanvas *cL0 = new TCanvas("cL0","cL0",0,0,650,600); hLmapP0->Draw("colz"); cL0->Update(); TCanvas *cS = new TCanvas("cS0","cS0",1000,0,650,600); hSmapP0->Draw("colz"); cS0->Update(); //TFile *histf = new TFile("HFPmc.root","RECREATE"); FILE *ft1; //sprintf(ctit,"corrHFPmc_%d_%d.txt",((int) Ethr1),((int) Ethr2)); sprintf(ctit,"corrHFP_%s_%d_%d.txt",ftit,((int) Ethr1),((int) Ethr2)); if ((ft1 = fopen(ctit,"w"))==NULL){ // Open new file printf("\nNo file %s open => EXIT\n\n",file); return; } printf("\n\n File '%s' open \n\n",ctit); TH1D *hprL[13],*hprS[13],*hprL0[13],*hprS0[13]; TH1D *hprcL[13],*hprcS[13]; TCanvas *cpr[13],*ccc[13]; TLine *lin1 = new TLine(0,1,71,1); lin1->SetLineWidth(1); int noff=0; for (int ii=0;ii<13;ii++) { sprintf(ctit,"HFPcorr_%d_L",ii+29); // draw corrections hprcL[ii] = hLmapPc->ProjectionY(ctit,ii+1,ii+1); hprcL[ii]->SetTitle(ctit); sprintf(ctit,"HFPcorr_%d_S",ii+29); hprcS[ii] = hSmapPc->ProjectionY(ctit,ii+1,ii+1); hprcS[ii]->SetTitle(ctit); ccc[ii] = new TCanvas(ctit,ctit,800,100,500,900); ccc[ii]->Divide(1,2); ccc[ii]->cd(1); if (ii+29>39) { hprcL[ii]->Rebin(2); hprcS[ii]->Rebin(2); } hprcL[ii]->SetMinimum(0); hprcL[ii]->SetTitleOffset(0.9,"X"); hprcL[ii]->Draw("e"); lin1->Draw(); ccc[ii]->cd(2); hprcS[ii]->SetMinimum(0); hprcS[ii]->SetTitleOffset(0.9,"X"); hprcS[ii]->Draw("e"); lin1->Draw(); sprintf(ctit,"pictHFplot/HFPcorr_%d.gif",ii+29); ccc[ii]->Update(); ccc[ii]->Print(ctit); //hprcL[ii]->Write(); //hprcS[ii]->Write(); sprintf(ctit,"HFP_%d_L",ii+29); // draw E depositions hprL0[ii] = hLmapP0->ProjectionY(ctit,ii+1,ii+1); sprintf(ctit,"HFP_%d_L;i#phi;GeV;",29+ii); // draw E depositions hprL0[ii]->SetTitle(ctit); sprintf(ctit,"HFP_L_%d",ii+29); hprL[ii] = hLmapP->ProjectionY(ctit,ii+1,ii+1); sprintf(ctit,"HFP_%d_S",ii+29); hprS0[ii] = hSmapP0->ProjectionY(ctit,ii+1,ii+1); sprintf(ctit,"HFP_%d_S;i#phi;GeV;",29+ii); // draw E depositions hprS0[ii]->SetTitle(ctit); sprintf(ctit,"HFP_S_%d",ii+29); hprS[ii] = hSmapP->ProjectionY(ctit,ii+1,ii+1); cpr[ii] = new TCanvas(ctit,ctit,800,100,500,900); cpr[ii]->Divide(1,2); cpr[ii]->cd(1); if (ii+29>39) { hprL0[ii]->Rebin(2); hprL[ii]->Rebin(2); hprS0[ii]->Rebin(2); hprS[ii]->Rebin(2); } hprL0[ii]->SetFillColor(3);hprL0[ii]->SetLineColor(3);hprL0[ii]->SetLineWidth(3); hprL0[ii]->SetMinimum(0); hprL0[ii]->SetTitleOffset(0.9,"X"); hprL0[ii]->Draw("hist"); hprL[ii]->Draw("samehist"); cpr[ii]->cd(2); hprS0[ii]->SetMinimum(0); hprS0[ii]->SetTitleOffset(0.9,"X"); hprS0[ii]->SetFillColor(3);hprS0[ii]->SetLineColor(3);hprS0[ii]->SetLineWidth(3); hprS0[ii]->Draw("hist"); hprS[ii]->Draw("samehist"); sprintf(ctit,"pictHFplot/HFP_%d.gif",ii+29); cpr[ii]->Print(ctit); //hprS0[ii]->Write(); //hprL0[ii]->Write(); cout<<"Results : "<<endl; for (int jj=1;jj<=72;jj+=2) { int ieta=ii+29; int iphi=jj; if (abs(ieta)>39 && (iphi-1)%4==0) continue; //if (ieta==29 && iphi==67) continue; corrL=hLmapPc->GetBinContent(ii+1,jj/2+1); corrS=hSmapPc->GetBinContent(ii+1,jj/2+1); dcorrL=hLmapPc->GetBinError(ii+1,jj/2+1); dcorrS=hSmapPc->GetBinError(ii+1,jj/2+1); hLcorr1D->Fill(corrL); hScorr1D->Fill(corrS); noff++; //printf("%2d : %2d / %2d / 1 %9.4f %9.4f\n",noff,ieta,iphi,corrL,dcorrL); fprintf(ft1,"%2d %2d 1 %9.4f %9.4f\n",ieta,iphi,corrL,dcorrL); noff++; //printf("%2d : %2d / %2d / 2 %9.4f %9.4f\n",noff,ieta,iphi,corrS,dcorrS); fprintf(ft1,"%2d %2d 2 %9.4f %9.4f\n",ieta,iphi,corrS,dcorrS); } } fclose(ft1); for (int ii=0;ii<13;ii++) for (int jj=1;jj<=72;jj+=2) { int ieta=ii+29; int iphi=jj; if (abs(ieta)>39 && (iphi-1)%4==0) continue; if (ieta==29 && iphi==67) continue; corrL=hLmapPc->GetBinContent(ii+1,jj/2+1); if (fabs(corrL-1)>0.16) printf("%2d / %2d / 1 %9.4f %9.4f\n",ieta,iphi,corrL,dcorrL); corrS=hSmapPc->GetBinContent(ii+1,jj/2+1); if (fabs(corrS-1)>0.16) printf("%2d / %2d / 2 %9.4f %9.4f\n",ieta,iphi,corrS,dcorrS); } TCanvas *cLcorr =new TCanvas("cLcorr","cLcorr",30,30,600,600); cLcorr->SetRightMargin(0.12); hLmapPc->SetAxisRange(0.6,1.6,"Z"); hLmapPc->Draw("colz"); TCanvas *cScorr =new TCanvas("cScorr","cScorr",30,300,600,600); cScorr->SetRightMargin(0.12); hSmapPc->SetAxisRange(0.6,1.6,"Z"); hSmapPc->Draw("colz"); TCanvas *cL = new TCanvas("cL","cL",0,0,650,600); hLmapP->Draw("colz"); cL->Update(); TCanvas *cS = new TCanvas("cS","cS",1000,0,650,600); hSmapP->Draw("colz"); cS->Update(); TCanvas *c1corr =new TCanvas("c1corr","c1corr",30,30,900,500); c1corr->Divide(2,1); c1corr->cd(1); hLcorr1D->Draw("hist"); histStat(hLcorr1D,1); c1corr->cd(2); hScorr1D->Draw("hist"); histStat(hScorr1D,1); //hLcorr1D->Write(); hScorr1D->Write(); c1corr->Print("pictHFplot/corrHFP.gif"); //c1corr->Print("pictHFmc/corrHFP.gif"); c1corr->Update(); //fila->Close(); //histf->Close(); sprintf(ctit,"HFPo_%s_%d_%d.root",ftit,((int) Ethr1),((int) Ethr2)); TFile *histf = new TFile(ctit,"RECREATE"); hLcorr1D->Write(); hScorr1D->Write(); hLmapP->Write(); hLmapP0->Write(); hLmapPc->Write(); hSmapP->Write(); hSmapP0->Write(); hSmapPc->Write(); grL->Write(); grS->Write(); histf->Close(); }
void genPngClsExpBarrel100(){ //Being calculated the number of rolls from luigi's file string line; ifstream rollslist; ifstream luigi; luigi.open("data/luigi.txt"); if(!luigi){ cout<<"WARNING luigi.txt do not exist"<<endl; } cout<<"Reading Luigis file"<<endl; int l=0; while(!luigi.eof()){ getline(luigi,line); l++; } const int runsAmmount = l-1; //Being defined the variables and constants const int P=200; ifstream runsData; TGraphErrors * hvcls; const int runsHavingInAccount = runsAmmount -3; float ex[runsAmmount]; float HV[runsAmmount]; float EFF[runsAmmount]; float ERR[runsAmmount]; float EXP[runsAmmount]; float CLS[runsAmmount]; float hv[runsHavingInAccount]; float cls[runsHavingInAccount]; float exc[runsHavingInAccount]; float ecls[runsHavingInAccount]; ifstream rolls; string rollName; double ca,cb; double chi2,wp,clswp; double knee,clsknee; ifstream fitData; TCanvas *c1 = new TCanvas("C1","CLS VS HV",200,10,800,600); TF1 *f1; float wpCh[1]; float clsWpCh[1]; float hvc[2]; float CLSc[2]; float xmax=9.9; float xmin = 8.5; float x[P]; float y[P]; double wpDef; double clsWpDef; ifstream wpChannel; rolls.open("data/Barrel.txt"); rolls>>rollName; while (!rolls.eof()){ //Being charged the working point per channel associated with the current roll /* wpChannel.open(("results/"+rollName+"/wpChannel.txt").c_str()); wpChannel>>wpDef; cout<<"wpDef= "<<wpDef<<endl; wpChannel.close(); */ //Being charged the run data for the current roll runsData.open(("results/"+rollName+"/runsData.txt").c_str()); for (int n=0;n<runsAmmount;n++){ runsData>>HV[n]>>EFF[n]>>ERR[n]>>EXP[n]>>CLS[n]; //The first three runs (lower high voltage) are not plotted if (n>2){ hv[n-3]=HV[n]; cls[n-3]=CLS[n]; } } runsData.close(); ///////////////////////////////// The error in this cases is defined in this way, this is something that must be improved for(int n=0;n<runsAmmount;n++){ if (n>2){ exc[n-3]=0.0001; ecls[n-3] = 0.0001; } } ////////////////////////////////////////////////////// //Being charged the fit data obtained for the current roll hvcls = new TGraphErrors(runsHavingInAccount, hv, cls, exc, ecls); cout<<rollName; fitData.open(("results/"+rollName+"/fitDataCLS.txt").c_str()); fitData>>ca>>cb>>chi2>>wp>>clswp>>wpDef>>clsWpDef; cout<<ca<<" "<<cb<<" "<<wp<<" "<<clswp<<endl; fitData.close(); f1 = new TF1("f1",expFunc,8.5,9.9,2); //3 es el numero de parametros del fit// f1->SetParameter(0, ca); f1->SetParameter(1, cb);// //Being made the plot of Working Point and Knee knee = wp - 0.100; clsknee=expFuncAMano(knee,ca,cb); hvc[0]=wp - 0.100; hvc[1]=wp; CLSc[0]=clsknee; CLSc[1]=clswp; TGraph *gr2 = new TGraph(2,hvc,CLSc); //Being made the plot of Working Point per Channel wpCh[0]=wpDef; clsWpCh[0]=clsWpDef; TGraph *gr4 = new TGraph(1,wpCh,clsWpCh); //Being made the plot of the sigmoid for (int k=0; k<P; k++){ x[k]=xmin+k*(xmax-xmin)/(P-1); y[k]=expFuncAMano(x[k],ca,cb); x[k]=x[k]; } TGraph *gr3 = new TGraph(200,x,y); //Being set plot parameters hvcls->SetLineColor(kRed); hvcls->SetMarkerStyle(20); hvcls->SetMarkerSize(2.0); hvcls->SetMinimum(-0.01); hvcls->SetMaximum(6); TAxis *axis = hvcls->GetXaxis(); axis->SetLimits(8.5,9.9); hvcls->SetTitle(("CLS vs HV_Eff " + rollName).c_str()); hvcls->GetXaxis()->SetTitle("HV_Eff(kV)"); hvcls->GetYaxis()->SetTitle("CLS"); hvcls->Draw("AP"); gr3->SetLineColor(kBlue); gr3->Draw("C");// superimpose the second graph by leaving out the axis option "A" gr2->SetMarkerStyle(28); gr2->SetMarkerSize(3); gr2->SetLineColor(kBlue); gr2->Draw("P"); gr4->SetMarkerStyle(24); gr4->SetMarkerSize(5); gr4->SetLineColor(kRed); gr4->Draw("P"); //Being stored the plot as png file gSystem->mkdir(("results/"+rollName).c_str()); c1->SaveAs(("results/"+rollName+"/CLSvsHV.png").c_str()); c1->Clear(); //} rolls>>rollName; } exit(0); }
int ntuAnalyzer(std::string fileName) { setGlobalStyle(); //############################### //## run274200 ## unsigned int HT250Calo = 9; //index of DST_HT250_CaloScouting_v old:1 ref:9 float HT250Calo_rate = 1928; unsigned int HT410PF = 7; //index of DST_HT410_PFScouting_v old:3 ref:7 float HT410PF_rate = 294; unsigned int MJJ200Calo = 12; //index of DST_DiCaloWideJetMass200_CaloScouting_v unsigned int HTT200 = 0; //index if L1_HTT200 unsigned int HTT240 = 1; //index if L1_HTT240 unsigned int HTT270 = 2; //index if L1_HTT270 unsigned int HTT280 = 3; //index if L1_HTT280 unsigned int DoubleJetC100 = 7; //index if L1_DoubleJetC100 unsigned int DoubleJetC112 = 8; //index if L1_DoubleJetC112 unsigned int DoubleIsoTau28er = 11; //index if L1_DoubleJetC112 float instLumi = 0.4; //E34 float targetLumi = 1; //E34 float lumiScaleFactor = targetLumi/instLumi; float PDRate = 59300; //unprescaled rate of HLTPhysics accordingly to: https://cmswbm2.web.cern.ch/cmswbm2/cmsdb/servlet/DatasetSummary?RUN=274200 and prescale of 9000 unsigned int L1scenario = HTT240; //############################### TChain* tt = new TChain("MyAnalysis/HLTree"); tt->Add(fileName.c_str()); //set branches TBranch* b_lumi; TBranch* b_caloMjj; TBranch* b_PFMjj; TBranch* b_hltAccept; TBranch* b_l1Accept; TBranch* b_l1Names; TBranch* b_caloJet1Pt; TBranch* b_caloJet2Pt; TBranch* b_caloJet1Eta; TBranch* b_caloJet2Eta; TBranch* b_caloDeltaEta; TBranch* b_PFJet1Pt; TBranch* b_PFJet2Pt; TBranch* b_PFJet1Eta; TBranch* b_PFJet2Eta; TBranch* b_PFDeltaEta; int lumi = 0; float caloMjj = 0; float PFMjj = 0; float caloJet1Pt_ = 0; float caloJet2Pt_ = 0; float caloJet1Eta_ = -999; float caloJet2Eta_ = -999; float caloDeltaEta_ = -999; float PFJet1Pt_ = 0; float PFJet2Pt_ = 0; float PFJet1Eta_ = -999; float PFJet2Eta_ = -999; float PFDeltaEta_ = -999; std::vector<int>* hltAccept = 0; std::vector<int>* l1Accept = 0; std::vector<string>* l1Names = 0; tt->SetBranchAddress("lumi", &lumi, &b_lumi); tt->SetBranchAddress("caloMjj", &caloMjj, &b_caloMjj); tt->SetBranchAddress("PFMjj", &PFMjj, &b_PFMjj); tt->SetBranchAddress("caloJet1Pt", &caloJet1Pt_, &b_caloJet1Pt); tt->SetBranchAddress("caloJet2Pt", &caloJet2Pt_, &b_caloJet2Pt); tt->SetBranchAddress("caloJet1Eta", &caloJet1Eta_, &b_caloJet1Eta); tt->SetBranchAddress("caloJet2Eta", &caloJet2Eta_, &b_caloJet2Eta); tt->SetBranchAddress("caloDeltaEta", &caloDeltaEta_, &b_caloDeltaEta); tt->SetBranchAddress("PFJet1Pt", &PFJet1Pt_, &b_PFJet1Pt); tt->SetBranchAddress("PFJet2Pt", &PFJet2Pt_, &b_PFJet2Pt); tt->SetBranchAddress("PFJet1Eta", &PFJet1Eta_, &b_PFJet1Eta); tt->SetBranchAddress("PFJet2Eta", &PFJet2Eta_, &b_PFJet2Eta); tt->SetBranchAddress("PFDeltaEta", &PFDeltaEta_, &b_PFDeltaEta); tt->SetBranchAddress("hltAccept", &hltAccept, &b_hltAccept); tt->SetBranchAddress("l1Accept", &l1Accept, &b_l1Accept); tt->SetBranchAddress("l1Names", &l1Names, &b_l1Names); int nentries = tt->GetEntries(); std::cout << "Number of entries: " << nentries << std::endl; //book graphs and plots float min = 0.; float max = 1000.; int nBins = 20; TF1* f1 = new TF1("f1","[0]*TMath::Erf((x-[1])/[2])-[0]*TMath::Erf((-x-[1])/[2])",min,max); f1->SetParameters(0.5,350,40); f1->FixParameter(0,0.5); f1->SetLineWidth(2.); f1->SetLineColor(kRed); TF1* f2 = (TF1*)f1->Clone("f2"); f2->SetParameters(0.5,150,10); f2->SetLineColor(kBlack); TH1F* caloMjjSpectrum = new TH1F("caloMjjSpectrum","caloMjjSpectrum",nBins,min,max); TH1F* PFMjjSpectrum = new TH1F("PFMjjSpectrum","PFMjjSpectrum",nBins,min,max); TEfficiency* mjj450_eff = new TEfficiency("mjj450_eff","mjj450_eff",nBins,min,max); mjj450_eff->SetMarkerColor(kRed); mjj450_eff->SetLineColor(kRed); mjj450_eff->SetLineWidth(2); mjj450_eff->SetTitle("turnOn;Mjj [GeV]"); TEfficiency* mjj200_eff = new TEfficiency("mjj200_eff","mjj200_eff",nBins,min,max); mjj200_eff->SetLineWidth(2); mjj200_eff->SetTitle("turnOn;Mjj [GeV]"); TEfficiency* pf410_eff = new TEfficiency("pf410_eff","pf410_eff",nBins,min,max); pf410_eff->SetMarkerColor(kOrange+1); pf410_eff->SetLineColor(kOrange+1); TEfficiency* calo250_eff = new TEfficiency("calo250_eff","calo250_eff",nBins,min,max); calo250_eff->SetMarkerColor(kBlue); calo250_eff->SetLineColor(kBlue); TEfficiency* HTT240_eff = new TEfficiency("HTT240_eff","HTT240_eff",nBins,min,max); HTT240_eff->SetMarkerColor(kGreen+2); HTT240_eff->SetLineColor(kGreen+2); TH1F* l1 = new TH1F("l1","l1",14,0.,14.); TH1F* l2 = new TH1F("l2","l2",14,0.,14.); //loop for (Long64_t jentry=0; jentry<nentries;++jentry) { tt->GetEntry(jentry); //remove low rate lumis. //see: https://cmswbm2.web.cern.ch/cmswbm2/cmsdb/servlet/ChartHLTTriggerRates?RUNID=274200&PATHID=2043408&LSLENGTH=23.31040958&TRIGGER_PATH=DST_HT250_CaloScouting_v2 //if(lumi > 539 && lumi < 553) continue; //l1 and hlt rates for(unsigned int ii=0; ii<l1Names->size(); ++ii) if (l1Accept->at(ii)==1) l1->Fill(ii); //analysis cuts needed to compare to the analysis //calo analysis if (caloJet1Pt_ > 60. && caloJet2Pt_ > 30. && fabs(caloJet1Eta_) < 2.5 && fabs(caloJet2Eta_) < 2.5 && caloDeltaEta_ < 1.3) { caloMjjSpectrum->Fill(caloMjj); mjj200_eff->Fill((caloMjj>200 && l1Accept->at(L1scenario)==1) || hltAccept->at(HT250Calo)==1, caloMjj); calo250_eff->Fill((hltAccept->at(HT250Calo)==1 && l1Accept->at(L1scenario)==1), caloMjj); //references HTT240_eff->Fill(l1Accept->at(HTT240)==1, caloMjj); //l1 and hlt rates for(unsigned int ii=0; ii<l1Names->size(); ++ii) if (l1Accept->at(ii)==1) l2->Fill(ii); } //PF analysis if (PFJet1Pt_ > 60. && PFJet2Pt_ > 30. && fabs(PFJet1Eta_) < 2.5 && fabs(PFJet2Eta_) < 2.5 && PFDeltaEta_ < 1.3) { PFMjjSpectrum->Fill(PFMjj); mjj450_eff->Fill((caloMjj>450 && l1Accept->at(L1scenario)==1) || hltAccept->at(HT410PF)==1, PFMjj); pf410_eff->Fill((hltAccept->at(HT410PF)==1 && l1Accept->at(L1scenario)==1), PFMjj); } } mjj450_eff->Fit(f1,"r"); mjj200_eff->Fit(f2,"r"); caloMjjSpectrum->Scale(1./caloMjjSpectrum->GetBinContent(caloMjjSpectrum->GetMaximumBin())); PFMjjSpectrum->Scale(1./PFMjjSpectrum->GetBinContent(PFMjjSpectrum->GetMaximumBin())); TLegend* leg0 = new TLegend(0.62, 0.78, 0.83, 0.89); leg0->AddEntry(mjj200_eff,"MJJ200Calo || HT250Calo","L"); leg0->AddEntry(calo250_eff,"HT250_Calo","P"); leg0->AddEntry(HTT240_eff,"HTT240","P"); TLegend* leg1 = new TLegend(0.62, 0.78, 0.83, 0.89); leg1->AddEntry(mjj450_eff,"MJJ450PF || HT410PF","L"); leg1->AddEntry(pf410_eff,"HT410_PF","P"); TCanvas* c1 = new TCanvas(); mjj200_eff->Draw(); calo250_eff->Draw("sames"); HTT240_eff->Draw("sames"); caloMjjSpectrum->Draw("L,sames"); leg0->Draw("sames"); TCanvas* c2 = new TCanvas(); mjj450_eff->Draw(); pf410_eff->Draw("sames"); PFMjjSpectrum->Draw("L,sames"); leg1->Draw("sames"); TCanvas* c3 = new TCanvas(); //l1->Scale(PDRate/nentries); for(unsigned int ii=0; ii<l1Names->size(); ++ii) l1->GetXaxis()->SetBinLabel(ii+1,l1Names->at(ii).c_str()); //l1->GetYaxis()->SetTitle("L1 Rate @4E33 [Hz]"); l1->SetMaximum(l1->GetMaximum()+200); l2->SetLineColor(kRed); l1->Draw(); l2->Draw("same"); c3->Update(); // TGaxis *l1axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(), gPad->GetUymax(), // l1->GetMinimum()*lumiScaleFactor, // l1->GetMaximum()*lumiScaleFactor,510,"+L"); // c2->SetTicky(0); // l1axis->SetLineColor(kRed); // l1axis->SetLabelColor(kRed); // l1axis->SetTextColor(kRed); // l1axis->SetTitleOffset(1.3); // l1axis->SetLabelSize(0.03); // l1axis->SetTitle("L1 Rate @1E34 [Hz]"); // l1axis->Draw(); //return 0; //############################################## //############################################## //book graphs and plots TGraphErrors* totRateVsCut = new TGraphErrors(); totRateVsCut->SetMinimum(0); TGraphErrors* pureRateVsCut450 = new TGraphErrors(); TGraphErrors* pureRateVsCut280 = new TGraphErrors(); //loops int bin = 0; for (int cut = 350; cut < 500; cut=cut+10) { int mjjPassed = 0; int HT250Calo_Passed = 0; int excl410_passed = 0; int excl250_passed = 0; for (Long64_t jentry=0; jentry<nentries;++jentry) { tt->GetEntry(jentry); if (hltAccept->at(HT250Calo) == 1) ++HT250Calo_Passed; //if (caloMjj > cut && !hltAccept->at(HT410PF)) if (caloMjj > cut && l1Accept->at(L1scenario) == 1 && hltAccept->at(HT410PF)==0) ++excl410_passed; if (caloMjj > cut && l1Accept->at(L1scenario)==1 && hltAccept->at(HT250Calo)==0) ++excl250_passed; if (caloMjj > cut && l1Accept->at(L1scenario)==1) ++mjjPassed; // if (hltAccept->at(HT250Calo) == 0 && mjj > cut) // std::cout << "ref trigger doesn't completely cover cut at " << cut << std::endl; } // float mjjTotalRate = (float)mjjPassed/(float)HT250Calo_Passed*HT250Calo_rate; // float mjjPureRate = (float)exclPassed/(float)HT250Calo_Passed*HT250Calo_rate; float sigmaMjjPassed = sqrt((float)mjjPassed); float sigmaNentries = sqrt((float)nentries); float sigmaExcl410_passed = sqrt((float)excl410_passed); float sigmaExcl250_passed = sqrt((float)excl250_passed); float mjjTotalRate = (float)mjjPassed/(float)nentries*PDRate; float mjjTotalRateE = PDRate*sqrt(pow((sigmaMjjPassed/nentries),2)+pow((sigmaNentries*mjjPassed/nentries/nentries),2)); float mjj450_PureRate = (float)excl410_passed/(float)nentries*PDRate; float mjj450_PureRateE = PDRate*sqrt(pow((sigmaExcl410_passed/nentries),2)+pow((sigmaNentries*excl410_passed/nentries/nentries),2)); float mjj280_PureRate = (float)excl250_passed/(float)nentries*PDRate; float mjj280_PureRateE = PDRate*sqrt(pow((sigmaExcl250_passed/nentries),2)+pow((sigmaNentries*excl250_passed/nentries/nentries),2)); totRateVsCut->SetPoint(bin,cut,mjjTotalRate); totRateVsCut->SetPointError(bin,0.,mjjTotalRateE); pureRateVsCut450->SetPoint(bin,cut,mjj450_PureRate); pureRateVsCut450->SetPointError(bin,0.,mjj450_PureRateE); pureRateVsCut280->SetPoint(bin,cut,mjj280_PureRate); pureRateVsCut280->SetPointError(bin,0.,mjj280_PureRateE); ++bin; } //plotting and styling TLegend* leg = new TLegend(0.62, 0.78, 0.83, 0.89); leg->AddEntry(totRateVsCut,"total rate","P"); leg->AddEntry(pureRateVsCut450,"pure rate wrt HT410PF","P"); leg->AddEntry(pureRateVsCut280,"pure rate wrt HT250Calo","P"); totRateVsCut->SetTitle("Rate Ref"); totRateVsCut->GetXaxis()->SetTitle("Mjj cut threshold [GeV]"); totRateVsCut->GetYaxis()->SetTitle("Rate @4E33 [Hz]"); pureRateVsCut450->SetMarkerColor(kRed); pureRateVsCut450->SetLineColor(kRed); pureRateVsCut280->SetMarkerColor(kOrange+1); pureRateVsCut280->SetLineColor(kOrange+1); TCanvas* c4 = new TCanvas(); c4->cd(); totRateVsCut->Draw("AP"); pureRateVsCut450->Draw("P,sames"); pureRateVsCut280->Draw("P,sames"); leg->Draw("sames"); c4->Update(); TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(), gPad->GetUymax(), (totRateVsCut->GetYaxis()->GetBinLowEdge(1))*lumiScaleFactor, (totRateVsCut->GetYaxis()->GetBinLowEdge(totRateVsCut->GetYaxis()->GetNbins())+totRateVsCut->GetYaxis()->GetBinWidth(1))*lumiScaleFactor,510,"+L"); c4->SetTicky(0); axis->SetLineColor(kRed); axis->SetLabelColor(kRed); axis->SetTextColor(kRed); axis->SetTitleOffset(1.3); axis->SetLabelSize(0.03); axis->SetTitle("Rate @1E34 [Hz]"); axis->Draw(); return 0; }
TGraphErrors * drawAll() { TFile *_file1 = TFile::Open("here.root"); // use also an old style file?? bool old = false; TFile *_file2; if (old == true){ _file2= TFile::Open("jetTagAnalysis.root"); } vector<TFile *> files; vector<string> algos; algos.push_back("trackCountingHighPurBJetTags"); algos.push_back("trackCountingHighEffBJetTags"); algos.push_back("jetProbabilityBJetTags"); algos.push_back("jetBProbabilityBJetTags"); algos.push_back("simpleSecondaryVertexBJetTags"); algos.push_back("combinedSecondaryVertexBJetTags"); algos.push_back("softMuonBJetTags"); algos.push_back("softMuonByIP3dBJetTags"); algos.push_back("softMuonByPtBJetTags"); algos.push_back("softElectronBJetTags"); TLegend * leg = new TLegend(0.2,0.65,0.4,0.9); TCanvas * c1 = new TCanvas(); c1->SetLogy(); c1->SetGridy(); c1->SetGridx(); for(int i = 0 ; i < algos.size() ; i++) { cout << algos[i] << endl; // get the eff vs dicriminant TH1F* effdiscrb = (TH1F *) getHistogram(_file1,algos[i],"effVsDiscrCut_discr","GLOBAL", "B"); TH1F* effdiscruds = (TH1F *) getHistogram(_file1,algos[i],"effVsDiscrCut_discr","GLOBAL", "DUS"); cout <<" HISTOS "<<effdiscrb <<" " <<effdiscruds<<endl; TGraphErrors * h = computeGraph(effdiscrb,effdiscruds); // h->SetMaximum(1.); h->SetMinimum(1e-5); // h->GetXaxis()->SetLimits(0,.2); // h->GetYaxis()->SetLimits(1e-4,1); cout << h << endl; // return h; setStyle(i,h); if(i==0) h->Draw("ALP"); else h->Draw("lpsame"); leg->AddEntry(h,algos[i].c_str(),"p"); } if (old == true){ for(int i = 0 ; i < algos.size() ; i++) { cout << algos[i] << endl; // get the eff vs dicriminant TH1F* effdiscrb = (TH1F *) getHistogram2(_file2,algos[i],"effVsDiscrCut_discr","GLOBAL", "B"); TH1F* effdiscruds = (TH1F *) getHistogram2(_file2,algos[i],"effVsDiscrCut_discr","GLOBAL", "DUS"); cout <<" HISTOS "<<effdiscrb <<" " <<effdiscruds<<endl; TGraphErrors * h = computeGraph(effdiscrb,effdiscruds); // h->SetMaximum(1.); h->SetMinimum(1e-5); // h->GetXaxis()->SetLimits(0,.2); // h->GetYaxis()->SetLimits(1e-4,1); cout << h << endl; // return h; setStyle(i+10,h); // if(i==0) h->Draw("ALP"); else h->Draw("lpsame"); leg->AddEntry(h,algos[i].c_str(),"p"); } } leg->Draw("same"); }
int rate(std::string fileName) { setGlobalStyle(); //############################### //## run274200 ## unsigned int HT250Calo = 9; //index of DST_HT250_CaloScouting_v old:1 ref:9 unsigned int HT410PF = 7; //index of DST_HT410_PFScouting_v old:3 ref:7 unsigned int MJJ200Calo = 12; //index of DST_DiCaloWideJetMass200_CaloScouting_v unsigned int HTT200 = 0; //index if L1_HTT200 unsigned int HTT240 = 1; //index if L1_HTT240 unsigned int HTT270 = 2; //index if L1_HTT270 unsigned int HTT280 = 3; //index if L1_HTT280 unsigned int DoubleJetC100 = 7; //index if L1_DoubleJetC100 unsigned int DoubleJetC112 = 8; //index if L1_DoubleJetC112 unsigned int DoubleIsoTau28er = 11; //index if L1_DoubleJetC112 float instLumi = 0.71; //E34 float targetLumi = 1; //E34 float lumiScaleFactor = targetLumi/instLumi; float PDRate = 21986976; //unprescaled rate of ParkingZeroBias accordingly to: nEv/(nLS*23.3)*hltPresc*l1Presc [*nPDs?] = 2343149/(824*23,3)*12*15013 unsigned int L1MjjThr = 150; //############################### TChain* tt = new TChain("MyAnalysis/HLTree"); tt->Add(fileName.c_str()); //set branches TBranch* b_lumi; TBranch* b_caloMjj; TBranch* b_PFMjj; TBranch* b_caloWMjj; TBranch* b_PFWMjj; TBranch* b_l1Mjj; TBranch* b_hltAccept; TBranch* b_l1Accept; TBranch* b_l1Names; TBranch* b_caloJet1Pt; TBranch* b_caloJet2Pt; TBranch* b_caloJet1Eta; TBranch* b_caloJet2Eta; TBranch* b_caloJet1Phi; TBranch* b_caloJet2Phi; TBranch* b_caloDeltaEta; TBranch* b_caloWJet1Pt; TBranch* b_caloWJet2Pt; TBranch* b_caloWJet1Eta; TBranch* b_caloWJet2Eta; TBranch* b_caloWJet1Phi; TBranch* b_caloWJet2Phi; TBranch* b_caloWDeltaEta; TBranch* b_PFJet1Pt; TBranch* b_PFJet2Pt; TBranch* b_PFJet1Eta; TBranch* b_PFJet2Eta; TBranch* b_PFJet1Phi; TBranch* b_PFJet2Phi; TBranch* b_PFDeltaEta; TBranch* b_PFWJet1Pt; TBranch* b_PFWJet2Pt; TBranch* b_PFWJet1Eta; TBranch* b_PFWJet2Eta; TBranch* b_PFWJet1Phi; TBranch* b_PFWJet2Phi; TBranch* b_PFWDeltaEta; TBranch* b_l1Jet1Pt; TBranch* b_l1Jet2Pt; TBranch* b_l1Jet1Eta; TBranch* b_l1Jet2Eta; TBranch* b_l1Jet1Phi; TBranch* b_l1Jet2Phi; TBranch* b_l1DeltaEta; TBranch* b_l1JetPt; TBranch* b_l1JetEta; TBranch* b_l1JetPhi; int lumi = 0; float caloMjj = 0; float PFMjj = 0; float caloWMjj = 0; float PFWMjj = 0; float l1Mjj = 0; float caloJet1Pt_ = 0; float caloJet2Pt_ = 0; float caloJet1Eta_ = -999; float caloJet2Eta_ = -999; float caloJet1Phi_ = -999; float caloJet2Phi_ = -999; float caloDeltaEta_ = -999; float caloWJet1Pt_ = 0; float caloWJet2Pt_ = 0; float caloWJet1Eta_ = -999; float caloWJet2Eta_ = -999; float caloWJet1Phi_ = -999; float caloWJet2Phi_ = -999; float caloWDeltaEta_ = -999; float PFJet1Pt_ = 0; float PFJet2Pt_ = 0; float PFJet1Eta_ = -999; float PFJet2Eta_ = -999; float PFJet1Phi_ = -999; float PFJet2Phi_ = -999; float PFDeltaEta_ = -999; float PFWJet1Pt_ = 0; float PFWJet2Pt_ = 0; float PFWJet1Eta_ = -999; float PFWJet2Eta_ = -999; float PFWJet1Phi_ = -999; float PFWJet2Phi_ = -999; float PFWDeltaEta_ = -999; float l1Jet1Pt_ = 0; float l1Jet2Pt_ = 0; float l1Jet1Eta_ = -999; float l1Jet2Eta_ = -999; float l1Jet1Phi_ = -999; float l1Jet2Phi_ = -999; float l1DeltaEta_ = -999; std::vector<float>* l1JetPt_ = 0; std::vector<float>* l1JetEta_ = 0; std::vector<float>* l1JetPhi_ = 0; std::vector<int>* hltAccept = 0; std::vector<int>* l1Accept = 0; std::vector<string>* l1Names = 0; tt->SetBranchAddress("lumi", &lumi, &b_lumi); tt->SetBranchAddress("caloMjj", &caloMjj, &b_caloMjj); tt->SetBranchAddress("PFMjj", &PFMjj, &b_PFMjj); tt->SetBranchAddress("caloWMjj", &caloWMjj, &b_caloWMjj); tt->SetBranchAddress("PFWMjj", &PFWMjj, &b_PFWMjj); tt->SetBranchAddress("l1Mjj", &l1Mjj, &b_l1Mjj); tt->SetBranchAddress("caloJet1Pt", &caloJet1Pt_, &b_caloJet1Pt); tt->SetBranchAddress("caloJet2Pt", &caloJet2Pt_, &b_caloJet2Pt); tt->SetBranchAddress("caloJet1Eta", &caloJet1Eta_, &b_caloJet1Eta); tt->SetBranchAddress("caloJet2Eta", &caloJet2Eta_, &b_caloJet2Eta); tt->SetBranchAddress("caloJet1Phi", &caloJet1Phi_, &b_caloJet1Phi); tt->SetBranchAddress("caloJet2Phi", &caloJet2Phi_, &b_caloJet2Phi); tt->SetBranchAddress("caloDeltaEta", &caloDeltaEta_, &b_caloDeltaEta); tt->SetBranchAddress("caloWJet1Pt", &caloWJet1Pt_, &b_caloWJet1Pt); tt->SetBranchAddress("caloWJet2Pt", &caloWJet2Pt_, &b_caloWJet2Pt); tt->SetBranchAddress("caloWJet1Eta", &caloWJet1Eta_, &b_caloWJet1Eta); tt->SetBranchAddress("caloWJet2Eta", &caloWJet2Eta_, &b_caloWJet2Eta); tt->SetBranchAddress("caloWJet1Phi", &caloWJet1Phi_, &b_caloWJet1Phi); tt->SetBranchAddress("caloWJet2Phi", &caloWJet2Phi_, &b_caloWJet2Phi); tt->SetBranchAddress("caloWDeltaEta", &caloWDeltaEta_, &b_caloWDeltaEta); tt->SetBranchAddress("PFJet1Pt", &PFJet1Pt_, &b_PFJet1Pt); tt->SetBranchAddress("PFJet2Pt", &PFJet2Pt_, &b_PFJet2Pt); tt->SetBranchAddress("PFJet1Eta", &PFJet1Eta_, &b_PFJet1Eta); tt->SetBranchAddress("PFJet2Eta", &PFJet2Eta_, &b_PFJet2Eta); tt->SetBranchAddress("PFJet1Phi", &PFJet1Phi_, &b_PFJet1Phi); tt->SetBranchAddress("PFJet2Phi", &PFJet2Phi_, &b_PFJet2Phi); tt->SetBranchAddress("PFDeltaEta", &PFDeltaEta_, &b_PFDeltaEta); tt->SetBranchAddress("PFWJet1Pt", &PFWJet1Pt_, &b_PFWJet1Pt); tt->SetBranchAddress("PFWJet2Pt", &PFWJet2Pt_, &b_PFWJet2Pt); tt->SetBranchAddress("PFWJet1Eta", &PFWJet1Eta_, &b_PFWJet1Eta); tt->SetBranchAddress("PFWJet2Eta", &PFWJet2Eta_, &b_PFWJet2Eta); tt->SetBranchAddress("PFWJet1Phi", &PFWJet1Phi_, &b_PFWJet1Phi); tt->SetBranchAddress("PFWJet2Phi", &PFWJet2Phi_, &b_PFWJet2Phi); tt->SetBranchAddress("PFWDeltaEta", &PFWDeltaEta_, &b_PFWDeltaEta); tt->SetBranchAddress("l1Jet1Pt", &l1Jet1Pt_, &b_l1Jet1Pt); tt->SetBranchAddress("l1Jet2Pt", &l1Jet2Pt_, &b_l1Jet2Pt); tt->SetBranchAddress("l1Jet1Eta", &l1Jet1Eta_, &b_l1Jet1Eta); tt->SetBranchAddress("l1Jet2Eta", &l1Jet2Eta_, &b_l1Jet2Eta); tt->SetBranchAddress("l1Jet1Phi", &l1Jet1Phi_, &b_l1Jet1Phi); tt->SetBranchAddress("l1Jet2Phi", &l1Jet2Phi_, &b_l1Jet2Phi); tt->SetBranchAddress("l1DeltaEta", &l1DeltaEta_, &b_l1DeltaEta); tt->SetBranchAddress("l1JetPt", &l1JetPt_, &b_l1JetPt); tt->SetBranchAddress("l1JetEta", &l1JetEta_, &b_l1JetEta); tt->SetBranchAddress("l1JetPhi", &l1JetPhi_, &b_l1JetPhi); tt->SetBranchAddress("hltAccept", &hltAccept, &b_hltAccept); tt->SetBranchAddress("l1Accept", &l1Accept, &b_l1Accept); tt->SetBranchAddress("l1Names", &l1Names, &b_l1Names); int nentries = tt->GetEntries(); std::cout << "Number of entries: " << nentries << std::endl; //book graphs and plots float min = 0.; float max = 1000.; int nBins = 20; TF1* f1 = new TF1("f1","[0]*TMath::Erf((x-[1])/[2])-[0]*TMath::Erf((-x-[1])/[2])",min,max); f1->SetParameters(0.5,350,40); f1->FixParameter(0,0.5); f1->SetLineWidth(2.); f1->SetLineColor(kRed); TF1* f2 = (TF1*)f1->Clone("f2"); f2->SetParameters(0.5,150,10); f2->SetLineColor(kBlack); //############################################## //############################################## //book graphs and plots TGraphErrors* totL1RateVsCut = new TGraphErrors(); totL1RateVsCut->SetMinimum(0); TGraphErrors* pureL1RateVsCut = new TGraphErrors(); TGraphErrors* totHltRateVsCut = new TGraphErrors(); totHltRateVsCut->SetMinimum(0); TGraphErrors* pureHltRateVsCut = new TGraphErrors(); //loops int bin = 0; for (int cut = 200; cut < 350; cut=cut+10) { std::cout << "analyzing point at " << cut << " GeV" << std::endl; int mjjHltPassed = 0; int excl_mjjHltPassed = 0; int mjjL1Passed = 0; int excl_mjjL1Passed = 0; int HTT240Passed = 0; for (Long64_t jentry=0; jentry<nentries;++jentry) { tt->GetEntry(jentry); //### Sanity checks ### if (l1Accept->at(HTT240) == 1) ++HTT240Passed; //### L1 ### bool l1Pass = (l1Mjj>cut && l1Jet1Pt_ > 15. && l1Jet2Pt_ > 15. && fabs(l1Jet1Eta_) < 5.0 && fabs(l1Jet2Eta_) < 5.0 && l1DeltaEta_ < 2.0 ); bool L1RefPass = (l1Mjj>L1MjjThr && l1Jet1Pt_ > 15. && l1Jet2Pt_ > 15. && fabs(l1Jet1Eta_) < 5.0 && fabs(l1Jet2Eta_) < 5.0 && l1DeltaEta_ < 2.0 ); // if(l1Pass && l1Accept->at(HTT240) == 0 && caloWMjj < 100 && caloWMjj>0) // { // std::cout << std::endl; // std::cout << std::fixed << std::setprecision(2) // << "l1Mjj-caloWMjj = " << l1Mjj-caloWMjj << " l1Mjj = " << l1Mjj << " caloWMjj = " << caloWMjj << std::endl; // std::cout << " caloWJet1Pt_ = " << caloWJet1Pt_ << " caloWJet1Eta_ = " << caloWJet1Eta_ << " caloWJet1Phi_ = " << caloWJet1Phi_ << std::endl; // std::cout << " l1Jet1Pt = " << l1Jet1Pt_ << " l1Jet1Eta = " << l1Jet1Eta_ << " l1Jet1Phi = " << l1Jet1Phi_ << std::endl; // std::cout << std::endl; // std::cout << " caloWJet2Pt_ = " << caloWJet2Pt_ << " caloWJet2Eta_ = " << caloWJet2Eta_ << " caloWJet2Phi_ = " << caloWJet2Phi_ << std::endl; // std::cout << " l1Jet2Pt = " << l1Jet2Pt_ << " l1Jet2Eta = " << l1Jet2Eta_ << " l1Jet2Phi = " << l1Jet2Phi_ << std::endl; // std::cout << "==========================================================" << std::endl; // } if (l1Pass) ++mjjL1Passed; if (l1Pass && l1Accept->at(HTT240) == 0) ++excl_mjjL1Passed; //### HLT ### //Hypothesis of HLT rates with L1Mjj seed at L1MjjThr if (caloWMjj > cut && L1RefPass) ++mjjHltPassed; if (caloWMjj > cut && L1RefPass && hltAccept->at(HT250Calo) == 0) ++excl_mjjHltPassed; } float HTT240rate = (float)HTT240Passed/(float)nentries*PDRate; //std::cout << "HTT240rate = " << HTT240rate << std::endl; float sigmaNentries = sqrt((float)nentries); float sigmaMjjHltPassed = sqrt((float)mjjHltPassed); float excl_sigmaMjjHltPassed = sqrt((float)excl_mjjHltPassed); float sigmaMjjL1Passed = sqrt((float)mjjL1Passed); float excl_sigmaMjjL1Passed = sqrt((float)excl_mjjL1Passed); float mjjHltRate = (float)mjjHltPassed/(float)nentries*PDRate; float mjjHltRateE = PDRate*sqrt(pow((sigmaMjjHltPassed/nentries),2)+pow((sigmaNentries*mjjHltPassed/nentries/nentries),2)); float excl_mjjHltRate = (float)excl_mjjHltPassed/(float)nentries*PDRate; float excl_mjjHltRateE = PDRate*sqrt(pow((excl_sigmaMjjHltPassed/nentries),2)+pow((sigmaNentries*excl_mjjHltPassed/nentries/nentries),2)); float mjjL1Rate = (float)mjjL1Passed/(float)nentries*PDRate; float mjjL1RateE = PDRate*sqrt(pow((sigmaMjjL1Passed/nentries),2)+pow((sigmaNentries*mjjL1Passed/nentries/nentries),2)); float excl_mjjL1Rate = (float)excl_mjjL1Passed/(float)nentries*PDRate; float excl_mjjL1RateE = PDRate*sqrt(pow((excl_sigmaMjjL1Passed/nentries),2)+pow((sigmaNentries*excl_mjjL1Passed/nentries/nentries),2)); totHltRateVsCut->SetPoint(bin,cut,mjjHltRate); totHltRateVsCut->SetPointError(bin,0.,mjjHltRateE); pureHltRateVsCut->SetPoint(bin,cut,excl_mjjHltRate); pureHltRateVsCut->SetPointError(bin,0.,excl_mjjHltRateE); totL1RateVsCut->SetPoint(bin,cut,mjjL1Rate); totL1RateVsCut->SetPointError(bin,0.,mjjL1RateE); pureL1RateVsCut->SetPoint(bin,cut,excl_mjjL1Rate); pureL1RateVsCut->SetPointError(bin,0.,excl_mjjL1RateE); ++bin; } //plotting and styling TLegend* legHlt = new TLegend(0.62, 0.78, 0.83, 0.89); legHlt->AddEntry(totHltRateVsCut,"hlt total rate","P"); legHlt->AddEntry(pureHltRateVsCut,"hlt pure rate wrt HT250","P"); TLegend* legL1 = new TLegend(0.62, 0.78, 0.83, 0.89); legL1->AddEntry(totL1RateVsCut,"l1 total rate","P"); legL1->AddEntry(pureL1RateVsCut,"l1 pure rate wrt HTT240","P"); totHltRateVsCut->GetXaxis()->SetTitle("Mjj cut threshold [GeV]"); totHltRateVsCut->GetYaxis()->SetTitle("Rate @7E33 [Hz]"); totHltRateVsCut->SetMarkerColor(kRed); pureHltRateVsCut->SetMarkerColor(kOrange+1); totL1RateVsCut->GetXaxis()->SetTitle("Mjj cut threshold [GeV]"); totL1RateVsCut->GetYaxis()->SetTitle("Rate @7E33 [Hz]"); totL1RateVsCut->SetMarkerColor(kBlue); totL1RateVsCut->SetMarkerColor(kAzure); TCanvas* c4 = new TCanvas(); c4->cd(); totHltRateVsCut->Draw("AP"); pureHltRateVsCut->Draw("P,sames"); legHlt->Draw("sames"); c4->Update(); TGaxis *axisHlt = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(), gPad->GetUymax(), (totHltRateVsCut->GetYaxis()->GetBinLowEdge(1))*lumiScaleFactor, (totHltRateVsCut->GetYaxis()->GetBinLowEdge(totHltRateVsCut->GetYaxis()->GetNbins())+totHltRateVsCut->GetYaxis()->GetBinWidth(1))*lumiScaleFactor,510,"+L"); c4->SetTicky(0); axisHlt->SetLineColor(kRed); axisHlt->SetLabelColor(kRed); axisHlt->SetTextColor(kRed); axisHlt->SetTitleOffset(1.3); axisHlt->SetLabelSize(0.03); axisHlt->SetTitle("Rate @1E34 [Hz]"); axisHlt->Draw(); c4->Print("rates/hltRate.pdf","pdf"); TCanvas* c5 = new TCanvas(); c5->cd(); totL1RateVsCut->Draw("AP"); pureL1RateVsCut->Draw("P,sames"); legL1->Draw("sames"); c5->Update(); TGaxis *axisL1 = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(), gPad->GetUymax(), (totL1RateVsCut->GetYaxis()->GetBinLowEdge(1))*lumiScaleFactor, (totL1RateVsCut->GetYaxis()->GetBinLowEdge(totL1RateVsCut->GetYaxis()->GetNbins())+totL1RateVsCut->GetYaxis()->GetBinWidth(1))*lumiScaleFactor,510,"+L"); c5->SetTicky(0); axisL1->SetLineColor(kRed); axisL1->SetLabelColor(kRed); axisL1->SetTextColor(kRed); axisL1->SetTitleOffset(1.3); axisL1->SetLabelSize(0.03); axisL1->SetTitle("Rate @1E34 [Hz]"); axisL1->Draw(); c5->Print("rates/l1Rate.pdf","pdf"); return 0; }
void GraphAndFit(){ int i, j; int NumOfBins_0 = 0, NumOfBins_1 = 0, NumOfBins_2 = 0, NumOfBins_3 = 0; float x[4], ex[4], mask[4]; string line, namesave; ofstream hvscaninfo; TFile *_file0 = TFile::Open("9000/67838.root"); TFile *_file1 = TFile::Open("9100/68288.root"); TFile *_file2 = TFile::Open("9200/66594.root"); TFile *_file3 = TFile::Open("9300/67647.root"); string name; string file; for(l=1;l<=10;l++){ if(l==1){ name = "GlobMaskedWheel_-2near"; file = "rollsWm2near.txt"; }else if(l==2){ name = "GlobMaskedWheel_-2far"; file = "rollsWm2far.txt"; }else if(l==3){ name = "GlobMaskedWheel_-1near"; file = "rollsWm1near.txt"; }else if(l==4){ name = "GlobMaskedWheel_-1far"; file = "rollsWm1far.txt"; }else if(l==5){ name = "GlobMaskedWheel_0near"; file = "rollsW0near.txt"; }else if(l==6){ name = "GlobMaskedWheel_0far"; file = "rollsW0far.txt"; }else if(l==7){ name = "GlobMaskedWheel_1near"; file = "rollsW1near.txt"; }else if(l==8){ name = "GlobMaskedWheel_1far"; file = "rollsW1far.txt"; }else if(l==9){ name = "GlobMaskedWheel_2near"; file = "rollsW2near.txt"; }else if(l==10){ name = "GlobMaskedWheel_2far"; file = "rollsW2far.txt"; } ifstream filein; //filein.open("rollsW2far.txt"); filein.open(file.c_str()); string output = "output" + file; hvscaninfo.open(output.c_str()); TH1F * masked0 = (TH1F*) (_file0->Get(name.c_str())); TH1F * masked1 = (TH1F*) (_file1->Get(name.c_str())); TH1F * masked2 = (TH1F*) (_file2->Get(name.c_str())); TH1F * masked3 = (TH1F*) (_file3->Get(name.c_str())); //cout<<"roll size"<<masked0->TH1F::GetNbinsX()<<endl; TGraphErrors * grp; TCanvas *C1 = new TCanvas("C1","Global Efficiency",200,10,800,600); C1->SetFillColor(10); C1->Draw(); C1->cd(); TF1 * f1; int k=1; while ( !filein.eof()){ //Masked Strips f1 = new TF1("f1",fitfunc,8.5,9.5, 3 ); f1->SetParameter(0, 80.0); f1->SetParameter(1, 100); f1->SetParameter(2, 8.9); float EFF_0 = 0, EFF_1 = 0, EFF_2 =0 , EFF_3 = 0; float ERR_0 = 0, ERR_1 = 0, ERR_2 =0 , ERR_3 = 0; float EFFSUM_0 = 0, EFFSUM_1 = 0, EFFSUM_2 = 0, EFFSUM_3 = 0; float ERRSUM_0 = 0, ERRSUM_1 = 0, ERRSUM_2 = 0, ERRSUM_3 = 0; float sqrtERR_0, sqrtERR_1, sqrtERR_2, sqrtERR_3; float avEFF[4]; float avERR[4]; getline(filein,line); //cout <<"In line"<< line << endl; string Roll = line; string name = "Profile_For_" + Roll; TH1F *HV9000 = (TH1F*)_file0->Get(name.c_str()); TH1F *HV9100 = (TH1F*)_file1->Get(name.c_str()); TH1F *HV9200 = (TH1F*)_file2->Get(name.c_str()); TH1F *HV9300 = (TH1F*)_file3->Get(name.c_str()); NumOfBins_0 = HV9000->TH1F::GetNbinsX(); NumOfBins_1 = HV9100->TH1F::GetNbinsX(); NumOfBins_2 = HV9200->TH1F::GetNbinsX(); NumOfBins_3 = HV9300->TH1F::GetNbinsX(); for(i = 1; i <= NumOfBins_0; ++i){ EFF_0 = HV9000->GetBinContent(i); ERR_0 = HV9000->GetBinError(i); EFFSUM_0 += EFF_0; ERRSUM_0 += ERR_0*ERR_0; } avEFF[0] = 100.*EFFSUM_0/NumOfBins_0; sqrtERR_0 = sqrt(ERRSUM_0); avERR[0] = 100.*sqrtERR_0/NumOfBins_0; for(i = 1; i <= NumOfBins_1; ++i){ EFF_1 = HV9100->GetBinContent(i); ERR_1 = HV9100->GetBinError(i); EFFSUM_1 += EFF_1; ERRSUM_1 += ERR_1*ERR_1; } avEFF[1] = 100.*EFFSUM_1/NumOfBins_1; sqrtERR_1 = sqrt(ERRSUM_1); avERR[1] = 100.*sqrtERR_1/NumOfBins_1; for(i = 1; i <= NumOfBins_2; ++i){ EFF_2 = HV9200->GetBinContent(i); ERR_2 = HV9200->GetBinError(i); EFFSUM_2 += EFF_2; ERRSUM_2 += ERR_2*ERR_2; } avEFF[2] = 100.*EFFSUM_2/NumOfBins_2; sqrtERR_2 = sqrt(ERRSUM_2); avERR[2] = 100.*sqrtERR_2/NumOfBins_2; for(i = 1; i <= NumOfBins_3; ++i){ EFF_3 = HV9300->GetBinContent(i); ERR_3 = HV9300->GetBinError(i); EFFSUM_3 += EFF_3; ERRSUM_3 += ERR_3*ERR_3; } avEFF[3] = 100.*EFFSUM_3/NumOfBins_3; sqrtERR_3 = sqrt(ERRSUM_3); avERR[3] = 100.*sqrtERR_3/NumOfBins_3; x[0] = 9.0; x[1] = 9.1; x[2] = 9.2; x[3] = 9.3; ex[0] = 0; ex[1] = 0; ex[2] = 0; ex[3] = 0; bool good=true; for(i=0;i<3;i++){ if(avEFF[i]-avEFF[i+1]>5.)good = false; if(avEFF[i]==0. || avEFF[i+1]==0.) good = false; } if(!good){ //cout<<Roll<<" bad scan"<<endl; }else{ //cout<<Roll<<" good scan"<<endl; } //cout << x[0] <<" : " << avEFF[0] << "------" << avERR[0] << endl; //cout << x[1] <<" : " << avEFF[1] << "------" << avERR[1] << endl; //cout << x[2] <<" : " << avEFF[2] << "------" << avERR[2] << endl; //cout << x[3] <<" : " << avEFF[3] << "------" << avERR[3] << endl; string titlename = "Efficiency vs HV " + Roll; namesave = "GlobalEff.png"; string foldername = Roll; string fullname = foldername + string("/") + namesave; grp = new TGraphErrors(4, x, avEFF, ex, avERR); grp->SetTitle(titlename.c_str()); grp->SetLineColor(kRed); grp->SetMarkerStyle(20); grp->SetMarkerSize(1.0); grp->SetMinimum(-0.01); grp->SetMaximum(100); grp->GetXaxis()->SetTitle("HV(kV)"); grp->GetYaxis()->SetTitle("Efficiency(%)"); grp->Fit(f1); grp->Draw("AP"); double emax=f1->GetParameter(0); double parameters[3]; parameters[0]=emax; parameters[1]=f1->GetParameter(1); parameters[2]=f1->GetParameter(2); for(i=0;i<3;i++){ cout<<"i="<<parameters[i]<<" "<<endl; } double hv[1]={0}; double wp=0; bool found=false; for(hv[0]=8.5;hv[0]<=9.7;hv[0]=hv[0]+0.01){ if(emax-amano(hv[0],f1->GetParameter(1),f1->GetParameter(0),f1->GetParameter(2))<=0.05 && found==false){ cout<<hv[0]<< " " <<amano(hv[0],f1->GetParameter(1),f1->GetParameter(0),f1->GetParameter(2))<<" "<<emax<<endl; wp=hv[0]; found=true; } } string cond = "bad"; if(good){ cond = "good"; } hvscaninfo<<Roll<<" "<<wp<<" "<<emax<<" "<<cond<<" roll scan"<<endl; TH1F * masked = new TH1F("Masked","Masked",4,8.95,9.35); masked->SetBinContent(1,masked0->GetBinContent(k)); masked->SetBinContent(2,masked1->GetBinContent(k)); masked->SetBinContent(3,masked2->GetBinContent(k)); masked->SetBinContent(4,masked3->GetBinContent(k)); masked->SetLineColor(kRed); masked->Draw("same"); gSystem->mkdir(foldername.c_str()); C1->SaveAs(fullname.c_str()); C1->Clear(); HV9000->SetLineColor(1); HV9100->SetLineColor(2); HV9200->SetLineColor(3); HV9300->SetLineColor(9); HV9000->SetMaximum(1); HV9100->SetMaximum(1); HV9200->SetMaximum(1); HV9300->SetMaximum(1); HV9000->Draw(); HV9100->Draw("same"); HV9200->Draw("same"); HV9300->Draw("same"); string titlename = "Profile " + Roll; HV9000->SetTitle(titlename.c_str()); HV9000->GetYaxis()->SetTitle("Efficiency(%)"); namesave = "Profile.png"; string foldername = Roll; string fullname = foldername + string("/") + namesave; C1->SaveAs(fullname.c_str()); C1->Clear(); delete grp; delete f1; delete masked; k++; } hvscaninfo.close(); } }
void IsoMultipole(Char_t* Mlp, Char_t* Iso, Bool_t SAVE=false, Double_t Lo=0.0, Double_t Hi=0.0) { if(SAVE) TCanvas* Canvas = new TCanvas(); //if(SAVE) SetBit(TH1::kNoTitle); FILE* InPlots; FILE* InModel_0; FILE* InModel_p; Char_t Buffer[256]; Char_t M, p; Int_t l; Double_t PlRe[N_MAX]; Double_t PlIm[N_MAX]; Double_t PlDRe[N_MAX]; Double_t PlDIm[N_MAX]; Double_t PlW[N_MAX]; Double_t MoRe_0[N_MAX]; Double_t MoRe_p[N_MAX]; Double_t MoIm_0[N_MAX]; Double_t MoIm_p[N_MAX]; Double_t MoW_0[N_MAX]; Double_t MoW_p[N_MAX]; Double_t MoRe[N_MAX]; Double_t MoIm[N_MAX]; Int_t PlPts; Int_t MoPts_0, MoPts_p; Double_t W, Re, DRe, Im, DIm; Double_t Min = 0.0; Double_t Max = 0.0; TGraphErrors* PlotsRe; TGraphErrors* PlotsIm; TGraph* ModelRe; TGraph* ModelIm; //Decompose multipole name sscanf(Mlp, "%c%d%c", &M, &l, &p); //Open text file with fit results for given multipole sprintf(Buffer, "isospin/%s_%s.txt", Mlp, Iso); InPlots = fopen(Buffer, "r"); //Skip two lines with table header fgets(Buffer, sizeof(Buffer), InPlots); fgets(Buffer, sizeof(Buffer), InPlots); //Read multipole fit values from file PlPts = 0; while(!feof(InPlots)) { if(fscanf(InPlots, "%lf %lf %lf %lf %lf", &W, &Re, &DRe, &Im, &DIm)==5) { //Look for maximum & minimum of values to adjust plotting range if(Re+DRe > Max) Max = Re+DRe; if(Im+DIm > Max) Max = Im+DIm; if(Re-DRe < Min) Min = Re-DRe; if(Im-DIm < Min) Min = Im-DIm; //Add real and imaginary parts of multipole (w/ errors) to graph PlW[PlPts] = W; PlRe[PlPts] = Re; PlIm[PlPts] = Im; PlDRe[PlPts] = DRe; PlDIm[PlPts] = DIm; PlPts++; } } //Close file with fit values fclose(InPlots); //Create graphs for real and imaginary parts of fitted multipole PlotsRe = new TGraphErrors(PlPts, PlW, PlRe, NULL, PlDRe); PlotsIm = new TGraphErrors(PlPts, PlW, PlIm, NULL, PlDIm); //Color, line size, marker style adjustments PlotsRe->SetLineColor(kRed+2); PlotsIm->SetLineColor(kBlue+2); PlotsRe->SetMarkerColor(kRed+2); PlotsIm->SetMarkerColor(kBlue+2); PlotsRe->SetMarkerStyle(21); PlotsIm->SetMarkerStyle(21); PlotsRe->SetMarkerSize(0.7); PlotsIm->SetMarkerSize(0.7); //Set plot titles and object names sprintf(Buffer, "%s_%s", Mlp, Iso); PlotsRe->SetTitle(Buffer); PlotsIm->SetTitle(Buffer); sprintf(Buffer, "Fit_Re%s_%s", Mlp, Iso); PlotsRe->SetName(Buffer); sprintf(Buffer, "Fit_Im%s_%s", Mlp, Iso); PlotsIm->SetName(Buffer); PlotsRe->Draw("APZ"); //Plot with x,y axis, points and small error bars PlotsIm->Draw("PZ"); //Plot with points and small error bars, into existing frame //x-axis labeling PlotsRe->GetXaxis()->SetTitle("W / MeV"); //y-axis labeling sprintf(Buffer, "%c_{%1d%c}", M, l, p); for(Int_t n=0; n<strlen(Buffer); n++) { if(Buffer[n]=='p') Buffer[n] = '+'; if(Buffer[n]=='m') Buffer[n] = '-'; } if(!strcmp(Iso, "32")) sprintf(Buffer, "%s^{3/2}", Buffer, Iso); if(!strcmp(Iso, "p12")) sprintf(Buffer, "%s^{p1/2}", Buffer, Iso); PlotsRe->GetYaxis()->SetTitle(Buffer); //Open text file with model values for given p pi0 multipole sprintf(Buffer, "model/ppi0/%s.txt", Mlp); InModel_0 = fopen(Buffer, "r"); //Skip two lines with table header fgets(Buffer, sizeof(Buffer), InModel_0); fgets(Buffer, sizeof(Buffer), InModel_0); //Read multipole model values from file MoPts_0 = 0; while(!feof(InModel_0)) { if(fscanf(InModel_0, "%lf %lf %lf", &W, &Re, &Im)==3) { MoW_0[MoPts_0] = W; MoRe_0[MoPts_0] = Re; MoIm_0[MoPts_0] = Im; MoPts_0++; } } //Close file with model values fclose(InModel_0); //Open text file with model values for given n pi+ multipole sprintf(Buffer, "model/npip/%s.txt", Mlp); InModel_p = fopen(Buffer, "r"); //Skip two lines with table header fgets(Buffer, sizeof(Buffer), InModel_p); fgets(Buffer, sizeof(Buffer), InModel_p); //Read multipole model values from file MoPts_p = 0; while(!feof(InModel_p)) { if(fscanf(InModel_p, "%lf %lf %lf", &W, &Re, &Im)==3) { MoW_p[MoPts_p] = W; MoRe_p[MoPts_p] = Re; MoIm_p[MoPts_p] = Im; MoPts_p++; } } //Close file with model values fclose(InModel_p); //Create selected isospin multipole from p pi0 and n pi+ multipoles for(Int_t wp=0; wp<MoPts_p; wp++) { //Find corresponding energy bin between n pi+ and p pi0 multipoles Int_t w0; for(Int_t w0=0; w0<MoPts_0; w0++) if(MoW_p[wp]==MoW_0[w0]) break; //Create isospin multipoles if(!strcmp(Iso, "32")) { MoRe[wp] = A_32(MoRe_0[w0], MoRe_p[wp]); MoIm[wp] = A_32(MoIm_0[w0], MoIm_p[wp]); } if(!strcmp(Iso, "p12")) { MoRe[wp] = A_12(MoRe_0[w0], MoRe_p[wp]); MoIm[wp] = A_12(MoIm_0[w0], MoIm_p[wp]); } } //Create graphs for real and imaginary parts of model multipole ModelRe = new TGraph(MoPts_p, MoW_p, MoRe); ModelIm = new TGraph(MoPts_p, MoW_p, MoIm); //Color, line size adjustments ModelRe->SetLineColor(kRed); ModelIm->SetLineColor(kBlue); ModelRe->SetLineWidth(2); ModelIm->SetLineWidth(2); //Set plot titles and object names sprintf(Buffer, "%s_%s", Mlp, Iso); ModelRe->SetTitle(Buffer); ModelIm->SetTitle(Buffer); sprintf(Buffer, "Model_Re%s_%s", Mlp, Iso); ModelRe->SetName(Buffer); sprintf(Buffer, "Model_Im%s_%s", Mlp, Iso); ModelIm->SetName(Buffer); //Plot graphs ModelRe->Draw("L"); //Plot as line, into same frame ModelIm->Draw("L"); //Plot as line, into same frame //Adjust drawing ranges for y-axis if((Lo==0.0) && (Hi==0.0)) { PlotsRe->SetMinimum(Min*1.05); PlotsRe->SetMaximum(Max*1.05); } else { PlotsRe->SetMinimum(Lo); PlotsRe->SetMaximum(Hi); } if(SAVE) PlotsRe->SetTitle(""); if(SAVE) sprintf(Buffer, "isospin/%s_%s.eps", Mlp, Iso); if(SAVE) Canvas->SaveAs(Buffer); }
void PlotPtTresh2() { // gROOT->ProcessLine(".L ./tdrstyle.C"); // setTDRStyle(); Int_t r=1; TFile *f1 = new TFile("histo_file_QCDPU50GEM2019.root"); char histo[40], histo1[40], histo2[40], histoDC[40]; TH1F *hInitialBarrel = (TH1F*)f1->Get("hInitialBarrel"); TH1F *hInitialEndcap = (TH1F*)f1->Get("hInitialEndcap"); TH1F *hPtBarrel = (TH1F*)f1->Get("hMuonPtFinal_Barrel"); TH1F *hPtHE = (TH1F*)f1->Get("hMuonPtFinal_HE"); TH1F *hPtFull = (TH1F*)f1->Get("hMuonPtFinal_Full"); TH1F *hInitial = (TH1F*)f1->Get("entries_after_vertex"); TH1F *hWP2012Pt = (TH1F*)f1->Get("hMuonPtWP2012"); TH1F *h_HTot = (TH1F*)f1->Get("H_tot"); TH1F *initial_entries = (TH1F*)f1->Get("initial_entries"); cout<<"Htot"<<h_HTot->Integral()<<" initial entries "<<initial_entries->Integral()<<endl; int Ninitial=hInitial->Integral(); cout<<" initial "<<Ninitial<<endl; cout<<" initial barrel "<<hInitialBarrel->Integral()<<endl; cout<<" initial endcap"<<hInitialEndcap->Integral()<<endl; cout<<" after muon barrel "<<hPtBarrel->Integral()<<endl; cout<<" after muon HE "<<hPtHE->Integral()<<endl; float MuonEff2012[1] =0; MuonEff2012[0]= hWP2012Pt->Integral()/hInitial->Integral(); float Err_MuonEff2012[1]; Err_MuonEff2012[0]=(TMath::Sqrt(Err_MuonEff2012[0]*(1-Err_MuonEff2012[0])))/Ninitial; //cout<<"Muon Eff WP 2012 "<<hWP2012Pt->Integral()/hInitial->Integral()<<endl; /////////////////////////compute selection eff as a function of muon pt threshold///////////////////////////// int EvAfterPtCut_HE[100]; float EffSel[100], xgr[100], ex[100],ey[100], EffSelFull[100], eyfull[100], Eff_Barrel[100], Eff_Endcap[100], err_Eff_barrel[100],err_Eff_endcap[100]; int EvAfterPtCut_Barrel[100]; int EvAfterPtCut[100]; int EvAfterPtCut_BB[100]; int EvAfterPtCut_EE[100]; // std::cout<<" Muon Pt in |eta|<2.4 "<<hMuonTot->Integral(0,200)<<endl; for(int i=0;i<40;i++){ EvAfterPtCut_Barrel[i]=hPtBarrel->Integral(10,100); EvAfterPtCut_HE[i]=hPtHE->Integral(i+1,100); EvAfterPtCut[i]=hPtFull->Integral(i+1,100); EvAfterPtCut_BB[i] =hPtBarrel->Integral(i+1,100); EvAfterPtCut_EE[i] =hPtHE->Integral(i+1,100); EffSelFull[i] = EvAfterPtCut[i] / (hInitialBarrel->Integral() + hInitialEndcap->Integral() ); Eff_Barrel[i]= EvAfterPtCut_BB[i]/hInitialBarrel->Integral(); Eff_Endcap[i]=EvAfterPtCut_EE[i]/hInitialEndcap->Integral(); std::cout<<i*2<<" nev after pt cut barrel "<<EvAfterPtCut_BB[i]<<" nev after pt cut endcap "<<EvAfterPtCut_HE[i]<<" eff sel "<<endl; xgr[i]=i*2; ex[i]=0; EffSel[i]=(EvAfterPtCut_Barrel[i]+EvAfterPtCut_HE[i])/(hInitial->Integral()); ey[i]=TMath::Sqrt((EffSel[i]*(1-EffSel[i])))/hInitial->Integral(); eyfull[i]=TMath::Sqrt((EffSelFull[i]*(1-EffSelFull[i])))/hInitial->Integral(); // std::cout<<i*2<<" nev after pt cut barrel || endcap "<<EvAfterPtCut_Barrel[i]+EvAfterPtCut_HE[i]<<" eff sel "<<EffSel[i]<<" errore "<<ey[i]<<endl; } double xgr12[1]; xgr12[0]=13.0; double ex12[1]; ex12[0]=0.; TGraphErrors* gr = new TGraphErrors(26,xgr,EffSel,ex,ey); TGraphErrors* gr_full = new TGraphErrors(26,xgr,EffSelFull,ex,eyfull); TGraph* gr12 = new TGraph(1); gr12->SetPoint(0,20,MuonEff2012[0]); TGraphErrors* gr_BB = new TGraphErrors(26,xgr,Eff_Barrel,ex,ey); TGraphErrors* gr_EE = new TGraphErrors(26,xgr,Eff_Endcap,ex,ey); ///////////////////////////////////////////************************************//////////////////////////////////////////// TCanvas *Canv5 = new TCanvas("Canv5","Palle",800,700); gr->SetMarkerStyle(24); gr12->SetMarkerStyle(23); gr->SetMarkerColor(kRed); gr12->SetMarkerColor(kBlue); gr->SetTitle(" Selection Efficiency as a function of muon pt threshold "); gr->GetYaxis()->SetTitle("Selection Efficiency"); gr->GetYaxis()->SetTitleOffset(1.4); gr->GetXaxis()->SetTitle("P_{T}^{#mu Endcap} Cut (GeV/c)"); gr->SetMarkerSize(1.2); gr12->SetMarkerSize(1.4); gr->Draw("ACP"); gr12->Draw("CP"); gr->SetMinimum(0.5); TLegend* legend = new TLegend( 0.15, 0.5, 0.75, 0.7); legend->SetTextSize(0.025); legend->SetFillColor(0); legend->AddEntry(gr, "PU=50 wGEM (P_{T}^{#mu, barrel}>20, |#eta|<2.1)","p"); legend->AddEntry(gr12, "PU=50 wGEM 2012 WP (P_{T}^{#mu Full Accept}>24,|#eta|<2.1)","p"); Canv5->cd(); legend->Draw("same"); Canv5->SaveAs("WHPtTresh.pdf"); ///////////////////////////////////////////************************************//////////////////////////////////////////// TCanvas *Canv6 = new TCanvas("Canv6","StraPalle",800,700); gr_full->SetMarkerStyle(24); gr_full->SetMarkerColor(kBlue); gr_BB->SetMarkerStyle(24); gr_EE->SetMarkerStyle(24); gr_BB->SetMarkerColor(kGreen); gr_EE->SetMarkerColor(kMagenta); gr_full->SetTitle(" Selection Efficiency as a function of muon pt threshold "); gr_full->GetYaxis()->SetTitle("Selection Efficiency"); gr_full->GetYaxis()->SetTitleOffset(1.4); gr_full->GetXaxis()->SetTitle("P_{T}^{#mu Endcap} Cut (GeV/c)"); gr_BB->Draw("ACP"); gr_full->Draw("CP"); // gr_BB->Draw("CP"); gr_EE->Draw("CP"); //gr12->Draw("CP"); //gr_full->SetMinimum(0.1); gr_BB->SetMinimum(0.); gr_BB->SetMaximum(0.001); gPad->SetGrid(); gPad->Update(); TLegend* legend = new TLegend( 0.65, 0.7, 0.85, 0.9); legend->SetTextSize(0.025); legend->SetFillColor(0); legend->AddEntry(gr_full, "full acceptance","p"); legend->AddEntry(gr_BB, "|#eta|<1.6","p"); legend->AddEntry(gr_EE, "1.6<|#eta|<2.1","p"); Canv6->cd(); legend->Draw("same"); Canv6->SaveAs("QCD_threshold_fullAcc.pdf"); }
void gptoy(){ int n = 100; TRandom3 rand(0); // sampling points double x [n]; for(int i=0; i < n; i++) x[i] = 1.0*i/n; // construct covariance matrix TMatrixD C(n,n); for(int i=0; i < n; i++) for(int j=0; j < n; j++) C[i][j] = kern(x[i],x[j],1); // add small number to diagonal (positive definite) for(int i=0; i < n; i++) C[i][i] += 0.00001; // use Cholesky decomposition to obtain vector distributed as multivariate gaussian TDecompChol D(C); TMatrixD L(n,n); L = D.GetU(); // random rumbers TVectorD u(n); for(int i=0; i < n; i++) u[i] = rand.Gaus(0,1); // result -- random vector TVectorD y(n); y = L*u; // plot /* TGraph *grand = new TGraph(); for(int i=0; i < n; i++){ grand->SetPoint(i, x[i], y[i]); } grand->SetLineWidth(2); grand->Draw("ACP"); */ // // prediction w/ noise-free observables // int m = 6; double t [m]; t[0] = 0.05; t[1] = 0.29; t[2] = 0.31; t[3] = 0.50; t[4] = 0.75; t[5] = 0.95; TVectorD ft(m); ft[0] = 1.0; ft[1] = 1.0; ft[2] = 2.0; ft[3] = 1.0; ft[4] = 1.0; ft[5] = 1.0; TMatrixD K11(m,m); TMatrixD K12(m,n); TMatrixD K21(n,m); TMatrixD K22(n,n); for(int i=0; i < n; i++){ for(int j=0; j < n; j++){ if( i < m and j < m ){ K11[i][j] = kern(t[i],t[j],1); if( i==j ) K11[i][j] += 0.00001; } if( i < m and j < n ){ K12[i][j] = kern(t[i],x[j],1); if( i==j ) K12[i][j] += 0.00001; } if( i < n and j < m ){ K21[i][j] = kern(x[i],t[j],1); if( i==j ) K21[i][j] += 0.00001; } if( i < n and j < n ){ K22[i][j] = kern(x[i],x[j],1); if( i==j ) K22[i][j] += 0.00001; } } } K11[2][2] += 0.1; // use Cholesky decomposition to obtain vector distributed as multivariate gaussian // compute covariance matrix TMatrixD fC(n,n); TMatrixD K11inv(m,m); K11inv = K11; K11inv.Invert(); fC = K22 - K21*K11inv*K12; TDecompChol fD(fC); TMatrixD fL(n,n); fL = fD.GetU(); // // result // TVectorD v(n); TVectorD fy(n); TVectorD fy_err(n); // mean value and error band for(int i=0; i < n; i++) v[i] = 1.0; fy = K21*K11inv*ft; fy_err = fL*v; TGraphErrors *gtest = new TGraphErrors(); for(int i=0; i < n; i++){ gtest->SetPoint(i, x[i], fy[i]); gtest->SetPointError(i, 0.0, fy_err[i]); } TCanvas * canvas = new TCanvas("canvas","canvas",800,800); canvas->cd(); TGraph *gtrain = new TGraph(); for(int i=0; i < m; i++) gtrain->SetPoint(i, t[i], ft[i]); gtest->SetFillStyle(3002); gtest->SetMinimum(-3.5); gtest->SetMaximum(4.5); gtest->Draw("AC3"); gtrain->SetMarkerStyle(20); gtrain->SetMarkerColor(2); gtrain->Draw("P"); canvas->Draw(); return; }
void make1DLimit(TString combine_dir,TString type= "WH",bool blind=true){ //TString combine_dir = "test_runSusyHgg/signalInj_sms_ChiWH_0_175/"; //WH wh_limits.push_back(wh_125); wh_limits.push_back(wh_150); wh_limits.push_back(wh_175); wh_limits.push_back(wh_200); //HH hh_limits.push_back(hh_125); hh_limits.push_back(hh_150); hh_limits.push_back(hh_175); hh_limits.push_back(hh_200); TGraph obser( (200-125)/25 ); TGraph graph( (200-125)/25 ); TGraphAsymmErrors error( (200-125)/25 ); TGraphAsymmErrors error2S( (200-125)/25 ); TGraph obser_r( (200-125)/25 ); TGraph graph_r( (200-125)/25 ); TGraphAsymmErrors error_r( (200-125)/25 ); TGraphAsymmErrors error_r2S( (200-125)/25 ); TGraphErrors* theo = 0; if(type=="WH") theo = getTheoXSec("xsecs/CharginoNeutralino.txt"); else theo = getTheoXSec("xsecs/Higgsino_ElectroHiggs.txt"); //else theo = getTheoXSec("/home/amott/HggApp/SusyHgg/xsecs/Higgsino.txt"); for(int m=125;m<=200;m+=25) { int i=(m-125)/25; TFile limit_file(Form("%s/higgsCombineChi%s_0_%d.Asymptotic.mH120.root",combine_dir.Data(),type.Data(),m) ); TTree *limit_tree = (TTree*)limit_file.Get("limit"); TTreeFormula limit_form("get_limit","limit",limit_tree); float down_2s = -1; float down = -1; float exp = -1; float up = -1; float up_2s = -1; float obs = -1; if( type == "WH" ) { down_2s = wh_limits.at(i)[0]; down = wh_limits.at(i)[1]; exp = wh_limits.at(i)[2]; up = wh_limits.at(i)[3]; up_2s = wh_limits.at(i)[4]; obs = wh_limits.at(i)[5]; } else if ( type == "HH") { down_2s = hh_limits.at(i)[0]; down = hh_limits.at(i)[1]; exp = hh_limits.at(i)[2]; up = hh_limits.at(i)[3]; up_2s = hh_limits.at(i)[4]; obs = hh_limits.at(i)[5]; } else { std::cerr << "UNRECOGNIZED OPTION!!! QUITTING" << std::endl; } if(i==0) m+=5; //first point is actually at m=130 graph.SetPoint(i,float(m), exp); error.SetPoint(i,float(m), exp); error2S.SetPoint(i, float(m), exp); error.SetPointError(i, 0, 0, exp-down, up-exp); error2S.SetPointError(i, 0 , 0 , exp-down_2s, up_2s-exp); graph_r.SetPoint(i,float(m),exp/theo->Eval(m)); error_r.SetPoint(i,float(m),exp/theo->Eval(m)); error_r2S.SetPoint(i,float(m),exp/theo->Eval(m)); error_r.SetPointError(i,0,0,(exp-down)/theo->Eval(m),(up-exp)/theo->Eval(m)); error_r2S.SetPointError(i, 0, 0, (exp-down_2s)/theo->Eval(m), (up_2s-exp)/theo->Eval(m) ); obser.SetPoint(i,float(m),obs); obser_r.SetPoint(i,float(m),obs/theo->Eval(m)); if(i==0) m-=5; } TCanvas cv; cv.SetLogy(); cv.SetGrid(1,1); theo->SetMaximum(1e2); theo->SetMinimum(1e-2); theo->GetYaxis()->SetLabelSize(0.05); theo->GetYaxis()->SetTitleSize(0.06); theo->GetYaxis()->SetTitleOffset(0.8); theo->GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)"); theo->GetXaxis()->SetTitle("m_{chargino} (GeV)"); if(type=="HH") theo->GetXaxis()->SetTitle("m_{neutralino} (GeV)"); theo->SetFillColor(kBlue); theo->SetLineStyle(kDotted); theo->SetLineWidth(2); error.SetMaximum(1e2); error.SetMinimum(1e-2); error.GetYaxis()->SetLabelSize(0.04); error.GetYaxis()->SetTitleSize(0.06); error.GetYaxis()->SetTitleOffset(0.8); error.GetXaxis()->SetLabelSize(0.04); error.GetXaxis()->SetTitleSize(0.05); error.GetXaxis()->SetTitleOffset(0.9); error.GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)"); error.GetXaxis()->SetTitle("m_{chargino} (GeV)"); if(type=="HH") error.GetXaxis()->SetTitle("m_{neutralino} (GeV)"); error.SetFillColor(kGreen); error2S.SetFillColor(kYellow); error2S.SetTitle(""); error.SetTitle(""); error.Draw("A3"); error2S.Draw("3SAME"); error.Draw("3"); theo->SetTitle(""); theo->Draw("3C"); graph.SetLineStyle(kDashed); graph.SetLineWidth(2.0); graph.SetTitle(""); graph.Draw("C"); obser.SetLineStyle(1); obser.SetLineWidth(2.0); obser.SetTitle(""); if(!blind) obser.Draw("C"); TLegend leg(0.65,0.65,0.89,0.89); leg.SetFillColor(0); leg.SetBorderSize(0); leg.AddEntry(&graph,"expected","l"); leg.AddEntry(&error,"expected #pm1#sigma","F"); leg.AddEntry(&error2S,"expected #pm2#sigma","F"); leg.AddEntry(theo,"theoretical","f"); if(!blind) leg.AddEntry(&obser,"observed","l"); leg.Draw("SAME"); TLatex latex; latex.SetNDC(); latex.SetTextAngle(0); latex.SetTextColor(kBlack); float extraTextSize = extraOverCmsTextSize*cmsSize; latex.SetTextFont(lumifont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(lumix, lumiy,lumiText); latex.SetTextFont(cmsTextFont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(cmsx, cmsy, CMSText); latex.SetTextFont(extraTextFont); latex.SetTextAlign(31); latex.SetTextSize(extraTextSize); latex.DrawLatex(extrax, extray, extraText); TString infix=(blind ? "" : "_OBS"); cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.png"); cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.pdf"); cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.C"); error_r.SetMaximum(1e2); error_r.SetMinimum(1e-2); error_r.SetTitle(""); error_r.GetYaxis()->SetLabelSize(0.04); error_r.GetYaxis()->SetTitleSize(0.06); error_r.GetYaxis()->SetTitleOffset(0.8); error_r.GetXaxis()->SetLabelSize(0.04); error_r.GetXaxis()->SetTitleSize(0.05); error_r.GetXaxis()->SetTitleOffset(0.9); error_r.GetYaxis()->SetTitle("#sigma_{95%}/#sigma_{NLO}"); if(type=="HH") error_r.GetXaxis()->SetTitle("m_{neutralino} (GeV)"); else error_r.GetXaxis()->SetTitle("m_{chargino} (GeV)"); error_r.SetFillColor(kGreen); error_r2S.SetFillColor(kYellow); error_r2S.SetTitle(""); error_r.Draw("A3"); error_r2S.Draw("3SAME"); error_r.Draw("3SAME"); graph_r.SetLineStyle(kDashed); graph_r.SetLineWidth(2); graph_r.SetTitle(""); graph_r.Draw("C"); TLine l(125,1,205,1); l.SetLineWidth(3); l.SetLineColor(kBlue); //l.Draw("SAME"); obser_r.SetLineWidth(2); if(!blind) obser_r.Draw("C"); leg.Draw("SAME"); //lbl.SetY(0.20); //leg.SetY1NDC(0.28); //leg.SetY2NDC(0.43); //prelim.Draw(); //lbl.Draw(); latex.SetTextFont(lumifont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(lumix, lumiy,lumiText); latex.SetTextFont(cmsTextFont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(cmsx, cmsy, CMSText); latex.SetTextFont(extraTextFont); latex.SetTextAlign(31); latex.SetTextSize(extraTextSize); latex.DrawLatex(extrax, extray, extraText); cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.png"); cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.pdf"); cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.C"); }
void histos_avg(){ gStyle->SetOptFit(1); gStyle->SetOptStat(1110); std::string material[3] = {"lxe","lxe_tpb","lyso"}; std::string interaction[3] = {"","_noCher","_noScint"}; std::string filepath = "/home/jmbenlloch/next/petalo/work/histo/phys/5ps/jitter/"; double sigmasNPE[3][2][2][5][10]; // [mat][inter][smear][pde][npe] double errorsNPE[3][2][2][5][10]; // [mat][inter][smear][pde][npe] double sigmasDT[3][2][2][5][8]; // [mat][inter]]smear][pde][dt] double errorsDT[3][2][2][5][8]; // [mat][inter][smear][pde][dt] int npes[10] = {1,2,3,4,5,6,7,8,9,10}; // int pdes[5] = {10,30,50,70,100}; char pdeChar[5]; TCanvas *c1 = new TCanvas("c1","multipads",900,700); for(int mat=0; mat<2;mat++){ if (mat==0){ int pdes[5] = {10,15,20,100}; }else{ int pdes[5] = {30,50,70,100}; } for(int inter=1; inter<2;inter++){ for(int smear=0; smear<1;smear++){ for(int pde=0; pde<4;pde++){ sprintf(pdeChar, "%.2lf", pdes[pde]/100.0); if(pdes[pde]==100){ sprintf(pdeChar, "0%.2lf", pdes[pde]/100.0); } std::string fileName = filepath + material[mat] + interaction[inter] + std::string("_QE_") + std::string(pdeChar) + std::string("_SPTR_80_ASIC_30_DT300_histos.root"); std::string(Form("%d", 1)); std::cout << fileName << std::endl; TFile *fIn = new TFile(fileName.c_str(), "read"); std::string baseName = "AVG."; std::string smearName = ""; if(smear==1){ smearName = "Smear"; } //NPE for(int npe=0;npe<10;npe++){ std::string histName = baseName + smearName + std::string("DTOF2") + std::string("N") + std::string(Form("%d", npes[npe])); std::cout << histName << std::endl; TH1F *h1 = (TH1F*) fIn->Get(histName.c_str()); TF1* gauF1 = new TF1("gauF1","gaus",-200,200); h1->Fit("gauF1","","e",-200,200); h1->Draw(); std::string path = "/home/jmbenlloch/next/petalo/work/histo/phys/5ps/jitter_avg/npe/"; std::string histo = path + material[mat] + interaction[inter] + std::string("_QE_") + std::string(pdeChar) + std::string("_") + histName + std::string(".png"); std::cout << histo << std::endl; c1->Print(histo.c_str()); // FWHM sigmasNPE[mat][inter][smear][pde][npe] = 2.35 * h1->GetFunction("gauF1")->GetParameter(2); errorsNPE[mat][inter][smear][pde][npe] = 2.35 * h1->GetFunction("gauF1")->GetParError(2); } fIn->Close(); } } } } c1->Close(); double npesD[10] = {1,2,3,4,5,6,7,8,9,10}; //EColor colors[5] = {kRed,kBlue,kGreen+3,kCyan}; EColor colors[5] = {kRed,kBlack,kGreen+3,kBlue}; for(int mat=0; mat<2;mat++){ if (mat==0){ int pdes[5] = {10,15,20,100}; }else{ int pdes[5] = {30,50,70,100}; } for(int inter=1; inter<2;inter++){ for(int smear=0; smear<1;smear++){ std::string smearName = ""; if(smear==1){ smearName = "_smear"; } //NPE //TCanvas *c2 = new TCanvas("c2","multipads",900,700); TCanvas *c2 = tcanvset("c"); //TLegend *leg = new TLegend(0.7, 0.7, 0.9, 0.9); TLegend *leg = tlegset(); leg->SetFillColor(0); for(int pde=0; pde<4;pde++){ TGraphErrors *gLxe = new TGraphErrors(10, npesD, sigmasNPE[mat][inter][smear][pde], 0, errorsNPE[mat][inter][smear][pde]); gLxe->SetLineColor(colors[pde]); gLxe->SetLineWidth(2); gLxe->SetLineStyle(4-pde); grerrplot(*gLxe); leg->AddEntry(gLxe,Form("PDE %d%%", pdes[pde]), "lp"); std::cout << "pde: " << pde << std::endl; if(pde==0){ gLxe->SetTitle(""); gLxe->GetXaxis()->SetTitle("Number of photoelectrons"); gLxe->GetXaxis()->SetLimits(0,10); gLxe->GetYaxis()->SetTitle("CRT (ps)"); gLxe->SetMinimum(0.); gLxe->SetMaximum(250.); gLxe->Draw(); }else{ gLxe->Draw("same"); } if(pde==3){ leg->Draw("same"); } } std::string path = "/home/jmbenlloch/next/petalo/PESOA/PETALOS/root/paper/plots/"; std::string histo = path + material[mat] + interaction[inter] + std::string("_avg_npe") + smearName + std::string(".png"); c2->Print(histo.c_str()); c2->Close(); } } } }
void histos_pde(){ gStyle->SetOptFit(1); gStyle->SetOptStat(1110); std::string material[3] = {"lxe","lxe_tpb","lyso"}; std::string interaction[3] = {"","_noCher","_noScint"}; double sigmas[3][3][20]; // [mat][inter][pde] double errors[3][3][20]; // [mat][inter][pde] double pdeValues[20]; char pde[5]; TCanvas *c1 = new TCanvas("c1","multipads",900,700); for(int mat=0; mat<3;mat++){ for(int inter=0; inter<2;inter++){ for(int i=5;i<=100;i+=5){ pdeValues[i/5-1] = i; //There is an error with lsyo noScint pde 0.05 if((mat==2 && inter==2) && i==5)){ continue; } sprintf(pde, "%.2lf", i/100.0); if(i==100){ sprintf(pde, "0%.2lf", i/100.0); } std::string path = "/home/jmbenlloch/next/petalo/work/histo/pde/"; std::string fileName = path + material[mat] + interaction[inter] + std::string("_QE_") + std::string(pde) + std::string("_SPTR_0_ASIC_0_DT300_histos.root"); std::string(Form("%d", 1)); std::cout << fileName << std::endl; TFile *fIn = new TFile(fileName.c_str(), "read"); TH1F *h1 = (TH1F*) fIn->Get("DTOF.DTOF2"); TF1* gauF1 = new TF1("gauF1","gaus",-100,100); // h1->Scale(1/h1->Integral(), "width"); h1->Fit("gauF1","","e",-200,200); h1->Draw(); std::string histo = path + material[mat] + interaction[inter] + std::string("_pde_") + pde + std::string(".png"); std::cout << histo << std::endl; c1->Print(histo.c_str()); std::cout << "PDE: " << pde << "sigma: " << h1->GetFunction("gauF1")->GetParameter(2) << std::endl; sigmas[mat][inter][i/5-1] = h1->GetFunction("gauF1")->GetParameter(2); errors[mat][inter][i/5-1] = h1->GetFunction("gauF1")->GetParError(2); fIn->Close(); } } } c1->Close(); TCanvas *c2 = new TCanvas("c2","multipads",900,700); TGraphErrors *gLxe = new TGraphErrors(20, pdeValues, sigmas[0][0], 0, errors[0][0]); gLxe->SetLineColor(kRed); gLxe->SetLineWidth(2); TGraphErrors *gTpb = new TGraphErrors(20, pdeValues, sigmas[1][0], 0, errors[1][0]); gTpb->SetLineColor(kBlue); gTpb->SetLineWidth(2); TGraphErrors *gLyso = new TGraphErrors(20, pdeValues, sigmas[2][0], 0, errors[2][0]); gLyso->SetLineColor(kGreen); gLyso->SetLineWidth(2); std::cout << "LXe: "; for(int i=0;i<20;i++){ std::cout << sigmas[0][0][i] << ", "; } std::cout << std::endl; std::cout << "TPB: "; for(int i=0;i<20;i++){ std::cout << sigmas[1][0][i] << ", "; } std::cout << std::endl; std::cout << "LYSO: "; for(int i=0;i<20;i++){ std::cout << sigmas[2][0][i] << ", "; } std::cout << std::endl; gLyso->Draw(); gLyso->SetTitle(""); gLyso->GetXaxis().SetTitle("PDE (%)"); gLyso->GetXaxis()->SetLimits(0.,100.); gLyso->GetYaxis().SetTitle("CRT (ps)"); gLyso->SetMinimum(0.); gLyso->SetMaximum(150.); gTpb->Draw("same"); gLxe->Draw("same"); TLegend *leg = new TLegend(0.7, 0.7, 0.9, 0.9); leg->SetFillColor(0); leg->AddEntry(gLxe, "LXe", "lp"); leg->AddEntry(gTpb, "LXe-TPB", "lp"); leg->AddEntry(gLyso, "LYSO", "lp"); leg->Draw("same"); c2->Print("/home/jmbenlloch/next/petalo/work/histo/pde/pde.png"); /* TCanvas *c4 = new TCanvas("c4","multipads",900,700); TGraphErrors *gLxeErrors = new TGraphErrors(20, pdeValues, sigmas[0][0], 0, errors[0][0]); gLxeErrors->SetMinimum(0.); gLxeErrors->SetMaximum(200.); gLxeErrors->Draw(); c4->Print("/home/jmbenlloch/next/petalo/work/histo/pde/pdeErrors.png");*/ TCanvas *c3 = new TCanvas("c3","multipads",900,700); TGraphErrors *gLxe_noCher = new TGraphErrors(20, pdeValues, sigmas[0][1], 0, errors[0][1]); gLxe_noCher->SetLineColor(kRed); gLxe_noCher->SetLineWidth(2); TGraphErrors *gTpb_noCher = new TGraphErrors(20, pdeValues, sigmas[1][1], 0, errors[1][1]); gTpb_noCher->SetLineColor(kBlue); gTpb_noCher->SetLineWidth(2); TGraphErrors *gLyso_noCher = new TGraphErrors(20, pdeValues, sigmas[2][1], 0, errors[2][1]); gLyso_noCher->SetLineColor(kGreen); gLyso_noCher->SetLineWidth(2); gLyso_noCher->Draw(); gLyso_noCher->SetTitle("noCher"); gLyso_noCher->GetXaxis().SetTitle("PDE (%)"); gLyso_noCher->GetXaxis()->SetLimits(0.,100.); gLyso_noCher->GetYaxis().SetTitle("CRT (ps)"); gLyso_noCher->SetMinimum(0.); gLyso_noCher->SetMaximum(150.); gTpb_noCher->Draw("same"); gLxe_noCher->Draw("same"); TLegend *leg_noCher = new TLegend(0.7, 0.7, 0.9, 0.9); leg_noCher->SetFillColor(0); leg_noCher->AddEntry(gLxe, "LXe", "lp"); leg_noCher->AddEntry(gTpb, "LXe-TPB", "lp"); leg_noCher->AddEntry(gLyso, "LYSO", "lp"); leg_noCher->Draw("same"); c3->Print("/home/jmbenlloch/next/petalo/work/histo/pde/pde_noCher.png"); }
void DrawResponsePlot( Float_t genMean[], Float_t genSigma[], Float_t recoMean[], Float_t recoSigma[]) { gROOT->ProcessLine(".L mystyle.C"); setTDRStyle(); tdrStyle->SetErrorX(0.5); tdrStyle->SetPadLeftMargin(0.2); tdrStyle->SetPadRightMargin(0.10); tdrStyle->SetLegendBorderSize(0); tdrStyle->SetTitleYOffset(1.3); // plot full spectrum TGraphErrors *ptbalanceGen = new TGraphErrors(nZPtBins, pt, genMean, errpt, genSigma); TGraphErrors *ptbalanceReco = new TGraphErrors(nZPtBins, pt, recoMean, errpt, recoSigma); // plot Zmumu values Float_t ptmm[9] = { 40.0, 60.0, 100.0, 140.0, 200.0, 250.0, 330.0, 400.0, 520.0 }; Float_t balancemm[9] = { 0.496, 0.568, 0.66, 0.71, 0.75, 0.765, 0.775, 0.79, 0.81 }; TGraph *ptbalancemm = new TGraph( 9, ptmm, balancemm); ptbalanceGen->GetXaxis()->SetTitle("p_{T}^{Z} (GeV/c)"); ptbalanceGen->GetYaxis()->SetTitle("p_{T}^{jet} / p_{T}^{Z}"); ptbalanceGen->SetMarkerStyle(22); ptbalanceGen->SetMarkerSize(1.2); ptbalanceGen->SetTitle(""); ptbalanceGen->SetMinimum(0.3); ptbalanceReco->SetMarkerColor(2); ptbalanceReco->SetLineColor(2); ptbalanceReco->SetMarkerStyle(22); ptbalanceReco->SetMarkerSize(1.2); ptbalanceReco->SetMinimum(0.3); ptbalancemm->SetMarkerStyle(24); ptbalancemm->SetMarkerSize(1.2); ptbalancemm->SetMinimum(0.3); ptbalancemm->SetMarkerColor(4); ptbalancemm->SetLineColor(4); TCanvas c1("c1","",500,500); ptbalanceGen->Draw("APL"); ptbalanceReco->Draw("PL"); ptbalancemm->Draw("PL"); leg_hist = new TLegend(0.6,0.7,0.89,0.89); leg_hist->AddEntry( ptbalanceGen, "Generator level", "l"); leg_hist->AddEntry( ptbalanceReco,"Calorimeter level","l"); leg_hist->AddEntry( ptbalancemm,"Z#rightarrow#mu#mu","l"); leg_hist->SetFillColor(0); leg_hist->Draw(); c1.SaveAs("PtBalanceVsPt.eps"); c1.SaveAs("PtBalanceVsPt.gif"); c1.SaveAs("PtBalanceVsPt.root"); c1.Close(); delete leg_hist; delete ptbalanceGen; delete ptbalanceReco; delete ptbalancemm; }
TGraphErrors *ReadMWGraph(const char *name, Int_t flag) { Double_t xreject = 0.49; TGraphErrors *g = new TGraphErrors(name); if (g->IsZombie()) return 0; while (g->GetX()[0] < xreject) g->RemovePoint(0); TGraphErrors *g2 = new TGraphErrors(name); if (g2->IsZombie()) return 0; while (g2->GetX()[0] < xreject) g2->RemovePoint(0); g2->SetMarkerStyle(4); g2->SetMarkerSize(1.00); g2->SetMarkerColor(kBlack); g2->SetLineColor(kBlack); TGraphErrors *gsys = new TGraphErrors(name, "%lg %lg %lg %*lg %lg"); if (gsys->IsZombie()) return 0; while (gsys->GetX()[0] < xreject) gsys->RemovePoint(0); for (Int_t i = 0; i < gsys->GetN(); i++) gsys->SetPointError(i, gsys->GetErrorX(i)*0.75, gsys->GetErrorY(i)); gsys->SetFillColor(kGray+2); gsys->SetLineColor(kGray+2); gsys->SetFillStyle(3000); if (flag == 1 || flag == 3) { TGraphErrors *gt = new TGraphErrors(Form("%s_%s", name, "trues")); if (gt->IsZombie()) return 0; while (gt->GetX()[0] < xreject) gt->RemovePoint(0); gt->SetMarkerStyle(20); gt->SetMarkerSize(0.75); gt->SetMarkerColor(kGreen+1); gt->SetLineColor(kGreen+1); TGraphErrors *gbw = new TGraphErrors(Form("%s_%s", name, "gen")); if (gbw->IsZombie()) return 0; while (gbw->GetX()[0] < xreject) gbw->RemovePoint(0); gbw->SetMarkerStyle(20); gbw->SetMarkerSize(0.75); gbw->SetMarkerColor(kBlue+1); gbw->SetLineColor(kBlue+1); for (Int_t i = 0; i < g->GetN(); i++) { g->SetPointError(i, g->GetEX()[i], 0.); gt->SetPointError(i, gt->GetEX()[i], 0.); gbw->SetPointError(i, gbw->GetEX()[i], 0.); } for (Int_t i = 0; i < g2->GetN(); i++) { g2->SetPoint(i, g2->GetX()[i], g2->GetY()[i] - gt->GetY()[i] + gbw->GetY()[i]); g2->SetPointError(i, g2->GetEX()[i], TMath::Sqrt(g2->GetEY()[i]*g2->GetEY()[i] + gt->GetEY()[i]*gt->GetEY()[i] + gbw->GetEY()[i]*gbw->GetEY()[i])); // g2->SetPoint(i, g2->GetX()[i], g2->GetY()[i] - gt->GetY()[i] + 1.01947); // g2->SetPointError(i, g2->GetEX()[i], TMath::Sqrt(g2->GetEY()[i]*g2->GetEY()[i] + gt->GetEY()[i]*gt->GetEY()[i] + // 7.78680e-06*7.78680e-06)); gsys->SetPoint(i, gsys->GetX()[i], g2->GetY()[i]); } } g->SetTitle(); g->SetName(name); g->GetXaxis()->SetTitle("p_{T}, GeV/c"); g->SetMarkerStyle(20); g->SetMarkerSize(0.95); g->SetMarkerColor(kRed+1); g->SetLineColor(kRed+1); const Double_t mass = 1.019455; const Double_t mass_delta = 0.000020; const Double_t width = 0.00426; const Double_t width_delta = 0.00004; if (flag == 1) { // mass g->GetYaxis()->SetTitleOffset(1.50); g->GetYaxis()->SetTitle("mass, GeV/c^{2}"); g->SetMaximum(mass+0.0015); g->SetMinimum(mass-0.0015); TBox *box = new TBox(g->GetXaxis()->GetXmin(), mass - mass_delta, g->GetXaxis()->GetXmax(), mass + mass_delta); box->SetFillColor(kGray+1); box->SetFillStyle(3001); g->GetListOfFunctions()->Add(box); g->GetListOfFunctions()->Add(g2, "CP"); g->GetListOfFunctions()->Add(gt, "CP"); g->GetListOfFunctions()->Add(gbw, "CP"); } else if (flag == 3) { // mass simple g2->SetTitle(); g2->SetName(Form("%s_only", name)); g2->GetXaxis()->SetTitle("p_{T}, GeV/c"); g2->SetMarkerStyle(20); g2->SetMarkerSize(0.75); g2->SetMarkerColor(kBlack); g2->SetLineColor(kBlack); g2->GetYaxis()->SetTitleOffset(1.50); g2->GetYaxis()->SetTitle("mass, GeV/c^{2}"); g2->SetMaximum(mass+0.0015); g2->SetMinimum(mass-0.0015); TBox *box = new TBox(g->GetXaxis()->GetXmin(), mass - mass_delta, g2->GetXaxis()->GetXmax(), mass + mass_delta); box->SetFillColor(kGray+1); box->SetFillStyle(3001); g2->GetListOfFunctions()->Add(box); g2->GetListOfFunctions()->Add(gsys, "E5"); return g2; } else if (flag == 2) { // width g->SetTitle(); g->SetName(name); g->GetXaxis()->SetTitle("p_{T}, GeV/c"); g->SetMarkerStyle(20); g->SetMarkerSize(0.75); g->SetMarkerColor(kBlack); g->SetLineColor(kBlack); g->GetYaxis()->SetTitleOffset(1.50); g->GetYaxis()->SetTitle("width, GeV/c^{2}"); g->SetMaximum(0.01); g->SetMinimum(0.0); TBox *box = new TBox(g->GetXaxis()->GetXmin(), width - width_delta, g->GetXaxis()->GetXmax(), width + width_delta); box->SetFillColor(kGray+1); box->SetFillStyle(3001); g->GetListOfFunctions()->Add(box); g->GetListOfFunctions()->Add(gsys, "E5"); } return g; }
void plot_ZJetBalance(int JetAlgo) { Float_t pt[NGenPtBins]; TString ptBin[NGenPtBins]; for(int i=0; i<NGenPtBins; i++) { pt[i] = 0.5*( GenPt[i] + GenPt[i+1] ); ptBin[i] = Form("%d_%d", (int) GenPt[i], (int) GenPt[i+1] ); } Float_t errpt[NGenPtBins]; Float_t genMean[NGenPtBins]; Float_t genSigma[NGenPtBins]; Float_t recoMean[NGenPtBins]; Float_t recoSigma[NGenPtBins]; TString algoSt; if(JetAlgo==0) algoSt = "_ic5"; if(JetAlgo==1) algoSt = "_ic7"; if(JetAlgo==2) algoSt = "_mp5"; if(JetAlgo==3) algoSt = "_mp7"; if(JetAlgo==4) algoSt = "_kt6"; TString textFilename = "ZjetPtBalance" + algoSt + TString(".txt"); TString JetResponseFilename = "Histograms_ZjetResponse" + algoSt + TString(".root"); FILE *file = fopen(textFilename,"w+"); fprintf( file ,"%s %s %s %s %s \n", "pT bin", "genMean", "genSigma", "recoMean", "recoSigma"); TH1F* responseHistGen; TH1F* responseHistReco; TH1F* genJetpt; TH1F* caloJetpt; TH1F* Zpt; if(storeResponsHistogramsInRootFile == true) { TFile respHistFile(JetResponseFilename,"RECREATE"); } for(int i=0; i<NGenPtBins; i++) { responseHistGen = new TH1F("responseHistGen_"+ptBin[i],"", 40, 0.0, 2.0); responseHistGen->Sumw2(); TAxis* responseHistGenx = responseHistGen->GetXaxis(); TAxis* responseHistGeny = responseHistGen->GetYaxis(); responseHistGenx->SetTitle("p_{T,Jet} / p_{T,Z} "); responseHistGeny->SetTitle("Events / 0.05 "); responseHistGeny->SetTitleOffset(1.2); responseHistReco = new TH1F("responseHistReco_"+ptBin[i],"", 40, 0.0, 2.0); responseHistReco->Sumw2(); responseHistReco->SetLineColor(2); responseHistReco->SetMarkerColor(2); genJetpt = new TH1F("genJetpt_"+ptBin[i],"", NGenPtBins-1, GenPt); genJetpt->Sumw2(); caloJetpt = new TH1F("caloJetpt_"+ptBin[i],"", NGenPtBins-1, GenPt); caloJetpt->Sumw2(); recoZpt = new TH1F("recoZpt_"+ptBin[i],"", NGenPtBins-1, GenPt); recoZpt->Sumw2(); errpt[i] = 0.0; genMean[i] = 0.0; genSigma[i] = 0.0; recoMean[i] = 0.0; recoSigma[i] = 0.0; plot_ZJetBalance( JetAlgo, i, *responseHistGen, *responseHistReco, *genJetpt, *caloJetpt, *recoZpt); genMean[i] = (Float_t) responseHistGen->GetMean(1); genSigma[i] = (Float_t) responseHistGen->GetMean(11); recoMean[i] = (Float_t) responseHistReco->GetMean(1); recoSigma[i] = (Float_t) responseHistReco->GetMean(11); if(storeResponseInTextFile == true) { fprintf( file ,"%5.1f %5.4f %5.4f %5.4f %5.4f \n", pt[i], genMean[i], genSigma[i], recoMean[i], recoSigma[i] ); } if(storeResponsHistogramsInRootFile == true) { respHistFile.cd(); responseHistGen->Write(); responseHistReco->Write(); genJetpt->Write(); caloJetpt->Write(); recoZpt->Write(); } delete responseHistGen; delete responseHistReco; delete genJetpt; delete caloJetpt; delete recoZpt; } fclose(file); respHistFile.Close(); if(makeplot_Response == true) { // plot full spectrum TGraphErrors *ptbalanceGen = new TGraphErrors(NGenPtBins, pt, genMean, errpt, genSigma); TGraphErrors *ptbalanceReco = new TGraphErrors(NGenPtBins, pt, recoMean, errpt, recoSigma); // plot Zmumu values Float_t ptmm[9] = { 40.0, 60.0, 100.0, 140.0, 200.0, 250.0, 330.0, 400.0, 520.0 }; Float_t balancemm[9] = { 0.496, 0.568, 0.66, 0.71, 0.75, 0.765, 0.775, 0.79, 0.81 }; TGraph *ptbalancemm = new TGraph( 9, ptmm, balancemm); ptbalanceGen->GetXaxis()->SetTitle("p_{T}^{Z} [GeV/c] "); ptbalanceGen->GetYaxis()->SetTitle("p_{T}^{Jet} / p_{T}^{Z} "); ptbalanceGen->SetMarkerStyle(22); ptbalanceGen->SetMarkerSize(1.2); ptbalanceGen->SetTitle(""); ptbalanceGen->SetMinimum(0.2); ptbalanceReco->SetMarkerColor(2); ptbalanceReco->SetLineColor(2); ptbalanceReco->SetMarkerStyle(22); ptbalanceReco->SetMarkerSize(1.2); ptbalanceReco->SetMinimum(0.2); ptbalancemm->SetMarkerStyle(24); ptbalancemm->SetMarkerSize(1.2); ptbalancemm->SetMinimum(0.2); ptbalancemm->SetMarkerColor(4); ptbalancemm->SetLineColor(4); TCanvas c1("c1","",800,600); c1.SetGrid(); ptbalanceGen->Draw("APL"); ptbalanceReco->Draw("PL"); ptbalancemm->Draw("PL"); leg_hist = new TLegend(0.6,0.35,0.85,0.55); leg_hist->AddEntry( ptbalanceGen, "Generator level", "l"); leg_hist->AddEntry( ptbalanceReco,"Calorimeter level","l"); leg_hist->AddEntry( ptbalancemm,"Z#rightarrow#mu#mu","l"); leg_hist->SetFillColor(0); leg_hist->Draw(); c1.SaveAs("PtBalanceVsPt.eps"); c1.SaveAs("PtBalanceVsPt.gif"); c1.SaveAs("PtBalanceVsPt.root"); c1.Close(); delete leg_hist; delete ptbalanceGen; delete ptbalanceReco; delete ptbalancemm; } }
// The actual job void signalEfficiency_w(int channel, double sqrts, int process, double JES, ofstream* txtYields) { TString schannel; if (channel == 1) schannel = "4mu"; else if (channel == 2) schannel = "4e"; else if (channel == 3) schannel = "2e2mu"; else cout << "Not a valid channel: " << channel << endl; TString schannelFilename = (schannel=="2e2mu"?"2mu2e":schannel); // adapt to naming convention of tree files TString sprocess; if (process == ggH) sprocess = "ggH"; else if (process == qqH) sprocess = "qqH"; else if (process == ZH) sprocess = "ZH"; else if (process == WH) sprocess = "WH"; else if (process == ttH) sprocess = "ttH"; else cout << "Not a valid channel: " << process << endl; TString sjes; if (JES==0.) sjes=""; else if (JES>0.) sjes="_up"; else if (JES<0.) sjes="_down"; TString ssqrts = (long) sqrts + TString("TeV"); // Print table with yields (*txtYields) << endl << endl << left << setw(7) << "*** Summary: " << sprocess << " process, sqrts = " << fixed << setprecision(0) <<sqrts << " TeV, channel = " << schannel << " ***" << endl << endl; (*txtYields) << left << setw(7) << "mH" << setw(13) << "XS*BR" << setw(13) << "Eff unt" << setw(13) << "Yield unt" << setw(13) << "Eff tag" << setw(13) << "Yield tag" << setw(13) << "Eff TOT" << setw(13) << "Yield TOT" << setw(13) << "Eff unt" << setw(13) << "Yield unt" << setw(13) << "Eff tag" << setw(13) << "Yield tag" << setw(13) << "Eff TOT" << setw(13) << "Yield TOT" << setw(13) << "n. raw" << setw(13) << "n. W pwg" << setw(13) << "n. W PU" << setw(13) << "n. W eff" << setw(13) << endl << left << setw(7) << " " << setw(13) << " " << setw(13) << "(in MW)" << setw(13) << "(in MW)" << setw(13) << "(in MW)" << setw(13) << "(in MW)" << setw(13) << "(in MW)" << setw(13) << "(in MW)" << setw(13) << "(full)" << setw(13) << "(full)" << setw(13) << "(full)" << setw(13) << "(full)" << setw(13) << "(full)" << setw(13) << "(full)" << setw(13) << "(full U+T)" << setw(13) << "(full U+T)" << setw(13) << "(full U+T)" << setw(13) << "(full U+T)" << endl << endl; cout << "process = " << sprocess << " schannel = " << schannel << " sqrts = " << sqrts << " JES = " << JES <<endl; TString totoutfile = "CardFragments/signalEfficiency_" + ssqrts + "_" + schannel + sjes + ".txt"; TString ratiooutfile = "CardFragments/signalEfficiency_" + ssqrts + "_" + schannel + sjes + "_ratio.txt"; TString jetyieldoutfile = "CardFragments/signalEfficiency_" + ssqrts + "_" + schannel + sjes + "_jetyields.txt"; // Create card fragments using new powheg samples ofstream oftot; ofstream ofrat; if (process==ggH) { oftot.open(totoutfile,ios_base::out); ofrat.open(ratiooutfile,ios_base::out); } else { oftot.open(totoutfile,ios_base::out | ios_base::app); ofrat.open(ratiooutfile,ios_base::out | ios_base::app); } ftot = new TFile("sigFigs" + ssqrts +"/eff_" + sprocess + "_" + schannel + sjes + (useNewGGHPowheg ? ".root" : "_oldPwg.root"),"RECREATE"); fratio = new TFile("sigFigs" + ssqrts +"/eff_" + sprocess + "_" + schannel + sjes + (useNewGGHPowheg ? "_ratio.root" : "_ratio_oldPwg.root"),"RECREATE"); gSystem->AddIncludePath("-I$ROOFITSYS/include"); setTDRStyle(false); gStyle->SetStatX(-0.5); int nPoints=0; int* masses=0; double* mHVal=0; // Pick the correct set of mass points, set subpath TString filepath; if (process==ggH){ if (useNewGGHPowheg) { if (sqrts==7) { nPoints = nPoints7TeV_p15; masses = masses7TeV_p15; mHVal = mHVal7TeV_p15; filepath = filePath7TeV; } else if (sqrts==8) { nPoints = nPoints8TeV_p15; masses = masses8TeV_p15; mHVal = mHVal8TeV_p15; filepath = filePath8TeV; } } else { // OLD powheg samples if (sqrts==7) { nPoints = nPoints7TeV; masses = masses7TeV; mHVal = mHVal7TeV; filepath = filePath7TeV; } else if (sqrts==8) { nPoints = nPoints8TeV; masses = masses8TeV; mHVal = mHVal8TeV; filepath = filePath8TeV; } } } else if (process==qqH) { if (sqrts==7) { nPoints = nVBFPoints7TeV; masses = VBFmasses7TeV; mHVal = mHVBFVal7TeV; filepath = filePath7TeV; } else if (sqrts==8) { nPoints = nVBFPoints8TeV; masses = VBFmasses8TeV; mHVal = mHVBFVal8TeV; filepath = filePath8TeV; } } else if (process==ZH || process==WH || process==ttH) { if (sqrts==7) { nPoints = nVHPoints7TeV; masses = VHmasses7TeV; mHVal = mHVHVal7TeV; filepath = filePath7TeV; } else if (sqrts==8) { nPoints = nVHPoints8TeV; masses = VHmasses8TeV; mHVal = mHVHVal8TeV; filepath = filePath8TeV; } } float xMax = masses[nPoints-1]+10; const int arraySize=200; assert (arraySize>=nPoints); double totefficiencyVal[arraySize]; double totefficiencyErr[arraySize]; double dijetratioVal[arraySize]; double dijetratioErr[arraySize]; double totefficiencyValInMW[arraySize]; double totefficiencyErrInMW[arraySize]; double dijetratioValInMW[arraySize]; double dijetratioErrInMW[arraySize]; // Define the object to compute XS and BRs HiggsCSandWidth *myCSW = new HiggsCSandWidth(gSystem->ExpandPathName("$CMSSW_BASE/src/Higgs/Higgs_CS_and_Width/txtFiles/")); TString infile; TGraph gJys(nPoints); for (int i = 0; i < nPoints; i++){ // Compute XS and BR double xsTimesBR = 0.; double BRH4e = myCSW->HiggsBR(12,masses[i]); double BRH2e2mu = myCSW->HiggsBR(13,masses[i]); double BRHZZ = myCSW->HiggsBR(11,masses[i]); double BR = BRHZZ; if (process==ggH || process==qqH) { if (channel==fs4mu || channel==fs4e) BR = BRH4e; else BR = BRH2e2mu; } if (process==ggH) xsTimesBR = BR*myCSW->HiggsCS(1,masses[i],sqrts); else if (process==qqH) xsTimesBR = BR*myCSW->HiggsCS(2,masses[i],sqrts); else if (process==ZH) xsTimesBR = BR*myCSW->HiggsCS(3,masses[i],sqrts); else if (process==WH) xsTimesBR = BR*myCSW->HiggsCS(4,masses[i],sqrts); else if (process==ttH) xsTimesBR = BR*myCSW->HiggsCS(5,masses[i],sqrts); if (process==ggH) { if (useNewGGHPowheg){ infile = filepath+ "/" + schannelFilename + "/HZZ4lTree_powheg15" + (masses[i]>200?"H":"jhuGenV3H") + (long)masses[i] + ".root"; } else { infile = filepath+ "/" + schannelFilename + "/HZZ4lTree_H" + (long)masses[i] + ".root"; } } else if (process==qqH) infile = filepath+ "/" + schannelFilename + "/HZZ4lTree_VBFH" + (long)masses[i] + ".root"; else if (process==WH || process==ZH || process==ttH) infile = filepath+ "/" + schannelFilename + "/HZZ4lTree_" + sprocess + (long)masses[i] + ".root"; TFile *f = TFile::Open(infile) ; TTree *t1 = (TTree*) f->Get("SelectedTree"); float MC_weight_norm, MC_weight_PUWeight, MC_weight_powhegWeight, MC_weight_dataMC; float MC_weight_noxsec; float GenHPt; //int NJets; short genProcessId=0; // short NJets30; vector<double> *JetPt=0; vector<double> *JetSigma=0; float ZZMass; t1->SetBranchAddress("MC_weight_norm",&MC_weight_norm); // For efficiency vs "proper" final state t1->SetBranchAddress("MC_weight_noxsec",&MC_weight_noxsec); // For efficiency vs all gen events t1->SetBranchAddress("MC_weight_powhegWeight",&MC_weight_powhegWeight); t1->SetBranchAddress("MC_weight_PUWeight",&MC_weight_PUWeight); t1->SetBranchAddress("MC_weight_dataMC",&MC_weight_dataMC); //t1->SetBranchAddress("NJets",&NJets); t1->SetBranchAddress("genProcessId",&genProcessId); t1->SetBranchAddress("JetPt",&JetPt); t1->SetBranchAddress("JetSigma",&JetSigma); // t1->SetBranchAddress("NJets30",&NJets30); t1->SetBranchAddress("GenHPt",&GenHPt); t1->SetBranchAddress("ZZMass",&ZZMass); //Initialize counters for non-dijet events Counts* untagInMW = new Counts(); Counts* untagAll = new Counts(); Counts* dijetInMW = new Counts(); Counts* dijetAll = new Counts(); // Find window width // FIXME move to external function double valueWidth = myCSW->HiggsWidth(0,masses[i]); double windowVal = max(valueWidth,1.); double lowside = 100.; double highside = 1000.0; if (masses[i] >= 275){ lowside = 180.0; highside = 650.0; } if (masses[i] >= 350){ lowside = 200.0; highside = 900.0; } if (masses[i] >= 500){ lowside = 250.0; highside = 1000.0; } if (masses[i] >= 700){ lowside = 350.0; highside = 1400.0; } double low_M = max( (masses[i] - 20.*windowVal), lowside); double high_M = min((masses[i] + 15.*windowVal), highside); // // Load Higgs pT weights for old powheg // TFile* fW; TH1D* h_HPtWeight; // TString fW_str = "./HPtWeights/weight_"; // fW_str += (long)masses[i]; // fW_str += (TString)".root"; // cout << fW_str << endl; // if (process==ggH) { // fW = TFile::Open(fW_str,"READ"); // h_HPtWeight = (TH1D*)fW->Get("h_weight"); // } for (int a = 0; a < t1->GetEntries(); a++){ t1->GetEntry(a); // Skip VH events that do not belong to the right gen prod mechanism. This is no longer necessary with the proper VH samples if ((process==ZH && genProcessId!=24) || (process==WH && genProcessId!=26) || (process==ttH && (genProcessId!=121 && genProcessId!=122))) continue; // We use the efficiency vs. generated events in the proper FS for ggH, VBF, and the efficiency vs all generated events for VH, ttH float effw = MC_weight_norm; if (process==ZH) { effw = MC_weight_noxsec*filter_eff_ZH_8TeV; } else if (process==WH){ effw = MC_weight_noxsec*filter_eff_WH_8TeV; } else if (process==ttH){ effw = MC_weight_noxsec*filter_eff_ttH_8TeV; } // double HPtWeight = 1.; // if (process==ggH) HPtWeight = h_HPtWeight->GetBinContent(h_HPtWeight->FindBin(GenHPt)); // //cout << "Higgs pT weight = " << HPtWeight << endl; // effw*=HPtWeight; int NJets=0; double jetptc=0; for (unsigned int j=0; j<JetPt->size();j++){ if (JES==0.) jetptc=JetPt->at(j); else if (JES!=0.) jetptc=JetPt->at(j)*(1+JES*JetSigma->at(j)); if (jetptc>30.) NJets++; } // Untagged if (NJets<2){ untagAll->incrCounters(effw, MC_weight_PUWeight, MC_weight_powhegWeight, MC_weight_dataMC); if ( (ZZMass>low_M && ZZMass<high_M) ) untagInMW->incrCounters(effw, MC_weight_PUWeight, MC_weight_powhegWeight, MC_weight_dataMC); } else{ // Dijet dijetAll->incrCounters(effw, MC_weight_PUWeight, MC_weight_powhegWeight, MC_weight_dataMC); if ( (ZZMass>low_M && ZZMass<high_M) ) dijetInMW->incrCounters(effw, MC_weight_PUWeight, MC_weight_powhegWeight, MC_weight_dataMC); } } // FIXME: the 7TeV old samples are assumed to have the ad-hoc correction factor for the mll>12 gen cut, // except for the 124,125,126 new samples. As this factor is accounted for in the x-section, we have to // apply it here. float m = masses[i]; if (!useNewGGHPowheg && process==ggH && sqrts==7 && m>=123.9 && m<=126.1) { float mllCorr = 0.5 + 0.5*erf((m-80.85)/50.42); untagAll->totalCtr = untagAll->totalCtr/mllCorr; untagAll->eff_noweight=untagAll->eff_noweight/mllCorr; untagInMW->totalCtr = untagInMW->totalCtr/mllCorr; untagInMW->eff_noweight=untagInMW->eff_noweight/mllCorr; dijetAll->totalCtr = dijetAll->totalCtr/mllCorr; dijetAll->eff_noweight=dijetAll->eff_noweight/mllCorr; dijetInMW->totalCtr = dijetInMW->totalCtr/mllCorr; dijetInMW->eff_noweight=dijetInMW->eff_noweight/mllCorr; } if (verbose) { cout << " m = " << masses[i] << " :" <<endl; cout << "Selected non-dijet events (all) = " << untagAll->numEventsRaw << " Powheg Wtd= " << untagAll->numEventsPowheg << " PU Wtd= " << untagAll->numEventsPU << " Data/MC Wtd= " << untagAll->numEventsDataMC << " Efficiency= " << untagAll->totalCtr << endl; cout << "Selected non-dijet events (in mass window) = " << untagInMW->numEventsRaw << " Powheg Wtd= " << untagInMW->numEventsPowheg << " PU Wtd= " << untagInMW->numEventsPU << " Data/MC Wtd= " << untagInMW->numEventsDataMC << " Efficiency= " << untagInMW->totalCtr << endl; cout << "Selected dijet events (all) = " << dijetAll->numEventsRaw << " Powheg Wtd= " << dijetAll->numEventsPowheg << " PU Wtd= " << dijetAll->numEventsPU << " Data/MC Wtd= " << dijetAll->numEventsDataMC << " Efficiency= " << dijetAll->totalCtr << endl; cout << "Selected dijet events (in mass window) = " << dijetInMW->numEventsRaw << " Powheg Wtd= " << dijetInMW->numEventsPowheg << " PU Wtd= " << dijetInMW->numEventsPU << " Data/MC Wtd= " << dijetInMW->numEventsDataMC << " Efficiency= " << dijetInMW->totalCtr << endl; } // All events totefficiencyVal[i] = untagAll->totalCtr + dijetAll->totalCtr; cout << "All events: " << sprocess << " " << m << " " << totefficiencyVal[i]<<endl; totefficiencyErr[i] = sqrt(untagAll->sumw2 + dijetAll->sumw2); dijetratioVal[i]=dijetAll->totalCtr/totefficiencyVal[i]; dijetratioErr[i]=sqrt(pow(untagAll->totalCtr,2)*dijetAll->sumw2 + pow(dijetAll->totalCtr,2)*untagAll->sumw2)/pow(totefficiencyVal[i],2); // FIXME: misses 1 term // Events inside the mass window totefficiencyValInMW[i] = untagInMW->totalCtr + dijetInMW->totalCtr; cout << "Events in mass window: " << sprocess << " " << m << " " << totefficiencyValInMW[i]<<endl; totefficiencyErrInMW[i] = sqrt(untagInMW->sumw2 + dijetInMW->sumw2); dijetratioValInMW[i]=dijetInMW->totalCtr/totefficiencyValInMW[i]; dijetratioErrInMW[i]=sqrt(pow(untagInMW->totalCtr,2)*dijetInMW->sumw2 + pow(dijetInMW->totalCtr,2)*untagInMW->sumw2)/pow(totefficiencyValInMW[i],2); // Write yields to output file double lumi = -1.; sqrts == 7 ? lumi = lumi7TeV*1000 : lumi = lumi8TeV*1000; double yieldTot = xsTimesBR*lumi*totefficiencyVal[i]; double yieldTag = xsTimesBR*lumi*dijetratioVal[i]*totefficiencyVal[i]; double yieldUnt = xsTimesBR*lumi*untagAll->totalCtr; double yieldTotInMW = xsTimesBR*lumi*totefficiencyValInMW[i]; double yieldTagInMW = xsTimesBR*lumi*dijetratioValInMW[i]*totefficiencyValInMW[i]; double yieldUntInMW = xsTimesBR*lumi*untagInMW->totalCtr; int prec = 3; if (process>=3) prec=5; (*txtYields) << left << setw(7) << fixed << setprecision(0) << masses[i] << setw(13) << fixed << setprecision(7) << xsTimesBR << setw(13) << fixed << setprecision(prec) << untagInMW->totalCtr << setw(13) << yieldUntInMW << setw(13) << dijetratioValInMW[i]*totefficiencyValInMW[i] << setw(13) << yieldTagInMW << setw(13) << fixed << setprecision(prec) << totefficiencyValInMW[i] << setw(13) << yieldTotInMW << setw(13) << fixed << setprecision(prec) << untagAll->totalCtr << setw(13) << yieldUnt << setw(13) << dijetratioVal[i]*totefficiencyVal[i] << setw(13) << yieldTag << setw(13) << totefficiencyVal[i] << setw(13) << yieldTot << setw(13) << fixed << setprecision(0) << untagAll->numEventsRaw + dijetAll->numEventsRaw << setw(13) << fixed << setprecision(2) << untagAll->numEventsRaw + dijetAll->numEventsPowheg << setw(13) << untagAll->numEventsPU + dijetAll->numEventsPU << setw(13) << untagAll->numEventsDataMC + dijetAll->numEventsDataMC << endl; f->Close(); gJys.SetPoint(i,masses[i],yieldTagInMW/yieldUntInMW); } TF1 *fitJys = new TF1("fitJys","pol3",100,1000); gJys.Fit(fitJys); (*txtYields) << endl << endl << endl; TGraphErrors* totgrEff; TGraphErrors* ratgrEff; if (process==ggH || process==qqH){ totgrEff = new TGraphErrors( nPoints, mHVal, totefficiencyVal, 0, totefficiencyErr); ratgrEff = new TGraphErrors( nPoints, mHVal, dijetratioVal, 0, dijetratioErr); } else { totgrEff = new TGraphErrors( nPoints, mHVal, totefficiencyValInMW, 0, totefficiencyErrInMW); ratgrEff = new TGraphErrors( nPoints, mHVal, dijetratioValInMW, 0, dijetratioErrInMW); } totgrEff->SetMarkerStyle(20); ratgrEff->SetMarkerStyle(20); //ICHEP parametrization //TF1 *polyFunc= new TF1("polyFunc","([0]+[1]*TMath::Erf( (x-[2])/[3] ))*([4]+[5]*x+[6]*x*x)", 110., xMax); //polyFunc->SetParameters(-4.42749e+00,4.61212e+0,-6.21611e+01,1.13168e+02,2.14321e+00,1.04083e-03,4.89570e-07); TF1 *polyFunctot= new TF1("polyFunctot","([0]+[1]*TMath::Erf( (x-[2])/[3] ))*([4]+[5]*x+[6]*x*x)+[7]*TMath::Gaus(x,[8],[9])", 110., xMax); polyFunctot->SetParameters(-4.42749e+00,4.61212e+0,-6.21611e+01,1.13168e+02,2.14321e+00,1.04083e-03,4.89570e-07, 0.03, 200, 30); polyFunctot->SetParLimits(7,0,0.2); polyFunctot->SetParLimits(8,160,210); polyFunctot->SetParLimits(9,10,70); if (process!=ggH && process!=qqH) { polyFunctot->FixParameter(7,0); polyFunctot->FixParameter(8,0); polyFunctot->FixParameter(9,1); } // if (channel==fs4mu && sqrts==7) { // polyFunctot->SetParLimits(7,0,0.035); // polyFunctot->SetParLimits(8,160,210); // polyFunctot->SetParLimits(9,30,50); // } polyFunctot->SetLineColor(4); TString cname = "eff" + sprocess + ssqrts + "_" + schannel; TCanvas *ctot = new TCanvas(cname,cname); ctot->SetGrid(); TString outname = "sigFigs" + ssqrts +"/eff_" + sprocess + "_" + schannel + "_" + sjes; if (!useNewGGHPowheg) outname+="_oldPwg"; totgrEff->Fit(polyFunctot,"Rt"); TString xaxisText = "m_{" + schannel + "}"; totgrEff->GetXaxis()->SetTitle(xaxisText); TString yaxisText = "Efficiency, " + sprocess + ", " + schannel; totgrEff->GetYaxis()->SetTitle(yaxisText); totgrEff->SetMinimum(0.0); totgrEff->SetMaximum(1.0); if (process>=3) totgrEff->SetMaximum(0.0035); totgrEff->Draw("AP"); polyFunctot->Draw("sames"); ctot->Print(outname+".eps"); //ctot->Print(outname+".png"); // Does not work in batch? ctot->Print(outname+".pdf"); //ctot->Print(outname+".root"); ftot->cd(); totgrEff->Write("TotalEfficiency"); ftot->Close(); cout << endl; cout << "------- Parameters for " << sprocess << " " << schannel << " sqrts=" << sqrts << endl; cout << " a1 = " << polyFunctot->GetParameter(0) << endl; cout << " a2 = " << polyFunctot->GetParameter(1) << endl; cout << " a3 = " << polyFunctot->GetParameter(2) << endl; cout << " a4 = " << polyFunctot->GetParameter(3) << endl; cout << " b1 = " << polyFunctot->GetParameter(4) << endl; cout << " b2 = " << polyFunctot->GetParameter(5) << endl; cout << " b3 = " << polyFunctot->GetParameter(6) << endl; cout << " g1 = " << polyFunctot->GetParameter(7) << endl; cout << " g2 = " << polyFunctot->GetParameter(8) << endl; cout << " g3 = " << polyFunctot->GetParameter(9) << endl; cout << "---------------------------" << endl << endl; // Create card fragments using new powheg samples string oftotprocess; if (process==ggH) oftotprocess=""; else oftotprocess=sprocess; if (process==ggH) { oftot << endl; oftot << "## signal efficiency ##" << endl; } oftot << "signalEff " << oftotprocess << "a1 " << polyFunctot->GetParameter(0) << endl; oftot << "signalEff " << oftotprocess << "a2 " << polyFunctot->GetParameter(1) << endl; oftot << "signalEff " << oftotprocess << "a3 " << polyFunctot->GetParameter(2) << endl; oftot << "signalEff " << oftotprocess << "a4 " << polyFunctot->GetParameter(3) << endl; oftot << "signalEff " << oftotprocess << "b1 " << polyFunctot->GetParameter(4) << endl; oftot << "signalEff " << oftotprocess << "b2 " << polyFunctot->GetParameter(5) << endl; oftot << "signalEff " << oftotprocess << "b3 " << polyFunctot->GetParameter(6) << endl; oftot << "signalEff " << oftotprocess << "g1 " << polyFunctot->GetParameter(7) << endl; oftot << "signalEff " << oftotprocess << "g2 " << polyFunctot->GetParameter(8) << endl; oftot << "signalEff " << oftotprocess << "g3 " << polyFunctot->GetParameter(9) << endl; oftot << endl; oftot.close(); cname = "eff" + sprocess + ssqrts + "_" + schannel + "_ratio"; TCanvas *crat = new TCanvas(cname,cname); crat->SetGrid(); outname = "sigFigs" + ssqrts +"/eff_" + sprocess + "_" + schannel + "_" + sjes + "_ratio"; if (!useNewGGHPowheg) outname+="_oldPwg"; TF1 *ratiofit=0; if (process==ggH || process==qqH) ratiofit = new TF1("ratiofit","([0]+[1]*x+[2]*x*x)",110.,xMax); if (process==ZH || process==WH || process==ttH ) ratiofit = new TF1("ratiofit","([0]+[1]*x)",110.,xMax); ratgrEff->Fit(ratiofit,"Rt"); ratgrEff->GetXaxis()->SetTitle(xaxisText); TString yaxisratio = "Dijet ratio, " + sprocess + ", " + schannel; ratgrEff->GetYaxis()->SetTitle(yaxisratio); ratgrEff->SetMinimum(0.0); ratgrEff->SetMaximum(1.0); ratgrEff->Draw("AP"); crat->Print(outname+".eps"); //crat->Print(outname+".png"); // Does not work in batch? crat->Print(outname+".pdf"); //crat->Print(outname+".root"); fratio->cd(); ratgrEff->Write("Ratio"); fratio->Close(); cout << endl; cout << "------- Parameters for " << sprocess << " " << schannel << " sqrts=" << sqrts << endl; cout << " a1 = " << ratiofit->GetParameter(0) << endl; cout << " a2 = " << ratiofit->GetParameter(1) << endl; if (process==ggH || process==qqH) cout << " a3 = " << ratiofit->GetParameter(2) << endl; cout << "---------------------------" << endl << endl; if (process==ggH) { ofrat<<"## jet tagged/untagged ratio"<<endl; ofrat<<"jetYieldRatio "<<fitJys->GetParameter(0)<<"+("<<fitJys->GetParameter(1)<<"*@0)+("<<fitJys->GetParameter(2)<<"*@0*@0)+("<<fitJys->GetParameter(3)<<"*@0*@0*@0)"<< endl <<endl; ofrat << "## signal efficiency ratios ##" << endl; } ofrat << "signalEff tagged_" << sprocess << "_ratio " << ratiofit->GetParameter(0) << "+(" << ratiofit->GetParameter(1) << "*@0)"; if (process==ggH || process==qqH) ofrat << "+(" << ratiofit->GetParameter(2) << "*@0*@0)" << endl; else if (process==ZH || process==WH ) ofrat << endl; else if (process==ttH) ofrat << endl << endl; ofrat.close(); // deviations cout << "Deviations..." << endl; double maxResidual=0; for (int i = 0; i < nPoints; i++){ double eval = polyFunctot->Eval(masses[i]); double residual = (eval - totefficiencyVal[i]); maxResidual = max(maxResidual,fabs(residual)); if (verbose) cout << "For mass, " << masses[i] << ": measured value is " << totefficiencyVal[i] << " and difference from function is " << residual <<endl; } cout << "Largest residual= " << maxResidual << endl; delete fitJys; delete myCSW; delete polyFunctot; delete ratiofit; }
void higgs_hlt87(){ float x[16], ex[16]; float x2[18], ex2[18]; float x3[19], ex3[19]; TFile *_fileggh[19]; _fileggh[0] = TFile::Open("ggh_m60_8TeV/output.root"); _fileggh[1] = TFile::Open("ggh_m65_8TeV/output.root"); _fileggh[2] = TFile::Open("ggh_m70_8TeV/output.root"); _fileggh[3] = TFile::Open("ggh_m75_8TeV/output.root"); _fileggh[4] = TFile::Open("ggh_m80_8TeV/output.root"); _fileggh[5] = TFile::Open("ggh_m85_8TeV/output.root"); _fileggh[6] = TFile::Open("ggh_m90_8TeV/output.root"); _fileggh[7] = TFile::Open("ggh_m95_8TeV/output.root"); _fileggh[8] = TFile::Open("ggh_m100_8TeV/output.root"); _fileggh[9] = TFile::Open("ggh_m105_8TeV/output.root"); _fileggh[10] = TFile::Open("ggh_m110_8TeV/output.root"); _fileggh[11] = TFile::Open("ggh_m115_8TeV/output.root"); _fileggh[12] = TFile::Open("ggh_m120_8TeV/output.root"); _fileggh[13] = TFile::Open("ggh_m125_8TeV/output.root"); _fileggh[14] = TFile::Open("ggh_m130_8TeV/output.root"); _fileggh[15] = TFile::Open("ggh_m135_8TeV/output.root"); _fileggh[16] = TFile::Open("ggh_m140_8TeV/output.root"); _fileggh[17] = TFile::Open("ggh_m145_8TeV/output.root"); _fileggh[18] = TFile::Open("ggh_m150_8TeV/output.root"); TFile *_filetth[19]; _filetth[0] = TFile::Open("tth_m60_8TeV/output.root"); _filetth[1] = TFile::Open("tth_m65_8TeV/output.root"); _filetth[2] = TFile::Open("tth_m70_8TeV/output.root"); _filetth[3] = TFile::Open("tth_m75_8TeV/output.root"); _filetth[4] = TFile::Open("tth_m80_8TeV/output.root"); _filetth[5] = TFile::Open("tth_m85_8TeV/output.root"); _filetth[6] = TFile::Open("tth_m90_8TeV/output.root"); _filetth[7] = TFile::Open("tth_m95_8TeV/output.root"); _filetth[8] = TFile::Open("tth_m100_8TeV/output.root"); _filetth[9] = TFile::Open("tth_m105_8TeV/output.root"); _filetth[10] = TFile::Open("tth_m110_8TeV/output.root"); _filetth[11] = TFile::Open("tth_m115_8TeV/output.root"); _filetth[12] = TFile::Open("tth_m120_8TeV/output.root"); _filetth[13] = TFile::Open("tth_m125_8TeV/output.root"); _filetth[14] = TFile::Open("tth_m130_8TeV/output.root"); _filetth[15] = TFile::Open("tth_m135_8TeV/output.root"); _filetth[16] = TFile::Open("tth_m140_8TeV/output.root"); _filetth[17] = TFile::Open("tth_m145_8TeV/output.root"); _filetth[18] = TFile::Open("tth_m150_8TeV/output.root"); TFile *_filevbf[19]; _filevbf[0] = TFile::Open("vbf_m60_8TeV/output.root"); _filevbf[1] = TFile::Open("vbf_m65_8TeV/output.root"); _filevbf[2] = TFile::Open("vbf_m70_8TeV/output.root"); _filevbf[3] = TFile::Open("vbf_m75_8TeV/output.root"); _filevbf[4] = TFile::Open("vbf_m80_8TeV/output.root"); _filevbf[5] = TFile::Open("vbf_m85_8TeV/output.root"); _filevbf[6] = TFile::Open("vbf_m90_8TeV/output.root"); _filevbf[7] = TFile::Open("vbf_m95_8TeV/output.root"); _filevbf[8] = TFile::Open("vbf_m100_8TeV/output.root"); _filevbf[9] = TFile::Open("vbf_m105_8TeV/output.root"); _filevbf[10] = TFile::Open("vbf_m110_8TeV/output.root"); _filevbf[11] = TFile::Open("vbf_m115_8TeV/output.root"); _filevbf[12] = TFile::Open("vbf_m120_8TeV/output.root"); _filevbf[13] = TFile::Open("vbf_m125_8TeV/output.root"); _filevbf[14] = TFile::Open("vbf_m130_8TeV/output.root"); _filevbf[15] = TFile::Open("vbf_m135_8TeV/output.root"); _filevbf[16] = TFile::Open("vbf_m140_8TeV/output.root"); _filevbf[17] = TFile::Open("vbf_m145_8TeV/output.root"); _filevbf[18] = TFile::Open("vbf_m150_8TeV/output.root"); TFile *_filewzh[19]; _filewzh[0] = TFile::Open("wzh_m60_8TeV/output.root"); _filewzh[1] = TFile::Open("wzh_m65_8TeV/output.root"); _filewzh[2] = TFile::Open("wzh_m70_8TeV/output.root"); _filewzh[3] = TFile::Open("wzh_m75_8TeV/output.root"); _filewzh[4] = TFile::Open("wzh_m80_8TeV/output.root"); _filewzh[5] = TFile::Open("wzh_m85_8TeV/output.root"); _filewzh[6] = TFile::Open("wzh_m90_8TeV/output.root"); _filewzh[7] = TFile::Open("wzh_m95_8TeV/output.root"); _filewzh[8] = TFile::Open("wzh_m100_8TeV/output.root"); _filewzh[9] = TFile::Open("wzh_m105_8TeV/output.root"); _filewzh[10] = TFile::Open("wzh_m110_8TeV/output.root"); _filewzh[11] = TFile::Open("wzh_m115_8TeV/output.root"); _filewzh[12] = TFile::Open("wzh_m120_8TeV/output.root"); _filewzh[13] = TFile::Open("wzh_m125_8TeV/output.root"); _filewzh[14] = TFile::Open("wzh_m130_8TeV/output.root"); _filewzh[15] = TFile::Open("wzh_m135_8TeV/output.root"); _filewzh[16] = TFile::Open("wzh_m140_8TeV/output.root"); _filewzh[17] = TFile::Open("wzh_m140_8TeV/output.root"); _filewzh[18] = TFile::Open("wzh_m145_8TeV/output.root"); float avEFFggh[19]; float avEFFtth[19]; float avEFFwzh[19]; float avEFFvbf[19]; float avERRggh[19]; float avERRtth[19]; float avERRwzh[19]; float avERRvbf[19]; float mass_value=55.; for(int k=0;k<19;k++){ mass_value=mass_value+5.; x3[k] = mass_value; ex3[k] = 0; avEFFggh[k] = efficiency(_fileggh[k]); avEFFtth[k] = efficiency(_filetth[k]); avEFFvbf[k] = efficiency(_filevbf[k]); avEFFwzh[k] = efficiency(_filewzh[k]); avERRggh[k] = error(_fileggh[k]); avERRwzh[k] = error(_filewzh[k]); avERRtth[k] = error(_filetth[k]); avERRvbf[k] = error(_filevbf[k]); } cout << x3[0] <<" : " << avEFFggh[0] << "------" << avERRggh[0] << endl; cout << x3[1] <<" : " << avEFFggh[1] << "------" << avERRggh[1] << endl; cout << x3[2] <<" : " << avEFFggh[2] << "------" << avERRggh[2] << endl; cout << x3[3] <<" : " << avEFFggh[3] << "------" << avERRggh[3] << endl; TGraphErrors * ggh = new TGraphErrors(19,x3,avEFFggh,ex3,avERRggh); TGraphErrors * vbf = new TGraphErrors(19,x3,avEFFvbf,ex3,avERRvbf); TGraphErrors * wzh = new TGraphErrors(19,x3,avEFFwzh,ex3,avERRwzh); TGraphErrors * tth = new TGraphErrors(19,x3,avEFFtth,ex3,avERRtth); ggh->SetMarkerStyle(22);ggh->SetMarkerSize(2.0); vbf->SetMarkerStyle(23);vbf->SetMarkerSize(2.0); wzh->SetMarkerStyle(20);wzh->SetMarkerSize(2.0); tth->SetMarkerStyle(21);tth->SetMarkerSize(2.0); ggh->SetMarkerColor(kRed); vbf->SetMarkerColor(kBlue); wzh->SetMarkerColor(kGreen); tth->SetMarkerColor(kBlack); tth->GetXaxis()->SetTitle("M_{H} (GeV)"); tth->GetYaxis()->SetTitle("#epsilon"); ggh->GetXaxis()->SetTitle("M_{H} (GeV)"); ggh->GetYaxis()->SetTitle("#epsilon"); vbf->GetXaxis()->SetTitle("M_{H} (GeV)"); vbf->GetYaxis()->SetTitle("#epsilon"); wzh->GetXaxis()->SetTitle("M_{H} (GeV)"); wzh->GetYaxis()->SetTitle("#epsilon"); TCanvas *C1 = new TCanvas("C1","Global Efficiency",200,10,1200,800); C1->SetFillColor(10); C1->Draw(); C1->cd(); float min=0.0; float max=1.0; ggh->SetMinimum(min);ggh->SetMaximum(max); vbf->SetMinimum(min);vbf->SetMaximum(max); wzh->SetMinimum(min);wzh->SetMaximum(max); tth->SetMinimum(min);tth->SetMaximum(max); ggh->Draw("AP"); vbf->Draw("Psame"); wzh->Draw("Psame"); tth->Draw("Psame"); C1->Update(); TLegend *leg = new TLegend(0.6,0.35,0.7,0.2); //leg->AddEntry(glui,"gluino split-SUSY","lp"); //leg->AddEntry(stop,"stop MSSM","lp"); leg->AddEntry(ggh,"ggh","p"); leg->AddEntry(vbf,"vbf","p"); leg->AddEntry(tth,"tth","p"); leg->AddEntry(wzh,"wzh","p"); leg->SetFillColor(0); leg->Draw("same"); C1->SaveAs("summary87.png"); min=0.9; max=1.0; ggh->SetMinimum(min);ggh->SetMaximum(max); vbf->SetMinimum(min);vbf->SetMaximum(max); wzh->SetMinimum(min);wzh->SetMaximum(max); tth->SetMinimum(min);tth->SetMaximum(max); ggh->Draw("AP"); vbf->Draw("Psame"); wzh->Draw("Psame"); tth->Draw("Psame"); C1->Update(); TLegend *leg = new TLegend(0.6,0.35,0.7,0.2); //leg->AddEntry(glui,"gluino split-SUSY","lp"); //leg->AddEntry(stop,"stop MSSM","lp"); leg->AddEntry(ggh,"ggh","p"); leg->AddEntry(vbf,"vbf","p"); leg->AddEntry(tth,"tth","p"); leg->AddEntry(wzh,"wzh","p"); leg->SetFillColor(0); leg->Draw("same"); C1->SaveAs("summary87_0p9.png"); min=0.7; max=1.0; ggh->SetMinimum(min);ggh->SetMaximum(max); vbf->SetMinimum(min);vbf->SetMaximum(max); wzh->SetMinimum(min);wzh->SetMaximum(max); tth->SetMinimum(min);tth->SetMaximum(max); ggh->Draw("AP"); vbf->Draw("Psame"); wzh->Draw("Psame"); tth->Draw("Psame"); C1->Update(); TLegend *leg = new TLegend(0.6,0.35,0.7,0.2); leg->AddEntry(ggh,"ggh","p"); leg->AddEntry(vbf,"vbf","p"); leg->AddEntry(tth,"tth","p"); leg->AddEntry(wzh,"wzh","p"); leg->SetFillColor(0); leg->Draw("same"); C1->SaveAs("summary87_0p7.png"); exit(0); }