7#include "GaudiKernel/ConcurrencyFlags.h"
8#include "GaudiKernel/IIncidentSvc.h"
9#include "GaudiKernel/ITHistSvc.h"
29 constexpr float SIG_VEL = 4.80000;
30 constexpr float C_VEL = 3.33564;
46 declareInterface<IMuonRecoValidationTool>(
this);
59 if (Gaudi::Concurrency::ConcurrencyFlags::numThreads() > 1) {
60 ATH_MSG_ERROR(
"This tool cannot be used in multi-threaded mode");
61 return StatusCode::FAILURE;
76 SmartIF<ITHistSvc> thistSvc{service(
"THistSvc")};
79 m_tree =
new TTree(
"data",
"RecoValidation");
88 return StatusCode::SUCCESS;
100 if (inc.type() == IncidentType::EndEvent) {
109 m_ntuple.trackParticleBlock.pt->push_back(indetTrackParticle.
pt());
110 m_ntuple.trackParticleBlock.p->push_back(1. / indetTrackParticle.
qOverP());
111 m_ntuple.trackParticleBlock.eta->push_back(indetTrackParticle.
eta());
112 m_ntuple.trackParticleBlock.phi->push_back(indetTrackParticle.
phi());
119 truthParticleLinkAcc(
"truthParticleLink");
120 if (truthParticleLinkAcc.
isAvailable(indetTrackParticle)) {
121 const ElementTruthLink_t link = truthParticleLinkAcc(indetTrackParticle);
122 if (link.isValid()) {
123 pdg = (*link)->pdgId();
125 beta = (*link)->p4().Beta();
128 m_ntuple.trackParticleBlock.truth.fill(pdg, uniqueID, beta);
143 const std::vector<Muon::MuonSystemExtension::Intersection>& layerIntersections = muonSystemExtension.
layerIntersections();
144 ATH_MSG_DEBUG(
"Adding ID track: pt " << indetTrackParticle.
pt() <<
" eta " << indetTrackParticle.
eta() <<
" phi "
145 << indetTrackParticle.
phi() <<
" layers " << layerIntersections.size());
147 for (std::vector<Muon::MuonSystemExtension::Intersection>::const_iterator it = layerIntersections.begin();
148 it != layerIntersections.end(); ++it) {
159 std::map<int, int> counters;
160 for (std::set<Identifier>::const_iterator it = ids.begin(); it != ids.end(); ++it) {
168 for (std::map<int, int>::iterator it = counters.begin(); it != counters.end(); ++it) {
169 if (it->second >
max) {
189 for (
const auto& stauHit : stauHits) {
192 double r = std::hypot(stauHit.x, stauHit.y);
193 double tof = muonBetaCalculationUtils.
calculateTof(1, std::hypot(
r, stauHit.z));
202 stauHit.error, stauHit.propagationTime, stauHit.e, tof, 0., stauHit.shift, 1000 *
m_candidateCounter);
210 m_ntuple.timeBlock.truth.fill(pdg, uniqueID);
217 const Amg::Vector3D& gpos,
float time,
float errorTime)
const {
225 m_ntuple.timeBlock.fill(2,
m_idHelperSvc->gasGapId(
id).get_identifier32().get_compact(), gpos.perp(), gpos.z(), time, errorTime);
233 m_ntuple.timeBlock.truth.fill(pdg, uniqueID);
240 float segmentTimeCorrection = 0.;
254 std::set<Identifier> ids;
255 std::vector<const MuonClusterOnTrack*> clusters;
260 m_ntuple.timeBlock.truth.fill(pdg, uniqueID);
278 m_ntuple.timeBlock.truth.fill(pdg, uniqueID);
287 double correct_time_along_strip = 0;
295 double av_correct_time_along_strip = 0;
297 av_correct_time_along_strip = rpc_readout_element->
distanceToEtaReadout(posi) / 1000. * SIG_VEL;
299 av_correct_time_along_strip = rpc_readout_element->
distanceToPhiReadout(posi) / 1000. * SIG_VEL;
303 double real_TOF_onRPCgap = GP.mag() / 1000. * C_VEL;
304 double nominal_TOF_onRPCgap = posi.mag() / 1000. * C_VEL;
307 double correct_time_tot = real_TOF_onRPCgap - nominal_TOF_onRPCgap + correct_time_along_strip - av_correct_time_along_strip;
311 rpc->
globalPosition().z(), rpc->
time(), 2., correct_time_along_strip, av_correct_time_along_strip,
312 real_TOF_onRPCgap, nominal_TOF_onRPCgap, correct_time_tot);
321 const EventContext& ctx = Gaudi::Hive::currentContext();
322 m_ntuple.segmentBlock.stage->push_back(stage);
335 m_ntuple.segmentBlock.t0Error->push_back(t0Error);
338 std::set<Identifier> ids;
339 std::vector<const MuonClusterOnTrack*> clusters;
340 extract(segment, ids, clusters);
346 m_ntuple.segmentBlock.t0TrigError->push_back(t0Error);
358 m_ntuple.segmentBlock.truth.fill(pdg, uniqueID);
363 std::shared_ptr<Trk::TrackParameters> exPars(
367 m_ntuple.segmentBlock.quality->push_back(-2);
368 m_ntuple.segmentBlock.xresiduals.fill(0., 1., 0., 1., -1);
369 m_ntuple.segmentBlock.yresiduals.fill(0., 1., 0., 1., -1);
370 m_ntuple.segmentBlock.angleXZ.fill(0., 1., 0., 1., -1);
371 m_ntuple.segmentBlock.angleYZ.fill(0., 1., 0., 1., -1);
372 m_ntuple.segmentBlock.combinedYZ.fill(0., 1., 0., 1., -1);
377 std::shared_ptr<Trk::AtaPlane> ataPlane = std::dynamic_pointer_cast<Trk::AtaPlane>(exPars);
380 m_ntuple.segmentBlock.quality->push_back(-2);
381 m_ntuple.segmentBlock.angleXZ.fill(0., 1., 0., 1., -1);
382 m_ntuple.segmentBlock.angleYZ.fill(0., 1., 0., 1., -1);
383 m_ntuple.segmentBlock.combinedYZ.fill(0., 1., 0., 1., -1);
403 m_ntuple.houghBlock.maximum->push_back(maximum.
max);
419 std::set<Identifier> ids;
421 MuonHough::HitVec::const_iterator hit = maximum.
hits.begin();
422 MuonHough::HitVec::const_iterator hit_end = maximum.
hits.end();
423 for (; hit != hit_end; ++hit) {
426 for (
const auto& prd : (*hit)->tgc->etaCluster) ids.insert(prd->identify());
427 }
else if ((*hit)->prd) {
428 ids.insert((*hit)->prd->identify());
436 m_ntuple.houghBlock.truth.fill(pdg, uniqueID);
444 float expos_err)
const {
454 m_ntuple.hitBlock.truth.fill(pdg, uniqueID);
456 float sign = expos < 0 ? -1. : 1.;
464 std::vector<const MuonClusterOnTrack*>& clusters)
const {
466 std::vector<const Trk::MeasurementBase*>::const_iterator mit = segment.
containedMeasurements().begin();
467 std::vector<const Trk::MeasurementBase*>::const_iterator mit_end = segment.
containedMeasurements().end();
468 for (; mit != mit_end; ++mit) {
471 if (!
id.is_valid())
continue;
478 clusters.push_back(clus);
488 Trk::Track* combinedTrack,
int ntimes,
float beta,
float chi2ndof,
int stage)
const {
503 nprec = summary.nprecisionLayers;
504 ntrigPhi = summary.nphiLayers;
505 ntrigEta = summary.ntrigEtaLayers;
507 m_ntuple.candidateBlock.fill(ntimes, beta, chi2ndof, nseg, nprec, ntrigPhi, ntrigEta, stage);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Helper class to provide constant type-safe access to aux data.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ElementLink implementation for ROOT usage.
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
double distanceToEtaReadout(const Amg::Vector3D &P) const
Amg::Vector3D stripPos(const Identifier &id) const
double distanceToPhiReadout(const Amg::Vector3D &P) const
Class for competing MuonClusters, it extends the Trk::CompetingRIOsOnTrack base class.
const std::vector< const MuonClusterOnTrack * > & containedROTs() const
returns the vector of SCT_ClusterOnTrack objects .
float calculateTof(float beta, float dist)
Base class for Muon cluster RIO_OnTracks.
virtual const Amg::Vector3D & globalPosition() const override
Returns global position.
This is the common class for 3D segments used in the muon spectrometer.
bool hasFittedT0() const
returns whether the segment has a fitted t0
virtual const Amg::Vector3D & globalPosition() const override final
global position
virtual const Trk::PlaneSurface & associatedSurface() const override final
returns the surface for the local to global transformation
Tracking class to hold the extrapolation from a particle from the calo entry to the end of muon syste...
const std::vector< Intersection > & layerIntersections() const
access to the intersections with the layers.
Class to represent calibrated clusters formed from RPC strips.
virtual const RpcPrepData * prepRawData() const override final
Returns the RpcPrepData - is a TRT_DriftCircle in this scope.
float time() const
Return the time (ns)
Class to represent RPC measurements.
virtual const MuonGM::RpcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD.
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
This class is the pure abstract base class for all fittable tracking measurements.
const Amg::Vector2D & localPosition() const
return the local position reference
Identifier identify() const
return the identifier
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
Identifier identify() const
return the identifier -extends MeasurementBase
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
float errorTime() const
access to the error on the measured time
float time() const
access to the measured time
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
float qOverP() const
Returns the parameter.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Matrix< double, 3, 1 > Vector3D
constexpr int INVALID_PARTICLE_ID
std::vector< StauHit > StauHits
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
constexpr int toInt(const EnumType enumVal)
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
double segErrorXZ
error from segment on angle in non-bending plane
double segErrorY
error from segment on residual in bending plane
double dangleYZ
angular residual in the Local coordinate bending plane
double exErrorX
error from extrapolation on residual in non-bending plane
double exErrorY
error from extrapolation on residual in bending plane
double pullCY
pull on combined local position Y and angle YZ
double resY
residual track - segment in Local coordinate in bending plane
double exErrorXZ
error from extrapolation on angle in non-bending plane
double pullXZ
pull on angle in non-bending plane
double pullX
pull on residual in non-bending plane
double resCY
residual on combined local position Y and angle YZ
double pullYZ
pull on angle in bending plane
double segErrorX
error from segment on residual in non-bending plane
double segErrorYZ
error from segment on angle in bending plane
double exErrorYZ
error from extrapolation on angle in bending plane
double pullY
pull on residual in bending plane
int quality
hit count summary
double resX
residual track - segment in Local coordinate non-bending plane
double dangleXZ
angular residual in the Local coordinate non-bending plane
struct representing the maximum in the hough space
const MuonLayerHough * hough
RegionDescriptor m_descriptor
std::vector< MuonLayerIntersection > layerIntersections
MuonLayerIntersections.