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";
145 std::vector<TrajectoryMeasurement> collectedmeas = measurementCollector->
recHits(vtraj, measTk);
149 if (collectedmeas.empty())
152 for (std::vector<TrajectoryMeasurement>::const_iterator iter = collectedmeas.begin(); iter != collectedmeas.end();
154 hits.push_back(iter->recHit());
165 LogDebug(
"DAFTrackProducerAlgorithm")
166 <<
"Pair (hits, TSOS) with TSOS predicted(collectedmeas.front().predictedState())";
167 return std::make_pair(
hits, initialStateFromTrack);
174 double annealing)
const {
175 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Calling DAFTrackProducerAlgorithm::updateHits";
177 std::vector<TrajectoryMeasurement> vmeas = vtraj.
measurements();
178 std::vector<TrajectoryMeasurement>::reverse_iterator imeas;
179 unsigned int hitcounter = 1;
182 for (imeas = vmeas.rbegin(); imeas != vmeas.rend(); imeas++, hitcounter++) {
183 DetId id = imeas->recHit()->geographicalId();
188 if (hitcounter == vmeas.size())
189 combtsos = imeas->predictedState();
190 else if (hitcounter == 1)
191 combtsos = imeas->backwardPredictedState();
193 combtsos =
combiner(imeas->backwardPredictedState(), imeas->predictedState());
195 PrintHit(&*imeas->recHit(), combtsos);
196 if (imeas->recHit()->isValid()) {
198 hits.push_back(updated);
200 hits.push_back(imeas->recHit());
207 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Pair (hits, TSOS) with TSOS predicted (vmeas.back().predictedState())";
209 return std::make_pair(
hits, updatedStateFromTrack);
213 const std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>&
hits,
222 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Fit no valid.";
232 LogDebug(
"DAFTrackProducerAlgorithm") <<
" BUILDER " << std::endl;
237 std::unique_ptr<Trajectory> theTraj(
new Trajectory(vtraj));
259 auto algo = (*BeforeDAFTrack)->algo();
267 theTrack->setQualityMask((*BeforeDAFTrack)->qualityMask());
269 AlgoProduct aProduct{theTraj.release(), theTrack.release(), vtraj.
direction(), 0};
270 algoResults.push_back(aProduct);
274 LogDebug(
"DAFTrackProducerAlgorithm") <<
" BUILDER NOT POSSIBLE: traj is not valid" << std::endl;
282 std::vector<TrajectoryMeasurement> vtm = traj.
measurements();
284 for (std::vector<TrajectoryMeasurement>::const_iterator tm = vtm.begin(); tm != vtm.end(); tm++) {
286 if (tm->recHit()->isValid()) {
292 for (std::vector<const TrackingRecHit*>::const_iterator iter =
components.begin(); iter !=
components.end();
295 if (mHit.
weight(iComp) > 1
e-6) {
304 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Original number of valid hits " << traj.
foundHits()
305 <<
" -> hit with good weight (>1e-6) are " << ngoodhits;
311 std::vector<Trajectory>&
input,
313 std::vector<Trajectory>&
output,
319 std::vector<TrajectoryMeasurement> vtm =
input[0].measurements();
323 for (std::vector<TrajectoryMeasurement>::reverse_iterator tm = vtm.rbegin(); tm != vtm.rend(); tm++) {
325 if (tm->recHit()->isValid()) {
330 for (std::vector<const TrackingRecHit*>::const_iterator iter =
components.begin(); iter !=
components.end();
333 if (mHit.
weight(iComp) > 1
e-6) {
342 auto tempHit = hc.
makeShared(tm->recHit(), tm->updatedState());
343 hits.push_back(tempHit);
348 auto tempHit = hc.
makeShared(tm->recHit(), tm->updatedState());
349 hits.push_back(tempHit);
353 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Original number of valid hits " <<
input[0].foundHits()
354 <<
"; after filtering " << ngoodhits;
355 if (ngoodhits >
input[0].foundHits())
357 <<
"Something wrong: the number of good hits from DAFTrackProducerAlgorithm::filter " << ngoodhits
358 <<
" is higher than the original one " <<
input[0].foundHits();
360 if (ngoodhits < minhits)
364 LogDebug(
"DAFTrackProducerAlgorithm") <<
"starting tsos for final refitting " << curstartingTSOS;
371 LogDebug(
"DAFTrackProducerAlgorithm") <<
"After filtering " <<
output.size() <<
" trajectories";
378 const std::vector<TrajectoryMeasurement>& meas = vtraj.
measurements();
379 for (std::vector<TrajectoryMeasurement>::const_iterator iter = meas.begin(); iter != meas.end(); iter++) {
380 if (iter->recHit()->isValid()) {
384 for (std::vector<const TrackingRecHit*>::const_iterator iter2 =
components.begin(); iter2 !=
components.end();
386 if ((*iter2)->isValid())
387 ndof += ((*iter2)->dimension()) * mHit.
weight(iComp);
396 std::vector<TrajectoryMeasurement> initmeasurements = iInitTraj.
measurements();
397 std::vector<TrajectoryMeasurement> finalmeasurements = iFinalTraj.
measurements();
398 std::vector<TrajectoryMeasurement>::iterator jmeas;
402 if (initmeasurements.empty() || finalmeasurements.empty()) {
403 LogDebug(
"DAFTrackProducerAlgorithm") <<
"Initial or Final Trajectory empty.";
407 if (initmeasurements.size() != finalmeasurements.size()) {
408 LogDebug(
"DAFTrackProducerAlgorithm")
409 <<
"Initial Trajectory size(" << initmeasurements.size() <<
" hits) " 410 <<
"is different to final traj size (" << finalmeasurements.size() <<
")! No checkHits possible! ";
414 for (jmeas = initmeasurements.begin(); jmeas != initmeasurements.end(); jmeas++) {
416 if (!initHit->
isValid() && ihit == 0)
428 std::vector<const TrackingRecHit*>::const_iterator icomp;
432 if ((*icomp)->isValid()) {
435 MaxWeightHit = *icomp;
444 auto myref1 =
reinterpret_cast<const BaseTrackerRecHit*
>(initHit)->firstClusterRef();
445 auto myref2 =
reinterpret_cast<const BaseTrackerRecHit*
>(MaxWeightHit)->firstClusterRef();
447 if (myref1 == myref2) {
450 LogDebug(
"DAFTrackProducerAlgorithm") <<
"diverso hit!" << std::endl;
452 LogTrace(
"DAFTrackProducerAlgorithm") <<
" This hit was:\n ";
454 LogTrace(
"DAFTrackProducerAlgorithm") <<
" instead now is:\n ";
473 if (
hit->isValid()) {
474 LogTrace(
"DAFTrackProducerAlgorithm")
475 <<
" Valid Hit with DetId " <<
hit->geographicalId().rawId() <<
" and dim:" <<
hit->dimension()
476 <<
" local position " <<
hit->localPosition() <<
" global position " <<
hit->globalPosition() <<
" and r " 477 <<
hit->globalPosition().perp();
482 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
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