CMS 3D CMS Logo

Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends

CRackTrajectoryBuilder Class Reference

#include <CRackTrajectoryBuilder.h>

List of all members.

Classes

class  CompareDetByTraj

Public Member Functions

 CRackTrajectoryBuilder (const edm::ParameterSet &conf)
Trajectory createStartingTrajectory (const TrajectorySeed &seed) const
void init (const edm::EventSetup &es, bool)
void run (const TrajectorySeedCollection &collseed, const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const SiPixelRecHitCollection &collpixel, const edm::EventSetup &es, edm::Event &e, std::vector< Trajectory > &trajoutput)
 Runs the algorithm.
 ~CRackTrajectoryBuilder ()

Private Types

typedef std::pair
< TrackingRecHitRangeIterator,
TSOS
PairTrackingRecHitTsos
typedef TrajectoryMeasurement TM
typedef std::vector< const
TrackingRecHit * >::iterator 
TrackingRecHitIterator
typedef std::pair
< TrackingRecHitIterator,
TrackingRecHitIterator
TrackingRecHitRange
typedef std::vector
< TrackingRecHitRange >
::iterator 
TrackingRecHitRangeIterator
typedef TrajectoryStateOnSurface TSOS

Private Member Functions

void AddHit (Trajectory &traj, std::vector< const TrackingRecHit * >Hits, Propagator *currPropagator)
std::pair
< TrajectoryStateOnSurface,
const GeomDet * > 
innerState (const Trajectory &traj) const
bool isDifferentStripReHit2D (const SiStripRecHit2D &hitA, const SiStripRecHit2D &hitB)
bool qualityFilter (Trajectory traj)
std::vector
< TrajectoryMeasurement
seedMeasurements (const TrajectorySeed &seed) const
std::vector< const
TrackingRecHit * > 
SortHits (const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const SiPixelRecHitCollection &collpixel, const TrajectorySeed &seed, const bool bAddSeedHits)
TSOS startingTSOS (const TrajectorySeed &seed) const
void updateTrajectory (Trajectory &traj, const TM &tm, const TransientTrackingRecHit &hit) const

Private Attributes

double chi2cut
edm::ParameterSet conf_
bool debug_info
bool fastPropagation
std::string geometry
TransientTrackingRecHit::RecHitContainer hits
edm::ESHandle< MagneticFieldmagfield
const
TransientTrackingRecHitBuilder
RHBuilder
bool seed_plus
Chi2MeasurementEstimatortheEstimator
const KFTrajectoryFittertheFitter
int theMinHits
PropagatorWithMaterialthePropagator
PropagatorWithMaterialthePropagatorOp
const KFTrajectorySmoothertheSmoother
KFUpdatortheUpdator
edm::ESHandle< TrackerGeometrytracker
std::vector< TrajectorytrajFit
bool useMatchedHits

Friends

class CompareDetByTraj

Detailed Description

Definition at line 128 of file CRackTrajectoryBuilder.h.


Member Typedef Documentation

Definition at line 141 of file CRackTrajectoryBuilder.h.

Definition at line 133 of file CRackTrajectoryBuilder.h.

typedef std::vector<const TrackingRecHit*>::iterator CRackTrajectoryBuilder::TrackingRecHitIterator [private]

Definition at line 135 of file CRackTrajectoryBuilder.h.

Definition at line 137 of file CRackTrajectoryBuilder.h.

Definition at line 138 of file CRackTrajectoryBuilder.h.

Definition at line 132 of file CRackTrajectoryBuilder.h.


Constructor & Destructor Documentation

CRackTrajectoryBuilder::CRackTrajectoryBuilder ( const edm::ParameterSet conf)

Definition at line 32 of file CRackTrajectoryBuilder.cc.

References chi2cut, conf_, debug_info, fastPropagation, geometry, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), theMinHits, and useMatchedHits.

                                                                          : conf_(conf) { 
  //minimum number of hits per tracks

  theMinHits=conf_.getParameter<int>("MinHits");
  //cut on chi2
  chi2cut=conf_.getParameter<double>("Chi2Cut");
  edm::LogInfo("CosmicTrackFinder")<<"Minimum number of hits "<<theMinHits<<" Cut on Chi2= "<<chi2cut;

  debug_info=conf_.getUntrackedParameter<bool>("debug", false);
  fastPropagation=conf_.getUntrackedParameter<bool>("fastPropagation", false);
  useMatchedHits=conf_.getUntrackedParameter<bool>("useMatchedHits", true);


  geometry=conf_.getUntrackedParameter<std::string>("GeometricStructure","STANDARD");

  

}
CRackTrajectoryBuilder::~CRackTrajectoryBuilder ( )

Definition at line 52 of file CRackTrajectoryBuilder.cc.

                                                {
//  delete theInitialState;
}

Member Function Documentation

void CRackTrajectoryBuilder::AddHit ( Trajectory traj,
std::vector< const TrackingRecHit * >  Hits,
Propagator currPropagator 
) [private]

do the old version ....

Definition at line 259 of file CosmicTrajectoryBuilder.cc.

References abs, TransientTrackingRecHitBuilder::build(), CosmicTrajectoryBuilder::chi2cut, Trajectory::chiSquared(), Chi2MeasurementEstimator::estimate(), Trajectory::firstMeasurement(), KFTrajectoryFitter::fit(), Trajectory::foundHits(), TrajectoryStateOnSurface::globalPosition(), CosmicTrajectoryBuilder::hits, TrajectoryStateOnSurface::isValid(), Trajectory::lastMeasurement(), TrajectoryStateOnSurface::localPosition(), LogDebug, PropagatorWithMaterial::propagate(), Trajectory::push(), CosmicTrajectoryBuilder::qualityFilter(), CosmicTrajectoryBuilder::RHBuilder, Trajectory::seed(), CosmicTrajectoryBuilder::theEstimator, CosmicTrajectoryBuilder::theFitter, CosmicTrajectoryBuilder::thePropagator, CosmicTrajectoryBuilder::thePropagatorOp, CosmicTrajectoryBuilder::theUpdator, CosmicTrajectoryBuilder::tracker, CosmicTrajectoryBuilder::trajFit, KFUpdator::update(), TrajectoryMeasurement::updatedState(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

                                                                       {


  unsigned int icosm2;
  unsigned int ibestdet;
  float chi2min;
  for (unsigned int icosmhit=0;icosmhit<Hits.size();icosmhit++){
    GlobalPoint gphit=RHBuilder->build(Hits[icosmhit])->globalPosition();
    unsigned int iraw= Hits[icosmhit]->geographicalId().rawId();
    LogDebug("CosmicTrackFinder")<<" HIT POSITION "<< gphit;
    //RC TransientTrackingRecHit* tmphit=RHBuilder->build(Hits[icosmhit]);
    TransientTrackingRecHit::RecHitPointer tmphit=RHBuilder->build(Hits[icosmhit]);
     TSOS prSt= thePropagator->propagate(traj.lastMeasurement().updatedState(),
                                        tracker->idToDet(Hits[icosmhit]->geographicalId())->surface());

    //After propagating the trajectory to a detector,
    //find the most compatible hit in the det
    chi2min=20000000;
    ibestdet=1000;
     if (prSt.isValid()){
       LocalPoint  prLoc = prSt.localPosition();
       LogDebug("CosmicTrackFinder") <<"STATE PROPAGATED AT DET "<<iraw<<" "<<prSt;
       for(icosm2=icosmhit;icosm2<Hits.size();icosm2++){

         if (iraw==Hits[icosm2]->geographicalId().rawId()){       
           TransientTrackingRecHit::RecHitPointer tmphit=RHBuilder->build(Hits[icosm2]);
           float contr= theEstimator->estimate(prSt, *tmphit).second;
           if (contr<chi2min) {
             chi2min=contr;
             ibestdet=icosm2;
           }
           if (icosm2!=icosmhit)        icosmhit++;

         }
         else  icosm2=Hits.size();
       }

       if(chi2min<chi2cut) 
         LogDebug("CosmicTrackFinder")<<"Chi2 contribution for hit at "
                                      <<RHBuilder->build(Hits[ibestdet])->globalPosition()
                                      <<" is "<<chi2min;

       if(traj.foundHits()<3 &&(chi2min<chi2cut)){
         //check on the first hit after the seed
         GlobalVector ck=RHBuilder->build(Hits[ibestdet])->globalPosition()-
           traj.firstMeasurement().updatedState().globalPosition();
         if ((abs(ck.x()/ck.y())>2)||(abs(ck.z()/ck.y())>2))  chi2min=300;
       }
       if (chi2min<chi2cut){
         if ( abs(prLoc.x()) < 25  && abs(prLoc.y()) < 25 ){
           TransientTrackingRecHit::RecHitPointer tmphitbestdet=RHBuilder->build(Hits[ibestdet]);
           TSOS UpdatedState= theUpdator->update( prSt, *tmphitbestdet);
           if (UpdatedState.isValid()){

             traj.push(TM(prSt,UpdatedState,RHBuilder->build(Hits[ibestdet])
                          , chi2min));
             LogDebug("CosmicTrackFinder") <<
               "STATE UPDATED WITH HIT AT POSITION "
                                           <<tmphitbestdet->globalPosition()
                                           <<UpdatedState<<" "
                                           <<traj.chiSquared();

             hits.push_back(&(*tmphitbestdet));
           }
         }else LogDebug("CosmicTrackFinder")<<" Hits outside module surface "<< prLoc;
       }else LogDebug("CosmicTrackFinder")<<" State can not be updated with hit at position " <<gphit;
     }else LogDebug("CosmicTrackFinder")<<" State can not be propagated at det "<< iraw;    
  }
  
  

  if ( qualityFilter( traj)){
    const TrajectorySeed& tmpseed=traj.seed();
    if (thePropagatorOp->propagate(traj.lastMeasurement().updatedState(),
                                   tracker->idToDet((*hits.begin())->geographicalId())->surface()).isValid()){
      TSOS startingState= 
        thePropagatorOp->propagate(traj.lastMeasurement().updatedState(),
                                   tracker->idToDet((*hits.begin())->geographicalId())->surface());
      
      trajFit = theFitter->fit(tmpseed,hits, startingState );
    }
  }
  
}
Trajectory CRackTrajectoryBuilder::createStartingTrajectory ( const TrajectorySeed seed) const

Definition at line 255 of file CRackTrajectoryBuilder.cc.

References TrajectorySeed::direction(), i, query::result, and seedMeasurements().

Referenced by SortHits().

{
  Trajectory result( seed, seed.direction());
  std::vector<TM> seedMeas = seedMeasurements(seed);
  if ( !seedMeas.empty()) {
    for (std::vector<TM>::const_iterator i=seedMeas.begin(); i!=seedMeas.end(); i++){
      result.push(*i);
    }
  }
 
  return result;
}
void CRackTrajectoryBuilder::init ( const edm::EventSetup es,
bool  seedplus 
)

Definition at line 57 of file CRackTrajectoryBuilder.cc.

References alongMomentum, chi2cut, Chi2MeasurementEstimatorESProducer_cfi::Chi2MeasurementEstimator, conf_, edm::EventSetup::get(), edm::ParameterSet::getParameter(), KFTrajectoryFitterESProducer_cfi::KFTrajectoryFitter, KFTrajectorySmootherESProducer_cfi::KFTrajectorySmoother, magfield, oppositeToMomentum, edm::ESHandle< T >::product(), RHBuilder, seed_plus, theEstimator, theFitter, thePropagator, thePropagatorOp, theSmoother, theUpdator, and tracker.

                                                                       {


//  edm::ParameterSet tise_params = conf_.getParameter<edm::ParameterSet>("TransientInitialStateEstimatorParameters") ;
// theInitialState          = new TransientInitialStateEstimator( es,tise_params);

  //services
  es.get<IdealMagneticFieldRecord>().get(magfield);
  es.get<TrackerDigiGeometryRecord>().get(tracker);
  
 
  
  if (seedplus) {        
    seed_plus=true;      
    thePropagator=      new PropagatorWithMaterial(alongMomentum,0.1057,&(*magfield) );          
    thePropagatorOp=    new PropagatorWithMaterial(oppositeToMomentum,0.1057,&(*magfield) );}    
  else {
    seed_plus=false;
    thePropagator=      new PropagatorWithMaterial(oppositeToMomentum,0.1057,&(*magfield) );    
    thePropagatorOp=    new PropagatorWithMaterial(alongMomentum,0.1057,&(*magfield) );
  }
  
  theUpdator=       new KFUpdator();
//  theUpdator=       new KFStripUpdator();
  theEstimator=     new Chi2MeasurementEstimator(chi2cut);
  

  edm::ESHandle<TransientTrackingRecHitBuilder> theBuilder;
  std::string builderName = conf_.getParameter<std::string>("TTRHBuilder");   
  es.get<TransientRecHitRecord>().get(builderName,theBuilder);
  

  RHBuilder=   theBuilder.product();




  theFitter=        new KFTrajectoryFitter(*thePropagator,
                                           *theUpdator, 
                                           *theEstimator) ;
  

  theSmoother=      new KFTrajectorySmoother(*thePropagatorOp,
                                             *theUpdator,       
                                             *theEstimator);
  
}
std::pair< TrajectoryStateOnSurface, const GeomDet * > CRackTrajectoryBuilder::innerState ( const Trajectory traj) const [private]

Definition at line 952 of file CRackTrajectoryBuilder.cc.

References alongMomentum, funct::C, Chi2MeasurementEstimatorESProducer_cfi::Chi2MeasurementEstimator, Trajectory::direction(), Trajectory::foundHits(), i, TrajectoryStateOnSurface::localParameters(), PropagatorWithMaterial::magneticField(), Trajectory::measurements(), oppositeToMomentum, TrajectoryMeasurement::recHit(), TrajectoryStateOnSurface::surface(), thePropagator, and TrajectoryMeasurement::updatedState().

{
  int lastFitted = 999;
  int nhits = traj.foundHits();
  if (nhits < lastFitted+1) lastFitted = nhits-1;

  std::vector<TrajectoryMeasurement> measvec = traj.measurements();
  TransientTrackingRecHit::ConstRecHitContainer firstHits;

  bool foundLast = false;
  int actualLast = -99;
  for (int i=lastFitted; i >= 0; i--) {
    if(measvec[i].recHit()->isValid()){
      if(!foundLast){
        actualLast = i; 
        foundLast = true;
      }
      firstHits.push_back( measvec[i].recHit());
    }
  }
  TSOS unscaledState = measvec[actualLast].updatedState();
  AlgebraicSymMatrix55 C=ROOT::Math::SMatrixIdentity();
  // C *= 100.;

  TSOS startingState( unscaledState.localParameters(), LocalTrajectoryError(C),
                      unscaledState.surface(),
                      thePropagator->magneticField());

  // cout << endl << "FitTester starts with state " << startingState << endl;

  KFTrajectoryFitter backFitter( *thePropagator,
                                 KFUpdator(),
                                 Chi2MeasurementEstimator( 100., 3));

  PropagationDirection backFitDirection = traj.direction() == alongMomentum ? oppositeToMomentum: alongMomentum;

  // only direction matters in this contest
  TrajectorySeed fakeSeed = TrajectorySeed(PTrajectoryStateOnDet() , 
                                           edm::OwnVector<TrackingRecHit>(),
                                           backFitDirection);

  vector<Trajectory> fitres = backFitter.fit( fakeSeed, firstHits, startingState);

  if (fitres.size() != 1) {
    // cout << "FitTester: first hits fit failed!" << endl;
    return std::pair<TrajectoryStateOnSurface, const GeomDet*>();
  }

  TrajectoryMeasurement firstMeas = fitres[0].lastMeasurement();
  TSOS firstState = firstMeas.updatedState();

  //  cout << "FitTester: Fitted first state " << firstState << endl;
  //cout << "FitTester: chi2 = " << fitres[0].chiSquared() << endl;

  TSOS initialState( firstState.localParameters(), LocalTrajectoryError(C),
                     firstState.surface(),
                     thePropagator->magneticField());

  return std::pair<TrajectoryStateOnSurface, const GeomDet*>( initialState, 
                                                              firstMeas.recHit()->det());
}
bool CRackTrajectoryBuilder::isDifferentStripReHit2D ( const SiStripRecHit2D &  hitA,
const SiStripRecHit2D &  hitB 
) [private]

Definition at line 931 of file CRackTrajectoryBuilder.cc.

Referenced by SortHits().

{
  if ( hitA.geographicalId() != hitB.geographicalId() )
    return true;
  if ( hitA.localPosition().x() != hitB.localPosition().x() )
    return true;
  if ( hitA.localPosition().y() != hitB.localPosition().y() )
    return true;
  if ( hitA.localPosition().z() != hitB.localPosition().z() )
    return true;

  //  if (debug_info) cout << hitA.localPosition() << endl;
  //  if (debug_info) cout << hitB << endl;

  return false;
}
bool CRackTrajectoryBuilder::qualityFilter ( Trajectory  traj) [private]

Definition at line 907 of file CRackTrajectoryBuilder.cc.

References Trajectory::foundHits(), geometry, Trajectory::recHits(), and theMinHits.

                                                    {
  int ngoodhits=0;
  if(geometry=="MTCC"){
    std::vector< ConstReferenceCountingPointer< TransientTrackingRecHit> > hits= traj.recHits();
    std::vector< ConstReferenceCountingPointer< TransientTrackingRecHit> >::const_iterator hit;
    for(hit=hits.begin();hit!=hits.end();hit++){
      unsigned int iid=(*hit)->hit()->geographicalId().rawId();
      //CHECK FOR 3 hits r-phi
      if(((iid>>0)&0x3)!=1) ngoodhits++;
    }
  }
  else ngoodhits=traj.foundHits();
  
  if ( ngoodhits >= theMinHits) {
    return true;
  }
  else {
    return false;
  }
}
void CRackTrajectoryBuilder::run ( const TrajectorySeedCollection collseed,
const SiStripRecHit2DCollection collstereo,
const SiStripRecHit2DCollection collrphi,
const SiStripMatchedRecHit2DCollection collmatched,
const SiPixelRecHitCollection collpixel,
const edm::EventSetup es,
edm::Event e,
std::vector< Trajectory > &  trajoutput 
)

Runs the algorithm.

Referenced by cms::CosmicTrackFinder::produce().

std::vector< TrajectoryMeasurement > CRackTrajectoryBuilder::seedMeasurements ( const TrajectorySeed seed) const [private]

Definition at line 270 of file CRackTrajectoryBuilder.cc.

References TransientTrackingRecHitBuilder::build(), TrajectorySeed::recHits(), query::result, RHBuilder, startingTSOS(), and GeomDet::surface().

Referenced by createStartingTrajectory().

{
  std::vector<TrajectoryMeasurement> result;
  TrajectorySeed::range hitRange = seed.recHits();
  for (TrajectorySeed::const_iterator ihit = hitRange.first; 
       ihit != hitRange.second; ihit++) {
    //RC TransientTrackingRecHit* recHit = RHBuilder->build(&(*ihit));
    TransientTrackingRecHit::RecHitPointer recHit = RHBuilder->build(&(*ihit));
    const GeomDet* hitGeomDet = (&(*tracker))->idToDet( ihit->geographicalId());
    TSOS invalidState( new BasicSingleTrajectoryState( hitGeomDet->surface()));

    if (ihit == hitRange.second - 1) {
      TSOS  updatedState=startingTSOS(seed);
      result.push_back(TM( invalidState, updatedState, recHit));

    } 
    else {
      result.push_back(TM( invalidState, recHit));
    }
    
  }

  return result;
}
vector< const TrackingRecHit * > CRackTrajectoryBuilder::SortHits ( const SiStripRecHit2DCollection collstereo,
const SiStripRecHit2DCollection collrphi,
const SiStripMatchedRecHit2DCollection collmatched,
const SiPixelRecHitCollection collpixel,
const TrajectorySeed seed,
const bool  bAddSeedHits 
) [private]

Definition at line 296 of file CRackTrajectoryBuilder.cc.

References TransientTrackingRecHitBuilder::build(), gather_cfg::cout, createStartingTrajectory(), edmNew::DetSetVector< T >::data(), debug_info, spr::find(), TrajectoryStateOnSurface::globalPosition(), isDifferentStripReHit2D(), TrajectoryStateOnSurface::isValid(), Trajectory::lastMeasurement(), TrajectoryStateOnSurface::localError(), LogDebug, m, LocalTrajectoryError::matrix(), TrajectorySeed::nHits(), PropagatorWithMaterial::propagate(), TrajectorySeed::recHits(), RHBuilder, alignCSCRings::s, seed_plus, startingTSOS(), thePropagator, tracker, TrajectoryMeasurement::updatedState(), and useMatchedHits.

                                   {


  //The Hits with global y more than the seed are discarded
  //The Hits correspondign to the seed are discarded
  //At the end all the hits are sorted in y
  vector<const TrackingRecHit*> allHits;

  SiStripRecHit2DCollection::DataContainer::const_iterator istrip;
  TrajectorySeed::range hRange= seed.recHits();
  TrajectorySeed::const_iterator ihit;
  float yref=0.;

  if (debug_info) cout << "SEED " << startingTSOS(seed) << endl; 
  if (debug_info) cout << "seed hits size " << seed.nHits() << endl;


  //seed debugging:
 // GeomDet *seedDet =  tracker->idToDet(seed.startingState().detId());


//  edm::LogInfo("CRackTrajectoryBuilder::SortHits") << "SEED " << seed.startingState(); 

  edm::LogInfo("CRackTrajectoryBuilder::SortHits") << "SEED " << startingTSOS(seed); 
//  edm::LogInfo("CRackTrajectoryBuilder::SortHits" << "seed hits size " << seed.nHits();



  //  if (seed.nHits()<2)
  //  return allHits;

  float_t yMin=0.;
  float_t yMax=0.;

  int seedHitSize= hRange.second - hRange.first;

  vector <int> detIDSeedMatched (seedHitSize);
  vector <int> detIDSeedRphi (seedHitSize);
  vector <int> detIDSeedStereo (seedHitSize);

  for (ihit = hRange.first; 
       ihit != hRange.second; ihit++) {

     // need to find track with lowest (seed_plus)/ highest y (seed_minus)
    // split matched hits ...
   const SiStripMatchedRecHit2D* matchedhit=dynamic_cast<const SiStripMatchedRecHit2D*>(&(*ihit));

   yref=RHBuilder->build(&(*ihit))->globalPosition().y();
   if (ihit == hRange.first)
     {
        yMin = yref;
        yMax = yref; 
     }

   if (matchedhit)
     {
       auto m = matchedhit->monoHit();
       auto s = matchedhit->stereoHit();
       float_t yGlobRPhi   = RHBuilder->build(&m)->globalPosition().y();
       float_t yGlobStereo = RHBuilder->build(&s)->globalPosition().y();

       if (debug_info) cout << "Rphi ..." << yGlobRPhi << endl;
       if (debug_info) cout << "Stereo ..." << yGlobStereo << endl;

       if ( yGlobStereo < yMin ) yMin = yGlobStereo;
       if ( yGlobRPhi   < yMin ) yMin = yGlobRPhi;

       if ( yGlobStereo > yMax ) yMax = yGlobStereo;
       if ( yGlobRPhi   > yMax ) yMax = yGlobRPhi;

       detIDSeedMatched.push_back (  matchedhit->geographicalId().rawId() );
       detIDSeedRphi.push_back ( m.geographicalId().rawId() );
       detIDSeedStereo.push_back ( s.geographicalId().rawId() );

      if (bAddSeedHits)
        {
          if (useMatchedHits) 
            {
              
              hits.push_back((RHBuilder->build(&(*ihit)))); 
            }
          else
            {
              if ( ( (yGlobRPhi > yGlobStereo ) && seed_plus ) || ((yGlobRPhi < yGlobStereo ) && !seed_plus ))  
                {
                  hits.push_back((RHBuilder->build(&m)));
                  hits.push_back((RHBuilder->build(&s)));
                }
              else
                {
                  hits.push_back((RHBuilder->build(&s)));     
                  hits.push_back((RHBuilder->build(&m)));
                  
                }
            }
        }
     }
   else if (bAddSeedHits)
     {
       hits.push_back((RHBuilder->build(&(*ihit)))); 
       detIDSeedRphi.push_back ( ihit->geographicalId().rawId() );
       detIDSeedMatched.push_back ( -1 );
       detIDSeedStereo.push_back ( -1 );
       
     }
       
   if ( yref < yMin ) yMin = yref;
   if ( yref > yMax ) yMax = yref;
   
//    if (bAddSeedHits)
//      hits.push_back((RHBuilder->build(&(*ihit)))); 

    LogDebug("CosmicTrackFinder")<<"SEED HITS"<<RHBuilder->build(&(*ihit))->globalPosition();
    if (debug_info) cout <<"SEED HITS"<<RHBuilder->build(&(*ihit))->globalPosition() << endl;
//    if (debug_info) cout <<"SEED HITS"<< seed.startingState().parameters() << endl;


  }
  
  yref = (seed_plus) ? yMin : yMax;
  
  if ((&collpixel)!=0){
    SiPixelRecHitCollection::DataContainer::const_iterator ipix;
    for(ipix=collpixel.data().begin();ipix!=collpixel.data().end();ipix++){
      float ych= RHBuilder->build(&(*ipix))->globalPosition().y();
      if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
        allHits.push_back(&(*ipix));
    }
  } 
  

  if (useMatchedHits) // use matched
    {
        //add the matched hits ...
      SiStripMatchedRecHit2DCollection::DataContainer::const_iterator istripm;

      if ((&collmatched)!=0){
        for(istripm=collmatched.data().begin();istripm!=collmatched.data().end();istripm++){
          float ych= RHBuilder->build(&(*istripm))->globalPosition().y();

          int cDetId=istripm->geographicalId().rawId();
          bool noSeedDet = ( detIDSeedMatched.end() == find (detIDSeedMatched.begin(), detIDSeedMatched.end(), cDetId ) ) ;

          if ( noSeedDet )
          if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
            {
          //if (debug_info) cout << "adding matched hit " << &(*istripm) << endl; 
              allHits.push_back(&(*istripm));
        }
        }
      }

   //add the rpi hits, but only accept hits that are not matched hits
  if ((&collrphi)!=0){
    for(istrip=collrphi.data().begin();istrip!=collrphi.data().end();istrip++){
      float ych= RHBuilder->build(&(*istrip))->globalPosition().y();
      StripSubdetector monoDetId(istrip->geographicalId());
      if (monoDetId.partnerDetId())
        {
          edm::LogInfo("CRackTrajectoryBuilder::SortHits")  << "this det belongs to a glued det " << ych << endl;
          continue;
        }
          int cDetId=istrip->geographicalId().rawId();
          bool noSeedDet = ( detIDSeedRphi.end()== find (detIDSeedRphi.begin(), detIDSeedRphi.end(), cDetId ) ) ;
          if (noSeedDet)
      if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
        {
         
          bool hitIsUnique = true;
          //now 
           if ((&collmatched)!=0)
             for(istripm=collmatched.data().begin();istripm!=collmatched.data().end();istripm++)
               {
                 //              if ( isDifferentStripReHit2D ( *istrip, (istripm->stereoHit() ) ) == false)
                   if ( isDifferentStripReHit2D ( *istrip, (istripm->monoHit() ) ) == false)
                   {
                     hitIsUnique = false;
                     edm::LogInfo("CRackTrajectoryBuilder::SortHits")  << "rphi hit is in matched hits; y: " << ych << endl;
                     break;
                   }
               } //end loop over all matched
           if (hitIsUnique)
             {
                 //      if (debug_info) cout << "adding rphi hit " << &(*istrip) << endl; 
                allHits.push_back(&(*istrip));   
             }
        }
    }
  }

  
  //add the stereo hits except the hits that are in the matched collection
  //update do not use unmatched rphi hist due to limitation of alignment framework
  //if (!useMatchedHits)
  //if ((&collstereo)!=0){
  //  for(istrip=collstereo.data().begin();istrip!=collstereo.data().end();istrip++){
  //    float ych= RHBuilder->build(&(*istrip))->globalPosition().y();
  //
  //
  //      int cDetId = istrip->geographicalId().rawId();
  //        bool noSeedDet = ( detIDSeedStereo.end()== find (detIDSeedStereo.begin(), detIDSeedStereo.end(), cDetId ) ) ;
  //
  //        if (noSeedDet)
  //    if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
  //      {
  //
  //        bool hitIsUnique = true;
  //        //now 
  //         if ((&collmatched)!=0)
  //           for(istripm=collmatched.data().begin();istripm!=collmatched.data().end();istripm++)
  //             {
  //             if ( isDifferentStripReHit2D ( *istrip, * (istripm->stereoHit() ) ) == false)
  //               {
  //                 hitIsUnique = false;
  //                 edm::LogInfo("CRackTrajectoryBuilder::SortHits") << "stereo hit already in matched hits; y:  " << ych << endl;
  //                 break;
  //               }
  //             } //end loop over all stereo
  //         if (hitIsUnique)
  //           {
  //             
  //          //   if (debug_info) cout << "now I am adding a stero hit, either noise or not in overlap ...!!!!" << endl;
  //                allHits.push_back(&(*istrip));   
  //           }
  //      }
  //  }
  //}
    }
  else // dont use matched ...
    {
      
      if ((&collrphi)!=0){
        for(istrip=collrphi.data().begin();istrip!=collrphi.data().end();istrip++){
          float ych= RHBuilder->build(&(*istrip))->globalPosition().y();
          if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
            allHits.push_back(&(*istrip));   
        }
      }


      if ((&collstereo)!=0){
        for(istrip=collstereo.data().begin();istrip!=collstereo.data().end();istrip++){
          float ych= RHBuilder->build(&(*istrip))->globalPosition().y();
          if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
            allHits.push_back(&(*istrip));
        }
      }

    }


//  if (seed_plus){
//    stable_sort(allHits.begin(),allHits.end(),CompareDetY_plus(*tracker));
//  }
//  else {
//    stable_sort(allHits.begin(),allHits.end(),CompareDetY_minus(*tracker));
//  }


  if (seed_plus){
      stable_sort(allHits.begin(),allHits.end(),CompareHitY_plus(*tracker));
  }
  else {
      stable_sort(allHits.begin(),allHits.end(),CompareHitY(*tracker));
  }



  if (debug_info) 
    {
      if (debug_info) cout << "all hits" << endl;

      //starting trajectory
      Trajectory startingTraj = createStartingTrajectory(seed);

      if (debug_info) cout << "START " << startingTraj.lastMeasurement().updatedState() << endl;
      if (debug_info) cout << "START  Err" << startingTraj.lastMeasurement().updatedState().localError().matrix() << endl;


      vector<const TrackingRecHit*>::iterator iHit;
      for (iHit=allHits.begin(); iHit<allHits.end(); iHit++)
        {
              GlobalPoint gphit=RHBuilder->build(*iHit)->globalPosition();
              if (debug_info) cout << "GH " << gphit << endl;

              //      tracker->idToDet((*iHit)->geographicalId())->surface();

      TSOS prSt = thePropagator->propagate(startingTraj.lastMeasurement().updatedState(),
                          tracker->idToDet((*iHit)->geographicalId())->surface());
              
              if(prSt.isValid()) 
                {
      if (debug_info) cout << "PR " << prSt.globalPosition() << endl;
      //if (debug_info) cout << "PR  Err" << prSt.localError().matrix() << endl;
                  
                }
              else
                {
                  if (debug_info) cout << "not valid" << endl;
                }
        }
              if (debug_info) cout << "all hits end" << endl;
    }


  return allHits;
}
TrajectoryStateOnSurface CRackTrajectoryBuilder::startingTSOS ( const TrajectorySeed seed) const [private]

Definition at line 611 of file CRackTrajectoryBuilder.cc.

References magfield, TrajectorySeed::startingState(), and trajectoryStateTransform::transientState().

Referenced by seedMeasurements(), and SortHits().

{
  PTrajectoryStateOnDet pState( seed.startingState());
  const GeomDet* gdet  = (&(*tracker))->idToDet(DetId(pState.detId()));
  TSOS  State= trajectoryStateTransform::transientState( pState, &(gdet->surface()), 
                                           &(*magfield));
  return State;

}
void CRackTrajectoryBuilder::updateTrajectory ( Trajectory traj,
const TM tm,
const TransientTrackingRecHit hit 
) const [private]

Friends And Related Function Documentation

friend class CompareDetByTraj [friend]

Definition at line 144 of file CRackTrajectoryBuilder.h.


Member Data Documentation

Definition at line 259 of file CRackTrajectoryBuilder.h.

Referenced by CRackTrajectoryBuilder(), and init().

Definition at line 239 of file CRackTrajectoryBuilder.h.

Referenced by CRackTrajectoryBuilder(), and init().

Definition at line 254 of file CRackTrajectoryBuilder.h.

Referenced by CRackTrajectoryBuilder(), and SortHits().

Definition at line 255 of file CRackTrajectoryBuilder.h.

Referenced by CRackTrajectoryBuilder().

std::string CRackTrajectoryBuilder::geometry [private]

Definition at line 264 of file CRackTrajectoryBuilder.h.

Referenced by CRackTrajectoryBuilder(), and qualityFilter().

Definition at line 262 of file CRackTrajectoryBuilder.h.

Definition at line 237 of file CRackTrajectoryBuilder.h.

Referenced by init(), and startingTSOS().

Definition at line 249 of file CRackTrajectoryBuilder.h.

Referenced by init(), seedMeasurements(), and SortHits().

Definition at line 263 of file CRackTrajectoryBuilder.h.

Referenced by init(), and SortHits().

Definition at line 248 of file CRackTrajectoryBuilder.h.

Referenced by init().

Definition at line 251 of file CRackTrajectoryBuilder.h.

Referenced by init().

Definition at line 258 of file CRackTrajectoryBuilder.h.

Referenced by CRackTrajectoryBuilder(), and qualityFilter().

Definition at line 241 of file CRackTrajectoryBuilder.h.

Referenced by init(), innerState(), and SortHits().

Definition at line 242 of file CRackTrajectoryBuilder.h.

Referenced by init().

Definition at line 250 of file CRackTrajectoryBuilder.h.

Referenced by init().

Definition at line 247 of file CRackTrajectoryBuilder.h.

Referenced by init().

Definition at line 238 of file CRackTrajectoryBuilder.h.

Referenced by init(), and SortHits().

Definition at line 260 of file CRackTrajectoryBuilder.h.

Definition at line 256 of file CRackTrajectoryBuilder.h.

Referenced by CRackTrajectoryBuilder(), and SortHits().