CMS 3D CMS Logo

ReferenceTrajectoryFactory.cc
Go to the documentation of this file.
11 
13 
15 
19 
21 public:
23  ~ReferenceTrajectoryFactory() override;
25 
29  const reco::BeamSpot &beamSpot) const override;
30 
34  const reco::BeamSpot &beamSpot) const override;
35 
36  ReferenceTrajectoryFactory *clone() const override { return new ReferenceTrajectoryFactory(*this); }
37 
38 protected:
40  const TrajectoryFactoryBase *bzeroFactory() const;
42 
43  double theMass;
45  //edm::ParameterSet pset;
47 };
48 
52 
55  m_MagFieldToken(iC.esConsumes()),
56  theMass(config.getParameter<double>("ParticleMass")),
57  theUseBzeroIfFieldOff(config.getParameter<bool>("UseBzeroIfFieldOff")),
58  theBzeroFactory(nullptr) {
59  edm::LogInfo("Alignment") << "@SUB=ReferenceTrajectoryFactory"
60  << "mass: " << theMass
61  << "\nusing Bzero if |B| = 0: " << (theUseBzeroIfFieldOff ? "yes" : "no");
62  // We take the config of this factory, copy it, replace its name and add
63  // the momentum parameter as expected by BzeroReferenceTrajectoryFactory and create it:
64  //
66  pset.copyForModify(config);
67  // next two lines not needed, but may help to better understand log file:
68  pset.eraseSimpleParameter("TrajectoryFactoryName");
69  pset.addParameter("TrajectoryFactoryName", std::string("BzeroReferenceTrajectoryFactory"));
70  pset.addParameter("MomentumEstimate", config.getParameter<double>("MomentumEstimateFieldOff"));
72 }
73 
76  theMass(other.theMass),
77  theUseBzeroIfFieldOff(other.theUseBzeroIfFieldOff),
78  theBzeroFactory(nullptr) // copy data members, but no double pointing to same Bzero factory...
79 {}
80 
82 
86 
87  if (theUseBzeroIfFieldOff && magneticField->inTesla(GlobalPoint(0., 0., 0.)).mag2() < 1.e-6) {
88  return this->bzeroFactory()->trajectories(setup, tracks, beamSpot);
89  }
90 
92 
93  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
94 
95  while (itTracks != tracks.end()) {
97 
98  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
99  if (input.first.isValid()) {
101  config.useBeamSpot = useBeamSpot_;
102  config.includeAPEs = includeAPEs_;
103  config.allowZeroMaterial = allowZeroMaterial_;
104  // set the flag for reversing the RecHits to false, since they are already in the correct order.
105  config.hitsAreReverse = false;
106  trajectories.push_back(
108  }
109 
110  ++itTracks;
111  }
112 
113  return trajectories;
114 }
115 
117  const edm::EventSetup &setup,
120  const reco::BeamSpot &beamSpot) const {
122 
123  if (tracks.size() != external.size()) {
124  edm::LogInfo("ReferenceTrajectories")
125  << "@SUB=ReferenceTrajectoryFactory::trajectories"
126  << "Inconsistent input:\n"
127  << "\tnumber of tracks = " << tracks.size() << "\tnumber of external predictions = " << external.size();
128  return trajectories;
129  }
131 
132  if (theUseBzeroIfFieldOff && magneticField->inTesla(GlobalPoint(0., 0., 0.)).mag2() < 1.e-6) {
133  return this->bzeroFactory()->trajectories(setup, tracks, external, beamSpot);
134  }
135 
136  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
137  ExternalPredictionCollection::const_iterator itExternal = external.begin();
138 
139  while (itTracks != tracks.end()) {
141  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
142  if (input.first.isValid()) {
143  if ((*itExternal).isValid() && sameSurface((*itExternal).surface(), input.first.surface())) {
145  config.useBeamSpot = useBeamSpot_;
146  config.includeAPEs = includeAPEs_;
147  config.allowZeroMaterial = allowZeroMaterial_;
148  // set the flag for reversing the RecHits to false, since they are already in the correct order.
149  config.hitsAreReverse = false;
150  ReferenceTrajectoryPtr refTraj(
151  new ReferenceTrajectory(*itExternal, input.second, magneticField, beamSpot, config));
152 
153  AlgebraicSymMatrix externalParamErrors(asHepMatrix<5>((*itExternal).localError().matrix()));
154  refTraj->setParameterErrors(externalParamErrors);
155  trajectories.push_back(refTraj);
156  } else {
158  config.useBeamSpot = useBeamSpot_;
159  config.includeAPEs = includeAPEs_;
160  config.allowZeroMaterial = allowZeroMaterial_;
161  config.hitsAreReverse = false;
164  }
165  }
166 
167  ++itTracks;
168  ++itExternal;
169  }
170 
171  return trajectories;
172 }
173 
175  if (!theBzeroFactory) {
176  edm::LogInfo("Alignment") << "@SUB=ReferenceTrajectoryFactory::bzeroFactory"
177  << "Using BzeroReferenceTrajectoryFactory for some (all?) events.";
178  }
179  return theBzeroFactory;
180 }
181 
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
ReferenceTrajectoryFactory * clone() const override
Definition: config.py:1
bool sameSurface(const Surface &s1, const Surface &s2) const
MaterialEffects materialEffects(void) const
static std::string const input
Definition: EdmProvDump.cc:47
BzeroReferenceTrajectoryFactory
BzeroReferenceTrajectoryFactory.
const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
Produce the reference trajectories.
std::pair< TrajectoryStateOnSurface, TransientTrackingRecHit::ConstRecHitContainer > TrajectoryInput
Log< level::Info, false > LogInfo
const TrajectoryFactoryBase * bzeroFactory() const
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
auto const & tracks
cannot be loose
virtual const TrajectoryInput innermostStateAndRecHits(const ConstTrajTrackPair &track) const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_MagFieldToken
const TrajectoryFactoryBase * theBzeroFactory
config
parse the configuration file
virtual const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const =0
CLHEP::HepSymMatrix AlgebraicSymMatrix
ReferenceTrajectoryFactory(const edm::ParameterSet &config, edm::ConsumesCollector &iC)
std::vector< TrajectoryStateOnSurface > ExternalPredictionCollection
PropagationDirection propagationDirection(void) const
#define DEFINE_EDM_PLUGIN(factory, type, name)
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection