CMS 3D CMS Logo

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< ParametersDefinerForTPclone () const override
 
 CosmicParametersDefinerForTP ()
 
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
 
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
 
 ParametersDefinerForTP ()
 
 ParametersDefinerForTP (const edm::ParameterSet &iConfig)
 
virtual TrackingParticle::Point vertex (const edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::Candidate &tp) const
 
virtual ~ParametersDefinerForTP ()
 

Private Attributes

edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationListsimHitsTPAssoc
 

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...
 
- Public Attributes inherited from ParametersDefinerForTP
edm::InputTag beamSpotInputTag_
 

Detailed Description

Author
Boris Mangano (UCSD) 5/7/2009

Definition at line 13 of file CosmicParametersDefinerForTP.h.

Constructor & Destructor Documentation

CosmicParametersDefinerForTP::CosmicParametersDefinerForTP ( )
inline

Definition at line 15 of file CosmicParametersDefinerForTP.h.

Referenced by clone().

15 {};
CosmicParametersDefinerForTP::~CosmicParametersDefinerForTP ( )
inlineoverride

Definition at line 16 of file CosmicParametersDefinerForTP.h.

References iEvent, momentum(), and vertex().

16 {};

Member Function Documentation

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

Reimplemented from ParametersDefinerForTP.

Definition at line 45 of file CosmicParametersDefinerForTP.h.

References CosmicParametersDefinerForTP().

Referenced by MuonTrackValidator::analyze().

45  {
46  return std::unique_ptr<CosmicParametersDefinerForTP>(new CosmicParametersDefinerForTP(*this));
47  }
void CosmicParametersDefinerForTP::initEvent ( edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList simHitsTPAssocToSet)
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 41 of file CosmicParametersDefinerForTP.h.

References simHitsTPAssoc.

41  {
42  simHitsTPAssoc = simHitsTPAssocToSet;
43  }
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 23 of file CosmicParametersDefinerForTP.cc.

References runEdmFileComparison::found, edm::EventSetup::get(), edm::Event::getByLabel(), runTauDisplay::gp, GlobalTrackingGeometry::idToDet(), TrajectoryStateClosestToBeamLine::isValid(), edm::HandleBase::isValid(), FreeTrajectoryState::momentum(), AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::perp(), edm::ESHandle< T >::product(), TCMET_cfi::radius, simHitsTPAssoc, SimHitTPAssociationProducer::simHitTPAssociationListGreater(), mathSSE::sqrt(), GeomDet::surface(), Surface::toGlobal(), trackingTruthProducer_cfi::tracker, TrajectoryStateClosestToBeamLine::trackStateAtPCA(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ~CosmicParametersDefinerForTP().

25  {
26  // to add a new implementation for cosmic. For the moment, it is just as for
27  // the base class:
28  using namespace edm;
29  using namespace std;
30  using namespace reco;
31 
33  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
35  iSetup.get<GlobalTrackingGeometryRecord>().get(theGeometry);
36 
38  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
39 
41  iEvent.getByLabel(InputTag("offlineBeamSpot"), bs);
42 
43  GlobalVector finalGV(0, 0, 0);
44  GlobalPoint finalGP(0, 0, 0);
45  double radius(9999);
46  bool found(false);
48 
49  edm::LogVerbatim("CosmicParametersDefinerForTP") << "\t in CosmicParametersDefinerForTP::momentum";
50  edm::LogVerbatim("CosmicParametersDefinerForTP")
51  << "\t \t Original TP state: pt = " << tpr->pt() << ", pz = " << tpr->pz();
52 
53  if (simHitsTPAssoc.isValid() == 0) {
54  LogError("TrackAssociation") << "Invalid handle!";
55  return momentum;
56  }
57  std::pair<TrackingParticleRef, TrackPSimHitRef> clusterTPpairWithDummyTP(
58  tpr,
59  TrackPSimHitRef()); // SimHit is dummy: for simHitTPAssociationListGreater
60  // sorting only the cluster is needed
61  auto range = std::equal_range(simHitsTPAssoc->begin(),
62  simHitsTPAssoc->end(),
63  clusterTPpairWithDummyTP,
65  for (auto ip = range.first; ip != range.second; ++ip) {
66  TrackPSimHitRef it = ip->second;
67  const GeomDet *tmpDet = theGeometry->idToDet(DetId(it->detUnitId()));
68  if (!tmpDet) {
69  edm::LogVerbatim("CosmicParametersDefinerForTP")
70  << "***WARNING in CosmicParametersDefinerForTP::momentum: no GeomDet "
71  "for: "
72  << it->detUnitId() << ". Skipping it."
73  << "\n";
74  continue;
75  }
76 
77  LocalVector lv = it->momentumAtEntry();
78  Local3DPoint lp = it->localPosition();
79  GlobalVector gv = tmpDet->surface().toGlobal(lv);
80  GlobalPoint gp = tmpDet->surface().toGlobal(lp);
81 
82  // discard hits related to low energy debris from the primary particle
83  if (it->processType() != 0)
84  continue;
85 
86  if (gp.perp() < radius) {
87  found = true;
88  radius = gp.perp();
89  finalGV = gv;
90  finalGP = gp;
91  }
92  }
93 
94  edm::LogVerbatim("CosmicParametersDefinerForTP")
95  // <<"\t FINAL State at InnerMost Hit: Radius = "<< finalGP.perp() << ",
96  // z = "<< finalGP.z()
97  // <<", pt = "<< finalGV.perp() << ", pz = "<< finalGV.z();
98  << "\t \t FINAL State at InnerMost Hit: pt = " << finalGV.perp() << ", pz = " << finalGV.z();
99 
100  if (found) {
101  FreeTrajectoryState ftsAtProduction(finalGP, finalGV, TrackCharge(tpr->charge()), theMF.product());
102  TSCBLBuilderNoMaterial tscblBuilder;
103  TrajectoryStateClosestToBeamLine tsAtClosestApproach =
104  tscblBuilder(ftsAtProduction, *bs); // as in TrackProducerAlgorithm
105 
106  if (tsAtClosestApproach.isValid()) {
107  GlobalVector p = tsAtClosestApproach.trackStateAtPCA().momentum();
108  momentum = TrackingParticle::Vector(p.x(), p.y(), p.z());
109  } else {
110  edm::LogVerbatim("CosmicParametersDefinerForTP") << "*** WARNING in CosmicParametersDefinerForTP::momentum: "
111  "tsAtClosestApproach is not valid."
112  << "\n";
113  }
114 
115  edm::LogVerbatim("CosmicParametersDefinerForTP")
116  << "\t \t FINAL State extrap. at PCA: pt = " << sqrt(momentum.x() * momentum.x() + momentum.y() * momentum.y())
117  << ", pz = " << momentum.z() << "\n";
118 
119  return momentum;
120  }
121 
122  edm::LogVerbatim("CosmicParametersDefinerForTP")
123  << "*** WARNING in CosmicParametersDefinerForTP::momentum: NOT found the "
124  "innermost TP point"
125  << "\n";
126  edm::LogVerbatim("CosmicParametersDefinerForTP")
127  << "*** FINAL Reference MOMENTUM TP (px,py,pz) = " << momentum.x() << momentum.y() << momentum.z() << "\n";
128  return momentum;
129 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
T perp() const
Definition: PV3DBase.h:72
static bool simHitTPAssociationListGreater(SimHitTPPair i, SimHitTPPair j)
T y() const
Definition: PV3DBase.h:63
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
int TrackCharge
Definition: TrackCharge.h:4
T sqrt(T t)
Definition: SSEVec.h:18
TrackingParticle::Vector momentum(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
T z() const
Definition: PV3DBase.h:64
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
GlobalVector momentum() const
Definition: DetId.h:18
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:71
const GeomDet * idToDet(DetId) const override
edm::Ref< edm::PSimHitContainer > TrackPSimHitRef
math::XYZVectorD Vector
point in the space
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:86
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 25 of file CosmicParametersDefinerForTP.h.

29  {
30  return TrackingParticle::Vector();
31  }
math::XYZVectorD Vector
point in the space
TrackingParticle::Point CosmicParametersDefinerForTP::vertex ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const TrackingParticleRef tpr 
) const
overridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 131 of file CosmicParametersDefinerForTP.cc.

References runEdmFileComparison::found, edm::EventSetup::get(), edm::Event::getByLabel(), runTauDisplay::gp, GlobalTrackingGeometry::idToDet(), TrajectoryStateClosestToBeamLine::isValid(), edm::HandleBase::isValid(), PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), edm::ESHandle< T >::product(), TCMET_cfi::radius, simHitsTPAssoc, SimHitTPAssociationProducer::simHitTPAssociationListGreater(), mathSSE::sqrt(), GeomDet::surface(), Surface::toGlobal(), trackingTruthProducer_cfi::tracker, TrajectoryStateClosestToBeamLine::trackStateAtPCA(), findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), reco::BeamSpot::x0(), PV3DBase< T, PVType, FrameType >::y(), reco::BeamSpot::y0(), PV3DBase< T, PVType, FrameType >::z(), and reco::BeamSpot::z0().

Referenced by Tau.Tau::dxy(), and ~CosmicParametersDefinerForTP().

133  {
134  using namespace edm;
135  using namespace std;
136  using namespace reco;
137 
139  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
141  iSetup.get<GlobalTrackingGeometryRecord>().get(theGeometry);
142 
144  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
145 
147  iEvent.getByLabel(InputTag("offlineBeamSpot"), bs);
148 
149  GlobalVector finalGV(0, 0, 0);
150  GlobalPoint finalGP(0, 0, 0);
151  double radius(9999);
152  bool found(false);
154 
155  edm::LogVerbatim("CosmicParametersDefinerForTP") << "\t in CosmicParametersDefinerForTP::vertex";
156  edm::LogVerbatim("CosmicParametersDefinerForTP")
157  << "\t \t Original TP state: radius = "
158  << sqrt(tpr->vertex().x() * tpr->vertex().x() + tpr->vertex().y() * tpr->vertex().y())
159  << ", z = " << tpr->vertex().z();
160 
161  if (simHitsTPAssoc.isValid() == 0) {
162  LogError("TrackAssociation") << "Invalid handle!";
163  return vertex;
164  }
165  std::pair<TrackingParticleRef, TrackPSimHitRef> clusterTPpairWithDummyTP(
166  tpr,
167  TrackPSimHitRef()); // SimHit is dummy: for simHitTPAssociationListGreater
168  // sorting only the cluster is needed
169  auto range = std::equal_range(simHitsTPAssoc->begin(),
170  simHitsTPAssoc->end(),
171  clusterTPpairWithDummyTP,
173  for (auto ip = range.first; ip != range.second; ++ip) {
174  TrackPSimHitRef it = ip->second;
175  const GeomDet *tmpDet = theGeometry->idToDet(DetId(it->detUnitId()));
176  if (!tmpDet) {
177  edm::LogVerbatim("CosmicParametersDefinerForTP")
178  << "***WARNING in CosmicParametersDefinerForTP::vertex: no GeomDet "
179  "for: "
180  << it->detUnitId() << ". Skipping it."
181  << "\n";
182  continue;
183  }
184 
185  LocalVector lv = it->momentumAtEntry();
186  Local3DPoint lp = it->localPosition();
187  GlobalVector gv = tmpDet->surface().toGlobal(lv);
188  GlobalPoint gp = tmpDet->surface().toGlobal(lp);
189 
190  // discard hits related to low energy debris from the primary particle
191  if (it->processType() != 0)
192  continue;
193 
194  if (gp.perp() < radius) {
195  found = true;
196  radius = gp.perp();
197  finalGV = gv;
198  finalGP = gp;
199  }
200  }
201  edm::LogVerbatim("CosmicParametersDefinerForTP")
202  << "\t \t FINAL State at InnerMost Hit: radius = " << finalGP.perp() << ", z = " << finalGP.z();
203 
204  if (found) {
205  FreeTrajectoryState ftsAtProduction(finalGP, finalGV, TrackCharge(tpr->charge()), theMF.product());
206  TSCBLBuilderNoMaterial tscblBuilder;
207  TrajectoryStateClosestToBeamLine tsAtClosestApproach =
208  tscblBuilder(ftsAtProduction, *bs); // as in TrackProducerAlgorithm
209 
210  if (tsAtClosestApproach.isValid()) {
211  GlobalPoint v = tsAtClosestApproach.trackStateAtPCA().position();
212  vertex = TrackingParticle::Point(v.x(), v.y(), v.z());
213  } else {
214  // to preserve old behaviour
215  // would be better to flag this somehow to allow ignoring in downstream
216  vertex = TrackingParticle::Point(bs->x0(), bs->y0(), bs->z0());
217  edm::LogVerbatim("CosmicParametersDefinerForTP") << "*** WARNING in CosmicParametersDefinerForTP::vertex: "
218  "tsAtClosestApproach is not valid."
219  << "\n";
220  }
221  edm::LogVerbatim("CosmicParametersDefinerForTP")
222  << "\t \t FINAL State extrap. at PCA: radius = " << sqrt(vertex.x() * vertex.x() + vertex.y() * vertex.y())
223  << ", z = " << vertex.z() << "\n";
224 
225  return vertex;
226  }
227 
228  edm::LogVerbatim("CosmicParametersDefinerForTP")
229  << "*** WARNING in CosmicParametersDefinerForTP::vertex: NOT found the "
230  "innermost TP point"
231  << "\n";
232  edm::LogVerbatim("CosmicParametersDefinerForTP")
233  << "*** FINAL Reference VERTEX TP V(x,y,z) = " << vertex.x() << vertex.y() << vertex.z() << "\n";
234 
235  return vertex;
236 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
double z0() const
z coordinate
Definition: BeamSpot.h:68
T perp() const
Definition: PV3DBase.h:72
static bool simHitTPAssociationListGreater(SimHitTPPair i, SimHitTPPair j)
T y() const
Definition: PV3DBase.h:63
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
math::XYZPointD Point
point in the space
int TrackCharge
Definition: TrackCharge.h:4
TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
Definition: DetId.h:18
GlobalPoint position() const
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:71
const GeomDet * idToDet(DetId) const override
double y0() const
y coordinate
Definition: BeamSpot.h:66
edm::Ref< edm::PSimHitContainer > TrackPSimHitRef
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:86
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc
double x0() const
x coordinate
Definition: BeamSpot.h:64
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 33 of file CosmicParametersDefinerForTP.h.

Referenced by Tau.Tau::dxy().

37  {
38  return TrackingParticle::Point();
39  }
math::XYZPointD Point
point in the space

Member Data Documentation

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

Definition at line 50 of file CosmicParametersDefinerForTP.h.

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