CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | 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 ()
 

Private Attributes

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

Detailed Description

Definition at line 22 of file TrackerValidationVariables.h.

Constructor & Destructor Documentation

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

Definition at line 44 of file TrackerValidationVariables.cc.

References edm::ParameterSet::getParameter(), HLT_FULL_cff::InputTag, dumpMFGeometry_cfg::MagneticField, AlCaHLTBitMon_QueryRunRegistry::string, tracksToken_, and trajCollectionToken_.

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

Definition at line 51 of file TrackerValidationVariables.cc.

51 {}

Member Function Documentation

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

Definition at line 182 of file TrackerValidationVariables.cc.

References RadialStripTopology::angularWidth(), PV3DBase< T, PVType, FrameType >::barePhi(), funct::cos(), srCondWrite_cfg::deltaPhi, RadialStripTopology::detHeight(), TrackerValidationVariables::AVHitStruct::eta, PV3DBase< T, PVType, FrameType >::eta(), Exception, F(), TrajectoryStateOnSurface::globalDirection(), SiPixelRecHit::hasBadPixels(), 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(), 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().

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

Definition at line 53 of file TrackerValidationVariables.cc.

References cms::cuda::assert(), PV3DBase< T, PVType, FrameType >::barePhi(), srCondWrite_cfg::deltaPhi, TrackerValidationVariables::AVHitStruct::eta, Exception, reco::Track::extra(), F(), h, SiPixelRecHit::hasBadPixels(), hcalSimParameters_cfi::hb, 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(), reco::Track::recHitsBegin(), reco::Track::recHitsSize(), 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(), RectangularPlaneBounds::width(), and PV3DBase< T, PVType, FrameType >::z().

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

Definition at line 421 of file TrackerValidationVariables.cc.

Referenced by MonitorTrackResidualsBase< pixel_or_strip >::analyze(), and TrackerOfflineValidation::analyze().

423  {
425  event, eventSetup, [](const reco::Track&) -> bool { return true; }, v_avtrackout);
426 }
void fillTrackQuantities(const edm::Event &, const edm::EventSetup &, std::vector< AVTrackStruct > &v_avtrackout)
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 428 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, fillHitQuantities(), edm::EventSetup::getData(), TrackerValidationVariables::AVTrackStruct::hits, mps_fire::i, MagneticField::inInverseGeV(), edm::HandleBase::isValid(), TrackerValidationVariables::AVTrackStruct::kappa, LogDebug, HLT_FULL_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_FULL_cff::track, valSkim_cff::trackFilter, tracks, tracksToken_, trajCollectionToken_, and PV3DBase< T, PVType, FrameType >::z().

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

Member Data Documentation

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

Definition at line 124 of file TrackerValidationVariables.h.

Referenced by fillTrackQuantities().

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