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  theConfig(config)
12 {
13  const std::string strMaterialEffects = config.getParameter< std::string >( "MaterialEffects" );
14  theMaterialEffects = this->materialEffects( strMaterialEffects );
15 
16  const std::string strPropagationDirection = config.getParameter< std::string >( "PropagationDirection" );
17  thePropDir = this->propagationDirection( strPropagationDirection );
18 
19  theUseWithoutDet = config.getParameter< bool >( "UseHitWithoutDet" );
20  theUseInvalidHits = config.getParameter< bool >( "UseInvalidHits" );
21  theUseProjectedHits = config.getParameter< bool >( "UseProjectedHits" );
22  theUseBeamSpot = config.getParameter< bool >( "UseBeamSpot" );
23 
24  edm::LogInfo("Alignment") << "@SUB=TrajectoryFactoryBase"
25  << "TrajectoryFactory '" << config.getParameter<std::string>("TrajectoryFactoryName")
26  << "' with following settings:"
27  << "\nmaterial effects: " << strMaterialEffects
28  << "\npropagation: " << strPropagationDirection
29  << "\nuse hits without det: " << (theUseWithoutDet ? "yes" : "no")
30  << "\nuse invalid hits: " << (theUseInvalidHits ? "yes" : "no")
31  << "\nuse projected hits: " << (theUseProjectedHits ? "yes" : "no")
32  << "\nuse beamspot: " << (theUseBeamSpot ? "yes" : "no");
33 }
34 
35 
37 
38 
41 {
43 
44  // get the trajectory measurements in the correct order, i.e. reverse if needed
45  Trajectory::DataContainer trajectoryMeasurements
46  = this->orderedTrajectoryMeasurements( *track.first );
47  Trajectory::DataContainer::iterator itM = trajectoryMeasurements.begin();
48 
49  // get the innermost valid trajectory state - the corresponding hit must be o.k. as well
50  while ( itM != trajectoryMeasurements.end() )
51  {
52  if ( ( *itM ).updatedState().isValid() && useRecHit( ( *itM ).recHit() ) ) break;
53  ++itM;
54  }
55  if ( itM != trajectoryMeasurements.end() ) result.first = ( *itM ).updatedState();
56 
57  // get the valid RecHits
58  while ( itM != trajectoryMeasurements.end() )
59  {
60  TransientTrackingRecHit::ConstRecHitPointer aRecHit = ( *itM ).recHit();
61  if ( useRecHit( aRecHit ) ) result.second.push_back( aRecHit );
62  ++itM;
63  }
64 
65  return result;
66 }
67 
68 
71 {
72  const PropagationDirection dir = trajectory.direction();
73  const bool hitsAreReverse = ( ( dir == thePropDir || thePropDir == anyDirection ) ? false : true );
74 
75  const Trajectory::DataContainer & original = trajectory.measurements();
76 
77  if ( hitsAreReverse )
78  {
79  // Simply use this line instead of the copying by hand?
80  // const Trajectory::DataContainer reordered(original.rbegin(), original.rend());
81  Trajectory::DataContainer reordered;
82  reordered.reserve( original.size() );
83 
84  Trajectory::DataContainer::const_reverse_iterator itM;
85  for ( itM = original.rbegin(); itM != original.rend(); ++itM )
86  {
87  reordered.push_back( *itM );
88  }
89  return reordered;
90  }
91 
92  return original;
93 }
94 
95 
96 bool TrajectoryFactoryBase::sameSurface( const Surface& s1, const Surface& s2 ) const
97 {
98  // - Should use perp2() instead of perp()
99  // - Should not rely on floating point equality, but make a minimal range, e.g. 1.e-6 ?
100  return ( s1.eta() == s2.eta() ) && ( s1.phi() == s2.phi() ) && ( s1.position().perp() == s2.position().perp() );
101 }
102 
103 
104 bool
106 {
107  const GeomDet* det = hitPtr->det();
108  if ( !det && !theUseWithoutDet ) return false;
109 
110  if ( !( theUseInvalidHits || hitPtr->isValid() ) ) return false;
111 
112  if ( !theUseProjectedHits )
113  {
114  if(trackerHitRTTI::isProjected(*hitPtr)) return false;
115  }
116 
117  return true;
118 }
119 
120 
123 {
124  if ( strME == "MultipleScattering" ) return ReferenceTrajectoryBase::multipleScattering;
125  if ( strME == "EnergyLoss" ) return ReferenceTrajectoryBase::energyLoss;
126  if ( strME == "Combined" ) return ReferenceTrajectoryBase::combined;
127  if ( strME == "None" ) return ReferenceTrajectoryBase::none;
128  if ( strME == "BreakPoints" ) return ReferenceTrajectoryBase::breakPoints;
129  if ( strME == "BrokenLines" ) return ReferenceTrajectoryBase::brokenLinesCoarse;
130  if ( strME == "BrokenLinesCoarse" ) return ReferenceTrajectoryBase::brokenLinesCoarse;
131  if ( strME == "BrokenLinesFine" ) return ReferenceTrajectoryBase::brokenLinesFine;
132  if ( strME == "LocalGBL" ) return ReferenceTrajectoryBase::localGBL;
133  if ( strME == "CurvlinGBL" ) return ReferenceTrajectoryBase::curvlinGBL;
134 
135  throw cms::Exception("BadConfig")
136  << "[TrajectoryFactoryBase::materialEffects] Unknown parameter: " << strME;
137 }
138 
139 
142 {
143  if ( strPD == "oppositeToMomentum" ) return oppositeToMomentum;
144  if ( strPD == "alongMomentum" ) return alongMomentum;
145  if ( strPD == "anyDirection" ) return anyDirection;
146 
147  throw cms::Exception("BadConfig")
148  << "[TrajectoryFactoryBase::propagationDirection] Unknown parameter: " << strPD;
149 }
T getParameter(std::string const &) const
MaterialEffects theMaterialEffects
T perp() const
Definition: PV3DBase.h:72
PropagationDirection thePropDir
MaterialEffects materialEffects(void) const
list original
Definition: definitions.py:57
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:118
DataContainer const & measurements() const
Definition: Trajectory.h:203
TrajectoryFactoryBase(const edm::ParameterSet &config)
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:42
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
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
bool isProjected(TrackingRecHit const &hit)