47 trajCollectionToken_ =
55 auto const& trajParams =
track.extra()->trajParams();
56 auto const& residuals =
track.extra()->residuals();
60 for (
unsigned int h = 0;
h <
track.recHitsSize();
h++) {
66 const DetId& hit_detId =
hit->geographicalId();
67 auto IntRawDetID = hit_detId.
rawId();
68 auto IntSubDetID = hit_detId.
subdetId();
74 const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(
82 auto lPTrk = trajParams[
h].position();
83 auto lVTrk = trajParams[
h].direction();
85 auto gtrkdirup =
hit->surface()->toGlobal(lVTrk);
88 hitStruct.
phi = gtrkdirup.phi();
89 hitStruct.
eta = gtrkdirup.eta();
91 hitStruct.
localAlpha = std::atan2(lVTrk.x(), lVTrk.z());
92 hitStruct.
localBeta = std::atan2(lVTrk.y(), lVTrk.z());
94 hitStruct.
resX = residuals.residualX(
h);
95 hitStruct.
resY = residuals.residualY(
h);
102 hitStruct.
localX = lPTrk.x();
103 hitStruct.
localY = lPTrk.y();
106 float resXprime(999.
F), resYprime(999.
F);
107 float resXatTrkY(999.
F);
108 float resXprimeErr(999.
F), resYprimeErr(999.
F);
110 if (
hit->detUnit()) {
111 float uOrientation(-999.
F), vOrientation(-999.
F);
112 float resXTopol(999.
F), resYTopol(999.
F);
113 float resXatTrkYTopol(999.
F);
115 const Surface& surface =
hit->detUnit()->surface();
117 const Bounds& bound = boundplane.bounds();
122 LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.);
124 gVDirection = surface.
toGlobal(lVDirection);
129 uOrientation = gUDirection.
perp() - gPModule.
perp() >= 0 ? +1.F : -1.F;
130 vOrientation =
deltaPhi(gVDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
132 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
133 vOrientation = gVDirection.z() - gPModule.
z() >= 0 ? +1.F : -1.F;
136 resXTopol = hitStruct.
resX;
137 resXatTrkYTopol = hitStruct.
resX;
138 resYTopol = hitStruct.
resY;
139 resXprimeErr = hitStruct.
resErrX;
140 resYprimeErr = hitStruct.
resErrY;
143 if (rectangularBound !=
nullptr) {
145 length = rectangularBound->
length();
151 <<
"[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
157 edm::LogWarning(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities"
158 <<
"No valid tracker subdetector " << IntSubDetID;
162 resXprime = resXTopol * uOrientation;
163 resXatTrkY = resXatTrkYTopol;
164 resYprime = resYTopol * vOrientation;
179 v_avhitout.push_back(hitStruct);
186 const std::vector<TrajectoryMeasurement>& tmColl = trajectory->
measurements();
187 for (std::vector<TrajectoryMeasurement>::const_iterator itTraj = tmColl.begin(); itTraj != tmColl.end(); ++itTraj) {
188 if (!itTraj->updatedState().isValid())
200 const DetId& hit_detId =
hit->geographicalId();
201 unsigned int IntRawDetID = (hit_detId.
rawId());
202 unsigned int IntSubDetID = (hit_detId.
subdetId());
204 if (IntSubDetID == 0)
208 const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(
233 if (errHit.xx() < 0. || errHit.yy() < 0. || errTrk.
xx() < 0. || errTrk.
yy() < 0.) {
235 <<
"@SUB=TrackerValidationVariables::fillHitQuantities"
236 <<
"One of the squared error methods gives negative result"
237 <<
"\n\terrHit.xx()\terrHit.yy()\terrTrk.xx()\terrTrk.yy()"
238 <<
"\n\t" << errHit.xx() <<
"\t" << errHit.yy() <<
"\t" << errTrk.
xx() <<
"\t" << errTrk.
yy();
244 float resXErr =
std::sqrt(errHit.xx() + errTrk.
xx());
245 float resYErr =
std::sqrt(errHit.yy() + errTrk.
yy());
259 float resXprime(999.
F), resYprime(999.
F);
260 float resXatTrkY(999.
F);
261 float resXprimeErr(999.
F), resYprimeErr(999.
F);
263 if (
hit->detUnit()) {
265 float uOrientation(-999.
F), vOrientation(-999.
F);
266 float resXTopol(999.
F), resYTopol(999.
F);
267 float resXatTrkYTopol(999.
F);
269 const Surface& surface =
hit->detUnit()->surface();
271 const Bounds& bound = boundplane.bounds();
276 LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.);
278 gVDirection = surface.
toGlobal(lVDirection);
282 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
283 vOrientation = gVDirection.z() - gPModule.
z() >= 0 ? +1.F : -1.F;
285 resXatTrkYTopol =
res.x();
287 resXprimeErr = resXErr;
288 resYprimeErr = resYErr;
291 if (rectangularBound !=
nullptr) {
293 length = rectangularBound->
length();
298 throw cms::Exception(
"Geometry Error") <<
"[TrackerValidationVariables] Cannot cast bounds to "
299 "RectangularPlaneBounds as expected for TPB, TIB and TOB";
303 uOrientation = gUDirection.perp() - gPModule.
perp() >= 0 ? +1.F : -1.F;
304 vOrientation =
deltaPhi(gVDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
306 resXatTrkYTopol =
res.x();
308 resXprimeErr = resXErr;
309 resYprimeErr = resYErr;
312 if (rectangularBound !=
nullptr) {
314 length = rectangularBound->
length();
320 <<
"[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
324 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
325 vOrientation = gVDirection.perp() - gPModule.
perp() >= 0. ? +1.F : -1.F;
327 if (!dynamic_cast<const RadialStripTopology*>(&detUnit.
type().
topology()))
337 if (measHitErr.
uu() < 0. || measHitErr.
vv() < 0. || measTrkErr.
uu() < 0. || measTrkErr.
vv() < 0.) {
339 <<
"@SUB=TrackerValidationVariables::fillHitQuantities"
340 <<
"One of the squared error methods gives negative result"
341 <<
"\n\tmeasHitErr.uu()\tmeasHitErr.vv()\tmeasTrkErr.uu()\tmeasTrkErr.vv()"
342 <<
"\n\t" << measHitErr.
uu() <<
"\t" << measHitErr.
vv() <<
"\t" << measTrkErr.
uu() <<
"\t"
349 float phiHit = topol.
stripAngle(measHitPos.x());
353 resXTopol = (phiTrk - phiHit) * r_0;
357 resXatTrkYTopol = lPTrk.
x() - LocalHitPosCor.
x();
360 float cosPhiHit(
cos(phiHit)), cosPhiTrk(
cos(phiTrk)), sinPhiHit(
sin(phiHit)), sinPhiTrk(
sin(phiTrk));
362 resYTopol = measTrkPos.
y() * localStripLengthTrk - measHitPos.y() * localStripLengthHit +
363 l_0 * (1 / cosPhiTrk - 1 / cosPhiHit);
368 (sinPhiHit * sinPhiHit /
pow(cosPhiHit, 4) * measHitErr.
uu() +
369 sinPhiTrk * sinPhiTrk /
pow(cosPhiTrk, 4) * measTrkErr.
uu());
370 resYprimeErr =
std::sqrt(measHitErr.
vv() * localStripLengthHit * localStripLengthHit +
371 measTrkErr.
vv() * localStripLengthTrk * localStripLengthTrk + helpSummand);
374 if (trapezoidalBound !=
nullptr) {
375 hitStruct.
inside = trapezoidalBound->inside(lPTrk);
376 length = trapezoidalBound->length();
377 width = trapezoidalBound->width();
387 throw cms::Exception(
"Geometry Error") <<
"[TrackerValidationVariables] Cannot cast bounds to "
388 "TrapezoidalPlaneBounds as expected for TID and TEC";
392 edm::LogWarning(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities"
393 <<
"No valid tracker subdetector " << IntSubDetID;
397 resXprime = resXTopol * uOrientation;
398 resXatTrkY = resXatTrkYTopol;
399 resYprime = resYTopol * vOrientation;
418 v_avhitout.push_back(hitStruct);
424 std::vector<AVTrackStruct>& v_avtrackout) {
426 event, eventSetup, [](
const reco::Track&) ->
bool {
return true; }, v_avtrackout);
432 std::vector<AVTrackStruct>& v_avtrackout) {
439 auto const&
tracks = *tracksH;
440 auto ntrk =
tracks.size();
441 LogDebug(
"TrackerValidationVariables") <<
"Track collection size " << ntrk;
445 bool yesTraj = trajsH.
isValid();
446 std::vector<Trajectory>
const* trajs =
nullptr;
453 for (
unsigned int i = 0;
i < ntrk; ++
i) {
456 trajectory = &(*trajs)[
i];
463 trackStruct.
p =
track.p();
475 double theLocalMagFieldInInverseGeV =
magneticField.inInverseGeV(gPoint).z();
476 trackStruct.
kappa = -
track.charge() * theLocalMagFieldInInverseGeV /
track.pt();
487 v_avtrackout.push_back(trackStruct);