CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
CosmicParametersDefinerForTP Class Reference

#include <CosmicParametersDefinerForTP.h>

Inheritance diagram for CosmicParametersDefinerForTP:
ParametersDefinerForTP

Public Member Functions

std::unique_ptr
< ParametersDefinerForTP
clone () const override
 
 CosmicParametersDefinerForTP (edm::ConsumesCollector iC)
 
void initEvent (edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) override
 
TrackingParticle::Vector momentum (const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
 
TrackingParticle::Vector momentum (const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vertex, const LorentzVector &lv) const override
 
std::tuple
< TrackingParticle::Vector,
TrackingParticle::Point
momentumAndVertex (const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
 
TrackingParticle::Point vertex (const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
 
TrackingParticle::Point vertex (const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vertex, const LorentzVector &lv) const override
 
 ~CosmicParametersDefinerForTP () override
 
- Public Member Functions inherited from ParametersDefinerForTP
virtual TrackingParticle::Vector momentum (const edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::Candidate &tp) const
 
std::tuple
< TrackingParticle::Vector,
TrackingParticle::Point
momentumAndVertex (const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const
 
 ParametersDefinerForTP (const edm::InputTag &beamspot, edm::ConsumesCollector iC)
 
virtual TrackingParticle::Point vertex (const edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::Candidate &tp) const
 
virtual ~ParametersDefinerForTP ()
 

Private Attributes

const edm::ESGetToken
< GlobalTrackingGeometry,
GlobalTrackingGeometryRecord
geometryToken_
 
edm::Handle
< SimHitTPAssociationProducer::SimHitTPAssociationList
simHitsTPAssoc
 

Additional Inherited Members

- Public Types inherited from ParametersDefinerForTP
typedef int Charge
 electric charge type More...
 
typedef math::XYZTLorentzVectorD LorentzVector
 Lorentz vector. More...
 
typedef math::XYZPointD Point
 point in the space More...
 
- Protected Attributes inherited from ParametersDefinerForTP
const edm::EDGetTokenT
< reco::BeamSpot
bsToken_
 
const edm::ESGetToken
< MagneticField,
IdealMagneticFieldRecord
mfToken_
 

Detailed Description

Author
Boris Mangano (UCSD) 5/7/2009

Definition at line 18 of file CosmicParametersDefinerForTP.h.

Constructor & Destructor Documentation

CosmicParametersDefinerForTP::CosmicParametersDefinerForTP ( edm::ConsumesCollector  iC)

Definition at line 15 of file CosmicParametersDefinerForTP.cc.

16  : ParametersDefinerForTP(edm::InputTag("offlineBeamSpot"), iC), geometryToken_(iC.esConsumes()) {}
ParametersDefinerForTP(const edm::InputTag &beamspot, edm::ConsumesCollector iC)
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
CosmicParametersDefinerForTP::~CosmicParametersDefinerForTP ( )
overridedefault

Member Function Documentation

std::unique_ptr<ParametersDefinerForTP> CosmicParametersDefinerForTP::clone ( void  ) const
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 55 of file CosmicParametersDefinerForTP.h.

55  {
56  return std::make_unique<CosmicParametersDefinerForTP>(*this);
57  }
void CosmicParametersDefinerForTP::initEvent ( edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList simHitsTPAssocToSet)
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 51 of file CosmicParametersDefinerForTP.h.

References simHitsTPAssoc.

51  {
52  simHitsTPAssoc = simHitsTPAssocToSet;
53  }
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc
TrackingParticle::Vector CosmicParametersDefinerForTP::momentum ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const TrackingParticleRef tpr 
) const
overridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 19 of file CosmicParametersDefinerForTP.cc.

References cms::cuda::bs, ParametersDefinerForTP::bsToken_, newFWLiteAna::found, relativeConstraints::geometry, geometryToken_, edm::Event::get(), edm::EventSetup::getData(), runTauDisplay::gp, TrajectoryStateClosestToBeamLine::isValid(), edm::HandleBase::isValid(), ParametersDefinerForTP::mfToken_, FreeTrajectoryState::momentum(), AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::perp(), CosmicsPD_Skims::radius, sistrip::SpyUtilities::range(), dt_dqm_sourceclient_common_cff::reco, simHitsTPAssoc, SimHitTPAssociationProducer::simHitTPAssociationListGreater(), mathSSE::sqrt(), GeomDet::surface(), Surface::toGlobal(), TrajectoryStateClosestToBeamLine::trackStateAtPCA(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by momentumAndVertex().

21  {
22  // to add a new implementation for cosmic. For the moment, it is just as for
23  // the base class:
24  using namespace edm;
25  using namespace std;
26  using namespace reco;
27 
28  auto const &bs = iEvent.get(bsToken_);
29  auto const &geometry = iSetup.getData(geometryToken_);
30  auto const &mf = iSetup.getData(mfToken_);
31 
32  GlobalVector finalGV(0, 0, 0);
33  GlobalPoint finalGP(0, 0, 0);
34  double radius(9999);
35  bool found(false);
37 
38  edm::LogVerbatim("CosmicParametersDefinerForTP") << "\t in CosmicParametersDefinerForTP::momentum";
39  edm::LogVerbatim("CosmicParametersDefinerForTP")
40  << "\t \t Original TP state: pt = " << tpr->pt() << ", pz = " << tpr->pz();
41 
42  if (simHitsTPAssoc.isValid() == 0) {
43  LogError("TrackAssociation") << "Invalid handle!";
44  return momentum;
45  }
46  std::pair<TrackingParticleRef, TrackPSimHitRef> clusterTPpairWithDummyTP(
47  tpr,
48  TrackPSimHitRef()); // SimHit is dummy: for simHitTPAssociationListGreater
49  // sorting only the cluster is needed
50  auto range = std::equal_range(simHitsTPAssoc->begin(),
51  simHitsTPAssoc->end(),
52  clusterTPpairWithDummyTP,
54  for (auto ip = range.first; ip != range.second; ++ip) {
55  TrackPSimHitRef it = ip->second;
56  const GeomDet *tmpDet = geometry.idToDet(DetId(it->detUnitId()));
57  if (!tmpDet) {
58  edm::LogVerbatim("CosmicParametersDefinerForTP")
59  << "***WARNING in CosmicParametersDefinerForTP::momentum: no GeomDet "
60  "for: "
61  << it->detUnitId() << ". Skipping it."
62  << "\n";
63  continue;
64  }
65 
66  LocalVector lv = it->momentumAtEntry();
67  Local3DPoint lp = it->localPosition();
68  GlobalVector gv = tmpDet->surface().toGlobal(lv);
69  GlobalPoint gp = tmpDet->surface().toGlobal(lp);
70 
71  // discard hits related to low energy debris from the primary particle
72  if (it->processType() != 0)
73  continue;
74 
75  if (gp.perp() < radius) {
76  found = true;
77  radius = gp.perp();
78  finalGV = gv;
79  finalGP = gp;
80  }
81  }
82 
83  edm::LogVerbatim("CosmicParametersDefinerForTP")
84  // <<"\t FINAL State at InnerMost Hit: Radius = "<< finalGP.perp() << ",
85  // z = "<< finalGP.z()
86  // <<", pt = "<< finalGV.perp() << ", pz = "<< finalGV.z();
87  << "\t \t FINAL State at InnerMost Hit: pt = " << finalGV.perp() << ", pz = " << finalGV.z();
88 
89  if (found) {
90  FreeTrajectoryState ftsAtProduction(finalGP, finalGV, TrackCharge(tpr->charge()), &mf);
91  TSCBLBuilderNoMaterial tscblBuilder;
92  TrajectoryStateClosestToBeamLine tsAtClosestApproach =
93  tscblBuilder(ftsAtProduction, bs); // as in TrackProducerAlgorithm
94 
95  if (tsAtClosestApproach.isValid()) {
96  GlobalVector p = tsAtClosestApproach.trackStateAtPCA().momentum();
97  momentum = TrackingParticle::Vector(p.x(), p.y(), p.z());
98  } else {
99  edm::LogVerbatim("CosmicParametersDefinerForTP") << "*** WARNING in CosmicParametersDefinerForTP::momentum: "
100  "tsAtClosestApproach is not valid."
101  << "\n";
102  }
103 
104  edm::LogVerbatim("CosmicParametersDefinerForTP")
105  << "\t \t FINAL State extrap. at PCA: pt = " << sqrt(momentum.x() * momentum.x() + momentum.y() * momentum.y())
106  << ", pz = " << momentum.z() << "\n";
107 
108  return momentum;
109  }
110 
111  edm::LogVerbatim("CosmicParametersDefinerForTP")
112  << "*** WARNING in CosmicParametersDefinerForTP::momentum: NOT found the "
113  "innermost TP point"
114  << "\n";
115  edm::LogVerbatim("CosmicParametersDefinerForTP")
116  << "*** FINAL Reference MOMENTUM TP (px,py,pz) = " << momentum.x() << momentum.y() << momentum.z() << "\n";
117  return momentum;
118 }
Log< level::Info, true > LogVerbatim
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
T perp() const
Definition: PV3DBase.h:69
static bool simHitTPAssociationListGreater(SimHitTPPair i, SimHitTPPair j)
TrackingParticle::Vector momentum(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
T y() const
Definition: PV3DBase.h:60
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
Log< level::Error, false > LogError
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const uint16_t range(const Frame &aFrame)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int TrackCharge
Definition: TrackCharge.h:4
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
bool isValid() const
Definition: HandleBase.h:70
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
GlobalVector momentum() const
Definition: DetId.h:17
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > mfToken_
edm::Ref< edm::PSimHitContainer > TrackPSimHitRef
math::XYZVectorD Vector
point in the space
T x() const
Definition: PV3DBase.h:59
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc
TrackingParticle::Vector CosmicParametersDefinerForTP::momentum ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const Charge  ch,
const Point vertex,
const LorentzVector lv 
) const
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 35 of file CosmicParametersDefinerForTP.h.

39  {
40  return TrackingParticle::Vector();
41  }
math::XYZVectorD Vector
point in the space
std::tuple<TrackingParticle::Vector, TrackingParticle::Point> CosmicParametersDefinerForTP::momentumAndVertex ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const TrackingParticleRef tpr 
) const
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 30 of file CosmicParametersDefinerForTP.h.

References momentum(), and vertex().

31  {
32  return std::make_tuple(momentum(iEvent, iSetup, tpr), vertex(iEvent, iSetup, tpr));
33  }
TrackingParticle::Vector momentum(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
TrackingParticle::Point CosmicParametersDefinerForTP::vertex ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const TrackingParticleRef tpr 
) const
overridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 120 of file CosmicParametersDefinerForTP.cc.

References cms::cuda::bs, ParametersDefinerForTP::bsToken_, newFWLiteAna::found, relativeConstraints::geometry, geometryToken_, edm::Event::get(), edm::EventSetup::getData(), runTauDisplay::gp, TrajectoryStateClosestToBeamLine::isValid(), edm::HandleBase::isValid(), ParametersDefinerForTP::mfToken_, PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), CosmicsPD_Skims::radius, sistrip::SpyUtilities::range(), dt_dqm_sourceclient_common_cff::reco, simHitsTPAssoc, SimHitTPAssociationProducer::simHitTPAssociationListGreater(), mathSSE::sqrt(), GeomDet::surface(), Surface::toGlobal(), TrajectoryStateClosestToBeamLine::trackStateAtPCA(), findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by Tau.Tau::dxy(), and momentumAndVertex().

122  {
123  using namespace edm;
124  using namespace std;
125  using namespace reco;
126 
127  auto const &bs = iEvent.get(bsToken_);
128  auto const &geometry = iSetup.getData(geometryToken_);
129  auto const &mf = iSetup.getData(mfToken_);
130 
131  GlobalVector finalGV(0, 0, 0);
132  GlobalPoint finalGP(0, 0, 0);
133  double radius(9999);
134  bool found(false);
136 
137  edm::LogVerbatim("CosmicParametersDefinerForTP") << "\t in CosmicParametersDefinerForTP::vertex";
138  edm::LogVerbatim("CosmicParametersDefinerForTP")
139  << "\t \t Original TP state: radius = "
140  << sqrt(tpr->vertex().x() * tpr->vertex().x() + tpr->vertex().y() * tpr->vertex().y())
141  << ", z = " << tpr->vertex().z();
142 
143  if (simHitsTPAssoc.isValid() == 0) {
144  LogError("TrackAssociation") << "Invalid handle!";
145  return vertex;
146  }
147  std::pair<TrackingParticleRef, TrackPSimHitRef> clusterTPpairWithDummyTP(
148  tpr,
149  TrackPSimHitRef()); // SimHit is dummy: for simHitTPAssociationListGreater
150  // sorting only the cluster is needed
151  auto range = std::equal_range(simHitsTPAssoc->begin(),
152  simHitsTPAssoc->end(),
153  clusterTPpairWithDummyTP,
155  for (auto ip = range.first; ip != range.second; ++ip) {
156  TrackPSimHitRef it = ip->second;
157  const GeomDet *tmpDet = geometry.idToDet(DetId(it->detUnitId()));
158  if (!tmpDet) {
159  edm::LogVerbatim("CosmicParametersDefinerForTP")
160  << "***WARNING in CosmicParametersDefinerForTP::vertex: no GeomDet "
161  "for: "
162  << it->detUnitId() << ". Skipping it."
163  << "\n";
164  continue;
165  }
166 
167  LocalVector lv = it->momentumAtEntry();
168  Local3DPoint lp = it->localPosition();
169  GlobalVector gv = tmpDet->surface().toGlobal(lv);
170  GlobalPoint gp = tmpDet->surface().toGlobal(lp);
171 
172  // discard hits related to low energy debris from the primary particle
173  if (it->processType() != 0)
174  continue;
175 
176  if (gp.perp() < radius) {
177  found = true;
178  radius = gp.perp();
179  finalGV = gv;
180  finalGP = gp;
181  }
182  }
183  edm::LogVerbatim("CosmicParametersDefinerForTP")
184  << "\t \t FINAL State at InnerMost Hit: radius = " << finalGP.perp() << ", z = " << finalGP.z();
185 
186  if (found) {
187  FreeTrajectoryState ftsAtProduction(finalGP, finalGV, TrackCharge(tpr->charge()), &mf);
188  TSCBLBuilderNoMaterial tscblBuilder;
189  TrajectoryStateClosestToBeamLine tsAtClosestApproach =
190  tscblBuilder(ftsAtProduction, bs); // as in TrackProducerAlgorithm
191 
192  if (tsAtClosestApproach.isValid()) {
193  GlobalPoint v = tsAtClosestApproach.trackStateAtPCA().position();
194  vertex = TrackingParticle::Point(v.x(), v.y(), v.z());
195  } else {
196  // to preserve old behaviour
197  // would be better to flag this somehow to allow ignoring in downstream
198  vertex = TrackingParticle::Point(bs.x0(), bs.y0(), bs.z0());
199  edm::LogVerbatim("CosmicParametersDefinerForTP") << "*** WARNING in CosmicParametersDefinerForTP::vertex: "
200  "tsAtClosestApproach is not valid."
201  << "\n";
202  }
203  edm::LogVerbatim("CosmicParametersDefinerForTP")
204  << "\t \t FINAL State extrap. at PCA: radius = " << sqrt(vertex.x() * vertex.x() + vertex.y() * vertex.y())
205  << ", z = " << vertex.z() << "\n";
206 
207  return vertex;
208  }
209 
210  edm::LogVerbatim("CosmicParametersDefinerForTP")
211  << "*** WARNING in CosmicParametersDefinerForTP::vertex: NOT found the "
212  "innermost TP point"
213  << "\n";
214  edm::LogVerbatim("CosmicParametersDefinerForTP")
215  << "*** FINAL Reference VERTEX TP V(x,y,z) = " << vertex.x() << vertex.y() << vertex.z() << "\n";
216 
217  return vertex;
218 }
Log< level::Info, true > LogVerbatim
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
T perp() const
Definition: PV3DBase.h:69
static bool simHitTPAssociationListGreater(SimHitTPPair i, SimHitTPPair j)
T y() const
Definition: PV3DBase.h:60
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
Log< level::Error, false > LogError
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const uint16_t range(const Frame &aFrame)
math::XYZPointD Point
point in the space
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int TrackCharge
Definition: TrackCharge.h:4
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
bool isValid() const
Definition: HandleBase.h:70
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
Definition: DetId.h:17
GlobalPoint position() const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > mfToken_
TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
edm::Ref< edm::PSimHitContainer > TrackPSimHitRef
T x() const
Definition: PV3DBase.h:59
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc
TrackingParticle::Point CosmicParametersDefinerForTP::vertex ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const Charge  ch,
const Point vertex,
const LorentzVector lv 
) const
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 43 of file CosmicParametersDefinerForTP.h.

Referenced by Tau.Tau::dxy().

47  {
48  return TrackingParticle::Point();
49  }
math::XYZPointD Point
point in the space

Member Data Documentation

const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> CosmicParametersDefinerForTP::geometryToken_
private

Definition at line 60 of file CosmicParametersDefinerForTP.h.

Referenced by momentum(), and vertex().

edm::Handle<SimHitTPAssociationProducer::SimHitTPAssociationList> CosmicParametersDefinerForTP::simHitsTPAssoc
private

Definition at line 61 of file CosmicParametersDefinerForTP.h.

Referenced by initEvent(), momentum(), and vertex().