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 ( 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 watchdog::const, SiTrackerMultiRecHitUpdator::getBuilder(), theHitCloner, and theUpdator.

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

Definition at line 34 of file SimpleDAFHitCollector.h.

References recHits().

34 {}

Member Function Documentation

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  }
void SimpleDAFHitCollector::Debug ( const std::vector< TrajectoryMeasurement TM) const

Definition at line 155 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.

Referenced by getPropagator().

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

Definition at line 46 of file SimpleDAFHitCollector.h.

References theEstimator.

46 { return theEstimator; }
const MeasurementEstimator * theEstimator
const Propagator* SimpleDAFHitCollector::getPropagator ( ) const
inline

Definition at line 47 of file SimpleDAFHitCollector.h.

References Debug(), and thePropagator.

47 { return thePropagator; }
const Propagator * thePropagator
const SiTrackerMultiRecHitUpdator* SimpleDAFHitCollector::getUpdator ( ) const
inline

Definition at line 45 of file SimpleDAFHitCollector.h.

References theUpdator.

45 { return theUpdator; }
const SiTrackerMultiRecHitUpdator * theUpdator
vector< TrajectoryMeasurement > SimpleDAFHitCollector::recHits ( const Trajectory traj,
const MeasurementTrackerEvent theMTE 
) const
overridevirtual

Implements MultiRecHitCollector.

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

Referenced by ~SimpleDAFHitCollector().

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

Definition at line 55 of file SimpleDAFHitCollector.h.

References clone(), TrackingRecHit::clone(), watchdog::const, TrackingRecHit::dimension(), TrackingRecHit::isValid(), 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  }
#define LogDebug(id)
std::unique_ptr< TrackingRecHit > clone(BaseTrackerRecHit const &hit2D) const

Member Data Documentation

const bool SimpleDAFHitCollector::debug_
private

Definition at line 95 of file SimpleDAFHitCollector.h.

const MeasurementEstimator* SimpleDAFHitCollector::theEstimator
private

Definition at line 91 of file SimpleDAFHitCollector.h.

Referenced by getEstimator().

TkClonerImpl SimpleDAFHitCollector::theHitCloner
private

Definition at line 94 of file SimpleDAFHitCollector.h.

Referenced by SimpleDAFHitCollector().

const Propagator* SimpleDAFHitCollector::thePropagator
private

Definition at line 93 of file SimpleDAFHitCollector.h.

Referenced by getPropagator().

const TrackerTopology* SimpleDAFHitCollector::theTopology
private

Definition at line 89 of file SimpleDAFHitCollector.h.

const SiTrackerMultiRecHitUpdator* SimpleDAFHitCollector::theUpdator
private

Definition at line 90 of file SimpleDAFHitCollector.h.

Referenced by getUpdator(), and SimpleDAFHitCollector().