CMS 3D CMS Logo

MuScleFitMuonSelector.cc
Go to the documentation of this file.
5 
6 const double MuScleFitMuonSelector::mMu2 = 0.011163612;
7 const unsigned int MuScleFitMuonSelector::motherPdgIdArray[] = {23, 100553, 100553, 553, 100443, 443};
8 
9 const reco::Candidate*
11  const reco::Candidate* tempMuon = status3Muon;
12  // bool lastCopy = (static_cast<const reco::GenParticle*>(tempMuon))->isLastCopy(); // isLastCopy() likely not enough robust
13  bool isPromptFinalState = static_cast<const reco::GenParticle*>(tempMuon)->isPromptFinalState(); // pre-CMSSW_74X code: int status = tempStatus1Muon->status();
14  while(tempMuon == nullptr || tempMuon->numberOfDaughters()!=0){
15  if ( isPromptFinalState ) break; // pre-CMSSW_74X code: if (status == 1) break;
16  //std::vector<const reco::Candidate*> daughters;
17  for (unsigned int i=0; i<tempMuon->numberOfDaughters(); ++i){
18  if ( tempMuon->daughter(i)->pdgId()==tempMuon->pdgId() ){
19  tempMuon = tempMuon->daughter(i);
20  isPromptFinalState = static_cast<const reco::GenParticle*>(tempMuon)->isPromptFinalState(); // pre-CMSSW_74X code: status = tempStatus1Muon->status();
21  break;
22  }else continue;
23  }//for loop
24  }//while loop
25 
26  return tempMuon;
27 }
28 
29 const reco::Candidate*
31  const reco::Candidate* tempMuon = status3Muon;
32  bool lastCopy = static_cast<const reco::GenParticle*>(tempMuon)->isLastCopyBeforeFSR(); // pre-CMSSW_74X code: int status = tempStatus1Muon->status();
33  while(tempMuon == nullptr || tempMuon->numberOfDaughters()!=0){
34  if ( lastCopy ) break; // pre-CMSSW_74X code: if (status == 3) break;
35  //std::vector<const reco::Candidate*> daughters;
36  for (unsigned int i=0; i<tempMuon->numberOfDaughters(); ++i){
37  if ( tempMuon->daughter(i)->pdgId()==tempMuon->pdgId() ){
38  tempMuon = tempMuon->daughter(i);
39  lastCopy = static_cast<const reco::GenParticle*>(tempMuon)->isLastCopyBeforeFSR(); // pre-CMSSW_74X code: status = tempStatus1Muon->status();
40  break;
41  }else continue;
42  }//for loop
43  }//while loop
44 
45  return tempMuon;
46 }
47 
48 
49 
51 {
52  reco::TrackRef iTrack = aMuon->innerTrack();
53  const reco::HitPattern& p = iTrack->hitPattern();
54 
55  reco::TrackRef gTrack = aMuon->globalTrack();
56  const reco::HitPattern& q = gTrack->hitPattern();
57 
58  return (//isMuonInAccept(aMuon) &&// no acceptance cuts!
59  iTrack->found() > 11 &&
60  gTrack->chi2()/gTrack->ndof() < 20.0 &&
61  q.numberOfValidMuonHits() > 0 &&
62  iTrack->chi2()/iTrack->ndof() < 4.0 &&
63  aMuon->muonID("TrackerMuonArbitrated") &&
64  aMuon->muonID("TMLastStationAngTight") &&
66  std::abs(iTrack->dxy()) < 3.0 && //should be done w.r.t. PV!
67  std::abs(iTrack->dz()) < 15.0 //should be done w.r.t. PV!
68  );
69 }
70 
72 {
73  reco::TrackRef iTrack = aMuon->innerTrack();
74  const reco::HitPattern& p = iTrack->hitPattern();
75 
76  return (//isMuonInAccept(aMuon) // no acceptance cuts!
77  iTrack->found() > 11 &&
78  iTrack->chi2()/iTrack->ndof() < 4.0 &&
79  aMuon->muonID("TrackerMuonArbitrated") &&
80  aMuon->muonID("TMLastStationAngTight") &&
82  std::abs(iTrack->dxy()) < 3.0 && //should be done w.r.t. PV!
83  std::abs(iTrack->dz()) < 15.0 //should be done w.r.t. PV!
84  );
85 }
86 
87 // Note that at this level we save all the information. Events for which no suitable muon pair is found
88 // are removed from the tree (together with the gen and sim information) at a later stage.
89 // It would be better to remove them directly at this point.
90 void MuScleFitMuonSelector::selectMuons(const edm::Event & event, std::vector<MuScleFitMuon> & muons,
91  std::vector<GenMuonPair> & genPair,
92  std::vector<std::pair<lorentzVector, lorentzVector> > & simPair,
94 {
96  event.getByLabel("onia2MuMuPatTrkTrk", collAll);
97  if(!collAll.isValid()) {
98  edm::LogWarning("MuScleFitUtils") << "J/psi not present in event!";
99  }
100  std::vector<const pat::Muon*> collMuSel;
101 
102  //================onia cuts===========================/
103 
104  if (muonType_ <= -1 && PATmuons_) {
105  std::vector<const pat::CompositeCandidate*> collSelGG;
106  std::vector<const pat::CompositeCandidate*> collSelGT;
107  std::vector<const pat::CompositeCandidate*> collSelTT;
108  if (collAll.isValid()) {
109 
110  for (std::vector<pat::CompositeCandidate>::const_iterator it=collAll->begin();
111  it!=collAll->end(); ++it) {
112 
113  const pat::CompositeCandidate* cand = &(*it);
114  // cout << "Now checking candidate of type " << theJpsiCat << " with pt = " << cand->pt() << endl;
115  const pat::Muon* muon1 = dynamic_cast<const pat::Muon*>(cand->daughter("muon1"));
116  const pat::Muon* muon2 = dynamic_cast<const pat::Muon*>(cand->daughter("muon2"));
117 
118  if ((muon1->charge() * muon2->charge())>0)
119  continue;
120  // global + global?
121  if (muon1->isGlobalMuon() && muon2->isGlobalMuon()) {
122  if (selGlobalMuon(muon1) && selGlobalMuon(muon2) && cand->userFloat("vProb") > 0.001) {
123  collSelGG.push_back(cand);
124  continue;
125  }
126  }
127  // global + tracker? (x2)
128  if (muon1->isGlobalMuon() && muon2->isTrackerMuon()) {
129  if (selGlobalMuon(muon1) && selTrackerMuon(muon2) && cand->userFloat("vProb") > 0.001) {
130  collSelGT.push_back(cand);
131  continue;
132  }
133  }
134  if (muon2->isGlobalMuon() && muon1->isTrackerMuon()) {
135  if (selGlobalMuon(muon2) && selTrackerMuon(muon1) && cand->userFloat("vProb") > 0.001) {
136  collSelGT.push_back(cand);
137  continue;
138  }
139  }
140  // tracker + tracker?
141  if (muon1->isTrackerMuon() && muon2->isTrackerMuon()) {
142  if (selTrackerMuon(muon1) && selTrackerMuon(muon2) && cand->userFloat("vProb") > 0.001) {
143  collSelTT.push_back(cand);
144  continue;
145  }
146  }
147  }
148  }
149  // Split them in independent collections if using muonType_ == -2, -3 or -4. Take them all if muonType_ == -1.
150  std::vector<reco::Track> tracks;
151  if (!collSelGG.empty()){
152  //CHECK THAT THEY ARE ORDERED BY PT !!!!!!!!!!!!!!!!!!!!!!!
153  const pat::Muon* muon1 = dynamic_cast<const pat::Muon*>(collSelGG[0]->daughter("muon1"));
154  const pat::Muon* muon2 = dynamic_cast<const pat::Muon*>(collSelGG[0]->daughter("muon2"));
155  if (muonType_ == -1 || muonType_ == -2) {
156  tracks.push_back(*(muon1->innerTrack()));
157  tracks.push_back(*(muon2->innerTrack()));
158  collMuSel.push_back(muon1);
159  collMuSel.push_back(muon2);
160  }
161  }
162  else if (collSelGG.empty() && !collSelGT.empty()){
163  //CHECK THAT THEY ARE ORDERED BY PT !!!!!!!!!!!!!!!!!!!!!!!
164  const pat::Muon* muon1 = dynamic_cast<const pat::Muon*>(collSelGT[0]->daughter("muon1"));
165  const pat::Muon* muon2 = dynamic_cast<const pat::Muon*>(collSelGT[0]->daughter("muon2"));
166  if (muonType_ == -1 || muonType_ == -3) {
167  tracks.push_back(*(muon1->innerTrack()));
168  tracks.push_back(*(muon2->innerTrack()));
169  collMuSel.push_back(muon1);
170  collMuSel.push_back(muon2);
171  }
172  }
173  else if (collSelGG.empty() && collSelGT.empty() && !collSelTT.empty()){
174  //CHECK THAT THEY ARE ORDERED BY PT !!!!!!!!!!!!!!!!!!!!!!!
175  const pat::Muon* muon1 = dynamic_cast<const pat::Muon*>(collSelTT[0]->daughter("muon1"));
176  const pat::Muon* muon2 = dynamic_cast<const pat::Muon*>(collSelTT[0]->daughter("muon2"));
177  if (muonType_ == -1 || muonType_ == -4) {
178  tracks.push_back(*(muon1->innerTrack()));
179  tracks.push_back(*(muon2->innerTrack()));
180  collMuSel.push_back(muon1);
181  collMuSel.push_back(muon2);
182  }
183  }
184  if (tracks.size() != 2 && !tracks.empty()){
185  std::cout<<"ERROR strange number of muons selected by onia cuts!"<<std::endl;
186  abort();
187  }
188  muons = fillMuonCollection(tracks);
189  }
190  else if ((muonType_<4 && muonType_>=0) || muonType_>=10) { // Muons (glb,sta,trk)
191  std::vector<reco::Track> tracks;
192  if (PATmuons_ == true) {
194  event.getByLabel(muonLabel_, allMuons);
195  if (muonType_ == 0) {
196  // Take directly the muon
197  muons = fillMuonCollection(*allMuons);
198  }
199  else {
200  for (std::vector<pat::Muon>::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon) {
201  //std::cout<<"pat muon is global "<<muon->isGlobalMuon()<<std::endl;
202  takeSelectedMuonType(muon, tracks);
203  }
204  muons = fillMuonCollection(tracks);
205  }
206  }
207  else {
209  event.getByLabel(muonLabel_, allMuons);
210  if (muonType_ == 0) {
211  // Take directly the muon
212  muons = fillMuonCollection(*allMuons);
213  }
214  else {
215  for (std::vector<reco::Muon>::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon) {
216  takeSelectedMuonType(muon, tracks);
217  }
218  muons = fillMuonCollection(tracks);
219  }
220  }
221  }
222  else if (muonType_==4){ //CaloMuons
224  event.getByLabel(muonLabel_, caloMuons);
225  std::vector<reco::Track> tracks;
226  for (std::vector<reco::CaloMuon>::const_iterator muon = caloMuons->begin(); muon != caloMuons->end(); ++muon){
227  tracks.push_back(*(muon->track()));
228  }
229  muons = fillMuonCollection(tracks);
230  }
231 
232  else if (muonType_==5) { // Inner tracker tracks
234  event.getByLabel(muonLabel_, tracks);
235  muons = fillMuonCollection(*tracks);
236  }
237  plotter->fillRec(muons);
238 
239  // Generation and simulation part
240  if (speedup_ == false)
241  {
242  if (PATmuons_) {
243  // EM 2015.04.02 temporary fix to run on MINIAODSIM (which contains PAT muons) but not the "onia2MuMuPatTrkTrk" collection
244  // selectGeneratedMuons(collAll, collMuSel, genPair, plotter);
245  selectGenSimMuons(event, genPair, simPair, plotter);
246  }
247  else {
248  selectGenSimMuons(event, genPair, simPair, plotter);
249  }
250  }
251 }
252 
255  const std::vector<const pat::Muon*> & collMuSel,
256  std::vector<GenMuonPair> & genPair,
258 {
259  reco::GenParticleCollection genPatParticles{};
260 
261  //explicitly for JPsi but can be adapted!!!!!
262  for(std::vector<pat::CompositeCandidate>::const_iterator it=collAll->begin();
263  it!=collAll->end();++it) {
264  reco::GenParticleRef genJpsi = it->genParticleRef();
265  bool isMatched = (genJpsi.isAvailable() && genJpsi->pdgId() == 443);
266  if (isMatched){
267  genPatParticles.push_back(*genJpsi.get());
268  }
269  }
270 
271  if(collMuSel.size()==2) {
272  reco::GenParticleRef genMu1 = collMuSel[0]->genParticleRef();
273  reco::GenParticleRef genMu2 = collMuSel[1]->genParticleRef();
274  bool isMuMatched = (genMu1.isAvailable() && genMu2.isAvailable() &&
275  genMu1->pdgId()*genMu2->pdgId() == -169);
276  if (isMuMatched) {
277  genPatParticles.push_back(*genMu1.get());
278  genPatParticles.push_back(*genMu2.get());
279 
280  unsigned int motherId = 0;
281  if( genMu1->mother() != nullptr ) {
282  motherId = genMu1->mother()->pdgId();
283  }
284  if(genMu1->pdgId()==13)
285  genPair.push_back(GenMuonPair(genMu1.get()->p4(), genMu2.get()->p4(), motherId));
286  else
287  // genPair.push_back(std::make_pair(genMu2.get()->p4(),genMu1.get()->p4()) );
288  genPair.push_back(GenMuonPair(genMu2.get()->p4(), genMu1.get()->p4(), motherId));
289 
290  plotter->fillGen(genPatParticles, true);
291 
292  if (debug_>0) std::cout << "Found genParticles in PAT" << std::endl;
293  }
294  else {
295  std::cout << "No recomuon selected so no access to generated info"<<std::endl;
296  // Fill it in any case, otherwise it will not be in sync with the event number
297  // genPair.push_back( std::make_pair( lorentzVector(0.,0.,0.,0.), lorentzVector(0.,0.,0.,0.) ) );
298  genPair.push_back( GenMuonPair(lorentzVector(0.,0.,0.,0.), lorentzVector(0.,0.,0.,0.), 0 ) );
299  }
300  }
301  else{
302  std::cout << "No recomuon selected so no access to generated info"<<std::endl;
303  // Fill it in any case, otherwise it will not be in sync with the event number
304  // genPair.push_back( std::make_pair( lorentzVector(0.,0.,0.,0.), lorentzVector(0.,0.,0.,0.) ) );
305  genPair.push_back( GenMuonPair(lorentzVector(0.,0.,0.,0.), lorentzVector(0.,0.,0.,0.), 0 ) );
306  }
307  if(debug_>0) {
308  std::cout << "genParticles:" << std::endl;
309  // std::cout << genPair.back().first << " , " << genPair.back().second << std::endl;
310  std::cout << genPair.back().mu1 << " , " << genPair.back().mu2 << std::endl;
311  }
312 }
313 
315  std::vector<GenMuonPair> & genPair,
316  std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
318 {
319  // Find and store in histograms the generated and simulated resonance and muons
320  // ----------------------------------------------------------------------------
323 
324  // Fill gen information only in the first loop
325  bool ifHepMC=false;
326 
327  event.getByLabel( genParticlesName_, evtMC );
328  event.getByLabel( genParticlesName_, genParticles );
329  if( evtMC.isValid() ) {
330  genPair.push_back( findGenMuFromRes(evtMC.product()) );
331  plotter->fillGen(*evtMC, sherpa_);
332  ifHepMC = true;
333  if (debug_>0) std::cout << "Found hepMC" << std::endl;
334  }
335  else if( genParticles.isValid() ) {
336  genPair.push_back( findGenMuFromRes(genParticles.product()) );
337  plotter->fillGen(*genParticles);
338  if (debug_>0) std::cout << "Found genParticles" << std::endl;
339  }
340  else {
341  std::cout<<"ERROR "<<"non generation info and speedup true!!!!!!!!!!!!"<<std::endl;
342  // Fill it in any case, otherwise it will not be in sync with the event number
343  // genPair.push_back( std::make_pair( lorentzVector(0.,0.,0.,0.), lorentzVector(0.,0.,0.,0.) ) );
344  genPair.push_back( GenMuonPair( lorentzVector(0.,0.,0.,0.), lorentzVector(0.,0.,0.,0.), 0 ) );
345  }
346  if(debug_>0) {
347  std::cout << "genParticles:" << std::endl;
348  std::cout << genPair.back().mu1 << " , " << genPair.back().mu2 << std::endl;
349  }
350  selectSimulatedMuons(event, ifHepMC, evtMC, simPair, plotter);
351 }
352 
354  const bool ifHepMC, edm::Handle<edm::HepMCProduct> evtMC,
355  std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
357 {
359  bool simTracksFound = false;
360  event.getByLabel(simTracksCollectionName_, simTracks);
361  if( simTracks.isValid() ) {
362  plotter->fillSim(simTracks);
363  if(ifHepMC) {
364  simPair.push_back( findSimMuFromRes(evtMC, simTracks) );
365  simTracksFound = true;
366  plotter->fillGenSim(evtMC,simTracks);
367  }
368  }
369  else {
370  std::cout << "SimTracks not existent" << std::endl;
371  }
372  if( !simTracksFound ) {
373  simPair.push_back( std::make_pair( lorentzVector(0.,0.,0.,0.), lorentzVector(0.,0.,0.,0.) ) );
374  }
375 }
376 
378 {
379  const HepMC::GenEvent* Evt = evtMC->GetEvent();
380  GenMuonPair muFromRes;
381  //Loop on generated particles
382  for (HepMC::GenEvent::particle_const_iterator part=Evt->particles_begin();
383  part!=Evt->particles_end(); part++) {
384  if (std::abs((*part)->pdg_id())==13 && (*part)->status()==1) {
385  bool fromRes = false;
386  unsigned int motherPdgId = 0;
387  for (HepMC::GenVertex::particle_iterator mother = (*part)->production_vertex()->particles_begin(HepMC::ancestors);
388  mother != (*part)->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
389  motherPdgId = (*mother)->pdg_id();
390 
391  // For sherpa the resonance is not saved. The muons from the resonance can be identified
392  // by having as mother a muon of status 3.
393  if( sherpa_ ) {
394  if( motherPdgId == 13 && (*mother)->status() == 3 ) fromRes = true;
395  }
396  else {
397  for( int ires = 0; ires < 6; ++ires ) {
398  if( motherPdgId == motherPdgIdArray[ires] && resfind_[ires] ) fromRes = true;
399  }
400  }
401  }
402  if(fromRes){
403  if((*part)->pdg_id()==13) {
404  // muFromRes.first = (*part)->momentum();
405  muFromRes.mu1 = (lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
406  (*part)->momentum().pz(),(*part)->momentum().e()));
407  }
408  else {
409  muFromRes.mu2 = (lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
410  (*part)->momentum().pz(),(*part)->momentum().e()));
411  }
412  muFromRes.motherId = motherPdgId;
413  }
414  }
415  }
416  return muFromRes;
417 }
418 
419 // std::pair<lorentzVector, lorentzVector> MuScleFitMuonSelector::findGenMuFromRes( const reco::GenParticleCollection* genParticles)
421 {
422  // std::pair<lorentzVector,lorentzVector> muFromRes;
423  GenMuonPair muFromRes;
424 
425  //Loop on generated particles
426  if( debug_>0 ) std::cout << "Starting loop on " << genParticles->size() << " genParticles" << std::endl;
427  for( reco::GenParticleCollection::const_iterator part=genParticles->begin(); part!=genParticles->end(); ++part ) {
428  if (debug_>0) std::cout<<"genParticle has pdgId = "<<std::abs(part->pdgId())<<" and status = "<<part->status()<<std::endl;
429  if (std::abs(part->pdgId())==13){// && part->status()==3) {
430  bool fromRes = false;
431  unsigned int motherPdgId = part->mother()->pdgId();
432  if( debug_>0 ) {
433  std::cout << "Found a muon with mother: " << motherPdgId << std::endl;
434  }
435  for( int ires = 0; ires < 6; ++ires ) {
436  // if( motherPdgId == motherPdgIdArray[ires] && resfind_[ires] ) fromRes = true; // changed by EM 2015.07.30
437  // begin of comment
438  // the list of resonances motherPdgIdArray does not contain the photon (PdgId = 21) while ~1% of the
439  // mu+mu- events in the range [50,120] GeV has a photon as the mother.
440  // It needs to be fixed without spoiling the logic of the selection of different resonances
441  // e.g. mixing up onia etc.
442  // end of comment
443  if( ( motherPdgId == motherPdgIdArray[ires] && resfind_[ires] ) || motherPdgId == 21 ) fromRes = true;
444  }
445  if(fromRes){
446  if (debug_>0) std::cout<<"fromRes = true, motherPdgId = "<<motherPdgId<<std::endl;
447  const reco::Candidate* status3Muon = &(*part);
448  const reco::Candidate* status1Muon = getStatus1Muon(status3Muon);
449  if(part->pdgId()==13) {
450  if (status1Muon->p4().pt()!=0) muFromRes.mu1 = MuScleFitMuon(status1Muon->p4(),-1);
451  else muFromRes.mu1 = MuScleFitMuon(status3Muon->p4(),-1);
452  if( debug_>0 ) std::cout << "Found a genMuon - : " << muFromRes.mu1 << std::endl;
453  // muFromRes.first = (lorentzVector(status1Muon->p4().px(),status1Muon->p4().py(),
454  // status1Muon->p4().pz(),status1Muon->p4().e()));
455  }
456  else {
457  if (status1Muon->p4().pt()!=0) muFromRes.mu2 = MuScleFitMuon(status1Muon->p4(),+1);
458  else muFromRes.mu2 = MuScleFitMuon(status3Muon->p4(),+1);
459  if( debug_>0 ) std::cout << "Found a genMuon + : " << muFromRes.mu2 << std::endl;
460  // muFromRes.second = (lorentzVector(status1Muon->p4().px(),status1Muon->p4().py(),
461  // status1Muon->p4().pz(),status1Muon->p4().e()));
462  }
463  muFromRes.motherId = motherPdgId;
464  }
465  }
466  }
467  return muFromRes;
468 }
469 
470 std::pair<lorentzVector, lorentzVector> MuScleFitMuonSelector::findSimMuFromRes( const edm::Handle<edm::HepMCProduct> & evtMC,
472 {
473  //Loop on simulated tracks
474  std::pair<lorentzVector, lorentzVector> simMuFromRes;
475  for( edm::SimTrackContainer::const_iterator simTrack=simTracks->begin(); simTrack!=simTracks->end(); ++simTrack ) {
476  //Chose muons
477  if (std::abs((*simTrack).type())==13) {
478  //If tracks from IP than find mother
479  if ((*simTrack).genpartIndex()>0) {
480  HepMC::GenParticle* gp = evtMC->GetEvent()->barcode_to_particle ((*simTrack).genpartIndex());
481  if( gp != nullptr ) {
482 
483  for (HepMC::GenVertex::particle_iterator mother = gp->production_vertex()->particles_begin(HepMC::ancestors);
484  mother!=gp->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
485 
486  bool fromRes = false;
487  unsigned int motherPdgId = (*mother)->pdg_id();
488  for( int ires = 0; ires < 6; ++ires ) {
489  if( ( motherPdgId == motherPdgIdArray[ires] && resfind_[ires] ) || motherPdgId == 21 ) fromRes = true;
490  }
491  if( fromRes ) {
492  if(gp->pdg_id() == 13)
493  simMuFromRes.first = lorentzVector(simTrack->momentum().px(),simTrack->momentum().py(),
494  simTrack->momentum().pz(),simTrack->momentum().e());
495  else
496  simMuFromRes.second = lorentzVector(simTrack->momentum().px(),simTrack->momentum().py(),
497  simTrack->momentum().pz(),simTrack->momentum().e());
498  }
499  }
500  }
501  // else LogDebug("MuScleFitUtils") << "WARNING: no matching genParticle found for simTrack" << std::endl;
502  }
503  }
504  }
505  return simMuFromRes;
506 }
Analysis-level particle class.
bool isAvailable() const
Definition: Ref.h:575
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
void selectGeneratedMuons(const edm::Handle< pat::CompositeCandidateCollection > &collAll, const std::vector< const pat::Muon * > &collMuSel, std::vector< GenMuonPair > &genPair, MuScleFitPlotter *plotter)
For PATmuons the generator information is read directly from the PAT object.
std::pair< lorentzVector, lorentzVector > findSimMuFromRes(const edm::Handle< edm::HepMCProduct > &evtMC, const edm::Handle< edm::SimTrackContainer > &simTracks)
const std::string genParticlesName_
void selectMuons(const edm::Event &event, std::vector< MuScleFitMuon > &muons, std::vector< GenMuonPair > &genPair, std::vector< std::pair< lorentzVector, lorentzVector > > &simPair, MuScleFitPlotter *plotter)
Main method used to select muons of type specified by muonType_ from the collection specified by muon...
void fillGenSim(edm::Handle< edm::HepMCProduct > evtMC, edm::Handle< edm::SimTrackContainer > simTracks)
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
int ires[2]
std::vector< MuScleFitMuon > fillMuonCollection(const std::vector< T > &tracks)
Template function used to convert the muon collection to a vector of reco::LeafCandidate.
#define nullptr
bool selTrackerMuon(const pat::Muon *aMuon)
Apply the Onia cuts to select trackerMuons.
bool muonID(const std::string &name) const
int charge() const final
electric charge
Definition: LeafCandidate.h:91
void selectSimulatedMuons(const edm::Event &event, const bool ifHepMC, edm::Handle< edm::HepMCProduct > evtMC, std::vector< std::pair< lorentzVector, lorentzVector > > &simPair, MuScleFitPlotter *plotter)
MuScleFitMuon mu1
Definition: GenMuonPair.h:54
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:538
Int_t motherId
Definition: GenMuonPair.h:56
float userFloat(const std::string &key) const
Definition: PATObject.h:791
reco::Particle::LorentzVector lorentzVector
Definition: GenMuonPair.h:9
bool isTrackerMuon() const override
Definition: Muon.h:292
static const unsigned int motherPdgIdArray[6]
const edm::InputTag muonLabel_
static const double mMu2
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:73
void fillRec(std::vector< MuScleFitMuon > &muons)
Used when running on the root tree containing preselected muon pairs.
bool isGlobalMuon() const override
Definition: Muon.h:291
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
virtual int pdgId() const =0
PDG identifier.
void fillSim(edm::Handle< edm::SimTrackContainer > simTracks)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isMatched(TrackingRecHit const &hit)
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
bool isValid() const
Definition: HandleBase.h:74
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
T const * product() const
Definition: Handle.h:74
reco::TrackRef globalTrack() const override
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.h:81
part
Definition: HCALResponse.h:20
GenMuonPair findGenMuFromRes(const reco::GenParticleCollection *genParticles)
void selectGenSimMuons(const edm::Event &event, std::vector< GenMuonPair > &genPair, std::vector< std::pair< lorentzVector, lorentzVector > > &simPair, MuScleFitPlotter *plotter)
void fillGen(const reco::GenParticleCollection &genParticles, bool=false)
const edm::InputTag simTracksCollectionName_
bool selGlobalMuon(const pat::Muon *aMuon)
Apply the Onia cuts to select globalMuons.
void takeSelectedMuonType(const T &muon, std::vector< reco::Track > &tracks)
Template function used to extract the selected muon type from the muon collection.
int numberOfValidMuonHits() const
Definition: HitPattern.h:906
const reco::Candidate * getStatus3Muon(const reco::Candidate *status3Muon)
virtual size_type numberOfDaughters() const =0
number of daughters
const std::vector< int > resfind_
Analysis-level muon class.
Definition: Muon.h:50
MuScleFitMuon mu2
Definition: GenMuonPair.h:55
Definition: event.py:1
const reco::Candidate * getStatus1Muon(const reco::Candidate *status3Muon)