ATLAS Offline Software
AtlRunQueryPVSS.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
4 #
5 # ----------------------------------------------------------------
6 # Script : AtlRunQueryPVSS.py
7 # Project: AtlRunQuery
8 # Purpose: Utility to retrieve information from PVSS DB (DCS quantities)
9 # Authors: Andreas Hoecker (CERN), Joerg Stelzer (DESY)
10 # Created: Mar 27, 2010
11 # ----------------------------------------------------------------
12 
13 def GetPVSS_BPMs( cursor, iovmin, iovmax ):
14 
15  # fetch the event history first
16  selcmd = "SELECT 'EVENTHISTORY_'||lpad (archive#,8,'0') from ( select archive#, start_time, end_time from atlas_pvssDCS.arc_archive A where A.group_name = 'EVENT' and (A.end_time > to_date('%s','DD-MM-YYYY HH24:MI:SS') or A.end_time is null) intersect select archive#, start_time, end_time from atlas_pvssDCS.arc_archive A where A.group_name = 'EVENT' and A.start_time < to_date('%s','DD-MM-YYYY HH24:MI:SS') )" % (iovmin, iovmax)
17  cursor.execute( selcmd )
18  eventhistory = cursor.fetchone()[0]
19 
20  # perform the actual query
21  res = {}
22  bpmvars = ['ATLGCSLHC:BPMSW_B1_distanceIP.position.horizontal', 'ATLGCSLHC:BPMSW_B1_distanceIP.position.vertical',
23  'ATLGCSLHC:BPMSW_B2_distanceIP.position.horizontal', 'ATLGCSLHC:BPMSW_B2_distanceIP.position.vertical']
24 
25  for var in bpmvars:
26  selcmd = "SELECT ROUND(A.VALUE_NUMBER,8), TO_CHAR(A.TS, 'DD-MM-YYYY HH24:MI:SS:FF3') FROM ATLAS_PVSSDCS.%s A,ATLAS_PVSSDCS.ELEMENTS B WHERE A.ELEMENT_ID = B.ELEMENT_ID and ROWNUM <= 15000 AND A.ELEMENT_ID = ( SELECT ELEMENT_ID FROM ATLAS_PVSSDCS.ELEMENTS WHERE ELEMENT_NAME LIKE '%s') AND TS BETWEEN TO_DATE('%s','DD-MM-YYYY HH24:MI:SS' ) AND TO_DATE('%s','DD-MM-YYYY HH24:MI:SS' ) AND A.VALUE_NUMBER <> 'NaN' AND A.VALUE_NUMBER <> BINARY_FLOAT_INFINITY ORDER BY B.ELEMENT_NAME, A.TS" % (eventhistory, var, iovmin, iovmax)
27  cursor.execute( selcmd )
28  res[var] = cursor.fetchall()
29 
30  return res
31 
python.AtlRunQueryPVSS.GetPVSS_BPMs
def GetPVSS_BPMs(cursor, iovmin, iovmax)
Definition: AtlRunQueryPVSS.py:13