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 in May 2014 by brondolin

Definition at line 36 of file DAFTrackProducerAlgorithm.h.

Member Typedef Documentation

Definition at line 40 of file DAFTrackProducerAlgorithm.h.

Definition at line 38 of file DAFTrackProducerAlgorithm.h.

Definition at line 39 of file DAFTrackProducerAlgorithm.h.

Definition at line 42 of file DAFTrackProducerAlgorithm.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file DAFTrackProducerAlgorithm.cc.

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

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

References patPFMETCorrections_cff::algo, 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().

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

Definition at line 377 of file DAFTrackProducerAlgorithm.cc.

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

Referenced by runWithCandidate().

378 {
379 
380  if (!vtraj.isValid()) return 0;
381  float ndof = 0;
382  const std::vector<TrajectoryMeasurement>& meas = vtraj.measurements();
383  for (std::vector<TrajectoryMeasurement>::const_iterator iter = meas.begin(); iter != meas.end(); iter++){
384 
385  if (iter->recHit()->isValid()){
386  SiTrackerMultiRecHit const & mHit = dynamic_cast<SiTrackerMultiRecHit const &>(*iter->recHit());
387  std::vector<const TrackingRecHit*> components = mHit.recHits();
388  int iComp = 0;
389  for(std::vector<const TrackingRecHit*>::const_iterator iter2 = components.begin(); iter2 != components.end(); iter2++, iComp++){
390  if ((*iter2)->isValid())
391  ndof += ((*iter2)->dimension())*mHit.weight(iComp);
392  }
393 
394  }
395  }
396 
397  return ndof-5;
398 
399 }
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
float weight(unsigned int i) const
DataContainer const & measurements() const
Definition: Trajectory.h:196
bool isValid() const
Definition: Trajectory.h:279
int DAFTrackProducerAlgorithm::checkHits ( Trajectory  iInitTraj,
const Trajectory  iFinalTraj 
) const
private

Definition at line 401 of file DAFTrackProducerAlgorithm.cc.

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().

401  {
402 
403  std::vector<TrajectoryMeasurement> initmeasurements = iInitTraj.measurements();
404  std::vector<TrajectoryMeasurement> finalmeasurements = iFinalTraj.measurements();
405  std::vector<TrajectoryMeasurement>::iterator jmeas;
406  int nSame = 0;
407  int ihit = 0;
408 
409  if( initmeasurements.empty() || finalmeasurements.empty() ){
410  LogDebug("DAFTrackProducerAlgorithm") << "Initial or Final Trajectory empty.";
411  return 0;
412  }
413 
414  if( initmeasurements.size() != finalmeasurements.size() ) {
415  LogDebug("DAFTrackProducerAlgorithm") << "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 
422  const TrackingRecHit* initHit = jmeas->recHit()->hit();
423  if(!initHit->isValid() && ihit == 0 ) continue;
424 
425  if(initHit->isValid()){
426 
427  TrajectoryMeasurement imeas = finalmeasurements.at(ihit);
428  const TrackingRecHit* finalHit = imeas.recHit()->hit();
429  const TrackingRecHit* MaxWeightHit=nullptr;
430  float maxweight = 0;
431 
432  const SiTrackerMultiRecHit* mrh = dynamic_cast<const SiTrackerMultiRecHit*>(finalHit);
433  if (mrh){
434  std::vector<const TrackingRecHit*> components = mrh->recHits();
435  std::vector<const TrackingRecHit*>::const_iterator icomp;
436  int hitcounter=0;
437 
438  for (icomp = components.begin(); icomp != components.end(); icomp++) {
439  if((*icomp)->isValid()) {
440  double weight = mrh->weight(hitcounter);
441  if(weight > maxweight) {
442  MaxWeightHit = *icomp;
443  maxweight = weight;
444  }
445  }
446  hitcounter++;
447  }
448  if(!MaxWeightHit) 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 
466  TrajectoryMeasurement imeas = finalmeasurements.at(ihit);
467  const TrackingRecHit* finalHit = imeas.recHit()->hit();
468  if(!finalHit->isValid()){
469  nSame++;
470  }
471  }
472 
473  ihit++;
474  }
475 
476  return nSame;
477 }
#define LogDebug(id)
ConstRecHitPointer const & recHit() const
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: weight.py:1
float weight(unsigned int i) const
DataContainer const & measurements() const
Definition: Trajectory.h:196
void PrintHit(const TrackingRecHit *const &hit, TrajectoryStateOnSurface &tsos) const
#define LogTrace(id)
virtual TrackingRecHit const * hit() const
bool isValid() const
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > DAFTrackProducerAlgorithm::collectHits ( const Trajectory  vtraj,
const MultiRecHitCollector measurementCollector,
const MeasurementTrackerEvent measTk 
) const
private

Definition at line 139 of file DAFTrackProducerAlgorithm.cc.

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

Referenced by runWithCandidate().

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

Definition at line 289 of file DAFTrackProducerAlgorithm.cc.

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

Referenced by runWithCandidate().

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

Definition at line 320 of file DAFTrackProducerAlgorithm.cc.

References makeMuonMisalignmentScenario::components, MillePedeFileConverter_cfg::e, TrajectoryFitter::fit(), edm::OwnVector< T, P >::front(), AnalysisDataFormats_SUSYBSMObjects::hc, hfClusterShapes_cfi::hits, LogDebug, TkClonerImpl::makeShared(), TrackingRecHit::missing, SiTrackerMultiRecHit::recHits(), and SiTrackerMultiRecHit::weight().

323 {
324  if (input.empty()) return;
325 
326  int ngoodhits = 0;
327  std::vector<TrajectoryMeasurement> vtm = input[0].measurements();
329 
330  //count the number of non-outlier and non-invalid hits
331  for (std::vector<TrajectoryMeasurement>::reverse_iterator tm=vtm.rbegin(); tm!=vtm.rend();tm++){
332  //if the rechit is valid
333  if (tm->recHit()->isValid()) {
334  SiTrackerMultiRecHit const & mHit = dynamic_cast<SiTrackerMultiRecHit const &>(*tm->recHit());
335  std::vector<const TrackingRecHit*> components = mHit.recHits();
336  int iComp = 0;
337  bool isGood = false;
338  for(std::vector<const TrackingRecHit*>::const_iterator iter = components.begin(); iter != components.end(); iter++, iComp++){
339  //if there is at least one component with weight higher than 1e-6 then the hit is not an outlier
340  if (mHit.weight(iComp)>1e-6) {ngoodhits++; iComp++; isGood = true; break;}
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  }
347  else 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 
356  LogDebug("DAFTrackProducerAlgorithm") << "Original number of valid hits " << input[0].foundHits() << "; after filtering " << ngoodhits;
357  if (ngoodhits>input[0].foundHits())
358  edm::LogError("DAFTrackProducerAlgorithm") << "Something wrong: the number of good hits from DAFTrackProducerAlgorithm::filter "
359  << ngoodhits << " is higher than the original one " << input[0].foundHits();
360 
361  if (ngoodhits < minhits) return;
362 
363  TrajectoryStateOnSurface curstartingTSOS = input.front().lastMeasurement().updatedState();
364  LogDebug("DAFTrackProducerAlgorithm") << "starting tsos for final refitting " << curstartingTSOS ;
365  //curstartingTSOS.rescaleError(100);
366 
369  input.front().seed().direction()),
370  hits,
371  TrajectoryStateWithArbitraryError()(curstartingTSOS));
372 
373  LogDebug("DAFTrackProducerAlgorithm") << "After filtering " << output.size() << " trajectories";
374 
375 }
#define LogDebug(id)
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
std::vector< ConstRecHitPointer > RecHitContainer
float weight(unsigned int i) const
static std::string const input
Definition: EdmProvDump.cc:44
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:57
susybsm::HSCParticleCollection hc
Definition: classes.h:25
std::vector< Trajectory > fit(const Trajectory &traj, fitType type=standard) const
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 220 of file DAFTrackProducerAlgorithm.cc.

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

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

223  {
224 
225  //creating a new trajectory starting from the direction of the seed of the input one and the hits
228  vtraj.seed().direction()),
229  hits.first, hits.second);
230 
231  if( newVec.isValid() ) return newVec;
232  else{
233  LogDebug("DAFTrackProducerAlgorithm") << "Fit no valid.";
234  return Trajectory();
235  }
236 
237 }
#define LogDebug(id)
PropagationDirection direction() const
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:285
virtual Trajectory fitOne(const Trajectory &traj, fitType type=standard) const =0
bool isValid() const
Definition: Trajectory.h:279
void DAFTrackProducerAlgorithm::PrintHit ( const TrackingRecHit *const &  hit,
TrajectoryStateOnSurface tsos 
) const
private

Definition at line 481 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().

482 {
483  if (hit->isValid()){
484 
485  LogTrace("DAFTrackProducerAlgorithm") << " Valid Hit with DetId " << hit->geographicalId().rawId() << " and dim:" << hit->dimension()
486  << " local position " << hit->localPosition()
487  << " global position " << hit->globalPosition()
488  << " and r " << hit->globalPosition().perp() ;
489  if(tsos.isValid()) LogTrace("DAFTrackProducerAlgorithm") << " TSOS combtsos " << tsos.localPosition() ;
490 
491  } else {
492  LogTrace("DAFTrackProducerAlgorithm") << " Invalid Hit with DetId " << hit->geographicalId().rawId();
493  }
494 
495 }
T perp() const
Definition: PV3DBase.h:72
virtual GlobalPoint globalPosition() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
virtual int dimension() const =0
virtual LocalPoint localPosition() const =0
#define LogTrace(id)
bool isValid() const
DetId geographicalId() const
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 33 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, countingGoodHits(), TrajectorySeed::direction(), Trajectory::direction(), edm::AssociationMap< Tag >::end(), fit(), Trajectory::foundHits(), SiTrackerMultiRecHitUpdator::getAnnealingProgram(), hfClusterShapes_cfi::hits, 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().

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

Definition at line 179 of file DAFTrackProducerAlgorithm.cc.

References hfClusterShapes_cfi::hits, MeasurementTrackerEvent::idToDet(), LogDebug, Trajectory::measurements(), PrintHit(), and SiTrackerMultiRecHitUpdator::update().

Referenced by runWithCandidate().

183 {
184  LogDebug("DAFTrackProducerAlgorithm") << "Calling DAFTrackProducerAlgorithm::updateHits";
186  std::vector<TrajectoryMeasurement> vmeas = vtraj.measurements();
187  std::vector<TrajectoryMeasurement>::reverse_iterator imeas;
188  unsigned int hitcounter = 1;
189 
190  //I run inversely on the trajectory obtained and update the state
191  for (imeas = vmeas.rbegin(); imeas != vmeas.rend(); imeas++, hitcounter++){
192 
193  DetId id = imeas->recHit()->geographicalId();
194  MeasurementDetWithData measDet = theMTE->idToDet(id);
195 
197  TrajectoryStateOnSurface combtsos;
198  if (hitcounter == vmeas.size()) combtsos = imeas->predictedState(); //fwd
199  else if (hitcounter == 1) combtsos = imeas->backwardPredictedState(); //bwd
200  else combtsos = combiner(imeas->backwardPredictedState(), imeas->predictedState());
201 
202  PrintHit(&*imeas->recHit(), combtsos);
203  if(imeas->recHit()->isValid()){
204  TransientTrackingRecHit::RecHitPointer updated = updator->update(imeas->recHit(),
205  combtsos, measDet, annealing);
206  hits.push_back(updated);
207  } else {
208  hits.push_back(imeas->recHit());
209  }
210  }
211 
212  TrajectoryStateOnSurface updatedStateFromTrack = vmeas.back().predictedState();
213 
214  //return std::make_pair(hits,TrajectoryStateWithArbitraryError()(vmeas.back().updatedState()));
215  LogDebug("DAFTrackProducerAlgorithm") << "Pair (hits, TSOS) with TSOS predicted (vmeas.back().predictedState())";
216 
217  return std::make_pair(hits,updatedStateFromTrack);
218 }
#define LogDebug(id)
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
std::vector< ConstRecHitPointer > RecHitContainer
DataContainer const & measurements() const
Definition: Trajectory.h:196
void PrintHit(const TrackingRecHit *const &hit, TrajectoryStateOnSurface &tsos) const
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: DetId.h:18
virtual TransientTrackingRecHit::RecHitPointer update(TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const

Member Data Documentation

edm::ParameterSet DAFTrackProducerAlgorithm::conf_
private

Definition at line 108 of file DAFTrackProducerAlgorithm.h.

int DAFTrackProducerAlgorithm::minHits_
private

Definition at line 109 of file DAFTrackProducerAlgorithm.h.

Referenced by runWithCandidate().