54 auto const& trajParams = track.
extra()->trajParams();
55 auto const& residuals = track.
extra()->residuals();
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();
145 width = rectangularBound->
width();
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())
195 if (!hit->isValid() || hit->geographicalId().det() !=
DetId::Tracker)
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)
224 LocalError errHit = hit->localPositionError();
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());
246 hitStruct.
resX = res.
x();
247 hitStruct.
resY = res.
y();
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();
269 const BoundPlane& boundplane = 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();
293 width = rectangularBound->
width();
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();
314 width = rectangularBound->
width();
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) {
425 event, eventSetup, [](
const reco::Track&) ->
bool {
return true; }, 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);
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
static constexpr auto TEC
LocalPoint localPosition(float strip) const override=0
const TrackExtraRef & extra() const
reference to "extra" object
virtual const GeomDetType & type() const
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
LocalVector localDirection() const
LocalPoint localPosition() const
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
constexpr uint32_t rawId() const
get the raw id
std::vector< Track > TrackCollection
collection of Tracks
auto const & tracks
cannot be loose
void fillHitQuantities(const Trajectory *trajectory, std::vector< AVHitStruct > &v_avhitout)
Log< level::Error, false > LogError
float length() const override
Lenght along local Y.
virtual float detHeight() const =0
std::vector< AVHitStruct > hits
LocalError positionError() const
bool hasBadPixels() const
MeasurementPoint measurementPosition(const LocalPoint &) const override=0
bool getData(T &iHolder) const
DataContainer const & measurements() const
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
edm::EDGetTokenT< std::vector< Trajectory > > trajCollectionToken_
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
if(conf_.getParameter< bool >("UseStripCablingDB"))
Cos< T >::type cos(const T &t)
~TrackerValidationVariables()
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
virtual float angularWidth() const =0
float stripAngle(float strip) const override=0
const LocalTrajectoryError & localError() const
static constexpr auto TOB
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
float localStripLength(const LocalPoint &) const override=0
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)
T getParameter(std::string const &) const
virtual float originToIntersection() const =0
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
virtual const Topology & topology() const =0
tuple config
parse the configuration file
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)
GlobalVector globalDirection() const