CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
DAFTrackProducerAlgorithm Class Reference

#include <DAFTrackProducerAlgorithm.h>

Inheritance diagram for DAFTrackProducerAlgorithm:
AlgoProductTraits< reco::Track >

Public Types

using AlgoProductCollection = typename Base::AlgoProductCollection
 
using Base = AlgoProductTraits< reco::Track >
 
using TrackCollection = typename Base::TrackCollection
 
using TrajAnnealingCollection = std::vector< TrajAnnealing >
 
- Public Types inherited from AlgoProductTraits< reco::Track >
using AlgoProductCollection = std::vector< AlgoProduct >
 
using TrackCollection = std::vector< reco::Track >
 
using TrackView = edm::View< reco::Track >
 

Public Member Functions

 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. More...
 
 ~DAFTrackProducerAlgorithm ()
 

Private Member Functions

bool buildTrack (const Trajectory, AlgoProductCollection &algoResults, float, const reco::BeamSpot &, const reco::TrackRef *) const
 Construct Tracks to be put in the event. More...
 
float calculateNdof (const Trajectory vtraj) const
 
int checkHits (Trajectory iInitTraj, const Trajectory iFinalTraj) const
 
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurfacecollectHits (const Trajectory vtraj, const MultiRecHitCollector *measurementCollector, const MeasurementTrackerEvent *measTk) const
 
int countingGoodHits (const Trajectory traj) const
 
void filter (const TrajectoryFitter *fitter, std::vector< Trajectory > &input, int minhits, std::vector< Trajectory > &output, const TransientTrackingRecHitBuilder *builder) 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 More...
 
void PrintHit (const TrackingRecHit *const &hit, TrajectoryStateOnSurface &tsos) const
 
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurfaceupdateHits (const Trajectory vtraj, const SiTrackerMultiRecHitUpdator *updator, const MeasurementTrackerEvent *theMTE, double annealing) const
 

Private Attributes

edm::ParameterSet conf_
 
int minHits_
 

Detailed Description

All is needed to run the deterministic annealing algorithm. Ported from ORCA.

Author
tropiano, genta \review in May 2014 by brondolin

Definition at line 34 of file DAFTrackProducerAlgorithm.h.

Member Typedef Documentation

◆ AlgoProductCollection

Definition at line 38 of file DAFTrackProducerAlgorithm.h.

◆ Base

Definition at line 36 of file DAFTrackProducerAlgorithm.h.

◆ TrackCollection

Definition at line 37 of file DAFTrackProducerAlgorithm.h.

◆ TrajAnnealingCollection

Definition at line 40 of file DAFTrackProducerAlgorithm.h.

Constructor & Destructor Documentation

◆ DAFTrackProducerAlgorithm()

DAFTrackProducerAlgorithm::DAFTrackProducerAlgorithm ( const edm::ParameterSet conf)

Definition at line 27 of file DAFTrackProducerAlgorithm.cc.

28  : conf_(conf), minHits_(conf.getParameter<int>("MinHits")) {}

◆ ~DAFTrackProducerAlgorithm()

DAFTrackProducerAlgorithm::~DAFTrackProducerAlgorithm ( )
inline

Definition at line 44 of file DAFTrackProducerAlgorithm.h.

44 {}

Member Function Documentation

◆ buildTrack()

bool DAFTrackProducerAlgorithm::buildTrack ( const Trajectory  vtraj,
AlgoProductCollection algoResults,
float  ndof,
const reco::BeamSpot bs,
const reco::TrackRef BeforeDAFTrack 
) const
private

Construct Tracks to be put in the event.

Definition at line 232 of file DAFTrackProducerAlgorithm.cc.

236  {
237  LogDebug("DAFTrackProducerAlgorithm") << " BUILDER " << std::endl;
238  ;
239  TrajectoryStateOnSurface innertsos;
240 
241  if (vtraj.isValid()) {
242  std::unique_ptr<Trajectory> theTraj(new Trajectory(vtraj));
243 
244  if (vtraj.direction() == alongMomentum) {
245  //if (theTraj->direction() == oppositeToMomentum) {
246  innertsos = vtraj.firstMeasurement().updatedState();
247  } else {
248  innertsos = vtraj.lastMeasurement().updatedState();
249  }
250 
251  TSCBLBuilderNoMaterial tscblBuilder;
252  TrajectoryStateClosestToBeamLine tscbl = tscblBuilder(*(innertsos.freeState()), bs);
253 
254  if (tscbl.isValid() == false)
255  return false;
256 
258  math::XYZPoint pos(v.x(), v.y(), v.z());
260  math::XYZVector mom(p.x(), p.y(), p.z());
261 
262  // LogDebug("TrackProducer") <<v<<p<<std::endl;
263 
264  auto algo = (*BeforeDAFTrack)->algo();
265  std::unique_ptr<reco::Track> theTrack(new reco::Track(vtraj.chiSquared(),
266  ndof, //in the DAF the ndof is not-integer
267  pos,
268  mom,
269  tscbl.trackStateAtPCA().charge(),
271  algo));
272  theTrack->setQualityMask((*BeforeDAFTrack)->qualityMask());
273 
274  AlgoProduct aProduct{theTraj.release(), theTrack.release(), vtraj.direction(), 0};
275  algoResults.push_back(aProduct);
276 
277  return true;
278  } else {
279  LogDebug("DAFTrackProducerAlgorithm") << " BUILDER NOT POSSIBLE: traj is not valid" << std::endl;
280  ;
281  return false;
282  }
283 }

References alongMomentum, cms::cuda::bs, FreeTrajectoryState::charge(), Trajectory::chiSquared(), FreeTrajectoryState::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::freeState(), TrajectoryStateClosestToBeamLine::isValid(), Trajectory::isValid(), Trajectory::lastMeasurement(), LogDebug, FreeTrajectoryState::momentum(), ndof, AlCaHLTBitMon_ParallelJobs::p, FreeTrajectoryState::position(), TrajectoryStateClosestToBeamLine::trackStateAtPCA(), TrajectoryMeasurement::updatedState(), and findQualityFiles::v.

Referenced by runWithCandidate().

◆ calculateNdof()

float DAFTrackProducerAlgorithm::calculateNdof ( const Trajectory  vtraj) const
private

Definition at line 380 of file DAFTrackProducerAlgorithm.cc.

380  {
381  if (!vtraj.isValid())
382  return 0;
383  float ndof = 0;
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()) {
387  SiTrackerMultiRecHit const& mHit = dynamic_cast<SiTrackerMultiRecHit const&>(*iter->recHit());
388  std::vector<const TrackingRecHit*> components = mHit.recHits();
389  int iComp = 0;
390  for (std::vector<const TrackingRecHit*>::const_iterator iter2 = components.begin(); iter2 != components.end();
391  iter2++, iComp++) {
392  if ((*iter2)->isValid())
393  ndof += ((*iter2)->dimension()) * mHit.weight(iComp);
394  }
395  }
396  }
397 
398  return ndof - 5;
399 }

References makeMuonMisalignmentScenario::components, Trajectory::isValid(), Trajectory::measurements(), ndof, SiTrackerMultiRecHit::recHits(), and SiTrackerMultiRecHit::weight().

Referenced by runWithCandidate().

◆ checkHits()

int DAFTrackProducerAlgorithm::checkHits ( Trajectory  iInitTraj,
const Trajectory  iFinalTraj 
) const
private

Definition at line 401 of file DAFTrackProducerAlgorithm.cc.

401  {
402  std::vector<TrajectoryMeasurement> initmeasurements = iInitTraj.measurements();
403  std::vector<TrajectoryMeasurement> finalmeasurements = iFinalTraj.measurements();
404  std::vector<TrajectoryMeasurement>::iterator jmeas;
405  int nSame = 0;
406  int ihit = 0;
407 
408  if (initmeasurements.empty() || finalmeasurements.empty()) {
409  LogDebug("DAFTrackProducerAlgorithm") << "Initial or Final Trajectory empty.";
410  return 0;
411  }
412 
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! ";
417  return 0;
418  }
419 
420  for (jmeas = initmeasurements.begin(); jmeas != initmeasurements.end(); jmeas++) {
421  const TrackingRecHit* initHit = jmeas->recHit()->hit();
422  if (!initHit->isValid() && ihit == 0)
423  continue;
424 
425  if (initHit->isValid()) {
426  TrajectoryMeasurement imeas = finalmeasurements.at(ihit);
427  const TrackingRecHit* finalHit = imeas.recHit()->hit();
428  const TrackingRecHit* MaxWeightHit = nullptr;
429  float maxweight = 0;
430 
431  const SiTrackerMultiRecHit* mrh = dynamic_cast<const SiTrackerMultiRecHit*>(finalHit);
432  if (mrh) {
433  std::vector<const TrackingRecHit*> components = mrh->recHits();
434  std::vector<const TrackingRecHit*>::const_iterator icomp;
435  int hitcounter = 0;
436 
437  for (icomp = components.begin(); icomp != components.end(); icomp++) {
438  if ((*icomp)->isValid()) {
439  double weight = mrh->weight(hitcounter);
440  if (weight > maxweight) {
441  MaxWeightHit = *icomp;
442  maxweight = weight;
443  }
444  }
445  hitcounter++;
446  }
447  if (!MaxWeightHit)
448  continue;
449 
450  auto myref1 = reinterpret_cast<const BaseTrackerRecHit*>(initHit)->firstClusterRef();
451  auto myref2 = reinterpret_cast<const BaseTrackerRecHit*>(MaxWeightHit)->firstClusterRef();
452 
453  if (myref1 == myref2) {
454  nSame++;
455  } else {
456  LogDebug("DAFTrackProducerAlgorithm") << "diverso hit!" << std::endl;
457  TrajectoryStateOnSurface dummState;
458  LogTrace("DAFTrackProducerAlgorithm") << " This hit was:\n ";
459  PrintHit(initHit, dummState);
460  LogTrace("DAFTrackProducerAlgorithm") << " instead now is:\n ";
461  PrintHit(MaxWeightHit, dummState);
462  }
463  }
464  } else {
465  TrajectoryMeasurement imeas = finalmeasurements.at(ihit);
466  const TrackingRecHit* finalHit = imeas.recHit()->hit();
467  if (!finalHit->isValid()) {
468  nSame++;
469  }
470  }
471 
472  ihit++;
473  }
474 
475  return nSame;
476 }

References makeMuonMisalignmentScenario::components, TrackingRecHit::hit(), TrackingRecHit::isValid(), LogDebug, LogTrace, Trajectory::measurements(), PrintHit(), TrajectoryMeasurement::recHit(), SiTrackerMultiRecHit::recHits(), SiTrackerMultiRecHit::weight(), and mps_merge::weight.

Referenced by runWithCandidate().

◆ collectHits()

std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > DAFTrackProducerAlgorithm::collectHits ( const Trajectory  vtraj,
const MultiRecHitCollector measurementCollector,
const MeasurementTrackerEvent measTk 
) const
private

Definition at line 137 of file DAFTrackProducerAlgorithm.cc.

140  {
141  LogDebug("DAFTrackProducerAlgorithm") << "Calling DAFTrackProducerAlgorithm::collectHits";
142 
143  //getting the traj measurements from the MeasurementCollector
144  int nHits = 0;
146  std::vector<TrajectoryMeasurement> collectedmeas = measurementCollector->recHits(vtraj, measTk);
147 
148  //if the MeasurementCollector is empty, make an "empty" pair
149  //else taking the collected measured hits and building the pair
150  if (collectedmeas.empty())
152 
153  for (std::vector<TrajectoryMeasurement>::const_iterator iter = collectedmeas.begin(); iter != collectedmeas.end();
154  iter++) {
155  nHits++;
156  hits.push_back(iter->recHit());
157  }
158 
159  //TrajectoryStateWithArbitraryError() == Creates a TrajectoryState with the same parameters
160  // as the input one, but with "infinite" errors, i.e. errors so big that they don't
161  // bias a fit starting with this state.
162  //return std::make_pair(hits,TrajectoryStateWithArbitraryError()(collectedmeas.front().predictedState()));
163 
164  // I do not have to rescale the error because it is already rescaled in the fit code
165  TrajectoryStateOnSurface initialStateFromTrack = collectedmeas.front().predictedState();
166 
167  LogDebug("DAFTrackProducerAlgorithm")
168  << "Pair (hits, TSOS) with TSOS predicted(collectedmeas.front().predictedState())";
169  return std::make_pair(hits, initialStateFromTrack);
170 }

References hfClusterShapes_cfi::hits, LogDebug, and MultiRecHitCollector::recHits().

Referenced by runWithCandidate().

◆ countingGoodHits()

int DAFTrackProducerAlgorithm::countingGoodHits ( const Trajectory  traj) const
private

Definition at line 285 of file DAFTrackProducerAlgorithm.cc.

285  {
286  int ngoodhits = 0;
287  std::vector<TrajectoryMeasurement> vtm = traj.measurements();
288 
289  for (std::vector<TrajectoryMeasurement>::const_iterator tm = vtm.begin(); tm != vtm.end(); tm++) {
290  //if the rechit is valid
291  if (tm->recHit()->isValid()) {
292  SiTrackerMultiRecHit const& mHit = dynamic_cast<SiTrackerMultiRecHit const&>(*tm->recHit());
293  std::vector<const TrackingRecHit*> components = mHit.recHits();
294 
295  int iComp = 0;
296 
297  for (std::vector<const TrackingRecHit*>::const_iterator iter = components.begin(); iter != components.end();
298  iter++, iComp++) {
299  //if there is at least one component with weight higher than 1e-6 then the hit is not an outlier
300  if (mHit.weight(iComp) > 1e-6) {
301  ngoodhits++;
302  iComp++;
303  break;
304  }
305  }
306  }
307  }
308 
309  LogDebug("DAFTrackProducerAlgorithm") << "Original number of valid hits " << traj.foundHits()
310  << " -> hit with good weight (>1e-6) are " << ngoodhits;
311  return ngoodhits;
312 }

References makeMuonMisalignmentScenario::components, MillePedeFileConverter_cfg::e, Trajectory::foundHits(), LogDebug, Trajectory::measurements(), SiTrackerMultiRecHit::recHits(), and SiTrackerMultiRecHit::weight().

Referenced by runWithCandidate().

◆ filter()

void DAFTrackProducerAlgorithm::filter ( const TrajectoryFitter fitter,
std::vector< Trajectory > &  input,
int  minhits,
std::vector< Trajectory > &  output,
const TransientTrackingRecHitBuilder builder 
) const
private

Definition at line 315 of file DAFTrackProducerAlgorithm.cc.

319  {
320  if (input.empty())
321  return;
322 
323  int ngoodhits = 0;
324  std::vector<TrajectoryMeasurement> vtm = input[0].measurements();
326 
327  //count the number of non-outlier and non-invalid hits
328  for (std::vector<TrajectoryMeasurement>::reverse_iterator tm = vtm.rbegin(); tm != vtm.rend(); tm++) {
329  //if the rechit is valid
330  if (tm->recHit()->isValid()) {
331  SiTrackerMultiRecHit const& mHit = dynamic_cast<SiTrackerMultiRecHit const&>(*tm->recHit());
332  std::vector<const TrackingRecHit*> components = mHit.recHits();
333  int iComp = 0;
334  bool isGood = false;
335  for (std::vector<const TrackingRecHit*>::const_iterator iter = components.begin(); iter != components.end();
336  iter++, iComp++) {
337  //if there is at least one component with weight higher than 1e-6 then the hit is not an outlier
338  if (mHit.weight(iComp) > 1e-6) {
339  ngoodhits++;
340  iComp++;
341  isGood = true;
342  break;
343  }
344  }
345  if (isGood) {
346  TkClonerImpl hc = static_cast<TkTransientTrackingRecHitBuilder const*>(builder)->cloner();
347  auto tempHit = hc.makeShared(tm->recHit(), tm->updatedState());
348  hits.push_back(tempHit);
349  } else
350  hits.push_back(std::make_shared<InvalidTrackingRecHit>(*tm->recHit()->det(), TrackingRecHit::missing));
351  } else {
352  TkClonerImpl hc = static_cast<TkTransientTrackingRecHitBuilder const*>(builder)->cloner();
353  auto tempHit = hc.makeShared(tm->recHit(), tm->updatedState());
354  hits.push_back(tempHit);
355  }
356  }
357 
358  LogDebug("DAFTrackProducerAlgorithm") << "Original number of valid hits " << input[0].foundHits()
359  << "; after filtering " << ngoodhits;
360  if (ngoodhits > input[0].foundHits())
361  edm::LogError("DAFTrackProducerAlgorithm")
362  << "Something wrong: the number of good hits from DAFTrackProducerAlgorithm::filter " << ngoodhits
363  << " is higher than the original one " << input[0].foundHits();
364 
365  if (ngoodhits < minhits)
366  return;
367 
368  TrajectoryStateOnSurface curstartingTSOS = input.front().lastMeasurement().updatedState();
369  LogDebug("DAFTrackProducerAlgorithm") << "starting tsos for final refitting " << curstartingTSOS;
370  //curstartingTSOS.rescaleError(100);
371 
372  output = fitter->fit(
374  hits,
375  TrajectoryStateWithArbitraryError()(curstartingTSOS));
376 
377  LogDebug("DAFTrackProducerAlgorithm") << "After filtering " << output.size() << " trajectories";
378 }

References makeMuonMisalignmentScenario::components, MillePedeFileConverter_cfg::e, TrajectoryFitter::fit(), hfClusterShapes_cfi::hits, input, LogDebug, TkClonerImpl::makeShared(), TrackingRecHit::missing, convertSQLitetoXML_cfg::output, SiTrackerMultiRecHit::recHits(), and SiTrackerMultiRecHit::weight().

◆ fit()

Trajectory DAFTrackProducerAlgorithm::fit ( const std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > &  hits,
const TrajectoryFitter theFitter,
Trajectory  vtraj 
) const
private

accomplishes the fitting-smoothing step for each annealing value

Definition at line 214 of file DAFTrackProducerAlgorithm.cc.

217  {
218  //creating a new trajectory starting from the direction of the seed of the input one and the hits
219  Trajectory newVec = theFitter->fitOne(
221  hits.first,
222  hits.second);
223 
224  if (newVec.isValid())
225  return newVec;
226  else {
227  LogDebug("DAFTrackProducerAlgorithm") << "Fit no valid.";
228  return Trajectory();
229  }
230 }

References TrajectorySeed::direction(), TrajectoryFitter::fitOne(), hfClusterShapes_cfi::hits, Trajectory::isValid(), LogDebug, and Trajectory::seed().

Referenced by trackingPlots.Iteration::modules(), and runWithCandidate().

◆ PrintHit()

void DAFTrackProducerAlgorithm::PrintHit ( const TrackingRecHit *const &  hit,
TrajectoryStateOnSurface tsos 
) const
private

Definition at line 478 of file DAFTrackProducerAlgorithm.cc.

478  {
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();
484  if (tsos.isValid())
485  LogTrace("DAFTrackProducerAlgorithm") << " TSOS combtsos " << tsos.localPosition();
486 
487  } else {
488  LogTrace("DAFTrackProducerAlgorithm") << " Invalid Hit with DetId " << hit->geographicalId().rawId();
489  }
490 }

References TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localPosition(), and LogTrace.

Referenced by checkHits(), and updateHits().

◆ runWithCandidate()

void DAFTrackProducerAlgorithm::runWithCandidate ( const TrackingGeometry theG,
const MagneticField theMF,
const TrajTrackAssociationCollection TTmap,
const MeasurementTrackerEvent measTk,
const TrajectoryFitter theFitter,
const TransientTrackingRecHitBuilder builder,
const MultiRecHitCollector measurementTracker,
const SiTrackerMultiRecHitUpdator updator,
const reco::BeamSpot bs,
AlgoProductCollection algoResults,
TrajAnnealingCollection trajann,
bool  TrajAnnSaving_,
AlgoProductCollection algoResultsBeforeDAF,
AlgoProductCollection algoResultsAfterDAF 
) const

Run the Final Fit taking TrackCandidates as input.

Definition at line 30 of file DAFTrackProducerAlgorithm.cc.

43  {
44  LogDebug("DAFTrackProducerAlgorithm") << "Size of map: " << TTmap.size() << "\n";
45 
46  int cont = 0;
47  int nTracksChanged = 0;
48 
49  for (TrajTrackAssociationCollection::const_iterator itTTmap = TTmap.begin(); itTTmap != TTmap.end(); itTTmap++) {
50  const edm::Ref<std::vector<Trajectory> > BeforeDAFTraj = itTTmap->key;
51  std::vector<TrajectoryMeasurement> BeforeDAFTrajMeas = BeforeDAFTraj->measurements();
52  const reco::TrackRef BeforeDAFTrack = itTTmap->val;
53 
54  float ndof = 0;
55  Trajectory CurrentTraj;
56 
57  if (BeforeDAFTraj->isValid()) {
58  LogDebug("DAFTrackProducerAlgorithm") << "The trajectory #" << cont + 1 << " is valid. \n";
59 
60  //getting the MultiRecHit collection and the trajectory with a first fit-smooth round
61  std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface> hits =
62  collectHits(*BeforeDAFTraj, measurementCollector, &*measTk);
63 
64  //new initial fit
65  CurrentTraj = fit(hits, theFitter, *BeforeDAFTraj);
66 
67  //starting the annealing program
68  for (std::vector<double>::const_iterator ian = updator->getAnnealingProgram().begin();
69  ian != updator->getAnnealingProgram().end();
70  ian++) {
71  if (CurrentTraj.isValid()) {
72  LogDebug("DAFTrackProducerAlgorithm") << "Seed direction is " << CurrentTraj.seed().direction()
73  << ".Traj direction is " << CurrentTraj.direction() << std::endl;
74 
75  //updating MultiRecHits and fit-smooth again
76  std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface> curiterationhits =
77  updateHits(CurrentTraj, updator, &*measTk, *ian);
78  if (curiterationhits.first.size() < 3) {
79  LogDebug("DAFTrackProducerAlgorithm")
80  << "Rejecting trajectory with " << curiterationhits.first.size() << " hits" << std::endl;
81  CurrentTraj = Trajectory();
82  break;
83  }
84 
85  CurrentTraj = fit(curiterationhits, theFitter, CurrentTraj);
86 
87  //saving trajectory for each annealing cycle ...
88  if (TrajAnnSaving_) {
89  TrajAnnealing temp(CurrentTraj, *ian);
90  trajann.push_back(temp);
91  }
92 
93  LogDebug("DAFTrackProducerAlgorithm") << "done annealing value " << (*ian);
94 
95  } else
96  break;
97  } //end annealing cycle
98 
99  int percOfHitsUnchangedAfterDAF =
100  (1. * checkHits(*BeforeDAFTraj, CurrentTraj) / (1. * BeforeDAFTrajMeas.size())) * 100.;
101  LogDebug("DAFTrackProducerAlgorithm")
102  << "Ended annealing program with " << percOfHitsUnchangedAfterDAF << " unchanged." << std::endl;
103 
104  //computing the ndof keeping into account the weights
105  ndof = calculateNdof(CurrentTraj);
106 
107  //checking if the trajectory has the minimum number of valid hits ( weight (>1e-6) )
108  //in order to remove tracks with too many outliers.
109  int goodHits = countingGoodHits(CurrentTraj);
110 
111  if (goodHits >= minHits_) {
112  bool ok = buildTrack(CurrentTraj, algoResults, ndof, bs, &BeforeDAFTrack);
113  // or filtered?
114  if (ok)
115  cont++;
116 
117  //saving tracks before and after DAF
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)
122  nTracksChanged++;
123  }
124  } else {
125  LogDebug("DAFTrackProducerAlgorithm") << "Rejecting trajectory with " << CurrentTraj.foundHits() << " hits";
126  }
127  } //end run on track collection
128  else {
129  LogDebug("DAFTrackProducerAlgorithm") << "Rejecting empty trajectory" << std::endl;
130  }
131  } //end run on track collection
132 
133  LogDebug("DAFTrackProducerAlgorithm") << "Number of Tracks found: " << cont << "\n";
134  LogDebug("DAFTrackProducerAlgorithm") << "Number of Tracks changed: " << nTracksChanged << "\n";
135 }

References cms::cuda::bs, buildTrack(), calculateNdof(), checkHits(), collectHits(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, generateEDF::cont, countingGoodHits(), TrajectorySeed::direction(), Trajectory::direction(), fit(), Trajectory::foundHits(), hfClusterShapes_cfi::hits, Trajectory::isValid(), edm::Ref< C, T, F >::key(), LogDebug, minHits_, ndof, convertSQLiteXML::ok, Trajectory::seed(), groupFilesInBlocks::temp, updateHits(), and HLT_2018_cff::updator.

Referenced by DAFTrackProducer::produce().

◆ updateHits()

std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > DAFTrackProducerAlgorithm::updateHits ( const Trajectory  vtraj,
const SiTrackerMultiRecHitUpdator updator,
const MeasurementTrackerEvent theMTE,
double  annealing 
) const
private

Definition at line 172 of file DAFTrackProducerAlgorithm.cc.

176  {
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;
182 
183  //I run inversely on the trajectory obtained and update the state
184  for (imeas = vmeas.rbegin(); imeas != vmeas.rend(); imeas++, hitcounter++) {
185  DetId id = imeas->recHit()->geographicalId();
186  MeasurementDetWithData measDet = theMTE->idToDet(id);
187 
189  TrajectoryStateOnSurface combtsos;
190  if (hitcounter == vmeas.size())
191  combtsos = imeas->predictedState(); //fwd
192  else if (hitcounter == 1)
193  combtsos = imeas->backwardPredictedState(); //bwd
194  else
195  combtsos = combiner(imeas->backwardPredictedState(), imeas->predictedState());
196 
197  PrintHit(&*imeas->recHit(), combtsos);
198  if (imeas->recHit()->isValid()) {
199  TransientTrackingRecHit::RecHitPointer updated = updator->update(imeas->recHit(), combtsos, measDet, annealing);
200  hits.push_back(updated);
201  } else {
202  hits.push_back(imeas->recHit());
203  }
204  }
205 
206  TrajectoryStateOnSurface updatedStateFromTrack = vmeas.back().predictedState();
207 
208  //return std::make_pair(hits,TrajectoryStateWithArbitraryError()(vmeas.back().updatedState()));
209  LogDebug("DAFTrackProducerAlgorithm") << "Pair (hits, TSOS) with TSOS predicted (vmeas.back().predictedState())";
210 
211  return std::make_pair(hits, updatedStateFromTrack);
212 }

References heavyFlavorValidationHarvestingSequence_cff::combiner, hfClusterShapes_cfi::hits, MeasurementTrackerEvent::idToDet(), LogDebug, Trajectory::measurements(), PrintHit(), and HLT_2018_cff::updator.

Referenced by runWithCandidate().

Member Data Documentation

◆ conf_

edm::ParameterSet DAFTrackProducerAlgorithm::conf_
private

Definition at line 102 of file DAFTrackProducerAlgorithm.h.

◆ minHits_

int DAFTrackProducerAlgorithm::minHits_
private

Definition at line 103 of file DAFTrackProducerAlgorithm.h.

Referenced by runWithCandidate().

Vector3DBase
Definition: Vector3DBase.h:8
FreeTrajectoryState::momentum
GlobalVector momentum() const
Definition: FreeTrajectoryState.h:68
TrajectoryStateClosestToBeamLine
Definition: TrajectoryStateClosestToBeamLine.h:15
TrajAnnealing
Definition: TrajAnnealing.h:13
input
static const std::string input
Definition: EdmProvDump.cc:48
DAFTrackProducerAlgorithm::minHits_
int minHits_
Definition: DAFTrackProducerAlgorithm.h:103
TkClonerImpl::makeShared
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:60
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
Trajectory::chiSquared
float chiSquared() const
Definition: Trajectory.h:241
Trajectory::direction
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
mps_merge.weight
weight
Definition: mps_merge.py:88
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
TrackingRecHit::hit
virtual TrackingRecHit const * hit() const
Definition: TrackingRecHit.h:75
pos
Definition: PixelAliasList.h:18
FreeTrajectoryState::charge
TrackCharge charge() const
Definition: FreeTrajectoryState.h:69
generateEDF.cont
cont
load Luminosity info ##
Definition: generateEDF.py:629
SiTrackerMultiRecHit::recHits
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: SiTrackerMultiRecHit.cc:59
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
DAFTrackProducerAlgorithm::buildTrack
bool buildTrack(const Trajectory, AlgoProductCollection &algoResults, float, const reco::BeamSpot &, const reco::TrackRef *) const
Construct Tracks to be put in the event.
Definition: DAFTrackProducerAlgorithm.cc:232
FreeTrajectoryState::position
GlobalPoint position() const
Definition: FreeTrajectoryState.h:67
TrackingRecHit::RecHitPointer
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: TrackingRecHit.h:24
Trajectory::foundHits
int foundHits() const
Definition: Trajectory.h:206
findQualityFiles.v
v
Definition: findQualityFiles.py:179
TTmap
std::map< reco::TransientTrack, AlgebraicMatrix33 > TTmap
Definition: TTtoTTmap.h:11
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
TrajectoryStateWithArbitraryError
Definition: TrajectoryStateWithArbitraryError.h:15
edm::Ref
Definition: AssociativeIterator.h:58
ndof
Definition: HIMultiTrackSelector.h:49
DetId
Definition: DetId.h:17
cmsdt::algo
algo
Definition: constants.h:164
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
cms::cuda::bs
bs
Definition: HistoContainer.h:127
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
HLT_2018_cff.updator
updator
Definition: HLT_2018_cff.py:123
TrackingRecHit::RecHitContainer
std::vector< ConstRecHitPointer > RecHitContainer
Definition: TrackingRecHit.h:31
MultiRecHitCollector::recHits
virtual std::vector< TrajectoryMeasurement > recHits(const Trajectory &, const MeasurementTrackerEvent *theMTE) const =0
FreeTrajectoryState::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: FreeTrajectoryState.h:89
reco::Track
Definition: Track.h:27
DAFTrackProducerAlgorithm::countingGoodHits
int countingGoodHits(const Trajectory traj) const
Definition: DAFTrackProducerAlgorithm.cc:285
MeasurementTrackerEvent::idToDet
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
Definition: MeasurementTrackerEvent.h:69
SiTrackerMultiRecHit::weight
float weight(unsigned int i) const
Definition: SiTrackerMultiRecHit.h:52
Point3DBase< float, GlobalTag >
DAFTrackProducerAlgorithm::collectHits
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > collectHits(const Trajectory vtraj, const MultiRecHitCollector *measurementCollector, const MeasurementTrackerEvent *measTk) const
Definition: DAFTrackProducerAlgorithm.cc:137
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator
friend struct const_iterator
Definition: AssociationMap.h:274
TrajectoryStateCombiner
Definition: TrajectoryStateCombiner.h:13
TrajectoryStateOnSurface::localPosition
LocalPoint localPosition() const
Definition: TrajectoryStateOnSurface.h:74
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
TrajectorySeed::direction
PropagationDirection direction() const
Definition: TrajectorySeed.h:54
edm::LogError
Definition: MessageLogger.h:183
Trajectory::lastMeasurement
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
DAFTrackProducerAlgorithm::PrintHit
void PrintHit(const TrackingRecHit *const &hit, TrajectoryStateOnSurface &tsos) const
Definition: DAFTrackProducerAlgorithm.cc:478
TrackingRecHit::missing
Definition: TrackingRecHit.h:47
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
DAFTrackProducerAlgorithm::calculateNdof
float calculateNdof(const Trajectory vtraj) const
Definition: DAFTrackProducerAlgorithm.cc:380
DAFTrackProducerAlgorithm::checkHits
int checkHits(Trajectory iInitTraj, const Trajectory iFinalTraj) const
Definition: DAFTrackProducerAlgorithm.cc:401
TrajectoryFitter::fit
std::vector< Trajectory > fit(const Trajectory &traj, fitType type=standard) const
Definition: TrajectoryFitter.h:43
Trajectory::measurements
DataContainer const & measurements() const
Definition: Trajectory.h:178
TrackingRecHit
Definition: TrackingRecHit.h:21
DAFTrackProducerAlgorithm::updateHits
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > updateHits(const Trajectory vtraj, const SiTrackerMultiRecHitUpdator *updator, const MeasurementTrackerEvent *theMTE, double annealing) const
Definition: DAFTrackProducerAlgorithm.cc:172
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TkClonerImpl
Definition: TkClonerImpl.h:12
Trajectory::firstMeasurement
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
MeasurementDetWithData
Definition: MeasurementDetWithData.h:6
Trajectory
Definition: Trajectory.h:38
TSCBLBuilderNoMaterial
Definition: TSCBLBuilderNoMaterial.h:13
makeMuonMisalignmentScenario.components
string components
Definition: makeMuonMisalignmentScenario.py:58
Trajectory::seed
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:263
TrajectorySeed
Definition: TrajectorySeed.h:17
DAFTrackProducerAlgorithm::fit
Trajectory fit(const std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > &hits, const TrajectoryFitter *theFitter, Trajectory vtraj) const
accomplishes the fitting-smoothing step for each annealing value
Definition: DAFTrackProducerAlgorithm.cc:214
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
TrajectoryStateClosestToBeamLine::isValid
bool isValid() const
Definition: TrajectoryStateClosestToBeamLine.h:50
heavyFlavorValidationHarvestingSequence_cff.combiner
combiner
Definition: heavyFlavorValidationHarvestingSequence_cff.py:107
TrajectoryStateClosestToBeamLine::trackStateAtPCA
FTS const & trackStateAtPCA() const
Definition: TrajectoryStateClosestToBeamLine.h:32
TrajectoryFitter::fitOne
virtual Trajectory fitOne(const Trajectory &traj, fitType type=standard) const =0
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
SiTrackerMultiRecHit
Definition: SiTrackerMultiRecHit.h:13
TrackingRecHit::isValid
bool isValid() const
Definition: TrackingRecHit.h:141
alongMomentum
Definition: PropagationDirection.h:4
weight
Definition: weight.py:1
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
Trajectory::isValid
bool isValid() const
Definition: Trajectory.h:257
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
DAFTrackProducerAlgorithm::conf_
edm::ParameterSet conf_
Definition: DAFTrackProducerAlgorithm.h:102
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37