Fork me on GitHub

Changeset 7b48085 in git for examples


Ignore:
Timestamp:
Aug 23, 2016, 4:00:03 PM (8 years ago)
Author:
GitHub <noreply@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
ea0f50d
Parents:
df315dc (diff), 20ca0cd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Pavel Demin <pavel-demin@…> (08/23/16 16:00:03)
git-committer:
GitHub <noreply@…> (08/23/16 16:00:03)
Message:

Merge pull request #2 from AlexandreMertens/ValidationWorkWithPavel

modify plot with central and forward

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/Validation.C

    rdf315dc r7b48085  
    144144  Int_t i, j;
    145145
    146   TH1D *histGenPt = new TH1D(name+" gen spectra Pt",name+" gen spectra Pt", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax));
    147   TH1D *histRecoPt = new TH1D(name+" reco spectra Pt",name+" reco spectra Pt", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax));
    148   TH1D *histGenEta  = new TH1D(name+" gen spectra Eta",name+" gen spectra Eta", 12, -3, 3);
    149   TH1D *histRecoEta = new TH1D(name+" reco spectra Eta",name+" reco spectra Eta", 12, -3, 3);
    150 
    151 
    152   BinLogX(histGenPt);
    153   BinLogX(histRecoPt);
     146  TH1D *histGenPtcen = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax));
     147  TH1D *histRecoPtcen = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax));
     148  TH1D *histGenPtfwd  = new TH1D(name+" gen spectra Eta",name+" gen spectra fwd", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax));
     149  TH1D *histRecoPtfwd = new TH1D(name+" reco spectra Eta",name+" reco spectra fwd", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax));
     150
     151
     152  BinLogX(histGenPtcen);
     153  BinLogX(histRecoPtcen);
     154  BinLogX(histGenPtfwd);
     155  BinLogX(histRecoPtfwd);
    154156
    155157  // Loop over all events
     
    201203        eta = genMomentum.Eta();
    202204
    203         histGenPt->Fill(pt);
    204         histGenEta->Fill(eta);
    205 
    206         if(deltaR < 0.3)
     205        if (TMath::Abs(eta) < 1.5)
    207206        {
    208           histRecoPt->Fill(pt);
    209           histRecoEta->Fill(eta);
     207          histGenPtcen->Fill(pt);
     208          if(deltaR < 0.3) { histRecoPtcen->Fill(pt); }
     209        }
     210        else if (TMath::Abs(eta) < 2.5)
     211        {
     212          histGenPtfwd->Fill(pt);
     213          if(deltaR < 0.3) { histRecoPtfwd->Fill(pt); }
     214         
    210215        }
    211216      }
     
    216221  std::pair<TH1D*,TH1D*> histos;
    217222
    218   histRecoPt->Divide(histGenPt);
    219   histRecoEta->Divide(histGenEta);
    220 
    221   histos.first = histRecoPt;
    222   histos.second = histRecoEta;
     223  histRecoPtcen->Divide(histGenPtcen);
     224  histRecoPtfwd->Divide(histGenPtfwd);
     225
     226  histos.first = histRecoPtcen;
     227  histos.second = histRecoPtfwd;
    223228
    224229  return histos;
     
    355360        for (bin = 0; bin < Nbins; bin++)
    356361        {
    357             if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta > 0.0 && eta < 1.5)
     362            if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 1.5)
    358363            {
    359364                histos->at(bin).cenResolHist->Fill(jetMomentum.Pt()/bestGenJetMomentum.Pt());
    360365            }
     366            else if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 2.5)
     367            {
     368                histos->at(bin).fwdResolHist->Fill(jetMomentum.Pt()/bestGenJetMomentum.Pt());
     369            }
     370
    361371        }
    362372      }
     
    430440        if (central == true && histos->at(bin).cenResolHist->GetEntries() > 100)
    431441        {
    432             std::cout << " pt : " << (histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0;
    433             std::cout << " mean : " << histos->at(bin).cenResolHist->GetMean() << " RMS : " << histos->at(bin).cenResolHist->GetRMS();
    434             std::cout << " entries : " << histos->at(bin).cenResolHist->GetEntries() << std::endl;
    435442            std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).cenResolHist);
    436443            if (rms == true)
     
    446453            count++;
    447454        }
    448         /*
    449         else if (histos->at(bin).cenResolHist->GetEntries() > 10)
     455       
     456        else if (central == false && histos->at(bin).fwdResolHist->GetEntries() > 10)
    450457        {
    451             histos->at(bin).fwdResolHist->Fit("gaus","","", -2*histos->at(bin).fwdResolHist->GetRMS(), 2*histos->at(bin).fwdResolHist->GetRMS());
    452             TF1 *f = histos->at(bin).fwdResolHist->GetFunction("gaus");
    453             Double_t sig = f->GetParameter(2);
    454             Double_t sigErr = f->GetParError(2);
    455             gr.SetPoint(bin,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sig);
    456             gr.SetPointError(bin,0, sigErr);
     458            std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).fwdResolHist);
     459            if (rms == true)
     460            {
     461              gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.second);
     462              gr.SetPointError(count,0, sigvalues.second); // to correct
     463            }
     464            else
     465            {
     466              gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.first);
     467              gr.SetPointError(count,0, sigvalues.second);
     468            }
     469            count++;
    457470        }
    458         */
     471       
    459472    }
    460473    return gr;
     
    629642  GetEres<Electron>( &plots_el, branchElectron, branchParticle, elID, treeReader);
    630643  TGraphErrors gr_el = EresGraph(&plots_el, true);
     644  TGraphErrors gr_elFwd = EresGraph(&plots_el, false);
    631645  gr_el.SetName("Electron");
     646  gr_elFwd.SetName("ElectronFwd");
    632647
    633648  // Electron Track Energy Resolution
     
    636651  GetEres<Track>( &plots_eltrack, branchTrack, branchParticle, elID, treeReader);
    637652  TGraphErrors gr_eltrack = EresGraph(&plots_eltrack, true);
     653  TGraphErrors gr_eltrackFwd = EresGraph(&plots_eltrack, false);
    638654  gr_eltrack.SetName("ElectronTracks");
     655  gr_eltrackFwd.SetName("ElectronTracksFwd");
    639656
    640657  // Electron Tower Energy Resolution
     
    643660  GetEres<Tower>( &plots_eltower, branchTower, branchParticle, elID, treeReader);
    644661  TGraphErrors gr_eltower = EresGraph(&plots_eltower, true);
     662  TGraphErrors gr_eltowerFwd = EresGraph(&plots_eltower, false);
    645663  gr_eltower.SetName("ElectronTower");
     664  gr_eltrackFwd.SetName("ElectronTracksFwd");
    646665
    647666  // Canvases
     
    666685  TLegend *leg_el2 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax);
    667686
     687  gPad->SetLogx();
    668688  histos_eltrack.second->Draw();
    669689  addHist(histos_eltrack.second, leg_el2, 2);
     
    673693  addHist(histos_el.second, leg_el2, 1);
    674694
    675   DrawAxis(histos_eltrack.second, leg_el2, 1);
     695  DrawAxis(histos_eltrack.second, leg_el2, 0);
    676696  delete(leg_el2);
    677697  C_el1->cd(0);
    678698 
    679699  TString elRes = "electronERes";
     700  TString elResFwd = "electronEResForward";
    680701  TCanvas *C_el2 = new TCanvas(elRes,elRes, 1000, 500);
     702  C_el2->Divide(2);
     703  C_el2->cd(1);
    681704  TMultiGraph *mg_el = new TMultiGraph(elRes,elRes);
    682705  TLegend *leg_el = new TLegend(0.52,0.7,0.9,0.9);
     
    690713
    691714  DrawAxis(mg_el, leg_el, 0.1);
     715
     716  C_el2->cd(2);
     717  TMultiGraph *mg_elFwd = new TMultiGraph(elResFwd,elResFwd);
     718  TLegend *leg_elFwd = new TLegend(0.52,0.7,0.9,0.9);
     719
     720  addGraph(mg_elFwd, &gr_eltowerFwd, leg_elFwd, 3);
     721  addGraph(mg_elFwd, &gr_eltrackFwd, leg_elFwd, 2);
     722  addGraph(mg_elFwd, &gr_elFwd, leg_elFwd, 1);
     723
     724  mg_elFwd->Draw("ACX");
     725
     726  DrawAxis(mg_elFwd, leg_elFwd, 0.1);
     727
    692728 
    693729  C_el1->SaveAs(elEff+".eps");
     
    716752  GetEres<Muon>( &plots_mu, branchMuon, branchParticle, muID, treeReader);
    717753  TGraphErrors gr_mu = EresGraph(&plots_mu, true);
     754  TGraphErrors gr_muFwd = EresGraph(&plots_mu, false);
    718755  gr_mu.SetName("Muon");
     756  gr_muFwd.SetName("MuonFwd");
    719757
    720758  // Muon Track Energy Resolution
     
    723761  GetEres<Track>( &plots_mutrack, branchTrack, branchParticle, muID, treeReader);
    724762  TGraphErrors gr_mutrack = EresGraph(&plots_mutrack, true);
    725   gr_mutrack.SetName("MuonTracks");
     763  TGraphErrors gr_mutrackFwd = EresGraph(&plots_mutrack, false);
     764  gr_mutrackFwd.SetName("MuonTracksFwd");
    726765
    727766  // Canvas
     
    745784  TLegend *leg_mu2 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax);
    746785
     786  gPad->SetLogx();
    747787  histos_mutrack.second->Draw();
    748788  addHist(histos_mutrack.second, leg_mu2, 2);
     
    753793
    754794  TString muRes = "muonERes";
     795  TString muResFwd = "muonEResFwd";
     796
    755797  TCanvas *C_mu = new TCanvas(muRes,muRes, 1000, 500);
     798  C_mu->Divide(2);
     799  C_mu->cd(1);
    756800  TMultiGraph *mg_mu = new TMultiGraph(muRes,muRes);
    757801  TLegend *leg_mu = new TLegend(0.52,0.7,0.9,0.9);
     
    764808
    765809  DrawAxis(mg_mu, leg_mu, 0.3);
     810
     811  C_mu->cd(2);
     812  TMultiGraph *mg_muFwd = new TMultiGraph(muResFwd,muResFwd);
     813  TLegend *leg_muFwd = new TLegend(0.52,0.7,0.9,0.9);
     814
     815  addGraph(mg_muFwd, &gr_mutrackFwd, leg_muFwd, 2);
     816  addGraph(mg_muFwd, &gr_muFwd, leg_muFwd, 1);
     817
     818  mg_muFwd->Draw("ACX");
     819
     820  DrawAxis(mg_muFwd, leg_muFwd, 0.3);
    766821
    767822  C_mu1->SaveAs(muEff+".eps");
     
    788843  GetEres<Photon>( &plots_ph, branchPhoton, branchParticle, phID, treeReader);
    789844  TGraphErrors gr_ph = EresGraph(&plots_ph, true);
     845  TGraphErrors gr_phFwd = EresGraph(&plots_ph, false);
    790846  gr_ph.SetName("Photon");
     847  gr_phFwd.SetName("PhotonFwd");
     848
    791849
    792850  // Photon Tower Energy Resolution
     
    795853  GetEres<Tower>( &plots_phtower, branchTower, branchParticle, phID, treeReader);
    796854  TGraphErrors gr_phtower = EresGraph(&plots_phtower, true);
     855  TGraphErrors gr_phtowerFwd = EresGraph(&plots_phtower, false);
    797856  gr_phtower.SetName("PhotonTower");
     857  gr_phtowerFwd.SetName("PhotonTowerFwd");
    798858
    799859  // Canvas
     
    817877  TLegend *leg_ph2 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax);
    818878
     879  gPad->SetLogx();
    819880  histos_phtower.second->Draw("same");
    820881  addHist(histos_phtower.second, leg_ph2, 3);
     
    827888
    828889  TString phRes = "phERes";
     890  TString phResFwd = "phEResFwd";
     891
    829892  TCanvas *C_ph = new TCanvas(phRes,phRes, 1000, 500);
     893  C_ph->Divide(2);
     894  C_ph->cd(1);
    830895  TMultiGraph *mg_ph = new TMultiGraph(phRes,phRes);
    831896  TLegend *leg_ph = new TLegend(0.52,0.7,0.9,0.9);
     
    838903
    839904  DrawAxis(mg_ph, leg_ph, 0.3);
     905
     906  C_ph->cd(2);
     907  TMultiGraph *mg_phFwd = new TMultiGraph(phResFwd,phResFwd);
     908  TLegend *leg_phFwd = new TLegend(0.52,0.7,0.9,0.9);
     909
     910  addGraph(mg_phFwd, &gr_phtowerFwd, leg_phFwd, 3);
     911  addGraph(mg_phFwd, &gr_phFwd, leg_phFwd, 1);
     912
     913  mg_phFwd->Draw("ACX");
     914
     915  DrawAxis(mg_phFwd, leg_phFwd, 0.3);
    840916
    841917  C_ph->SaveAs(phRes+".eps");
     
    864940  GetJetsEres( &plots_pfjets, branchPFJet, branchGenJet, treeReader);
    865941  TGraphErrors gr_pfjets = EresGraph(&plots_pfjets, true);
     942  TGraphErrors gr_pfjetsFwd = EresGraph(&plots_pfjets, false);
    866943  gr_pfjets.SetName("pfJet");
     944  gr_pfjetsFwd.SetName("pfJetFwd");
    867945
    868946  // CaloJets Energy Resolution
     
    871949  GetJetsEres( &plots_calojets, branchCaloJet, branchGenJet, treeReader);
    872950  TGraphErrors gr_calojets = EresGraph(&plots_calojets, true);
     951  TGraphErrors gr_calojetsFwd = EresGraph(&plots_calojets, false);
    873952  gr_calojets.SetName("caloJet");
     953  gr_calojetsFwd.SetName("caloJetFwd");
    874954
    875955  // MET Resolution vs HT
     
    881961
    882962  // Canvas
    883 
    884963  TString btagEff = "btagEff";
    885964  TCanvas *C_btag1 = new TCanvas(btagEff,btagEff, 1000, 500);
     
    9291008
    9301009  TString jetRes = "jetERes";
     1010  TString jetResFwd = "jetEResFwd";
    9311011  TCanvas *C_jet = new TCanvas(jetRes,jetRes, 1000, 500);
     1012  C_jet->Divide(2);
     1013
     1014  C_jet->cd(1);
    9321015  TMultiGraph *mg_jet = new TMultiGraph(jetRes,jetRes);
    9331016  TLegend *leg_jet = new TLegend(0.52,0.7,0.9,0.9);
     
    9401023
    9411024  DrawAxis(mg_jet, leg_jet, 0.25);
     1025
     1026  C_jet->cd(2);
     1027  TMultiGraph *mg_jetFwd = new TMultiGraph(jetResFwd,jetResFwd);
     1028  TLegend *leg_jetFwd = new TLegend(0.52,0.7,0.9,0.9);
     1029
     1030  addGraph(mg_jetFwd, &gr_calojetsFwd, leg_jetFwd, 3);
     1031  addGraph(mg_jetFwd, &gr_pfjetsFwd, leg_jetFwd, 1);
     1032
     1033  mg_jetFwd->Draw("ACX");
     1034
     1035  DrawAxis(mg_jetFwd, leg_jetFwd, 0.25);
    9421036
    9431037  C_btag1->SaveAs(btagEff+".eps");
     
    9791073      plots_eltrack.at(bin).cenResolHist->Write();
    9801074      plots_eltower.at(bin).cenResolHist->Write();
     1075      plots_el.at(bin).fwdResolHist->Write();
     1076      plots_eltrack.at(bin).fwdResolHist->Write();
     1077      plots_eltower.at(bin).fwdResolHist->Write();
    9811078  }
    9821079  //  gr.Write();
     
    10101107  {
    10111108      plots_pfjets.at(bin).cenResolHist->Write();
     1109      plots_pfjets.at(bin).fwdResolHist->Write();
    10121110      plots_calojets.at(bin).cenResolHist->Write();
     1111      plots_calojets.at(bin).fwdResolHist->Write();
    10131112      plots_met.at(bin).cenResolHist->Write();
    10141113  }
Note: See TracChangeset for help on using the changeset viewer.