CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

GroupedDAFHitCollector Class Reference

#include <GroupedDAFHitCollector.h>

Inheritance diagram for GroupedDAFHitCollector:
MultiRecHitCollector

List of all members.

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 ()

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 
) [inline, explicit]

Definition at line 13 of file GroupedDAFHitCollector.h.

                                  :MultiRecHitCollector(measurementTracker), theLM(measurementTracker), theUpdator(updator), theEstimator(est), thePropagator(propagator), theReversePropagator(reversePropagator){}
virtual GroupedDAFHitCollector::~GroupedDAFHitCollector ( ) [inline, virtual]

Definition at line 21 of file GroupedDAFHitCollector.h.

{}

Member Function Documentation

void GroupedDAFHitCollector::buildMultiRecHits ( const std::vector< TrajectoryMeasurementGroup > &  measgroup,
std::vector< TrajectoryMeasurement > &  result 
) const [private]
const MeasurementEstimator* GroupedDAFHitCollector::getEstimator ( ) const [inline]

Definition at line 32 of file GroupedDAFHitCollector.h.

References theEstimator.

{return theEstimator;}
const Propagator* GroupedDAFHitCollector::getPropagator ( ) const [inline]

Definition at line 33 of file GroupedDAFHitCollector.h.

References thePropagator.

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

Definition at line 34 of file GroupedDAFHitCollector.h.

References theReversePropagator.

const SiTrackerMultiRecHitUpdator* GroupedDAFHitCollector::getUpdator ( ) const [inline]

Definition at line 31 of file GroupedDAFHitCollector.h.

References theUpdator.

{return 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.

                                                                                         {

        //it assumes that the measurements are sorted in the smoothing direction
        const vector<TrajectoryMeasurement>& meas = traj.measurements();
        const Propagator* forwardPropagator = getPropagator();
        const Propagator* backwardPropagator = getReversePropagator();
        if (traj.direction() == alongMomentum){
                forwardPropagator = getReversePropagator();
                backwardPropagator = getPropagator(); 
        }  
        if (meas.empty()) //return TransientTrackingRecHit::ConstRecHitContainer();     
                return vector<TrajectoryMeasurement>();

        vector<pair<const DetLayer*, vector<TrajectoryMeasurement> > > mol = MeasurementByLayerGrouper(getMeasurementTracker()->geometricSearchTracker())(meas);


        //TransientTrackingRecHit::ConstRecHitContainer result;
        vector<TrajectoryMeasurement> result;

        //add a protection if all the measurement are on the same layer
        if(mol.size()<2)return vector<TrajectoryMeasurement>();

        //first layer
        //  cout<<"DAFHitCollectionFromRecTrack: first layer"<<endl;

        //it assumes that the measurements are sorted in the smoothing direction
        //TrajectoryStateOnSurface current = (*(mol.begin()+1)).second.front().updatedState();
        TrajectoryStateOnSurface current = (*(mol.rbegin()+1)).second.back().updatedState();
        //if (current.isValid()) current.rescaleError(10);

        
        vector<TrajectoryMeasurementGroup> groupedMeas;
        //protection for layers with invalid meas with no id associated
        //to be fixed
        //for the moment no hit are lookerd for in these layers
        //remind that:
        //groupedMeasurements will return at least a measurement with an invalid hit with no detid
        LogDebug("MultiRecHitCollector") << "Layer "  << mol.back().first  << " has " << mol.back().second.size() << " measurements";
        //debug
        LogTrace("MultiRecHitCollector") << "Original measurements are:";
        vector<TrajectoryMeasurement>::const_iterator ibeg = mol.back().second.begin();
        vector<TrajectoryMeasurement>::const_iterator iend = mol.back().second.end();
        for (vector<TrajectoryMeasurement>::const_iterator imeas = ibeg; imeas != iend; ++imeas){
                if (imeas->recHit()->isValid()){
                  LogTrace("MultiRecHitCollector") << "Valid Hit with DetId " << imeas->recHit()->geographicalId().rawId()
                                                   << " local position " << imeas->recHit()->hit()->localPosition();
                    //                                             << " on " << giulioGetLayer(imeas->recHit()->geographicalId());
                } else {
                  LogTrace("MultiRecHitCollector") << "Invalid Hit with DetId " << imeas->recHit()->geographicalId().rawId(); 
                    //" on " << giulioGetLayer(imeas->recHit()->geographicalId());
                }
        }
        //debug          
        if (mol.back().first) groupedMeas = theLM.groupedMeasurements(*(mol.back().first), current, *backwardPropagator, *(getEstimator()));
        //in this case we have to sort the detGroups in the opposite way (according the forward propagator, not the backward one)
        vector<TrajectoryMeasurementGroup> sortedgroupedMeas; 
        for (vector<TrajectoryMeasurementGroup>::reverse_iterator iter = groupedMeas.rbegin();  iter != groupedMeas.rend(); iter++){
                sortedgroupedMeas.push_back(*iter);
        }
        buildMultiRecHits(sortedgroupedMeas, result);
                

        //other layers
        current = mol.back().second.front().updatedState();
        //if (current.isValid()) current.rescaleError(10);
        for(vector<pair<const DetLayer*, vector<TrajectoryMeasurement> > >::reverse_iterator imol = mol.rbegin() + 1; imol != mol.rend(); imol++) {
                const DetLayer* lay = (*imol).first;
                LogDebug("MultiRecHitCollector") << "Layer "  << lay << " has " << (*imol).second.size() << " measurements";
                //debug
                LogTrace("MultiRecHitCollector") << "Original measurements are:";
                vector<TrajectoryMeasurement>::const_iterator ibeg = (*imol).second.begin();
                vector<TrajectoryMeasurement>::const_iterator iend = (*imol).second.end();
                for (vector<TrajectoryMeasurement>::const_iterator imeas = ibeg; imeas != iend; ++imeas){
                        if (imeas->recHit()->isValid()){
                          LogTrace("MultiRecHitCollector") << "Valid Hit with DetId " << imeas->recHit()->geographicalId().rawId()
                                                           << " local position " << imeas->recHit()->hit()->localPosition();
                            //<< " on " << giulioGetLayer(imeas->recHit()->geographicalId());
                        } else {
                          LogTrace("MultiRecHitCollector") << "Invalid Hit with DetId " << imeas->recHit()->geographicalId().rawId();
                          //<< " on " << giulioGetLayer(imeas->recHit()->geographicalId());
                        }
                }
                //debug 
                vector<TrajectoryMeasurementGroup> currentLayerMeas;
                if (lay) currentLayerMeas = theLM.groupedMeasurements(*lay, current, *forwardPropagator, *(getEstimator()));
                buildMultiRecHits(currentLayerMeas, result);
                current = (*imol).second.front().updatedState();
                //if (current.isValid()) current.rescaleError(10);
        }
        LogTrace("MultiRecHitCollector") << "Original Measurement size "  << meas.size() << " GroupedDAFHitCollector returned " << result.size() << " measurements";
        //results are sorted in the fitting direction

 //     adding a protection against too few hits and invalid hits (due to failed propagation on the same surface of the original hits)
        if (result.size()>2)
          {
            int hitcounter=0;
            //check if the vector result has more than 3 valid hits
            for (vector<TrajectoryMeasurement>::const_iterator iimeas = result.begin(); iimeas != result.end(); ++iimeas)
              {
                if(iimeas->recHit()->isValid()) hitcounter++;
              }
            
            if(hitcounter>2) 
              {return result;} 
            
            else return vector<TrajectoryMeasurement>();
          }
        
        else{return vector<TrajectoryMeasurement>();}
        
}

Member Data Documentation

Definition at line 42 of file GroupedDAFHitCollector.h.

Referenced by getEstimator().

Definition at line 40 of file GroupedDAFHitCollector.h.

Definition at line 43 of file GroupedDAFHitCollector.h.

Referenced by getPropagator().

Definition at line 44 of file GroupedDAFHitCollector.h.

Referenced by getReversePropagator().

Definition at line 41 of file GroupedDAFHitCollector.h.

Referenced by getUpdator().