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 
32 using namespace edm;
33 using namespace std;
34 using namespace reco;
35 using namespace isodeposit;
36 
38  // Input collections
39  trigTag_(cfg.getUntrackedParameter<edm::InputTag> ("TrigTag", edm::InputTag("TriggerResults::HLT"))),
40  trigToken_(consumes<edm::TriggerResults>(trigTag_)),
41  trigEvToken_(consumes<trigger::TriggerEvent>(
42  cfg.getUntrackedParameter<edm::InputTag> ("triggerEvent"))),
43  beamSpotToken_(consumes<reco::BeamSpot>(
44  cfg.getUntrackedParameter<edm::InputTag> ("offlineBeamSpot", edm::InputTag("offlineBeamSpot")))),
45  muonToken_(consumes<edm::View<reco::Muon> >(
46  cfg.getUntrackedParameter<edm::InputTag>("muons"))),
47  trackToken_(consumes<reco::TrackCollection>(
48  cfg.getUntrackedParameter<edm::InputTag>("tracks"))),
49  caloTowerToken_(consumes<CaloTowerCollection>(
50  cfg.getUntrackedParameter<edm::InputTag>("calotower"))),
51  metToken_(consumes<edm::View<reco::MET> >(
52  cfg.getUntrackedParameter<edm::InputTag> ("metTag"))),
53  metIncludesMuons_(cfg.getUntrackedParameter<bool> ("METIncludesMuons")),
54  // Main cuts
55  // massMin_(cfg.getUntrackedParameter<double>("MtMin", 20.)),
56  // massMax_(cfg.getUntrackedParameter<double>("MtMax", 2000.))
57  // hltPath_(cfg.getUntrackedParameter<std::string> ("hltPath")) ,
58  // L3FilterName_(cfg.getUntrackedParameter<std::string> ("L3FilterName")),
59  ptMuCut_(cfg.getUntrackedParameter<double>("ptMuCut")),
60  etaMuCut_(cfg.getUntrackedParameter<double>("etaMuCut")),
61  isRelativeIso_(cfg.getUntrackedParameter<bool>("IsRelativeIso")),
62  isCombinedIso_(cfg.getUntrackedParameter<bool>("IsCombinedIso")),
63  isoCut03_(cfg.getUntrackedParameter<double>("IsoCut03")),
64  // deltaRTrk_(cfg.getUntrackedParameter<double>("deltaRTrk")),
65  ptThreshold_(cfg.getUntrackedParameter<double>("ptThreshold")),
66  //deltaRVetoTrk_(cfg.getUntrackedParameter<double>("deltaRVetoTrk")),
67  maxDPtRel_(cfg.getUntrackedParameter<double>("maxDPtRel")),
68  maxDeltaR_(cfg.getUntrackedParameter<double>("maxDeltaR")),
69  mtMin_(cfg.getUntrackedParameter<double>("mtMin")),
70  mtMax_(cfg.getUntrackedParameter<double>("mtMax")),
71  acopCut_(cfg.getUntrackedParameter<double>("acopCut")),
72  dxyCut_(cfg.getUntrackedParameter<double>("DxyCut")) {
73  // just to initialize
74  isValidHltConfig_ = false;
75 
76  // dqm service & histograms
78  theDbe->setCurrentFolder("Physics/EwkMuLumiMonitorDQM");
80 
81 }
82 
83 
84 
85 void EwkMuLumiMonitorDQM::beginRun(const Run& r, const EventSetup&iSetup) {
86  nall = 0;
88  nInKinRange= 0;
89  nsel = 0;
90  niso = 0;
91  nhlt =0;
92  n1hlt =0;
93  n2hlt =0;
94  nNotIso =0;
95  nGlbSta =0;
96  nGlbTrk =0;
97  nTMass =0;
98  nW=0;
99 
100  // passed as parameter to HLTConfigProvider::init(), not yet used
101  bool isConfigChanged = false;
102 
103  // isValidHltConfig_ used to short-circuit analyze() in case of problems
104  isValidHltConfig_ = hltConfigProvider_.init( r, iSetup, trigTag_.process(), isConfigChanged );
105  //std::cout << "hlt config trigger is valid??" << isValidHltConfig_ << std::endl;
106 
107  }
108 
109 
111 
112 }
113 
115 
116  mass2HLT_ = theDbe->book1D("Z_2HLT_MASS","Z mass [GeV/c^{2}]",200,0.,200.);
117  mass1HLT_ = theDbe->book1D("Z_1HLT_MASS","Z mass [GeV/c^{2}]",200,0.,200.);
118  massNotIso_ = theDbe->book1D("Z_NOTISO_MASS","Z mass [GeV/c^{2}]",200,0.,200.);
119  massGlbSta_ = theDbe->book1D("Z_GLBSTA_MASS","Z mass [GeV/c^{2}]",200,0.,200.);
120  massGlbTrk_ = theDbe->book1D("Z_GLBTRK_MASS","Z mass [GeV/c^{2}]",200,0.,200.);
121  massIsBothGlbTrkThanW_ = theDbe->book1D("Z_ISBOTHGLBTRKTHANW_MASS","Z mass [GeV/c^{2}]",200,0.,200.);
122 
123  highMass2HLT_ = theDbe->book1D("Z_2HLT_HIGHMASS","Z high mass [GeV/c^{2}]",2000,0.,2000.);
124  highMass1HLT_ = theDbe->book1D("Z_1HLT_HIGHMASS","Z high mass [GeV/c^{2}]",2000,0.,2000.);
125  highMassNotIso_ = theDbe->book1D("Z_NOTISO_HIGHMASS","Z high mass [GeV/c^{2}]",2000,0.,2000.);
126  highMassGlbSta_ = theDbe->book1D("Z_GLBSTA_HIGHMASS","Z high mass [GeV/c^{2}]",2000,0.,2000.);
127  highMassGlbTrk_ = theDbe->book1D("Z_GLBTRK_HIGHMASS","Z high mass [GeV/c^{2}]",2000,0.,2000.);
128  highMassIsBothGlbTrkThanW_ = theDbe->book1D("Z_ISBOTHGLBTRKTHANW_HIGHMASS","Z high mass [GeV/c^{2}]",2000,0.,2000.);
129 
130  /*
131  highest_mupt2HLT_ = theDbe->book1D("HIGHEST_MU_PT_2HLT","Highest muon p_{t}[GeV/c]",200,0.,200.);
132  highest_mupt1HLT_ = theDbe->book1D("HIGHEST_MU_PT_1HLT","Highest muon p_{t}[GeV/c]",200,0.,200.);
133  highest_muptNotIso_ = theDbe->book1D("HIGHEST_MU_PT_NOTISO","Highest muon p_{t}[GeV/c]",200,0.,200.);
134  highest_muptGlbSta_ = theDbe->book1D("HIGHEST_MU_PT_GLBSTA","Highest muon p_{t}[GeV/c]",200,0.,200.);
135  highest_muptGlbTrk_ = theDbe->book1D("HIGHEST_MU_PT_GLBTRK","Highest muon p_{t}[GeV/c]",200,0.,200.);
136 
137  lowest_mupt2HLT_ = theDbe->book1D("LOWEST_MU_PT_2HLT","Lowest muon p_{t} [GeV/c]",200,0.,200.);
138  lowest_mupt1HLT_ = theDbe->book1D("LOWEST_MU_PT_1HLT","Lowest muon p_{t} [GeV/c]",200,0.,200.);
139  lowest_muptNotIso_ = theDbe->book1D("LOWEST_MU_PT_NOTISO","Lowest muon p_{t} [GeV/c]",200,0.,200.);
140  lowest_muptGlbSta_ = theDbe->book1D("LOWEST_MU_PT_GLBSTA","Lowest muon p_{t} [GeV/c]",200,0.,200.);
141  lowest_muptGlbTrk_ = theDbe->book1D("LOWEST_MU_PT_GLBTRK","Lowest muon p_{t} [GeV/c]",200,0.,200.);
142  */
143 
144  TMass_ = theDbe->book1D("TMASS","Transverse mass [GeV]",300,0.,300.);
145 
146 }
147 
148 
149 
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, const 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 hlt_sel = false;
230  double iso1=-1;
231  double iso2=-1;
232  bool isMu1Iso = false;
233  bool isMu2Iso = false;
234  bool singleTrigFlag1 = false;
235  bool singleTrigFlag2 = false;
236  isZGolden1HLT_=false;
237  isZGolden2HLT_=false;
238  isZGoldenNoIso_=false;
239  isZGlbSta_=false;
240  isZGlbTrk_=false;
241  isW_=false;
242  // Trigger
243  bool trigger_fired = false;
244 
246  if (!ev.getByToken(trigToken_, triggerResults)) {
247  //LogWarning("") << ">>> TRIGGER collection does not exist !!!";
248  return;
249  }
250 
251  ev.getByToken(trigToken_, triggerResults);
252  /*
253  const edm::TriggerNames & trigNames = ev.triggerNames(*triggerResults);
254 
255 
256  for (size_t i=0; i<triggerResults->size(); i++) {
257  std::string trigName = trigNames.triggerName(i);
258  //std::cout << " trigName == " << trigName << std::endl;
259  if ( trigName == hltPath_ && triggerResults->accept(i)) {
260  trigger_fired = true;
261  hlt_sel=true;
262  nhlt++;
263  }
264  }
265  */
266  // see the trigger single muon which are present
267  string lowestMuonUnprescaledTrig = "";
268  bool lowestMuonUnprescaledTrigFound = false;
269  const std::vector<std::string>& triggerNames = hltConfigProvider_.triggerNames();
270  for (size_t ts = 0; ts< triggerNames.size() ; ts++){
271  string trig = triggerNames[ts];
272  size_t f = trig.find("HLT_Mu");
273  if ( (f != std::string::npos) ) {
274  // std::cout << "single muon trigger present: " << trig << std::endl;
275  // See if the trigger is prescaled;
277  bool prescaled = false;
278  const unsigned int prescaleSize = hltConfigProvider_.prescaleSize() ;
279  for (unsigned int ps= 0; ps< prescaleSize; ps++){
280  const unsigned int prescaleValue = hltConfigProvider_.prescaleValue(ps, trig) ;
281  if (prescaleValue != 1) prescaled =true;
282  // std::cout<< " prescaleValue[" << ps << "] =" << prescaleValue <<std::endl;
283  }
284  if (!prescaled){
285  //looking now for the lowest hlt path not prescaled, with name of the form HLT_MuX or HLTMuX_vY
286  for (unsigned int n=9; n<100 ; n++ ){
287  string lowestTrig= "HLT_Mu";
288  string lowestTrigv0 = "copy";
289  std::stringstream out;
290  out << n;
291  std::string s = out.str();
292  lowestTrig.append(s);
293  lowestTrigv0 = lowestTrig;
294  for (unsigned int v = 1; v<10 ; v++ ){
295  lowestTrig.append("_v");
296  std::stringstream oout;
297  oout << v;
298  std::string ss = oout.str();
299  lowestTrig.append(ss);
300  if (trig==lowestTrig) lowestMuonUnprescaledTrig = trig ;
301  if (trig==lowestTrig) lowestMuonUnprescaledTrigFound = true ;
302  if (trig==lowestTrig) break ;
303  }
304  if (lowestMuonUnprescaledTrigFound) break;
305 
306  lowestTrig = lowestTrigv0;
307  if (trig==lowestTrig) lowestMuonUnprescaledTrig = trig ;
308  // if (trig==lowestTrig) {std::cout << " before break, lowestTrig lowest single muon trigger present unprescaled: " << lowestTrig << std::endl; }
309  if (trig==lowestTrig) lowestMuonUnprescaledTrigFound = true ;
310  if (trig==lowestTrig) break ;
311  }
312  if (lowestMuonUnprescaledTrigFound) break;
313  }
314  }
315  }
316  // std::cout << "after break, lowest single muon trigger present unprescaled: " << lowestMuonUnprescaledTrig << std::endl;
317  unsigned int triggerIndex; // index of trigger path
318 
319  // See if event passed trigger paths
320  std::string hltPath_ = lowestMuonUnprescaledTrig;
321 
322  triggerIndex = hltConfigProvider_.triggerIndex(hltPath_);
323  if (triggerIndex < triggerResults->size()) trigger_fired = triggerResults->accept(triggerIndex);
324  std::string L3FilterName_="";
325  if (trigger_fired){
326  const std::vector<std::string>& moduleLabs = hltConfigProvider_.moduleLabels(hltPath_);
327  /*for (size_t k =0; k < moduleLabs.size()-1 ; k++){
328  std::cout << "moduleLabs[" << k << "] == " << moduleLabs[k] << std::endl;
329  }
330  */
331  // the l3 filter name is just the last module....
332  size_t moduleLabsSizeMinus2 = moduleLabs.size() - 2 ;
333  // std::cout<<"moduleLabs[" << moduleLabsSizeMinus2 << "]== "<< moduleLabs[moduleLabsSizeMinus2] << std::endl;
334 
335  L3FilterName_ = moduleLabs[moduleLabsSizeMinus2];
336 
337  }
338 
339 
340  edm::Handle< trigger::TriggerEvent > handleTriggerEvent;
341  LogTrace("") << ">>> Trigger bit: " << trigger_fired << " (" << hltPath_ << ")";
342  if ( ! ev.getByToken( trigEvToken_, handleTriggerEvent )) {
343  //LogWarning( "errorTriggerEventValid" ) << "trigger::TriggerEvent product with InputTag " << trigEv_.encode() << " not in event";
344  return;
345  }
346  ev.getByToken( trigEvToken_, handleTriggerEvent );
347  const trigger::TriggerObjectCollection & toc(handleTriggerEvent->getObjects());
348  size_t nMuHLT =0;
349  std::vector<reco::Particle> HLTMuMatched;
350  for ( size_t ia = 0; ia < handleTriggerEvent->sizeFilters(); ++ ia) {
351  std::string fullname = handleTriggerEvent->filterTag(ia).encode();
352  //std::cout<< "fullname::== " << fullname<< std::endl;
354  size_t p = fullname.find_first_of(':');
355  if ( p != std::string::npos) {
356  name = fullname.substr(0, p);
357  }
358  else {
359  name = fullname;
360  }
361  if ( &toc !=0 ) {
362  const trigger::Keys & k = handleTriggerEvent->filterKeys(ia);
363  for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
364  // looking at all the single muon l3 trigger present, for example hltSingleMu15L3Filtered15.....
365  if (name == L3FilterName_ ) {
366  // trigger_fired = true;
367  hlt_sel=true;
368  nhlt++;
369  HLTMuMatched.push_back(toc[*ki].particle());
370  nMuHLT++;
371  }
372  }
373  }
374  }
375 
376  // Beam spot
377  Handle<reco::BeamSpot> beamSpotHandle;
378  if (!ev.getByToken(beamSpotToken_, beamSpotHandle)) {
379  //LogWarning("") << ">>> No beam spot found !!!";
380  return;
381  }
382 
383 
384  // looping on muon....
386  if (!ev.getByToken(muonToken_, muons)) {
387  //LogError("") << ">>> muon collection does not exist !!!";
388  return;
389  }
390 
391  ev.getByToken(muonToken_, muons);
392  //saving only muons with pt> ptMuCut and eta<etaMuCut, and dxy<dxyCut
393  std::vector<reco::Muon> highPtGlbMuons;
394  std::vector<reco::Muon> highPtStaMuons;
395 
396  for (size_t i=0; i<muons->size(); i++ ){
397  const reco::Muon & mu = muons->at(i);
398  double pt = mu.pt();
399  double eta = mu.eta();
400  if (pt> ptMuCut_ && fabs(eta)< etaMuCut_ ) {
401  if (mu.isGlobalMuon()) {
402  //check the dxy....
403  double dxy = mu.innerTrack()->dxy(beamSpotHandle->position());
404  if (fabs(dxy)>dxyCut_) continue;
405  highPtGlbMuons.push_back(mu);
406  }
407  if (mu.isGlobalMuon()) continue;
408  // if is not, look if it is a standalone....
409  if(mu.isStandAloneMuon()) highPtStaMuons.push_back(mu);
410  nEvWithHighPtMu++;
411  }
412  }
413  size_t nHighPtGlbMu = highPtGlbMuons.size();
414  size_t nHighPtStaMu = highPtStaMuons.size();
415  if ( hlt_sel && (nHighPtGlbMu> 0) ) {
416  // loop on high pt muons if there's at least two with opposite charge build a Z, more then one z candidate is foreseen.........
417  // stop the loop after 10 cicles....
418  (nHighPtGlbMu> 10)? nHighPtGlbMu=10 : 1;
419  // Z selection
420  if (nHighPtGlbMu>1 ){
421  for(unsigned int i =0 ; i < nHighPtGlbMu ; i++) {
422  reco::Muon muon1 = highPtGlbMuons[i];
423  math::XYZTLorentzVector mu1(muon1.p4());
424  //double pt1= muon1.pt();
425  for (unsigned int j =i+1; j <nHighPtGlbMu ; ++j ){
426  reco::Muon muon2 = highPtGlbMuons[j];
427  math::XYZTLorentzVector mu2(muon2.p4());
428  //double pt2= muon2.pt();
429  if (muon1.charge() == muon2.charge()) continue;
430  math::XYZTLorentzVector pair = mu1 + mu2;
431  double mass = pair.M();
432  // checking isolation and hlt maching
433  iso1 = muIso ( muon1 );
434  iso2 = muIso ( muon2 );
435  isMu1Iso = (iso1 < isoCut03_);
436  isMu2Iso = (iso2 < isoCut03_);
437  singleTrigFlag1 = IsMuMatchedToHLTMu ( muon1, HLTMuMatched ,maxDeltaR_, maxDPtRel_ );
438  singleTrigFlag2 = IsMuMatchedToHLTMu ( muon2, HLTMuMatched ,maxDeltaR_, maxDPtRel_ );
439  if (singleTrigFlag1 && singleTrigFlag2) isZGolden2HLT_ = true;
440  if ( (singleTrigFlag1 && !singleTrigFlag2) || (!singleTrigFlag1 && singleTrigFlag2) ) isZGolden1HLT_ = true;
441  // 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
443  // 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.........
444  highPtGlbMuons.erase(highPtGlbMuons.begin() + i );
445  highPtGlbMuons.erase(highPtGlbMuons.begin() + j );
446  // and updating the number of high pt muons....
447  nHighPtGlbMu = highPtGlbMuons.size();
448 
449  if ( isMu1Iso && isMu2Iso ){
450  niso++;
451  if (isZGolden2HLT_) {
452  n2hlt++;
453  mass2HLT_->Fill(mass);
454  highMass2HLT_->Fill(mass);
455  /*
456  if (pt1 > pt2) {
457  highest_mupt2HLT_ -> Fill (pt1);
458  lowest_mupt2HLT_ -> Fill (pt2);
459  } else {
460  highest_mupt2HLT_ -> Fill (pt2);
461  lowest_mupt2HLT_ -> Fill (pt1);
462  }
463  */
464  }
465  if (isZGolden1HLT_) {
466  n1hlt++;
467  mass1HLT_->Fill(mass);
468  highMass1HLT_->Fill(mass);
469  /*
470  if (pt1 >pt2) {
471  highest_mupt1HLT_ -> Fill (pt1);
472  lowest_mupt1HLT_ -> Fill (pt2);
473  } else {
474  highest_mupt1HLT_ -> Fill (pt2);
475  lowest_mupt1HLT_ -> Fill (pt1);
476  }
477  */
478  }
479  } else {
480  // 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
481  // filling events with one muon not isolated and both hlt mathced
482  if (((isMu1Iso && !isMu2Iso) || (!isMu1Iso && isMu2Iso )) && (isZGolden2HLT_ && isZGolden1HLT_) ) {
483  isZGoldenNoIso_=true;
484  nNotIso++;
485  massNotIso_->Fill(mass);
486  highMassNotIso_->Fill(mass);
487  }
488  /*
489  if (pt1 > pt2) {
490  highest_muptNotIso_ -> Fill (pt1);
491  lowest_muptNotIso_ -> Fill (pt2);
492  } else {
493  highest_muptNotIso_ -> Fill (pt2);
494  lowest_muptNotIso_ -> Fill (pt1);
495  }
496  */
497  }
498  }
499  }
500  }
501  }
502 // W->MuNu selection (if at least one muon has been selected)
503  // looking for a W if a Z is not found.... let's think if we prefer to exclude zMuMuNotIso or zMuSta....
504  if ( !(isZGolden2HLT_ || isZGolden1HLT_ )){
505  Handle<View<MET> > metCollection;
506  if (!ev.getByToken(metToken_, metCollection)) {
507  //LogError("") << ">>> MET collection does not exist !!!";
508  return;
509  }
510  const MET& met = metCollection->at(0);
511  nW=0;
512  for(unsigned int i =0 ; i < nHighPtGlbMu ; i++) {
513  reco::Muon muon1 = highPtGlbMuons[i];
514  /*
515  quality cut not implemented
516  Quality Cuts double dxy = gm->dxy(beamSpotHandle->position());
517  Cut in 0.2 double trackerHits = gm->hitPattern().numberOfValidTrackerHits();
518  Cut in 11 bool quality = fabs(dxy)<dxyCut_ && muon::isGoodMuon(mu,muon::GlobalMuonPromptTight) && trackerHits>=trackerHitsCut_ && mu.isTrackerMuon() ;
519  if (!quality) continue;
520  */
521  // isolation cut and hlt maching
522  iso1 = muIso ( muon1 );
523  isMu1Iso = (iso1 < isoCut03_);
524  if (!isMu1Iso) continue;
525  // checking if muon is matched to any HLT muon....
526  singleTrigFlag1 = IsMuMatchedToHLTMu ( muon1, HLTMuMatched ,maxDeltaR_, maxDPtRel_ );
527  if (!singleTrigFlag1) continue;
528  //std::cout << " is GlobMu macthecd to HLT: " << singleTrigFlag1 << std::endl;
529  // MT cuts
530  double met_px = met.px();
531  double met_py = met.py();
532 
533  if (!metIncludesMuons_) {
534  for(unsigned int i =0 ; i < nHighPtGlbMu ; i++) {
535  reco::Muon muon1 = highPtGlbMuons[i];
536  met_px -= muon1.px();
537  met_py -= muon1.py();
538  }
539  }
540  double met_et = met.pt() ; //sqrt(met_px*met_px+met_py*met_py);
541  LogTrace("") << ">>> MET, MET_px, MET_py: " << met_et << ", " << met_px << ", " << met_py << " [GeV]";
542  double w_et = met_et+ muon1.pt();
543  double w_px = met_px+ muon1.px();
544  double w_py = met_py+muon1.py();
545  double massT = w_et*w_et - w_px*w_px - w_py*w_py;
546  massT = (massT>0) ? sqrt(massT) : 0;
547  // Acoplanarity cuts
548  Geom::Phi<double> deltaphi(muon1.phi()-atan2(met_py,met_px));
549  double acop = M_PI - fabs(deltaphi.value());
550  //std::cout << " is acp of W candidate less then cut: " << (acop< acopCut_) << std::endl;
551  if (acop > acopCut_) continue ; // Cut in 2.0
552  TMass_->Fill(massT);
553  if (massT<mtMin_ || massT>mtMax_) continue; // Cut in (50,200) GeV
554  // we give the number of W only in the tMass selected but we have a look at mass tails to check the QCD background
555  isW_=true;
556  nW++;
557  nTMass++;
558  }
559  }
560 // 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
562  for(unsigned int i =0 ; i < nHighPtGlbMu ; ++i) {
563  reco::Muon glbMuon = highPtGlbMuons[i];
564  math::XYZTLorentzVector mu1(glbMuon.p4());
565  //double pt1= glbMuon.pt();
566  // checking that the global muon is hlt matched otherwise skip the event
567  singleTrigFlag1 = IsMuMatchedToHLTMu ( glbMuon, HLTMuMatched ,maxDeltaR_, maxDPtRel_ );
568  if (!singleTrigFlag1) continue;
569  // checking that the global muon is isolated matched otherwise skip the event
570  iso1 = muIso ( glbMuon );
571  isMu1Iso = (iso1 < isoCut03_);
572  if (!isMu1Iso) continue;
573  // look at the standalone muon ....
574  // stop the loop after 10 cicles....
575  (nHighPtStaMu> 10)? nHighPtStaMu=10 : 1;
576  for (unsigned int j =0; j <nHighPtStaMu ; ++j ){
577  reco::Muon staMuon = highPtStaMuons[j];
578  math::XYZTLorentzVector mu2(staMuon.p4());
579  //double pt2= staMuon.pt();
580  if (glbMuon.charge() == staMuon.charge()) 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 isolated
588  if (isMu2Iso ) {
589  isZGlbSta_=true;
590  nGlbSta++;
591  massGlbSta_->Fill(mass);
592  highMassGlbSta_->Fill(mass);
593  /*
594  if (pt1 > pt2) {
595  highest_muptGlbSta_ -> Fill (pt1);
596  lowest_muptGlbSta_ -> Fill (pt2);
597  } else {
598  highest_muptGlbSta_ -> Fill (pt2);
599  lowest_muptGlbSta_ -> Fill (pt1);
600  }
601  */
602  }
603  }
604  // look at the tracks....
606  if (!ev.getByToken(trackToken_, tracks)) {
607  //LogError("") << ">>> track collection does not exist !!!";
608  return;
609  }
610  ev.getByToken(trackToken_, tracks);
612  if (!ev.getByToken(caloTowerToken_, calotower)) {
613  //LogError("") << ">>> calotower collection does not exist !!!";
614  return;
615  }
616  ev.getByToken(caloTowerToken_, calotower);
617  // avoid to loop on more than 5000 trks
618  size_t nTrk = tracks->size();
619  (nTrk> 5000)? nTrk=5000 : 1;
620  for (unsigned int j=0; j<nTrk; j++ ){
621  const reco::Track & tk = tracks->at(j);
622  if (glbMuon.charge() == tk.charge()) continue;
623  double pt2 = tk.pt();
624  double eta = tk.eta();
625  double dxy = tk.dxy(beamSpotHandle->position());
626  if (pt2< ptMuCut_ || fabs(eta) > etaMuCut_ || fabs(dxy)>dxyCut_) continue;
627  //assuming that the track is a mu....
628  math::XYZTLorentzVector mu2(tk.px(),tk.py(), tk.pz(), sqrt( (tk.p() * tk.p()) + ( 0.10566 * 0.10566))) ;
629  math::XYZTLorentzVector pair = mu1 + mu2;
630  double mass = pair.M();
631  // now requiring that the tracks is isolated.......
632  iso2 = tkIso( tk, tracks, calotower);
633  isMu2Iso = (iso2 < isoCut03_);
634  // std::cout << "found a track with rel/comb iso: " << iso2 << std::endl;
635  if (isMu2Iso) {
636  isZGlbTrk_=true;
637  nGlbTrk++;
638  massGlbTrk_->Fill(mass);
639  highMassGlbTrk_->Fill(mass);
640  if (!isW_) continue;
643  /*
644  if (pt1 > pt2) {
645  highest_muptGlbTrk_ -> Fill (pt1);
646  lowest_muptGlbTrk_ -> Fill (pt2);
647  } else {
648  highest_muptGlbTrk_ -> Fill (pt2);
649  lowest_muptGlbTrk_ -> Fill (pt1);
650  }
651  */
652  }
653  }
654  }
655  }
656  }
657  if ( (hlt_sel || isZGolden2HLT_ || isZGolden1HLT_ || isZGoldenNoIso_ || isZGlbSta_ || isZGlbTrk_ || isW_) ) {
658  nsel++;
659  LogTrace("") << ">>>> Event ACCEPTED";
660  } else {
661  LogTrace("") << ">>>> Event REJECTED";
662  }
663  return;
664 }
665 
666 // Local Variables:
667 // show-trailing-whitespace: t
668 // truncate-lines: t
669 // End:
MonitorElement * highMass1HLT_
double p() const
momentum vector magnitude
Definition: TrackBase.h:127
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:9
int i
Definition: DBlmapReader.cc:9
tuple met
____________________________________________________________________________||
Definition: CaloMET_cfi.py:4
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
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:942
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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:10
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:137
MonitorElement * highMassGlbTrk_
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
MonitorElement * massNotIso_
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:131
T eta() const
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
bool isStandAloneMuon() const
Definition: Muon.h:220
MonitorElement * highMassGlbSta_
EwkMuLumiMonitorDQM(const edm::ParameterSet &)
edm::EDGetTokenT< edm::TriggerResults > trigToken_
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
void Fill(long long x)
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
MonitorElement * mass1HLT_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
unsigned int prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:139
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:39
T sqrt(T t)
Definition: SSEVec.h:48
double pt() const
track transverse momentum
Definition: TrackBase.h:129
float emEt
ecal sum-Et
Definition: MuonIsolation.h:8
edm::EDGetTokenT< CaloTowerCollection > caloTowerToken_
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
int j
Definition: DBlmapReader.cc:9
MonitorElement * highMassNotIso_
double f[11][100]
edm::EDGetTokenT< reco::TrackCollection > trackToken_
const int mu
Definition: Constants.h:22
static std::string const triggerResults
Definition: EdmProvDump.cc:41
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
#define LogTrace(id)
#define M_PI
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:135
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
int k[5][pyjets_maxn]
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
tuple out
Definition: dbtoconf.py:99
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:145
double outerEta() const
pseudorapidity of the momentum vector at the outermost hit position
Definition: Track.h:89
MonitorElement * massGlbSta_
tuple tracks
Definition: testEve_cfg.py:39
double muIso(const reco::Muon &)
virtual int charge() const GCC11_FINAL
electric charge
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
MonitorElement * TMass_
std::string const & process() const
Definition: InputTag.h:46
HLTConfigProvider hltConfigProvider_
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:143
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:111
virtual float pt() const GCC11_FINAL
transverse momentum
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:119
double outerPhi() const
azimuthal angle of the momentum vector at the outermost hit position
Definition: Track.h:87
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:133
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:141