CMS 3D CMS Logo

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

#include <GroupedDAFHitCollector.h>

Inheritance diagram for GroupedDAFHitCollector:
MultiRecHitCollector

Public Member Functions

const MeasurementEstimatorgetEstimator () const
 
const PropagatorgetPropagator () const
 
const PropagatorgetReversePropagator () const
 
const SiTrackerMultiRecHitUpdatorgetUpdator () const
 
 GroupedDAFHitCollector (const MeasurementTracker *measurementTracker, const SiTrackerMultiRecHitUpdator *updator, const MeasurementEstimator *est, const Propagator *propagator, const Propagator *reversePropagator, bool debug)
 
std::vector< TrajectoryMeasurementrecHits (const Trajectory &, const MeasurementTrackerEvent *theMT) const override
 
 ~GroupedDAFHitCollector () override
 
- Public Member Functions inherited from MultiRecHitCollector
const MeasurementTrackergetMeasurementTracker () const
 
 MultiRecHitCollector (const MeasurementTracker *meas)
 
virtual ~MultiRecHitCollector ()=default
 

Private Member Functions

void buildMultiRecHits (const std::vector< TrajectoryMeasurementGroup > &measgroup, std::vector< TrajectoryMeasurement > &result, const MeasurementTrackerEvent *&theMTE) const
 

Private Attributes

const bool debug_
 
const MeasurementEstimatortheEstimator
 
const PropagatorthePropagator
 
const PropagatortheReversePropagator
 
const SiTrackerMultiRecHitUpdatortheUpdator
 

Detailed Description

Returns a collection of SiTrackerMultiRecHits and InvalidRecHits given a Trajectory. Builds a SiTrackerMultiRecHit for each detGroup (i.e. a group of detectors mutually exclusive for the track's crossing point)

Author
tropiano, genta in May 2014 by brondolin

Definition at line 22 of file GroupedDAFHitCollector.h.

Constructor & Destructor Documentation

◆ GroupedDAFHitCollector()

GroupedDAFHitCollector::GroupedDAFHitCollector ( const MeasurementTracker measurementTracker,
const SiTrackerMultiRecHitUpdator updator,
const MeasurementEstimator est,
const Propagator propagator,
const Propagator reversePropagator,
bool  debug 
)
inlineexplicit

Definition at line 24 of file GroupedDAFHitCollector.h.

32  theEstimator(est),
34  theReversePropagator(reversePropagator),
35  debug_(debug) {}
const Propagator * theReversePropagator
const MeasurementEstimator * theEstimator
MultiRecHitCollector(const MeasurementTracker *meas)
#define debug
Definition: HDRShower.cc:19
const SiTrackerMultiRecHitUpdator * theUpdator
const Propagator * thePropagator

◆ ~GroupedDAFHitCollector()

GroupedDAFHitCollector::~GroupedDAFHitCollector ( )
inlineoverride

Definition at line 37 of file GroupedDAFHitCollector.h.

37 {}

Member Function Documentation

◆ buildMultiRecHits()

void GroupedDAFHitCollector::buildMultiRecHits ( const std::vector< TrajectoryMeasurementGroup > &  measgroup,
std::vector< TrajectoryMeasurement > &  result,
const MeasurementTrackerEvent *&  theMTE 
) const
private

Definition at line 136 of file GroupedDAFHitCollector.cc.

References TrackingRecHit::bad, hfClusterShapes_cfi::hits, TrackingRecHit::inactive, LogTrace, TrackingRecHit::missing, position, and mps_fire::result.

138  {
139  unsigned int initial_size = result.size();
140 
141  //TransientTrackingRecHit::ConstRecHitContainer rhits;
142  if (measgroup.empty()) {
143  LogTrace("MultiRecHitCollector") << "No TrajectoryMeasurementGroups found for this layer\n";
144  //should we do something?
145  //result.push_back(InvalidTransientRecHit::build(0,TrackingRecHit::missing));
146  return;
147  }
148 
149  //we build a MultiRecHit out of each group
150  //groups are sorted along momentum or opposite to momentum,
151  //measurements in groups are sorted with increating chi2
152  LogTrace("MultiRecHitCollector") << "Found " << measgroup.size() << " groups for this layer";
153 
154  //trajectory state to store the last valid TrajectoryState (if present) to be used
155  //to add an invalid Measurement in case no valid state or no valid hits are found in any group
156  for (vector<TrajectoryMeasurementGroup>::const_iterator igroup = measgroup.begin(); igroup != measgroup.end();
157  igroup++) {
158  //the TrajectoryState is the first one
159  TrajectoryStateOnSurface state = igroup->measurements().front().predictedState();
160  if (!state.isValid()) {
161  LogTrace("MultiRecHitCollector") << "Something wrong! no valid TSOS found in current group ";
162  continue;
163  }
164 
165  LogTrace("MultiRecHitCollector") << "This group has " << igroup->measurements().size() << " measurements";
166  LogTrace("MultiRecHitCollector") << "This group has the following " << igroup->detGroup().size()
167  << " detector ids: " << endl;
168  for (DetGroup::const_iterator idet = igroup->detGroup().begin(); idet != igroup->detGroup().end(); ++idet) {
169  LogTrace("MultiRecHitCollector") << idet->det()->geographicalId().rawId();
170  }
171 
172  vector<const TrackingRecHit*> hits;
173  for (vector<TrajectoryMeasurement>::const_iterator imeas = igroup->measurements().begin();
174  imeas != igroup->measurements().end();
175  imeas++) {
176  //should be fixed!!
177  //DetId id = imeas->recHit()->geographicalId();
178  //MeasurementDetWithData measDet = theMTE->idToDet(id);
179 
180  //collect the non missing hits to build the MultiRecHits
181  //we use the recHits method; anyway only simple hits, not MultiHits should be present
182  if (imeas->recHit()->getType() != TrackingRecHit::missing) {
183  LogTrace("MultiRecHitCollector") << "This hit is valid ";
184  hits.push_back(imeas->recHit()->hit());
185  } else {
186  LogTrace("MultiRecHitCollector") << " This hit is not valid and will not enter in the MRH. ";
187  }
188  }
189 
190  if (hits.empty()) {
191  LogTrace("MultiRecHitCollector") << "No valid hits found in current group ";
192  continue;
193  }
194 
195  LogTrace("MultiRecHitCollector") << "The best TSOS in this group is " << state << " it lays on surface located at "
196  << state.surface().position();
197 
198  LogTrace("MultiRecHitCollector") << "For the MRH on this group the following hits will be used";
199  for (vector<const TrackingRecHit*>::iterator iter = hits.begin(); iter != hits.end(); iter++) {
200  string validity = "valid";
201  if ((*iter)->getType() == TrackingRecHit::missing)
202  validity = "missing !should not happen!";
203  else if ((*iter)->getType() == TrackingRecHit::inactive)
204  validity = "inactive";
205  else if ((*iter)->getType() == TrackingRecHit::bad)
206  validity = "bad";
207  LogTrace("MultiRecHitCollector")
208  << "DetId " << (*iter)->geographicalId().rawId() << " validity: " << validity << " surface position "
209  << getMeasurementTracker()->geomTracker()->idToDet((*iter)->geographicalId())->position()
210  << " hit local position " << (*iter)->localPosition();
211  }
212  //should be fixed!!
213  //result.push_back(TrajectoryMeasurement(state,theUpdator->buildMultiRecHit(hits, state, *MeasurementDetWithData())));
214  }
215  //can this happen? it means that the measgroup was not empty but no valid measurement was found inside
216  //in this case we add an invalid measuremnt for this layer
217  if (result.size() == initial_size) {
218  LogTrace("MultiRecHitCollector") << "no valid measuremnt or no valid TSOS in none of the groups";
219  //measgroup has been already checked for size != 0
220  if (!measgroup.back().measurements().empty()) {
221  result.push_back(measgroup.back().measurements().back());
222  }
223  }
224 }
const MeasurementTracker * getMeasurementTracker() const
#define LogTrace(id)
static int position[264][3]
Definition: ReadPGInfo.cc:289

◆ getEstimator()

const MeasurementEstimator* GroupedDAFHitCollector::getEstimator ( ) const
inline

Definition at line 42 of file GroupedDAFHitCollector.h.

References theEstimator.

42 { return theEstimator; }
const MeasurementEstimator * theEstimator

◆ getPropagator()

const Propagator* GroupedDAFHitCollector::getPropagator ( ) const
inline

Definition at line 43 of file GroupedDAFHitCollector.h.

References thePropagator.

43 { return thePropagator; }
const Propagator * thePropagator

◆ getReversePropagator()

const Propagator* GroupedDAFHitCollector::getReversePropagator ( ) const
inline

Definition at line 44 of file GroupedDAFHitCollector.h.

References theReversePropagator.

44 { return theReversePropagator; }
const Propagator * theReversePropagator

◆ getUpdator()

const SiTrackerMultiRecHitUpdator* GroupedDAFHitCollector::getUpdator ( ) const
inline

Definition at line 41 of file GroupedDAFHitCollector.h.

References theUpdator.

41 { return theUpdator; }
const SiTrackerMultiRecHitUpdator * theUpdator

◆ recHits()

vector< TrajectoryMeasurement > GroupedDAFHitCollector::recHits ( const Trajectory traj,
const MeasurementTrackerEvent theMT 
) const
overridevirtual

Implements MultiRecHitCollector.

Definition at line 18 of file GroupedDAFHitCollector.cc.

References alongMomentum, Trajectory::direction(), LogDebug, LogTrace, Trajectory::measurements(), mps_fire::result, edm::second(), and trackerHitRTTI::vector.

19  {
20  LayerMeasurements theLM(theMTE->measurementTracker(), *theMTE);
21 
22  //WARNING: At the moment the trajectories has the measurements with reversed sorting after the track smoothing
23  const vector<TrajectoryMeasurement>& meas = traj.measurements();
24  const Propagator* forwardPropagator = getPropagator();
25  const Propagator* backwardPropagator = getReversePropagator();
26  if (traj.direction() == alongMomentum) {
27  forwardPropagator = getReversePropagator();
28  backwardPropagator = getPropagator();
29  }
30  if (meas.empty()) //return TransientTrackingRecHit::ConstRecHitContainer();
31  return vector<TrajectoryMeasurement>();
32 
33  //groups the TrajectoryMeasurements on a layer by layer
34  vector<pair<const DetLayer*, vector<TrajectoryMeasurement> > > mol;
35  mol = MeasurementByLayerGrouper(getMeasurementTracker()->geometricSearchTracker())(meas);
36 
37  vector<TrajectoryMeasurement> result;
38 
39  //add a protection if all the measurement are on the same layer
40  if (mol.size() < 2)
41  return vector<TrajectoryMeasurement>();
42 
43  //it assumes that the measurements are sorted in the smoothing direction
44  //TrajectoryStateOnSurface current = (*(mol.begin()+1)).second.front().updatedState();
45  TrajectoryStateOnSurface current = (*(mol.rbegin() + 1)).second.back().updatedState();
46  //if (current.isValid()) current.rescaleError(10);
47 
48  //protection for layers with invalid meas with no id associated
49  //to be fixed
50  //for the moment no hit are lookerd for in these layers
51  //remind that:
52  //groupedMeasurements will return at least a measurement with an invalid hit with no detid
53  LogDebug("MultiRecHitCollector") << "Layer " << mol.back().first << " has " << mol.back().second.size()
54  << " measurements";
55  LogTrace("MultiRecHitCollector") << "Original measurements are:";
56  for (unsigned int iLay = 0; iLay < mol.size(); iLay++) {
57  LogTrace("MultiRecHitCollector") << " Layer " << mol.at(iLay).first << " has " << mol.at(iLay).second.size()
58  << " measurements:";
59  vector<TrajectoryMeasurement>::const_iterator ibeg = (mol.at(iLay)).second.begin();
60  vector<TrajectoryMeasurement>::const_iterator iend = (mol.at(iLay)).second.end();
61  for (vector<TrajectoryMeasurement>::const_iterator imeas = ibeg; imeas != iend; ++imeas) {
62  if (imeas->recHit()->isValid()) {
63  LogTrace("MultiRecHitCollector") << " Valid Hit with DetId " << imeas->recHit()->geographicalId().rawId()
64  << " local position " << imeas->recHit()->hit()->localPosition()
65  << " global position " << imeas->recHit()->hit()->globalPosition();
66  } else {
67  LogTrace("MultiRecHitCollector") << " Invalid Hit with DetId " << imeas->recHit()->geographicalId().rawId();
68  }
69  }
70  }
71 
72  //ERICA: I have to understand how are set the TM now. REPLACE THIS PART!!
73  vector<TrajectoryMeasurementGroup> groupedMeas;
74  if (mol.back().first)
75  groupedMeas = theLM.groupedMeasurements(*(mol.back().first), current, *backwardPropagator, *(getEstimator()));
76 
77  //Since we have passed the backwardPropagator, we have to sort the detGroups in the opposite way
78  //(according the forward propagator, not the backward one)
79  vector<TrajectoryMeasurementGroup> sortedgroupedMeas;
80  for (vector<TrajectoryMeasurementGroup>::reverse_iterator iter = groupedMeas.rbegin(); iter != groupedMeas.rend();
81  iter++) {
82  sortedgroupedMeas.push_back(*iter);
83  }
84 
85  //for the first layer
86  buildMultiRecHits(sortedgroupedMeas, result, theMTE);
87 
88  //for other layers
89  current = mol.back().second.front().updatedState();
90  //if (current.isValid()) current.rescaleError(10);
91 
92  for (vector<pair<const DetLayer*, vector<TrajectoryMeasurement> > >::reverse_iterator imol = mol.rbegin() + 1;
93  imol != mol.rend();
94  imol++) {
95  const DetLayer* lay = (*imol).first;
96  LogDebug("MultiRecHitCollector") << "Layer " << lay << " has " << (*imol).second.size() << " measurements";
97  //debug
98  vector<TrajectoryMeasurementGroup> currentLayerMeas;
99  if (lay) {
100  currentLayerMeas = theLM.groupedMeasurements(*lay, current, *forwardPropagator, *(getEstimator()));
101  }
102 
103  buildMultiRecHits(currentLayerMeas, result, theMTE);
104  current = (*imol).second.front().updatedState();
105  //if (current.isValid()) current.rescaleError(10);
106  }
107 
108  LogTrace("MultiRecHitCollector") << " Ending GroupedDAFHitCollector::recHits >> Original Measurement size "
109  << meas.size()
110  << "\n >> GroupedDAFHitCollector returned "
111  << result.size() << " measurements";
112  //results are sorted in the fitting direction
113 
114  // adding a protection against too few hits and invalid hits (due to failed propagation on the same surface of the original hits)
115  if (result.size() > 2) {
116  int hitcounter = 0;
117  //check if the vector result has more than 3 valid hits
118  for (vector<TrajectoryMeasurement>::const_iterator iimeas = result.begin(); iimeas != result.end(); ++iimeas) {
119  if (iimeas->recHit()->isValid())
120  hitcounter++;
121  }
122 
123  if (hitcounter > 2) {
124  return result;
125  }
126 
127  else
128  return vector<TrajectoryMeasurement>();
129  }
130 
131  else {
132  return vector<TrajectoryMeasurement>();
133  }
134 }
void buildMultiRecHits(const std::vector< TrajectoryMeasurementGroup > &measgroup, std::vector< TrajectoryMeasurement > &result, const MeasurementTrackerEvent *&theMTE) const
const Propagator * getReversePropagator() const
const MeasurementTracker * getMeasurementTracker() const
#define LogTrace(id)
DataContainer const & measurements() const
Definition: Trajectory.h:178
U second(std::pair< T, U > const &p)
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
const MeasurementEstimator * getEstimator() const
const Propagator * getPropagator() const
#define LogDebug(id)

Member Data Documentation

◆ debug_

const bool GroupedDAFHitCollector::debug_
private

Definition at line 55 of file GroupedDAFHitCollector.h.

◆ theEstimator

const MeasurementEstimator* GroupedDAFHitCollector::theEstimator
private

Definition at line 52 of file GroupedDAFHitCollector.h.

Referenced by getEstimator().

◆ thePropagator

const Propagator* GroupedDAFHitCollector::thePropagator
private

Definition at line 53 of file GroupedDAFHitCollector.h.

Referenced by getPropagator().

◆ theReversePropagator

const Propagator* GroupedDAFHitCollector::theReversePropagator
private

Definition at line 54 of file GroupedDAFHitCollector.h.

Referenced by getReversePropagator().

◆ theUpdator

const SiTrackerMultiRecHitUpdator* GroupedDAFHitCollector::theUpdator
private

Definition at line 51 of file GroupedDAFHitCollector.h.

Referenced by getUpdator().