ATLAS Offline Software
Loading...
Searching...
No Matches
TgcPrepDataReplicationToolAllBCto3BC.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
11
12
13//================ Constructor =================================================
15 (const std::string& t, const std::string& n, const IInterface* p)
16 : base_class(t, n, p) {}
17
18//================ Initialization ==============================================
20 ATH_CHECK(m_idHelperSvc.retrieve());
21
22 for(int ibc = 0; ibc < BC_ALL; ibc++) {
23 std::ostringstream location;
24 location << "TGC_Measurements"
25 << (ibc == BC_PREVIOUS ? "PriorBC" : "")
26 << (ibc == BC_NEXT ? "NextBC" : "");
27 m_3BCKeys.at(ibc) = location.str();
28 }
29
30 ATH_CHECK(m_3BCKeys.initialize());
31 ATH_CHECK(m_AllBCKey.initialize());
32
33 return StatusCode::SUCCESS;
34}
35
36StatusCode Muon::TgcPrepDataReplicationToolAllBCto3BC::replicate(const EventContext& ctx) const
37{
38 return convertAllBCto3BC(ctx);
39}
40
41StatusCode Muon::TgcPrepDataReplicationToolAllBCto3BC::convertAllBCto3BC(const EventContext& ctx) const {
42
44
45 if(!tgcAll.isValid()) {
46 ATH_MSG_FATAL("Cannot retrieve TGC_MeasurementsAllBCs");
47 return StatusCode::FAILURE;
48 }
49
50
51 // convert
52 auto tgc3BCHandles = m_3BCKeys.makeHandles(ctx);
53 for (int ibc = 0; ibc < BC_ALL; ibc++){
54 tgc3BCHandles.at(ibc) = std::make_unique<TgcPrepDataContainer>(m_idHelperSvc->tgcIdHelper().module_hash_max());
55 }
56
57 for (const Muon::TgcPrepDataCollection * coll : *tgcAll) {
58 for (const Muon::TgcPrepData* to_copy : *coll) {
59
60 uint16_t bcBitMap = to_copy->getBcBitMap();
61 std::array<uint16_t, BC_NUM> hasBC{0};
62 if (bcBitMap & TgcPrepData::BCBIT_PREVIOUS)
64 if (bcBitMap & TgcPrepData::BCBIT_CURRENT)
66 if (bcBitMap & TgcPrepData::BCBIT_NEXT)
68
69 const Identifier channelId = to_copy->identify();
70 const Identifier elementId = m_idHelperSvc->tgcIdHelper().elementID(channelId);
71 std::array<Muon::TgcPrepDataCollection*, BC_ALL> collections{};
72 for (int ibc = 0; ibc < BC_ALL; ibc++) {
73 collections[ibc] = Muon::IDC_Helper::getCollection<TgcPrepDataContainer, TgcIdHelper>
74 (elementId, tgc3BCHandles[ibc].ptr(), m_idHelperSvc->tgcIdHelper(), msg());
75
76 if (!hasBC[ibc]) continue;
77 Muon::TgcPrepData* newPrepData = makeTgcPrepData(to_copy, hasBC[ibc]);
78 newPrepData->setHashAndIndex(collections[ibc]->identifyHash(), collections[ibc]->size());
79 collections[ibc]->push_back(newPrepData);
80 }
81 }
82 }
83
84
85 return StatusCode::SUCCESS;
86}
87
88
91{
92 Identifier channelId = to_copy->identify();
93 IdentifierHash tgcHashId = to_copy->collectionHash();
94 const std::vector<Identifier> &identifierList = to_copy->rdoList();
95 const Amg::MatrixX& newErrHitPos{to_copy->localCovariance()};
96 const MuonGM::TgcReadoutElement* descriptor = to_copy->detectorElement();
97 Muon::TgcPrepData* newPrepData = new TgcPrepData(channelId, tgcHashId, to_copy->localPosition(),
98 identifierList, newErrHitPos, descriptor);
99 newPrepData->setBcBitMap(bcBitMap);
100
101 return newPrepData;
102}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
This is a "hash" representation of an Identifier.
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
virtual IdentifierHash collectionHash() const
Returns the IdentifierHash corresponding to the PRD collection in the PRD container.
StatusCode convertAllBCto3BC(const EventContext &ctx) const
static TgcPrepData * makeTgcPrepData(const TgcPrepData *to_copy, uint16_t bcBitMap)
Make new TgcPrepData.
virtual StatusCode replicate(const EventContext &ctx) const override
SG::WriteHandleKeyArray< TgcPrepDataContainer > m_3BCKeys
TgcPrepDataReplicationToolAllBCto3BC(const std::string &t, const std::string &n, const IInterface *p)
Constructor.
Class to represent TGC measurements.
Definition TgcPrepData.h:32
void setBcBitMap(const uint16_t)
set the bcBitMap for this PRD
virtual const MuonGM::TgcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD The pointer will be zero if the det el is not ...
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const Amg::Vector2D & localPosition() const
return the local position reference
Identifier identify() const
return the identifier
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
TEMP for testing: might make some classes friends later ...
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
MuonPrepDataCollection< TgcPrepData > TgcPrepDataCollection
MsgStream & msg
Definition testRead.cxx:32