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

24  :MultiRecHitCollector(measurementTracker), theTopology(trackerTopology), theUpdator(updator), theEstimator(est), thePropagator(propagator), debug_(debug){
25  theHitCloner = static_cast<TkTransientTrackingRecHitBuilder const *>(theUpdator->getBuilder())->cloner();
26 }
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 29 of file SimpleDAFHitCollector.h.

References recHits().

29 {}

Member Function Documentation

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

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

67  {
68  auto const & detU = *hit2D.detUnit();
69  //Use 2D SiStripRecHit in endcap
70  bool endcap = detU.type().isEndcap();
71  if (endcap) return std::unique_ptr<TrackingRecHit>{hit2D.clone()};
72  return std::unique_ptr<TrackingRecHit>{
73  new SiStripRecHit1D(hit2D.localPosition(),
74  LocalError(hit2D.localPositionError().xx(),0.f,std::numeric_limits<float>::max()),
75  *hit2D.det(), hit2D.firstClusterRef()) };
76 
77  }
void SimpleDAFHitCollector::Debug ( const std::vector< TrajectoryMeasurement TM) const

Definition at line 154 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();
158  itrajmeas++) {
159  if (itrajmeas->recHit()->isValid()){
160 
161  LogTrace("MultiRecHitCollector") << " Valid Hit with DetId " << itrajmeas->recHit()->geographicalId().rawId() << " and dim:" << 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); break;
174  LogTrace("MultiRecHitCollector") << " I am TOB " << theTopology->tobLayer(hitId); break;
176  LogTrace("MultiRecHitCollector") << " I am TEC " << theTopology->tecWheel(hitId); break;
178  LogTrace("MultiRecHitCollector") << " I am TID " << theTopology->tidWheel(hitId); break;
180  LogTrace("MultiRecHitCollector") << " I am PixBar " << theTopology->pxbLayer(hitId); break;
182  LogTrace("MultiRecHitCollector") << " I am PixFwd " << theTopology->pxfDisk(hitId); break;
183  default:
184  LogTrace("MultiRecHitCollector") << " UNKNOWN TRACKER HIT TYPE "; break;
185  }
186  }
187  else if(hitId.det() == DetId::Muon) {
188  if(hitId.subdetId() == MuonSubdetId::DT)
189  LogTrace("MultiRecHitCollector") << " I am DT " << DTWireId(hitId);
190  else if (hitId.subdetId() == MuonSubdetId::CSC )
191  LogTrace("MultiRecHitCollector") << " I am CSC " << CSCDetId(hitId);
192  else if (hitId.subdetId() == MuonSubdetId::RPC )
193  LogTrace("MultiRecHitCollector") << " I am RPC " << RPCDetId(hitId);
194  else
195  LogTrace("MultiRecHitCollector") << " UNKNOWN MUON HIT TYPE ";
196  }
197  else
198  LogTrace("MultiRecHitCollector") << " UNKNOWN HIT TYPE ";
199 
200 
201  LogTrace("MultiRecHitCollector") << " TSOS predicted_fwd " << itrajmeas->predictedState().localPosition() ;
202  LogTrace("MultiRecHitCollector") << " TSOS predicted_bwd " << itrajmeas->backwardPredictedState().localPosition() ;
203  LogTrace("MultiRecHitCollector") << " TSOS smoothtsos " << itrajmeas->updatedState().localPosition() ;
204  } else {
205  LogTrace("MultiRecHitCollector") << " Invalid Hit with DetId " << itrajmeas->recHit()->geographicalId().rawId();
206  }
207  LogTrace("MultiRecHitCollector") << "\n";
208  }
209 #endif
210 }
unsigned int tibLayer(const DetId &id) const
unsigned int pxfDisk(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
static const int CSC
Definition: MuonSubdetId.h:13
const TrackerTopology * theTopology
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
#define LogTrace(id)
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
static const int RPC
Definition: MuonSubdetId.h:14
static const int DT
Definition: MuonSubdetId.h:12
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
const MeasurementEstimator* SimpleDAFHitCollector::getEstimator ( ) const
inline

Definition at line 41 of file SimpleDAFHitCollector.h.

References theEstimator.

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

Definition at line 42 of file SimpleDAFHitCollector.h.

References Debug(), and thePropagator.

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

Definition at line 40 of file SimpleDAFHitCollector.h.

References theUpdator.

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

Implements MultiRecHitCollector.

Definition at line 28 of file SimpleDAFHitCollector.cc.

References 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 
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()) 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 
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()) combtsos = predtsos_fwd;
69  else if (hitcounter == 1) combtsos = predtsos_bwd;
70  else combtsos = combiner(predtsos_bwd, predtsos_fwd);
71 
72  //collected hits compatible with the itrajmeas
73  if( measDet.measurements(smoothtsos, *(getEstimator()), tmps)){
74 
75  LogTrace("MultiRecHitCollector") << " Found " << tmps.size() << " compatible measurements";
76 
77  for (std::size_t i=0; i!=tmps.size(); ++i){
78 
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() << " and error " << tmps.hits[i]->hit()->localPositionError();
83 
85  theUpdator->getBuilder()->build(tmps.hits[i]->hit());
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 
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() ) continue;
102 
103  result.push_back(TrajectoryMeasurement(predtsos_fwd,
104  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") << " -> " << hits.size() << " valid hits for this sensor. (IT WAS INVALID!!!)";
110  else LogTrace("MultiRecHitCollector") << " -> " << hits.size() << " valid hits for this sensor.";
111 
112  //building a MultiRecHit out of each sensor group
113  result.push_back(TrajectoryMeasurement(predtsos_fwd,theUpdator->buildMultiRecHit(hits, combtsos, measDet)));
114  }
115  } else {
116  LogTrace("MultiRecHitCollector") << " No measurements found in current group.";
117  //the error was scaled, now is scaled back (even if this is not tightly necessary)
118 // if (smoothtsos.isValid()) smoothtsos.rescaleError(0.1);
119 
120  if( result.empty() ) continue;
121 
122  result.push_back(TrajectoryMeasurement(predtsos_fwd,
123  std::make_shared<InvalidTrackingRecHit>(measDet.mdet().geomDet(), TrackingRecHit::missing)));
124 
125  }
126 
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  {
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()) hitcounter++;
142  }
143 
144  if(hitcounter>2)
145  return result;
146  else return vector<TrajectoryMeasurement>();
147  }
148 
149  else{return vector<TrajectoryMeasurement>();}
150 
151 }
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:57
DataContainer const & measurements() const
Definition: Trajectory.h:196
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:18
const TransientTrackingRecHitBuilder * getBuilder() const
bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, TempMeasurements &result) const
def move(src, dest)
Definition: eostools.py:510
const SiTrackerMultiRecHitUpdator * theUpdator
std::unique_ptr<TrackingRecHit> SimpleDAFHitCollector::rightdimension ( TrackingRecHit const &  hit) const
inlineprivate

Definition at line 50 of file SimpleDAFHitCollector.h.

References clone(), TrackingRecHit::clone(), TrackingRecHit::dimension(), BaseTrackerRecHit::firstClusterRef(), TrackingRecHit::isValid(), and LogDebug.

50  {
51  if( !hit.isValid() || ( hit.dimension()!=2) ) {
52  return std::unique_ptr<TrackingRecHit>{hit.clone()};
53  }
54  auto const & thit = static_cast<BaseTrackerRecHit const&>(hit);
55  auto const & clus = thit.firstClusterRef();
56  if (clus.isPixel()) return std::unique_ptr<TrackingRecHit>{hit.clone()};
57  else if (clus.isPhase2()) return std::unique_ptr<TrackingRecHit>{hit.clone()};
58  else if (thit.isMatched()) {
59  LogDebug("MultiRecHitCollector") << " SiStripMatchedRecHit2D to check!!!";
60  return std::unique_ptr<TrackingRecHit>{hit.clone()};
61  } else if (thit.isProjected()) {
62  edm::LogError("MultiRecHitCollector") << " ProjectedSiStripRecHit2D should not be present at this stage!!!";
63  return std::unique_ptr<TrackingRecHit>{hit.clone()};
64  } else return clone(thit);
65  }
#define LogDebug(id)
std::unique_ptr< TrackingRecHit > clone(BaseTrackerRecHit const &hit2D) const
virtual OmniClusterRef const & firstClusterRef() const =0

Member Data Documentation

const bool SimpleDAFHitCollector::debug_
private

Definition at line 86 of file SimpleDAFHitCollector.h.

const MeasurementEstimator* SimpleDAFHitCollector::theEstimator
private

Definition at line 82 of file SimpleDAFHitCollector.h.

Referenced by getEstimator().

TkClonerImpl SimpleDAFHitCollector::theHitCloner
private

Definition at line 85 of file SimpleDAFHitCollector.h.

Referenced by SimpleDAFHitCollector().

const Propagator* SimpleDAFHitCollector::thePropagator
private

Definition at line 84 of file SimpleDAFHitCollector.h.

Referenced by getPropagator().

const TrackerTopology* SimpleDAFHitCollector::theTopology
private

Definition at line 80 of file SimpleDAFHitCollector.h.

const SiTrackerMultiRecHitUpdator* SimpleDAFHitCollector::theUpdator
private

Definition at line 81 of file SimpleDAFHitCollector.h.

Referenced by getUpdator(), and SimpleDAFHitCollector().