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
SiTrackerMultiRecHitUpdator Class Reference

#include <SiTrackerMultiRecHitUpdator.h>

Public Types

typedef std::pair< LocalPoint,
LocalError
LocalParameters
 

Public Member Functions

const std::vector< double > & annealingProgram () const
 
virtual
TransientTrackingRecHit::RecHitPointer 
buildMultiRecHit (const std::vector< const TrackingRecHit * > &rhv, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, float annealing=1.) const
 
double ComputeWeight (const TrajectoryStateOnSurface &tsos, const TransientTrackingRecHit &aRecHit, bool CutWeight, double annealing=1.) const
 
template<unsigned int N>
double ComputeWeight (const TrajectoryStateOnSurface &tsos, const TransientTrackingRecHit &aRecHit, bool CutWeight, double annealing=1.) const
 
const std::vector< double > & getAnnealingProgram () const
 
const
TransientTrackingRecHitBuilder
getBuilder () const
 
 SiTrackerMultiRecHitUpdator (const TransientTrackingRecHitBuilder *builder, const TrackingRecHitPropagator *hitpropagator, const float Chi2Cut1D, const float Chi2Cut2D, const std::vector< double > &anAnnealingProgram, bool debug)
 
virtual
TransientTrackingRecHit::RecHitPointer 
update (TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const
 
TransientTrackingRecHit::RecHitPointer update (TransientTrackingRecHit::ConstRecHitContainer &tcomponents, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const
 
virtual ~SiTrackerMultiRecHitUpdator ()
 

Private Member Functions

LocalParameters calcParameters (const TrajectoryStateOnSurface &tsos, std::vector< std::pair< const TrackingRecHit *, float > > &aHitMap) const
 
template<unsigned int N>
LocalParameters calcParameters (const TrajectoryStateOnSurface &tsos, std::vector< std::pair< const TrackingRecHit *, float > > &aHitMap) const
 
bool TIDorTEChit (const TrackingRecHit *const &hit) const
 

Private Attributes

bool debug_
 
const std::vector< double > theAnnealingProgram
 
const
TransientTrackingRecHitBuilder
theBuilder
 
double theChi2Cut1D
 
double theChi2Cut2D
 
TkClonerImpl theHitCloner
 
const TrackingRecHitPropagatortheHitPropagator
 

Detailed Description

Builds a SiTrackerMultiRecHit out of a vector of TrackingRecHit or updates an existing SiTrackerMultiRecHit given a tsos.

Author
tropiano, genta in May 2014 by brondolin

Definition at line 27 of file SiTrackerMultiRecHitUpdator.h.

Member Typedef Documentation

Definition at line 29 of file SiTrackerMultiRecHitUpdator.h.

Constructor & Destructor Documentation

SiTrackerMultiRecHitUpdator::SiTrackerMultiRecHitUpdator ( const TransientTrackingRecHitBuilder builder,
const TrackingRecHitPropagator hitpropagator,
const float  Chi2Cut1D,
const float  Chi2Cut2D,
const std::vector< double > &  anAnnealingProgram,
bool  debug 
)

Definition at line 17 of file SiTrackerMultiRecHitUpdator.cc.

References runTheMatrix::const, and theHitCloner.

23  : theBuilder(builder),
24  theHitPropagator(hitpropagator),
25  theChi2Cut1D(Chi2Cut1D),
26  theChi2Cut2D(Chi2Cut2D),
27  theAnnealingProgram(anAnnealingProgram),
28  debug_(debug) {
29  theHitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(builder)->cloner();
30 }
const std::vector< double > theAnnealingProgram
const TrackingRecHitPropagator * theHitPropagator
const TransientTrackingRecHitBuilder * theBuilder
#define debug
Definition: HDRShower.cc:19
virtual SiTrackerMultiRecHitUpdator::~SiTrackerMultiRecHitUpdator ( )
inlinevirtual

Definition at line 36 of file SiTrackerMultiRecHitUpdator.h.

36 {};

Member Function Documentation

const std::vector<double>& SiTrackerMultiRecHitUpdator::annealingProgram ( ) const
inline

Definition at line 68 of file SiTrackerMultiRecHitUpdator.h.

References theAnnealingProgram.

68 { return theAnnealingProgram; }
const std::vector< double > theAnnealingProgram
TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::buildMultiRecHit ( const std::vector< const TrackingRecHit * > &  rhv,
const TrajectoryStateOnSurface tsos,
MeasurementDetWithData measDet,
float  annealing = 1. 
) const
virtual

Definition at line 32 of file SiTrackerMultiRecHitUpdator.cc.

References TransientTrackingRecHitBuilder::build(), LogTrace, theBuilder, and update().

36  {
37  LogTrace("SiTrackerMultiRecHitUpdator")
38  << "Calling SiTrackerMultiRecHitUpdator::buildMultiRecHit with AnnealingFactor: " << annealing;
39 
41  for (std::vector<const TrackingRecHit*>::const_iterator iter = rhv.begin(); iter != rhv.end(); iter++) {
43  if (transient->isValid())
44  tcomponents.push_back(transient);
45  }
46  return update(tcomponents, tsos, measDet, annealing);
47 }
#define LogTrace(id)
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
const TransientTrackingRecHitBuilder * theBuilder
std::shared_ptr< TrackingRecHit const > RecHitPointer
std::vector< ConstRecHitPointer > ConstRecHitContainer
virtual TransientTrackingRecHit::RecHitPointer update(TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const
SiTrackerMultiRecHitUpdator::LocalParameters SiTrackerMultiRecHitUpdator::calcParameters ( const TrajectoryStateOnSurface tsos,
std::vector< std::pair< const TrackingRecHit *, float > > &  aHitMap 
) const
private

Definition at line 298 of file SiTrackerMultiRecHitUpdator.cc.

References Exception, first, LogTrace, and mergeVDriftHistosByStation::name.

Referenced by update().

299  {
300  //supposing all the hits inside of a MRH have the same dimension
301  LogTrace("SiTrackerMultiRecHitUpdator")
302  << "SiTrackerMultiRecHitUpdator::LocalParameters: dim first recHit: " << aHitMap[0].first->dimension()
303  << std::endl;
304  switch (aHitMap[0].first->dimension()) {
305  case 1:
306  return calcParameters<1>(tsos, aHitMap);
307  case 2:
308  return calcParameters<2>(tsos, aHitMap);
309  }
310  throw cms::Exception("Rec hit of invalid dimension for computing MRH (not 1,2)")
311  << "The value was " << aHitMap[0].first->dimension() << ", type is " << typeid(aHitMap[0].first).name() << "\n";
312 }
#define LogTrace(id)
template<unsigned int N>
LocalParameters SiTrackerMultiRecHitUpdator::calcParameters ( const TrajectoryStateOnSurface tsos,
std::vector< std::pair< const TrackingRecHit *, float > > &  aHitMap 
) const
private
double SiTrackerMultiRecHitUpdator::ComputeWeight ( const TrajectoryStateOnSurface tsos,
const TransientTrackingRecHit aRecHit,
bool  CutWeight,
double  annealing = 1. 
) const

Definition at line 193 of file SiTrackerMultiRecHitUpdator.cc.

References TrackingRecHit::dimension(), Exception, and mergeVDriftHistosByStation::name.

Referenced by update().

196  {
197  switch (aRecHit.dimension()) {
198  case 1:
199  return ComputeWeight<1>(tsos, aRecHit, CutWeight, annealing);
200  case 2:
201  return ComputeWeight<2>(tsos, aRecHit, CutWeight, annealing);
202  case 3:
203  return ComputeWeight<3>(tsos, aRecHit, CutWeight, annealing);
204  case 4:
205  return ComputeWeight<4>(tsos, aRecHit, CutWeight, annealing);
206  case 5:
207  return ComputeWeight<5>(tsos, aRecHit, CutWeight, annealing);
208  }
209  throw cms::Exception("Rec hit of invalid dimension (not 1,2,3,4,5)")
210  << "The value was " << aRecHit.dimension() << ", type is " << typeid(aRecHit).name() << "\n";
211 }
virtual int dimension() const =0
template<unsigned int N>
double SiTrackerMultiRecHitUpdator::ComputeWeight ( const TrajectoryStateOnSurface tsos,
const TransientTrackingRecHit aRecHit,
bool  CutWeight,
double  annealing = 1. 
) const
const std::vector<double>& SiTrackerMultiRecHitUpdator::getAnnealingProgram ( ) const
inline

Definition at line 69 of file SiTrackerMultiRecHitUpdator.h.

References theAnnealingProgram.

Referenced by DAFTrackProducerAlgorithm::runWithCandidate().

69 { return theAnnealingProgram; }
const std::vector< double > theAnnealingProgram
const TransientTrackingRecHitBuilder* SiTrackerMultiRecHitUpdator::getBuilder ( ) const
inline

Definition at line 71 of file SiTrackerMultiRecHitUpdator.h.

References theBuilder.

Referenced by SimpleDAFHitCollector::SimpleDAFHitCollector().

71 { return theBuilder; }
const TransientTrackingRecHitBuilder * theBuilder
bool SiTrackerMultiRecHitUpdator::TIDorTEChit ( const TrackingRecHit *const &  hit) const
private

Definition at line 387 of file SiTrackerMultiRecHitUpdator.cc.

References DetId::det(), TrackingRecHit::geographicalId(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TID, and DetId::Tracker.

387  {
388  DetId hitId = hit->geographicalId();
389 
390  if (hitId.det() == DetId::Tracker &&
391  (hitId.subdetId() == StripSubdetector::TEC || hitId.subdetId() == StripSubdetector::TID)) {
392  return true;
393  }
394 
395  return false;
396 }
static constexpr auto TEC
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
DetId geographicalId() const
static constexpr auto TID
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::update ( TransientTrackingRecHit::ConstRecHitPointer  original,
const TrajectoryStateOnSurface tsos,
MeasurementDetWithData measDet,
double  annealing = 1. 
) const
virtual

Definition at line 49 of file SiTrackerMultiRecHitUpdator.cc.

References Exception, TrajectoryStateOnSurface::isValid(), LogTrace, TkClonerImpl::makeShared(), and theHitCloner.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), buildMultiRecHit(), progressbar.ProgressBar::finish(), MatrixUtil.Steps::overwrite(), and DAFTrackProducerAlgorithm::updateHits().

53  {
54  LogTrace("SiTrackerMultiRecHitUpdator")
55  << "Calling SiTrackerMultiRecHitUpdator::update with AnnealingFactor: " << annealing;
56 
57  if (!tsos.isValid()) {
58  //return original->clone();
59  throw cms::Exception("SiTrackerMultiRecHitUpdator") << "!!! MultiRecHitUpdator::update(..): tsos NOT valid!!! ";
60  }
61 
62  //check if to clone is the right thing
63  if (original->isValid()) {
64  if (original->transientHits().empty()) {
65  return theHitCloner.makeShared(original, tsos);
66  }
67  } else {
68  return theHitCloner.makeShared(original, tsos);
69  }
70 
71  TransientTrackingRecHit::ConstRecHitContainer tcomponents = original->transientHits();
72  return update(tcomponents, tsos, measDet, annealing);
73 }
list original
Definition: definitions.py:57
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:64
#define LogTrace(id)
std::vector< ConstRecHitPointer > ConstRecHitContainer
virtual TransientTrackingRecHit::RecHitPointer update(TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const
TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::update ( TransientTrackingRecHit::ConstRecHitContainer tcomponents,
const TrajectoryStateOnSurface tsos,
MeasurementDetWithData measDet,
double  annealing = 1. 
) const

Definition at line 76 of file SiTrackerMultiRecHitUpdator.cc.

References calcParameters(), cropTnPTrees::cloned, ComputeWeight(), counter, alignCSCRings::e, Exception, first, MeasurementDet::geomDet(), invalid, TrajectoryStateOnSurface::isValid(), LogTrace, TkClonerImpl::makeShared(), MeasurementDetWithData::mdet(), TrackingRecHit::missing, mergeVDriftHistosByStation::name, AlCaHLTBitMon_ParallelJobs::p, GloballyPositioned< T >::position(), TrackingRecHitPropagator::project(), edm::second(), TrajectoryStateOnSurface::surface(), theBuilder, theHitCloner, theHitPropagator, and createJobs::tmp.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

80  {
81  if (tcomponents.empty()) {
82  LogTrace("SiTrackerMultiRecHitUpdator") << "Empty components vector passed to SiTrackerMultiRecHitUpdator::update, "
83  "returning an InvalidTransientRecHit ";
84  return std::make_shared<InvalidTrackingRecHit>(measDet.mdet().geomDet(), TrackingRecHit::missing);
85  }
86 
87  if (!tsos.isValid()) {
88  LogTrace("SiTrackerMultiRecHitUpdator")
89  << "SiTrackerMultiRecHitUpdator::update: tsos NOT valid!!!, returning an InvalidTransientRecHit";
90  return std::make_shared<InvalidTrackingRecHit>(measDet.mdet().geomDet(), TrackingRecHit::missing);
91  }
92 
93  std::vector<TransientTrackingRecHit::RecHitPointer> updatedcomponents;
94  const GeomDet* geomdet = nullptr;
95 
96  //running on all over the MRH components
97  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator iter = tcomponents.begin();
98  iter != tcomponents.end();
99  iter++) {
100  //the first rechit must belong to the same surface of TSOS
101  if (iter == tcomponents.begin()) {
102  if (&((*iter)->det()->surface()) != &(tsos.surface())) {
103  throw cms::Exception("SiTrackerMultiRecHitUpdator")
104  << "the Trajectory state and the first rechit "
105  "passed to the SiTrackerMultiRecHitUpdator lay on different surfaces!: state lays on surface "
106  << tsos.surface().position() << " hit with detid " << (*iter)->det()->geographicalId().rawId()
107  << " lays on surface " << (*iter)->det()->surface().position();
108  }
109 
110  geomdet = (*iter)->det();
111  }
112 
113  //if the rechit does not belong to the surface of the tsos
114  //GenericProjectedRecHit2D is used to prepagate
115  if (&((*iter)->det()->surface()) != &(tsos.surface())) {
118  //if it is used a sensor by sensor grouping this should not appear
119  if (cloned->isValid())
120  updatedcomponents.push_back(cloned);
121 
122  } else {
124  if (cloned->isValid()) {
125  updatedcomponents.push_back(cloned);
126  }
127  }
128  }
129 
130  std::vector<std::pair<const TrackingRecHit*, float> > mymap;
131  std::vector<std::pair<const TrackingRecHit*, float> > normmap;
132 
133  double a_sum = 0, c_sum = 0;
134 
135  for (std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin();
136  ihit != updatedcomponents.end();
137  ihit++) {
138  double a_i = ComputeWeight(tsos, *(*ihit), false, annealing); //exp(-0.5*Chi2)
139  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t a_i:" << a_i;
140  //double c_i = ComputeWeight(tsos, *(*ihit), true, annealing); //exp(-0.5*theChi2Cut/annealing)/(2.*M_PI*sqrt(det));
141  //LogTrace("SiTrackerMultiRecHitUpdator")<< "\t\t c_i:" << c_i ;
142  mymap.push_back(std::pair<const TrackingRecHit*, float>((*ihit)->hit(), a_i));
143 
144  a_sum += a_i;
145  //with the new definition, the cut weight is computed only once
146  if (ihit == updatedcomponents.begin())
147  c_sum = ComputeWeight(tsos, *(*ihit), true, annealing); //exp(-0.5*theChi2Cut/annealing)
148  }
149  double total_sum = a_sum + c_sum;
150  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t c_sum:" << c_sum;
151  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t total sum:" << total_sum;
152 
153  unsigned int counter = 0;
154  bool invalid = true;
155  for (std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin();
156  ihit != updatedcomponents.end();
157  ihit++) {
158  double p = ((mymap[counter].second) / total_sum > 1.e-12 ? (mymap[counter].second) / total_sum : 1.e-12);
159  //ORCA: float p = ((mymap[counter].second)/total_sum > 0.01 ? (mymap[counter].second)/total_sum : 1.e-6);
160 
161 #ifdef EDM_ML_DEBUG
162  auto const& tmp = *mymap[counter].first;
163  LogTrace("SiTrackerMultiRecHitUpdator")
164  << " Component hit type " << typeid(tmp).name() << " and dim:" << tmp.dimension() << " position (PRECISE!!!)"
165  << tmp.localPosition() << " error " << tmp.localPositionError() << " with weight " << p;
166 #endif
167 
168  if (p > 10e-6) {
169  invalid = false;
170  normmap.push_back(std::pair<const TrackingRecHit*, float>(mymap[counter].first, p));
171  }
172 
173  counter++;
174  }
175 
176  if (!invalid) {
178  SiTrackerMultiRecHit updated(param.first, param.second, *normmap.front().first->det(), normmap, annealing);
179  LogTrace("SiTrackerMultiRecHitUpdator") << " Updated Hit position " << updated.localPosition() << " updated error "
180  << updated.localPositionError() << std::endl;
181 
182  return std::make_shared<SiTrackerMultiRecHit>(
183  param.first, param.second, *normmap.front().first->det(), normmap, annealing);
184 
185  } else {
186  LogTrace("SiTrackerMultiRecHitUpdator")
187  << " No hits with weight (> 10e-6) have been found for this MRH." << std::endl;
188  return std::make_shared<InvalidTrackingRecHit>(measDet.mdet().geomDet(), TrackingRecHit::missing);
189  }
190 }
virtual const GeomDet & geomDet() const
double ComputeWeight(const TrajectoryStateOnSurface &tsos, const TransientTrackingRecHit &aRecHit, bool CutWeight, double annealing=1.) const
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:64
const TrackingRecHitPropagator * theHitPropagator
#define LogTrace(id)
U second(std::pair< T, U > const &p)
const SurfaceType & surface() const
const TransientTrackingRecHitBuilder * theBuilder
const MeasurementDet & mdet() const
std::shared_ptr< TrackingRecHit const > RecHitPointer
std::pair< LocalPoint, LocalError > LocalParameters
static std::atomic< unsigned int > counter
TrackingRecHit::RecHitPointer project(const TrackingRecHit::ConstRecHitPointer hit, const GeomDet &det, const TrajectoryStateOnSurface ts, const TransientTrackingRecHitBuilder *builder) const
tmp
align.sh
Definition: createJobs.py:716
const PositionType & position() const
LocalParameters calcParameters(const TrajectoryStateOnSurface &tsos, std::vector< std::pair< const TrackingRecHit *, float > > &aHitMap) const

Member Data Documentation

bool SiTrackerMultiRecHitUpdator::debug_
private

Definition at line 88 of file SiTrackerMultiRecHitUpdator.h.

const std::vector<double> SiTrackerMultiRecHitUpdator::theAnnealingProgram
private

Definition at line 86 of file SiTrackerMultiRecHitUpdator.h.

Referenced by annealingProgram(), and getAnnealingProgram().

const TransientTrackingRecHitBuilder* SiTrackerMultiRecHitUpdator::theBuilder
private

Definition at line 82 of file SiTrackerMultiRecHitUpdator.h.

Referenced by buildMultiRecHit(), getBuilder(), and update().

double SiTrackerMultiRecHitUpdator::theChi2Cut1D
private

Definition at line 84 of file SiTrackerMultiRecHitUpdator.h.

double SiTrackerMultiRecHitUpdator::theChi2Cut2D
private

Definition at line 85 of file SiTrackerMultiRecHitUpdator.h.

TkClonerImpl SiTrackerMultiRecHitUpdator::theHitCloner
private

Definition at line 87 of file SiTrackerMultiRecHitUpdator.h.

Referenced by SiTrackerMultiRecHitUpdator(), and update().

const TrackingRecHitPropagator* SiTrackerMultiRecHitUpdator::theHitPropagator
private

Definition at line 83 of file SiTrackerMultiRecHitUpdator.h.

Referenced by update().