CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MBUEandQCDValidation.cc
Go to the documentation of this file.
1 /*Class MBUEandQCDValidation
2  *
3  * Class to fill dqm monitor elements from existing EDM file
4  *
5  */
6 
7 #include "MBUEandQCDValidation.h"
9 
10 #include "CLHEP/Units/defs.h"
11 #include "CLHEP/Units/PhysicalConstants.h"
12 #include "CLHEP/Units/SystemOfUnits.h"
13 
14 #include "fastjet/JetDefinition.hh"
15 #include "fastjet/ClusterSequence.hh"
17 using namespace edm;
18 
20  wmanager_(iPSet,consumesCollector()),
21  hepmcCollection_(iPSet.getParameter<edm::InputTag>("hepmcCollection")),
22  genchjetCollection_(iPSet.getParameter<edm::InputTag>("genChjetsCollection")),
23  genjetCollection_(iPSet.getParameter<edm::InputTag>("genjetsCollection")),
24  verbosity_(iPSet.getUntrackedParameter<unsigned int>("verbosity",0))
25 {
26 
27  hepmcGPCollection.reserve(initSize);
28  hepmcCharge.reserve(initSize);
29 
31 
33 
34  hepmcCollectionToken_=consumes<HepMCProduct>(hepmcCollection_);
35  genjetCollectionToken_=consumes<reco::GenJetCollection>(genjetCollection_);
36  genchjetCollectionToken_=consumes<reco::GenJetCollection>(genchjetCollection_);
37 
38 }
39 
41 
42  delete theCalo;
43 
44 }
45 
47  c.getData( fPDGTable );
48 }
49 
50 
53  DQMHelper dqm(&i); i.setCurrentFolder("Generator/MBUEandQCD");
54 
56 
57  // Number of analyzed events
58  nEvt = dqm.book1dHisto("nEvt", "n analyzed Events", 1, 0., 1.);
59 
60  // Number of events with no forward trigger
61  nNoFwdTrig = dqm.book1dHisto("nNoFwdTrig", "n Events no forward trigger", 1, 0., 1.);
62 
63  // Number of events with a single arm forward trigger
64  nSaFwdTrig = dqm.book1dHisto("nSaFwdTrig", "n Events single arm forward trigger", 1, 0., 1.);
65 
66  // Number of events with b quark
67  nbquark = dqm.book1dHisto("nbquark", "n Events with b quark", 1, 0., 1.);
68 
69  // Number of events with c and b quark
70  ncandbquark = dqm.book1dHisto("ncandbquark", "n Events with c and b quark", 1, 0., 1.);
71 
72  // Number of events with c and no b quark
73  ncnobquark = dqm.book1dHisto("ncnobquark", "n Events with c and no b quark", 1, 0., 1.);
74 
75 
76  // Number of selected events for QCD-09-010
77  nEvt1 = dqm.book1dHisto("nEvt1", "n Events QCD-09-010", 1, 0., 1.);
78  // dNchdpt QCD-09-010
79  dNchdpt1 = dqm.book1dHisto("dNchdpt1", "dNchdpt QCD-09-010", 30, 0., 6.);
80  // dNchdeta QCD-09-010
81  dNchdeta1 = dqm.book1dHisto("dNchdeta1", "dNchdeta QCD-09-010", 10, -2.5, 2.5);
82  // Number of selected events for QCD-10-001
83 
84  nEvt2 = dqm.book1dHisto("nEvt2", "n Events QCD-10-001", 1, 0., 1.);
85  // Leading track pt QCD-10-001
86  leadTrackpt = dqm.book1dHisto("leadTrackpt", "leading track pt QCD-10-001", 200, 0., 100.);
87  // Leading track eta QCD-10-001
88  leadTracketa = dqm.book1dHisto("leadTracketa", "leading track eta QCD-10-001", 50., -2.5,2.5);
89  // transverse charged particle density vs leading track pt
90  nChaDenLpt = i.bookProfile("nChaDenLpt", "charged density vs leading pt", 200, 0., 100., 0., 100., " ");
91  // transverse charged particle density vs leading track pt
92  sptDenLpt = i.bookProfile("sptDenLpt", "sum pt density vs leading pt", 200, 0., 100., 0., 300., " ");
93  // dNchdpt QCD-10-001 transverse
94  dNchdpt2 = dqm.book1dHisto("dNchdpt2", "dNchdpt QCD-10-001", 200, 0., 100.);
95  // dNchdeta QCD-10-001 transverse
96  dNchdeta2 = dqm.book1dHisto("dNchdeta2", "dNchdeta QCD-10-001", 50, -2.5, 2.5);
97  // nCha QCD-10-001 transverse
98  nCha = dqm.book1dHisto("nCha", "n charged QCD-10-001", 100, 0., 100.);
99  // dNchdSpt transverse
100  dNchdSpt = dqm.book1dHisto("dNchdSpt", "dNchdSpt QCD-10-001", 300, 0., 300.);
101  // dNchdphi
102  dNchdphi = i.bookProfile("dNchdphi", "dNchdphi QCD-10-001", nphiBin, -180., 180., 0., 30., " ");
103  // dSptdphi
104  dSptdphi = i.bookProfile("dSptdphi", "dSptdphi QCD-10-001", nphiBin, -180., 180., 0., 30., " ");
105 
106  // number of charged jets QCD-10-001
107  nChj = dqm.book1dHisto("nChj", "n charged jets QCD-10-001", 30, 0, 30.);
108  // dNchjdeta QCD-10-001
109  dNchjdeta = dqm.book1dHisto("dNchjdeta", "dNchjdeta QCD-10-001", 50, -2.5, 2.5);
110  // dNchjdpt QCD-10-001
111  dNchjdpt = dqm.book1dHisto("dNchjdpt", "dNchjdpt QCD-10-001", 100, 0., 100.);
112  // leading charged jet pt QCD-10-001
113  leadChjpt = dqm.book1dHisto("leadChjpt", "leadChjpt QCD-10-001", 100, 0., 100.);
114  // leading charged jet eta QCD-10-001
115  leadChjeta = dqm.book1dHisto("leadChjeta", "leadChjeta QCD-10-001", 50, -2.5, 2.5);
116  // (pt1+pt2)/ptot
117  pt1pt2optotch = i.bookProfile("pt1pt2optotch", "sum 2 leading jets over ptot", 50, 0., 100., 0., 1., " ");
118 
119  // particle rates in tracker acceptance
120  nPPbar = dqm.book1dHisto("nPPbar", "nPPbar QCD-10-001", 30, 0., 30.);
121  nKpm = dqm.book1dHisto("nKpm", "nKpm QCD-10-001", 30, 0., 30.);
122  nK0s = dqm.book1dHisto("nK0s", "nK0s QCD-10-001", 30, 0., 30.);
123  nL0 = dqm.book1dHisto("nL0", "nL0 QCD-10-001", 30, 0., 30.);
124  nXim = dqm.book1dHisto("nXim", "nXim QCD-10-001", 30, 0., 30.);
125  nOmega = dqm.book1dHisto("nOmega", "nOmega QCD-10-001", 30, 0., 30.);
126 
127  pPPbar = dqm.book1dHisto("pPPbar", "Log10(pt) PPbar QCD-10-001", 25, -2., 3.);
128  pKpm = dqm.book1dHisto("pKpm", "Log10(pt) Kpm QCD-10-001", 25, -2., 3.);
129  pK0s = dqm.book1dHisto("pK0s", "Log10(pt) K0s QCD-10-001", 25, -2., 3.);
130  pL0 = dqm.book1dHisto("pL0", "Log10(pt) L0 QCD-10-001", 25, -2., 3.);
131  pXim = dqm.book1dHisto("pXim", "Log10(pt) Xim QCD-10-001", 25, -2., 3.);
132  pOmega = dqm.book1dHisto("pOmega", "Log10(pt) Omega QCD-10-001", 25, -2., 3.);
133 
134  // neutral rate in the barrel + HF acceptance
135  nNNbar = dqm.book1dHisto("nNNbar", "nNNbar QCD-10-001", 30, 0., 30.);
136  nGamma = dqm.book1dHisto("nGamma", "nGamma QCD-10-001", 50, 0., 200.);
137 
138  pNNbar = dqm.book1dHisto("pNNbar", "Log10(pt) NNbar QCD-10-001", 25, -2., 3.);
139  pGamma = dqm.book1dHisto("pGamma", "Log10(pt) Gamma QCD-10-001", 25, -2., 3.);
140 
141  // highest pt electron spectrum
142  elePt = dqm.book1dHisto("elePt", "highest pt electron Log10(pt)", 30, -2., 4.);
143 
144  // highest pt muon spectrum
145  muoPt = dqm.book1dHisto("muoPt", "highest pt muon Log10(pt)", 30, -2., 4.);
146 
147 
148  // number of selected di-jet events
149  nDijet = dqm.book1dHisto("nDijet", "n Dijet Events", 1, 0., 1.);
150  // number of jets
151  nj = dqm.book1dHisto("nj", "n jets ", 30, 0, 30.);
152  // dNjdeta
153  dNjdeta = dqm.book1dHisto("dNjdeta", "dNjdeta ", 50, -5., 5.);
154  // dNjdpt
155  dNjdpt = dqm.book1dHisto("dNjdpt", "dNjdpt ", 60, 0., 300.);
156  // (pt1+pt2)/ptot
157  pt1pt2optot = i.bookProfile("pt1pt2optot", "sum 2 leading jets over Et tot ", 60, 0., 300., 0., 1., " ");
158  // pt1-pt2
159  pt1pt2balance = dqm.book1dHisto("pt1pt2balance", "2 leading jets pt difference ", 10, 0., 1.);
160  // pt1 pt2 Delta phi
161  pt1pt2Dphi = dqm.book1dHisto("pt1pt2Dphi", "pt1 pt2 delta phi ", nphiBin, 0., 180.);
162  // pt1 pt2 invariant mass
163  pt1pt2InvM = dqm.book1dHisto("pt1pt2InvM", "pt1 pt2 invariant mass ", 60, 0., 600.);
164  // pt3 fraction
165  pt3Frac = dqm.book1dHisto("pt3Frac", "2 pt3 over pt1+pt2 ", 30, 0., 1.);
166  // sum of jets Et
167  sumJEt = dqm.book1dHisto("sumJEt", "sum Jet Et ", 60, 0., 300.);
168  // fraction of missing Et over sum of jets Et
169  missEtosumJEt = dqm.book1dHisto("missEtosumJEt", "missing Et over sumJet Et ", 30, 0., 1.);
170  // sum of final state particle Pt
171  sumPt = dqm.book1dHisto("sumPt", "sum particle Pt ", 60, 0., 600.);
172  // sum of final state charged particle Pt
173  sumChPt = dqm.book1dHisto("sumChPt", "sum charged particle Pt ", 60, 0., 300.);
174 
175  //Number of selected events for the HF energy flux analysis
176  nHFflow = dqm.book1dHisto("nHFflow", "n HF flow events", 1, 0., 1.);
177  //Forward energy flow for MinBias BSC selection
178  dEdetaHFmb = i.bookProfile("dEdetaHFmb", "dEdeta HF MinBias", (int)CaloCellManager::nForwardEta, 0, (double)CaloCellManager::nForwardEta, 0., 300., " ");
179  //Forward energy flow for QCD dijet selection
180  dEdetaHFdj = i.bookProfile("dEdetaHFdj", "dEdeta HF QCD dijet", (int)CaloCellManager::nForwardEta, 0, (double)CaloCellManager::nForwardEta, 0., 300., " ");
181 
182  // FWD-10-001 like diffraction analysis
183  nHFSD = dqm.book1dHisto("nHFSD","n single diffraction in HF", 1, 0., 1.);
184  // E-pz HF-
185  EmpzHFm = dqm.book1dHisto("EmpzHFm", "E-pz HF- SD", 40, 0., 200.);
186  // Number of cells above threshold
187  ntHFm = dqm.book1dHisto("ntHFm", "number of HF- tower SD", 20, 0., 20.);
188  // Energy in HF-
189  eneHFmSel = dqm.book1dHisto("eneHFmSel", "energy in HF-", 40, 0., 200.);
190 
191  // number of jets accepted in the 'Jet-Multiplicity' analysis
192  _JM25njets = dqm.book1dHisto("JM25njets", "n jets", 15, 0, 15.);
193  _JM25ht = dqm.book1dHisto("JM25ht", "HT", 80, 0, 800.);
194  _JM25pt1 = dqm.book1dHisto("JM25pt1", "pt", 40, 0, 200.);
195  _JM25pt2 = dqm.book1dHisto("JM25pt2", "pt", 40, 0, 200.);
196  _JM25pt3 = dqm.book1dHisto("JM25pt3", "pt", 40, 0, 200.);
197  _JM25pt4 = dqm.book1dHisto("JM25pt4", "pt", 40, 0, 200.);
198 
199  _JM80njets = dqm.book1dHisto("JM80njets", "n jets", 15, 0, 15.);
200  _JM80ht = dqm.book1dHisto("JM80ht", "HT", 80, 300, 1100.);
201  _JM80pt1 = dqm.book1dHisto("JM80pt1", "pt", 40, 60, 260.);
202  _JM80pt2 = dqm.book1dHisto("JM80pt2", "pt", 40, 60, 260.);
203  _JM80pt3 = dqm.book1dHisto("JM80pt3", "pt", 40, 60, 260.);
204  _JM80pt4 = dqm.book1dHisto("JM80pt4", "pt", 40, 60, 260.);
205 
206 
207  // differential jet rates
208  djr10 = dqm.book1dHisto("djr10", "Differential Jet Rate 1#rightarrow0", 60, -1., 5.);
209  djr21 = dqm.book1dHisto("djr21", "Differential Jet Rate 2#rightarrow1", 60, -1., 5.);
210  djr32 = dqm.book1dHisto("djr32", "Differential Jet Rate 3#rightarrow2", 60, -1., 5.);
211  djr43 = dqm.book1dHisto("djr43", "Differential Jet Rate 4#rightarrow3", 60, -1., 5.);
212 
213  // sumET analysis
214  _sumEt = dqm.book1dHisto("sumET", "Sum of stable particles Et", 150, 0, 600.);
215  _sumEt1 = dqm.book1dHisto("sumET1", "Sum of stable particles Et (eta<0.5)", 150, 0, 200.);
216  _sumEt2 = dqm.book1dHisto("sumET2", "Sum of stable particles Et (0.5<eta<1.0)", 150, 0, 200.);
217  _sumEt3 = dqm.book1dHisto("sumET3", "Sum of stable particles Et (1.0<eta<1.5)", 150, 0, 200.);
218  _sumEt4 = dqm.book1dHisto("sumET4", "Sum of stable particles Et (1.5<eta<2.0)", 150, 0, 200.);
219  _sumEt5 = dqm.book1dHisto("sumET5", "Sum of stable particles Et (2.0<eta<5.0)", 150, 0, 200.);
220 
221 
222  return;
223 }
224 
226 {
227 
230  iEvent.getByToken(hepmcCollectionToken_, evt);
231 
232  //Get HepMC EVENT
233  HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent()));
234 
235  double weight = wmanager_.weight(iEvent);
236 
237 
238  if ( verbosity_ > 0 ) { myGenEvent->print(); }
239 
240  double binW = 1.;
241 
242  hepmcGPCollection.clear();
243  hepmcCharge.clear();
244  for (unsigned int i = 0; i < eneInCell.size(); i++) { eneInCell[i] = 0.; }
245 
246  nEvt->Fill(0.5,weight);
247 
248  //Looping through HepMC::GenParticle collection to search for status 1 particles
249  double charge = 0.;
250  unsigned int nb = 0;
251  unsigned int nc = 0;
252  for (HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); ++iter){
253  if ( std::fabs((*iter)->pdg_id()) == 4 ) { nc++; }
254  if ( std::fabs((*iter)->pdg_id()) == 5 ) { nb++; }
255  if ( (*iter)->status() == 1) {
256  hepmcGPCollection.push_back(*iter);
257  const HepPDT::ParticleData* PData = fPDGTable->particle(HepPDT::ParticleID((*iter)->pdg_id()));
258  if(PData==0) { charge = -999.; }
259  else
260  charge = PData->charge();
261 
262  hepmcCharge.push_back(charge);
263 
264  if ( verbosity_ > 0 ) {
265  std::cout << "HepMC " << std::setw(14) << std::fixed << (*iter)->barcode()
266  << std::setw(14) << std::fixed << (*iter)->pdg_id()
267  << std::setw(14) << std::fixed << (*iter)->momentum().perp()
268  << std::setw(14) << std::fixed << (*iter)->momentum().eta()
269  << std::setw(14) << std::fixed << (*iter)->momentum().phi() << std::endl;
270  }
271 
272  }
273  }
274 
275  int nBSCp = 0; int nBSCm = 0; double eneHFp = 0.; double eneHFm = 0.; int nChapt05 = 0; int nChaVtx = 0;
276  for (unsigned int i = 0; i < hepmcGPCollection.size(); i++ ){
277  if ( !isNeutrino(i) ) {
278 
279  // BSC trigger
280 
281  if ( hepmcGPCollection[i]->momentum().eta() > 3.23 && hepmcGPCollection[i]->momentum().eta() < 4.65 ) { nBSCp++; }
282  if ( hepmcGPCollection[i]->momentum().eta() < -3.23 && hepmcGPCollection[i]->momentum().eta() > -4.65 ) { nBSCm++; }
283 
284  // number of charged particles in different selections
285 
286  if ( std::fabs(hepmcGPCollection[i]->momentum().eta()) < 2.5 && hepmcGPCollection[i]->momentum().perp() > 0.5 && isCharged(i) ) { nChapt05++; }
287  if ( std::fabs(hepmcGPCollection[i]->momentum().eta()) < 2.5 && hepmcGPCollection[i]->momentum().perp() > 0.1 && isCharged(i) ) { nChaVtx++; }
288  unsigned int theIndex = theCalo->getCellIndexFromAngle(hepmcGPCollection[i]->momentum().eta(),hepmcGPCollection[i]->momentum().phi());
289  if ( theIndex < CaloCellManager::nCaloCell ) eneInCell[theIndex] += hepmcGPCollection[i]->momentum().rho();
290  }
291  }
292 
293  // Forward calorimeters energy
294 
295  for (unsigned int icell = CaloCellManager::nBarrelCell+CaloCellManager::nEndcapCell; icell < CaloCellManager::nCaloCell; icell++ ) {
296  if ( theCalo->getCellFromIndex(icell)->getEtaMin() < 0. ) { eneHFm += eneInCell[icell]; }
297  else { eneHFp += eneInCell[icell]; }
298  }
299 
300  // QCD-09-010 selection
301  bool sel1 = false;
302  if ( (nBSCp > 0 || nBSCm > 0) && eneHFp >= 3. && eneHFm >= 3. ) { sel1 = true; }
303 
304  // QCD-10-001 selection
305  bool sel2 = false;
306  if ( (nBSCp >0 || nBSCm > 0) && nChaVtx >= 3 && nChapt05 > 1 ) { sel2 = true; }
307 
308  // no forward trigger selection
309  bool sel3 = false;
310  if ( nBSCp == 0 && nBSCm == 0 ) { sel3 = true; }
311 
312  // single arm forward trigger selection
313  bool sel4 = false;
314  if ( ( nBSCp>0 && nBSCm == 0 ) || ( nBSCm>0 && nBSCp == 0 ) ) { sel4 = true; }
315 
316  // BSC selection
317  bool sel5 = false;
318  if ( nBSCp > 0 && nBSCm > 0 ) { sel5 = true; }
319 
320  // basic JME-10-001, FWD-10-002 and Jet-Multiplicity selection
321  bool sel6 = false;
322  if ( sel5 && nChaVtx > 3 ) { sel6 = true; }
323 
324  // FWD-10-001 selection
325  bool sel7 = false;
326  if ( nChaVtx >= 3 && nBSCm > 0 && eneHFp < 8. ) { sel7 = true; }
327 
328  // Fill selection histograms
329  if ( sel1 ) nEvt1->Fill(0.5,weight);
330  if ( sel2 ) nEvt2->Fill(0.5,weight);
331  if ( sel3 ) nNoFwdTrig->Fill(0.5,weight);
332  if ( sel4 ) nSaFwdTrig->Fill(0.5,weight);
333  if ( sel6 ) nHFflow->Fill(0.5,weight);
334  if ( sel7 ) nHFSD->Fill(0.5,weight);
335 
336  if ( nb > 0 ) nbquark->Fill(0.5,weight);
337  if ( nb > 0 && nc > 0 ) ncandbquark->Fill(0.5,weight);
338  if ( nb == 0 && nc > 0 ) ncnobquark->Fill(0.5,weight);
339 
340  // track analyses
341  double ptMax = 0.;
342  unsigned int iMax = 0;
343  double ptot = 0.;
344  unsigned int ppbar = 0; unsigned int nnbar = 0; unsigned int kpm = 0; unsigned int k0s = 0; unsigned int l0 = 0; unsigned int gamma = 0;
345  unsigned int xim = 0; unsigned int omega = 0;
346  unsigned int ele = 0; unsigned int muo = 0;
347  unsigned int eleMax = 0;
348  unsigned int muoMax = 0;
349 
350  std::vector<double> hfMB (CaloCellManager::nForwardEta,0);
351  std::vector<double> hfDJ (CaloCellManager::nForwardEta,0);
352 
353  for (unsigned int i = 0; i < hepmcGPCollection.size(); i++ ){
354  double eta = hepmcGPCollection[i]->momentum().eta();
355  double pt = hepmcGPCollection[i]->momentum().perp();
356  int pdgId = hepmcGPCollection[i]->pdg_id();
357  if ( isCharged(i) && std::fabs(eta) < 2.5 ) {
358  if ( sel1 ) {
359  // QCD-09-010
360  binW = dNchdpt1->getTH1()->GetBinWidth(1);
361  dNchdpt1->Fill(pt,1./binW); // weight to account for the pt bin width
362  binW = dNchdeta1->getTH1()->GetBinWidth(1);
363  dNchdeta1->Fill(eta,1./binW); // weight to account for the eta bin width
364  }
365  // search for the leading track QCD-10-001
366  if ( sel2 ) {
367  if ( pt > ptMax ) { ptMax = pt; iMax = i; }
368  ptot += pt;
369 
370  // identified charged particle
371  if (std::abs(pdgId) == 2212) {
372  ppbar++;
373  pPPbar->Fill(std::log10(pt),weight);
374  }
375  else if (std::abs(pdgId) == 321) {
376  kpm++;
377  pKpm->Fill(std::log10(pt),weight);
378  }
379  else if (std::abs(pdgId) == 3312) {
380  xim++;
381  pXim->Fill(std::log10(pt),weight);
382  }
383  else if (std::abs(pdgId) == 3334) {
384  omega++;
385  pOmega->Fill(std::log10(pt),weight);
386  }
387  else if (std::abs(pdgId) == 11) {
388  ele++;
389  eleMax = i;
390  }
391  else if (std::abs(pdgId) == 13) {
392  muo++;
393  muoMax = i;
394  }
395  }
396  }
397  else if ( sel2 && isNeutral(i) && std::fabs(eta) < 2.5 ) {
398  if (std::abs(pdgId) == 310) {
399  k0s++;
400  pK0s->Fill(std::log10(pt),weight);
401  }
402  else if (std::abs(pdgId) == 3122) {
403  l0++;
404  pL0->Fill(std::log10(pt),weight);
405  }
406  }
407  else if ( sel2 && isNeutral(i) && std::fabs(eta) < 5.19 ) {
408  if (std::abs(pdgId) == 2112) {
409  nnbar++;
410  pNNbar->Fill(std::log10(pt),weight);
411  }
412  else if (std::abs(pdgId) == 22) {
413  gamma++;
414  pGamma->Fill(std::log10(pt),weight);
415  }
416  }
417  unsigned int iBin = getHFbin(eta);
418  if ( sel6 && !isNeutrino(i) && iBin < CaloCellManager::nForwardEta ) {
419  hfMB[iBin] += hepmcGPCollection[i]->momentum().rho();
420  }
421  }
422  nPPbar->Fill(ppbar,weight);
423  nNNbar->Fill(nnbar,weight);
424  nKpm->Fill(kpm,weight);
425  nK0s->Fill(k0s,weight);
426  nL0->Fill(l0,weight);
427  nXim->Fill(xim,weight);
428  nOmega->Fill(omega,weight);
429  nGamma->Fill(gamma,weight);
430 
431  if ( ele > 0 ) elePt->Fill(std::log10(hepmcGPCollection[eleMax]->momentum().perp()),weight);
432  if ( muo > 0 ) muoPt->Fill(std::log10(hepmcGPCollection[muoMax]->momentum().perp()),weight);
433 
434  leadTrackpt->Fill(hepmcGPCollection[iMax]->momentum().perp(),weight);
435  leadTracketa->Fill(hepmcGPCollection[iMax]->momentum().eta(),weight);
436 
437  std::vector<double> theEtaRanges(theCalo->getEtaRanges());
438 
439  for (unsigned int i = 0; i < CaloCellManager::nForwardEta; i++ ) {
441  dEdetaHFmb->Fill(i+0.5,hfMB[i]/binW);
442  }
443 
444  // FWD-10-001
445 
446  if ( sel7 ) {
447 
448  double empz = 0.;
449  unsigned int nCellOvTh = 0;
450  double threshold = 0.;
451 
452  for (unsigned int icell = 0; icell < eneInCell.size(); icell++ ) {
453 
454  if ( theCalo->getCellFromIndex(icell)->getSubSys() != CaloCellId::Forward ) { threshold = 3.; }
455  else { threshold = 4.; }
456 
457  if ( eneInCell[icell] > threshold ) {
458  if ( theCalo->getCellFromIndex(icell)->getSubSys() == CaloCellId::Forward ) { nCellOvTh++; }
459  empz += eneInCell[icell]*(1.-std::cos(theCalo->getCellFromIndex(icell)->getThetaCell()));
460  }
461 
462  }
463 
464  EmpzHFm->Fill(empz,weight);
465  ntHFm->Fill(nCellOvTh,weight);
466  eneHFmSel->Fill(eneHFm,weight);
467 
468  }
469 
470  // QCD-10-001
471  double phiMax = hepmcGPCollection[iMax]->momentum().phi();
472  std::vector<unsigned int> nchvsphi (nphiBin,0);
473  std::vector<double> sptvsphi (nphiBin,0.);
474  unsigned int nChaTra = 0;
475  double sptTra = 0.;
476 
477  double binPhiW = 360./nphiBin;
478  if ( sel2 ) {
479  for (unsigned int i = 0; i < hepmcGPCollection.size(); i++ ){
480  if ( isCharged(i) && std::fabs(hepmcGPCollection[i]->momentum().eta()) < 2. ) {
481  double thePhi = (hepmcGPCollection[i]->momentum().phi()-phiMax)/CLHEP::degree;
482  if ( thePhi < -180. ) { thePhi += 360.; }
483  else if ( thePhi > 180. ) { thePhi -= 360.; }
484  unsigned int thePhiBin = (int)((thePhi+180.)/binPhiW);
485  if ( thePhiBin == nphiBin ) { thePhiBin -= 1; }
486  nchvsphi[thePhiBin]++;
487  sptvsphi[thePhiBin] += hepmcGPCollection[i]->momentum().perp();
488  // analysis in the transverse region
489  if ( std::fabs(thePhi) > 60. && std::fabs(thePhi) < 120. ) {
490  nChaTra++;
491  sptTra += hepmcGPCollection[i]->momentum().perp();
492  binW = dNchdpt2->getTH1()->GetBinWidth(1);
493  dNchdpt2->Fill(hepmcGPCollection[i]->momentum().perp(),1./binW); // weight to account for the pt bin width
494  binW = dNchdeta2->getTH1()->GetBinWidth(1);
495  dNchdeta2->Fill(hepmcGPCollection[i]->momentum().eta(),1./binW); // weight to account for the eta bin width
496  }
497  }
498  }
499  nCha->Fill(nChaTra,weight);
500  binW = dNchdSpt->getTH1()->GetBinWidth(1);
501  dNchdSpt->Fill(sptTra,1.);
502  //how do one apply weights to a profile? MonitorElement doesn't allow to
503  nChaDenLpt->Fill(hepmcGPCollection[iMax]->momentum().perp(),nChaTra/4./CLHEP::twopi);
504  sptDenLpt->Fill(hepmcGPCollection[iMax]->momentum().perp(),sptTra/4./CLHEP::twopi);
505  for ( unsigned int i = 0; i < nphiBin; i++ ) {
506  double thisPhi = -180.+(i+0.5)*binPhiW;
507  dNchdphi->Fill(thisPhi,nchvsphi[i]/binPhiW/4.); // density in phi and eta
508  dSptdphi->Fill(thisPhi,sptvsphi[i]/binPhiW/4.); // density in phi and eta
509  }
510  }
511 
512  // Gather information in the charged GenJet collection
514  iEvent.getByToken(genchjetCollectionToken_, genChJets );
515 
516  unsigned int nJets = 0;
517  double pt1 = 0.;
518  double pt2 = 0.;
519  reco::GenJetCollection::const_iterator ij1 = genChJets->begin();
520  reco::GenJetCollection::const_iterator ij2 = genChJets->begin();
521  if ( sel2 ) {
522  for (reco::GenJetCollection::const_iterator iter=genChJets->begin();iter!=genChJets->end();++iter){
523  double eta = (*iter).eta();
524  double pt = (*iter).pt();
525  if ( verbosity_ > 0 ) {
526  std::cout << "GenJet " << std::setw(14) << std::fixed << (*iter).pt()
527  << std::setw(14) << std::fixed << (*iter).eta()
528  << std::setw(14) << std::fixed << (*iter).phi() << std::endl;
529  }
530  if ( std::fabs(eta) < 2. ) {
531  nJets++;
532  binW = dNchjdeta->getTH1()->GetBinWidth(1);
533  dNchjdeta->Fill(eta,1./binW);
534  binW = dNchjdpt->getTH1()->GetBinWidth(1);
535  dNchjdpt->Fill(pt,1./binW);
536  if ( pt >= pt1 ) { pt1 = pt; ij1 = iter; }
537  if ( pt < pt1 && pt >= pt2 ) { pt2 = pt; ij2 = iter; }
538  }
539  }
540 
541  nChj->Fill(nJets,weight);
542  if ( nJets > 0 && ij1 != genChJets->end() ) {
543  leadChjpt->Fill(pt1,weight);
544  leadChjeta->Fill((*ij1).eta(),weight);
545  if ( nJets > 1 && ij2 != genChJets->end() ) {
546  pt1pt2optotch->Fill(pt1+pt2,(pt1+pt2)/ptot);
547  }
548  }
549  }
550 
551 
552  // Gather information in the GenJet collection
554  iEvent.getByToken(genjetCollectionToken_, genJets );
555 
556  nJets = 0;
557  pt1 = 0.;
558  pt2 = 0.;
559  double pt3 = 0.;
560 
561 
562  // needed for Jet-Multiplicity Analysis
563  int jm25njets = 0;
564  double jm25HT = 0.;
565  double jm25pt1 = 0.;
566  double jm25pt2 = 0.;
567  double jm25pt3 = 0.;
568  double jm25pt4 = 0.;
569 
570  int jm80njets = 0;
571  double jm80HT = 0.;
572  double jm80pt1 = 0.;
573  double jm80pt2 = 0.;
574  double jm80pt3 = 0.;
575  double jm80pt4 = 0.;
576 
577 
578 
579  reco::GenJetCollection::const_iterator ij3 = genJets->begin();
580  if ( sel6 ) {
581  for (reco::GenJetCollection::const_iterator iter=genJets->begin();iter!=genJets->end();++iter){
582  double eta = (*iter).eta();
583  double pt = (*iter).pt();
584  if ( verbosity_ > 0 ) {
585  std::cout << "GenJet " << std::setw(14) << std::fixed << (*iter).pt()
586  << std::setw(14) << std::fixed << (*iter).eta()
587  << std::setw(14) << std::fixed << (*iter).phi() << std::endl;
588  }
589  if ( std::fabs(eta) < 5. ) {
590  nJets++;
591  if ( pt >= pt1 ) { pt1 = pt; ij1 = iter; }
592  if ( pt < pt1 && pt >= pt2 ) { pt2 = pt; ij2 = iter; }
593  if ( pt < pt2 && pt >= pt3 ) { pt3 = pt; ij3 = iter; }
594  }
595 
596  // find variables for Jet-Multiplicity Analysis
597  if(fabs(iter->eta()) < 3. && iter->pt()>25.) {
598  jm25njets++;
599  jm25HT += iter->pt();
600  if(iter->pt()>jm25pt1) {
601  jm25pt4 = jm25pt3;
602  jm25pt3 = jm25pt2;
603  jm25pt2 = jm25pt1;
604  jm25pt1 = iter->pt();
605  } else if(iter->pt()>jm25pt2) {
606  jm25pt4 = jm25pt3;
607  jm25pt3 = jm25pt2;
608  jm25pt2 = iter->pt();
609  } else if(iter->pt()>jm25pt3) {
610  jm25pt4 = jm25pt3;
611  jm25pt3 = iter->pt();
612  } else if(iter->pt()>jm25pt4) {
613  jm25pt4 = iter->pt();
614  }
615  // even harder jets...
616  if(iter->pt()>80.) {
617  jm80njets++;
618  jm80HT += iter->pt();
619  if(iter->pt()>jm80pt1) {
620  jm80pt4 = jm80pt3;
621  jm80pt3 = jm80pt2;
622  jm80pt2 = jm80pt1;
623  jm80pt1 = iter->pt();
624  } else if(iter->pt()>jm80pt2) {
625  jm80pt4 = jm80pt3;
626  jm80pt3 = jm80pt2;
627  jm80pt2 = iter->pt();
628  } else if(iter->pt()>jm80pt3) {
629  jm80pt4 = jm80pt3;
630  jm80pt3 = iter->pt();
631  } else if(iter->pt()>jm80pt4) {
632  jm80pt4 = iter->pt();
633  }
634  }
635 
636  }
637 
638  if(jm25njets>3) {
639  _JM25njets ->Fill(jm25njets,weight);
640  _JM25ht ->Fill(jm25HT,weight);
641  _JM25pt1 ->Fill(jm25pt1,weight);
642  _JM25pt2 ->Fill(jm25pt2,weight);
643  _JM25pt3 ->Fill(jm25pt3,weight);
644  _JM25pt4 ->Fill(jm25pt4,weight);
645  }
646  if(jm80njets>3) {
647  _JM80njets ->Fill(jm80njets,weight);
648  _JM80ht ->Fill(jm80HT,weight);
649  _JM80pt1 ->Fill(jm80pt1,weight);
650  _JM80pt2 ->Fill(jm80pt2,weight);
651  _JM80pt3 ->Fill(jm80pt3,weight);
652  _JM80pt4 ->Fill(jm80pt4,weight);
653  }
654  }
655 
656  // select a di-jet event JME-10-001 variant
657  double sumJetEt = 0; double sumPartPt = 0.; double sumChPartPt = 0.;
658  double jpx = 0; double jpy = 0;
659  if ( nJets >= 2 && ij1 != genJets->end() && ij2 != genJets->end() ) {
660  if ( (*ij1).pt() > 25. && (*ij1).pt() > 25. ) {
661  double deltaPhi = std::fabs((*ij1).phi()-(*ij2).phi())/CLHEP::degree;
662  if ( deltaPhi > 180. ) deltaPhi = 360.-deltaPhi;
663  pt1pt2Dphi->Fill(deltaPhi,weight);
664  if ( std::fabs(deltaPhi) > 2.5*CLHEP::degree ) {
665 
666  nDijet->Fill(0.5,weight);
667 
668  for (unsigned int i = 0; i < hepmcGPCollection.size(); i++ ){
669  double eta = hepmcGPCollection[i]->momentum().eta();
670  unsigned int iBin = getHFbin(eta);
671  if ( !isNeutrino(i) && iBin < CaloCellManager::nForwardEta ) {
672  hfDJ[iBin] += hepmcGPCollection[i]->momentum().rho();
673  }
674  if ( !isNeutrino(i) && std::fabs(eta) < 5. ) {
675  sumPartPt += hepmcGPCollection[i]->momentum().perp();
676  if ( isCharged(i) ) {
677  sumChPartPt += hepmcGPCollection[i]->momentum().perp();
678  }
679  }
680  }
681  for (unsigned int i = 0; i < CaloCellManager::nForwardEta; i++ ) {
683  dEdetaHFdj->Fill(i+0.5,hfDJ[i]/binW);
684  }
685 
686  double invMass = (*ij1).energy()*(*ij2).energy()-(*ij1).px()*(*ij2).px()-(*ij1).py()*(*ij2).py()-(*ij1).pz()*(*ij2).pz();
687  invMass = std::sqrt(invMass);
688  pt1pt2InvM->Fill(invMass,weight);
689 
690  sumPt->Fill(sumPartPt,weight);
691  sumChPt->Fill(sumChPartPt,weight);
692 
693  unsigned int nSelJets = 0;
694  for (reco::GenJetCollection::const_iterator iter=genJets->begin();iter!=genJets->end();++iter){
695  double pt = (*iter).pt();
696  double eta = (*iter).eta();
697  if ( std::fabs(eta) < 5. ) {
698  nSelJets++;
699  binW = dNjdeta->getTH1()->GetBinWidth(1);
700  dNjdeta->Fill(eta,1./binW*weight);
701  binW = dNjdpt->getTH1()->GetBinWidth(1);
702  dNjdpt->Fill(pt,1./binW*weight);
703  sumJetEt += (*iter).pt();
704  jpx += (*iter).px();
705  jpy += (*iter).py();
706  }
707  }
708 
709  nj->Fill(nSelJets,weight);
710  double mEt = std::sqrt(jpx*jpx+jpy*jpy);
711  sumJEt->Fill(sumJetEt,weight);
712  missEtosumJEt->Fill(mEt/sumJetEt,weight);
713 
714  if ( nSelJets >= 3 ) { pt3Frac->Fill((*ij3).pt()/(pt1+pt2),weight); }
715 
716  pt1pt2optot->Fill(pt1+pt2,(pt1+pt2)/sumJetEt);
717  pt1pt2balance->Fill((pt1-pt2)/(pt1+pt2),weight);
718  }
719  }
720  }
721  }
722 
723 
724  //compute differential jet rates
725  std::vector<const HepMC::GenParticle*> qcdActivity;
726  HepMCValidationHelper::removeIsolatedLeptons(myGenEvent, 0.2, 3., qcdActivity);
727  //HepMCValidationHelper::allStatus1(myGenEvent, qcdActivity);
728  //fill PseudoJets to use fastjet
729  std::vector<fastjet::PseudoJet> vecs;
730  int counterUser = 1;
731  std::vector<const HepMC::GenParticle*>::const_iterator iqcdact;
732  for (iqcdact = qcdActivity.begin(); iqcdact != qcdActivity.end(); ++iqcdact){
733  const HepMC::FourVector& fmom = (*iqcdact)->momentum();
734  fastjet::PseudoJet pseudoJet(fmom.px(), fmom.py(), fmom.pz(), fmom.e());
735  pseudoJet.set_user_index(counterUser);
736  vecs.push_back(pseudoJet);
737  ++counterUser;
738  }
739  //compute jets
740  fastjet::ClusterSequence cseq(vecs, fastjet::JetDefinition(fastjet::kt_algorithm, 1., fastjet::E_scheme));
741  //access the cluster sequence and get the relevant info
742  djr10->Fill(std::log10(sqrt(cseq.exclusive_dmerge(0))),weight);
743  djr21->Fill(std::log10(sqrt(cseq.exclusive_dmerge(1))),weight);
744  djr32->Fill(std::log10(sqrt(cseq.exclusive_dmerge(2))),weight);
745  djr43->Fill(std::log10(sqrt(cseq.exclusive_dmerge(3))),weight);
746 
747 
748  // compute sumEt for all stable particles
749  std::vector<const HepMC::GenParticle*> allStable;
750  HepMCValidationHelper::allStatus1(myGenEvent, allStable);
751 
752  double sumEt = 0.;
753  double sumEt1 = 0.;
754  double sumEt2 = 0.;
755  double sumEt3 = 0.;
756  double sumEt4 = 0.;
757  double sumEt5 = 0.;
758 
759  for(std::vector<const HepMC::GenParticle*>::const_iterator iter=allStable.begin();
760  iter != allStable.end(); ++iter) {
761 
762  double thisEta=fabs((*iter)->momentum().eta());
763 
764  if(thisEta < 5.) {
765  const HepMC::FourVector mom=(*iter)->momentum();
766  double px=mom.px();
767  double py=mom.py();
768  double pz=mom.pz();
769  double E=mom.e();
770  double thisSumEt = (
771  sqrt(px*px + py*py)*E /
772  sqrt(px*px + py*py + pz*pz)
773  );
774  sumEt += thisSumEt;
775  if(thisEta<1.0) sumEt1 += thisSumEt;
776  else if(thisEta<2.0) sumEt2 += thisSumEt;
777  else if(thisEta<3.0) sumEt3 += thisSumEt;
778  else if(thisEta<4.0) sumEt4 += thisSumEt;
779  else sumEt5 += thisSumEt;
780 
781  }
782  }
783 
784  if(sumEt>0.)
785  _sumEt->Fill(sumEt,weight);
786  if(sumEt1>0.)
787  _sumEt1->Fill(sumEt1,weight);
788  if(sumEt2>0.)
789  _sumEt2->Fill(sumEt2,weight);
790  if(sumEt3>0.)
791  _sumEt3->Fill(sumEt3,weight);
792  if(sumEt4>0.)
793  _sumEt4->Fill(sumEt4,weight);
794  if(sumEt5>0.)
795  _sumEt5->Fill(sumEt5,weight);
796 
797  delete myGenEvent;
798 }//analyze
799 
801 
802  bool status = false;
803  if ( hepmcGPCollection.size() < i+1 ) { return status; }
804  else { status = (hepmcCharge[i] != 0. && hepmcCharge[i] != -999.); }
805  return status;
806 
807 }
808 
810 
811  bool status = false;
812  int pdgId = std::abs(hepmcGPCollection[i]->pdg_id());
813  if ( hepmcGPCollection.size() < i+1 ) { return status; }
814  else { status = (hepmcCharge[i] == 0. && pdgId != 12 && pdgId != 14 && pdgId != 16) ; }
815  return status;
816 
817 }
818 
820 
821  bool status = false;
822  int pdgId = std::abs(hepmcGPCollection[i]->pdg_id());
823  if ( hepmcGPCollection.size() < i+1 ) { return status; }
824  else { status = (pdgId == 12 || pdgId == 14 || pdgId == 16) ; }
825  return status;
826 
827 }
828 
829 unsigned int MBUEandQCDValidation::getHFbin(double eta) {
830 
831  unsigned int iBin = 999;
832 
833  std::vector<double> theEtaRanges(theCalo->getEtaRanges());
834 
837  if ( std::fabs(eta) >= theEtaRanges[i] && std::fabs(eta) < theEtaRanges[i+1] )
839  }
840 
841  return iBin;
842 
843 }
844 
845 const unsigned int MBUEandQCDValidation::nphiBin = 36;
846 const unsigned int MBUEandQCDValidation::initSize = 1000;
bool isCharged(unsigned int i)
MonitorElement * ncnobquark
int i
Definition: DBlmapReader.cc:9
double getThetaCell()
Definition: CaloCellId.cc:47
MonitorElement * nbquark
static const unsigned int nphiBin
std::vector< const HepMC::GenParticle * > hepmcGPCollection
status 1 GenParticle collection
MonitorElement * sptDenLpt
MonitorElement * leadTracketa
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
static const unsigned int nForwardEta
MonitorElement * leadTrackpt
MBUEandQCDValidation(const edm::ParameterSet &)
static const unsigned int nBarrelCell
MonitorElement * dSptdphi
MonitorElement * dNchdpt1
MonitorElement * dNchdSpt
MonitorElement * _JM80njets
theIndex(0)
void allStatus1(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle * > &status1)
MonitorElement * dNchjdeta
CaloCellManager * theCalo
manager of calorimetric cell structure
MonitorElement * dNchdeta1
static const unsigned int nEndcapEta
edm::InputTag genjetCollection_
double getEtaMin() const
Definition: CaloCellId.h:24
MonitorElement * pt1pt2Dphi
MonitorElement * dNchdeta2
void getData(T &iHolder) const
Definition: EventSetup.h:78
void Fill(long long x)
MonitorElement * _JM25njets
std::vector< double > hepmcCharge
bool isNeutrino(unsigned int i)
MonitorElement * pt1pt2InvM
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
std::vector< double > getEtaRanges()
CaloCellId * getCellFromIndex(unsigned int id)
int iEvent
Definition: GenABIO.cc:230
void removeIsolatedLeptons(const HepMC::GenEvent *all, double deltaR, double sumPt, std::vector< const HepMC::GenParticle * > &pruned)
MonitorElement * eneHFmSel
MonitorElement * nSaFwdTrig
MonitorElement * pt1pt2optot
MonitorElement * pt1pt2optotch
static const unsigned int nCaloCell
MonitorElement * leadChjpt
T sqrt(T t)
Definition: SSEVec.h:48
virtual void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
MonitorElement * dNchdpt2
MonitorElement * nEvt1
QCD-09-010 analysis.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
System getSubSys() const
Definition: CaloCellId.h:28
MonitorElement * dNchdphi
TH1 * getTH1(void) const
virtual void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
MonitorElement * dEdetaHFdj
std::vector< double > eneInCell
static const unsigned int nEndcapCell
MonitorElement * pt1pt2balance
edm::InputTag hepmcCollection_
HepPDT::ParticleData ParticleData
static const unsigned int nBarrelEta
edm::InputTag genchjetCollection_
MonitorElement * leadChjeta
edm::EDGetTokenT< reco::GenJetCollection > genchjetCollectionToken_
MonitorElement * nNoFwdTrig
edm::EDGetTokenT< reco::GenJetCollection > genjetCollectionToken_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
MonitorElement * book1dHisto(const std::string &name, const std::string &title, int n, double xmin, double xmax)
Definition: DQMHelper.cc:12
MonitorElement * ncandbquark
unsigned int getHFbin(double eta)
bool isNeutral(unsigned int i)
T perp() const
Magnitude of transverse component.
MonitorElement * dEdetaHFmb
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
tuple cout
Definition: gather_cfg.py:121
int weight
Definition: histoStyle.py:50
tuple status
Definition: ntuplemaker.py:245
MonitorElement * nChaDenLpt
unsigned int getCellIndexFromAngle(double eta, double phi)
double weight(const edm::Event &)
static const unsigned int initSize
Definition: Run.h:41
MonitorElement * missEtosumJEt