CMS 3D CMS Logo

L1ValidatorHists.cc
Go to the documentation of this file.
2 
3 //#include <DataFormats/HepMCCandidate/interface/GenParticle.h>
4 
6 
7 /*#define BOOKHISTS(TYPE) \
8 TYPE ## _N_Pt = new TH2F(#TYPE "_N_Pt", #TYPE " Number", 20, 0, 200); \
9 TYPE ## _N_Eta = new TH2F(#TYPE "_N_Eta", #TYPE " Number", 20, -4, 4); \
10 TYPE ## _Eff_Pt = new TH2F(#TYPE "_Eff_Pt", #TYPE " Number", 20, 0, 200); \
11 TYPE ## _Eff_Eta = new TH2F(#TYPE "_Eff_Eta", #TYPE " Number", 20, -4, 4); \
12 TYPE ## _dR = new TH2F(#TYPE "_dR", #TYPE " Number", 20, 0, 1); \
13 TYPE ## _dPt = new TH2F(#TYPE "_dPt", #TYPE " Number", 20, -1, 1);
14 */
16  // Name[0]="IsoEG"; // Run I legacy
17  // Name[1]="NonIsoEG";
18  // Name[2]="CenJet";
19  // Name[3]="ForJet";
20  // Name[4]="TauJet";
21  // Name[5]="Muon";
22  Name[0] = "Egamma";
23  Name[1] = "Jet";
24  Name[2] = "Tau";
25  Name[3] = "Muon";
26 }
28 
30  NEvents = 0;
31 
32  float ptbins[14] = {0, 5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 120, 160};
33  int Nptbin = 13;
34 
35  iBooker.setCurrentFolder(dirname + "/numerators_denominators");
36  for (int i = 0; i < Type::Number; i++) {
37  Eff_Pt_Denom[i] = iBooker.book1D((Name[i] + "_Eff_Pt_Denom").c_str(),
38  (Name[i] + " Efficiency vs Pt Denom; Gen p_{T} [GeV]; Entries").c_str(),
39  Nptbin,
40  ptbins);
41  Eff_Pt_Nomin[i] = iBooker.book1D((Name[i] + "_Eff_Pt_Nomin").c_str(),
42  (Name[i] + " Efficiency vs Pt Nomin; Gen p_{T} [GeV]; Entries").c_str(),
43  Nptbin,
44  ptbins);
45  Eff_Eta_Denom[i] = iBooker.book1D((Name[i] + "_Eff_Eta_Denom").c_str(),
46  (Name[i] + " Efficiency vs #eta Denom; Gen #eta; Entries").c_str(),
47  80,
48  -4,
49  4);
50  Eff_Eta_Nomin[i] = iBooker.book1D((Name[i] + "_Eff_Eta_Nomin").c_str(),
51  (Name[i] + " Efficiency vs #eta Nomin; Gen #eta; Entries").c_str(),
52  80,
53  -4,
54  4);
55  TurnOn_15_Denom[i] = iBooker.book1D((Name[i] + "_TurnOn_15_Denom").c_str(),
56  (Name[i] + " Turn On (15 GeV) Denom; Gen p_{T} [GeV]; Entries").c_str(),
57  Nptbin,
58  ptbins);
59  TurnOn_15_Nomin[i] = iBooker.book1D((Name[i] + "_TurnOn_15_Nomin").c_str(),
60  (Name[i] + " Turn On (15 GeV) Nomin; Gen p_{T} [GeV]; Entries").c_str(),
61  Nptbin,
62  ptbins);
63  TurnOn_30_Denom[i] = iBooker.book1D((Name[i] + "_TurnOn_30_Denom").c_str(),
64  (Name[i] + " Turn On (30 GeV) Denom; Gen p_{T} [GeV]; Entries").c_str(),
65  Nptbin,
66  ptbins);
67  TurnOn_30_Nomin[i] = iBooker.book1D((Name[i] + "_TurnOn_30_Nomin").c_str(),
68  (Name[i] + " Turn On (30 GeV) Nomin; Gen p_{T} [GeV]; Entries").c_str(),
69  Nptbin,
70  ptbins);
71  }
72 
73  iBooker.setCurrentFolder(dirname);
74  for (int i = 0; i < Type::Number; i++) {
75  N[i] = iBooker.book1D((Name[i] + "_N").c_str(), ("L1 " + Name[i] + " Number with BX=0").c_str(), 16, -0.5, 15.5);
76 
77  Eff_Pt[i] = iBooker.book1D((Name[i] + "_Eff_Pt").c_str(),
78  (Name[i] + " Efficiency vs Pt; Gen p_{T} [GeV]; L1T Efficiency").c_str(),
79  Nptbin,
80  ptbins);
82  Eff_Eta[i] = iBooker.book1D((Name[i] + "_Eff_Eta").c_str(),
83  (Name[i] + " Efficiency vs #eta (Gen p_{T} > 10GeV); Gen #eta; L1T Efficiency").c_str(),
84  80,
85  -4,
86  4);
88  TurnOn_15[i] = iBooker.book1D((Name[i] + "_TurnOn_15").c_str(),
89  (Name[i] + " Turn On (15 GeV); Gen p_{T} [GeV]; L1T Efficiency").c_str(),
90  Nptbin,
91  ptbins);
93  TurnOn_30[i] = iBooker.book1D((Name[i] + "_TurnOn_30").c_str(),
94  (Name[i] + " Turn On (30 GeV); Gen p_{T} [GeV]; L1T Efficiency").c_str(),
95  Nptbin,
96  ptbins);
98  dR[i] = iBooker.book1D(
99  (Name[i] + "_dR").c_str(), (Name[i] + " #DeltaR; #DeltaR(L1 object, Gen object); Entries").c_str(), 40, 0, 1);
100  dR_vs_Pt[i] = iBooker.book2D((Name[i] + "_dR_vs_Pt").c_str(),
101  (Name[i] + " #DeltaR vs p_{T}; Gen p_{T} [GeV]; "
102  "#DeltaR(L1 object, Gen object); Entries")
103  .c_str(),
104  12,
105  0,
106  120,
107  40,
108  0,
109  1);
110  dPt[i] = iBooker.book1D((Name[i] + "_dPt").c_str(),
111  (Name[i] + " #Deltap_{T}; (p_{T}^{L1}-p_{T}^{Gen})/p_{T}^{Gen}; Entries").c_str(),
112  100,
113  -2,
114  2);
115  dPt_vs_Pt[i] = iBooker.book2D((Name[i] + "_dPt_vs_Pt").c_str(),
116  (Name[i] + " #Deltap_{T} vs p_{T}; Gen p_{T} [GeV]; "
117  "(p_{T}^{L1}-p_{T}^{Gen})/p_{T}^{Gen}; Entries")
118  .c_str(),
119  12,
120  0,
121  120,
122  40,
123  -2,
124  2);
125  }
126 }
127 
129  double GenPartPt = GenPart->pt();
130  // fill the overflow in the last bin
131  if (GenPart->pt() >= 160.0)
132  GenPartPt = 159.0;
133  if (L1Part == nullptr) {
134  Eff_Pt_Denom[i]->Fill(GenPartPt);
135  if (GenPart->pt() > 10)
136  Eff_Eta_Denom[i]->Fill(GenPart->eta());
137  TurnOn_15_Denom[i]->Fill(GenPartPt);
138  TurnOn_30_Denom[i]->Fill(GenPartPt);
139  } else {
140  double idR = reco::deltaR(GenPart->eta(), GenPart->phi(), L1Part->eta(), L1Part->phi());
141  bool matched = idR < 0.15;
142  Eff_Pt_Denom[i]->Fill(GenPartPt);
143  if (GenPart->pt() > 10)
144  Eff_Eta_Denom[i]->Fill(GenPart->eta());
145  if (matched)
146  Eff_Pt_Nomin[i]->Fill(GenPartPt);
147  if (matched && GenPart->pt() > 10)
148  Eff_Eta_Nomin[i]->Fill(GenPart->eta());
149  TurnOn_15_Denom[i]->Fill(GenPartPt);
150  TurnOn_30_Denom[i]->Fill(GenPartPt);
151  if (L1Part->pt() > 15 && matched)
152  TurnOn_15_Nomin[i]->Fill(GenPartPt);
153  if (L1Part->pt() > 30 && matched)
154  TurnOn_30_Nomin[i]->Fill(GenPartPt);
155  dR[i]->Fill(idR);
156  dPt[i]->Fill((L1Part->pt() - GenPart->pt()) / GenPart->pt());
157  dR_vs_Pt[i]->Fill(GenPart->pt(), idR);
158  dPt_vs_Pt[i]->Fill(GenPart->pt(), (L1Part->pt() - GenPart->pt()) / GenPart->pt());
159  }
160 }
161 
163 
165  for (int i = 0; i < Type::Number; i++) {
166  N[i]->getTH1()->Write();
167  Eff_Pt[i]->getTH1()->Write();
168  Eff_Pt_Denom[i]->getTH1()->Write();
169  Eff_Pt_Nomin[i]->getTH1()->Write();
170  Eff_Eta[i]->getTH1()->Write();
171  Eff_Eta_Denom[i]->getTH1()->Write();
172  Eff_Eta_Nomin[i]->getTH1()->Write();
173  TurnOn_15[i]->getTH1()->Write();
174  TurnOn_15_Denom[i]->getTH1()->Write();
175  TurnOn_15_Nomin[i]->getTH1()->Write();
176  TurnOn_30[i]->getTH1()->Write();
177  TurnOn_30_Denom[i]->getTH1()->Write();
178  TurnOn_30_Nomin[i]->getTH1()->Write();
179  dR[i]->getTH1()->Write();
180  dPt[i]->getTH1()->Write();
181  dR_vs_Pt[i]->getTH2F()->Write();
182  dPt_vs_Pt[i]->getTH2F()->Write();
183  }
184 }
185 
186 /*void L1ValidatorHists::NormalizeSlices(TH2F *Hist){
187  int NBinsX = Hist->GetNbinsX();
188  int NBinsY = Hist->GetNbinsY();
189  for(int i=0; i<NBinsX+2; i++){
190  float Total = Hist->Integral(i, i, 0, -1);
191  if(Total == 0) continue;
192  for(int j=0; j<NBinsY+2; j++){
193  Hist->SetBinContent(i,j, Hist->GetBinContent(i,j)/Total);
194  }
195  }
196 }
197 */
void Fill(int, const reco::LeafCandidate *, const reco::LeafCandidate *)
MonitorElement * dR_vs_Pt[Type::Number]
double pt() const final
transverse momentum
MonitorElement * Eff_Eta[Type::Number]
MonitorElement * N[Type::Number]
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
MonitorElement * TurnOn_15[Type::Number]
MonitorElement * Eff_Pt_Denom[Type::Number]
MonitorElement * TurnOn_15_Denom[Type::Number]
MonitorElement * Eff_Eta_Nomin[Type::Number]
void FillNumber(int, int)
void Fill(long long x)
MonitorElement * TurnOn_15_Nomin[Type::Number]
virtual TH2F * getTH2F() const
void Book(DQMStore::IBooker &, std::string dirname)
MonitorElement * TurnOn_30_Denom[Type::Number]
MonitorElement * dPt[Type::Number]
MonitorElement * TurnOn_30[Type::Number]
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
MonitorElement * dR[Type::Number]
MonitorElement * TurnOn_30_Nomin[Type::Number]
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
MonitorElement * dPt_vs_Pt[Type::Number]
virtual TH1 * getTH1() const
MonitorElement * Eff_Pt_Nomin[Type::Number]
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
double phi() const final
momentum azimuthal angle
MonitorElement * Eff_Eta_Denom[Type::Number]
std::string Name[4]
MonitorElement * Eff_Pt[Type::Number]
double eta() const final
momentum pseudorapidity