CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
CRackTrajectoryBuilder Class Reference

#include <CRackTrajectoryBuilder.h>

Classes

class  CompareDetByTraj
 

Public Member Functions

 CRackTrajectoryBuilder (const edm::ParameterSet &conf)
 
Trajectory createStartingTrajectory (const TrajectorySeed &seed) const
 
const
TransientTrackingRecHitBuilder
hitBuilder () 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. More...
 
 ~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, const 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 (const 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 125 of file CRackTrajectoryBuilder.h.

Member Typedef Documentation

Definition at line 138 of file CRackTrajectoryBuilder.h.

Definition at line 130 of file CRackTrajectoryBuilder.h.

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

Definition at line 132 of file CRackTrajectoryBuilder.h.

Definition at line 134 of file CRackTrajectoryBuilder.h.

Definition at line 135 of file CRackTrajectoryBuilder.h.

Definition at line 129 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(), AlCaHLTBitMon_QueryRunRegistry::string, theMinHits, and useMatchedHits.

32  : conf_(conf) {
33  //minimum number of hits per tracks
34 
35  theMinHits=conf_.getParameter<int>("MinHits");
36  //cut on chi2
37  chi2cut=conf_.getParameter<double>("Chi2Cut");
38  edm::LogInfo("CosmicTrackFinder")<<"Minimum number of hits "<<theMinHits<<" Cut on Chi2= "<<chi2cut;
39 
40  debug_info=conf_.getUntrackedParameter<bool>("debug", false);
41  fastPropagation=conf_.getUntrackedParameter<bool>("fastPropagation", false);
42  useMatchedHits=conf_.getUntrackedParameter<bool>("useMatchedHits", true);
43 
44 
45  geometry=conf_.getUntrackedParameter<std::string>("GeometricStructure","STANDARD");
46 
47 
48 
49 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
CRackTrajectoryBuilder::~CRackTrajectoryBuilder ( )

Definition at line 52 of file CRackTrajectoryBuilder.cc.

52  {
53 // delete theInitialState;
54 }

Member Function Documentation

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

do the old version ....

Definition at line 614 of file CRackTrajectoryBuilder.cc.

References TransientTrackingRecHitBuilder::build(), chi2cut, Trajectory::chiSquared(), CompareDetByTraj, gather_cfg::cout, debug_info, Chi2MeasurementEstimator::estimate(), fastPropagation, spr::find(), TrackingRecHit::geographicalId(), TrajectoryStateOnSurface::globalPosition(), hits, TrajectoryStateOnSurface::isValid(), Trajectory::lastMeasurement(), Propagator::propagate(), Trajectory::push(), DetId::rawId(), RHBuilder, theEstimator, theUpdator, tracker, KFUpdator::update(), and TrajectoryMeasurement::updatedState().

Referenced by run().

615  {
616  vector<const TrackingRecHit*> Hits = _Hits;
617  if ( Hits.size() == 0 )
618  return;
619 
620  if (debug_info) cout << "CRackTrajectoryBuilder::AddHit" << endl;
621  if (debug_info) cout << "START " << traj.lastMeasurement().updatedState() << endl;
622 
623  vector <TrackingRecHitRange> hitRangeByDet;
624  TrackingRecHitIterator prevDet;
625 
626  prevDet = Hits.begin();
627  for( TrackingRecHitIterator iHit = Hits.begin(); iHit != Hits.end(); iHit++ )
628  {
629  if ( (*prevDet)->geographicalId() == (*iHit)->geographicalId() )
630  continue;
631 
632  hitRangeByDet.push_back( make_pair( prevDet, iHit ) );
633  prevDet = iHit;
634  }
635  hitRangeByDet.push_back( make_pair( prevDet, Hits.end() ) );
636 
638 
639  if (fastPropagation) {
640  for( TrackingRecHitRangeIterator iHitRange = hitRangeByDet.begin(); iHitRange != hitRangeByDet.end(); iHitRange++ )
641  {
642  const TrackingRecHit *currHit = *(iHitRange->first);
643  DetId currDet = currHit->geographicalId();
644 
645  TSOS prSt= currPropagator->propagate(traj.lastMeasurement().updatedState(),
646  tracker->idToDet(currDet)->surface());
647 
648  if ( !prSt.isValid())
649  {
650  if (debug_info) cout << "Not Valid: PRST" << prSt.globalPosition();
651  // if (debug_info) cout << "Not Valid: HIT" << *currHit;
652 
653 
654  continue;
655  }
656 
658  double chi2min = theEstimator->estimate( prSt, *bestHit).second;
659 
660  if (debug_info) cout << "Size " << iHitRange->first - (*iHitRange).second << endl;
661  for( TrackingRecHitIterator iHit = (*iHitRange).first+1; iHit != iHitRange->second; iHit++ )
662  {
663  if (debug_info) cout << "loop3 " <<" "<< Hits.end() - iHit << endl;
664 
666  double currChi2 = theEstimator->estimate(prSt, *tmpHit).second;
667  if ( currChi2 < chi2min )
668  {
669  currChi2 = chi2min;
670  bestHit = tmpHit;
671  }
672  }
673  //now we have check if the track can be added to the trajectory
674  if (debug_info) cout << chi2min << endl;
675  if (chi2min < chi2cut)
676  {
677  if (debug_info) cout << "chi2 fine : " << chi2min << endl;
678  TSOS UpdatedState= theUpdator->update( prSt, *bestHit );
679  if (UpdatedState.isValid()){
680  hits.push_back(bestHit);
681  traj.push( TM(prSt,UpdatedState, bestHit, chi2min) );
682  if (debug_info) edm::LogInfo("CosmicTrackFinder") <<
683  "STATE UPDATED WITH HIT AT POSITION "
684 
685  << bestHit->globalPosition()
686  <<UpdatedState<<" "
687  <<traj.chiSquared();
688  if (debug_info) cout <<
689  "STATE UPDATED WITH HIT AT POSITION "
690 
691  << bestHit->globalPosition()
692  <<UpdatedState<<" "
693  <<traj.chiSquared();
694  if (debug_info) cout << "State is valid ..." << endl;
695  break; // now we need to
696  }
697  else
698  {
699  edm::LogWarning("CosmicTrackFinder")<<" State can not be updated with hit at position " << endl;
700  TSOS UpdatedState= theUpdator->update( prSt, *bestHit );
701  if (UpdatedState.isValid()){
702  cout <<
703  "NOT! UPDATED WITH HIT AT POSITION "
704 
705  << bestHit->globalPosition()
706  <<UpdatedState<<" "
707  <<traj.chiSquared();
708 
709  }
710  }
711  }
712  }
713  } //simple version end
714  else
715  {
716  //first sort the dets in the order they are traversed by the trajectory
717  // we need three loops:
718  // 1: loop as long as there can be an new hit added to the trajectory
719  // 2: loop over all dets that might be hit
720  // 3: loop over all hits on a certain det
721 
722 
723  std::vector < std::pair<TrackingRecHitRangeIterator, TSOS> > trackHitCandidates;
724  std::vector <std::pair<TrackingRecHitRangeIterator, TSOS> >::iterator iHitRange;
725  std::vector <uint32_t> processedDets;
726  do
727  {
728 
729  //create vector of possibly hit detectors...
730  trackHitCandidates.clear();
731  DetId currDet;
732  for( TrackingRecHitRangeIterator iHit = hitRangeByDet.begin(); iHit != hitRangeByDet.end(); iHit++ )
733  {
734  const TrackingRecHit *currHit = *(iHit->first);
735  currDet = currHit->geographicalId();
736 
737  if ( find(processedDets.begin(), processedDets.end(), currDet.rawId()) != processedDets.end() )
738  continue;
739 
740  TSOS prSt= currPropagator->propagate(traj.lastMeasurement().updatedState(),
741  tracker->idToDet(currDet)->surface());
742  if ( ( !prSt.isValid() ) || (theEstimator->Chi2MeasurementEstimatorBase::estimate(prSt,tracker->idToDet(currDet)->surface() ) == false) )
743  // if ( ( !prSt.isValid() ) || (theEstimator->estimate(prSt,tracker->idToDet(currDet)->surface() ) == false) )
744  continue;
745 
746  trackHitCandidates.push_back( make_pair(iHit, prSt) );
747  }
748 
749  if (!trackHitCandidates.size())
750  break;
751 
752  if (debug_info) cout << Hits.size() << " (int) trackHitCandidates.begin() " << trackHitCandidates.size() << endl;
753  if (debug_info) cout << "Before sorting ... " << endl;
754 
755  if (debug_info)
756  for( iHitRange = trackHitCandidates.begin(); iHitRange != trackHitCandidates.end(); iHitRange++ )
757  {
758  if (debug_info) cout << (tracker->idToDet((*(iHitRange->first->first))->geographicalId()))->position();
759  }
760  if (debug_info) cout << endl;
761 
762 
763  stable_sort( trackHitCandidates.begin(), trackHitCandidates.end(), CompareDetByTraj(traj.lastMeasurement().updatedState()) );
764 
765  if (debug_info) cout << "After sorting ... " << endl;
766  if (debug_info)
767  {
768  for( iHitRange = trackHitCandidates.begin(); iHitRange != trackHitCandidates.end(); iHitRange++ )
769  {
770  if (debug_info) cout << (tracker->idToDet((*(iHitRange->first->first))->geographicalId()))->position();
771  }
772  cout << endl;
773  }
774 
775  for( iHitRange = trackHitCandidates.begin(); iHitRange != trackHitCandidates.end(); iHitRange++ ) //loop over dets
776  {
777 
778  //now find the best hit of the detector
779  if (debug_info) cout << "loop2 " << trackHitCandidates.size() <<" " << trackHitCandidates.end() - iHitRange << endl;
780  const TrackingRecHit *currHit = *(iHitRange->first->first);
781 
783  TSOS currPrSt = (*iHitRange).second;
784 
785  if (debug_info) cout << "curr position" << bestHit->globalPosition();
786  for( TrackingRecHitIterator iHit = (*iHitRange).first->first+1; iHit != iHitRange->first->second; iHit++ )
787  {
789  if (debug_info) cout << "curr position" << tmpHit->globalPosition() ;
790 
791  }
792  }
793  if (debug_info) cout << "Cross check end ..." << endl;
794 
795 
796  //just a simple test if the same hit can be added twice ...
797  // for( iHitRange = trackHitCandidates.begin(); iHitRange != trackHitCandidates.end(); iHitRange++ ) //loop over all hits
798 
799  // break;
800 
801  for( iHitRange = trackHitCandidates.begin(); iHitRange != trackHitCandidates.end(); iHitRange++ ) //loop over detsall hits
802  {
803 
804  //now find the best hit of the detector
805  if (debug_info) cout << "loop2 " << trackHitCandidates.size() <<" " << trackHitCandidates.end() - iHitRange << endl;
806 
807  const TrackingRecHit *currHit = *(iHitRange->first->first);
808 
809  processedDets.push_back(currHit->geographicalId().rawId());
810 
811 
813 
814  if (debug_info) cout << "curr position A" << bestHit->globalPosition() << endl;
815  TSOS currPrSt = (*iHitRange).second;
816  double chi2min = theEstimator->estimate( currPrSt, *bestHit).second;
817 
818  if (debug_info) cout << "Size " << iHitRange->first->second - (*iHitRange).first->first << endl;
819  for( TrackingRecHitIterator iHit = (*iHitRange).first->first+1; iHit != iHitRange->first->second; iHit++ )
820  {
821  if (debug_info) cout << "loop3 " <<" "<< Hits.end() - iHit << endl;
822 
824  if (debug_info) cout << "curr position B" << tmpHit->globalPosition() << endl;
825  double currChi2 = theEstimator->estimate(currPrSt, *tmpHit).second;
826  if ( currChi2 < chi2min )
827  {
828  if (debug_info) cout << "Is best hit" << endl;
829  chi2min = currChi2;
830  bestHit = tmpHit;
831  }
832  }
833  //now we have checked the det and can remove the entry from the vector...
834 
835  //if (debug_info) cout << "before erase ..." << endl;
836  //this is to slow ...
837  // hitRangeByDet.erase( (*iHitRange).first,(*iHitRange).first+1 );
838  //if (debug_info) cout << "after erase ..." << endl;
839 
840  if (debug_info) cout << chi2min << endl;
841  //if the track can be added to the trajectory
842  if (chi2min < chi2cut)
843  {
844  if (debug_info) cout << "chi2 fine : " << chi2min << endl;
845 
846  // if (debug_info) cout << "previaous state " << traj.lastMeasurement().updatedState() <<endl;
847  TSOS UpdatedState= theUpdator->update( currPrSt, *bestHit );
848  if (UpdatedState.isValid()){
849 
850  hits.push_back(bestHit);
851  traj.push( TM(currPrSt,UpdatedState, bestHit, chi2min) );
852  if (debug_info) edm::LogInfo("CosmicTrackFinder") <<
853  "STATE UPDATED WITH HIT AT POSITION "
854  // <<tmphitbestdet->globalPosition()
855  <<UpdatedState<<" "
856  <<traj.chiSquared();
857  if (debug_info) cout << "Added Hit" << bestHit->globalPosition() << endl;
858  if (debug_info) cout << "State is valid ..." << UpdatedState << endl;
859  //cout << "updated state " << traj.lastMeasurement().updatedState() <<endl;
860 
861  // return; //break;
862  //
863  // TSOS prSt= currPropagator->propagate(traj.lastMeasurement().updatedState(),
864  // tracker->idToDet( bestHit->geographicalId() )->surface());
865  //
866  // if ( prSt.isValid())
867  // cout << "the same hit can be added twice ..." << endl;
868  //
869 
870  break;
871  }
872  else
873  {
874  if (debug_info) edm::LogWarning("CosmicTrackFinder")<<" State can not be updated with hit at position "
875  << bestHit->globalPosition();
876  // cout << "State can not be updated with hit at " << bestHit->globalPosition() << endl;
877  }
878  continue;
879  }
880  else
881  {
882  // cout << "chi2 to big : " << chi2min << endl;
883  }
884  if (debug_info) cout << " continue 1 " << endl;
885  }
886  //now we remove all already processed dets from the list ...
887  // hitRangeByDet.erase( (*trackHitCandidates.begin()).first,(*iHitRange).first+1 );
888 
889  if (debug_info) cout << " continue 2 " << endl;
890  }
891  //if this was the last exit
892  while ( iHitRange != trackHitCandidates.end() );
893  }
894 
895 
896 }
std::vector< TrackingRecHitRange >::iterator TrackingRecHitRangeIterator
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
Definition: Propagator.h:119
Chi2MeasurementEstimator * theEstimator
GlobalPoint globalPosition() const
const TransientTrackingRecHitBuilder * RHBuilder
TransientTrackingRecHit::RecHitContainer hits
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< const TrackingRecHit * >::iterator TrackingRecHitIterator
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
Definition: KFUpdator.cc:75
edm::ESHandle< TrackerGeometry > tracker
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:181
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: DetId.h:18
float chiSquared() const
Definition: Trajectory.h:252
virtual std::pair< bool, double > estimate(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
tuple cout
Definition: gather_cfg.py:121
TrajectoryStateOnSurface const & updatedState() const
DetId geographicalId() const
void push(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:30
TrajectoryMeasurement TM
Trajectory CRackTrajectoryBuilder::createStartingTrajectory ( const TrajectorySeed seed) const

Definition at line 253 of file CRackTrajectoryBuilder.cc.

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

Referenced by run(), and SortHits().

254 {
255  Trajectory result( seed, seed.direction());
256  std::vector<TM> && seedMeas = seedMeasurements(seed);
257  for (auto i : seedMeas) result.push(std::move(i));
258  return result;
259 }
PropagationDirection direction() const
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137
std::vector< TrajectoryMeasurement > seedMeasurements(const TrajectorySeed &seed) const
const TransientTrackingRecHitBuilder* CRackTrajectoryBuilder::hitBuilder ( ) const
inline

Definition at line 201 of file CRackTrajectoryBuilder.h.

References RHBuilder.

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

201 {return RHBuilder;}
const TransientTrackingRecHitBuilder * RHBuilder
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< class >::product(), RHBuilder, seed_plus, AlCaHLTBitMon_QueryRunRegistry::string, theEstimator, theFitter, thePropagator, thePropagatorOp, theSmoother, theUpdator, and tracker.

Referenced by run().

57  {
58 
59 
60 // edm::ParameterSet tise_params = conf_.getParameter<edm::ParameterSet>("TransientInitialStateEstimatorParameters") ;
61 // theInitialState = new TransientInitialStateEstimator( es,tise_params);
62 
63  //services
66 
67 
68 
69  if (seedplus) {
70  seed_plus=true;
73  else {
74  seed_plus=false;
77  }
78 
79  theUpdator= new KFUpdator();
80 // theUpdator= new KFStripUpdator();
82 
83 
85  std::string builderName = conf_.getParameter<std::string>("TTRHBuilder");
86  es.get<TransientRecHitRecord>().get(builderName,theBuilder);
87 
88 
89  RHBuilder= theBuilder.product();
90 
91 
92 
93 
95  *theUpdator,
96  *theEstimator) ;
97 
98 
100  *theUpdator,
101  *theEstimator);
102 
103 }
T getParameter(std::string const &) const
edm::ESHandle< MagneticField > magfield
Chi2MeasurementEstimator * theEstimator
const TransientTrackingRecHitBuilder * RHBuilder
const KFTrajectorySmoother * theSmoother
edm::ESHandle< TrackerGeometry > tracker
PropagatorWithMaterial * thePropagatorOp
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
PropagatorWithMaterial * thePropagator
const KFTrajectoryFitter * theFitter
std::pair< TrajectoryStateOnSurface, const GeomDet * > CRackTrajectoryBuilder::innerState ( const Trajectory traj) const
private

Definition at line 944 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().

Referenced by run().

945 {
946  int lastFitted = 999;
947  int nhits = traj.foundHits();
948  if (nhits < lastFitted+1) lastFitted = nhits-1;
949 
950  std::vector<TrajectoryMeasurement> measvec = traj.measurements();
952 
953  bool foundLast = false;
954  int actualLast = -99;
955  for (int i=lastFitted; i >= 0; i--) {
956  if(measvec[i].recHit()->isValid()){
957  if(!foundLast){
958  actualLast = i;
959  foundLast = true;
960  }
961  firstHits.push_back( measvec[i].recHit());
962  }
963  }
964  TSOS unscaledState = measvec[actualLast].updatedState();
965  AlgebraicSymMatrix55 C=ROOT::Math::SMatrixIdentity();
966  // C *= 100.;
967 
968  TSOS startingState( unscaledState.localParameters(), LocalTrajectoryError(C),
969  unscaledState.surface(),
971 
972  // cout << endl << "FitTester starts with state " << startingState << endl;
973 
974  KFTrajectoryFitter backFitter( *thePropagator,
975  KFUpdator(),
976  Chi2MeasurementEstimator( 100., 3));
977 
979 
980  // only direction matters in this contest
983  backFitDirection);
984 
985  vector<Trajectory> fitres = backFitter.fit( fakeSeed, firstHits, startingState);
986 
987  if (fitres.size() != 1) {
988  // cout << "FitTester: first hits fit failed!" << endl;
989  return std::pair<TrajectoryStateOnSurface, const GeomDet*>();
990  }
991 
992  TrajectoryMeasurement firstMeas = fitres[0].lastMeasurement();
993  TSOS firstState = firstMeas.updatedState();
994 
995  // cout << "FitTester: Fitted first state " << firstState << endl;
996  //cout << "FitTester: chi2 = " << fitres[0].chiSquared() << endl;
997 
998  TSOS initialState( firstState.localParameters(), LocalTrajectoryError(C),
999  firstState.surface(),
1001 
1002  return std::pair<TrajectoryStateOnSurface, const GeomDet*>( initialState,
1003  firstMeas.recHit()->det());
1004 }
virtual const MagneticField * magneticField() const
int foundHits() const
Definition: Trajectory.h:234
int i
Definition: DBlmapReader.cc:9
ConstRecHitPointer const & recHit() const
const LocalTrajectoryParameters & localParameters() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
PropagationDirection
PropagationDirection const & direction() const
Definition: Trajectory.cc:118
DataContainer const & measurements() const
Definition: Trajectory.h:203
const SurfaceType & surface() const
std::vector< ConstRecHitPointer > ConstRecHitContainer
PropagatorWithMaterial * thePropagator
TrajectoryStateOnSurface const & updatedState() const
bool CRackTrajectoryBuilder::isDifferentStripReHit2D ( const SiStripRecHit2D hitA,
const SiStripRecHit2D hitB 
)
private

Definition at line 923 of file CRackTrajectoryBuilder.cc.

References TrackingRecHit::geographicalId(), BaseTrackerRecHit::localPosition(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by SortHits().

924 {
925  if ( hitA.geographicalId() != hitB.geographicalId() )
926  return true;
927  if ( hitA.localPosition().x() != hitB.localPosition().x() )
928  return true;
929  if ( hitA.localPosition().y() != hitB.localPosition().y() )
930  return true;
931  if ( hitA.localPosition().z() != hitB.localPosition().z() )
932  return true;
933 
934  // if (debug_info) cout << hitA.localPosition() << endl;
935  // if (debug_info) cout << hitB << endl;
936 
937  return false;
938 }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
DetId geographicalId() const
T x() const
Definition: PV3DBase.h:62
virtual LocalPoint localPosition() const
bool CRackTrajectoryBuilder::qualityFilter ( const Trajectory traj)
private

Definition at line 900 of file CRackTrajectoryBuilder.cc.

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

Referenced by run().

900  {
901  int ngoodhits=0;
902  if(geometry=="MTCC"){
903  auto hits= traj.recHits();
904  for(auto hit=hits.begin();hit!=hits.end();hit++){
905  unsigned int iid=(*hit)->hit()->geographicalId().rawId();
906  //CHECK FOR 3 hits r-phi
907  if(((iid>>0)&0x3)!=1) ngoodhits++;
908  }
909  }
910  else ngoodhits=traj.foundHits();
911 
912  if ( ngoodhits >= theMinHits) {
913  return true;
914  }
915  else {
916  return false;
917  }
918 }
int foundHits() const
Definition: Trajectory.h:234
TransientTrackingRecHit::RecHitContainer hits
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.

Definition at line 106 of file CRackTrajectoryBuilder.cc.

References AddHit(), alongMomentum, TransientTrackingRecHitBuilder::build(), gather_cfg::cout, createStartingTrajectory(), debug_info, Trajectory::firstMeasurement(), TrajectoryFitter::fit(), Trajectory::foundHits(), hits, init(), innerState(), iseed, Propagator::propagate(), qualityFilter(), RHBuilder, Trajectory::seed(), seed_plus, SortHits(), theEstimator, theFitter, thePropagator, thePropagatorOp, theSmoother, theUpdator, tracker, TrajectorySmoother::trajectories(), trajFit, and TrajectoryMeasurement::updatedState().

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

114 {
115 
116  std::vector<Trajectory> trajSmooth;
117  std::vector<Trajectory>::iterator trajIter;
118 
119  TrajectorySeedCollection::const_iterator iseed;
120  unsigned int IS=0;
121  for(iseed=collseed.begin();iseed!=collseed.end();iseed++){
122  bool seedplus=((*iseed).direction()==alongMomentum);
123  init(es,seedplus);
124  hits.clear();
125  trajFit.clear();
126  trajSmooth.clear();
127 
128  Trajectory startingTraj = createStartingTrajectory(*iseed);
129  Trajectory trajTmp; // used for the opposite direction
130  Trajectory traj = startingTraj;
131 
132 
133  //first propagate track in opposite direction ...
134  seed_plus = !seed_plus;
135  vector<const TrackingRecHit*> allHitsOppsite = SortHits(collstereo,collrphi,collmatched,collpixel, *iseed, true);
136  seed_plus = !seed_plus;
137  if (allHitsOppsite.size())
138  {
139  //there are hits which are above the seed,
140  //cout << "Number of hits higher than seed " <<allHitsOppsite.size() << endl;
141 
142  AddHit( traj, allHitsOppsite, thePropagatorOp);
143 
144 
145  if (debug_info)
146  {
147  cout << "Hits in opposite direction..." << endl;
148  TransientTrackingRecHit::RecHitContainer::const_iterator iHit;
149  for ( iHit = hits.begin(); iHit!=hits.end(); iHit++)
150  {
151  cout << (**iHit).globalPosition() << endl;
152  }
153  }
154 
155 
156  // now add hist opposite to seed
157  //now crate new starting trajectory
158  reverse(hits.begin(), hits.end());
160  tracker->idToDet((hits.front())->geographicalId())->surface()).isValid()){
161  TSOS startingStateNew = //TrajectoryStateWithArbitraryError()//
163  tracker->idToDet((hits.front())->geographicalId())->surface()));
164 
165  if (debug_info)
166  {
167  cout << "Hits in opposite direction reversed..." << endl;
168  TransientTrackingRecHit::RecHitContainer::const_iterator iHit;
169  for ( iHit = hits.begin(); iHit!=hits.end(); iHit++)
170  {
171  cout << (**iHit).globalPosition() << endl;
172  }
173  }
174 
175  const TrajectorySeed& tmpseed=traj.seed();
176  trajTmp = theFitter->fit(tmpseed,hits, startingStateNew ).front();
177 
178  if(debug_info){
179  cout << "Debugging show fitted hits" << endl;
180  auto hitsFit= trajTmp.recHits();
181  for(auto hit=hitsFit.begin();hit!=hitsFit.end();hit++){
182 
183  cout << RHBuilder->build( &(*(*hit)->hit()) )->globalPosition() << endl;
184  }
185  }
186 
187  }
188  }
189  else
190  {
191  if(debug_info) cout << "There are no hits in opposite direction ..." << endl;
192  }
193 
194  vector<const TrackingRecHit*> allHits;
195  if (trajTmp.foundHits())
196  {
197  traj = trajTmp;
198  allHits= SortHits(collstereo,collrphi,collmatched,collpixel,*iseed, false);
199  }
200  else
201  {
202  traj = startingTraj;
203  hits.clear();
204  allHits= SortHits(collstereo,collrphi,collmatched,collpixel,*iseed, true);
205  }
206 
207  AddHit( traj,allHits, thePropagator);
208 
209 
210  if(debug_info){
211  cout << "Debugging show All fitted hits" << endl;
212  auto hits= traj.recHits();
213  for(auto hit=hits.begin();hit!=hits.end();hit++){
214 
215  cout << (*hit)->globalPosition() << endl;
216  }
217 
218  cout << qualityFilter( traj) << " <- quality filter good?" << endl;
219  }
220 
221 
222  if (debug_info) cout << "now do quality checks" << endl;
223  if ( qualityFilter( traj) ) {
224  const TrajectorySeed& tmpseed=traj.seed();
225  std::pair<TrajectoryStateOnSurface, const GeomDet*> initState = innerState(traj); //theInitialState->innerState(traj);
226  if (initState.first.isValid())
227  trajFit = theFitter->fit(tmpseed,hits, initState.first);
228  }
229 
230  for (trajIter=trajFit.begin(); trajIter!=trajFit.end();trajIter++){
231  trajSmooth=theSmoother->trajectories((*trajIter));
232  }
233  for (trajIter= trajSmooth.begin(); trajIter!=trajSmooth.end();trajIter++){
234  if((*trajIter).isValid()){
235 
236  if (debug_info) cout << "adding track ... " << endl;
237  trajoutput.push_back((*trajIter));
238  }
239  }
240  delete theUpdator;
241  delete theEstimator;
242  delete thePropagator;
243  delete thePropagatorOp;
244  delete theFitter;
245  delete theSmoother;
246  //Only the first 30 seeds are considered
247  if (IS>30) return;
248  IS++;
249 
250  }
251 }
int foundHits() const
Definition: Trajectory.h:234
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
Definition: Propagator.h:119
Trajectory createStartingTrajectory(const TrajectorySeed &seed) const
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:275
Chi2MeasurementEstimator * theEstimator
const TransientTrackingRecHitBuilder * RHBuilder
TransientTrackingRecHit::RecHitContainer hits
virtual TrajectoryContainer trajectories(const Trajectory &traj) const
const KFTrajectorySmoother * theSmoother
std::pair< TrajectoryStateOnSurface, const GeomDet * > innerState(const Trajectory &traj) const
std::vector< Trajectory > trajFit
bool qualityFilter(const Trajectory &traj)
edm::ESHandle< TrackerGeometry > tracker
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
PropagatorWithMaterial * thePropagatorOp
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:194
int iseed
Definition: AMPTWrapper.h:124
void init(const edm::EventSetup &es, bool)
PropagatorWithMaterial * thePropagator
const KFTrajectoryFitter * theFitter
std::vector< const TrackingRecHit * > SortHits(const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const SiPixelRecHitCollection &collpixel, const TrajectorySeed &seed, const bool bAddSeedHits)
tuple cout
Definition: gather_cfg.py:121
TrajectoryStateOnSurface const & updatedState() const
std::vector< Trajectory > fit(const Trajectory &traj, fitType type=standard) const
void AddHit(Trajectory &traj, const std::vector< const TrackingRecHit * > &Hits, Propagator *currPropagator)
std::vector< TrajectoryMeasurement > CRackTrajectoryBuilder::seedMeasurements ( const TrajectorySeed seed) const
private

Definition at line 263 of file CRackTrajectoryBuilder.cc.

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

Referenced by createStartingTrajectory().

264 {
265  std::vector<TrajectoryMeasurement> result;
266  TrajectorySeed::range hitRange = seed.recHits();
267  for (TrajectorySeed::const_iterator ihit = hitRange.first;
268  ihit != hitRange.second; ihit++) {
269  //RC TransientTrackingRecHit* recHit = RHBuilder->build(&(*ihit));
271  const GeomDet* hitGeomDet = (&(*tracker))->idToDet( ihit->geographicalId());
272  TSOS invalidState( new BasicSingleTrajectoryState( hitGeomDet->surface()));
273 
274  if (ihit == hitRange.second - 1) {
275  TSOS updatedState=startingTSOS(seed);
276  result.push_back(std::move(TM( invalidState, updatedState, recHit)));
277 
278  }
279  else {
280  result.push_back(std::move(TM( invalidState, recHit)));
281  }
282 
283  }
284 
285  return result;
286 }
const TransientTrackingRecHitBuilder * RHBuilder
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
recHitContainer::const_iterator const_iterator
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
tuple result
Definition: query.py:137
std::pair< const_iterator, const_iterator > range
TSOS startingTSOS(const TrajectorySeed &seed) const
std::shared_ptr< TrackingRecHit const > RecHitPointer
range recHits() const
TrajectoryMeasurement TM
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 289 of file CRackTrajectoryBuilder.cc.

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

Referenced by run().

295  {
296 
297 
298  //The Hits with global y more than the seed are discarded
299  //The Hits correspondign to the seed are discarded
300  //At the end all the hits are sorted in y
301  vector<const TrackingRecHit*> allHits;
302 
304  TrajectorySeed::range hRange= seed.recHits();
306  float yref=0.;
307 
308  if (debug_info) cout << "SEED " << startingTSOS(seed) << endl;
309  if (debug_info) cout << "seed hits size " << seed.nHits() << endl;
310 
311 
312  //seed debugging:
313  // GeomDet *seedDet = tracker->idToDet(seed.startingState().detId());
314 
315 
316 // edm::LogInfo("CRackTrajectoryBuilder::SortHits") << "SEED " << seed.startingState();
317 
318  edm::LogInfo("CRackTrajectoryBuilder::SortHits") << "SEED " << startingTSOS(seed);
319 // edm::LogInfo("CRackTrajectoryBuilder::SortHits" << "seed hits size " << seed.nHits();
320 
321 
322 
323  // if (seed.nHits()<2)
324  // return allHits;
325 
326  float_t yMin=0.;
327  float_t yMax=0.;
328 
329  int seedHitSize= hRange.second - hRange.first;
330 
331  vector <int> detIDSeedMatched (seedHitSize);
332  vector <int> detIDSeedRphi (seedHitSize);
333  vector <int> detIDSeedStereo (seedHitSize);
334 
335  for (ihit = hRange.first;
336  ihit != hRange.second; ihit++) {
337 
338  // need to find track with lowest (seed_plus)/ highest y (seed_minus)
339  // split matched hits ...
340  const SiStripMatchedRecHit2D* matchedhit=dynamic_cast<const SiStripMatchedRecHit2D*>(&(*ihit));
341 
342  yref=RHBuilder->build(&(*ihit))->globalPosition().y();
343  if (ihit == hRange.first)
344  {
345  yMin = yref;
346  yMax = yref;
347  }
348 
349  if (matchedhit)
350  {
351  auto m = matchedhit->monoHit();
352  auto s = matchedhit->stereoHit();
353  float_t yGlobRPhi = RHBuilder->build(&m)->globalPosition().y();
354  float_t yGlobStereo = RHBuilder->build(&s)->globalPosition().y();
355 
356  if (debug_info) cout << "Rphi ..." << yGlobRPhi << endl;
357  if (debug_info) cout << "Stereo ..." << yGlobStereo << endl;
358 
359  if ( yGlobStereo < yMin ) yMin = yGlobStereo;
360  if ( yGlobRPhi < yMin ) yMin = yGlobRPhi;
361 
362  if ( yGlobStereo > yMax ) yMax = yGlobStereo;
363  if ( yGlobRPhi > yMax ) yMax = yGlobRPhi;
364 
365  detIDSeedMatched.push_back ( matchedhit->geographicalId().rawId() );
366  detIDSeedRphi.push_back ( m.geographicalId().rawId() );
367  detIDSeedStereo.push_back ( s.geographicalId().rawId() );
368 
369  if (bAddSeedHits)
370  {
371  if (useMatchedHits)
372  {
373 
374  hits.push_back((RHBuilder->build(&(*ihit))));
375  }
376  else
377  {
378  if ( ( (yGlobRPhi > yGlobStereo ) && seed_plus ) || ((yGlobRPhi < yGlobStereo ) && !seed_plus ))
379  {
380  hits.push_back((RHBuilder->build(&m)));
381  hits.push_back((RHBuilder->build(&s)));
382  }
383  else
384  {
385  hits.push_back((RHBuilder->build(&s)));
386  hits.push_back((RHBuilder->build(&m)));
387 
388  }
389  }
390  }
391  }
392  else if (bAddSeedHits)
393  {
394  hits.push_back((RHBuilder->build(&(*ihit))));
395  detIDSeedRphi.push_back ( ihit->geographicalId().rawId() );
396  detIDSeedMatched.push_back ( -1 );
397  detIDSeedStereo.push_back ( -1 );
398 
399  }
400 
401  if ( yref < yMin ) yMin = yref;
402  if ( yref > yMax ) yMax = yref;
403 
404 // if (bAddSeedHits)
405 // hits.push_back((RHBuilder->build(&(*ihit))));
406 
407  LogDebug("CosmicTrackFinder")<<"SEED HITS"<<RHBuilder->build(&(*ihit))->globalPosition();
408  if (debug_info) cout <<"SEED HITS"<<RHBuilder->build(&(*ihit))->globalPosition() << endl;
409 // if (debug_info) cout <<"SEED HITS"<< seed.startingState().parameters() << endl;
410 
411 
412  }
413 
414  yref = (seed_plus) ? yMin : yMax;
415 
416  if ((&collpixel)!=0){
418  for(ipix=collpixel.data().begin();ipix!=collpixel.data().end();ipix++){
419  float ych= RHBuilder->build(&(*ipix))->globalPosition().y();
420  if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
421  allHits.push_back(&(*ipix));
422  }
423  }
424 
425 
426  if (useMatchedHits) // use matched
427  {
428  //add the matched hits ...
430 
431  if ((&collmatched)!=0){
432  for(istripm=collmatched.data().begin();istripm!=collmatched.data().end();istripm++){
433  float ych= RHBuilder->build(&(*istripm))->globalPosition().y();
434 
435  int cDetId=istripm->geographicalId().rawId();
436  bool noSeedDet = ( detIDSeedMatched.end() == find (detIDSeedMatched.begin(), detIDSeedMatched.end(), cDetId ) ) ;
437 
438  if ( noSeedDet )
439  if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
440  {
441  //if (debug_info) cout << "adding matched hit " << &(*istripm) << endl;
442  allHits.push_back(&(*istripm));
443  }
444  }
445  }
446 
447  //add the rpi hits, but only accept hits that are not matched hits
448  if ((&collrphi)!=0){
449  for(istrip=collrphi.data().begin();istrip!=collrphi.data().end();istrip++){
450  float ych= RHBuilder->build(&(*istrip))->globalPosition().y();
451  StripSubdetector monoDetId(istrip->geographicalId());
452  if (monoDetId.partnerDetId())
453  {
454  edm::LogInfo("CRackTrajectoryBuilder::SortHits") << "this det belongs to a glued det " << ych << endl;
455  continue;
456  }
457  int cDetId=istrip->geographicalId().rawId();
458  bool noSeedDet = ( detIDSeedRphi.end()== find (detIDSeedRphi.begin(), detIDSeedRphi.end(), cDetId ) ) ;
459  if (noSeedDet)
460  if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
461  {
462 
463  bool hitIsUnique = true;
464  //now
465  if ((&collmatched)!=0)
466  for(istripm=collmatched.data().begin();istripm!=collmatched.data().end();istripm++)
467  {
468  // if ( isDifferentStripReHit2D ( *istrip, (istripm->stereoHit() ) ) == false)
469  if ( isDifferentStripReHit2D ( *istrip, (istripm->monoHit() ) ) == false)
470  {
471  hitIsUnique = false;
472  edm::LogInfo("CRackTrajectoryBuilder::SortHits") << "rphi hit is in matched hits; y: " << ych << endl;
473  break;
474  }
475  } //end loop over all matched
476  if (hitIsUnique)
477  {
478  // if (debug_info) cout << "adding rphi hit " << &(*istrip) << endl;
479  allHits.push_back(&(*istrip));
480  }
481  }
482  }
483  }
484 
485 
486  //add the stereo hits except the hits that are in the matched collection
487  //update do not use unmatched rphi hist due to limitation of alignment framework
488  //if (!useMatchedHits)
489  //if ((&collstereo)!=0){
490  // for(istrip=collstereo.data().begin();istrip!=collstereo.data().end();istrip++){
491  // float ych= RHBuilder->build(&(*istrip))->globalPosition().y();
492  //
493  //
494  // int cDetId = istrip->geographicalId().rawId();
495  // bool noSeedDet = ( detIDSeedStereo.end()== find (detIDSeedStereo.begin(), detIDSeedStereo.end(), cDetId ) ) ;
496  //
497  // if (noSeedDet)
498  // if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
499  // {
500  //
501  // bool hitIsUnique = true;
502  // //now
503  // if ((&collmatched)!=0)
504  // for(istripm=collmatched.data().begin();istripm!=collmatched.data().end();istripm++)
505  // {
506  // if ( isDifferentStripReHit2D ( *istrip, * (istripm->stereoHit() ) ) == false)
507  // {
508  // hitIsUnique = false;
509  // edm::LogInfo("CRackTrajectoryBuilder::SortHits") << "stereo hit already in matched hits; y: " << ych << endl;
510  // break;
511  // }
512  // } //end loop over all stereo
513  // if (hitIsUnique)
514  // {
515  //
516  // // if (debug_info) cout << "now I am adding a stero hit, either noise or not in overlap ...!!!!" << endl;
517  // allHits.push_back(&(*istrip));
518  // }
519  // }
520  // }
521  //}
522  }
523  else // dont use matched ...
524  {
525 
526  if ((&collrphi)!=0){
527  for(istrip=collrphi.data().begin();istrip!=collrphi.data().end();istrip++){
528  float ych= RHBuilder->build(&(*istrip))->globalPosition().y();
529  if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
530  allHits.push_back(&(*istrip));
531  }
532  }
533 
534 
535  if ((&collstereo)!=0){
536  for(istrip=collstereo.data().begin();istrip!=collstereo.data().end();istrip++){
537  float ych= RHBuilder->build(&(*istrip))->globalPosition().y();
538  if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
539  allHits.push_back(&(*istrip));
540  }
541  }
542 
543  }
544 
545 
546 // if (seed_plus){
547 // stable_sort(allHits.begin(),allHits.end(),CompareDetY_plus(*tracker));
548 // }
549 // else {
550 // stable_sort(allHits.begin(),allHits.end(),CompareDetY_minus(*tracker));
551 // }
552 
553 
554  if (seed_plus){
555  stable_sort(allHits.begin(),allHits.end(),CompareHitY_plus(*tracker));
556  }
557  else {
558  stable_sort(allHits.begin(),allHits.end(),CompareHitY(*tracker));
559  }
560 
561 
562 
563  if (debug_info)
564  {
565  if (debug_info) cout << "all hits" << endl;
566 
567  //starting trajectory
568  Trajectory startingTraj = createStartingTrajectory(seed);
569 
570  if (debug_info) cout << "START " << startingTraj.lastMeasurement().updatedState() << endl;
571  if (debug_info) cout << "START Err" << startingTraj.lastMeasurement().updatedState().localError().matrix() << endl;
572 
573 
574  vector<const TrackingRecHit*>::iterator iHit;
575  for (iHit=allHits.begin(); iHit<allHits.end(); iHit++)
576  {
577  GlobalPoint gphit=RHBuilder->build(*iHit)->globalPosition();
578  if (debug_info) cout << "GH " << gphit << endl;
579 
580  // tracker->idToDet((*iHit)->geographicalId())->surface();
581 
582  TSOS prSt = thePropagator->propagate(startingTraj.lastMeasurement().updatedState(),
583  tracker->idToDet((*iHit)->geographicalId())->surface());
584 
585  if(prSt.isValid())
586  {
587  if (debug_info) cout << "PR " << prSt.globalPosition() << endl;
588  //if (debug_info) cout << "PR Err" << prSt.localError().matrix() << endl;
589 
590  }
591  else
592  {
593  if (debug_info) cout << "not valid" << endl;
594  }
595  }
596  if (debug_info) cout << "all hits end" << endl;
597  }
598 
599 
600  return allHits;
601 }
#define LogDebug(id)
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
Definition: Propagator.h:119
Trajectory createStartingTrajectory(const TrajectorySeed &seed) const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
GlobalPoint globalPosition() const
const TransientTrackingRecHitBuilder * RHBuilder
TransientTrackingRecHit::RecHitContainer hits
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
recHitContainer::const_iterator const_iterator
edm::ESHandle< TrackerGeometry > tracker
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:181
data_type const * data(size_t cell) const
std::pair< const_iterator, const_iterator > range
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
TSOS startingTSOS(const TrajectorySeed &seed) const
SiStripRecHit2D stereoHit() const
bool isDifferentStripReHit2D(const SiStripRecHit2D &hitA, const SiStripRecHit2D &hitB)
range recHits() const
PropagatorWithMaterial * thePropagator
SiStripRecHit2D monoHit() const
unsigned int nHits() const
tuple cout
Definition: gather_cfg.py:121
TrajectoryStateOnSurface const & updatedState() const
DetId geographicalId() const
TrajectoryStateOnSurface CRackTrajectoryBuilder::startingTSOS ( const TrajectorySeed seed) const
private

Definition at line 604 of file CRackTrajectoryBuilder.cc.

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

Referenced by seedMeasurements(), and SortHits().

605 {
606  PTrajectoryStateOnDet pState( seed.startingState());
607  const GeomDet* gdet = (&(*tracker))->idToDet(DetId(pState.detId()));
608  TSOS State= trajectoryStateTransform::transientState( pState, &(gdet->surface()),
609  &(*magfield));
610  return State;
611 
612 }
edm::ESHandle< MagneticField > magfield
Definition: DetId.h:18
PTrajectoryStateOnDet const & startingState() const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
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 141 of file CRackTrajectoryBuilder.h.

Referenced by AddHit().

Member Data Documentation

double CRackTrajectoryBuilder::chi2cut
private

Definition at line 261 of file CRackTrajectoryBuilder.h.

Referenced by AddHit(), CRackTrajectoryBuilder(), and init().

edm::ParameterSet CRackTrajectoryBuilder::conf_
private

Definition at line 241 of file CRackTrajectoryBuilder.h.

Referenced by CRackTrajectoryBuilder(), and init().

bool CRackTrajectoryBuilder::debug_info
private

Definition at line 256 of file CRackTrajectoryBuilder.h.

Referenced by AddHit(), CRackTrajectoryBuilder(), run(), and SortHits().

bool CRackTrajectoryBuilder::fastPropagation
private

Definition at line 257 of file CRackTrajectoryBuilder.h.

Referenced by AddHit(), and CRackTrajectoryBuilder().

std::string CRackTrajectoryBuilder::geometry
private
TransientTrackingRecHit::RecHitContainer CRackTrajectoryBuilder::hits
private

Definition at line 264 of file CRackTrajectoryBuilder.h.

Referenced by AddHit(), qualityFilter(), run(), and SortHits().

edm::ESHandle<MagneticField> CRackTrajectoryBuilder::magfield
private

Definition at line 239 of file CRackTrajectoryBuilder.h.

Referenced by init(), and startingTSOS().

const TransientTrackingRecHitBuilder* CRackTrajectoryBuilder::RHBuilder
private

Definition at line 251 of file CRackTrajectoryBuilder.h.

Referenced by AddHit(), hitBuilder(), init(), run(), seedMeasurements(), and SortHits().

bool CRackTrajectoryBuilder::seed_plus
private

Definition at line 265 of file CRackTrajectoryBuilder.h.

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

Chi2MeasurementEstimator* CRackTrajectoryBuilder::theEstimator
private

Definition at line 250 of file CRackTrajectoryBuilder.h.

Referenced by AddHit(), init(), and run().

const KFTrajectoryFitter* CRackTrajectoryBuilder::theFitter
private

Definition at line 253 of file CRackTrajectoryBuilder.h.

Referenced by init(), and run().

int CRackTrajectoryBuilder::theMinHits
private

Definition at line 260 of file CRackTrajectoryBuilder.h.

Referenced by CRackTrajectoryBuilder(), and qualityFilter().

PropagatorWithMaterial* CRackTrajectoryBuilder::thePropagator
private

Definition at line 243 of file CRackTrajectoryBuilder.h.

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

PropagatorWithMaterial* CRackTrajectoryBuilder::thePropagatorOp
private

Definition at line 244 of file CRackTrajectoryBuilder.h.

Referenced by init(), and run().

const KFTrajectorySmoother* CRackTrajectoryBuilder::theSmoother
private

Definition at line 252 of file CRackTrajectoryBuilder.h.

Referenced by init(), and run().

KFUpdator* CRackTrajectoryBuilder::theUpdator
private

Definition at line 249 of file CRackTrajectoryBuilder.h.

Referenced by AddHit(), init(), and run().

edm::ESHandle<TrackerGeometry> CRackTrajectoryBuilder::tracker
private

Definition at line 240 of file CRackTrajectoryBuilder.h.

Referenced by AddHit(), init(), run(), and SortHits().

std::vector<Trajectory> CRackTrajectoryBuilder::trajFit
private

Definition at line 262 of file CRackTrajectoryBuilder.h.

Referenced by run().

bool CRackTrajectoryBuilder::useMatchedHits
private

Definition at line 258 of file CRackTrajectoryBuilder.h.

Referenced by CRackTrajectoryBuilder(), and SortHits().