ATLAS Offline Software
Hid2RESrcID.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 #include "GaudiKernel/IToolSvc.h"
11 #include "GaudiKernel/ToolHandle.h"
12 #include "StoreGate/StoreGateSvc.h"
13 #include "GaudiKernel/MsgStream.h"
14 
15 #include <iostream>
16 
17 #include "eformat/SourceIdentifier.h"
18 
19 using eformat::helper::SourceIdentifier;
20 
21 // implementation of LArOnlineID to RESrcID conversion.
22 //
23 // FIXME: need to check the convention for posNeg vs left-right.
24 // DET id assumes left-right
25 // FEB_ID assumes pos-neg.
26 // I have assumed here, left for pn=0 (negative?)
27 // right for pn=1 (positive?)
28 
29 // using ByteStream::Nat8;
30 
32  m_initialized(false),
33  m_onlineHelper(0)
34 {
35 
36 }
37 
39 {
40  ATH_CHECK( initialize (rodMapping.getLArRoModIDvec()) );
41  return StatusCode::SUCCESS;
42 }
43 
44 
45 StatusCode Hid2RESrcID::initialize (const std::vector<HWIdentifier>& roms)
46 {
47  // retrieve onlineHelper
48  ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "Hid2RESrcID");
49  ATH_CHECK( detStore.retrieve() );
50  ATH_CHECK( detStore->retrieve(m_onlineHelper, "LArOnlineID") );
51 
52  // make internal maps
53 
54  eformat::SubDetector detid ;
55  for (const HWIdentifier& mId : roms)
56  {
57  detid = (eformat::SubDetector) m_readoutModuleSvc.subDet(mId);
59 
60  SourceIdentifier sid = SourceIdentifier(detid,m);
61  uint32_t rod_id = sid.code();
62 
63  assert( m_coll2ROD.count(mId) == 0 );
64  m_coll2ROD[ mId ]=rod_id;
65 
66  }
67 
68 
69  m_initialized = true ;
70 
71  return StatusCode::SUCCESS;
72 }
73 
74 
76 { // this method returns a RESrcID for the ROD, for a given COLLECTION_ID
77 
78  COLL_MAP::const_iterator it = m_coll2ROD.find( id );
79  if(it == m_coll2ROD.end()){
80  std::cout <<" H2d2RESrcID invalid COLL ID in hex "<<std::hex<<id.get_compact()<<std::dec<<std::endl;
81  std::abort();
82  }
83 
84  return (*it).second ;
85 }
86 
87 
89  const HWIdentifier& hid) const
90 { // this method returns a RESrcID for the ROD, for a given LArOnlineID
91  // channel number is ignored.
92  HWIdentifier febId = m_onlineHelper->feb_Id(hid) ;
93  HWIdentifier romId = rodMapping.getReadoutModuleID(febId);
94 
95  return getRodIDFromROM(romId);
96 }
97 
101 {
102  return m_rodRobIdMap.getRobID (rod_id);
103 }
104 
105 
109 {
110 // Change Module Type to ROS, moduleid = 0
111 
112  SourceIdentifier id = SourceIdentifier(rob_id);
113  SourceIdentifier id2 = SourceIdentifier(id.subdetector_id(), 0);
114  return id2.code();
115 
116 }
117 
121 {
122 // ROS to DET
123 
124  SourceIdentifier id = SourceIdentifier(ros_id);
125  SourceIdentifier id2 = SourceIdentifier(id.subdetector_id(), 0);
126  return id2.code();
127 }
LArFebRodMapping
Definition: LArFebRodMapping.h:17
Hid2RESrcID::getRobID
uint32_t getRobID(uint32_t rod_id) const
Make a ROB Source ID from a ROD source ID.
Definition: Hid2RESrcID.cxx:100
LArFebRodMapping.h
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
AthCheckMacros.h
LArFebRodMapping::getReadoutModuleID
HWIdentifier getReadoutModuleID(const HWIdentifier &id) const
Definition: LArFebRodMapping.cxx:15
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
LArReadoutModuleService::subDet
static int subDet(const HWIdentifier &id)
return sub-detector identifier
Definition: LArReadoutModuleService.cxx:162
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
RodRobIdMap::getRobID
uint32_t getRobID(uint32_t rod_id) const
Make a ROB Source ID from a ROD source ID.
Definition: RodRobIdMap.cxx:18
Hid2RESrcID::getRodID
uint32_t getRodID(const LArFebRodMapping &rodMapping, const HWIdentifier &hid) const
make a ROD SrcID for a HWIdentifier
Definition: Hid2RESrcID.cxx:88
LArID_Exception.h
LArReadoutModuleService::rodFragId
static int rodFragId(const HWIdentifier &id)
return ROD fragment identifier ( == ROL == ROB identifier )
Definition: LArReadoutModuleService.cxx:211
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Hid2RESrcID::m_initialized
bool m_initialized
Definition: Hid2RESrcID.h:76
HWIdentifier
Definition: HWIdentifier.h:13
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
id2
HWIdentifier id2
Definition: LArRodBlockPhysicsV0.cxx:562
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Hid2RESrcID::getRosID
uint32_t getRosID(uint32_t rob_id) const
Make a ROS Source ID from a ROB source ID.
Definition: Hid2RESrcID.cxx:108
Hid2RESrcID::initialize
StatusCode initialize(const LArFebRodMapping &rodMapping)
Definition: Hid2RESrcID.cxx:38
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArOnlineID_Base::feb_Id
HWIdentifier feb_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Create feb_Id from fields.
Definition: LArOnlineID_Base.cxx:1479
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
LArFebRodMapping::getLArRoModIDvec
const std::vector< HWIdentifier > & getLArRoModIDvec() const
"iterator" on LArReadoutModuleIDs
Definition: LArFebRodMapping.h:46
Hid2RESrcID::getRodIDFromROM
uint32_t getRodIDFromROM(const COLLECTION_ID &hid) const
make a ROD SrcID for a COLLECTION_ID
Definition: Hid2RESrcID.cxx:75
Hid2RESrcID::m_coll2ROD
COLL_MAP m_coll2ROD
Definition: Hid2RESrcID.h:79
Hid2RESrcID::getDetID
uint32_t getDetID(uint32_t ros_id) const
Make a SubDetector ID from ROS source ID.
Definition: Hid2RESrcID.cxx:120
Hid2RESrcID::m_rodRobIdMap
RodRobIdMap m_rodRobIdMap
Definition: Hid2RESrcID.h:81
Hid2RESrcID::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: Hid2RESrcID.h:77
StoreGateSvc.h
Hid2RESrcID::m_readoutModuleSvc
LArReadoutModuleService m_readoutModuleSvc
Definition: Hid2RESrcID.h:80
Hid2RESrcID.h
Hid2RESrcID::Hid2RESrcID
Hid2RESrcID()
constructor
Definition: Hid2RESrcID.cxx:31
ServiceHandle< StoreGateSvc >