Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/Validation.C

    r6563d4d rcf88574  
    4949    double ptmin;
    5050    double ptmax;
    51     double xmin;
    52     double xmax;
    5351    TString obj;
    5452
    5553    resolPlot();
    5654    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);
    5856    void print(){std::cout << ptmin << std::endl;}
    5957};
     
    6967}
    7068
    71 void resolPlot::set(double ptdown, double ptup, TString object, double xmin, double xmax){
     69void resolPlot::set(double ptdown, double ptup, TString object){
    7270    ptmin = ptdown;
    7371    ptmax = ptup;
    7472    obj = object;
    7573
    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
     79void HistogramsCollection(std::vector<resolPlot> *histos, double ptmin, double ptmax, TString obj)
    8280{
    8381    double width;
     
    9189        ptdown = TMath::Power(10,ptmin + i * width );
    9290        ptup = TMath::Power(10,ptmin + (i+1) * width );
    93         ptemp.set(ptdown, ptup, obj, xmin, xmax);
     91        ptemp.set(ptdown, ptup, obj);
    9492        histos->push_back(ptemp);
    9593    }
     
    364362  }
    365363}
    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 events
    383   for(entry = 0; entry < allEntries; ++entry)
    384   {
    385     // Load selected branches with data from specified event
    386     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 
    409364std::pair<Double_t, Double_t> GausFit(TH1* hist)
    410365{
     
    419374
    420375
    421 TGraphErrors EresGraph(std::vector<resolPlot> *histos, bool central, bool rms = false)
     376TGraphErrors EresGraph(std::vector<resolPlot> *histos, bool central)
    422377{
    423378    Int_t bin;
     
    434389            std::cout << " entries : " << histos->at(bin).cenResolHist->GetEntries() << std::endl;
    435390            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);
    446393            count++;
    447394        }
     
    604551  TClonesArray *branchPFJet = treeReader->UseBranch("Jet");
    605552  TClonesArray *branchCaloJet = treeReader->UseBranch("CaloJet");
    606   TClonesArray *branchScalarHT = treeReader->UseBranch("ScalarHT");
    607   TClonesArray *branchMet = treeReader->UseBranch("MissingET");
    608553
    609554#ifdef ELECTRON
     
    866811  gr_pfjets.SetName("pfJet");
    867812
    868   // CaloJets Energy Resolution
     813
     814  // PFJets Energy Resolution
    869815  std::vector<resolPlot> plots_calojets;
    870816  HistogramsCollection(&plots_calojets, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "CaloJet");
     
    873819  gr_calojets.SetName("caloJet");
    874820
    875   // MET Resolution vs HT
    876   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 
    882821  // Canvas
    883822
     
    943882  C_btag1->SaveAs(btagEff+".eps");
    944883  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 
    961884
    962885#endif
     
    1011934      plots_pfjets.at(bin).cenResolHist->Write();
    1012935      plots_calojets.at(bin).cenResolHist->Write();
    1013       plots_met.at(bin).cenResolHist->Write();
    1014936  }
    1015937  histos_btag.first->Write();
     
    1020942  C_tautag1->Write();
    1021943  C_jet->Write();
    1022   C_met->Write();
    1023944#endif
    1024945
Note: See TracChangeset for help on using the changeset viewer.