CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MatchCandidateBenchmark.cc
Go to the documentation of this file.
2 
3 
5 
6 
7 #include <TROOT.h>
8 #include <TFile.h>
9 #include <TH1.h>
10 #include <TH2.h>
11 #include <TProfile.h>
12 
13 
14 using namespace std;
15 
16 
18 
20  delta_et_VS_et_ = 0;
21  delta_eta_VS_et_ = 0;
22  delta_phi_VS_et_ = 0;
23 
26  // pTRes are initialzied in the setup since ptBinsPS.size() is needed
27 
28  histogramBooked_ = false;
29 }
30 
31 
33 
34 
36  if (!histogramBooked_) {
37  PhaseSpace ptPS;
38  PhaseSpace dptOvptPS;
39  PhaseSpace dptPS;
40  PhaseSpace detaPS;
41  PhaseSpace dphiPS;
42  switch(mode_) {
43  case VALIDATION:
44  ptPS = PhaseSpace(100,0,1000);
45  dptOvptPS = PhaseSpace( 200, -1, 1);
46  dphiPS = PhaseSpace( 200, -1, 1);
47  detaPS = PhaseSpace( 200, -1, 1);
48  dptPS = PhaseSpace( 100, -100, 100);
49  break;
50  case DQMOFFLINE:
51  default:
52  ptPS = PhaseSpace(50,0,100);
53  dptOvptPS = PhaseSpace( 50, -1, 1);
54  dphiPS = PhaseSpace( 50, -1, 1);
55  detaPS = PhaseSpace( 50, -1, 1);
56  dptPS = PhaseSpace( 50, -50, 50);
57  break;
58  }
59  float ptBins[11] = {0, 1, 2, 5, 10, 20, 50, 100, 200, 400, 1000};
60  int size = sizeof(ptBins)/sizeof(*ptBins);
61 
62  delta_et_Over_et_VS_et_ = book2D(b, "delta_et_Over_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
63  size, ptBins,
64  dptOvptPS.n, dptOvptPS.m, dptOvptPS.M );
65 
66  BRdelta_et_Over_et_VS_et_ = book2D(b, "BRdelta_et_Over_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
67  size, ptBins,
68  dptOvptPS.n, dptOvptPS.m, dptOvptPS.M );
69  ERdelta_et_Over_et_VS_et_ = book2D(b, "ERdelta_et_Over_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
70  size, ptBins,
71  dptOvptPS.n, dptOvptPS.m, dptOvptPS.M );
72 
73  delta_et_VS_et_ = book2D(b, "delta_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}",
74  size, ptBins,
75  dptPS.n, dptPS.m, dptPS.M );
76 
77  delta_eta_VS_et_ = book2D(b, "delta_eta_VS_et_", ";#E_{T, true} (GeV);#Delta#eta",
78  size, ptBins,
79  detaPS.n, detaPS.m, detaPS.M );
80 
81  delta_phi_VS_et_ = book2D(b, "delta_phi_VS_et_", ";E_{T, true} (GeV);#Delta#phi",
82  size, ptBins,
83  dphiPS.n, dphiPS.m, dphiPS.M );
84  /*
85  // TProfile
86  profile_delta_et_Over_et_VS_et_ = bookProfile("profile_delta_et_Over_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
87  size, ptBins,
88  dptOvptPS.m, dptOvptPS.M, "" );
89 
90  profile_delta_et_VS_et_ = bookProfile("profile_delta_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}",
91  size, ptBins,
92  dptPS.m, dptPS.M, "" );
93 
94  profile_delta_eta_VS_et_ = bookProfile("profile_delta_eta_VS_et_", ";#E_{T, true} (GeV);#Delta#eta",
95  size, ptBins,
96  detaPS.m, detaPS.M, "" );
97 
98  profile_delta_phi_VS_et_ = bookProfile("profile_delta_phi_VS_et_", ";E_{T, true} (GeV);#Delta#phi",
99  size, ptBins,
100  dphiPS.m, dphiPS.M, "" );
101  // TProfile RMS
102  profileRMS_delta_et_Over_et_VS_et_ = bookProfile("profileRMS_delta_et_Over_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
103  size, ptBins,
104  dptOvptPS.m, dptOvptPS.M, "s" );
105 
106  profileRMS_delta_et_VS_et_ = bookProfile("profileRMS_delta_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}",
107  size, ptBins,
108  dptPS.m, dptPS.M, "s" );
109 
110  profileRMS_delta_eta_VS_et_ = bookProfile("profileRMS_delta_eta_VS_et_", ";#E_{T, true} (GeV);#Delta#eta",
111  size, ptBins,
112  detaPS.m, detaPS.M, "s" );
113 
114  profileRMS_delta_phi_VS_et_ = bookProfile("profileRMS_delta_phi_VS_et_", ";E_{T, true} (GeV);#Delta#phi",
115  size, ptBins,
116  dphiPS.m, dphiPS.M, "s" );
117  */
118  pTRes_.resize(size); BRpTRes_.resize(size); ERpTRes_.resize(size);
119  for (size_t i = 0; i < pTRes_.size(); i++) {
120  pTRes_[i] = 0; BRpTRes_[i] = 0; ERpTRes_[i] = 0; }
121 
122  histogramBooked_ = true;
123  }
124 }
125 
126 
128 
129  std::vector<double> ptBinsPS = parameterSet.getParameter< std::vector<double> >( "VariablePtBins" );
130  pTRes_.resize(ptBinsPS.size()-1); BRpTRes_.resize(ptBinsPS.size()-1); ERpTRes_.resize(ptBinsPS.size()-1);
131  if (pTRes_.size() > 0)
132  for (size_t i = 0; i < pTRes_.size(); i++) {
133  pTRes_[i] = 0; BRpTRes_[i] = 0; ERpTRes_[i] = 0; }
134 
135  if (!histogramBooked_) {
136 
137  edm::ParameterSet ptPS = parameterSet.getParameter<edm::ParameterSet>("PtHistoParameter");
138  edm::ParameterSet dptPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPtHistoParameter");
139  edm::ParameterSet dptOvptPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPtOvPtHistoParameter");
140  edm::ParameterSet detaPS = parameterSet.getParameter<edm::ParameterSet>("DeltaEtaHistoParameter");
141  edm::ParameterSet dphiPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPhiHistoParameter");
142 
143  std::vector<float> ptBins;
144  if (ptBinsPS.size() > 1) {
145  ptBins.reserve(ptBinsPS.size());
146  for (size_t i = 0; i < ptBinsPS.size(); i++)
147  ptBins.push_back(ptBinsPS[i]);
148  } else {
149  Int_t nFixedBins = ptPS.getParameter<int32_t>("nBin");
150  ptBins.reserve(nFixedBins+1);
151  for (Int_t i = 0; i <= nFixedBins; i++)
152  ptBins.push_back(ptPS.getParameter<double>("xMin") + i*((ptPS.getParameter<double>("xMax") - ptPS.getParameter<double>("xMin")) / nFixedBins)) ;
153  ptBinsPS.resize(nFixedBins);
154  }
155 
156  if (dptOvptPS.getParameter<bool>("switchOn")) {
157  delta_et_Over_et_VS_et_ = book2D(b, "delta_et_Over_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
158  ptBinsPS.size()-1, &(ptBins.front()),
159  dptOvptPS.getParameter<int32_t>("nBin"),
160  dptOvptPS.getParameter<double>("xMin"),
161  dptOvptPS.getParameter<double>("xMax"));
162  }
163  if (dptOvptPS.getParameter<bool>("slicingOn")) {
164  for (size_t i = 0; i < pTRes_.size(); i++) {
165  pTRes_[i] = book1D( b, TString::Format("Pt%d_%d", (int)ptBins[i], (int)ptBins[i+1]), ";#Deltap_{T}/p_{T};Entries",
166  dptOvptPS.getParameter<int32_t>("nBin"),
167  dptOvptPS.getParameter<double>("xMin"),
168  dptOvptPS.getParameter<double>("xMax"));
169  BRpTRes_[i] = book1D( b, TString::Format("BRPt%d_%d", (int)ptBins[i], (int)ptBins[i+1]), ";#Deltap_{T}/p_{T};Entries",
170  dptOvptPS.getParameter<int32_t>("nBin"),
171  dptOvptPS.getParameter<double>("xMin"),
172  dptOvptPS.getParameter<double>("xMax"));
173  ERpTRes_[i] = book1D( b, TString::Format("ERPt%d_%d", (int)ptBins[i], (int)ptBins[i+1]), ";#Deltap_{T}/p_{T};Entries",
174  dptOvptPS.getParameter<int32_t>("nBin"),
175  dptOvptPS.getParameter<double>("xMin"),
176  dptOvptPS.getParameter<double>("xMax"));
177  }
178  }
179  if (dptOvptPS.getParameter<bool>("BROn")) {
180  BRdelta_et_Over_et_VS_et_ = book2D(b, "BRdelta_et_Over_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
181  ptBinsPS.size()-1, &(ptBins.front()),
182  dptOvptPS.getParameter<int32_t>("nBin"),
183  dptOvptPS.getParameter<double>("xMin"),
184  dptOvptPS.getParameter<double>("xMax"));
185  }
186  if (dptOvptPS.getParameter<bool>("EROn")) {
187  ERdelta_et_Over_et_VS_et_ = book2D(b, "ERdelta_et_Over_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
188  ptBinsPS.size()-1, &(ptBins.front()),
189  dptOvptPS.getParameter<int32_t>("nBin"),
190  dptOvptPS.getParameter<double>("xMin"),
191  dptOvptPS.getParameter<double>("xMax"));
192  }
193 
194  if (dptPS.getParameter<bool>("switchOn")) {
195  delta_et_VS_et_ = book2D(b, "delta_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}",
196  ptBinsPS.size()-1, &(ptBins.front()),
197  dptPS.getParameter<int32_t>("nBin"),
198  dptPS.getParameter<double>("xMin"),
199  dptPS.getParameter<double>("xMax"));
200  }
201 
202  if (detaPS.getParameter<bool>("switchOn")) {
203  delta_eta_VS_et_ = book2D(b, "delta_eta_VS_et_", ";E_{T, true} (GeV);#Delta#eta",
204  ptBinsPS.size()-1, &(ptBins.front()),
205  detaPS.getParameter<int32_t>("nBin"),
206  detaPS.getParameter<double>("xMin"),
207  detaPS.getParameter<double>("xMax"));
208  }
209 
210  if (dphiPS.getParameter<bool>("switchOn")) {
211  delta_phi_VS_et_ = book2D(b, "delta_phi_VS_et_", ";E_{T, true} (GeV);#Delta#phi",
212  ptBinsPS.size()-1, &(ptBins.front()),
213  dphiPS.getParameter<int32_t>("nBin"),
214  dphiPS.getParameter<double>("xMin"),
215  dphiPS.getParameter<double>("xMax"));
216  }
217  /*
218  // TProfile
219  if (dptOvptPS.getParameter<bool>("switchOn")) {
220  profile_delta_et_Over_et_VS_et_ = bookProfile("profile_delta_et_Over_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
221  ptBinsPS.size()-1, &(ptBins.front()),
222  dptOvptPS.getParameter<double>("xMin"),
223  dptOvptPS.getParameter<double>("xMax"), "" );
224  profileRMS_delta_et_Over_et_VS_et_ = bookProfile("profileRMS_delta_et_Over_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
225  ptBinsPS.size()-1, &(ptBins.front()),
226  dptOvptPS.getParameter<double>("xMin"),
227  dptOvptPS.getParameter<double>("xMax"), "s" );
228  }
229 
230  if (dptPS.getParameter<bool>("switchOn")) {
231  profile_delta_et_VS_et_ = bookProfile("profile_delta_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}",
232  ptBinsPS.size()-1, &(ptBins.front()),
233  dptPS.getParameter<double>("xMin"),
234  dptPS.getParameter<double>("xMax"), "" );
235  profileRMS_delta_et_VS_et_ = bookProfile("profileRMS_delta_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}",
236  ptBinsPS.size()-1, &(ptBins.front()),
237  dptPS.getParameter<double>("xMin"),
238  dptPS.getParameter<double>("xMax"), "s" );
239  }
240 
241  if (detaPS.getParameter<bool>("switchOn")) {
242  profile_delta_eta_VS_et_ = bookProfile("profile_delta_eta_VS_et_", ";E_{T, true} (GeV);#Delta#eta",
243  ptBinsPS.size()-1, &(ptBins.front()),
244  detaPS.getParameter<double>("xMin"),
245  detaPS.getParameter<double>("xMax"), "" );
246  profileRMS_delta_eta_VS_et_ = bookProfile("profileRMS_delta_eta_VS_et_", ";E_{T, true} (GeV);#Delta#eta",
247  ptBinsPS.size()-1, &(ptBins.front()),
248  detaPS.getParameter<double>("xMin"),
249  detaPS.getParameter<double>("xMax"), "s" );
250  }
251 
252  if (dphiPS.getParameter<bool>("switchOn")) {
253  profile_delta_phi_VS_et_ = bookProfile("profile_delta_phi_VS_et_", ";E_{T, true} (GeV);#Delta#phi",
254  ptBinsPS.size()-1, &(ptBins.front()),
255  dphiPS.getParameter<double>("xMin"),
256  dphiPS.getParameter<double>("xMax"), "" );
257  profileRMS_delta_phi_VS_et_ = bookProfile("profileRMS_delta_phi_VS_et_", ";E_{T, true} (GeV);#Delta#phi",
258  ptBinsPS.size()-1, &(ptBins.front()),
259  dphiPS.getParameter<double>("xMin"),
260  dphiPS.getParameter<double>("xMax"), "s" );
261  }
262  */
263 
264  histogramBooked_ = true;
265  }
266 }
267 
269  const reco::Candidate& matchedCand) {
270 
271  if( !isInRange(cand.pt(), cand.eta(), cand.phi() ) ) return;
272 
273  if (histogramBooked_) {
274  if (delta_et_Over_et_VS_et_) delta_et_Over_et_VS_et_->Fill( matchedCand.pt(), (cand.pt() - matchedCand.pt())/matchedCand.pt() );
275  if ( fabs(cand.eta()) <= 1.4 )
276  if (BRdelta_et_Over_et_VS_et_) BRdelta_et_Over_et_VS_et_->Fill( matchedCand.pt(), (cand.pt() - matchedCand.pt())/matchedCand.pt() );
277  if ( fabs(cand.eta()) >= 1.6 && fabs(cand.eta()) <= 2.4 )
278  if (ERdelta_et_Over_et_VS_et_) ERdelta_et_Over_et_VS_et_->Fill( matchedCand.pt(), (cand.pt() - matchedCand.pt())/matchedCand.pt() );
279  if (delta_et_VS_et_) delta_et_VS_et_->Fill( matchedCand.pt(), cand.pt() - matchedCand.pt() );
280  if (delta_eta_VS_et_) delta_eta_VS_et_->Fill( matchedCand.pt(), cand.eta() - matchedCand.eta() );
281  if (delta_phi_VS_et_) delta_phi_VS_et_->Fill( matchedCand.pt(), cand.phi() - matchedCand.phi() );
282  /*
283  // TProfile
284  if (profile_delta_et_Over_et_VS_et_) {
285  profile_delta_et_Over_et_VS_et_->Fill( matchedCand.pt(), (cand.pt() - matchedCand.pt())/matchedCand.pt() );
286  profileRMS_delta_et_Over_et_VS_et_->Fill( matchedCand.pt(), (cand.pt() - matchedCand.pt())/matchedCand.pt() ); }
287  if (profile_delta_et_VS_et_) {
288  profile_delta_et_VS_et_->Fill( matchedCand.pt(), cand.pt() - matchedCand.pt() );
289  profileRMS_delta_et_VS_et_->Fill( matchedCand.pt(), cand.pt() - matchedCand.pt() ); }
290  if (profile_delta_eta_VS_et_) {
291  profile_delta_eta_VS_et_->Fill( matchedCand.pt(), cand.eta() - matchedCand.eta() );
292  profileRMS_delta_eta_VS_et_->Fill( matchedCand.pt(), cand.eta() - matchedCand.eta() ); }
293  if (profile_delta_phi_VS_et_) {
294  profile_delta_phi_VS_et_->Fill( matchedCand.pt(), cand.phi() - matchedCand.phi() );
295  profileRMS_delta_phi_VS_et_->Fill( matchedCand.pt(), cand.phi() - matchedCand.phi() ); }
296  */
297  }
298 }
299 
301  const reco::Candidate& matchedCand,
303  if( !isInRange(cand.pt(), cand.eta(), cand.phi() ) ) return;
304 
305  if (histogramBooked_) {
306 
307  std::vector<double> ptBinsPS = parameterSet.getParameter< std::vector<double> >( "VariablePtBins" );
308  edm::ParameterSet ptPS = parameterSet.getParameter<edm::ParameterSet>("PtHistoParameter");
309  std::vector<float> ptBins;
310  if (ptBinsPS.size() > 1) {
311  ptBins.reserve(ptBinsPS.size());
312  for (size_t i = 0; i < ptBinsPS.size(); i++) {
313  ptBins.push_back(ptBinsPS[i]);
314  }
315  } else {
316  Int_t nFixedBins = ptPS.getParameter<int32_t>("nBin");
317  ptBins.reserve(nFixedBins + 1);
318  for (Int_t i = 0; i <= nFixedBins; i++) {
319  ptBins.push_back( ptPS.getParameter<double>("xMin") + i*((ptPS.getParameter<double>("xMax") - ptPS.getParameter<double>("xMin")) / nFixedBins) );
320  }
321  ptBinsPS.resize(nFixedBins);
322  }
323 
324  edm::ParameterSet dptOvptPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPtOvPtHistoParameter");
325  if (matchedCand.pt() > ptBins.at(0)) { // underflow problem
326  if (delta_et_Over_et_VS_et_) delta_et_Over_et_VS_et_->Fill( matchedCand.pt(), (cand.pt() - matchedCand.pt()) / matchedCand.pt() );
327  if ( fabs(cand.eta()) >= dptOvptPS.getParameter<double>("BREtaMin") && fabs(cand.eta()) <= dptOvptPS.getParameter<double>("BREtaMax"))
328  if (BRdelta_et_Over_et_VS_et_) BRdelta_et_Over_et_VS_et_->Fill( matchedCand.pt(), (cand.pt() - matchedCand.pt())/matchedCand.pt() );
329  if ( fabs(cand.eta()) >= dptOvptPS.getParameter<double>("EREtaMin") && fabs(cand.eta()) <= dptOvptPS.getParameter<double>("EREtaMax"))
330  if (ERdelta_et_Over_et_VS_et_) ERdelta_et_Over_et_VS_et_->Fill( matchedCand.pt(), (cand.pt() - matchedCand.pt())/matchedCand.pt() );
331  if (delta_et_VS_et_) delta_et_VS_et_->Fill( matchedCand.pt(), cand.pt() - matchedCand.pt() );
332  if (delta_eta_VS_et_) delta_eta_VS_et_->Fill( matchedCand.pt(), cand.eta() - matchedCand.eta() );
333  if (delta_phi_VS_et_) delta_phi_VS_et_->Fill( matchedCand.pt(), cand.phi() - matchedCand.phi() );
334  }
335  /*
336  // TProfile
337  if (profile_delta_et_Over_et_VS_et_) {
338  profile_delta_et_Over_et_VS_et_->Fill( matchedCand.pt(), (cand.pt() - matchedCand.pt())/matchedCand.pt() );
339  profileRMS_delta_et_Over_et_VS_et_->Fill( matchedCand.pt(), (cand.pt() - matchedCand.pt())/matchedCand.pt() ); }
340  if (profile_delta_et_VS_et_) {
341  profile_delta_et_VS_et_->Fill( matchedCand.pt(), cand.pt() - matchedCand.pt() );
342  profileRMS_delta_et_VS_et_->Fill( matchedCand.pt(), cand.pt() - matchedCand.pt() ); }
343  if (profile_delta_eta_VS_et_) {
344  profile_delta_eta_VS_et_->Fill( matchedCand.pt(), cand.eta() - matchedCand.eta() );
345  profileRMS_delta_eta_VS_et_->Fill( matchedCand.pt(), cand.eta() - matchedCand.eta() ); }
346  if (profile_delta_phi_VS_et_) {
347  profile_delta_phi_VS_et_->Fill( matchedCand.pt(), cand.phi() - matchedCand.phi() );
348  profileRMS_delta_phi_VS_et_->Fill( matchedCand.pt(), cand.phi() - matchedCand.phi() ); }
349  */
350 
351  for (size_t i = 0; i < pTRes_.size(); i++) {
352  if (matchedCand.pt() >= ptBins.at(i) && matchedCand.pt() < ptBins.at(i+1)) {
353  if (pTRes_[i]) pTRes_[i]->Fill( (cand.pt() - matchedCand.pt()) / matchedCand.pt() ) ;
354  if ( fabs(cand.eta()) >= dptOvptPS.getParameter<double>("BREtaMin") && fabs(cand.eta()) <= dptOvptPS.getParameter<double>("BREtaMax"))
355  if (BRpTRes_[i]) BRpTRes_[i]->Fill( (cand.pt() - matchedCand.pt()) / matchedCand.pt() ) ; // Fill Barrel
356  if ( fabs(cand.eta()) >= dptOvptPS.getParameter<double>("EREtaMin") && fabs(cand.eta()) <= dptOvptPS.getParameter<double>("EREtaMax"))
357  if (ERpTRes_[i]) ERpTRes_[i]->Fill( (cand.pt() - matchedCand.pt()) / matchedCand.pt() ) ; // Fill Endcap
358  }
359  }
360  }
361 }
362 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
TH1F * book1D(DQMStore::IBooker &b, const char *histname, const char *title, int nbins, float xmin, float xmax)
book a 1D histogram, either with DQM or plain root depending if DQM_ has been initialized in a child ...
Definition: Benchmark.cc:23
void fillOne(const reco::Candidate &candidate, const reco::Candidate &matchedCandidate)
fill histograms with a given particle
virtual double pt() const =0
transverse momentum
abstract base class
Definition: Benchmark.h:22
void setup(DQMStore::IBooker &b)
book histograms
std::vector< TH1F * > pTRes_
std::vector< TH1F * > BRpTRes_
TH2F * book2D(DQMStore::IBooker &b, const char *histname, const char *title, int nbinsx, float xmin, float xmax, int nbinsy, float ymin, float ymax)
book a 2D histogram, either with DQM or plain root depending if DQM_ has been initialized in a child ...
Definition: Benchmark.cc:32
double b
Definition: hdecay.h:120
std::vector< TH1F * > ERpTRes_
Mode mode_
Definition: Benchmark.h:105
bool isInRange(float pt, float eta, float phi) const
Definition: Benchmark.h:58
tuple size
Write out results.
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity