46 trajCollectionToken_ =
54 auto const& trajParams =
track.extra()->trajParams();
55 auto const& residuals =
track.extra()->residuals();
59 for (
unsigned int h = 0;
h <
track.recHitsSize();
h++) {
65 const DetId& hit_detId =
hit->geographicalId();
66 auto IntRawDetID = hit_detId.
rawId();
67 auto IntSubDetID = hit_detId.
subdetId();
81 auto lPTrk = trajParams[
h].position();
82 auto lVTrk = trajParams[
h].direction();
84 auto gtrkdirup =
hit->surface()->toGlobal(lVTrk);
87 hitStruct.
phi = gtrkdirup.phi();
88 hitStruct.
eta = gtrkdirup.eta();
90 hitStruct.
localAlpha = std::atan2(lVTrk.x(), lVTrk.z());
91 hitStruct.
localBeta = std::atan2(lVTrk.y(), lVTrk.z());
93 hitStruct.
resX = residuals.residualX(
h);
94 hitStruct.
resY = residuals.residualY(
h);
101 hitStruct.
localX = lPTrk.x();
102 hitStruct.
localY = lPTrk.y();
105 float resXprime(999.
F), resYprime(999.
F);
106 float resXatTrkY(999.
F);
107 float resXprimeErr(999.
F), resYprimeErr(999.
F);
109 if (
hit->detUnit()) {
110 float uOrientation(-999.
F), vOrientation(-999.
F);
111 float resXTopol(999.
F), resYTopol(999.
F);
112 float resXatTrkYTopol(999.
F);
114 const Surface& surface =
hit->detUnit()->surface();
116 const Bounds& bound = boundplane.bounds();
121 LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.);
123 gVDirection = surface.
toGlobal(lVDirection);
128 uOrientation = gUDirection.
perp() - gPModule.
perp() >= 0 ? +1.F : -1.F;
129 vOrientation =
deltaPhi(gVDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
131 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
132 vOrientation = gVDirection.z() - gPModule.
z() >= 0 ? +1.F : -1.F;
135 resXTopol = hitStruct.
resX;
136 resXatTrkYTopol = hitStruct.
resX;
137 resYTopol = hitStruct.
resY;
138 resXprimeErr = hitStruct.
resErrX;
139 resYprimeErr = hitStruct.
resErrY;
142 if (rectangularBound !=
nullptr) {
144 length = rectangularBound->
length();
150 <<
"[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
156 edm::LogWarning(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 157 <<
"No valid tracker subdetector " << IntSubDetID;
161 resXprime = resXTopol * uOrientation;
162 resXatTrkY = resXatTrkYTopol;
163 resYprime = resYTopol * vOrientation;
178 v_avhitout.push_back(hitStruct);
185 const std::vector<TrajectoryMeasurement>& tmColl = trajectory->
measurements();
186 for (std::vector<TrajectoryMeasurement>::const_iterator itTraj = tmColl.begin(); itTraj != tmColl.end(); ++itTraj) {
187 if (!itTraj->updatedState().isValid())
199 const DetId& hit_detId =
hit->geographicalId();
200 unsigned int IntRawDetID = (hit_detId.
rawId());
201 unsigned int IntSubDetID = (hit_detId.
subdetId());
203 if (IntSubDetID == 0)
232 if (errHit.xx() < 0. || errHit.yy() < 0. || errTrk.
xx() < 0. || errTrk.
yy() < 0.) {
234 <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 235 <<
"One of the squared error methods gives negative result" 236 <<
"\n\terrHit.xx()\terrHit.yy()\terrTrk.xx()\terrTrk.yy()" 237 <<
"\n\t" << errHit.xx() <<
"\t" << errHit.yy() <<
"\t" << errTrk.
xx() <<
"\t" << errTrk.
yy();
243 float resXErr =
std::sqrt(errHit.xx() + errTrk.
xx());
244 float resYErr =
std::sqrt(errHit.yy() + errTrk.
yy());
258 float resXprime(999.
F), resYprime(999.
F);
259 float resXatTrkY(999.
F);
260 float resXprimeErr(999.
F), resYprimeErr(999.
F);
262 if (
hit->detUnit()) {
264 float uOrientation(-999.
F), vOrientation(-999.
F);
265 float resXTopol(999.
F), resYTopol(999.
F);
266 float resXatTrkYTopol(999.
F);
268 const Surface& surface =
hit->detUnit()->surface();
270 const Bounds& bound = boundplane.bounds();
275 LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.);
277 gVDirection = surface.
toGlobal(lVDirection);
281 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
282 vOrientation = gVDirection.z() - gPModule.
z() >= 0 ? +1.F : -1.F;
284 resXatTrkYTopol =
res.x();
286 resXprimeErr = resXErr;
287 resYprimeErr = resYErr;
290 if (rectangularBound !=
nullptr) {
292 length = rectangularBound->
length();
297 throw cms::Exception(
"Geometry Error") <<
"[TrackerValidationVariables] Cannot cast bounds to " 298 "RectangularPlaneBounds as expected for TPB, TIB and TOB";
302 uOrientation = gUDirection.perp() - gPModule.
perp() >= 0 ? +1.F : -1.F;
303 vOrientation =
deltaPhi(gVDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
305 resXatTrkYTopol =
res.x();
307 resXprimeErr = resXErr;
308 resYprimeErr = resYErr;
311 if (rectangularBound !=
nullptr) {
313 length = rectangularBound->
length();
319 <<
"[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
323 uOrientation =
deltaPhi(gUDirection.barePhi(), gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
324 vOrientation = gVDirection.perp() - gPModule.
perp() >= 0. ? +1.F : -1.F;
326 if (!dynamic_cast<const RadialStripTopology*>(&detUnit.
type().
topology()))
336 if (measHitErr.
uu() < 0. || measHitErr.
vv() < 0. || measTrkErr.
uu() < 0. || measTrkErr.
vv() < 0.) {
338 <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 339 <<
"One of the squared error methods gives negative result" 340 <<
"\n\tmeasHitErr.uu()\tmeasHitErr.vv()\tmeasTrkErr.uu()\tmeasTrkErr.vv()" 341 <<
"\n\t" << measHitErr.
uu() <<
"\t" << measHitErr.
vv() <<
"\t" << measTrkErr.
uu() <<
"\t" 352 resXTopol = (phiTrk - phiHit) * r_0;
356 resXatTrkYTopol = lPTrk.
x() - LocalHitPosCor.
x();
359 float cosPhiHit(
cos(phiHit)), cosPhiTrk(
cos(phiTrk)), sinPhiHit(
sin(phiHit)), sinPhiTrk(
sin(phiTrk));
361 resYTopol = measTrkPos.
y() * localStripLengthTrk - measHitPos.
y() * localStripLengthHit +
362 l_0 * (1 / cosPhiTrk - 1 / cosPhiHit);
367 (sinPhiHit * sinPhiHit /
pow(cosPhiHit, 4) * measHitErr.
uu() +
368 sinPhiTrk * sinPhiTrk /
pow(cosPhiTrk, 4) * measTrkErr.
uu());
369 resYprimeErr =
std::sqrt(measHitErr.
vv() * localStripLengthHit * localStripLengthHit +
370 measTrkErr.
vv() * localStripLengthTrk * localStripLengthTrk + helpSummand);
373 if (trapezoidalBound !=
nullptr) {
374 hitStruct.
inside = trapezoidalBound->inside(lPTrk);
375 length = trapezoidalBound->length();
376 width = trapezoidalBound->width();
386 throw cms::Exception(
"Geometry Error") <<
"[TrackerValidationVariables] Cannot cast bounds to " 387 "TrapezoidalPlaneBounds as expected for TID and TEC";
391 edm::LogWarning(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 392 <<
"No valid tracker subdetector " << IntSubDetID;
396 resXprime = resXTopol * uOrientation;
397 resXatTrkY = resXatTrkYTopol;
398 resYprime = resYTopol * vOrientation;
417 v_avhitout.push_back(hitStruct);
423 std::vector<AVTrackStruct>& v_avtrackout) {
431 std::vector<AVTrackStruct>& v_avtrackout) {
438 auto const&
tracks = *tracksH;
439 auto ntrk =
tracks.size();
440 LogDebug(
"TrackerValidationVariables") <<
"Track collection size " << ntrk;
444 bool yesTraj = trajsH.
isValid();
445 std::vector<Trajectory>
const* trajs =
nullptr;
452 for (
unsigned int i = 0;
i < ntrk; ++
i) {
455 trajectory = &(*trajs)[
i];
462 trackStruct.
p =
track.p();
474 double theLocalMagFieldInInverseGeV =
magneticField.inInverseGeV(gPoint).z();
475 trackStruct.
kappa = -
track.charge() * theLocalMagFieldInInverseGeV /
track.pt();
486 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()
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)
auto const & tracks
cannot be loose
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
Power< A, B >::type pow(const A &a, const B &b)