Changes in / [df315dc:9f8d4e7] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/Validation.C
rdf315dc r9f8d4e7 49 49 double ptmin; 50 50 double ptmax; 51 double xmin;52 double xmax;53 51 TString obj; 54 52 55 53 resolPlot(); 56 54 resolPlot(double ptdown, double ptup, TString object); 57 void set(double ptdown, double ptup, TString object , double xmin = 0, double xmax = 2);55 void set(double ptdown, double ptup, TString object); 58 56 void print(){std::cout << ptmin << std::endl;} 59 57 }; … … 69 67 } 70 68 71 void resolPlot::set(double ptdown, double ptup, TString object , double xmin, double xmax){69 void resolPlot::set(double ptdown, double ptup, TString object){ 72 70 ptmin = ptdown; 73 71 ptmax = ptup; 74 72 obj = object; 75 73 76 cenResolHist = new TH1D(obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_cen", obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_cen", 500, xmin, xmax);77 fwdResolHist = new TH1D(obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_fwd", obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_fwd", 500, xmin, xmax);78 79 } 80 81 void HistogramsCollection(std::vector<resolPlot> *histos, double ptmin, double ptmax, TString obj , double xmin = 0, double xmax = 2)74 cenResolHist = new TH1D(obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_cen", obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_cen", 500, 0, 2); 75 fwdResolHist = new TH1D(obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_fwd", obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_fwd", 500, 0.4, 0.4); 76 77 } 78 79 void HistogramsCollection(std::vector<resolPlot> *histos, double ptmin, double ptmax, TString obj) 82 80 { 83 81 double width; … … 91 89 ptdown = TMath::Power(10,ptmin + i * width ); 92 90 ptup = TMath::Power(10,ptmin + (i+1) * width ); 93 ptemp.set(ptdown, ptup, obj , xmin, xmax);91 ptemp.set(ptdown, ptup, obj); 94 92 histos->push_back(ptemp); 95 93 } … … 364 362 } 365 363 } 366 367 void GetMetres(std::vector<resolPlot> *histos, TClonesArray *branchScalarHT, TClonesArray *branchMet, TClonesArray *branchJet, ExRootTreeReader *treeReader)368 {369 370 Long64_t allEntries = treeReader->GetEntries();371 372 cout << "** Computing resolution of " << branchMet->GetName() << " vs " << branchScalarHT->GetName() << endl;373 374 MissingET *met;375 ScalarHT *scalarHT;376 377 Long64_t entry;378 379 Int_t bin;380 Double_t ht;381 382 // Loop over all events383 for(entry = 0; entry < allEntries; ++entry)384 {385 // Load selected branches with data from specified event386 treeReader->ReadEntry(entry);387 388 if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;389 390 if (branchJet->GetEntriesFast() > 1)391 {392 met = (MissingET*) branchMet->At(0);393 scalarHT = (ScalarHT*) branchScalarHT->At(0);394 ht = scalarHT->HT;395 396 for (bin = 0; bin < Nbins; bin++)397 {398 if(ht > histos->at(bin).ptmin && ht < histos->at(bin).ptmax )399 {400 histos->at(bin).cenResolHist->Fill(met->P4().Px());401 histos->at(bin).fwdResolHist->Fill(met->P4().Py());402 }403 }404 }405 }406 }407 408 409 364 std::pair<Double_t, Double_t> GausFit(TH1* hist) 410 365 { … … 419 374 420 375 421 TGraphErrors EresGraph(std::vector<resolPlot> *histos, bool central , bool rms = false)376 TGraphErrors EresGraph(std::vector<resolPlot> *histos, bool central) 422 377 { 423 378 Int_t bin; … … 434 389 std::cout << " entries : " << histos->at(bin).cenResolHist->GetEntries() << std::endl; 435 390 std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).cenResolHist); 436 if (rms == true) 437 { 438 gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.second); 439 gr.SetPointError(count,0, sigvalues.second); // to correct 440 } 441 else 442 { 443 gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.first); 444 gr.SetPointError(count,0, sigvalues.second); 445 } 391 gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.first); 392 gr.SetPointError(count,0, sigvalues.second); 446 393 count++; 447 394 } … … 604 551 TClonesArray *branchPFJet = treeReader->UseBranch("Jet"); 605 552 TClonesArray *branchCaloJet = treeReader->UseBranch("CaloJet"); 606 TClonesArray *branchScalarHT = treeReader->UseBranch("ScalarHT");607 TClonesArray *branchMet = treeReader->UseBranch("MissingET");608 553 609 554 #ifdef ELECTRON … … 866 811 gr_pfjets.SetName("pfJet"); 867 812 868 // CaloJets Energy Resolution 813 814 // PFJets Energy Resolution 869 815 std::vector<resolPlot> plots_calojets; 870 816 HistogramsCollection(&plots_calojets, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "CaloJet"); … … 873 819 gr_calojets.SetName("caloJet"); 874 820 875 // MET Resolution vs HT876 std::vector<resolPlot> plots_met;877 HistogramsCollection(&plots_met, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "MET", -200, 200);878 GetMetres( &plots_met, branchScalarHT, branchMet, branchPFJet, treeReader);879 TGraphErrors gr_met = EresGraph(&plots_met, true);880 gr_calojets.SetName("MET");881 882 821 // Canvas 883 822 … … 943 882 C_btag1->SaveAs(btagEff+".eps"); 944 883 C_jet->SaveAs(jetRes+".eps"); 945 946 TString metRes = "MetRes";947 TCanvas *C_met = new TCanvas(metRes,metRes, 1000, 500);948 949 TMultiGraph *mg_met = new TMultiGraph(metRes,metRes);950 TLegend *leg_met = new TLegend(0.52,0.7,0.9,0.9);951 952 addGraph(mg_met, &gr_met, leg_met, 3);953 954 mg_met->Draw("ACX");955 leg_met->Draw();956 957 DrawAxis(mg_met, leg_met, 100);958 959 C_met->SaveAs(metRes+".eps");960 961 884 962 885 #endif … … 1011 934 plots_pfjets.at(bin).cenResolHist->Write(); 1012 935 plots_calojets.at(bin).cenResolHist->Write(); 1013 plots_met.at(bin).cenResolHist->Write();1014 936 } 1015 937 histos_btag.first->Write(); … … 1020 942 C_tautag1->Write(); 1021 943 C_jet->Write(); 1022 C_met->Write();1023 944 #endif 1024 945
Note:
See TracChangeset
for help on using the changeset viewer.