CMS 3D CMS Logo

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