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 Charge ch, const Point &vertex, const LorentzVector &lv) const override
 
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 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
 
 ~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::CosmicParametersDefinerForTP ( )
inline

Definition at line 15 of file CosmicParametersDefinerForTP.h.

15 {};

Referenced by clone().

◆ ~CosmicParametersDefinerForTP()

CosmicParametersDefinerForTP::~CosmicParametersDefinerForTP ( )
inlineoverride

Definition at line 16 of file CosmicParametersDefinerForTP.h.

16 {};

Member Function Documentation

◆ clone()

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

Reimplemented from ParametersDefinerForTP.

Definition at line 45 of file CosmicParametersDefinerForTP.h.

45  {
46  return std::unique_ptr<CosmicParametersDefinerForTP>(new CosmicParametersDefinerForTP(*this));
47  }

References CosmicParametersDefinerForTP().

Referenced by MuonTrackValidator::analyze().

◆ initEvent()

void CosmicParametersDefinerForTP::initEvent ( edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList simHitsTPAssocToSet)
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 41 of file CosmicParametersDefinerForTP.h.

41  {
42  simHitsTPAssoc = simHitsTPAssocToSet;
43  }

References simHitsTPAssoc.

◆ momentum() [1/2]

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  }

◆ momentum() [2/2]

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.

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 
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 }

References cms::cuda::bs, newFWLiteAna::found, edm::EventSetup::get(), get, runTauDisplay::gp, GlobalTrackingGeometry::idToDet(), iEvent, HLT_FULL_cff::InputTag, TrajectoryStateClosestToBeamLine::isValid(), edm::HandleBase::isValid(), FreeTrajectoryState::momentum(), AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::perp(), edm::ESHandle< T >::product(), CosmicsPD_Skims::radius, FastTimerService_cff::range, simHitsTPAssoc, SimHitTPAssociationProducer::simHitTPAssociationListGreater(), mathSSE::sqrt(), GeomDet::surface(), Surface::toGlobal(), PbPb_ZMuSkimMuonDPG_cff::tracker, TrajectoryStateClosestToBeamLine::trackStateAtPCA(), and PV3DBase< T, PVType, FrameType >::z().

◆ vertex() [1/2]

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.

37  {
38  return TrackingParticle::Point();
39  }

Referenced by Tau.Tau::dxy().

◆ vertex() [2/2]

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.

133  {
134  using namespace edm;
135  using namespace std;
136  using namespace reco;
137 
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 }

References cms::cuda::bs, newFWLiteAna::found, edm::EventSetup::get(), get, runTauDisplay::gp, GlobalTrackingGeometry::idToDet(), iEvent, HLT_FULL_cff::InputTag, TrajectoryStateClosestToBeamLine::isValid(), edm::HandleBase::isValid(), PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), edm::ESHandle< T >::product(), CosmicsPD_Skims::radius, FastTimerService_cff::range, simHitsTPAssoc, SimHitTPAssociationProducer::simHitTPAssociationListGreater(), mathSSE::sqrt(), GeomDet::surface(), Surface::toGlobal(), PbPb_ZMuSkimMuonDPG_cff::tracker, TrajectoryStateClosestToBeamLine::trackStateAtPCA(), findQualityFiles::v, and PV3DBase< T, PVType, FrameType >::z().

Referenced by Tau.Tau::dxy().

Member Data Documentation

◆ simHitsTPAssoc

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

Definition at line 50 of file CosmicParametersDefinerForTP.h.

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

Vector3DBase
Definition: Vector3DBase.h:8
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
FreeTrajectoryState::momentum
GlobalVector momentum() const
Definition: FreeTrajectoryState.h:68
TrajectoryStateClosestToBeamLine
Definition: TrajectoryStateClosestToBeamLine.h:15
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
CosmicParametersDefinerForTP::simHitsTPAssoc
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc
Definition: CosmicParametersDefinerForTP.h:50
TrackCharge
int TrackCharge
Definition: TrackCharge.h:4
GeomDet
Definition: GeomDet.h:27
CosmicParametersDefinerForTP::momentum
TrackingParticle::Vector momentum(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
Definition: CosmicParametersDefinerForTP.cc:23
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
GlobalTrackingGeometryRecord
Definition: GlobalTrackingGeometryRecord.h:17
TrackingParticle::Vector
math::XYZVectorD Vector
point in the space
Definition: TrackingParticle.h:37
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
FreeTrajectoryState::position
GlobalPoint position() const
Definition: FreeTrajectoryState.h:67
CosmicParametersDefinerForTP::CosmicParametersDefinerForTP
CosmicParametersDefinerForTP()
Definition: CosmicParametersDefinerForTP.h:15
findQualityFiles.v
v
Definition: findQualityFiles.py:179
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle< reco::BeamSpot >
edm::Ref
Definition: AssociativeIterator.h:58
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
cms::cuda::bs
bs
Definition: HistoContainer.h:127
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
edm::ESHandle< TrackerGeometry >
Point3DBase< float, GlobalTag >
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
std
Definition: JetResolutionObject.h:76
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
TSCBLBuilderNoMaterial
Definition: TSCBLBuilderNoMaterial.h:13
GlobalTrackingGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GlobalTrackingGeometry.cc:44
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
TrackPSimHitRef
edm::Ref< edm::PSimHitContainer > TrackPSimHitRef
Definition: PSimHitContainer.h:14
TrajectoryStateClosestToBeamLine::isValid
bool isValid() const
Definition: TrajectoryStateClosestToBeamLine.h:50
TrajectoryStateClosestToBeamLine::trackStateAtPCA
FTS const & trackStateAtPCA() const
Definition: TrajectoryStateClosestToBeamLine.h:32
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
TrackingParticle::Point
math::XYZPointD Point
point in the space
Definition: TrackingParticle.h:36
CosmicParametersDefinerForTP::vertex
TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
Definition: CosmicParametersDefinerForTP.cc:131
SimHitTPAssociationProducer::simHitTPAssociationListGreater
static bool simHitTPAssociationListGreater(SimHitTPPair i, SimHitTPPair j)
Definition: SimHitTPAssociationProducer.h:23