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