#include <RecoMuon/TrackingTools/interface/MuonTrackLoader.h>
Public Types | |
typedef MuonCandidate::CandidateContainer | CandidateContainer |
typedef MuonCandidate::TrajectoryContainer | TrajectoryContainer |
Public Member Functions | |
edm::OrphanHandle < reco::MuonTrackLinksCollection > | loadTracks (const CandidateContainer &, edm::Event &) |
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::TrackCollection > | loadTracks (const TrajectoryContainer &, edm::Event &, const std::string &="", bool=true) |
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 |
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 product in the event.
Definition at line 32 of file MuonTrackLoader.h.
Definition at line 36 of file MuonTrackLoader.h.
Definition at line 35 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 41 of file MuonTrackLoader.cc.
References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), MuonUpdatorAtVertex_cff::MuonUpdatorAtVertex, theAllowNoVtxFlag, theL2SeededTkLabel, thePutTkTrackFlag, theSmootherName, theSmoothingStep, theSmoothTkTrackFlag, theTrajectoryFlag, theUpdatingAtVtx, and theUpdatorAtVtx.
00041 : 00042 theService(service){ 00043 00044 // option to do or not the smoothing step. 00045 // the trajectories which are passed to the track loader are supposed to be non-smoothed 00046 theSmoothingStep = parameterSet.getParameter<bool>("DoSmoothing"); 00047 if(theSmoothingStep) 00048 theSmootherName = parameterSet.getParameter<string>("Smoother"); 00049 00050 // update at vertex 00051 theUpdatingAtVtx = parameterSet.getParameter<bool>("VertexConstraint"); 00052 00053 // Flag to put the trajectory into the event 00054 theTrajectoryFlag = parameterSet.getUntrackedParameter<bool>("PutTrajectoryIntoEvent",true); 00055 00056 theL2SeededTkLabel = parameterSet.getUntrackedParameter<string>("MuonSeededTracksInstance",string()); 00057 00058 ParameterSet updatorPar = parameterSet.getParameter<ParameterSet>("MuonUpdatorAtVertexParameters"); 00059 theUpdatorAtVtx = new MuonUpdatorAtVertex(updatorPar,service); 00060 00061 thePutTkTrackFlag = parameterSet.getUntrackedParameter<bool>("PutTkTrackIntoEvent",false); 00062 theSmoothTkTrackFlag = parameterSet.getUntrackedParameter<bool>("SmoothTkTrack",false); 00063 theAllowNoVtxFlag = parameterSet.getUntrackedParameter<bool>("AllowNoVertex",false); 00064 }
MuonTrackLoader::~MuonTrackLoader | ( | ) | [virtual] |
Destructor.
Definition at line 66 of file MuonTrackLoader.cc.
References theUpdatorAtVtx.
00066 { 00067 if(theUpdatorAtVtx) delete theUpdatorAtVtx; 00068 }
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 544 of file MuonTrackLoader.cc.
References funct::abs(), FreeTrajectoryState::cartesianError(), FreeTrajectoryState::charge(), Trajectory::chiSquared(), FreeTrajectoryState::curvilinearError(), debug, MuonPatternRecoDumper::dumpFTS(), MuonPatternRecoDumper::dumpTSOS(), TrajectoryStateOnSurface::freeState(), Trajectory::geometricalInnermostState(), TrajectoryStateOnSurface::globalPosition(), TrackerBounds::isInside(), LogTrace, CartesianTrajectoryError::matrix(), CurvilinearTrajectoryError::matrix(), FreeTrajectoryState::momentum(), Trajectory::ndof(), p, FreeTrajectoryState::parameters(), FreeTrajectoryState::position(), MuonUpdatorAtVertex::propagate(), theAllowNoVtxFlag, theService, theUpdatorAtVtx, track, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
00544 { 00545 00546 const string metname = "Muon|RecoMuon|MuonTrackLoader"; 00547 00548 MuonPatternRecoDumper debug; 00549 00550 TrajectoryStateOnSurface innerTSOS = trajectory.geometricalInnermostState(); 00551 00552 LogTrace(metname) << "TSOS before the extrapolation at PCA"; 00553 LogTrace(metname) << debug.dumpTSOS(innerTSOS); 00554 LogTrace(metname) << innerTSOS.freeState()->parameters(); 00555 LogTrace(metname) << "Cartesian Errors"; 00556 LogTrace(metname) << innerTSOS.freeState()->cartesianError().matrix(); 00557 LogTrace(metname) << "Curvilinear Errors"; 00558 LogTrace(metname) << innerTSOS.freeState()->curvilinearError().matrix(); 00559 00560 00561 // This is needed to extrapolate the tsos at vertex 00562 LogTrace(metname) << "Propagate to PCA..."; 00563 pair<bool,FreeTrajectoryState> 00564 extrapolationResult = theUpdatorAtVtx->propagate(innerTSOS, beamSpot); 00565 FreeTrajectoryState ftsAtVtx; 00566 00567 if(extrapolationResult.first) 00568 ftsAtVtx = extrapolationResult.second; 00569 else{ 00570 if(TrackerBounds::isInside(innerTSOS.globalPosition())){ 00571 LogInfo(metname) << "Track in the Tracker: taking the innermost state instead of the state at PCA"; 00572 ftsAtVtx = *innerTSOS.freeState(); 00573 } 00574 else{ 00575 if ( theAllowNoVtxFlag ) { 00576 LogInfo(metname) << "Propagation to PCA failed, taking the innermost state instead of the state at PCA"; 00577 ftsAtVtx = *innerTSOS.freeState(); 00578 } else { 00579 LogInfo(metname) << "Stand Alone track: this track will be rejected"; 00580 return pair<bool,reco::Track>(false,reco::Track()); 00581 } 00582 } 00583 } 00584 00585 LogTrace(metname) << "TSOS after the extrapolation at vtx"; 00586 LogTrace(metname) << debug.dumpFTS(ftsAtVtx); 00587 00588 GlobalPoint pca = ftsAtVtx.position(); 00589 math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z()); 00590 GlobalVector p = ftsAtVtx.momentum(); 00591 math::XYZVector persistentMomentum(p.x(),p.y(),p.z()); 00592 00593 bool bon = true; 00594 if(abs(theService->magneticField()->inTesla(GlobalPoint(0,0,0)).z()) < 0.01) bon=false; 00595 double ndof = trajectory.ndof(bon); 00596 00597 reco::Track track(trajectory.chiSquared(), 00598 ndof, 00599 persistentPCA, 00600 persistentMomentum, 00601 ftsAtVtx.charge(), 00602 ftsAtVtx.curvilinearError()); 00603 00604 return pair<bool,reco::Track>(true,track); 00605 }
reco::TrackExtra MuonTrackLoader::buildTrackExtra | ( | const Trajectory & | trajectory | ) | const [private] |
Definition at line 646 of file MuonTrackLoader.cc.
References alongMomentum, TrajectoryStateOnSurface::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::globalParameters(), Trajectory::lastMeasurement(), LogTrace, GlobalTrajectoryParameters::momentum(), oppositeToMomentum, p, GlobalTrajectoryParameters::position(), TrajectoryMeasurement::recHit(), Trajectory::recHits(), Trajectory::seedRef(), TrajectoryMeasurement::updatedState(), v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
00646 { 00647 00648 const string metname = "Muon|RecoMuon|MuonTrackLoader"; 00649 00650 const Trajectory::RecHitContainer transRecHits = trajectory.recHits(); 00651 00652 // put the collection of TrackingRecHit in the event 00653 00654 // sets the outermost and innermost TSOSs 00655 // FIXME: check it! 00656 TrajectoryStateOnSurface outerTSOS; 00657 TrajectoryStateOnSurface innerTSOS; 00658 unsigned int innerId=0, outerId=0; 00659 00660 if (trajectory.direction() == alongMomentum) { 00661 LogTrace(metname)<<"alongMomentum"; 00662 outerTSOS = trajectory.lastMeasurement().updatedState(); 00663 innerTSOS = trajectory.firstMeasurement().updatedState(); 00664 outerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId(); 00665 innerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId(); 00666 } 00667 else if (trajectory.direction() == oppositeToMomentum) { 00668 LogTrace(metname)<<"oppositeToMomentum"; 00669 outerTSOS = trajectory.firstMeasurement().updatedState(); 00670 innerTSOS = trajectory.lastMeasurement().updatedState(); 00671 outerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId(); 00672 innerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId(); 00673 } 00674 else LogError(metname)<<"Wrong propagation direction!"; 00675 00676 //build the TrackExtra 00677 GlobalPoint v = outerTSOS.globalParameters().position(); 00678 GlobalVector p = outerTSOS.globalParameters().momentum(); 00679 math::XYZPoint outpos( v.x(), v.y(), v.z() ); 00680 math::XYZVector outmom( p.x(), p.y(), p.z() ); 00681 00682 v = innerTSOS.globalParameters().position(); 00683 p = innerTSOS.globalParameters().momentum(); 00684 math::XYZPoint inpos( v.x(), v.y(), v.z() ); 00685 math::XYZVector inmom( p.x(), p.y(), p.z() ); 00686 00687 reco::TrackExtra trackExtra(outpos, outmom, true, inpos, inmom, true, 00688 outerTSOS.curvilinearError(), outerId, 00689 innerTSOS.curvilinearError(), innerId, 00690 trajectory.direction(),trajectory.seedRef()); 00691 00692 return trackExtra; 00693 00694 }
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 608 of file MuonTrackLoader.cc.
References FreeTrajectoryState::charge(), reco::TrackBase::chi2(), FreeTrajectoryState::curvilinearError(), debug, MuonPatternRecoDumper::dumpFTS(), LogTrace, FreeTrajectoryState::momentum(), reco::TrackBase::ndof(), p, FreeTrajectoryState::position(), theService, theUpdatorAtVtx, MuonUpdatorAtVertex::update(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
00608 { 00609 00610 const string metname = "Muon|RecoMuon|MuonTrackLoader"; 00611 MuonPatternRecoDumper debug; 00612 00613 // build the transient track 00614 reco::TransientTrack transientTrack(track, 00615 &*theService->magneticField(), 00616 theService->trackingGeometry()); 00617 00618 LogTrace(metname) << "Apply the vertex constraint"; 00619 pair<bool,FreeTrajectoryState> updateResult = theUpdatorAtVtx->update(transientTrack,beamSpot); 00620 00621 if(!updateResult.first){ 00622 return pair<bool,reco::Track>(false,reco::Track()); 00623 } 00624 00625 LogTrace(metname) << "FTS after the vertex constraint"; 00626 FreeTrajectoryState &ftsAtVtx = updateResult.second; 00627 00628 LogTrace(metname) << debug.dumpFTS(ftsAtVtx); 00629 00630 GlobalPoint pca = ftsAtVtx.position(); 00631 math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z()); 00632 GlobalVector p = ftsAtVtx.momentum(); 00633 math::XYZVector persistentMomentum(p.x(),p.y(),p.z()); 00634 00635 reco::Track updatedTrack(track.chi2(), 00636 track.ndof(), 00637 persistentPCA, 00638 persistentMomentum, 00639 ftsAtVtx.charge(), 00640 ftsAtVtx.curvilinearError()); 00641 00642 return pair<bool,reco::Track>(true,updatedTrack); 00643 }
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 278 of file MuonTrackLoader.cc.
References it, loadTracks(), LogDebug, LogTrace, reco::MuonTrackLinks::setStandAloneTrack(), reco::MuonTrackLinks::setTrackerTrack(), theL2SeededTkLabel, thePutTkTrackFlag, and theSmoothTkTrackFlag.
00279 { 00280 00281 const string metname = "Muon|RecoMuon|MuonTrackLoader"; 00282 00283 // the muon collection, it will be loaded in the event 00284 auto_ptr<reco::MuonTrackLinksCollection> trackLinksCollection(new reco::MuonTrackLinksCollection()); 00285 // don't waste any time... 00286 if ( muonCands.empty() ) { 00287 auto_ptr<reco::TrackExtraCollection> trackExtraCollection(new reco::TrackExtraCollection() ); 00288 auto_ptr<TrackingRecHitCollection> recHitCollection(new TrackingRecHitCollection() ); 00289 auto_ptr<reco::TrackCollection> trackCollection( new reco::TrackCollection() ); 00290 00291 event.put(recHitCollection); 00292 event.put(trackExtraCollection); 00293 event.put(trackCollection); 00294 00295 //need to also put the tracker tracks collection if requested 00296 if(thePutTkTrackFlag){ 00297 //will take care of putting nothing in the event but the empty collection 00298 TrajectoryContainer trackerTrajs; 00299 loadTracks(trackerTrajs, event, theL2SeededTkLabel, theSmoothTkTrackFlag); 00300 } 00301 00302 return event.put(trackLinksCollection); 00303 } 00304 00305 // get combined Trajectories 00306 TrajectoryContainer combinedTrajs; 00307 TrajectoryContainer trackerTrajs; 00308 00309 for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); it++) { 00310 LogDebug(metname) << "Loader glbSeedRef " << (*it)->trajectory()->seedRef().isNonnull(); 00311 if ((*it)->trackerTrajectory() ) LogDebug(metname) << " " << "tkSeedRef " << (*it)->trackerTrajectory()->seedRef().isNonnull(); 00312 combinedTrajs.push_back((*it)->trajectory()); 00313 if ( thePutTkTrackFlag ) trackerTrajs.push_back((*it)->trackerTrajectory()); 00314 // Create the links between sta and tracker tracks 00315 reco::MuonTrackLinks links; 00316 links.setStandAloneTrack((*it)->muonTrack()); 00317 links.setTrackerTrack((*it)->trackerTrack()); 00318 trackLinksCollection->push_back(links); 00319 delete *it; 00320 } 00321 00322 // create the TrackCollection of combined Trajectories 00323 // FIXME: could this be done one track at a time in the previous loop? 00324 OrphanHandle<reco::TrackCollection> combinedTracks = loadTracks(combinedTrajs, event); 00325 00326 OrphanHandle<reco::TrackCollection> trackerTracks; 00327 if(thePutTkTrackFlag) { 00328 trackerTracks = loadTracks(trackerTrajs, event, theL2SeededTkLabel, theSmoothTkTrackFlag); 00329 } else { 00330 for (TrajectoryContainer::iterator it = trackerTrajs.begin(); it != trackerTrajs.end(); ++it) { 00331 if(*it) delete *it; 00332 } 00333 } 00334 00335 00336 reco::MuonTrackLinksCollection::iterator links = trackLinksCollection->begin(); 00337 for ( unsigned int position = 0; position != combinedTracks->size(); ++position, ++links) { 00338 reco::TrackRef combinedTR(combinedTracks, position); 00339 00340 reco::TrackRef trackerTR; 00341 if(thePutTkTrackFlag) trackerTR = reco::TrackRef(trackerTracks, position); 00342 00343 // fill the combined information. 00344 links->setGlobalTrack(combinedTR); 00345 if(thePutTkTrackFlag) links->setTrackerTrack(trackerTR); 00346 } 00347 00348 // put the MuonCollection in the event 00349 LogTrace(metname) << "put the MuonCollection in the event" << "\n"; 00350 00351 return event.put(trackLinksCollection); 00352 }
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(), loadTracks(), and TevMuonProducer::produce().
bool MuonTrackLoader::theAllowNoVtxFlag [private] |
Definition at line 84 of file MuonTrackLoader.h.
Referenced by buildTrackAtPCA(), and MuonTrackLoader().
std::string MuonTrackLoader::theL2SeededTkLabel [private] |
Label for L2SeededTracks.
Definition at line 81 of file MuonTrackLoader.h.
Referenced by loadTracks(), and MuonTrackLoader().
bool MuonTrackLoader::thePutTkTrackFlag [private] |
const MuonServiceProxy* MuonTrackLoader::theService [private] |
Definition at line 69 of file MuonTrackLoader.h.
Referenced by buildTrackAtPCA(), and buildTrackUpdatedAtPCA().
Definition at line 78 of file MuonTrackLoader.h.
std::string MuonTrackLoader::theSmootherName [private] |
bool MuonTrackLoader::theSmoothingStep [private] |
bool MuonTrackLoader::theSmoothTkTrackFlag [private] |
bool MuonTrackLoader::theTrajectoryFlag [private] |
bool MuonTrackLoader::theUpdatingAtVtx [private] |
Definition at line 72 of file MuonTrackLoader.h.
Referenced by buildTrackAtPCA(), buildTrackUpdatedAtPCA(), MuonTrackLoader(), and ~MuonTrackLoader().