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()));
230 const std::vector<const pat::Muon*> & collMuSel,
231 std::vector<GenMuonPair> & genPair,
237 for(std::vector<pat::CompositeCandidate>::const_iterator it=collAll->begin();
238 it!=collAll->end();++it) {
242 genPatParticles->push_back(*(const_cast<reco::GenParticle*>(genJpsi.
get())));
246 if(collMuSel.size()==2) {
250 genMu1->pdgId()*genMu2->pdgId() == -169);
252 genPatParticles->push_back(*(const_cast<reco::GenParticle*>(genMu1.
get())));
253 genPatParticles->push_back(*(const_cast<reco::GenParticle*>(genMu2.
get())));
255 unsigned int motherId = 0;
256 if( genMu1->mother() != 0 ) {
257 motherId = genMu1->mother()->pdgId();
259 if(genMu1->pdgId()==13)
260 genPair.push_back(
GenMuonPair(genMu1.
get()->p4(), genMu2.
get()->p4(), motherId));
263 genPair.push_back(
GenMuonPair(genMu2.
get()->p4(), genMu1.
get()->p4(), motherId));
265 plotter->
fillGen(const_cast <reco::GenParticleCollection*> (genPatParticles),
true);
270 std::cout <<
"No recomuon selected so no access to generated info"<<std::endl;
277 std::cout <<
"No recomuon selected so no access to generated info"<<std::endl;
283 std::cout <<
"genParticles:" << std::endl;
285 std::cout << genPair.back().mu1 <<
" , " << genPair.back().mu2 << std::endl;
290 std::vector<GenMuonPair> & genPair,
291 std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
310 else if( genParticles.
isValid() ) {
316 std::cout<<
"ERROR "<<
"non generation info and speedup true!!!!!!!!!!!!"<<std::endl;
322 std::cout <<
"genParticles:" << std::endl;
323 std::cout << genPair.back().mu1 <<
" , " << genPair.back().mu2 << std::endl;
330 std::vector<std::pair<lorentzVector,lorentzVector> > & simPair,
334 bool simTracksFound =
false;
340 simTracksFound =
true;
345 std::cout <<
"SimTracks not existent" << std::endl;
347 if( !simTracksFound ) {
354 const HepMC::GenEvent* Evt = evtMC->
GetEvent();
357 for (HepMC::GenEvent::particle_const_iterator
part=Evt->particles_begin();
358 part!=Evt->particles_end();
part++) {
359 if (fabs((*part)->pdg_id())==13 && (*part)->status()==1) {
360 bool fromRes =
false;
361 unsigned int motherPdgId = 0;
362 for (HepMC::GenVertex::particle_iterator mother = (*part)->production_vertex()->particles_begin(HepMC::ancestors);
363 mother != (*part)->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
364 motherPdgId = (*mother)->pdg_id();
369 if( motherPdgId == 13 && (*mother)->status() == 3 ) fromRes =
true;
378 if((*part)->pdg_id()==13) {
380 muFromRes.
mu1 = (
lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
381 (*part)->momentum().pz(),(*part)->momentum().e()));
384 muFromRes.
mu2 = (
lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
385 (*part)->momentum().pz(),(*part)->momentum().e()));
401 if(
debug_>0 )
std::cout <<
"Starting loop on " << genParticles->size() <<
" genParticles" << std::endl;
402 for( reco::GenParticleCollection::const_iterator
part=genParticles->begin();
part!=genParticles->end(); ++
part ) {
403 if (
debug_>0)
std::cout<<
"genParticle has pdgId = "<<fabs(
part->pdgId())<<
" and status = "<<
part->status()<<std::endl;
404 if (fabs(
part->pdgId())==13){
405 bool fromRes =
false;
406 unsigned int motherPdgId =
part->mother()->pdgId();
408 std::cout <<
"Found a muon with mother: " << motherPdgId << std::endl;
414 if (
debug_>0)
std::cout<<
"fromRes = true, motherPdgId = "<<motherPdgId<<std::endl;
417 if(
part->pdgId()==13) {
441 std::pair<lorentzVector, lorentzVector> simMuFromRes;
442 for( edm::SimTrackContainer::const_iterator simTrack=simTracks->begin(); simTrack!=simTracks->end(); ++simTrack ) {
444 if (fabs((*simTrack).type())==13) {
446 if ((*simTrack).genpartIndex()>0) {
447 HepMC::GenParticle* gp = evtMC->GetEvent()->barcode_to_particle ((*simTrack).genpartIndex());
450 for (HepMC::GenVertex::particle_iterator mother = gp->production_vertex()->particles_begin(HepMC::ancestors);
451 mother!=gp->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
453 bool fromRes =
false;
454 unsigned int motherPdgId = (*mother)->pdg_id();
459 if(gp->pdg_id() == 13)
460 simMuFromRes.first =
lorentzVector(simTrack->momentum().px(),simTrack->momentum().py(),
461 simTrack->momentum().pz(),simTrack->momentum().e());
463 simMuFromRes.second =
lorentzVector(simTrack->momentum().px(),simTrack->momentum().py(),
464 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