13 bool isPromptFinalState =
static_cast<const reco::GenParticle*
>(tempMuon)->isPromptFinalState();
15 if ( isPromptFinalState )
break;
20 isPromptFinalState =
static_cast<const reco::GenParticle*
>(tempMuon)->isPromptFinalState();
32 bool lastCopy =
static_cast<const reco::GenParticle*
>(tempMuon)->isLastCopyBeforeFSR();
34 if ( lastCopy )
break;
39 lastCopy =
static_cast<const reco::GenParticle*
>(tempMuon)->isLastCopyBeforeFSR();
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 event.getByLabel(
"onia2MuMuPatTrkTrk", collAll);
100 std::vector<const pat::Muon*> collMuSel;
105 std::vector<const pat::CompositeCandidate*> collSelGG;
106 std::vector<const pat::CompositeCandidate*> collSelGT;
107 std::vector<const pat::CompositeCandidate*> collSelTT;
110 for (std::vector<pat::CompositeCandidate>::const_iterator it=collAll->begin();
111 it!=collAll->end(); ++it) {
123 collSelGG.push_back(cand);
130 collSelGT.push_back(cand);
136 collSelGT.push_back(cand);
143 collSelTT.push_back(cand);
150 std::vector<reco::Track>
tracks;
151 if (!collSelGG.empty()){
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"));
158 collMuSel.push_back(muon1);
159 collMuSel.push_back(muon2);
162 else if (collSelGG.empty() && !collSelGT.empty()){
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"));
169 collMuSel.push_back(muon1);
170 collMuSel.push_back(muon2);
173 else if (collSelGG.empty() && collSelGT.empty() && !collSelTT.empty()){
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"));
180 collMuSel.push_back(muon1);
181 collMuSel.push_back(muon2);
184 if (tracks.size() != 2 && !tracks.empty()){
185 std::cout<<
"ERROR strange number of muons selected by onia cuts!"<<std::endl;
190 else if ((muonType_<4 && muonType_>=0) ||
muonType_>=10) {
191 std::vector<reco::Track>
tracks;
200 for (std::vector<pat::Muon>::const_iterator
muon = allMuons->begin();
muon != allMuons->end(); ++
muon) {
215 for (std::vector<reco::Muon>::const_iterator
muon = allMuons->begin();
muon != allMuons->end(); ++
muon) {
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()));
255 const std::vector<const pat::Muon*> & collMuSel,
256 std::vector<GenMuonPair> & genPair,
262 for(std::vector<pat::CompositeCandidate>::const_iterator it=collAll->begin();
263 it!=collAll->end();++it) {
267 genPatParticles.push_back(*genJpsi.
get());
271 if(collMuSel.size()==2) {
275 genMu1->pdgId()*genMu2->pdgId() == -169);
277 genPatParticles.push_back(*genMu1.
get());
278 genPatParticles.push_back(*genMu2.
get());
281 if( genMu1->mother() !=
nullptr ) {
282 motherId = genMu1->mother()->pdgId();
284 if(genMu1->pdgId()==13)
290 plotter->
fillGen(genPatParticles,
true);
295 std::cout <<
"No recomuon selected so no access to generated info"<<std::endl;
302 std::cout <<
"No recomuon selected so no access to generated info"<<std::endl;
308 std::cout <<
"genParticles:" << std::endl;
310 std::cout << genPair.back().mu1 <<
" , " << genPair.back().mu2 << std::endl;
315 std::vector<GenMuonPair> & genPair,
316 std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
335 else if( genParticles.
isValid() ) {
337 plotter->
fillGen(*genParticles);
341 std::cout<<
"ERROR "<<
"non generation info and speedup true!!!!!!!!!!!!"<<std::endl;
347 std::cout <<
"genParticles:" << std::endl;
348 std::cout << genPair.back().mu1 <<
" , " << genPair.back().mu2 << std::endl;
355 std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
359 bool simTracksFound =
false;
365 simTracksFound =
true;
370 std::cout <<
"SimTracks not existent" << std::endl;
372 if( !simTracksFound ) {
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();
394 if( motherPdgId == 13 && (*mother)->status() == 3 ) fromRes =
true;
403 if((*part)->pdg_id()==13) {
405 muFromRes.
mu1 = (
lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
406 (*part)->momentum().pz(),(*part)->momentum().e()));
409 muFromRes.
mu2 = (
lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
410 (*part)->momentum().pz(),(*part)->momentum().e()));
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 ) {
430 bool fromRes =
false;
431 unsigned int motherPdgId =
part->mother()->pdgId();
433 std::cout <<
"Found a muon with mother: " << motherPdgId << std::endl;
446 if (
debug_>0)
std::cout<<
"fromRes = true, motherPdgId = "<<motherPdgId<<std::endl;
449 if(
part->pdgId()==13) {
474 std::pair<lorentzVector, lorentzVector> simMuFromRes;
477 if (
std::abs((*simTrack).type())==13) {
479 if ((*simTrack).genpartIndex()>0) {
481 if( gp !=
nullptr ) {
483 for (HepMC::GenVertex::particle_iterator mother = gp->production_vertex()->particles_begin(HepMC::ancestors);
484 mother!=gp->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
486 bool fromRes =
false;
487 unsigned int motherPdgId = (*mother)->pdg_id();
492 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.
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)
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
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)