CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
virtual std::vector
< TrajectoryMeasurement
recHits (const Trajectory &, const MeasurementTrackerEvent *theMTE) const override
 
 SimpleDAFHitCollector (const MeasurementTracker *measurementTracker, const SiTrackerMultiRecHitUpdator *updator, const MeasurementEstimator *est, const Propagator *propagator, bool debug)
 
virtual ~SimpleDAFHitCollector ()
 
- Public Member Functions inherited from MultiRecHitCollector
const MeasurementTrackergetMeasurementTracker () const
 
 MultiRecHitCollector (const MeasurementTracker *meas)
 

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 SiTrackerMultiRecHitUpdatortheUpdator
 

Detailed Description

Definition at line 17 of file SimpleDAFHitCollector.h.

Constructor & Destructor Documentation

SimpleDAFHitCollector::SimpleDAFHitCollector ( 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.

23  :MultiRecHitCollector(measurementTracker), theUpdator(updator), theEstimator(est), thePropagator(propagator), debug_(debug){
24  theHitCloner = static_cast<TkTransientTrackingRecHitBuilder const *>(theUpdator->getBuilder())->cloner();
25 }
const MeasurementEstimator * theEstimator
MultiRecHitCollector(const MeasurementTracker *meas)
const Propagator * thePropagator
#define debug
Definition: HDRShower.cc:19
const TransientTrackingRecHitBuilder * getBuilder() const
const SiTrackerMultiRecHitUpdator * theUpdator
virtual SimpleDAFHitCollector::~SimpleDAFHitCollector ( )
inlinevirtual

Definition at line 28 of file SimpleDAFHitCollector.h.

28 {}

Member Function Documentation

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

Definition at line 65 of file SimpleDAFHitCollector.h.

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

Referenced by rightdimension().

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

Definition at line 160 of file SimpleDAFHitCollector.cc.

References MuonSubdetId::CSC, CSCDetId, DetId::det(), PXFDetId::disk(), MuonSubdetId::DT, PXBDetId::layer(), TOBDetId::layer(), TIBDetId::layer(), LogTrace, DetId::Muon, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, MuonSubdetId::RPC, RPCDetId, DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, DetId::Tracker, TIDDetId::wheel(), and TECDetId::wheel().

161 {
162 #ifdef EDM_ML_DEBUG
163  for(vector<TrajectoryMeasurement>::const_iterator itrajmeas = TM.begin(); itrajmeas < TM.end();
164  itrajmeas++) {
165  if (itrajmeas->recHit()->isValid()){
166 
167  LogTrace("MultiRecHitCollector") << " Valid Hit with DetId " << itrajmeas->recHit()->geographicalId().rawId() << " and dim:" << itrajmeas->recHit()->dimension()
168  //<< " type " << typeid(itrajmeas->recHit()).name()
169  << " local position " << itrajmeas->recHit()->hit()->localPosition()
170  << " global position " << itrajmeas->recHit()->hit()->globalPosition()
171  << " and r " << itrajmeas->recHit()->hit()->globalPosition().perp() ;
172 
173  DetId hitId = itrajmeas->recHit()->geographicalId();
174 
175  if(hitId.det() == DetId::Tracker) {
176  if (hitId.subdetId() == StripSubdetector::TIB )
177  LogTrace("MultiRecHitCollector") << " I am TIB " << TIBDetId(hitId).layer();
178  else if (hitId.subdetId() == StripSubdetector::TOB )
179  LogTrace("MultiRecHitCollector") << " I am TOB " << TOBDetId(hitId).layer();
180  else if (hitId.subdetId() == StripSubdetector::TEC )
181  LogTrace("MultiRecHitCollector") << " I am TEC " << TECDetId(hitId).wheel();
182  else if (hitId.subdetId() == StripSubdetector::TID )
183  LogTrace("MultiRecHitCollector") << " I am TID " << TIDDetId(hitId).wheel();
184  else if (hitId.subdetId() == (int) PixelSubdetector::PixelBarrel )
185  LogTrace("MultiRecHitCollector") << " I am PixBar " << PXBDetId(hitId).layer();
186  else if (hitId.subdetId() == (int) PixelSubdetector::PixelEndcap )
187  LogTrace("MultiRecHitCollector") << " I am PixFwd " << PXFDetId(hitId).disk();
188  else
189  LogTrace("MultiRecHitCollector") << " UNKNOWN TRACKER HIT TYPE ";
190  }
191  else if(hitId.det() == DetId::Muon) {
192  if(hitId.subdetId() == MuonSubdetId::DT)
193  LogTrace("MultiRecHitCollector") << " I am DT " << DTWireId(hitId);
194  else if (hitId.subdetId() == MuonSubdetId::CSC )
195  LogTrace("MultiRecHitCollector") << " I am CSC " << CSCDetId(hitId);
196  else if (hitId.subdetId() == MuonSubdetId::RPC )
197  LogTrace("MultiRecHitCollector") << " I am RPC " << RPCDetId(hitId);
198  else
199  LogTrace("MultiRecHitCollector") << " UNKNOWN MUON HIT TYPE ";
200  }
201  else
202  LogTrace("MultiRecHitCollector") << " UNKNOWN HIT TYPE ";
203 
204 
205  LogTrace("MultiRecHitCollector") << " TSOS predicted_fwd " << itrajmeas->predictedState().localPosition() ;
206  LogTrace("MultiRecHitCollector") << " TSOS predicted_bwd " << itrajmeas->backwardPredictedState().localPosition() ;
207  LogTrace("MultiRecHitCollector") << " TSOS smoothtsos " << itrajmeas->updatedState().localPosition() ;
208  } else {
209  LogTrace("MultiRecHitCollector") << " Invalid Hit with DetId " << itrajmeas->recHit()->geographicalId().rawId();
210  }
211  LogTrace("MultiRecHitCollector") << "\n";
212  }
213 #endif
214 }
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
static const int CSC
Definition: MuonSubdetId.h:13
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 disk() const
disk id
Definition: PXFDetId.h:43
Definition: DetId.h:18
unsigned int wheel() const
wheel id
Definition: TECDetId.h:52
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
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 wheel() const
wheel id
Definition: TIDDetId.h:50
const MeasurementEstimator* SimpleDAFHitCollector::getEstimator ( ) const
inline

Definition at line 40 of file SimpleDAFHitCollector.h.

References theEstimator.

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

Definition at line 41 of file SimpleDAFHitCollector.h.

References thePropagator.

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

Definition at line 39 of file SimpleDAFHitCollector.h.

References theUpdator.

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

Implements MultiRecHitCollector.

Definition at line 34 of file SimpleDAFHitCollector.cc.

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

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

Definition at line 49 of file SimpleDAFHitCollector.h.

References clone(), TrackingRecHit::clone(), compareJSON::const, TrackingRecHit::dimension(), TrackingRecHit::isValid(), and LogDebug.

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

Member Data Documentation

const bool SimpleDAFHitCollector::debug_
private

Definition at line 83 of file SimpleDAFHitCollector.h.

const MeasurementEstimator* SimpleDAFHitCollector::theEstimator
private

Definition at line 79 of file SimpleDAFHitCollector.h.

Referenced by getEstimator().

TkClonerImpl SimpleDAFHitCollector::theHitCloner
private

Definition at line 82 of file SimpleDAFHitCollector.h.

Referenced by SimpleDAFHitCollector().

const Propagator* SimpleDAFHitCollector::thePropagator
private

Definition at line 81 of file SimpleDAFHitCollector.h.

Referenced by getPropagator().

const SiTrackerMultiRecHitUpdator* SimpleDAFHitCollector::theUpdator
private

Definition at line 78 of file SimpleDAFHitCollector.h.

Referenced by getUpdator(), and SimpleDAFHitCollector().