15 #define _debug_GroupedDAFHitCollector_
23 const vector<TrajectoryMeasurement>& meas = traj.
measurements();
24 const Propagator* forwardPropagator = getPropagator();
25 const Propagator* backwardPropagator = getReversePropagator();
27 forwardPropagator = getReversePropagator();
28 backwardPropagator = getPropagator();
31 return vector<TrajectoryMeasurement>();
33 vector<pair<const DetLayer*, vector<TrajectoryMeasurement> > > mol =
MeasurementByLayerGrouper(getMeasurementTracker()->geometricSearchTracker())(meas);
37 vector<TrajectoryMeasurement>
result;
40 if(mol.size()<2)
return vector<TrajectoryMeasurement>();
51 vector<TrajectoryMeasurementGroup> groupedMeas;
57 LogDebug(
"MultiRecHitCollector") <<
"Layer " << mol.back().first <<
" has " << mol.back().second.size() <<
" measurements";
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();
68 LogTrace(
"MultiRecHitCollector") <<
"Invalid Hit with DetId " << imeas->recHit()->geographicalId().rawId();
73 if (mol.back().first) groupedMeas = theLM.groupedMeasurements(*(mol.back().first), current, *backwardPropagator, *(getEstimator()));
75 vector<TrajectoryMeasurementGroup> sortedgroupedMeas;
76 for (vector<TrajectoryMeasurementGroup>::reverse_iterator iter = groupedMeas.rbegin(); iter != groupedMeas.rend(); iter++){
77 sortedgroupedMeas.push_back(*iter);
79 buildMultiRecHits(sortedgroupedMeas, result);
83 current = mol.back().second.front().updatedState();
85 for(vector<pair<
const DetLayer*, vector<TrajectoryMeasurement> > >::reverse_iterator imol = mol.rbegin() + 1; imol != mol.rend(); imol++) {
87 LogDebug(
"MultiRecHitCollector") <<
"Layer " << lay <<
" has " << (*imol).second.size() <<
" measurements";
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();
98 LogTrace(
"MultiRecHitCollector") <<
"Invalid Hit with DetId " << imeas->recHit()->geographicalId().rawId();
103 vector<TrajectoryMeasurementGroup> currentLayerMeas;
104 if (lay) currentLayerMeas = theLM.groupedMeasurements(*lay, current, *forwardPropagator, *(getEstimator()));
105 buildMultiRecHits(currentLayerMeas, result);
106 current = (*imol).second.front().updatedState();
109 LogTrace(
"MultiRecHitCollector") <<
"Original Measurement size " << meas.size() <<
" GroupedDAFHitCollector returned " << result.size() <<
" measurements";
117 for (vector<TrajectoryMeasurement>::const_iterator iimeas = result.begin(); iimeas != result.end(); ++iimeas)
119 if(iimeas->recHit()->isValid()) hitcounter++;
125 else return vector<TrajectoryMeasurement>();
128 else{
return vector<TrajectoryMeasurement>();}
134 unsigned int initial_size = result.size();
136 if (measgroup.empty()) {
137 LogTrace(
"MultiRecHitCollector") <<
"No TrajectoryMeasurementGroups found for this layer" ;
146 LogTrace(
"MultiRecHitCollector") <<
"Found " << measgroup.size() <<
" groups for this layer";
149 for (vector<TrajectoryMeasurementGroup>::const_iterator igroup = measgroup.begin(); igroup != measgroup.end(); igroup++ ){
153 LogTrace(
"MultiRecHitCollector") <<
"Something wrong! no valid TSOS found in current group ";
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();
164 vector<const TrackingRecHit*> hits;
165 for (vector<TrajectoryMeasurement>::const_iterator imeas = igroup->measurements().begin(); imeas != igroup->measurements().end(); imeas++){
169 LogTrace(
"MultiRecHitCollector") <<
"This hit is valid ";
170 hits.push_back(imeas->recHit()->hit());
174 LogTrace(
"MultiRecHitCollector") <<
"No valid hits found in current group ";
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";
185 LogTrace(
"MultiRecHitCollector") <<
"DetId " << (*iter)->geographicalId().rawId() <<
" validity: " << validity
186 <<
" surface position " << getMeasurementTracker()->geomTracker()->idToDet((*iter)->geographicalId())->
position()
187 <<
" hit local position " << (*iter)->localPosition();
196 if (result.size() == initial_size){
197 LogTrace(
"MultiRecHitCollector") <<
"no valid measuremnt or no valid TSOS in none of the groups";
199 if (measgroup.back().measurements().size() != 0){
200 result.push_back(measgroup.back().measurements().back());
void buildMultiRecHits(const std::vector< TrajectoryMeasurementGroup > &measgroup, std::vector< TrajectoryMeasurement > &result) const
virtual std::vector< TrajectoryMeasurement > recHits(const Trajectory &) const
static int position[TOTALCHAMBERS][3]
PropagationDirection const & direction() const
DataContainer const & measurements() const
const Surface & surface() const
const PositionType & position() const