CMS 3D CMS Logo

ReferenceTrajectoryFactory.cc
Go to the documentation of this file.
11 
13 
15 
19 
21 public:
23  ~ReferenceTrajectoryFactory() override;
24 
28  const reco::BeamSpot &beamSpot) const override;
29 
33  const reco::BeamSpot &beamSpot) const override;
34 
35  ReferenceTrajectoryFactory *clone() const override { return new ReferenceTrajectoryFactory(*this); }
36 
37 protected:
39  const TrajectoryFactoryBase *bzeroFactory() const;
40 
41  double theMass;
44 };
45 
49 
52  theMass(config.getParameter<double>("ParticleMass")),
53  theUseBzeroIfFieldOff(config.getParameter<bool>("UseBzeroIfFieldOff")),
54  theBzeroFactory(nullptr) {
55  edm::LogInfo("Alignment") << "@SUB=ReferenceTrajectoryFactory"
56  << "mass: " << theMass
57  << "\nusing Bzero if |B| = 0: " << (theUseBzeroIfFieldOff ? "yes" : "no");
58 }
59 
62  theMass(other.theMass),
63  theUseBzeroIfFieldOff(other.theUseBzeroIfFieldOff),
64  theBzeroFactory(nullptr) // copy data members, but no double pointing to same Bzero factory...
65 {}
66 
68 
73  if (theUseBzeroIfFieldOff && magneticField->inTesla(GlobalPoint(0., 0., 0.)).mag2() < 1.e-6) {
74  return this->bzeroFactory()->trajectories(setup, tracks, beamSpot);
75  }
76 
78 
79  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
80 
81  while (itTracks != tracks.end()) {
83 
84  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
85  if (input.first.isValid()) {
87  config.useBeamSpot = useBeamSpot_;
88  config.includeAPEs = includeAPEs_;
89  config.allowZeroMaterial = allowZeroMaterial_;
90  // set the flag for reversing the RecHits to false, since they are already in the correct order.
91  config.hitsAreReverse = false;
93  new ReferenceTrajectory(input.first, input.second, magneticField.product(), beamSpot, config)));
94  }
95 
96  ++itTracks;
97  }
98 
99  return trajectories;
100 }
101 
103  const edm::EventSetup &setup,
106  const reco::BeamSpot &beamSpot) const {
108 
109  if (tracks.size() != external.size()) {
110  edm::LogInfo("ReferenceTrajectories")
111  << "@SUB=ReferenceTrajectoryFactory::trajectories"
112  << "Inconsistent input:\n"
113  << "\tnumber of tracks = " << tracks.size() << "\tnumber of external predictions = " << external.size();
114  return trajectories;
115  }
116 
119  if (theUseBzeroIfFieldOff && magneticField->inTesla(GlobalPoint(0., 0., 0.)).mag2() < 1.e-6) {
120  return this->bzeroFactory()->trajectories(setup, tracks, external, beamSpot);
121  }
122 
123  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
124  ExternalPredictionCollection::const_iterator itExternal = external.begin();
125 
126  while (itTracks != tracks.end()) {
128  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
129  if (input.first.isValid()) {
130  if ((*itExternal).isValid() && sameSurface((*itExternal).surface(), input.first.surface())) {
132  config.useBeamSpot = useBeamSpot_;
133  config.includeAPEs = includeAPEs_;
134  config.allowZeroMaterial = allowZeroMaterial_;
135  // set the flag for reversing the RecHits to false, since they are already in the correct order.
136  config.hitsAreReverse = false;
137  ReferenceTrajectoryPtr refTraj(
138  new ReferenceTrajectory(*itExternal, input.second, magneticField.product(), beamSpot, config));
139 
140  AlgebraicSymMatrix externalParamErrors(asHepMatrix<5>((*itExternal).localError().matrix()));
141  refTraj->setParameterErrors(externalParamErrors);
142  trajectories.push_back(refTraj);
143  } else {
145  config.useBeamSpot = useBeamSpot_;
146  config.includeAPEs = includeAPEs_;
147  config.allowZeroMaterial = allowZeroMaterial_;
148  config.hitsAreReverse = false;
150  new ReferenceTrajectory(input.first, input.second, magneticField.product(), beamSpot, config)));
151  }
152  }
153 
154  ++itTracks;
155  ++itExternal;
156  }
157 
158  return trajectories;
159 }
160 
162  if (!theBzeroFactory) {
163  const edm::ParameterSet &myPset = this->configuration();
164  edm::LogInfo("Alignment") << "@SUB=ReferenceTrajectoryFactory::bzeroFactory"
165  << "Using BzeroReferenceTrajectoryFactory for some (all?) events.";
166  // We take the config of this factory, copy it, replace its name and add
167  // the momentum parameter as expected by BzeroReferenceTrajectoryFactory and create it:
169  pset.copyForModify(myPset);
170  // next two lines not needed, but may help to better understand log file:
171  pset.eraseSimpleParameter("TrajectoryFactoryName");
172  pset.addParameter("TrajectoryFactoryName", std::string("BzeroReferenceTrajectoryFactory"));
173  pset.addParameter("MomentumEstimate", myPset.getParameter<double>("MomentumEstimateFieldOff"));
175  }
176  return theBzeroFactory;
177 }
178 
ReferenceTrajectoryFactory::clone
ReferenceTrajectoryFactory * clone() const override
Definition: ReferenceTrajectoryFactory.cc:35
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
electrons_cff.bool
bool
Definition: electrons_cff.py:372
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
ESHandle.h
HLT_2018_cff.magneticField
magneticField
Definition: HLT_2018_cff.py:348
ReferenceTrajectory.h
TrajectoryFactories_cff.BzeroReferenceTrajectoryFactory
BzeroReferenceTrajectoryFactory
BzeroReferenceTrajectoryFactory.
Definition: TrajectoryFactories_cff.py:50
edm::LogInfo
Definition: MessageLogger.h:254
ReferenceTrajectoryFactory::theUseBzeroIfFieldOff
bool theUseBzeroIfFieldOff
Definition: ReferenceTrajectoryFactory.cc:42
TrajectoryFactoryBase::includeAPEs_
const bool includeAPEs_
Definition: TrajectoryFactoryBase.h:71
ReferenceTrajectoryBase::Config
Definition: ReferenceTrajectoryBase.h:121
ReferenceCountingPointer
Definition: ReferenceCounted.h:60
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
config
Definition: config.py:1
external
Definition: HEPTopTaggerV2.h:20
TrajectoryFactoryBase::configuration
const edm::ParameterSet & configuration() const
Definition: TrajectoryFactoryBase.h:47
TrajectoryFactoryBase::sameSurface
bool sameSurface(const Surface &s1, const Surface &s2) const
Definition: TrajectoryFactoryBase.cc:88
TrajectoryFactoryBase::ReferenceTrajectoryPtr
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr
Definition: TrajectoryFactoryBase.h:22
TrajectoryFactoryBase::useBeamSpot_
const bool useBeamSpot_
Definition: TrajectoryFactoryBase.h:70
reco::BeamSpot
Definition: BeamSpot.h:21
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
ReferenceTrajectoryFactory::ReferenceTrajectoryFactory
ReferenceTrajectoryFactory(const edm::ParameterSet &config)
Definition: ReferenceTrajectoryFactory.cc:50
trackingPlots.other
other
Definition: trackingPlots.py:1465
TrajectoryFactoryBase::propagationDirection
PropagationDirection propagationDirection(void) const
Definition: TrajectoryFactoryBase.h:46
looper.config
config
Definition: looper.py:291
Point3DBase< float, GlobalTag >
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ReferenceTrajectoryFactory::bzeroFactory
const TrajectoryFactoryBase * bzeroFactory() const
Definition: ReferenceTrajectoryFactory.cc:161
ReferenceTrajectoryFactory::trajectories
const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
Produce the reference trajectories.
Definition: ReferenceTrajectoryFactory.cc:69
TrajectoryFactoryBase::ReferenceTrajectoryCollection
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
Definition: TrajectoryFactoryBase.h:26
edm::ParameterSet
Definition: ParameterSet.h:36
TrajectoryFactoryBase::innermostStateAndRecHits
virtual const TrajectoryInput innermostStateAndRecHits(const ConstTrajTrackPair &track) const
Definition: TrajectoryFactoryBase.cc:37
TrajectoryFactoryBase::TrajectoryInput
std::pair< TrajectoryStateOnSurface, TransientTrackingRecHit::ConstRecHitContainer > TrajectoryInput
Definition: TrajectoryFactoryBase.h:27
TrajectoryFactoryBase
Definition: TrajectoryFactoryBase.h:20
TrajectoryFactoryPlugin.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
TrajectoryFactoryBase::materialEffects
MaterialEffects materialEffects(void) const
Definition: TrajectoryFactoryBase.h:45
get
#define get
TrajectoryFactoryBase::allowZeroMaterial_
const bool allowZeroMaterial_
Definition: TrajectoryFactoryBase.h:72
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TrajectoryFactoryBase::trajectories
virtual const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const =0
ReferenceTrajectoryFactory::theMass
double theMass
Definition: ReferenceTrajectoryFactory.cc:41
TrajectoryFactoryBase::ConstTrajTrackPairCollection
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
Definition: TrajectoryFactoryBase.h:25
ReferenceTrajectory
Definition: ReferenceTrajectory.h:55
GlobalVector.h
EventSetup.h
ReferenceTrajectoryFactory::theBzeroFactory
const TrajectoryFactoryBase * theBzeroFactory
Definition: ReferenceTrajectoryFactory.cc:43
ParameterSet.h
GlobalPoint.h
ReferenceTrajectoryFactory::~ReferenceTrajectoryFactory
~ReferenceTrajectoryFactory() override
Definition: ReferenceTrajectoryFactory.cc:67
BzeroReferenceTrajectoryFactory.h
TrajectoryFactoryBase.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
ReferenceTrajectoryFactory
Definition: ReferenceTrajectoryFactory.cc:20
TrajectoryFactoryBase::ExternalPredictionCollection
std::vector< TrajectoryStateOnSurface > ExternalPredictionCollection
Definition: TrajectoryFactoryBase.h:28