34 return fitOne(aTraj.
seed(), aTraj.recHits(), firstTsos,
type);
38 const RecHitContainer&, fitType)
const{
41 "KFTrajectoryFitter::fit(TrajectorySeed, <TransientTrackingRecHit>) not implemented");
47 const RecHitContainer& hits,
48 const TSOS& firstPredTsos,fitType)
const
54 throw cms::Exception(
"KFTrajectoryFitter",
"TrajectorySeed::direction() requested but not set");
61 <<
" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
62 <<
" KFTrajectoryFitter::fit starting with " << hits.size() <<
" HITS";
64 for (
unsigned int j=0;
j<hits.size();
j++) {
66 LogTrace(
"TrackFitters") <<
"hit #:" <<
j+1 <<
" rawId=" << hits[
j]->det()->geographicalId().rawId()
67 <<
" validity=" << hits[
j]->isValid();
69 LogTrace(
"TrackFitters") <<
"hit #:" <<
j+1 <<
" Hit with no Det information";
71 LogTrace(
"TrackFitters") <<
" INITIAL STATE "<< firstPredTsos;
76 myTraj.reserve(hits.size());
78 TSOS predTsos(firstPredTsos);
82 for(RecHitContainer::const_iterator ihit = hits.begin(); ihit != hits.end(); ++ihit, ++hitcounter) {
89 LogDebug(
"TrackFitters")<<
" Error: invalid hit with no GeomDet attached .... skipping";
97 LogTrace(
"TrackFitters")<<
" ----------------- HIT #" << hitcounter <<
" (VALID)-----------------------\n"
104 <<
"SURFACE POSITION" <<
"\n"
106 <<
"SURFACE ROTATION" <<
"\n"
127 LogTrace(
"TrackFitters") <<
" UNKNOWN TRACKER HIT TYPE ";
137 LogTrace(
"TrackFitters") <<
" UNKNOWN MUON HIT TYPE ";
140 LogTrace(
"TrackFitters") <<
" UNKNOWN HIT TYPE ";
144 <<
" ----------------- INVALID HIT #" << hitcounter <<
" -----------------------";
148 if ( hitcounter != 1)
149 predTsos = p_cloned->propagate( currTsos, *(hit.
surface()) );
154 <<
"SOMETHING WRONG !" <<
"\n"
155 <<
"KFTrajectoryFitter: predicted tsos not valid!\n"
156 <<
"current TSOS: " << currTsos <<
"\n";
160 if( myTraj.foundHits() >= minHits_ ) {
161 LogDebug(
"TrackFitters") <<
" breaking trajectory" <<
"\n";
164 LogDebug(
"TrackFitters") <<
" killing trajectory" <<
"\n";
171 assert(hit.
surface()!=
nullptr);
173 LogTrace(
"TrackFitters") <<
"THE HIT IS VALID: updating hit with predTsos";
174 assert( (!(*ihit)->canImproveWithTrack()) | (
nullptr!=theHitCloner));
175 assert( (!(*ihit)->canImproveWithTrack()) | (
nullptr!=dynamic_cast<BaseTrackerRecHit const*>((*ihit).get())));
176 auto preciseHit = theHitCloner->makeShared(*ihit,predTsos);
177 assert(preciseHit->isValid());
178 assert(preciseHit->geographicalId()!=0U);
179 assert(preciseHit->surface()!=
nullptr);
181 if unlikely(!preciseHit->isValid()){
182 LogTrace(
"TrackFitters") <<
"THE Precise HIT IS NOT VALID: using currTsos = predTsos" <<
"\n";
184 myTraj.push(TM(predTsos, *ihit,0,theGeometry->idToLayer((*ihit)->geographicalId()) ));
187 LogTrace(
"TrackFitters") <<
"THE Precise HIT IS VALID: updating currTsos" <<
"\n";
188 currTsos = updator()->
update(predTsos, *preciseHit);
190 bool badState = (!currTsos.
isValid())
199 edm::LogError(
"FailedUpdate") <<
"updating with the hit failed. Not updating the trajectory with the hit";
207 LogTrace(
"FailedUpdate")<<
"updated state is valid but pretty bad, skipping. currTsos " <<currTsos<<
"\n predTsos "<<predTsos;
209 myTraj.push(TM(predTsos, *ihit,0,theGeometry->idToLayer((*ihit)->geographicalId()) ));
212 if( myTraj.foundHits() >= minHits_ ) {
213 LogDebug(
"TrackFitters") <<
" breaking trajectory" <<
"\n";
216 LogDebug(
"TrackFitters") <<
" killing trajectory" <<
"\n";
220 if (preciseHit->det()){
221 myTraj.push(TM(predTsos, currTsos, preciseHit,
222 estimator()->estimate(predTsos, *preciseHit).
second,
223 theGeometry->idToLayer(preciseHit->geographicalId()) ));
226 myTraj.push(TM(predTsos, currTsos, preciseHit,
227 estimator()->estimate(predTsos, *preciseHit).
second));
233 LogDebug(
"TrackFitters") <<
"THE HIT IS NOT VALID: using currTsos" <<
"\n";
235 assert( ((*ihit)->det()==
nullptr) || (*ihit)->geographicalId()!=0U);
236 if ((*ihit)->det()) myTraj.push(TM(predTsos, *ihit,0,theGeometry->idToLayer((*ihit)->geographicalId()) ));
237 else myTraj.push(TM(predTsos, *ihit,0));
240 <<
"predTsos !" <<
"\n"
242 <<
"currTsos !" <<
"\n"
246 LogDebug(
"TrackFitters") <<
"Found 1 trajectory with " << myTraj.foundHits() <<
" valid hits\n";
PropagationDirection direction() const
bool empty() const
True if trajectory has no measurements.
virtual const Surface * surface() const
unsigned int layer() const
layer id
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
const LocalTrajectoryParameters & localParameters() const
LocalPoint position() const
Local x and y position coordinates.
Geom::Phi< T > phi() const
virtual GlobalPoint globalPosition() const
unsigned int layer() const
layer id
uint32_t rawId() const
get the raw id
U second(std::pair< T, U > const &p)
std::unique_ptr< Propagator > SetPropagationDirection(Propagator const &iprop, PropagationDirection dir)
void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
Abs< T >::type abs(const T &t)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned int disk() const
disk id
TrajectoryMeasurement const & firstMeasurement() const
virtual LocalError localPositionError() const =0
unsigned int wheel() const
wheel id
unsigned int layer() const
layer id
const RotationType & rotation() const
DetId geographicalId() const
Detector det() const
get the detector field from this detid
virtual LocalPoint localPosition() const =0
const PositionType & position() const
unsigned int wheel() const
wheel id