Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:11

0001 #include "Validation/L1T/interface/L1ValidatorHists.h"
0002 
0003 //#include <DataFormats/HepMCCandidate/interface/GenParticle.h>
0004 
0005 #include "DataFormats/Math/interface/deltaR.h"
0006 
0007 /*#define BOOKHISTS(TYPE) \
0008 TYPE ## _N_Pt = new TH2F(#TYPE "_N_Pt", #TYPE " Number", 20, 0, 200); \
0009 TYPE ## _N_Eta = new TH2F(#TYPE "_N_Eta", #TYPE " Number", 20, -4, 4); \
0010 TYPE ## _Eff_Pt = new TH2F(#TYPE "_Eff_Pt", #TYPE " Number", 20, 0, 200); \
0011 TYPE ## _Eff_Eta = new TH2F(#TYPE "_Eff_Eta", #TYPE " Number", 20, -4, 4); \
0012 TYPE ## _dR = new TH2F(#TYPE "_dR", #TYPE " Number", 20, 0, 1); \
0013 TYPE ## _dPt = new TH2F(#TYPE "_dPt", #TYPE " Number", 20, -1, 1);
0014 */
0015 L1ValidatorHists::L1ValidatorHists() {
0016   //  Name[0]="IsoEG"; // Run I legacy
0017   //  Name[1]="NonIsoEG";
0018   //  Name[2]="CenJet";
0019   //  Name[3]="ForJet";
0020   //  Name[4]="TauJet";
0021   //  Name[5]="Muon";
0022   Name[0] = "Egamma";
0023   Name[1] = "Jet";
0024   Name[2] = "Tau";
0025   Name[3] = "Muon";
0026 }
0027 L1ValidatorHists::~L1ValidatorHists() {}
0028 
0029 void L1ValidatorHists::Book(DQMStore::IBooker &iBooker, std::string dirname) {
0030   NEvents = 0;
0031 
0032   float ptbins[14] = {0, 5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 120, 160};
0033   int Nptbin = 13;
0034 
0035   iBooker.setCurrentFolder(dirname + "/numerators_denominators");
0036   for (int i = 0; i < Type::Number; i++) {
0037     Eff_Pt_Denom[i] = iBooker.book1D((Name[i] + "_Eff_Pt_Denom").c_str(),
0038                                      (Name[i] + " Efficiency vs Pt Denom; Gen p_{T} [GeV]; Entries").c_str(),
0039                                      Nptbin,
0040                                      ptbins);
0041     Eff_Pt_Nomin[i] = iBooker.book1D((Name[i] + "_Eff_Pt_Nomin").c_str(),
0042                                      (Name[i] + " Efficiency vs Pt Nomin; Gen p_{T} [GeV]; Entries").c_str(),
0043                                      Nptbin,
0044                                      ptbins);
0045     Eff_Eta_Denom[i] = iBooker.book1D((Name[i] + "_Eff_Eta_Denom").c_str(),
0046                                       (Name[i] + " Efficiency vs #eta Denom; Gen #eta; Entries").c_str(),
0047                                       80,
0048                                       -4,
0049                                       4);
0050     Eff_Eta_Nomin[i] = iBooker.book1D((Name[i] + "_Eff_Eta_Nomin").c_str(),
0051                                       (Name[i] + " Efficiency vs #eta Nomin; Gen #eta; Entries").c_str(),
0052                                       80,
0053                                       -4,
0054                                       4);
0055     TurnOn_15_Denom[i] = iBooker.book1D((Name[i] + "_TurnOn_15_Denom").c_str(),
0056                                         (Name[i] + " Turn On (15 GeV) Denom; Gen p_{T} [GeV]; Entries").c_str(),
0057                                         Nptbin,
0058                                         ptbins);
0059     TurnOn_15_Nomin[i] = iBooker.book1D((Name[i] + "_TurnOn_15_Nomin").c_str(),
0060                                         (Name[i] + " Turn On (15 GeV) Nomin; Gen p_{T} [GeV]; Entries").c_str(),
0061                                         Nptbin,
0062                                         ptbins);
0063     TurnOn_30_Denom[i] = iBooker.book1D((Name[i] + "_TurnOn_30_Denom").c_str(),
0064                                         (Name[i] + " Turn On (30 GeV) Denom; Gen p_{T} [GeV]; Entries").c_str(),
0065                                         Nptbin,
0066                                         ptbins);
0067     TurnOn_30_Nomin[i] = iBooker.book1D((Name[i] + "_TurnOn_30_Nomin").c_str(),
0068                                         (Name[i] + " Turn On (30 GeV) Nomin; Gen p_{T} [GeV]; Entries").c_str(),
0069                                         Nptbin,
0070                                         ptbins);
0071   }
0072 
0073   iBooker.setCurrentFolder(dirname);
0074   for (int i = 0; i < Type::Number; i++) {
0075     N[i] = iBooker.book1D((Name[i] + "_N").c_str(), ("L1 " + Name[i] + " Number with BX=0").c_str(), 16, -0.5, 15.5);
0076 
0077     Eff_Pt[i] = iBooker.book1D((Name[i] + "_Eff_Pt").c_str(),
0078                                (Name[i] + " Efficiency vs Pt; Gen p_{T} [GeV]; L1T Efficiency").c_str(),
0079                                Nptbin,
0080                                ptbins);
0081     Eff_Pt[i]->setEfficiencyFlag();
0082     Eff_Eta[i] = iBooker.book1D((Name[i] + "_Eff_Eta").c_str(),
0083                                 (Name[i] + " Efficiency vs #eta (Gen p_{T} > 10GeV); Gen #eta; L1T Efficiency").c_str(),
0084                                 80,
0085                                 -4,
0086                                 4);
0087     Eff_Eta[i]->setEfficiencyFlag();
0088     TurnOn_15[i] = iBooker.book1D((Name[i] + "_TurnOn_15").c_str(),
0089                                   (Name[i] + " Turn On (15 GeV); Gen p_{T} [GeV]; L1T Efficiency").c_str(),
0090                                   Nptbin,
0091                                   ptbins);
0092     TurnOn_15[i]->setEfficiencyFlag();
0093     TurnOn_30[i] = iBooker.book1D((Name[i] + "_TurnOn_30").c_str(),
0094                                   (Name[i] + " Turn On (30 GeV); Gen p_{T} [GeV]; L1T Efficiency").c_str(),
0095                                   Nptbin,
0096                                   ptbins);
0097     TurnOn_30[i]->setEfficiencyFlag();
0098     dR[i] = iBooker.book1D(
0099         (Name[i] + "_dR").c_str(), (Name[i] + " #DeltaR; #DeltaR(L1 object, Gen object); Entries").c_str(), 40, 0, 1);
0100     dR_vs_Pt[i] = iBooker.book2D((Name[i] + "_dR_vs_Pt").c_str(),
0101                                  (Name[i] + " #DeltaR vs p_{T}; Gen p_{T} [GeV]; "
0102                                             "#DeltaR(L1 object, Gen object); Entries")
0103                                      .c_str(),
0104                                  12,
0105                                  0,
0106                                  120,
0107                                  40,
0108                                  0,
0109                                  1);
0110     dPt[i] = iBooker.book1D((Name[i] + "_dPt").c_str(),
0111                             (Name[i] + " #Deltap_{T}; (p_{T}^{L1}-p_{T}^{Gen})/p_{T}^{Gen}; Entries").c_str(),
0112                             100,
0113                             -2,
0114                             2);
0115     dPt_vs_Pt[i] = iBooker.book2D((Name[i] + "_dPt_vs_Pt").c_str(),
0116                                   (Name[i] + " #Deltap_{T} vs p_{T}; Gen p_{T} [GeV]; "
0117                                              "(p_{T}^{L1}-p_{T}^{Gen})/p_{T}^{Gen}; Entries")
0118                                       .c_str(),
0119                                   12,
0120                                   0,
0121                                   120,
0122                                   40,
0123                                   -2,
0124                                   2);
0125   }
0126 }
0127 
0128 void L1ValidatorHists::Fill(int i, const reco::LeafCandidate *GenPart, const reco::LeafCandidate *L1Part) {
0129   double GenPartPt = GenPart->pt();
0130   // fill the overflow in the last bin
0131   if (GenPart->pt() >= 160.0)
0132     GenPartPt = 159.0;
0133   if (L1Part == nullptr) {
0134     Eff_Pt_Denom[i]->Fill(GenPartPt);
0135     if (GenPart->pt() > 10)
0136       Eff_Eta_Denom[i]->Fill(GenPart->eta());
0137     TurnOn_15_Denom[i]->Fill(GenPartPt);
0138     TurnOn_30_Denom[i]->Fill(GenPartPt);
0139   } else {
0140     double idR = reco::deltaR(GenPart->eta(), GenPart->phi(), L1Part->eta(), L1Part->phi());
0141     bool matched = idR < 0.15;
0142     Eff_Pt_Denom[i]->Fill(GenPartPt);
0143     if (GenPart->pt() > 10)
0144       Eff_Eta_Denom[i]->Fill(GenPart->eta());
0145     if (matched)
0146       Eff_Pt_Nomin[i]->Fill(GenPartPt);
0147     if (matched && GenPart->pt() > 10)
0148       Eff_Eta_Nomin[i]->Fill(GenPart->eta());
0149     TurnOn_15_Denom[i]->Fill(GenPartPt);
0150     TurnOn_30_Denom[i]->Fill(GenPartPt);
0151     if (L1Part->pt() > 15 && matched)
0152       TurnOn_15_Nomin[i]->Fill(GenPartPt);
0153     if (L1Part->pt() > 30 && matched)
0154       TurnOn_30_Nomin[i]->Fill(GenPartPt);
0155     dR[i]->Fill(idR);
0156     dPt[i]->Fill((L1Part->pt() - GenPart->pt()) / GenPart->pt());
0157     dR_vs_Pt[i]->Fill(GenPart->pt(), idR);
0158     dPt_vs_Pt[i]->Fill(GenPart->pt(), (L1Part->pt() - GenPart->pt()) / GenPart->pt());
0159   }
0160 }
0161 
0162 void L1ValidatorHists::FillNumber(int i, int Number) { N[i]->Fill(Number); }
0163 
0164 void L1ValidatorHists::Write() {
0165   for (int i = 0; i < Type::Number; i++) {
0166     N[i]->getTH1()->Write();
0167     Eff_Pt[i]->getTH1()->Write();
0168     Eff_Pt_Denom[i]->getTH1()->Write();
0169     Eff_Pt_Nomin[i]->getTH1()->Write();
0170     Eff_Eta[i]->getTH1()->Write();
0171     Eff_Eta_Denom[i]->getTH1()->Write();
0172     Eff_Eta_Nomin[i]->getTH1()->Write();
0173     TurnOn_15[i]->getTH1()->Write();
0174     TurnOn_15_Denom[i]->getTH1()->Write();
0175     TurnOn_15_Nomin[i]->getTH1()->Write();
0176     TurnOn_30[i]->getTH1()->Write();
0177     TurnOn_30_Denom[i]->getTH1()->Write();
0178     TurnOn_30_Nomin[i]->getTH1()->Write();
0179     dR[i]->getTH1()->Write();
0180     dPt[i]->getTH1()->Write();
0181     dR_vs_Pt[i]->getTH2F()->Write();
0182     dPt_vs_Pt[i]->getTH2F()->Write();
0183   }
0184 }
0185 
0186 /*void L1ValidatorHists::NormalizeSlices(TH2F *Hist){
0187   int NBinsX = Hist->GetNbinsX();
0188   int NBinsY = Hist->GetNbinsY();
0189   for(int i=0; i<NBinsX+2; i++){
0190     float Total = Hist->Integral(i, i, 0, -1);
0191     if(Total == 0) continue;
0192     for(int j=0; j<NBinsY+2; j++){
0193       Hist->SetBinContent(i,j, Hist->GetBinContent(i,j)/Total);
0194     }
0195   }
0196 }
0197 */