14 const bool materialBeforeUpdate,
20 theUpdator(aUpdator.
clone()),
21 theEstimator(aEstimator.
clone()),
22 theMerger(aMerger.
clone()),
23 theMatBeforeUpdate(materialBeforeUpdate),
24 theErrorRescaling(errorRescaling),
25 theGeometry(detLayerGeometry)
27 auto p = aPropagator.
clone();
29 theAlongPropagator =
p;
32 theOppositePropagator =
p;
33 if ( !theMatBeforeUpdate ) {
38 if(!theGeometry) theGeometry = &dummyGeometry;
44 GsfTrajectorySmoother::~GsfTrajectorySmoother() {
45 delete theAlongPropagator;
46 delete theOppositePropagator;
47 delete theGeomPropagator;
55 GsfTrajectorySmoother::trajectory(
const Trajectory& aTraj)
const {
68 const Propagator* usePropagator = theAlongPropagator;
70 usePropagator = theOppositePropagator;
72 if( not usePropagator) {
73 usePropagator = theGeomPropagator;
76 Trajectory myTraj(aTraj.
seed(), usePropagator->propagationDirection());
80 TSOS predTsos = avtm.back().forwardPredictedState();
85 <<
"GsfTrajectorySmoother: predicted tsos of last measurement not valid!";
91 if(avtm.back().recHit()->isValid()) {
94 currTsos = updator()->
update(predTsos, *avtm.back().recHit());
98 edm::LogInfo(
"GsfTrajectorySmoother") <<
"GsfTrajectorySmoother: tsos not valid after update!";
103 if (!avtm.back().forwardPredictedState().isValid() || !predTsos.
isValid() || !avtm.back().updatedState().isValid()){
108 myTraj.push(TM(avtm.back().forwardPredictedState(),
110 avtm.back().updatedState(),
111 avtm.back().recHit(),
112 avtm.back().estimate(),
113 theGeometry->idToLayer(avtm.back().recHit()->geographicalId()) ),
114 avtm.back().estimate());
118 if (!avtm.back().forwardPredictedState().isValid()){
123 myTraj.push(TM(avtm.back().forwardPredictedState(),
124 avtm.back().recHit(),
126 theGeometry->idToLayer(avtm.back().recHit()->geographicalId() ) ));
131 for(std::vector<TM>::const_reverse_iterator itm = avtm.rbegin() + 1;
132 itm < avtm.rend() - 1; ++itm) {
151 predTsos = usePropagator->propagate(currTsos,
154 if ( predTsos.
isValid() && theConvolutor && theMatBeforeUpdate )
155 predTsos = (*theConvolutor)(predTsos,
156 usePropagator->propagationDirection());
158 edm::LogInfo(
"GsfTrajectorySmoother") <<
"GsfTrajectorySmoother: predicted tsos not valid!";
161 if ( theMerger ) predTsos = theMerger->merge(predTsos);
163 if((*itm).recHit()->isValid()) {
167 currTsos = updator()->
update(predTsos, *(*itm).recHit());
169 if ( currTsos.
isValid() && theConvolutor && !theMatBeforeUpdate )
170 currTsos = (*theConvolutor)(currTsos,
171 usePropagator->propagationDirection());
174 <<
"GsfTrajectorySmoother: tsos not valid after update / material effects!";
181 TSOS combTsos =
combiner(predTsos, (*itm).forwardPredictedState());
183 LogDebug(
"GsfTrajectorySmoother") <<
184 "KFTrajectorySmoother: combined tsos not valid!\n"<<
187 "TrackingRecHit: "<<(*itm).recHit()->surface()->toGlobal((*itm).recHit()->localPosition())<<
"\n" ;
191 TSOS smooTsos =
combiner((*itm).updatedState(), predTsos);
194 LogDebug(
"GsfTrajectorySmoother") <<
195 "KFTrajectorySmoother: smoothed tsos not valid!";
199 if (!(*itm).forwardPredictedState().isValid() || !predTsos.
isValid() || !smooTsos.
isValid() ){
200 edm::LogError(
"InvalidState")<<
"inside hits with combination.";
205 myTraj.push(TM((*itm).forwardPredictedState(),
209 estimator()->estimate(combTsos, *(*itm).recHit()).
second,
210 theGeometry->idToLayer((*itm).recHit()->geographicalId() ) ),
215 TSOS combTsos =
combiner(predTsos, (*itm).forwardPredictedState());
218 LogDebug(
"GsfTrajectorySmoother") <<
219 "KFTrajectorySmoother: combined tsos not valid!";
223 if (!(*itm).forwardPredictedState().isValid() || !predTsos.
isValid() || !combTsos.
isValid() ){
224 edm::LogError(
"InvalidState")<<
"inside hits with invalid rechit.";
228 myTraj.push(TM((*itm).forwardPredictedState(),
233 theGeometry->idToLayer((*itm).recHit()->geographicalId()) ));
235 if ( theMerger ) currTsos = theMerger->merge(currTsos);
241 predTsos = usePropagator->propagate(currTsos,
242 *avtm.front().recHit()->
surface());
244 if ( predTsos.
isValid() && theConvolutor && theMatBeforeUpdate )
245 predTsos = (*theConvolutor)(predTsos,
246 usePropagator->propagationDirection());
248 edm::LogInfo(
"GsfTrajectorySmoother") <<
"GsfTrajectorySmoother: predicted tsos not valid!";
251 if ( theMerger ) predTsos = theMerger->merge(predTsos);
253 if(avtm.front().recHit()->isValid()) {
257 currTsos = updator()->
update(predTsos, *avtm.front().recHit());
259 if ( currTsos.
isValid() && theConvolutor && !theMatBeforeUpdate )
260 currTsos = (*theConvolutor)(currTsos,
261 usePropagator->propagationDirection());
264 <<
"GsfTrajectorySmoother: tsos not valid after update / material effects!";
268 if (!avtm.front().forwardPredictedState().isValid() || !predTsos.
isValid() || !currTsos.
isValid() ){
273 myTraj.push(TM(avtm.front().forwardPredictedState(),
276 avtm.front().recHit(),
277 estimator()->estimate(predTsos, *avtm.front().recHit()).
second,
278 theGeometry->idToLayer(avtm.front().recHit()->geographicalId() )),
279 avtm.front().estimate());
283 if (!avtm.front().forwardPredictedState().isValid()){
287 myTraj.push(TM(avtm.front().forwardPredictedState(),
288 avtm.front().recHit(),
290 theGeometry->idToLayer(avtm.front().recHit()->geographicalId()) ));
bool empty() const
True if trajectory has no measurements.
void rescaleError(double factor)
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
GlobalPoint globalPosition() const
FullConvolutionWithMaterial * clone() const
Clone.
PropagationDirection const & direction() const
U second(std::pair< T, U > const &p)
DataContainer const & measurements() const
const SurfaceType & surface() const
void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
DeepCopyPointerByClone< FullConvolutionWithMaterial > theConvolutor
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
tuple GsfTrajectorySmoother
const Propagator & geometricalPropagator() const
Access to the geometrical propagator.
GlobalVector globalMomentum() const
virtual GsfPropagatorWithMaterial * clone() const
const FullConvolutionWithMaterial & convolutionWithMaterial() const
Access to the convolutor and thus to the material effects.