CMS 3D CMS Logo

TwoBodyDecayTrajectoryFactory.cc
Go to the documentation of this file.
8 
10 
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 
96  if (tracks.size() == 2) {
97  // produce transient tracks from persistent tracks
98  std::vector<reco::TransientTrack> transientTracks(2);
99 
100  transientTracks[0] = reco::TransientTrack(*tracks[0].second, magneticField.product());
101  transientTracks[0].setES(setup);
102 
103  transientTracks[1] = reco::TransientTrack(*tracks[1].second, magneticField.product());
104  transientTracks[1].setES(setup);
105 
106  // estimate the decay parameters
108  TwoBodyDecay tbd = theFitter.estimate(transientTracks, vm);
109 
110  if (!tbd.isValid() || (tbd.chi2() > theChi2CutValue)) {
112  return trajectories;
113  }
114 
115  return constructTrajectories(tracks, tbd, magneticField.product(), beamSpot, false);
116  } else {
117  edm::LogInfo("ReferenceTrajectories") << "@SUB=TwoBodyDecayTrajectoryFactory::trajectories"
118  << "Need 2 tracks, got " << tracks.size() << ".\n";
119  }
120 
121  return trajectories;
122 }
123 
125  const edm::EventSetup &setup,
128  const reco::BeamSpot &beamSpot) const {
130 
133 
134  if (tracks.size() == 2 && external.size() == 2) {
135  if (external[0].isValid() && external[1].isValid()) // Include external estimates
136  {
137  // produce transient tracks from persistent tracks
138  std::vector<reco::TransientTrack> transientTracks(2);
139 
140  transientTracks[0] = reco::TransientTrack(*tracks[0].second, magneticField.product());
141  transientTracks[0].setES(setup);
142 
143  transientTracks[1] = reco::TransientTrack(*tracks[1].second, magneticField.product());
144  transientTracks[1].setES(setup);
145 
146  // estimate the decay parameters. the transient tracks are not really associated to the
147  // the external tsos, but this is o.k., because the only information retrieved from them
148  // is the magnetic field.
150  TwoBodyDecay tbd = theFitter.estimate(transientTracks, external, vm);
151 
152  if (!tbd.isValid() || (tbd.chi2() > theChi2CutValue)) {
154  return trajectories;
155  }
156 
157  return constructTrajectories(tracks, tbd, magneticField.product(), beamSpot, true);
158  } else {
159  // Return without external estimate
160  trajectories = this->trajectories(setup, tracks, beamSpot);
161  }
162  } else {
163  edm::LogInfo("ReferenceTrajectories") << "@SUB=TwoBodyDecayTrajectoryFactory::trajectories"
164  << "Need 2 tracks, got " << tracks.size() << ".\n";
165  }
166 
167  return trajectories;
168 }
169 
172  const TwoBodyDecay &tbd,
173  const MagneticField *magField,
174  const reco::BeamSpot &beamSpot,
175  bool setParameterErrors) const {
177 
178  // get innermost valid trajectory state and hits from the tracks
181 
182  if (!(input1.first.isValid() && input2.first.isValid()))
183  return trajectories;
184 
185  // produce TwoBodyDecayTrajectoryState (input for TwoBodyDecayTrajectory)
186  TsosContainer tsos(input1.first, input2.first);
187  ConstRecHitCollection recHits(input1.second, input2.second);
188  TwoBodyDecayTrajectoryState trajectoryState(tsos, tbd, theSecondaryMass, magField);
189 
190  if (!trajectoryState.isValid()) {
192  return trajectories;
193  }
194 
195  // always use the refitted trajectory state for matching
196  // FIXME FIXME CLONE
197  //TrackingRecHit::ConstRecHitPointer updatedRecHit1( recHits.first.front()->clone( tsos.first ) );
198  // TrackingRecHit::ConstRecHitPointer updatedRecHit2( recHits.second.front()->clone( tsos.second ) );
199 
200  TrackingRecHit::ConstRecHitPointer updatedRecHit1(recHits.first.front());
201  TrackingRecHit::ConstRecHitPointer updatedRecHit2(recHits.second.front());
202 
203  bool valid1 = match(trajectoryState.trajectoryStates(true).first, updatedRecHit1);
204 
205  bool valid2 = match(trajectoryState.trajectoryStates(true).second, updatedRecHit2);
206 
207  if (!valid1 || !valid2) {
209  return trajectories;
210  }
211 
213  config.useBeamSpot = useBeamSpot_;
214  config.includeAPEs = includeAPEs_;
215  config.allowZeroMaterial = allowZeroMaterial_;
216  config.useRefittedState = theUseRefittedStateFlag;
217  config.constructTsosWithErrors = theConstructTsosWithErrorsFlag;
218  // set the flag for reversing the RecHits to false, since they are already in the correct order.
219  config.hitsAreReverse = false;
220  TwoBodyDecayTrajectory *result = new TwoBodyDecayTrajectory(trajectoryState, recHits, magField, beamSpot, config);
221  if (setParameterErrors && tbd.hasError())
222  result->setParameterErrors(tbd.covariance());
224  return trajectories;
225 }
226 
229  LocalPoint lp1 = state.localPosition();
230  LocalPoint lp2 = recHit->localPosition();
231 
232  double deltaX = lp1.x() - lp2.x();
233  double deltaY = lp1.y() - lp2.y();
234 
235  LocalError le = recHit->localPositionError();
236 
237  double varX = le.xx();
238  double varY = le.yy();
239 
240  return ((fabs(deltaX) / sqrt(varX) < theNSigmaCutValue) && (fabs(deltaY) / sqrt(varY) < theNSigmaCutValue));
241 }
242 
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
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
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
HLT_2018_cff.magneticField
magneticField
Definition: HLT_2018_cff.py:348
TwoBodyDecayTrajectoryFactory::VirtualMeasurement
TwoBodyDecayVirtualMeasurement VirtualMeasurement
Definition: TwoBodyDecayTrajectoryFactory.cc:30
TwoBodyDecayTrajectoryState::isValid
bool isValid(void) const
Definition: TwoBodyDecayTrajectoryState.h:28
edm::LogInfo
Definition: MessageLogger.h:254
TrajectoryFactoryBase::includeAPEs_
const bool includeAPEs_
Definition: TrajectoryFactoryBase.h:71
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
ReferenceTrajectoryBase::Config
Definition: ReferenceTrajectoryBase.h:121
TwoBodyDecayFitter
Definition: TwoBodyDecayFitter.h:21
TransientTrack.h
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:170
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
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
looper.config
config
Definition: looper.py:291
Point3DBase< float, LocalTag >
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
TwoBodyDecayVirtualMeasurement
Definition: TwoBodyDecayVirtualMeasurement.h:19
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
Error.h
TrajectoryStateOnSurface::localPosition
LocalPoint localPosition() const
Definition: TrajectoryStateOnSurface.h:74
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
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
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:57
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
reco::TransientTrack::setES
void setES(const edm::EventSetup &es)
Definition: TransientTrack.h:78
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TwoBodyDecayTrajectoryFactory::match
bool match(const TrajectoryStateOnSurface &state, const TransientTrackingRecHit::ConstRecHitPointer &recHit) const
Definition: TwoBodyDecayTrajectoryFactory.cc:227
TrajectoryFactoryBase::ConstTrajTrackPairCollection
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
Definition: TrajectoryFactoryBase.h:25
reco::TransientTrack
Definition: TransientTrack.h:19
PerigeeLinearizedTrackState.h
TwoBodyDecayTrajectoryFactory::theChi2CutValue
double theChi2CutValue
Definition: TwoBodyDecayTrajectoryFactory.cc:65
TwoBodyDecay
Definition: TwoBodyDecay.h:15
TwoBodyDecayTrajectoryFactory::theNSigmaCutValue
double theNSigmaCutValue
Definition: TwoBodyDecayTrajectoryFactory.cc:64
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:303
TwoBodyDecay::chi2
double chi2(void) const
Definition: TwoBodyDecay.h:44
input1
#define input1
Definition: AMPTWrapper.h:139
MagneticField
Definition: MagneticField.h:19
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