CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZMuMu_MCanalyzer.cc
Go to the documentation of this file.
1 /* \class ZMuMu_MCanalyzer
2  *
3  * author: Davide Piccolo
4  *
5  * ZMuMu MC analyzer:
6  * check muon reco efficiencies from MC truth,
7  *
8  */
9 
36 
37 
38 
39 
40 #include "TH1.h"
41 #include "TH2.h"
42 #include "TH3.h"
43 #include <vector>
44 using namespace edm;
45 using namespace std;
46 using namespace reco;
47 using namespace reco;
48 using namespace isodeposit;
49 
50 
52 public:
54 private:
55  virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
56  bool check_ifZmumu(const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
57  float getParticlePt(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
58  float getParticleEta(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
59  float getParticlePhi(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
60  Particle::LorentzVector getParticleP4(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
61  virtual void endJob() override;
62 
66  edm::InputTag muons_, muonMatchMap_, muonIso_;
67  edm::InputTag tracks_, trackIso_;
69 
70  bool bothMuons_;
71 
72  double etamin_, etamax_, ptmin_, massMin_, massMax_, isoMax_;
73 
74  double ptThreshold_, etEcalThreshold_, etHcalThreshold_ ,dRVetoTrk_, dRTrk_, dREcal_ , dRHcal_, alpha_, beta_;
75 
77  string hltPath_;
78  reco::CandidateBaseRef globalMuonCandRef_, trackMuonCandRef_, standAloneMuonCandRef_;
80 
81  // general histograms
82  TH1D *h_trackProbe_eta, *h_trackProbe_pt, *h_staProbe_eta, *h_staProbe_pt, *h_ProbeOk_eta, *h_ProbeOk_pt;
83 
84  // global counters
85  int nGlobalMuonsMatched_passed; // total number of global muons MC matched and passing cuts (and triggered)
86  int nGlobalMuonsMatched_passedIso; // total number of global muons MC matched and passing cuts including Iso
87  int n2GlobalMuonsMatched_passedIso; // total number of Z->2 global muons MC matched and passing cuts including Iso
88  int nStaMuonsMatched_passedIso; // total number of sta only muons MC matched and passing cuts including Iso
89  int nTracksMuonsMatched_passedIso; // total number of tracks only muons MC matched and passing cuts including Iso
90  int n2GlobalMuonsMatched_passedIso2Trg; // total number of Z->2 global muons MC matched and passing cuts including Iso and both triggered
91  int nMu0onlyTriggered; // n. of events zMuMu with mu0 only triggered
92  int nMu1onlyTriggered; // n. of events zMuMu with mu1 only triggered
93 
94  int nZMuMu_matched; // n. of events zMuMu macthed
95  int nZMuSta_matched; // n of events zMuSta macthed
96  int nZMuTrk_matched; // n. of events zMuTrk mathced
97 };
98 
99 
100 template<typename T>
101 double isolation(const T * t, double ptThreshold, double etEcalThreshold, double etHcalThreshold , double dRVetoTrk, double dRTrk, double dREcal , double dRHcal, double alpha, double beta, bool relativeIsolation) {
102  // on 34X:
103  const pat::IsoDeposit * trkIso = t->isoDeposit(pat::TrackIso);
104  // const pat::IsoDeposit * trkIso = t->trackerIsoDeposit();
105  // on 34X
106  const pat::IsoDeposit * ecalIso = t->isoDeposit(pat::EcalIso);
107  // const pat::IsoDeposit * ecalIso = t->ecalIsoDeposit();
108  // on 34X
109  const pat::IsoDeposit * hcalIso = t->isoDeposit(pat::HcalIso);
110  // const pat::IsoDeposit * hcalIso = t->hcalIsoDeposit();
111 
112  Direction dir = Direction(t->eta(), t->phi());
113 
114  pat::IsoDeposit::AbsVetos vetosTrk;
115  vetosTrk.push_back(new ConeVeto( dir, dRVetoTrk ));
116  vetosTrk.push_back(new ThresholdVeto( ptThreshold ));
117 
118  pat::IsoDeposit::AbsVetos vetosEcal;
119  vetosEcal.push_back(new ConeVeto( dir, 0.));
120  vetosEcal.push_back(new ThresholdVeto( etEcalThreshold ));
121 
122  pat::IsoDeposit::AbsVetos vetosHcal;
123  vetosHcal.push_back(new ConeVeto( dir, 0. ));
124  vetosHcal.push_back(new ThresholdVeto( etHcalThreshold ));
125 
126  double isovalueTrk = (trkIso->sumWithin(dRTrk,vetosTrk));
127  double isovalueEcal = (ecalIso->sumWithin(dREcal,vetosEcal));
128  double isovalueHcal = (hcalIso->sumWithin(dRHcal,vetosHcal));
129 
130 
131  double iso = alpha*( ((1+beta)/2*isovalueEcal) + ((1-beta)/2*isovalueHcal) ) + ((1-alpha)*isovalueTrk) ;
132  if(relativeIsolation) iso /= t->pt();
133  return iso;
134 }
135 
136 
137 double candidateIsolation( const reco::Candidate* c, double ptThreshold, double etEcalThreshold, double etHcalThreshold , double dRVetoTrk, double dRTrk, double dREcal , double dRHcal, double alpha, double beta, bool relativeIsolation) {
138  const pat::Muon * mu = dynamic_cast<const pat::Muon *>(&*c->masterClone());
139  if(mu != 0) return isolation(mu, ptThreshold, etEcalThreshold, etHcalThreshold ,dRVetoTrk, dRTrk, dREcal , dRHcal, alpha, beta, relativeIsolation);
140  const pat::GenericParticle * trk = dynamic_cast<const pat::GenericParticle*>(&*c->masterClone());
141  if(trk != 0) return isolation(trk, ptThreshold, etEcalThreshold, etHcalThreshold ,dRVetoTrk, dRTrk, dREcal ,
142  dRHcal, alpha, beta, relativeIsolation);
144  << "Candidate daughter #0 is neither pat::Muons nor pat::GenericParticle\n";
145  return -1;
146 }
147 
148 
149 
150 
161 #include <iostream>
162 #include <iterator>
163 #include <cmath>
164 using namespace std;
165 using namespace reco;
166 using namespace edm;
167 
168 
170 
172  zMuMu_(pset.getParameter<InputTag>("zMuMu")),
173  zMuMuMatchMap_(pset.getParameter<InputTag>("zMuMuMatchMap")),
174  zMuStandAlone_(pset.getParameter<InputTag>("zMuStandAlone")),
175  zMuStandAloneMatchMap_(pset.getParameter<InputTag>("zMuStandAloneMatchMap")),
176  zMuTrack_(pset.getParameter<InputTag>("zMuTrack")),
177  zMuTrackMatchMap_(pset.getParameter<InputTag>("zMuTrackMatchMap")),
178  muons_(pset.getParameter<InputTag>("muons")),
179  tracks_(pset.getParameter<InputTag>("tracks")),
180  genParticles_(pset.getParameter<InputTag>( "genParticles" ) ),
181 
182  bothMuons_(pset.getParameter<bool>("bothMuons")),
183  etamin_(pset.getUntrackedParameter<double>("etamin")),
184  etamax_(pset.getUntrackedParameter<double>("etamax")),
185  ptmin_(pset.getUntrackedParameter<double>("ptmin")),
186  massMin_(pset.getUntrackedParameter<double>("zMassMin")),
187  massMax_(pset.getUntrackedParameter<double>("zMassMax")),
188  isoMax_(pset.getUntrackedParameter<double>("isomax")),
189  ptThreshold_(pset.getUntrackedParameter<double>("ptThreshold")),
190  etEcalThreshold_(pset.getUntrackedParameter<double>("etEcalThreshold")),
191  etHcalThreshold_(pset.getUntrackedParameter<double>("etHcalThreshold")),
192  dRVetoTrk_(pset.getUntrackedParameter<double>("deltaRVetoTrk")),
193  dRTrk_(pset.getUntrackedParameter<double>("deltaRTrk")),
194  dREcal_(pset.getUntrackedParameter<double>("deltaREcal")),
195  dRHcal_(pset.getUntrackedParameter<double>("deltaRHcal")),
196  alpha_(pset.getUntrackedParameter<double>("alpha")),
197  beta_(pset.getUntrackedParameter<double>("beta")),
198  relativeIsolation_(pset.getUntrackedParameter<bool>("relativeIsolation")),
199  hltPath_(pset.getUntrackedParameter<std::string >("hltPath")) {
201 
202  // binning of entries array (at moment defined by hand and not in cfg file)
203  double etaRange[8] = {-2.5,-2.,-1.2,-0.8,0.8,1.2,2.,2.5};
204  double ptRange[4] = {20.,40.,60.,100.};
205 
206  // general histograms
207  h_trackProbe_eta = fs->make<TH1D>("trackProbeEta","Eta of tracks",7,etaRange);
208  h_trackProbe_pt = fs->make<TH1D>("trackProbePt","Pt of tracks",3,ptRange);
209  h_staProbe_eta = fs->make<TH1D>("standAloneProbeEta","Eta of standAlone",7,etaRange);
210  h_staProbe_pt = fs->make<TH1D>("standAloneProbePt","Pt of standAlone",3,ptRange);
211  h_ProbeOk_eta = fs->make<TH1D>("probeOkEta","Eta of probe Ok",7,etaRange);
212  h_ProbeOk_pt = fs->make<TH1D>("probeOkPt","Pt of probe ok",3,ptRange);
213 
214  // clear global counters
221  nMu0onlyTriggered = 0;
222  nMu1onlyTriggered = 0;
223  nZMuMu_matched = 0;
224  nZMuSta_matched = 0;
225  nZMuTrk_matched = 0;
226 }
227 
230  Handle<GenParticleMatch> zMuMuMatchMap; //Map of Z made by Mu global + Mu global
231  Handle<CandidateView> zMuStandAlone;
232  Handle<GenParticleMatch> zMuStandAloneMatchMap; //Map of Z made by Mu + StandAlone
233  Handle<CandidateView> zMuTrack;
234  Handle<GenParticleMatch> zMuTrackMatchMap; //Map of Z made by Mu + Track
235  Handle<CandidateView> muons; //Collection of Muons
236  Handle<CandidateView> tracks; //Collection of Tracks
237 
238  Handle<GenParticleCollection> genParticles; // Collection of Generatd Particles
239 
240  event.getByLabel(zMuMu_, zMuMu);
241  event.getByLabel(zMuStandAlone_, zMuStandAlone);
242  event.getByLabel(zMuTrack_, zMuTrack);
243  event.getByLabel(genParticles_, genParticles);
244  event.getByLabel(muons_, muons);
245  event.getByLabel(tracks_, tracks);
246 
247  /*
248  cout << "********* zMuMu size : " << zMuMu->size() << endl;
249  cout << "********* zMuStandAlone size : " << zMuStandAlone->size() << endl;
250  cout << "********* zMuTrack size : " << zMuTrack->size() << endl;
251  cout << "********* muons size : " << muons->size() << endl;
252  cout << "********* tracks size : " << tracks->size() << endl;
253  */
254  // std::cout<<"Run-> "<<event.id().run()<<std::endl;
255  // std::cout<<"Event-> "<<event.id().event()<<std::endl;
256 
257 
258  bool zMuMu_found = false;
259 
260  // loop on ZMuMu
261  if (zMuMu->size() > 0 ) {
262  event.getByLabel(zMuMuMatchMap_, zMuMuMatchMap);
263  for(unsigned int i = 0; i < zMuMu->size(); ++i) { //loop on candidates
264  const Candidate & zMuMuCand = (*zMuMu)[i]; //the candidate
265  CandidateBaseRef zMuMuCandRef = zMuMu->refAt(i);
266 
267  const Candidate * lep0 = zMuMuCand.daughter( 0 );
268  const Candidate * lep1 = zMuMuCand.daughter( 1 );
269  const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
270  // double trkiso0 = muonDau0.trackIso();
271  const pat::Muon & muonDau1 = dynamic_cast<const pat::Muon &>(*lep1->masterClone());
272  //double trkiso1 = muonDau1.trackIso();
273 
276 
277  double pt0 = zMuMuCand.daughter(0)->pt();
278  double pt1 = zMuMuCand.daughter(1)->pt();
279  double eta0 = zMuMuCand.daughter(0)->eta();
280  double eta1 = zMuMuCand.daughter(1)->eta();
281  double mass = zMuMuCand.mass();
282 
283  // HLT match
284  const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
286  const pat::TriggerObjectStandAloneCollection mu1HLTMatches =
288 
289  bool trig0found = false;
290  bool trig1found = false;
291  if( mu0HLTMatches.size()>0 )
292  trig0found = true;
293  if( mu1HLTMatches.size()>0 )
294  trig1found = true;
295 
296  GenParticleRef zMuMuMatch = (*zMuMuMatchMap)[zMuMuCandRef];
297  if(zMuMuMatch.isNonnull()) { // ZMuMu matched
298  zMuMu_found = true;
299  nZMuMu_matched++;
300  if (pt0>ptmin_ && pt1>ptmin_ && abs(eta0)>etamin_ && abs(eta1) >etamin_ && abs(eta0)<etamax_ && abs(eta1) <etamax_ && mass >massMin_ && mass < massMax_ && (trig0found || trig1found)) { // kinematic and trigger cuts passed
301  nGlobalMuonsMatched_passed++; // first global Muon passed kine cuts
302  nGlobalMuonsMatched_passed++; // second global muon passsed kine cuts
303  if (iso0<isoMax_) nGlobalMuonsMatched_passedIso++; // first global muon passed the iso cut
304  if (iso1<isoMax_) nGlobalMuonsMatched_passedIso++; // second global muon passed the iso cut
305  if (iso0<isoMax_ && iso1<isoMax_) {
306  n2GlobalMuonsMatched_passedIso++; // both muons passed iso cut
307  if (trig0found && trig1found) n2GlobalMuonsMatched_passedIso2Trg++; // both muons have HLT
308  if (trig0found && !trig1found) nMu0onlyTriggered++;
309  if (trig1found && !trig0found) nMu1onlyTriggered++;
310  // histograms vs eta and pt
311  if (trig1found) { // check efficiency of muon0 not imposing the trigger on it
312  h_trackProbe_eta->Fill(eta0);
313  h_trackProbe_pt->Fill(pt0);
314  h_staProbe_eta->Fill(eta0);
315  h_staProbe_pt->Fill(pt0);
316  h_ProbeOk_eta->Fill(eta0);
317  h_ProbeOk_pt->Fill(pt0);
318  }
319  if (trig0found) { // check efficiency of muon1 not imposing the trigger on it
320  h_trackProbe_eta->Fill(eta1);
321  h_staProbe_eta->Fill(eta1);
322  h_trackProbe_pt->Fill(pt1);
323  h_staProbe_pt->Fill(pt1);
324  h_ProbeOk_eta->Fill(eta1);
325  h_ProbeOk_pt->Fill(pt1);
326  }
327  }
328  }
329  } // end MC match
330 
331  } // end loop on ZMuMu cand
332  } // end if ZMuMu size > 0
333 
334  // loop on ZMuSta
335  bool zMuSta_found = false;
336  if (!zMuMu_found && zMuStandAlone->size() > 0 ) {
337  event.getByLabel(zMuStandAloneMatchMap_, zMuStandAloneMatchMap);
338  for(unsigned int i = 0; i < zMuStandAlone->size(); ++i) { //loop on candidates
339  const Candidate & zMuStandAloneCand = (*zMuStandAlone)[i]; //the candidate
340  CandidateBaseRef zMuStandAloneCandRef = zMuStandAlone->refAt(i);
341  GenParticleRef zMuStandAloneMatch = (*zMuStandAloneMatchMap)[zMuStandAloneCandRef];
342 
343  const Candidate * lep0 = zMuStandAloneCand.daughter( 0 );
344  const Candidate * lep1 = zMuStandAloneCand.daughter( 1 );
345  const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
346  //double trkiso0 = muonDau0.trackIso();
347  // const pat::Muon & muonDau1 = dynamic_cast<const pat::Muon &>(*lep1->masterClone());
348  //double trkiso1 = muonDau1.trackIso();
349 
352 
353  double pt0 = zMuStandAloneCand.daughter(0)->pt();
354  double pt1 = zMuStandAloneCand.daughter(1)->pt();
355  double eta0 = zMuStandAloneCand.daughter(0)->eta();
356  double eta1 = zMuStandAloneCand.daughter(1)->eta();
357  double mass = zMuStandAloneCand.mass();
358 
359  // HLT match (check just dau0 the global)
360  const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
362 
363  bool trig0found = false;
364  if( mu0HLTMatches.size()>0 )
365  trig0found = true;
366 
367  if(zMuStandAloneMatch.isNonnull()) { // ZMuStandAlone matched
368  zMuSta_found = true;
369  nZMuSta_matched++;
370  if (pt0>ptmin_ && pt1>ptmin_ && abs(eta0)>etamin_ && abs(eta1)>etamin_ && abs(eta0)<etamax_ && abs(eta1) <etamax_ && mass >massMin_ &&
371  mass < massMax_ && iso0<isoMax_ && iso1 < isoMax_ && trig0found) { // all cuts and trigger passed
373  // histograms vs eta and pt
374  h_staProbe_eta->Fill(eta1);
375  h_staProbe_pt->Fill(pt1);
376  }
377  } // end MC match
378  } // end loop on ZMuStandAlone cand
379  } // end if ZMuStandAlone size > 0
380 
381 
382  // loop on ZMuTrack
383  if (!zMuMu_found && !zMuSta_found && zMuTrack->size() > 0 ) {
384  event.getByLabel(zMuTrackMatchMap_, zMuTrackMatchMap);
385  for(unsigned int i = 0; i < zMuTrack->size(); ++i) { //loop on candidates
386  const Candidate & zMuTrackCand = (*zMuTrack)[i]; //the candidate
387  CandidateBaseRef zMuTrackCandRef = zMuTrack->refAt(i);
388  const Candidate * lep0 = zMuTrackCand.daughter( 0 );
389  const Candidate * lep1 = zMuTrackCand.daughter( 1 );
390  const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
391  //double trkiso0 = muonDau0.trackIso();
392  //const pat::GenericParticle & trackDau1 = dynamic_cast<const pat::GenericParticle &>(*lep1->masterClone());
393  //double trkiso1 = trackDau1.trackIso();
396 
397 
398  double pt0 = zMuTrackCand.daughter(0)->pt();
399  double pt1 = zMuTrackCand.daughter(1)->pt();
400  double eta0 = zMuTrackCand.daughter(0)->eta();
401  double eta1 = zMuTrackCand.daughter(1)->eta();
402  double mass = zMuTrackCand.mass();
403 
404  // HLT match (check just dau0 the global)
405  const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
407 
408  bool trig0found = false;
409  if( mu0HLTMatches.size()>0 )
410  trig0found = true;
411 
412  GenParticleRef zMuTrackMatch = (*zMuTrackMatchMap)[zMuTrackCandRef];
413  if(zMuTrackMatch.isNonnull()) { // ZMuTrack matched
414  nZMuTrk_matched++;
415  if (pt0>ptmin_ && pt1>ptmin_ && abs(eta0)>etamin_ && abs(eta1)>etamin_ && abs(eta0)<etamax_ && abs(eta1) <etamax_ && mass >massMin_ &&
416  mass < massMax_ && iso0<isoMax_ && iso1 < isoMax_ && trig0found) { // all cuts and trigger passed
418  // histograms vs eta and pt
419  h_trackProbe_eta->Fill(eta1);
420  h_trackProbe_pt->Fill(pt1);
421  }
422  } // end MC match
423  } // end loop on ZMuTrack cand
424  } // end if ZMuTrack size > 0
425 
426 } // end analyze
427 
428 bool ZMuMu_MCanalyzer::check_ifZmumu(const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
429 {
430  int partId0 = dauGen0->pdgId();
431  int partId1 = dauGen1->pdgId();
432  int partId2 = dauGen2->pdgId();
433  bool muplusFound=false;
434  bool muminusFound=false;
435  bool ZFound=false;
436  if (partId0==13 || partId1==13 || partId2==13) muminusFound=true;
437  if (partId0==-13 || partId1==-13 || partId2==-13) muplusFound=true;
438  if (partId0==23 || partId1==23 || partId2==23) ZFound=true;
439  return muplusFound*muminusFound*ZFound;
440 }
441 
442 float ZMuMu_MCanalyzer::getParticlePt(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
443 {
444  int partId0 = dauGen0->pdgId();
445  int partId1 = dauGen1->pdgId();
446  int partId2 = dauGen2->pdgId();
447  float ptpart=0.;
448  if (partId0 == ipart) {
449  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
450  const Candidate * dauMuGen = dauGen0->daughter(k);
451  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
452  ptpart = dauMuGen->pt();
453  }
454  }
455  }
456  if (partId1 == ipart) {
457  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
458  const Candidate * dauMuGen = dauGen1->daughter(k);
459  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
460  ptpart = dauMuGen->pt();
461  }
462  }
463  }
464  if (partId2 == ipart) {
465  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
466  const Candidate * dauMuGen = dauGen2->daughter(k);
467  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
468  ptpart = dauMuGen->pt();
469  }
470  }
471  }
472  return ptpart;
473 }
474 
475 float ZMuMu_MCanalyzer::getParticleEta(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
476 {
477  int partId0 = dauGen0->pdgId();
478  int partId1 = dauGen1->pdgId();
479  int partId2 = dauGen2->pdgId();
480  float etapart=0.;
481  if (partId0 == ipart) {
482  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
483  const Candidate * dauMuGen = dauGen0->daughter(k);
484  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
485  etapart = dauMuGen->eta();
486  }
487  }
488  }
489  if (partId1 == ipart) {
490  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
491  const Candidate * dauMuGen = dauGen1->daughter(k);
492  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
493  etapart = dauMuGen->eta();
494  }
495  }
496  }
497  if (partId2 == ipart) {
498  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
499  const Candidate * dauMuGen = dauGen2->daughter(k);
500  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
501  etapart = dauMuGen->eta();
502  }
503  }
504  }
505  return etapart;
506 }
507 
508 float ZMuMu_MCanalyzer::getParticlePhi(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
509 {
510  int partId0 = dauGen0->pdgId();
511  int partId1 = dauGen1->pdgId();
512  int partId2 = dauGen2->pdgId();
513  float phipart=0.;
514  if (partId0 == ipart) {
515  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
516  const Candidate * dauMuGen = dauGen0->daughter(k);
517  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
518  phipart = dauMuGen->phi();
519  }
520  }
521  }
522  if (partId1 == ipart) {
523  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
524  const Candidate * dauMuGen = dauGen1->daughter(k);
525  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
526  phipart = dauMuGen->phi();
527  }
528  }
529  }
530  if (partId2 == ipart) {
531  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
532  const Candidate * dauMuGen = dauGen2->daughter(k);
533  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
534  phipart = dauMuGen->phi();
535  }
536  }
537  }
538  return phipart;
539 }
540 
541 Particle::LorentzVector ZMuMu_MCanalyzer::getParticleP4(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
542 {
543  int partId0 = dauGen0->pdgId();
544  int partId1 = dauGen1->pdgId();
545  int partId2 = dauGen2->pdgId();
546  Particle::LorentzVector p4part(0.,0.,0.,0.);
547  if (partId0 == ipart) {
548  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
549  const Candidate * dauMuGen = dauGen0->daughter(k);
550  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
551  p4part = dauMuGen->p4();
552  }
553  }
554  }
555  if (partId1 == ipart) {
556  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
557  const Candidate * dauMuGen = dauGen1->daughter(k);
558  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
559  p4part = dauMuGen->p4();
560  }
561  }
562  }
563  if (partId2 == ipart) {
564  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
565  const Candidate * dauMuGen = dauGen2->daughter(k);
566  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
567  p4part = dauMuGen->p4();
568  }
569  }
570  }
571  return p4part;
572 }
573 
574 
575 
577 
578 
580  double err_effIso = sqrt(eff_Iso*(1-eff_Iso)/nGlobalMuonsMatched_passed);
581 
585  double effSta_afterIso = (2*n2GlobalMuonsMatched_passedIso2Trg+nMu0onlyTriggered+nMu1onlyTriggered)/n1_afterIso;
586  double effTrk_afterIso = (2*n2GlobalMuonsMatched_passedIso2Trg+nMu0onlyTriggered+nMu1onlyTriggered)/n2_afterIso;
587  double effHLT_afterIso = (2.* n2GlobalMuonsMatched_passedIso2Trg)/(2.* n2GlobalMuonsMatched_passedIso2Trg + nMu0onlyTriggered + nMu1onlyTriggered);
588  double err_effHLT_afterIso= sqrt( effHLT_afterIso * (1 - effHLT_afterIso)/nGLB_afterIso);
589  double err_effsta_afterIso = sqrt(effSta_afterIso*(1-effSta_afterIso)/n1_afterIso);
590  double err_efftrk_afterIso = sqrt(effTrk_afterIso*(1-effTrk_afterIso)/n2_afterIso);
591 
592 
593  cout << "------------------------------------ Counters --------------------------------" << endl;
594 
595  cout << "number of events zMuMu matched " << nZMuMu_matched << endl;
596  cout << "number of events zMuSta matched " << nZMuSta_matched << endl;
597  cout << "number of events zMuTk matched " << nZMuTrk_matched << endl;
598  cout << "number of events zMuMu with mu0 only triggered " << nMu0onlyTriggered << endl;
599  cout << "number of events zMuMu with mu1 only triggered " << nMu1onlyTriggered << endl;
600  cout << "=========================================" << endl;
601  cout << "n. of global muons MC matched and passing cuts: " << nGlobalMuonsMatched_passed << endl;
602  cout << "n. of global muons MC matched and passing also Iso cut: " << nGlobalMuonsMatched_passedIso << endl;
603  cout << "n. of Z -> 2 global muons MC matched and passing ALL cuts: " << n2GlobalMuonsMatched_passedIso << endl;
604  cout << "n. of ZMuSta MC matched and passing ALL cuts: " << nStaMuonsMatched_passedIso << endl;
605  cout << "n. of ZmuTrck MC matched and passing ALL cuts: " << nTracksMuonsMatched_passedIso << endl;
606  cout << "n. of Z -> 2 global muons MC matched and passing ALL cuts and both triggered: " << n2GlobalMuonsMatched_passedIso2Trg << endl;
607  cout << "=================================================================================" << endl;
608  cout << "Iso efficiency: " << eff_Iso << " +/- " << err_effIso << endl;
609  cout << "HLT efficiency: " << effHLT_afterIso << " +/- " << err_effHLT_afterIso << endl;
610  cout << "eff StandAlone (after Isocut) : " << effSta_afterIso << "+/-" << err_effsta_afterIso << endl;
611  cout << "eff Tracker (after Isocut) : " << effTrk_afterIso << "+/-" << err_efftrk_afterIso << endl;
612 
613 }
614 
616 
618 
const double beta
edm::InputTag zMuStandAlone_
int i
Definition: DBlmapReader.cc:9
ZMuMu_MCanalyzer(const edm::ParameterSet &pset)
float alpha
Definition: AMPTWrapper.h:95
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
const std::vector< reco::PFCandidatePtr > & tracks_
double candidateIsolation(const reco::Candidate *c, double ptThreshold, double etEcalThreshold, double etHcalThreshold, double dRVetoTrk, double dRTrk, double dREcal, double dRHcal, double alpha, double beta, bool relativeIsolation)
virtual float mass() const =0
mass
virtual float eta() const =0
momentum pseudorapidity
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual int status() const =0
status word
virtual float phi() const =0
momentum azimuthal angle
float getParticlePhi(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup) override
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:138
bool check_ifZmumu(const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
edm::InputTag zMuTrackMatchMap_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
virtual size_type numberOfDaughters() const =0
number of daughters
virtual float pt() const =0
transverse momentum
edm::ValueMap< float > IsolationCollection
edm::InputTag zMuMuMatchMap_
T sqrt(T t)
Definition: SSEVec.h:48
reco::CandidateBaseRef trackMuonCandRef_
edm::InputTag zMuStandAloneMatchMap_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::InputTag zMuTrack_
const int mu
Definition: Constants.h:22
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:596
edm::InputTag genParticles_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int k[5][pyjets_maxn]
edm::InputTag muons_
virtual int pdgId() const =0
PDG identifier.
int n2GlobalMuonsMatched_passedIso2Trg
edm::InputTag tracks_
tuple tracks
Definition: testEve_cfg.py:39
OverlapChecker overlap_
tuple muons
Definition: patZpeak.py:38
float getParticleEta(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
tuple cout
Definition: gather_cfg.py:121
dbl *** dir
Definition: mlp_gen.cc:35
isodeposit::AbsVetos AbsVetos
Definition: IsoDeposit.h:51
long double T
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:27
Analysis-level muon class.
Definition: Muon.h:50
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple zMuMu
zMuMu vector of PSet is common to all categories except zMuTrk category
float getParticlePt(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
virtual void endJob() override
Particle::LorentzVector getParticleP4(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
virtual const CandidateBaseRef & masterClone() const =0
edm::InputTag zMuMu_