8#include "Identifier/Identifier.h"
22 const std::set<int> bad_origins{
23 ParticleOrigin ::LightMeson,
24 ParticleOrigin ::StrangeMeson,
25 ParticleOrigin ::LightBaryon,
26 ParticleOrigin ::StrangeBaryon,
27 ParticleOrigin ::PionDecay,
28 ParticleOrigin ::NucReact,
29 ParticleOrigin ::PiZero,
55 return StatusCode::SUCCESS;
69 ATH_CHECK(segmentContainer.
record(std::make_unique<xAOD::MuonSegmentContainer>(),
70 std::make_unique<xAOD::MuonSegmentAuxContainer>()));
71 ATH_MSG_DEBUG(
"Recorded MuonSegmentContainer with key: " << segmentContainer.
name());
76 const int iOrigin = truthOrigin(*truthParticle);
77 bool goodMuon = bad_origins.find(iOrigin) == bad_origins.end();
91 ATH_MSG_DEBUG(
"Registered " << segmentContainer->size() <<
" truth muon segments ");
93 return StatusCode::SUCCESS;
101 for (
const unsigned long long& hit_compID : hitCollection(truthParticle)){
105 ids[ChIndex::EIS].push_back(
id);
106 ids[ChIndex::EIL].push_back(
id);
108 ids[ChIndex::EMS].push_back(
id);
109 ids[ChIndex::EML].push_back(
id);
116 return StatusCode::SUCCESS;
127 constexpr unsigned techMax =
toInt(TechnologyIndex::TechnologyIndexMax);
128 std::array<const MuonSimDataCollection*, techMax> sdoCollections{};
141 for (
const auto& [chIdx, assocIds] : ids) {
143 Amg::Vector3D firstPos{Amg::Vector3D::Zero()}, secondPos{Amg::Vector3D::Zero()};
144 bool firstPosSet{
false}, secondPosSet{
false};
147 uint8_t nprecLayers{0}, nphiLayers{0}, ntrigEtaLayers{0};
148 std::unordered_set<int> phiLayers{}, etaLayers{}, precLayers{};
151 for (
const auto&
id : assocIds) {
167 precLayers.insert(iid);
182 if (sdoCollections[
toInt(techIdx)]) {
183 auto pos = sdoCollections[
toInt(techIdx)]->find(
id);
184 if (pos != sdoCollections[
toInt(techIdx)]->end()) {
185 gpos = pos->second.globalPosition();
186 if (gpos.perp() > 0.1) ok =
true;
195 return std::abs(p1.z()) < std::abs(p2.z());
197 return p1.perp() < p2.perp();
202 }
else if (!secondPosSet) {
205 if (isSmaller(secondPos, firstPos))
std::swap(firstPos, secondPos);
208 if (isSmaller(gpos, firstPos))
210 else if (isSmaller(secondPos, gpos))
216 auto pos = cscCollection->find(
id);
217 if (pos == cscCollection->end()) {
221 ATH_MSG_DEBUG(
"found csc sdo with " << pos->second.getdeposits().size() <<
" deposits");
222 Amg::Vector3D locpos(0, pos->second.getdeposits()[0].second.ypos(), pos->second.getdeposits()[0].second.zpos());
228 }
else if (!secondPosSet) {
231 if (secondPos.perp() < firstPos.perp())
std::swap(firstPos, secondPos);
233 if (gpos.perp() < firstPos.perp())
235 else if (secondPos.perp() < gpos.perp())
240 if (precLayers.size() > 2) {
241 if (!phiLayers.empty()) nphiLayers = phiLayers.size();
242 ntrigEtaLayers = etaLayers.size();
243 nprecLayers = precLayers.size();
244 ATH_MSG_DEBUG(
" total counts: precision " <<
static_cast<int>(nprecLayers) <<
" phi layers " <<
static_cast<int>(nphiLayers)
245 <<
" eta trig layers " <<
static_cast<int>(ntrigEtaLayers)
247 <<
" truthLink " << truthLink);
250 segment->
setNHits(nprecLayers, nphiLayers, ntrigEtaLayers);
252 truthParticleLinkAcc(
"truthParticleLink");
253 truthParticleLinkAcc(*segment) = truthLink;
261 if (firstPosSet && secondPosSet) {
264 ATH_MSG_DEBUG(
" got position : r " << gpos.perp() <<
" z " << gpos.z() <<
" and direction: theta " << gdir.theta()
265 <<
" phi " << gdir.phi());
266 segment->
setPosition(gpos.x(), gpos.y(), gpos.z());
271 return StatusCode::SUCCESS;
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)
Handle class for reading a decoration on an object.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ElementLink implementation for ROOT usage.
bool toPersistent()
Dummy function provinding the offline interface.
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...
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_truthOriginKey
virtual StatusCode execute(const EventContext &ctx) const override
StatusCode fillChamberIdMap(const EventContext &ctx, const xAOD::TruthParticle &truthParticle, ChamberIdMap &ids) const
This function uses the 6 vectors, contained in.
virtual StatusCode initialize() override
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Handle for the muonIdHelper service.
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.
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::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
MuonDetectorManager from the conditions store.
SG::WriteHandleKey< xAOD::MuonSegmentContainer > m_muonTruthSegmentContainerName
Key for segment container that will be populated with segments.
SG::ReadHandleKey< CscSimDataCollection > m_CSC_SDO_TruthNames
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::ReadHandleKeyArray< MuonSimDataCollection > m_SDO_TruthNames
Keys for all çontainers of muon hit simulation data, classified by detector technology.
Helper class to provide type-safe access to aux data.
Handle class for reading a decoration on an object.
Property holding a SG store/key/clid from which a ReadHandle is made.
bool isPresent() const
Is the referenced object present in SG?
const std::string & name() const
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void setDirection(float px, float py, float pz)
Sets the direction.
void setNHits(int nPrecisionHits, int nPhiLayers, int nTrigEtaLayers)
Set the number of hits/layers.
void setIdentifier(int sector, ::Muon::MuonStationIndex::ChIndex chamberIndex, int etaIndex, ::Muon::MuonStationIndex::TechnologyIndex technology)
Set the identifier.
void setPosition(float x, float y, float z)
Sets the global position.
Eigen::Matrix< double, 3, 1 > Vector3D
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
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
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)
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
TruthParticle_v1 TruthParticle
Typedef to implementation.
MuonSegment_v1 MuonSegment
Reference the current persistent version:
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.