CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

FastTSGFromPropagation Class Reference

#include <FastTSGFromPropagation.h>

Inheritance diagram for FastTSGFromPropagation:
TrackerSeedGenerator

List of all members.

Classes

struct  increasingEstimate
struct  isInvalid

Public Member Functions

 FastTSGFromPropagation (const edm::ParameterSet &pset)
 constructor
 FastTSGFromPropagation (const edm::ParameterSet &par, const MuonServiceProxy *)
void init (const MuonServiceProxy *)
 initialize
void setEvent (const edm::Event &)
 set an event
void trackerSeeds (const TrackCand &, const TrackingRegion &, std::vector< TrajectorySeed > &)
 generate seed(s) for a track
virtual ~FastTSGFromPropagation ()
 destructor

Private Member Functions

void adjust (FreeTrajectoryState &) const
 adjust the error matrix of the FTS
void adjust (TrajectoryStateOnSurface &) const
 adjust the error matrix of the TSOS
TrajectorySeed createSeed (const TrajectoryStateOnSurface &tsos, const edm::OwnVector< TrackingRecHit > &container, const DetId &id) const
 create a seed from a trajectory state
TrajectorySeed createSeed (const TrajectoryStateOnSurface &, const DetId &) const
 create a hitless seed from a trajectory state
double dxyDis (const TrajectoryStateOnSurface &tsos) const
const Chi2MeasurementEstimatorestimator () const
std::vector
< TrajectoryMeasurement
findMeasurements (const DetLayer *, const TrajectoryStateOnSurface &) const
 look for measurements on the first compatible layer
std::vector
< TrajectoryMeasurement
findMeasurements_new (const DetLayer *, const TrajectoryStateOnSurface &) const
 look for measurements on the first compatible layer (faster way)
void getRescalingFactor (const TrackCand &staMuon)
TrajectoryStateOnSurface innerState (const TrackCand &) const
TrajectoryStateOnSurface outerTkState (const TrackCand &) const
bool passSelection (const TrajectoryStateOnSurface &) const
 check some quantity and beam-spot compatibility and decide to continue
edm::ESHandle< Propagatorpropagator () const
void stateOnDet (const TrajectoryStateOnSurface &ts, unsigned int detid, PTrajectoryStateOnDet &pts) const
 A mere copy (without memory leak) of an existing tracking method.
const LayerMeasurementstkLayerMeasurements () const
const TrajectoryStateUpdatorupdator () const
void validMeasurements (std::vector< TrajectoryMeasurement > &) const
 select valid measurements
double zDis (const TrajectoryStateOnSurface &tsos) const

Private Attributes

edm::InputTag beamSpot_
bool theAdjustAtIp
edm::Handle< reco::BeamSpottheBeamSpot
unsigned long long theCacheId_MT
unsigned long long theCacheId_TG
std::string theCategory
edm::ParameterSet theConfig
MuonErrorMatrixtheErrorMatrixAdjuster
const Chi2MeasurementEstimatortheEstimator
double theFixedErrorRescaling
double theFlexErrorRescaling
const TrackerGeometrytheGeometry
edm::Handle
< SiTrackerGSMatchedRecHit2DCollection
theGSRecHits
edm::InputTag theHitProducer
double theMaxChi2
edm::ESHandle< MeasurementTrackertheMeasTracker
const DirectTrackerNavigationtheNavigation
std::string thePropagatorName
std::string theResetMethod
bool theSelectStateFlag
const MuonServiceProxytheService
double theSigmaZ
edm::InputTag theSimTrackCollectionLabel
edm::Handle
< edm::SimTrackContainer
theSimTracks
const LayerMeasurementstheTkLayerMeasurements
edm::ESHandle
< GeometricSearchTracker
theTracker
TrajectoryStateTransformtheTSTransformer
edm::ESHandle
< TransientTrackingRecHitBuilder
theTTRHBuilder
bool theUpdateStateFlag
const TrajectoryStateUpdatortheUpdator
bool theUseVertexStateFlag

Detailed Description

Emulate TSGFromPropagation in RecoMuon

Author:
Hwidong Yoo - Purdue University

Tracker Seed Generator by propagating and updating a standAlone muon to the first 2 (or 1) rechits it meets in tracker system

Emulate TSGFromPropagation in RecoMuon

Author:
Hwidong Yoo - Purdue University

Definition at line 43 of file FastTSGFromPropagation.h.


Constructor & Destructor Documentation

FastTSGFromPropagation::FastTSGFromPropagation ( const edm::ParameterSet pset)

constructor

Definition at line 47 of file FastTSGFromPropagation.cc.

References theCategory.

                                                                              :theTkLayerMeasurements (0), theTracker(0), theNavigation(0), theService(0), theEstimator(0),  theSigmaZ(0), theConfig (iConfig),
  beamSpot_(iConfig.getParameter<edm::InputTag>("beamSpot"))
{
  theCategory = "FastSimulation|Muons||FastTSGFromPropagation";

}
FastTSGFromPropagation::FastTSGFromPropagation ( const edm::ParameterSet par,
const MuonServiceProxy *  service 
)

Definition at line 54 of file FastTSGFromPropagation.cc.

References theCategory.

                                                                                                               : theTkLayerMeasurements (0), theTracker(0), theNavigation(0), theService(service),theUpdator(0), theEstimator(0), theSigmaZ(0), theConfig (iConfig),
  beamSpot_(iConfig.getParameter<edm::InputTag>("beamSpot"))
{
  theCategory = "FastSimulation|Muons|FastTSGFromPropagation";
}
FastTSGFromPropagation::~FastTSGFromPropagation ( ) [virtual]

destructor

Definition at line 60 of file FastTSGFromPropagation.cc.

References LogTrace, theCategory, theErrorMatrixAdjuster, theEstimator, theNavigation, theTkLayerMeasurements, and theUpdator.

{

  LogTrace(theCategory) << " FastTSGFromPropagation dtor called ";
  if ( theNavigation ) delete theNavigation;
  if ( theUpdator ) delete theUpdator;
  if ( theEstimator ) delete theEstimator;
  if ( theTkLayerMeasurements ) delete theTkLayerMeasurements;
  if ( theErrorMatrixAdjuster ) delete theErrorMatrixAdjuster;

}

Member Function Documentation

void FastTSGFromPropagation::adjust ( FreeTrajectoryState state) const [private]
void FastTSGFromPropagation::adjust ( TrajectoryStateOnSurface state) const [private]
TrajectorySeed FastTSGFromPropagation::createSeed ( const TrajectoryStateOnSurface tsos,
const DetId id 
) const [private]

create a hitless seed from a trajectory state

Definition at line 436 of file FastTSGFromPropagation.cc.

Referenced by trackerSeeds().

                                                                                                             {

  edm::OwnVector<TrackingRecHit> container;
  return createSeed(tsos, container, id);

}
TrajectorySeed FastTSGFromPropagation::createSeed ( const TrajectoryStateOnSurface tsos,
const edm::OwnVector< TrackingRecHit > &  container,
const DetId id 
) const [private]

create a seed from a trajectory state

Definition at line 443 of file FastTSGFromPropagation.cc.

References oppositeToMomentum, and trajectoryStateTransform::persistentState().

                                                                                                                                                            {

  PTrajectoryStateOnDet seedTSOS = trajectoryStateTransform::persistentState(tsos,id.rawId());
  return TrajectorySeed(seedTSOS,container,oppositeToMomentum);

}
double FastTSGFromPropagation::dxyDis ( const TrajectoryStateOnSurface tsos) const [private]
const Chi2MeasurementEstimator* FastTSGFromPropagation::estimator ( void  ) const [inline, private]

Definition at line 77 of file FastTSGFromPropagation.h.

References theEstimator.

Referenced by findMeasurements(), findMeasurements_new(), and trackerSeeds().

{ return theEstimator; }
std::vector< TrajectoryMeasurement > FastTSGFromPropagation::findMeasurements ( const DetLayer nl,
const TrajectoryStateOnSurface staState 
) const [private]

look for measurements on the first compatible layer

Definition at line 484 of file FastTSGFromPropagation.cc.

References estimator(), LayerMeasurements::measurements(), propagator(), query::result, tkLayerMeasurements(), and validMeasurements().

                                                                                                                                            {

  std::vector<TrajectoryMeasurement> result = tkLayerMeasurements()->measurements((*nl), staState, *propagator(), *estimator());
  validMeasurements(result);
  return result;
}
std::vector< TrajectoryMeasurement > FastTSGFromPropagation::findMeasurements_new ( const DetLayer nl,
const TrajectoryStateOnSurface staState 
) const [private]

look for measurements on the first compatible layer (faster way)

Definition at line 459 of file FastTSGFromPropagation.cc.

References GeometricSearchDet::compatibleDets(), estimator(), propagator(), query::result, and theMeasTracker.

Referenced by trackerSeeds().

                                                                                                                                                {

  std::vector<TrajectoryMeasurement> result;

  std::vector<DetLayer::DetWithState> compatDets = nl->compatibleDets(staState, *propagator(), *estimator());
  if ( compatDets.empty() )  return result;

  for (std::vector<DetLayer::DetWithState>::const_iterator idws = compatDets.begin(); idws != compatDets.end(); ++idws) {
     if ( idws->second.isValid() && (idws->first) )  {
         std::vector<TrajectoryMeasurement> tmptm = 
           theMeasTracker->idToDet(idws->first->geographicalId())->fastMeasurements(idws->second, idws->second, *propagator(), *estimator());
         //validMeasurements(tmptm);
//         if ( tmptm.size() > 2 ) {
//            std::stable_sort(tmptm.begin(),tmptm.end(),increasingEstimate());
//            result.insert(result.end(),tmptm.begin(), tmptm.begin()+2);
//         } else {
            result.insert(result.end(),tmptm.begin(), tmptm.end());
//         }
     }
  }
  
  return result;

}
void FastTSGFromPropagation::getRescalingFactor ( const TrackCand staMuon) [private]

Definition at line 514 of file FastTSGFromPropagation.cc.

References theFlexErrorRescaling.

Referenced by trackerSeeds().

                                                                        {
    float pt = (staMuon.second)->pt();
    if ( pt < 13.0 ) theFlexErrorRescaling = 3; 
    else if ( pt < 30.0 ) theFlexErrorRescaling = 5;
    else theFlexErrorRescaling = 10;
    return;
}
void FastTSGFromPropagation::init ( const MuonServiceProxy *  service) [virtual]

initialize

Reimplemented from TrackerSeedGenerator.

Definition at line 292 of file FastTSGFromPropagation.cc.

References Chi2MeasurementEstimatorESProducer_cfi::Chi2MeasurementEstimator, geometry, MuonErrorMatrix::get(), edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, theAdjustAtIp, theCacheId_MT, theCacheId_TG, theConfig, theErrorMatrixAdjuster, theEstimator, theFixedErrorRescaling, theFlexErrorRescaling, theGeometry, theHitProducer, theMaxChi2, theNavigation, thePropagatorName, theResetMethod, theSelectStateFlag, theService, theSigmaZ, theSimTrackCollectionLabel, theTracker, theTTRHBuilder, theUpdateStateFlag, theUpdator, and theUseVertexStateFlag.

                                                                 {

  theMaxChi2 = theConfig.getParameter<double>("MaxChi2");

  theFixedErrorRescaling = theConfig.getParameter<double>("ErrorRescaling");

  theFlexErrorRescaling = 1.0;

  theResetMethod = theConfig.getParameter<std::string>("ResetMethod");

  if (theResetMethod != "discrete" && theResetMethod != "fixed" && theResetMethod != "matrix"  ) {
    edm::LogError("FastTSGFromPropagation") 
      <<"Wrong error rescaling method: "<<theResetMethod <<"\n"
      <<"Possible choices are: discrete, fixed, matrix.\n"
      <<"Use discrete method" <<std::endl;
    theResetMethod = "discrete"; 
  }

  theEstimator = new Chi2MeasurementEstimator(theMaxChi2);

  theCacheId_MT = 0;

  theCacheId_TG = 0;

  thePropagatorName = theConfig.getParameter<std::string>("Propagator");

  theService = service;

  theUseVertexStateFlag = theConfig.getParameter<bool>("UseVertexState");

  theUpdateStateFlag = theConfig.getParameter<bool>("UpdateState");

  theSelectStateFlag = theConfig.getParameter<bool>("SelectState");

  theSimTrackCollectionLabel = theConfig.getParameter<edm::InputTag>("SimTrackCollectionLabel");
  theHitProducer = theConfig.getParameter<edm::InputTag>("HitProducer");

  theUpdator = new KFUpdator();

  theSigmaZ = theConfig.getParameter<double>("SigmaZ");

  edm::ParameterSet errorMatrixPset = theConfig.getParameter<edm::ParameterSet>("errorMatrixPset");
  if ( theResetMethod == "matrix" && !errorMatrixPset.empty()){
    theAdjustAtIp = errorMatrixPset.getParameter<bool>("atIP");
    theErrorMatrixAdjuster = new MuonErrorMatrix(errorMatrixPset);
  } else {
    theAdjustAtIp =false;
    theErrorMatrixAdjuster=0;
  }

  theService->eventSetup().get<TrackerRecoGeometryRecord>().get(theTracker); 
  theNavigation = new DirectTrackerNavigation(theTracker);

  edm::ESHandle<TrackerGeometry>        geometry;
  theService->eventSetup().get<TrackerDigiGeometryRecord>().get(geometry);
  theGeometry = &(*geometry);

  theService->eventSetup().get<TransientRecHitRecord>().get("WithTrackAngle", theTTRHBuilder);

}
TrajectoryStateOnSurface FastTSGFromPropagation::innerState ( const TrackCand staMuon) const [private]

Definition at line 397 of file FastTSGFromPropagation.cc.

References adjust(), alongMomentum, trajectoryStateTransform::innerStateOnSurface(), oppositeToMomentum, and theService.

Referenced by outerTkState().

                                                                                          {

  TrajectoryStateOnSurface innerTS;

  if ( staMuon.first && staMuon.first->isValid() ) {
    if (staMuon.first->direction() == alongMomentum) {
      innerTS = staMuon.first->firstMeasurement().updatedState();
    } 
    else if (staMuon.first->direction() == oppositeToMomentum) { 
      innerTS = staMuon.first->lastMeasurement().updatedState();
    }
  } else {
    innerTS = trajectoryStateTransform::innerStateOnSurface(*(staMuon.second),*theService->trackingGeometry(), &*theService->magneticField());
  }
  //rescale the error
  adjust(innerTS);

  return  innerTS;

}
TrajectoryStateOnSurface FastTSGFromPropagation::outerTkState ( const TrackCand staMuon) const [private]

Definition at line 418 of file FastTSGFromPropagation.cc.

References adjust(), trajectoryStateTransform::initialFreeState(), innerState(), propagator(), query::result, theService, and theUseVertexStateFlag.

Referenced by trackerSeeds().

                                                                                            {

  TrajectoryStateOnSurface result;

  if ( theUseVertexStateFlag && staMuon.second->pt() > 1.0 ) {
    FreeTrajectoryState iniState = trajectoryStateTransform::initialFreeState(*(staMuon.second), &*theService->magneticField());
    //rescale the error at IP
    adjust(iniState); 

    StateOnTrackerBound fromInside(&*(theService->propagator("PropagatorWithMaterial")));
    result = fromInside(iniState);
  } else {
    StateOnTrackerBound fromOutside(&*propagator());
    result = fromOutside(innerState(staMuon));
  }
  return result;
}
bool FastTSGFromPropagation::passSelection ( const TrajectoryStateOnSurface tsos) const [private]

check some quantity and beam-spot compatibility and decide to continue

Definition at line 491 of file FastTSGFromPropagation.cc.

References edm::HandleBase::isValid(), theBeamSpot, theSelectStateFlag, theSigmaZ, and zDis().

Referenced by trackerSeeds().

                                                                                     {
  if ( !theSelectStateFlag ) return true;
  else {
     if ( theBeamSpot.isValid() ) {
       return ( ( fabs(zDis(tsos) - theBeamSpot->z0() ) < theSigmaZ) );

     } else {
       return ( ( fabs(zDis(tsos)) < theSigmaZ) ); 
//      double theDxyCut = 100;
//      return ( (zDis(tsos) < theSigmaZ) && (dxyDis(tsos) < theDxyCut) );
     }
  }

}
edm::ESHandle<Propagator> FastTSGFromPropagation::propagator ( void  ) const [inline, private]
void FastTSGFromPropagation::setEvent ( const edm::Event iEvent) [virtual]

set an event

Reimplemented from TrackerSeedGenerator.

Definition at line 353 of file FastTSGFromPropagation.cc.

References beamSpot_, edm::Event::getByLabel(), LogTrace, theBeamSpot, theCacheId_MT, theCacheId_TG, theCategory, theGSRecHits, theHitProducer, theMeasTracker, theNavigation, theService, theSimTrackCollectionLabel, theSimTracks, theTkLayerMeasurements, theTracker, and theUpdateStateFlag.

                                                            {

  bool measTrackerChanged = false;

  iEvent.getByLabel(beamSpot_, theBeamSpot);
  
  // retrieve the MC truth (SimTracks)
  iEvent.getByLabel(theSimTrackCollectionLabel, theSimTracks);
  iEvent.getByLabel(theHitProducer, theGSRecHits);


  unsigned long long newCacheId_MT = theService->eventSetup().get<CkfComponentsRecord>().cacheIdentifier();

  if ( theUpdateStateFlag && newCacheId_MT != theCacheId_MT ) {
    LogTrace(theCategory) << "Measurment Tracker Geometry changed!";
    theCacheId_MT = newCacheId_MT;
    theService->eventSetup().get<CkfComponentsRecord>().get(theMeasTracker);
    measTrackerChanged = true;
  }

  //if ( theUpdateStateFlag ) theMeasTracker->update(iEvent);

  if ( measTrackerChanged && (&*theMeasTracker) ) {
     if ( theTkLayerMeasurements ) delete theTkLayerMeasurements;
     theTkLayerMeasurements = new LayerMeasurements(&*theMeasTracker);
  }

  bool trackerGeomChanged = false;

  unsigned long long newCacheId_TG = theService->eventSetup().get<TrackerRecoGeometryRecord>().cacheIdentifier();

  if ( newCacheId_TG != theCacheId_TG ) {
    LogTrace(theCategory) << "Tracker Reco Geometry changed!";
    theCacheId_TG = newCacheId_TG;
    theService->eventSetup().get<TrackerRecoGeometryRecord>().get(theTracker);
    trackerGeomChanged = true;
  }

  if ( trackerGeomChanged && (&*theTracker) ) {
    if ( theNavigation ) delete theNavigation;
    theNavigation = new DirectTrackerNavigation(theTracker);
  }
}
void FastTSGFromPropagation::stateOnDet ( const TrajectoryStateOnSurface ts,
unsigned int  detid,
PTrajectoryStateOnDet pts 
) const [private]

A mere copy (without memory leak) of an existing tracking method.

should check if corresponds to m

Definition at line 569 of file FastTSGFromPropagation.cc.

References cond::rpcobgas::detid, i, j, gen::k, TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), m, LocalTrajectoryError::matrix(), and TrajectoryStateOnSurface::surfaceSide().

{
    const AlgebraicSymMatrix55& m = ts.localError().matrix();
    int dim = 5; 
    float localErrors[15];
    int k = 0;
    for (int i=0; i<dim; ++i) {
        for (int j=0; j<=i; ++j) {
            localErrors[k++] = m(i,j);
        }
    }
    int surfaceSide = static_cast<int>(ts.surfaceSide());
    pts = PTrajectoryStateOnDet( ts.localParameters(),
                                localErrors, detid,
                                surfaceSide);
}
const LayerMeasurements* FastTSGFromPropagation::tkLayerMeasurements ( ) const [inline, private]

Definition at line 73 of file FastTSGFromPropagation.h.

References theTkLayerMeasurements.

Referenced by findMeasurements().

void FastTSGFromPropagation::trackerSeeds ( const TrackCand staMuon,
const TrackingRegion region,
std::vector< TrajectorySeed > &  result 
) [virtual]

generate seed(s) for a track

Reimplemented from TrackerSeedGenerator.

Definition at line 72 of file FastTSGFromPropagation.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), CoreSimTrack::charge(), DeDxDiscriminatorTools::charge(), RecHit2DLocalPos::clone(), DirectTrackerNavigation::compatibleLayers(), createSeed(), PTrajectoryStateOnDet::detId(), estimator(), PV3DBase< T, PVType, FrameType >::eta(), findMeasurements_new(), TrajectoryStateOnSurface::freeState(), g, TrackingRecHit::geographicalId(), getRescalingFactor(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TrackerRecHit::hit(), TrackerGeometry::idToDet(), TrajectoryStateOnSurface::isValid(), LogTrace, oppositeToMomentum, outerTkState(), passSelection(), PV3DBase< T, PVType, FrameType >::perp(), position, propagator(), edm::OwnVector< T, P >::push_back(), DetId::rawId(), GeomDet::surface(), theCategory, theGeometry, theGSRecHits, theNavigation, theResetMethod, theService, theTTRHBuilder, theUpdateStateFlag, SimTrack::trackerSurfaceMomentum(), SimTrack::trackerSurfacePosition(), trajectoryStateTransform::transientState(), TrajectoryStateUpdator::update(), updator(), and PV3DBase< T, PVType, FrameType >::y().

                                                                                                                                    {

  if ( theResetMethod == "discrete" ) getRescalingFactor(staMuon);

  TrajectoryStateOnSurface staState = outerTkState(staMuon);

  if ( !staState.isValid() ) { 
    LogTrace(theCategory) << "Error: initial state from L2 muon is invalid.";
    return;
  }

  LogTrace(theCategory) << "begin of trackerSeed:\n staState pos: "<<staState.globalPosition()
                        << " mom: "<<staState.globalMomentum() 
                        <<"pos eta: "<<staState.globalPosition().eta()
                        <<"mom eta: "<<staState.globalMomentum().eta();


  std::vector<const DetLayer*> nls = theNavigation->compatibleLayers(*(staState.freeState()), oppositeToMomentum);

  LogTrace(theCategory) << " compatible layers: "<<nls.size();

  if ( nls.empty() ) return;

  int ndesLayer = 0;

  bool usePredictedState = false;

  if ( theUpdateStateFlag ) { //use updated states
     std::vector<TrajectoryMeasurement> alltm; 

     for (std::vector<const DetLayer*>::const_iterator inl = nls.begin();
         inl != nls.end(); inl++, ndesLayer++ ) {
         if ( (*inl == 0) ) break;
//         if ( (inl != nls.end()-1 ) && ( (*inl)->subDetector() == GeomDetEnumerators::TEC ) && ( (*(inl+1))->subDetector() == GeomDetEnumerators::TOB ) ) continue; 
         alltm = findMeasurements_new(*inl, staState);
         if ( (!alltm.empty()) ) {
            LogTrace(theCategory) << "final compatible layer: "<<ndesLayer;
            break;
         }
     }

     if ( alltm.empty() ) {
        LogTrace(theCategory) << " NO Measurements Found: eta: "<<staState.globalPosition().eta() <<"pt "<<staState.globalMomentum().perp();
        usePredictedState = true;
     } else {
       LogTrace(theCategory) << " Measurements for seeds: "<<alltm.size();
       std::stable_sort(alltm.begin(),alltm.end(),increasingEstimate()); 
       if ( alltm.size() > 5 ) alltm.erase(alltm.begin() + 5, alltm.end());

       const edm::SimTrackContainer* simTracks = &(*theSimTracks);
       const std::vector<unsigned> theSimTrackIds = theGSRecHits->ids();
       TrackerRecHit theSeedHits;
       std::vector<TrackerRecHit> outerHits;

       //std::vector<TrajectorySeed>  tmpTS;
       bool isMatch = false;
       for (std::vector<TrajectoryMeasurement>::const_iterator itm = alltm.begin(); itm != alltm.end(); itm++) {
           const TrajectoryStateOnSurface seedState = itm->predictedState();
           double preY = seedState.globalPosition().y();

           // Check SimTrack
           TrackingRecHit* aTrackingRecHit;
           FreeTrajectoryState simtrack_trackerstate;
           for( unsigned tkId=0;  tkId != theSimTrackIds.size(); ++tkId ) {
               const SimTrack & simtrack = (*simTracks)[theSimTrackIds[tkId]];
               SiTrackerGSMatchedRecHit2DCollection::range theRecHitRange = theGSRecHits->get(theSimTrackIds[tkId]);
               SiTrackerGSMatchedRecHit2DCollection::const_iterator theRecHitRangeIteratorBegin = theRecHitRange.first;
               SiTrackerGSMatchedRecHit2DCollection::const_iterator theRecHitRangeIteratorEnd   = theRecHitRange.second;
               SiTrackerGSMatchedRecHit2DCollection::const_iterator iterRecHit;

               GlobalPoint position(simtrack.trackerSurfacePosition().x(),
                                    simtrack.trackerSurfacePosition().y(),
                                    simtrack.trackerSurfacePosition().z());
               GlobalVector momentum(simtrack.trackerSurfaceMomentum().x(),
                                     simtrack.trackerSurfaceMomentum().y(),
                                     simtrack.trackerSurfaceMomentum().z());
               int charge = (int)simtrack.charge();
               GlobalTrajectoryParameters glb_parameters(position, momentum, charge, &*theService->magneticField().product());
               simtrack_trackerstate = FreeTrajectoryState(glb_parameters);

               unsigned int outerId = 0;
               for( iterRecHit = theRecHitRangeIteratorBegin; iterRecHit != theRecHitRangeIteratorEnd; ++iterRecHit) {
                   theSeedHits = TrackerRecHit(&(*iterRecHit), theGeometry);
                   unsigned int id = theSeedHits.hit()->geographicalId().rawId();
                   if( preY < 0 ) {
                       if( id > outerId ) outerId = id;
                   }
                   else {
                       if( id > outerId ) outerId = id;
                   }
               }
               for( iterRecHit = theRecHitRangeIteratorBegin; iterRecHit != theRecHitRangeIteratorEnd; ++iterRecHit) {
                   theSeedHits = TrackerRecHit(&(*iterRecHit), theGeometry);
                   if( itm->recHit()->hit()->geographicalId().rawId() == theSeedHits.hit()->geographicalId().rawId() ) {
                       aTrackingRecHit = theSeedHits.hit()->clone();
                       TransientTrackingRecHit::ConstRecHitPointer recHit = theTTRHBuilder->build(aTrackingRecHit);
                       if( !recHit ) continue;
                       TrajectoryStateOnSurface updatedTSOS = updator()->update(seedState, *(recHit));
                       if( updatedTSOS.isValid() && passSelection(updatedTSOS) ) {
                           edm::OwnVector<TrackingRecHit> container;
                           container.push_back(recHit->hit()->clone());
                           TrajectorySeed ts = createSeed(updatedTSOS, container, recHit->geographicalId());
                           // check direction
                           const BasicTrajectorySeed* aSeed = &ts;
                           PTrajectoryStateOnDet PTSOD = aSeed->startingState();
                           
                           const GeomDet *g = theGeometry->idToDet(PTSOD.detId());
                           TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState(PTSOD, &(g->surface()),  &*theService->magneticField().product());
                           if( tsos.globalMomentum().basicVector()*seedState.globalMomentum().basicVector() < 0. ) continue;
                           result.push_back(ts);
                           isMatch = true;
                       }
                   }
               }
           }
       }
       if( !isMatch ) {
         // if there is no hits w.r.t. TM, find outermost hit
         for (std::vector<TrajectoryMeasurement>::const_iterator itm = alltm.begin(); itm != alltm.end(); itm++) {
           const TrajectoryStateOnSurface seedState = itm->predictedState();
           double preY = seedState.globalPosition().y();

           // Check SimTrack
           TrackingRecHit* aTrackingRecHit;
           FreeTrajectoryState simtrack_trackerstate;
           for( unsigned tkId=0;  tkId != theSimTrackIds.size(); ++tkId ) {
               const SimTrack & simtrack = (*simTracks)[theSimTrackIds[tkId]];
               SiTrackerGSMatchedRecHit2DCollection::range theRecHitRange = theGSRecHits->get(theSimTrackIds[tkId]);
               SiTrackerGSMatchedRecHit2DCollection::const_iterator theRecHitRangeIteratorBegin = theRecHitRange.first;
               SiTrackerGSMatchedRecHit2DCollection::const_iterator theRecHitRangeIteratorEnd   = theRecHitRange.second;
               SiTrackerGSMatchedRecHit2DCollection::const_iterator iterRecHit;

               GlobalPoint position(simtrack.trackerSurfacePosition().x(),
                                    simtrack.trackerSurfacePosition().y(),
                                    simtrack.trackerSurfacePosition().z());
               GlobalVector momentum(simtrack.trackerSurfaceMomentum().x(),
                                     simtrack.trackerSurfaceMomentum().y(),
                                     simtrack.trackerSurfaceMomentum().z());
               int charge = (int)simtrack.charge();
               GlobalTrajectoryParameters glb_parameters(position, momentum, charge, &*theService->magneticField().product());
               simtrack_trackerstate = FreeTrajectoryState(glb_parameters);

               unsigned int outerId = 0;
               for( iterRecHit = theRecHitRangeIteratorBegin; iterRecHit != theRecHitRangeIteratorEnd; ++iterRecHit) {
                   theSeedHits = TrackerRecHit(&(*iterRecHit), theGeometry);
                   unsigned int id = theSeedHits.hit()->geographicalId().rawId();
                   if( preY < 0 ) {
                       if( id > outerId ) outerId = id;
                   }
                   else {
                       if( id > outerId ) outerId = id;
                   }
               }
               for( iterRecHit = theRecHitRangeIteratorBegin; iterRecHit != theRecHitRangeIteratorEnd; ++iterRecHit) {
                   theSeedHits = TrackerRecHit(&(*iterRecHit), theGeometry);
                   if( outerId == theSeedHits.hit()->geographicalId().rawId() ) {
                       aTrackingRecHit = theSeedHits.hit()->clone();
                       TransientTrackingRecHit::ConstRecHitPointer recHit = theTTRHBuilder->build(aTrackingRecHit);
                       if( !recHit ) continue;
                       TrajectoryStateOnSurface updatedTSOS = updator()->update(seedState, *(recHit));
                       if( updatedTSOS.isValid() && passSelection(updatedTSOS) ) {
                           edm::OwnVector<TrackingRecHit> container;
                           container.push_back(recHit->hit()->clone());
                           TrajectorySeed ts = createSeed(updatedTSOS, container, recHit->geographicalId());
                           // check direction
                           const BasicTrajectorySeed* aSeed = &ts;
                           PTrajectoryStateOnDet PTSOD = aSeed->startingState();
                           
                           const GeomDet *g = theGeometry->idToDet(PTSOD.detId());
                           TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState(PTSOD, &(g->surface()),  &*theService->magneticField().product());
                           if( tsos.globalMomentum().basicVector()*seedState.globalMomentum().basicVector() < 0. ) continue;
                           result.push_back(ts);
                       }
                   }
               }
           }
         }
       }

       /*
       for( unsigned ir = 0; ir < tmpTS.size(); ir++ ) {
         const BasicTrajectorySeed* aSeed = &((tmpTS)[ir]);
         PTrajectoryStateOnDet PTSOD = aSeed->startingState();
         
         DetId seedDetId(PTSOD.detId());
         const GeomDet * g = theGeometry->idToDet(seedDetId);
         TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState(PTSOD, &(g->surface()),  &*theService->magneticField().product());
                 cout << "tsos3 = " << tsos.globalMomentum() << endl;
         if( _index == ir ) {
                 cout << "tsos4 = " << tsos.globalMomentum() << endl;
             result.push_back(tmpTS[ir]);
         }
       }
       */
       LogTrace(theCategory) << "result: "<<result.size();
       return;
     }
  }
  
  if ( !theUpdateStateFlag || usePredictedState ) { //use predicted states
     LogTrace(theCategory) << "use predicted state: ";
     for (std::vector<const DetLayer*>::const_iterator inl = nls.begin();
         inl != nls.end(); inl++ ) {

         if ( !result.empty() || *inl == 0 ) {
            break;
         }
         std::vector<DetLayer::DetWithState> compatDets = (*inl)->compatibleDets(staState, *propagator(), *estimator());
         LogTrace(theCategory) << " compatDets "<<compatDets.size();
         if ( compatDets.empty() ) continue;
         TrajectorySeed ts = createSeed(compatDets.front().second, compatDets.front().first->geographicalId());
         result.push_back(ts);

     }
     LogTrace(theCategory) << "result: "<<result.size();
     return;
  } 
  return;
}
const TrajectoryStateUpdator* FastTSGFromPropagation::updator ( ) const [inline, private]

Definition at line 75 of file FastTSGFromPropagation.h.

References theUpdator.

Referenced by trackerSeeds().

{return theUpdator;}
void FastTSGFromPropagation::validMeasurements ( std::vector< TrajectoryMeasurement > &  tms) const [private]

select valid measurements

Definition at line 451 of file FastTSGFromPropagation.cc.

Referenced by findMeasurements().

                                                                                          {

  std::vector<TrajectoryMeasurement>::iterator tmsend = std::remove_if(tms.begin(), tms.end(), isInvalid());
  tms.erase(tmsend, tms.end());
  return;

}
double FastTSGFromPropagation::zDis ( const TrajectoryStateOnSurface tsos) const [private]

Member Data Documentation

Definition at line 172 of file FastTSGFromPropagation.h.

Referenced by setEvent().

Definition at line 167 of file FastTSGFromPropagation.h.

Referenced by init().

Definition at line 174 of file FastTSGFromPropagation.h.

Referenced by passSelection(), and setEvent().

unsigned long long FastTSGFromPropagation::theCacheId_MT [private]

Definition at line 124 of file FastTSGFromPropagation.h.

Referenced by init(), and setEvent().

unsigned long long FastTSGFromPropagation::theCacheId_TG [private]

Definition at line 125 of file FastTSGFromPropagation.h.

Referenced by init(), and setEvent().

std::string FastTSGFromPropagation::theCategory [private]

Definition at line 171 of file FastTSGFromPropagation.h.

Referenced by init().

Definition at line 165 of file FastTSGFromPropagation.h.

Referenced by adjust(), init(), and ~FastTSGFromPropagation().

Definition at line 142 of file FastTSGFromPropagation.h.

Referenced by estimator(), init(), and ~FastTSGFromPropagation().

Definition at line 150 of file FastTSGFromPropagation.h.

Referenced by adjust(), and init().

Definition at line 148 of file FastTSGFromPropagation.h.

Referenced by adjust(), getRescalingFactor(), and init().

Definition at line 136 of file FastTSGFromPropagation.h.

Referenced by init(), and trackerSeeds().

Definition at line 176 of file FastTSGFromPropagation.h.

Referenced by setEvent(), and trackerSeeds().

Definition at line 157 of file FastTSGFromPropagation.h.

Referenced by init(), and setEvent().

Definition at line 146 of file FastTSGFromPropagation.h.

Referenced by init().

Definition at line 133 of file FastTSGFromPropagation.h.

Referenced by findMeasurements_new(), and setEvent().

Definition at line 135 of file FastTSGFromPropagation.h.

Referenced by init(), setEvent(), trackerSeeds(), and ~FastTSGFromPropagation().

Definition at line 163 of file FastTSGFromPropagation.h.

Referenced by init(), and propagator().

Definition at line 159 of file FastTSGFromPropagation.h.

Referenced by adjust(), init(), and trackerSeeds().

Definition at line 161 of file FastTSGFromPropagation.h.

Referenced by init(), and passSelection().

Definition at line 169 of file FastTSGFromPropagation.h.

Referenced by init(), and passSelection().

Definition at line 156 of file FastTSGFromPropagation.h.

Referenced by init(), and setEvent().

Definition at line 175 of file FastTSGFromPropagation.h.

Referenced by setEvent().

Definition at line 131 of file FastTSGFromPropagation.h.

Referenced by init(), and setEvent().

Definition at line 144 of file FastTSGFromPropagation.h.

Definition at line 177 of file FastTSGFromPropagation.h.

Referenced by init(), and trackerSeeds().

Definition at line 154 of file FastTSGFromPropagation.h.

Referenced by init(), setEvent(), and trackerSeeds().

Definition at line 140 of file FastTSGFromPropagation.h.

Referenced by init(), updator(), and ~FastTSGFromPropagation().

Definition at line 152 of file FastTSGFromPropagation.h.

Referenced by init(), and outerTkState().