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