28 : conf_(conf), minHits_(conf.getParameter<
int>(
"MinHits")) {}
44 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Size of map: " <<
TTmap.size() <<
"\n";
47 int nTracksChanged = 0;
51 std::vector<TrajectoryMeasurement> BeforeDAFTrajMeas = BeforeDAFTraj->measurements();
57 if (BeforeDAFTraj->isValid()) {
58 LogDebug(
"DAFTrackProducerAlgorithm") <<
"The trajectory #" <<
cont + 1 <<
" is valid. \n";
61 std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>
hits =
62 collectHits(*BeforeDAFTraj, measurementCollector, &*measTk);
65 CurrentTraj =
fit(
hits, theFitter, *BeforeDAFTraj);
68 for (std::vector<double>::const_iterator ian =
updator->getAnnealingProgram().begin();
69 ian !=
updator->getAnnealingProgram().end();
73 <<
".Traj direction is " << CurrentTraj.
direction() << std::endl;
76 std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface> curiterationhits =
78 if (curiterationhits.first.size() < 3) {
79 LogDebug(
"DAFTrackProducerAlgorithm")
80 <<
"Rejecting trajectory with " << curiterationhits.first.size() <<
" hits" << std::endl;
85 CurrentTraj =
fit(curiterationhits, theFitter, CurrentTraj);
90 trajann.push_back(
temp);
93 LogDebug(
"DAFTrackProducerAlgorithm") <<
"done annealing value " << (*ian);
99 int percOfHitsUnchangedAfterDAF =
100 (1. *
checkHits(*BeforeDAFTraj, CurrentTraj) / (1. * BeforeDAFTrajMeas.size())) * 100.;
101 LogDebug(
"DAFTrackProducerAlgorithm")
102 <<
"Ended annealing program with " << percOfHitsUnchangedAfterDAF <<
" unchanged." << std::endl;
118 if ((100. - percOfHitsUnchangedAfterDAF) > 0.) {
119 bool okBefore =
buildTrack(*BeforeDAFTraj, algoResultsBeforeDAF,
ndof,
bs, &BeforeDAFTrack);
120 bool okAfter =
buildTrack(CurrentTraj, algoResultsAfterDAF,
ndof,
bs, &BeforeDAFTrack);
121 if (okBefore && okAfter)
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";
141 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Calling DAFTrackProducerAlgorithm::collectHits";
146 std::vector<TrajectoryMeasurement> collectedmeas = measurementCollector->
recHits(vtraj, measTk);
150 if (collectedmeas.empty())
153 for (std::vector<TrajectoryMeasurement>::const_iterator iter = collectedmeas.begin(); iter != collectedmeas.end();
156 hits.push_back(iter->recHit());
167 LogDebug(
"DAFTrackProducerAlgorithm")
168 <<
"Pair (hits, TSOS) with TSOS predicted(collectedmeas.front().predictedState())";
169 return std::make_pair(
hits, initialStateFromTrack);
176 double annealing)
const {
177 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Calling DAFTrackProducerAlgorithm::updateHits";
179 std::vector<TrajectoryMeasurement> vmeas = vtraj.
measurements();
180 std::vector<TrajectoryMeasurement>::reverse_iterator imeas;
181 unsigned int hitcounter = 1;
184 for (imeas = vmeas.rbegin(); imeas != vmeas.rend(); imeas++, hitcounter++) {
185 DetId id = imeas->recHit()->geographicalId();
190 if (hitcounter == vmeas.size())
191 combtsos = imeas->predictedState();
192 else if (hitcounter == 1)
193 combtsos = imeas->backwardPredictedState();
195 combtsos =
combiner(imeas->backwardPredictedState(), imeas->predictedState());
197 PrintHit(&*imeas->recHit(), combtsos);
198 if (imeas->recHit()->isValid()) {
200 hits.push_back(updated);
202 hits.push_back(imeas->recHit());
209 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Pair (hits, TSOS) with TSOS predicted (vmeas.back().predictedState())";
211 return std::make_pair(
hits, updatedStateFromTrack);
215 const std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>&
hits,
224 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Fit no valid.";
234 LogDebug(
"DAFTrackProducerAlgorithm") <<
" BUILDER " << std::endl;
239 std::unique_ptr<Trajectory> theTraj(
new Trajectory(vtraj));
261 auto algo = (*BeforeDAFTrack)->algo();
269 theTrack->setQualityMask((*BeforeDAFTrack)->qualityMask());
271 AlgoProduct aProduct{theTraj.release(), theTrack.release(), vtraj.
direction(), 0};
272 algoResults.push_back(aProduct);
276 LogDebug(
"DAFTrackProducerAlgorithm") <<
" BUILDER NOT POSSIBLE: traj is not valid" << std::endl;
284 std::vector<TrajectoryMeasurement> vtm = traj.
measurements();
286 for (std::vector<TrajectoryMeasurement>::const_iterator tm = vtm.begin(); tm != vtm.end(); tm++) {
288 if (tm->recHit()->isValid()) {
294 for (std::vector<const TrackingRecHit*>::const_iterator iter =
components.begin(); iter !=
components.end();
297 if (mHit.
weight(iComp) > 1
e-6) {
306 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Original number of valid hits " << traj.
foundHits()
307 <<
" -> hit with good weight (>1e-6) are " << ngoodhits;
313 std::vector<Trajectory>&
input,
315 std::vector<Trajectory>&
output,
321 std::vector<TrajectoryMeasurement> vtm =
input[0].measurements();
325 for (std::vector<TrajectoryMeasurement>::reverse_iterator tm = vtm.rbegin(); tm != vtm.rend(); tm++) {
327 if (tm->recHit()->isValid()) {
332 for (std::vector<const TrackingRecHit*>::const_iterator iter =
components.begin(); iter !=
components.end();
335 if (mHit.
weight(iComp) > 1
e-6) {
344 auto tempHit = hc.
makeShared(tm->recHit(), tm->updatedState());
345 hits.push_back(tempHit);
350 auto tempHit = hc.
makeShared(tm->recHit(), tm->updatedState());
351 hits.push_back(tempHit);
355 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Original number of valid hits " <<
input[0].foundHits()
356 <<
"; after filtering " << ngoodhits;
357 if (ngoodhits >
input[0].foundHits())
359 <<
"Something wrong: the number of good hits from DAFTrackProducerAlgorithm::filter " << ngoodhits
360 <<
" is higher than the original one " <<
input[0].foundHits();
362 if (ngoodhits < minhits)
366 LogDebug(
"DAFTrackProducerAlgorithm") <<
"starting tsos for final refitting " << curstartingTSOS;
373 LogDebug(
"DAFTrackProducerAlgorithm") <<
"After filtering " <<
output.size() <<
" trajectories";
380 const std::vector<TrajectoryMeasurement>& meas = vtraj.
measurements();
381 for (std::vector<TrajectoryMeasurement>::const_iterator iter = meas.begin(); iter != meas.end(); iter++) {
382 if (iter->recHit()->isValid()) {
386 for (std::vector<const TrackingRecHit*>::const_iterator iter2 =
components.begin(); iter2 !=
components.end();
388 if ((*iter2)->isValid())
389 ndof += ((*iter2)->dimension()) * mHit.
weight(iComp);
398 std::vector<TrajectoryMeasurement> initmeasurements = iInitTraj.
measurements();
399 std::vector<TrajectoryMeasurement> finalmeasurements = iFinalTraj.
measurements();
400 std::vector<TrajectoryMeasurement>::iterator jmeas;
404 if (initmeasurements.empty() || finalmeasurements.empty()) {
405 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Initial or Final Trajectory empty.";
409 if (initmeasurements.size() != finalmeasurements.size()) {
410 LogDebug(
"DAFTrackProducerAlgorithm")
411 <<
"Initial Trajectory size(" << initmeasurements.size() <<
" hits) " 412 <<
"is different to final traj size (" << finalmeasurements.size() <<
")! No checkHits possible! ";
416 for (jmeas = initmeasurements.begin(); jmeas != initmeasurements.end(); jmeas++) {
418 if (!initHit->
isValid() && ihit == 0)
430 std::vector<const TrackingRecHit*>::const_iterator icomp;
434 if ((*icomp)->isValid()) {
437 MaxWeightHit = *icomp;
446 auto myref1 =
reinterpret_cast<const BaseTrackerRecHit*
>(initHit)->firstClusterRef();
447 auto myref2 =
reinterpret_cast<const BaseTrackerRecHit*
>(MaxWeightHit)->firstClusterRef();
449 if (myref1 == myref2) {
452 LogDebug(
"DAFTrackProducerAlgorithm") <<
"diverso hit!" << std::endl;
454 LogTrace(
"DAFTrackProducerAlgorithm") <<
" This hit was:\n ";
456 LogTrace(
"DAFTrackProducerAlgorithm") <<
" instead now is:\n ";
475 if (
hit->isValid()) {
476 LogTrace(
"DAFTrackProducerAlgorithm")
477 <<
" Valid Hit with DetId " <<
hit->geographicalId().rawId() <<
" and dim:" <<
hit->dimension()
478 <<
" local position " <<
hit->localPosition() <<
" global position " <<
hit->globalPosition() <<
" and r " 479 <<
hit->globalPosition().perp();
484 LogTrace(
"DAFTrackProducerAlgorithm") <<
" Invalid Hit with DetId " <<
hit->geographicalId().rawId();
Trajectory fit(const std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > &hits, const TrajectoryFitter *theFitter, Trajectory vtraj) const
accomplishes the fitting-smoothing step for each annealing value
void PrintHit(const TrackingRecHit *const &hit, TrajectoryStateOnSurface &tsos) const
const CurvilinearTrajectoryError & curvilinearError() const
LocalPoint localPosition() const
friend struct const_iterator
float calculateNdof(const Trajectory vtraj) const
bool buildTrack(const Trajectory, AlgoProductCollection &algoResults, float, const reco::BeamSpot &, const reco::TrackRef *) const
Construct Tracks to be put in the event.
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > updateHits(const Trajectory vtraj, const SiTrackerMultiRecHitUpdator *updator, const MeasurementTrackerEvent *theMTE, double annealing) const
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
std::vector< ConstRecHitPointer > RecHitContainer
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > collectHits(const Trajectory vtraj, const MultiRecHitCollector *measurementCollector, const MeasurementTrackerEvent *measTk) const
virtual std::vector< TrajectoryMeasurement > recHits(const Trajectory &, const MeasurementTrackerEvent *theMTE) const =0
Log< level::Error, false > LogError
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
std::map< reco::TransientTrack, AlgebraicMatrix33 > TTmap
key_type key() const
Accessor for product key.
TrajectoryMeasurement const & lastMeasurement() const
static std::string const input
std::vector< TrajAnnealing > TrajAnnealingCollection
DataContainer const & measurements() const
GlobalPoint position() const
PropagationDirection direction() const
PropagationDirection const & direction() const
TrackCharge charge() const
GlobalVector momentum() const
FTS const & trackStateAtPCA() const
virtual Trajectory fitOne(const Trajectory &traj, fitType type=standard) const =0
void filter(const TrajectoryFitter *fitter, std::vector< Trajectory > &input, int minhits, std::vector< Trajectory > &output, const TransientTrackingRecHitBuilder *builder) const
std::shared_ptr< TrackingRecHit const > RecHitPointer
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t nHits
TrajectoryStateOnSurface const & updatedState() const
float weight(unsigned int i) const
int checkHits(Trajectory iInitTraj, const Trajectory iFinalTraj) const
TrajectoryMeasurement const & firstMeasurement() const
int countingGoodHits(const Trajectory traj) const
typename Base::AlgoProductCollection AlgoProductCollection
FreeTrajectoryState const * freeState(bool withErrors=true) const
virtual TrackingRecHit const * hit() const
DAFTrackProducerAlgorithm(const edm::ParameterSet &conf)
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< Trajectory > fit(const Trajectory &traj, fitType type=standard) const
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
cont
load Luminosity info ##
ConstRecHitPointer const & recHit() const