ATLAS Offline Software
createCoolChannelIdFile.py
Go to the documentation of this file.
1 #!/bin/env python
2 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 # Author: nils.gollub@cern.ch
4 
5 from __future__ import print_function
6 
7 import sys, re
8 import ROOT
9 from TileCoolDcs import TileDCSDataInfo
10 
11 
12 buffer=[]
13 
14 re_ai = re.compile("ATLTILLV(\\d{2})(:ELMB/LVCAN.*_)(\\d*)/AI/M5VMB_TEMP2.value")
15 re_states = re.compile("ATLTILLV(\\d{2})(:ELMB/LVCAN.*_)(\\d*)/states.ForDAQ_MBHV")
16 re_hv = re.compile("ATLTILLV(\\d{2}):Drawer(\\d*).Readings.Monitoring.hvOut1.value")
17 re_hvset = re.compile("ATLTILLV(\\d{2}):Drawer(\\d*).Readings.Requests.hvOut1.order")
18 re_daq = re.compile("ATLTILSCS:DAQ(.*).state")
19 
20 #=== mapping of system name number to partition
21 partitionID = { 0 : "EBA",
22  1 : "LBA",
23  2 : "LBC",
24  3 : "EBC"}
25 
26 
27 #=== connect to Oracle DB
28 
29 par = sys.argv
30 info = TileDCSDataInfo.TileDCSDataInfo()
31 dbstring=info.get_dbstring('ORACLE',int(par[1]) if len(par)>1 and par[1].isdigit() else 2)
32 if dbstring is None:
33  print ("Unknown DB")
34  sys.exit(2)
35 
36 print ("Connecting to",dbstring[0])
37 
38 db = ROOT.TSQLServer.Connect( dbstring[0], dbstring[1], dbstring[2])
39 
40 
41 statement = "select ELEMENT_NAME, SYS_ID, DP_ID from ATLAS_PVSSTIL.elements"
42 stmt = db.Statement(statement)
43 if stmt.Process() is True:
44  stmt.StoreResult()
45  while stmt.NextResultRow():
46 
47  element_name = stmt.GetString(0)
48  sys_id = stmt.GetString(1)
49  dp_id = stmt.GetString(2)
50 
51  #=== build COOL channel id
52  channel_id = dp_id + ('000'+sys_id)[-3:]
53 
54  #=== find components
55  result_ai = re_ai.search(element_name)
56  result_states = re_states.search(element_name)
57  result_hv = re_hv.search(element_name)
58  result_hvset = re_hvset.search(element_name)
59  result_daq = re_daq.search(element_name)
60 
61  if result_ai:
62  partition = partitionID[int(result_ai.groups()[0])]
63  drawer = partition+('00'+result_ai.groups()[2])[-2:]
64  oracleId = "ATLTILLV"
65  for part in result_ai.groups():
66  oracleId += part
67  oracleId += "/AI"
68  buffer.append( "/TILE/DCS/AI\t%s\t%s\t%s\n"%(drawer,channel_id,oracleId) )
69 
70  elif result_states:
71  partition = partitionID[int(result_states.groups()[0])]
72  drawer = partition+('00'+result_states.groups()[2])[-2:]
73  oracleId = "ATLTILLV"
74  for part in result_states.groups():
75  oracleId += part
76  oracleId += "/states"
77  buffer.append( "/TILE/DCS/STATES\t%s\t%s\t%s\n"%(drawer,channel_id,oracleId) )
78 
79  elif result_hv:
80  part = result_hv.groups()
81  partition = partitionID[int(part[0])]
82  drawer = partition+('00'+part[1])[-2:]
83  oracleId = "ATLTILLV"+part[0]
84  oracleId += ":Drawer"+part[1]+".Readings.Monitoring"
85  buffer.append( "/TILE/DCS/HV\t%s\t%s\t%s\n"%(drawer,channel_id,oracleId) )
86 
87  elif result_hvset:
88  part = result_hvset.groups()
89  partition = partitionID[int(part[0])]
90  drawer = partition+('00'+part[1])[-2:]
91  oracleId = "ATLTILLV"+part[0]
92  oracleId += ":Drawer"+part[1]+".Readings.Requests"
93  buffer.append( "/TILE/DCS/HVSET\t%s\t%s\t%s\n"%(drawer,channel_id,oracleId) )
94 
95  elif result_daq:
96  part = result_daq.groups()
97  partition = part[0][:3]
98  oracleId = "ATLTILSCS:DAQ"+partition+".state"
99  #=== only one entry per partition, set module number to "XX"
100  drawer = partition + "XX"
101  buffer.append( "/DAQdummy/%s/DAQdummy\t%s\t%s\t%s\n"%(partition,drawer,channel_id,oracleId) )
102 
103 
104 #=== write file
105 oldname=info.find_data_file("cool_channel_id.dat")
106 newname="cool_channel_id.dat"
107 print ("Old file:", oldname)
108 print ("New file:", newname)
109 buffer.sort()
110 file = open(newname,"w")
111 for item in buffer:
112  file.write( item )
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Trk::open
@ open
Definition: BinningType.h:40