ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::MuonRecoValidationTool Class Reference

#include <MuonRecoValidationTool.h>

Inheritance diagram for Muon::MuonRecoValidationTool:

Public Member Functions

 MuonRecoValidationTool (const std::string &, const std::string &, const IInterface *)
 default AlgTool constructor
 ~MuonRecoValidationTool ()=default
 destructor
virtual StatusCode initialize () override
 initialize method, method taken from bass-class AlgTool
bool addTrackParticle (const xAOD::TrackParticle &indetTrackParticle, const MuonSystemExtension &muonSystemExtention) const override
 add a new TrackParticle with it's muon system extension
bool add (const MuonSystemExtension::Intersection &intersection, const MuonSegment &segment, int stage) const override
 add a new segment
bool add (const MuonSystemExtension::Intersection &intersection, const MuonHough::MuonLayerHough::Maximum &maximum) const override
 add a new hough maximum
bool add (const MuonSystemExtension::Intersection &intersection, const Trk::PrepRawData &prd, float expos, float expos_err) const override
 add a new prd
bool addTimeMeasurement (const MuonSystemExtension::Intersection &intersection, const Trk::MeasurementBase &meas) const override
 add a new time measurement
bool addTimeMeasurement (const MuonSystemExtension::Intersection &intersection, const Identifier &id, const Amg::Vector3D &gpos, float time, float errorTime) const override
 add a new time measurement
bool addTimeMeasurements (const xAOD::TrackParticle &indetTrackParticle, const MuGirlNS::StauHits &stauHits) const override
 add StauHits to ntuple
bool addMuonCandidate (const xAOD::TrackParticle &indetTrackParticle, const MuonCandidate *candidate, Trk::Track *combinedTrack, int ntimes, float beta, float chi2ndof, int stage) const override
 add a new muon candidate
virtual void handle (const Incident &inc) override
 incident service handle for EndEvent
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 AlgTool and IAlgTool interface methods.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

void clear ()
 clear ntuples
void extract (const MuonSegment &segment, std::set< Identifier > &ids, std::vector< const MuonClusterOnTrack * > &clusters) const
int getIndex (const MuonSystemExtension::Intersection &intersection) const
int getUniqueID (const std::set< Identifier > &ids) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
ServiceHandle< IMuonEDMHelperSvcm_edmHelperSvc
ToolHandle< IMuonSegmentHitSummaryToolm_segmentHitSummaryTool
ToolHandle< IMuonHitSummaryToolm_hitSummaryTool
ToolHandle< IMuonTruthSummaryToolm_truthSummaryTool
ToolHandle< Trk::IExtrapolatorm_extrapolator
ToolHandle< IMuTagMatchingToolm_matchingTool
ToolHandle< IMuonHitTimingToolm_hitTimingTool
ServiceHandle< IIncidentSvc > m_incidentSvc
std::vector< const xAOD::TrackParticle * > m_trackParticles
std::map< const Trk::TrackParameters *, unsigned int > m_trackParticleIndexLookup
MuonInsideOutValidationNtuple m_ntuple
TTree * m_tree = nullptr
std::atomic< unsigned int > m_candidateCounter
bool m_isMC
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 46 of file MuonRecoValidationTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ MuonRecoValidationTool()

Muon::MuonRecoValidationTool::MuonRecoValidationTool ( const std::string & t,
const std::string & n,
const IInterface * p )

default AlgTool constructor

Definition at line 36 of file MuonRecoValidationTool.cxx.

36 :
37 AthAlgTool(t, n, p),
38 m_segmentHitSummaryTool("Muon::MuonSegmentHitSummaryTool/MuonSegmentHitSummaryTool"),
39 m_hitSummaryTool("Muon::MuonHitSummaryTool/MuonHitSummaryTool"),
40 m_truthSummaryTool("Muon::MuonTruthSummaryTool/MuonTruthSummaryTool"),
41 m_extrapolator("Trk::Extrapolation/AtlasExtrapolator"),
42 m_matchingTool("MuTagMatchingTool/MuTagMatchingTool"),
43 m_hitTimingTool("Muon::MuonHitTimingTool/MuonHitTimingTool"),
44 m_incidentSvc("IncidentSvc", n),
46 declareInterface<IMuonRecoValidationTool>(this);
47 declareProperty("MuonSegmentHitSummaryTool", m_segmentHitSummaryTool);
48 declareProperty("MuonHitSummaryTool", m_hitSummaryTool);
49 declareProperty("MuonTruthSummaryTool", m_truthSummaryTool);
50 declareProperty("Extrapolator", m_extrapolator);
51 declareProperty("MatchTool", m_matchingTool);
52 declareProperty("MuonHitTimingTool", m_hitTimingTool);
53 declareProperty("IncidentSvc", m_incidentSvc);
54 declareProperty("isMC", m_isMC = false);
55 }
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< IMuTagMatchingTool > m_matchingTool
std::atomic< unsigned int > m_candidateCounter
ToolHandle< Trk::IExtrapolator > m_extrapolator
ToolHandle< IMuonSegmentHitSummaryTool > m_segmentHitSummaryTool
ServiceHandle< IIncidentSvc > m_incidentSvc
ToolHandle< IMuonHitTimingTool > m_hitTimingTool
ToolHandle< IMuonTruthSummaryTool > m_truthSummaryTool
ToolHandle< IMuonHitSummaryTool > m_hitSummaryTool

◆ ~MuonRecoValidationTool()

Muon::MuonRecoValidationTool::~MuonRecoValidationTool ( )
default

destructor

Member Function Documentation

◆ add() [1/3]

bool Muon::MuonRecoValidationTool::add ( const MuonSystemExtension::Intersection & intersection,
const MuonHough::MuonLayerHough::Maximum & maximum ) const
overridevirtual

add a new hough maximum

Implements Muon::IMuonRecoValidationTool.

Definition at line 401 of file MuonRecoValidationTool.cxx.

402 {
403 m_ntuple.houghBlock.maximum->push_back(maximum.max);
404
405 m_ntuple.houghBlock.track.fill(getIndex(intersection));
406
407 int sector = -1;
408 int chIndex = -1;
409 float maxwidth = (maximum.binposmax - maximum.binposmin);
410 if (maximum.hough) {
411 maxwidth *= maximum.hough->m_binsize;
412 sector = maximum.hough->m_descriptor.sector;
414 }
415 m_ntuple.houghBlock.id.fill(sector, chIndex);
416 m_ntuple.houghBlock.residuals.fill(maximum.pos, maxwidth, intersection, Trk::loc1);
417
418 // get truth from hits
419 std::set<Identifier> ids;
420
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) {
424 // treat the case that the hit is a composite TGC hit
425 if ((*hit)->tgc) {
426 for (const auto& prd : (*hit)->tgc->etaCluster) ids.insert(prd->identify());
427 } else if ((*hit)->prd) {
428 ids.insert((*hit)->prd->identify());
429 }
430 }
432 if (m_isMC) {
433 uniqueID = getUniqueID(ids);
434 pdg = uniqueID != HepMC::INVALID_PARTICLE_ID ? m_truthSummaryTool->getPdgId(uniqueID) : 0;
435 }
436 m_ntuple.houghBlock.truth.fill(pdg, uniqueID);
437
438 ATH_MSG_DEBUG(" Adding Hough maximum to ntuple ");
439
440 return true;
441 }
#define ATH_MSG_DEBUG(x)
int getUniqueID(const std::set< Identifier > &ids) const
int getIndex(const MuonSystemExtension::Intersection &intersection) const
MuonInsideOutValidationNtuple m_ntuple
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
constexpr int INVALID_PARTICLE_ID
int uniqueID(const T &p)
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
constexpr int toInt(const EnumType enumVal)
@ loc1
Definition ParamDefs.h:34
RegionDescriptor m_descriptor

◆ add() [2/3]

bool Muon::MuonRecoValidationTool::add ( const MuonSystemExtension::Intersection & intersection,
const MuonSegment & segment,
int stage ) const
overridevirtual

add a new segment

Implements Muon::IMuonRecoValidationTool.

Definition at line 320 of file MuonRecoValidationTool.cxx.

320 {
321 const EventContext& ctx = Gaudi::Hive::currentContext();
322 m_ntuple.segmentBlock.stage->push_back(stage);
323
324 Identifier id = m_edmHelperSvc->chamberId(segment);
325 m_ntuple.segmentBlock.id.fill(m_idHelperSvc->sector(id), toInt(m_idHelperSvc->chamberIndex(id)));
326
327 // position information
328 m_ntuple.segmentBlock.r->push_back(segment.globalPosition().perp());
329 m_ntuple.segmentBlock.z->push_back(segment.globalPosition().z());
330
331 // timing information
332 float t0 = segment.hasFittedT0() ? segment.time() : -99999;
333 float t0Error = segment.hasFittedT0() ? segment.errorTime() : -99999;
334 m_ntuple.segmentBlock.t0->push_back(t0);
335 m_ntuple.segmentBlock.t0Error->push_back(t0Error);
336
337 // extract clusters and ids
338 std::set<Identifier> ids;
339 std::vector<const MuonClusterOnTrack*> clusters;
340 extract(segment, ids, clusters);
341
342 IMuonHitTimingTool::TimingResult result = m_hitTimingTool->calculateTimingResult(clusters);
343 t0 = result.valid ? result.time : -99999;
344 t0Error = result.valid ? result.error : -99999;
345 m_ntuple.segmentBlock.t0Trig->push_back(t0);
346 m_ntuple.segmentBlock.t0TrigError->push_back(t0Error);
347
348 // hit counts
349 IMuonSegmentHitSummaryTool::HitCounts hitCounts = m_segmentHitSummaryTool->getHitCounts(segment);
350 m_ntuple.segmentBlock.nmdtHits->push_back(hitCounts.nmdtHits()+ hitCounts.nmmHits() + hitCounts.ncscHits.netaHits);
351 m_ntuple.segmentBlock.ntrigEtaHits->push_back(hitCounts.netaTrigHitLayers);
352 m_ntuple.segmentBlock.ntrigPhiHits->push_back(hitCounts.nphiTrigHitLayers);
353
354 // uniqueID + pdg
355 int uniqueID = getUniqueID(ids);
356 int pdg = 0;
357 if (m_isMC) pdg = uniqueID != HepMC::INVALID_PARTICLE_ID ? m_truthSummaryTool->getPdgId(uniqueID) : 0;
358 m_ntuple.segmentBlock.truth.fill(pdg, uniqueID);
359
360 m_ntuple.segmentBlock.track.fill(getIndex(intersection));
361
362 // extrapolate and create an intersection @ the segment surface.
363 std::shared_ptr<Trk::TrackParameters> exPars(
364 m_extrapolator->extrapolate(ctx, *intersection.trackParameters, segment.associatedSurface(), Trk::anyDirection, false, Trk::muon));
365 if (!exPars) {
366 ATH_MSG_VERBOSE(" extrapolation failed ");
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);
373 return false;
374 }
375
376 // cast to AtaPlane so we can get the segment info
377 std::shared_ptr<Trk::AtaPlane> ataPlane = std::dynamic_pointer_cast<Trk::AtaPlane>(exPars);
378 if (!ataPlane) {
379 ATH_MSG_WARNING(" dynamic_cast<> failed ");
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);
384 return false;
385 }
386 MuonCombined::MuonSegmentInfo segmentInfo = m_matchingTool->muTagSegmentInfo(ctx, nullptr, segment, ataPlane);
387 m_ntuple.segmentBlock.quality->push_back(segmentInfo.quality);
388 m_ntuple.segmentBlock.xresiduals.fillResPull(segmentInfo.resX, segmentInfo.pullX, segmentInfo.segErrorX, segmentInfo.exErrorX, 1);
389 m_ntuple.segmentBlock.yresiduals.fillResPull(segmentInfo.resY, segmentInfo.pullY, segmentInfo.segErrorY, segmentInfo.exErrorY, 1);
390 m_ntuple.segmentBlock.angleXZ.fillResPull(segmentInfo.dangleXZ, segmentInfo.pullXZ, segmentInfo.segErrorXZ, segmentInfo.exErrorXZ,
391 1);
392 m_ntuple.segmentBlock.angleYZ.fillResPull(segmentInfo.dangleYZ, segmentInfo.pullYZ, segmentInfo.segErrorYZ, segmentInfo.exErrorYZ,
393 1);
394 m_ntuple.segmentBlock.combinedYZ.fillResPull(segmentInfo.resCY, segmentInfo.pullCY, 1);
395
396 ATH_MSG_DEBUG(" Adding Segment to ntuple: stage " << stage);
397
398 return true;
399 }
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static Double_t t0
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
ServiceHandle< IMuonEDMHelperSvc > m_edmHelperSvc
void extract(const MuonSegment &segment, std::set< Identifier > &ids, std::vector< const MuonClusterOnTrack * > &clusters) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
float errorTime() const
access to the error on the measured time
float time() const
access to the measured time
@ anyDirection
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
double resX
residual track - segment in Local coordinate non-bending plane
double dangleXZ
angular residual in the Local coordinate non-bending plane

◆ add() [3/3]

bool Muon::MuonRecoValidationTool::add ( const MuonSystemExtension::Intersection & intersection,
const Trk::PrepRawData & prd,
float expos,
float expos_err ) const
overridevirtual

add a new prd

Implements Muon::IMuonRecoValidationTool.

Definition at line 443 of file MuonRecoValidationTool.cxx.

444 {
445 Identifier id = prd.identify();
446 m_ntuple.hitBlock.id.fill(m_idHelperSvc->sector(id), toInt(m_idHelperSvc->chamberIndex(id)));
447 m_ntuple.hitBlock.track.fill(getIndex(intersection));
448
450 if (m_isMC) {
451 uniqueID = m_truthSummaryTool->getUniqueID(id);
452 pdg = uniqueID != HepMC::INVALID_PARTICLE_ID ? m_truthSummaryTool->getPdgId(uniqueID) : 0;
453 }
454 m_ntuple.hitBlock.truth.fill(pdg, uniqueID);
455
456 float sign = expos < 0 ? -1. : 1.;
457 m_ntuple.hitBlock.residuals.fill(sign * prd.localPosition()[Trk::locX], Amg::error(prd.localCovariance(), Trk::locX), expos,
458 expos_err);
459
460 return true;
461 }
int sign(int a)
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
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 ...
@ locX
Definition ParamDefs.h:37

◆ addMuonCandidate()

bool Muon::MuonRecoValidationTool::addMuonCandidate ( const xAOD::TrackParticle & indetTrackParticle,
const MuonCandidate * candidate,
Trk::Track * combinedTrack,
int ntimes,
float beta,
float chi2ndof,
int stage ) const
overridevirtual

add a new muon candidate

Implements Muon::IMuonRecoValidationTool.

Definition at line 487 of file MuonRecoValidationTool.cxx.

488 {
489 auto pos = std::find(m_trackParticles.begin(), m_trackParticles.end(), &indetTrackParticle);
490 if (pos == m_trackParticles.end()) {
491 ATH_MSG_WARNING("addMuonCandidate: indetTrackParticle not found ");
492 return false;
493 }
494
495 m_ntuple.candidateBlock.track.fill(std::distance(m_trackParticles.begin(), pos));
496 int nprec = 0;
497 int ntrigPhi = 0;
498 int ntrigEta = 0;
499 int nseg = candidate ? candidate->layerIntersections.size() : 0;
500 const Trk::Track* track = combinedTrack;
501 if (combinedTrack) {
502 IMuonHitSummaryTool::CompactSummary summary = m_hitSummaryTool->summary(*track);
503 nprec = summary.nprecisionLayers;
504 ntrigPhi = summary.nphiLayers;
505 ntrigEta = summary.ntrigEtaLayers;
506 }
507 m_ntuple.candidateBlock.fill(ntimes, beta, chi2ndof, nseg, nprec, ntrigPhi, ntrigEta, stage);
508 return true;
509 }
std::vector< const xAOD::TrackParticle * > m_trackParticles
void combinedTrack(long int ICH, double *pv0, double *covi, double BMAG, double *par, double *covo)
Definition XYZtrp.cxx:113

◆ addTimeMeasurement() [1/2]

bool Muon::MuonRecoValidationTool::addTimeMeasurement ( const MuonSystemExtension::Intersection & intersection,
const Identifier & id,
const Amg::Vector3D & gpos,
float time,
float errorTime ) const
overridevirtual

add a new time measurement

Implements Muon::IMuonRecoValidationTool.

Definition at line 216 of file MuonRecoValidationTool.cxx.

217 {
218 // track index
219 m_ntuple.timeBlock.track.fill(getIndex(intersection));
220
221 // identifier info
222 m_ntuple.timeBlock.id.fill(m_idHelperSvc->sector(id), toInt(m_idHelperSvc->chamberIndex(id)));
223
224 // position information
225 m_ntuple.timeBlock.fill(2, m_idHelperSvc->gasGapId(id).get_identifier32().get_compact(), gpos.perp(), gpos.z(), time, errorTime);
226
227 // uniqueID + pdg
229 if (m_isMC) {
230 uniqueID = m_truthSummaryTool->getUniqueID(id);
231 pdg = uniqueID != HepMC::INVALID_PARTICLE_ID ? m_truthSummaryTool->getPdgId(uniqueID) : 0;
232 }
233 m_ntuple.timeBlock.truth.fill(pdg, uniqueID);
234
235 return true;
236 }

◆ addTimeMeasurement() [2/2]

bool Muon::MuonRecoValidationTool::addTimeMeasurement ( const MuonSystemExtension::Intersection & intersection,
const Trk::MeasurementBase & meas ) const
overridevirtual

add a new time measurement

Implements Muon::IMuonRecoValidationTool.

Definition at line 238 of file MuonRecoValidationTool.cxx.

239 {
240 float segmentTimeCorrection = 0.;
241
242 const MuonSegment* seg = dynamic_cast<const MuonSegment*>(&meas);
243 if (seg && seg->hasFittedT0()) {
244 m_ntuple.timeBlock.track.fill(getIndex(intersection));
245
246 Identifier id = m_edmHelperSvc->chamberId(*seg);
247 m_ntuple.timeBlock.id.fill(m_idHelperSvc->sector(id), toInt(m_idHelperSvc->chamberIndex(id)));
248
249 // position information
250 m_ntuple.timeBlock.fill(1, m_idHelperSvc->chamberId(id).get_identifier32().get_compact(), seg->globalPosition().perp(),
251 seg->globalPosition().z(), seg->time() - segmentTimeCorrection, seg->errorTime());
252
253 // uniqueID + pdg
254 std::set<Identifier> ids;
255 std::vector<const MuonClusterOnTrack*> clusters;
256 extract(*seg, ids, clusters);
257 int uniqueID = getUniqueID(ids);
258 int pdg = 0;
259 if (m_isMC) pdg = uniqueID != HepMC::INVALID_PARTICLE_ID ? m_truthSummaryTool->getPdgId(uniqueID) : 0;
260 m_ntuple.timeBlock.truth.fill(pdg, uniqueID);
261
262 return true;
263 }
264
265 const RpcClusterOnTrack* rpc = dynamic_cast<const RpcClusterOnTrack*>(&meas);
266 if (rpc) {
267 m_ntuple.timeBlock.track.fill(getIndex(intersection));
268
269 Identifier id = rpc->identify();
270 m_ntuple.timeBlock.id.fill(m_idHelperSvc->sector(id), toInt(m_idHelperSvc->chamberIndex(id)));
271
272 // uniqueID + pdg
274 if (m_isMC) {
275 uniqueID = m_truthSummaryTool->getUniqueID(id);
276 pdg = uniqueID != HepMC::INVALID_PARTICLE_ID ? m_truthSummaryTool->getPdgId(uniqueID) : 0;
277 }
278 m_ntuple.timeBlock.truth.fill(pdg, uniqueID);
279
280 bool measphi = m_idHelperSvc->measuresPhi(id);
281 const Amg::Vector3D& GP = rpc->globalPosition();
282 const Muon::RpcPrepData* MClus = rpc->prepRawData();
283 const MuonGM::RpcReadoutElement* rpc_readout_element = MClus->detectorElement();
284 Amg::Vector3D posi = rpc_readout_element->stripPos(id);
285
286 // let's correct rpc time subtracting delay due to the induced electric signal propagation along strip
287 double correct_time_along_strip = 0;
288 if (measphi == 0) {
289 correct_time_along_strip = rpc_readout_element->distanceToEtaReadout(GP) / 1000. * SIG_VEL;
290 } else {
291 correct_time_along_strip = rpc_readout_element->distanceToPhiReadout(GP) / 1000. * SIG_VEL;
292 }
293
294 // let's evaluate the average delay due to the induced electric signal propagation along strip
295 double av_correct_time_along_strip = 0;
296 if (measphi == 0) {
297 av_correct_time_along_strip = rpc_readout_element->distanceToEtaReadout(posi) / 1000. * SIG_VEL;
298 } else {
299 av_correct_time_along_strip = rpc_readout_element->distanceToPhiReadout(posi) / 1000. * SIG_VEL;
300 }
301
302 // let's evaluate [real TOF - nominal TOF]
303 double real_TOF_onRPCgap = GP.mag() / 1000. * C_VEL;
304 double nominal_TOF_onRPCgap = posi.mag() / 1000. * C_VEL;
305
306 // let's evaluate the total time correction
307 double correct_time_tot = real_TOF_onRPCgap - nominal_TOF_onRPCgap + correct_time_along_strip - av_correct_time_along_strip;
308
309 // time and position information
310 m_ntuple.timeBlock.fill(0, m_idHelperSvc->gasGapId(id).get_identifier32().get_compact(), rpc->globalPosition().perp(),
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);
313
314 return true;
315 }
316
317 return true;
318 }
MuonSegment_v1 MuonSegment
Reference the current persistent version:
virtual const MuonGM::RpcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD.
Eigen::Matrix< double, 3, 1 > Vector3D

◆ addTimeMeasurements()

bool Muon::MuonRecoValidationTool::addTimeMeasurements ( const xAOD::TrackParticle & indetTrackParticle,
const MuGirlNS::StauHits & stauHits ) const
overridevirtual

add StauHits to ntuple

Implements Muon::IMuonRecoValidationTool.

Definition at line 178 of file MuonRecoValidationTool.cxx.

179 {
180 Muon::MuonBetaCalculationUtils muonBetaCalculationUtils;
181
182 auto pos = std::find(m_trackParticles.begin(), m_trackParticles.end(), &indetTrackParticle);
183 if (pos == m_trackParticles.end()) {
184 ATH_MSG_WARNING("addTimeMeasurement: indetTrackParticle not found ");
185 return false;
186 }
187 int index = std::distance(m_trackParticles.begin(), pos);
188
189 for (const auto& stauHit : stauHits) {
190 Identifier id = stauHit.id;
191 int type = toInt(m_idHelperSvc->technologyIndex(id)) + 10;
192 double r = std::hypot(stauHit.x, stauHit.y);
193 double tof = muonBetaCalculationUtils.calculateTof(1, std::hypot(r, stauHit.z));
194 // track index
195 m_ntuple.timeBlock.track.fill(index);
196
197 // identifier info
198 m_ntuple.timeBlock.id.fill(m_idHelperSvc->sector(id), toInt(m_idHelperSvc->chamberIndex(id)));
199
200 // position + time information
201 m_ntuple.timeBlock.fill(type, m_idHelperSvc->gasGapId(id).get_identifier32().get_compact(), r, stauHit.z, stauHit.mToF - tof,
202 stauHit.error, stauHit.propagationTime, stauHit.e, tof, 0., stauHit.shift, 1000 * m_candidateCounter);
203
204 // uniqueID + pdg
206 if (m_isMC) {
207 uniqueID = m_truthSummaryTool->getUniqueID(id);
208 pdg = uniqueID != HepMC::INVALID_PARTICLE_ID ? m_truthSummaryTool->getPdgId(uniqueID) : 0;
209 }
210 m_ntuple.timeBlock.truth.fill(pdg, uniqueID);
211 }
213 return true;
214 }
float calculateTof(float beta, float dist)
int r
Definition globals.cxx:22
str index
Definition DeMoScan.py:362

◆ addTrackParticle()

bool Muon::MuonRecoValidationTool::addTrackParticle ( const xAOD::TrackParticle & indetTrackParticle,
const MuonSystemExtension & muonSystemExtention ) const
overridevirtual

add a new TrackParticle with it's muon system extension

Implements Muon::IMuonRecoValidationTool.

Definition at line 107 of file MuonRecoValidationTool.cxx.

108 {
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());
113 int pdg = 0;
115 float beta = 1.;
116 // set truth
117 typedef ElementLink<xAOD::TruthParticleContainer> ElementTruthLink_t;
118 static const SG::ConstAccessor<ElementTruthLink_t>
119 truthParticleLinkAcc("truthParticleLink");
120 if (truthParticleLinkAcc.isAvailable(indetTrackParticle)) {
121 const ElementTruthLink_t link = truthParticleLinkAcc(indetTrackParticle);
122 if (link.isValid()) {
123 pdg = (*link)->pdgId();
124 uniqueID = HepMC::uniqueID(*link);
125 beta = (*link)->p4().Beta();
126 }
127 }
128 m_ntuple.trackParticleBlock.truth.fill(pdg, uniqueID, beta);
129
130 // try to find the pointer of the indetTrackParticle
131 bool found = false;
132 for (unsigned int index = 0; index < m_trackParticles.size(); ++index) {
133 if (&indetTrackParticle == m_trackParticles[index]) {
134 found = true;
135 break;
136 }
137 }
138 if (!found) {
139 // set index to the last element
140 unsigned int index = m_trackParticles.size();
141 m_trackParticles.push_back(&indetTrackParticle);
142
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());
146
147 for (std::vector<Muon::MuonSystemExtension::Intersection>::const_iterator it = layerIntersections.begin();
148 it != layerIntersections.end(); ++it) {
149 m_trackParticleIndexLookup[it->trackParameters.get()] = index;
150 }
151 }
152 return true;
153 }
std::map< const Trk::TrackParameters *, unsigned int > m_trackParticleIndexLookup
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.

◆ clear()

void Muon::MuonRecoValidationTool::clear ( )
private

clear ntuples

Definition at line 91 of file MuonRecoValidationTool.cxx.

91 {
93 m_ntuple.clear();
94 m_trackParticles.clear();
96 }

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extract()

void Muon::MuonRecoValidationTool::extract ( const MuonSegment & segment,
std::set< Identifier > & ids,
std::vector< const MuonClusterOnTrack * > & clusters ) const
private

Definition at line 463 of file MuonRecoValidationTool.cxx.

464 {
465 // loop over hits and extract clusters and ids
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) {
469 // get Identifier and remove MDT hits
470 Identifier id = m_edmHelperSvc->getIdentifier(**mit);
471 if (!id.is_valid()) continue;
472 ids.insert(id);
473 if (!m_idHelperSvc->isTrigger(id)) continue;
474
475 // cast to MuonClusterOnTrack
476 const MuonClusterOnTrack* clus = dynamic_cast<const MuonClusterOnTrack*>(*mit);
477 if (clus)
478 clusters.push_back(clus);
479 else {
480 const CompetingMuonClustersOnTrack* crot = dynamic_cast<const CompetingMuonClustersOnTrack*>(*mit);
481 if (!crot || crot->containedROTs().empty()) continue;
482 clusters.insert(clusters.end(), crot->containedROTs().begin(), crot->containedROTs().end());
483 }
484 }
485 }
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getIndex()

int Muon::MuonRecoValidationTool::getIndex ( const MuonSystemExtension::Intersection & intersection) const
inlineprivate

Definition at line 93 of file MuonRecoValidationTool.h.

93 {
94 int index = -1;
95 auto result = m_trackParticleIndexLookup.find(intersection.trackParameters.get());
96 if (result != m_trackParticleIndexLookup.end()) index = result->second;
97 return index;
98 }

◆ getUniqueID()

int Muon::MuonRecoValidationTool::getUniqueID ( const std::set< Identifier > & ids) const
private

Definition at line 155 of file MuonRecoValidationTool.cxx.

155 {
157
158 // count how often a barcode occurs
159 std::map<int, int> counters;
160 for (std::set<Identifier>::const_iterator it = ids.begin(); it != ids.end(); ++it) {
161 const int uniqueID = m_truthSummaryTool->getUniqueID(*it);
162 if (uniqueID != HepMC::INVALID_PARTICLE_ID) ++counters[uniqueID];
163 }
164
165 // pick the most frequent
167 int max = -1;
168 for (std::map<int, int>::iterator it = counters.begin(); it != counters.end(); ++it) {
169 if (it->second > max) {
170 barcode = it->first; // FIXME barcode-based
171 max = it->second;
172 }
173 }
174
175 return barcode;
176 }
#define max(a, b)
Definition cfImp.cxx:41
int barcode(const T *p)
Definition Barcode.h:16

◆ handle()

void Muon::MuonRecoValidationTool::handle ( const Incident & inc)
overridevirtual

incident service handle for EndEvent

Definition at line 98 of file MuonRecoValidationTool.cxx.

98 {
99 // Only clear cache for EndEvent incident
100 if (inc.type() == IncidentType::EndEvent) {
101 ATH_MSG_DEBUG(" clearing cache at end of event ");
102 m_tree->Fill();
103 clear();
104 }
105 }

◆ initialize()

StatusCode Muon::MuonRecoValidationTool::initialize ( )
overridevirtual

initialize method, method taken from bass-class AlgTool

Definition at line 57 of file MuonRecoValidationTool.cxx.

57 {
58
59 if (Gaudi::Concurrency::ConcurrencyFlags::numThreads() > 1) {
60 ATH_MSG_ERROR("This tool cannot be used in multi-threaded mode");
61 return StatusCode::FAILURE;
62 }
63
64 ATH_CHECK(m_idHelperSvc.retrieve());
65 ATH_CHECK(m_edmHelperSvc.retrieve());
67 ATH_CHECK(m_hitSummaryTool.retrieve());
68 if (m_isMC) {
69 ATH_CHECK(m_truthSummaryTool.retrieve());
70 } else {
71 m_truthSummaryTool.disable();
72 }
73 ATH_CHECK(m_extrapolator.retrieve());
74 ATH_CHECK(m_matchingTool.retrieve());
75 ATH_CHECK(m_hitTimingTool.retrieve());
76 SmartIF<ITHistSvc> thistSvc{service("THistSvc")};
77 ATH_CHECK(thistSvc.isValid());
78
79 m_tree = new TTree("data", "RecoValidation");
80 ATH_CHECK(thistSvc->regTree("/MuonRecoVal/data", m_tree));
81
82 m_ntuple.init("", m_tree);
83
84 // call handle in case of EndEvent
85 ATH_CHECK(m_incidentSvc.retrieve());
86 m_incidentSvc->addListener(this, IncidentType::EndEvent);
87
88 return StatusCode::SUCCESS;
89 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Muon::IMuonRecoValidationTool::interfaceID ( )
inlinestaticinherited

AlgTool and IAlgTool interface methods.

Definition at line 27 of file IMuonRecoValidationTool.h.

27 {
28 static const InterfaceID IID_IMuonRecoValidationTool("Muon::IMuonRecoValidationTool", 1, 0);
29 return IID_IMuonRecoValidationTool;
30 }

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_candidateCounter

std::atomic<unsigned int> Muon::MuonRecoValidationTool::m_candidateCounter
mutableprivate

Definition at line 121 of file MuonRecoValidationTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_edmHelperSvc

ServiceHandle<IMuonEDMHelperSvc> Muon::MuonRecoValidationTool::m_edmHelperSvc
private
Initial value:
{this, "edmHelper", "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
"Handle to the service providing the IMuonEDMHelperSvc interface"}

Definition at line 104 of file MuonRecoValidationTool.h.

104 {this, "edmHelper", "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
105 "Handle to the service providing the IMuonEDMHelperSvc interface"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extrapolator

ToolHandle<Trk::IExtrapolator> Muon::MuonRecoValidationTool::m_extrapolator
private

Definition at line 109 of file MuonRecoValidationTool.h.

◆ m_hitSummaryTool

ToolHandle<IMuonHitSummaryTool> Muon::MuonRecoValidationTool::m_hitSummaryTool
private

Definition at line 107 of file MuonRecoValidationTool.h.

◆ m_hitTimingTool

ToolHandle<IMuonHitTimingTool> Muon::MuonRecoValidationTool::m_hitTimingTool
private

Definition at line 111 of file MuonRecoValidationTool.h.

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::MuonRecoValidationTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 103 of file MuonRecoValidationTool.h.

103{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_incidentSvc

ServiceHandle<IIncidentSvc> Muon::MuonRecoValidationTool::m_incidentSvc
private

Definition at line 112 of file MuonRecoValidationTool.h.

◆ m_isMC

bool Muon::MuonRecoValidationTool::m_isMC
private

Definition at line 123 of file MuonRecoValidationTool.h.

◆ m_matchingTool

ToolHandle<IMuTagMatchingTool> Muon::MuonRecoValidationTool::m_matchingTool
private

Definition at line 110 of file MuonRecoValidationTool.h.

◆ m_ntuple

MuonInsideOutValidationNtuple Muon::MuonRecoValidationTool::m_ntuple
mutableprivate

Definition at line 118 of file MuonRecoValidationTool.h.

◆ m_segmentHitSummaryTool

ToolHandle<IMuonSegmentHitSummaryTool> Muon::MuonRecoValidationTool::m_segmentHitSummaryTool
private

Definition at line 106 of file MuonRecoValidationTool.h.

◆ m_trackParticleIndexLookup

std::map<const Trk::TrackParameters*, unsigned int> Muon::MuonRecoValidationTool::m_trackParticleIndexLookup
mutableprivate

Definition at line 116 of file MuonRecoValidationTool.h.

◆ m_trackParticles

std::vector<const xAOD::TrackParticle*> Muon::MuonRecoValidationTool::m_trackParticles
mutableprivate

Definition at line 115 of file MuonRecoValidationTool.h.

◆ m_tree

TTree* Muon::MuonRecoValidationTool::m_tree = nullptr
private

Definition at line 119 of file MuonRecoValidationTool.h.

◆ m_truthSummaryTool

ToolHandle<IMuonTruthSummaryTool> Muon::MuonRecoValidationTool::m_truthSummaryTool
private

Definition at line 108 of file MuonRecoValidationTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: