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)
 
virtual std::vector
< TrajectoryMeasurement
recHits (const Trajectory &) const
 
virtual ~GroupedDAFHitCollector ()
 
- Public Member Functions inherited from MultiRecHitCollector
const MeasurementTrackergetMeasurementTracker () const
 
 MultiRecHitCollector (const MeasurementTracker *meas)
 
void updateEvent (const edm::Event &e) const
 

Private Member Functions

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

Private Attributes

const MeasurementEstimatortheEstimator
 
LayerMeasurements theLM
 
const PropagatorthePropagator
 
const PropagatortheReversePropagator
 
const SiTrackerMultiRecHitUpdatortheUpdator
 

Detailed Description

Definition at line 11 of file GroupedDAFHitCollector.h.

Constructor & Destructor Documentation

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

Definition at line 13 of file GroupedDAFHitCollector.h.

18  :MultiRecHitCollector(measurementTracker), theLM(measurementTracker), theUpdator(updator), theEstimator(est), thePropagator(propagator), theReversePropagator(reversePropagator){}
const Propagator * theReversePropagator
const MeasurementEstimator * theEstimator
MultiRecHitCollector(const MeasurementTracker *meas)
const SiTrackerMultiRecHitUpdator * theUpdator
const Propagator * thePropagator
virtual GroupedDAFHitCollector::~GroupedDAFHitCollector ( )
inlinevirtual

Definition at line 21 of file GroupedDAFHitCollector.h.

21 {}

Member Function Documentation

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

Definition at line 132 of file GroupedDAFHitCollector.cc.

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

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

Definition at line 32 of file GroupedDAFHitCollector.h.

References theEstimator.

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

Definition at line 33 of file GroupedDAFHitCollector.h.

References thePropagator.

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

Definition at line 34 of file GroupedDAFHitCollector.h.

References theReversePropagator.

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

Definition at line 31 of file GroupedDAFHitCollector.h.

References theUpdator.

31 {return theUpdator;}
const SiTrackerMultiRecHitUpdator * theUpdator
vector< TrajectoryMeasurement > GroupedDAFHitCollector::recHits ( const Trajectory traj) const
virtual

Implements MultiRecHitCollector.

Definition at line 20 of file GroupedDAFHitCollector.cc.

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

20  {
21 
22  //it assumes that the measurements are sorted in the smoothing direction
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  vector<pair<const DetLayer*, vector<TrajectoryMeasurement> > > mol = MeasurementByLayerGrouper(getMeasurementTracker()->geometricSearchTracker())(meas);
34 
35 
36  //TransientTrackingRecHit::ConstRecHitContainer result;
37  vector<TrajectoryMeasurement> result;
38 
39  //add a protection if all the measurement are on the same layer
40  if(mol.size()<2)return vector<TrajectoryMeasurement>();
41 
42  //first layer
43  // cout<<"DAFHitCollectionFromRecTrack: first layer"<<endl;
44 
45  //it assumes that the measurements are sorted in the smoothing direction
46  //TrajectoryStateOnSurface current = (*(mol.begin()+1)).second.front().updatedState();
47  TrajectoryStateOnSurface current = (*(mol.rbegin()+1)).second.back().updatedState();
48  //if (current.isValid()) current.rescaleError(10);
49 
50 
51  vector<TrajectoryMeasurementGroup> groupedMeas;
52  //protection for layers with invalid meas with no id associated
53  //to be fixed
54  //for the moment no hit are lookerd for in these layers
55  //remind that:
56  //groupedMeasurements will return at least a measurement with an invalid hit with no detid
57  LogDebug("MultiRecHitCollector") << "Layer " << mol.back().first << " has " << mol.back().second.size() << " measurements";
58  //debug
59  LogTrace("MultiRecHitCollector") << "Original measurements are:";
60  vector<TrajectoryMeasurement>::const_iterator ibeg = mol.back().second.begin();
61  vector<TrajectoryMeasurement>::const_iterator iend = mol.back().second.end();
62  for (vector<TrajectoryMeasurement>::const_iterator imeas = ibeg; imeas != iend; ++imeas){
63  if (imeas->recHit()->isValid()){
64  LogTrace("MultiRecHitCollector") << "Valid Hit with DetId " << imeas->recHit()->geographicalId().rawId()
65  << " local position " << imeas->recHit()->hit()->localPosition();
66  // << " on " << giulioGetLayer(imeas->recHit()->geographicalId());
67  } else {
68  LogTrace("MultiRecHitCollector") << "Invalid Hit with DetId " << imeas->recHit()->geographicalId().rawId();
69  //" on " << giulioGetLayer(imeas->recHit()->geographicalId());
70  }
71  }
72  //debug
73  if (mol.back().first) groupedMeas = theLM.groupedMeasurements(*(mol.back().first), current, *backwardPropagator, *(getEstimator()));
74  //in this case we have to sort the detGroups in the opposite way (according the forward propagator, not the backward one)
75  vector<TrajectoryMeasurementGroup> sortedgroupedMeas;
76  for (vector<TrajectoryMeasurementGroup>::reverse_iterator iter = groupedMeas.rbegin(); iter != groupedMeas.rend(); iter++){
77  sortedgroupedMeas.push_back(*iter);
78  }
79  buildMultiRecHits(sortedgroupedMeas, result);
80 
81 
82  //other layers
83  current = mol.back().second.front().updatedState();
84  //if (current.isValid()) current.rescaleError(10);
85  for(vector<pair<const DetLayer*, vector<TrajectoryMeasurement> > >::reverse_iterator imol = mol.rbegin() + 1; imol != mol.rend(); imol++) {
86  const DetLayer* lay = (*imol).first;
87  LogDebug("MultiRecHitCollector") << "Layer " << lay << " has " << (*imol).second.size() << " measurements";
88  //debug
89  LogTrace("MultiRecHitCollector") << "Original measurements are:";
90  vector<TrajectoryMeasurement>::const_iterator ibeg = (*imol).second.begin();
91  vector<TrajectoryMeasurement>::const_iterator iend = (*imol).second.end();
92  for (vector<TrajectoryMeasurement>::const_iterator imeas = ibeg; imeas != iend; ++imeas){
93  if (imeas->recHit()->isValid()){
94  LogTrace("MultiRecHitCollector") << "Valid Hit with DetId " << imeas->recHit()->geographicalId().rawId()
95  << " local position " << imeas->recHit()->hit()->localPosition();
96  //<< " on " << giulioGetLayer(imeas->recHit()->geographicalId());
97  } else {
98  LogTrace("MultiRecHitCollector") << "Invalid Hit with DetId " << imeas->recHit()->geographicalId().rawId();
99  //<< " on " << giulioGetLayer(imeas->recHit()->geographicalId());
100  }
101  }
102  //debug
103  vector<TrajectoryMeasurementGroup> currentLayerMeas;
104  if (lay) currentLayerMeas = theLM.groupedMeasurements(*lay, current, *forwardPropagator, *(getEstimator()));
105  buildMultiRecHits(currentLayerMeas, result);
106  current = (*imol).second.front().updatedState();
107  //if (current.isValid()) current.rescaleError(10);
108  }
109  LogTrace("MultiRecHitCollector") << "Original Measurement size " << meas.size() << " GroupedDAFHitCollector returned " << result.size() << " measurements";
110  //results are sorted in the fitting direction
111 
112  // adding a protection against too few hits and invalid hits (due to failed propagation on the same surface of the original hits)
113  if (result.size()>2)
114  {
115  int hitcounter=0;
116  //check if the vector result has more than 3 valid hits
117  for (vector<TrajectoryMeasurement>::const_iterator iimeas = result.begin(); iimeas != result.end(); ++iimeas)
118  {
119  if(iimeas->recHit()->isValid()) hitcounter++;
120  }
121 
122  if(hitcounter>2)
123  {return result;}
124 
125  else return vector<TrajectoryMeasurement>();
126  }
127 
128  else{return vector<TrajectoryMeasurement>();}
129 
130 }
#define LogDebug(id)
void buildMultiRecHits(const std::vector< TrajectoryMeasurementGroup > &measgroup, std::vector< TrajectoryMeasurement > &result) const
PropagationDirection const & direction() const
Definition: Trajectory.cc:195
DataContainer const & measurements() const
Definition: Trajectory.h:169
const MeasurementTracker * getMeasurementTracker() const
tuple result
Definition: query.py:137
#define LogTrace(id)
const Propagator * getPropagator() const
std::vector< TrajectoryMeasurementGroup > groupedMeasurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
const Propagator * getReversePropagator() const
const MeasurementEstimator * getEstimator() const

Member Data Documentation

const MeasurementEstimator* GroupedDAFHitCollector::theEstimator
private

Definition at line 42 of file GroupedDAFHitCollector.h.

Referenced by getEstimator().

LayerMeasurements GroupedDAFHitCollector::theLM
private

Definition at line 40 of file GroupedDAFHitCollector.h.

const Propagator* GroupedDAFHitCollector::thePropagator
private

Definition at line 43 of file GroupedDAFHitCollector.h.

Referenced by getPropagator().

const Propagator* GroupedDAFHitCollector::theReversePropagator
private

Definition at line 44 of file GroupedDAFHitCollector.h.

Referenced by getReversePropagator().

const SiTrackerMultiRecHitUpdator* GroupedDAFHitCollector::theUpdator
private

Definition at line 41 of file GroupedDAFHitCollector.h.

Referenced by getUpdator().