13 ->isPromptFinalState();
15 if (isPromptFinalState)
22 ->isPromptFinalState();
35 ->isLastCopyBeforeFSR();
44 ->isLastCopyBeforeFSR();
63 iTrack->chi2() / iTrack->ndof() < 4.0 && aMuon->
muonID(
"TrackerMuonArbitrated") &&
75 iTrack->found() > 11 && iTrack->chi2() / iTrack->ndof() < 4.0 && aMuon->
muonID(
"TrackerMuonArbitrated") &&
86 std::vector<MuScleFitMuon>&
muons,
87 std::vector<GenMuonPair>& genPair,
88 std::vector<std::pair<lorentzVector, lorentzVector> >& simPair,
91 event.getByLabel(
"onia2MuMuPatTrkTrk", collAll);
95 std::vector<const pat::Muon*> collMuSel;
100 std::vector<const pat::CompositeCandidate*> collSelGG;
101 std::vector<const pat::CompositeCandidate*> collSelGT;
102 std::vector<const pat::CompositeCandidate*> collSelTT;
104 for (std::vector<pat::CompositeCandidate>::const_iterator it = collAll->begin(); it != collAll->end(); ++it) {
115 collSelGG.push_back(cand);
122 collSelGT.push_back(cand);
128 collSelGT.push_back(cand);
135 collSelTT.push_back(cand);
142 std::vector<reco::Track>
tracks;
143 if (!collSelGG.empty()) {
145 const pat::Muon* muon1 =
dynamic_cast<const pat::Muon*
>(collSelGG[0]->daughter(
"muon1"));
146 const pat::Muon* muon2 =
dynamic_cast<const pat::Muon*
>(collSelGG[0]->daughter(
"muon2"));
150 collMuSel.push_back(muon1);
151 collMuSel.push_back(muon2);
153 }
else if (collSelGG.empty() && !collSelGT.empty()) {
155 const pat::Muon* muon1 =
dynamic_cast<const pat::Muon*
>(collSelGT[0]->daughter(
"muon1"));
156 const pat::Muon* muon2 =
dynamic_cast<const pat::Muon*
>(collSelGT[0]->daughter(
"muon2"));
160 collMuSel.push_back(muon1);
161 collMuSel.push_back(muon2);
163 }
else if (collSelGG.empty() && collSelGT.empty() && !collSelTT.empty()) {
165 const pat::Muon* muon1 =
dynamic_cast<const pat::Muon*
>(collSelTT[0]->daughter(
"muon1"));
166 const pat::Muon* muon2 =
dynamic_cast<const pat::Muon*
>(collSelTT[0]->daughter(
"muon2"));
170 collMuSel.push_back(muon1);
171 collMuSel.push_back(muon2);
174 if (tracks.size() != 2 && !tracks.empty()) {
175 std::cout <<
"ERROR strange number of muons selected by onia cuts!" << std::endl;
179 }
else if ((muonType_ < 4 && muonType_ >= 0) ||
muonType_ >= 10) {
180 std::vector<reco::Track>
tracks;
188 for (std::vector<pat::Muon>::const_iterator
muon = allMuons->begin();
muon != allMuons->end(); ++
muon) {
201 for (std::vector<reco::Muon>::const_iterator
muon = allMuons->begin();
muon != allMuons->end(); ++
muon) {
210 std::vector<reco::Track>
tracks;
211 for (std::vector<reco::CaloMuon>::const_iterator
muon = caloMuons->begin();
muon != caloMuons->end(); ++
muon) {
212 tracks.push_back(*(
muon->track()));
238 const std::vector<const pat::Muon*>& collMuSel,
239 std::vector<GenMuonPair>& genPair,
244 for (std::vector<pat::CompositeCandidate>::const_iterator it = collAll->begin(); it != collAll->end(); ++it) {
248 genPatParticles.push_back(*genJpsi.
get());
252 if (collMuSel.size() == 2) {
255 bool isMuMatched = (genMu1.
isAvailable() && genMu2.
isAvailable() && genMu1->pdgId() * genMu2->pdgId() == -169);
257 genPatParticles.push_back(*genMu1.
get());
258 genPatParticles.push_back(*genMu2.
get());
260 unsigned int motherId = 0;
261 if (genMu1->mother() !=
nullptr) {
262 motherId = genMu1->mother()->pdgId();
264 if (genMu1->pdgId() == 13)
265 genPair.push_back(
GenMuonPair(genMu1.
get()->p4(), genMu2.
get()->p4(), motherId));
268 genPair.push_back(
GenMuonPair(genMu2.
get()->p4(), genMu1.
get()->p4(), motherId));
270 plotter->
fillGen(genPatParticles,
true);
273 std::cout <<
"Found genParticles in PAT" << std::endl;
275 std::cout <<
"No recomuon selected so no access to generated info" << std::endl;
281 std::cout <<
"No recomuon selected so no access to generated info" << std::endl;
287 std::cout <<
"genParticles:" << std::endl;
289 std::cout << genPair.back().mu1 <<
" , " << genPair.back().mu2 << std::endl;
294 std::vector<GenMuonPair>& genPair,
295 std::vector<std::pair<lorentzVector, lorentzVector> >& simPair,
303 bool ifHepMC =
false;
313 }
else if (genParticles.
isValid()) {
315 plotter->
fillGen(*genParticles);
317 std::cout <<
"Found genParticles" << std::endl;
320 <<
"non generation info and speedup true!!!!!!!!!!!!" << std::endl;
326 std::cout <<
"genParticles:" << std::endl;
327 std::cout << genPair.back().mu1 <<
" , " << genPair.back().mu2 << std::endl;
335 std::vector<std::pair<lorentzVector, lorentzVector> >& simPair,
338 bool simTracksFound =
false;
344 simTracksFound =
true;
348 std::cout <<
"SimTracks not existent" << std::endl;
350 if (!simTracksFound) {
359 for (HepMC::GenEvent::particle_const_iterator
part = Evt->particles_begin();
part != Evt->particles_end();
part++) {
360 if (
std::abs((*part)->pdg_id()) == 13 && (*part)->status() == 1) {
361 bool fromRes =
false;
362 unsigned int motherPdgId = 0;
363 for (HepMC::GenVertex::particle_iterator mother = (*part)->production_vertex()->particles_begin(HepMC::ancestors);
364 mother != (*part)->production_vertex()->particles_end(HepMC::ancestors);
366 motherPdgId = (*mother)->pdg_id();
371 if (motherPdgId == 13 && (*mother)->status() == 3)
381 if ((*part)->pdg_id() == 13) {
384 (*part)->momentum().px(), (*part)->momentum().py(), (*part)->momentum().pz(), (*part)->momentum().e()));
387 (*part)->momentum().px(), (*part)->momentum().py(), (*part)->momentum().pz(), (*part)->momentum().e()));
403 std::cout <<
"Starting loop on " << genParticles->size() <<
" genParticles" << std::endl;
404 for (reco::GenParticleCollection::const_iterator
part = genParticles->begin();
part != genParticles->end(); ++
part) {
409 bool fromRes =
false;
410 unsigned int motherPdgId =
part->mother()->pdgId();
412 std::cout <<
"Found a muon with mother: " << motherPdgId << std::endl;
427 std::cout <<
"fromRes = true, motherPdgId = " << motherPdgId << std::endl;
430 if (
part->pdgId() == 13) {
431 if (status1Muon->
p4().pt() != 0)
436 std::cout <<
"Found a genMuon - : " << muFromRes.
mu1 << std::endl;
440 if (status1Muon->
p4().pt() != 0)
445 std::cout <<
"Found a genMuon + : " << muFromRes.
mu2 << std::endl;
459 std::pair<lorentzVector, lorentzVector> simMuFromRes;
460 for (edm::SimTrackContainer::const_iterator
simTrack = simTracks->begin();
simTrack != simTracks->end(); ++
simTrack) {
462 if (
std::abs((*simTrack).type()) == 13) {
464 if ((*simTrack).genpartIndex() > 0) {
467 for (HepMC::GenVertex::particle_iterator mother = gp->production_vertex()->particles_begin(HepMC::ancestors);
468 mother != gp->production_vertex()->particles_end(HepMC::ancestors);
470 bool fromRes =
false;
471 unsigned int motherPdgId = (*mother)->pdg_id();
477 if (gp->pdg_id() == 13)
Analysis-level particle class.
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
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)
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)
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
auto const & tracks
cannot be loose
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
bool isTrackerMuon() const override
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)
Abs< T >::type abs(const T &t)
bool isMatched(TrackingRecHit const &hit)
T const * get() const
Returns C++ pointer to the item.
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)
reco::TrackRef globalTrack() const override
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
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
Log< level::Warning, false > LogWarning
const reco::Candidate * getStatus3Muon(const reco::Candidate *status3Muon)
const std::vector< int > resfind_
Analysis-level muon class.
bool isGlobalMuon() const override
int charge() const final
electric charge
const reco::Candidate * getStatus1Muon(const reco::Candidate *status3Muon)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector