ATLAS Offline Software
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
11 #include "ISF_Event/ISFParticle.h"
12 
14 ISF::EntryLayerToolMT::EntryLayerToolMT(const std::string& t, const std::string& n, const IInterface* p) :
15  base_class(t,n,p),
16  m_volumeName()
17 {
18  // volumeNames for TrackRecords
19  declareProperty( "CaloEntryVolumeString",
20  m_volumeName[ISF::fAtlasCaloEntry] = "IDET::IDET",
21  "VolumeName in TrackRecords in CaloEntryLayer");
22  declareProperty( "MuonEntryVolumeString",
23  m_volumeName[ISF::fAtlasMuonEntry] = "CALO::CALO",
24  "VolumeName in TrackRecords in MuonEntryLayer");
25  declareProperty( "MuonExitVolumeString",
26  m_volumeName[ISF::fAtlasMuonExit] = "MUONQ02::MUONQ02",
27  "VolumeName in TrackRecords in MuonExitLayer");
28 }
29 
30 
33 {
34  ATH_MSG_INFO("initialize() ...");
35 
36  // retrieve the GeoIDSvc
37  ATH_CHECK ( m_geoIDSvc.retrieve() );
38  // store a quick-access pointer to the c++ class directly
39  m_geoIDSvcQuick = &(*m_geoIDSvc);
40 
41  // retrieve the ParticleFilters
42  ATH_CHECK ( m_particleFilterHandle.retrieve() );
43  // store a quick-access pointer to the c++ classes directly
44  m_numParticleFilters = m_particleFilterHandle.size();
45  m_particleFilter = new ISF::IParticleFilter*[ m_numParticleFilters ];
46  for ( size_t curFilter = 0; curFilter<m_numParticleFilters; curFilter++) {
47  // convert ToolHandle to standard c++ class pointer
48  m_particleFilter[curFilter] = &(*m_particleFilterHandle[curFilter]);
49  }
50 
51  ATH_MSG_INFO("initialize() successful");
52  return StatusCode::SUCCESS;
53 }
54 
55 
58  bool pass = true;
59  for ( size_t curFilter=0; pass && (curFilter<m_numParticleFilters); curFilter++) {
60  // check current filter
61  pass = m_particleFilter[curFilter]->passFilter( particle);
62  }
63 
64  return pass;
65 }
66 
67 
71  // the return value
73 
74  const Amg::Vector3D &pos = particle.position();
75 
76  // check if particle on ID and/or Calo surface
77  bool onIDSurface = (m_geoIDSvcQuick->inside( pos, AtlasDetDescr::fAtlasID) == ISF::fSurface);
78  bool onCaloSurface = (m_geoIDSvcQuick->inside( pos, AtlasDetDescr::fAtlasCalo) == ISF::fSurface);
79 
80  // on CaloEntry layer ?
81  if ( onIDSurface && onCaloSurface ) {
82  layerHit = ISF::fAtlasCaloEntry;
83  }
84 
85  // no surface hit yet -> test MS volume surface hit
86  else {
87  // check if particle on MS surface
88  bool onMSSurface = (m_geoIDSvcQuick->inside( pos, AtlasDetDescr::fAtlasMS) == ISF::fSurface);
89 
90  // on MuonEntry layer ?
91  if (onCaloSurface && onMSSurface) {
92  layerHit = ISF::fAtlasMuonEntry;
93  }
94  // on MuonExit layer ?
95  else if (onMSSurface) {
96  layerHit = ISF::fAtlasMuonExit;
97  }
98  }
99  return layerHit;
100 }
101 
102 
105 {
106  // (1.) check whether the particle actually passes all the filters
107  // -> rather fast usually
108  if ( !passesFilters(particle) ) {
109  // return if not passed
110  return ISF::fUnsetEntryLayer;
111  }
112 
113  // (2.) check whether the particle lies on any entry surface
114  // -> this goes second because computation intensive routines
115  // are used for this
116  if ( layerHit == ISF::fUnsetEntryLayer) {
117  layerHit = identifyEntryLayer( particle);
118  }
119 
120  // (3.) if particle is on a boundary surface
121  // -> add it to TrackRecordCollection
122  if ( layerHit != ISF::fUnsetEntryLayer) {
123  ATH_MSG_VERBOSE( "Particle >>" << particle << "<< hit boundary surface, "
124  "adding it to '" << (*m_collectionHolder.get())[layerHit]->Name() << "' TrackRecord collection");
125 
126  const Amg::Vector3D &pos = particle.position();
127  const Amg::Vector3D &mom = particle.momentum();
128  CLHEP::Hep3Vector hepPos( pos.x(), pos.y(), pos.z() ); // not optimal, but required by TrackRecord
129  CLHEP::Hep3Vector hepMom( mom.x(), mom.y(), mom.z() ); // not optimal, but required by TrackRecord
130 
131  double mass = particle.mass();
132  double energy = std::sqrt(mass*mass + mom.mag2());
133 
134  // Use barcode of generation zero particle from truth binding if possible (reproduces legacy AtlasG4 behaviour).
135  // Use barcode assigend to ISFParticle only if no generation zero particle is present.
136  auto truthBinding = particle.getTruthBinding();
137  auto generationZeroGenParticle = truthBinding ? truthBinding->getGenerationZeroGenParticle() : nullptr;
138  const int barcode = generationZeroGenParticle ? HepMC::barcode(generationZeroGenParticle) : HepMC::barcode(particle); // FIXME barcode-based
139  const int id = generationZeroGenParticle ? HepMC::uniqueID(generationZeroGenParticle) : particle.id();
140  const int status = generationZeroGenParticle ? generationZeroGenParticle->status() : particle.status();
141 
142  (*m_collectionHolder.get())[layerHit]->Emplace(particle.pdgCode(),
143  status,
144  energy,
145  hepMom,
146  hepPos,
147  particle.timeStamp(),
148  barcode, // FIXME barcode-based
149  id,
150  m_volumeName[layerHit] );
151  }
152 
153  return layerHit;
154 }
155 
158 {
159  // Do we need to lock around this code???
160  auto* collectionArray = m_collectionHolder.get();
161  if (not collectionArray) {
162  // need to create the array of TrackRecordCollections for this thread
163  auto* temp = new std::array<TrackRecordCollection*, ISF::fNumAtlasEntryLayers>;
164  m_collectionHolder.set(temp);
165  collectionArray = m_collectionHolder.get();
166  }
167  (*collectionArray)[layer]=collection;
168  return StatusCode::SUCCESS;
169 }
ISF::fAtlasMuonEntry
@ fAtlasMuonEntry
Definition: EntryLayer.h:38
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ISF::fAtlasMuonExit
@ fAtlasMuonExit
Definition: EntryLayer.h:39
ISF::EntryLayerToolMT::identifyEntryLayer
virtual ISF::EntryLayer identifyEntryLayer(const ISFParticle &particle) override final
Identify the corresponding entry layer for the given particle (may return ISF::fUnsetEntryLayere if p...
Definition: EntryLayerToolMT.cxx:70
AtlasHitsVector
Definition: AtlasHitsVector.h:33
ISF::ISFParticle
Definition: ISFParticle.h:42
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ISF::EntryLayerToolMT::m_volumeName
std::string m_volumeName[ISF::fNumAtlasEntryLayers]
Definition: EntryLayerToolMT.h:84
dqt_zlumi_pandas.mass
mass
Definition: dqt_zlumi_pandas.py:170
ISF::fSurface
@ fSurface
Definition: IGeoIDSvc.h:24
ISF::EntryLayerToolMT::EntryLayerToolMT
EntryLayerToolMT(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: EntryLayerToolMT.cxx:14
ISFParticle.h
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
ISF::fUnsetEntryLayer
@ fUnsetEntryLayer
Definition: EntryLayer.h:33
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
AtlasDetDescr::fAtlasMS
@ fAtlasMS
Definition: AtlasRegion.h:36
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
HepMC::uniqueID
int uniqueID(const T &p)
Definition: MagicNumbers.h:113
ISF::EntryLayerToolMT::passesFilters
virtual bool passesFilters(const ISFParticle &particle) override final
Check if given particle passes the EntryLayer filters.
Definition: EntryLayerToolMT.cxx:57
EntryLayerToolMT.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ISF::EntryLayerToolMT::registerTrackRecordCollection
virtual StatusCode registerTrackRecordCollection(TrackRecordCollection *collection, EntryLayer layer) override final
Register the TrackRecordCollection pointer for a layer.
Definition: EntryLayerToolMT.cxx:157
ISF::EntryLayerToolMT::registerParticle
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.
Definition: EntryLayerToolMT.cxx:104
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
MagicNumbers.h
AtlasDetDescr::fAtlasID
@ fAtlasID
Definition: AtlasRegion.h:33
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ISF::EntryLayer
EntryLayer
Definition: EntryLayer.h:31
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
AtlasDetDescr::fAtlasCalo
@ fAtlasCalo
Definition: AtlasRegion.h:35
ISF::fAtlasCaloEntry
@ fAtlasCaloEntry
Definition: EntryLayer.h:37
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
merge.status
status
Definition: merge.py:17
ISF::EntryLayerToolMT::initialize
virtual StatusCode initialize() override final
Athena algtool's Hooks.
Definition: EntryLayerToolMT.cxx:32
ISF::IParticleFilter
Definition: IParticleFilter.h:28