CMS 3D CMS Logo

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