CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EwkMuLumiMonitorDQM.cc
Go to the documentation of this file.
2 
6 
9 
12 
15 
18 
25 
28 
30 
31 using namespace edm;
32 using namespace std;
33 using namespace reco;
34 using namespace isodeposit;
35 
37  :
38  // Input collections
39  trigTag_(cfg.getUntrackedParameter<edm::InputTag>(
40  "TrigTag", edm::InputTag("TriggerResults::HLT"))),
41  trigToken_(consumes<edm::TriggerResults>(trigTag_)),
42  trigEvToken_(consumes<trigger::TriggerEvent>(
43  cfg.getUntrackedParameter<edm::InputTag>("triggerEvent"))),
44  beamSpotToken_(
45  consumes<reco::BeamSpot>(cfg.getUntrackedParameter<edm::InputTag>(
46  "offlineBeamSpot", edm::InputTag("offlineBeamSpot")))),
47  muonToken_(consumes<edm::View<reco::Muon> >(
48  cfg.getUntrackedParameter<edm::InputTag>("muons"))),
49  trackToken_(consumes<reco::TrackCollection>(
50  cfg.getUntrackedParameter<edm::InputTag>("tracks"))),
51  caloTowerToken_(consumes<CaloTowerCollection>(
52  cfg.getUntrackedParameter<edm::InputTag>("calotower"))),
53  metToken_(consumes<edm::View<reco::MET> >(
54  cfg.getUntrackedParameter<edm::InputTag>("metTag"))),
55  metIncludesMuons_(cfg.getUntrackedParameter<bool>("METIncludesMuons")),
56  // Main cuts
57  // massMin_(cfg.getUntrackedParameter<double>("MtMin", 20.)),
58  // massMax_(cfg.getUntrackedParameter<double>("MtMax", 2000.))
59  // hltPath_(cfg.getUntrackedParameter<std::string> ("hltPath")) ,
60  // L3FilterName_(cfg.getUntrackedParameter<std::string>
61  // ("L3FilterName")),
62  ptMuCut_(cfg.getUntrackedParameter<double>("ptMuCut")),
63  etaMuCut_(cfg.getUntrackedParameter<double>("etaMuCut")),
64  isRelativeIso_(cfg.getUntrackedParameter<bool>("IsRelativeIso")),
65  isCombinedIso_(cfg.getUntrackedParameter<bool>("IsCombinedIso")),
66  isoCut03_(cfg.getUntrackedParameter<double>("IsoCut03")),
67  // deltaRTrk_(cfg.getUntrackedParameter<double>("deltaRTrk")),
68  ptThreshold_(cfg.getUntrackedParameter<double>("ptThreshold")),
69  // deltaRVetoTrk_(cfg.getUntrackedParameter<double>("deltaRVetoTrk")),
70  maxDPtRel_(cfg.getUntrackedParameter<double>("maxDPtRel")),
71  maxDeltaR_(cfg.getUntrackedParameter<double>("maxDeltaR")),
72  mtMin_(cfg.getUntrackedParameter<double>("mtMin")),
73  mtMax_(cfg.getUntrackedParameter<double>("mtMax")),
74  acopCut_(cfg.getUntrackedParameter<double>("acopCut")),
75  dxyCut_(cfg.getUntrackedParameter<double>("DxyCut")) {
76  // just to initialize
77  isValidHltConfig_ = false;
78 
79  // dqm service & histograms
81  theDbe->setCurrentFolder("Physics/EwkMuLumiMonitorDQM");
83 }
84 
85 void EwkMuLumiMonitorDQM::beginRun(const Run& r, const EventSetup& iSetup) {
86  nall = 0;
87  nEvWithHighPtMu = 0;
88  nInKinRange = 0;
89  nsel = 0;
90  niso = 0;
91  nhlt = 0;
92  n1hlt = 0;
93  n2hlt = 0;
94  nNotIso = 0;
95  nGlbSta = 0;
96  nGlbTrk = 0;
97  nTMass = 0;
98  nW = 0;
99 
100  // passed as parameter to HLTConfigProvider::init(), not yet used
101  bool isConfigChanged = false;
102 
103  // isValidHltConfig_ used to short-circuit analyze() in case of problems
105  hltConfigProvider_.init(r, iSetup, trigTag_.process(), isConfigChanged);
106  // std::cout << "hlt config trigger is valid??" << isValidHltConfig_ <<
107  // std::endl;
108 }
109 
111 
113 
114  mass2HLT_ =
115  theDbe->book1D("Z_2HLT_MASS", "Z mass [GeV/c^{2}]", 200, 0., 200.);
116  mass1HLT_ =
117  theDbe->book1D("Z_1HLT_MASS", "Z mass [GeV/c^{2}]", 200, 0., 200.);
118  massNotIso_ =
119  theDbe->book1D("Z_NOTISO_MASS", "Z mass [GeV/c^{2}]", 200, 0., 200.);
120  massGlbSta_ =
121  theDbe->book1D("Z_GLBSTA_MASS", "Z mass [GeV/c^{2}]", 200, 0., 200.);
122  massGlbTrk_ =
123  theDbe->book1D("Z_GLBTRK_MASS", "Z mass [GeV/c^{2}]", 200, 0., 200.);
124  massIsBothGlbTrkThanW_ = theDbe->book1D("Z_ISBOTHGLBTRKTHANW_MASS",
125  "Z mass [GeV/c^{2}]", 200, 0., 200.);
126 
127  highMass2HLT_ = theDbe->book1D("Z_2HLT_HIGHMASS", "Z high mass [GeV/c^{2}]",
128  2000, 0., 2000.);
129  highMass1HLT_ = theDbe->book1D("Z_1HLT_HIGHMASS", "Z high mass [GeV/c^{2}]",
130  2000, 0., 2000.);
131  highMassNotIso_ = theDbe->book1D("Z_NOTISO_HIGHMASS",
132  "Z high mass [GeV/c^{2}]", 2000, 0., 2000.);
133  highMassGlbSta_ = theDbe->book1D("Z_GLBSTA_HIGHMASS",
134  "Z high mass [GeV/c^{2}]", 2000, 0., 2000.);
135  highMassGlbTrk_ = theDbe->book1D("Z_GLBTRK_HIGHMASS",
136  "Z high mass [GeV/c^{2}]", 2000, 0., 2000.);
138  theDbe->book1D("Z_ISBOTHGLBTRKTHANW_HIGHMASS", "Z high mass [GeV/c^{2}]",
139  2000, 0., 2000.);
140 
141  /*
142  highest_mupt2HLT_ = theDbe->book1D("HIGHEST_MU_PT_2HLT","Highest muon
143  p_{t}[GeV/c]",200,0.,200.);
144  highest_mupt1HLT_ = theDbe->book1D("HIGHEST_MU_PT_1HLT","Highest muon
145  p_{t}[GeV/c]",200,0.,200.);
146  highest_muptNotIso_ = theDbe->book1D("HIGHEST_MU_PT_NOTISO","Highest muon
147  p_{t}[GeV/c]",200,0.,200.);
148  highest_muptGlbSta_ = theDbe->book1D("HIGHEST_MU_PT_GLBSTA","Highest muon
149  p_{t}[GeV/c]",200,0.,200.);
150  highest_muptGlbTrk_ = theDbe->book1D("HIGHEST_MU_PT_GLBTRK","Highest muon
151  p_{t}[GeV/c]",200,0.,200.);
152 
153  lowest_mupt2HLT_ = theDbe->book1D("LOWEST_MU_PT_2HLT","Lowest muon p_{t}
154  [GeV/c]",200,0.,200.);
155  lowest_mupt1HLT_ = theDbe->book1D("LOWEST_MU_PT_1HLT","Lowest muon p_{t}
156  [GeV/c]",200,0.,200.);
157  lowest_muptNotIso_ = theDbe->book1D("LOWEST_MU_PT_NOTISO","Lowest muon p_{t}
158  [GeV/c]",200,0.,200.);
159  lowest_muptGlbSta_ = theDbe->book1D("LOWEST_MU_PT_GLBSTA","Lowest muon p_{t}
160  [GeV/c]",200,0.,200.);
161  lowest_muptGlbTrk_ = theDbe->book1D("LOWEST_MU_PT_GLBTRK","Lowest muon p_{t}
162  [GeV/c]",200,0.,200.);
163  */
164 
165  TMass_ = theDbe->book1D("TMASS", "Transverse mass [GeV]", 300, 0., 300.);
166 }
167 
169  double isovar = mu.isolationR03().sumPt;
170  if (isCombinedIso_) {
171  isovar += mu.isolationR03().emEt;
172  isovar += mu.isolationR03().hadEt;
173  }
174  if (isRelativeIso_) isovar /= mu.pt();
175  return isovar;
176 }
177 
180  Handle<CaloTowerCollection> calotower) {
181  double ptSum = 0;
182  for (size_t i = 0; i < tracks->size(); ++i) {
183  const reco::Track& elem = tracks->at(i);
184  double elemPt = elem.pt();
185  // same parameter used for muIsolation: dR [0.01, IsoCut03_], |dZ|<0.2,
186  // |d_r(xy)|<0.1
187  double elemVx = elem.vx();
188  double elemVy = elem.vy();
189  double elemD0 = sqrt(elemVx * elemVx + elemVy * elemVy);
190  if (elemD0 > 0.2) continue;
191  double dz = fabs(elem.vz() - tk.vz());
192  if (dz > 0.1) continue;
193  // evaluate only for tracks with pt>ptTreshold
194  if (elemPt < ptThreshold_) continue;
195  double dR = deltaR(elem.eta(), elem.phi(), tk.eta(), tk.phi());
196  // isolation in a cone with dR=0.3, and vetoing the track itself
197  if ((dR < 0.01) || (dR > 0.3)) continue;
198  ptSum += elemPt;
199  }
200  if (isCombinedIso_) {
201  // loop on clusters....
202  for (CaloTowerCollection::const_iterator it = calotower->begin();
203  it != calotower->end(); ++it) {
204  double dR = deltaR(it->eta(), it->phi(), tk.outerEta(), tk.outerPhi());
205  // veto value is 0.1 for towers....
206  if ((dR < 0.1) || (dR > 0.3)) continue;
207  ptSum += it->emEnergy();
208  ptSum += it->hadEnergy();
209  }
210  }
211  if (isRelativeIso_) ptSum /= tk.pt();
212  return ptSum;
213 }
214 
216  const reco::Muon& mu, const std::vector<reco::Particle>& HLTMu, double DR,
217  double DPtRel) {
218  size_t dim = HLTMu.size();
219  size_t nPass = 0;
220  if (dim == 0) return false;
221  for (size_t k = 0; k < dim; k++) {
222  if ((deltaR(HLTMu[k], mu) < DR) &&
223  (fabs(HLTMu[k].pt() - mu.pt()) / HLTMu[k].pt() < DPtRel)) {
224  nPass++;
225  }
226  }
227  return (nPass > 0);
228 }
229 
231 
233 
234  LogVerbatim("") << "\n>>>>>> Z/W SELECTION SUMMARY BEGIN >>>>>>>>>>>>>>>";
235  LogVerbatim("") << "Total numer of events analyzed: " << nall << " [events]";
236  LogVerbatim("") << "Total numer of events selected: " << nsel << " [events]";
237 
238  LogVerbatim("") << "Passing HLT criteria: " << nhlt << " [events] ";
239  LogVerbatim("") << "Passing 2 HLT match criteria: " << n2hlt
240  << " [events] ";
241  LogVerbatim("") << "Passing 1 HLT match criteria: " << n1hlt
242  << " [events] ";
243  LogVerbatim("") << "Passing Not Iso criteria: " << nNotIso
244  << " [events] ";
245  LogVerbatim("") << "Passing GlbSta criteria: " << nGlbSta
246  << " [events] ";
247  LogVerbatim("") << "Passing W criteria: " << nTMass << " [events] ";
248  LogVerbatim("") << ">>>>>> Z/W SELECTION SUMMARY END >>>>>>>>>>>>>>>\n";
249 }
250 
252  nall++;
253  bool hlt_sel = false;
254  double iso1 = -1;
255  double iso2 = -1;
256  bool isMu1Iso = false;
257  bool isMu2Iso = false;
258  bool singleTrigFlag1 = false;
259  bool singleTrigFlag2 = false;
260  isZGolden1HLT_ = false;
261  isZGolden2HLT_ = false;
262  isZGoldenNoIso_ = false;
263  isZGlbSta_ = false;
264  isZGlbTrk_ = false;
265  isW_ = false;
266  // Trigger
267  bool trigger_fired = false;
268 
270  if (!ev.getByToken(trigToken_, triggerResults)) {
271  // LogWarning("") << ">>> TRIGGER collection does not exist !!!";
272  return;
273  }
274 
275  ev.getByToken(trigToken_, triggerResults);
276  /*
277  const edm::TriggerNames & trigNames = ev.triggerNames(*triggerResults);
278 
279 
280  for (size_t i=0; i<triggerResults->size(); i++) {
281  std::string trigName = trigNames.triggerName(i);
282  //std::cout << " trigName == " << trigName << std::endl;
283  if ( trigName == hltPath_ && triggerResults->accept(i)) {
284  trigger_fired = true;
285  hlt_sel=true;
286  nhlt++;
287  }
288  }
289  */
290  // see the trigger single muon which are present
291  string lowestMuonUnprescaledTrig = "";
292  bool lowestMuonUnprescaledTrigFound = false;
293  const std::vector<std::string>& triggerNames =
295  for (size_t ts = 0; ts < triggerNames.size(); ts++) {
296  string trig = triggerNames[ts];
297  size_t f = trig.find("HLT_Mu");
298  if ((f != std::string::npos)) {
299  // std::cout << "single muon trigger present: " << trig << std::endl;
300  // See if the trigger is prescaled;
302  bool prescaled = false;
303  const unsigned int prescaleSize = hltConfigProvider_.prescaleSize();
304  for (unsigned int ps = 0; ps < prescaleSize; ps++) {
305  const unsigned int prescaleValue =
307  if (prescaleValue != 1) prescaled = true;
308  // std::cout<< " prescaleValue[" << ps << "] =" << prescaleValue
309  //<<std::endl;
310  }
311  if (!prescaled) {
312  // looking now for the lowest hlt path not prescaled, with name of the
313  // form HLT_MuX or HLTMuX_vY
314  for (unsigned int n = 9; n < 100; n++) {
315  string lowestTrig = "HLT_Mu";
316  string lowestTrigv0 = "copy";
317  std::stringstream out;
318  out << n;
319  std::string s = out.str();
320  lowestTrig.append(s);
321  lowestTrigv0 = lowestTrig;
322  for (unsigned int v = 1; v < 10; v++) {
323  lowestTrig.append("_v");
324  std::stringstream oout;
325  oout << v;
326  std::string ss = oout.str();
327  lowestTrig.append(ss);
328  if (trig == lowestTrig) lowestMuonUnprescaledTrig = trig;
329  if (trig == lowestTrig) lowestMuonUnprescaledTrigFound = true;
330  if (trig == lowestTrig) break;
331  }
332  if (lowestMuonUnprescaledTrigFound) break;
333 
334  lowestTrig = lowestTrigv0;
335  if (trig == lowestTrig) lowestMuonUnprescaledTrig = trig;
336  // if (trig==lowestTrig) {std::cout << " before break, lowestTrig
337  // lowest single muon trigger present unprescaled: " << lowestTrig <<
338  // std::endl; }
339  if (trig == lowestTrig) lowestMuonUnprescaledTrigFound = true;
340  if (trig == lowestTrig) break;
341  }
342  if (lowestMuonUnprescaledTrigFound) break;
343  }
344  }
345  }
346  // std::cout << "after break, lowest single muon trigger present unprescaled:
347  // " << lowestMuonUnprescaledTrig << std::endl;
348  unsigned int triggerIndex; // index of trigger path
349 
350  // See if event passed trigger paths
351  std::string hltPath_ = lowestMuonUnprescaledTrig;
352 
353  triggerIndex = hltConfigProvider_.triggerIndex(hltPath_);
354  if (triggerIndex < triggerResults->size())
355  trigger_fired = triggerResults->accept(triggerIndex);
356  std::string L3FilterName_ = "";
357  if (trigger_fired) {
358  const std::vector<std::string>& moduleLabs =
360  /*for (size_t k =0; k < moduleLabs.size()-1 ; k++){
361  std::cout << "moduleLabs[" << k << "] == " << moduleLabs[k] << std::endl;
362  }
363  */
364  // the l3 filter name is just the last module....
365  size_t moduleLabsSizeMinus2 = moduleLabs.size() - 2;
366  // std::cout<<"moduleLabs[" << moduleLabsSizeMinus2 << "]== "<<
367  // moduleLabs[moduleLabsSizeMinus2] << std::endl;
368 
369  L3FilterName_ = moduleLabs[moduleLabsSizeMinus2];
370  }
371 
372  edm::Handle<trigger::TriggerEvent> handleTriggerEvent;
373  LogTrace("") << ">>> Trigger bit: " << trigger_fired << " (" << hltPath_
374  << ")";
375  if (!ev.getByToken(trigEvToken_, handleTriggerEvent)) {
376  // LogWarning( "errorTriggerEventValid" ) << "trigger::TriggerEvent product
377  // with InputTag " << trigEv_.encode() << " not in event";
378  return;
379  }
380  ev.getByToken(trigEvToken_, handleTriggerEvent);
381  const trigger::TriggerObjectCollection& toc(handleTriggerEvent->getObjects());
382  size_t nMuHLT = 0;
383  std::vector<reco::Particle> HLTMuMatched;
384  for (size_t ia = 0; ia < handleTriggerEvent->sizeFilters(); ++ia) {
385  std::string fullname = handleTriggerEvent->filterTag(ia).encode();
386  // std::cout<< "fullname::== " << fullname<< std::endl;
388  size_t p = fullname.find_first_of(':');
389  if (p != std::string::npos) {
390  name = fullname.substr(0, p);
391  } else {
392  name = fullname;
393  }
394  if (&toc != 0) {
395  const trigger::Keys& k = handleTriggerEvent->filterKeys(ia);
396  for (trigger::Keys::const_iterator ki = k.begin(); ki != k.end(); ++ki) {
397  // looking at all the single muon l3 trigger present, for example
398  // hltSingleMu15L3Filtered15.....
399  if (name == L3FilterName_) {
400  // trigger_fired = true;
401  hlt_sel = true;
402  nhlt++;
403  HLTMuMatched.push_back(toc[*ki].particle());
404  nMuHLT++;
405  }
406  }
407  }
408  }
409 
410  // Beam spot
411  Handle<reco::BeamSpot> beamSpotHandle;
412  if (!ev.getByToken(beamSpotToken_, beamSpotHandle)) {
413  // LogWarning("") << ">>> No beam spot found !!!";
414  return;
415  }
416 
417  // looping on muon....
419  if (!ev.getByToken(muonToken_, muons)) {
420  // LogError("") << ">>> muon collection does not exist !!!";
421  return;
422  }
423 
424  ev.getByToken(muonToken_, muons);
425  // saving only muons with pt> ptMuCut and eta<etaMuCut, and dxy<dxyCut
426  std::vector<reco::Muon> highPtGlbMuons;
427  std::vector<reco::Muon> highPtStaMuons;
428 
429  for (size_t i = 0; i < muons->size(); i++) {
430  const reco::Muon& mu = muons->at(i);
431  double pt = mu.pt();
432  double eta = mu.eta();
433  if (pt > ptMuCut_ && fabs(eta) < etaMuCut_) {
434  if (mu.isGlobalMuon()) {
435  // check the dxy....
436  double dxy = mu.innerTrack()->dxy(beamSpotHandle->position());
437  if (fabs(dxy) > dxyCut_) continue;
438  highPtGlbMuons.push_back(mu);
439  }
440  if (mu.isGlobalMuon()) continue;
441  // if is not, look if it is a standalone....
442  if (mu.isStandAloneMuon()) highPtStaMuons.push_back(mu);
443  nEvWithHighPtMu++;
444  }
445  }
446  size_t nHighPtGlbMu = highPtGlbMuons.size();
447  size_t nHighPtStaMu = highPtStaMuons.size();
448  if (hlt_sel && (nHighPtGlbMu > 0)) {
449  // loop on high pt muons if there's at least two with opposite charge build
450  // a Z, more then one z candidate is foreseen.........
451  // stop the loop after 10 cicles....
452  (nHighPtGlbMu > 10) ? nHighPtGlbMu = 10 : 1;
453  // Z selection
454  if (nHighPtGlbMu > 1) {
455  for (unsigned int i = 0; i < nHighPtGlbMu; i++) {
456  reco::Muon muon1 = highPtGlbMuons[i];
457  math::XYZTLorentzVector mu1(muon1.p4());
458  // double pt1= muon1.pt();
459  for (unsigned int j = i + 1; j < nHighPtGlbMu; ++j) {
460  reco::Muon muon2 = highPtGlbMuons[j];
461  math::XYZTLorentzVector mu2(muon2.p4());
462  // double pt2= muon2.pt();
463  if (muon1.charge() == muon2.charge()) continue;
464  math::XYZTLorentzVector pair = mu1 + mu2;
465  double mass = pair.M();
466  // checking isolation and hlt maching
467  iso1 = muIso(muon1);
468  iso2 = muIso(muon2);
469  isMu1Iso = (iso1 < isoCut03_);
470  isMu2Iso = (iso2 < isoCut03_);
471  singleTrigFlag1 =
472  IsMuMatchedToHLTMu(muon1, HLTMuMatched, maxDeltaR_, maxDPtRel_);
473  singleTrigFlag2 =
474  IsMuMatchedToHLTMu(muon2, HLTMuMatched, maxDeltaR_, maxDPtRel_);
475  if (singleTrigFlag1 && singleTrigFlag2) isZGolden2HLT_ = true;
476  if ((singleTrigFlag1 && !singleTrigFlag2) ||
477  (!singleTrigFlag1 && singleTrigFlag2))
478  isZGolden1HLT_ = true;
479  // Z Golden passing all criteria, with 2 or 1 muon matched to an HLT
480  // muon. Using the two cathegories as a control sample for the HLT
481  // matching efficiency
483  // a Z golden has been found, let's remove the two muons from the
484  // list, dome for avoiding resolution effect enter muons in the
485  // standalone and tracker collections.........
486  highPtGlbMuons.erase(highPtGlbMuons.begin() + i);
487  highPtGlbMuons.erase(highPtGlbMuons.begin() + j);
488  // and updating the number of high pt muons....
489  nHighPtGlbMu = highPtGlbMuons.size();
490 
491  if (isMu1Iso && isMu2Iso) {
492  niso++;
493  if (isZGolden2HLT_) {
494  n2hlt++;
495  mass2HLT_->Fill(mass);
496  highMass2HLT_->Fill(mass);
497  /*
498  if (pt1 > pt2) {
499  highest_mupt2HLT_ -> Fill (pt1);
500  lowest_mupt2HLT_ -> Fill (pt2);
501  } else {
502  highest_mupt2HLT_ -> Fill (pt2);
503  lowest_mupt2HLT_ -> Fill (pt1);
504  }
505  */
506  }
507  if (isZGolden1HLT_) {
508  n1hlt++;
509  mass1HLT_->Fill(mass);
510  highMass1HLT_->Fill(mass);
511  /*
512  if (pt1 >pt2) {
513  highest_mupt1HLT_ -> Fill (pt1);
514  lowest_mupt1HLT_ -> Fill (pt2);
515  } else {
516  highest_mupt1HLT_ -> Fill (pt2);
517  lowest_mupt1HLT_ -> Fill (pt1);
518  }
519  */
520  }
521  } else {
522  // ZGlbGlb when at least one of the two muon is not isolated and
523  // at least one HLT matched, used as control sample for the
524  // isolation efficiency
525  // filling events with one muon not isolated and both hlt mathced
526  if (((isMu1Iso && !isMu2Iso) || (!isMu1Iso && isMu2Iso)) &&
528  isZGoldenNoIso_ = true;
529  nNotIso++;
530  massNotIso_->Fill(mass);
531  highMassNotIso_->Fill(mass);
532  }
533  /*
534  if (pt1 > pt2) {
535  highest_muptNotIso_ -> Fill (pt1);
536  lowest_muptNotIso_ -> Fill (pt2);
537  } else {
538  highest_muptNotIso_ -> Fill (pt2);
539  lowest_muptNotIso_ -> Fill (pt1);
540  }
541  */
542  }
543  }
544  }
545  }
546  }
547  // W->MuNu selection (if at least one muon has been selected)
548  // looking for a W if a Z is not found.... let's think if we prefer to
549  // exclude zMuMuNotIso or zMuSta....
550  if (!(isZGolden2HLT_ || isZGolden1HLT_)) {
551  Handle<View<MET> > metCollection;
552  if (!ev.getByToken(metToken_, metCollection)) {
553  // LogError("") << ">>> MET collection does not exist !!!";
554  return;
555  }
556  const MET& met = metCollection->at(0);
557  nW = 0;
558  for (unsigned int i = 0; i < nHighPtGlbMu; i++) {
559  reco::Muon muon1 = highPtGlbMuons[i];
560  /*
561  quality cut not implemented
562  Quality Cuts double dxy =
563 gm->dxy(beamSpotHandle->position());
564  Cut in 0.2 double trackerHits =
565 gm->hitPattern().numberOfValidTrackerHits();
566  Cut in 11 bool quality = fabs(dxy)<dxyCut_ &&
567 muon::isGoodMuon(mu,muon::GlobalMuonPromptTight) && trackerHits>=trackerHitsCut_
568 && mu.isTrackerMuon() ;
569 if (!quality) continue;
570  */
571  // isolation cut and hlt maching
572  iso1 = muIso(muon1);
573  isMu1Iso = (iso1 < isoCut03_);
574  if (!isMu1Iso) continue;
575  // checking if muon is matched to any HLT muon....
576  singleTrigFlag1 =
577  IsMuMatchedToHLTMu(muon1, HLTMuMatched, maxDeltaR_, maxDPtRel_);
578  if (!singleTrigFlag1) continue;
579  // std::cout << " is GlobMu macthecd to HLT: " << singleTrigFlag1 <<
580  // std::endl;
581  // MT cuts
582  double met_px = met.px();
583  double met_py = met.py();
584 
585  if (!metIncludesMuons_) {
586  for (unsigned int i = 0; i < nHighPtGlbMu; i++) {
587  reco::Muon muon1 = highPtGlbMuons[i];
588  met_px -= muon1.px();
589  met_py -= muon1.py();
590  }
591  }
592  double met_et = met.pt(); // sqrt(met_px*met_px+met_py*met_py);
593  LogTrace("") << ">>> MET, MET_px, MET_py: " << met_et << ", " << met_px
594  << ", " << met_py << " [GeV]";
595  double w_et = met_et + muon1.pt();
596  double w_px = met_px + muon1.px();
597  double w_py = met_py + muon1.py();
598  double massT = w_et * w_et - w_px * w_px - w_py * w_py;
599  massT = (massT > 0) ? sqrt(massT) : 0;
600  // Acoplanarity cuts
601  Geom::Phi<double> deltaphi(muon1.phi() - atan2(met_py, met_px));
602  double acop = M_PI - fabs(deltaphi.value());
603  // std::cout << " is acp of W candidate less then cut: " << (acop<
604  // acopCut_) << std::endl;
605  if (acop > acopCut_) continue; // Cut in 2.0
606  TMass_->Fill(massT);
607  if (massT < mtMin_ || massT > mtMax_) continue; // Cut in (50,200) GeV
608  // we give the number of W only in the tMass selected but we have a look
609  // at mass tails to check the QCD background
610  isW_ = true;
611  nW++;
612  nTMass++;
613  }
614  }
615  // if a zGlobal is not selected, look at the dimuonGlobalOneStandAlone and
616  // dimuonGlobalOneTrack...., used as a control sample for the tracking
617  // efficiency and muon system efficiency
619  for (unsigned int i = 0; i < nHighPtGlbMu; ++i) {
620  reco::Muon glbMuon = highPtGlbMuons[i];
621  math::XYZTLorentzVector mu1(glbMuon.p4());
622  // double pt1= glbMuon.pt();
623  // checking that the global muon is hlt matched otherwise skip the event
624  singleTrigFlag1 =
625  IsMuMatchedToHLTMu(glbMuon, HLTMuMatched, maxDeltaR_, maxDPtRel_);
626  if (!singleTrigFlag1) continue;
627  // checking that the global muon is isolated matched otherwise skip the
628  // event
629  iso1 = muIso(glbMuon);
630  isMu1Iso = (iso1 < isoCut03_);
631  if (!isMu1Iso) continue;
632  // look at the standalone muon ....
633  // stop the loop after 10 cicles....
634  (nHighPtStaMu > 10) ? nHighPtStaMu = 10 : 1;
635  for (unsigned int j = 0; j < nHighPtStaMu; ++j) {
636  reco::Muon staMuon = highPtStaMuons[j];
637  math::XYZTLorentzVector mu2(staMuon.p4());
638  // double pt2= staMuon.pt();
639  if (glbMuon.charge() == staMuon.charge()) continue;
640  math::XYZTLorentzVector pair = mu1 + mu2;
641  double mass = pair.M();
642  iso2 = muIso(staMuon);
643  isMu2Iso = (iso2 < isoCut03_);
644  LogTrace("") << "\t... isolation value" << iso1 << ", isolated? "
645  << isMu1Iso;
646  LogTrace("") << "\t... isolation value" << iso2 << ", isolated? "
647  << isMu2Iso;
648  // requiring theat the global mu is mathed to the HLT and both are
649  // isolated
650  if (isMu2Iso) {
651  isZGlbSta_ = true;
652  nGlbSta++;
653  massGlbSta_->Fill(mass);
654  highMassGlbSta_->Fill(mass);
655  /*
656  if (pt1 > pt2) {
657  highest_muptGlbSta_ -> Fill (pt1);
658  lowest_muptGlbSta_ -> Fill (pt2);
659  } else {
660  highest_muptGlbSta_ -> Fill (pt2);
661  lowest_muptGlbSta_ -> Fill (pt1);
662  }
663  */
664  }
665  }
666  // look at the tracks....
668  if (!ev.getByToken(trackToken_, tracks)) {
669  // LogError("") << ">>> track collection does not exist !!!";
670  return;
671  }
672  ev.getByToken(trackToken_, tracks);
673  Handle<CaloTowerCollection> calotower;
674  if (!ev.getByToken(caloTowerToken_, calotower)) {
675  // LogError("") << ">>> calotower collection does not exist !!!";
676  return;
677  }
678  ev.getByToken(caloTowerToken_, calotower);
679  // avoid to loop on more than 5000 trks
680  size_t nTrk = tracks->size();
681  (nTrk > 5000) ? nTrk = 5000 : 1;
682  for (unsigned int j = 0; j < nTrk; j++) {
683  const reco::Track& tk = tracks->at(j);
684  if (glbMuon.charge() == tk.charge()) continue;
685  double pt2 = tk.pt();
686  double eta = tk.eta();
687  double dxy = tk.dxy(beamSpotHandle->position());
688  if (pt2 < ptMuCut_ || fabs(eta) > etaMuCut_ || fabs(dxy) > dxyCut_)
689  continue;
690  // assuming that the track is a mu....
692  tk.px(), tk.py(), tk.pz(),
693  sqrt((tk.p() * tk.p()) + (0.10566 * 0.10566)));
694  math::XYZTLorentzVector pair = mu1 + mu2;
695  double mass = pair.M();
696  // now requiring that the tracks is isolated.......
697  iso2 = tkIso(tk, tracks, calotower);
698  isMu2Iso = (iso2 < isoCut03_);
699  // std::cout << "found a track with rel/comb iso: " << iso2
700  //<< std::endl;
701  if (isMu2Iso) {
702  isZGlbTrk_ = true;
703  nGlbTrk++;
704  massGlbTrk_->Fill(mass);
705  highMassGlbTrk_->Fill(mass);
706  if (!isW_) continue;
709  /*
710  if (pt1 > pt2) {
711  highest_muptGlbTrk_ -> Fill (pt1);
712  lowest_muptGlbTrk_ -> Fill (pt2);
713  } else {
714  highest_muptGlbTrk_ -> Fill (pt2);
715  lowest_muptGlbTrk_ -> Fill (pt1);
716  }
717  */
718  }
719  }
720  }
721  }
722  }
723  if ((hlt_sel || isZGolden2HLT_ || isZGolden1HLT_ || isZGoldenNoIso_ ||
724  isZGlbSta_ || isZGlbTrk_ || isW_)) {
725  nsel++;
726  LogTrace("") << ">>>> Event ACCEPTED";
727  } else {
728  LogTrace("") << ">>>> Event REJECTED";
729  }
730  return;
731 }
732 
733 // Local Variables:
734 // show-trailing-whitespace: t
735 // truncate-lines: t
736 // End:
MonitorElement * highMass1HLT_
double p() const
momentum vector magnitude
Definition: TrackBase.h:591
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:9
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:7
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
virtual void endRun(const edm::Run &, const edm::EventSetup &)
const std::vector< std::string > & triggerNames() const
names of trigger paths
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
std::vector< CaloTower >::const_iterator const_iterator
MonitorElement * highMassIsBothGlbTrkThanW_
bool isGlobalMuon() const
Definition: Muon.h:218
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:621
MonitorElement * highMassGlbTrk_
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
MonitorElement * massNotIso_
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:603
T eta() const
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
bool isStandAloneMuon() const
Definition: Muon.h:220
MonitorElement * highMassGlbSta_
EwkMuLumiMonitorDQM(const edm::ParameterSet &)
edm::EDGetTokenT< edm::TriggerResults > trigToken_
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
void Fill(long long x)
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
MonitorElement * mass1HLT_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
unsigned int prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:627
MonitorElement * massIsBothGlbTrkThanW_
MonitorElement * massGlbTrk_
bool IsMuMatchedToHLTMu(const reco::Muon &, const std::vector< reco::Particle > &, double, double)
double tkIso(const reco::Track &, edm::Handle< reco::TrackCollection >, edm::Handle< CaloTowerCollection >)
Definition: MET.h:42
T sqrt(T t)
Definition: SSEVec.h:48
double pt() const
track transverse momentum
Definition: TrackBase.h:597
float emEt
ecal sum-Et
Definition: MuonIsolation.h:8
edm::EDGetTokenT< CaloTowerCollection > caloTowerToken_
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
int j
Definition: DBlmapReader.cc:9
MonitorElement * highMassNotIso_
double f[11][100]
edm::EDGetTokenT< reco::TrackCollection > trackToken_
const int mu
Definition: Constants.h:22
static std::string const triggerResults
Definition: EdmProvDump.cc:41
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
#define LogTrace(id)
#define M_PI
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:615
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
int k[5][pyjets_maxn]
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
tuple out
Definition: dbtoconf.py:99
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:645
double outerEta() const
pseudorapidity of the momentum vector at the outermost hit position
Definition: Track.h:169
MonitorElement * massGlbSta_
tuple tracks
Definition: testEve_cfg.py:39
double muIso(const reco::Muon &)
virtual int charge() const GCC11_FINAL
electric charge
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
MonitorElement * TMass_
std::string const & process() const
Definition: InputTag.h:46
HLTConfigProvider hltConfigProvider_
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:639
tuple muons
Definition: patZpeak.py:38
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * mass2HLT_
edm::EDGetTokenT< trigger::TriggerEvent > trigEvToken_
unsigned int prescaleSize() const
MonitorElement * highMass2HLT_
int charge() const
track electric charge
Definition: TrackBase.h:543
virtual float pt() const GCC11_FINAL
transverse momentum
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:567
double outerPhi() const
azimuthal angle of the momentum vector at the outermost hit position
Definition: Track.h:164
tuple size
Write out results.
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:609
const MuonIsolation & isolationR03() const
Definition: Muon.h:158
Definition: Run.h:41
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:633