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