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