CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Attributes
TrackerValidationVariables Class Reference

#include <TrackerValidationVariables.h>

Classes

struct  AVHitStruct
 
struct  AVTrackStruct
 

Public Member Functions

void fillHitQuantities (const Trajectory *trajectory, std::vector< AVHitStruct > &v_avhitout)
 
void fillHitQuantities (reco::Track const &track, std::vector< AVHitStruct > &v_avhitout)
 
void fillTrackQuantities (const edm::Event &, const edm::EventSetup &, std::vector< AVTrackStruct > &v_avtrackout)
 
void fillTrackQuantities (const edm::Event &event, const edm::EventSetup &eventSetup, std::function< bool(const reco::Track &)> trackFilter, std::vector< AVTrackStruct > &v_avtrackout)
 
 TrackerValidationVariables (const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
 
 ~TrackerValidationVariables ()
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &descriptions)
 

Private Attributes

edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldToken_
 
edm::EDGetTokenT< std::vector< reco::Track > > tracksToken_
 
edm::EDGetTokenT< std::vector< Trajectory > > trajCollectionToken_
 

Detailed Description

Definition at line 23 of file TrackerValidationVariables.h.

Constructor & Destructor Documentation

◆ TrackerValidationVariables()

TrackerValidationVariables::TrackerValidationVariables ( const edm::ParameterSet config,
edm::ConsumesCollector &&  iC 
)

Definition at line 44 of file TrackerValidationVariables.cc.

References SiStripFineDelayHit_cfi::MagneticField.

47  iC.consumes<std::vector<Trajectory>>(edm::InputTag(config.getParameter<std::string>("trajectoryInput")));
48  tracksToken_ = iC.consumes<reco::TrackCollection>(config.getParameter<edm::InputTag>("Tracks"));
49 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
Definition: config.py:1
edm::EDGetTokenT< std::vector< Trajectory > > trajCollectionToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
edm::EDGetTokenT< std::vector< reco::Track > > tracksToken_

◆ ~TrackerValidationVariables()

TrackerValidationVariables::~TrackerValidationVariables ( )
default

Member Function Documentation

◆ fillHitQuantities() [1/2]

void TrackerValidationVariables::fillHitQuantities ( const Trajectory trajectory,
std::vector< AVHitStruct > &  v_avhitout 
)

Definition at line 188 of file TrackerValidationVariables.cc.

References RadialStripTopology::angularWidth(), PV3DBase< T, PVType, FrameType >::barePhi(), funct::cos(), SiPixelRawToDigiRegional_cfi::deltaPhi, RadialStripTopology::detHeight(), TrackerValidationVariables::AVHitStruct::eta, PV3DBase< T, PVType, FrameType >::eta(), Exception, F(), TrajectoryStateOnSurface::globalDirection(), SiPixelRecHit::hasBadPixels(), ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), RectangularPlaneBounds::inside(), TrackerValidationVariables::AVHitStruct::inside, SiPixelRecHit::isOnEdge(), TrackerValidationVariables::AVHitStruct::isOnEdgePixel, TrackerValidationVariables::AVHitStruct::isOtherBadPixel, TrajectoryStateOnSurface::isValid(), RectangularPlaneBounds::length(), TrackerValidationVariables::AVHitStruct::localAlpha, TrackerValidationVariables::AVHitStruct::localBeta, TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localError(), RadialStripTopology::localPosition(), TrajectoryStateOnSurface::localPosition(), RadialStripTopology::localStripLength(), TrackerValidationVariables::AVHitStruct::localX, TrackerValidationVariables::AVHitStruct::localXnorm, TrackerValidationVariables::AVHitStruct::localY, TrackerValidationVariables::AVHitStruct::localYnorm, RadialStripTopology::measurementError(), RadialStripTopology::measurementPosition(), Trajectory::measurements(), RadialStripTopology::originToIntersection(), PV3DBase< T, PVType, FrameType >::perp(), TrackerValidationVariables::AVHitStruct::phi, PV3DBase< T, PVType, FrameType >::phi(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, LocalTrajectoryError::positionError(), funct::pow(), TrackerValidationVariables::AVHitStruct::rawDetId, DetId::rawId(), TrackerValidationVariables::AVHitStruct::resErrX, TrackerValidationVariables::AVHitStruct::resErrY, TrackerValidationVariables::AVHitStruct::resX, TrackerValidationVariables::AVHitStruct::resXatTrkY, TrackerValidationVariables::AVHitStruct::resXprime, TrackerValidationVariables::AVHitStruct::resXprimeErr, TrackerValidationVariables::AVHitStruct::resY, TrackerValidationVariables::AVHitStruct::resYprime, TrackerValidationVariables::AVHitStruct::resYprimeErr, funct::sin(), mathSSE::sqrt(), RadialStripTopology::stripAngle(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, Surface::toGlobal(), GeomDetType::topology(), DetId::Tracker, GeomDet::type(), MeasurementError::uu(), MeasurementError::vv(), RectangularPlaneBounds::width(), ApeEstimator_cff::width, PV2DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), PV2DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::y(), LocalError::yy(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by fillTrackQuantities().

188  {
189  TrajectoryStateCombiner tsoscomb;
190 
191  const std::vector<TrajectoryMeasurement>& tmColl = trajectory->measurements();
192  for (std::vector<TrajectoryMeasurement>::const_iterator itTraj = tmColl.begin(); itTraj != tmColl.end(); ++itTraj) {
193  if (!itTraj->updatedState().isValid())
194  continue;
195 
196  TrajectoryStateOnSurface tsos = tsoscomb(itTraj->forwardPredictedState(), itTraj->backwardPredictedState());
197  if (!tsos.isValid())
198  continue;
200 
201  if (!hit->isValid() || hit->geographicalId().det() != DetId::Tracker)
202  continue;
203 
204  AVHitStruct hitStruct;
205  const DetId& hit_detId = hit->geographicalId();
206  unsigned int IntRawDetID = (hit_detId.rawId());
207  unsigned int IntSubDetID = (hit_detId.subdetId());
208 
209  if (IntSubDetID == 0)
210  continue;
211 
212  if (IntSubDetID == PixelSubdetector::PixelBarrel || IntSubDetID == PixelSubdetector::PixelEndcap) {
213  const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(
214  hit.get()); //to be used to get the associated cluster and the cluster probability
215  if (prechit->isOnEdge())
216  hitStruct.isOnEdgePixel = true;
217  if (prechit->hasBadPixels())
218  hitStruct.isOtherBadPixel = true;
219  }
220 
221  //first calculate residuals in cartesian coordinates in the local module coordinate system
222 
223  LocalPoint lPHit = hit->localPosition();
224  LocalPoint lPTrk = tsos.localPosition();
225  LocalVector lVTrk = tsos.localDirection();
226 
227  hitStruct.localAlpha = atan2(lVTrk.x(), lVTrk.z()); // wrt. normal tg(alpha)=x/z
228  hitStruct.localBeta = atan2(lVTrk.y(), lVTrk.z()); // wrt. normal tg(beta)= y/z
229 
230  LocalError errHit = hit->localPositionError();
231  // no need to add APE to hitError anymore
232  // AlgebraicROOTObject<2>::SymMatrix mat = asSMatrix<2>(hit->parametersError());
233  // LocalError errHit = LocalError( mat(0,0),mat(0,1),mat(1,1) );
234  LocalError errTrk = tsos.localError().positionError();
235 
236  //check for negative error values: track error can have negative value, if matrix inversion fails (very rare case)
237  //hit error should always give positive values
238  if (errHit.xx() < 0. || errHit.yy() < 0. || errTrk.xx() < 0. || errTrk.yy() < 0.) {
239  edm::LogError("TrackerValidationVariables")
240  << "@SUB=TrackerValidationVariables::fillHitQuantities"
241  << "One of the squared error methods gives negative result"
242  << "\n\terrHit.xx()\terrHit.yy()\terrTrk.xx()\terrTrk.yy()"
243  << "\n\t" << errHit.xx() << "\t" << errHit.yy() << "\t" << errTrk.xx() << "\t" << errTrk.yy();
244  continue;
245  }
246 
247  align::LocalVector res = lPTrk - lPHit;
248 
249  float resXErr = std::sqrt(errHit.xx() + errTrk.xx());
250  float resYErr = std::sqrt(errHit.yy() + errTrk.yy());
251 
252  hitStruct.resX = res.x();
253  hitStruct.resY = res.y();
254  hitStruct.resErrX = resXErr;
255  hitStruct.resErrY = resYErr;
256 
257  // hitStruct.localX = lPhit.x();
258  // hitStruct.localY = lPhit.y();
259  // EM: use predictions for local coordinates
260  hitStruct.localX = lPTrk.x();
261  hitStruct.localY = lPTrk.y();
262 
263  // now calculate residuals taking global orientation of modules and radial topology in TID/TEC into account
264  float resXprime(999.F), resYprime(999.F);
265  float resXatTrkY(999.F);
266  float resXprimeErr(999.F), resYprimeErr(999.F);
267 
268  if (hit->detUnit()) { // is it a single physical module?
269  const GeomDetUnit& detUnit = *(hit->detUnit());
270  float uOrientation(-999.F), vOrientation(-999.F);
271  float resXTopol(999.F), resYTopol(999.F);
272  float resXatTrkYTopol(999.F);
273 
274  const Surface& surface = hit->detUnit()->surface();
275  const BoundPlane& boundplane = hit->detUnit()->surface();
276  const Bounds& bound = boundplane.bounds();
277 
278  float length = 0;
279  float width = 0;
280 
281  LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.);
282  GlobalPoint gPModule = surface.toGlobal(lPModule), gUDirection = surface.toGlobal(lUDirection),
283  gVDirection = surface.toGlobal(lVDirection);
284 
285  if (IntSubDetID == PixelSubdetector::PixelBarrel || IntSubDetID == StripSubdetector::TIB ||
286  IntSubDetID == StripSubdetector::TOB) {
287  uOrientation = deltaPhi(gUDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
288  vOrientation = gVDirection.z() - gPModule.z() >= 0 ? +1.F : -1.F;
289  resXTopol = res.x();
290  resXatTrkYTopol = res.x();
291  resYTopol = res.y();
292  resXprimeErr = resXErr;
293  resYprimeErr = resYErr;
294 
295  const RectangularPlaneBounds* rectangularBound = dynamic_cast<const RectangularPlaneBounds*>(&bound);
296  if (rectangularBound != nullptr) {
297  hitStruct.inside = rectangularBound->inside(lPTrk);
298  length = rectangularBound->length();
299  width = rectangularBound->width();
300  hitStruct.localXnorm = 2 * hitStruct.localX / width;
301  hitStruct.localYnorm = 2 * hitStruct.localY / length;
302  } else {
303  throw cms::Exception("Geometry Error") << "[TrackerValidationVariables] Cannot cast bounds to "
304  "RectangularPlaneBounds as expected for TPB, TIB and TOB";
305  }
306 
307  } else if (IntSubDetID == PixelSubdetector::PixelEndcap) {
308  uOrientation = gUDirection.perp() - gPModule.perp() >= 0 ? +1.F : -1.F;
309  vOrientation = deltaPhi(gVDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
310  resXTopol = res.x();
311  resXatTrkYTopol = res.x();
312  resYTopol = res.y();
313  resXprimeErr = resXErr;
314  resYprimeErr = resYErr;
315 
316  const RectangularPlaneBounds* rectangularBound = dynamic_cast<const RectangularPlaneBounds*>(&bound);
317  if (rectangularBound != nullptr) {
318  hitStruct.inside = rectangularBound->inside(lPTrk);
319  length = rectangularBound->length();
320  width = rectangularBound->width();
321  hitStruct.localXnorm = 2 * hitStruct.localX / width;
322  hitStruct.localYnorm = 2 * hitStruct.localY / length;
323  } else {
324  throw cms::Exception("Geometry Error")
325  << "[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
326  }
327 
328  } else if (IntSubDetID == StripSubdetector::TID || IntSubDetID == StripSubdetector::TEC) {
329  uOrientation = deltaPhi(gUDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
330  vOrientation = gVDirection.perp() - gPModule.perp() >= 0. ? +1.F : -1.F;
331 
332  if (!dynamic_cast<const RadialStripTopology*>(&detUnit.type().topology()))
333  continue;
334  const RadialStripTopology& topol = dynamic_cast<const RadialStripTopology&>(detUnit.type().topology());
335 
336  MeasurementPoint measHitPos = topol.measurementPosition(lPHit);
337  MeasurementPoint measTrkPos = topol.measurementPosition(lPTrk);
338 
339  MeasurementError measHitErr = topol.measurementError(lPHit, errHit);
340  MeasurementError measTrkErr = topol.measurementError(lPTrk, errTrk);
341 
342  if (measHitErr.uu() < 0. || measHitErr.vv() < 0. || measTrkErr.uu() < 0. || measTrkErr.vv() < 0.) {
343  edm::LogError("TrackerValidationVariables")
344  << "@SUB=TrackerValidationVariables::fillHitQuantities"
345  << "One of the squared error methods gives negative result"
346  << "\n\tmeasHitErr.uu()\tmeasHitErr.vv()\tmeasTrkErr.uu()\tmeasTrkErr.vv()"
347  << "\n\t" << measHitErr.uu() << "\t" << measHitErr.vv() << "\t" << measTrkErr.uu() << "\t"
348  << measTrkErr.vv();
349  continue;
350  }
351 
352  float localStripLengthHit = topol.localStripLength(lPHit);
353  float localStripLengthTrk = topol.localStripLength(lPTrk);
354  float phiHit = topol.stripAngle(measHitPos.x());
355  float phiTrk = topol.stripAngle(measTrkPos.x());
356  float r_0 = topol.originToIntersection();
357 
358  resXTopol = (phiTrk - phiHit) * r_0;
359  // resXTopol = (tan(phiTrk)-tan(phiHit))*r_0;
360 
361  LocalPoint LocalHitPosCor = topol.localPosition(MeasurementPoint(measHitPos.x(), measTrkPos.y()));
362  resXatTrkYTopol = lPTrk.x() - LocalHitPosCor.x();
363 
364  //resYTopol = measTrkPos.y()*localStripLengthTrk - measHitPos.y()*localStripLengthHit;
365  float cosPhiHit(cos(phiHit)), cosPhiTrk(cos(phiTrk)), sinPhiHit(sin(phiHit)), sinPhiTrk(sin(phiTrk));
366  float l_0 = r_0 - topol.detHeight() / 2;
367  resYTopol = measTrkPos.y() * localStripLengthTrk - measHitPos.y() * localStripLengthHit +
368  l_0 * (1 / cosPhiTrk - 1 / cosPhiHit);
369 
370  resXprimeErr = std::sqrt(measHitErr.uu() + measTrkErr.uu()) * topol.angularWidth() * r_0;
371  //resYprimeErr = std::sqrt(measHitErr.vv()*localStripLengthHit*localStripLengthHit + measTrkErr.vv()*localStripLengthTrk*localStripLengthTrk);
372  float helpSummand = l_0 * l_0 * topol.angularWidth() * topol.angularWidth() *
373  (sinPhiHit * sinPhiHit / pow(cosPhiHit, 4) * measHitErr.uu() +
374  sinPhiTrk * sinPhiTrk / pow(cosPhiTrk, 4) * measTrkErr.uu());
375  resYprimeErr = std::sqrt(measHitErr.vv() * localStripLengthHit * localStripLengthHit +
376  measTrkErr.vv() * localStripLengthTrk * localStripLengthTrk + helpSummand);
377 
378  const TrapezoidalPlaneBounds* trapezoidalBound = dynamic_cast<const TrapezoidalPlaneBounds*>(&bound);
379  if (trapezoidalBound != nullptr) {
380  hitStruct.inside = trapezoidalBound->inside(lPTrk);
381  length = trapezoidalBound->length();
382  width = trapezoidalBound->width();
383  //float widthAtHalfLength = trapezoidalBound->widthAtHalfLength();
384 
385  // int yAxisOrientation=trapezoidalBound->yAxisOrientation();
386  // for trapezoidal shape modules, scale with as function of local y coordinate
387  // float widthAtlocalY=width-(1-yAxisOrientation*2*lPTrk.y()/length)*(width-widthAtHalfLength);
388  // hitStruct.localXnorm = 2*hitStruct.localX/widthAtlocalY;
389  hitStruct.localXnorm = 2 * hitStruct.localX / width;
390  hitStruct.localYnorm = 2 * hitStruct.localY / length;
391  } else {
392  throw cms::Exception("Geometry Error") << "[TrackerValidationVariables] Cannot cast bounds to "
393  "TrapezoidalPlaneBounds as expected for TID and TEC";
394  }
395 
396  } else {
397  edm::LogWarning("TrackerValidationVariables") << "@SUB=TrackerValidationVariables::fillHitQuantities"
398  << "No valid tracker subdetector " << IntSubDetID;
399  continue;
400  }
401 
402  resXprime = resXTopol * uOrientation;
403  resXatTrkY = resXatTrkYTopol;
404  resYprime = resYTopol * vOrientation;
405 
406  } else { // not a detUnit, so must be a virtual 2D-Module
407  // FIXME: at present only for det units residuals are calculated and filled in the hitStruct
408  // But in principle this method should also be useable for the gluedDets (2D modules in TIB, TID, TOB, TEC)
409  // In this case, only orientation should be taken into account for primeResiduals, but not the radial topology
410  // At present, default values (999.F) are given out
411  }
412 
413  hitStruct.resXprime = resXprime;
414  hitStruct.resXatTrkY = resXatTrkY;
415  hitStruct.resYprime = resYprime;
416  hitStruct.resXprimeErr = resXprimeErr;
417  hitStruct.resYprimeErr = resYprimeErr;
418 
419  hitStruct.rawDetId = IntRawDetID;
420  hitStruct.phi = tsos.globalDirection().phi();
421  hitStruct.eta = tsos.globalDirection().eta();
422 
423  v_avhitout.push_back(hitStruct);
424  }
425 }
static constexpr auto TEC
float uu() const
T perp() const
Definition: PV3DBase.h:69
LocalPoint localPosition(float strip) const override=0
bool isOnEdge() const
Definition: SiPixelRecHit.h:97
const LocalTrajectoryError & localError() const
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T eta() const
Definition: PV3DBase.h:73
bool hasBadPixels() const
Definition: SiPixelRecHit.h:99
T x() const
Definition: PV2DBase.h:43
Log< level::Error, false > LogError
float length() const override
Lenght along local Y.
LocalError positionError() const
virtual const GeomDetType & type() const
Definition: GeomDet.cc:69
virtual float detHeight() const =0
Definition: Electron.h:6
T barePhi() const
Definition: PV3DBase.h:65
DataContainer const & measurements() const
Definition: Trajectory.h:178
MeasurementPoint measurementPosition(const LocalPoint &) const override=0
T y() const
Definition: PV2DBase.h:44
float yy() const
Definition: LocalError.h:24
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
LocalVector localDirection() const
virtual float angularWidth() const =0
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
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
Definition: Surface.h:79
Definition: DetId.h:17
static constexpr auto TIB
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
GlobalVector globalDirection() const
virtual float originToIntersection() const =0
bool inside(const Local2DPoint &p) const override
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.
Definition: Bounds.h:18
Log< level::Warning, false > LogWarning
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
static constexpr auto TID
float vv() const
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
float xx() const
Definition: LocalError.h:22
Our base class.
Definition: SiPixelRecHit.h:23

◆ fillHitQuantities() [2/2]

void TrackerValidationVariables::fillHitQuantities ( reco::Track const &  track,
std::vector< AVHitStruct > &  v_avhitout 
)

Definition at line 59 of file TrackerValidationVariables.cc.

References cms::cuda::assert(), PV3DBase< T, PVType, FrameType >::barePhi(), SiPixelRawToDigiRegional_cfi::deltaPhi, TrackerValidationVariables::AVHitStruct::eta, Exception, F(), h, SiPixelRecHit::hasBadPixels(), hcalSimParameters_cfi::hb, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), RectangularPlaneBounds::inside(), TrackerValidationVariables::AVHitStruct::inside, SiPixelRecHit::isOnEdge(), TrackerValidationVariables::AVHitStruct::isOnEdgePixel, TrackerValidationVariables::AVHitStruct::isOtherBadPixel, RectangularPlaneBounds::length(), TrackerValidationVariables::AVHitStruct::localAlpha, TrackerValidationVariables::AVHitStruct::localBeta, TrackerValidationVariables::AVHitStruct::localX, TrackerValidationVariables::AVHitStruct::localXnorm, TrackerValidationVariables::AVHitStruct::localY, TrackerValidationVariables::AVHitStruct::localYnorm, PV3DBase< T, PVType, FrameType >::perp(), TrackerValidationVariables::AVHitStruct::phi, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerValidationVariables::AVHitStruct::rawDetId, DetId::rawId(), TrackerValidationVariables::AVHitStruct::resErrX, TrackerValidationVariables::AVHitStruct::resErrY, TrackerValidationVariables::AVHitStruct::resX, TrackerValidationVariables::AVHitStruct::resXatTrkY, TrackerValidationVariables::AVHitStruct::resXprime, TrackerValidationVariables::AVHitStruct::resXprimeErr, TrackerValidationVariables::AVHitStruct::resY, TrackerValidationVariables::AVHitStruct::resYprime, TrackerValidationVariables::AVHitStruct::resYprimeErr, DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, Surface::toGlobal(), HLT_2024v10_cff::track, RectangularPlaneBounds::width(), ApeEstimator_cff::width, and PV3DBase< T, PVType, FrameType >::z().

59  {
60  auto const& trajParams = track.extra()->trajParams();
61  auto const& residuals = track.extra()->residuals();
62 
63  assert(trajParams.size() == track.recHitsSize());
64  auto hb = track.recHitsBegin();
65  for (unsigned int h = 0; h < track.recHitsSize(); h++) {
66  auto hit = *(hb + h);
67  if (!hit->isValid())
68  continue;
69 
70  AVHitStruct hitStruct;
71  const DetId& hit_detId = hit->geographicalId();
72  auto IntRawDetID = hit_detId.rawId();
73  auto IntSubDetID = hit_detId.subdetId();
74 
75  if (IntSubDetID == 0)
76  continue;
77 
78  if (IntSubDetID == PixelSubdetector::PixelBarrel || IntSubDetID == PixelSubdetector::PixelEndcap) {
79  const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(
80  hit); //to be used to get the associated cluster and the cluster probability
81  if (prechit->isOnEdge())
82  hitStruct.isOnEdgePixel = true;
83  if (prechit->hasBadPixels())
84  hitStruct.isOtherBadPixel = true;
85  }
86 
87  auto lPTrk = trajParams[h].position(); // update state
88  auto lVTrk = trajParams[h].direction();
89 
90  auto gtrkdirup = hit->surface()->toGlobal(lVTrk);
91 
92  hitStruct.rawDetId = IntRawDetID;
93  hitStruct.phi = gtrkdirup.phi(); // direction, not position
94  hitStruct.eta = gtrkdirup.eta(); // same
95 
96  hitStruct.localAlpha = std::atan2(lVTrk.x(), lVTrk.z()); // wrt. normal tg(alpha)=x/z
97  hitStruct.localBeta = std::atan2(lVTrk.y(), lVTrk.z()); // wrt. normal tg(beta)= y/z
98 
99  hitStruct.resX = residuals.residualX(h);
100  hitStruct.resY = residuals.residualY(h);
101  hitStruct.resErrX = hitStruct.resX / residuals.pullX(h); // for backward compatibility....
102  hitStruct.resErrY = hitStruct.resY / residuals.pullY(h);
103 
104  // hitStruct.localX = lPhit.x();
105  // hitStruct.localY = lPhit.y();
106  // EM: use predictions for local coordinates
107  hitStruct.localX = lPTrk.x();
108  hitStruct.localY = lPTrk.y();
109 
110  // now calculate residuals taking global orientation of modules and radial topology in TID/TEC into account
111  float resXprime(999.F), resYprime(999.F);
112  float resXatTrkY(999.F);
113  float resXprimeErr(999.F), resYprimeErr(999.F);
114 
115  if (hit->detUnit()) { // is it a single physical module?
116  float uOrientation(-999.F), vOrientation(-999.F);
117  float resXTopol(999.F), resYTopol(999.F);
118  float resXatTrkYTopol(999.F);
119 
120  const Surface& surface = hit->detUnit()->surface();
121  const BoundPlane& boundplane = hit->detUnit()->surface();
122  const Bounds& bound = boundplane.bounds();
123 
124  float length = 0;
125  float width = 0;
126 
127  LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.);
128  GlobalPoint gPModule = surface.toGlobal(lPModule), gUDirection = surface.toGlobal(lUDirection),
129  gVDirection = surface.toGlobal(lVDirection);
130 
131  if (IntSubDetID == PixelSubdetector::PixelBarrel || IntSubDetID == PixelSubdetector::PixelEndcap ||
132  IntSubDetID == StripSubdetector::TIB || IntSubDetID == StripSubdetector::TOB) {
133  if (IntSubDetID == PixelSubdetector::PixelEndcap) {
134  uOrientation = gUDirection.perp() - gPModule.perp() >= 0 ? +1.F : -1.F;
135  vOrientation = deltaPhi(gVDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
136  } else {
137  uOrientation = deltaPhi(gUDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
138  vOrientation = gVDirection.z() - gPModule.z() >= 0 ? +1.F : -1.F;
139  }
140 
141  resXTopol = hitStruct.resX;
142  resXatTrkYTopol = hitStruct.resX;
143  resYTopol = hitStruct.resY;
144  resXprimeErr = hitStruct.resErrX;
145  resYprimeErr = hitStruct.resErrY;
146 
147  const RectangularPlaneBounds* rectangularBound = dynamic_cast<const RectangularPlaneBounds*>(&bound);
148  if (rectangularBound != nullptr) {
149  hitStruct.inside = rectangularBound->inside(lPTrk);
150  length = rectangularBound->length();
151  width = rectangularBound->width();
152  hitStruct.localXnorm = 2 * hitStruct.localX / width;
153  hitStruct.localYnorm = 2 * hitStruct.localY / length;
154  } else {
155  throw cms::Exception("Geometry Error")
156  << "[TrackerValidationVariables] Cannot cast bounds to RectangularPlaneBounds as expected for TPE";
157  }
158 
159  } else if (IntSubDetID == StripSubdetector::TID || IntSubDetID == StripSubdetector::TEC) {
160  // not possible to compute precisely as with Trajectory
161  } else {
162  edm::LogWarning("TrackerValidationVariables") << "@SUB=TrackerValidationVariables::fillHitQuantities"
163  << "No valid tracker subdetector " << IntSubDetID;
164  continue;
165  }
166 
167  resXprime = resXTopol * uOrientation;
168  resXatTrkY = resXatTrkYTopol;
169  resYprime = resYTopol * vOrientation;
170 
171  } else { // not a detUnit, so must be a virtual 2D-Module
172  // FIXME: at present only for det units residuals are calculated and filled in the hitStruct
173  // But in principle this method should also be useable for the gluedDets (2D modules in TIB, TID, TOB, TEC)
174  // In this case, only orientation should be taken into account for primeResiduals, but not the radial topology
175  // At present, default values (999.F) are given out
176  }
177 
178  hitStruct.resXprime = resXprime;
179  hitStruct.resXatTrkY = resXatTrkY;
180  hitStruct.resYprime = resYprime;
181  hitStruct.resXprimeErr = resXprimeErr;
182  hitStruct.resYprimeErr = resYprimeErr;
183 
184  v_avhitout.push_back(hitStruct);
185  }
186 }
static constexpr auto TEC
T perp() const
Definition: PV3DBase.h:69
bool isOnEdge() const
Definition: SiPixelRecHit.h:97
T z() const
Definition: PV3DBase.h:61
bool hasBadPixels() const
Definition: SiPixelRecHit.h:99
float length() const override
Lenght along local Y.
assert(be >=bs)
T barePhi() const
Definition: PV3DBase.h:65
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static constexpr auto TOB
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
Definition: DetId.h:17
static constexpr auto TIB
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
bool inside(const Local2DPoint &p) const override
float width() const override
Width along local X.
Definition: Bounds.h:18
Log< level::Warning, false > LogWarning
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
static constexpr auto TID
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
Our base class.
Definition: SiPixelRecHit.h:23

◆ fillPSetDescription()

void TrackerValidationVariables::fillPSetDescription ( edm::ParameterSetDescription descriptions)
static

Definition at line 53 of file TrackerValidationVariables.cc.

References submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by TrackerOfflineValidation::fillDescriptions().

53  {
54  desc.setComment("auxilliary class to store information about track-hit residuals");
55  desc.add<std::string>("trajectoryInput", "generalTracks");
56  desc.add<edm::InputTag>("Tracks", edm::InputTag("generalTracks"));
57 }

◆ fillTrackQuantities() [1/2]

void TrackerValidationVariables::fillTrackQuantities ( const edm::Event event,
const edm::EventSetup eventSetup,
std::vector< AVTrackStruct > &  v_avtrackout 
)

Definition at line 427 of file TrackerValidationVariables.cc.

References options_cfi::eventSetup.

Referenced by TrackerOfflineValidation::analyze().

429  {
431  event, eventSetup, [](const reco::Track&) -> bool { return true; }, v_avtrackout);
432 }
void fillTrackQuantities(const edm::Event &, const edm::EventSetup &, std::vector< AVTrackStruct > &v_avtrackout)
Definition: event.py:1

◆ fillTrackQuantities() [2/2]

void TrackerValidationVariables::fillTrackQuantities ( const edm::Event event,
const edm::EventSetup eventSetup,
std::function< bool(const reco::Track &)>  trackFilter,
std::vector< AVTrackStruct > &  v_avtrackout 
)

Definition at line 434 of file TrackerValidationVariables.cc.

References cms::cuda::assert(), TrackerValidationVariables::AVTrackStruct::charge, TrackerValidationVariables::AVTrackStruct::chi2, TrackerValidationVariables::AVTrackStruct::chi2Prob, TrackerValidationVariables::AVTrackStruct::d0, TrackerValidationVariables::AVTrackStruct::dz, TrackerValidationVariables::AVTrackStruct::eta, options_cfi::eventSetup, fillHitQuantities(), TrackerValidationVariables::AVTrackStruct::hits, mps_fire::i, edm::HandleBase::isValid(), TrackerValidationVariables::AVTrackStruct::kappa, LogDebug, HLT_2024v10_cff::magneticField, magneticFieldToken_, TrackerValidationVariables::AVTrackStruct::normchi2, TrackerValidationVariables::AVTrackStruct::numberOfLostHits, TrackerValidationVariables::AVTrackStruct::numberOfValidHits, TrackerValidationVariables::AVTrackStruct::p, TrackerValidationVariables::AVTrackStruct::phi, TrackerValidationVariables::AVTrackStruct::pt, TrackerValidationVariables::AVTrackStruct::ptError, TrackerValidationVariables::AVTrackStruct::px, TrackerValidationVariables::AVTrackStruct::py, TrackerValidationVariables::AVTrackStruct::pz, HLT_2024v10_cff::track, MinBiasPDSkim_cfg::trackFilter, DiMuonV_cfg::tracks, tracksToken_, and trajCollectionToken_.

437  {
439 
441  event.getByToken(tracksToken_, tracksH);
442  if (!tracksH.isValid())
443  return;
444  auto const& tracks = *tracksH;
445  auto ntrk = tracks.size();
446  LogDebug("TrackerValidationVariables") << "Track collection size " << ntrk;
447 
449  event.getByToken(trajCollectionToken_, trajsH);
450  bool yesTraj = trajsH.isValid();
451  std::vector<Trajectory> const* trajs = nullptr;
452  if (yesTraj)
453  trajs = &(*trajsH);
454  if (yesTraj)
455  assert(trajs->size() == tracks.size());
456 
457  Trajectory const* trajectory = nullptr;
458  for (unsigned int i = 0; i < ntrk; ++i) {
459  auto const& track = tracks[i];
460  if (yesTraj)
461  trajectory = &(*trajs)[i];
462 
463  if (!trackFilter(track))
464  continue;
465 
466  AVTrackStruct trackStruct;
467 
468  trackStruct.p = track.p();
469  trackStruct.pt = track.pt();
470  trackStruct.ptError = track.ptError();
471  trackStruct.px = track.px();
472  trackStruct.py = track.py();
473  trackStruct.pz = track.pz();
474  trackStruct.eta = track.eta();
475  trackStruct.phi = track.phi();
476  trackStruct.chi2 = track.chi2();
477  trackStruct.chi2Prob = TMath::Prob(track.chi2(), track.ndof());
478  trackStruct.normchi2 = track.normalizedChi2();
479  GlobalPoint gPoint(track.vx(), track.vy(), track.vz());
480  double theLocalMagFieldInInverseGeV = magneticField.inInverseGeV(gPoint).z();
481  trackStruct.kappa = -track.charge() * theLocalMagFieldInInverseGeV / track.pt();
482  trackStruct.charge = track.charge();
483  trackStruct.d0 = track.d0();
484  trackStruct.dz = track.dz();
485  trackStruct.numberOfValidHits = track.numberOfValidHits();
486  trackStruct.numberOfLostHits = track.numberOfLostHits();
487  if (trajectory)
488  fillHitQuantities(trajectory, trackStruct.hits);
489  else
490  fillHitQuantities(track, trackStruct.hits);
491 
492  v_avtrackout.push_back(trackStruct);
493  }
494 }
void fillHitQuantities(const Trajectory *trajectory, std::vector< AVHitStruct > &v_avhitout)
assert(be >=bs)
edm::EDGetTokenT< std::vector< Trajectory > > trajCollectionToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< std::vector< reco::Track > > tracksToken_
#define LogDebug(id)

Member Data Documentation

◆ magneticFieldToken_

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> TrackerValidationVariables::magneticFieldToken_
private

Definition at line 127 of file TrackerValidationVariables.h.

Referenced by fillTrackQuantities().

◆ tracksToken_

edm::EDGetTokenT<std::vector<reco::Track> > TrackerValidationVariables::tracksToken_
private

Definition at line 126 of file TrackerValidationVariables.h.

Referenced by fillTrackQuantities().

◆ trajCollectionToken_

edm::EDGetTokenT<std::vector<Trajectory> > TrackerValidationVariables::trajCollectionToken_
private

Definition at line 125 of file TrackerValidationVariables.h.

Referenced by fillTrackQuantities().