CMS 3D CMS Logo

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