CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Attributes

GlobalTrajectoryBuilderBase Class Reference

#include <GlobalTrajectoryBuilderBase.h>

Inheritance diagram for GlobalTrajectoryBuilderBase:
MuonTrajectoryBuilder GlobalMuonTrajectoryBuilder L3MuonTrajectoryBuilder

List of all members.

Classes

struct  ComparatorInOut

Public Types

typedef
MuonTransientTrackingRecHit::ConstMuonRecHitContainer 
ConstMuonRecHitContainer
typedef
MuonTransientTrackingRecHit::ConstMuonRecHitPointer 
ConstMuonRecHitPointer
typedef
TransientTrackingRecHit::ConstRecHitContainer 
ConstRecHitContainer
typedef
TransientTrackingRecHit::ConstRecHitPointer 
ConstRecHitPointer
typedef
MuonTransientTrackingRecHit::MuonRecHitContainer 
MuonRecHitContainer
typedef
MuonTransientTrackingRecHit::MuonRecHitPointer 
MuonRecHitPointer
typedef
TransientTrackingRecHit::RecHitContainer 
RecHitContainer
typedef
TransientTrackingRecHit::RecHitPointer 
RecHitPointer
typedef std::vector< TrajectoryTC
typedef TC::const_iterator TI

Public Member Functions

 GlobalTrajectoryBuilderBase (const edm::ParameterSet &, const MuonServiceProxy *)
 constructor with Parameter Set and MuonServiceProxy
virtual void setEvent (const edm::Event &)
 pass the Event to the algo at each event
MuonTrajectoryBuilder::TrajectoryContainer trajectories (const TrajectorySeed &)
 dummy implementation, unused in this class
virtual ~GlobalTrajectoryBuilderBase ()
 destructor

Protected Types

enum  RefitDirection { inToOut, outToIn, undetermined }

Protected Member Functions

void addTraj (TrackCand &)
 if TrackCand has only a TrackRef, attempt to add Trajectory*
MuonTrajectoryBuilder::CandidateContainer build (const TrackCand &, MuonTrajectoryBuilder::CandidateContainer &) const
 build combined trajectory from sta Track and tracker RecHits
void checkMuonHits (const reco::Track &, ConstRecHitContainer &, ConstRecHitContainer &, std::vector< int > &) const
 check muon RecHits, calculate chamber occupancy and select hits to be used in the final fit
RefitDirection checkRecHitsOrdering (const ConstRecHitContainer &) const
 This does nothing now.
std::vector< TrackCandchooseRegionalTrackerTracks (const TrackCand &, const std::vector< TrackCand > &)
 choose tracker tracks within region of interest
const TrajectorychooseTrajectory (const std::vector< Trajectory * > &, int) const
 choose final trajectory
RectangularEtaPhiTrackingRegion defineRegionOfInterest (const reco::TrackRef &) const
 define region of interest with tracker
void fixTEC (ConstRecHitContainer &all, double scl_x, double scl_y) const
 rescale errors of outermost TEC RecHit
TransientTrackingRecHit::ConstRecHitContainer getTransientRecHits (const reco::Track &) const
 get transient RecHits of a Track
virtual std::vector< TrackCandmakeTkCandCollection (const TrackCand &)=0
 make a TrackCand collection using tracker Track, Trajectory information
void printHits (const ConstRecHitContainer &) const
 print all RecHits of a trajectory
ConstRecHitContainer selectMuonHits (const Trajectory &, const std::vector< int > &) const
 select muon hits compatible with trajectory; check hits in chambers with showers
ConstRecHitContainer selectTrackerHits (const ConstRecHitContainer &) const
 select tracker hits; exclude some tracker hits in the global trajectory
const MuonServiceProxyservice () const
GlobalMuonTrackMatchertrackMatcher () const
double trackProbability (const Trajectory &) const
 calculate chi2 probability (-ln(P))

Protected Attributes

std::string theCategory
float thePCut
float thePtCut

Private Attributes

unsigned long long theCacheId_TRH
const edm::EventtheEvent
GlobalMuonRefittertheGlbRefitter
MuonDetLayerMeasurementstheLayerMeasurements
int theMuonHitsOption
edm::ESHandle
< TransientTrackingRecHitBuilder
theMuonRecHitBuilder
std::string theMuonRecHitBuilderName
MuonTrackingRegionBuildertheRegionBuilder
bool theRPCInTheFit
const MuonServiceProxytheService
float theTECxScale
float theTECyScale
std::string theTrackerPropagatorName
edm::ESHandle
< TransientTrackingRecHitBuilder
theTrackerRecHitBuilder
std::string theTrackerRecHitBuilderName
GlobalMuonTrackMatchertheTrackMatcher
TrackTransformertheTrackTransformer
const TrackerTopologytTopo_

Detailed Description

Base class for GlobalMuonTrajectoryBuilder and L3MuonTrajectoryBuilder Provide common tools and interface to reconstruct muons starting from a muon track reconstructed in the standalone muon system (with DT, CSC and RPC information). It tries to reconstruct the corresponding track in the tracker and performs matching between the reconstructed tracks in the muon system and the tracker.

Date:
2013/01/06 19:16:51
Revision:
1.24
Author:
N. Neumeister Purdue University
C. Liu Purdue University
A. Everett Purdue University

Definition at line 50 of file GlobalTrajectoryBuilderBase.h.


Member Typedef Documentation

Definition at line 62 of file GlobalTrajectoryBuilderBase.h.

Definition at line 60 of file GlobalTrajectoryBuilderBase.h.

Definition at line 55 of file GlobalTrajectoryBuilderBase.h.

Definition at line 57 of file GlobalTrajectoryBuilderBase.h.

Definition at line 61 of file GlobalTrajectoryBuilderBase.h.

Definition at line 59 of file GlobalTrajectoryBuilderBase.h.

Definition at line 54 of file GlobalTrajectoryBuilderBase.h.

Definition at line 56 of file GlobalTrajectoryBuilderBase.h.

Definition at line 64 of file GlobalTrajectoryBuilderBase.h.

typedef TC::const_iterator GlobalTrajectoryBuilderBase::TI

Definition at line 65 of file GlobalTrajectoryBuilderBase.h.


Member Enumeration Documentation

Enumerator:
inToOut 
outToIn 
undetermined 

Definition at line 83 of file GlobalTrajectoryBuilderBase.h.


Constructor & Destructor Documentation

GlobalTrajectoryBuilderBase::GlobalTrajectoryBuilderBase ( const edm::ParameterSet par,
const MuonServiceProxy *  service 
)

constructor with Parameter Set and MuonServiceProxy

Definition at line 91 of file GlobalTrajectoryBuilderBase.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), GlobalMuonRefitter_cff::GlobalMuonRefitter, GlobalMuonTrackMatcher_cff::GlobalMuonTrackMatcher, theCacheId_TRH, theCategory, theGlbRefitter, theMuonHitsOption, theMuonRecHitBuilderName, thePCut, thePtCut, theRegionBuilder, theRPCInTheFit, theService, theTECxScale, theTECyScale, theTrackerPropagatorName, theTrackerRecHitBuilderName, theTrackMatcher, and theTrackTransformer.

                                                                                          : 
  theTrackMatcher(0),theLayerMeasurements(0),theTrackTransformer(0),theRegionBuilder(0), theService(service),theGlbRefitter(0) {

  theCategory = par.getUntrackedParameter<string>("Category", "Muon|RecoMuon|GlobalMuon|GlobalTrajectoryBuilderBase");

  
  ParameterSet trackMatcherPSet = par.getParameter<ParameterSet>("GlobalMuonTrackMatcher");
  theTrackMatcher = new GlobalMuonTrackMatcher(trackMatcherPSet,theService);
  
  theTrackerPropagatorName = par.getParameter<string>("TrackerPropagator");

  ParameterSet trackTransformerPSet = par.getParameter<ParameterSet>("TrackTransformer");
  theTrackTransformer = new TrackTransformer(trackTransformerPSet);

  ParameterSet regionBuilderPSet = par.getParameter<ParameterSet>("MuonTrackingRegionBuilder");

  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet,theService);

  // TrackRefitter parameters
  ParameterSet refitterParameters = par.getParameter<ParameterSet>("GlbRefitterParameters");
  theGlbRefitter = new GlobalMuonRefitter(refitterParameters, theService);

  theMuonHitsOption = refitterParameters.getParameter<int>("MuonHitsOption");

  theTrackerRecHitBuilderName = par.getParameter<string>("TrackerRecHitBuilder");
  theMuonRecHitBuilderName = par.getParameter<string>("MuonRecHitBuilder");  

  theRPCInTheFit = par.getParameter<bool>("RefitRPCHits");

  theTECxScale = par.getParameter<double>("ScaleTECxFactor");
  theTECyScale = par.getParameter<double>("ScaleTECyFactor");
  thePtCut = par.getParameter<double>("PtCut");
  thePCut = par.getParameter<double>("PCut");

  theCacheId_TRH = 0;

}
GlobalTrajectoryBuilderBase::~GlobalTrajectoryBuilderBase ( ) [virtual]

Member Function Documentation

void GlobalTrajectoryBuilderBase::addTraj ( TrackCand ) [inline, protected]

if TrackCand has only a TrackRef, attempt to add Trajectory*

Definition at line 127 of file GlobalTrajectoryBuilderBase.h.

{} 
MuonCandidate::CandidateContainer GlobalTrajectoryBuilderBase::build ( const TrackCand staCand,
MuonTrajectoryBuilder::CandidateContainer tkTrajs 
) const [protected]

build combined trajectory from sta Track and tracker RecHits

Definition at line 176 of file GlobalTrajectoryBuilderBase.cc.

References checkRecHitsOrdering(), fixTEC(), getTransientRecHits(), LogDebug, LogTrace, MuonCandidate::muonTrack(), outToIn, mix_2012_Summer_inTimeOnly_cff::prob, GlobalMuonRefitter::refit(), selectTrackerHits(), Trajectory::setSeedRef(), theCategory, theGlbRefitter, theMuonHitsOption, thePCut, thePtCut, theService, theTECxScale, theTECyScale, theTrackTransformer, MuonCandidate::trackerTrack(), MuonCandidate::trackerTrajectory(), trackProbability(), MuonCandidate::trajectory(), TrackTransformer::transform(), and tTopo_.

Referenced by L3MuonTrajectoryBuilder::trajectories(), and GlobalMuonTrajectoryBuilder::trajectories().

                                                                                    {

  LogTrace(theCategory) << " Begin Build" << endl;

  // tracker trajectory should be built and refit before this point
  if ( tkTrajs.empty() ) return CandidateContainer();

  // add muon hits and refit/smooth trajectories
  CandidateContainer refittedResult;
  ConstRecHitContainer muonRecHits = getTransientRecHits(*(staCand.second));

  // check order of muon measurements
  if ( (muonRecHits.size() > 1) &&
       ( muonRecHits.front()->globalPosition().mag() >
         muonRecHits.back()->globalPosition().mag() ) ) {
    LogTrace(theCategory)<< "   reverse order: ";
  }

  for ( CandidateContainer::const_iterator it = tkTrajs.begin(); it != tkTrajs.end(); it++ ) {

    // cut on tracks with low momenta
    LogTrace(theCategory)<< "   Track p and pT " << (*it)->trackerTrack()->p() << " " << (*it)->trackerTrack()->pt();
    if(  (*it)->trackerTrack()->p() < thePCut || (*it)->trackerTrack()->pt() < thePtCut  ) continue;

    ConstRecHitContainer trackerRecHits;
    if ((*it)->trackerTrack().isNonnull()) {
      trackerRecHits = getTransientRecHits(*(*it)->trackerTrack());
    } else {
      LogDebug(theCategory)<<"     NEED HITS FROM TRAJ";
      //trackerRecHits = (*it)->trackerTrajectory()->recHits();
    }

    // check for single TEC RecHits in trajectories in the overalp region
    if ( fabs((*it)->trackerTrack()->eta()) > 0.95 && fabs((*it)->trackerTrack()->eta()) < 1.15 && (*it)->trackerTrack()->pt() < 60 ) {
      if ( theTECxScale < 0 || theTECyScale < 0 )
        trackerRecHits = selectTrackerHits(trackerRecHits);
      else
        fixTEC(trackerRecHits,theTECxScale,theTECyScale);
    }
                  
    RefitDirection recHitDir = checkRecHitsOrdering(trackerRecHits);
    if ( recHitDir == outToIn ) reverse(trackerRecHits.begin(),trackerRecHits.end());

    reco::TransientTrack tTT((*it)->trackerTrack(),&*theService->magneticField(),theService->trackingGeometry());
    TrajectoryStateOnSurface innerTsos = tTT.innermostMeasurementState();

    edm::RefToBase<TrajectorySeed> tmpSeed;
    if((*it)->trackerTrack()->seedRef().isAvailable()) tmpSeed = (*it)->trackerTrack()->seedRef();

    if ( !innerTsos.isValid() ) {
      LogTrace(theCategory) << "     inner Trajectory State is invalid. ";
      continue;
    }
  
    innerTsos.rescaleError(100.);
                  
    TC refitted0,refitted1;
    MuonCandidate* finalTrajectory = 0;
    Trajectory *tkTrajectory = 0;

    // tracker only track
    if ( ! ((*it)->trackerTrajectory() && (*it)->trackerTrajectory()->isValid()) ) { 
      refitted0 = theTrackTransformer->transform((*it)->trackerTrack()) ;
      if (!refitted0.empty()) tkTrajectory = new Trajectory(*(refitted0.begin())); 
      else LogWarning(theCategory)<< "     Failed to load tracker track trajectory";
    } else tkTrajectory = (*it)->trackerTrajectory();
    if (tkTrajectory) tkTrajectory->setSeedRef(tmpSeed);

    // full track with all muon hits using theGlbRefitter    
    ConstRecHitContainer allRecHits = trackerRecHits;
    allRecHits.insert(allRecHits.end(), muonRecHits.begin(),muonRecHits.end());
    refitted1 = theGlbRefitter->refit( *(*it)->trackerTrack(), tTT, allRecHits,theMuonHitsOption, tTopo_);
    LogTrace(theCategory)<<"     This track-sta refitted to " << refitted1.size() << " trajectories";

    Trajectory *glbTrajectory1 = 0;
    if (!refitted1.empty()) glbTrajectory1 = new Trajectory(*(refitted1.begin()));
    else LogDebug(theCategory)<< "     Failed to load global track trajectory 1"; 
    if (glbTrajectory1) glbTrajectory1->setSeedRef(tmpSeed);
    
    finalTrajectory = 0;
    if(glbTrajectory1 && tkTrajectory) finalTrajectory = new MuonCandidate(glbTrajectory1, (*it)->muonTrack(), (*it)->trackerTrack(), 
                                        tkTrajectory? new Trajectory(*tkTrajectory) : 0);

    if ( finalTrajectory ) 
      refittedResult.push_back(finalTrajectory);
     
    if(tkTrajectory) delete tkTrajectory;
  }

  // choose the best global fit for this Standalone Muon based on the track probability
  CandidateContainer selectedResult;
  MuonCandidate* tmpCand = 0;
  if ( refittedResult.size() > 0 ) tmpCand = *(refittedResult.begin());
  double minProb = 9999;

  for (CandidateContainer::const_iterator iter=refittedResult.begin(); iter != refittedResult.end(); iter++) {
    double prob = trackProbability(*(*iter)->trajectory());
    LogTrace(theCategory)<<"   refitted-track-sta with pT " << (*iter)->trackerTrack()->pt() << " has probability " << prob;

    if (prob < minProb) {
      minProb = prob;
      tmpCand = (*iter);
    }
  }

  if ( tmpCand )  selectedResult.push_back(new MuonCandidate(new Trajectory(*(tmpCand->trajectory())), tmpCand->muonTrack(), tmpCand->trackerTrack(), 
                                                             (tmpCand->trackerTrajectory())? new Trajectory( *(tmpCand->trackerTrajectory()) ):0 ) );

  for (CandidateContainer::const_iterator it = refittedResult.begin(); it != refittedResult.end(); ++it) {
    if ( (*it)->trajectory() ) delete (*it)->trajectory();
    if ( (*it)->trackerTrajectory() ) delete (*it)->trackerTrajectory();
    if ( *it ) delete (*it);
  }
  refittedResult.clear();

  return selectedResult;

}
void GlobalMuonRefitter::checkMuonHits ( const reco::Track ,
ConstRecHitContainer ,
ConstRecHitContainer ,
std::vector< int > &   
) const [protected]

check muon RecHits, calculate chamber occupancy and select hits to be used in the final fit

Definition at line 272 of file GlobalMuonRefitter.cc.

References alongMomentum, CSCDetId::chamberId(), MuonSubdetId::CSC, MuonSubdetId::DT, LogTrace, mag(), DetId::Muon, DetId::rawId(), MuonSubdetId::RPC, GlobalMuonRefitter::theCategory, GlobalMuonRefitter::theCSCRecHits, and GlobalMuonRefitter::theDTRecHits.

                                                                      {

  LogTrace(theCategory) << " GlobalMuonRefitter::checkMuonHits " << endl;

  float coneSize = 20.0;

  // loop through all muon hits and calculate the maximum # of hits in each chamber
  for (ConstRecHitContainer::const_iterator imrh = all.begin(); imrh != all.end(); imrh++ ) {
        
    if ( (*imrh != 0 ) && !(*imrh)->isValid() ) continue;
  
    int detRecHits = 0;
    MuonRecHitContainer dRecHits;
      
    DetId id = (*imrh)->geographicalId();
    DetId chamberId;

    // Skip tracker hits
    if (id.det()!=DetId::Muon) continue;

    if ( id.subdetId() == MuonSubdetId::DT ) {
      DTChamberId did(id.rawId());
      chamberId=did;
      
      if ((*imrh)->recHits().size()>1) {
        std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
        for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
          if ((*imrh)->recHits().size()>1) {
            std::vector <const TrackingRecHit*> hits1d = (*hit2d)->recHits();
            for (std::vector <const TrackingRecHit*>::const_iterator hit1d = hits1d.begin(); hit1d!= hits1d.end(); hit1d++) {
              DetId id1 = (*hit1d)->geographicalId();
              DTLayerId lid(id1.rawId());
              // Get the 1d DT RechHits from this layer
              DTRecHitCollection::range dRecHits = theDTRecHits->get(lid);
              int layerHits=0;
              for (DTRecHitCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
                double rhitDistance = fabs(ir->localPosition().x()-(**hit1d).localPosition().x()); 
                if ( rhitDistance < coneSize ) layerHits++;
                LogTrace(theCategory) << "       " << (ir)->localPosition() << "  " << (**hit1d).localPosition()
                     << " Distance: " << rhitDistance << " recHits: " << layerHits << "  SL: " << lid.superLayer() << endl;
              }
              if (layerHits>detRecHits) detRecHits=layerHits;
            }
          }
        }
      
      } else {
        DTLayerId lid(id.rawId());
    
        // Get the 1d DT RechHits from this layer
        DTRecHitCollection::range dRecHits = theDTRecHits->get(lid);

        for (DTRecHitCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
          double rhitDistance = fabs(ir->localPosition().x()-(**imrh).localPosition().x());
          if ( rhitDistance < coneSize ) detRecHits++;
          LogTrace(theCategory) << "       " << (ir)->localPosition() << "  " << (**imrh).localPosition()
               << " Distance: " << rhitDistance << " recHits: " << detRecHits << endl;
        }
      }
    }// end of if DT
    else if ( id.subdetId() == MuonSubdetId::CSC ) {
      CSCDetId did(id.rawId());
      chamberId=did.chamberId();

      if ((*imrh)->recHits().size()>1) {
        std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
        for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
          DetId id1 = (*hit2d)->geographicalId();
          CSCDetId lid(id1.rawId());
          
          // Get the CSC Rechits from this layer
          CSCRecHit2DCollection::range dRecHits = theCSCRecHits->get(lid);      
          int layerHits=0;

          for (CSCRecHit2DCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
            double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).mag();
            if ( rhitDistance < coneSize ) layerHits++;
            LogTrace(theCategory) << ir->localPosition() << "  " << (**hit2d).localPosition()
                   << " Distance: " << rhitDistance << " recHits: " << layerHits << endl;
          }
          if (layerHits>detRecHits) detRecHits=layerHits;
        }
      } else {
        // Get the CSC Rechits from this layer
        CSCRecHit2DCollection::range dRecHits = theCSCRecHits->get(did);      

        for (CSCRecHit2DCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
          double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).mag();
          if ( rhitDistance < coneSize ) detRecHits++;
          LogTrace(theCategory) << ir->localPosition() << "  " << (**imrh).localPosition()
                 << " Distance: " << rhitDistance << " recHits: " << detRecHits << endl;
        }
      }
    }
    else {
      if ( id.subdetId() != MuonSubdetId::RPC ) LogError(theCategory)<<" Wrong Hit Type ";
      continue;      
    }
      
    map<DetId,int>::iterator imap=hitMap.find(chamberId);
    if (imap!=hitMap.end()) {
      if (detRecHits>imap->second) imap->second=detRecHits;
    } else hitMap[chamberId]=detRecHits;

  } // end of loop over muon rechits

  for (map<DetId,int>::iterator imap=hitMap.begin(); imap!=hitMap.end(); imap++ ) 
    LogTrace(theCategory) << " Station " << imap->first.rawId() << ": " << imap->second <<endl; 

  LogTrace(theCategory) << "CheckMuonHits: "<<all.size();

  // check order of muon measurements
  if ( (all.size() > 1) &&
       ( all.front()->globalPosition().mag() >
         all.back()->globalPosition().mag() ) ) {
    LogTrace(theCategory)<< "reverse order: ";
    stable_sort(all.begin(),all.end(),RecHitLessByDet(alongMomentum));
  }
}
GlobalTrajectoryBuilderBase::RefitDirection GlobalTrajectoryBuilderBase::checkRecHitsOrdering ( const ConstRecHitContainer recHits) const [protected]

This does nothing now.

check order of RechIts on a trajectory

Definition at line 406 of file GlobalTrajectoryBuilderBase.cc.

References inToOut, outToIn, theCategory, and undetermined.

Referenced by build().

                                                                                                                  {

  if ( !recHits.empty() ) {
    ConstRecHitContainer::const_iterator frontHit = recHits.begin();
    ConstRecHitContainer::const_iterator backHit  = recHits.end() - 1;
    while ( !(*frontHit)->isValid() && frontHit != backHit ) {frontHit++;}
    while ( !(*backHit)->isValid() && backHit != frontHit )  {backHit--;}

    double rFirst = (*frontHit)->globalPosition().mag();
    double rLast  = (*backHit) ->globalPosition().mag();

    if ( rFirst < rLast ) return inToOut;
    else if (rFirst > rLast) return outToIn;
    else {
      LogError(theCategory) << "Impossible to determine the rechits order" << endl;
      return undetermined;
    }
  }
  else {
    LogError(theCategory) << "Impossible to determine the rechits order" << endl;
    return undetermined;
  }
}
vector< GlobalTrajectoryBuilderBase::TrackCand > GlobalTrajectoryBuilderBase::chooseRegionalTrackerTracks ( const TrackCand ,
const std::vector< TrackCand > &   
) [protected]

choose tracker tracks within region of interest

Definition at line 301 of file GlobalTrajectoryBuilderBase.cc.

References defineRegionOfInterest(), deltaR(), and query::result.

Referenced by GlobalMuonTrajectoryBuilder::makeTkCandCollection().

                                                                                        {
  
  // define eta-phi region
  RectangularEtaPhiTrackingRegion regionOfInterest = defineRegionOfInterest(staCand.second);
  
  // get region's etaRange and phiMargin
  //UNUSED:  PixelRecoRange<float> etaRange = regionOfInterest.etaRange();
  //UNUSED:  TkTrackingRegionsMargin<float> phiMargin = regionOfInterest.phiMargin();

  vector<TrackCand> result;

  double deltaR_max = 1.0;

  for ( vector<TrackCand>::const_iterator is = tkTs.begin(); is != tkTs.end(); ++is ) {
    // check if each trackCand is in region of interest
//    bool inEtaRange = etaRange.inside(is->second->eta());
//    bool inPhiRange = (fabs(Geom::Phi<float>(is->second->phi()) - Geom::Phi<float>(regionOfInterest.direction().phi())) < phiMargin.right() ) ? true : false ;

    double deltaR_tmp = deltaR(static_cast<double>(regionOfInterest.direction().eta()),
                                                           static_cast<double>(regionOfInterest.direction().phi()),
                                                           is->second->eta(), is->second->phi());

    // for each trackCand in region, add trajectory and add to result
    //if ( inEtaRange && inPhiRange ) {
    if (deltaR_tmp < deltaR_max) {
      TrackCand tmpCand = TrackCand(*is);
      result.push_back(tmpCand);
    }
  }

  return result; 

}
const Trajectory* GlobalTrajectoryBuilderBase::chooseTrajectory ( const std::vector< Trajectory * > &  ,
int   
) const [protected]

choose final trajectory

RectangularEtaPhiTrackingRegion GlobalTrajectoryBuilderBase::defineRegionOfInterest ( const reco::TrackRef staTrack) const [protected]

define region of interest with tracker

Definition at line 341 of file GlobalTrajectoryBuilderBase.cc.

References MuonTrackingRegionBuilder::region(), and theRegionBuilder.

Referenced by chooseRegionalTrackerTracks().

                                                                                      {

  RectangularEtaPhiTrackingRegion* region1 = theRegionBuilder->region(staTrack);
  
  TkTrackingRegionsMargin<float> etaMargin(fabs(region1->etaRange().min() - region1->etaRange().mean()),
                                           fabs(region1->etaRange().max() - region1->etaRange().mean()));
  
  RectangularEtaPhiTrackingRegion region2(region1->direction(),
                                          region1->origin(),
                                          region1->ptMin(),
                                          region1->originRBound(),
                                          region1->originZBound(),
                                          etaMargin,
                                          region1->phiMargin());
  
  delete region1;
  return region2;
  
}
void GlobalTrajectoryBuilderBase::fixTEC ( ConstRecHitContainer all,
double  scl_x,
double  scl_y 
) const [protected]

rescale errors of outermost TEC RecHit

Definition at line 459 of file GlobalTrajectoryBuilderBase.cc.

References angle(), MuonTransientTrackingRecHit::build(), error, i, pos, LocalError::rotate(), StripTopology::strip(), StripTopology::stripAngle(), sistripsummary::TEC, DetId::Tracker, LocalError::xx(), and LocalError::yy().

Referenced by build().

                                                             {

  int nTEC(0);
  ConstRecHitContainer::iterator lone_tec;

  for ( ConstRecHitContainer::iterator i = all.begin(); i != all.end(); i++) {
    if ( !(*i)->isValid() ) continue;
    
    if ( (*i)->det()->geographicalId().det() == DetId::Tracker &&
         (*i)->det()->geographicalId().subdetId() == StripSubdetector::TEC) {
      lone_tec = i;
      nTEC++;
      
      if ( (i+1) != all.end() && (*(i+1))->isValid() &&
          (*(i+1))->det()->geographicalId().det() == DetId::Tracker &&
          (*(i+1))->det()->geographicalId().subdetId() == StripSubdetector::TEC) {
        nTEC++;
        break;
      }
    }
    
    if (nTEC > 1) break;
  }
  
  int hitDet = (*lone_tec)->hit()->geographicalId().det();
  int hitSubDet = (*lone_tec)->hit()->geographicalId().subdetId();
  if ( nTEC == 1 && (*lone_tec)->hit()->isValid() &&
       hitDet == DetId::Tracker && hitSubDet == StripSubdetector::TEC) {
    
    // rescale the TEC rechit error matrix in its rotated frame
    const SiStripRecHit2D* strip = dynamic_cast<const SiStripRecHit2D*>((*lone_tec)->hit());
    const TSiStripRecHit2DLocalPos* Tstrip = dynamic_cast<const TSiStripRecHit2DLocalPos*>((*lone_tec).get());
    if (strip && Tstrip->det() && Tstrip) {
      LocalPoint pos = Tstrip->localPosition();
      if ((*lone_tec)->detUnit()) {
        const StripTopology* topology = dynamic_cast<const StripTopology*>(&(*lone_tec)->detUnit()->topology());
        if (topology) {
          // rescale the local error along/perp the strip by a factor
          float angle = topology->stripAngle(topology->strip((*lone_tec)->hit()->localPosition()));
          LocalError error = Tstrip->localPositionError();
          LocalError rotError = error.rotate(angle);
          LocalError scaledError(rotError.xx() * scl_x * scl_x, 0, rotError.yy() * scl_y * scl_y);
          error = scaledError.rotate(-angle);
          MuonTransientTrackingRecHit* mtt_rechit;
          if (strip->cluster().isNonnull()) {
            SiStripRecHit2D* st = new SiStripRecHit2D(pos,error,
                                                      (*lone_tec)->geographicalId().rawId(),
                                                      strip->cluster());
            *lone_tec = mtt_rechit->build((*lone_tec)->det(),st);
          }
          else {
            SiStripRecHit2D* st = new SiStripRecHit2D(pos,error,
                                                      (*lone_tec)->geographicalId().rawId(),
                                                      strip->cluster_regional());
            *lone_tec = mtt_rechit->build((*lone_tec)->det(),st);
          }
        }
      }
    }
  }

}
TransientTrackingRecHit::ConstRecHitContainer GlobalTrajectoryBuilderBase::getTransientRecHits ( const reco::Track track) const [protected]

get transient RecHits of a Track

Definition at line 532 of file GlobalTrajectoryBuilderBase.cc.

References DetId::det(), trajectoryStateTransform::innerStateOnSurface(), TrajectoryStateOnSurface::isValid(), LogDebug, DetId::Muon, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), query::result, theCategory, theMuonRecHitBuilder, theRPCInTheFit, theService, theTrackerPropagatorName, theTrackerRecHitBuilder, and align::Tracker.

Referenced by build().

                                                                             {

  TransientTrackingRecHit::ConstRecHitContainer result;
  
  

  TrajectoryStateOnSurface currTsos = trajectoryStateTransform::innerStateOnSurface(track, *theService->trackingGeometry(), &*theService->magneticField());

  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
    if((*hit)->isValid()) {
      DetId recoid = (*hit)->geographicalId();
      if ( recoid.det() == DetId::Tracker ) {
        TransientTrackingRecHit::RecHitPointer ttrhit = theTrackerRecHitBuilder->build(&**hit);
        if (!ttrhit->hit()->hasPositionAndError()){
          TrajectoryStateOnSurface predTsos =  theService->propagator(theTrackerPropagatorName)->propagate(currTsos, theService->trackingGeometry()->idToDet(recoid)->surface());
          
          if ( !predTsos.isValid() ) {
            edm::LogError("MissingTransientHit")
              <<"Could not get a tsos on the hit surface. We will miss a tracking hit.";
            continue; 
          }
          currTsos = predTsos;
          TransientTrackingRecHit::RecHitPointer preciseHit = ttrhit->clone(predTsos);
          result.push_back(preciseHit);
        }else{
          result.push_back(ttrhit);
        }
      } else if ( recoid.det() == DetId::Muon ) {
        if ( (*hit)->geographicalId().subdetId() == 3 && !theRPCInTheFit) {
          LogDebug(theCategory) << "RPC Rec Hit discarded"; 
          continue;
        }
        result.push_back(theMuonRecHitBuilder->build(&**hit));
      }
    }
  }
  
  return result;
}
virtual std::vector<TrackCand> GlobalTrajectoryBuilderBase::makeTkCandCollection ( const TrackCand ) [protected, pure virtual]

make a TrackCand collection using tracker Track, Trajectory information

Implemented in GlobalMuonTrajectoryBuilder, and L3MuonTrajectoryBuilder.

void GlobalTrajectoryBuilderBase::printHits ( const ConstRecHitContainer hits) const [protected]

print all RecHits of a trajectory

Definition at line 380 of file GlobalTrajectoryBuilderBase.cc.

References LogTrace, pos, mathSSE::sqrt(), theCategory, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

                                                                                  {

  LogTrace(theCategory) << "Used RecHits: " << hits.size();
  for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
    if ( !(*ir)->isValid() ) {
      LogTrace(theCategory) << "invalid RecHit";
      continue; 
    }
    
    const GlobalPoint& pos = (*ir)->globalPosition();
    
    LogTrace(theCategory) 
      << "r = " << sqrt(pos.x() * pos.x() + pos.y() * pos.y())
      << "  z = " << pos.z()
      << "  dimension = " << (*ir)->dimension()
      << "  " << (*ir)->det()->geographicalId().det()
      << "  " << (*ir)->det()->subDetector();

  }

}
GlobalMuonRefitter::ConstRecHitContainer GlobalMuonRefitter::selectMuonHits ( const Trajectory ,
const std::vector< int > &   
) const [protected]

select muon hits compatible with trajectory; check hits in chambers with showers

Definition at line 446 of file GlobalMuonRefitter.cc.

References CSCDetId::chamberId(), keep, LogTrace, Trajectory::measurements(), DetId::Muon, GlobalMuonRefitter::theCategory, GlobalMuonRefitter::theCSCChi2Cut, GlobalMuonRefitter::theDTChi2Cut, GlobalMuonRefitter::theHitThreshold, GlobalMuonRefitter::theRPCChi2Cut, and dtDQMClient_cfg::threshold.

                                                                        {

  ConstRecHitContainer muonRecHits;
  const double globalChi2Cut = 200.0;

  vector<TrajectoryMeasurement> muonMeasurements = traj.measurements(); 

  // loop through all muon hits and skip hits with bad chi2 in chambers with high occupancy      
  for (std::vector<TrajectoryMeasurement>::const_iterator im = muonMeasurements.begin(); im != muonMeasurements.end(); im++ ) {

    if ( !(*im).recHit()->isValid() ) continue;
    if ( (*im).recHit()->det()->geographicalId().det() != DetId::Muon ) {
      //      if ( ( chi2ndf < globalChi2Cut ) )
      muonRecHits.push_back((*im).recHit());
      continue;
    }  
    ConstMuonRecHitPointer immrh = dynamic_cast<const MuonTransientTrackingRecHit*>((*im).recHit().get());

    DetId id = immrh->geographicalId();
    DetId chamberId;
    int threshold = 0;
    double chi2Cut = 0.0;

    // get station of hit if it is in DT
    if ( (*immrh).isDT() ) {
      DTChamberId did(id.rawId());
      chamberId = did;
      threshold = theHitThreshold;
      chi2Cut = theDTChi2Cut;
    }
    // get station of hit if it is in CSC
    else if ( (*immrh).isCSC() ) {
      CSCDetId did(id.rawId());
      chamberId = did.chamberId();
      threshold = theHitThreshold;
      chi2Cut = theCSCChi2Cut;
    }
    // get station of hit if it is in RPC
    else if ( (*immrh).isRPC() ) {
      RPCDetId rpcid(id.rawId());
      chamberId = rpcid;
      threshold = theHitThreshold;
      chi2Cut = theRPCChi2Cut;
    } else
      continue;

    double chi2ndf = (*im).estimate()/(*im).recHit()->dimension();  

    bool keep = true;
    map<DetId,int>::const_iterator imap=hitMap.find(chamberId);
    if ( imap!=hitMap.end() ) 
      if (imap->second>threshold) keep = false;
    
    if ( (keep || (chi2ndf<chi2Cut)) && (chi2ndf<globalChi2Cut) ) {
      muonRecHits.push_back((*im).recHit());
    } else {
      LogTrace(theCategory)
        << "Skip hit: " << id.rawId() << " chi2=" 
        << chi2ndf << " ( threshold: " << chi2Cut << ") Det: " 
        << imap->second << endl;
    }
  }
  
  // check order of rechits
  reverse(muonRecHits.begin(),muonRecHits.end());
  return muonRecHits;
}
GlobalTrajectoryBuilderBase::ConstRecHitContainer GlobalTrajectoryBuilderBase::selectTrackerHits ( const ConstRecHitContainer all) const [protected]

select tracker hits; exclude some tracker hits in the global trajectory

Definition at line 435 of file GlobalTrajectoryBuilderBase.cc.

References cond::ecalcond::all, i, sistripsummary::TEC, and DetId::Tracker.

Referenced by build().

                                                                                    {
 
  int nTEC(0);

  ConstRecHitContainer hits;
  for (ConstRecHitContainer::const_iterator i = all.begin(); i != all.end(); i++) {
    if ( !(*i)->isValid() ) continue;
    if ( (*i)->det()->geographicalId().det() == DetId::Tracker &&
         (*i)->det()->geographicalId().subdetId() == StripSubdetector::TEC) {
      nTEC++;
    } else {
      hits.push_back((*i).get());
    }
    if ( nTEC > 1 ) return all;
  }

  return hits;

}
const MuonServiceProxy* GlobalTrajectoryBuilderBase::service ( ) const [inline, protected]

Definition at line 140 of file GlobalTrajectoryBuilderBase.h.

References theService.

{ return theService; }
void GlobalTrajectoryBuilderBase::setEvent ( const edm::Event event) [virtual]
GlobalMuonTrackMatcher* GlobalTrajectoryBuilderBase::trackMatcher ( ) const [inline, protected]
double GlobalTrajectoryBuilderBase::trackProbability ( const Trajectory track) const [protected]

calculate chi2 probability (-ln(P))

Definition at line 366 of file GlobalTrajectoryBuilderBase.cc.

References Trajectory::chiSquared(), LnChiSquaredProbability(), and Trajectory::ndof().

Referenced by build().

                                                                           {

  if ( track.ndof() > 0 && track.chiSquared() > 0 ) { 
    return -LnChiSquaredProbability(track.chiSquared(), track.ndof());
  } else {
    return 0.0;
  }

}
MuonTrajectoryBuilder::TrajectoryContainer GlobalTrajectoryBuilderBase::trajectories ( const TrajectorySeed ) [inline, virtual]

dummy implementation, unused in this class

Implements MuonTrajectoryBuilder.

Definition at line 76 of file GlobalTrajectoryBuilderBase.h.


Member Data Documentation

unsigned long long GlobalTrajectoryBuilderBase::theCacheId_TRH [private]

Definition at line 176 of file GlobalTrajectoryBuilderBase.h.

Referenced by GlobalTrajectoryBuilderBase(), and setEvent().

Definition at line 184 of file GlobalTrajectoryBuilderBase.h.

Referenced by setEvent().

Definition at line 171 of file GlobalTrajectoryBuilderBase.h.

Definition at line 179 of file GlobalTrajectoryBuilderBase.h.

Referenced by build(), and GlobalTrajectoryBuilderBase().

Definition at line 190 of file GlobalTrajectoryBuilderBase.h.

Referenced by getTransientRecHits(), and setEvent().

Definition at line 189 of file GlobalTrajectoryBuilderBase.h.

Referenced by GlobalTrajectoryBuilderBase(), and setEvent().

Definition at line 166 of file GlobalTrajectoryBuilderBase.h.

Referenced by build(), and GlobalTrajectoryBuilderBase().

Definition at line 180 of file GlobalTrajectoryBuilderBase.h.

Referenced by build(), and GlobalTrajectoryBuilderBase().

Definition at line 181 of file GlobalTrajectoryBuilderBase.h.

Referenced by build(), and GlobalTrajectoryBuilderBase().

Definition at line 187 of file GlobalTrajectoryBuilderBase.h.

Referenced by getTransientRecHits(), and setEvent().

Definition at line 186 of file GlobalTrajectoryBuilderBase.h.

Referenced by GlobalTrajectoryBuilderBase(), and setEvent().

Definition at line 192 of file GlobalTrajectoryBuilderBase.h.

Referenced by build(), and setEvent().