CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

DynamicTruncation Class Reference

#include <DynamicTruncation.h>

List of all members.

Public Types

typedef
TransientTrackingRecHit::ConstRecHitContainer 
ConstRecHitContainer
typedef
TransientTrackingRecHit::ConstRecHitPointer 
ConstRecHitPointer

Public Member Functions

 DynamicTruncation (const edm::Event &, const MuonServiceProxy &)
TransientTrackingRecHit::ConstRecHitContainer filter (const Trajectory &)
std::vector< double > getEstimators ()
void setThr (int, int)
 ~DynamicTruncation ()

Private Member Functions

void compatibleDets (TrajectoryStateOnSurface &, std::map< int, std::vector< DetId > > &)
void filteringAlgo (std::map< int, std::vector< DetId > > &)
double getBest (std::vector< DTRecSegment4D > &, TrajectoryStateOnSurface &, DTRecSegment4D &)
double getBest (std::vector< CSCSegment > &, TrajectoryStateOnSurface &, CSCSegment &)
ConstRecHitContainer sort (ConstRecHitContainer &)
void update (TrajectoryStateOnSurface &, ConstRecHitPointer)
void updateWithCSChits (ConstRecHitContainer &)
void updateWithDThits (ConstRecHitContainer &)

Private Attributes

edm::ESHandle< CSCGeometrycscGeom
int CSCThr
TrajectoryStateOnSurface currentState
int DTThr
std::vector< double > estimators
edm::ESHandle< MagneticFieldmagfield
DirectMuonNavigationnavigation
edm::ESHandle
< MuonDetLayerGeometry
navMuon
edm::ESHandle< Propagatorpropagator
edm::ESHandle< PropagatorpropagatorCompatibleDet
ConstRecHitContainer result
const edm::EventtheEvent
edm::ESHandle
< GlobalTrackingGeometry
theG
edm::ESHandle
< TransientTrackingRecHitBuilder
theMuonRecHitBuilder
const edm::EventSetuptheSetup
edm::ESHandle
< TrajectoryStateUpdator
updatorHandle

Detailed Description

Class: DynamicTruncation

Description: class for the dynamical stop of the KF according to the compatibility degree between the extrapolated track state and the reconstructed segment in the muon chambers

Date:
2011/06/08 09:42:58
Revision:
1.5

Authors : D. Pagano & G. Bruno - UCL Louvain

Definition at line 46 of file DynamicTruncation.h.


Member Typedef Documentation

Definition at line 51 of file DynamicTruncation.h.

Definition at line 50 of file DynamicTruncation.h.


Constructor & Destructor Documentation

DynamicTruncation::DynamicTruncation ( const edm::Event event,
const MuonServiceProxy &  theService 
)

Definition at line 41 of file DynamicTruncation.cc.

References cscGeom, event(), magfield, navigation, navMuon, propagator, propagatorCompatibleDet, theEvent, theG, theMuonRecHitBuilder, theSetup, and updatorHandle.

                                                                                             :
  DTThr(0), CSCThr(0) 
{
  theEvent = &event;
  theSetup = &theService.eventSetup();
  propagator = theService.propagator("SmartPropagator");
  propagatorCompatibleDet = theService.propagator("SteppingHelixPropagatorAny");
  theG = theService.trackingGeometry();
  theService.eventSetup().get<TransientRecHitRecord>().get("MuonRecHitBuilder",theMuonRecHitBuilder);
  theService.eventSetup().get<TrackingComponentsRecord>().get("KFUpdator",updatorHandle);
  theService.eventSetup().get<MuonGeometryRecord>().get(cscGeom);
  theService.eventSetup().get<MuonRecoGeometryRecord>().get(navMuon);
  theService.eventSetup().get<IdealMagneticFieldRecord>().get(magfield);
  navigation = new DirectMuonNavigation(theService.detLayerGeometry());
}
DynamicTruncation::~DynamicTruncation ( )

Definition at line 59 of file DynamicTruncation.cc.

References navigation.

                                      {
  if (navigation) delete navigation;
}

Member Function Documentation

void DynamicTruncation::compatibleDets ( TrajectoryStateOnSurface ,
std::map< int, std::vector< DetId > > &   
) [private]

Referenced by filter().

TransientTrackingRecHit::ConstRecHitContainer DynamicTruncation::filter ( const Trajectory traj)

Definition at line 65 of file DynamicTruncation.cc.

References compatibleDets(), currentState, DetId::det(), filteringAlgo(), TrajectoryMeasurement::forwardPredictedState(), TrackingRecHit::geographicalId(), TrajectoryStateOnSurface::globalPosition(), PV3DBase< T, PVType, FrameType >::mag(), Trajectory::measurements(), TrajectoryMeasurement::recHit(), result, align::Tracker, and update().

Referenced by GlobalMuonRefitter::refit().

                                                                                            {
  result.clear();
  // Put the tracker hits in the final vector and get the last tracker valid measure
  std::vector<TrajectoryMeasurement> muonMeasurements = traj.measurements();
  TrajectoryMeasurement lastTKm = muonMeasurements.front();
  for (std::vector<TrajectoryMeasurement>::const_iterator imT = muonMeasurements.begin(); imT != muonMeasurements.end(); imT++ ) {
    if ( !(*imT).recHit()->isValid() ) continue;
    const TransientTrackingRecHit* hit = &(*(*imT).recHit());
    if (hit->geographicalId().det() == DetId::Tracker) {
      result.push_back((*imT).recHit());
      if (!(*imT).forwardPredictedState().isValid()) continue;
      if ((*imT).forwardPredictedState().globalPosition().mag() 
          > lastTKm.forwardPredictedState().globalPosition().mag()) lastTKm = *imT;
    }
  }

  // get the last (forward) predicted state for the tracker
  currentState = lastTKm.forwardPredictedState();
  
  // update the state with the last tracker measure
  update(currentState, lastTKm.recHit());

  // use the navigation to get the list of compatible dets
  map<int, std::vector<DetId> > detMap;
  compatibleDets(currentState, detMap);
  
  // selects the muon hits for the final refit
  filteringAlgo(detMap);

  return result;
}
void DynamicTruncation::filteringAlgo ( std::map< int, std::vector< DetId > > &  ) [private]

Definition at line 168 of file DynamicTruncation.cc.

References CSC(), CSCThr, currentState, GeomDetEnumerators::DT, MuonSubdetId::DT, DTThr, estimators, getBest(), ChamberSegmentUtility::getCSClist(), ChamberSegmentUtility::getCSCRHmap(), ChamberSegmentUtility::getDTlist(), ChamberSegmentUtility::getDTRHmap(), TrajectoryStateOnSurface::isValid(), j, MAX_THR, DetId::Muon, propagator, result, sort(), DTChamberId::station(), CSCDetId::station(), theEvent, theG, theMuonRecHitBuilder, theSetup, updateWithCSChits(), and updateWithDThits().

Referenced by filter().

                                                                         {
  ChamberSegmentUtility getSegs(*theEvent, *theSetup);
  for (unsigned int iDet = 0; iDet < detMap.size(); ++iDet) {
    double bestLayerValue = MAX_THR;
    bool isDTorCSC = false;
    ConstRecHitContainer layerRH;
    std::vector<DetId> chamber = detMap[iDet];
    for (unsigned int j = 0; j < chamber.size(); ++j) {
      DetId id = chamber[j];
      
      if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT) {
        isDTorCSC = true;
        DTChamberId DTid(id);
        
        std::vector<DTRecSegment4D> allDTsegs;
        std::map<int, std::vector<DTRecSegment4D> >::const_iterator dtIter = getSegs.getDTlist().find(DTid.station());
        if (dtIter != getSegs.getDTlist().end()){
          allDTsegs = dtIter->second;
        }
        std::vector<DTRecSegment4D>::size_type sz = allDTsegs.size();
        for (unsigned int iSeg=0; iSeg<sz; ++iSeg) {
          
          // Propagate the state to the current chamber
          TrajectoryStateOnSurface tsosdt = propagator->propagate(currentState, 
                                                                  theG->idToDet(allDTsegs[iSeg].chamberId())->surface());
          if (!tsosdt.isValid()) continue;

          std::vector<DTRecSegment4D> DTsegs;
          DTsegs.push_back(allDTsegs[iSeg]); 
          
          DTRecSegment4D bestDTSeg;
          double bestChamberValue = getBest(DTsegs, tsosdt, bestDTSeg);
          if (bestChamberValue < bestLayerValue) bestLayerValue = bestChamberValue;
          
          // Check if the best estimator value is below the THR and then get the RH componing the segment
          if (bestChamberValue >= DTThr || bestChamberValue > bestLayerValue) continue; 
          layerRH.clear();
          std::vector<DTRecHit1D> DTrh = getSegs.getDTRHmap(bestDTSeg);
          for (std::vector<DTRecHit1D>::iterator it = DTrh.begin(); it != DTrh.end(); it++) {
            layerRH.push_back(theMuonRecHitBuilder->build(&*it));
          }
        }
      }
      if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
        isDTorCSC = true;
        CSCDetId CSCid(id);
        
        std::vector<CSCSegment> allCSCsegs;
        std::map<int, std::vector<CSCSegment> >::const_iterator cscIter = getSegs.getCSClist().find(CSCid.station()); 
        if (cscIter != getSegs.getCSClist().end()){
          allCSCsegs = cscIter->second;
        }
        
        std::vector<CSCSegment>::size_type sz = allCSCsegs.size();
        for (unsigned int iSeg=0; iSeg<sz; ++iSeg) {
          
          // Propagate the state to the current chamber
          TrajectoryStateOnSurface tsoscsc = propagator->propagate(currentState, 
                                                                   theG->idToDet(allCSCsegs[iSeg].cscDetId())->surface());
          if (!tsoscsc.isValid()) continue;
          
          std::vector<CSCSegment> CSCsegs;
          CSCsegs.push_back(allCSCsegs[iSeg]);
          
          CSCSegment bestCSCSeg;
          double bestChamberValue = getBest(CSCsegs, tsoscsc, bestCSCSeg);
          if (bestChamberValue < bestLayerValue) bestLayerValue = bestChamberValue;
          
          // Check if the best estimator value is below the THR and then get the RH componing the segment
          if (bestChamberValue >= CSCThr || bestChamberValue > bestLayerValue) continue;
          layerRH.clear();
          std::vector<CSCRecHit2D> CSCrh = getSegs.getCSCRHmap(bestCSCSeg);
          for (std::vector<CSCRecHit2D>::iterator it = CSCrh.begin(); it != CSCrh.end(); ++it) {
            layerRH.push_back(theMuonRecHitBuilder->build(&*it));
          }
        }
      }
    }

    if (isDTorCSC) {
      if (bestLayerValue < MAX_THR) estimators.push_back(bestLayerValue);
      else estimators.push_back(-1);
    }

    if (layerRH.size() > 0) {                                                                                                                                          
      for (ConstRecHitContainer::iterator it = layerRH.begin(); it != layerRH.end(); ++it) {                                                                         
        result.push_back((*it));                                                                                                                                         
      }                                                                                                                                                                
      
      // sort the vector                                                                                                                                             
      layerRH = sort(layerRH);                                                                                                                                         
      
      // update the currentState using all rh                                                                                                             
      DetId id = layerRH.front()->geographicalId();                                                                                                      
      if (id.subdetId() == MuonSubdetId::DT) updateWithDThits(layerRH);                                                                                 
      else updateWithCSChits(layerRH);                                                                                                                 
    }
    layerRH.clear();                                                                                                                                                    
  }
}  
double DynamicTruncation::getBest ( std::vector< CSCSegment > &  segs,
TrajectoryStateOnSurface tsos,
CSCSegment bestCSCSeg 
) [private]

Definition at line 108 of file DynamicTruncation.cc.

References i, MAX_THR, tmp, and StateSegmentMatcher::value().

Referenced by filteringAlgo().

                                                                                                                     {
  unsigned int i = 0;
  double val = MAX_THR;
  std::vector<CSCSegment>::size_type sz = segs.size();
  for (i=0; i<sz; i++) {
    StateSegmentMatcher estim(&tsos, &segs[i]);
    double tmp = estim.value();
    if (tmp < val) {
      bestCSCSeg = segs[i];
      val = tmp;
    }
  }
  return val;
}
double DynamicTruncation::getBest ( std::vector< DTRecSegment4D > &  segs,
TrajectoryStateOnSurface tsos,
DTRecSegment4D bestDTSeg 
) [private]

Definition at line 125 of file DynamicTruncation.cc.

References i, MAX_THR, tmp, and StateSegmentMatcher::value().

                                                                                                                            {
  unsigned int i = 0;
  double val = MAX_THR;
  std::vector<DTRecSegment4D>::size_type sz = segs.size();
  for (i=0; i<sz; i++) {
    StateSegmentMatcher estim(&tsos, &segs[i]); 
    double tmp = estim.value();                                                                                                                                              
    if (tmp < val) {
      bestDTSeg = segs[i];
      val = tmp;
    }
  }
  return val;
}
std::vector<double> DynamicTruncation::getEstimators ( ) [inline]

Definition at line 64 of file DynamicTruncation.h.

References estimators.

{return estimators;};
void DynamicTruncation::setThr ( int  bThr,
int  eThr 
)

Definition at line 99 of file DynamicTruncation.cc.

References CSCThr, DTThr, and MAX_THR.

Referenced by GlobalMuonRefitter::refit().

                                                 {
  if (bThr <= MAX_THR && bThr >= 0) DTThr  = bThr; // DT thr 
  else DTThr = MAX_THR;
  if (eThr <= MAX_THR && eThr >= 0) CSCThr = eThr; // CSC thr
  else CSCThr = MAX_THR;
}
TransientTrackingRecHit::ConstRecHitContainer DynamicTruncation::sort ( ConstRecHitContainer recHits) [private]

Definition at line 299 of file DynamicTruncation.cc.

References i, j, mag(), n, and swap().

Referenced by filteringAlgo().

                                                                                                 {
  unsigned int i=0;
  unsigned int j=0;
  ConstRecHitContainer::size_type n = recHits.size();
  for(i=1; i<n; ++i)
    for(j=n-1; j>=i; --j)
      {
        if(recHits[j-1]->globalPosition().mag() > recHits[j]->globalPosition().mag())
          {
            swap (recHits[j-1],recHits[j]);
          }
      }
  return recHits;
}
void DynamicTruncation::update ( TrajectoryStateOnSurface tsos,
ConstRecHitPointer  rechit 
) [private]

Definition at line 271 of file DynamicTruncation.cc.

References currentState, TrajectoryStateOnSurface::isValid(), cond::rpcobtemp::temp, and updatorHandle.

Referenced by filter().

                                                                                        {
  TrajectoryStateOnSurface temp = updatorHandle->update(tsos, *rechit);
  if (temp.isValid()) currentState = updatorHandle->update(tsos, *rechit);
}
void DynamicTruncation::updateWithCSChits ( ConstRecHitContainer recHits) [private]

Definition at line 288 of file DynamicTruncation.cc.

References cscGeom, currentState, GeomDet::geographicalId(), TrajectoryStateOnSurface::isValid(), propagator, cond::rpcobtemp::temp, theG, and updatorHandle.

Referenced by filteringAlgo().

                                                                       {
  for (ConstRecHitContainer::const_iterator it = recHits.begin(); it != recHits.end(); ++it) {
    const CSCLayer* cscChamber = cscGeom->layer((*it)->det()->geographicalId());
    CSCDetId layid = cscChamber->geographicalId();
    TrajectoryStateOnSurface temp = propagator->propagate(currentState, theG->idToDet(layid)->surface());
    if (temp.isValid()) currentState = updatorHandle->update(temp, **it);
  }
}
void DynamicTruncation::updateWithDThits ( ConstRecHitContainer recHits) [private]

Definition at line 278 of file DynamicTruncation.cc.

References currentState, propagator, cond::rpcobtemp::temp, theG, and updatorHandle.

Referenced by filteringAlgo().

                                                                      {
  for (ConstRecHitContainer::const_iterator it = recHits.begin(); it != recHits.end(); ++it) {
    DTLayerId layid((*it)->det()->geographicalId());
    TrajectoryStateOnSurface temp = propagator->propagate(currentState, theG->idToDet(layid)->surface());
    if (temp.isValid()) currentState = updatorHandle->update(temp, **it);
  }
}

Member Data Documentation

Definition at line 85 of file DynamicTruncation.h.

Referenced by DynamicTruncation(), and updateWithCSChits().

Definition at line 80 of file DynamicTruncation.h.

Referenced by filteringAlgo(), and setThr().

int DynamicTruncation::DTThr [private]

Definition at line 79 of file DynamicTruncation.h.

Referenced by filteringAlgo(), and setThr().

std::vector<double> DynamicTruncation::estimators [private]

Definition at line 93 of file DynamicTruncation.h.

Referenced by filteringAlgo(), and getEstimators().

Definition at line 90 of file DynamicTruncation.h.

Referenced by DynamicTruncation().

Definition at line 88 of file DynamicTruncation.h.

Referenced by DynamicTruncation().

Definition at line 83 of file DynamicTruncation.h.

Referenced by GeometricSearchDet::compatibleDets(), and DynamicTruncation().

Definition at line 77 of file DynamicTruncation.h.

Referenced by filter(), and filteringAlgo().

Definition at line 91 of file DynamicTruncation.h.

Referenced by DynamicTruncation(), and filteringAlgo().

Definition at line 86 of file DynamicTruncation.h.

Referenced by DynamicTruncation(), and filteringAlgo().

Definition at line 92 of file DynamicTruncation.h.

Referenced by DynamicTruncation(), and filteringAlgo().

Definition at line 87 of file DynamicTruncation.h.

Referenced by DynamicTruncation(), update(), updateWithCSChits(), and updateWithDThits().