#include <MuonTrackLoader.h>
Public Types | |
typedef MuonCandidate::CandidateContainer | CandidateContainer |
typedef MuonCandidate::TrajectoryContainer | TrajectoryContainer |
Public Member Functions | |
edm::OrphanHandle < reco::TrackCollection > | loadTracks (const TrajectoryContainer &, edm::Event &, const std::string &="", bool=true) |
Convert the trajectories into tracks and load the tracks in the event. | |
edm::OrphanHandle < reco::TrackCollection > | loadTracks (const TrajectoryContainer &, edm::Event &, std::vector< bool > &, const std::string &="", bool=true) |
Convert the trajectories into tracks and load the tracks in the event. | |
edm::OrphanHandle < reco::TrackCollection > | loadTracks (const TrajectoryContainer &, edm::Event &, std::vector< std::pair< Trajectory *, reco::TrackRef > >, const std::string &="", bool=true) |
Convert the trajectories into tracks and load the tracks in the event. | |
edm::OrphanHandle < reco::MuonTrackLinksCollection > | loadTracks (const CandidateContainer &, edm::Event &) |
Convert the trajectories into tracks and load the tracks in the event. | |
MuonTrackLoader (edm::ParameterSet ¶meterSet, const MuonServiceProxy *service=0) | |
Constructor for the STA reco the args must be specify! | |
virtual | ~MuonTrackLoader () |
Destructor. | |
Private Member Functions | |
std::pair< bool, reco::Track > | buildTrackAtPCA (const Trajectory &trajectory, const reco::BeamSpot &) const |
Build a track at the PCA WITHOUT any vertex constriant. | |
reco::TrackExtra | buildTrackExtra (const Trajectory &) const |
std::pair< bool, reco::Track > | buildTrackUpdatedAtPCA (const reco::Track &trackAtPCA, const reco::BeamSpot &) const |
Takes a track at the PCA and applies the vertex constriant. | |
Private Attributes | |
bool | theAllowNoVtxFlag |
edm::InputTag | theBeamSpotInputTag |
std::string | theL2SeededTkLabel |
Label for L2SeededTracks. | |
bool | thePutTkTrackFlag |
const MuonServiceProxy * | theService |
edm::ESHandle< TrajectorySmoother > | theSmoother |
std::string | theSmootherName |
bool | theSmoothingStep |
bool | theSmoothTkTrackFlag |
bool | theTrajectoryFlag |
bool | theUpdatingAtVtx |
MuonUpdatorAtVertex * | theUpdatorAtVtx |
Class to load the tracks in the event, it provide some common functionalities both for all the RecoMuon producers.
Class to load the product in the event
Definition at line 36 of file MuonTrackLoader.h.
Definition at line 40 of file MuonTrackLoader.h.
Definition at line 39 of file MuonTrackLoader.h.
MuonTrackLoader::MuonTrackLoader | ( | edm::ParameterSet & | parameterSet, |
const MuonServiceProxy * | service = 0 |
||
) |
Constructor for the STA reco the args must be specify!
Definition at line 46 of file MuonTrackLoader.cc.
References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), MuonUpdatorAtVertex_cff::MuonUpdatorAtVertex, theAllowNoVtxFlag, theBeamSpotInputTag, theL2SeededTkLabel, thePutTkTrackFlag, theSmootherName, theSmoothingStep, theSmoothTkTrackFlag, theTrajectoryFlag, theUpdatingAtVtx, and theUpdatorAtVtx.
: theService(service){ // option to do or not the smoothing step. // the trajectories which are passed to the track loader are supposed to be non-smoothed theSmoothingStep = parameterSet.getParameter<bool>("DoSmoothing"); if(theSmoothingStep) theSmootherName = parameterSet.getParameter<string>("Smoother"); // update at vertex theUpdatingAtVtx = parameterSet.getParameter<bool>("VertexConstraint"); // beam spot input tag theBeamSpotInputTag = parameterSet.getParameter<edm::InputTag>("beamSpot"); // Flag to put the trajectory into the event theTrajectoryFlag = parameterSet.getUntrackedParameter<bool>("PutTrajectoryIntoEvent",true); theL2SeededTkLabel = parameterSet.getUntrackedParameter<string>("MuonSeededTracksInstance",string()); ParameterSet updatorPar = parameterSet.getParameter<ParameterSet>("MuonUpdatorAtVertexParameters"); theUpdatorAtVtx = new MuonUpdatorAtVertex(updatorPar,service); thePutTkTrackFlag = parameterSet.getUntrackedParameter<bool>("PutTkTrackIntoEvent",false); theSmoothTkTrackFlag = parameterSet.getUntrackedParameter<bool>("SmoothTkTrack",false); theAllowNoVtxFlag = parameterSet.getUntrackedParameter<bool>("AllowNoVertex",false); }
MuonTrackLoader::~MuonTrackLoader | ( | ) | [virtual] |
Destructor.
Definition at line 74 of file MuonTrackLoader.cc.
References theUpdatorAtVtx.
{ if(theUpdatorAtVtx) delete theUpdatorAtVtx; }
pair< bool, reco::Track > MuonTrackLoader::buildTrackAtPCA | ( | const Trajectory & | trajectory, |
const reco::BeamSpot & | beamSpot | ||
) | const [private] |
Build a track at the PCA WITHOUT any vertex constriant.
Definition at line 594 of file MuonTrackLoader.cc.
References FreeTrajectoryState::charge(), Trajectory::chiSquared(), FreeTrajectoryState::curvilinearError(), debug, MuonPatternRecoDumper::dumpFTS(), TrajectoryStateOnSurface::freeState(), Trajectory::geometricalInnermostState(), TrajectoryStateOnSurface::globalPosition(), TrackerBounds::isInside(), LogTrace, FreeTrajectoryState::momentum(), Trajectory::ndof(), AlCaHLTBitMon_ParallelJobs::p, FreeTrajectoryState::position(), MuonUpdatorAtVertex::propagate(), theAllowNoVtxFlag, theService, theUpdatorAtVtx, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
{ const string metname = "Muon|RecoMuon|MuonTrackLoader"; MuonPatternRecoDumper debug; // FIXME: check the prop direction TrajectoryStateOnSurface innerTSOS = trajectory.geometricalInnermostState(); // This is needed to extrapolate the tsos at vertex LogTrace(metname) << "Propagate to PCA..."; pair<bool,FreeTrajectoryState> extrapolationResult = theUpdatorAtVtx->propagate(innerTSOS, beamSpot); FreeTrajectoryState ftsAtVtx; if(extrapolationResult.first) ftsAtVtx = extrapolationResult.second; else{ if(TrackerBounds::isInside(innerTSOS.globalPosition())){ LogInfo(metname) << "Track in the Tracker: taking the innermost state instead of the state at PCA"; ftsAtVtx = *innerTSOS.freeState(); } else{ if ( theAllowNoVtxFlag ) { LogInfo(metname) << "Propagation to PCA failed, taking the innermost state instead of the state at PCA"; ftsAtVtx = *innerTSOS.freeState(); } else { LogInfo(metname) << "Stand Alone track: this track will be rejected"; return pair<bool,reco::Track>(false,reco::Track()); } } } LogTrace(metname) << "TSOS after the extrapolation at vtx"; LogTrace(metname) << debug.dumpFTS(ftsAtVtx); GlobalPoint pca = ftsAtVtx.position(); math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z()); GlobalVector p = ftsAtVtx.momentum(); math::XYZVector persistentMomentum(p.x(),p.y(),p.z()); bool bon = true; if(fabs(theService->magneticField()->inTesla(GlobalPoint(0,0,0)).z()) < 0.01) bon=false; double ndof = trajectory.ndof(bon); reco::Track track(trajectory.chiSquared(), ndof, persistentPCA, persistentMomentum, ftsAtVtx.charge(), ftsAtVtx.curvilinearError()); return pair<bool,reco::Track>(true,track); }
reco::TrackExtra MuonTrackLoader::buildTrackExtra | ( | const Trajectory & | trajectory | ) | const [private] |
Definition at line 688 of file MuonTrackLoader.cc.
References alongMomentum, BoundSurface::bounds(), TrajectoryStateOnSurface::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::globalParameters(), Bounds::inside(), Trajectory::lastMeasurement(), LogTrace, GlobalTrajectoryParameters::momentum(), oppositeToMomentum, AlCaHLTBitMon_ParallelJobs::p, GlobalTrajectoryParameters::position(), TrajectoryMeasurement::recHit(), Trajectory::recHits(), Trajectory::seedRef(), GeomDet::surface(), theService, GeomDet::toLocal(), TrajectoryMeasurement::updatedState(), v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
{ const string metname = "Muon|RecoMuon|MuonTrackLoader"; const Trajectory::RecHitContainer transRecHits = trajectory.recHits(); // put the collection of TrackingRecHit in the event // sets the outermost and innermost TSOSs // FIXME: check it! TrajectoryStateOnSurface outerTSOS; TrajectoryStateOnSurface innerTSOS; unsigned int innerId=0, outerId=0; TrajectoryMeasurement::ConstRecHitPointer outerRecHit; DetId outerDetId; if (trajectory.direction() == alongMomentum) { LogTrace(metname)<<"alongMomentum"; outerTSOS = trajectory.lastMeasurement().updatedState(); innerTSOS = trajectory.firstMeasurement().updatedState(); outerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId(); innerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId(); outerRecHit = trajectory.lastMeasurement().recHit(); outerDetId = trajectory.lastMeasurement().recHit()->geographicalId(); } else if (trajectory.direction() == oppositeToMomentum) { LogTrace(metname)<<"oppositeToMomentum"; outerTSOS = trajectory.firstMeasurement().updatedState(); innerTSOS = trajectory.lastMeasurement().updatedState(); outerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId(); innerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId(); outerRecHit = trajectory.firstMeasurement().recHit(); outerDetId = trajectory.firstMeasurement().recHit()->geographicalId(); } else LogError(metname)<<"Wrong propagation direction!"; const GeomDet *outerDet = theService->trackingGeometry()->idToDet(outerDetId); GlobalPoint outerTSOSPos = outerTSOS.globalParameters().position(); bool inside = outerDet->surface().bounds().inside(outerDet->toLocal(outerTSOSPos)); GlobalPoint hitPos = (outerRecHit->isValid()) ? outerRecHit->globalPosition() : outerTSOS.globalParameters().position() ; if(!inside) { LogTrace(metname)<<"The Global Muon outerMostMeasurementState is not compatible with the recHit detector! Setting outerMost postition to recHit position if recHit isValid: " << outerRecHit->isValid(); LogTrace(metname)<<"From " << outerTSOSPos << " to " << hitPos; } //build the TrackExtra GlobalPoint v = (inside) ? outerTSOSPos : hitPos ; GlobalVector p = outerTSOS.globalParameters().momentum(); math::XYZPoint outpos( v.x(), v.y(), v.z() ); math::XYZVector outmom( p.x(), p.y(), p.z() ); v = innerTSOS.globalParameters().position(); p = innerTSOS.globalParameters().momentum(); math::XYZPoint inpos( v.x(), v.y(), v.z() ); math::XYZVector inmom( p.x(), p.y(), p.z() ); reco::TrackExtra trackExtra(outpos, outmom, true, inpos, inmom, true, outerTSOS.curvilinearError(), outerId, innerTSOS.curvilinearError(), innerId, trajectory.direction(),trajectory.seedRef()); return trackExtra; }
pair< bool, reco::Track > MuonTrackLoader::buildTrackUpdatedAtPCA | ( | const reco::Track & | trackAtPCA, |
const reco::BeamSpot & | beamSpot | ||
) | const [private] |
Takes a track at the PCA and applies the vertex constriant.
Definition at line 650 of file MuonTrackLoader.cc.
References FreeTrajectoryState::charge(), reco::TrackBase::chi2(), FreeTrajectoryState::curvilinearError(), debug, MuonPatternRecoDumper::dumpFTS(), LogTrace, FreeTrajectoryState::momentum(), reco::TrackBase::ndof(), AlCaHLTBitMon_ParallelJobs::p, FreeTrajectoryState::position(), theService, theUpdatorAtVtx, MuonUpdatorAtVertex::update(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
{ const string metname = "Muon|RecoMuon|MuonTrackLoader"; MuonPatternRecoDumper debug; // build the transient track reco::TransientTrack transientTrack(track, &*theService->magneticField(), theService->trackingGeometry()); LogTrace(metname) << "Apply the vertex constraint"; pair<bool,FreeTrajectoryState> updateResult = theUpdatorAtVtx->update(transientTrack,beamSpot); if(!updateResult.first){ return pair<bool,reco::Track>(false,reco::Track()); } LogTrace(metname) << "FTS after the vertex constraint"; FreeTrajectoryState &ftsAtVtx = updateResult.second; LogTrace(metname) << debug.dumpFTS(ftsAtVtx); GlobalPoint pca = ftsAtVtx.position(); math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z()); GlobalVector p = ftsAtVtx.momentum(); math::XYZVector persistentMomentum(p.x(),p.y(),p.z()); reco::Track updatedTrack(track.chi2(), track.ndof(), persistentPCA, persistentMomentum, ftsAtVtx.charge(), ftsAtVtx.curvilinearError()); return pair<bool,reco::Track>(true,updatedTrack); }
edm::OrphanHandle<reco::TrackCollection> MuonTrackLoader::loadTracks | ( | const TrajectoryContainer & | , |
edm::Event & | , | ||
std::vector< bool > & | , | ||
const std::string & | = "" , |
||
bool | = true |
||
) |
Convert the trajectories into tracks and load the tracks in the event.
OrphanHandle< reco::MuonTrackLinksCollection > MuonTrackLoader::loadTracks | ( | const CandidateContainer & | muonCands, |
edm::Event & | event | ||
) |
Convert the trajectories into tracks and load the tracks in the event.
Definition at line 292 of file MuonTrackLoader.cc.
References edm::OrphanHandleBase::isValid(), loadTracks(), LogDebug, LogTrace, position, reco::MuonTrackLinks::setGlobalTrack(), reco::MuonTrackLinks::setStandAloneTrack(), reco::MuonTrackLinks::setTrackerTrack(), theL2SeededTkLabel, thePutTkTrackFlag, and theSmoothTkTrackFlag.
{ const string metname = "Muon|RecoMuon|MuonTrackLoader"; // the muon collection, it will be loaded in the event auto_ptr<reco::MuonTrackLinksCollection> trackLinksCollection(new reco::MuonTrackLinksCollection()); // don't waste any time... if ( muonCands.empty() ) { auto_ptr<reco::TrackExtraCollection> trackExtraCollection(new reco::TrackExtraCollection() ); auto_ptr<TrackingRecHitCollection> recHitCollection(new TrackingRecHitCollection() ); auto_ptr<reco::TrackCollection> trackCollection( new reco::TrackCollection() ); event.put(recHitCollection); event.put(trackExtraCollection); event.put(trackCollection); //need to also put the tracker tracks collection if requested if(thePutTkTrackFlag){ //will take care of putting nothing in the event but the empty collection TrajectoryContainer trackerTrajs; loadTracks(trackerTrajs, event, theL2SeededTkLabel, theSmoothTkTrackFlag); } return event.put(trackLinksCollection); } // get combined Trajectories TrajectoryContainer combinedTrajs; TrajectoryContainer trackerTrajs; for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it) { LogDebug(metname) << "Loader glbSeedRef " << (*it)->trajectory()->seedRef().isNonnull(); if ((*it)->trackerTrajectory() ) LogDebug(metname) << " " << "tkSeedRef " << (*it)->trackerTrajectory()->seedRef().isNonnull(); combinedTrajs.push_back((*it)->trajectory()); if ( thePutTkTrackFlag ) trackerTrajs.push_back((*it)->trackerTrajectory()); else { if ((*it)->trackerTrajectory()) delete ((*it)->trackerTrajectory()); } // // Create the links between sta and tracker tracks // reco::MuonTrackLinks links; // links.setStandAloneTrack((*it)->muonTrack()); // links.setTrackerTrack((*it)->trackerTrack()); // trackLinksCollection->push_back(links); // delete *it; } // create the TrackCollection of combined Trajectories // FIXME: could this be done one track at a time in the previous loop? LogTrace(metname) << "Build combinedTracks"; std::vector<bool> combTksVec(combinedTrajs.size(), false); OrphanHandle<reco::TrackCollection> combinedTracks = loadTracks(combinedTrajs, event, combTksVec); OrphanHandle<reco::TrackCollection> trackerTracks; std::vector<bool> trackerTksVec(trackerTrajs.size(), false); if(thePutTkTrackFlag) { LogTrace(metname) << "Build trackerTracks: " << trackerTrajs.size(); trackerTracks = loadTracks(trackerTrajs, event, trackerTksVec, theL2SeededTkLabel, theSmoothTkTrackFlag); } else { for (TrajectoryContainer::iterator it = trackerTrajs.begin(); it != trackerTrajs.end(); ++it) { if(*it) delete *it; } } LogTrace(metname) << "Set the final links in the MuonTrackLinks collection"; unsigned int candposition(0), position(0), tkposition(0); //reco::TrackCollection::const_iterator glIt = combinedTracks->begin(), // glEnd = combinedTracks->end(); for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it, ++candposition) { // The presence of the global track determines whether to fill the MuonTrackLinks or not // N.B. We are assuming here that the global tracks in "combinedTracks" // have the same order as the muon candidates in "muonCands" // (except for possible missing tracks), which should always be the case... //if( glIt == glEnd ) break; if(combTksVec[candposition]) { reco::TrackRef combinedTR(combinedTracks, position++); //++glIt; // Create the links between sta and tracker tracks reco::MuonTrackLinks links; links.setStandAloneTrack((*it)->muonTrack()); links.setTrackerTrack((*it)->trackerTrack()); links.setGlobalTrack(combinedTR); if(thePutTkTrackFlag && trackerTksVec[candposition]) { reco::TrackRef trackerTR(trackerTracks, tkposition++); links.setTrackerTrack(trackerTR); } trackLinksCollection->push_back(links); } else { // if no global track, still increment the tracker-track counter when appropriate if(thePutTkTrackFlag && trackerTksVec[candposition]) tkposition++; } delete *it; } if( thePutTkTrackFlag && trackerTracks.isValid() && !(combinedTracks->size() > 0 && trackerTracks->size() > 0 ) ) LogWarning(metname)<<"The MuonTrackLinkCollection is incomplete"; // put the MuonCollection in the event LogTrace(metname) << "put the MuonCollection in the event" << "\n"; return event.put(trackLinksCollection); }
edm::OrphanHandle<reco::TrackCollection> MuonTrackLoader::loadTracks | ( | const TrajectoryContainer & | , |
edm::Event & | , | ||
std::vector< std::pair< Trajectory *, reco::TrackRef > > | , | ||
const std::string & | = "" , |
||
bool | = true |
||
) |
Convert the trajectories into tracks and load the tracks in the event.
edm::OrphanHandle<reco::TrackCollection> MuonTrackLoader::loadTracks | ( | const TrajectoryContainer & | , |
edm::Event & | , | ||
const std::string & | = "" , |
||
bool | = true |
||
) |
Convert the trajectories into tracks and load the tracks in the event.
Referenced by MuonTrackFinder::load(), and loadTracks().
bool MuonTrackLoader::theAllowNoVtxFlag [private] |
Definition at line 96 of file MuonTrackLoader.h.
Referenced by buildTrackAtPCA(), and MuonTrackLoader().
Definition at line 90 of file MuonTrackLoader.h.
Referenced by MuonTrackLoader().
std::string MuonTrackLoader::theL2SeededTkLabel [private] |
Label for L2SeededTracks.
Definition at line 93 of file MuonTrackLoader.h.
Referenced by loadTracks(), and MuonTrackLoader().
bool MuonTrackLoader::thePutTkTrackFlag [private] |
Definition at line 94 of file MuonTrackLoader.h.
Referenced by loadTracks(), and MuonTrackLoader().
const MuonServiceProxy* MuonTrackLoader::theService [private] |
Definition at line 79 of file MuonTrackLoader.h.
Referenced by buildTrackAtPCA(), buildTrackExtra(), and buildTrackUpdatedAtPCA().
Definition at line 88 of file MuonTrackLoader.h.
std::string MuonTrackLoader::theSmootherName [private] |
Definition at line 87 of file MuonTrackLoader.h.
Referenced by MuonTrackLoader().
bool MuonTrackLoader::theSmoothingStep [private] |
Definition at line 86 of file MuonTrackLoader.h.
Referenced by MuonTrackLoader().
bool MuonTrackLoader::theSmoothTkTrackFlag [private] |
Definition at line 95 of file MuonTrackLoader.h.
Referenced by loadTracks(), and MuonTrackLoader().
bool MuonTrackLoader::theTrajectoryFlag [private] |
Definition at line 84 of file MuonTrackLoader.h.
Referenced by MuonTrackLoader().
bool MuonTrackLoader::theUpdatingAtVtx [private] |
Definition at line 81 of file MuonTrackLoader.h.
Referenced by MuonTrackLoader().
Definition at line 82 of file MuonTrackLoader.h.
Referenced by buildTrackAtPCA(), buildTrackUpdatedAtPCA(), MuonTrackLoader(), and ~MuonTrackLoader().