CMS 3D CMS Logo

CosmicParametersDefinerForTP.cc
Go to the documentation of this file.
20 
22 
24  const edm::EventSetup &iSetup,
25  const TrackingParticleRef &tpr) const {
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 }
130 
132  const edm::EventSetup &iSetup,
133  const TrackingParticleRef &tpr) const {
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 }
237 
Vector3DBase
Definition: Vector3DBase.h:8
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TSCBLBuilderNoMaterial.h
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
FreeTrajectoryState.h
MessageLogger.h
TrackCharge
int TrackCharge
Definition: TrackCharge.h:4
TrackerGeometry.h
GeomDet
Definition: GeomDet.h:27
ESHandle.h
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
typelookup.h
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
findQualityFiles.v
v
Definition: findQualityFiles.py:179
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle< reco::BeamSpot >
edm::Ref< TrackingParticleCollection >
TrajectoryStateClosestToBeamLineBuilder
Definition: TrajectoryStateClosestToBeamLineBuilder.h:14
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
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
Surface.h
CosmicParametersDefinerForTP
Definition: CosmicParametersDefinerForTP.h:13
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
GloballyPositioned.h
IdealMagneticFieldRecord.h
edm::ESHandle< TrackerGeometry >
Point3DBase< float, GlobalTag >
GlobalTrackingGeometryRecord.h
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
TrackerDigiGeometryRecord.h
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
TSCPBuilderNoMaterial.h
get
#define get
TYPELOOKUP_DATA_REG
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:102
GeomDet.h
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
GlobalVector.h
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
GlobalTrackingGeometry.h
edm::Event
Definition: Event.h:73
TrackingParticle::Point
math::XYZPointD Point
point in the space
Definition: TrackingParticle.h:36
GlobalPoint.h
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
CosmicParametersDefinerForTP::vertex
TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
Definition: CosmicParametersDefinerForTP.cc:131
CosmicParametersDefinerForTP.h
SimHitTPAssociationProducer::simHitTPAssociationListGreater
static bool simHitTPAssociationListGreater(SimHitTPPair i, SimHitTPPair j)
Definition: SimHitTPAssociationProducer.h:23