ATLAS Offline Software
Loading...
Searching...
No Matches
MM_DigitToRDO.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "MM_DigitToRDO.h"
6
9
10MM_DigitToRDO::MM_DigitToRDO(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {}
11
13 ATH_MSG_DEBUG(" in initialize()");
14 ATH_CHECK(m_idHelperSvc.retrieve());
15 ATH_CHECK(m_rdoContainer.initialize());
16 ATH_CHECK(m_digitContainer.initialize());
17 ATH_CHECK(m_calibTool.retrieve());
18 ATH_CHECK(m_cablingKey.initialize(!m_cablingKey.empty()));
19 return StatusCode::SUCCESS;
20}
21
22StatusCode MM_DigitToRDO::execute(const EventContext& ctx) const {
23 using namespace Muon;
24 ATH_MSG_DEBUG("in execute()");
26 ATH_CHECK(digits.isPresent());
27 std::unique_ptr<MM_RawDataContainer> rdos = std::make_unique<MM_RawDataContainer>(m_idHelperSvc->mmIdHelper().module_hash_max());
28
29 const Nsw_CablingMap* mmCablingMap{nullptr};
30 if (!m_cablingKey.empty()) {
32 if(!readCondHandle.isValid()){
33 ATH_MSG_ERROR("Cannot find Micromegas cabling map!");
34 return StatusCode::FAILURE;
35 }
36 mmCablingMap = readCondHandle.cptr();
37 }
38
39 for (const MmDigitCollection* digitColl : *digits) {
40 // the identifier of the digit collection is the detector element Id ( multilayer granularity )
41 Identifier digitId = digitColl->identify();
42
43 // get the hash of the RDO collection
44 IdentifierHash hash;
45 int getRdoCollHash = m_idHelperSvc->mmIdHelper().get_module_hash(digitId, hash);
46 if (getRdoCollHash != 0) {
47 ATH_MSG_ERROR("Could not get the module hash Id");
48 return StatusCode::FAILURE;
49 }
50
52 if (rdos->addCollection(coll, hash).isFailure()) {
53 ATH_MSG_WARNING("Failed to add collection with hash " << (int)hash);
54 delete coll;
55 continue;
56 }
57
58 for (const MmDigit* digit : *digitColl) {
59 Identifier newId = digit->identify();
60 // RDO has time and charge in counts
61 int tdo{0}, relBcid{0}, pdo{0};
62 m_calibTool->timeToTdo(ctx, digit->stripResponseTime(), newId, tdo, relBcid);
63 m_calibTool->chargeToPdo(ctx, digit->stripResponseCharge(), newId, pdo);
64
65 // the cabling map is introduced here for studies of the MM strip misalignment. It does not run in standart jobs (read key is empty)
66 if (mmCablingMap) {
67 std::optional<Identifier> correctedChannelId = mmCablingMap->correctChannel(newId, msgStream());
68 if (!correctedChannelId) {
69 ATH_MSG_DEBUG("Channel was shifted outside its connector and is therefore not decoded into and RDO");
70 continue;
71 }
72 newId = (*correctedChannelId);
73 }
74 // Fill object
75 std::unique_ptr<MM_RawData> rdo = std::make_unique<MM_RawData>(newId, m_idHelperSvc->mmIdHelper().channel(newId),
76 tdo, pdo, relBcid, true);
77 coll->push_back(std::move(rdo));
78 }
79 }
80
82 ATH_CHECK(writeHanlde.record(std::move(rdos)));
83
84 ATH_MSG_DEBUG("done execute()");
85 return StatusCode::SUCCESS;
86}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
This is a "hash" representation of an Identifier.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadCondHandleKey< Nsw_CablingMap > m_cablingKey
virtual StatusCode initialize() override final
ToolHandle< Muon::INSWCalibTool > m_calibTool
SG::WriteHandleKey< Muon::MM_RawDataContainer > m_rdoContainer
MM_DigitToRDO(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< MmDigitContainer > m_digitContainer
virtual StatusCode execute(const EventContext &ctx) const override final
std::optional< Identifier > correctChannel(const Identifier &id, MsgStream &msg) const
const_pointer_type cptr()
bool isPresent() const
Is the referenced object present in SG?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.