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 std::cout <<
"TrackFitters" <<
" Error: invalid hit with no GeomDet attached .... skipping" << std::endl;
90 LogDebug(
"TrackFitters")<<
" Error: invalid hit with no GeomDet attached .... skipping";
99 <<
" ----------------- HIT #" << hitcounter <<
" (VALID)-----------------------\n"
106 <<
"SURFACE POSITION" <<
"\n"
108 <<
"SURFACE ROTATION" <<
"\n"
129 LogTrace(
"TrackFitters") <<
" UNKNOWN TRACKER HIT TYPE ";
139 LogTrace(
"TrackFitters") <<
" UNKNOWN MUON HIT TYPE ";
142 LogTrace(
"TrackFitters") <<
" UNKNOWN HIT TYPE ";
146 <<
" ----------------- INVALID HIT #" << hitcounter <<
" -----------------------";
150 if ( hitcounter != 1)
151 predTsos = p_cloned->propagate( currTsos, *(hit.
surface()) );
156 <<
"SOMETHING WRONG !" <<
"\n"
157 <<
"KFTrajectoryFitter: predicted tsos not valid!\n"
158 <<
"current TSOS: " << currTsos <<
"\n";
162 if( myTraj.foundHits() >= minHits_ ) {
163 LogDebug(
"TrackFitters") <<
" breaking trajectory" <<
"\n";
166 LogDebug(
"TrackFitters") <<
" killing trajectory" <<
"\n";
173 assert(hit.
surface()!=
nullptr);
175 LogTrace(
"TrackFitters") <<
"THE HIT IS VALID: updating hit with predTsos";
176 assert( (!(*ihit)->canImproveWithTrack()) | (
nullptr!=theHitCloner));
177 assert( (!(*ihit)->canImproveWithTrack()) | (
nullptr!=dynamic_cast<BaseTrackerRecHit const*>((*ihit).get())));
178 auto preciseHit = theHitCloner->makeShared(*ihit,predTsos);
179 assert(preciseHit->isValid());
180 assert(preciseHit->geographicalId()!=0U);
181 assert(preciseHit->surface()!=
nullptr);
183 if unlikely(!preciseHit->isValid()){
184 LogTrace(
"TrackFitters") <<
"THE Precise HIT IS NOT VALID: using currTsos = predTsos" <<
"\n";
186 myTraj.push(TM(predTsos, *ihit,0,theGeometry->idToLayer((*ihit)->geographicalId()) ));
189 LogTrace(
"TrackFitters") <<
"THE Precise HIT IS VALID: updating currTsos" <<
"\n";
190 currTsos = updator()->
update(predTsos, *preciseHit);
192 bool badState = (!currTsos.
isValid())
201 <<
"updating with the hit failed. Not updating the trajectory with the hit";
203 else LogTrace(
"FailedUpdate")<<
"updated state is valid but pretty bad, skipping. currTsos "
204 <<currTsos<<
"\n predTsos "<<predTsos;
205 myTraj.push(TM(predTsos, *ihit,0,theGeometry->idToLayer((*ihit)->geographicalId()) ));
208 if( myTraj.foundHits() >= minHits_ ) {
209 LogDebug(
"TrackFitters") <<
" breaking trajectory" <<
"\n";
212 LogDebug(
"TrackFitters") <<
" killing trajectory" <<
"\n";
216 if (preciseHit->det()) myTraj.push(TM(predTsos, currTsos, preciseHit,
217 estimator()->estimate(predTsos, *preciseHit).
second,
218 theGeometry->idToLayer(preciseHit->geographicalId()) ));
219 else myTraj.push(TM(predTsos, currTsos, preciseHit,
220 estimator()->estimate(predTsos, *preciseHit).second));
225 LogDebug(
"TrackFitters") <<
"THE HIT IS NOT VALID: using currTsos" <<
"\n";
227 assert( ((*ihit)->det()==
nullptr) || (*ihit)->geographicalId()!=0U);
228 if ((*ihit)->det()) myTraj.push(TM(predTsos, *ihit,0,theGeometry->idToLayer((*ihit)->geographicalId()) ));
229 else myTraj.push(TM(predTsos, *ihit,0));
233 <<
"predTsos !" <<
"\n"
235 <<
"currTsos !" <<
"\n"
239 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)
const GeomDet * det() const
void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
Abs< T >::type abs(const T &t)
DetId geographicalId() const
The label of this GeomDet.
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