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 48 of file TrackerValidationVariables.cc.

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

Definition at line 53 of file TrackerValidationVariables.cc.

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

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

Definition at line 60 of file TrackerValidationVariables.cc.

61 {
62 
63 }

Member Function Documentation

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

Definition at line 194 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(), RectangularPlaneBounds::inside(), TrackerValidationVariables::AVHitStruct::inside, 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().

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

Definition at line 65 of file TrackerValidationVariables.cc.

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

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

Definition at line 437 of file TrackerValidationVariables.cc.

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

440 {
441  fillTrackQuantities(event,
442  eventSetup,
443  [](const reco::Track&) -> bool { return true; },
444  v_avtrackout);
445 }
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 448 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().

452 {
454  eventSetup.get<IdealMagneticFieldRecord>().get(magneticField);
455 
457  event.getByToken(tracksToken_, tracksH);
458  if(!tracksH.isValid()) return;
459  auto const & tracks = *tracksH;
460  auto ntrk = tracks.size();
461  LogDebug("TrackerValidationVariables") << "Track collection size " << ntrk;
462 
463 
465  event.getByToken(trajCollectionToken_, trajsH);
466  bool yesTraj = trajsH.isValid();
467  std::vector<Trajectory> const * trajs = nullptr;
468  if (yesTraj) trajs = &(*trajsH);
469  if (yesTraj) assert (trajs->size()==tracks.size());
470 
471  Trajectory const * trajectory = nullptr;
472  for (unsigned int i=0; i<ntrk; ++i) {
473  auto const & track = tracks[i];
474  if (yesTraj) trajectory = &(*trajs)[i];
475 
476  if (!trackFilter(track)) continue;
477 
478  AVTrackStruct trackStruct;
479 
480  trackStruct.p = track.p();
481  trackStruct.pt = track.pt();
482  trackStruct.ptError = track.ptError();
483  trackStruct.px = track.px();
484  trackStruct.py = track.py();
485  trackStruct.pz = track.pz();
486  trackStruct.eta = track.eta();
487  trackStruct.phi = track.phi();
488  trackStruct.chi2 = track.chi2();
489  trackStruct.chi2Prob= TMath::Prob(track.chi2(),track.ndof());
490  trackStruct.normchi2 = track.normalizedChi2();
491  GlobalPoint gPoint(track.vx(), track.vy(), track.vz());
492  double theLocalMagFieldInInverseGeV = magneticField->inInverseGeV(gPoint).z();
493  trackStruct.kappa = -track.charge()*theLocalMagFieldInInverseGeV/track.pt();
494  trackStruct.charge = track.charge();
495  trackStruct.d0 = track.d0();
496  trackStruct.dz = track.dz();
497  trackStruct.numberOfValidHits = track.numberOfValidHits();
498  trackStruct.numberOfLostHits = track.numberOfLostHits();
499  if (trajectory)
500  fillHitQuantities(trajectory, trackStruct.hits);
501  else fillHitQuantities(track, trackStruct.hits);
502 
503  v_avtrackout.push_back(trackStruct);
504  }
505 }
#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:62
edm::EDGetTokenT< std::vector< reco::Track > > tracksToken_

Member Data Documentation

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

Definition at line 94 of file TrackerValidationVariables.h.

Referenced by fillTrackQuantities(), and TrackerValidationVariables().

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

Definition at line 93 of file TrackerValidationVariables.h.

Referenced by fillTrackQuantities(), and TrackerValidationVariables().