Public Member Functions | |
MuonsFromRefitTracksProducer (const edm::ParameterSet &) | |
~MuonsFromRefitTracksProducer () | |
Private Member Functions | |
virtual void | beginJob () |
reco::Muon * | cloneAndSwitchTrack (const reco::Muon &muon, const reco::Muon::MuonTrackTypePair &newTrack) const |
virtual void | endJob () |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
bool | storeMatchMaps (const edm::Event &event) |
Private Attributes | |
bool | fromCocktail |
bool | fromGlobalTrack |
bool | fromSigmaSwitch |
bool | fromTeVRefit |
bool | fromTMR |
bool | fromTrackerTrack |
double | nSigmaSwitch |
double | ptThreshold |
edm::InputTag | src |
std::string | tevMuonTracks |
double | TMRcut |
edm::Handle < reco::TrackToTrackMap > | trackMap |
edm::Handle < reco::TrackToTrackMap > | trackMapDefault |
edm::Handle < reco::TrackToTrackMap > | trackMapFirstHit |
edm::Handle < reco::TrackToTrackMap > | trackMapPicky |
Definition at line 67 of file MuonsFromRefitTracksProducer.cc.
MuonsFromRefitTracksProducer::MuonsFromRefitTracksProducer | ( | const edm::ParameterSet & | cfg | ) | [explicit] |
Definition at line 143 of file MuonsFromRefitTracksProducer.cc.
References fromTeVRefit, and tevMuonTracks.
: src(cfg.getParameter<edm::InputTag>("src")), fromTrackerTrack(cfg.getParameter<bool>("fromTrackerTrack")), fromGlobalTrack(cfg.getParameter<bool>("fromGlobalTrack")), tevMuonTracks(cfg.getParameter<std::string>("tevMuonTracks")), fromCocktail(cfg.getParameter<bool>("fromCocktail")), fromTMR(cfg.getParameter<bool>("fromTMR")), TMRcut(cfg.getParameter<double>("TMRcut")), fromSigmaSwitch(cfg.getParameter<bool>("fromSigmaSwitch")), nSigmaSwitch(cfg.getParameter<double>("nSigmaSwitch")), ptThreshold(cfg.getParameter<double>("ptThreshold")) { fromTeVRefit = tevMuonTracks != "none"; produces<reco::MuonCollection>(); }
MuonsFromRefitTracksProducer::~MuonsFromRefitTracksProducer | ( | ) | [inline] |
Definition at line 70 of file MuonsFromRefitTracksProducer.cc.
{}
virtual void MuonsFromRefitTracksProducer::beginJob | ( | void | ) | [inline, private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 73 of file MuonsFromRefitTracksProducer.cc.
{}
reco::Muon * MuonsFromRefitTracksProducer::cloneAndSwitchTrack | ( | const reco::Muon & | muon, |
const reco::Muon::MuonTrackTypePair & | newTrack | ||
) | const [private] |
Definition at line 173 of file MuonsFromRefitTracksProducer.cc.
References reco::Muon::clone(), reco::Muon::innerTrack(), RPCpg::mu, reco::Muon::outerTrack(), AlCaHLTBitMon_ParallelJobs::p, p4, reco::Muon::setBestTrack(), reco::LeafCandidate::setCharge(), reco::Muon::setGlobalTrack(), reco::Muon::setInnerTrack(), reco::Muon::setOuterTrack(), reco::LeafCandidate::setP4(), reco::LeafCandidate::setVertex(), and mathSSE::sqrt().
Referenced by produce().
{ // Muon mass to make a four-vector out of the new track. static const double muMass = 0.10566; reco::TrackRef tkTrack = muon.innerTrack(); reco::TrackRef muTrack = muon.outerTrack(); // Make up a real Muon from the tracker track. reco::Particle::Point vtx(newTrack.first->vx(), newTrack.first->vy(), newTrack.first->vz()); reco::Particle::LorentzVector p4; double p = newTrack.first->p(); p4.SetXYZT(newTrack.first->px(), newTrack.first->py(), newTrack.first->pz(), sqrt(p*p + muMass*muMass)); reco::Muon* mu = muon.clone(); mu->setCharge(newTrack.first->charge()); mu->setP4(p4); mu->setVertex(vtx); mu->setGlobalTrack(newTrack.first); mu->setInnerTrack(tkTrack); mu->setOuterTrack(muTrack); mu->setBestTrack(newTrack.second); return mu; }
virtual void MuonsFromRefitTracksProducer::endJob | ( | void | ) | [inline, private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 75 of file MuonsFromRefitTracksProducer.cc.
{}
void MuonsFromRefitTracksProducer::produce | ( | edm::Event & | event, |
const edm::EventSetup & | eSetup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 199 of file MuonsFromRefitTracksProducer.cc.
References edm::ViewBase::clone(), cloneAndSwitchTrack(), reco::Muon::CombinedTrack, edm::HandleBase::failedToGet(), fromCocktail, fromGlobalTrack, fromSigmaSwitch, fromTeVRefit, fromTMR, fromTrackerTrack, reco::Muon::InnerTrack, prof2calltree::last, metsig::muon, patZpeak::muons, nSigmaSwitch, convertSQLiteXML::ok, ptThreshold, reco::Muon::setGlobalTrack(), reco::Muon::setInnerTrack(), reco::Muon::setOuterTrack(), sigmaSwitch(), src, storeMatchMaps(), tevMuonTracks, muon::tevOptimized(), tevOptimizedTMR(), TMRcut, trackMap, trackMapDefault, trackMapFirstHit, and trackMapPicky.
{ // Get the global muons from the event. edm::Handle<edm::View<reco::Muon> > muons; event.getByLabel(src, muons); // If we can't get the global muon collection, or below the // track-to-track maps needed, still produce an empty collection of // muons so consumers don't throw an exception. bool ok = !muons.failedToGet(); // If we're instructed to use the TeV refit tracks in some way, we // need the track-to-track maps. If we're making a cocktail muon, // get all three track maps (the cocktail ingredients); else just // get the map which takes the above global tracks to the desired // TeV-muon refitted tracks (firstHit or picky). if (ok && fromTeVRefit) ok = storeMatchMaps(event); // Make the output collection. std::auto_ptr<reco::MuonCollection> cands(new reco::MuonCollection); if (ok) { edm::View<reco::Muon>::const_iterator muon; for (muon = muons->begin(); muon != muons->end(); muon++) { // Filter out the so-called trackerMuons and stand-alone muons // (and caloMuons, if they were ever to get into the input muons // collection). if (!muon->isGlobalMuon()) continue; if (fromTeVRefit || fromSigmaSwitch) { // Start out with a null TrackRef. reco::Muon::MuonTrackTypePair tevTk; // If making a cocktail muon, use tevOptimized() to get the track // desired. Otherwise, get the refit track from the desired track // map. if (fromTMR) tevTk = tevOptimizedTMR(*muon, *trackMapFirstHit, TMRcut); else if (fromCocktail) tevTk = muon::tevOptimized(*muon, *trackMapDefault, *trackMapFirstHit, *trackMapPicky); else if (fromSigmaSwitch) tevTk = sigmaSwitch(*muon, nSigmaSwitch, ptThreshold); else { reco::TrackToTrackMap::const_iterator tevTkRef = trackMap->find(muon->combinedMuon()); if (tevTkRef != trackMap->end()) tevTk = make_pair(tevTkRef->val,reco::Muon::CombinedTrack); } // If the TrackRef is valid, make a new Muon that has the same // tracker and stand-alone tracks, but has the refit track as // its global track. if (tevTk.first.isNonnull()) cands->push_back(*cloneAndSwitchTrack(*muon, tevTk)); } else if (fromTrackerTrack) cands->push_back(*cloneAndSwitchTrack(*muon, make_pair(muon->innerTrack(),reco::Muon::InnerTrack))); else if (fromGlobalTrack) cands->push_back(*cloneAndSwitchTrack(*muon, make_pair(muon->globalTrack(),reco::Muon::CombinedTrack))); else { cands->push_back(*muon->clone()); // Just cloning does not work in the case of the source being // a pat::Muon with embedded track references -- these do not // get copied. Explicitly set them. reco::Muon& last = cands->at(cands->size()-1); if (muon->globalTrack().isTransient()) last.setGlobalTrack(muon->globalTrack()); if (muon->innerTrack().isTransient()) last.setInnerTrack(muon->innerTrack()); if (muon->outerTrack().isTransient()) last.setOuterTrack(muon->outerTrack()); } } } else edm::LogWarning("MuonsFromRefitTracksProducer") << "either " << src << " or the track map(s) " << tevMuonTracks << " not present in the event; producing empty collection"; event.put(cands); }
bool MuonsFromRefitTracksProducer::storeMatchMaps | ( | const edm::Event & | event | ) | [private] |
Definition at line 159 of file MuonsFromRefitTracksProducer.cc.
References edm::HandleBase::failedToGet(), fromCocktail, fromTMR, tevMuonTracks, trackMap, trackMapDefault, trackMapFirstHit, and trackMapPicky.
Referenced by produce().
{ if (fromCocktail || fromTMR) { event.getByLabel(tevMuonTracks, "default", trackMapDefault); event.getByLabel(tevMuonTracks, "firstHit", trackMapFirstHit); event.getByLabel(tevMuonTracks, "picky", trackMapPicky); return !trackMapDefault.failedToGet() && !trackMapFirstHit.failedToGet() && !trackMapPicky.failedToGet(); } else { event.getByLabel(edm::InputTag(tevMuonTracks), trackMap); return !trackMap.failedToGet(); } }
bool MuonsFromRefitTracksProducer::fromCocktail [private] |
Definition at line 113 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce(), and storeMatchMaps().
bool MuonsFromRefitTracksProducer::fromGlobalTrack [private] |
Definition at line 99 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce().
bool MuonsFromRefitTracksProducer::fromSigmaSwitch [private] |
Definition at line 124 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce().
bool MuonsFromRefitTracksProducer::fromTeVRefit [private] |
Definition at line 103 of file MuonsFromRefitTracksProducer.cc.
Referenced by MuonsFromRefitTracksProducer(), and produce().
bool MuonsFromRefitTracksProducer::fromTMR [private] |
Definition at line 117 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce(), and storeMatchMaps().
bool MuonsFromRefitTracksProducer::fromTrackerTrack [private] |
Definition at line 93 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce().
double MuonsFromRefitTracksProducer::nSigmaSwitch [private] |
Definition at line 127 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce().
double MuonsFromRefitTracksProducer::ptThreshold [private] |
Definition at line 130 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce().
Definition at line 87 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce().
std::string MuonsFromRefitTracksProducer::tevMuonTracks [private] |
Definition at line 108 of file MuonsFromRefitTracksProducer.cc.
Referenced by MuonsFromRefitTracksProducer(), produce(), and storeMatchMaps().
double MuonsFromRefitTracksProducer::TMRcut [private] |
Definition at line 120 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce().
Definition at line 135 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce(), and storeMatchMaps().
Definition at line 138 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce(), and storeMatchMaps().
Definition at line 139 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce(), and storeMatchMaps().
Definition at line 140 of file MuonsFromRefitTracksProducer.cc.
Referenced by produce(), and storeMatchMaps().