46 trajCollectionToken_ =
54 desc.setComment(
"auxilliary class to store information about track-hit residuals");
60 auto const& trajParams =
track.extra()->trajParams();
61 auto const& residuals =
track.extra()->residuals();
65 for (
unsigned int h = 0;
h <
track.recHitsSize();
h++) {
71 const DetId& hit_detId =
hit->geographicalId();
72 auto IntRawDetID = hit_detId.
rawId();
73 auto IntSubDetID = hit_detId.
subdetId();
87 auto lPTrk = trajParams[
h].position();
88 auto lVTrk = trajParams[
h].direction();
90 auto gtrkdirup =
hit->surface()->toGlobal(lVTrk);
93 hitStruct.
phi = gtrkdirup.phi();
94 hitStruct.
eta = gtrkdirup.eta();
96 hitStruct.
localAlpha = std::atan2(lVTrk.x(), lVTrk.z());
97 hitStruct.
localBeta = std::atan2(lVTrk.y(), lVTrk.z());
99 hitStruct.
resX = residuals.residualX(
h);
100 hitStruct.
resY = residuals.residualY(
h);
101 hitStruct.
resErrX = hitStruct.
resX / residuals.pullX(
h);
102 hitStruct.
resErrY = hitStruct.
resY / residuals.pullY(
h);
107 hitStruct.
localX = lPTrk.x();
108 hitStruct.
localY = lPTrk.y();
111 float resXprime(999.
F), resYprime(999.
F);
112 float resXatTrkY(999.
F);
113 float resXprimeErr(999.
F), resYprimeErr(999.
F);
115 if (
hit->detUnit()) {
116 float uOrientation(-999.
F), vOrientation(-999.
F);
117 float resXTopol(999.
F), resYTopol(999.
F);
118 float resXatTrkYTopol(999.
F);
120 const Surface& surface =
hit->detUnit()->surface();
122 const Bounds& bound = boundplane.bounds();
127 LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.);
129 gVDirection = surface.
toGlobal(lVDirection);
134 uOrientation = gUDirection.
perp() - gPModule.
perp() >= 0 ? +1.F : -1.F;
135 vOrientation =
deltaPhi(gVDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
137 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
138 vOrientation = gVDirection.z() - gPModule.
z() >= 0 ? +1.F : -1.F;
141 resXTopol = hitStruct.
resX;
142 resXatTrkYTopol = hitStruct.
resX;
143 resYTopol = hitStruct.
resY;
144 resXprimeErr = hitStruct.
resErrX;
145 resYprimeErr = hitStruct.
resErrY;
148 if (rectangularBound !=
nullptr) {
150 length = rectangularBound->
length();
156 <<
"[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
162 edm::LogWarning(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 163 <<
"No valid tracker subdetector " << IntSubDetID;
167 resXprime = resXTopol * uOrientation;
168 resXatTrkY = resXatTrkYTopol;
169 resYprime = resYTopol * vOrientation;
184 v_avhitout.push_back(hitStruct);
191 const std::vector<TrajectoryMeasurement>& tmColl = trajectory->
measurements();
192 for (std::vector<TrajectoryMeasurement>::const_iterator itTraj = tmColl.begin(); itTraj != tmColl.end(); ++itTraj) {
193 if (!itTraj->updatedState().isValid())
205 const DetId& hit_detId =
hit->geographicalId();
206 unsigned int IntRawDetID = (hit_detId.
rawId());
207 unsigned int IntSubDetID = (hit_detId.
subdetId());
209 if (IntSubDetID == 0)
238 if (errHit.xx() < 0. || errHit.yy() < 0. || errTrk.
xx() < 0. || errTrk.
yy() < 0.) {
240 <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 241 <<
"One of the squared error methods gives negative result" 242 <<
"\n\terrHit.xx()\terrHit.yy()\terrTrk.xx()\terrTrk.yy()" 243 <<
"\n\t" << errHit.xx() <<
"\t" << errHit.yy() <<
"\t" << errTrk.
xx() <<
"\t" << errTrk.
yy();
249 float resXErr =
std::sqrt(errHit.xx() + errTrk.
xx());
250 float resYErr =
std::sqrt(errHit.yy() + errTrk.
yy());
264 float resXprime(999.
F), resYprime(999.
F);
265 float resXatTrkY(999.
F);
266 float resXprimeErr(999.
F), resYprimeErr(999.
F);
268 if (
hit->detUnit()) {
270 float uOrientation(-999.
F), vOrientation(-999.
F);
271 float resXTopol(999.
F), resYTopol(999.
F);
272 float resXatTrkYTopol(999.
F);
274 const Surface& surface =
hit->detUnit()->surface();
276 const Bounds& bound = boundplane.bounds();
281 LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.);
283 gVDirection = surface.
toGlobal(lVDirection);
287 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
288 vOrientation = gVDirection.z() - gPModule.
z() >= 0 ? +1.F : -1.F;
290 resXatTrkYTopol =
res.x();
292 resXprimeErr = resXErr;
293 resYprimeErr = resYErr;
296 if (rectangularBound !=
nullptr) {
298 length = rectangularBound->
length();
303 throw cms::Exception(
"Geometry Error") <<
"[TrackerValidationVariables] Cannot cast bounds to " 304 "RectangularPlaneBounds as expected for TPB, TIB and TOB";
308 uOrientation = gUDirection.perp() - gPModule.
perp() >= 0 ? +1.F : -1.F;
309 vOrientation =
deltaPhi(gVDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
311 resXatTrkYTopol =
res.x();
313 resXprimeErr = resXErr;
314 resYprimeErr = resYErr;
317 if (rectangularBound !=
nullptr) {
319 length = rectangularBound->
length();
325 <<
"[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
329 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
330 vOrientation = gVDirection.perp() - gPModule.
perp() >= 0. ? +1.F : -1.F;
332 if (!dynamic_cast<const RadialStripTopology*>(&detUnit.
type().
topology()))
342 if (measHitErr.
uu() < 0. || measHitErr.
vv() < 0. || measTrkErr.
uu() < 0. || measTrkErr.
vv() < 0.) {
344 <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 345 <<
"One of the squared error methods gives negative result" 346 <<
"\n\tmeasHitErr.uu()\tmeasHitErr.vv()\tmeasTrkErr.uu()\tmeasTrkErr.vv()" 347 <<
"\n\t" << measHitErr.
uu() <<
"\t" << measHitErr.
vv() <<
"\t" << measTrkErr.
uu() <<
"\t" 358 resXTopol = (phiTrk - phiHit) * r_0;
362 resXatTrkYTopol = lPTrk.
x() - LocalHitPosCor.
x();
365 float cosPhiHit(
cos(phiHit)), cosPhiTrk(
cos(phiTrk)), sinPhiHit(
sin(phiHit)), sinPhiTrk(
sin(phiTrk));
367 resYTopol = measTrkPos.
y() * localStripLengthTrk - measHitPos.
y() * localStripLengthHit +
368 l_0 * (1 / cosPhiTrk - 1 / cosPhiHit);
373 (sinPhiHit * sinPhiHit /
pow(cosPhiHit, 4) * measHitErr.
uu() +
374 sinPhiTrk * sinPhiTrk /
pow(cosPhiTrk, 4) * measTrkErr.
uu());
375 resYprimeErr =
std::sqrt(measHitErr.
vv() * localStripLengthHit * localStripLengthHit +
376 measTrkErr.
vv() * localStripLengthTrk * localStripLengthTrk + helpSummand);
379 if (trapezoidalBound !=
nullptr) {
380 hitStruct.
inside = trapezoidalBound->inside(lPTrk);
381 length = trapezoidalBound->length();
382 width = trapezoidalBound->width();
392 throw cms::Exception(
"Geometry Error") <<
"[TrackerValidationVariables] Cannot cast bounds to " 393 "TrapezoidalPlaneBounds as expected for TID and TEC";
397 edm::LogWarning(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 398 <<
"No valid tracker subdetector " << IntSubDetID;
402 resXprime = resXTopol * uOrientation;
403 resXatTrkY = resXatTrkYTopol;
404 resYprime = resYTopol * vOrientation;
423 v_avhitout.push_back(hitStruct);
429 std::vector<AVTrackStruct>& v_avtrackout) {
437 std::vector<AVTrackStruct>& v_avtrackout) {
444 auto const&
tracks = *tracksH;
445 auto ntrk =
tracks.size();
446 LogDebug(
"TrackerValidationVariables") <<
"Track collection size " << ntrk;
450 bool yesTraj = trajsH.
isValid();
451 std::vector<Trajectory>
const* trajs =
nullptr;
458 for (
unsigned int i = 0;
i < ntrk; ++
i) {
461 trajectory = &(*trajs)[
i];
468 trackStruct.
p =
track.p();
480 double theLocalMagFieldInInverseGeV =
magneticField.inInverseGeV(gPoint).z();
481 trackStruct.
kappa = -
track.charge() * theLocalMagFieldInInverseGeV /
track.pt();
492 v_avtrackout.push_back(trackStruct);
static constexpr auto TEC
LocalPoint localPosition(float strip) const override=0
const LocalTrajectoryError & localError() const
LocalPoint localPosition() const
Geom::Phi< T > phi() const
Sin< T >::type sin(const T &t)
std::vector< Track > TrackCollection
collection of Tracks
bool hasBadPixels() const
void fillHitQuantities(const Trajectory *trajectory, std::vector< AVHitStruct > &v_avhitout)
Log< level::Error, false > LogError
float length() const override
Lenght along local Y.
LocalError positionError() const
virtual const GeomDetType & type() const
virtual float detHeight() const =0
std::vector< AVHitStruct > hits
DataContainer const & measurements() const
MeasurementPoint measurementPosition(const LocalPoint &) const override=0
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
edm::EDGetTokenT< std::vector< Trajectory > > trajCollectionToken_
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Cos< T >::type cos(const T &t)
LocalVector localDirection() const
~TrackerValidationVariables()
static void fillPSetDescription(edm::ParameterSetDescription &descriptions)
virtual float angularWidth() const =0
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
float stripAngle(float strip) const override=0
static constexpr auto TOB
float localStripLength(const LocalPoint &) const override=0
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
TrackerValidationVariables(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
static constexpr auto TIB
void fillTrackQuantities(const edm::Event &, const edm::EventSetup &, std::vector< AVTrackStruct > &v_avtrackout)
constexpr uint32_t rawId() const
get the raw id
GlobalVector globalDirection() const
virtual float originToIntersection() const =0
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
virtual const Topology & topology() const =0
bool inside(const Local2DPoint &p) const override
MeasurementError measurementError(const LocalPoint &, const LocalError &) const override=0
float width() const override
Width along local X.
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< std::vector< reco::Track > > tracksToken_
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
static constexpr auto TID
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
Power< A, B >::type pow(const A &a, const B &b)