#include <TrackerValidationVariables.h>
Classes | |
struct | AVHitStruct |
struct | AVTrackStruct |
Public Member Functions | |
void | fillHitQuantities (const Trajectory *trajectory, std::vector< AVHitStruct > &v_avhitout) |
void | fillHitQuantities (const edm::Event &, std::vector< AVHitStruct > &v_avhitout) |
void | fillTrackQuantities (const edm::Event &, std::vector< AVTrackStruct > &v_avtrackout) |
TrackerValidationVariables (const edm::EventSetup &, const edm::ParameterSet &) | |
TrackerValidationVariables () | |
~TrackerValidationVariables () | |
Private Attributes | |
const edm::ParameterSet | conf_ |
edm::ESHandle< MagneticField > | magneticField_ |
edm::ESHandle< TrackerGeometry > | tkGeom_ |
Definition at line 16 of file TrackerValidationVariables.h.
TrackerValidationVariables::TrackerValidationVariables | ( | ) |
Definition at line 45 of file TrackerValidationVariables.cc.
{ }
TrackerValidationVariables::TrackerValidationVariables | ( | const edm::EventSetup & | es, |
const edm::ParameterSet & | iSetup | ||
) |
Definition at line 50 of file TrackerValidationVariables.cc.
References edm::EventSetup::get(), magneticField_, and tkGeom_.
: conf_(iSetup) { es.get<TrackerDigiGeometryRecord>().get(tkGeom_); es.get<IdealMagneticFieldRecord>().get(magneticField_); }
TrackerValidationVariables::~TrackerValidationVariables | ( | ) |
Definition at line 57 of file TrackerValidationVariables.cc.
{ }
void TrackerValidationVariables::fillHitQuantities | ( | const Trajectory * | trajectory, |
std::vector< AVHitStruct > & | v_avhitout | ||
) |
Definition at line 63 of file TrackerValidationVariables.cc.
References RadialStripTopology::angularWidth(), BoundSurface::bounds(), TrajectoryStateCombiner::combine(), funct::cos(), Geom::deltaPhi(), RadialStripTopology::detHeight(), PV3DBase< T, PVType, FrameType >::eta(), TrackerValidationVariables::AVHitStruct::eta, TrajectoryStateOnSurface::globalDirection(), TrajectoryStateOnSurface::globalPosition(), TrackerValidationVariables::AVHitStruct::inside, RectangularPlaneBounds::inside(), TrajectoryStateOnSurface::isValid(), RectangularPlaneBounds::length(), TrackerValidationVariables::AVHitStruct::localAlpha, TrackerValidationVariables::AVHitStruct::localBeta, TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localPosition(), RadialStripTopology::localStripLength(), TrackerValidationVariables::AVHitStruct::localX, TrackerValidationVariables::AVHitStruct::localXnorm, TrackerValidationVariables::AVHitStruct::localY, TrackerValidationVariables::AVHitStruct::localYnorm, magneticField_, RadialStripTopology::measurementError(), RadialStripTopology::measurementPosition(), Trajectory::measurements(), RadialStripTopology::originToIntersection(), TrackerValidationVariables::AVHitStruct::overlapres, SiStripDetId::partnerDetId(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), TrackerValidationVariables::AVHitStruct::phi, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, LocalTrajectoryError::positionError(), funct::pow(), AnalyticalPropagator::propagate(), AnalyticalPropagator::propagateWithPath(), LargeD0_PixelPairStep_cff::propagator, TrackerValidationVariables::AVHitStruct::rawDetId, DetId::rawId(), TrackerValidationVariables::AVHitStruct::resErrX, TrackerValidationVariables::AVHitStruct::resErrY, TrackerValidationVariables::AVHitStruct::resX, TrackerValidationVariables::AVHitStruct::resXprime, TrackerValidationVariables::AVHitStruct::resXprimeErr, TrackerValidationVariables::AVHitStruct::resY, TrackerValidationVariables::AVHitStruct::resYprime, TrackerValidationVariables::AVHitStruct::resYprimeErr, funct::sin(), mathSSE::sqrt(), RadialStripTopology::stripAngle(), DetId::subdetId(), TrajectoryStateOnSurface::surface(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, Surface::toGlobal(), GeomDetType::topology(), align::Tracker, GeomDetUnit::type(), TrackerAlignableId::typeAndLayerFromDetId(), MeasurementError::uu(), MeasurementError::vv(), tablePrinter::width, RectangularPlaneBounds::width(), PV3DBase< T, PVType, FrameType >::x(), PV2DBase< T, PVType, FrameType >::x(), LocalError::xx(), PV3DBase< T, PVType, FrameType >::y(), PV2DBase< T, PVType, FrameType >::y(), LocalError::yy(), and PV3DBase< T, PVType, FrameType >::z().
Referenced by MonitorTrackResiduals::analyze(), fillHitQuantities(), and fillTrackQuantities().
{ TrajectoryStateCombiner tsoscomb; const std::vector<TrajectoryMeasurement> &tmColl = trajectory->measurements(); for(std::vector<TrajectoryMeasurement>::const_iterator itTraj = tmColl.begin(); itTraj != tmColl.end(); ++itTraj) { if (!itTraj->updatedState().isValid()) continue; TrajectoryStateOnSurface tsos = tsoscomb( itTraj->forwardPredictedState(), itTraj->backwardPredictedState() ); TransientTrackingRecHit::ConstRecHitPointer hit = itTraj->recHit(); if(!hit->isValid() || hit->geographicalId().det() != DetId::Tracker) continue; AVHitStruct hitStruct; const DetId& hit_detId = hit->geographicalId(); unsigned int IntRawDetID = (hit_detId.rawId()); unsigned int IntSubDetID = (hit_detId.subdetId()); if(IntSubDetID == 0) continue; //first calculate residuals in cartesian coordinates in the local module coordinate system LocalPoint lPHit = hit->localPosition(); LocalPoint lPTrk = tsos.localPosition(); LocalVector lVTrk = tsos.localDirection(); hitStruct.localAlpha = atan2(lVTrk.x(), lVTrk.z()); // wrt. normal tg(alpha)=x/z hitStruct.localBeta = atan2(lVTrk.y(), lVTrk.z()); // wrt. normal tg(beta)= y/z //LocalError errHit = hit->localPositionError(); // adding APE to hitError AlgebraicROOTObject<2>::SymMatrix mat = asSMatrix<2>(hit->parametersError()); LocalError errHit = LocalError( mat(0,0),mat(0,1),mat(1,1) ); LocalError errTrk = tsos.localError().positionError(); //check for negative error values: track error can have negative value, if matrix inversion fails (very rare case) //hit error should always give positive values if(errHit.xx()<0. || errHit.yy()<0. || errTrk.xx()<0. || errTrk.yy()<0.){ edm::LogError("TrackerValidationVariables") << "@SUB=TrackerValidationVariables::fillHitQuantities" << "One of the squared error methods gives negative result" << "\n\terrHit.xx()\terrHit.yy()\terrTrk.xx()\terrTrk.yy()" << "\n\t" << errHit.xx() << "\t" << errHit.yy() << "\t" << errTrk.xx() << "\t" << errTrk.yy(); continue; } align::LocalVector res = lPTrk - lPHit; float resXErr = std::sqrt( errHit.xx() + errTrk.xx() ); float resYErr = std::sqrt( errHit.yy() + errTrk.yy() ); hitStruct.resX = res.x(); hitStruct.resY = res.y(); hitStruct.resErrX = resXErr; hitStruct.resErrY = resYErr; // hitStruct.localX = lPhit.x(); // hitStruct.localY = lPhit.y(); // EM: use predictions for local coordinates hitStruct.localX = lPTrk.x(); hitStruct.localY = lPTrk.y(); // now calculate residuals taking global orientation of modules and radial topology in TID/TEC into account float resXprime(999.F), resYprime(999.F); float resXprimeErr(999.F), resYprimeErr(999.F); if(hit->detUnit()){ // is it a single physical module? const GeomDetUnit& detUnit = *(hit->detUnit()); float uOrientation(-999.F), vOrientation(-999.F); float resXTopol(999.F), resYTopol(999.F); const Surface& surface = hit->detUnit()->surface(); const BoundPlane& boundplane = hit->detUnit()->surface(); const Bounds& bound = boundplane.bounds(); float length = 0; float width = 0; float widthAtHalfLength = 0; LocalPoint lPModule(0.,0.,0.), lUDirection(1.,0.,0.), lVDirection(0.,1.,0.); GlobalPoint gPModule = surface.toGlobal(lPModule), gUDirection = surface.toGlobal(lUDirection), gVDirection = surface.toGlobal(lVDirection); if (IntSubDetID == PixelSubdetector::PixelBarrel || IntSubDetID == StripSubdetector::TIB || IntSubDetID == StripSubdetector::TOB) { uOrientation = deltaPhi(gUDirection.phi(),gPModule.phi()) >= 0. ? +1.F : -1.F; vOrientation = gVDirection.z() - gPModule.z() >= 0 ? +1.F : -1.F; resXTopol = res.x(); resYTopol = res.y(); resXprimeErr = resXErr; resYprimeErr = resYErr; const RectangularPlaneBounds *rectangularBound = dynamic_cast<const RectangularPlaneBounds*>(&bound); hitStruct.inside = rectangularBound->inside(lPTrk); length = rectangularBound->length(); width = rectangularBound->width(); hitStruct.localXnorm = 2*hitStruct.localX/width; hitStruct.localYnorm = 2*hitStruct.localY/length; } else if (IntSubDetID == PixelSubdetector::PixelEndcap) { uOrientation = gUDirection.perp() - gPModule.perp() >= 0 ? +1.F : -1.F; vOrientation = deltaPhi(gVDirection.phi(),gPModule.phi()) >= 0. ? +1.F : -1.F; resXTopol = res.x(); resYTopol = res.y(); resXprimeErr = resXErr; resYprimeErr = resYErr; const RectangularPlaneBounds *rectangularBound = dynamic_cast<const RectangularPlaneBounds*>(&bound); hitStruct.inside = rectangularBound->inside(lPTrk); length = rectangularBound->length(); width = rectangularBound->width(); hitStruct.localXnorm = 2*hitStruct.localX/width; hitStruct.localYnorm = 2*hitStruct.localY/length; } else if (IntSubDetID == StripSubdetector::TID || IntSubDetID == StripSubdetector::TEC) { uOrientation = deltaPhi(gUDirection.phi(),gPModule.phi()) >= 0. ? +1.F : -1.F; vOrientation = gVDirection.perp() - gPModule.perp() >= 0. ? +1.F : -1.F; if (!dynamic_cast<const RadialStripTopology*>(&detUnit.type().topology()))continue; const RadialStripTopology& topol = dynamic_cast<const RadialStripTopology&>(detUnit.type().topology()); MeasurementPoint measHitPos = topol.measurementPosition(lPHit); MeasurementPoint measTrkPos = topol.measurementPosition(lPTrk); MeasurementError measHitErr = topol.measurementError(lPHit,errHit); MeasurementError measTrkErr = topol.measurementError(lPTrk,errTrk); if (measHitErr.uu()<0. || measHitErr.vv()<0. || measTrkErr.uu()<0. || measTrkErr.vv()<0.){ edm::LogError("TrackerValidationVariables") << "@SUB=TrackerValidationVariables::fillHitQuantities" << "One of the squared error methods gives negative result" << "\n\tmeasHitErr.uu()\tmeasHitErr.vv()\tmeasTrkErr.uu()\tmeasTrkErr.vv()" << "\n\t" << measHitErr.uu() << "\t" << measHitErr.vv() << "\t" << measTrkErr.uu() << "\t" << measTrkErr.vv(); continue; } float localStripLengthHit = topol.localStripLength(lPHit); float localStripLengthTrk = topol.localStripLength(lPTrk); float phiHit = topol.stripAngle(measHitPos.x()); float phiTrk = topol.stripAngle(measTrkPos.x()); float r_0 = topol.originToIntersection(); resXTopol = (phiTrk-phiHit)*r_0; //resYTopol = measTrkPos.y()*localStripLengthTrk - measHitPos.y()*localStripLengthHit; float cosPhiHit(cos(phiHit)), cosPhiTrk(cos(phiTrk)), sinPhiHit(sin(phiHit)), sinPhiTrk(sin(phiTrk)); float l_0 = r_0 - topol.detHeight()/2; resYTopol = measTrkPos.y()*localStripLengthTrk - measHitPos.y()*localStripLengthHit + l_0*(1/cosPhiTrk - 1/cosPhiHit); resXprimeErr = std::sqrt(measHitErr.uu()+measTrkErr.uu())*topol.angularWidth()*r_0; //resYprimeErr = std::sqrt(measHitErr.vv()*localStripLengthHit*localStripLengthHit + measTrkErr.vv()*localStripLengthTrk*localStripLengthTrk); float helpSummand = l_0*l_0*topol.angularWidth()*topol.angularWidth()*(sinPhiHit*sinPhiHit/pow(cosPhiHit,4)*measHitErr.uu() + sinPhiTrk*sinPhiTrk/pow(cosPhiTrk,4)*measTrkErr.uu() ); resYprimeErr = std::sqrt(measHitErr.vv()*localStripLengthHit*localStripLengthHit + measTrkErr.vv()*localStripLengthTrk*localStripLengthTrk + helpSummand ); const TrapezoidalPlaneBounds *trapezoidalBound = dynamic_cast < const TrapezoidalPlaneBounds * >(& bound); hitStruct.inside = trapezoidalBound->inside(lPTrk); length = trapezoidalBound->length(); width = trapezoidalBound->width(); widthAtHalfLength = trapezoidalBound->widthAtHalfLength(); int yAxisOrientation=trapezoidalBound->yAxisOrientation(); // for trapezoidal shape modules, scale with as function of local y coordinate float widthAtlocalY=width-(1-yAxisOrientation*2*lPTrk.y()/length)*(width-widthAtHalfLength); hitStruct.localXnorm = 2*hitStruct.localX/widthAtlocalY; hitStruct.localYnorm = 2*hitStruct.localY/length; } else { edm::LogWarning("TrackerValidationVariables") << "@SUB=TrackerValidationVariables::fillHitQuantities" << "No valid tracker subdetector " << IntSubDetID; continue; } resXprime = resXTopol*uOrientation; resYprime = resYTopol*vOrientation; } else { // not a detUnit, so must be a virtual 2D-Module // FIXME: at present only for det units residuals are calculated and filled in the hitStruct // But in principle this method should also be useable for the gluedDets (2D modules in TIB, TID, TOB, TEC) // In this case, only orientation should be taken into account for primeResiduals, but not the radial topology // At present, default values (999.F) are given out } hitStruct.resXprime = resXprime; hitStruct.resYprime = resYprime; hitStruct.resXprimeErr = resXprimeErr; hitStruct.resYprimeErr = resYprimeErr; hitStruct.rawDetId = IntRawDetID; hitStruct.phi = tsos.globalDirection().phi(); hitStruct.eta = tsos.globalDirection().eta(); // first try for overlap residuals // based on Code from Keith and Wolfgang if (itTraj+1 != tmColl.end()) { TransientTrackingRecHit::ConstRecHitPointer hit2 = (itTraj+1)->recHit(); TrackerAlignableId ali1, ali2; if (hit2->isValid() && ali1.typeAndLayerFromDetId(hit->geographicalId()) == ali2.typeAndLayerFromDetId(hit2->geographicalId()) && hit2->geographicalId().rawId() != SiStripDetId(IntRawDetID).partnerDetId()) { float overlapPath_; TrajectoryStateCombiner combiner_; AnalyticalPropagator propagator(&(*magneticField_)); // forward and backward predicted states at module 1 TrajectoryStateOnSurface fwdPred1 = (itTraj)->forwardPredictedState(); TrajectoryStateOnSurface bwdPred1 = (itTraj)->backwardPredictedState(); if ( !fwdPred1.isValid() || !bwdPred1.isValid() ) continue; // backward predicted state at module 2 TrajectoryStateOnSurface bwdPred2 = (itTraj+1)->backwardPredictedState(); TrajectoryStateOnSurface fwdPred2 = (itTraj+1)->forwardPredictedState(); if ( !bwdPred2.isValid() ) continue; // extrapolation bwdPred2 to module 1 TrajectoryStateOnSurface bwdPred2At1 = propagator.propagate(bwdPred2,fwdPred1.surface()); if ( !bwdPred2At1.isValid() ) continue; // combination with fwdPred1 (ref. state, best estimate without hits 1 and 2) TrajectoryStateOnSurface comb1 = combiner_.combine(fwdPred1,bwdPred2At1); if ( !comb1.isValid() ) continue; // // propagation of reference parameters to module 2 // std::pair<TrajectoryStateOnSurface,double> tsosWithS = propagator.propagateWithPath(comb1,bwdPred2.surface()); TrajectoryStateOnSurface comb1At2 = tsosWithS.first; // Alternative possibility, not used at present // TrajectoryStateOnSurface comb1At2 = propagator.propagate(comb1,bwdPred2.surface()); if ( !comb1At2.isValid() ) continue; overlapPath_ = tsosWithS.second; std::vector<GlobalPoint> predictedPositions; predictedPositions.push_back(comb1.globalPosition()); predictedPositions.push_back(comb1At2.globalPosition()); GlobalVector diff_pred = predictedPositions[0] - predictedPositions[1]; TrajectoryStateOnSurface tsos2 = tsoscomb( (itTraj+1)->forwardPredictedState(), (itTraj+1)->backwardPredictedState() ); align::LocalVector res2 = tsos2.localPosition() - hit2->localPosition(); //float overlapresidual = res2.x() - res.x(); float overlapresidual = diff_pred.x(); hitStruct.overlapres = std::make_pair(hit2->geographicalId().rawId(),overlapresidual); } } v_avhitout.push_back(hitStruct); } }
void TrackerValidationVariables::fillHitQuantities | ( | const edm::Event & | event, |
std::vector< AVHitStruct > & | v_avhitout | ||
) |
Definition at line 379 of file TrackerValidationVariables.cc.
References conf_, fillHitQuantities(), edm::ParameterSet::getParameter(), and LogDebug.
{ edm::Handle<std::vector<Trajectory> > trajCollectionHandle; event.getByLabel(conf_.getParameter<std::string>("trajectoryInput"), trajCollectionHandle); LogDebug("TrackerValidationVariables") << "trajColl->size(): " << trajCollectionHandle->size() ; for (std::vector<Trajectory>::const_iterator it = trajCollectionHandle->begin(), itEnd = trajCollectionHandle->end(); it!=itEnd; ++it) { fillHitQuantities(&(*it), v_avhitout); } }
void TrackerValidationVariables::fillTrackQuantities | ( | const edm::Event & | event, |
std::vector< AVTrackStruct > & | v_avtrackout | ||
) |
Definition at line 333 of file TrackerValidationVariables.cc.
References TrackerValidationVariables::AVTrackStruct::charge, reco::TrackBase::charge(), reco::TrackBase::chi2(), TrackerValidationVariables::AVTrackStruct::chi2, TrackerValidationVariables::AVTrackStruct::chi2Prob, conf_, TrackerValidationVariables::AVTrackStruct::d0, reco::TrackBase::d0(), TrackerValidationVariables::AVTrackStruct::dz, reco::TrackBase::dz(), reco::TrackBase::eta(), TrackerValidationVariables::AVTrackStruct::eta, fillHitQuantities(), edm::ParameterSet::getParameter(), TrackerValidationVariables::AVTrackStruct::hits, TrackerValidationVariables::AVTrackStruct::kappa, LogDebug, magneticField_, reco::TrackBase::ndof(), reco::TrackBase::normalizedChi2(), TrackerValidationVariables::AVTrackStruct::normchi2, TrackerValidationVariables::AVTrackStruct::numberOfLostHits, reco::TrackBase::numberOfLostHits(), reco::TrackBase::numberOfValidHits(), TrackerValidationVariables::AVTrackStruct::numberOfValidHits, TrackerValidationVariables::AVTrackStruct::p, reco::TrackBase::p(), reco::TrackBase::phi(), TrackerValidationVariables::AVTrackStruct::phi, reco::TrackBase::pt(), TrackerValidationVariables::AVTrackStruct::pt, TrackerValidationVariables::AVTrackStruct::ptError, reco::TrackBase::ptError(), TrackerValidationVariables::AVTrackStruct::px, reco::TrackBase::px(), TrackerValidationVariables::AVTrackStruct::py, reco::TrackBase::py(), TrackerValidationVariables::AVTrackStruct::pz, reco::TrackBase::pz(), ExpressReco_HICollisions_FallBack::track, reco::TrackBase::vx(), reco::TrackBase::vy(), and reco::TrackBase::vz().
Referenced by TrackerOfflineValidation::analyze().
{ edm::InputTag TrjTrackTag = conf_.getParameter<edm::InputTag>("Tracks"); edm::Handle<TrajTrackAssociationCollection> TrajTracksMap; event.getByLabel(TrjTrackTag, TrajTracksMap); LogDebug("TrackerValidationVariables") << "TrajTrack collection size " << TrajTracksMap->size(); const Trajectory* trajectory; const reco::Track* track; for ( TrajTrackAssociationCollection::const_iterator iPair = TrajTracksMap->begin(); iPair != TrajTracksMap->end(); ++iPair) { trajectory = &(*(*iPair).key); track = &(*(*iPair).val); AVTrackStruct trackStruct; trackStruct.p = track->p(); trackStruct.pt = track->pt(); trackStruct.ptError = track->ptError(); trackStruct.px = track->px(); trackStruct.py = track->py(); trackStruct.pz = track->pz(); trackStruct.eta = track->eta(); trackStruct.phi = track->phi(); trackStruct.chi2 = track->chi2(); trackStruct.chi2Prob= TMath::Prob(track->chi2(),track->ndof()); trackStruct.normchi2 = track->normalizedChi2(); GlobalPoint gPoint(track->vx(), track->vy(), track->vz()); double theLocalMagFieldInInverseGeV = magneticField_->inInverseGeV(gPoint).z(); trackStruct.kappa = -track->charge()*theLocalMagFieldInInverseGeV/track->pt(); trackStruct.charge = track->charge(); trackStruct.d0 = track->d0(); trackStruct.dz = track->dz(); trackStruct.numberOfValidHits = track->numberOfValidHits(); trackStruct.numberOfLostHits = track->numberOfLostHits(); fillHitQuantities(trajectory, trackStruct.hits); v_avtrackout.push_back(trackStruct); } }
const edm::ParameterSet TrackerValidationVariables::conf_ [private] |
Definition at line 83 of file TrackerValidationVariables.h.
Referenced by fillHitQuantities(), and fillTrackQuantities().
Definition at line 85 of file TrackerValidationVariables.h.
Referenced by fillHitQuantities(), fillTrackQuantities(), and TrackerValidationVariables().
Definition at line 84 of file TrackerValidationVariables.h.
Referenced by TrackerValidationVariables().