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);
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();
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 
228 void ZMuMu_MCanalyzer::analyze(const Event& event, const EventSetup& setup) {
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  bool zMuTrack_found = false;
384  if (!zMuMu_found && !zMuSta_found && zMuTrack->size() > 0 ) {
385  event.getByLabel(zMuTrackMatchMap_, zMuTrackMatchMap);
386  for(unsigned int i = 0; i < zMuTrack->size(); ++i) { //loop on candidates
387  const Candidate & zMuTrackCand = (*zMuTrack)[i]; //the candidate
388  CandidateBaseRef zMuTrackCandRef = zMuTrack->refAt(i);
389  const Candidate * lep0 = zMuTrackCand.daughter( 0 );
390  const Candidate * lep1 = zMuTrackCand.daughter( 1 );
391  const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
392  //double trkiso0 = muonDau0.trackIso();
393  //const pat::GenericParticle & trackDau1 = dynamic_cast<const pat::GenericParticle &>(*lep1->masterClone());
394  //double trkiso1 = trackDau1.trackIso();
397 
398 
399  double pt0 = zMuTrackCand.daughter(0)->pt();
400  double pt1 = zMuTrackCand.daughter(1)->pt();
401  double eta0 = zMuTrackCand.daughter(0)->eta();
402  double eta1 = zMuTrackCand.daughter(1)->eta();
403  double mass = zMuTrackCand.mass();
404 
405  // HLT match (check just dau0 the global)
406  const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
408 
409  bool trig0found = false;
410  if( mu0HLTMatches.size()>0 )
411  trig0found = true;
412 
413  GenParticleRef zMuTrackMatch = (*zMuTrackMatchMap)[zMuTrackCandRef];
414  if(zMuTrackMatch.isNonnull()) { // ZMuTrack matched
415  zMuTrack_found = true;
416  nZMuTrk_matched++;
417  if (pt0>ptmin_ && pt1>ptmin_ && abs(eta0)>etamin_ && abs(eta1)>etamin_ && abs(eta0)<etamax_ && abs(eta1) <etamax_ && mass >massMin_ &&
418  mass < massMax_ && iso0<isoMax_ && iso1 < isoMax_ && trig0found) { // all cuts and trigger passed
420  // histograms vs eta and pt
421  h_trackProbe_eta->Fill(eta1);
422  h_trackProbe_pt->Fill(pt1);
423  }
424  } // end MC match
425  } // end loop on ZMuTrack cand
426  } // end if ZMuTrack size > 0
427 
428 } // end analyze
429 
430 bool ZMuMu_MCanalyzer::check_ifZmumu(const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
431 {
432  int partId0 = dauGen0->pdgId();
433  int partId1 = dauGen1->pdgId();
434  int partId2 = dauGen2->pdgId();
435  bool muplusFound=false;
436  bool muminusFound=false;
437  bool ZFound=false;
438  if (partId0==13 || partId1==13 || partId2==13) muminusFound=true;
439  if (partId0==-13 || partId1==-13 || partId2==-13) muplusFound=true;
440  if (partId0==23 || partId1==23 || partId2==23) ZFound=true;
441  return muplusFound*muminusFound*ZFound;
442 }
443 
444 float ZMuMu_MCanalyzer::getParticlePt(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
445 {
446  int partId0 = dauGen0->pdgId();
447  int partId1 = dauGen1->pdgId();
448  int partId2 = dauGen2->pdgId();
449  float ptpart=0.;
450  if (partId0 == ipart) {
451  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
452  const Candidate * dauMuGen = dauGen0->daughter(k);
453  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
454  ptpart = dauMuGen->pt();
455  }
456  }
457  }
458  if (partId1 == ipart) {
459  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
460  const Candidate * dauMuGen = dauGen1->daughter(k);
461  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
462  ptpart = dauMuGen->pt();
463  }
464  }
465  }
466  if (partId2 == ipart) {
467  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
468  const Candidate * dauMuGen = dauGen2->daughter(k);
469  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
470  ptpart = dauMuGen->pt();
471  }
472  }
473  }
474  return ptpart;
475 }
476 
477 float ZMuMu_MCanalyzer::getParticleEta(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
478 {
479  int partId0 = dauGen0->pdgId();
480  int partId1 = dauGen1->pdgId();
481  int partId2 = dauGen2->pdgId();
482  float etapart=0.;
483  if (partId0 == ipart) {
484  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
485  const Candidate * dauMuGen = dauGen0->daughter(k);
486  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
487  etapart = dauMuGen->eta();
488  }
489  }
490  }
491  if (partId1 == ipart) {
492  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
493  const Candidate * dauMuGen = dauGen1->daughter(k);
494  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
495  etapart = dauMuGen->eta();
496  }
497  }
498  }
499  if (partId2 == ipart) {
500  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
501  const Candidate * dauMuGen = dauGen2->daughter(k);
502  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
503  etapart = dauMuGen->eta();
504  }
505  }
506  }
507  return etapart;
508 }
509 
510 float ZMuMu_MCanalyzer::getParticlePhi(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
511 {
512  int partId0 = dauGen0->pdgId();
513  int partId1 = dauGen1->pdgId();
514  int partId2 = dauGen2->pdgId();
515  float phipart=0.;
516  if (partId0 == ipart) {
517  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
518  const Candidate * dauMuGen = dauGen0->daughter(k);
519  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
520  phipart = dauMuGen->phi();
521  }
522  }
523  }
524  if (partId1 == ipart) {
525  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
526  const Candidate * dauMuGen = dauGen1->daughter(k);
527  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
528  phipart = dauMuGen->phi();
529  }
530  }
531  }
532  if (partId2 == ipart) {
533  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
534  const Candidate * dauMuGen = dauGen2->daughter(k);
535  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
536  phipart = dauMuGen->phi();
537  }
538  }
539  }
540  return phipart;
541 }
542 
543 Particle::LorentzVector ZMuMu_MCanalyzer::getParticleP4(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
544 {
545  int partId0 = dauGen0->pdgId();
546  int partId1 = dauGen1->pdgId();
547  int partId2 = dauGen2->pdgId();
548  Particle::LorentzVector p4part(0.,0.,0.,0.);
549  if (partId0 == ipart) {
550  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
551  const Candidate * dauMuGen = dauGen0->daughter(k);
552  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
553  p4part = dauMuGen->p4();
554  }
555  }
556  }
557  if (partId1 == ipart) {
558  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
559  const Candidate * dauMuGen = dauGen1->daughter(k);
560  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
561  p4part = dauMuGen->p4();
562  }
563  }
564  }
565  if (partId2 == ipart) {
566  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
567  const Candidate * dauMuGen = dauGen2->daughter(k);
568  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
569  p4part = dauMuGen->p4();
570  }
571  }
572  }
573  return p4part;
574 }
575 
576 
577 
579 
580 
582  double err_effIso = sqrt(eff_Iso*(1-eff_Iso)/nGlobalMuonsMatched_passed);
583 
587  double effSta_afterIso = (2*n2GlobalMuonsMatched_passedIso2Trg+nMu0onlyTriggered+nMu1onlyTriggered)/n1_afterIso;
588  double effTrk_afterIso = (2*n2GlobalMuonsMatched_passedIso2Trg+nMu0onlyTriggered+nMu1onlyTriggered)/n2_afterIso;
589  double effHLT_afterIso = (2.* n2GlobalMuonsMatched_passedIso2Trg)/(2.* n2GlobalMuonsMatched_passedIso2Trg + nMu0onlyTriggered + nMu1onlyTriggered);
590  double err_effHLT_afterIso= sqrt( effHLT_afterIso * (1 - effHLT_afterIso)/nGLB_afterIso);
591  double err_effsta_afterIso = sqrt(effSta_afterIso*(1-effSta_afterIso)/n1_afterIso);
592  double err_efftrk_afterIso = sqrt(effTrk_afterIso*(1-effTrk_afterIso)/n2_afterIso);
593 
594 
595  cout << "------------------------------------ Counters --------------------------------" << endl;
596 
597  cout << "number of events zMuMu matched " << nZMuMu_matched << endl;
598  cout << "number of events zMuSta matched " << nZMuSta_matched << endl;
599  cout << "number of events zMuTk matched " << nZMuTrk_matched << endl;
600  cout << "number of events zMuMu with mu0 only triggered " << nMu0onlyTriggered << endl;
601  cout << "number of events zMuMu with mu1 only triggered " << nMu1onlyTriggered << endl;
602  cout << "=========================================" << endl;
603  cout << "n. of global muons MC matched and passing cuts: " << nGlobalMuonsMatched_passed << endl;
604  cout << "n. of global muons MC matched and passing also Iso cut: " << nGlobalMuonsMatched_passedIso << endl;
605  cout << "n. of Z -> 2 global muons MC matched and passing ALL cuts: " << n2GlobalMuonsMatched_passedIso << endl;
606  cout << "n. of ZMuSta MC matched and passing ALL cuts: " << nStaMuonsMatched_passedIso << endl;
607  cout << "n. of ZmuTrck MC matched and passing ALL cuts: " << nTracksMuonsMatched_passedIso << endl;
608  cout << "n. of Z -> 2 global muons MC matched and passing ALL cuts and both triggered: " << n2GlobalMuonsMatched_passedIso2Trg << endl;
609  cout << "=================================================================================" << endl;
610  cout << "Iso efficiency: " << eff_Iso << " +/- " << err_effIso << endl;
611  cout << "HLT efficiency: " << effHLT_afterIso << " +/- " << err_effHLT_afterIso << endl;
612  cout << "eff StandAlone (after Isocut) : " << effSta_afterIso << "+/-" << err_effsta_afterIso << endl;
613  cout << "eff Tracker (after Isocut) : " << effTrk_afterIso << "+/-" << err_efftrk_afterIso << endl;
614 
615 }
616 
618 
620 
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) ...
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 double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual double mass() const =0
mass
virtual int status() const =0
status word
#define abs(x)
Definition: mlp_lapack.h:159
float getParticlePhi(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=true) const
Definition: PATObject.h:584
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:248
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
virtual size_type numberOfDaughters() const =0
number of daughters
edm::ValueMap< float > IsolationCollection
edm::InputTag zMuMuMatchMap_
T sqrt(T t)
Definition: SSEVec.h:28
reco::CandidateBaseRef trackMuonCandRef_
edm::InputTag zMuStandAloneMatchMap_
edm::InputTag zMuTrack_
tuple pset
Definition: CrabTask.py:85
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
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup)
OverlapChecker overlap_
float getParticleEta(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
T * make() const
make new ROOT object
tuple cout
Definition: gather_cfg.py:41
dbl *** dir
Definition: mlp_gen.cc:35
isodeposit::AbsVetos AbsVetos
Definition: IsoDeposit.h:50
virtual void endJob()
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:26
Analysis-level muon class.
Definition: Muon.h:47
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 double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity
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_