CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SimpleDAFHitCollector Class Reference

#include <SimpleDAFHitCollector.h>

Inheritance diagram for SimpleDAFHitCollector:
MultiRecHitCollector

Public Member Functions

void Debug (const std::vector< TrajectoryMeasurement > TM) const
 
const MeasurementEstimatorgetEstimator () const
 
const PropagatorgetPropagator () const
 
const SiTrackerMultiRecHitUpdatorgetUpdator () const
 
std::vector< TrajectoryMeasurementrecHits (const Trajectory &, const MeasurementTrackerEvent *theMTE) const override
 
 SimpleDAFHitCollector (const TrackerTopology *trackerTopology, const MeasurementTracker *measurementTracker, const SiTrackerMultiRecHitUpdator *updator, const MeasurementEstimator *est, const Propagator *propagator, bool debug)
 
 ~SimpleDAFHitCollector () override
 
- Public Member Functions inherited from MultiRecHitCollector
const MeasurementTrackergetMeasurementTracker () const
 
 MultiRecHitCollector (const MeasurementTracker *meas)
 
virtual ~MultiRecHitCollector ()=default
 

Private Member Functions

std::unique_ptr< TrackingRecHitclone (BaseTrackerRecHit const &hit2D) const
 
std::unique_ptr< TrackingRecHitrightdimension (TrackingRecHit const &hit) const
 

Private Attributes

const bool debug_
 
const MeasurementEstimatortheEstimator
 
TkClonerImpl theHitCloner
 
const PropagatorthePropagator
 
const TrackerTopologytheTopology
 
const SiTrackerMultiRecHitUpdatortheUpdator
 

Detailed Description

Definition at line 17 of file SimpleDAFHitCollector.h.

Constructor & Destructor Documentation

◆ SimpleDAFHitCollector()

SimpleDAFHitCollector::SimpleDAFHitCollector ( const TrackerTopology trackerTopology,
const MeasurementTracker measurementTracker,
const SiTrackerMultiRecHitUpdator updator,
const MeasurementEstimator est,
const Propagator propagator,
bool  debug 
)
inlineexplicit

Definition at line 19 of file SimpleDAFHitCollector.h.

References runTheMatrix::const, SiTrackerMultiRecHitUpdator::getBuilder(), theHitCloner, and theUpdator.

26  theTopology(trackerTopology),
28  theEstimator(est),
30  debug_(debug) {
32  }
const MeasurementEstimator * theEstimator
MultiRecHitCollector(const MeasurementTracker *meas)
const TrackerTopology * theTopology
const Propagator * thePropagator
const TransientTrackingRecHitBuilder * getBuilder() const
#define debug
Definition: HDRShower.cc:19
const SiTrackerMultiRecHitUpdator * theUpdator

◆ ~SimpleDAFHitCollector()

SimpleDAFHitCollector::~SimpleDAFHitCollector ( )
inlineoverride

Definition at line 34 of file SimpleDAFHitCollector.h.

34 {}

Member Function Documentation

◆ clone()

std::unique_ptr<TrackingRecHit> SimpleDAFHitCollector::clone ( BaseTrackerRecHit const &  hit2D) const
inlineprivate

Definition at line 75 of file SimpleDAFHitCollector.h.

References TrackingRecHit::clone(), TrackingRecHit::det(), TrackingRecHit::detUnit(), makeMuonMisalignmentScenario::endcap, BaseTrackerRecHit::firstClusterRef(), BaseTrackerRecHit::localPosition(), BaseTrackerRecHit::localPositionError(), SiStripPI::max, and LocalError::xx().

Referenced by rightdimension().

75  {
76  auto const& detU = *hit2D.detUnit();
77  //Use 2D SiStripRecHit in endcap
78  bool endcap = detU.type().isEndcap();
79  if (endcap)
80  return std::unique_ptr<TrackingRecHit>{hit2D.clone()};
81  return std::unique_ptr<TrackingRecHit>{
82  new SiStripRecHit1D(hit2D.localPosition(),
83  LocalError(hit2D.localPositionError().xx(), 0.f, std::numeric_limits<float>::max()),
84  *hit2D.det(),
85  hit2D.firstClusterRef())};
86  }

◆ Debug()

void SimpleDAFHitCollector::Debug ( const std::vector< TrajectoryMeasurement TM) const

Definition at line 156 of file SimpleDAFHitCollector.cc.

References MuonSubdetId::CSC, DetId::det(), MuonSubdetId::DT, LogTrace, DetId::Muon, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, MuonSubdetId::RPC, DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, and DetId::Tracker.

156  {
157 #ifdef EDM_ML_DEBUG
158  for (vector<TrajectoryMeasurement>::const_iterator itrajmeas = TM.begin(); itrajmeas < TM.end(); itrajmeas++) {
159  if (itrajmeas->recHit()->isValid()) {
160  LogTrace("MultiRecHitCollector") << " Valid Hit with DetId " << itrajmeas->recHit()->geographicalId().rawId()
161  << " and dim:"
162  << itrajmeas->recHit()->dimension()
163  //<< " type " << typeid(itrajmeas->recHit()).name()
164  << " local position " << itrajmeas->recHit()->hit()->localPosition()
165  << " global position " << itrajmeas->recHit()->hit()->globalPosition()
166  << " and r " << itrajmeas->recHit()->hit()->globalPosition().perp();
167 
168  DetId hitId = itrajmeas->recHit()->geographicalId();
169 
170  if (hitId.det() == DetId::Tracker) {
171  switch (hitId.subdetId()) {
173  LogTrace("MultiRecHitCollector") << " I am TIB " << theTopology->tibLayer(hitId);
174  break;
176  LogTrace("MultiRecHitCollector") << " I am TOB " << theTopology->tobLayer(hitId);
177  break;
179  LogTrace("MultiRecHitCollector") << " I am TEC " << theTopology->tecWheel(hitId);
180  break;
182  LogTrace("MultiRecHitCollector") << " I am TID " << theTopology->tidWheel(hitId);
183  break;
185  LogTrace("MultiRecHitCollector") << " I am PixBar " << theTopology->pxbLayer(hitId);
186  break;
188  LogTrace("MultiRecHitCollector") << " I am PixFwd " << theTopology->pxfDisk(hitId);
189  break;
190  default:
191  LogTrace("MultiRecHitCollector") << " UNKNOWN TRACKER HIT TYPE ";
192  break;
193  }
194  } else if (hitId.det() == DetId::Muon) {
195  if (hitId.subdetId() == MuonSubdetId::DT)
196  LogTrace("MultiRecHitCollector") << " I am DT " << DTWireId(hitId);
197  else if (hitId.subdetId() == MuonSubdetId::CSC)
198  LogTrace("MultiRecHitCollector") << " I am CSC " << CSCDetId(hitId);
199  else if (hitId.subdetId() == MuonSubdetId::RPC)
200  LogTrace("MultiRecHitCollector") << " I am RPC " << RPCDetId(hitId);
201  else
202  LogTrace("MultiRecHitCollector") << " UNKNOWN MUON HIT TYPE ";
203  } else
204  LogTrace("MultiRecHitCollector") << " UNKNOWN HIT TYPE ";
205 
206  LogTrace("MultiRecHitCollector") << " TSOS predicted_fwd " << itrajmeas->predictedState().localPosition();
207  LogTrace("MultiRecHitCollector") << " TSOS predicted_bwd "
208  << itrajmeas->backwardPredictedState().localPosition();
209  LogTrace("MultiRecHitCollector") << " TSOS smoothtsos " << itrajmeas->updatedState().localPosition();
210  } else {
211  LogTrace("MultiRecHitCollector") << " Invalid Hit with DetId " << itrajmeas->recHit()->geographicalId().rawId();
212  }
213  LogTrace("MultiRecHitCollector") << "\n";
214  }
215 #endif
216 }
static constexpr auto TEC
unsigned int tobLayer(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
#define LogTrace(id)
const TrackerTopology * theTopology
unsigned int pxfDisk(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static constexpr auto TOB
Definition: DetId.h:17
static constexpr auto TIB
static constexpr int RPC
Definition: MuonSubdetId.h:13
unsigned int tibLayer(const DetId &id) const
static constexpr int DT
Definition: MuonSubdetId.h:11
static constexpr int CSC
Definition: MuonSubdetId.h:12
static constexpr auto TID

◆ getEstimator()

const MeasurementEstimator* SimpleDAFHitCollector::getEstimator ( ) const
inline

Definition at line 46 of file SimpleDAFHitCollector.h.

References theEstimator.

46 { return theEstimator; }
const MeasurementEstimator * theEstimator

◆ getPropagator()

const Propagator* SimpleDAFHitCollector::getPropagator ( ) const
inline

Definition at line 47 of file SimpleDAFHitCollector.h.

References thePropagator.

47 { return thePropagator; }
const Propagator * thePropagator

◆ getUpdator()

const SiTrackerMultiRecHitUpdator* SimpleDAFHitCollector::getUpdator ( ) const
inline

Definition at line 45 of file SimpleDAFHitCollector.h.

References theUpdator.

45 { return theUpdator; }
const SiTrackerMultiRecHitUpdator * theUpdator

◆ recHits()

vector< TrajectoryMeasurement > SimpleDAFHitCollector::recHits ( const Trajectory traj,
const MeasurementTrackerEvent theMTE 
) const
overridevirtual

Implements MultiRecHitCollector.

Definition at line 28 of file SimpleDAFHitCollector.cc.

References heavyFlavorValidationHarvestingSequence_cff::combiner, Debug, MeasurementDet::geomDet(), hfClusterShapes_cfi::hits, tracking::TempMeasurements::hits, mps_fire::i, TrajectoryStateOnSurface::isValid(), LogTrace, MeasurementDetWithData::mdet(), MeasurementDetWithData::measurements(), Trajectory::measurements(), TrackingRecHit::missing, eostools::move(), mps_fire::result, and tracking::TempMeasurements::size().

29  {
30  LogTrace("MultiRecHitCollector") << " Calling SimpleDAFHitCollector::recHits" << std::endl;
31 
32  //WARNING: At the moment the trajectories has the measurements
33  //with reversed sorting after the track smoothing
34  const vector<TrajectoryMeasurement>& meas = traj.measurements();
35  unsigned int hitcounter = 1;
36 
37  if (meas.empty())
38  return vector<TrajectoryMeasurement>();
39 
40  LogTrace("MultiRecHitCollector") << " Original measurements are:";
41  Debug(meas);
42 
43  //groups hits on a sensor by sensor with same Id of previous TM
44  //we have to sort the TrajectoryMeasurements in the opposite way in the fitting direction
45  vector<TrajectoryMeasurement> result;
46  for (vector<TrajectoryMeasurement>::const_reverse_iterator itrajmeas = meas.rbegin(); itrajmeas < meas.rend();
47  itrajmeas++, hitcounter++) {
48  DetId id = itrajmeas->recHit()->geographicalId();
49  MeasurementDetWithData measDet = theMTE->idToDet(id);
51 
52  std::vector<const TrackingRecHit*> hits;
53  std::vector<std::unique_ptr<const TrackingRecHit>> hitsOwner;
54 
55  TrajectoryStateOnSurface smoothtsos = itrajmeas->updatedState();
56  //the error is scaled in order to take more "compatible" hits
57  // if( smoothtsos.isValid() ) smoothtsos.rescaleError(10);
58 
59  TrajectoryStateOnSurface predtsos_fwd = itrajmeas->predictedState();
60  TrajectoryStateOnSurface predtsos_bwd = itrajmeas->backwardPredictedState();
61  if (!predtsos_fwd.isValid() || !predtsos_bwd.isValid()) {
62  LogTrace("MultiRecHitCollector") << "Something wrong! no valid TSOS found in current group ";
63  continue;
64  }
65 
67  TrajectoryStateOnSurface combtsos;
68  if (hitcounter == meas.size())
69  combtsos = predtsos_fwd;
70  else if (hitcounter == 1)
71  combtsos = predtsos_bwd;
72  else
73  combtsos = combiner(predtsos_bwd, predtsos_fwd);
74 
75  //collected hits compatible with the itrajmeas
76  if (measDet.measurements(smoothtsos, *(getEstimator()), tmps)) {
77  LogTrace("MultiRecHitCollector") << " Found " << tmps.size() << " compatible measurements";
78 
79  for (std::size_t i = 0; i != tmps.size(); ++i) {
80  DetId idtemps = tmps.hits[i]->geographicalId();
81 
82  if (idtemps == id && tmps.hits[i]->hit()->isValid()) {
83  LogTrace("MultiRecHitCollector") << " This is valid with position " << tmps.hits[i]->hit()->localPosition()
84  << " and error " << tmps.hits[i]->hit()->localPositionError();
85 
87  TrackingRecHit::ConstRecHitPointer preciseHit = theHitCloner.makeShared(transient, combtsos);
88  auto righthit = rightdimension(*preciseHit);
89  hitsOwner.push_back(std::move(righthit));
90  hits.push_back(hitsOwner.back().get());
91  }
92  }
93 
94  //the error was scaled, now is scaled back (even if this is not tightly necessary)
95  // if (smoothtsos.isValid()) smoothtsos.rescaleError(0.1);
96 
97  //I will keep the Invalid hit, IF this is not the first one
98  if (hits.empty()) {
99  LogTrace("MultiRecHitCollector") << " -> but no valid hits found in current group.";
100 
101  if (result.empty())
102  continue;
103 
104  result.push_back(TrajectoryMeasurement(
105  predtsos_fwd, std::make_shared<InvalidTrackingRecHit>(measDet.mdet().geomDet(), TrackingRecHit::missing)));
106  } else {
107  //measurements in groups are sorted with increating chi2
108  //sort( *hits.begin(), *hits.end(), TrajMeasLessEstim());
109  if (!itrajmeas->recHit()->isValid())
110  LogTrace("MultiRecHitCollector")
111  << " -> " << hits.size() << " valid hits for this sensor. (IT WAS INVALID!!!)";
112  else
113  LogTrace("MultiRecHitCollector") << " -> " << hits.size() << " valid hits for this sensor.";
114 
115  //building a MultiRecHit out of each sensor group
116  result.push_back(TrajectoryMeasurement(predtsos_fwd, theUpdator->buildMultiRecHit(hits, combtsos, measDet)));
117  }
118  } else {
119  LogTrace("MultiRecHitCollector") << " No measurements found in current group.";
120  //the error was scaled, now is scaled back (even if this is not tightly necessary)
121  // if (smoothtsos.isValid()) smoothtsos.rescaleError(0.1);
122 
123  if (result.empty())
124  continue;
125 
126  result.push_back(TrajectoryMeasurement(
127  predtsos_fwd, std::make_shared<InvalidTrackingRecHit>(measDet.mdet().geomDet(), TrackingRecHit::missing)));
128  }
129  }
130  LogTrace("MultiRecHitCollector") << " Ending SimpleDAFHitCollector::recHits >> " << result.size();
131 
132  //LogTrace("MultiRecHitCollector") << " New measurements are:";
133  //Debug(result);
134 
135  //adding a protection against too few hits and invalid hits
136  //(due to failed propagation on the same surface of the original hits)
137  if (result.size() > 2) {
138  int hitcounter = 0;
139  //check if the vector result has more than 3 valid hits
140  for (vector<TrajectoryMeasurement>::const_iterator iimeas = result.begin(); iimeas != result.end(); ++iimeas) {
141  if (iimeas->recHit()->isValid())
142  hitcounter++;
143  }
144 
145  if (hitcounter > 2)
146  return result;
147  else
148  return vector<TrajectoryMeasurement>();
149  }
150 
151  else {
152  return vector<TrajectoryMeasurement>();
153  }
154 }
void Debug(const std::vector< TrajectoryMeasurement > TM) const
virtual const GeomDet & geomDet() const
bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, TempMeasurements &result) const
const MeasurementEstimator * getEstimator() const
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:64
#define LogTrace(id)
std::unique_ptr< TrackingRecHit > rightdimension(TrackingRecHit const &hit) const
DataContainer const & measurements() const
Definition: Trajectory.h:178
virtual TransientTrackingRecHit::RecHitPointer buildMultiRecHit(const std::vector< const TrackingRecHit *> &rhv, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, float annealing=1.) const
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
const TransientTrackingRecHitBuilder * getBuilder() const
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: DetId.h:17
const MeasurementDet & mdet() const
std::size_t size() const
def move(src, dest)
Definition: eostools.py:511
const SiTrackerMultiRecHitUpdator * theUpdator

◆ rightdimension()

std::unique_ptr<TrackingRecHit> SimpleDAFHitCollector::rightdimension ( TrackingRecHit const &  hit) const
inlineprivate

Definition at line 55 of file SimpleDAFHitCollector.h.

References clone(), runTheMatrix::const, and LogDebug.

55  {
56  if (!hit.isValid() || (hit.dimension() != 2)) {
57  return std::unique_ptr<TrackingRecHit>{hit.clone()};
58  }
59  auto const& thit = static_cast<BaseTrackerRecHit const&>(hit);
60  auto const& clus = thit.firstClusterRef();
61  if (clus.isPixel())
62  return std::unique_ptr<TrackingRecHit>{hit.clone()};
63  else if (clus.isPhase2())
64  return std::unique_ptr<TrackingRecHit>{hit.clone()};
65  else if (thit.isMatched()) {
66  LogDebug("MultiRecHitCollector") << " SiStripMatchedRecHit2D to check!!!";
67  return std::unique_ptr<TrackingRecHit>{hit.clone()};
68  } else if (thit.isProjected()) {
69  edm::LogError("MultiRecHitCollector") << " ProjectedSiStripRecHit2D should not be present at this stage!!!";
70  return std::unique_ptr<TrackingRecHit>{hit.clone()};
71  } else
72  return clone(thit);
73  }
Log< level::Error, false > LogError
#define LogDebug(id)
std::unique_ptr< TrackingRecHit > clone(BaseTrackerRecHit const &hit2D) const

Member Data Documentation

◆ debug_

const bool SimpleDAFHitCollector::debug_
private

Definition at line 95 of file SimpleDAFHitCollector.h.

◆ theEstimator

const MeasurementEstimator* SimpleDAFHitCollector::theEstimator
private

Definition at line 91 of file SimpleDAFHitCollector.h.

Referenced by getEstimator().

◆ theHitCloner

TkClonerImpl SimpleDAFHitCollector::theHitCloner
private

Definition at line 94 of file SimpleDAFHitCollector.h.

Referenced by SimpleDAFHitCollector().

◆ thePropagator

const Propagator* SimpleDAFHitCollector::thePropagator
private

Definition at line 93 of file SimpleDAFHitCollector.h.

Referenced by getPropagator().

◆ theTopology

const TrackerTopology* SimpleDAFHitCollector::theTopology
private

Definition at line 89 of file SimpleDAFHitCollector.h.

◆ theUpdator

const SiTrackerMultiRecHitUpdator* SimpleDAFHitCollector::theUpdator
private

Definition at line 90 of file SimpleDAFHitCollector.h.

Referenced by getUpdator(), and SimpleDAFHitCollector().