CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZMuMu_vtxAnalyzer.cc
Go to the documentation of this file.
1 /* \class ZMuMu_vtxAnalyzer
2  *
3  * author: Davide Piccolo
4  *
5  * ZMuMu Vtx analyzer:
6  * check muon vtx distributions,
7  *
8  */
9 
30 
31 #include "TH1.h"
32 #include "TH2.h"
33 #include "TH3.h"
34 #include <vector>
35 using namespace edm;
36 using namespace std;
37 using namespace reco;
38 
40 public:
42 private:
43  virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
44  bool check_ifZmumu(const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
45  float getParticlePt(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
46  float getParticleEta(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
47  float getParticlePhi(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
48  Particle::LorentzVector getParticleP4(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2);
49  virtual void endJob() override;
50 
54  edm::InputTag muons_, muonMatchMap_, muonIso_;
55  edm::InputTag tracks_, trackIso_;
57 
58  bool bothMuons_;
59 
60  double etamax_, ptmin_, massMin_, massMax_, isoMax_;
61 
62  reco::CandidateBaseRef globalMuonCandRef_, trackMuonCandRef_, standAloneMuonCandRef_;
64 
65  // general histograms
66 
67  // vertex studies
68  // ... zmumu No cuts
69  TH1D *h_muon_vz, *h_dimuon_vz, *h_muon_d0signed;
70  TH1D *h_muon_vz_respectToPV, *h_muon_d0signed_respectToPV;
71  // ... cynematic cuts zmumu
72  TH1D *h_zmumuSele_muon_vz, *h_zmumuSele_dimuon_vz, *h_zmumuSele_muon_d0signed;
73  TH1D *h_zmumuSele_muon_vz_respectToPV, *h_zmumuSele_muon_d0signed_respectToPV;
74  // ... cynematic cuts zmumuNotIso
76  TH1D *h_zmumuNotIsoSele_muonIso_vz, *h_zmumuNotIsoSele_muonIso_d0signed;
77  TH1D *h_zmumuNotIsoSele_muonIso_vz_respectToPV, *h_zmumuNotIsoSele_muonIso_d0signed_respectToPV;
78  TH1D *h_zmumuNotIsoSele_muonNotIso_vz, *h_zmumuNotIsoSele_muonNotIso_d0signed;
79  TH1D *h_zmumuNotIsoSele_muonNotIso_vz_respectToPV, *h_zmumuNotIsoSele_muonNotIso_d0signed_respectToPV;
80  // ... cynematic cuts zmutrack
81  TH1D *h_zmutrackSele_muon_vz, *h_zmutrackSele_muon_d0signed;
82  TH1D *h_zmutrackSele_muon_vz_respectToPV, *h_zmutrackSele_muon_d0signed_respectToPV;
83  TH1D *h_zmutrackSele_track_vz, *h_zmutrackSele_track_d0signed;
84  TH1D *h_zmutrackSele_track_vz_respectToPV, *h_zmutrackSele_track_d0signed_respectToPV;
85  // ... cynematic cuts zmusta
86  TH1D *h_zmustaSele_muon_vz, *h_zmustaSele_muon_d0signed;
87  TH1D *h_zmustaSele_muon_vz_respectToPV, *h_zmustaSele_muon_d0signed_respectToPV;
88  TH1D *h_zmustaSele_sta_vz, *h_zmustaSele_sta_d0signed;
89  TH1D *h_zmustaSele_sta_vz_respectToPV, *h_zmustaSele_sta_d0signed_respectToPV;
90 
91 
92  // global counters
93 };
94 
105 #include <iostream>
106 #include <iterator>
107 #include <cmath>
108 using namespace std;
109 using namespace reco;
110 using namespace edm;
111 
113 
115  zMuMu_(pset.getParameter<InputTag>("zMuMu")),
116  zMuMuMatchMap_(pset.getParameter<InputTag>("zMuMuMatchMap")),
117  zMuStandAlone_(pset.getParameter<InputTag>("zMuStandAlone")),
118  zMuStandAloneMatchMap_(pset.getParameter<InputTag>("zMuStandAloneMatchMap")),
119  zMuTrack_(pset.getParameter<InputTag>("zMuTrack")),
120  zMuTrackMatchMap_(pset.getParameter<InputTag>("zMuTrackMatchMap")),
121  muons_(pset.getParameter<InputTag>("muons")),
122  tracks_(pset.getParameter<InputTag>("tracks")),
123  genParticles_(pset.getParameter<InputTag>( "genParticles" ) ),
124  primaryVertices_(pset.getParameter<InputTag>( "primaryVertices" ) ),
125 
126  bothMuons_(pset.getParameter<bool>("bothMuons")),
127 
128  etamax_(pset.getUntrackedParameter<double>("etamax")),
129  ptmin_(pset.getUntrackedParameter<double>("ptmin")),
130  massMin_(pset.getUntrackedParameter<double>("zMassMin")),
131  massMax_(pset.getUntrackedParameter<double>("zMassMax")),
132  isoMax_(pset.getUntrackedParameter<double>("isomax")) {
134 
135  // general histograms
136 
137  // vertex histograms
138  // ... zmumu no Cuts
139  h_muon_vz = fs->make<TH1D>("muonVz","z vertex of muons",50,-20.,20.);
140  h_muon_d0signed = fs->make<TH1D>("muonD0signed","d0 vertex of muons",50,-.1,.1);
141  h_dimuon_vz = fs->make<TH1D>("dimuonVz","z vertex of dimuon",50,-20.,20.);
142  h_muon_vz_respectToPV = fs->make<TH1D>("muonVz_respectToPV","z vertex of muons respect to PrimaryVertex",50,-.05,.05);
143  h_muon_d0signed_respectToPV = fs->make<TH1D>("muonD0signed_respectToPV","d0 vertex of muons respect to PrimaryVertex",50,-.05,.05);
144  // ... zmumu cynematic Cuts
145  h_zmumuSele_muon_vz = fs->make<TH1D>("zmumuSele_muonVz","z vertex of muons (zmumu sele)",50,-20.,20.);
146  h_zmumuSele_muon_d0signed = fs->make<TH1D>("zmumuSele_muonD0signed","d0 vertex of muons (zmumu sele)",50,-.1,.1);
147  h_zmumuSele_dimuon_vz = fs->make<TH1D>("zmumuSele_dimuonVz","z vertex of dimuon (zmumu sele)",50,-20.,20.);
148  h_zmumuSele_muon_vz_respectToPV = fs->make<TH1D>("zmumuSele_muonVz_respectToPV","z vertex of muons respect to PrimaryVertex (zmumu sele)",50,-.05,.05);
149  h_zmumuSele_muon_d0signed_respectToPV = fs->make<TH1D>("zmumuSele_muonD0signed_respectToPV","d0 vertex of muons respect to PrimaryVertex (zmumu sele)",50,-.05,.05);
150  // ... zmumuNotIso cynematic Cuts
151  h_zmumuNotIsoSele_dimuon_vz = fs->make<TH1D>("zmumuNotIsoSele_dimuonVz","z vertex of dimuon (zmumuNotIso sele)",50,-20.,20.);
152  h_zmumuNotIsoSele_muonIso_vz = fs->make<TH1D>("zmumuNotIsoSele_muonIsoVz","z vertex of muons (zmumuNotIso sele muon Iso)",50,-20.,20.);
153  h_zmumuNotIsoSele_muonIso_d0signed = fs->make<TH1D>("zmumuNotIsoSele_muonIsoD0signed","d0 vertex of muons (zmumuNotIso sele muon Iso)",50,-.1,.1);
154  h_zmumuNotIsoSele_muonIso_vz_respectToPV = fs->make<TH1D>("zmumuNotIsoSele_muonIsoVz_respectToPV","z vertex of muons respect to PrimaryVertex (zmumuNotIso sele muon Iso)",50,-.05,.05);
155  h_zmumuNotIsoSele_muonIso_d0signed_respectToPV = fs->make<TH1D>("zmumuNotIsoSele_muonIsoD0signed_respectToPV","d0 vertex of muons respect to PrimaryVertex (zmumuNotIso sele muon Iso)",50,-.05,.05);
156  h_zmumuNotIsoSele_muonNotIso_vz = fs->make<TH1D>("zmumuNotIsoSele_muonNotIsoVz","z vertex of muons (zmumuNotIso sele muon Not Iso)",50,-20.,20.);
157  h_zmumuNotIsoSele_muonNotIso_d0signed = fs->make<TH1D>("zmumuNotIsoSele_muonNotIsoD0signed","d0 vertex of muons (zmumuNotIso sele muon Not Iso)",50,-.1,.1);
158  h_zmumuNotIsoSele_muonNotIso_vz_respectToPV = fs->make<TH1D>("zmumuNotIsoSele_muonNotIsoVz_respectToPV","z vertex of muons respect to PrimaryVertex (zmumuNotIso sele muon Not Iso)",50,-.05,.05);
159  h_zmumuNotIsoSele_muonNotIso_d0signed_respectToPV = fs->make<TH1D>("zmumuNotIsoSele_muonNotIsoD0signed_respectToPV","d0 vertex of muons respect to PrimaryVertex (zmumuNotIso sele muon Not Iso)",50,-.05,.05);
160  // ... zmutrack cynematic Cuts
161  h_zmutrackSele_muon_vz = fs->make<TH1D>("zmutrackSele_muonVz","z vertex of muon (zmutrack sele)",50,-20.,20.);
162  h_zmutrackSele_muon_d0signed = fs->make<TH1D>("zmutrackSele_muonD0signed","d0 vertex of muon (zmutrack sele)",50,-.1,.1);
163  h_zmutrackSele_muon_vz_respectToPV = fs->make<TH1D>("zmutrackSele_muonVz_respectToPV","z vertex of muon respect to PV (zmutrack sele)",50,-.05,.05);
164  h_zmutrackSele_muon_d0signed_respectToPV = fs->make<TH1D>("zmutrackSele_muonD0signed_respectToPV","d0 vertex of muon respect to PV (zmutrack sele)",50,-.1,.1);
165  h_zmutrackSele_track_vz = fs->make<TH1D>("zmutrackSele_trackVz","z vertex of track (zmutrack sele)",50,-20.,20.);
166  h_zmutrackSele_track_d0signed = fs->make<TH1D>("zmutrackSele_trackD0signed","d0 vertex of track (zmutrack sele)",50,-.1,.1);
167  h_zmutrackSele_track_vz_respectToPV = fs->make<TH1D>("zmutrackSele_trackVz_respectToPV","z vertex of track respect to PV (zmutrack sele)",50,-.05,.05);
168  h_zmutrackSele_track_d0signed_respectToPV = fs->make<TH1D>("zmutrackSele_trackD0signed_respectToPV","d0 vertex of track respect to PV (zmutrack sele)",50,-.1,.1);
169  // ... zmusta cynematic Cuts
170  h_zmustaSele_muon_vz = fs->make<TH1D>("zmustaSele_muonVz","z vertex of muon (zmusta sele)",50,-20.,20.);
171  h_zmustaSele_muon_d0signed = fs->make<TH1D>("zmustaSele_muonD0signed","d0 vertex of muon (zmusta sele)",50,-.1,.1);
172  h_zmustaSele_muon_vz_respectToPV = fs->make<TH1D>("zmustaSele_muonVz_respectToPV","z vertex of muon respect to PV (zmusta sele)",50,-.05,.05);
173  h_zmustaSele_muon_d0signed_respectToPV = fs->make<TH1D>("zmustaSele_muonD0signed_respectToPV","d0 vertex of muon respect to PV (zmusta sele)",50,-.1,.1);
174  h_zmustaSele_sta_vz = fs->make<TH1D>("zmustaSele_staVz","z vertex of sta (zmusta sele)",50,-20.,20.);
175  h_zmustaSele_sta_d0signed = fs->make<TH1D>("zmustaSele_staD0signed","d0 vertex of sta (zmusta sele)",50,-.1,.1);
176  h_zmustaSele_sta_vz_respectToPV = fs->make<TH1D>("zmustaSele_staVz_respectToPV","z vertex of sta respect to PV (zmusta sele)",50,-.05,.05);
177  h_zmustaSele_sta_d0signed_respectToPV = fs->make<TH1D>("zmustaSele_staD0signed_respectToPV","d0 vertex of sta respect to PV (zmusta sele)",50,-.1,.1);
178 
179 }
180 
183  Handle<GenParticleMatch> zMuMuMatchMap; //Map of Z made by Mu global + Mu global
184  Handle<CandidateView> zMuStandAlone;
185  Handle<GenParticleMatch> zMuStandAloneMatchMap; //Map of Z made by Mu + StandAlone
186  Handle<CandidateView> zMuTrack;
187  Handle<GenParticleMatch> zMuTrackMatchMap; //Map of Z made by Mu + Track
188  Handle<CandidateView> muons; //Collection of Muons
189  Handle<CandidateView> tracks; //Collection of Tracks
190 
191  Handle<GenParticleCollection> genParticles; // Collection of Generatd Particles
192  Handle<reco::VertexCollection> primaryVertices; // Collection of primary Vertices
193 
194  event.getByLabel(zMuMu_, zMuMu);
195  event.getByLabel(zMuStandAlone_, zMuStandAlone);
196  event.getByLabel(zMuTrack_, zMuTrack);
197  event.getByLabel(genParticles_, genParticles);
198  event.getByLabel(primaryVertices_, primaryVertices);
199  event.getByLabel(muons_, muons);
200  event.getByLabel(tracks_, tracks);
201 
202  /*
203  cout << "********* zMuMu size : " << zMuMu->size() << endl;
204  cout << "********* zMuStandAlone size : " << zMuStandAlone->size() << endl;
205  cout << "********* zMuTrack size : " << zMuTrack->size() << endl;
206  cout << "********* muons size : " << muons->size() << endl;
207  cout << "********* tracks size : " << tracks->size() << endl;
208  cout << "********* vertices size : " << primaryVertices->size() << endl;
209  */
210 
211  // std::cout<<"Run-> "<<event.id().run()<<std::endl;
212  // std::cout<<"Event-> "<<event.id().event()<<std::endl;
213 
214  bool zMuMu_found = false;
215 
216  // loop on ZMuMu
217  if (zMuMu->size() > 0 ) {
218  event.getByLabel(zMuMuMatchMap_, zMuMuMatchMap);
219  for(unsigned int i = 0; i < zMuMu->size(); ++i) { //loop on candidates
220  const Candidate & zMuMuCand = (*zMuMu)[i]; //the candidate
221  CandidateBaseRef zMuMuCandRef = zMuMu->refAt(i);
222 
223  const Candidate * lep0 = zMuMuCand.daughter( 0 );
224  const Candidate * lep1 = zMuMuCand.daughter( 1 );
225  const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
226  double trkiso0 = muonDau0.trackIso();
227  const pat::Muon & muonDau1 = dynamic_cast<const pat::Muon &>(*lep1->masterClone());
228  double trkiso1 = muonDau1.trackIso();
229 
230  // vertex
231  h_muon_vz->Fill(muonDau0.vz());
232  h_muon_vz->Fill(muonDau1.vz());
233  h_dimuon_vz->Fill((muonDau0.vz()+muonDau1.vz())/2.);
234 
235  TrackRef mu0TrkRef = muonDau0.track();
236  float d0signed_mu0 = (*mu0TrkRef).dxy();
237  float d0signed_mu0_respectToPV= (*mu0TrkRef).dxy( primaryVertices->begin()->position() );
238  float vz_mu0_respectToPV= (*mu0TrkRef).dz( primaryVertices->begin()->position() );
239 
240  TrackRef mu1TrkRef = muonDau1.track();
241  float d0signed_mu1 = (*mu1TrkRef).dxy();
242  float d0signed_mu1_respectToPV= (*mu1TrkRef).dxy( primaryVertices->begin()->position() );
243  float vz_mu1_respectToPV= (*mu1TrkRef).dz( primaryVertices->begin()->position() );
244  h_muon_d0signed->Fill(d0signed_mu0);
245  h_muon_d0signed->Fill(d0signed_mu1);
246  h_muon_d0signed_respectToPV->Fill(d0signed_mu0_respectToPV);
247  h_muon_d0signed_respectToPV->Fill(d0signed_mu1_respectToPV);
248  h_muon_vz_respectToPV->Fill(vz_mu0_respectToPV);
249  h_muon_vz_respectToPV->Fill(vz_mu1_respectToPV);
250 
251  // eta , pt distributions
252  double pt0 = zMuMuCand.daughter(0)->pt();
253  double pt1 = zMuMuCand.daughter(1)->pt();
254  double eta0 = zMuMuCand.daughter(0)->eta();
255  double eta1 = zMuMuCand.daughter(1)->eta();
256  double mass = zMuMuCand.mass();
257 
258  // HLT match
259  const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
260  muonDau0.triggerObjectMatchesByPath( "HLT_Mu9" );
261  const pat::TriggerObjectStandAloneCollection mu1HLTMatches =
262  muonDau1.triggerObjectMatchesByPath( "HLT_Mu9" );
263 
264  bool trig0found = false;
265  bool trig1found = false;
266  if( mu0HLTMatches.size()>0 )
267  trig0found = true;
268  if( mu1HLTMatches.size()>0 )
269  trig1found = true;
270 
271  // cynematical selection
272  if ((trig0found || trig1found) && pt0>ptmin_ && pt1>ptmin_ && abs(eta0)<etamax_ && abs(eta1)<etamax_ && mass > massMin_) {
273  if (trkiso0<isoMax_ && trkiso1<isoMax_) { // zmumu both isolated
274  h_zmumuSele_muon_vz->Fill(muonDau0.vz());
275  h_zmumuSele_muon_vz->Fill(muonDau1.vz());
276  h_zmumuSele_dimuon_vz->Fill((muonDau0.vz()+muonDau1.vz())/2.);
277  h_zmumuSele_muon_d0signed->Fill(d0signed_mu0);
278  h_zmumuSele_muon_d0signed->Fill(d0signed_mu1);
279  h_zmumuSele_muon_d0signed_respectToPV->Fill(d0signed_mu0_respectToPV);
280  h_zmumuSele_muon_d0signed_respectToPV->Fill(d0signed_mu1_respectToPV);
281  h_zmumuSele_muon_vz_respectToPV->Fill(vz_mu0_respectToPV);
282  h_zmumuSele_muon_vz_respectToPV->Fill(vz_mu1_respectToPV);
283  }
284  if (trkiso0>=isoMax_ && trkiso1<isoMax_) { // zmumu just muon1 isolated
285  h_zmumuNotIsoSele_muonNotIso_vz->Fill(muonDau0.vz());
286  h_zmumuNotIsoSele_muonIso_vz->Fill(muonDau1.vz());
287  h_zmumuNotIsoSele_dimuon_vz->Fill((muonDau0.vz()+muonDau1.vz())/2.);
288  h_zmumuNotIsoSele_muonNotIso_d0signed->Fill(d0signed_mu0);
289  h_zmumuNotIsoSele_muonIso_d0signed->Fill(d0signed_mu1);
290  h_zmumuNotIsoSele_muonNotIso_d0signed_respectToPV->Fill(d0signed_mu0_respectToPV);
291  h_zmumuNotIsoSele_muonIso_d0signed_respectToPV->Fill(d0signed_mu1_respectToPV);
292  h_zmumuNotIsoSele_muonNotIso_vz_respectToPV->Fill(vz_mu0_respectToPV);
293  h_zmumuNotIsoSele_muonIso_vz_respectToPV->Fill(vz_mu1_respectToPV);
294  }
295  if (trkiso0<isoMax_ && trkiso1>=isoMax_) { // zmumu just muon0 isolated
296  h_zmumuNotIsoSele_muonNotIso_vz->Fill(muonDau1.vz());
297  h_zmumuNotIsoSele_muonIso_vz->Fill(muonDau0.vz());
298  h_zmumuNotIsoSele_dimuon_vz->Fill((muonDau1.vz()+muonDau1.vz())/2.);
299  h_zmumuNotIsoSele_muonNotIso_d0signed->Fill(d0signed_mu1);
300  h_zmumuNotIsoSele_muonIso_d0signed->Fill(d0signed_mu0);
301  h_zmumuNotIsoSele_muonNotIso_d0signed_respectToPV->Fill(d0signed_mu1_respectToPV);
302  h_zmumuNotIsoSele_muonIso_d0signed_respectToPV->Fill(d0signed_mu0_respectToPV);
303  h_zmumuNotIsoSele_muonNotIso_vz_respectToPV->Fill(vz_mu1_respectToPV);
304  h_zmumuNotIsoSele_muonIso_vz_respectToPV->Fill(vz_mu0_respectToPV);
305  }
306  }
307  } // end loop on ZMuMu cand
308  } // end if ZMuMu size > 0
309 
310  // loop on ZMuSta
311  bool zMuSta_found = false;
312  if (!zMuMu_found && zMuStandAlone->size() > 0 ) {
313  event.getByLabel(zMuStandAloneMatchMap_, zMuStandAloneMatchMap);
314  for(unsigned int i = 0; i < zMuStandAlone->size(); ++i) { //loop on candidates
315  const Candidate & zMuStandAloneCand = (*zMuStandAlone)[i]; //the candidate
316  CandidateBaseRef zMuStandAloneCandRef = zMuStandAlone->refAt(i);
317  GenParticleRef zMuStandAloneMatch = (*zMuStandAloneMatchMap)[zMuStandAloneCandRef];
318 
319  const Candidate * lep0 = zMuStandAloneCand.daughter( 0 );
320  const Candidate * lep1 = zMuStandAloneCand.daughter( 1 );
321  const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
322  double trkiso0 = muonDau0.trackIso();
323  const pat::Muon & muonDau1 = dynamic_cast<const pat::Muon &>(*lep1->masterClone());
324  double trkiso1 = muonDau1.trackIso();
325 
326  // vertex
327 
328  TrackRef mu0TrkRef = muonDau0.track();
329  float d0signed_mu0 = (*mu0TrkRef).dxy();
330  float d0signed_mu0_respectToPV= (*mu0TrkRef).dxy( primaryVertices->begin()->position() );
331  float vz_mu0_respectToPV= (*mu0TrkRef).dz( primaryVertices->begin()->position() );
332 
333  TrackRef mu1TrkRef = muonDau1.track();
334  float d0signed_mu1 = (*mu1TrkRef).dxy();
335  float d0signed_mu1_respectToPV= (*mu1TrkRef).dxy( primaryVertices->begin()->position() );
336  float vz_mu1_respectToPV= (*mu1TrkRef).dz( primaryVertices->begin()->position() );
337 
338  double pt0 = zMuStandAloneCand.daughter(0)->pt();
339  double pt1 = zMuStandAloneCand.daughter(1)->pt();
340  double eta0 = zMuStandAloneCand.daughter(0)->eta();
341  double eta1 = zMuStandAloneCand.daughter(1)->eta();
342  double mass = zMuStandAloneCand.mass();
343 
344  // HLT match
345  const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
346  muonDau0.triggerObjectMatchesByPath( "HLT_Mu9" );
347  const pat::TriggerObjectStandAloneCollection mu1HLTMatches =
348  muonDau1.triggerObjectMatchesByPath( "HLT_Mu9" );
349 
350  bool trig0found = false;
351  bool trig1found = false;
352  if( mu0HLTMatches.size()>0 )
353  trig0found = true;
354  if( mu1HLTMatches.size()>0 )
355  trig1found = true;
356 
357  // check the global muon ... trigger is required just on global muon
358  bool trigfound = false;
359  if (muonDau0.isGlobalMuon()) trigfound = trig0found;
360  if (muonDau1.isGlobalMuon()) trigfound = trig1found;
361 
362  // cynematical selection
363  if (trigfound && pt0>ptmin_ && pt1>ptmin_ && abs(eta0)<etamax_ && abs(eta1)<etamax_ && mass>massMin_ && trkiso0<isoMax_ && trkiso1<isoMax_) {
364  zMuSta_found = true;
365  h_zmustaSele_muon_vz->Fill(muonDau0.vz(),1.); // muon vz
366  h_zmustaSele_sta_vz->Fill(muonDau1.vz(),1.); // sta vz
367  h_zmustaSele_muon_d0signed->Fill(d0signed_mu0,1.); // muon d0
368  h_zmustaSele_sta_d0signed->Fill(d0signed_mu1,1.); // sta d0
369  h_zmustaSele_muon_d0signed_respectToPV->Fill(d0signed_mu0_respectToPV,1.); // muon d0 respect PV
370  h_zmustaSele_sta_d0signed_respectToPV->Fill(d0signed_mu1_respectToPV,1.); // sta d0 respect PV
371  h_zmustaSele_muon_vz_respectToPV->Fill(vz_mu0_respectToPV,1.); // muon vz respect PV
372  h_zmustaSele_sta_vz_respectToPV->Fill(vz_mu1_respectToPV,1.); // sta vz respect PV
373  }
374 
375  } // end loop on ZMuStandAlone cand
376  } // end if ZMuStandAlone size > 0
377 
378 
379  // loop on ZMuTrack
380  if (!zMuMu_found && !zMuSta_found && zMuTrack->size() > 0 ) {
381  event.getByLabel(zMuTrackMatchMap_, zMuTrackMatchMap);
382  for(unsigned int i = 0; i < zMuTrack->size(); ++i) { //loop on candidates
383  const Candidate & zMuTrackCand = (*zMuTrack)[i]; //the candidate
384  CandidateBaseRef zMuTrackCandRef = zMuTrack->refAt(i);
385  const Candidate * lep0 = zMuTrackCand.daughter( 0 );
386  const Candidate * lep1 = zMuTrackCand.daughter( 1 );
387  const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
388  double trkiso0 = muonDau0.trackIso();
389  const pat::GenericParticle & trackDau1 = dynamic_cast<const pat::GenericParticle &>(*lep1->masterClone());
390  double trkiso1 = trackDau1.trackIso();
391 
392  // vertex
393 
394  TrackRef mu0TrkRef = muonDau0.track();
395  float d0signed_mu0 = (*mu0TrkRef).dxy();
396  float d0signed_mu0_respectToPV= (*mu0TrkRef).dxy( primaryVertices->begin()->position() );
397  float vz_mu0_respectToPV= (*mu0TrkRef).dz( primaryVertices->begin()->position() );
398 
399  TrackRef mu1TrkRef = trackDau1.track();
400  float d0signed_mu1 = (*mu1TrkRef).dxy();
401  float d0signed_mu1_respectToPV= (*mu1TrkRef).dxy( primaryVertices->begin()->position() );
402  float vz_mu1_respectToPV= (*mu1TrkRef).dz( primaryVertices->begin()->position() );
403 
404  // cynematical parameters
405 
406  double pt0 = zMuTrackCand.daughter(0)->pt();
407  double pt1 = zMuTrackCand.daughter(1)->pt();
408  double eta0 = zMuTrackCand.daughter(0)->eta();
409  double eta1 = zMuTrackCand.daughter(1)->eta();
410  double mass = zMuTrackCand.mass();
411 
412  // HLT match (check just dau0 the global)
413  const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
414  muonDau0.triggerObjectMatchesByPath( "HLT_Mu9" );
415 
416  bool trig0found = false;
417  if( mu0HLTMatches.size()>0 )
418  trig0found = true;
419 
420  // cynematical selection
421  if (trig0found && pt0>ptmin_ && pt1>ptmin_ && abs(eta0)<etamax_ && abs(eta1)<etamax_ && mass>massMin_ && trkiso0<isoMax_ && trkiso1<isoMax_) {
422  h_zmutrackSele_muon_vz->Fill(muonDau0.vz(),1.); // muon vz
423  h_zmutrackSele_track_vz->Fill(trackDau1.vz(),1.); // track vz
424  h_zmutrackSele_muon_d0signed->Fill(d0signed_mu0,1.); // muon d0
425  h_zmutrackSele_track_d0signed->Fill(d0signed_mu1,1.); // track d0
426  h_zmutrackSele_muon_d0signed_respectToPV->Fill(d0signed_mu0_respectToPV,1.); // muon d0 respect PV
427  h_zmutrackSele_track_d0signed_respectToPV->Fill(d0signed_mu1_respectToPV,1.); // track d0 respect PV
428  h_zmutrackSele_muon_vz_respectToPV->Fill(vz_mu0_respectToPV,1.); // muon vz respect PV
429  h_zmutrackSele_track_vz_respectToPV->Fill(vz_mu1_respectToPV,1.); // track vz respect PV
430  }
431 
432  } // end loop on ZMuTrack cand
433  } // end if ZMuTrack size > 0
434 
435 } // end analyze
436 
437 bool ZMuMu_vtxAnalyzer::check_ifZmumu(const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
438 {
439  int partId0 = dauGen0->pdgId();
440  int partId1 = dauGen1->pdgId();
441  int partId2 = dauGen2->pdgId();
442  bool muplusFound=false;
443  bool muminusFound=false;
444  bool ZFound=false;
445  if (partId0==13 || partId1==13 || partId2==13) muminusFound=true;
446  if (partId0==-13 || partId1==-13 || partId2==-13) muplusFound=true;
447  if (partId0==23 || partId1==23 || partId2==23) ZFound=true;
448  return muplusFound*muminusFound*ZFound;
449 }
450 
451 float ZMuMu_vtxAnalyzer::getParticlePt(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
452 {
453  int partId0 = dauGen0->pdgId();
454  int partId1 = dauGen1->pdgId();
455  int partId2 = dauGen2->pdgId();
456  float ptpart=0.;
457  if (partId0 == ipart) {
458  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
459  const Candidate * dauMuGen = dauGen0->daughter(k);
460  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
461  ptpart = dauMuGen->pt();
462  }
463  }
464  }
465  if (partId1 == ipart) {
466  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
467  const Candidate * dauMuGen = dauGen1->daughter(k);
468  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
469  ptpart = dauMuGen->pt();
470  }
471  }
472  }
473  if (partId2 == ipart) {
474  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
475  const Candidate * dauMuGen = dauGen2->daughter(k);
476  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
477  ptpart = dauMuGen->pt();
478  }
479  }
480  }
481  return ptpart;
482 }
483 
484 float ZMuMu_vtxAnalyzer::getParticleEta(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
485 {
486  int partId0 = dauGen0->pdgId();
487  int partId1 = dauGen1->pdgId();
488  int partId2 = dauGen2->pdgId();
489  float etapart=0.;
490  if (partId0 == ipart) {
491  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
492  const Candidate * dauMuGen = dauGen0->daughter(k);
493  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
494  etapart = dauMuGen->eta();
495  }
496  }
497  }
498  if (partId1 == ipart) {
499  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
500  const Candidate * dauMuGen = dauGen1->daughter(k);
501  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
502  etapart = dauMuGen->eta();
503  }
504  }
505  }
506  if (partId2 == ipart) {
507  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
508  const Candidate * dauMuGen = dauGen2->daughter(k);
509  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
510  etapart = dauMuGen->eta();
511  }
512  }
513  }
514  return etapart;
515 }
516 
517 float ZMuMu_vtxAnalyzer::getParticlePhi(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
518 {
519  int partId0 = dauGen0->pdgId();
520  int partId1 = dauGen1->pdgId();
521  int partId2 = dauGen2->pdgId();
522  float phipart=0.;
523  if (partId0 == ipart) {
524  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
525  const Candidate * dauMuGen = dauGen0->daughter(k);
526  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
527  phipart = dauMuGen->phi();
528  }
529  }
530  }
531  if (partId1 == ipart) {
532  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
533  const Candidate * dauMuGen = dauGen1->daughter(k);
534  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
535  phipart = dauMuGen->phi();
536  }
537  }
538  }
539  if (partId2 == ipart) {
540  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
541  const Candidate * dauMuGen = dauGen2->daughter(k);
542  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
543  phipart = dauMuGen->phi();
544  }
545  }
546  }
547  return phipart;
548 }
549 
550 Particle::LorentzVector ZMuMu_vtxAnalyzer::getParticleP4(const int ipart, const Candidate * dauGen0, const Candidate * dauGen1, const Candidate * dauGen2)
551 {
552  int partId0 = dauGen0->pdgId();
553  int partId1 = dauGen1->pdgId();
554  int partId2 = dauGen2->pdgId();
555  Particle::LorentzVector p4part(0.,0.,0.,0.);
556  if (partId0 == ipart) {
557  for(unsigned int k = 0; k < dauGen0->numberOfDaughters(); ++k) {
558  const Candidate * dauMuGen = dauGen0->daughter(k);
559  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
560  p4part = dauMuGen->p4();
561  }
562  }
563  }
564  if (partId1 == ipart) {
565  for(unsigned int k = 0; k < dauGen1->numberOfDaughters(); ++k) {
566  const Candidate * dauMuGen = dauGen1->daughter(k);
567  if(dauMuGen->pdgId() == ipart && dauMuGen->status() ==1) {
568  p4part = dauMuGen->p4();
569  }
570  }
571  }
572  if (partId2 == ipart) {
573  for(unsigned int k = 0; k < dauGen2->numberOfDaughters(); ++k) {
574  const Candidate * dauMuGen = dauGen2->daughter(k);
575  if(abs(dauMuGen->pdgId()) == ipart && dauMuGen->status() ==1) {
576  p4part = dauMuGen->p4();
577  }
578  }
579  }
580  return p4part;
581 }
582 
583 
584 
586 
587 }
588 
590 
592 
TH1D * h_zmumuSele_muon_d0signed_respectToPV
TH1D * h_zmumuNotIsoSele_muonNotIso_d0signed
float getParticlePt(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
int i
Definition: DBlmapReader.cc:9
OverlapChecker overlap_
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
edm::InputTag zMuMu_
edm::InputTag zMuStandAloneMatchMap_
const std::vector< reco::PFCandidatePtr > & tracks_
virtual float mass() const =0
mass
TH1D * h_zmumuNotIsoSele_muonIso_d0signed
virtual float eta() const =0
momentum pseudorapidity
bool check_ifZmumu(const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TH1D * h_zmutrackSele_track_vz_respectToPV
TH1D * h_zmumuNotIsoSele_dimuon_vz
virtual int status() const =0
status word
float getParticleEta(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
edm::InputTag muons_
bool isGlobalMuon() const
Definition: Muon.h:218
virtual float phi() const =0
momentum azimuthal angle
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
TH1D * h_zmustaSele_muon_vz_respectToPV
float trackIso() const
float trackIso() const
Definition: Muon.h:156
TH1D * h_zmutrackSele_track_d0signed
TH1D * h_zmutrackSele_muon_d0signed
TH1D * h_zmumuNotIsoSele_muonIso_vz
TH1D * h_zmutrackSele_track_d0signed_respectToPV
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
TH1D * h_zmumuNotIsoSele_muonNotIso_d0signed_respectToPV
TH1D * h_zmumuSele_muon_vz_respectToPV
virtual size_type numberOfDaughters() const =0
number of daughters
edm::InputTag zMuTrackMatchMap_
virtual float pt() const =0
transverse momentum
edm::ValueMap< float > IsolationCollection
TH1D * h_zmumuNotIsoSele_muonIso_d0signed_respectToPV
virtual void endJob() override
edm::InputTag zMuStandAlone_
TH1D * h_zmustaSele_sta_d0signed_respectToPV
edm::InputTag genParticles_
TH1D * h_zmutrackSele_muon_vz_respectToPV
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Particle::LorentzVector getParticleP4(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
TH1D * h_zmumuNotIsoSele_muonNotIso_vz_respectToPV
virtual reco::TrackRef track() const
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:592
TH1D * h_zmustaSele_sta_vz_respectToPV
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
virtual double vz() const
z coordinate of vertex position
int k[5][pyjets_maxn]
virtual int pdgId() const =0
PDG identifier.
TH1D * h_zmumuNotIsoSele_muonNotIso_vz
reco::CandidateBaseRef trackMuonCandRef_
tuple tracks
Definition: testEve_cfg.py:39
TH1D * h_zmustaSele_muon_d0signed_respectToPV
edm::InputTag zMuMuMatchMap_
ZMuMu_vtxAnalyzer(const edm::ParameterSet &pset)
tuple muons
Definition: patZpeak.py:38
edm::InputTag tracks_
TH1D * h_zmumuNotIsoSele_muonIso_vz_respectToPV
TH1D * h_muon_d0signed_respectToPV
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup) override
TH1D * h_zmutrackSele_muon_d0signed_respectToPV
edm::InputTag primaryVertices_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:27
float getParticlePhi(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
Analysis-level muon class.
Definition: Muon.h:49
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
edm::InputTag zMuTrack_
tuple zMuMu
zMuMu vector of PSet is common to all categories except zMuTrk category
reco::TrackRef track() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:141
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
virtual const CandidateBaseRef & masterClone() const =0