ATLAS Offline Software
Loading...
Searching...
No Matches
python.LArIdHelperStandalone.LArIdHelper Class Reference
Collaboration diagram for python.LArIdHelperStandalone.LArIdHelper:

Public Member Functions

 __init__ (self)
 larOnlHelper (self)
 caloHelper (self)
 getCabling (self)

Protected Attributes

 _msg = logging.getLogger("LArIdHelper")
 _larOnlHelper = LArOnlineID()
list _allHelpers = []
 _caloHelper = CaloCell_ID(*self._allHelpers)
return self._cabling _cabling = None

Detailed Description

Definition at line 15 of file LArIdHelperStandalone.py.

Constructor & Destructor Documentation

◆ __init__()

python.LArIdHelperStandalone.LArIdHelper.__init__ ( self)

Definition at line 16 of file LArIdHelperStandalone.py.

16 def __init__(self):
17 self._msg=logging.getLogger("LArIdHelper")
18 #Set up LArOnlineID helper class in standalone mode (from xml file)
19 from ROOT import IdDictParser
20 parser=IdDictParser()
21 #Get xml files:
22 xmlpath=None
23 for dd in os.getenv('XMLPATH').split(os.pathsep):
24 d=dd+"/IdDictParser/ATLAS_IDS.xml"
25 if os.access(d,os.R_OK):
26 xmlpath=dd
27 break
28 if not xmlpath:
29 self._msg.error("unable to locate identifier dictionaries in $XMLPATH")
30 sys.exit(-1)
31
32 parser.register_external_entity("LArCalorimeter",xmlpath+"/IdDictParser/IdDictLArCalorimeter_DC3-05-Comm-01.xml")
33 parser.register_external_entity("Calorimeter",xmlpath+"/IdDictParser/IdDictCalorimeter_L1Onl.xml")
34 parser.register_external_entity("TileCalorimeter",xmlpath+"/IdDictParser/IdDictTileCalorimeter.xml")
35
36
37 idd = parser.parse(xmlpath+"/IdDictParser/ATLAS_IDS.xml")
38 from ROOT import LArOnlineID
39 self._larOnlHelper=LArOnlineID()
40 stat=self._larOnlHelper.initialize_from_dictionary(idd)
41 if stat==1:
42 self._msg.error("failed to init LArOnlineID")
43 sys.exit(-1)
44
45
46 from ROOT import LArEM_ID, LArHEC_ID, LArFCAL_ID, LArMiniFCAL_ID, TileID
47
48 self._allHelpers=[]
49 for subHelper in (LArEM_ID, LArHEC_ID, LArFCAL_ID, LArMiniFCAL_ID, TileID):
50 helper=subHelper()
51 helper.set_do_neighbours(False)
52 stat=helper.initialize_from_dictionary(idd)
53 if stat==1:
54 self._msg.error("failed to init" + str(subHelper))
55 else:
56 self._allHelpers.append(helper)
57 pass
58 from ROOT import CaloCell_ID
59 self._caloHelper=CaloCell_ID(*self._allHelpers)
60 self._caloHelper.initialize_from_dictionary(idd)
61 #Note: It's important that all sub-helpers are part of this class. The CaloCell_ID keeps pointers to the individual sub-helpers,
62 #but python's garbage collector doesn't know about this relationship. So it may delete the sub-helpers at any time.
63
64 self._cabling=None
65 return
66
67
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179

Member Function Documentation

◆ caloHelper()

python.LArIdHelperStandalone.LArIdHelper.caloHelper ( self)

Definition at line 71 of file LArIdHelperStandalone.py.

71 def caloHelper(self):
72 return self._caloHelper
73

◆ getCabling()

python.LArIdHelperStandalone.LArIdHelper.getCabling ( self)

Definition at line 74 of file LArIdHelperStandalone.py.

74 def getCabling(self):
75 if self._cabling: return self._cabling
76
77 lardb=indirectOpen("COOLONL_LAR/CONDBR2")
78 f=lardb.getFolder("/LAR/Identifier/OnOffIdMap")
79 ptr=f.findObject(cool.ValidityKeyMax-1,cool.ChannelId(0),"LARIdentifierOnOffIdMap-RUN2-001")
80 payload=ptr.payload()["OnlineHashToOfflineId"]
81 on2off=payload.read()
82 nChans=int(payload.size()/4)
83
84 self._cabling=ROOT.LArOnOffIdMapping(self._larOnlHelper,self._caloHelper)
85 onlHash2OflIdVec=self._cabling.getOnlHash2OflId()
86 oflHash2OnlIdVec=self._cabling.getOflHash2OnId()
87
88
89 i=0
90 nConnected=0
91 iChan=0
92 while (iChan<nChans):
93 idnum=int.from_bytes(on2off[i:i+4],'little')
94 #self._msg.debug("From Blob[%i]=0x%x" % (iChan,idnum))
95 oflId=ROOT.Identifier(ROOT.Identifier32(idnum))
96 if oflId.is_valid():
97 oflHash=self._caloHelper.calo_cell_hash(oflId)
98 onlHash=ROOT.IdentifierHash(iChan)
99 if oflHash.value()>=oflHash2OnlIdVec.size():
100 self._msg.error("invalid offline hash %i", oflHash.value())
101 return
102
103 if onlHash.value()>=onlHash2OflIdVec.size():
104 self._msg.error("invalid offline hash %i", onlHash.value())
105 return
106 nConnected+=1
107 onlId=self._larOnlHelper.channel_Id(onlHash)
108 onlHash2OflIdVec[iChan]=oflId
109 oflHash2OnlIdVec[oflHash.value()]=onlId
110 pass
111 else:
112 #print ("idnum %i give invalid offline id 0x%x",(idnum,oflId.get_identifier32().get_compact()))
113 pass
114 i+=4
115 iChan+=1
116 pass
117
118 self._msg.info("Found identifier mapping for %i connected channels", nConnected)
119
120 return self._cabling
121
122

◆ larOnlHelper()

python.LArIdHelperStandalone.LArIdHelper.larOnlHelper ( self)

Definition at line 68 of file LArIdHelperStandalone.py.

68 def larOnlHelper(self):
69 return self._larOnlHelper
70

Member Data Documentation

◆ _allHelpers

list python.LArIdHelperStandalone.LArIdHelper._allHelpers = []
protected

Definition at line 48 of file LArIdHelperStandalone.py.

◆ _cabling

return self._cabling python.LArIdHelperStandalone.LArIdHelper._cabling = None
protected

Definition at line 64 of file LArIdHelperStandalone.py.

◆ _caloHelper

python.LArIdHelperStandalone.LArIdHelper._caloHelper = CaloCell_ID(*self._allHelpers)
protected

Definition at line 59 of file LArIdHelperStandalone.py.

◆ _larOnlHelper

python.LArIdHelperStandalone.LArIdHelper._larOnlHelper = LArOnlineID()
protected

Definition at line 39 of file LArIdHelperStandalone.py.

◆ _msg

python.LArIdHelperStandalone.LArIdHelper._msg = logging.getLogger("LArIdHelper")
protected

Definition at line 17 of file LArIdHelperStandalone.py.


The documentation for this class was generated from the following file: