CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ParametersDefinerForTP.cc
Go to the documentation of this file.
11 
13  : bsToken_(iC.consumes(beamspot)), mfToken_(iC.esConsumes()) {}
14 
16 
18  const edm::EventSetup &iSetup,
19  const Charge charge,
20  const Point &vtx,
21  const LorentzVector &lv) const {
22  // to add a new implementation for cosmic. For the moment, it is just as for
23  // the base class:
24 
25  using namespace edm;
26 
27  auto const &bs = iEvent.get(bsToken_);
28  auto const &mf = iSetup.getData(mfToken_);
29 
31 
32  FreeTrajectoryState ftsAtProduction(
33  GlobalPoint(vtx.x(), vtx.y(), vtx.z()), GlobalVector(lv.x(), lv.y(), lv.z()), TrackCharge(charge), &mf);
34 
35  TSCBLBuilderNoMaterial tscblBuilder;
36  TrajectoryStateClosestToBeamLine tsAtClosestApproach =
37  tscblBuilder(ftsAtProduction, bs); // as in TrackProducerAlgorithm
38  if (tsAtClosestApproach.isValid()) {
39  GlobalVector p = tsAtClosestApproach.trackStateAtPCA().momentum();
40  momentum = TrackingParticle::Vector(p.x(), p.y(), p.z());
41  }
42  return momentum;
43 }
44 
46  const edm::EventSetup &iSetup,
47  const Charge charge,
48  const Point &vtx,
49  const LorentzVector &lv) const {
50  // to add a new implementation for cosmic. For the moment, it is just as for
51  // the base class:
52  using namespace edm;
53 
54  auto const &bs = iEvent.get(bsToken_);
55  auto const &mf = iSetup.getData(mfToken_);
56 
58 
59  FreeTrajectoryState ftsAtProduction(
60  GlobalPoint(vtx.x(), vtx.y(), vtx.z()), GlobalVector(lv.x(), lv.y(), lv.z()), TrackCharge(charge), &mf);
61 
62  TSCBLBuilderNoMaterial tscblBuilder;
63  TrajectoryStateClosestToBeamLine tsAtClosestApproach =
64  tscblBuilder(ftsAtProduction, bs); // as in TrackProducerAlgorithm
65  if (tsAtClosestApproach.isValid()) {
66  GlobalPoint v = tsAtClosestApproach.trackStateAtPCA().position();
67  vertex = TrackingParticle::Point(v.x(), v.y(), v.z());
68  } else {
69  // to preserve old behaviour
70  // would be better to flag this somehow to allow ignoring in downstream
71  vertex = TrackingParticle::Point(bs.x0(), bs.y0(), bs.z0());
72  }
73  return vertex;
74 }
75 
76 std::tuple<TrackingParticle::Vector, TrackingParticle::Point> ParametersDefinerForTP::momentumAndVertex(
77  const edm::Event &iEvent,
78  const edm::EventSetup &iSetup,
79  const Charge charge,
80  const Point &vtx,
81  const LorentzVector &lv) const {
82  using namespace edm;
83 
84  auto const &bs = iEvent.get(bsToken_);
85  auto const &mf = iSetup.getData(mfToken_);
86 
87  TrackingParticle::Point vertex(bs.x0(), bs.y0(), bs.z0());
89 
90  FreeTrajectoryState ftsAtProduction(
91  GlobalPoint(vtx.x(), vtx.y(), vtx.z()), GlobalVector(lv.x(), lv.y(), lv.z()), TrackCharge(charge), &mf);
92 
93  TSCBLBuilderNoMaterial tscblBuilder;
94  TrajectoryStateClosestToBeamLine tsAtClosestApproach =
95  tscblBuilder(ftsAtProduction, bs); // as in TrackProducerAlgorithm
96  if (tsAtClosestApproach.isValid()) {
97  GlobalPoint v = tsAtClosestApproach.trackStateAtPCA().position();
98  vertex = TrackingParticle::Point(v.x(), v.y(), v.z());
99  GlobalVector p = tsAtClosestApproach.trackStateAtPCA().momentum();
100  momentum = TrackingParticle::Vector(p.x(), p.y(), p.z());
101  ;
102  }
103 
104  return std::make_tuple(momentum, vertex);
105 }
virtual ~ParametersDefinerForTP()
math::XYZTLorentzVectorD LorentzVector
Lorentz vector.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:60
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
ParametersDefinerForTP(const edm::InputTag &beamspot, edm::ConsumesCollector iC)
math::XYZPointD Point
point in the space
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int TrackCharge
Definition: TrackCharge.h:4
int iEvent
Definition: GenABIO.cc:224
virtual std::tuple< TrackingParticle::Vector, TrackingParticle::Point > momentumAndVertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const
T z() const
Definition: PV3DBase.h:61
virtual TrackingParticle::Vector momentum(const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
int Charge
electric charge type
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > mfToken_
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
math::XYZVectorD Vector
point in the space
T x() const
Definition: PV3DBase.h:59
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Global3DVector GlobalVector
Definition: GlobalVector.h:10
virtual TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const