CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrajectoryFactoryBase.cc
Go to the documentation of this file.
4 
6 
8 
9 
11 {
12  const std::string strMaterialEffects = config.getParameter< std::string >( "MaterialEffects" );
13  theMaterialEffects = this->materialEffects( strMaterialEffects );
14 
15  const std::string strPropagationDirection = config.getParameter< std::string >( "PropagationDirection" );
16  thePropDir = this->propagationDirection( strPropagationDirection );
17 
18  theUseWithoutDet = config.getParameter< bool >( "UseHitWithoutDet" );
19  theUseInvalidHits = config.getParameter< bool >( "UseInvalidHits" );
20  theUseProjectedHits = config.getParameter< bool >( "UseProjectedHits" );
21  theUseBeamSpot = config.getParameter< bool >( "UseBeamSpot" );
22 }
23 
24 
26 
27 
30 {
32 
33  // get the trajectory measurements in the correct order, i.e. reverse if needed
34  Trajectory::DataContainer trajectoryMeasurements
35  = this->orderedTrajectoryMeasurements( *track.first );
36  Trajectory::DataContainer::iterator itM = trajectoryMeasurements.begin();
37 
38  // get the innermost valid trajectory state - the corresponding hit must be o.k. as well
39  while ( itM != trajectoryMeasurements.end() )
40  {
41  if ( ( *itM ).updatedState().isValid() && useRecHit( ( *itM ).recHit() ) ) break;
42  ++itM;
43  }
44  if ( itM != trajectoryMeasurements.end() ) result.first = ( *itM ).updatedState();
45 
46  // get the valid RecHits
47  while ( itM != trajectoryMeasurements.end() )
48  {
49  TransientTrackingRecHit::ConstRecHitPointer aRecHit = ( *itM ).recHit();
50  if ( useRecHit( aRecHit ) ) result.second.push_back( aRecHit );
51  ++itM;
52  }
53 
54  return result;
55 }
56 
57 
60 {
61  const PropagationDirection dir = trajectory.direction();
62  const bool hitsAreReverse = ( ( dir == thePropDir || thePropDir == anyDirection ) ? false : true );
63 
64  const Trajectory::DataContainer & original = trajectory.measurements();
65 
66  if ( hitsAreReverse )
67  {
68  // Simply use this line instead of the copying by hand?
69  // const Trajectory::DataContainer reordered(original.rbegin(), original.rend());
70  Trajectory::DataContainer reordered;
71  reordered.reserve( original.size() );
72 
73  Trajectory::DataContainer::const_reverse_iterator itM;
74  for ( itM = original.rbegin(); itM != original.rend(); ++itM )
75  {
76  reordered.push_back( *itM );
77  }
78  return reordered;
79  }
80 
81  return original;
82 }
83 
84 
85 bool TrajectoryFactoryBase::sameSurface( const Surface& s1, const Surface& s2 ) const
86 {
87  // - Should use perp2() instead of perp()
88  // - Should not rely on floating point equality, but make a minimal range, e.g. 1.e-6 ?
89  return ( s1.eta() == s2.eta() ) && ( s1.phi() == s2.phi() ) && ( s1.position().perp() == s2.position().perp() );
90 }
91 
92 
93 bool
95 {
96  const GeomDet* det = hitPtr->det();
97  if ( !det && !theUseWithoutDet ) return false;
98 
99  if ( !( theUseInvalidHits || hitPtr->isValid() ) ) return false;
100 
101  if ( !theUseProjectedHits )
102  {
103  const ProjectedRecHit2D* projectedHit = dynamic_cast< const ProjectedRecHit2D* >( hitPtr.get() );
104  if ( projectedHit != 0 ) return false;
105  }
106 
107  return true;
108 }
109 
110 
112 TrajectoryFactoryBase::materialEffects( const std::string & strME ) const
113 {
114  if ( strME == "MultipleScattering" ) return ReferenceTrajectoryBase::multipleScattering;
115  if ( strME == "EnergyLoss" ) return ReferenceTrajectoryBase::energyLoss;
116  if ( strME == "Combined" ) return ReferenceTrajectoryBase::combined;
117  if ( strME == "None" ) return ReferenceTrajectoryBase::none;
118  if ( strME == "BreakPoints" ) return ReferenceTrajectoryBase::breakPoints;
119  if ( strME == "BrokenLines" ) return ReferenceTrajectoryBase::brokenLinesCoarse;
120  if ( strME == "BrokenLinesCoarse" ) return ReferenceTrajectoryBase::brokenLinesCoarse;
121  if ( strME == "BrokenLinesFine" ) return ReferenceTrajectoryBase::brokenLinesFine;
122 
123  throw cms::Exception("BadConfig")
124  << "[TrajectoryFactoryBase::materialEffects] Unknown parameter: " << strME;
125 }
126 
127 
129 TrajectoryFactoryBase::propagationDirection( const std::string & strPD ) const
130 {
131  if ( strPD == "oppositeToMomentum" ) return oppositeToMomentum;
132  if ( strPD == "alongMomentum" ) return alongMomentum;
133  if ( strPD == "anyDirection" ) return anyDirection;
134 
135  throw cms::Exception("BadConfig")
136  << "[TrajectoryFactoryBase::propagationDirection] Unknown parameter: " << strPD;
137 }
T getParameter(std::string const &) const
MaterialEffects theMaterialEffects
T perp() const
Definition: PV3DBase.h:71
PropagationDirection thePropDir
MaterialEffects materialEffects(void) const
list original
Definition: definitions.py:60
virtual const Trajectory::DataContainer orderedTrajectoryMeasurements(const Trajectory &trajectory) const
AlignmentAlgorithmBase::ConstTrajTrackPair ConstTrajTrackPair
PropagationDirection
bool useRecHit(const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
tuple s2
Definition: indexGen.py:106
PropagationDirection const & direction() const
Definition: Trajectory.cc:195
DataContainer const & measurements() const
Definition: Trajectory.h:203
TrajectoryFactoryBase(const edm::ParameterSet &config)
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:42
bool sameSurface(const Surface &s1, const Surface &s2) const
tuple result
Definition: query.py:137
virtual const TrajectoryInput innermostStateAndRecHits(const ConstTrajTrackPair &track) const
PropagationDirection propagationDirection(void) const
std::pair< TrajectoryStateOnSurface, TransientTrackingRecHit::ConstRecHitContainer > TrajectoryInput
dbl *** dir
Definition: mlp_gen.cc:35
virtual ~TrajectoryFactoryBase(void)
const PositionType & position() const