19 const float Chi2Cut1D,
20 const float Chi2Cut2D,
21 const std::vector<double>& anAnnealingProgram,
23 : theBuilder(builder),
24 theHitPropagator(hitpropagator),
25 theChi2Cut1D(Chi2Cut1D),
26 theChi2Cut2D(Chi2Cut2D),
27 theAnnealingProgram(anAnnealingProgram),
33 const std::vector<const TrackingRecHit*>& rhv,
36 float annealing)
const {
37 LogTrace(
"SiTrackerMultiRecHitUpdator")
38 <<
"Calling SiTrackerMultiRecHitUpdator::buildMultiRecHit with AnnealingFactor: " << annealing;
41 for (std::vector<const TrackingRecHit*>::const_iterator iter = rhv.begin(); iter != rhv.end(); iter++) {
43 if (transient->isValid())
44 tcomponents.push_back(
transient);
46 return update(tcomponents, tsos, measDet, annealing);
53 double annealing)
const {
54 LogTrace(
"SiTrackerMultiRecHitUpdator")
55 <<
"Calling SiTrackerMultiRecHitUpdator::update with AnnealingFactor: " << annealing;
59 throw cms::Exception(
"SiTrackerMultiRecHitUpdator") <<
"!!! MultiRecHitUpdator::update(..): tsos NOT valid!!! ";
64 if (
original->transientHits().empty()) {
72 return update(tcomponents, tsos, measDet, annealing);
80 double annealing)
const {
81 if (tcomponents.empty()) {
82 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"Empty components vector passed to SiTrackerMultiRecHitUpdator::update, " 83 "returning an InvalidTransientRecHit ";
88 LogTrace(
"SiTrackerMultiRecHitUpdator")
89 <<
"SiTrackerMultiRecHitUpdator::update: tsos NOT valid!!!, returning an InvalidTransientRecHit";
93 std::vector<TransientTrackingRecHit::RecHitPointer> updatedcomponents;
94 const GeomDet* geomdet =
nullptr;
97 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator iter = tcomponents.begin();
98 iter != tcomponents.end();
101 if (iter == tcomponents.begin()) {
102 if (&((*iter)->det()->surface()) != &(tsos.
surface())) {
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();
110 geomdet = (*iter)->det();
115 if (&((*iter)->det()->surface()) != &(tsos.
surface())) {
120 updatedcomponents.push_back(
cloned);
125 updatedcomponents.push_back(
cloned);
130 std::vector<std::pair<const TrackingRecHit*, float> > mymap;
131 std::vector<std::pair<const TrackingRecHit*, float> > normmap;
133 double a_sum = 0, c_sum = 0;
135 for (std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin();
136 ihit != updatedcomponents.end();
138 double a_i =
ComputeWeight(tsos, *(*ihit),
false, annealing);
139 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t\t a_i:" << a_i;
142 mymap.push_back(std::pair<const TrackingRecHit*, float>((*ihit)->hit(), a_i));
146 if (ihit == updatedcomponents.begin())
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;
155 for (std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin();
156 ihit != updatedcomponents.end();
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;
170 normmap.push_back(std::pair<const TrackingRecHit*, float>(mymap[
counter].
first,
p));
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;
182 return std::make_shared<SiTrackerMultiRecHit>(
183 param.first, param.second, *normmap.front().first->det(), normmap, annealing);
186 LogTrace(
"SiTrackerMultiRecHitUpdator")
187 <<
" No hits with weight (> 10e-6) have been found for this MRH." << std::endl;
196 double annealing)
const {
199 return ComputeWeight<1>(tsos, aRecHit, CutWeight, annealing);
201 return ComputeWeight<2>(tsos, aRecHit, CutWeight, annealing);
203 return ComputeWeight<3>(tsos, aRecHit, CutWeight, annealing);
205 return ComputeWeight<4>(tsos, aRecHit, CutWeight, annealing);
207 return ComputeWeight<5>(tsos, aRecHit, CutWeight, annealing);
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";
214 template <
unsigned int N>
218 double annealing)
const {
233 holder.template setup<N>(&
r, &
R, &
pf, &rMeas, &RMeas,
x,
C);
239 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t\t r:" <<
r;
240 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t\t tsospos:" << rMeas;
241 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t\t diff:" <<
diff;
242 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t\t R:" <<
R;
243 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t\t RMeas:" << RMeas;
248 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t\t R+RMeas:" <<
R;
265 bool ierr =
R.Det2(det);
268 double Chi2 = ROOT::Math::Similarity(
diff,
R);
270 if (!ierr || !ierr2) {
271 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"SiTrackerMultiRecHitUpdator::ComputeWeight: W not valid!" << std::endl;
272 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"V: " <<
R <<
" AnnealingFactor: " << annealing << std::endl;
276 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t\t det:" << det;
277 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t\t Chi2:" <<
Chi2;
278 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t\t Chi2/ann:" <<
Chi2 / annealing;
281 double temp_weight = 0.0;
282 if (CutWeight &&
N == 1) {
285 }
else if (CutWeight &&
N == 2) {
291 temp_weight =
exp(-0.5 *
Chi2 / annealing);
301 LogTrace(
"SiTrackerMultiRecHitUpdator")
302 <<
"SiTrackerMultiRecHitUpdator::LocalParameters: dim first recHit: " << aHitMap[0].first->dimension()
304 switch (aHitMap[0].
first->dimension()) {
306 return calcParameters<1>(tsos, aHitMap);
308 return calcParameters<2>(tsos, aHitMap);
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";
315 template <
unsigned int N>
329 for (
std::vector<std::pair<const TrackingRecHit*, float> >::const_iterator ihit = aHitMap.begin();
330 ihit != aHitMap.end();
341 holder.template setup<N>(&
r, &
V, &
pf, &rMeas, &VMeas,
x,
C);
342 (ihit->first)->getKfComponents(holder);
344 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t position: " <<
r;
345 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t error: " <<
V;
349 V(0, 1) =
V(1, 0) =
V(0, 1) *
s;
351 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t error scorr: " <<
V;
356 edm::LogError(
"SiTrackerMultiRecHitUpdator") <<
"SiTrackerMultiRecHitUpdator::calcParameters: V not valid!";
358 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t inverse error: " <<
V;
361 m_sum += (ihit->second *
V *
r);
362 W_sum += (ihit->second *
V);
367 edm::LogError(
"SiTrackerMultiRecHitUpdator") <<
"SiTrackerMultiRecHitUpdator::calcParameters: W_sum not valid!";
370 LogTrace(
"SiTrackerMultiRecHitUpdator") <<
"\t inverse total error: " << W_sum;
388 DetId hitId =
hit->geographicalId();
static constexpr auto TEC
virtual int dimension() const =0
Point3DBase< Scalar, LocalTag > LocalPoint
const LocalTrajectoryError & localError() const
ROOT::Math::SMatrix< double, D1, D1, ROOT::Math::MatRepSym< double, D1 > > SymMatrix
virtual const GeomDet & geomDet() const
virtual TransientTrackingRecHit::RecHitPointer update(TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const
const LocalTrajectoryParameters & localParameters() const
Log< level::Error, false > LogError
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
const SurfaceType & surface() const
const TrackingRecHitPropagator * theHitPropagator
constexpr Detector det() const
get the detector field from this detid
TrackingRecHit::RecHitPointer project(const TrackingRecHit::ConstRecHitPointer hit, const GeomDet &det, const TrajectoryStateOnSurface ts, const TransientTrackingRecHitBuilder *builder) const
U second(std::pair< T, U > const &p)
virtual TransientTrackingRecHit::RecHitPointer buildMultiRecHit(const std::vector< const TrackingRecHit *> &rhv, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, float annealing=1.) const
TkClonerImpl theHitCloner
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t V
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
const TransientTrackingRecHitBuilder * theBuilder
AlgebraicVector5 vector() const
bool TIDorTEChit(const TrackingRecHit *const &hit) const
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
SiTrackerMultiRecHitUpdator(const TransientTrackingRecHitBuilder *builder, const TrackingRecHitPropagator *hitpropagator, const float Chi2Cut1D, const float Chi2Cut2D, const std::vector< double > &anAnnealingProgram, bool debug)
std::shared_ptr< TrackingRecHit const > RecHitPointer
std::vector< ConstRecHitPointer > ConstRecHitContainer
std::pair< LocalPoint, LocalError > LocalParameters
const PositionType & position() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
double ComputeWeight(const TrajectoryStateOnSurface &tsos, const TransientTrackingRecHit &aRecHit, bool CutWeight, double annealing=1.) const
ROOT::Math::SVector< double, D1 > Vector
const MeasurementDet & mdet() const
static std::atomic< unsigned int > counter
static int position[264][3]
const AlgebraicSymMatrix55 & matrix() const
LocalParameters calcParameters(const TrajectoryStateOnSurface &tsos, std::vector< std::pair< const TrackingRecHit *, float > > &aHitMap) const
static constexpr auto TID
virtual void getKfComponents(KfComponentsHolder &holder) const