ATLAS Offline Software
checkUPD1.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 #COOLOFL_INDET /Indet/Align InDetAlign-RUN2-BLK-UPD4-13
5 #logging.debug( "%s, %s, %s, %s" %(pcaltag.tag,pcaltag.folder,pcaltag.schema,pcaltag.status) )
6 #pcaltag.tag COOLOFL_INDET
7 #p3caltag.folder /Indet/Align
8 #pcaltag.schema InDetAlign-RUN2-BLK-UPD4-13
9 #pcaltag.status 1
10 
11 from PyCool import cool
12 
13 def getDBNumberFromUPD4(run, tag, foldername, connstr):
14  readonly=(connstr.find('//')==-1)
15  tokens=connstr.split('/')
16  schema=tokens[0]
17  dbname=tokens[1]
18  connstr2='oracle://ATLAS_COOLPROD;schema=ATLAS_%s;dbname=%s' % (schema,dbname)
19  dbSvc=cool.DatabaseSvcFactory.databaseService()
20  dbconn=dbSvc.openDatabase(connstr2,readonly)
21  folder=dbconn.getFolder(foldername)
22  iovstart=int(run)<<32
23  iovend=iovstart+0xFFFFFFFF
24  objs=folder.browseObjects(iovstart,iovend,cool.ChannelSelection.all(),tag)
25  for obj in objs:
26  payload = obj.payload()
27  payload_string = "%s" %( payload )
28  DB_number = payload_string.split()[-1].split("]")[0].split("[")[1]
29  #print ("since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']',)
30  #print ("payload : %s" %(DB_number))
31  #print ()
32  return DB_number
33 
34 def getRunNumberFromUPD1(DB_number, tag, run, foldername, connstr):
35  readonly=(connstr.find('//')==-1)
36  tokens=connstr.split('/')
37  schema=tokens[0]
38  dbname=tokens[1]
39  connstr2='oracle://ATLAS_COOLPROD;schema=ATLAS_%s;dbname=%s' % (schema,dbname)
40  dbSvc=cool.DatabaseSvcFactory.databaseService()
41  dbconn=dbSvc.openDatabase(connstr2,readonly)
42  folder=dbconn.getFolder(foldername)
43  #iovstart=int(run)<<32
44  objs=folder.browseObjects( cool.ValidityKeyMin,
45  #iovstart,
46  cool.ValidityKeyMax,
47  cool.ChannelSelection.all(),
48  tag)
49  print ("ref", DB_number)
50  for obj in objs:
51  payload = obj.payload()
52  payload_string = "%s" %( payload )
53  test_number = payload_string.split()[-1].split("]")[0].split("[")[1]
54  #print (test_number)
55  run_string = obj.since() >> 32,',',obj.since()%0x100000000
56  #print ("since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', end='')
57  #print ("payload : %s" %(test_number))
58  if test_number == DB_number:
59  return run_string
60  return 0
61 
62 
63 
64 from optparse import OptionParser
65 
66 parser=OptionParser(usage="\n ./checkUPD1.py --upd4 <UPD4 folder tag name> --upd1 <UPD1 folder tag name> --folder <e.g. /Indet/Align> -r <run> \n")
67 parser.add_option("-r","--run" ,type="string" ,dest="run" ,default=None ,help="runnumber in UPD4 tag")
68 parser.add_option("-b","--upd4" ,type="string" ,dest="upd4" ,default='InDetAlign-RUN2-BLK-UPD4-13' ,help="runnumber in UPD4 tag")
69 parser.add_option("-e","--upd1" ,type="string" ,dest="upd1" ,default='InDetAlign-RUN2-ES1-UPD1-06' ,help="runnumber in UPD1 tag")
70 parser.add_option("-f","--folder" ,type="string" ,dest="folder" ,default='/Indet/Align' ,help="runnumber in UPD1 tag")
71 (options,args)=parser.parse_args()
72 
73 run = options.run
74 upd4_tag = options.upd4
75 upd1_tag = options.upd1
76 
77 foldername = options.folder
78 connstr = 'COOLOFL_INDET/CONDBR2'
79 
80 if foldername == '/TRT/Align':
81  connstr = 'COOLOFL_TRT/CONDBR2'
82 #print (connstr)
83 #print (foldername)
84 
85 DB_number = getDBNumberFromUPD4(run, upd4_tag, foldername, connstr)
86 run = getRunNumberFromUPD1(DB_number, upd1_tag, run, foldername, connstr)
87 if run:
88  print ("first run in UPD1 tag with matching UPD4 conditions is run %i" %(run[0]))
89 else:
90  print ("no matching conditions found in UPD1 tag!!!")
91 
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.checkUPD1.getRunNumberFromUPD1
def getRunNumberFromUPD1(DB_number, tag, run, foldername, connstr)
Definition: checkUPD1.py:34
python.checkUPD1.getDBNumberFromUPD4
def getDBNumberFromUPD4(run, tag, foldername, connstr)
Definition: checkUPD1.py:13
Trk::split
@ split
Definition: LayerMaterialProperties.h:38