30 minHits_(conf.getParameter<int>(
"MinHits")){}
48 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Size of map: " << TTmap.
size() <<
"\n";
51 int nTracksChanged = 0;
56 std::vector<TrajectoryMeasurement> BeforeDAFTrajMeas = BeforeDAFTraj->measurements();
62 if(BeforeDAFTraj->isValid()){
63 LogDebug(
"DAFTrackProducerAlgorithm") <<
"The trajectory #" << cont+1 <<
" is valid. \n";
66 std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface> hits =
collectHits(*BeforeDAFTraj, measurementCollector, &*measTk);
69 CurrentTraj =
fit(hits, theFitter, *BeforeDAFTraj);
78 <<
".Traj direction is " << CurrentTraj.
direction() << std::endl;
81 std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface> curiterationhits =
82 updateHits(CurrentTraj, updator, &*measTk, *ian);
83 if( curiterationhits.first.size() < 3 ){
84 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Rejecting trajectory with " << curiterationhits.first.size() <<
" hits" << std::endl;
89 CurrentTraj =
fit(curiterationhits, theFitter, CurrentTraj);
94 trajann.push_back(temp);
97 LogDebug(
"DAFTrackProducerAlgorithm") <<
"done annealing value " << (*ian) ;
103 int percOfHitsUnchangedAfterDAF = (1.*
checkHits(*BeforeDAFTraj, CurrentTraj)/(1.*BeforeDAFTrajMeas.size()))*100.;
104 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Ended annealing program with " << percOfHitsUnchangedAfterDAF <<
" unchanged." << std::endl;
114 bool ok =
buildTrack(CurrentTraj, algoResults, ndof, bs, &BeforeDAFTrack);
119 if( (100. - percOfHitsUnchangedAfterDAF) > 0.){
120 bool okBefore =
buildTrack(*BeforeDAFTraj, algoResultsBeforeDAF, ndof, bs, &BeforeDAFTrack);
121 bool okAfter =
buildTrack(CurrentTraj, algoResultsAfterDAF, ndof, bs, &BeforeDAFTrack);
122 if( okBefore && okAfter ) nTracksChanged++;
125 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Rejecting trajectory with " << CurrentTraj.
foundHits()<<
" hits";
129 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Rejecting empty trajectory" << std::endl;
133 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Number of Tracks found: " << cont <<
"\n";
134 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Number of Tracks changed: " << nTracksChanged <<
"\n";
138 std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>
144 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Calling DAFTrackProducerAlgorithm::collectHits";
149 std::vector<TrajectoryMeasurement> collectedmeas = measurementCollector->
recHits(vtraj, measTk);
153 if( collectedmeas.empty() )
156 for( std::vector<TrajectoryMeasurement>::const_iterator iter = collectedmeas.begin();
157 iter!=collectedmeas.end(); iter++ ){
160 hits.push_back(iter->recHit());
173 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Pair (hits, TSOS) with TSOS predicted(collectedmeas.front().predictedState())";
174 return std::make_pair(hits, initialStateFromTrack);
178 std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>
182 double annealing)
const
184 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Calling DAFTrackProducerAlgorithm::updateHits";
186 std::vector<TrajectoryMeasurement> vmeas = vtraj.
measurements();
187 std::vector<TrajectoryMeasurement>::reverse_iterator imeas;
188 unsigned int hitcounter = 1;
191 for (imeas = vmeas.rbegin(); imeas != vmeas.rend(); imeas++, hitcounter++){
193 DetId id = imeas->recHit()->geographicalId();
198 if (hitcounter == vmeas.size()) combtsos = imeas->predictedState();
199 else if (hitcounter == 1) combtsos = imeas->backwardPredictedState();
200 else combtsos =
combiner(imeas->backwardPredictedState(), imeas->predictedState());
202 PrintHit(&*imeas->recHit(), combtsos);
203 if(imeas->recHit()->isValid()){
205 combtsos, measDet, annealing);
206 hits.push_back(updated);
208 hits.push_back(imeas->recHit());
215 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Pair (hits, TSOS) with TSOS predicted (vmeas.back().predictedState())";
217 return std::make_pair(hits,updatedStateFromTrack);
229 hits.first, hits.second);
231 if( newVec.
isValid() )
return newVec;
233 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Fit no valid.";
245 LogDebug(
"DAFTrackProducerAlgorithm") <<
" BUILDER " << std::endl;;
250 std::unique_ptr<Trajectory> theTraj(
new Trajectory( vtraj ));
262 if (tscbl.
isValid()==
false)
return false;
271 auto algo = (*BeforeDAFTrack)->algo();
276 theTrack->setQualityMask((*BeforeDAFTrack)->qualityMask());
279 algoResults.push_back(aProduct);
284 LogDebug(
"DAFTrackProducerAlgorithm") <<
" BUILDER NOT POSSIBLE: traj is not valid" << std::endl;;
293 std::vector<TrajectoryMeasurement> vtm = traj.
measurements();
295 for (std::vector<TrajectoryMeasurement>::const_iterator tm = vtm.begin(); tm != vtm.end(); tm++){
297 if (tm->recHit()->isValid()) {
303 for(std::vector<const TrackingRecHit*>::const_iterator iter = components.begin(); iter != components.end(); iter++, iComp++){
315 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Original number of valid hits " << traj.
foundHits() <<
" -> hit with good weight (>1e-6) are " << ngoodhits;
322 int minhits, std::vector<Trajectory>&
output,
325 if (input.empty())
return;
328 std::vector<TrajectoryMeasurement> vtm = input[0].measurements();
332 for (std::vector<TrajectoryMeasurement>::reverse_iterator tm=vtm.rbegin(); tm!=vtm.rend();tm++){
334 if (tm->recHit()->isValid()) {
339 for(std::vector<const TrackingRecHit*>::const_iterator iter = components.begin(); iter != components.end(); iter++, iComp++){
341 if (mHit.
weight(iComp)>1
e-6) {ngoodhits++; iComp++; isGood =
true;
break;}
345 auto tempHit = hc.
makeShared(tm->recHit(),tm->updatedState());
346 hits.push_back(tempHit);
351 auto tempHit = hc.
makeShared(tm->recHit(),tm->updatedState());
352 hits.push_back(tempHit);
357 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Original number of valid hits " << input[0].foundHits() <<
"; after filtering " << ngoodhits;
358 if (ngoodhits>input[0].foundHits())
359 edm::LogError(
"DAFTrackProducerAlgorithm") <<
"Something wrong: the number of good hits from DAFTrackProducerAlgorithm::filter "
360 << ngoodhits <<
" is higher than the original one " << input[0].foundHits();
362 if (ngoodhits < minhits)
return;
365 LogDebug(
"DAFTrackProducerAlgorithm") <<
"starting tsos for final refitting " << curstartingTSOS ;
370 input.
front().seed().direction()),
374 LogDebug(
"DAFTrackProducerAlgorithm") <<
"After filtering " << output.size() <<
" trajectories";
381 if (!vtraj.
isValid())
return 0;
383 const std::vector<TrajectoryMeasurement>& meas = vtraj.
measurements();
384 for (std::vector<TrajectoryMeasurement>::const_iterator iter = meas.begin(); iter != meas.end(); iter++){
386 if (iter->recHit()->isValid()){
390 for(std::vector<const TrackingRecHit*>::const_iterator iter2 = components.begin(); iter2 != components.end(); iter2++, iComp++){
391 if ((*iter2)->isValid())
392 ndof += ((*iter2)->dimension())*mHit.
weight(iComp);
404 std::vector<TrajectoryMeasurement> initmeasurements = iInitTraj.
measurements();
405 std::vector<TrajectoryMeasurement> finalmeasurements = iFinalTraj.
measurements();
406 std::vector<TrajectoryMeasurement>::iterator jmeas;
410 if( initmeasurements.empty() || finalmeasurements.empty() ){
411 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Initial or Final Trajectory empty.";
415 if( initmeasurements.size() != finalmeasurements.size() ) {
416 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Initial Trajectory size(" << initmeasurements.size() <<
" hits) "
417 <<
"is different to final traj size (" << finalmeasurements.size() <<
")! No checkHits possible! ";
421 for(jmeas = initmeasurements.begin(); jmeas != initmeasurements.end(); jmeas++){
424 if(!initHit->
isValid() && ihit == 0 )
continue;
436 std::vector<const TrackingRecHit*>::const_iterator icomp;
439 for (icomp = components.begin(); icomp != components.end(); icomp++) {
440 if((*icomp)->isValid()) {
442 if(weight > maxweight) {
443 MaxWeightHit = *icomp;
450 auto myref1 =
reinterpret_cast<const BaseTrackerRecHit *
>(initHit)->firstClusterRef();
451 auto myref2 =
reinterpret_cast<const BaseTrackerRecHit *
>(MaxWeightHit)->firstClusterRef();
453 if( myref1 == myref2 ){
456 LogDebug(
"DAFTrackProducerAlgorithm") <<
"diverso hit!" << std::endl;
458 LogTrace(
"DAFTrackProducerAlgorithm") <<
" This hit was:\n ";
460 LogTrace(
"DAFTrackProducerAlgorithm") <<
" instead now is:\n ";
PropagationDirection direction() const
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
virtual int dimension() const =0
ConstRecHitPointer const & recHit() const
int countingGoodHits(const Trajectory traj) 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.
friend struct const_iterator
const_iterator end() const
last iterator over the map (read only)
LocalPoint localPosition() const
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > updateHits(const Trajectory vtraj, const SiTrackerMultiRecHitUpdator *updator, const MeasurementTrackerEvent *theMTE, double annealing) const
void runWithCandidate(const TrackingGeometry *, const MagneticField *, const TrajTrackAssociationCollection &, const MeasurementTrackerEvent *measTk, const TrajectoryFitter *, const TransientTrackingRecHitBuilder *, const MultiRecHitCollector *measurementTracker, const SiTrackerMultiRecHitUpdator *, const reco::BeamSpot &, AlgoProductCollection &, TrajAnnealingCollection &, bool, AlgoProductCollection &, AlgoProductCollection &) const
Run the Final Fit taking TrackCandidates as input.
std::vector< ConstRecHitPointer > RecHitContainer
virtual std::vector< TrajectoryMeasurement > recHits(const Trajectory &, const MeasurementTrackerEvent *theMTE) const =0
int checkHits(Trajectory iInitTraj, const Trajectory iFinalTraj) const
bool buildTrack(const Trajectory, AlgoProductCollection &algoResults, float, const reco::BeamSpot &, const reco::TrackRef *) const
Construct Tracks to be put in the event.
key_type key() const
Accessor for product key.
TrackCharge charge() const
virtual TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
virtual GlobalPoint globalPosition() const
const CurvilinearTrajectoryError & curvilinearError() const
const std::vector< double > & getAnnealingProgram() const
std::map< reco::TransientTrack, AlgebraicMatrix33 > TTmap
std::vector< TrajAnnealing > TrajAnnealingCollection
float weight(unsigned int i) const
static std::string const input
PropagationDirection const & direction() const
uint32_t rawId() const
get the raw id
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
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
void PrintHit(const TrackingRecHit *const &hit, TrajectoryStateOnSurface &tsos) const
GlobalVector momentum() const
std::shared_ptr< TrackingRecHit const > RecHitPointer
FTS const & trackStateAtPCA() const
virtual TransientTrackingRecHit::RecHitPointer update(TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) 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
size_type size() const
map size
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
float calculateNdof(const Trajectory vtraj) const
TrajectoryStateOnSurface const & updatedState() const
const_iterator begin() const
first iterator over the map (read only)
std::vector< Trajectory > fit(const Trajectory &traj, fitType type=standard) const
DetId geographicalId() const
DAFTrackProducerAlgorithm(const edm::ParameterSet &conf)
virtual LocalPoint localPosition() const =0