CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
TrajectoryStateOnSurface
collectHits (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,
TrajectoryStateOnSurface
updateHits (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 in May 2014 by brondolin

Definition at line 34 of file DAFTrackProducerAlgorithm.h.

Member Typedef Documentation

Definition at line 38 of file DAFTrackProducerAlgorithm.h.

Definition at line 36 of file DAFTrackProducerAlgorithm.h.

Definition at line 37 of file DAFTrackProducerAlgorithm.h.

Definition at line 40 of file DAFTrackProducerAlgorithm.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file DAFTrackProducerAlgorithm.cc.

28  : conf_(conf), minHits_(conf.getParameter<int>("MinHits")) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DAFTrackProducerAlgorithm::~DAFTrackProducerAlgorithm ( )
inline

Definition at line 44 of file DAFTrackProducerAlgorithm.h.

44 {}

Member Function Documentation

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 229 of file DAFTrackProducerAlgorithm.cc.

References alongMomentum, 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(), findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by runWithCandidate().

233  {
234  LogDebug("DAFTrackProducerAlgorithm") << " BUILDER " << std::endl;
235  ;
236  TrajectoryStateOnSurface innertsos;
237 
238  if (vtraj.isValid()) {
239  std::unique_ptr<Trajectory> theTraj(new Trajectory(vtraj));
240 
241  if (vtraj.direction() == alongMomentum) {
242  //if (theTraj->direction() == oppositeToMomentum) {
243  innertsos = vtraj.firstMeasurement().updatedState();
244  } else {
245  innertsos = vtraj.lastMeasurement().updatedState();
246  }
247 
248  TSCBLBuilderNoMaterial tscblBuilder;
249  TrajectoryStateClosestToBeamLine tscbl = tscblBuilder(*(innertsos.freeState()), bs);
250 
251  if (tscbl.isValid() == false)
252  return false;
253 
255  math::XYZPoint pos(v.x(), v.y(), v.z());
257  math::XYZVector mom(p.x(), p.y(), p.z());
258 
259  // LogDebug("TrackProducer") <<v<<p<<std::endl;
260 
261  auto algo = (*BeforeDAFTrack)->algo();
262  std::unique_ptr<reco::Track> theTrack(new reco::Track(vtraj.chiSquared(),
263  ndof, //in the DAF the ndof is not-integer
264  pos,
265  mom,
266  tscbl.trackStateAtPCA().charge(),
268  algo));
269  theTrack->setQualityMask((*BeforeDAFTrack)->qualityMask());
270 
271  AlgoProduct aProduct{theTraj.release(), theTrack.release(), vtraj.direction(), 0};
272  algoResults.push_back(aProduct);
273 
274  return true;
275  } else {
276  LogDebug("DAFTrackProducerAlgorithm") << " BUILDER NOT POSSIBLE: traj is not valid" << std::endl;
277  ;
278  return false;
279  }
280 }
T y() const
Definition: PV3DBase.h:60
TrackCharge charge() const
const CurvilinearTrajectoryError & curvilinearError() const
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
FreeTrajectoryState const * freeState(bool withErrors=true) const
T z() const
Definition: PV3DBase.h:61
GlobalVector momentum() const
GlobalPoint position() const
bool isValid() const
Definition: Trajectory.h:257
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
float chiSquared() const
Definition: Trajectory.h:241
TrajectoryStateOnSurface const & updatedState() const
T x() const
Definition: PV3DBase.h:59
#define LogDebug(id)
float DAFTrackProducerAlgorithm::calculateNdof ( const Trajectory  vtraj) const
private

Definition at line 376 of file DAFTrackProducerAlgorithm.cc.

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

Referenced by runWithCandidate().

376  {
377  if (!vtraj.isValid())
378  return 0;
379  float ndof = 0;
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()) {
383  SiTrackerMultiRecHit const& mHit = dynamic_cast<SiTrackerMultiRecHit const&>(*iter->recHit());
384  std::vector<const TrackingRecHit*> components = mHit.recHits();
385  int iComp = 0;
386  for (std::vector<const TrackingRecHit*>::const_iterator iter2 = components.begin(); iter2 != components.end();
387  iter2++, iComp++) {
388  if ((*iter2)->isValid())
389  ndof += ((*iter2)->dimension()) * mHit.weight(iComp);
390  }
391  }
392  }
393 
394  return ndof - 5;
395 }
float weight(unsigned int i) const
DataContainer const & measurements() const
Definition: Trajectory.h:178
bool isValid() const
Definition: Trajectory.h:257
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
int DAFTrackProducerAlgorithm::checkHits ( Trajectory  iInitTraj,
const Trajectory  iFinalTraj 
) const
private

Definition at line 397 of file DAFTrackProducerAlgorithm.cc.

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

Referenced by runWithCandidate().

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

References LogDebug, nHits, and MultiRecHitCollector::recHits().

Referenced by runWithCandidate().

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 }
std::vector< ConstRecHitPointer > RecHitContainer
virtual std::vector< TrajectoryMeasurement > recHits(const Trajectory &, const MeasurementTrackerEvent *theMTE) const =0
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
#define LogDebug(id)
int DAFTrackProducerAlgorithm::countingGoodHits ( const Trajectory  traj) const
private

Definition at line 282 of file DAFTrackProducerAlgorithm.cc.

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

Referenced by runWithCandidate().

282  {
283  int ngoodhits = 0;
284  std::vector<TrajectoryMeasurement> vtm = traj.measurements();
285 
286  for (std::vector<TrajectoryMeasurement>::const_iterator tm = vtm.begin(); tm != vtm.end(); tm++) {
287  //if the rechit is valid
288  if (tm->recHit()->isValid()) {
289  SiTrackerMultiRecHit const& mHit = dynamic_cast<SiTrackerMultiRecHit const&>(*tm->recHit());
290  std::vector<const TrackingRecHit*> components = mHit.recHits();
291 
292  int iComp = 0;
293 
294  for (std::vector<const TrackingRecHit*>::const_iterator iter = components.begin(); iter != components.end();
295  iter++, iComp++) {
296  //if there is at least one component with weight higher than 1e-6 then the hit is not an outlier
297  if (mHit.weight(iComp) > 1e-6) {
298  ngoodhits++;
299  iComp++;
300  break;
301  }
302  }
303  }
304  }
305 
306  LogDebug("DAFTrackProducerAlgorithm") << "Original number of valid hits " << traj.foundHits()
307  << " -> hit with good weight (>1e-6) are " << ngoodhits;
308  return ngoodhits;
309 }
int foundHits() const
Definition: Trajectory.h:206
float weight(unsigned int i) const
DataContainer const & measurements() const
Definition: Trajectory.h:178
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
#define LogDebug(id)
void DAFTrackProducerAlgorithm::filter ( const TrajectoryFitter fitter,
std::vector< Trajectory > &  input,
int  minhits,
std::vector< Trajectory > &  output,
const TransientTrackingRecHitBuilder builder 
) const
private

Definition at line 312 of file DAFTrackProducerAlgorithm.cc.

References makeMuonMisalignmentScenario::components, runTheMatrix::const, alignCSCRings::e, TrajectoryFitter::fit(), LogDebug, TkClonerImpl::makeShared(), TrackingRecHit::missing, SiTrackerMultiRecHit::recHits(), and SiTrackerMultiRecHit::weight().

316  {
317  if (input.empty())
318  return;
319 
320  int ngoodhits = 0;
321  std::vector<TrajectoryMeasurement> vtm = input[0].measurements();
323 
324  //count the number of non-outlier and non-invalid hits
325  for (std::vector<TrajectoryMeasurement>::reverse_iterator tm = vtm.rbegin(); tm != vtm.rend(); tm++) {
326  //if the rechit is valid
327  if (tm->recHit()->isValid()) {
328  SiTrackerMultiRecHit const& mHit = dynamic_cast<SiTrackerMultiRecHit const&>(*tm->recHit());
329  std::vector<const TrackingRecHit*> components = mHit.recHits();
330  int iComp = 0;
331  bool isGood = false;
332  for (std::vector<const TrackingRecHit*>::const_iterator iter = components.begin(); iter != components.end();
333  iter++, iComp++) {
334  //if there is at least one component with weight higher than 1e-6 then the hit is not an outlier
335  if (mHit.weight(iComp) > 1e-6) {
336  ngoodhits++;
337  iComp++;
338  isGood = true;
339  break;
340  }
341  }
342  if (isGood) {
343  TkClonerImpl hc = static_cast<TkTransientTrackingRecHitBuilder const*>(builder)->cloner();
344  auto tempHit = hc.makeShared(tm->recHit(), tm->updatedState());
345  hits.push_back(tempHit);
346  } else
347  hits.push_back(std::make_shared<InvalidTrackingRecHit>(*tm->recHit()->det(), TrackingRecHit::missing));
348  } else {
349  TkClonerImpl hc = static_cast<TkTransientTrackingRecHitBuilder const*>(builder)->cloner();
350  auto tempHit = hc.makeShared(tm->recHit(), tm->updatedState());
351  hits.push_back(tempHit);
352  }
353  }
354 
355  LogDebug("DAFTrackProducerAlgorithm") << "Original number of valid hits " << input[0].foundHits()
356  << "; after filtering " << ngoodhits;
357  if (ngoodhits > input[0].foundHits())
358  edm::LogError("DAFTrackProducerAlgorithm")
359  << "Something wrong: the number of good hits from DAFTrackProducerAlgorithm::filter " << ngoodhits
360  << " is higher than the original one " << input[0].foundHits();
361 
362  if (ngoodhits < minhits)
363  return;
364 
365  TrajectoryStateOnSurface curstartingTSOS = input.front().lastMeasurement().updatedState();
366  LogDebug("DAFTrackProducerAlgorithm") << "starting tsos for final refitting " << curstartingTSOS;
367  //curstartingTSOS.rescaleError(100);
368 
369  output = fitter->fit(TrajectorySeed({}, {}, input.front().seed().direction()),
370  hits,
371  TrajectoryStateWithArbitraryError()(curstartingTSOS));
372 
373  LogDebug("DAFTrackProducerAlgorithm") << "After filtering " << output.size() << " trajectories";
374 }
std::vector< ConstRecHitPointer > RecHitContainer
Log< level::Error, false > LogError
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:64
float weight(unsigned int i) const
static std::string const input
Definition: EdmProvDump.cc:47
std::vector< Trajectory > fit(const Trajectory &traj, fitType type=standard) const
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
#define LogDebug(id)
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.

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

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

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(TrajectorySeed({}, {}, vtraj.seed().direction()), hits.first, hits.second);
220 
221  if (newVec.isValid())
222  return newVec;
223  else {
224  LogDebug("DAFTrackProducerAlgorithm") << "Fit no valid.";
225  return Trajectory();
226  }
227 }
PropagationDirection direction() const
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:263
virtual Trajectory fitOne(const Trajectory &traj, fitType type=standard) const =0
bool isValid() const
Definition: Trajectory.h:257
#define LogDebug(id)
void DAFTrackProducerAlgorithm::PrintHit ( const TrackingRecHit *const &  hit,
TrajectoryStateOnSurface tsos 
) const
private

Definition at line 474 of file DAFTrackProducerAlgorithm.cc.

References TrackingRecHit::dimension(), TrackingRecHit::geographicalId(), TrackingRecHit::globalPosition(), TrajectoryStateOnSurface::isValid(), TrackingRecHit::isValid(), TrajectoryStateOnSurface::localPosition(), TrackingRecHit::localPosition(), LogTrace, PV3DBase< T, PVType, FrameType >::perp(), and DetId::rawId().

Referenced by checkHits(), and updateHits().

474  {
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();
480  if (tsos.isValid())
481  LogTrace("DAFTrackProducerAlgorithm") << " TSOS combtsos " << tsos.localPosition();
482 
483  } else {
484  LogTrace("DAFTrackProducerAlgorithm") << " Invalid Hit with DetId " << hit->geographicalId().rawId();
485  }
486 }
virtual int dimension() const =0
T perp() const
Definition: PV3DBase.h:69
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
virtual GlobalPoint globalPosition() const
#define LogTrace(id)
bool isValid() const
DetId geographicalId() const
virtual LocalPoint localPosition() const =0
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.

References edm::AssociationMap< Tag >::begin(), buildTrack(), calculateNdof(), checkHits(), collectHits(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, generateEDF::cont, countingGoodHits(), TrajectorySeed::direction(), Trajectory::direction(), edm::AssociationMap< Tag >::end(), fit(), Trajectory::foundHits(), SiTrackerMultiRecHitUpdator::getAnnealingProgram(), Trajectory::isValid(), edm::Ref< C, T, F >::key(), LogDebug, minHits_, ndof, convertSQLiteXML::ok, Trajectory::seed(), edm::AssociationMap< Tag >::size(), groupFilesInBlocks::temp, and updateHits().

Referenced by DAFTrackProducer::produce().

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 }
PropagationDirection direction() const
int foundHits() const
Definition: Trajectory.h:206
int countingGoodHits(const Trajectory traj) const
tuple cont
load Luminosity info ##
Definition: generateEDF.py:628
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:263
const_iterator end() const
last iterator over the map (read only)
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > updateHits(const Trajectory vtraj, const SiTrackerMultiRecHitUpdator *updator, const MeasurementTrackerEvent *theMTE, double annealing) const
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.
Definition: Ref.h:250
const std::vector< double > & getAnnealingProgram() const
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
Trajectory fit(const std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > &hits, const TrajectoryFitter *theFitter, Trajectory vtraj) const
accomplishes the fitting-smoothing step for each annealing value
bool isValid() const
Definition: Trajectory.h:257
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > collectHits(const Trajectory vtraj, const MultiRecHitCollector *measurementCollector, const MeasurementTrackerEvent *measTk) const
size_type size() const
map size
float calculateNdof(const Trajectory vtraj) const
const_iterator begin() const
first iterator over the map (read only)
#define LogDebug(id)
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.

References heavyFlavorValidationHarvestingSequence_cff::combiner, hitcounter, MeasurementTrackerEvent::idToDet(), LogDebug, Trajectory::measurements(), PrintHit(), and SiTrackerMultiRecHitUpdator::update().

Referenced by runWithCandidate().

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 }
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
std::vector< ConstRecHitPointer > RecHitContainer
DataContainer const & measurements() const
Definition: Trajectory.h:178
void PrintHit(const TrackingRecHit *const &hit, TrajectoryStateOnSurface &tsos) const
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: DetId.h:17
virtual TransientTrackingRecHit::RecHitPointer update(TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const
#define LogDebug(id)

Member Data Documentation

edm::ParameterSet DAFTrackProducerAlgorithm::conf_
private

Definition at line 102 of file DAFTrackProducerAlgorithm.h.

int DAFTrackProducerAlgorithm::minHits_
private

Definition at line 103 of file DAFTrackProducerAlgorithm.h.

Referenced by runWithCandidate().