14 if (status == 1)
break;
18 tempStatus1Muon = tempStatus1Muon->
daughter(
i);
19 status = tempStatus1Muon->
status();
25 return tempStatus1Muon;
38 iTrack->found() > 11 &&
39 gTrack->chi2()/gTrack->ndof() < 20.0 &&
41 iTrack->chi2()/iTrack->ndof() < 4.0 &&
42 aMuon->
muonID(
"TrackerMuonArbitrated") &&
43 aMuon->
muonID(
"TMLastStationAngTight") &&
45 fabs(iTrack->dxy()) < 3.0 &&
46 fabs(iTrack->dz()) < 15.0
56 iTrack->found() > 11 &&
57 iTrack->chi2()/iTrack->ndof() < 4.0 &&
58 aMuon->
muonID(
"TrackerMuonArbitrated") &&
59 aMuon->
muonID(
"TMLastStationAngTight") &&
61 fabs(iTrack->dxy()) < 3.0 &&
62 fabs(iTrack->dz()) < 15.0
70 std::vector<GenMuonPair> & genPair,
71 std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
75 try {
event.getByLabel(
"onia2MuMuPatTrkTrk",collAll);}
76 catch (...) {
std::cout <<
"J/psi not present in event!" << std::endl;}
77 std::vector<const pat::Muon*> collMuSel;
82 std::vector<const pat::CompositeCandidate*> collSelGG;
83 std::vector<const pat::CompositeCandidate*> collSelGT;
84 std::vector<const pat::CompositeCandidate*> collSelTT;
87 for(std::vector<pat::CompositeCandidate>::const_iterator it=collAll->begin();
88 it!=collAll->end();++it) {
100 collSelGG.push_back(cand);
107 collSelGT.push_back(cand);
113 collSelGT.push_back(cand);
120 collSelTT.push_back(cand);
127 std::vector<reco::Track>
tracks;
128 if(collSelGG.size()){
130 const pat::Muon* muon1 =
dynamic_cast<const pat::Muon*
>(collSelGG[0]->daughter(
"muon1"));
131 const pat::Muon* muon2 =
dynamic_cast<const pat::Muon*
>(collSelGG[0]->daughter(
"muon2"));
135 collMuSel.push_back(muon1);
136 collMuSel.push_back(muon2);
139 else if(!collSelGG.size() && collSelGT.size()){
141 const pat::Muon* muon1 =
dynamic_cast<const pat::Muon*
>(collSelGT[0]->daughter(
"muon1"));
142 const pat::Muon* muon2 =
dynamic_cast<const pat::Muon*
>(collSelGT[0]->daughter(
"muon2"));
146 collMuSel.push_back(muon1);
147 collMuSel.push_back(muon2);
150 else if(!collSelGG.size() && !collSelGT.size() && collSelTT.size()){
152 const pat::Muon* muon1 =
dynamic_cast<const pat::Muon*
>(collSelTT[0]->daughter(
"muon1"));
153 const pat::Muon* muon2 =
dynamic_cast<const pat::Muon*
>(collSelTT[0]->daughter(
"muon2"));
157 collMuSel.push_back(muon1);
158 collMuSel.push_back(muon2);
161 if (tracks.size() != 2 && tracks.size() != 0){
162 std::cout<<
"ERROR strange number of muons selected by onia cuts!"<<std::endl;
167 else if( (muonType_<4 && muonType_>=0) ||
muonType_>=10 ) {
168 std::vector<reco::Track>
tracks;
177 for( std::vector<pat::Muon>::const_iterator
muon = allMuons->begin();
muon != allMuons->end(); ++
muon ) {
192 for( std::vector<reco::Muon>::const_iterator
muon = allMuons->begin();
muon != allMuons->end(); ++
muon ) {
202 std::vector<reco::Track>
tracks;
203 for (std::vector<reco::CaloMuon>::const_iterator
muon = caloMuons->begin();
muon != caloMuons->end(); ++
muon){
204 tracks.push_back(*(
muon->track()));
232 const std::vector<const pat::Muon*> & collMuSel,
233 std::vector<GenMuonPair> & genPair,
239 for(std::vector<pat::CompositeCandidate>::const_iterator it=collAll->begin();
240 it!=collAll->end();++it) {
244 genPatParticles->push_back(*(const_cast<reco::GenParticle*>(genJpsi.
get())));
248 if(collMuSel.size()==2) {
252 genMu1->pdgId()*genMu2->pdgId() == -169);
254 genPatParticles->push_back(*(const_cast<reco::GenParticle*>(genMu1.
get())));
255 genPatParticles->push_back(*(const_cast<reco::GenParticle*>(genMu2.
get())));
257 unsigned int motherId = 0;
258 if( genMu1->mother() != 0 ) {
259 motherId = genMu1->mother()->pdgId();
261 if(genMu1->pdgId()==13)
262 genPair.push_back(
GenMuonPair(genMu1.
get()->p4(), genMu2.
get()->p4(), motherId));
265 genPair.push_back(
GenMuonPair(genMu2.
get()->p4(), genMu1.
get()->p4(), motherId));
267 plotter->
fillGen(const_cast <reco::GenParticleCollection*> (genPatParticles),
true);
272 std::cout <<
"No recomuon selected so no access to generated info"<<std::endl;
279 std::cout <<
"No recomuon selected so no access to generated info"<<std::endl;
285 std::cout <<
"genParticles:" << std::endl;
287 std::cout << genPair.back().mu1 <<
" , " << genPair.back().mu2 << std::endl;
292 std::vector<GenMuonPair> & genPair,
293 std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
312 else if( genParticles.
isValid() ) {
318 std::cout<<
"ERROR "<<
"non generation info and speedup true!!!!!!!!!!!!"<<std::endl;
324 std::cout <<
"genParticles:" << std::endl;
325 std::cout << genPair.back().mu1 <<
" , " << genPair.back().mu2 << std::endl;
332 std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
336 bool simTracksFound =
false;
342 simTracksFound =
true;
347 std::cout <<
"SimTracks not existent" << std::endl;
349 if( !simTracksFound ) {
356 const HepMC::GenEvent* Evt = evtMC->
GetEvent();
359 for (HepMC::GenEvent::particle_const_iterator
part=Evt->particles_begin();
360 part!=Evt->particles_end();
part++) {
361 if (fabs((*part)->pdg_id())==13 && (*part)->status()==1) {
362 bool fromRes =
false;
363 unsigned int motherPdgId = 0;
364 for (HepMC::GenVertex::particle_iterator mother = (*part)->production_vertex()->particles_begin(HepMC::ancestors);
365 mother != (*part)->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
366 motherPdgId = (*mother)->pdg_id();
371 if( motherPdgId == 13 && (*mother)->status() == 3 ) fromRes =
true;
380 if((*part)->pdg_id()==13) {
382 muFromRes.
mu1 = (
lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
383 (*part)->momentum().pz(),(*part)->momentum().e()));
386 muFromRes.
mu2 = (
lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
387 (*part)->momentum().pz(),(*part)->momentum().e()));
403 if(
debug_>0 )
std::cout <<
"Starting loop on " << genParticles->size() <<
" genParticles" << std::endl;
404 for( reco::GenParticleCollection::const_iterator
part=genParticles->begin();
part!=genParticles->end(); ++
part ) {
405 if (
debug_>0)
std::cout<<
"genParticle has pdgId = "<<fabs(
part->pdgId())<<
" and status = "<<
part->status()<<std::endl;
406 if (fabs(
part->pdgId())==13){
407 bool fromRes =
false;
408 unsigned int motherPdgId =
part->mother()->pdgId();
410 std::cout <<
"Found a muon with mother: " << motherPdgId << std::endl;
416 if (
debug_>0)
std::cout<<
"fromRes = true, motherPdgId = "<<motherPdgId<<std::endl;
419 if(
part->pdgId()==13) {
443 std::pair<lorentzVector, lorentzVector> simMuFromRes;
444 for( edm::SimTrackContainer::const_iterator simTrack=simTracks->begin(); simTrack!=simTracks->end(); ++simTrack ) {
446 if (fabs((*simTrack).type())==13) {
448 if ((*simTrack).genpartIndex()>0) {
449 HepMC::GenParticle* gp = evtMC->GetEvent()->barcode_to_particle ((*simTrack).genpartIndex());
452 for (HepMC::GenVertex::particle_iterator mother = gp->production_vertex()->particles_begin(HepMC::ancestors);
453 mother!=gp->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
455 bool fromRes =
false;
456 unsigned int motherPdgId = (*mother)->pdg_id();
461 if(gp->pdg_id() == 13)
462 simMuFromRes.first =
lorentzVector(simTrack->momentum().px(),simTrack->momentum().py(),
463 simTrack->momentum().pz(),simTrack->momentum().e());
465 simMuFromRes.second =
lorentzVector(simTrack->momentum().px(),simTrack->momentum().py(),
466 simTrack->momentum().pz(),simTrack->momentum().e());
Analysis-level particle class.
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.
reco::TrackRef innerTrack() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
std::pair< lorentzVector, lorentzVector > findSimMuFromRes(const edm::Handle< edm::HepMCProduct > &evtMC, const 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) ...
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)
bool isTrackerMuon() const
virtual int status() const =0
status word
std::vector< MuScleFitMuon > fillMuonCollection(const std::vector< T > &tracks)
Template function used to convert the muon collection to a vector of reco::LeafCandidate.
bool selTrackerMuon(const pat::Muon *aMuon)
Apply the Onia cuts to select trackerMuons.
bool isGlobalMuon() const
bool muonID(const std::string &name) const
void selectSimulatedMuons(const edm::Event &event, const bool ifHepMC, edm::Handle< edm::HepMCProduct > evtMC, std::vector< std::pair< lorentzVector, lorentzVector > > &simPair, MuScleFitPlotter *plotter)
int pixelLayersWithMeasurement() const
float userFloat(const std::string &key) const
reco::Particle::LorentzVector lorentzVector
static const unsigned int motherPdgIdArray[6]
const edm::InputTag muonLabel_
virtual size_type numberOfDaughters() const =0
number of daughters
void fillRec(std::vector< MuScleFitMuon > &muons)
Used when running on the root tree containing preselected muon pairs.
void fillSim(edm::Handle< edm::SimTrackContainer > simTracks)
virtual int charge() const
electric charge
bool isMatched(TrackingRecHit const &hit)
T const * get() const
Returns C++ pointer to the item.
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
reco::TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
virtual int pdgId() const =0
PDG identifier.
const HepMC::GenEvent * GetEvent() const
T const * product() const
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)
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
const edm::InputTag simTracksCollectionName_
void fillGen(const reco::GenParticleCollection *genParticles, bool=false)
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
const std::vector< int > resfind_
Analysis-level muon class.
const reco::Candidate * getStatus1Muon(const reco::Candidate *status3Muon)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector