15 if ( isPromptFinalState )
break;
34 if ( lastCopy )
break;
59 iTrack->found() > 11 &&
60 gTrack->chi2()/gTrack->ndof() < 20.0 &&
62 iTrack->chi2()/iTrack->ndof() < 4.0 &&
63 aMuon->
muonID(
"TrackerMuonArbitrated") &&
64 aMuon->
muonID(
"TMLastStationAngTight") &&
66 fabs(iTrack->dxy()) < 3.0 &&
67 fabs(iTrack->dz()) < 15.0
77 iTrack->found() > 11 &&
78 iTrack->chi2()/iTrack->ndof() < 4.0 &&
79 aMuon->
muonID(
"TrackerMuonArbitrated") &&
80 aMuon->
muonID(
"TMLastStationAngTight") &&
82 fabs(iTrack->dxy()) < 3.0 &&
83 fabs(iTrack->dz()) < 15.0
91 std::vector<GenMuonPair> & genPair,
92 std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
96 try {
event.getByLabel(
"onia2MuMuPatTrkTrk",collAll);}
97 catch (...) {
std::cout <<
"J/psi not present in event!" << std::endl;}
98 std::vector<const pat::Muon*> collMuSel;
103 std::vector<const pat::CompositeCandidate*> collSelGG;
104 std::vector<const pat::CompositeCandidate*> collSelGT;
105 std::vector<const pat::CompositeCandidate*> collSelTT;
108 for(std::vector<pat::CompositeCandidate>::const_iterator it=collAll->begin();
109 it!=collAll->end();++it) {
121 collSelGG.push_back(cand);
128 collSelGT.push_back(cand);
134 collSelGT.push_back(cand);
141 collSelTT.push_back(cand);
148 std::vector<reco::Track>
tracks;
149 if(collSelGG.size()){
151 const pat::Muon* muon1 =
dynamic_cast<const pat::Muon*
>(collSelGG[0]->daughter(
"muon1"));
152 const pat::Muon* muon2 =
dynamic_cast<const pat::Muon*
>(collSelGG[0]->daughter(
"muon2"));
156 collMuSel.push_back(muon1);
157 collMuSel.push_back(muon2);
160 else if(!collSelGG.size() && collSelGT.size()){
162 const pat::Muon* muon1 =
dynamic_cast<const pat::Muon*
>(collSelGT[0]->daughter(
"muon1"));
163 const pat::Muon* muon2 =
dynamic_cast<const pat::Muon*
>(collSelGT[0]->daughter(
"muon2"));
167 collMuSel.push_back(muon1);
168 collMuSel.push_back(muon2);
171 else if(!collSelGG.size() && !collSelGT.size() && collSelTT.size()){
173 const pat::Muon* muon1 =
dynamic_cast<const pat::Muon*
>(collSelTT[0]->daughter(
"muon1"));
174 const pat::Muon* muon2 =
dynamic_cast<const pat::Muon*
>(collSelTT[0]->daughter(
"muon2"));
178 collMuSel.push_back(muon1);
179 collMuSel.push_back(muon2);
182 if (tracks.size() != 2 && tracks.size() != 0){
183 std::cout<<
"ERROR strange number of muons selected by onia cuts!"<<std::endl;
188 else if( (muonType_<4 && muonType_>=0) ||
muonType_>=10 ) {
189 std::vector<reco::Track>
tracks;
198 for( std::vector<pat::Muon>::const_iterator
muon = allMuons->begin();
muon != allMuons->end(); ++
muon ) {
213 for( std::vector<reco::Muon>::const_iterator
muon = allMuons->begin();
muon != allMuons->end(); ++
muon ) {
223 std::vector<reco::Track>
tracks;
224 for (std::vector<reco::CaloMuon>::const_iterator
muon = caloMuons->begin();
muon != caloMuons->end(); ++
muon){
225 tracks.push_back(*(
muon->track()));
253 const std::vector<const pat::Muon*> & collMuSel,
254 std::vector<GenMuonPair> & genPair,
260 for(std::vector<pat::CompositeCandidate>::const_iterator it=collAll->begin();
261 it!=collAll->end();++it) {
265 genPatParticles->push_back(*(const_cast<reco::GenParticle*>(genJpsi.
get())));
269 if(collMuSel.size()==2) {
273 genMu1->pdgId()*genMu2->pdgId() == -169);
275 genPatParticles->push_back(*(const_cast<reco::GenParticle*>(genMu1.
get())));
276 genPatParticles->push_back(*(const_cast<reco::GenParticle*>(genMu2.
get())));
278 unsigned int motherId = 0;
279 if( genMu1->mother() != 0 ) {
280 motherId = genMu1->mother()->pdgId();
282 if(genMu1->pdgId()==13)
283 genPair.push_back(
GenMuonPair(genMu1.
get()->p4(), genMu2.
get()->p4(), motherId));
286 genPair.push_back(
GenMuonPair(genMu2.
get()->p4(), genMu1.
get()->p4(), motherId));
288 plotter->
fillGen(const_cast <reco::GenParticleCollection*> (genPatParticles),
true);
293 std::cout <<
"No recomuon selected so no access to generated info"<<std::endl;
300 std::cout <<
"No recomuon selected so no access to generated info"<<std::endl;
306 std::cout <<
"genParticles:" << std::endl;
308 std::cout << genPair.back().mu1 <<
" , " << genPair.back().mu2 << std::endl;
313 std::vector<GenMuonPair> & genPair,
314 std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
333 else if( genParticles.
isValid() ) {
339 std::cout<<
"ERROR "<<
"non generation info and speedup true!!!!!!!!!!!!"<<std::endl;
345 std::cout <<
"genParticles:" << std::endl;
346 std::cout << genPair.back().mu1 <<
" , " << genPair.back().mu2 << std::endl;
353 std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
357 bool simTracksFound =
false;
363 simTracksFound =
true;
368 std::cout <<
"SimTracks not existent" << std::endl;
370 if( !simTracksFound ) {
377 const HepMC::GenEvent* Evt = evtMC->
GetEvent();
380 for (HepMC::GenEvent::particle_const_iterator
part=Evt->particles_begin();
381 part!=Evt->particles_end();
part++) {
382 if (fabs((*part)->pdg_id())==13 && (*part)->status()==1) {
383 bool fromRes =
false;
384 unsigned int motherPdgId = 0;
385 for (HepMC::GenVertex::particle_iterator mother = (*part)->production_vertex()->particles_begin(HepMC::ancestors);
386 mother != (*part)->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
387 motherPdgId = (*mother)->pdg_id();
392 if( motherPdgId == 13 && (*mother)->status() == 3 ) fromRes =
true;
401 if((*part)->pdg_id()==13) {
403 muFromRes.
mu1 = (
lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
404 (*part)->momentum().pz(),(*part)->momentum().e()));
407 muFromRes.
mu2 = (
lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
408 (*part)->momentum().pz(),(*part)->momentum().e()));
424 if(
debug_>0 )
std::cout <<
"Starting loop on " << genParticles->size() <<
" genParticles" << std::endl;
425 for( reco::GenParticleCollection::const_iterator
part=genParticles->begin();
part!=genParticles->end(); ++
part ) {
426 if (
debug_>0)
std::cout<<
"genParticle has pdgId = "<<fabs(
part->pdgId())<<
" and status = "<<
part->status()<<std::endl;
427 if (fabs(
part->pdgId())==13){
428 bool fromRes =
false;
429 unsigned int motherPdgId =
part->mother()->pdgId();
431 std::cout <<
"Found a muon with mother: " << motherPdgId << std::endl;
444 if (
debug_>0)
std::cout<<
"fromRes = true, motherPdgId = "<<motherPdgId<<std::endl;
447 if(
part->pdgId()==13) {
472 std::pair<lorentzVector, lorentzVector> simMuFromRes;
473 for( edm::SimTrackContainer::const_iterator simTrack=simTracks->begin(); simTrack!=simTracks->end(); ++simTrack ) {
475 if (fabs((*simTrack).type())==13) {
477 if ((*simTrack).genpartIndex()>0) {
478 HepMC::GenParticle* gp = evtMC->GetEvent()->barcode_to_particle ((*simTrack).genpartIndex());
481 for (HepMC::GenVertex::particle_iterator mother = gp->production_vertex()->particles_begin(HepMC::ancestors);
482 mother!=gp->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
484 bool fromRes =
false;
485 unsigned int motherPdgId = (*mother)->pdg_id();
490 if(gp->pdg_id() == 13)
491 simMuFromRes.first =
lorentzVector(simTrack->momentum().px(),simTrack->momentum().py(),
492 simTrack->momentum().pz(),simTrack->momentum().e());
494 simMuFromRes.second =
lorentzVector(simTrack->momentum().px(),simTrack->momentum().py(),
495 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
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 final
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 reco::Candidate * getStatus3Muon(const reco::Candidate *status3Muon)
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