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
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)
 
virtual std::vector
< TrajectoryMeasurement
recHits (const Trajectory &, const MeasurementTrackerEvent *theMT) const override
 
virtual ~GroupedDAFHitCollector ()
 
- Public Member Functions inherited from MultiRecHitCollector
const MeasurementTrackergetMeasurementTracker () const
 
 MultiRecHitCollector (const MeasurementTracker *meas)
 

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 ( const MeasurementTracker measurementTracker,
const SiTrackerMultiRecHitUpdator updator,
const MeasurementEstimator est,
const Propagator propagator,
const Propagator reversePropagator,
bool  debug 
)
inlineexplicit

Definition at line 25 of file GroupedDAFHitCollector.h.

29  :
30  MultiRecHitCollector(measurementTracker), theUpdator(updator),
31  theEstimator(est), thePropagator(propagator), theReversePropagator(reversePropagator), debug_(debug){}
const Propagator * theReversePropagator
const MeasurementEstimator * theEstimator
MultiRecHitCollector(const MeasurementTracker *meas)
#define debug
Definition: HDRShower.cc:19
const SiTrackerMultiRecHitUpdator * theUpdator
const Propagator * thePropagator
virtual GroupedDAFHitCollector::~GroupedDAFHitCollector ( )
inlinevirtual

Definition at line 34 of file GroupedDAFHitCollector.h.

34 {}

Member Function Documentation

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

Definition at line 138 of file GroupedDAFHitCollector.cc.

References TrackingRecHit::bad, TrackingRecHit::inactive, TrajectoryStateOnSurface::isValid(), LogTrace, TrackingRecHit::missing, GloballyPositioned< T >::position(), position, and TrajectoryStateOnSurface::surface().

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

Definition at line 40 of file GroupedDAFHitCollector.h.

References theEstimator.

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

Definition at line 41 of file GroupedDAFHitCollector.h.

References thePropagator.

41 {return thePropagator;}
const Propagator * thePropagator
const Propagator* GroupedDAFHitCollector::getReversePropagator ( ) const
inline

Definition at line 42 of file GroupedDAFHitCollector.h.

References theReversePropagator.

42 {return theReversePropagator;}
const Propagator * theReversePropagator
const SiTrackerMultiRecHitUpdator* GroupedDAFHitCollector::getUpdator ( ) const
inline

Definition at line 39 of file GroupedDAFHitCollector.h.

References theUpdator.

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

Implements MultiRecHitCollector.

Definition at line 18 of file GroupedDAFHitCollector.cc.

References alongMomentum, cond::rpcobimon::current, Trajectory::direction(), LogDebug, LogTrace, Trajectory::measurements(), query::result, and edm::second().

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

Member Data Documentation

const bool GroupedDAFHitCollector::debug_
private

Definition at line 53 of file GroupedDAFHitCollector.h.

const MeasurementEstimator* GroupedDAFHitCollector::theEstimator
private

Definition at line 50 of file GroupedDAFHitCollector.h.

Referenced by getEstimator().

const Propagator* GroupedDAFHitCollector::thePropagator
private

Definition at line 51 of file GroupedDAFHitCollector.h.

Referenced by getPropagator().

const Propagator* GroupedDAFHitCollector::theReversePropagator
private

Definition at line 52 of file GroupedDAFHitCollector.h.

Referenced by getReversePropagator().

const SiTrackerMultiRecHitUpdator* GroupedDAFHitCollector::theUpdator
private

Definition at line 49 of file GroupedDAFHitCollector.h.

Referenced by getUpdator().