CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 >
 

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 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

Definition at line 47 of file DAFTrackProducerAlgorithm.h.

47 {}

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 ecalcalib_dqm_sourceclient-live_cfg::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:125
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:228
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:324
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:241
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:307
TrajectoryStateOnSurface const & updatedState() const
T x() const
Definition: PV3DBase.h:62
float DAFTrackProducerAlgorithm::calculateNdof ( const Trajectory  vtraj) const
private

Definition at line 378 of file DAFTrackProducerAlgorithm.cc.

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

Referenced by runWithCandidate().

379 {
380 
381  if (!vtraj.isValid()) return 0;
382  float ndof = 0;
383  const std::vector<TrajectoryMeasurement>& meas = vtraj.measurements();
384  for (std::vector<TrajectoryMeasurement>::const_iterator iter = meas.begin(); iter != meas.end(); iter++){
385 
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(); iter2++, iComp++){
391  if ((*iter2)->isValid())
392  ndof += ((*iter2)->dimension())*mHit.weight(iComp);
393  }
394 
395  }
396  }
397 
398  return ndof-5;
399 
400 }
float weight(unsigned int i) const
DataContainer const & measurements() const
Definition: Trajectory.h:250
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
bool isValid() const
Definition: Trajectory.h:324
int DAFTrackProducerAlgorithm::checkHits ( Trajectory  iInitTraj,
const Trajectory  iFinalTraj 
) const
private

Definition at line 402 of file DAFTrackProducerAlgorithm.cc.

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

Referenced by runWithCandidate().

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

Referenced by runWithCandidate().

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

Definition at line 321 of file DAFTrackProducerAlgorithm.cc.

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

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

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

483 {
484  if (hit->isValid()){
485 
486  LogTrace("DAFTrackProducerAlgorithm") << " Valid Hit with DetId " << hit->geographicalId().rawId() << " and dim:" << hit->dimension()
487  << " local position " << hit->localPosition()
488  << " global position " << hit->globalPosition()
489  << " and r " << hit->globalPosition().perp() ;
490  if(tsos.isValid()) LogTrace("DAFTrackProducerAlgorithm") << " TSOS combtsos " << tsos.localPosition() ;
491 
492  } else {
493  LogTrace("DAFTrackProducerAlgorithm") << " Invalid Hit with DetId " << hit->geographicalId().rawId();
494  }
495 
496 }
virtual int dimension() const =0
T perp() const
Definition: PV3DBase.h:72
virtual GlobalPoint globalPosition() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
#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 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, 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().

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:279
int countingGoodHits(const Trajectory traj) const
tuple cont
load Luminosity info ##
Definition: generateEDF.py:622
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:330
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:264
const std::vector< double > & getAnnealingProgram() const
PropagationDirection const & direction() const
Definition: Trajectory.cc:125
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:324
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 heavyFlavorValidationHarvestingSequence_cff::combiner, 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:250
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().