ATLAS Offline Software
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 
10 #include "StoreGate/StoreGateSvc.h"
11 #include <fstream>
12 
13 LArCablingTest::LArCablingTest(const std::string& name, ISvcLocator* pSvcLocator):
14  AthAlgorithm(name, pSvcLocator), m_print(true),
15  m_onlineId(0),
16  m_caloCellId(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 
24 }
25 
27  detStore()->retrieve(m_onlineId,"LArOnlineID").ignore();
28  detStore()->retrieve(m_caloCellId,"CaloCell_ID").ignore();
29 
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 
112 void 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 
LArFebRodMapping
Definition: LArFebRodMapping.h:17
LArCablingTest::execute
StatusCode execute()
Definition: LArCablingTest.cxx:39
LArOnlineID_Base::channel_Hash
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Definition: LArOnlineID_Base.cxx:1636
get_generator_info.result
result
Definition: get_generator_info.py:21
CaloCell_Base_ID::region
int region(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArCalibLineMapping::calibSlotLine
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
Definition: LArCalibLineMapping.cxx:15
CaloCell_Base_ID::pos_neg
int pos_neg(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
LArCalibLineMapping
Definition: LArCalibLineMapping.h:17
LArCablingTest::~LArCablingTest
~LArCablingTest()
Definition: LArCablingTest.cxx:23
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
LArOnlineID_Base::slot
int slot(const HWIdentifier id) const
Return the slot number of a hardware cell identifier: slot = [1,15] Slot-ID in top part of the crat...
Definition: LArOnlineID_Base.cxx:1961
LArCablingTest::m_mode
unsigned m_mode
Definition: LArCablingTest.h:38
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
HWIdentifier
Definition: HWIdentifier.h:13
LArOnlineID_Base::barrel_ec
int barrel_ec(const HWIdentifier id) const
Return the position barrel or endcap of a hardware cell identifier: barrel_ec = [0,...
Definition: LArOnlineID_Base.cxx:1942
CaloCell_ID.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArCablingTest::initialize
StatusCode initialize()
Definition: LArCablingTest.cxx:26
LArCablingTest::print
void print(const HWIdentifier &hwid, std::ostream &out, const LArOnOffIdMapping *cabling, const LArCalibLineMapping *clCont)
Definition: LArCablingTest.cxx:112
LArOnlineID_Base::channel
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
Definition: LArOnlineID_Base.cxx:1967
LArCablingTest::LArCablingTest
LArCablingTest(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArCablingTest.cxx:13
LArOnlineID_Base::feb_range
id_range feb_range() const
Definition: LArOnlineID_Base.cxx:1920
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArOnlineID_Base::channel_range
id_range channel_range() const
Definition: LArOnlineID_Base.cxx:1936
Identifier32::get_compact
value_type get_compact(void) const
Get the compact id.
Definition: Identifier32.h:171
LArCablingTest::m_RodKey
SG::ReadCondHandleKey< LArFebRodMapping > m_RodKey
Definition: LArCablingTest.h:35
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
CaloCell_Base_ID::sampling
int sampling(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArOnlineID_Base::pos_neg
int pos_neg(const HWIdentifier id) const
Return the side of a hardware cell identifier pos_neg = [0,1] positive-side or negative-side Barrel...
Definition: LArOnlineID_Base.cxx:1954
CaloCell_Base_ID::eta
int eta(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
CaloCell_Base_ID::sub_calo
int sub_calo(const Identifier id) const
returns an int taken from SUBCALO enum and describing the subCalo to which the Id belongs.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArCablingTest::m_caloCellId
const CaloCell_ID * m_caloCellId
Definition: LArCablingTest.h:40
AthAlgorithm
Definition: AthAlgorithm.h:47
CaloCell_Base_ID::cell_range
id_range cell_range(void) const
Range over full set of Identifiers (LAr + Tiles)
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArCablingTest::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArCablingTest.h:33
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCell_Base_ID::phi
int phi(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
LArCablingTest::m_CLKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
Definition: LArCablingTest.h:34
LArOnlineID_Base::feedthrough
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
Definition: LArOnlineID_Base.cxx:1948
LArCablingTest::m_onlineId
const LArOnlineID * m_onlineId
Definition: LArCablingTest.h:39
LArCablingTest::m_print
bool m_print
Definition: LArCablingTest.h:37
CaloIdManager.h
IdentifierHash
Definition: IdentifierHash.h:38
Identifier::get_identifier32
Identifier32 get_identifier32(void) const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
LArCablingTest.h
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
StoreGateSvc.h
LArOnlineID.h
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20