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

#include <MuonTruthSegmentCreationAlg.h>

Inheritance diagram for Muon::MuonTruthSegmentCreationAlg:
Collaboration diagram for Muon::MuonTruthSegmentCreationAlg:

Public Types

using ChamberIdMap = std::map<Muon::MuonStationIndex::ChIndex, std::vector<Identifier>>
 This map contains all the hits corresponding to truth muons classified by chamber layer that recorded them.

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode execute (const EventContext &ctx) const override
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
 Get filter decision:
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 Set filter decision:
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 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

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

StatusCode fillChamberIdMap (const EventContext &ctx, const xAOD::TruthParticle &truthParticle, ChamberIdMap &ids) const
 This function uses the 6 vectors, contained in.
StatusCode createSegments (const EventContext &ctx, const ElementLink< xAOD::TruthParticleContainer > &truthLink, const ChamberIdMap &ids, xAOD::MuonSegmentContainer &segmentContainer) const
 This function performs, for each truth muon, the actual segment creation and stores segments into a new container.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< xAOD::TruthParticleContainerm_muonTruth {this, "muonTruth", "MuonTruthParticles"}
 Key for the truth muon container and muon origin decoration.
SG::ReadDecorHandleKey< xAOD::TruthParticleContainerm_truthOriginKey {this, "truthOriginKey", m_muonTruth, "truthOrigin"}
 FIXME ReadDecorHandle should not be used to access dynamic variables applied by the algorithm which created the container, instead a SG::AuxElement::ConstAccessor should be used.
SG::ReadDecorHandleKey< xAOD::TruthParticleContainerm_truthClassificationKey {this, "truthClassificationKey", m_muonTruth, "truthClassification"}
SG::ReadDecorHandleKeyArray< xAOD::TruthParticleContainer, std::vector< unsigned long long > > m_truthHitsKeyArray {this, "truthHitsKeyArray", { }}
 Keys of the truth muon decorations that we need to read to (re-)fill the chamberIdMap.
SG::WriteHandleKey< xAOD::MuonSegmentContainerm_muonTruthSegmentContainerName {this, "MuonTruthSegmentName", "MuonTruthSegments"}
 Key for segment container that will be populated with segments.
SG::ReadHandleKeyArray< MuonSimDataCollectionm_SDO_TruthNames
 Keys for all çontainers of muon hit simulation data, classified by detector technology.
SG::ReadHandleKey< CscSimDataCollectionm_CSC_SDO_TruthNames {this, "CSCSDOs", "CSC_SDO"}
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 Handle for the muonIdHelper service.
SG::ReadCondHandleKey< MuonGM::MuonDetectorManagerm_detMgrKey
 MuonDetectorManager from the conditions store.
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
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 38 of file MuonTruthSegmentCreationAlg.h.

Member Typedef Documentation

◆ ChamberIdMap

This map contains all the hits corresponding to truth muons classified by chamber layer that recorded them.

ChIndex is the chamber layer index (e.g. BMS, BOL,...), while Identifier is the hit ID, which represents the channel where the hit has been recorded.

Definition at line 52 of file MuonTruthSegmentCreationAlg.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Function Documentation

◆ createSegments()

StatusCode Muon::MuonTruthSegmentCreationAlg::createSegments ( const EventContext & ctx,
const ElementLink< xAOD::TruthParticleContainer > & truthLink,
const ChamberIdMap & ids,
xAOD::MuonSegmentContainer & segmentContainer ) const
private

This function performs, for each truth muon, the actual segment creation and stores segments into a new container.

Parameters
segmentContainer.Firstly, we retrieve simulation data from m_SDO_TruthNames and copy it into a new vector, keeping only the data corresponding to the correct detector technologies. Then, we loop over chamber layers and over the corresponding hit IDs, both provided by
ids,andwe store: *- gas-gap for hits with a phi measurement -> phiLayers *- gas-gap for hits recorded by MM or CSC -> precLayers *- 10*multi-layer + tube_layer for hits recorded by MDT -> precLayers *- gas-gap for hits recorded by trigger chambers without phi measurement -> etaLayers Then, in the same loop over hit IDs, we retrieve simulation data for that hit, specifically the global position, needed to retrieve for each chamber layer the pair of hits with the largest distance. If a pair of hits is found and at least three precision measurements are available, we proceed with the truth segment creation. We create a segment obj and we fill it with number and type (see above) of hits available, the
truthLinklink to the corresponding truth muon, and the position and direction of the truth segment, calculated with hit pair global positions. Finally, we append the sector, chamber layer, station eta, and technology of the chamber where the segment was recorded.
ctxtells us in which event we are
truthLinklink to the corresponding truth muons
idschamberIdMap storing truth hit IDs classified by chamber layer
segmentContainersegment container

Definition at line 123 of file MuonTruthSegmentCreationAlg.cxx.

126 {
127
128 const MuonGM::MuonDetectorManager* detMgr{nullptr};
129 ATH_CHECK(SG::get(detMgr, m_detMgrKey, ctx));
130
131 constexpr unsigned techMax = toInt(TechnologyIndex::TechnologyIndexMax);
132 std::array<const MuonSimDataCollection*, techMax> sdoCollections{};
133 bool useSDO = !m_CSC_SDO_TruthNames.empty();
134 for (const SG::ReadHandleKey<MuonSimDataCollection>& k : m_SDO_TruthNames) {
135 const MuonSimDataCollection* coll{nullptr};
136 ATH_CHECK(SG::get(coll, k, ctx));
137 if (coll->empty()) {
138 continue;
139 }
140 Identifier id = coll->begin()->first;
141 sdoCollections[toInt(m_idHelperSvc->technologyIndex(id))] = coll;
142 useSDO = true;
143 }
144 // loop over chamber layers
145 for (const auto& [chIdx, assocIds] : ids) {
146 // skip empty layers
147 Amg::Vector3D firstPos{Amg::Vector3D::Zero()}, secondPos{Amg::Vector3D::Zero()};
148 bool firstPosSet{false}, secondPosSet{false};
149 Identifier chId{};
150 int index = -1;
151 uint8_t nprecLayers{0}, nphiLayers{0}, ntrigEtaLayers{0};
152 std::unordered_set<int> phiLayers{}, etaLayers{}, precLayers{};
153 ATH_MSG_DEBUG(" new chamber layer " << Muon::MuonStationIndex::chName(chIdx) << " hits " << assocIds.size());
154 // loop over hits
155 for (const auto& id : assocIds) {
156 ATH_MSG_VERBOSE(" hit " << m_idHelperSvc->toString(id));
157 bool measPhi = m_idHelperSvc->measuresPhi(id);
158 bool isCsc = m_idHelperSvc->isCsc(id);
159 bool isMM = m_idHelperSvc->isMM(id);
160 bool isTrig = m_idHelperSvc->isTrigger(id);
161 bool isEndcap = m_idHelperSvc->isEndcap(id);
162 if (measPhi) {
163 phiLayers.insert(m_idHelperSvc->gasGap(id));
164 } else {
165 if (!isTrig) {
166 if (!chId.is_valid()) chId = id; // use first precision hit in list
167 if (isCsc || isMM) {
168 precLayers.insert(m_idHelperSvc->gasGap(id));
169 } else {
170 int iid = 10 * m_idHelperSvc->mdtIdHelper().multilayer(id) + m_idHelperSvc->mdtIdHelper().tubeLayer(id);
171 precLayers.insert(iid);
172 // ATH_MSG_VERBOSE("iid " << iid << " precLayers size " << precLayers.size() );
173 }
174 } else {
175 etaLayers.insert(m_idHelperSvc->gasGap(id));
176 }
177 }
178 // use SDO to look-up truth position of the hit
179 if (!useSDO) {
180 continue;
181 }
182 Amg::Vector3D gpos{Amg::Vector3D::Zero()};
183 if (!isCsc) {
184 bool ok = false;
185 TechnologyIndex techIdx = m_idHelperSvc->technologyIndex(id);
186 if (sdoCollections[toInt(techIdx)]) {
187 auto pos = sdoCollections[toInt(techIdx)]->find(id);
188 if (pos != sdoCollections[toInt(techIdx)]->end()) {
189 gpos = pos->second.globalPosition();
190 if (gpos.perp() > 0.1) ok = true; // sanity check
191 }
192 }
193 // look up successful, calculate
194 if (!ok) continue;
195
196 // small comparison function
197 auto isSmaller = [isEndcap](const Amg::Vector3D& p1, const Amg::Vector3D& p2) {
198 if (isEndcap)
199 return std::abs(p1.z()) < std::abs(p2.z());
200 else
201 return p1.perp() < p2.perp();
202 };
203 if (!firstPosSet) {
204 firstPos = gpos;
205 firstPosSet = true;
206 } else if (!secondPosSet) {
207 secondPos = gpos;
208 secondPosSet = true;
209 if (isSmaller(secondPos, firstPos)) std::swap(firstPos, secondPos);
210 } else {
211 // update position if we can increase the distance between the two positions
212 if (isSmaller(gpos, firstPos))
213 firstPos = gpos;
214 else if (isSmaller(secondPos, gpos))
215 secondPos = gpos;
216 }
217 } else {
218 SG::ReadHandle cscCollection(m_CSC_SDO_TruthNames, ctx);
219 ATH_CHECK(cscCollection.isPresent());
220 auto pos = cscCollection->find(id);
221 if (pos == cscCollection->end()) {
222 continue;
223 }
224 const MuonGM::CscReadoutElement* descriptor = detMgr->getCscReadoutElement(id);
225 ATH_MSG_DEBUG("found csc sdo with " << pos->second.getdeposits().size() << " deposits");
226 Amg::Vector3D locpos(0, pos->second.getdeposits()[0].second.ypos(), pos->second.getdeposits()[0].second.zpos());
227 gpos = descriptor->localToGlobalCoords(locpos, m_idHelperSvc->cscIdHelper().elementID(id));
228 ATH_MSG_DEBUG("got CSC global position " << gpos);
229 if (!firstPosSet) {
230 firstPos = gpos;
231 firstPosSet = true;
232 } else if (!secondPosSet) {
233 secondPos = gpos;
234 secondPosSet = true;
235 if (secondPos.perp() < firstPos.perp()) std::swap(firstPos, secondPos);
236 } else {
237 if (gpos.perp() < firstPos.perp())
238 firstPos = gpos;
239 else if (secondPos.perp() < gpos.perp())
240 secondPos = gpos;
241 }
242 }
243 }
244 if (precLayers.size() > 2) {
245 if (!phiLayers.empty()) nphiLayers = phiLayers.size();
246 ntrigEtaLayers = etaLayers.size();
247 nprecLayers = precLayers.size();
248 ATH_MSG_DEBUG(" total counts: precision " << static_cast<int>(nprecLayers) << " phi layers " << static_cast<int>(nphiLayers)
249 << " eta trig layers " << static_cast<int>(ntrigEtaLayers)
250 << " associated reco muon " << index << " unique ID " << HepMC::uniqueID(*truthLink)
251 << " truthLink " << truthLink);
252 xAOD::MuonSegment* segment = segmentContainer.push_back(std::make_unique<xAOD::MuonSegment>());
253
254 segment->setNHits(nprecLayers, nphiLayers, ntrigEtaLayers);
256 truthParticleLinkAcc("truthParticleLink");
257 truthParticleLinkAcc(*segment) = truthLink;
258 if (chId.is_valid()) { //we should always enter here if we have precision measurements
259 int eta = m_idHelperSvc->stationEta(chId);
260 int sector = m_idHelperSvc->sector(chId);
261 MuonStationIndex::TechnologyIndex technology = m_idHelperSvc->technologyIndex(chId);
262 MuonStationIndex::ChIndex chIndex = m_idHelperSvc->chamberIndex(chId);
263 segment->setIdentifier(sector, chIndex, eta, technology);
264 }
265 if (firstPosSet && secondPosSet) {
266 Amg::Vector3D gpos = (firstPos + secondPos) / 2.;
267 Amg::Vector3D gdir = (firstPos - secondPos).unit();
268 ATH_MSG_DEBUG(" got position : r " << gpos.perp() << " z " << gpos.z() << " and direction: theta " << gdir.theta()
269 << " phi " << gdir.phi());
270 segment->setPosition(gpos.x(), gpos.y(), gpos.z());
271 segment->setDirection(gdir.x(), gdir.y(), gdir.z());
272 }
273 }
274 }
275 return StatusCode::SUCCESS;
276 }
Scalar eta() const
pseudorapidity method
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
bool is_valid() const
Check if id is in a valid state.
Amg::Vector3D localToGlobalCoords(const Amg::Vector3D &x, const Identifier &id) const
localToGlobalCoords and Transf connect the Gas Gap Frame (defined as a Sensitive Detector) to the Glo...
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Handle for the muonIdHelper service.
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
MuonDetectorManager from the conditions store.
SG::ReadHandleKey< CscSimDataCollection > m_CSC_SDO_TruthNames
SG::ReadHandleKeyArray< MuonSimDataCollection > m_SDO_TruthNames
Keys for all çontainers of muon hit simulation data, classified by detector technology.
void setDirection(float px, float py, float pz)
Sets the direction.
void setNHits(const std::uint8_t nPrecisionHits, const std::uint8_t nPhiLayers, const std::uint8_t nTrigEtaLayers)
Assign the segment hit summary.
void setPosition(float x, float y, float z)
Sets the global position.
void setIdentifier(const std::uint8_t sector, const ::Muon::MuonStationIndex::ChIndex chamberIndex, const std::int8_t etaIndex, const ::Muon::MuonStationIndex::TechnologyIndex technology)
Set the Identifier fields of the Segment.
Eigen::Matrix< double, 3, 1 > Vector3D
str index
Definition DeMoScan.py:362
int uniqueID(const T &p)
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
TechnologyIndex
enum to classify the different layers in the muon spectrometer
constexpr int toInt(const EnumType enumVal)
const std::string & chName(ChIndex index)
convert ChIndex into a string
ChIndex
enum to classify the different chamber layers in the muon spectrometer
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:573
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
MuonSegment_v1 MuonSegment
Reference the current persistent version:

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

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

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode Muon::MuonTruthSegmentCreationAlg::execute ( const EventContext & ctx) const
overridevirtual

Definition at line 61 of file MuonTruthSegmentCreationAlg.cxx.

61 {
62
63 const xAOD::TruthParticleContainer* muonTruthContainer{nullptr};
64 ATH_CHECK(SG::get(muonTruthContainer, m_muonTruth, ctx));
65
66 SG::ReadDecorHandle<xAOD::TruthParticleContainer, int> truthOrigin(m_truthOriginKey, ctx);
67 ATH_CHECK(truthOrigin.isPresent());
68 SG::ReadDecorHandle<xAOD::TruthParticleContainer, unsigned int> truthClassification(m_truthClassificationKey, ctx);
69 ATH_CHECK(truthClassification.isPresent()); // May need to comment this out initially
70
71 // create output container
72 SG::WriteHandle segmentContainer(m_muonTruthSegmentContainerName, ctx);
73 ATH_CHECK(segmentContainer.record(std::make_unique<xAOD::MuonSegmentContainer>(),
74 std::make_unique<xAOD::MuonSegmentAuxContainer>()));
75 ATH_MSG_DEBUG("Recorded MuonSegmentContainer with key: " << segmentContainer.name());
76
77 size_t itr = 0;
78 for (const xAOD::TruthParticle* truthParticle : *muonTruthContainer) {
79 // TODO adapt the logic in this loop to use truthClassification rather than truthOrigin
80 const int iOrigin = truthOrigin(*truthParticle);
81 bool goodMuon = bad_origins.find(iOrigin) == bad_origins.end();
82
83 // create segments
84 if (goodMuon) {
85 ElementLink<xAOD::TruthParticleContainer> truthLink(*muonTruthContainer, itr);
86 truthLink.toPersistent();
87
89 ATH_CHECK(fillChamberIdMap(ctx, *truthParticle, ids));
90 ATH_CHECK(createSegments(ctx, truthLink, ids, *segmentContainer));
91 }
92 itr++;
93 }
94
95 ATH_MSG_DEBUG("Registered " << segmentContainer->size() << " truth muon segments ");
96
97 return StatusCode::SUCCESS;
98 }
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_truthOriginKey
FIXME ReadDecorHandle should not be used to access dynamic variables applied by the algorithm which c...
StatusCode fillChamberIdMap(const EventContext &ctx, const xAOD::TruthParticle &truthParticle, ChamberIdMap &ids) const
This function uses the 6 vectors, contained in.
std::map< Muon::MuonStationIndex::ChIndex, std::vector< Identifier > > ChamberIdMap
This map contains all the hits corresponding to truth muons classified by chamber layer that recorded...
SG::WriteHandleKey< xAOD::MuonSegmentContainer > m_muonTruthSegmentContainerName
Key for segment container that will be populated with segments.
StatusCode createSegments(const EventContext &ctx, const ElementLink< xAOD::TruthParticleContainer > &truthLink, const ChamberIdMap &ids, xAOD::MuonSegmentContainer &segmentContainer) const
This function performs, for each truth muon, the actual segment creation and stores segments into a n...
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_muonTruth
Key for the truth muon container and muon origin decoration.
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_truthClassificationKey
int truthOrigin(const U &p)
TruthParticle_v1 TruthParticle
Typedef to implementation.
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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

◆ extraOutputDeps()

const DataObjIDColl & AthCommonAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 89 of file AthCommonAlgorithm.cxx.

54{
55 // If we didn't find any symlinks to add, just return the collection
56 // from the base class. Otherwise, return the extended collection.
57 if (!m_extendedExtraObjects.empty()) {
59 }
61}
Common base class for algorithms.

◆ fillChamberIdMap()

StatusCode Muon::MuonTruthSegmentCreationAlg::fillChamberIdMap ( const EventContext & ctx,
const xAOD::TruthParticle & truthParticle,
ChamberIdMap & ids ) const
private

This function uses the 6 vectors, contained in.

Parameters
hitsCollection,carryingtruth muon hit IDs categorized by detector technology (MDT, TGC, RPC, sTGC, CSC, MM) to (re-)fill the
idsChamberIdMap, which contains all truth muon hit IDs classified by chamber layer. This function retrieves the chamber layer from the hit ID by means of the muonIdHelper tool.
hitsCollectionhit collection
idsempty chamberIdMap

Definition at line 100 of file MuonTruthSegmentCreationAlg.cxx.

102 {
103
104 for (SG::ReadDecorHandle<xAOD::TruthParticleContainer, std::vector<unsigned long long>>& hitCollection : m_truthHitsKeyArray.makeHandles(ctx)){
105 for (const unsigned long long& hit_compID : hitCollection(truthParticle)){
106 const Identifier id{hit_compID};
107 if (m_idHelperSvc->isTgc(id)) { // TGCS should be added to both EIL and EIS
108 if (m_idHelperSvc->phiIndex(id) == PhiIndex::T4) {
109 ids[ChIndex::EIS].push_back(id);
110 ids[ChIndex::EIL].push_back(id);
111 } else {
112 ids[ChIndex::EMS].push_back(id);
113 ids[ChIndex::EML].push_back(id);
114 }
115 } else {
116 ids[m_idHelperSvc->chamberIndex(id) ].push_back(id);
117 }
118 }
119 }
120 return StatusCode::SUCCESS;
121 }
SG::ReadDecorHandleKeyArray< xAOD::TruthParticleContainer, std::vector< unsigned long long > > m_truthHitsKeyArray
Keys of the truth muon decorations that we need to read to (re-)fill the chamberIdMap.

◆ filterPassed()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Get filter decision:

Definition at line 93 of file AthCommonAlgorithm.h.

93 {
94 return execState( ctx ).filterPassed();
95 }
virtual bool filterPassed(const EventContext &ctx) const
Get filter decision:

◆ initialize()

StatusCode Muon::MuonTruthSegmentCreationAlg::initialize ( )
overridevirtual

Definition at line 38 of file MuonTruthSegmentCreationAlg.cxx.

38 {
39 ATH_CHECK(m_muonTruth.initialize());
40
42 ATH_CHECK(m_SDO_TruthNames.initialize());
44
45 ATH_CHECK(m_detMgrKey.initialize());
46 ATH_CHECK(m_idHelperSvc.retrieve());
47
48 ATH_CHECK(m_truthOriginKey.initialize());
50 if(m_idHelperSvc->hasRPC()) {m_truthHitsKeyArray.emplace_back(m_muonTruth, "truthRpcHits");}
51 if(m_idHelperSvc->hasTGC()) {m_truthHitsKeyArray.emplace_back(m_muonTruth, "truthTgcHits");}
52 if(m_idHelperSvc->hasMDT()) {m_truthHitsKeyArray.emplace_back(m_muonTruth, "truthMdtHits");}
53 if(m_idHelperSvc->hasMM()) {m_truthHitsKeyArray.emplace_back(m_muonTruth, "truthMMHits");}
54 if(m_idHelperSvc->hasSTGC()) {m_truthHitsKeyArray.emplace_back(m_muonTruth, "truthStgcHits");}
55 if(m_idHelperSvc->hasCSC()) {m_truthHitsKeyArray.emplace_back(m_muonTruth, "truthCscHits");}
56 ATH_CHECK(m_truthHitsKeyArray.initialize());
57 return StatusCode::SUCCESS;
58 }

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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.

◆ isClonable()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::isClonable ( ) const
inlineoverridevirtualinherited

Specify if the algorithm is clonable.

Only relevant for non-reentrant algorithms. Actual number of clones needs to be set via the "Cardinality" property.

Reimplemented in AFP_DigiTop, AlgB, AlgT, BCM_Digitization, CscDigitBuilder, CscDigitToCscRDO, G4AtlasAlg, G4RunAlg, HGTD_Digitization, HiveAlgBase, InDet::GNNSeedingTrackMaker, InDet::SCT_Clusterization, InDet::SiSPGNNTrackMaker, InDet::SiSPSeededTrackFinder, InDet::SiTrackerSpacePointFinder, ISF::SimKernelMT, ITk::StripDigitization, ITkPixelCablingAlg, ITkStripCablingAlg, LArHitEMapMaker, LArTTL1Maker, LUCID_DigiTop, LVL1::L1TopoSimulation, MergeCalibHits, MergeGenericMuonSimHitColl, MergeHijingPars, MergeMcEventCollection, MergeTrackRecordCollection, MergeTruthJets, MergeTruthParticles, MuonDigitizer, PileUpMTAlg, PixelDigitization, RoIBResultToxAOD, SCT_ByteStreamErrorsTestAlg, SCT_CablingCondAlgFromCoraCool, SCT_CablingCondAlgFromText, SCT_ConditionsParameterTestAlg, SCT_ConditionsSummaryTestAlg, SCT_ConfigurationConditionsTestAlg, SCT_Digitization, SCT_FlaggedConditionTestAlg, SCT_LinkMaskingTestAlg, SCT_MajorityConditionsTestAlg, SCT_ModuleVetoTestAlg, SCT_MonitorConditionsTestAlg, SCT_PrepDataToxAOD, SCT_RawDataToxAOD, SCT_ReadCalibChipDataTestAlg, SCT_ReadCalibDataTestAlg, SCT_RODVetoTestAlg, SCT_SensorsTestAlg, SCT_SiliconConditionsTestAlg, SCT_StripVetoTestAlg, SCT_TdaqEnabledTestAlg, SCT_TestCablingAlg, SCTEventFlagWriter, SCTRawDataProvider, SCTSiLorentzAngleTestAlg, SCTSiPropertiesTestAlg, SGInputLoader, Simulation::BeamEffectsAlg, TileHitVecToCnt, TileMuonFitter, TilePulseForTileMuonReceiver, TileRawChannelMaker, TRTDigitization, and ZDC_DigiTop.

Definition at line 68 of file AthCommonAlgorithm.h.

68 {
69 return true;
70 }

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::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< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Set filter decision:

Reimplemented in AthFilterAlgorithm.

Definition at line 99 of file AthCommonAlgorithm.h.

99 {
101 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Set filter decision:

◆ sysExecute()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Reimplemented in AthAnalysisAlgorithm.

Definition at line 80 of file AthCommonAlgorithm.cxx.

41{
42 return BaseAlg::sysExecute (ctx);
43}

◆ sysInitialize()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, HypoBase, InputMakerBase, and PyAthena::Alg.

Definition at line 60 of file AthCommonAlgorithm.cxx.

71 {
73
74 if (sc.isFailure()) {
75 return sc;
76 }
77
78 ServiceHandle<ICondSvc> cs("CondSvc",name());
79 for (auto h : outputHandles()) {
80 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
81 // do this inside the loop so we don't create the CondSvc until needed
82 if ( cs.retrieve().isFailure() ) {
83 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
85 }
86 if (cs->regHandle(this,*h).isFailure()) {
88 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
89 << " with CondSvc");
90 }
91 }
92 }
93 return sc;
94}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
virtual StatusCode sysInitialize() override
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::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 }

Member Data Documentation

◆ m_CSC_SDO_TruthNames

SG::ReadHandleKey<CscSimDataCollection> Muon::MuonTruthSegmentCreationAlg::m_CSC_SDO_TruthNames {this, "CSCSDOs", "CSC_SDO"}
private

Definition at line 108 of file MuonTruthSegmentCreationAlg.h.

108{this, "CSCSDOs", "CSC_SDO"};

◆ m_detMgrKey

SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> Muon::MuonTruthSegmentCreationAlg::m_detMgrKey
private
Initial value:
{this, "DetectorManagerKey", "MuonDetectorManager",
"Key of input MuonDetectorManager condition data"}

MuonDetectorManager from the conditions store.

Definition at line 114 of file MuonTruthSegmentCreationAlg.h.

114 {this, "DetectorManagerKey", "MuonDetectorManager",
115 "Key of input MuonDetectorManager condition data"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 108 of file AthCommonAlgorithm.h.

◆ m_idHelperSvc

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

Handle for the muonIdHelper service.

Definition at line 111 of file MuonTruthSegmentCreationAlg.h.

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

◆ m_muonTruth

SG::ReadHandleKey<xAOD::TruthParticleContainer> Muon::MuonTruthSegmentCreationAlg::m_muonTruth {this, "muonTruth", "MuonTruthParticles"}
private

Key for the truth muon container and muon origin decoration.

Definition at line 90 of file MuonTruthSegmentCreationAlg.h.

90{this, "muonTruth", "MuonTruthParticles"};

◆ m_muonTruthSegmentContainerName

SG::WriteHandleKey<xAOD::MuonSegmentContainer> Muon::MuonTruthSegmentCreationAlg::m_muonTruthSegmentContainerName {this, "MuonTruthSegmentName", "MuonTruthSegments"}
private

Key for segment container that will be populated with segments.

Definition at line 103 of file MuonTruthSegmentCreationAlg.h.

103{this, "MuonTruthSegmentName", "MuonTruthSegments"};

◆ m_SDO_TruthNames

SG::ReadHandleKeyArray<MuonSimDataCollection> Muon::MuonTruthSegmentCreationAlg::m_SDO_TruthNames
private
Initial value:
{
this, "SDOs", {"RPC_SDO", "TGC_SDO", "MDT_SDO" }, "remove NSW by default for now, can always be changed in the configuration"}

Keys for all çontainers of muon hit simulation data, classified by detector technology.

Definition at line 106 of file MuonTruthSegmentCreationAlg.h.

106 {
107 this, "SDOs", {"RPC_SDO", "TGC_SDO", "MDT_SDO" }, "remove NSW by default for now, can always be changed in the configuration"};

◆ m_truthClassificationKey

SG::ReadDecorHandleKey<xAOD::TruthParticleContainer> Muon::MuonTruthSegmentCreationAlg::m_truthClassificationKey {this, "truthClassificationKey", m_muonTruth, "truthClassification"}
private

Definition at line 96 of file MuonTruthSegmentCreationAlg.h.

96{this, "truthClassificationKey", m_muonTruth, "truthClassification"};

◆ m_truthHitsKeyArray

SG::ReadDecorHandleKeyArray<xAOD::TruthParticleContainer, std::vector<unsigned long long> > Muon::MuonTruthSegmentCreationAlg::m_truthHitsKeyArray {this, "truthHitsKeyArray", { }}
private

Keys of the truth muon decorations that we need to read to (re-)fill the chamberIdMap.

Each key corresponds to the decorator containing hit IDs for each muon for a specific detector technology.

Definition at line 100 of file MuonTruthSegmentCreationAlg.h.

100{this, "truthHitsKeyArray", { }};

◆ m_truthOriginKey

SG::ReadDecorHandleKey<xAOD::TruthParticleContainer> Muon::MuonTruthSegmentCreationAlg::m_truthOriginKey {this, "truthOriginKey", m_muonTruth, "truthOrigin"}
private

FIXME ReadDecorHandle should not be used to access dynamic variables applied by the algorithm which created the container, instead a SG::AuxElement::ConstAccessor should be used.

Definition at line 95 of file MuonTruthSegmentCreationAlg.h.

95{this, "truthOriginKey", m_muonTruth, "truthOrigin"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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