#include <TrackTransformer.h>
This class takes a reco::Track and refits the rechits inside it. The final result is a Trajectory refitted and smoothed. To make the refitting (and the smoothing) the usual KF tools are used.
CAVEAT: till now (it will be changed in the near future) the class stores the pointers to the services, therefore EACH event the setServices(const edm::EventSetup&) method MUST be called in the code in which the TrackTransformer is used.
This class takes a reco::Track and refits the rechits inside it. The final result is a Trajectory refitted and smoothed. To make the refitting (and the smoothing) the usual KF tools are used.
CAVEAT: till now (it will be changed in the near future) the class stores the pointers to the services, therefore EACH event the setServices(const edm::EventSetup&) method MUST be called in the code in which the TrackTransformer is used.
Rec hits are ordered in rank of increasing |z| assuing muons are coming from the top of the detector.
$Date: 2009/01/15
author R. Bellan - CERN <riccardo.bellan@cern.ch> modified for zed ordering by N. Kypreos - UF <nicholas.theodore.kypreos@cern.ch>
This class takes a reco::Track and refits the rechits inside it. The final result is a Trajectory refitted and smoothed. To make the refitting (and the smoothing) the usual KF tools are used.
CAVEAT: till now (it will be changed in the near future) the class stores the pointers to the services, therefore EACH event the setServices(const edm::EventSetup&) method MUST be called in the code in which the TrackTransformer is used.
Definition at line 39 of file TrackTransformer.h.
TrackTransformer::TrackTransformer | ( | const edm::ParameterSet & | parameterSet | ) |
Constructor.
Definition at line 29 of file TrackTransformer.cc.
References edm::ParameterSet::getParameter().
{ // Refit direction string refitDirectionName = parameterSet.getParameter<string>("RefitDirection"); theRefitDirection = RefitDirection(refitDirectionName); theFitterName = parameterSet.getParameter<string>("Fitter"); theSmootherName = parameterSet.getParameter<string>("Smoother"); thePropagatorName = parameterSet.getParameter<string>("Propagator"); theTrackerRecHitBuilderName = parameterSet.getParameter<string>("TrackerRecHitBuilder"); theMuonRecHitBuilderName = parameterSet.getParameter<string>("MuonRecHitBuilder"); theRPCInTheFit = parameterSet.getParameter<bool>("RefitRPCHits"); theDoPredictionsOnly = parameterSet.getParameter<bool>("DoPredictionsOnly"); theCacheId_TC = theCacheId_GTG = theCacheId_MG = theCacheId_TRH = 0; }
TrackTransformer::~TrackTransformer | ( | ) | [virtual] |
RefitDirection::GeometricalDirection TrackTransformer::checkRecHitsOrdering | ( | TransientTrackingRecHit::ConstRecHitContainer & | recHits | ) | const [private] |
Definition at line 124 of file TrackTransformer.cc.
References first, insideOut, prof2calltree::last, LogDebug, PV3DBase< T, PVType, FrameType >::mag(), outsideIn, position, and RefitDirection::undetermined.
{ if (!recHits.empty()){ GlobalPoint first = trackingGeometry()->idToDet(recHits.front()->geographicalId())->position(); GlobalPoint last = trackingGeometry()->idToDet(recHits.back()->geographicalId())->position(); double rFirst = first.mag(); double rLast = last.mag(); if(rFirst < rLast) return RefitDirection::insideOut; else if(rFirst > rLast) return RefitDirection::outsideIn; else{ LogDebug("Reco|TrackingTools|TrackTransformer") << "Impossible to determine the rechits order" <<endl; return RefitDirection::undetermined; } } else{ LogDebug("Reco|TrackingTools|TrackTransformer") << "Impossible to determine the rechits order" <<endl; return RefitDirection::undetermined; } }
TransientTrackingRecHit::ConstRecHitContainer TrackTransformer::getTransientRecHits | ( | const reco::TransientTrack & | track | ) | const |
Definition at line 101 of file TrackTransformer.cc.
References LogTrace, DetId::Muon, reco::TransientTrack::recHitsBegin(), reco::TransientTrack::recHitsEnd(), query::result, and align::Tracker.
{ TransientTrackingRecHit::ConstRecHitContainer result; for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) { if((*hit)->isValid()) { if ( (*hit)->geographicalId().det() == DetId::Tracker ) { result.push_back(theTrackerRecHitBuilder->build(&**hit)); } else if ( (*hit)->geographicalId().det() == DetId::Muon ){ if( (*hit)->geographicalId().subdetId() == 3 && !theRPCInTheFit){ LogTrace("Reco|TrackingTools|TrackTransformer") << "RPC Rec Hit discarged"; continue; } result.push_back(theMuonRecHitBuilder->build(&**hit)); } } } return result; }
const MagneticField* TrackTransformer::magneticField | ( | ) | const [inline] |
the magnetic field
Definition at line 62 of file TrackTransformer.h.
References theMGField.
{return &*theMGField;}
edm::ESHandle<Propagator> TrackTransformer::propagator | ( | void | ) | const [inline, private] |
edm::ESHandle<TrajectoryFitter> TrackTransformer::refitter | ( | ) | const [inline] |
the refitter used to refit the reco::Track
Definition at line 71 of file TrackTransformer.h.
References theFitter.
{return theFitter;}
void TrackTransformer::setServices | ( | const edm::EventSetup & | setup | ) | [virtual] |
set the services needed by the TrackTransformer
Implements TrackTransformerBase.
Definition at line 52 of file TrackTransformer.cc.
References edm::EventSetup::get(), LogTrace, and metname.
Referenced by MuonKinkFinder::init(), TrackerToMuonPropagator::produce(), CSCOverlapsAlignmentAlgorithm::run(), and GlobalTrajectoryBuilderBase::setEvent().
{ const std::string metname = "Reco|TrackingTools|TrackTransformer"; setup.get<TrajectoryFitter::Record>().get(theFitterName,theFitter); setup.get<TrajectoryFitter::Record>().get(theSmootherName,theSmoother); unsigned long long newCacheId_TC = setup.get<TrackingComponentsRecord>().cacheIdentifier(); if ( newCacheId_TC != theCacheId_TC ){ LogTrace(metname) << "Tracking Component changed!"; theCacheId_TC = newCacheId_TC; setup.get<TrackingComponentsRecord>().get(thePropagatorName,thePropagator); } // Global Tracking Geometry unsigned long long newCacheId_GTG = setup.get<GlobalTrackingGeometryRecord>().cacheIdentifier(); if ( newCacheId_GTG != theCacheId_GTG ) { LogTrace(metname) << "GlobalTrackingGeometry changed!"; theCacheId_GTG = newCacheId_GTG; setup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry); } // Magfield Field unsigned long long newCacheId_MG = setup.get<IdealMagneticFieldRecord>().cacheIdentifier(); if ( newCacheId_MG != theCacheId_MG ) { LogTrace(metname) << "Magnetic Field changed!"; theCacheId_MG = newCacheId_MG; setup.get<IdealMagneticFieldRecord>().get(theMGField); } // Transient Rechit Builders unsigned long long newCacheId_TRH = setup.get<TransientRecHitRecord>().cacheIdentifier(); if ( newCacheId_TRH != theCacheId_TRH ) { theCacheId_TRH = newCacheId_TRH; LogTrace(metname) << "TransientRecHitRecord changed!"; setup.get<TransientRecHitRecord>().get(theTrackerRecHitBuilderName,theTrackerRecHitBuilder); setup.get<TransientRecHitRecord>().get(theMuonRecHitBuilderName,theMuonRecHitBuilder); } }
edm::ESHandle<TrajectorySmoother> TrackTransformer::smoother | ( | ) | const [inline] |
the smoother used to smooth the trajectory which came from the refitting step
Definition at line 74 of file TrackTransformer.h.
References theSmoother.
{return theSmoother;}
edm::ESHandle<GlobalTrackingGeometry> TrackTransformer::trackingGeometry | ( | ) | const [inline] |
the tracking geometry
Definition at line 65 of file TrackTransformer.h.
References theTrackingGeometry.
{return theTrackingGeometry;}
vector< Trajectory > TrackTransformer::transform | ( | const reco::TransientTrack | track, |
TransientTrackingRecHit::ConstRecHitContainer | recHitsForReFit | ||
) | const |
Convert a reco::TrackRef into Trajectory, refit with a new set of hits.
Convert Tracks into Trajectories with a given set of hits.
Definition at line 170 of file TrackTransformer.cc.
References alongMomentum, anyDirection, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), reco::TransientTrack::innermostMeasurementState(), RefitDirection::insideOut, TrajectoryStateOnSurface::isValid(), LogTrace, metname, oppositeToMomentum, reco::TransientTrack::outermostMeasurementState(), outsideIn, RefitDirection::outsideIn, AlCaHLTBitMon_ParallelJobs::p, position, LargeD0_PixelPairStep_cff::propagator, Trajectory::push(), TrajectoryStateOnSurface::surface(), reco::TransientTrack::track(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().
{ const std::string metname = "Reco|TrackingTools|TrackTransformer"; if(recHitsForReFit.size() < 2) return vector<Trajectory>(); // 8 cases are foreseen: // [RH = rec hit order, P = momentum dir, FD = fit direction. IO/OI = inside-out/outside-in, AM/OM = along momentum/opposite to momentum] // (1) RH IO | P IO | FD AM ---> Start from IN // (2) RH IO | P IO | FD OM ---> Reverse RH and start from OUT // (3) RH IO | P OI | FD AM ---> Reverse RH and start from IN // (4) RH IO | P OI | FD OM ---> Start from OUT // (5) RH OI | P IO | FD AM ---> Reverse RH and start from IN // (6) RH OI | P IO | FD OM ---> Start from OUT // (7) RH OI | P OI | FD AM ---> Start from IN // (8) RH OI | P OI | FD OM ---> Reverse RH and start from OUT // // *** Rules: *** // -A- If RH-FD agree (IO-AM,OI-OM) do not reverse the RH // -B- If FD along momentum start from innermost state, otherwise use outermost // Other special cases can be handled: // (1 bis) RH IO | P IO | GFD IO => FD AM ---> Start from IN // (2 bis) RH IO | P IO | GFD OI => FD OM ---> Reverse RH and start from OUT // (3 bis) RH IO | P OI | GFD OI => FD AM ---> Reverse RH and start from OUT // (4 bis) RH IO | P OI | GFD IO => FD OM ---> Start from IN // (5 bis) RH OI | P IO | GFD IO => FD AM ---> Reverse RH and start from IN // (6 bis) RH OI | P IO | GFD OI => FD OM ---> Start from OUT // (7 bis) RH OI | P OI | GFD OI => FD AM ---> Start from OUT // (8 bis) RH OI | P OI | GFD IO => FD OM ---> Reverse RH and start from IN // // *** Additional rule: *** // -A0- If P and GFD agree, then FD is AM otherwise is OM // -A00- rechit must be ordered as GFD in order to handle the case of cosmics // -B0- The starting state is decided by GFD // Determine the RH order RefitDirection::GeometricalDirection recHitsOrder = checkRecHitsOrdering(recHitsForReFit); // FIXME change nome of the *type* --> RecHit order! LogTrace(metname) << "RH order (0-insideOut, 1-outsideIn): " << recHitsOrder; PropagationDirection propagationDirection = theRefitDirection.propagationDirection(); // Apply rule -A0- if(propagationDirection == anyDirection){ GlobalVector momentum = track.innermostMeasurementState().globalMomentum(); GlobalVector position = track.innermostMeasurementState().globalPosition() - GlobalPoint(0,0,0); RefitDirection::GeometricalDirection p = (momentum.x()*position.x() > 0 || momentum.y()*position.y() > 0) ? RefitDirection::insideOut : RefitDirection::outsideIn; propagationDirection = p == theRefitDirection.geometricalDirection() ? alongMomentum : oppositeToMomentum; LogTrace(metname) << "P (0-insideOut, 1-outsideIn): " << p; LogTrace(metname) << "FD (0-OM, 1-AM, 2-ANY): " << propagationDirection; } // -A0- // Apply rule -A- if(theRefitDirection.propagationDirection() != anyDirection){ if((recHitsOrder == RefitDirection::insideOut && propagationDirection == oppositeToMomentum) || (recHitsOrder == RefitDirection::outsideIn && propagationDirection == alongMomentum) ) reverse(recHitsForReFit.begin(),recHitsForReFit.end());} // -A- // Apply rule -A00- else{ // reorder the rechit as defined in theRefitDirection.geometricalDirection(); if(theRefitDirection.geometricalDirection() != recHitsOrder) reverse(recHitsForReFit.begin(),recHitsForReFit.end()); } // -A00- // Apply rule -B- TrajectoryStateOnSurface firstTSOS = track.innermostMeasurementState(); unsigned int innerId = track.track().innerDetId(); if(theRefitDirection.propagationDirection() != anyDirection){ if(propagationDirection == oppositeToMomentum){ innerId = track.track().outerDetId(); firstTSOS = track.outermostMeasurementState(); } } else { // if(theRefitDirection.propagationDirection() == anyDirection) // Apply rule -B0- if(theRefitDirection.geometricalDirection() == RefitDirection::outsideIn){ innerId = track.track().outerDetId(); firstTSOS = track.outermostMeasurementState(); } // -B0- } // -B- if(!firstTSOS.isValid()){ LogTrace(metname)<<"Error wrong initial state!"<<endl; return vector<Trajectory>(); } TrajectorySeed seed(PTrajectoryStateOnDet(),TrajectorySeed::recHitContainer(),propagationDirection); if(recHitsForReFit.front()->geographicalId() != DetId(innerId)){ LogTrace(metname)<<"Propagation occured"<<endl; firstTSOS = propagator()->propagate(firstTSOS, recHitsForReFit.front()->det()->surface()); if(!firstTSOS.isValid()){ LogTrace(metname)<<"Propagation error!"<<endl; return vector<Trajectory>(); } } if(theDoPredictionsOnly){ Trajectory aTraj(seed,propagationDirection); TrajectoryStateOnSurface predTSOS = firstTSOS; for(TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit = recHitsForReFit.begin(); ihit != recHitsForReFit.end(); ++ihit ) { predTSOS = propagator()->propagate(predTSOS, (*ihit)->det()->surface()); if (predTSOS.isValid()) aTraj.push(TrajectoryMeasurement(predTSOS, *ihit)); } return vector<Trajectory>(1, aTraj); } vector<Trajectory> trajectories = theFitter->fit(seed,recHitsForReFit,firstTSOS); if(trajectories.empty()){ LogTrace(metname)<<"No Track refitted!"<<endl; return vector<Trajectory>(); } Trajectory trajectoryBW = trajectories.front(); vector<Trajectory> trajectoriesSM = theSmoother->trajectories(trajectoryBW); if(trajectoriesSM.empty()){ LogTrace(metname)<<"No Track smoothed!"<<endl; return vector<Trajectory>(); } return trajectoriesSM; }
vector< Trajectory > TrackTransformer::transform | ( | const reco::TrackRef & | track | ) | const |
Convert a reco::TrackRef into Trajectory.
Definition at line 95 of file TrackTransformer.cc.
{ return transform(*track); }
vector< Trajectory > TrackTransformer::transform | ( | const reco::Track & | newTrack | ) | const [virtual] |
Convert a reco::Track into Trajectory.
Convert Tracks into Trajectories.
Implements TrackTransformerBase.
Definition at line 156 of file TrackTransformer.cc.
References metname.
Referenced by GlobalTrajectoryBuilderBase::build(), CSCPairResidualsConstraint::dphidzFromTrack(), MuonKinkFinder::fillTrkKink(), and TrackerToMuonPropagator::produce().
{ const std::string metname = "Reco|TrackingTools|TrackTransformer"; reco::TransientTrack track(newTrack,magneticField(),trackingGeometry()); // Build the transient Rechits TransientTrackingRecHit::ConstRecHitContainer recHitsForReFit = getTransientRecHits(track); return transform(track, recHitsForReFit); }
unsigned long long TrackTransformer::theCacheId_GTG [private] |
Definition at line 88 of file TrackTransformer.h.
unsigned long long TrackTransformer::theCacheId_MG [private] |
Definition at line 89 of file TrackTransformer.h.
unsigned long long TrackTransformer::theCacheId_TC [private] |
Definition at line 87 of file TrackTransformer.h.
unsigned long long TrackTransformer::theCacheId_TRH [private] |
Definition at line 90 of file TrackTransformer.h.
bool TrackTransformer::theDoPredictionsOnly [private] |
Definition at line 94 of file TrackTransformer.h.
Definition at line 101 of file TrackTransformer.h.
Referenced by refitter().
std::string TrackTransformer::theFitterName [private] |
Definition at line 100 of file TrackTransformer.h.
Definition at line 98 of file TrackTransformer.h.
Referenced by magneticField().
Definition at line 115 of file TrackTransformer.h.
std::string TrackTransformer::theMuonRecHitBuilderName [private] |
Definition at line 114 of file TrackTransformer.h.
Definition at line 85 of file TrackTransformer.h.
Referenced by propagator().
std::string TrackTransformer::thePropagatorName [private] |
Definition at line 83 of file TrackTransformer.h.
Definition at line 95 of file TrackTransformer.h.
bool TrackTransformer::theRPCInTheFit [private] |
Definition at line 92 of file TrackTransformer.h.
Definition at line 104 of file TrackTransformer.h.
Referenced by smoother().
std::string TrackTransformer::theSmootherName [private] |
Definition at line 103 of file TrackTransformer.h.
Definition at line 112 of file TrackTransformer.h.
std::string TrackTransformer::theTrackerRecHitBuilderName [private] |
Definition at line 111 of file TrackTransformer.h.
Definition at line 97 of file TrackTransformer.h.
Referenced by trackingGeometry().