ATLAS Offline Software
Loading...
Searching...
No Matches
LArCablingTest.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
11#include <fstream>
12
13LArCablingTest::LArCablingTest(const std::string& name, ISvcLocator* pSvcLocator):
14 AthAlgorithm(name, pSvcLocator), m_print(true),
15 m_onlineId(0),
17{
18 declareProperty("Print",m_print=true);
19 declareProperty("TestMode",m_mode=0xF,
20 "1: On->Off, 2: Off->On 4: disconnected, 8: FEB->ROD");
21}
22
25
27 detStore()->retrieve(m_onlineId,"LArOnlineID").ignore();
28 detStore()->retrieve(m_caloCellId,"CaloCell_ID").ignore();
29
30 ATH_CHECK( m_cablingKey.initialize() );
31 ATH_CHECK( m_CLKey.initialize() );
32 ATH_CHECK( m_RodKey.initialize() );
33
34 return StatusCode::SUCCESS;
35}
36
37
38
40
41 std::ofstream outfile;
42 if (m_print) {
43 outfile.open("identifiers.txt");
44 outfile << "hash id bec pn FT SL chan id calo pn sampl reg eta phi calib" << std::endl;
45 }
47 const LArOnOffIdMapping* cabling{*cablingHdl};
48 if(!cabling){
49 ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key() );
50 return StatusCode::FAILURE;
51 }
53 const LArCalibLineMapping *clCont {*clHdl};
54 if(!clCont){
55 ATH_MSG_ERROR("Do not have calib mapping object " << m_CLKey.key() );
56 return StatusCode::FAILURE;
57 }
59 const LArFebRodMapping *rodCont {*rodHdl};
60 if(!rodCont){
61 ATH_MSG_ERROR("Do not have ROD mapping object " << m_RodKey.key() );
62 return StatusCode::FAILURE;
63 }
64 if (m_mode & 1) {
65 for (HWIdentifier hwid : m_onlineId->channel_range()) {
66 if (m_print)
67 print(hwid,outfile,cabling,clCont);
68 const Identifier id=cabling->cnvToIdentifier(hwid);
69 if (m_print)
70 if (id!=Identifier())
71 std::cout << "ON:OFF 0x" << hwid.get_identifier32().get_compact() << ":0x"<<id.get_identifier32().get_compact() << std::dec << std::endl;
72 }
73 }
74 if (m_mode & 2) {
75 for (Identifier id : m_caloCellId->cell_range()) {
76 if (!m_caloCellId->is_tile(id)) {
77 const HWIdentifier hwid=cabling->createSignalChannelID(id);
78 if (m_print)
79 std::cout << "OFF:ON 0x" << std::hex << id.get_identifier32().get_compact() << ":0x"<<hwid.get_identifier32().get_compact() << std::dec << std::endl;
80 }
81 }
82 }
83 if (m_mode & 4) {
84 for (HWIdentifier hwid : m_onlineId->channel_range()) {
85 bool result=cabling->isOnlineConnected(hwid);
86 if (m_print)
87 std::cout << "Connected 0x" << std::hex << hwid.get_identifier32().get_compact() << ":"<<result << std::dec << std::endl;
88 }
89 }
90
91 if (m_mode & 8) {
92 for (HWIdentifier FEBID : m_onlineId->feb_range()) {
93#ifdef LARREADOUTMODULEID_H //Old version
94 const uint32_t RODID=rodCont->getReadoutModuleID(FEBID).id();
95#else //New version, LArReadoutModuleID replaced my HWIdentifier
96 const uint32_t RODID=rodCont->getReadoutModuleID(FEBID).get_identifier32().get_compact();
97#endif
98 if (m_print) {
99 std::cout << "FEB:ROD 0x" << FEBID.get_identifier32().get_compact() << ":0x" <<
100 RODID << std::dec << std::endl;
101 }
102 }//end loop over FEBs
103 }
104 if (m_print)
105 outfile.close();
106 m_print=false;
107 return StatusCode::SUCCESS;
108}
109
110
111
112void LArCablingTest::print (const HWIdentifier& hwid, std::ostream& out, const LArOnOffIdMapping* cabling, const LArCalibLineMapping *clCont) {
113 const IdentifierHash hwid_hash=m_onlineId->channel_Hash(hwid);
114 out << hwid_hash << " " << std::hex << "0x" << hwid.get_identifier32().get_compact() << std::dec << " "
115 << m_onlineId->barrel_ec(hwid) << " "
116 << m_onlineId->pos_neg(hwid) << " "
117 << m_onlineId->feedthrough(hwid) << " "
118 << m_onlineId->slot(hwid) << " "
119 << m_onlineId->channel(hwid) << " : ";
120 if (cabling->isOnlineConnected(hwid)) {
121 const Identifier id=cabling->cnvToIdentifier(hwid);
122 out << std::hex << "0x" << id.get_identifier32().get_compact() << std::dec << " "
123 << m_caloCellId->sub_calo(id) << " "
124 << m_caloCellId->pos_neg(id) << " "
125 << m_caloCellId->sampling(id) << " "
126 << m_caloCellId->region(id) << " "
127 << m_caloCellId->eta(id) << " "
128 << m_caloCellId->phi(id) << " ";
129 }
130 else
131 out << " disconnected ";
132
133 const std::vector<HWIdentifier>& calibIDs=clCont->calibSlotLine(hwid);
134 for (size_t i=0;i<calibIDs.size();++i) {
135 out << std::hex << "0x" << calibIDs[i].get_identifier32().get_compact() << " ";
136 }
137 out << std::dec << std::endl;
138}
139
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
const CaloCell_ID * m_caloCellId
StatusCode execute()
StatusCode initialize()
LArCablingTest(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< LArFebRodMapping > m_RodKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
const LArOnlineID * m_onlineId
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
void print(const HWIdentifier &hwid, std::ostream &out, const LArOnOffIdMapping *cabling, const LArCalibLineMapping *clCont)
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
HWIdentifier getReadoutModuleID(const HWIdentifier &id) const