48 trajCollectionToken_ =
56 auto const& trajParams =
track.extra()->trajParams();
57 auto const& residuals =
track.extra()->residuals();
61 for (
unsigned int h = 0;
h <
track.recHitsSize();
h++) {
67 const DetId& hit_detId =
hit->geographicalId();
68 auto IntRawDetID = hit_detId.
rawId();
69 auto IntSubDetID = hit_detId.
subdetId();
75 const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(
83 auto lPTrk = trajParams[
h].position();
84 auto lVTrk = trajParams[
h].direction();
86 auto gtrkdirup =
hit->surface()->toGlobal(lVTrk);
89 hitStruct.
phi = gtrkdirup.phi();
90 hitStruct.
eta = gtrkdirup.eta();
92 hitStruct.
localAlpha = std::atan2(lVTrk.x(), lVTrk.z());
93 hitStruct.
localBeta = std::atan2(lVTrk.y(), lVTrk.z());
95 hitStruct.
resX = residuals.residualX(
h);
96 hitStruct.
resY = residuals.residualY(
h);
103 hitStruct.
localX = lPTrk.x();
104 hitStruct.
localY = lPTrk.y();
107 float resXprime(999.
F), resYprime(999.
F);
108 float resXatTrkY(999.
F);
109 float resXprimeErr(999.
F), resYprimeErr(999.
F);
111 if (
hit->detUnit()) {
112 float uOrientation(-999.
F), vOrientation(-999.
F);
113 float resXTopol(999.
F), resYTopol(999.
F);
114 float resXatTrkYTopol(999.
F);
116 const Surface& surface =
hit->detUnit()->surface();
118 const Bounds& bound = boundplane.bounds();
123 LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.);
125 gVDirection = surface.
toGlobal(lVDirection);
130 uOrientation = gUDirection.
perp() - gPModule.
perp() >= 0 ? +1.F : -1.F;
131 vOrientation =
deltaPhi(gVDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
133 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
134 vOrientation = gVDirection.z() - gPModule.
z() >= 0 ? +1.F : -1.F;
137 resXTopol = hitStruct.
resX;
138 resXatTrkYTopol = hitStruct.
resX;
139 resYTopol = hitStruct.
resY;
140 resXprimeErr = hitStruct.
resErrX;
141 resYprimeErr = hitStruct.
resErrY;
144 if (rectangularBound !=
nullptr) {
146 length = rectangularBound->
length();
152 <<
"[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
158 edm::LogWarning(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities"
159 <<
"No valid tracker subdetector " << IntSubDetID;
163 resXprime = resXTopol * uOrientation;
164 resXatTrkY = resXatTrkYTopol;
165 resYprime = resYTopol * vOrientation;
180 v_avhitout.push_back(hitStruct);
187 const std::vector<TrajectoryMeasurement>& tmColl = trajectory->
measurements();
188 for (std::vector<TrajectoryMeasurement>::const_iterator itTraj = tmColl.begin(); itTraj != tmColl.end(); ++itTraj) {
189 if (!itTraj->updatedState().isValid())
201 const DetId& hit_detId =
hit->geographicalId();
202 unsigned int IntRawDetID = (hit_detId.
rawId());
203 unsigned int IntSubDetID = (hit_detId.
subdetId());
205 if (IntSubDetID == 0)
209 const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(
234 if (errHit.xx() < 0. || errHit.yy() < 0. || errTrk.
xx() < 0. || errTrk.
yy() < 0.) {
236 <<
"@SUB=TrackerValidationVariables::fillHitQuantities"
237 <<
"One of the squared error methods gives negative result"
238 <<
"\n\terrHit.xx()\terrHit.yy()\terrTrk.xx()\terrTrk.yy()"
239 <<
"\n\t" << errHit.xx() <<
"\t" << errHit.yy() <<
"\t" << errTrk.
xx() <<
"\t" << errTrk.
yy();
245 float resXErr =
std::sqrt(errHit.xx() + errTrk.
xx());
246 float resYErr =
std::sqrt(errHit.yy() + errTrk.
yy());
260 float resXprime(999.
F), resYprime(999.
F);
261 float resXatTrkY(999.
F);
262 float resXprimeErr(999.
F), resYprimeErr(999.
F);
264 if (
hit->detUnit()) {
266 float uOrientation(-999.
F), vOrientation(-999.
F);
267 float resXTopol(999.
F), resYTopol(999.
F);
268 float resXatTrkYTopol(999.
F);
270 const Surface& surface =
hit->detUnit()->surface();
272 const Bounds& bound = boundplane.bounds();
277 LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.);
279 gVDirection = surface.
toGlobal(lVDirection);
283 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
284 vOrientation = gVDirection.z() - gPModule.
z() >= 0 ? +1.F : -1.F;
286 resXatTrkYTopol =
res.x();
288 resXprimeErr = resXErr;
289 resYprimeErr = resYErr;
292 if (rectangularBound !=
nullptr) {
294 length = rectangularBound->
length();
299 throw cms::Exception(
"Geometry Error") <<
"[TrackerValidationVariables] Cannot cast bounds to "
300 "RectangularPlaneBounds as expected for TPB, TIB and TOB";
304 uOrientation = gUDirection.perp() - gPModule.
perp() >= 0 ? +1.F : -1.F;
305 vOrientation =
deltaPhi(gVDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
307 resXatTrkYTopol =
res.x();
309 resXprimeErr = resXErr;
310 resYprimeErr = resYErr;
313 if (rectangularBound !=
nullptr) {
315 length = rectangularBound->
length();
321 <<
"[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
325 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
326 vOrientation = gVDirection.perp() - gPModule.
perp() >= 0. ? +1.F : -1.F;
328 if (!dynamic_cast<const RadialStripTopology*>(&detUnit.
type().
topology()))
338 if (measHitErr.
uu() < 0. || measHitErr.
vv() < 0. || measTrkErr.
uu() < 0. || measTrkErr.
vv() < 0.) {
340 <<
"@SUB=TrackerValidationVariables::fillHitQuantities"
341 <<
"One of the squared error methods gives negative result"
342 <<
"\n\tmeasHitErr.uu()\tmeasHitErr.vv()\tmeasTrkErr.uu()\tmeasTrkErr.vv()"
343 <<
"\n\t" << measHitErr.
uu() <<
"\t" << measHitErr.
vv() <<
"\t" << measTrkErr.
uu() <<
"\t"
350 float phiHit = topol.
stripAngle(measHitPos.x());
354 resXTopol = (phiTrk - phiHit) * r_0;
358 resXatTrkYTopol = lPTrk.
x() - LocalHitPosCor.
x();
361 float cosPhiHit(
cos(phiHit)), cosPhiTrk(
cos(phiTrk)), sinPhiHit(
sin(phiHit)), sinPhiTrk(
sin(phiTrk));
363 resYTopol = measTrkPos.
y() * localStripLengthTrk - measHitPos.y() * localStripLengthHit +
364 l_0 * (1 / cosPhiTrk - 1 / cosPhiHit);
369 (sinPhiHit * sinPhiHit /
pow(cosPhiHit, 4) * measHitErr.
uu() +
370 sinPhiTrk * sinPhiTrk /
pow(cosPhiTrk, 4) * measTrkErr.
uu());
371 resYprimeErr =
std::sqrt(measHitErr.
vv() * localStripLengthHit * localStripLengthHit +
372 measTrkErr.
vv() * localStripLengthTrk * localStripLengthTrk + helpSummand);
375 if (trapezoidalBound !=
nullptr) {
376 hitStruct.
inside = trapezoidalBound->inside(lPTrk);
377 length = trapezoidalBound->length();
378 width = trapezoidalBound->width();
388 throw cms::Exception(
"Geometry Error") <<
"[TrackerValidationVariables] Cannot cast bounds to "
389 "TrapezoidalPlaneBounds as expected for TID and TEC";
393 edm::LogWarning(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities"
394 <<
"No valid tracker subdetector " << IntSubDetID;
398 resXprime = resXTopol * uOrientation;
399 resXatTrkY = resXatTrkYTopol;
400 resYprime = resYTopol * vOrientation;
419 v_avhitout.push_back(hitStruct);
425 std::vector<AVTrackStruct>& v_avtrackout) {
427 event, eventSetup, [](
const reco::Track&) ->
bool {
return true; }, v_avtrackout);
433 std::vector<AVTrackStruct>& v_avtrackout) {
440 auto const&
tracks = *tracksH;
441 auto ntrk =
tracks.size();
442 LogDebug(
"TrackerValidationVariables") <<
"Track collection size " << ntrk;
446 bool yesTraj = trajsH.
isValid();
447 std::vector<Trajectory>
const* trajs =
nullptr;
454 for (
unsigned int i = 0;
i < ntrk; ++
i) {
457 trajectory = &(*trajs)[
i];
464 trackStruct.
p =
track.p();
476 double theLocalMagFieldInInverseGeV =
magneticField.inInverseGeV(gPoint).z();
477 trackStruct.
kappa = -
track.charge() * theLocalMagFieldInInverseGeV /
track.pt();
488 v_avtrackout.push_back(trackStruct);