15 #define _debug_SimpleMTFHitCollector_
19 vector<TrajectoryMeasurement>
22 double annealing)
const{
26 map< int, vector<TrajectoryMeasurement> >::const_iterator itmeas = tmmap.find(i);
27 LogDebug(
"SimpleMTFHitCollector") <<
"found the element "<< i <<
"in the map" << std::endl;
29 vector<TrajectoryMeasurement> meas = itmeas->second;
30 LogDebug(
"SimpleMTFHitCollector") <<
"got the vector corresponding to " << i <<
" element of the map "<< std::endl;
33 return vector<TrajectoryMeasurement>();
37 vector<TrajectoryMeasurement>
result;
41 for(vector<TrajectoryMeasurement>::reverse_iterator imeas = meas.rbegin(); imeas != meas.rend(); imeas++)
45 if(imeas->recHit()->geographicalId().rawId())
51 uint32_t
id = imeas->recHit()->geographicalId().rawId();
53 LogDebug(
"SimpleMTFHitCollector") <<
"Detector Id: " <<
id << std::endl;
56 std::vector<std::pair<int, TrajectoryMeasurement> > layermeas;
57 getMeasurements(layermeas, tmmap,*imeas,i);
66 for (vector<std::pair<int, TrajectoryMeasurement> >::const_iterator ittmeas = layermeas.begin(); ittmeas != layermeas.end(); ittmeas++)
70 if(ittmeas->second.recHit()->isValid())
73 LogDebug(
"SimpleMTFHitCollector") <<
"this rechit in the vector layermeas is valid." << std::endl;
81 hits.push_back(ittmeas->second.recHit());
89 for(TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihits = hits.begin(); ihits != hits.end(); ihits++ )
97 LogDebug(
"SimpleMTFHitCollector") <<
"the rechit coming from layermeas is the same as the first rechit "
98 <<
"we skip this rechit in building the multirechit" << std::endl;
117 LogTrace(
"SimpleMTFHitCollector") <<
"This hit is valid ";
118 hits.push_back(ittmeas->second.recHit());
132 result.push_back(*imeas);
133 LogDebug(
"SimpleMTFHitCollector") <<
"we found no valid rechits, so we fill the vector with the initial measurement" << std::endl;
142 LogDebug(
"SimpleMTFHitCollector") <<
"we build a trajectory measurement from a vector of hits of size" << hits.size() <<std::endl;
144 result.push_back(
TrajectoryMeasurement(state,theUpdator->buildMultiRecHit(state, hits, &mtm, annealing)));
154 result.push_back(*imeas);
160 LogTrace(
"MultiRecHitCollector") <<
"Original Measurement size "
161 << meas.size() <<
" SimpleMTFHitCollector returned "
162 << result.size() <<
" rechits";
171 const std::map<
int, vector<TrajectoryMeasurement> >& tmmap,
175 uint32_t
id = pmeas.
recHit()->geographicalId().rawId();
177 LogDebug(
"SimpleMTFHitCollector") <<
"Detector Id: " <<
id << std::endl;
181 if( pmeas.
recHit()->geographicalId().rawId() )
207 for (
std::map<
int, vector<TrajectoryMeasurement> >::const_iterator immap=tmmap.begin();
211 int ntraj2 = immap->first;
214 const vector<TrajectoryMeasurement> & vecmeas = immap->second;
219 for(vector<TrajectoryMeasurement>::const_reverse_iterator itvmeas = vecmeas.rbegin(); itvmeas!=vecmeas.rend(); itvmeas++)
224 if ( (itvmeas->recHit()->geographicalId().rawId() == id) )
226 LogDebug(
"SimpleMTFHitCollector") <<
"found a matching rechit in the collector";
229 layermeas.push_back(make_pair(ntraj2,*itvmeas));
248 LogDebug(
"SimpleMTFHitCollector") <<
" built a vector of Trajectory Measurements all on the same layer, of size: "
253 else layermeas.push_back(make_pair(i,pmeas));
263 uint32_t
id = rechit->geographicalId().rawId();
265 LogDebug(
"SimpleMTFHitCollector") <<
"Detector Id: " <<
id << std::endl;
267 LogDebug(
"SimpleMTFHitCollector") <<
"LayerMeas size: " << layermeas.size() << std::endl;
269 const DetLayer* layer = layermeas.front().second.layer();
271 std::map<int,TSOS> predictions;
272 std::map<int,TSOS> updates;
273 LogDebug(
"SimpleMTFHitCollector") <<
" about to build a map with predicted and updated states " << std::endl;
291 for (std::vector<std::pair<int,TrajectoryMeasurement> >::const_iterator itmeas=layermeas.begin(); itmeas!=layermeas.end(); itmeas++)
295 LogDebug(
"SimpleMTFHitCollector") <<
" number of the trajectory examined: " << itmeas->first << std::endl;
308 if ( (itmeas->second.recHit()->geographicalId().rawId() == id) )
314 if(itmeas->second.predictedState().isValid())
316 predictions[itmeas->first] = itmeas->second.predictedState();
318 if ( itmeas->second.backwardPredictedState().isValid() ){
319 updates[itmeas->first]= statecombiner.
combine(itmeas->second.predictedState(), itmeas->second.backwardPredictedState());
330 LogDebug(
"SimpleMTFHitCollector") <<
"error:invalid predicted state" << std::endl;
384 vector<TrajectoryMeasurement>
result;
396 uint32_t
id = pmeas.
recHit()->geographicalId().rawId();
398 LogDebug(
"SimpleMTFHitCollector") <<
"Detector Id: " <<
id << std::endl;
401 vector<std::pair<int, TrajectoryMeasurement> > layermeas;
402 getMeasurements(layermeas, tmmap,pmeas,i);
406 return getTSOS(layermeas, rechit, i);
430 vector<TrajectoryMeasurement>&
result,
431 double annealing)
const {
434 LogTrace(
"SimpleMTFHitCollector") <<
"the search for the measurement on the same layer returned an empty vector...we have got a problem... " ;
443 LogTrace(
"SimpleMTFHitCollector") <<
"Position (local) of the first measurement state: " << state.
localPosition();
444 LogTrace(
"SimpleMTFHitCollector") <<
"Position (global) of the first measurement state: " << state.
globalPosition();
447 LogTrace(
"MultiRecHitCollector") <<
"first state is invalid; skipping ";
454 for (vector<std::pair<int, TrajectoryMeasurement> >::const_iterator ittmeas = vmeas.begin(); ittmeas != vmeas.end(); ittmeas++){
456 LogTrace(
"SimpleMTFHitCollector") <<
"This hit is valid ";
457 hits.push_back(ittmeas->second.recHit());
462 LogTrace(
"MultiTrackFilterHitCollector") <<
"No valid hits found ";
466 LogTrace(
"SimpleMTFHitCollector") <<
"The hits vector has size: " << hits.size() <<
"\n"
467 <<
"and has first component global position: " << hits.front()->globalPosition();
480 result.push_back(
TrajectoryMeasurement(state,theUpdator->buildMultiRecHit(state, hits, mtm, annealing)));
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
LocalPoint localPosition() const
GlobalPoint globalPosition() const
ConstRecHitPointer recHit() const
MultiTrajectoryMeasurement TSOSfinder(const std::map< int, std::vector< TrajectoryMeasurement > > &tmmap, TrajectoryMeasurement &pmeas, int i) const
virtual std::vector< TrajectoryMeasurement > recHits(const std::map< int, std::vector< TrajectoryMeasurement > > &tmmap, int i, double annealing=1.) const
MultiTrajectoryMeasurement getTSOS(const std::vector< std::pair< int, TrajectoryMeasurement > > &layermeas, TransientTrackingRecHit::ConstRecHitPointer rechit, int i) const
std::vector< ConstRecHitPointer > ConstRecHitContainer
void buildMultiRecHits(const std::vector< std::pair< int, TrajectoryMeasurement > > &measgroup, MultiTrajectoryMeasurement *mtm, std::vector< TrajectoryMeasurement > &result, double annealing=1.) const
void getMeasurements(std::vector< std::pair< int, TrajectoryMeasurement > > &layermeas, const std::map< int, std::vector< TrajectoryMeasurement > > &tmmap, TrajectoryMeasurement &pmeas, int i) const