ATLAS Offline Software
Loading...
Searching...
No Matches
EntryLayerToolMT.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// class header include
6#include "EntryLayerToolMT.h"
7
9
10// ISF includes
12
13thread_local std::unique_ptr<std::array<TrackRecordCollection*, ISF::fNumAtlasEntryLayers>> ISF::EntryLayerToolMT::s_collection;
14
16ISF::EntryLayerToolMT::EntryLayerToolMT(const std::string& t, const std::string& n, const IInterface* p) :
17 base_class(t,n,p),
19{
20 // volumeNames for TrackRecords
21 declareProperty( "CaloEntryVolumeString",
22 m_volumeName[ISF::fAtlasCaloEntry] = "IDET::IDET",
23 "VolumeName in TrackRecords in CaloEntryLayer");
24 declareProperty( "MuonEntryVolumeString",
25 m_volumeName[ISF::fAtlasMuonEntry] = "CALO::CALO",
26 "VolumeName in TrackRecords in MuonEntryLayer");
27 declareProperty( "MuonExitVolumeString",
28 m_volumeName[ISF::fAtlasMuonExit] = "MUONQ02::MUONQ02",
29 "VolumeName in TrackRecords in MuonExitLayer");
30}
31
32
35{
36 ATH_MSG_INFO("initialize() ...");
37
38 // retrieve the GeoIDSvc
39 ATH_CHECK ( m_geoIDSvc.retrieve() );
40 // store a quick-access pointer to the c++ class directly
41 m_geoIDSvcQuick = &(*m_geoIDSvc);
42
43 // retrieve the ParticleFilters
44 ATH_CHECK ( m_particleFilterHandle.retrieve() );
45 // store a quick-access pointer to the c++ classes directly
48 for ( size_t curFilter = 0; curFilter<m_numParticleFilters; curFilter++) {
49 // convert ToolHandle to standard c++ class pointer
50 m_particleFilter[curFilter] = &(*m_particleFilterHandle[curFilter]);
51 }
52
53 ATH_MSG_INFO("initialize() successful");
54 return StatusCode::SUCCESS;
55}
56
57
60 bool pass = true;
61 for ( size_t curFilter=0; pass && (curFilter<m_numParticleFilters); curFilter++) {
62 // check current filter
63 pass = m_particleFilter[curFilter]->passFilter( particle);
64 }
65
66 return pass;
67}
68
69
73 // the return value
75
76 const Amg::Vector3D &pos = particle.position();
77
78 // check if particle on ID and/or Calo surface
79 bool onIDSurface = (m_geoIDSvcQuick->inside( pos, AtlasDetDescr::fAtlasID) == ISF::fSurface);
80 bool onCaloSurface = (m_geoIDSvcQuick->inside( pos, AtlasDetDescr::fAtlasCalo) == ISF::fSurface);
81
82 // on CaloEntry layer ?
83 if ( onIDSurface && onCaloSurface ) {
84 layerHit = ISF::fAtlasCaloEntry;
85 }
86
87 // no surface hit yet -> test MS volume surface hit
88 else {
89 // check if particle on MS surface
90 bool onMSSurface = (m_geoIDSvcQuick->inside( pos, AtlasDetDescr::fAtlasMS) == ISF::fSurface);
91
92 // on MuonEntry layer ?
93 if (onCaloSurface && onMSSurface) {
94 layerHit = ISF::fAtlasMuonEntry;
95 }
96 // on MuonExit layer ?
97 else if (onMSSurface) {
98 layerHit = ISF::fAtlasMuonExit;
99 }
100 }
101 return layerHit;
102}
103
104
107{
108 // (1.) check whether the particle actually passes all the filters
109 // -> rather fast usually
110 if ( !passesFilters(particle) ) {
111 // return if not passed
113 }
114
115 // (2.) check whether the particle lies on any entry surface
116 // -> this goes second because computation intensive routines
117 // are used for this
118 if ( layerHit == ISF::fUnsetEntryLayer) {
119 layerHit = identifyEntryLayer( particle);
120 }
121
122 // (3.) if particle is on a boundary surface
123 // -> add it to TrackRecordCollection
124 if ( layerHit != ISF::fUnsetEntryLayer) {
125 ATH_MSG_VERBOSE( "Particle >>" << particle << "<< hit boundary surface, "
126 "adding it to '" << (*s_collection)[layerHit]->Name() << "' TrackRecord collection");
127
128 const Amg::Vector3D &pos = particle.position();
129 const Amg::Vector3D &mom = particle.momentum();
130 CLHEP::Hep3Vector hepPos( pos.x(), pos.y(), pos.z() ); // not optimal, but required by TrackRecord
131 CLHEP::Hep3Vector hepMom( mom.x(), mom.y(), mom.z() ); // not optimal, but required by TrackRecord
132
133 double mass = particle.mass();
134 double energy = std::sqrt(mass*mass + mom.mag2());
135
136 // Use barcode of generation zero particle from truth binding if possible (reproduces legacy AtlasG4 behaviour).
137 // Use barcode assigend to ISFParticle only if no generation zero particle is present.
138 auto truthBinding = particle.getTruthBinding();
139 auto generationZeroGenParticle = truthBinding ? truthBinding->getGenerationZeroGenParticle() : nullptr;
140 const int barcode = generationZeroGenParticle ? HepMC::barcode(generationZeroGenParticle) : HepMC::barcode(particle); // FIXME barcode-based
141 const int id = generationZeroGenParticle ? HepMC::uniqueID(generationZeroGenParticle) : particle.id();
142 const int status = generationZeroGenParticle ? generationZeroGenParticle->status() : particle.status();
143
144 (*s_collection)[layerHit]->Emplace(particle.pdgCode(),
145 status,
146 energy,
147 hepMom,
148 hepPos,
149 particle.timeStamp(),
150 barcode, // FIXME barcode-based
151 id,
152 m_volumeName[layerHit] );
153 }
154
155 return layerHit;
156}
157
160{
161 if (!s_collection) {
162 // need to create the array of TrackRecordCollections for this thread
163 s_collection = std::make_unique<std::array<TrackRecordCollection*, ISF::fNumAtlasEntryLayers>>();
164 }
165 (*s_collection)[layer]=collection;
166 return StatusCode::SUCCESS;
167}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
JetDumper::Name Name
Definition JetDumper.cxx:19
AtlasHitsVector< TrackRecord > TrackRecordCollection
ServiceHandle< ISF::IGeoIDSvc > m_geoIDSvc
GeoIDSvc will be used to determine the entry layer surface, the particle is on.
virtual bool passesFilters(const ISFParticle &particle) override final
handle for incident service
ISF::IParticleFilter ** m_particleFilter
static thread_local std::unique_ptr< std::array< TrackRecordCollection *, ISF::fNumAtlasEntryLayers > > s_collection
The entry layer collections.
std::string m_volumeName[ISF::fNumAtlasEntryLayers]
virtual StatusCode registerTrackRecordCollection(TrackRecordCollection *collection, EntryLayer layer) override final
Register the TrackRecordCollection pointer for a layer.
virtual ISF::EntryLayer identifyEntryLayer(const ISFParticle &particle) override final
Identify the corresponding entry layer for the given particle (may return ISF::fUnsetEntryLayere if p...
ParticleFilterArray m_particleFilterHandle
Array of filters to decide whether a particle is added to the Entry/Exit layer.
virtual StatusCode initialize() override final
Athena algtool's Hooks.
EntryLayerToolMT(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
virtual ISF::EntryLayer registerParticle(const ISF::ISFParticle &particle, ISF::EntryLayer entryLayer) override final
Add the given particle to the corresponding Entry/Exit layer if applicable.
ISF::IGeoIDSvc * m_geoIDSvcQuick
The generic ISF particle definition,.
Definition ISFParticle.h:42
Eigen::Matrix< double, 3, 1 > Vector3D
int barcode(const T *p)
Definition Barcode.h:16
int uniqueID(const T &p)
EntryLayer
Identifiers for the TrackRecordCollections on the boundaries between CaloEntry: Inner Detector - Calo...
Definition EntryLayer.h:31
@ fAtlasMuonExit
Definition EntryLayer.h:39
@ fUnsetEntryLayer
Definition EntryLayer.h:33
@ fAtlasCaloEntry
Definition EntryLayer.h:37
@ fAtlasMuonEntry
Definition EntryLayer.h:38
@ fSurface
Definition IGeoIDSvc.h:24