ATLAS Offline Software
Functions | Variables
runInfo Namespace Reference

Functions

def main (runNum=None, projectName='')
 
def sinceUntilStr (runNum)
 
def channelValueQuery (url)
 
def extractValue (xmlString, valueName)
 
def extractChannelIov (xmlString)
 
def main (runNum=None)
 

Variables

 runNumber = int( sys.argv[1] )
 
 runNum
 
string coolCherryPyRoot = 'http://coolcherrypy.cern.ch:8080/cooldb/ATLAS_COOLPROD/ATLAS_COOLONL_TDAQ/COMP200/TDAQ/RunCtrl/EOR_Params/timespan/'
 

Function Documentation

◆ channelValueQuery()

def runInfo.channelValueQuery (   url)

Definition at line 23 of file scripts/runInfo.py.

23 def channelValueQuery(url):
24  httpHeaders={'Accept':'text/xml'}
25  textData=None
26  request=urllib2.Request(url,textData, httpHeaders)
27  u=urllib2.urlopen(request)
28  xmlDocString = u.read()
29  return xmlDocString
30 
31 #never know which xml library is available, so we'll use regex instead

◆ extractChannelIov()

def runInfo.extractChannelIov (   xmlString)

Definition at line 40 of file scripts/runInfo.py.

40 def extractChannelIov(xmlString):
41  regex='<channel .+ since="(\d+)" until="(\d+)"'
42  m=re.search(regex,xmlString)
43  try:
44  return long(m.group(1)), long(m.group(2))
45  except AttributeError:
46  return None
47 
48 

◆ extractValue()

def runInfo.extractValue (   xmlString,
  valueName 
)

Definition at line 32 of file scripts/runInfo.py.

32 def extractValue(xmlString, valueName):
33  regex='<value name="'+valueName+'">(.+)</value>'
34  m=re.search(regex,xmlString)
35  try:
36  return m.group(1)
37  except AttributeError:
38  return None
39 

◆ main() [1/2]

def runInfo.main (   runNum = None)

Definition at line 49 of file scripts/runInfo.py.

49 def main( runNum=None ):
50  if runNum == None:
51  print 'ERROR no runNumber given'
52  sys.exit(-1)
53  url=coolCherryPyRoot+sinceUntilStr(runNum)+"/channels/0"
54  print 'runInfo from scripts folder'
55  #e.g. : http://coolcherrypy.cern.ch:8080/cooldb/ATLAS_COOLPROD/ATLAS_COOLONL_TDAQ/COMP200/TDAQ/RunCtrl/EOR_Params/timespan/732227499458560-732231794425855/channels/0
56 
57  xmlString = channelValueQuery(url)
58  RunNumber = extractValue(xmlString,'RunNumber')
59  iovstart,iovend = extractChannelIov(xmlString)
60  nLB = iovend - ( iovstart + 1 )
61  ProjectTag = extractValue(xmlString,'FilenameTag' )
62  DetectorMask = extractValue(xmlString,'DetectorMask' )
63 
64  ts1 = long(extractValue(xmlString,"SORTime"))/1000000000L
65  ts2 = long(extractValue(xmlString,"EORTime"))/1000000000L
66  #--- Detector mask
67  mask=long(DetectorMask)
68  dName, NotInAll, vetoedbits = InitDetectorMaskDecoder()
69  res=''
70  signatures={"SCT BA":"SCTBA,", "SCT BC": "SCTBC,", "SCT EA":"SCTEA,", "SCT EC":"SCTEC,"}
71  for i in range(64):
72  if ( mask & (1 << i) ) :
73  for k,v in signatures.iteritems():
74  if k in dName[i] :
75  res += v
76  res = res[:-1] #chop off that last comma
77  if not res: #if res is empty...make it 'NONE'
78  res = 'NONE'
79 
80  #print RunNumber, ProjectTag, ts1, ts2, nLB, res
81  fw = open( 'runInfo.txt', 'w' )
82  fw.write( str(RunNumber) + ' ' + str(ProjectTag) + ' ' + str(ts1) + ' ' + str(ts2) + ' ' + str(nLB) + ' ' + res )
83  fw.close()
84 

◆ main() [2/2]

def runInfo.main (   runNum = None,
  projectName = '' 
)

Definition at line 10 of file python/runInfo.py.

10 def main( runNum=None, projectName='' ):
11  if runNum is None:
12  print('ERROR no runNumber given')
13  sys.exit(-1)
14 
15  if projectName == '':
16  print('ERROR no projectName given')
17  sys.exit(-1)
18 
19  year=int(projectName[4:6])
20 
21  print('runInfo from python folder')
22  since = ( runNum << 32 )
23  until = ( (runNum+1) << 32 )-1
24  dbSvc = cool.DatabaseSvcFactory.databaseService()
25  #load COMP200 or CONDBR2 depending on date A.Gascon 2014-12-08
26 
27  if os.path.exists("/afs/cern.ch/work/s/sctcalib/CondReadPwd") :
28  pwdinfo = open( '/afs/cern.ch/work/s/sctcalib/CondReadPwd', 'r' ).read()
29  pwdinfolist = pwdinfo.split( ' ' )
30  pwd = pwdinfolist[0]
31  else :
32  print('ERROR : unable to open pwd file')
33  sys.exit(-1)
34 
35  if (year > 13):
36  RunCtrlDB = 'oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TDAQ;dbname=CONDBR2;user=ATLAS_COOL_READER;password='+pwd
37  else:
38  RunCtrlDB = 'oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TDAQ;dbname=COMP200;user=ATLAS_COOL_READER;password='+pwd
39 
40  try:
41  RunCtrlDb = dbSvc.openDatabase( RunCtrlDB )
42  except Exception as e:
43  print('Problem opening database', e)
44  sys.exit(-1)
45 
46  folder_runCtrl = RunCtrlDb.getFolder( '/TDAQ/RunCtrl/EOR' )
47  chList = folder_runCtrl.listChannels()
48  if not chList:
49  print('ERROR : no data in /TDAQ/RunCtrl/EOR')
50 
51  for Id in chList:
52 
53  objs = folder_runCtrl.browseObjects( since, until, cool.ChannelSelection(Id) )
54  for obj in objs:
55  payl = obj.payload()
56  #print(payl)
57  RunNumber = payl[ 'RunNumber' ]
58  SORTime = payl[ 'SORTime' ]
59  EORTime = payl[ 'EORTime' ]
60  iovstart = obj.since()
61  iovend = obj.until()
62  nLB = iovend - ( iovstart + 1 )
63  ProjectTag = payl[ 'T0ProjectTag' ]
64  DetectorMask = payl[ 'DetectorMask' ]
65  objs.close()
66  break
67  RunCtrlDb.closeDatabase()
68 
69  ts1 = SORTime/1000000000
70  ts2 = EORTime/1000000000
71 
72  #--- Detector mask
73  mask= int (DetectorMask,16)
74 
75  if (year < 12):
76  dName, NotInAll, vetoedbits = InitDetectorMaskDecoder( 1 )
77  elif (year < 21):
78  dName, NotInAll, vetoedbits = InitDetectorMaskDecoder( 2 )
79  else:
80  dName, NotInAll, vetoedbits = InitDetectorMaskDecoder( 3 )
81 
82  res=''
83  found = False
84  for i in range(64):
85  if ( mask & (1 << i) ) :
86  if "SCT BA" in dName[i] :
87  found = True
88  res += "SCTBA,"
89  if "SCT BC" in dName[i] :
90  found = True
91  res += "SCTBC,"
92  if "SCT EA" in dName[i] :
93  found = True
94  res += "SCTEA,"
95  if "SCT EC" in dName[i] :
96  found = True
97  res += "SCTEC,"
98 
99  if found:
100  if len(res)>1:
101  res = res[:-1]
102  else:
103  res += 'NONE'
104 
105  #print(RunNumber, ProjectTag, ts1, ts2, nLB, res)
106  fw = open( 'runInfo.txt', 'w' )
107  fw.write( str(RunNumber) + ' ' + str(ProjectTag) + ' ' + str(ts1) + ' ' + str(ts2) + ' ' + str(nLB) + ' ' + res )
108  fw.close()
109 

◆ sinceUntilStr()

def runInfo.sinceUntilStr (   runNum)

Definition at line 17 of file scripts/runInfo.py.

17 def sinceUntilStr(runNum):
18  since = ( runNum << 32 )
19  until = ( (runNum+1) << 32 )-1
20  return str(since)+'-'+str(until)
21 
22 

Variable Documentation

◆ coolCherryPyRoot

string runInfo.coolCherryPyRoot = 'http://coolcherrypy.cern.ch:8080/cooldb/ATLAS_COOLPROD/ATLAS_COOLONL_TDAQ/COMP200/TDAQ/RunCtrl/EOR_Params/timespan/'

Definition at line 15 of file scripts/runInfo.py.

◆ runNum

runInfo.runNum

Definition at line 117 of file python/runInfo.py.

◆ runNumber

runInfo.runNumber = int( sys.argv[1] )

Definition at line 112 of file python/runInfo.py.

runInfo.main
def main(runNum=None, projectName='')
Definition: python/runInfo.py:10
read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition: openCoraCool.cxx:569
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
runInfo.extractValue
def extractValue(xmlString, valueName)
Definition: scripts/runInfo.py:32
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
runInfo.extractChannelIov
def extractChannelIov(xmlString)
Definition: scripts/runInfo.py:40
runInfo.channelValueQuery
def channelValueQuery(url)
Definition: scripts/runInfo.py:23
runInfo.main
def main(runNum=None)
Definition: scripts/runInfo.py:49
runInfo.sinceUntilStr
def sinceUntilStr(runNum)
Definition: scripts/runInfo.py:17
Trk::open
@ open
Definition: BinningType.h:40
python.utils.AtlRunQueryLookup.InitDetectorMaskDecoder
def InitDetectorMaskDecoder(lhcRun)
Definition: AtlRunQueryLookup.py:171
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
str
Definition: BTagTrackIpAccessor.cxx:11