29 minHits_(conf.getParameter<int>(
"MinHits")){}
34 const std::vector<Trajectory>& theTrajectoryCollection,
43 bool TrajAnnSaving_)
const
45 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Number of Trajectories: " << theTrajectoryCollection.size() <<
"\n";
49 for (std::vector<Trajectory>::const_iterator ivtraj = theTrajectoryCollection.begin();
50 ivtraj != theTrajectoryCollection.end(); ivtraj++)
58 if ( (*ivtraj).isValid() ){
60 LogDebug(
"DAFTrackProducerAlgorithm") <<
"The trajectory is valid. \n";
63 std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface> hits =
64 collectHits(*ivtraj, measurementCollector, &*measTk);
66 currentTraj =
fit(hits, theFitter, *ivtraj);
75 <<
".Traj direction is " << currentTraj.
direction();
78 std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface> curiterationhits =
80 currentTraj =
fit(curiterationhits, theFitter, currentTraj);
85 trajann.push_back(temp);
88 LogDebug(
"DAFTrackProducerAlgorithm") <<
"done annealing value " << (*ian) ;
96 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Ended annealing program with " << (1.*
checkHits(*ivtraj, currentTraj))/(1.*(*ivtraj).measurements().size())*100. <<
" unchanged." << std::endl;
109 bool ok =
buildTrack(currentTraj, algoResults, ndof, bs) ;
114 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Rejecting trajectory with "
119 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Rejecting empty trajectory" << std::endl;
123 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Number of Tracks found: " << cont <<
"\n";
127 std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>
133 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Calling DAFTrackProducerAlgorithm::collectHits";
138 std::vector<TrajectoryMeasurement> collectedmeas = measurementCollector->
recHits(vtraj, measTk);
142 if( collectedmeas.empty() )
145 for( std::vector<TrajectoryMeasurement>::const_iterator
iter = collectedmeas.begin();
146 iter!=collectedmeas.end();
iter++ ){
149 hits.push_back(
iter->recHit());
162 return std::make_pair(hits, initialStateFromTrack);
166 std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>
169 double annealing)
const
172 std::vector<TrajectoryMeasurement> vmeas = vtraj.
measurements();
173 std::vector<TrajectoryMeasurement>::reverse_iterator imeas;
176 for (imeas = vmeas.rbegin(); imeas != vmeas.rend(); imeas++){
178 imeas->updatedState(), annealing);
179 hits.push_back(updated);
186 return std::make_pair(hits,updatedStateFromTrack);
198 hits.first, hits.second);
200 if( newVec.
isValid() )
return newVec;
202 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Fit no valid.";
217 LogDebug(
"DAFTrackProducerAlgorithm") <<
" BUILDER " << std::endl;;
234 if (tscbl.
isValid()==
false)
return false;
249 algoResults.push_back(aProduct);
258 int minhits, std::vector<Trajectory>&
output,
261 if (input.empty())
return;
264 std::vector<TrajectoryMeasurement> vtm = input[0].measurements();
268 for (std::vector<TrajectoryMeasurement>::reverse_iterator tm=vtm.rbegin(); tm!=vtm.rend();tm++){
270 if (tm->recHit()->isValid()) {
275 for(std::vector<const TrackingRecHit*>::const_iterator
iter = components.begin();
iter != components.end();
iter++, iComp++){
277 if (mHit.
weight(iComp)>1
e-6) {ngoodhits++; iComp++; isGood =
true;
break;}
281 auto tempHit = hc.
makeShared(tm->recHit(),tm->updatedState());
282 hits.push_back(tempHit);
287 auto tempHit = hc.
makeShared(tm->recHit(),tm->updatedState());
288 hits.push_back(tempHit);
293 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Original number of valid hits " << input[0].foundHits() <<
"; after filtering " << ngoodhits;
295 if (ngoodhits>input[0].foundHits())
edm::LogError(
"DAFTrackProducerAlgorithm") <<
"Something wrong: the number of good hits from DAFTrackProducerAlgorithm::filter " << ngoodhits <<
" is higher than the original one " << input[0].foundHits();
297 if (ngoodhits < minhits)
return;
300 LogDebug(
"DAFTrackProducerAlgorithm") <<
"starting tsos for final refitting " << curstartingTSOS ;
305 input.
front().seed().direction()),
308 LogDebug(
"DAFTrackProducerAlgorithm") <<
"After filtering " << output.size() <<
" trajectories";
315 if (!vtraj.
isValid())
return 0;
317 const std::vector<TrajectoryMeasurement>& meas = vtraj.
measurements();
318 for (std::vector<TrajectoryMeasurement>::const_iterator
iter = meas.begin();
iter != meas.end();
iter++){
319 if (
iter->recHit()->isValid()){
323 for(std::vector<const TrackingRecHit*>::const_iterator iter2 = components.begin(); iter2 != components.end(); iter2++, iComp++){
324 if ((*iter2)->isValid())
325 ndof += ((*iter2)->dimension())*mHit.
weight(iComp);
337 std::vector<TrajectoryMeasurement> initmeasurements = iInitTraj.
measurements();
338 std::vector<TrajectoryMeasurement> finalmeasurements = iFinalTraj.
measurements();
339 std::vector<TrajectoryMeasurement>::iterator imeas;
340 std::vector<TrajectoryMeasurement>::iterator jmeas;
344 if( initmeasurements.empty() || finalmeasurements.empty() ){
345 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Initial or Final Trajectory empty.";
349 if( initmeasurements.size() != finalmeasurements.size() ) {
350 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Initial and Final Trajectory have different size.";
354 for(jmeas = initmeasurements.begin(); jmeas != initmeasurements.end(); jmeas++){
358 if(!initHit->
isValid() && ihit == 0 )
continue;
370 std::vector<const TrackingRecHit*>::const_iterator icomp;
373 for (icomp = components.begin(); icomp != components.end(); icomp++) {
374 if((*icomp)->isValid()) {
376 if(weight > maxweight) {
377 MaxWeightHit = *icomp;
384 auto myref1 =
reinterpret_cast<const BaseTrackerRecHit *
>(initHit)->firstClusterRef();
385 auto myref2 =
reinterpret_cast<const BaseTrackerRecHit *
>(MaxWeightHit)->firstClusterRef();
387 if( myref1 == myref2 ){
PropagationDirection direction() const
ConstRecHitPointer const & recHit() const
tuple cont
load Luminosity info ##
std::pair< Trajectory *, std::pair< reco::Track *, PropagationDirection > > AlgoProduct
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
virtual TransientTrackingRecHit::RecHitPointer update(TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, double annealing=1.) const
std::vector< ConstRecHitPointer > RecHitContainer
virtual std::vector< TrajectoryMeasurement > recHits(const Trajectory &, const MeasurementTrackerEvent *theMTE) const =0
int checkHits(Trajectory iInitTraj, const Trajectory iFinalTraj) const
TrackCharge charge() const
virtual TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
const CurvilinearTrajectoryError & curvilinearError() const
const std::vector< double > & getAnnealingProgram() const
std::vector< TrajAnnealing > TrajAnnealingCollection
float weight(unsigned int i) const
static std::string const input
PropagationDirection const & direction() const
void filter(const TrajectoryFitter *fitter, std::vector< Trajectory > &input, int minhits, std::vector< Trajectory > &output, const TransientTrackingRecHitBuilder *builder) const
DataContainer const & measurements() const
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
std::vector< AlgoProduct > AlgoProductCollection
TrajectoryMeasurement const & lastMeasurement() const
FreeTrajectoryState const * freeState(bool withErrors=true) const
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > updateHits(const Trajectory vtraj, const SiTrackerMultiRecHitUpdator *updator, double annealing) const
Trajectory fit(const std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > &hits, const TrajectoryFitter *theFitter, Trajectory vtraj) const
accomplishes the fitting-smoothing step for each annealing value
virtual Trajectory fitOne(const Trajectory &traj, fitType type=standard) const =0
GlobalVector momentum() const
std::shared_ptr< TrackingRecHit const > RecHitPointer
FTS const & trackStateAtPCA() const
GlobalPoint position() const
virtual TrackingRecHit const * hit() const
TrajectoryMeasurement const & firstMeasurement() const
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > collectHits(const Trajectory vtraj, const MultiRecHitCollector *measurementCollector, const MeasurementTrackerEvent *measTk) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
bool buildTrack(const Trajectory, AlgoProductCollection &algoResults, float, const reco::BeamSpot &) const
Construct Tracks to be put in the event.
float calculateNdof(const Trajectory vtraj) const
void runWithCandidate(const TrackingGeometry *, const MagneticField *, const std::vector< Trajectory > &, const MeasurementTrackerEvent *measTk, const TrajectoryFitter *, const TransientTrackingRecHitBuilder *, const MultiRecHitCollector *measurementTracker, const SiTrackerMultiRecHitUpdator *, const reco::BeamSpot &, AlgoProductCollection &, TrajAnnealingCollection &, bool) const
Run the Final Fit taking TrackCandidates as input.
TrajectoryStateOnSurface const & updatedState() const
std::vector< Trajectory > fit(const Trajectory &traj, fitType type=standard) const
DAFTrackProducerAlgorithm(const edm::ParameterSet &conf)