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,
227 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Fit no valid.";
237 LogDebug(
"DAFTrackProducerAlgorithm") <<
" BUILDER " << std::endl;
242 std::unique_ptr<Trajectory> theTraj(
new Trajectory(vtraj));
264 auto algo = (*BeforeDAFTrack)->algo();
272 theTrack->setQualityMask((*BeforeDAFTrack)->qualityMask());
274 AlgoProduct aProduct{theTraj.release(), theTrack.release(), vtraj.
direction(), 0};
275 algoResults.push_back(aProduct);
279 LogDebug(
"DAFTrackProducerAlgorithm") <<
" BUILDER NOT POSSIBLE: traj is not valid" << std::endl;
287 std::vector<TrajectoryMeasurement> vtm = traj.
measurements();
289 for (std::vector<TrajectoryMeasurement>::const_iterator tm = vtm.begin(); tm != vtm.end(); tm++) {
291 if (tm->recHit()->isValid()) {
297 for (std::vector<const TrackingRecHit*>::const_iterator iter =
components.begin(); iter !=
components.end();
300 if (mHit.
weight(iComp) > 1
e-6) {
309 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Original number of valid hits " << traj.
foundHits()
310 <<
" -> hit with good weight (>1e-6) are " << ngoodhits;
316 std::vector<Trajectory>&
input,
318 std::vector<Trajectory>&
output,
324 std::vector<TrajectoryMeasurement> vtm =
input[0].measurements();
328 for (std::vector<TrajectoryMeasurement>::reverse_iterator tm = vtm.rbegin(); tm != vtm.rend(); tm++) {
330 if (tm->recHit()->isValid()) {
335 for (std::vector<const TrackingRecHit*>::const_iterator iter =
components.begin(); iter !=
components.end();
338 if (mHit.
weight(iComp) > 1
e-6) {
346 TkClonerImpl hc = static_cast<TkTransientTrackingRecHitBuilder const*>(builder)->cloner();
347 auto tempHit = hc.
makeShared(tm->recHit(), tm->updatedState());
348 hits.push_back(tempHit);
352 TkClonerImpl hc = static_cast<TkTransientTrackingRecHitBuilder const*>(builder)->cloner();
353 auto tempHit = hc.
makeShared(tm->recHit(), tm->updatedState());
354 hits.push_back(tempHit);
358 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Original number of valid hits " <<
input[0].foundHits()
359 <<
"; after filtering " << ngoodhits;
360 if (ngoodhits >
input[0].foundHits())
362 <<
"Something wrong: the number of good hits from DAFTrackProducerAlgorithm::filter " << ngoodhits
363 <<
" is higher than the original one " <<
input[0].foundHits();
365 if (ngoodhits < minhits)
369 LogDebug(
"DAFTrackProducerAlgorithm") <<
"starting tsos for final refitting " << curstartingTSOS;
377 LogDebug(
"DAFTrackProducerAlgorithm") <<
"After filtering " <<
output.size() <<
" trajectories";
384 const std::vector<TrajectoryMeasurement>& meas = vtraj.
measurements();
385 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();
392 if ((*iter2)->isValid())
393 ndof += ((*iter2)->dimension()) * mHit.
weight(iComp);
402 std::vector<TrajectoryMeasurement> initmeasurements = iInitTraj.
measurements();
403 std::vector<TrajectoryMeasurement> finalmeasurements = iFinalTraj.
measurements();
404 std::vector<TrajectoryMeasurement>::iterator jmeas;
408 if (initmeasurements.empty() || finalmeasurements.empty()) {
409 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Initial or Final Trajectory empty.";
413 if (initmeasurements.size() != finalmeasurements.size()) {
414 LogDebug(
"DAFTrackProducerAlgorithm")
415 <<
"Initial Trajectory size(" << initmeasurements.size() <<
" hits) "
416 <<
"is different to final traj size (" << finalmeasurements.size() <<
")! No checkHits possible! ";
420 for (jmeas = initmeasurements.begin(); jmeas != initmeasurements.end(); jmeas++) {
422 if (!initHit->
isValid() && ihit == 0)
434 std::vector<const TrackingRecHit*>::const_iterator icomp;
438 if ((*icomp)->isValid()) {
441 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 ";
479 if (
hit->isValid()) {
480 LogTrace(
"DAFTrackProducerAlgorithm")
481 <<
" Valid Hit with DetId " <<
hit->geographicalId().rawId() <<
" and dim:" <<
hit->dimension()
482 <<
" local position " <<
hit->localPosition() <<
" global position " <<
hit->globalPosition() <<
" and r "
483 <<
hit->globalPosition().perp();
488 LogTrace(
"DAFTrackProducerAlgorithm") <<
" Invalid Hit with DetId " <<
hit->geographicalId().rawId();