CMS 3D CMS Logo

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 ()
 
 TrackerValidationVariables (const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
 
 ~TrackerValidationVariables ()
 

Private Attributes

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

Detailed Description

Definition at line 20 of file TrackerValidationVariables.h.

Constructor & Destructor Documentation

TrackerValidationVariables::TrackerValidationVariables ( )

Definition at line 49 of file TrackerValidationVariables.cc.

50 {
51 
52 }
TrackerValidationVariables::TrackerValidationVariables ( const edm::ParameterSet config,
edm::ConsumesCollector &&  iC 
)

Definition at line 54 of file TrackerValidationVariables.cc.

References edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, tracksToken_, and trajCollectionToken_.

56 {
57  trajCollectionToken_ = iC.consumes<std::vector<Trajectory> >(edm::InputTag(config.getParameter<std::string>("trajectoryInput")));
59 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
edm::EDGetTokenT< std::vector< Trajectory > > trajCollectionToken_
edm::EDGetTokenT< std::vector< reco::Track > > tracksToken_
TrackerValidationVariables::~TrackerValidationVariables ( )

Definition at line 61 of file TrackerValidationVariables.cc.

62 {
63 
64 }

Member Function Documentation

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

Definition at line 201 of file TrackerValidationVariables.cc.

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

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

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

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

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

453 {
454  fillTrackQuantities(event,
455  eventSetup,
456  [](const reco::Track&) -> bool { return true; },
457  v_avtrackout);
458 }
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 461 of file TrackerValidationVariables.cc.

References TrackerValidationVariables::AVTrackStruct::charge, TrackerValidationVariables::AVTrackStruct::chi2, TrackerValidationVariables::AVTrackStruct::chi2Prob, TrackerValidationVariables::AVTrackStruct::d0, TrackerValidationVariables::AVTrackStruct::dz, TrackerValidationVariables::AVTrackStruct::eta, fillHitQuantities(), edm::EventSetup::get(), TrackerValidationVariables::AVTrackStruct::hits, mps_fire::i, MagneticField::inInverseGeV(), edm::HandleBase::isValid(), TrackerValidationVariables::AVTrackStruct::kappa, LogDebug, seedCreatorFromRegionConsecutiveHitsEDProducer_cff::magneticField, 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, HiIsolationCommonParameters_cff::track, l1t::tracks, tracksToken_, trajCollectionToken_, and PV3DBase< T, PVType, FrameType >::z().

465 {
467  eventSetup.get<IdealMagneticFieldRecord>().get(magneticField);
468 
470  event.getByToken(tracksToken_, tracksH);
471  if(!tracksH.isValid()) return;
472  auto const & tracks = *tracksH;
473  auto ntrk = tracks.size();
474  LogDebug("TrackerValidationVariables") << "Track collection size " << ntrk;
475 
476 
478  event.getByToken(trajCollectionToken_, trajsH);
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());
483 
484  Trajectory const * trajectory = nullptr;
485  for (unsigned int i=0; i<ntrk; ++i) {
486  auto const & track = tracks[i];
487  if (yesTraj) trajectory = &(*trajs)[i];
488 
489  if (!trackFilter(track)) continue;
490 
491  AVTrackStruct trackStruct;
492 
493  trackStruct.p = track.p();
494  trackStruct.pt = track.pt();
495  trackStruct.ptError = track.ptError();
496  trackStruct.px = track.px();
497  trackStruct.py = track.py();
498  trackStruct.pz = track.pz();
499  trackStruct.eta = track.eta();
500  trackStruct.phi = track.phi();
501  trackStruct.chi2 = track.chi2();
502  trackStruct.chi2Prob= TMath::Prob(track.chi2(),track.ndof());
503  trackStruct.normchi2 = track.normalizedChi2();
504  GlobalPoint gPoint(track.vx(), track.vy(), track.vz());
505  double theLocalMagFieldInInverseGeV = magneticField->inInverseGeV(gPoint).z();
506  trackStruct.kappa = -track.charge()*theLocalMagFieldInInverseGeV/track.pt();
507  trackStruct.charge = track.charge();
508  trackStruct.d0 = track.d0();
509  trackStruct.dz = track.dz();
510  trackStruct.numberOfValidHits = track.numberOfValidHits();
511  trackStruct.numberOfLostHits = track.numberOfLostHits();
512  if (trajectory)
513  fillHitQuantities(trajectory, trackStruct.hits);
514  else fillHitQuantities(track, trackStruct.hits);
515 
516  v_avtrackout.push_back(trackStruct);
517  }
518 }
#define LogDebug(id)
void fillHitQuantities(const Trajectory *trajectory, std::vector< AVHitStruct > &v_avhitout)
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:41
edm::EDGetTokenT< std::vector< Trajectory > > trajCollectionToken_
T z() const
Definition: PV3DBase.h:64
bool isValid() const
Definition: HandleBase.h:74
T get() const
Definition: EventSetup.h:71
edm::EDGetTokenT< std::vector< reco::Track > > tracksToken_

Member Data Documentation

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

Definition at line 96 of file TrackerValidationVariables.h.

Referenced by fillTrackQuantities(), and TrackerValidationVariables().

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

Definition at line 95 of file TrackerValidationVariables.h.

Referenced by fillTrackQuantities(), and TrackerValidationVariables().