CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TrackTransformer Class Reference

#include <TrackTransformer.h>

Inheritance diagram for TrackTransformer:
TrackTransformerBase

List of all members.

Public Member Functions

TransientTrackingRecHit::ConstRecHitContainer getTransientRecHits (const reco::TransientTrack &track) const
const MagneticFieldmagneticField () const
 the magnetic field
edm::ESHandle< TrajectoryFitterrefitter () const
 the refitter used to refit the reco::Track
virtual void setServices (const edm::EventSetup &)
 set the services needed by the TrackTransformer
edm::ESHandle< TrajectorySmoothersmoother () const
 the smoother used to smooth the trajectory which came from the refitting step
edm::ESHandle
< GlobalTrackingGeometry
trackingGeometry () const
 the tracking geometry
 TrackTransformer (const edm::ParameterSet &)
 Constructor.
std::vector< Trajectorytransform (const reco::TrackRef &) const
 Convert a reco::TrackRef into Trajectory.
std::vector< Trajectorytransform (const reco::TransientTrack, TransientTrackingRecHit::ConstRecHitContainer) const
 Convert a reco::TrackRef into Trajectory, refit with a new set of hits.
virtual std::vector< Trajectorytransform (const reco::Track &) const
 Convert a reco::Track into Trajectory.
virtual ~TrackTransformer ()
 Destructor.

Private Member Functions

RefitDirection::GeometricalDirection checkRecHitsOrdering (TransientTrackingRecHit::ConstRecHitContainer &) const
edm::ESHandle< Propagatorpropagator () const

Private Attributes

unsigned long long theCacheId_GTG
unsigned long long theCacheId_MG
unsigned long long theCacheId_TC
unsigned long long theCacheId_TRH
bool theDoPredictionsOnly
edm::ESHandle< TrajectoryFittertheFitter
std::string theFitterName
edm::ESHandle< MagneticFieldtheMGField
edm::ESHandle
< TransientTrackingRecHitBuilder
theMuonRecHitBuilder
std::string theMuonRecHitBuilderName
edm::ESHandle< PropagatorthePropagator
std::string thePropagatorName
RefitDirection theRefitDirection
bool theRPCInTheFit
edm::ESHandle< TrajectorySmoothertheSmoother
std::string theSmootherName
edm::ESHandle
< TransientTrackingRecHitBuilder
theTrackerRecHitBuilder
std::string theTrackerRecHitBuilderName
edm::ESHandle
< GlobalTrackingGeometry
theTrackingGeometry

Detailed Description

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.

Date:
2009/08/03 13:39:07
Revision:
1.15
Author:
R. Bellan - INFN Torino <riccardo.bellan@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.

Rec hits are ordered in rank of increasing |z| assuing muons are coming from the top of the detector.

$Date: 2009/01/15

Revision:
1.4

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.

Date:
2009/03/03 11:03:08
Revision:
1.4
Author:
R. Bellan - CERN <riccardo.bellan@cern.ch>

Definition at line 39 of file TrackTransformer.h.


Constructor & Destructor Documentation

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]

Destructor.

Definition at line 49 of file TrackTransformer.cc.

{}

Member Function Documentation

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]

Definition at line 84 of file TrackTransformer.h.

References thePropagator.

{return thePropagator;}
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.

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);
}

Member Data Documentation

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.

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.

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.

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.

Definition at line 111 of file TrackTransformer.h.

Definition at line 97 of file TrackTransformer.h.

Referenced by trackingGeometry().