CMS 3D CMS Logo

TwoBodyDecayTrajectoryFactory.cc
Go to the documentation of this file.
8 
12 
14 
17 
20 
22 
29 public:
33 
36 
40  const reco::BeamSpot &beamSpot) const override;
41 
45  const reco::BeamSpot &beamSpot) const override;
46 
47  TwoBodyDecayTrajectoryFactory *clone() const override { return new TwoBodyDecayTrajectoryFactory(*this); }
48 
49 protected:
51  const TwoBodyDecay &tbd,
52  const MagneticField *magField,
53  const reco::BeamSpot &beamSpot,
54  bool setParameterErrors) const;
55 
57 
59 
63 
68 };
69 
73 
75  : TrajectoryFactoryBase(config, 2), theFitter(config) {
76  const edm::ParameterSet ppc = config.getParameter<edm::ParameterSet>("ParticleProperties");
77  thePrimaryMass = ppc.getParameter<double>("PrimaryMass");
78  thePrimaryWidth = ppc.getParameter<double>("PrimaryWidth");
79  theSecondaryMass = ppc.getParameter<double>("SecondaryMass");
80 
81  theNSigmaCutValue = config.getParameter<double>("NSigmaCut");
82  theChi2CutValue = config.getParameter<double>("Chi2Cut");
83  theUseRefittedStateFlag = config.getParameter<bool>("UseRefittedState");
84  theConstructTsosWithErrorsFlag = config.getParameter<bool>("ConstructTsosWithErrors");
85 }
86 
88 
92 
95 
97  setup.get<GlobalTrackingGeometryRecord>().get(trackingGeometry);
98 
99  if (tracks.size() == 2) {
100  // produce transient tracks from persistent tracks
101  std::vector<reco::TransientTrack> transientTracks(2);
102 
103  transientTracks[0] = reco::TransientTrack(*tracks[0].second, magneticField.product());
104  transientTracks[0].setTrackingGeometry(trackingGeometry);
105 
106  transientTracks[1] = reco::TransientTrack(*tracks[1].second, magneticField.product());
107  transientTracks[1].setTrackingGeometry(trackingGeometry);
108 
109  // estimate the decay parameters
111  TwoBodyDecay tbd = theFitter.estimate(transientTracks, vm);
112 
113  if (!tbd.isValid() || (tbd.chi2() > theChi2CutValue)) {
115  return trajectories;
116  }
117 
118  return constructTrajectories(tracks, tbd, magneticField.product(), beamSpot, false);
119  } else {
120  edm::LogInfo("ReferenceTrajectories") << "@SUB=TwoBodyDecayTrajectoryFactory::trajectories"
121  << "Need 2 tracks, got " << tracks.size() << ".\n";
122  }
123 
124  return trajectories;
125 }
126 
128  const edm::EventSetup &setup,
131  const reco::BeamSpot &beamSpot) const {
133 
136 
137  edm::ESHandle<GlobalTrackingGeometry> trackingGeometry;
138  setup.get<GlobalTrackingGeometryRecord>().get(trackingGeometry);
139 
140  if (tracks.size() == 2 && external.size() == 2) {
141  if (external[0].isValid() && external[1].isValid()) // Include external estimates
142  {
143  // produce transient tracks from persistent tracks
144  std::vector<reco::TransientTrack> transientTracks(2);
145 
146  transientTracks[0] = reco::TransientTrack(*tracks[0].second, magneticField.product());
147  transientTracks[0].setTrackingGeometry(trackingGeometry);
148 
149  transientTracks[1] = reco::TransientTrack(*tracks[1].second, magneticField.product());
150  transientTracks[1].setTrackingGeometry(trackingGeometry);
151 
152  // estimate the decay parameters. the transient tracks are not really associated to the
153  // the external tsos, but this is o.k., because the only information retrieved from them
154  // is the magnetic field.
156  TwoBodyDecay tbd = theFitter.estimate(transientTracks, external, vm);
157 
158  if (!tbd.isValid() || (tbd.chi2() > theChi2CutValue)) {
160  return trajectories;
161  }
162 
163  return constructTrajectories(tracks, tbd, magneticField.product(), beamSpot, true);
164  } else {
165  // Return without external estimate
166  trajectories = this->trajectories(setup, tracks, beamSpot);
167  }
168  } else {
169  edm::LogInfo("ReferenceTrajectories") << "@SUB=TwoBodyDecayTrajectoryFactory::trajectories"
170  << "Need 2 tracks, got " << tracks.size() << ".\n";
171  }
172 
173  return trajectories;
174 }
175 
178  const TwoBodyDecay &tbd,
179  const MagneticField *magField,
180  const reco::BeamSpot &beamSpot,
181  bool setParameterErrors) const {
183 
184  // get innermost valid trajectory state and hits from the tracks
187 
188  if (!(input1.first.isValid() && input2.first.isValid()))
189  return trajectories;
190 
191  // produce TwoBodyDecayTrajectoryState (input for TwoBodyDecayTrajectory)
192  TsosContainer tsos(input1.first, input2.first);
193  ConstRecHitCollection recHits(input1.second, input2.second);
194  TwoBodyDecayTrajectoryState trajectoryState(tsos, tbd, theSecondaryMass, magField);
195 
196  if (!trajectoryState.isValid()) {
198  return trajectories;
199  }
200 
201  // always use the refitted trajectory state for matching
202  // FIXME FIXME CLONE
203  //TrackingRecHit::ConstRecHitPointer updatedRecHit1( recHits.first.front()->clone( tsos.first ) );
204  // TrackingRecHit::ConstRecHitPointer updatedRecHit2( recHits.second.front()->clone( tsos.second ) );
205 
206  TrackingRecHit::ConstRecHitPointer updatedRecHit1(recHits.first.front());
207  TrackingRecHit::ConstRecHitPointer updatedRecHit2(recHits.second.front());
208 
209  bool valid1 = match(trajectoryState.trajectoryStates(true).first, updatedRecHit1);
210 
211  bool valid2 = match(trajectoryState.trajectoryStates(true).second, updatedRecHit2);
212 
213  if (!valid1 || !valid2) {
215  return trajectories;
216  }
217 
219  config.useBeamSpot = useBeamSpot_;
220  config.includeAPEs = includeAPEs_;
221  config.allowZeroMaterial = allowZeroMaterial_;
222  config.useRefittedState = theUseRefittedStateFlag;
223  config.constructTsosWithErrors = theConstructTsosWithErrorsFlag;
224  // set the flag for reversing the RecHits to false, since they are already in the correct order.
225  config.hitsAreReverse = false;
226  TwoBodyDecayTrajectory *result = new TwoBodyDecayTrajectory(trajectoryState, recHits, magField, beamSpot, config);
227  if (setParameterErrors && tbd.hasError())
228  result->setParameterErrors(tbd.covariance());
230  return trajectories;
231 }
232 
235  LocalPoint lp1 = state.localPosition();
236  LocalPoint lp2 = recHit->localPosition();
237 
238  double deltaX = lp1.x() - lp2.x();
239  double deltaY = lp1.y() - lp2.y();
240 
241  LocalError le = recHit->localPositionError();
242 
243  double varX = le.xx();
244  double varY = le.yy();
245 
246  return ((fabs(deltaX) / sqrt(varX) < theNSigmaCutValue) && (fabs(deltaY) / sqrt(varY) < theNSigmaCutValue));
247 }
248 
TwoBodyDecayTrajectoryState::TsosContainer
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > TsosContainer
Definition: TwoBodyDecayTrajectoryState.h:14
TwoBodyDecayTrajectoryFactory::thePrimaryMass
double thePrimaryMass
Definition: TwoBodyDecayTrajectoryFactory.cc:60
TwoBodyDecayTrajectoryFactory::theUseRefittedStateFlag
bool theUseRefittedStateFlag
Definition: TwoBodyDecayTrajectoryFactory.cc:66
FreeTrajectoryState.h
TwoBodyDecayFitter::estimate
virtual const TwoBodyDecay estimate(const std::vector< reco::TransientTrack > &tracks, const TwoBodyDecayVirtualMeasurement &vm) const
Definition: TwoBodyDecayFitter.cc:16
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
TwoBodyDecay::isValid
bool isValid(void) const
Definition: TwoBodyDecay.h:46
MessageLogger.h
TwoBodyDecay::hasError
bool hasError(void) const
Definition: TwoBodyDecay.h:42
Vector.h
ESHandle.h
AlgebraicObjects.h
TwoBodyDecayTrajectoryFactory::TsosContainer
TwoBodyDecayTrajectoryState::TsosContainer TsosContainer
Definition: TwoBodyDecayTrajectoryFactory.cc:31
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
TwoBodyDecayTrajectoryFactory::VirtualMeasurement
TwoBodyDecayVirtualMeasurement VirtualMeasurement
Definition: TwoBodyDecayTrajectoryFactory.cc:30
TwoBodyDecayTrajectoryState::isValid
bool isValid(void) const
Definition: TwoBodyDecayTrajectoryState.h:28
TrajectoryFactoryBase::includeAPEs_
const bool includeAPEs_
Definition: TrajectoryFactoryBase.h:71
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
GlobalTrackingGeometryRecord
Definition: GlobalTrackingGeometryRecord.h:17
ReferenceTrajectoryBase::Config
Definition: ReferenceTrajectoryBase.h:121
TwoBodyDecayFitter
Definition: TwoBodyDecayFitter.h:21
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
TransientTrack.h
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
TwoBodyDecayTrajectoryFactory::~TwoBodyDecayTrajectoryFactory
~TwoBodyDecayTrajectoryFactory() override
Definition: TwoBodyDecayTrajectoryFactory.cc:87
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
TwoBodyDecayTrajectoryFactory::ConstRecHitCollection
TwoBodyDecayTrajectory::ConstRecHitCollection ConstRecHitCollection
Definition: TwoBodyDecayTrajectoryFactory.cc:32
TwoBodyDecayTrajectory
Definition: TwoBodyDecayTrajectory.h:15
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
config
Definition: config.py:1
external
Definition: HEPTopTaggerV2.h:20
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TwoBodyDecayTrajectoryFactory::constructTrajectories
const ReferenceTrajectoryCollection constructTrajectories(const ConstTrajTrackPairCollection &tracks, const TwoBodyDecay &tbd, const MagneticField *magField, const reco::BeamSpot &beamSpot, bool setParameterErrors) const
Definition: TwoBodyDecayTrajectoryFactory.cc:176
TwoBodyDecayTrajectoryFactory::theFitter
TwoBodyDecayFitter theFitter
Definition: TwoBodyDecayTrajectoryFactory.cc:58
Surface.h
TwoBodyDecayTrajectoryFactory::theConstructTsosWithErrorsFlag
bool theConstructTsosWithErrorsFlag
Definition: TwoBodyDecayTrajectoryFactory.cc:67
LocalError::xx
float xx() const
Definition: LocalError.h:22
TwoBodyDecayTrajectory::ConstRecHitCollection
std::pair< ConstRecHitContainer, ConstRecHitContainer > ConstRecHitCollection
Definition: TwoBodyDecayTrajectory.h:18
submitPVResolutionJobs.config
config
parse the configuration file
Definition: submitPVResolutionJobs.py:281
TrajectoryFactoryBase::ReferenceTrajectoryPtr
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr
Definition: TrajectoryFactoryBase.h:22
TrajectoryFactoryBase::useBeamSpot_
const bool useBeamSpot_
Definition: TrajectoryFactoryBase.h:70
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::BeamSpot
Definition: BeamSpot.h:21
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
TrajectoryFactoryBase::propagationDirection
PropagationDirection propagationDirection(void) const
Definition: TrajectoryFactoryBase.h:46
Point3DBase< float, LocalTag >
sistrip::SpyUtilities::isValid
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
Definition: SiStripSpyUtilities.cc:124
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
GlobalTrackingGeometryRecord.h
TwoBodyDecayVirtualMeasurement
Definition: TwoBodyDecayVirtualMeasurement.h:19
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
Error.h
TrajectoryFactoryBase::ReferenceTrajectoryCollection
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
Definition: TrajectoryFactoryBase.h:26
edm::ParameterSet
Definition: ParameterSet.h:47
TrajectoryFactoryBase::innermostStateAndRecHits
virtual const TrajectoryInput innermostStateAndRecHits(const ConstTrajTrackPair &track) const
Definition: TrajectoryFactoryBase.cc:37
TwoBodyDecayTrajectoryFactory::trajectories
const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
Produce the trajectories.
Definition: TwoBodyDecayTrajectoryFactory.cc:89
TwoBodyDecayTrajectoryState::trajectoryStates
const TsosContainer & trajectoryStates(bool useRefittedState=true) const
Definition: TwoBodyDecayTrajectoryState.h:32
TwoBodyDecay::covariance
const AlgebraicSymMatrix & covariance(void) const
Definition: TwoBodyDecay.h:34
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
TrackerGeomDet.h
TrajectoryFactoryBase::TrajectoryInput
std::pair< TrajectoryStateOnSurface, TransientTrackingRecHit::ConstRecHitContainer > TrajectoryInput
Definition: TrajectoryFactoryBase.h:27
TwoBodyDecayTrajectoryFactory::theSecondaryMass
double theSecondaryMass
Definition: TwoBodyDecayTrajectoryFactory.cc:62
TrajectoryFactoryBase
Definition: TrajectoryFactoryBase.h:20
TrajectoryFactoryPlugin.h
LocalError
Definition: LocalError.h:12
edmplugin::PluginFactory
Definition: PluginFactory.h:34
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
TrackingRecHit::ConstRecHitPointer
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Definition: TrackingRecHit.h:25
TwoBodyDecayTrajectoryFactory::clone
TwoBodyDecayTrajectoryFactory * clone() const override
Definition: TwoBodyDecayTrajectoryFactory.cc:47
edm::EventSetup
Definition: EventSetup.h:58
TrajectoryFactoryBase::materialEffects
MaterialEffects materialEffects(void) const
Definition: TrajectoryFactoryBase.h:45
TwoBodyDecayTrajectoryState
Definition: TwoBodyDecayTrajectoryState.h:12
get
#define get
input2
#define input2
Definition: AMPTWrapper.h:159
TrajectoryFactoryBase::allowZeroMaterial_
const bool allowZeroMaterial_
Definition: TrajectoryFactoryBase.h:72
TwoBodyDecayTrajectoryFactory::match
bool match(const TrajectoryStateOnSurface &state, const TransientTrackingRecHit::ConstRecHitPointer &recHit) const
Definition: TwoBodyDecayTrajectoryFactory.cc:233
TrajectoryFactoryBase::ConstTrajTrackPairCollection
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
Definition: TrajectoryFactoryBase.h:25
reco::TransientTrack
Definition: TransientTrack.h:19
PerigeeLinearizedTrackState.h
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
TwoBodyDecayTrajectoryFactory::theChi2CutValue
double theChi2CutValue
Definition: TwoBodyDecayTrajectoryFactory.cc:65
TwoBodyDecay
Definition: TwoBodyDecay.h:15
TwoBodyDecayTrajectoryFactory::theNSigmaCutValue
double theNSigmaCutValue
Definition: TwoBodyDecayTrajectoryFactory.cc:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TwoBodyDecayTrajectory.h
TwoBodyDecayFitter.h
TwoBodyDecayTrajectoryFactory::TwoBodyDecayTrajectoryFactory
TwoBodyDecayTrajectoryFactory(const edm::ParameterSet &config)
Definition: TwoBodyDecayTrajectoryFactory.cc:74
TwoBodyDecayTrajectoryFactory::thePrimaryWidth
double thePrimaryWidth
Definition: TwoBodyDecayTrajectoryFactory.cc:61
mps_fire.result
result
Definition: mps_fire.py:311
TwoBodyDecay::chi2
double chi2(void) const
Definition: TwoBodyDecay.h:44
input1
#define input1
Definition: AMPTWrapper.h:139
MagneticField
Definition: MagneticField.h:19
reco::TransientTrack::setTrackingGeometry
void setTrackingGeometry(const edm::ESHandle< GlobalTrackingGeometry > &tg)
Definition: TransientTrack.h:78
LocalError::yy
float yy() const
Definition: LocalError.h:24
TrajectoryFactoryBase.h
TwoBodyDecayTrajectoryFactory
Definition: TwoBodyDecayTrajectoryFactory.cc:28
TrajectoryFactoryBase::ExternalPredictionCollection
std::vector< TrajectoryStateOnSurface > ExternalPredictionCollection
Definition: TrajectoryFactoryBase.h:28