CMS 3D CMS Logo

CosmicMuonTrajectoryBuilder Class Reference

#include <RecoMuon/CosmicMuonProducer/interface/CosmicMuonTrajectoryBuilder.h>

Inheritance diagram for CosmicMuonTrajectoryBuilder:

MuonTrajectoryBuilder

List of all members.

Public Member Functions

MuonTrajectoryUpdatorbackwardUpdator () const
MuonBestMeasurementFinderbestMeasurementFinder () const
PropagationDirection checkDirectionByT0 (const DTRecSegment4D *, const DTRecSegment4D *) const
 CosmicMuonTrajectoryBuilder (const edm::ParameterSet &, const MuonServiceProxy *service)
 Constructor.
DirectMuonNavigationnavigation () const
const Propagatorpropagator () const
const PropagatorpropagatorAlong () const
const PropagatorpropagatorOpposite () const
virtual void setEvent (const edm::Event &)
 pass the Event to the algo at each event
CosmicMuonSmoothersmoother () const
double t0 (const DTRecSegment4D *deseg) const
virtual CandidateContainer trajectories (const TrackCand &)
 dummy implementation, unused in this class
std::vector< Trajectory * > trajectories (const TrajectorySeed &)
 build trajectories from seed
MuonTrajectoryUpdatorupdator () const
CosmicMuonUtilitiesutilities () const
virtual ~CosmicMuonTrajectoryBuilder ()
 Destructor.

Private Member Functions

void build (const TrajectoryStateOnSurface &, const NavigationDirection &, Trajectory &)
void buildSecondHalf (Trajectory &)
void estimateDirection (Trajectory &) const
 check the direction of trajectory by checking eta spread
std::vector
< TrajectoryMeasurement
findBestMeasurements (const DetLayer *, const TrajectoryStateOnSurface &, const Propagator *, const MeasurementEstimator *)
void flipTrajectory (Trajectory &) const
 flip a trajectory with refit (the momentum direction is opposite)
void getDirectionByTime (Trajectory &) const
 check the direction of trajectory by checking the timing
void incrementChamberCounters (const DetLayer *layer, int &dtChambers, int &cscChambers, int &rpcChambers, int &totalChambers)
TrajectoryStateOnSurface intermediateState (const TrajectoryStateOnSurface &) const
void reverseTrajectory (Trajectory &) const
 reverse a trajectory without refit (out the measurements order changed)
void reverseTrajectoryPropagationDirection (Trajectory &) const
 reverse the propagation direction of a trajectory
void selectHits (MuonTransientTrackingRecHit::MuonRecHitContainer &) const
bool selfDuplicate (const Trajectory &) const
 check if the trajectory iterates the same hit more than once
MuonTransientTrackingRecHit::MuonRecHitContainer unusedHits (const DetLayer *, const TrajectoryMeasurement &) const

Private Attributes

std::string category_
edm::Handle
< CSCRecHit2DCollection
cschits_
edm::Handle< DTRecHitCollectiondthits_
MuonBestMeasurementFindertheBestMeasurementFinder
MuonTrajectoryUpdatortheBKUpdator
unsigned long long theCacheId_DG
MuonDetLayerMeasurementstheLayerMeasurements
DirectMuonNavigationtheNavigation
edm::ParameterSet theNavigationPSet
int theNSuccess
int theNTraversing
std::string thePropagatorName
const MuonServiceProxy * theService
CosmicMuonSmoothertheSmoother
bool theTraversingMuonFlag
MuonTrajectoryUpdatortheUpdator


Detailed Description

Definition at line 39 of file CosmicMuonTrajectoryBuilder.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 47 of file CosmicMuonTrajectoryBuilder.cc.

References category_, edm::ParameterSet::getParameter(), insideOut, outsideIn, theBestMeasurementFinder, theBKUpdator, theCacheId_DG, theLayerMeasurements, theNavigation, theNavigationPSet, theNSuccess, theNTraversing, thePropagatorName, theService, theSmoother, theTraversingMuonFlag, and theUpdator.

00047                                                                                                                    :theService(service) { 
00048 
00049   thePropagatorName = par.getParameter<string>("Propagator");
00050 
00051   bool enableDTMeasurement = par.getParameter<bool>("EnableDTMeasurement");
00052   bool enableCSCMeasurement = par.getParameter<bool>("EnableCSCMeasurement");
00053   bool enableRPCMeasurement = par.getParameter<bool>("EnableRPCMeasurement");
00054 
00055 //  if(enableDTMeasurement)
00056   InputTag DTRecSegmentLabel = par.getParameter<InputTag>("DTRecSegmentLabel");
00057 
00058 //  if(enableCSCMeasurement)
00059   InputTag CSCRecSegmentLabel = par.getParameter<InputTag>("CSCRecSegmentLabel");
00060 
00061 //  if(enableRPCMeasurement)
00062   InputTag RPCRecSegmentLabel = par.getParameter<InputTag>("RPCRecSegmentLabel");
00063 
00064 
00065   theLayerMeasurements= new MuonDetLayerMeasurements(DTRecSegmentLabel,
00066                                                      CSCRecSegmentLabel,
00067                                                      RPCRecSegmentLabel,
00068                                                      enableDTMeasurement,
00069                                                      enableCSCMeasurement,
00070                                                      enableRPCMeasurement);
00071 
00072   ParameterSet muonUpdatorPSet = par.getParameter<ParameterSet>("MuonTrajectoryUpdatorParameters");
00073   
00074   theNavigation = 0; // new DirectMuonNavigation(theService->detLayerGeometry());
00075   theUpdator = new MuonTrajectoryUpdator(muonUpdatorPSet, insideOut);
00076 
00077   theBestMeasurementFinder = new MuonBestMeasurementFinder();
00078 
00079   ParameterSet muonBackwardUpdatorPSet = par.getParameter<ParameterSet>("BackwardMuonTrajectoryUpdatorParameters");
00080 
00081   theBKUpdator = new MuonTrajectoryUpdator(muonBackwardUpdatorPSet, outsideIn);
00082 
00083   theTraversingMuonFlag = par.getParameter<bool>("BuildTraversingMuon");
00084 
00085   ParameterSet smootherPSet = par.getParameter<ParameterSet>("MuonSmootherParameters");
00086 
00087   theNavigationPSet = par.getParameter<ParameterSet>("MuonNavigationParameters");
00088 
00089   theSmoother = new CosmicMuonSmoother(smootherPSet,theService);
00090 
00091   theNTraversing = 0;
00092   theNSuccess = 0;
00093   theCacheId_DG = 0;
00094   category_ = "Muon|RecoMuon|CosmicMuon|CosmicMuonTrajectoryBuilder";
00095 
00096 }

CosmicMuonTrajectoryBuilder::~CosmicMuonTrajectoryBuilder (  )  [virtual]

Destructor.

Definition at line 98 of file CosmicMuonTrajectoryBuilder.cc.

References category_, LogTrace, theBestMeasurementFinder, theBKUpdator, theLayerMeasurements, theNavigation, theNSuccess, theNTraversing, theSmoother, and theUpdator.

00098                                                           {
00099 
00100   LogTrace(category_)<< "CosmicMuonTrajectoryBuilder dtor called";
00101   if (theUpdator) delete theUpdator;
00102   if (theBKUpdator) delete theBKUpdator;
00103   if (theLayerMeasurements) delete theLayerMeasurements;
00104   if (theSmoother) delete theSmoother;
00105   if (theNavigation) delete theNavigation; 
00106   delete theBestMeasurementFinder;
00107 
00108   LogTrace(category_)<< "CosmicMuonTrajectoryBuilder Traversing: "<<theNSuccess<<"/"<<theNTraversing;
00109 
00110 }


Member Function Documentation

MuonTrajectoryUpdator* CosmicMuonTrajectoryBuilder::backwardUpdator (  )  const [inline]

Definition at line 67 of file CosmicMuonTrajectoryBuilder.h.

References theBKUpdator.

Referenced by build(), and trajectories().

00067 {return theBKUpdator;}

MuonBestMeasurementFinder* CosmicMuonTrajectoryBuilder::bestMeasurementFinder (  )  const [inline]

Definition at line 75 of file CosmicMuonTrajectoryBuilder.h.

References theBestMeasurementFinder.

00075 {return theBestMeasurementFinder;}

void CosmicMuonTrajectoryBuilder::build ( const TrajectoryStateOnSurface ts,
const NavigationDirection startingDir,
Trajectory traj 
) [private]

Definition at line 422 of file CosmicMuonTrajectoryBuilder.cc.

References alongMomentum, backwardUpdator(), PV3DBase< T, PVType, FrameType >::basicVector(), category_, DirectMuonNavigation::compatibleLayers(), Trajectory::empty(), HLT_VtxMuL3::estimator, findBestMeasurements(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::globalPosition(), if(), incrementChamberCounters(), TrajectoryStateOnSurface::isValid(), Trajectory::lastMeasurement(), LogTrace, MuonTrajectoryUpdator::makeFirstTime(), FreeTrajectoryState::momentum(), navigation(), oppositeToMomentum, FreeTrajectoryState::position(), Propagator::propagate(), propagator(), propagatorAlong(), propagatorOpposite(), TrajectoryStateOnSurface::rescaleError(), MuonTrajectoryUpdator::setFitDirection(), theBKUpdator, MuonTrajectoryUpdator::update(), TrajectoryMeasurement::updatedState(), updator(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by buildSecondHalf().

00424                                                           {
00425 
00426   if ( !ts.isValid() ) return;
00427 
00428   FreeTrajectoryState* fts = ts.freeState();
00429   if ( !fts ) return;
00430 
00431   vector<const DetLayer*> navLayers = (fts->position().basicVector().dot(fts->momentum().basicVector())>0) ? navigation()->compatibleLayers((*fts), alongMomentum) : navigation()->compatibleLayers((*fts), oppositeToMomentum);
00432   if (navLayers.empty()) return;
00433 
00434   theBKUpdator->setFitDirection(startingDir);
00435 
00436   int DTChamberUsedBack = 0;
00437   int CSCChamberUsedBack = 0;
00438   int RPCChamberUsedBack = 0;
00439   int TotalChamberUsedBack = 0;
00440 
00441   TrajectoryStateOnSurface lastTsos = 
00442       (traj.lastMeasurement().updatedState().globalPosition().y() <
00443       traj.firstMeasurement().updatedState().globalPosition().y()) ? 
00444       propagatorAlong()->propagate((*fts),navLayers.front()->surface()) : propagatorOpposite()->propagate((*fts),navLayers.front()->surface());
00445 
00446   if ( !lastTsos.isValid() ) { 
00447       LogTrace(category_)<<"propagation failed from fts to inner cylinder";
00448       return;
00449   }
00450   LogTrace(category_)<<"tsos  "<<lastTsos.globalPosition();
00451   lastTsos.rescaleError(10.);
00452   vector<TrajectoryMeasurement> measL;
00453   for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin();
00454       rnxtlayer!= navLayers.end(); ++rnxtlayer) {
00455 
00456       measL.clear();
00457       measL =
00458         findBestMeasurements(*rnxtlayer, lastTsos, propagator(), (backwardUpdator()->estimator()));
00459 
00460      if ( measL.empty() ) continue;
00461 
00462      for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
00463 
00464          pair<bool,TrajectoryStateOnSurface> bkresult
00465               = backwardUpdator()->update((&*theMeas), traj, propagator());
00466         if (bkresult.first ) {
00467             LogTrace(category_)<<"update ok : "<<(theMeas)->recHit()->globalPosition() ;
00468 
00469               incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
00470 
00471             if ( (!traj.empty()) && bkresult.second.isValid() ) 
00472                lastTsos = bkresult.second;
00473             else if ((theMeas)->predictedState().isValid()) 
00474                lastTsos = (theMeas)->predictedState();
00475           }
00476        }
00477   }
00478   navLayers.clear();
00479   updator()->makeFirstTime();
00480   backwardUpdator()->makeFirstTime();
00481 
00482   measL.clear();
00483   return;
00484 }

void CosmicMuonTrajectoryBuilder::buildSecondHalf ( Trajectory traj  )  [private]

Definition at line 486 of file CosmicMuonTrajectoryBuilder.cc.

References build(), category_, Trajectory::empty(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), insideOut, intermediateState(), TrajectoryStateOnSurface::isValid(), Trajectory::lastMeasurement(), LogTrace, TrajectoryMeasurement::predictedState(), TrajectoryMeasurement::recHit(), reverseTrajectory(), and TrajectoryMeasurement::updatedState().

Referenced by trajectories().

00486                                                                   {
00487 
00488   //C.L.:
00489   // the method builds trajectory in second hemisphere with pattern
00490   // recognition starting from an intermediate state
00491 
00492   if ( (traj.firstMeasurement().recHit()->globalPosition().perp()
00493       < traj.lastMeasurement().recHit()->globalPosition().perp()) ) {
00494     LogTrace(category_)<<"inside-out: reverseTrajectory"; 
00495     reverseTrajectory(traj);
00496   }
00497   if (traj.empty()) return;
00498   TrajectoryStateOnSurface tsos = traj.lastMeasurement().updatedState();
00499   if ( !tsos.isValid() ) tsos = traj.lastMeasurement().predictedState();
00500  LogTrace(category_)<<"last tsos on traj: pos: "<< tsos.globalPosition()<<" mom: "<< tsos.globalMomentum();
00501   if ( !tsos.isValid() ) {
00502      LogTrace(category_)<<"last tsos on traj invalid";
00503      return;
00504   }
00505 
00506   build(intermediateState(tsos),insideOut,traj);
00507   return;
00508 }

PropagationDirection CosmicMuonTrajectoryBuilder::checkDirectionByT0 ( const DTRecSegment4D dtseg1,
const DTRecSegment4D dtseg2 
) const

Definition at line 801 of file CosmicMuonTrajectoryBuilder.cc.

References alongMomentum, anyDirection, category_, lat::endl(), LogTrace, oppositeToMomentum, HLT_VtxMuL3::result, and t0().

00801                                                                                                                                      {
00802    LogTrace(category_) << "comparing dtseg: "<<dtseg1<<" "<<dtseg2<<endl;
00803    if (dtseg1 == dtseg2 || t0(dtseg1) == t0(dtseg2)) return anyDirection; 
00804 
00805    PropagationDirection result =
00806     (t0(dtseg1) < t0(dtseg2) ) ? alongMomentum : oppositeToMomentum;
00807    return result;
00808 }

void CosmicMuonTrajectoryBuilder::estimateDirection ( Trajectory traj  )  const [private]

check the direction of trajectory by checking eta spread

Definition at line 665 of file CosmicMuonTrajectoryBuilder.cc.

References category_, PV3DBase< T, PVType, FrameType >::eta(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), Trajectory::lastMeasurement(), LogTrace, Trajectory::recHits(), CosmicMuonUtilities::reverseDirection(), Trajectory::seed(), theService, theSmoother, CosmicMuonSmoother::trajectories(), TrajectoryMeasurement::updatedState(), and utilities().

Referenced by trajectories().

00665                                                                           {
00666 
00667   TransientTrackingRecHit::ConstRecHitContainer hits = traj.recHits();
00668 
00669   TrajectoryStateOnSurface firstTSOS = traj.firstMeasurement().updatedState();
00670 
00671   TrajectoryStateOnSurface lastTSOS = traj.lastMeasurement().updatedState();
00672 
00673   if ( !firstTSOS.isValid() || !lastTSOS.isValid() ) return;
00674 
00675   LogTrace(category_) <<"Two ends of the traj "<<firstTSOS.globalPosition()
00676                     <<", "<<lastTSOS.globalPosition();
00677 
00678   LogTrace(category_) <<"Their mom: "<<firstTSOS.globalMomentum()
00679                     <<", "<<lastTSOS.globalMomentum();
00680 
00681   LogTrace(category_) <<"Their mom eta: "<<firstTSOS.globalMomentum().eta()
00682                     <<", "<<lastTSOS.globalMomentum().eta();
00683 
00684   // momentum eta can be used to estimate direction
00685   // the beam-halo muon seems enter with a larger |eta|
00686 
00687   if ( fabs(firstTSOS.globalMomentum().eta()) > fabs(lastTSOS.globalMomentum().eta()) ) {
00688 
00689     vector<Trajectory> refitted = theSmoother->trajectories(traj.seed(),hits,firstTSOS);
00690     if ( !refitted.empty() ) traj = refitted.front();
00691 
00692   } else {
00693     std::reverse(hits.begin(), hits.end());
00694     utilities()->reverseDirection(lastTSOS,&*theService->magneticField());
00695     vector<Trajectory> refittedback = theSmoother->trajectories(traj.seed(),hits,lastTSOS);
00696     if ( !refittedback.empty() ) traj = refittedback.front();
00697 
00698   }
00699 
00700   return;
00701 
00702 }

std::vector< TrajectoryMeasurement > CosmicMuonTrajectoryBuilder::findBestMeasurements ( const DetLayer layer,
const TrajectoryStateOnSurface tsos,
const Propagator propagator,
const MeasurementEstimator estimator 
) [private]

Definition at line 747 of file CosmicMuonTrajectoryBuilder.cc.

References MuonBestMeasurementFinder::findBestMeasurement(), MuonDetLayerMeasurements::groupedMeasurements(), GeometricSearchDet::hasGroups(), MuonDetLayerMeasurements::measurements(), HLT_VtxMuL3::result, theBestMeasurementFinder, and theLayerMeasurements.

Referenced by build(), and trajectories().

00748                                                                                                                                                        {
00749 
00750   std::vector<TrajectoryMeasurement> result;
00751   std::vector<TrajectoryMeasurement> measurements;
00752 
00753   if( layer->hasGroups() ){
00754     std::vector<TrajectoryMeasurementGroup> measurementGroups =
00755       theLayerMeasurements->groupedMeasurements(layer, tsos, *propagator, *estimator);
00756 
00757     for(std::vector<TrajectoryMeasurementGroup>::const_iterator tmGroupItr = measurementGroups.begin();
00758         tmGroupItr != measurementGroups.end(); ++tmGroupItr){
00759     
00760       measurements = tmGroupItr->measurements();
00761       const TrajectoryMeasurement* bestMeasurement 
00762         = theBestMeasurementFinder->findBestMeasurement(measurements, propagator);
00763       
00764       if(bestMeasurement) result.push_back(*bestMeasurement);
00765     }
00766   } 
00767   else{
00768     measurements = theLayerMeasurements->measurements(layer, tsos, *propagator, *estimator);
00769     const TrajectoryMeasurement* bestMeasurement 
00770       = theBestMeasurementFinder->findBestMeasurement(measurements, propagator);
00771 
00772     if(bestMeasurement) result.push_back(*bestMeasurement);
00773   }
00774   measurements.clear();
00775   return result;
00776 }

void CosmicMuonTrajectoryBuilder::flipTrajectory ( Trajectory traj  )  const [private]

flip a trajectory with refit (the momentum direction is opposite)

Definition at line 619 of file CosmicMuonTrajectoryBuilder.cc.

References category_, lat::endl(), CosmicMuonSmoother::fit(), TrajectoryStateOnSurface::isValid(), Trajectory::lastMeasurement(), LogTrace, Trajectory::recHits(), CosmicMuonUtilities::reverseDirection(), Trajectory::seed(), theService, theSmoother, TrajectoryMeasurement::updatedState(), and utilities().

Referenced by trajectories().

00619                                                                        {
00620 
00621     TrajectoryStateOnSurface lastTSOS = traj.lastMeasurement().updatedState();
00622     if ( !lastTSOS.isValid() )   {
00623           LogTrace(category_)<< "Error: last TrajectoryState invalid.";
00624     }  
00625     TransientTrackingRecHit::ConstRecHitContainer hits = traj.recHits();
00626     std::reverse(hits.begin(), hits.end());
00627 
00628     LogTrace(category_)<< "last tsos before flipping "<<lastTSOS;
00629     utilities()->reverseDirection(lastTSOS,&*theService->magneticField());
00630     LogTrace(category_)<< "last tsos after flipping "<<lastTSOS;
00631 
00632     vector<Trajectory> refittedback = theSmoother->fit(traj.seed(),hits,lastTSOS);
00633     if ( refittedback.empty() ) {
00634        LogTrace(category_) <<"flipTrajectory fail. "<<endl;
00635        return;
00636     }
00637   LogTrace(category_) <<"flipTrajectory: first "<< refittedback.front().firstMeasurement().updatedState()
00638                       <<"\nflipTrajectory: last "<<refittedback.front().lastMeasurement().updatedState();
00639 
00640     traj = refittedback.front();
00641     return;
00642 }

void CosmicMuonTrajectoryBuilder::getDirectionByTime ( Trajectory traj  )  const [private]

check the direction of trajectory by checking the timing

Definition at line 707 of file CosmicMuonTrajectoryBuilder.cc.

References category_, cschits_, dthits_, lat::endl(), LogTrace, PV3DBase< T, PVType, FrameType >::perp(), range, and Trajectory::recHits().

00707                                                                            {
00708 
00709   TransientTrackingRecHit::ConstRecHitContainer hits = traj.recHits();
00710   LogTrace(category_) << "getDirectionByTime"<<endl;
00711   for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
00712     if ( !(*ir)->isValid() ) {
00713       LogTrace(category_) << "invalid RecHit"<<endl;
00714       continue;
00715     }
00716 
00717     const GlobalPoint& pos = (*ir)->globalPosition();
00718     LogTrace(category_)
00719     << "pos"<<pos
00720     << "radius "<<pos.perp()
00721     << "  dim " << (*ir)->dimension()
00722     << "  det " << (*ir)->det()->geographicalId().det()
00723     << "  sub det " << (*ir)->det()->subDetector()<<endl;
00724 
00725     if ((*ir)->det()->geographicalId().det() == 2 && (*ir)->det()->subDetector() == 6) { 
00726 //      const CSCRecHit2D* iCSC = dynamic_cast<const CSCRecHit2D*>(&**ir);
00727 //      if (iCSC) LogTrace(category_)<<"csc from cast tpeak "<<iCSC->tpeak(); 
00728       CSCRecHit2DCollection::range thisrange = cschits_->get(CSCDetId((*ir)->geographicalId()));
00729       for (CSCRecHit2DCollection::const_iterator rechit = thisrange.first; rechit!=thisrange.second;++rechit) {
00730          if ((*rechit).isValid()) LogTrace(category_)<<"csc from collection tpeak "<<(*rechit).tpeak();
00731       }
00732     }
00733     if ((*ir)->det()->geographicalId().det() == 2 && (*ir)->det()->subDetector() == 7) {
00734 //      const DTRecHit1D* iDT = dynamic_cast<const DTRecHit1D*>(&**ir);
00735 //      if (iDT) LogTrace(category_)<<"dt digitime "<<iDT->digiTime();
00736       DTRecHitCollection::range thisrange = dthits_->get(DTLayerId((*ir)->geographicalId()));
00737       for (DTRecHitCollection::const_iterator rechit = thisrange.first; rechit!=thisrange.second;++rechit) {
00738          if ((*rechit).isValid()) LogTrace(category_)<<"dt from collection digitime "<<(*rechit).digiTime();
00739       }
00740     }
00741   }
00742   return;
00743 
00744 }

void CosmicMuonTrajectoryBuilder::incrementChamberCounters ( const DetLayer layer,
int dtChambers,
int cscChambers,
int rpcChambers,
int totalChambers 
) [private]

Definition at line 778 of file CosmicMuonTrajectoryBuilder.cc.

References GeomDetEnumerators::CSC, GeomDetEnumerators::DT, GeomDetEnumerators::RPCBarrel, GeomDetEnumerators::RPCEndcap, and DetLayer::subDetector().

Referenced by build(), and trajectories().

00778                                                                                                                                                         {
00779 
00780   if(layer->subDetector()==GeomDetEnumerators::DT) dtChambers++; 
00781   else if(layer->subDetector()==GeomDetEnumerators::CSC) cscChambers++; 
00782   else if(layer->subDetector()==GeomDetEnumerators::RPCBarrel || layer->subDetector()==GeomDetEnumerators::RPCEndcap) rpcChambers++; 
00783   totalChambers++;
00784 }

TrajectoryStateOnSurface CosmicMuonTrajectoryBuilder::intermediateState ( const TrajectoryStateOnSurface tsos  )  const [private]

Definition at line 510 of file CosmicMuonTrajectoryBuilder.cc.

References category_, TrajectoryStateOnSurface::globalDirection(), LogTrace, Propagator::propagate(), and propagator().

Referenced by buildSecondHalf().

00510                                                                                                                   {
00511 
00512 
00513   PerpendicularBoundPlaneBuilder planeBuilder;
00514   GlobalPoint pos(0.0, 0.0, 0.0);
00515   BoundPlane* SteppingPlane = planeBuilder(pos,tsos.globalDirection());
00516 
00517   TrajectoryStateOnSurface predTsos = propagator()->propagate(tsos, *SteppingPlane);
00518   if ( predTsos.isValid() )
00519   LogTrace(category_)<<"intermediateState: a intermediate state: pos: "<<predTsos.globalPosition() << "mom: " << predTsos.globalMomentum();
00520 
00521   return predTsos;
00522 
00523 }

DirectMuonNavigation* CosmicMuonTrajectoryBuilder::navigation (  )  const [inline]

Definition at line 73 of file CosmicMuonTrajectoryBuilder.h.

References theNavigation.

Referenced by build(), and trajectories().

00073 {return theNavigation;}

const Propagator* CosmicMuonTrajectoryBuilder::propagator ( void   )  const [inline]

Definition at line 58 of file CosmicMuonTrajectoryBuilder.h.

References thePropagatorName, and theService.

Referenced by build(), intermediateState(), and trajectories().

00058 {return &*theService->propagator(thePropagatorName);}

const Propagator* CosmicMuonTrajectoryBuilder::propagatorAlong (  )  const [inline]

Definition at line 61 of file CosmicMuonTrajectoryBuilder.h.

References theService.

Referenced by build().

00061 {return &*theService->propagator("SteppingHelixPropagatorAlong");}

const Propagator* CosmicMuonTrajectoryBuilder::propagatorOpposite (  )  const [inline]

Definition at line 63 of file CosmicMuonTrajectoryBuilder.h.

References theService.

Referenced by build().

00063 {return &*theService->propagator("SteppingHelixPropagatorOpposite");}

void CosmicMuonTrajectoryBuilder::reverseTrajectory ( Trajectory traj  )  const [private]

reverse a trajectory without refit (out the measurements order changed)

Definition at line 599 of file CosmicMuonTrajectoryBuilder.cc.

References alongMomentum, Trajectory::firstMeasurement(), Trajectory::lastMeasurement(), Trajectory::measurements(), oppositeToMomentum, TrajectoryMeasurement::recHit(), and Trajectory::seed().

Referenced by buildSecondHalf().

00599                                                                           {
00600 
00601   PropagationDirection newDir = (traj.firstMeasurement().recHit()->globalPosition().y()
00602       < traj.lastMeasurement().recHit()->globalPosition().y())
00603   ? oppositeToMomentum : alongMomentum;
00604   Trajectory newTraj(traj.seed(), newDir);
00605   
00606  const std::vector<TrajectoryMeasurement>& meas = traj.measurements();
00607 
00608   for (std::vector<TrajectoryMeasurement>::const_reverse_iterator itm = meas.rbegin();
00609        itm != meas.rend(); ++itm ) {
00610     newTraj.push(*itm);
00611   }
00612   traj = newTraj;
00613 
00614 }

void CosmicMuonTrajectoryBuilder::reverseTrajectoryPropagationDirection ( Trajectory traj  )  const [private]

reverse the propagation direction of a trajectory

Definition at line 644 of file CosmicMuonTrajectoryBuilder.cc.

References alongMomentum, anyDirection, Trajectory::direction(), Trajectory::empty(), Trajectory::measurements(), oppositeToMomentum, Trajectory::pop(), and Trajectory::seed().

Referenced by trajectories().

00644                                                                                               {
00645    if ( traj.direction() == anyDirection ) return;
00646    PropagationDirection newDir = (traj.direction() == alongMomentum)? oppositeToMomentum : alongMomentum;
00647    Trajectory newTraj(traj.seed(), newDir);
00648    const std::vector<TrajectoryMeasurement>& meas = traj.measurements();
00649 
00650    for (std::vector<TrajectoryMeasurement>::const_iterator itm = meas.begin();
00651          itm != meas.end(); ++itm) {
00652       newTraj.push(*itm);
00653    }
00654 
00655    while (!traj.empty()) {
00656      traj.pop();
00657    }
00658 
00659    traj = newTraj;
00660 }

void CosmicMuonTrajectoryBuilder::selectHits ( MuonTransientTrackingRecHit::MuonRecHitContainer hits  )  const [private]

Definition at line 525 of file CosmicMuonTrajectoryBuilder.cc.

References i, j, keep, and tmp.

00525                                                                                                        {
00526 
00527   if ( hits.size() < 2 ) return;
00528 
00529   MuonRecHitContainer tmp;
00530   vector<bool> keep(hits.size(),true);
00531   int i(0);
00532   int j(0);
00533 
00534   for (MuonRecHitContainer::const_iterator ihit = hits.begin();
00535        ihit != hits.end(); ++ihit ) {
00536     if ( !keep[i] ) { i++; continue; };
00537     j = i + 1;
00538     for (MuonRecHitContainer::const_iterator ihit2 = ihit + 1;
00539          ihit2 != hits.end(); ++ihit2 ) {
00540          if ( !keep[j] ) { j++; continue; }
00541          if ((*ihit)->geographicalId() == (*ihit2)->geographicalId() ) {
00542            if ( (*ihit)->dimension() > (*ihit2)->dimension() ) {
00543               keep[j] = false;
00544            } else if ( (*ihit)->dimension() < (*ihit2)->dimension() ) {
00545               keep[i] = false;
00546            } else  {
00547            if ( (*ihit)->transientHits().size()>(*ihit2)->transientHits().size() ) { 
00548               keep[j] = false;
00549            } else if ( (*ihit)->transientHits().size()<(*ihit2)->transientHits().size() ) {
00550               keep[i] = false;
00551            } 
00552             else if ( (*ihit)->degreesOfFreedom() != 0 && (*ihit2)->degreesOfFreedom() != 0)  {
00553             if (((*ihit)->chi2()/(*ihit)->degreesOfFreedom()) > ((*ihit2)->chi2()/(*ihit)->degreesOfFreedom())) keep[i] = false;
00554             else keep[j] = false;
00555            }
00556           }
00557          } // if same geomid 
00558       j++;
00559     }
00560     i++;
00561   }
00562 
00563   i = 0;
00564   for (MuonRecHitContainer::const_iterator ihit = hits.begin();
00565        ihit != hits.end(); ++ihit ) {
00566      if (keep[i] ) tmp.push_back(*ihit);
00567      i++;
00568   }
00569 
00570   hits.clear();
00571   hits.swap(tmp);
00572   return;
00573 
00574 }

bool CosmicMuonTrajectoryBuilder::selfDuplicate ( const Trajectory traj  )  const [private]

check if the trajectory iterates the same hit more than once

Definition at line 577 of file CosmicMuonTrajectoryBuilder.cc.

References Trajectory::empty(), Trajectory::recHits(), and HLT_VtxMuL3::result.

Referenced by trajectories().

00577                                                                             {
00578 
00579   TransientTrackingRecHit::ConstRecHitContainer hits = traj.recHits();
00580 
00581   if (traj.empty()) return true;
00582 
00583   bool result = false;
00584   for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
00585     if ( !(*ir)->isValid() )  continue;
00586     for (ConstRecHitContainer::const_iterator ir2 = ir+1; ir2 != hits.end(); ir2++ ) {
00587       if ( !(*ir2)->isValid() )  continue;
00588       if ( (*ir) == (*ir2) ) result = true;
00589     }
00590   }
00591 
00592   return result;
00593 }

void CosmicMuonTrajectoryBuilder::setEvent ( const edm::Event event  )  [virtual]

pass the Event to the algo at each event

Implements MuonTrajectoryBuilder.

Definition at line 112 of file CosmicMuonTrajectoryBuilder.cc.

References category_, LogTrace, MuonDetLayerMeasurements::setEvent(), theCacheId_DG, theLayerMeasurements, theNavigation, theNavigationPSet, and theService.

00112                                                                 {
00113 
00114   theLayerMeasurements->setEvent(event);
00115 
00116   // DetLayer Geometry
00117   unsigned long long newCacheId_DG = theService->eventSetup().get<MuonRecoGeometryRecord>().cacheIdentifier();
00118   if ( newCacheId_DG != theCacheId_DG ) {
00119     LogTrace(category_) << "Muon Reco Geometry changed!";
00120     theCacheId_DG = newCacheId_DG;
00121     if (theNavigation) delete theNavigation;
00122     theNavigation = new DirectMuonNavigation(theService->detLayerGeometry(), theNavigationPSet);
00123   }
00124 
00125 //  event.getByLabel("csc2DRecHits", cschits_);
00126 //  event.getByLabel("dt1DRecHits", dthits_);
00127 
00128 }

CosmicMuonSmoother* CosmicMuonTrajectoryBuilder::smoother (  )  const [inline]

Definition at line 69 of file CosmicMuonTrajectoryBuilder.h.

References theSmoother.

Referenced by utilities().

00069 {return theSmoother;}

double CosmicMuonTrajectoryBuilder::t0 ( const DTRecSegment4D deseg  )  const

Definition at line 786 of file CosmicMuonTrajectoryBuilder.cc.

References category_, DTRecSegment4D::hasPhi(), LogTrace, DTRecSegment4D::phiSegment(), HLT_VtxMuL3::result, DTRecSegment2D::specificRecHits(), and DTRecSegment2D::t0().

Referenced by checkDirectionByT0().

00786                                                                         {
00787 
00788    if ( (dtseg == 0) || (!dtseg->hasPhi()) ) return 0;
00789    // timing information
00790    double result = 0;
00791    if ( dtseg->phiSegment() == 0 )  return 0; 
00792    int phiHits = dtseg->phiSegment()->specificRecHits().size();
00793    LogTrace(category_) << "phiHits "<<phiHits;
00794    if (phiHits>5) {
00795      result = dtseg->phiSegment()->t0();
00796      LogTrace(category_) << " Phi t0: " << dtseg->phiSegment()->t0() << " hits: " << phiHits;
00797    }
00798    return result;
00799 }

virtual CandidateContainer CosmicMuonTrajectoryBuilder::trajectories ( const TrackCand  )  [inline, virtual]

dummy implementation, unused in this class

Definition at line 52 of file CosmicMuonTrajectoryBuilder.h.

00052                                                             {
00053     return CandidateContainer();
00054   }

MuonTrajectoryBuilder::TrajectoryContainer CosmicMuonTrajectoryBuilder::trajectories ( const TrajectorySeed seed  )  [virtual]

build trajectories from seed

Implements MuonTrajectoryBuilder.

Definition at line 131 of file CosmicMuonTrajectoryBuilder.cc.

References funct::abs(), alongMomentum, backwardUpdator(), GeomDetEnumerators::barrel, PV3DBase< T, PVType, FrameType >::basicVector(), buildSecondHalf(), category_, Trajectory::chiSquared(), DirectMuonNavigation::compatibleEndcapLayers(), DirectMuonNavigation::compatibleLayers(), MuonSubdetId::CSC, debug, dir, Trajectory::direction(), MuonPatternRecoDumper::dumpLayer(), MuonPatternRecoDumper::dumpMuonId(), Trajectory::empty(), GeomDetEnumerators::endcap, lat::endl(), estimateDirection(), HLT_VtxMuL3::estimator, MuonTrajectoryUpdator::estimator(), PV3DBase< T, PVType, FrameType >::eta(), findBestMeasurements(), Trajectory::firstMeasurement(), flipTrajectory(), TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), if(), incrementChamberCounters(), insideOut, Trajectory::isValid(), TrajectoryStateOnSurface::isValid(), Trajectory::lastLayer(), Trajectory::lastMeasurement(), TrajectoryMeasurement::layer(), DetLayer::location(), LogTrace, PV3DBase< T, PVType, FrameType >::mag(), Trajectory::measurements(), navigation(), oppositeToMomentum, outsideIn, Trajectory::pop(), propagator(), TrajectoryStateOnSurface::rescaleError(), HLT_VtxMuL3::result, reverseTrajectoryPropagationDirection(), selfDuplicate(), MuonTrajectoryUpdator::setFitDirection(), TrajectorySeed::startingState(), t, theBKUpdator, theService, theSmoother, theTraversingMuonFlag, CosmicMuonSmoother::trajectories(), unusedHits(), MuonTrajectoryUpdator::update(), TrajectoryMeasurement::updatedState(), updator(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

00131                                                                    {
00132 
00133   vector<Trajectory*> trajL = vector<Trajectory*>();
00134   TrajectoryStateTransform tsTransform;
00135   MuonPatternRecoDumper debug;
00136 
00137   PTrajectoryStateOnDet ptsd1(seed.startingState());
00138   DetId did(ptsd1.detId());
00139   const BoundPlane& bp = theService->trackingGeometry()->idToDet(did)->surface();
00140   TrajectoryStateOnSurface lastTsos = tsTransform.transientState(ptsd1,&bp,&*theService->magneticField());
00141       LogTrace(category_) << "Seed: mom "<<lastTsos.globalMomentum()
00142                           <<"pos: " <<lastTsos.globalPosition();
00143   
00144   bool beamhaloFlag =  ( (did.subdetId() == MuonSubdetId::CSC) && fabs(lastTsos.globalMomentum().eta()) > 4.0);
00145 
00146   vector<const DetLayer*> navLayers = ( beamhaloFlag )? navigation()->compatibleEndcapLayers(*(lastTsos.freeState()), alongMomentum) : navigation()->compatibleLayers(*(lastTsos.freeState()), alongMomentum);
00147 
00148   LogTrace(category_)<<"found "<<navLayers.size()<<" compatible DetLayers for the Seed";
00149   if (navLayers.empty()) return trajL;
00150   
00151   vector<DetWithState> detsWithStates;
00152   LogTrace(category_) <<"Compatible layers:";
00153   for( vector<const DetLayer*>::const_iterator layer = navLayers.begin();
00154        layer != navLayers.end(); layer++){
00155     LogTrace(category_)<< debug.dumpMuonId((*layer)->basicComponents().front()->geographicalId()) 
00156                      << debug.dumpLayer(*layer);
00157   }
00158 
00159   detsWithStates = navLayers.front()->compatibleDets(lastTsos, *propagator(), *(updator()->estimator()));
00160   LogTrace(category_)<<"Number of compatible dets: "<<detsWithStates.size()<<endl;
00161 
00162   if( !detsWithStates.empty() ){
00163     // get the updated TSOS
00164     if ( detsWithStates.front().second.isValid() ) {
00165       LogTrace(category_)<<"New starting TSOS is on det: "<<endl;
00166       LogTrace(category_) << debug.dumpMuonId(detsWithStates.front().first->geographicalId())
00167                         << debug.dumpLayer(navLayers.front());
00168       lastTsos = detsWithStates.front().second;
00169       LogTrace(category_) << "Seed after extrapolation: mom "<<lastTsos.globalMomentum()
00170                           <<"pos: " << lastTsos.globalPosition();
00171     }
00172   }
00173   detsWithStates.clear();
00174   if ( !lastTsos.isValid() ) return trajL;
00175 
00176   TrajectoryStateOnSurface secondLast = lastTsos;
00177 
00178   lastTsos.rescaleError(10.0);
00179 
00180   Trajectory* theTraj = new Trajectory(seed,alongMomentum);
00181 
00182   navLayers.clear();
00183 
00184   navLayers =  ( beamhaloFlag ) ? navigation()->compatibleEndcapLayers(*(lastTsos.freeState()), alongMomentum) : navigation()->compatibleLayers(*(lastTsos.freeState()), alongMomentum);
00185 
00186   int DTChamberUsedBack = 0;
00187   int CSCChamberUsedBack = 0;
00188   int RPCChamberUsedBack = 0;
00189   int TotalChamberUsedBack = 0;
00190   MuonTransientTrackingRecHit::MuonRecHitContainer allUnusedHits;
00191   vector<TrajectoryMeasurement> measL;
00192 
00193   LogTrace(category_)<<"Begin forward fit "<<navLayers.size();
00194 
00195   for ( vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin(); rnxtlayer!= navLayers.end(); ++rnxtlayer) {
00196      LogTrace(category_)<<"new layer ";
00197      measL.clear();
00198      LogTrace(category_)<< debug.dumpMuonId((*rnxtlayer)->basicComponents().front()->geographicalId())
00199                      << debug.dumpLayer(*rnxtlayer);
00200      LogTrace(category_)<<"from lastTsos "<<lastTsos.globalMomentum()<<" at "<<lastTsos.globalPosition();
00201  
00202       measL =
00203         findBestMeasurements(*rnxtlayer, lastTsos, propagator(), (updator()->estimator()));
00204 
00205      if ( measL.empty() &&  (abs(theService->magneticField()->inTesla(GlobalPoint(0,0,0)).z()) < 0.01) && (theService->propagator("StraightLinePropagator").isValid() ) )  {
00206        LogTrace(category_)<<"try straight line propagator ";
00207        measL = findBestMeasurements(*rnxtlayer, lastTsos, &*theService->propagator("StraightLinePropagator"), (updator()->estimator()));
00208      }
00209      if ( measL.empty() ) continue;
00210 
00211      for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
00212             pair<bool,TrajectoryStateOnSurface> result
00213               = updator()->update((&*theMeas), *theTraj, propagator());
00214 
00215             if (result.first ) {
00216               LogTrace(category_)<<"update ok ";
00217               incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
00218               secondLast = lastTsos;
00219               if ( (!theTraj->empty()) && result.second.isValid() ) {
00220                 lastTsos = result.second;
00221                 LogTrace(category_)<<"get new lastTsos here "<<lastTsos.globalMomentum()<<" at "<<lastTsos.globalPosition();
00222 
00223               }  else if ((theMeas)->predictedState().isValid()) lastTsos = (theMeas)->predictedState();
00224            }
00225       }
00226   } 
00227   measL.clear();
00228   while (!theTraj->empty()) {
00229     theTraj->pop();
00230   }
00231 
00232   if (!theTraj->isValid() || TotalChamberUsedBack < 2 || (DTChamberUsedBack+CSCChamberUsedBack) == 0 || !lastTsos.isValid()) {
00233     delete theTraj;
00234     return trajL;
00235   }
00236   delete theTraj;
00237 
00238 
00239   //if got good trajectory, then do backward refitting
00240   DTChamberUsedBack = 0;
00241   CSCChamberUsedBack = 0;
00242   RPCChamberUsedBack = 0;
00243   TotalChamberUsedBack = 0;
00244 
00245   Trajectory myTraj(seed, oppositeToMomentum);
00246 
00247   // set starting navigation direction for MuonTrajectoryUpdator
00248 
00249   GlobalPoint lastPos = lastTsos.globalPosition();
00250   GlobalPoint secondLastPos = secondLast.globalPosition();
00251   GlobalVector momDir = secondLastPos - lastPos;
00252 
00253   if ( lastPos.basicVector().dot(momDir.basicVector()) > 0 ) { 
00254 //      LogTrace("CosmicMuonTrajectoryBuilder")<<"Fit direction changed to insideOut";
00255       theBKUpdator->setFitDirection(insideOut);
00256     } else theBKUpdator->setFitDirection(outsideIn);
00257 
00258   if ( beamhaloFlag ) { 
00259      std::reverse(navLayers.begin(), navLayers.end());
00260   } else navLayers = navigation()->compatibleLayers(*(lastTsos.freeState()), oppositeToMomentum);
00261 
00262   LogTrace(category_)<<"Begin backward refitting";
00263 
00264   for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin();
00265       rnxtlayer!= navLayers.end(); ++rnxtlayer) {
00266 
00267      measL.clear();
00268 
00269      measL =
00270         findBestMeasurements(*rnxtlayer, lastTsos, propagator(), (backwardUpdator()->estimator()));
00271 
00272      if ( measL.empty() ) continue;
00273 
00274      for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
00275       // if the part change, we need to reconsider the fit direction
00276          if (rnxtlayer != navLayers.begin()) {
00277            vector<const DetLayer*>::const_iterator lastlayer = rnxtlayer;
00278            lastlayer--;
00279 
00280            if((*rnxtlayer)->location() != (*lastlayer)->location() ) {
00281 
00282               lastPos = lastTsos.globalPosition();
00283               GlobalPoint thisPos = (theMeas)->predictedState().globalPosition();
00284               GlobalVector momDir = thisPos - lastPos;
00285 //          LogTrace("CosmicMuonTrajectoryBuilder")<<"momDir "<<momDir;
00286  
00287               if ( momDir.mag() > 0.01 ) { //if lastTsos is on the surface, no need
00288                 if ( thisPos.basicVector().dot(momDir.basicVector()) > 0 ) {
00289                      theBKUpdator->setFitDirection(insideOut);
00290                   } else theBKUpdator->setFitDirection(outsideIn);
00291               }
00292             }
00293            if ( ((*lastlayer)->location() == GeomDetEnumerators::endcap) && 
00294                 ((*rnxtlayer)->location() == GeomDetEnumerators::endcap) && 
00295                 (lastTsos.globalPosition().z() * (theMeas)->predictedState().globalPosition().z() < 0)  ) {
00296                     theBKUpdator->setFitDirection(insideOut);
00297             }
00298 
00299        }
00300 //       if (theBKUpdator->fitDirection() == insideOut) 
00301 //          LogTrace("CosmicMuonTrajectoryBuilder")<<"Fit direction insideOut";
00302 //       else LogTrace("CosmicMuonTrajectoryBuilder")<<"Fit direction outsideIn";
00303          pair<bool,TrajectoryStateOnSurface> bkresult
00304               = backwardUpdator()->update((&*theMeas), myTraj, propagator());
00305 
00306          if (bkresult.first ) {
00307 
00308               incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
00309 
00310             if ( theTraversingMuonFlag ) {
00311               MuonRecHitContainer tmpUnusedHits = unusedHits(*rnxtlayer,*theMeas);
00312               allUnusedHits.insert(allUnusedHits.end(),tmpUnusedHits.begin(),tmpUnusedHits.end());
00313             }
00314             if ( (!myTraj.empty()) && bkresult.second.isValid() ) 
00315                lastTsos = bkresult.second;
00316             else if ((theMeas)->predictedState().isValid()) 
00317                lastTsos = (theMeas)->predictedState();
00318           }
00319        }
00320   }
00321 
00322   for ( vector<Trajectory*>::iterator t = trajL.begin(); t != trajL.end(); ++t ) delete *t;
00323 
00324   trajL.clear();
00325 
00326   if (( !myTraj.isValid() ) || ( myTraj.empty() ) || ( (selfDuplicate(myTraj)) )|| TotalChamberUsedBack < 2 || (DTChamberUsedBack+CSCChamberUsedBack) < 1) {
00327       return trajL;
00328   }
00329 
00330   if ( theTraversingMuonFlag && ( allUnusedHits.size() >= 2 ) && 
00331      ( ( myTraj.lastLayer()->location() == GeomDetEnumerators::barrel ) ||
00332        ( myTraj.firstMeasurement().layer()->location() == GeomDetEnumerators::barrel ) ) ) {
00333 //      LogTrace(category_)<<utilities()->print(allUnusedHits);
00334       LogTrace(category_)<<"Building trajectory in second hemisphere...";
00335       buildSecondHalf(myTraj);
00336   }
00337 
00338   LogTrace(category_) <<" traj ok ";
00339 
00340 //     getDirectionByTime(myTraj);
00341   if (beamhaloFlag) estimateDirection(myTraj);
00342   if ( myTraj.empty() ) return trajL;
00343 
00344   // try to smooth it 
00345   vector<Trajectory> smoothed = theSmoother->trajectories(myTraj); 
00346 
00347   if ( !smoothed.empty() && smoothed.front().foundHits()> 3 )  {  
00348     LogTrace(category_) <<" Smoothed successfully."; 
00349     myTraj = smoothed.front(); 
00350   } 
00351   else {  
00352     LogTrace(category_) <<" Smooth failed."; 
00353   } 
00354 
00355   LogTrace(category_) <<"first "<< myTraj.firstMeasurement().updatedState()
00356                       <<"\n last "<<myTraj.lastMeasurement().updatedState();
00357   if ( myTraj.direction() == alongMomentum ) LogTrace(category_)<<"alongMomentum";
00358   else if (myTraj.direction() == oppositeToMomentum ) LogTrace(category_)<<"oppositeMomentum";
00359   else LogTrace(category_)<<"anyDirection";
00360 
00361   if (!beamhaloFlag) {
00362       if ( myTraj.lastMeasurement().updatedState().globalMomentum().y() > 0 ) {
00363           LogTrace(category_)<<"flip trajectory ";
00364           flipTrajectory(myTraj);
00365       }
00366 
00367       if ( ( myTraj.direction() == alongMomentum && 
00368            (myTraj.firstMeasurement().updatedState().globalPosition().y() 
00369            < myTraj.lastMeasurement().updatedState().globalPosition().y()))
00370         || (myTraj.direction() == oppositeToMomentum && 
00371            (myTraj.firstMeasurement().updatedState().globalPosition().y() 
00372            > myTraj.lastMeasurement().updatedState().globalPosition().y())) ) {
00373            LogTrace(category_)<<"reverse propagation direction";
00374           reverseTrajectoryPropagationDirection(myTraj); 
00375       }
00376   }
00377 //  getDirectionByTime(myTraj);
00378   if ( !myTraj.isValid() ) return trajL;
00379 
00380 //check direction agree with position!
00381   PropagationDirection dir = myTraj.direction();
00382   GlobalVector dirFromPos = myTraj.measurements().back().recHit()->globalPosition() - myTraj.measurements().front().recHit()->globalPosition();
00383 
00384   LogTrace(category_)<< "last hit " <<myTraj.measurements().back().recHit()->globalPosition()<<endl;
00385   LogTrace(category_)<< "first hit " <<myTraj.measurements().front().recHit()->globalPosition()<<endl;
00386 
00387   LogTrace(category_)<< "last tsos " <<myTraj.measurements().back().updatedState().globalPosition()<<" mom "<<myTraj.measurements().back().updatedState().globalMomentum()<<endl;
00388   LogTrace(category_)<< "first tsos " <<myTraj.measurements().front().updatedState().globalPosition()<<" mom "<<myTraj.measurements().front().updatedState().globalMomentum()<<endl;
00389 
00390   PropagationDirection propDir =
00391       ( dirFromPos.basicVector().dot(myTraj.firstMeasurement().updatedState().globalMomentum().basicVector()) > 0) ? alongMomentum : oppositeToMomentum;
00392   LogTrace(category_)<<" dir "<<dir <<" propDir "<<propDir<<endl;
00393 
00394   LogTrace(category_)<<"chi2 "<<myTraj.chiSquared() <<endl;
00395 
00396   if (dir != propDir ) {
00397       LogTrace(category_)<< "reverse propagation direction ";
00398       reverseTrajectoryPropagationDirection(myTraj);
00399   }
00400   if ( myTraj.empty() ) return trajL;
00401 
00402   trajL.push_back(new Trajectory(myTraj));
00403   navLayers.clear();
00404   return trajL;
00405 }

MuonTransientTrackingRecHit::MuonRecHitContainer CosmicMuonTrajectoryBuilder::unusedHits ( const DetLayer layer,
const TrajectoryMeasurement meas 
) const [private]

Definition at line 407 of file CosmicMuonTrajectoryBuilder.cc.

References TrajectoryMeasurement::recHit(), MuonDetLayerMeasurements::recHits(), HLT_VtxMuL3::result, and theLayerMeasurements.

Referenced by trajectories().

00407                                                                                                                                                      {
00408   MuonTransientTrackingRecHit::MuonRecHitContainer tmpHits = theLayerMeasurements->recHits(layer);
00409   MuonRecHitContainer result;
00410   for (MuonRecHitContainer::const_iterator ihit = tmpHits.begin();
00411        ihit != tmpHits.end(); ++ihit ) {
00412        if ((*ihit)->geographicalId() != meas.recHit()->geographicalId() ) 
00413          result.push_back(*ihit);
00414   }
00415   return result;
00416 
00417 }

MuonTrajectoryUpdator* CosmicMuonTrajectoryBuilder::updator (  )  const [inline]

Definition at line 65 of file CosmicMuonTrajectoryBuilder.h.

References theUpdator.

Referenced by build(), and trajectories().

00065 {return theUpdator;}

CosmicMuonUtilities* CosmicMuonTrajectoryBuilder::utilities (  )  const [inline]

Definition at line 71 of file CosmicMuonTrajectoryBuilder.h.

References smoother(), and CosmicMuonSmoother::utilities().

Referenced by estimateDirection(), and flipTrajectory().

00071 {return smoother()->utilities();}


Member Data Documentation

std::string CosmicMuonTrajectoryBuilder::category_ [private]

Definition at line 132 of file CosmicMuonTrajectoryBuilder.h.

Referenced by build(), buildSecondHalf(), checkDirectionByT0(), CosmicMuonTrajectoryBuilder(), estimateDirection(), flipTrajectory(), getDirectionByTime(), intermediateState(), setEvent(), t0(), trajectories(), and ~CosmicMuonTrajectoryBuilder().

edm::Handle<CSCRecHit2DCollection> CosmicMuonTrajectoryBuilder::cschits_ [private]

Definition at line 137 of file CosmicMuonTrajectoryBuilder.h.

Referenced by getDirectionByTime().

edm::Handle<DTRecHitCollection> CosmicMuonTrajectoryBuilder::dthits_ [private]

Definition at line 138 of file CosmicMuonTrajectoryBuilder.h.

Referenced by getDirectionByTime().

MuonBestMeasurementFinder* CosmicMuonTrajectoryBuilder::theBestMeasurementFinder [private]

Definition at line 126 of file CosmicMuonTrajectoryBuilder.h.

Referenced by bestMeasurementFinder(), CosmicMuonTrajectoryBuilder(), findBestMeasurements(), and ~CosmicMuonTrajectoryBuilder().

MuonTrajectoryUpdator* CosmicMuonTrajectoryBuilder::theBKUpdator [private]

Definition at line 120 of file CosmicMuonTrajectoryBuilder.h.

Referenced by backwardUpdator(), build(), CosmicMuonTrajectoryBuilder(), trajectories(), and ~CosmicMuonTrajectoryBuilder().

unsigned long long CosmicMuonTrajectoryBuilder::theCacheId_DG [private]

Definition at line 136 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), and setEvent().

MuonDetLayerMeasurements* CosmicMuonTrajectoryBuilder::theLayerMeasurements [private]

Definition at line 121 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), findBestMeasurements(), setEvent(), unusedHits(), and ~CosmicMuonTrajectoryBuilder().

DirectMuonNavigation* CosmicMuonTrajectoryBuilder::theNavigation [private]

Definition at line 116 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), navigation(), setEvent(), and ~CosmicMuonTrajectoryBuilder().

edm::ParameterSet CosmicMuonTrajectoryBuilder::theNavigationPSet [private]

Definition at line 117 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), and setEvent().

int CosmicMuonTrajectoryBuilder::theNSuccess [private]

Definition at line 134 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), and ~CosmicMuonTrajectoryBuilder().

int CosmicMuonTrajectoryBuilder::theNTraversing [private]

Definition at line 133 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), and ~CosmicMuonTrajectoryBuilder().

std::string CosmicMuonTrajectoryBuilder::thePropagatorName [private]

Definition at line 128 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), and propagator().

const MuonServiceProxy* CosmicMuonTrajectoryBuilder::theService [private]

Definition at line 123 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), estimateDirection(), flipTrajectory(), propagator(), propagatorAlong(), propagatorOpposite(), setEvent(), and trajectories().

CosmicMuonSmoother* CosmicMuonTrajectoryBuilder::theSmoother [private]

Definition at line 124 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), estimateDirection(), flipTrajectory(), smoother(), trajectories(), and ~CosmicMuonTrajectoryBuilder().

bool CosmicMuonTrajectoryBuilder::theTraversingMuonFlag [private]

Definition at line 130 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), and trajectories().

MuonTrajectoryUpdator* CosmicMuonTrajectoryBuilder::theUpdator [private]

Definition at line 119 of file CosmicMuonTrajectoryBuilder.h.

Referenced by CosmicMuonTrajectoryBuilder(), updator(), and ~CosmicMuonTrajectoryBuilder().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:16:57 2009 for CMSSW by  doxygen 1.5.4