68 auto const & trajParams = track.
extra()->trajParams();
69 auto const & residuals = track.
extra()->residuals();
75 if(!
hit->isValid())
continue;
78 const DetId & hit_detId =
hit->geographicalId();
79 auto IntRawDetID = hit_detId.
rawId();
80 auto IntSubDetID = hit_detId.
subdetId();
82 if(IntSubDetID == 0)
continue;
90 auto lPTrk = trajParams[
h].position();
91 auto lVTrk = trajParams[
h].direction();
93 auto gtrkdirup=
hit->surface()->toGlobal(lVTrk);
96 hitStruct.
phi = gtrkdirup.phi();
97 hitStruct.
eta = gtrkdirup.eta();
100 hitStruct.
localAlpha = std::atan2(lVTrk.x(), lVTrk.z());
101 hitStruct.
localBeta = std::atan2(lVTrk.y(), lVTrk.z());
103 hitStruct.
resX = residuals.residualX(
h);
104 hitStruct.
resY = residuals.residualY(
h);
111 hitStruct.
localX = lPTrk.x();
112 hitStruct.
localY = lPTrk.y();
115 float resXprime(999.
F), resYprime(999.
F);
116 float resXatTrkY(999.
F);
117 float resXprimeErr(999.
F), resYprimeErr(999.
F);
120 float uOrientation(-999.
F), vOrientation(-999.
F);
121 float resXTopol(999.
F), resYTopol(999.
F);
122 float resXatTrkYTopol(999.
F);
124 const Surface& surface =
hit->detUnit()->surface();
126 const Bounds& bound = boundplane.bounds();
131 LocalPoint lPModule(0.,0.,0.), lUDirection(1.,0.,0.), lVDirection(0.,1.,0.);
133 gUDirection = surface.
toGlobal(lUDirection),
134 gVDirection = surface.
toGlobal(lVDirection);
142 uOrientation = gUDirection.
perp() - gPModule.
perp() >= 0 ? +1.F : -1.F;
143 vOrientation =
deltaPhi(gVDirection.barePhi(),gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
145 uOrientation =
deltaPhi(gUDirection.barePhi(),gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
146 vOrientation = gVDirection.z() - gPModule.
z() >= 0 ? +1.F : -1.F;
149 resXTopol = hitStruct.
resX;
150 resXatTrkYTopol = hitStruct.
resX;
151 resYTopol = hitStruct.
resY;
152 resXprimeErr = hitStruct.
resErrX;
153 resYprimeErr = hitStruct.
resErrY;
156 if (rectangularBound!=
nullptr) {
158 length = rectangularBound->
length();
159 width = rectangularBound->
width();
164 <<
"[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
171 edm::LogWarning(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 172 <<
"No valid tracker subdetector " << IntSubDetID;
176 resXprime = resXTopol*uOrientation;
177 resXatTrkY = resXatTrkYTopol;
178 resYprime = resYTopol*vOrientation;
194 v_avhitout.push_back(hitStruct);
205 const std::vector<TrajectoryMeasurement> &tmColl = trajectory->
measurements();
206 for(std::vector<TrajectoryMeasurement>::const_iterator itTraj = tmColl.begin();
207 itTraj != tmColl.end();
210 if (!itTraj->updatedState().isValid())
continue;
216 if(!hit->isValid() || hit->geographicalId().det() !=
DetId::Tracker)
continue;
219 const DetId& hit_detId = hit->geographicalId();
220 unsigned int IntRawDetID = (hit_detId.
rawId());
221 unsigned int IntSubDetID = (hit_detId.
subdetId());
223 if(IntSubDetID == 0)
continue;
240 LocalError errHit = hit->localPositionError();
248 if(errHit.xx()<0. || errHit.yy()<0. || errTrk.
xx()<0. || errTrk.
yy()<0.){
249 edm::LogError(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 250 <<
"One of the squared error methods gives negative result" 251 <<
"\n\terrHit.xx()\terrHit.yy()\terrTrk.xx()\terrTrk.yy()" 252 <<
"\n\t" << errHit.xx()
253 <<
"\t" << errHit.yy()
254 <<
"\t" << errTrk.
xx()
255 <<
"\t" << errTrk.
yy();
261 float resXErr =
std::sqrt( errHit.xx() + errTrk.
xx() );
262 float resYErr =
std::sqrt( errHit.yy() + errTrk.
yy() );
264 hitStruct.
resX = res.
x();
265 hitStruct.
resY = res.
y();
276 float resXprime(999.
F), resYprime(999.
F);
277 float resXatTrkY(999.
F);
278 float resXprimeErr(999.
F), resYprimeErr(999.
F);
282 float uOrientation(-999.
F), vOrientation(-999.
F);
283 float resXTopol(999.
F), resYTopol(999.
F);
284 float resXatTrkYTopol(999.
F);
286 const Surface& surface = hit->detUnit()->surface();
287 const BoundPlane& boundplane = hit->detUnit()->surface();
288 const Bounds& bound = boundplane.bounds();
293 LocalPoint lPModule(0.,0.,0.), lUDirection(1.,0.,0.), lVDirection(0.,1.,0.);
295 gUDirection = surface.
toGlobal(lUDirection),
296 gVDirection = surface.
toGlobal(lVDirection);
302 uOrientation =
deltaPhi(gUDirection.barePhi(),gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
303 vOrientation = gVDirection.z() - gPModule.
z() >= 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 TPB, TIB and TOB";
324 uOrientation = gUDirection.perp() - gPModule.
perp() >= 0 ? +1.F : -1.F;
325 vOrientation =
deltaPhi(gVDirection.barePhi(),gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
327 resXatTrkYTopol = res.
x();
329 resXprimeErr = resXErr;
330 resYprimeErr = resYErr;
333 if (rectangularBound!=
nullptr) {
335 length = rectangularBound->
length();
336 width = rectangularBound->
width();
341 <<
"[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
347 uOrientation =
deltaPhi(gUDirection.barePhi(),gPModule.
barePhi()) >= 0. ? +1.
F : -1.
F;
348 vOrientation = gVDirection.perp() - gPModule.
perp() >= 0. ? +1.F : -1.F;
350 if (!dynamic_cast<const RadialStripTopology*>(&detUnit.
type().
topology()))
continue;
359 if (measHitErr.
uu()<0. ||
360 measHitErr.
vv()<0. ||
361 measTrkErr.
uu()<0. ||
363 edm::LogError(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 364 <<
"One of the squared error methods gives negative result" 365 <<
"\n\tmeasHitErr.uu()\tmeasHitErr.vv()\tmeasTrkErr.uu()\tmeasTrkErr.vv()" 366 <<
"\n\t" << measHitErr.
uu()
367 <<
"\t" << measHitErr.
vv()
368 <<
"\t" << measTrkErr.
uu()
369 <<
"\t" << measTrkErr.
vv();
379 resXTopol = (phiTrk-phiHit)*r_0;
383 resXatTrkYTopol = lPTrk.
x() - LocalHitPosCor.
x();
387 float cosPhiHit(
cos(phiHit)), cosPhiTrk(
cos(phiTrk)),
388 sinPhiHit(
sin(phiHit)), sinPhiTrk(
sin(phiTrk));
390 resYTopol = measTrkPos.
y()*localStripLengthTrk - measHitPos.
y()*localStripLengthHit + l_0*(1/cosPhiTrk - 1/cosPhiHit);
395 + sinPhiTrk*sinPhiTrk/
pow(cosPhiTrk,4)*measTrkErr.
uu() );
396 resYprimeErr =
std::sqrt(measHitErr.
vv()*localStripLengthHit*localStripLengthHit
397 + measTrkErr.
vv()*localStripLengthTrk*localStripLengthTrk + helpSummand );
401 if (trapezoidalBound!=
nullptr) {
402 hitStruct.
inside = trapezoidalBound->inside(lPTrk);
403 length = trapezoidalBound->length();
404 width = trapezoidalBound->width();
415 <<
"[TrackerValidationVariables] Cannot cast bounds to TrapezoidalPlaneBounds as expected for TID and TEC";
419 edm::LogWarning(
"TrackerValidationVariables") <<
"@SUB=TrackerValidationVariables::fillHitQuantities" 420 <<
"No valid tracker subdetector " << IntSubDetID;
424 resXprime = resXTopol*uOrientation;
425 resXatTrkY = resXatTrkYTopol;
426 resYprime = resYTopol*vOrientation;
445 v_avhitout.push_back(hitStruct);
452 std::vector<AVTrackStruct> & v_avtrackout)
464 std::vector<AVTrackStruct> & v_avtrackout)
472 auto const &
tracks = *tracksH;
473 auto ntrk =
tracks.size();
474 LogDebug(
"TrackerValidationVariables") <<
"Track collection size " << ntrk;
479 bool yesTraj = trajsH.
isValid();
480 std::vector<Trajectory>
const * trajs =
nullptr;
481 if (yesTraj) trajs = &(*trajsH);
482 if (yesTraj) assert (trajs->size()==
tracks.size());
485 for (
unsigned int i=0;
i<ntrk; ++
i) {
487 if (yesTraj) trajectory = &(*trajs)[
i];
489 if (!trackFilter(
track))
continue;
493 trackStruct.
p =
track.p();
505 double theLocalMagFieldInInverseGeV = magneticField->
inInverseGeV(gPoint).
z();
506 trackStruct.
kappa = -
track.charge()*theLocalMagFieldInInverseGeV/
track.pt();
516 v_avtrackout.push_back(trackStruct);
TrackerValidationVariables()
virtual const Topology & topology() const =0
float width() const override
Width along local X.
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
virtual float angularWidth() const =0
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const TrackExtraRef & extra() const
reference to "extra" object
virtual const GeomDetType & type() const
virtual float originToIntersection() const =0
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
void fillHitQuantities(const Trajectory *trajectory, std::vector< AVHitStruct > &v_avhitout)
std::vector< AVHitStruct > hits
LocalError positionError() const
bool hasBadPixels() const
LocalPoint localPosition(float strip) const override=0
float localStripLength(const LocalPoint &) const override=0
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
float stripAngle(float strip) const override=0
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) ...
const LocalTrajectoryError & localError() const
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
MeasurementError measurementError(const LocalPoint &, const LocalError &) const override=0
float length() const override
Lenght along local Y.
virtual float detHeight() const =0
MeasurementPoint measurementPosition(const LocalPoint &) const override=0
void fillTrackQuantities(const edm::Event &, const edm::EventSetup &, std::vector< AVTrackStruct > &v_avtrackout)
bool inside(const Local2DPoint &p) const override
edm::EDGetTokenT< std::vector< reco::Track > > tracksToken_
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Power< A, B >::type pow(const A &a, const B &b)
GlobalVector globalDirection() const