CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Types | Private Member Functions | Private Attributes

HICTrajectoryBuilder Class Reference

#include <HICTrajectoryBuilder.h>

Inheritance diagram for HICTrajectoryBuilder:
BaseCkfTrajectoryBuilder TrajectoryBuilder

List of all members.

Public Types

typedef std::vector
< TempTrajectory
TempTrajectoryContainer
typedef std::vector< TrajectoryTrajectoryContainer

Public Member Functions

 HICTrajectoryBuilder (const edm::ParameterSet &conf, const edm::EventSetup &es, const TrajectoryStateUpdator *updator, const Propagator *propagatorAlong, const Propagator *propagatorOpposite, const Chi2MeasurementEstimatorBase *estimator, const TransientTrackingRecHitBuilder *RecHitBuilder, const MeasurementTracker *measurementTracker, const TrajectoryFilter *filter)
virtual void setEvent (const edm::Event &event) const
 set Event for the internal MeasurementTracker data member
virtual void settracker (const MeasurementTracker *measurementTracker)
virtual TrajectoryContainer trajectories (const TrajectorySeed &seed) const
 trajectories building starting from a seed
 ~HICTrajectoryBuilder ()

Protected Types

typedef TrajectoryMeasurement TM
typedef TrajectoryStateOnSurface TSOS

Private Member Functions

void addToResult (TempTrajectory &traj, TrajectoryContainer &result) const
TempTrajectory createStartingTrajectory (const TrajectorySeed &seed) const
std::vector
< TrajectoryMeasurement
findCompatibleMeasurements (const TempTrajectory &traj) const
void limitedCandidates (TempTrajectory &startingTraj, TrajectoryContainer &result) const
bool qualityFilter (const TempTrajectory &traj) const
std::vector
< TrajectoryMeasurement
seedMeasurements (const TrajectorySeed &seed) const
bool toBeContinued (const TempTrajectory &traj) const
bool updateTrajectory (TempTrajectory &traj, const TM &tm) const

Private Attributes

edm::ESHandle
< GlobalTrackingGeometry
globTkGeomHandle
bool theAlwaysUseInvalidHits
const PropagatortheBackwardPropagator
const
Chi2MeasurementEstimatorBase
theEstimator
edm::ESHandle< TrajectoryFittertheFitterTrack
const PropagatortheForwardPropagator
cms::HICConsttheHICConst
bool theIntermediateCleaning
const LayerMeasurementstheLayerMeasurements
float theLostHitPenalty
int theMaxCand
int theMaxConsecLostHit
TrajectoryFiltertheMaxHitsCondition
int theMaxLostHit
const MeasurementTrackertheMeasurementTracker
int theMinimumNumberOfHits
TrajectoryFiltertheMinPtCondition
const PropagatorthePropagatorAlong
const PropagatorthePropagatorOpposite
edm::ESHandle< PropagatorthePropagatorTrack
edm::ESHandle< TrajectorySmoothertheSmootherTrack
const
TransientTrackingRecHitBuilder
theTTRHBuilder
const TrajectoryStateUpdatortheUpdator

Detailed Description

Definition at line 40 of file HICTrajectoryBuilder.h.


Member Typedef Documentation

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 49 of file HICTrajectoryBuilder.h.

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 44 of file HICTrajectoryBuilder.h.

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 48 of file HICTrajectoryBuilder.h.

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 43 of file HICTrajectoryBuilder.h.


Constructor & Destructor Documentation

HICTrajectoryBuilder::HICTrajectoryBuilder ( const edm::ParameterSet conf,
const edm::EventSetup es,
const TrajectoryStateUpdator updator,
const Propagator propagatorAlong,
const Propagator propagatorOpposite,
const Chi2MeasurementEstimatorBase estimator,
const TransientTrackingRecHitBuilder RecHitBuilder,
const MeasurementTracker *  measurementTracker,
const TrajectoryFilter filter 
)

Definition at line 46 of file HICTrajectoryBuilder.cc.

References gather_cfg::cout, edm::EventSetup::get(), globTkGeomHandle, theAlwaysUseInvalidHits, theFitterTrack, theIntermediateCleaning, theLostHitPenalty, theMaxCand, theMaxConsecLostHit, theMaxLostHit, theMinimumNumberOfHits, thePropagatorTrack, and theSmootherTrack.

                                                                    :

    BaseCkfTrajectoryBuilder(conf,
                             updator, propagatorAlong,propagatorOpposite,
                             estimator, RecHitBuilder, measurementTracker,filter),
    theUpdator(updator),thePropagatorAlong(propagatorAlong),
    thePropagatorOpposite(propagatorOpposite),theEstimator(estimator),
        theTTRHBuilder(RecHitBuilder),theMeasurementTracker(measurementTracker),
        theLayerMeasurements(new LayerMeasurements(theMeasurementTracker)),
        theForwardPropagator(0), theBackwardPropagator(0)                                                        
{
  theMaxCand              = 1;
  theMaxLostHit           = 0;
  theMaxConsecLostHit     = 0;
  theLostHitPenalty       = 0.;
  theIntermediateCleaning = false;
  theMinimumNumberOfHits  = 5;
  theAlwaysUseInvalidHits = false;
  es1.get<GlobalTrackingGeometryRecord>().get(globTkGeomHandle);
//  es1.get<TrackingComponentsRecord>().get("KFFitterForRefitInsideOut",theFitterTrack);
//  es1.get<TrackingComponentsRecord>().get("KFSmootherForRefitInsideOut",theSmootherTrack);
  es1.get<TrajectoryFitter::Record>().get("KFFitterForRefitInsideOut",theFitterTrack); 
  es1.get<TrajectoryFitter::Record>().get("KFSmootherForRefitInsideOut",theSmootherTrack);
  es1.get<TrackingComponentsRecord>().get("SmartPropagatorAny",thePropagatorTrack);
  
#ifdef DEBUG  
  cout<<" HICTrajectoryBuilder::contructor "<<endl;
#endif 
}
HICTrajectoryBuilder::~HICTrajectoryBuilder ( )

Definition at line 84 of file HICTrajectoryBuilder.cc.

References theLayerMeasurements.

{
  delete theLayerMeasurements;
//  delete theMinPtCondition;
//  delete theMaxHitsCondition;
}

Member Function Documentation

void HICTrajectoryBuilder::addToResult ( TempTrajectory traj,
TrajectoryContainer result 
) const [private]

Definition at line 418 of file HICTrajectoryBuilder.cc.

References TempTrajectory::toTrajectory().

Referenced by limitedCandidates().

{
  Trajectory traj = tmptraj.toTrajectory();
  result.push_back( traj);
}
TempTrajectory HICTrajectoryBuilder::createStartingTrajectory ( const TrajectorySeed seed) const [private]

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 128 of file HICTrajectoryBuilder.cc.

References gather_cfg::cout, TrajectorySeed::direction(), i, oppositeToMomentum, TempTrajectory::push(), query::result, seedMeasurements(), theBackwardPropagator, and theForwardPropagator.

Referenced by trajectories().

{
#ifdef DEBUG
  cout<<" HICTrajectoryBuilder::createStartingTrajectory "<<seed.direction()<<endl;
#endif  
  TempTrajectory result( seed, oppositeToMomentum );
  theForwardPropagator = &(*thePropagatorOpposite);
  theBackwardPropagator = &(*thePropagatorAlong);

  std::vector<TM> seedMeas = seedMeasurements(seed);

#ifdef DEBUG  
  std::cout<<" Size of seed "<<seedMeas.size()<<endl;
#endif  
  if ( !seedMeas.empty()) {
#ifdef DEBUG
  std::cout<<" TempTrajectory "<<std::endl;
#endif
    for (std::vector<TM>::const_iterator i=seedMeas.begin(); i!=seedMeas.end(); i++){
    
       result.push(*i); 
      
                 
    }
  }
   
  return result;
  
}
std::vector< TrajectoryMeasurement > HICTrajectoryBuilder::findCompatibleMeasurements ( const TempTrajectory traj) const [private]

Definition at line 528 of file HICTrajectoryBuilder.cc.

References abs, accept(), Reference_intrackfit_cff::barrel, GlobalTrajectoryParameters::charge(), HICMeasurementEstimator::chooseCuts(), HICTrajectoryCorrector::correct(), gather_cfg::cout, TempTrajectory::direction(), GeomDetEnumerators::endcap, HICMeasurementEstimator::estimate(), TrajectoryMeasurement::estimate(), first, TrajectoryStateOnSurface::freeTrajectoryState(), HICMeasurementEstimator::getField(), TrajectoryStateOnSurface::isValid(), TempTrajectory::lastLayer(), Trajectory::lastMeasurement(), TempTrajectory::lastMeasurement(), TrajectoryMeasurement::layer(), DetLayer::location(), TempTrajectory::measurements(), Trajectory::measurements(), LayerMeasurements::measurements(), GlobalTrajectoryParameters::momentum(), DetLayer::nextLayers(), FreeTrajectoryState::parameters(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), GeomDetEnumerators::PixelEndcap, GlobalTrajectoryParameters::position(), TrajectoryMeasurement::predictedState(), TrajectoryMeasurement::recHit(), query::result, HICMeasurementEstimator::setCuts(), python::multivaluedict::sort(), sistripsummary::TEC, theEstimator, theForwardPropagator, theHICConst, theLayerMeasurements, GeomDetEnumerators::TID, tmp, TempTrajectory::toTrajectory(), TrajectoryMeasurement::updatedState(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by limitedCandidates().

{
  //cout<<" HICTrajectoryBuilder::FindCompatibleMeasurement start "<<traj.empty()<<endl; 
  vector<TM> result;
 // int invalidHits = 0;
  int theLowMult = 1; 

  TSOS currentState( traj.lastMeasurement().updatedState());

  vector<const DetLayer*> nl = 
                               traj.lastLayer()->nextLayers( *currentState.freeState(), traj.direction());
#ifdef DEBUG
  std::cout<<" Number of layers "<<nl.size()<<std::endl;
#endif
  
  if (nl.empty()) return result;

  int seedLayerCode = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->
                                                              getDetectorCode(traj.measurements().front().layer());
#ifdef DEBUG
  std::cout<<"findCompatibleMeasurements Point 0 "<<seedLayerCode<<std::endl;
#endif
                                                              
  int currentLayerCode = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->
                                                               getDetectorCode(traj.lastLayer()); 
#ifdef DEBUG
  std::cout<<"findCompatibleMeasurements Point 1 "<<currentLayerCode<<std::endl;
#endif
  for (vector<const DetLayer*>::iterator il = nl.begin(); 
                                         il != nl.end(); il++) {

   int nextLayerCode = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->
                                                               getDetectorCode((*il)); 
#ifdef DEBUG
  std::cout<<"findCompatibleMeasurements Point 2 "<<nextLayerCode<<std::endl;
#endif

   if( traj.lastLayer()->location() == GeomDetEnumerators::endcap && (**il).location() == GeomDetEnumerators::barrel )
   {
   if( abs(seedLayerCode) > 100 && abs(seedLayerCode) < 108 )
   {
      if( (**il).subDetector() == GeomDetEnumerators::PixelEndcap ) continue;
   } // 100-108
   else
   {
    if(theLowMult == 0 )
    {      
      if( nextLayerCode == 0 ) continue;
    }         
      if( (**il).subDetector() == GeomDetEnumerators::TID || (**il).subDetector() == GeomDetEnumerators::TEC) continue;
   } // 100-108
   } // barrel and endcap
   
   if( currentLayerCode == 101 && nextLayerCode < 100 ) {
     continue; 
   }  // currentLayer-nextLayer
#ifdef DEBUG   
  std::cout<<" findCompatibleMeasurements Point 3 "<<nextLayerCode<<std::endl;
#endif   
                                                                       
  Trajectory traj0 = traj.toTrajectory();
  
  vector<double> theCut = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->setCuts(traj0,(*il));
  
  // Choose Win
  int icut = 1;
  dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->chooseCuts(icut);
#ifdef DEBUG
  std::cout<<" findCompatibleMeasurements::current state : "<<
             " charge "<< currentState.freeTrajectoryState()->parameters().charge()<<
             " pt "<<currentState.freeTrajectoryState()->parameters().momentum().perp()<<
             " pz "<<currentState.freeTrajectoryState()->parameters().momentum().z()<<
             " r  "<<currentState.freeTrajectoryState()->parameters().position().perp()<<
             " phi  "<<currentState.freeTrajectoryState()->parameters().position().phi()<<
             " z  "<<currentState.freeTrajectoryState()->parameters().position().z()<<
             endl; 
#endif
  const MagneticField * mf = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->getField();
  vector<TM> tmp0;

//
// We must check the charge of the high pt track after first step
//

/*
  if(abs(currentLayerCode) > 100&&traj0.measurements().size()>1) {
           HICMuonPropagator hmp(mf);
#ifdef DEBUG
  std::cout<<" findCompatibleMeasurements::HICMuonPropagator::for forward::start "<<std::endl;
#endif     
               tmp0 = 
                      theLayerMeasurements->measurements((**il), currentState, hmp, *theEstimator); 
      for( vector<TM>::iterator itm = tmp0.begin(); itm != tmp0.end(); itm++ )
     {
        TM tm = (*itm);
        TSOS predictedState = tm.predictedState();
        TM::ConstRecHitPointer  hit = tm.recHit();
        TSOS updateState = traj0.lastMeasurement().updatedState();
#ifdef DEBUG
        std::cout<<" findCompatibleMeasurements::Size of trajectory "<<traj0.measurements().size()<<
                   " valid updated state "<< updateState.isValid()<<" Predicted state is valid "
                    <<predictedState.isValid()<<
                   " charge "<< predictedState.freeTrajectoryState()->parameters().charge()<<
                   " pt "<<predictedState.freeTrajectoryState()->parameters().momentum().perp()<<
                   " pz "<<predictedState.freeTrajectoryState()->parameters().momentum().z()<<
                   " r  "<<predictedState.freeTrajectoryState()->parameters().position().perp()<<
                   " phi  "<<predictedState.freeTrajectoryState()->parameters().position().phi()<<
                   " z  "<<predictedState.freeTrajectoryState()->parameters().position().z()<<
         std::endl;        
#endif
     }
#ifdef DEBUG
  std::cout<<" findCompatibleMeasurements::HICMuonPropagator::for forward::end "<<std::endl;
#endif             
  }
*/
       tmp0 = theLayerMeasurements->measurements((**il), currentState, *theForwardPropagator, *theEstimator); 
                                      
#ifdef DEBUG 
  std::cout<<" findCompatibleMeasurements Point 6 "<<theCut[0]<<" "<<theCut[1]<<std::endl;
  std::cout<<" findCompatibleMeasurements Point 7 "<<traj0.measurements().size()<<std::endl;
#endif
//   
// ========================= Choose Cut and filter =================================
//
     vector<TM> tmp;
     icut = 2;
     dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->chooseCuts(icut);
#ifdef DEBUG
     std::cout<<" findCompatibleMeasurements Point 8 "<<theCut[0]<<" "<<theCut[1]<<" Size of candidates "<<tmp0.size()<<std::endl;
#endif  
    int numtmp = 0; 
     for( vector<TM>::iterator itm = tmp0.begin(); itm != tmp0.end(); itm++ )
     {
        TM tm = (*itm);
        TSOS predictedState = tm.predictedState();
        TM::ConstRecHitPointer  hit = tm.recHit();
        TSOS updateState = traj0.lastMeasurement().updatedState();
//
// If track is not valid - stop with this hit
//
        if(!(*hit).isValid()) {
#ifdef DEBUG
         cout<<" findCompatibleMeasurements::hit is not valid "<<endl;
#endif
         continue;
        } 

#ifdef DEBUG
        std::cout<<" findCompatibleMeasurements::Size of trajectory "<<traj0.measurements().size()
                 <<" Number of TM "<< numtmp<<
                   " valid updated state "<< updateState.isValid()<<" Predicted state is valid "
                    <<predictedState.isValid()<<
                   " charge "<< predictedState.freeTrajectoryState()->parameters().charge()<<
                   " pt "<<predictedState.freeTrajectoryState()->parameters().momentum().perp()<<
                   " pz "<<predictedState.freeTrajectoryState()->parameters().momentum().z()<<
                   " r  "<<predictedState.freeTrajectoryState()->parameters().position().perp()<<
                   " phi  "<<predictedState.freeTrajectoryState()->parameters().position().phi()<<
                   " z  "<<predictedState.freeTrajectoryState()->parameters().position().z()<<
         std::endl;
#endif

  if( traj0.measurements().size() == 1 )
  {
#ifdef DEBUG
       std::cout<<" findCompatibleMeasurements::start corrector "<<std::endl;
#endif
        HICTrajectoryCorrector theCorrector(mf,theHICConst);
#ifdef DEBUG    
        std::cout<<" findCompatibleMeasurements::corrector::initialized "<<std::endl;
#endif  
        TSOS predictedState0 = theCorrector.correct( (*traj0.lastMeasurement().updatedState().freeTrajectoryState()), 
                                                      (*(predictedState.freeTrajectoryState())), 
                                                      hit->det() );
#ifdef DEBUG                                                  
     std::cout<<" findCompatibleMeasurements::end corrector "<<std::endl; 
#endif
      if(predictedState0.isValid()) 
      {
#ifdef DEBUG
              std::cout<<" Accept the corrected state "<<numtmp<<" Hit Valid "<<(*hit).isValid()<<std::endl; 
#endif
              predictedState = predictedState0;
              
        if((*hit).isValid())
        {
#ifdef DEBUG
                 std::cout<<" findCompatibleMeasurements::end corrector::hit valid "<<std::endl;
#endif  
              bool accept= true;
              accept = (dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->estimate(predictedState,*hit)).first; 
              
              if(!accept) {
#ifdef DEBUG
                  std::cout<<" findCompatibleMeasurements::failed after the first step "<<numtmp<<std::endl;
#endif
                  numtmp++;
                  continue;
              } // accept
#ifdef DEBUG
             std::cout<<" findCompatibleMeasurements::estimate at the first step is ok "<<numtmp<<std::endl;
#endif
// Add trajectory measurements
             tmp.push_back(TM(predictedState, updateState, hit, tm.estimate(), tm.layer())); 
#ifdef DEBUG
             std::cout<<" findCompatibleMeasurements::fill estimate "<<numtmp<<std::endl;
#endif
        } // Hit Valid
        
       } // predicted state is valid
   } // first step
      else
      { 
//          tmp.push_back(TM(predictedState, updateState, hit, tm.estimate(), tm.layer()));
#ifdef DEBUG
            std::cout<<" findCompatibleMeasurements::Add TM to collection::Predicted state is valid "<<predictedState.isValid()<<" Hit is valid "<<(*hit).isValid()<<std::endl;
#endif      
            if( predictedState.isValid() && (*hit).isValid() ) tmp.push_back(*itm);
      } 
          numtmp++;

  }             // tm                      
#ifdef DEBUG
        std::cout<<" findCompatibleMeasurements::point 9 "<<std::endl;
#endif
    if ( !tmp.empty()) {
      if ( result.empty() ) result = tmp;
      else {
        // keep one dummy TM at the end, skip the others
        result.insert( result.end(), tmp.begin(), tmp.end());
      }
    }
   //  std::cout<<" Results size "<<result.size()<<std::endl;
  } // next layers

  // sort the final result, keep dummy measurements at the end
  if ( result.size() > 1) {
    sort( result.begin(), result.end(), TrajMeasLessEstim());
  }
#ifdef DEBUG
       std::cout<<" findCompatibleMeasurements::point 10 "<<std::endl;
#endif
  return result;
}
void HICTrajectoryBuilder::limitedCandidates ( TempTrajectory startingTraj,
TrajectoryContainer result 
) const [private]

Definition at line 159 of file HICTrajectoryBuilder.cc.

References addToResult(), gather_cfg::cout, findCompatibleMeasurements(), TempTrajectory::measurements(), qualityFilter(), HICMeasurementEstimator::setSign(), theEstimator, theMaxCand, toBeContinued(), and updateTrajectory().

Referenced by trajectories().

{
  TempTrajectoryContainer candidates; // = TrajectoryContainer();
  TempTrajectoryContainer newCand; // = TrajectoryContainer();
  candidates.push_back( startingTraj);
// Add the additional stuff
#ifdef DEBUG
  cout<<" HICTrajectoryBuilder::limitedCandidates "<<candidates.size()<<endl;
#endif   

  int theIniSign = 1;
  dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->setSign(theIniSign);
#ifdef DEBUG
  cout<<" Number of measurements "<<startingTraj.measurements().size()<<endl;
#endif
//
// Calculate the number of final trajectories. Allow no more then 4.
//
   
  int numtraj = 0; 
   
  while ( !candidates.empty()) {
#ifdef DEBUG
  cout<<" HICTrajectoryBuilder::limitedCandidates::cycle "<<candidates.size()<<endl;
#endif
    newCand.clear();

    for (TempTrajectoryContainer::iterator traj=candidates.begin();
         traj!=candidates.end(); traj++) {
#ifdef DEBUG     
         cout<< " Before findCompatibleMeasurements "<<endl;
#endif
      std::vector<TM> meas = findCompatibleMeasurements(*traj);
#ifdef DEBUG
         cout<< " After findCompatibleMeasurements "<<meas.size()<<endl;
#endif

      if ( meas.empty()) {
#ifdef DEBUG
        cout<<": Measurements empty : "<<endl;
#endif
        if ( qualityFilter( *traj)) {addToResult( *traj, result); numtraj++;}
      }
      else {
#ifdef DEBUG
        cout<<" : Update trajectoris :   "<<endl;
#endif
        for( std::vector<TM>::const_iterator itm = meas.begin(); 
                                             itm != meas.end(); itm++) {
          TempTrajectory newTraj = *traj;
          bool good = updateTrajectory( newTraj, *itm);
          if(good)
          {
            if ( toBeContinued(newTraj)) {
                        newCand.push_back(newTraj);
#ifdef DEBUG
               cout<<": toBeContinued : increase "<<newCand.size()<<" maximal size "<<theMaxCand<<endl;
#endif
             }
             else {
#ifdef DEBUG
               cout<<": good TM : to be stored :"<<endl;
#endif
               if ( qualityFilter(newTraj)) {addToResult( newTraj, result); numtraj++;}
                  }
          } // good
            else
            {
#ifdef DEBUG
                  cout<<": bad TM : to be stored :"<<endl;
#endif
               if ( qualityFilter( *traj)) {addToResult( *traj, result);numtraj++;}
            }
         } //meas 
      }
    
//      if ((int)newCand.size() > theMaxCand) {
//      sort( newCand.begin(), newCand.end(), TrajCandLess<TempTrajectory>(theLostHitPenalty));
//      newCand.erase( newCand.begin()+theMaxCand, newCand.end());
//      }

        if(numtraj > 4) break;
    } // trajectories
        if(numtraj > 4) break;
        candidates.swap(newCand);
  }

#ifdef DEBUG 
  std::cout<<" qualityFilter::Number of trajectories "<<numtraj<<std::endl;
#endif
  
}
bool HICTrajectoryBuilder::qualityFilter ( const TempTrajectory traj) const [private]

Definition at line 282 of file HICTrajectoryBuilder.cc.

References alongMomentum, FreeTrajectoryState::charge(), TempTrajectory::chiSquared(), gather_cfg::cout, Trajectory::direction(), Trajectory::firstMeasurement(), TempTrajectory::foundHits(), TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::freeTrajectoryState(), insideOut, TrajectoryStateOnSurface::isValid(), TrajectoryStateClosestToBeamLine::isValid(), Trajectory::lastMeasurement(), makeMuonMisalignmentScenario::matrix, Trajectory::measurements(), FreeTrajectoryState::momentum(), outsideIn, PV3DBase< T, PVType, FrameType >::perp(), GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, pos, FreeTrajectoryState::position(), Trajectory::recHits(), theFitterTrack, theHICConst, theMinimumNumberOfHits, TempTrajectory::toTrajectory(), TrajectoryStateClosestToBeamLine::trackStateAtPCA(), trajectories(), TrajectoryMeasurement::updatedState(), v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and cms::HICConst::zvert.

Referenced by limitedCandidates().

{
#ifdef DEBUG
    cout << "qualityFilter called for trajectory with " 
         << traj.foundHits() << " found hits and Chi2 = "
         << traj.chiSquared() << endl;
#endif
  if ( traj.foundHits() < theMinimumNumberOfHits) {
    return false;
  }

  Trajectory traj0 = traj.toTrajectory();
// Check the number of pixels
  const Trajectory::DataContainer tms = traj0.measurements();
  int ipix = 0; 
  for( Trajectory::DataContainer::const_iterator itm = tms.begin(); itm != tms.end(); itm++) {
     if((*itm).layer()->subDetector() == GeomDetEnumerators::PixelEndcap || (*itm).layer()->subDetector() == GeomDetEnumerators::PixelBarrel) ipix++;
  }
  
#ifdef DEBUG
 cout<<" Number of pixels "<<ipix<<endl;
#endif

 if(ipix < 1) return false;
 
//
// Refit the trajectory
//

    reco::BeamSpot::CovarianceMatrix matrix;
    matrix(2,2) = 0.001;
    matrix(3,3) = 0.001;

    reco::BeamSpot bs( reco::BeamSpot::Point(0., 0., theHICConst->zvert),
                                                     0.1,
                                                     0.,
                                                     0.,
                                                     0.,
                                                    matrix
                     );
    
    enum RefitDirection{insideOut,outsideIn,undetermined};
    
    Trajectory::ConstRecHitContainer recHitsForReFit = traj0.recHits();
   
#ifdef DEBUG
 cout<<" Take recHits for reFit "<<endl;
#endif

 
    PTrajectoryStateOnDet garbage1;
    edm::OwnVector<TrackingRecHit> garbage2;
//    TrajectoryStateOnSurface firstTSOS = traj0.firstMeasurement().updatedState(); 

    TrajectoryStateOnSurface firstTSOS = traj0.lastMeasurement().updatedState();
    Trajectory::ConstRecHitContainer newRecHitsForReFit;
    for(Trajectory::ConstRecHitContainer::const_iterator it=recHitsForReFit.end()-1; it!=recHitsForReFit.begin()-1; it--){
//     cout<<" RecHIT is valid "<<(*it)->isValid()<<endl;
     if((*it)->isValid()) {
//           cout<<(*it)->globalPosition()<<endl;
           newRecHitsForReFit.push_back(*it);
     } 
//           else{cout<<" Invalid! "<<endl;
//           }
    }




#ifdef DEBUG
 cout<<" Take firstTSOS "<<firstTSOS.isValid()<<endl;
 if(firstTSOS.isValid()) cout<<firstTSOS.freeTrajectoryState()->charge()<<" "<<firstTSOS.freeTrajectoryState()->position()<<" "<<firstTSOS.freeTrajectoryState()->momentum()<<endl;
#endif

//    PropagationDirection propDir = oppositeToMomentum;
    PropagationDirection propDir = alongMomentum;
    TrajectorySeed seed(garbage1,garbage2,propDir);
    vector<Trajectory> trajectories = theFitterTrack->fit(seed,newRecHitsForReFit,firstTSOS);

 //   vector<Trajectory> trajectories = theFitterTrack->fit(seed,recHitsForReFit,firstTSOS);
 //   vector<Trajectory> trajectories = theFitterTrack->fit(seed,recHitsForReFit);
 //   vector<Trajectory> trajectories = theFitterTrack->fit(traj0);

#ifdef DEBUG
 cout<<" fit Trajectory "<<endl;
#endif



    TrajectoryStateOnSurface innertsos;

    if (traj0.direction() == alongMomentum) {
   //    cout<<" Direction is along momentum "<<endl;
      innertsos = traj0.firstMeasurement().updatedState();
    } else {
      innertsos = traj0.lastMeasurement().updatedState();
   //   cout<<" Direction is opposite to momentum "<<endl;
      
    }

#ifdef DEBUG
 cout<<" take inertsos "<<endl;
#endif


    TSCBLBuilderNoMaterial tscblBuilder;

    //TrajectoryStateClosestToBeamLineBuilder tscblBuilder;
    TrajectoryStateClosestToBeamLine tscbl = tscblBuilder(*(innertsos.freeState()),bs);

#ifdef DEBUG
 cout<<" closest to Beam "<<endl;
#endif


    if (tscbl.isValid()==false) {
    //cout<<" false track "<<endl; 
     return false;
    }
    
    GlobalPoint v = tscbl.trackStateAtPCA().position();
    math::XYZPoint  pos( v.x(), v.y(), v.z() );
   
#ifdef DEBUG
 cout<<" check vertex constraints "<<endl;
#endif

 
    if(v.perp() > 0.1 ) return false;
    if(fabs(v.z() - theHICConst->zvert ) > 0.4 ) return false;

 return true;
 
}
std::vector< TrajectoryMeasurement > HICTrajectoryBuilder::seedMeasurements ( const TrajectorySeed seed) const [private]

Definition at line 261 of file HICTrajectoryBuilder.cc.

References gather_cfg::cout, cms::DiMuonTrajectorySeed::measurements(), and query::result.

Referenced by createStartingTrajectory().

{
  std::vector<TrajectoryMeasurement> result;
//  TrajectoryStateTransform tsTransform;

#ifdef DEBUG 
  cout<<" HICTrajectoryBuilder::seedMeasurements number of TM "<<dynamic_cast<DiMuonTrajectorySeed*>(const_cast<TrajectorySeed*>(&seed))->measurements().size()<<endl;
#endif  

   std::vector<TrajectoryMeasurement> start = dynamic_cast<DiMuonTrajectorySeed*>(const_cast<TrajectorySeed*>(&seed))->measurements();
   for(std::vector<TrajectoryMeasurement>::iterator imh = start.begin(); imh != start.end(); imh++)
   { 
#ifdef DEBUG       
     cout<<" HICTrajectoryBuilder::seedMeasurements::RecHit "<<endl;
#endif       
     result.push_back(*imh);
   }

  return result;
}
void HICTrajectoryBuilder::setEvent ( const edm::Event event) const [virtual]

set Event for the internal MeasurementTracker data member

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 91 of file HICTrajectoryBuilder.cc.

References theMeasurementTracker.

{
  theMeasurementTracker->update(event);
}
virtual void HICTrajectoryBuilder::settracker ( const MeasurementTracker measurementTracker) [inline, virtual]

Definition at line 72 of file HICTrajectoryBuilder.h.

References theMeasurementTracker.

{theMeasurementTracker = measurementTracker;}
bool HICTrajectoryBuilder::toBeContinued ( const TempTrajectory traj) const [private]

Definition at line 496 of file HICTrajectoryBuilder.cc.

References Trajectory::lost(), TempTrajectory::lostHits(), TempTrajectory::measurements(), cmsutils::bqueue< T >::rbegin(), cmsutils::bqueue< T >::rend(), theMaxConsecLostHit, and theMaxLostHit.

Referenced by limitedCandidates().

{
  if ( traj.lostHits() > theMaxLostHit) return false;

  // check for conscutive lost hits only at the end 
  // (before the last valid hit),
  // since if there was an unacceptable gap before the last 
  // valid hit the trajectory would have been stopped already

  int consecLostHit = 0;

  const TempTrajectory::DataContainer & tms = traj.measurements();
  //for( TempTrajectory::DataContainer::const_iterator itm=tms.end()-1; itm>=tms.begin(); itm--) {
  for( TempTrajectory::DataContainer::const_iterator itm=tms.rbegin(), itb = tms.rend(); itm != itb; --itm) {
    if (itm->recHit()->isValid()) break;
    else if ( // FIXME: restore this:   !Trajectory::inactive(itm->recHit()->det()) &&
             Trajectory::lost(*itm->recHit())) consecLostHit++;
  }
  if (consecLostHit > theMaxConsecLostHit) return false; 

  // stopping condition from region has highest priority
  // if ( regionalCondition && !(*regionalCondition)(traj) )  return false;
  // next: pt-cut
  //if ( !(*theMinPtCondition)(traj) )  return false;
  //if ( !(*theMaxHitsCondition)(traj) )  return false;
  // finally: configurable condition
  // FIXME: restore this:  if ( !(*theConfigurableCondition)(traj) )  return false;

  return true;
}
HICTrajectoryBuilder::TrajectoryContainer HICTrajectoryBuilder::trajectories ( const TrajectorySeed seed) const [virtual]

trajectories building starting from a seed

limitedCandidates( startingTraj, regionalCondition, result); FIXME: restore regionalCondition

Implements BaseCkfTrajectoryBuilder.

Definition at line 97 of file HICTrajectoryBuilder.cc.

References gather_cfg::cout, createStartingTrajectory(), TempTrajectory::empty(), HICMeasurementEstimator::getHICConst(), limitedCandidates(), query::result, theEstimator, and theHICConst.

Referenced by qualityFilter().

{ 
   theHICConst = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->getHICConst(); 
#ifdef DEBUG
   cout<<" HICTrajectoryBuilder::trajectories start with seed"<<endl;
#endif   
  TrajectoryContainer result;

  TempTrajectory startingTraj = createStartingTrajectory( seed );
#ifdef DEBUG  
  cout<<" HICTrajectoryBuilder::trajectories starting trajectories created "<<endl;
#endif  
  if(startingTraj.empty()) {
#ifdef DEBUG
        cout<<" Problem with starting trajectory "<<endl; 
#endif
  return result;
  }


  limitedCandidates( startingTraj, result);
#ifdef DEBUG  
   cout<<" HICTrajectoryBuilder::trajectories candidates found "<<result.size()<<endl;
#endif

  return result;
}
bool HICTrajectoryBuilder::updateTrajectory ( TempTrajectory traj,
const TM tm 
) const [private]

Definition at line 425 of file HICTrajectoryBuilder.cc.

References accept(), FreeTrajectoryState::charge(), HICMeasurementEstimator::chooseCuts(), gather_cfg::cout, TrajectoryStateOnSurface::curvilinearError(), HICMeasurementEstimator::estimate(), TrajectoryMeasurement::estimate(), first, TrajectoryStateOnSurface::freeTrajectoryState(), HICMeasurementEstimator::getField(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TempTrajectory::lastMeasurement(), TrajectoryMeasurement::layer(), TrajectoryStateOnSurface::magneticField(), FreeTrajectoryState::momentum(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), FreeTrajectoryState::position(), TrajectoryMeasurement::predictedState(), TempTrajectory::push(), TrajectoryMeasurement::recHit(), HICMeasurementEstimator::setCuts(), TrajectoryStateOnSurface::surface(), theEstimator, theHICConst, tmp, TempTrajectory::toTrajectory(), HICMuonUpdator::update(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by limitedCandidates().

{
  bool good=false; 
#ifdef DEBUG
  std::cout<<"HICTrajectoryBuilder::updateTrajectory::start"<<std::endl;
#endif
  TSOS predictedState = tm.predictedState();
  TM::ConstRecHitPointer hit = tm.recHit();
  Trajectory traj0 = traj.toTrajectory();
  
// My update
   vector<double> theCut = dynamic_cast<HICMeasurementEstimator*>
                          (const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->setCuts(traj0,tm.layer());
   int icut = 3;
   dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->chooseCuts(icut);
   const MagneticField * mf = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->getField();
   HICMuonUpdator hicup(theCut[2],theCut[3], mf,theHICConst);
   double chi2rz,chi2rf;
 
  if ( hit->isValid()) {
// Check the charge
// if() { 

   TrajectoryMeasurement tmlast = traj.lastMeasurement();
   TM::ConstRecHitPointer lasthit = tmlast.recHit();
   double dfi1 = predictedState.freeTrajectoryState()->position().phi() - lasthit->globalPosition().phi();
   double dfi2 = hit->globalPosition().phi() - lasthit->globalPosition().phi();
   

   if(dfi1*dfi2<0) {
//    cout<<" Need to change charge "<<endl;
    TrackCharge aCharge = -1*predictedState.freeTrajectoryState()->charge();
    GlobalPoint xnew = predictedState.globalPosition();
    GlobalVector pnew = predictedState.globalMomentum();
    TrajectoryStateOnSurface tsos(
                            GlobalTrajectoryParameters(xnew, pnew, aCharge, predictedState.magneticField()),
                            predictedState.curvilinearError(), predictedState.surface());
    predictedState = tsos;
   }
   
// Update trajectory
//
  TrajectoryStateOnSurface newUpdateState=hicup.update(traj0, predictedState, tm, tm.layer(), chi2rz, chi2rf);

  bool accept=
              (dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->estimate(newUpdateState,*hit)).first;
  if(accept)
  {
#ifdef DEBUG
  std::cout<<" updateTrajectory::UpdateState::New momentum "<<newUpdateState.freeTrajectoryState()->momentum().perp()<<" "<<newUpdateState.freeTrajectoryState()->momentum().z()<<std::endl;
#endif
  TM tmp = TM(predictedState, newUpdateState, hit, tm.estimate(), tm.layer());

  traj.push(tmp );
  good=true;
  return good;
  }
    else
    {
#ifdef DEBUG
       std::cout<<" updateTrajectory::failed after update "<<accept<<std::endl;
#endif
       return good;
    }
  }
  else {
    return good;
  }
}

Member Data Documentation

Definition at line 82 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder().

Definition at line 107 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder().

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 93 of file HICTrajectoryBuilder.h.

Referenced by createStartingTrajectory().

Definition at line 83 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder(), and qualityFilter().

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 92 of file HICTrajectoryBuilder.h.

Referenced by createStartingTrajectory(), and findCompatibleMeasurements().

Tells whether an intermediary cleaning stage should take place during TB.

Definition at line 104 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder().

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 89 of file HICTrajectoryBuilder.h.

Referenced by findCompatibleMeasurements(), and ~HICTrajectoryBuilder().

Chi**2 Penalty for each lost hit.

Definition at line 103 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder().

Maximum number of trajectory candidates to propagate to the next layer.

Definition at line 98 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder(), and limitedCandidates().

Maximum number of consecutive lost hits per trajectory candidate.

Definition at line 101 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder(), and toBeContinued().

Definition at line 96 of file HICTrajectoryBuilder.h.

Maximum number of lost hits per trajectory candidate.

Definition at line 100 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder(), and toBeContinued().

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 88 of file HICTrajectoryBuilder.h.

Referenced by setEvent(), and settracker().

Minimum number of hits for a trajectory to be returned.

Definition at line 106 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder(), and qualityFilter().

Definition at line 95 of file HICTrajectoryBuilder.h.

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 76 of file HICTrajectoryBuilder.h.

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 77 of file HICTrajectoryBuilder.h.

Definition at line 85 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder().

Definition at line 84 of file HICTrajectoryBuilder.h.

Referenced by HICTrajectoryBuilder().

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 87 of file HICTrajectoryBuilder.h.

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 75 of file HICTrajectoryBuilder.h.