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") &&
77 iTrack->found() > 11 &&
78 iTrack->chi2()/iTrack->ndof() < 4.0 &&
79 aMuon->
muonID(
"TrackerMuonArbitrated") &&
80 aMuon->
muonID(
"TMLastStationAngTight") &&
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.empty()){
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.empty() && !collSelGT.empty()){
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.empty() && collSelGT.empty() && !collSelTT.empty()){
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.empty()){
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())));
279 if( genMu1->mother() !=
nullptr ) {
280 motherId = genMu1->mother()->pdgId();
282 if(genMu1->pdgId()==13)
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 ) {
380 for (HepMC::GenEvent::particle_const_iterator
part=Evt->particles_begin();
381 part!=Evt->particles_end();
part++) {
382 if (
std::abs((*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 ) {
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;
475 if (
std::abs((*simTrack).type())==13) {
477 if ((*simTrack).genpartIndex()>0) {
479 if( gp !=
nullptr ) {
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)
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.
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) ...
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 muonID(const std::string &name) const
int charge() const final
electric charge
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
bool isTrackerMuon() const override
static const unsigned int motherPdgIdArray[6]
const edm::InputTag muonLabel_
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
void fillRec(std::vector< MuScleFitMuon > &muons)
Used when running on the root tree containing preselected muon pairs.
bool isGlobalMuon() const override
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
virtual int pdgId() const =0
PDG identifier.
simTrack
per collection params
void fillSim(edm::Handle< edm::SimTrackContainer > simTracks)
Abs< T >::type abs(const T &t)
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.
const HepMC::GenEvent * GetEvent() const
T const * product() const
reco::TrackRef globalTrack() const override
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
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)
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)
virtual size_type numberOfDaughters() const =0
number of daughters
const std::vector< int > resfind_
Analysis-level muon class.
const reco::Candidate * getStatus1Muon(const reco::Candidate *status3Muon)