ATLAS Offline Software
Functions | Variables
calibdata Namespace Reference

Functions

def usage ()
 
def ask_confirm ()
 
def perr (error, exc=None, exit=False)
 
def pout (output, newline=True)
 
def check_path (path)
 
def check_algo_type (type)
 
def checktypes (arg)
 
def parse_date_dir (upload_arg)
 
def summary (cd)
 

Variables

 usedb = CalibDbInfo.calibdb
 
bool noask = False
 
bool force = False
 
bool debug = False
 
bool quiet = False
 
bool nobatch = False
 
bool upload = False
 
bool createid = False
 
bool showlist = False
 
bool modifyhead = False
 
bool copy = False
 
list copydata = []
 
 head_id = None
 
 tube_id = None
 
 tube = None
 
 chamber = None
 
 lowrun = None
 
 uprun = None
 
 lowtime = None
 
 uptime = None
 
 copysrc = None
 
bool syncdb = False
 
 constant_type = None
 
 constant_arg = None
 
 insert_time = None
 
 sitename = None
 
 implementation = None
 
string status_flag = "NULL"
 
list valid = []
 
list delete = []
 
list upload_args = []
 
 rootfile = None
 
 luminosity = None
 
 newidfile = None
 
 cd = None
 
bool autoimpl = False
 
int synclimit = 1
 
list datatypes = ['t0','rt','adc','id']
 
 file
 
 arg
 
 flags
 
 exit
 
 syncsrc = CalibData()
 
 srcdata = syncsrc.fetch_head_data()
 
 dstdata = cd.fetch_head_data()
 
list dst_ids = []
 
list sync_ids = []
 
int scount = 0
 
 ignore_missing
 
 idfile = open(newidfile, 'r')
 
int count_files = 0
 
list files = ["copyloop"]
 
string dirprep = ''
 
def upload_date = parse_date_dir(upload_arg)
 
 f = open(dirprep + filename, 'r')
 
 f_start = f.tell()
 
 rts = f.readline().split()
 
 ct = rts[3]
 
int fieldcount = 19
 
 match_type = re.findall(r'[GPTM]+',rts[2])
 
 idlines = line.split()
 
 cdsource = CalibData(copysrc)
 
string output = "\nCould not retrieve head id(s) from database: "
 
 error
 
 exception
 
 filename
 
 newline
 
 chamber_string = CalibData.extract_tubestring(filename)
 
 chamber_id = CalibData.get_tube_id(chamber_string)
 
 type
 
int point_nr = 0
 
string tube_id_string = rts[0] + "_" + rts[1] + "_" + rts[2] + "-" + rts[4] + "-" + rts[5] + "-" + rts[6]
 
 t0_tube_grouping
 
dictionary fields = { 'implementation':implementation, 'lowrun':lowrun, 'uprun':uprun, 'lowtime':lowtime, 'uptime':uptime,'luminosity':luminosity, 'rootfile':rootfile, 'sitename':sitename,'insert_time':insert_time, 'status_flag':status_flag }
 
bool modified = False
 
bool commit = True
 

Function Documentation

◆ ask_confirm()

def calibdata.ask_confirm ( )

Definition at line 106 of file calibdata.py.

106 def ask_confirm():
107  if noask == False and quiet == False:
108  confirm = raw_input("Enter 'y' or 'yes' if you wish to continue with operation: ")
109  else:
110  confirm = "y"
111  if confirm not in ("y","yes","Y","YES"):
112  return False
113  else:
114  return True
115 

◆ check_algo_type()

def calibdata.check_algo_type (   type)

Definition at line 143 of file calibdata.py.

143 def check_algo_type(type):
144  if re.match(r'[GTPM]', type):
145  return True
146 
147  if type == 'T0CalibrationMT' or type == 'T0BS' or type == 'T0MT':
148  return True
149 
150  return False
151 
152 # check input data type in t0,adc,rt,id

◆ check_path()

def calibdata.check_path (   path)

Definition at line 135 of file calibdata.py.

135 def check_path(path):
136  if os.path.isdir(path) or os.path.isfile(path):
137  return True
138  else:
139  perr("File/path argument to upload option does not exist", exit=True)
140  #sys.exit(1)
141 
142 # check --type argument

◆ checktypes()

def calibdata.checktypes (   arg)

Definition at line 153 of file calibdata.py.

153 def checktypes(arg):
154  if len(list(set(arg) & set(datatypes))) == 0:
155  return False
156  else:
157  return True
158 

◆ parse_date_dir()

def calibdata.parse_date_dir (   upload_arg)

Definition at line 159 of file calibdata.py.

159 def parse_date_dir(upload_arg):
160  global lowtime
161  global uptime
162  # try to parse a date from dirname and figure out IOV
163  check = re.compile(r'.*2[0-9][0-9][0-9][0-1][0-9][0-3][0-9]\/*')
164  find = re.compile(r'2[0-9][0-9][0-9][0-1][0-9][0-3][0-9]')
165  check_date = check.match(upload_arg)
166  if check_date != None and (lowtime == None and uptime == None):
167  upload_date = find.findall(upload_arg)
168  # calculate times for IOV from date found in upload_arg
169  lowtime = upload_date[0] + " 00:00:00"
170  uptime = upload_date[0] + " 23:59:59"
171  elif (lowtime != None and uptime != None):
172  upload_date = find.findall(uptime)
173  else:
174  pout("Upload directory name does not contain date in format: 20091021 and you did not specify lowtime/uptime in arguments. Today's date will be used.")
175  today = time.strftime('%Y%m%d')
176  lowtime = today + " 00:00:00"
177  uptime = today + " 23:59:59"
178  return [today]
179  return upload_date
180 

◆ perr()

def calibdata.perr (   error,
  exc = None,
  exit = False 
)

Definition at line 116 of file calibdata.py.

116 def perr(error,exc=None,exit=False,):
117  if quiet == False:
118  output = error
119  if isinstance(exc,KeyboardInterrupt):
120  output += ": User Interrupt"
121  elif isinstance(exc,Exception):
122  if not isinstance(exc,SystemExit):
123  output += ": " + exc.__str__()
124  output += "\n"
125  print (output, file=sys.stderr)
126  if exit == True:
127  sys.exit(1)
128 

◆ pout()

def calibdata.pout (   output,
  newline = True 
)

Definition at line 129 of file calibdata.py.

129 def pout(output,newline=True):
130  if newline:
131  output += "\n"
132  if quiet == False:
133  print (output)
134 

◆ summary()

def calibdata.summary (   cd)

Definition at line 181 of file calibdata.py.

181 def summary(cd):
182  pout("Committed %s database operations this session in %s separate transactions. \nRolled back or failed %s write operations.\nTotal walltime %s and total CPU time %s seconds." % (cd.optotal, cd.transtotal, cd.opcount,cd.dbtime['wtime'],cd.dbtime['ptime']))
183 
184 # TODO: Rewrite all this to use argparse and
185 # consolidate some options into argument-optional
186 # versions (like --db to list db, --db= to set db, and then can remove --listdb)
187 # (getopt cannot handle optional arguments)
188 
189 # options
190 try:
191  opts, args = getopt.getopt(sys.argv[1:], "hup:d:t:b:c:m:i:nf:r:ylqDFL:U:W:P:", ["help", "upload","path=","delete=","type=","tube=","chamber=","implementation=","id=","newid","newidfile=","setvalid=","yes","list","quiet","debug","force","lowrun=","uprun=","lowtime=","uptime=","from=","copy=","modifyhead","luminosity=","rootfile=","statusflag=","listdb","db=","sync","synclimit=" ])

◆ usage()

def calibdata.usage ( )

Definition at line 56 of file calibdata.py.

56 def usage():
57  print("\n --yes to avoid being asked for confirmation (-y)")
58  print("\n --quiet (-q) to run with no output. Will return 0 if no errors, 1 if any problem.")
59  print("\n --force (-F) to force delete of existing data attached to head id before upload or copy")
60  print("\n --list to list head id information from database (-l)")
61  print("\n --listdb to list available databases.")
62  print("\n--db=DATABASE to specify database to operate on (or to be used as destination in case of copy commands)")
63  print("\t If --db not specified actions will apply to default set by calibdb variable in CalibDbInfo.py")
64  print("\n --id=head id to apply actions to (-i headid). Not required by actions that \n\tmay create new head id (upload,copy,newid). If specified for upload or copy \n\tthen inserted data will be associated with that id. \n\t--force may be required to delete existing data for id")
65  print("\n --upload (-u) --path=/path/to/files [--path=/path/to/files] (-p)")
66  print("\tPath to 1 or more dir of files to upload named with chamber in filenames.\n\tIf directory is named YYYYMMDD will automatically use for lowtime/uptime. \n\tAssume 24HR period with end at midnight UTC of day in dir name.")
67  print("\tUpload can be a single filename. Filename doesn't have to contain chamber name if --chamber is specified.\n\tAny number of path arguments can be used though generally 2 would be used to upload RT and T0 together.\n")
68  print(" --implementation='implementation string'\n")
69  print("\tImplementation is ignored for RT as it is derived from type and path")
70  print("\n --type=[GTPM][T0BS][T0MT] (-t)")
71  print("\tArgument required if files do not have header. Ignored on per-file basis if standard header is provided in any file. Only one type can be specified (if uploading RT and T0 together at least one set must specify correct type in file headers). For RT upload type arguments are:")
72  print(" \tG = Gasmon RT")
73  print(" \tT = temperature-corrected")
74  print(" \tP = pressure-corrected")
75  print(" \tM = magnetic-field corrected")
76  print("\tFor T0 or ADC spectra types are:")
77  print(" \tT0BS = T0 Beam Splash")
78  print(" \tT0MT = T0 Mag,Temp corrected (also will accept T0CalibrationMT)")
79  print("\n --sync --from=database [--synclimit=<integer> (0 for no limit)] [--db=database]\n\tCompares head ids in source(--from) and destination db (--db), and synchronizes ids/data from\n\tsource if not found in destination (must be configured as 'replica').\n\tIf synclimit is not specified, will only sync highest head id. Otherwise sync until synclimit ids have been copied.\n\tIf both source and destination already contain same head ids then program will exit with no action.")
80  print("\n --copy=[t0,adc,rt] --from=ID[@DATABASE] (copy single id) or --from=database (for syncing to replicas) [--force] \n\tIf you do not provide existing --id to copy into then you may provide\n\timplementation, lowrun, uprun, lowtime, uptime to create new id with those parameters.\n\tTo modify some destination fields add --modifyhead and provide new values. \n\tFor convenience --implementation will be accepted without --modifyhead.\n\tIf target is specified as a replica in CalibDbInfo.py then you\n\tdo not need to specify destination ID or new id information - source meta information will be copied exactly.")
81  print("\tMultiple types may be copied at once, separate them with commas. t0 and adc are synonynms that copy the same tables (MDT_TUBE*)\n")
82  print("\tIn any case where a database is not provided for source (@DATABASE) or destination (--db)\n\tlocal database specified in config variable 'calibdb' is used")
83  print("\n --tube=tubeid (-b tubeid) \n\tNumeric ID (321937408) or tube name string (BIL1C01) to apply operations to")
84  print(" --chamber=chamberid (-c chamberid) \n\tChamber id or string to apply operations to.")
85  print("\n\tTube and chamber arguments can be applied to limit scope of any relevant operation.");
86  print("\tIf no tube or chamber is provided, operations effect all data for head id.")
87  print("\tMust provide --id with --tube or --chamber \n\tThey cannot be used to create new id with info for only one tube or chamber.")
88  print("\n --modifyhead --implementation='string' (only implementation,rootfile,statusflag supported). \n\tUse alone or in conjunction with 'copy' commands to modify existing head ids")
89  print("\n --newid to create a new headid from command line arguments (-n)")
90  print("\n --newidfile[=filename] -f [filename] \n\tUse to create a new headid from rows in file if provided \n\tor from info provided in command line args if no filename provided")
91  print("\tFile format is 5 columns ordered: \n\tIMPLEMENTATION LOWRUN UPRUN LOWTIME UPTIME\n\tFile can contain any number of rows to insert")
92  print("\n--lowrun (-L)")
93  print(" --uprun (-U)")
94  print("\tlowrun/uprun are required for new head ids")
95  print("\n --lowtime (-W) format: '20101231 23:59:00'")
96  print(" --uptime (-P) format '20101231 23:59:00'")
97  print("\tNote: lowtime/uptime are required for new head ids. \n\tIf first --path argument contains date in YYYYMMDD format then lowtime/uptime will be start and end of that day unless specified. ")
98  print("\n --luminosity (optional, defaults to 1.0)")
99  print("\n --rootfile (optional, defaults to 'none')")
100  print("\n --statusflag (optional, defaults to NULL")
101  print("\n --implementation (required for new head id)")
102  print("\tNOTE: Modifying other values is implemented internally but there is no option available to specify them - if needed please request.")
103  print("\n --delete [rt,t0,adc,id] (-e) to delete values for head id given by --id.\n\tIf id is in list, deletes that head id.\n\tDeleting id implies deleting values associated regardless of specification of adc,t0,rt in command.")
104  print("\n --setvalid [rt,t0,adc] (-z) sets data as valid for chamber or head id, requires --id and optionally --chamber args.\n")
105 

Variable Documentation

◆ arg

calibdata.arg

Definition at line 232 of file calibdata.py.

◆ autoimpl

bool calibdata.autoimpl = False

Definition at line 51 of file calibdata.py.

◆ cd

calibdata.cd = None

Definition at line 50 of file calibdata.py.

◆ cdsource

calibdata.cdsource = CalibData(copysrc)

Definition at line 483 of file calibdata.py.

◆ chamber

calibdata.chamber = None

Definition at line 31 of file calibdata.py.

◆ chamber_id

calibdata.chamber_id = CalibData.get_tube_id(chamber_string)

Definition at line 535 of file calibdata.py.

◆ chamber_string

calibdata.chamber_string = CalibData.extract_tubestring(filename)

Definition at line 531 of file calibdata.py.

◆ commit

def calibdata.commit = True

Definition at line 831 of file calibdata.py.

◆ constant_arg

calibdata.constant_arg = None

Definition at line 39 of file calibdata.py.

◆ constant_type

string calibdata.constant_type = None

Definition at line 38 of file calibdata.py.

◆ copy

bool calibdata.copy = False

Definition at line 26 of file calibdata.py.

◆ copydata

calibdata.copydata = []

Definition at line 27 of file calibdata.py.

◆ copysrc

calibdata.copysrc = None

Definition at line 36 of file calibdata.py.

◆ count_files

int calibdata.count_files = 0

Definition at line 385 of file calibdata.py.

◆ createid

bool calibdata.createid = False

Definition at line 23 of file calibdata.py.

◆ ct

calibdata.ct = rts[3]

Definition at line 417 of file calibdata.py.

◆ datatypes

list calibdata.datatypes = ['t0','rt','adc','id']

Definition at line 54 of file calibdata.py.

◆ debug

bool calibdata.debug = False

Definition at line 19 of file calibdata.py.

◆ delete

calibdata.delete = []

Definition at line 45 of file calibdata.py.

◆ dirprep

string calibdata.dirprep = ''

Definition at line 396 of file calibdata.py.

◆ dst_ids

list calibdata.dst_ids = []

Definition at line 348 of file calibdata.py.

◆ dstdata

calibdata.dstdata = cd.fetch_head_data()

Definition at line 347 of file calibdata.py.

◆ error

calibdata.error

Definition at line 495 of file calibdata.py.

◆ exception

calibdata.exception

Definition at line 495 of file calibdata.py.

◆ exit

calibdata.exit

Definition at line 235 of file calibdata.py.

◆ f

calibdata.f = open(dirprep + filename, 'r')

Definition at line 410 of file calibdata.py.

◆ f_start

calibdata.f_start = f.tell()

Definition at line 412 of file calibdata.py.

◆ fieldcount

int calibdata.fieldcount = 19

Definition at line 426 of file calibdata.py.

◆ fields

Definition at line 671 of file calibdata.py.

◆ file

calibdata.file

Definition at line 193 of file calibdata.py.

◆ filename

calibdata.filename

Definition at line 525 of file calibdata.py.

◆ files

list calibdata.files = ["copyloop"]

Definition at line 390 of file calibdata.py.

◆ flags

calibdata.flags

Definition at line 232 of file calibdata.py.

◆ force

bool calibdata.force = False

Definition at line 18 of file calibdata.py.

◆ head_id

calibdata.head_id = None

Definition at line 28 of file calibdata.py.

◆ idfile

string calibdata.idfile = open(newidfile, 'r')

Definition at line 377 of file calibdata.py.

◆ idlines

calibdata.idlines = line.split()

Definition at line 470 of file calibdata.py.

◆ ignore_missing

calibdata.ignore_missing

Definition at line 369 of file calibdata.py.

◆ implementation

string calibdata.implementation = None

Definition at line 42 of file calibdata.py.

◆ insert_time

calibdata.insert_time = None

Definition at line 40 of file calibdata.py.

◆ lowrun

calibdata.lowrun = None

Definition at line 32 of file calibdata.py.

◆ lowtime

string calibdata.lowtime = None

Definition at line 34 of file calibdata.py.

◆ luminosity

calibdata.luminosity = None

Definition at line 48 of file calibdata.py.

◆ match_type

calibdata.match_type = re.findall(r'[GPTM]+',rts[2])

Definition at line 444 of file calibdata.py.

◆ modified

bool calibdata.modified = False

Definition at line 672 of file calibdata.py.

◆ modifyhead

bool calibdata.modifyhead = False

Definition at line 25 of file calibdata.py.

◆ newidfile

calibdata.newidfile = None

Definition at line 49 of file calibdata.py.

◆ newline

calibdata.newline

Definition at line 525 of file calibdata.py.

◆ noask

bool calibdata.noask = False

Definition at line 17 of file calibdata.py.

◆ nobatch

bool calibdata.nobatch = False

Definition at line 21 of file calibdata.py.

◆ output

calibdata.output = "\nCould not retrieve head id(s) from database: "

Definition at line 490 of file calibdata.py.

◆ point_nr

int calibdata.point_nr = 0

Definition at line 574 of file calibdata.py.

◆ quiet

bool calibdata.quiet = False

Definition at line 20 of file calibdata.py.

◆ rootfile

calibdata.rootfile = None

Definition at line 47 of file calibdata.py.

◆ rts

calibdata.rts = f.readline().split()

Definition at line 413 of file calibdata.py.

◆ scount

int calibdata.scount = 0

Definition at line 354 of file calibdata.py.

◆ showlist

bool calibdata.showlist = False

Definition at line 24 of file calibdata.py.

◆ sitename

calibdata.sitename = None

Definition at line 41 of file calibdata.py.

◆ srcdata

calibdata.srcdata = syncsrc.fetch_head_data()

Definition at line 346 of file calibdata.py.

◆ status_flag

calibdata.status_flag = "NULL"

Definition at line 43 of file calibdata.py.

◆ sync_ids

list calibdata.sync_ids = []

Definition at line 349 of file calibdata.py.

◆ syncdb

bool calibdata.syncdb = False

Definition at line 37 of file calibdata.py.

◆ synclimit

calibdata.synclimit = 1

Definition at line 52 of file calibdata.py.

◆ syncsrc

calibdata.syncsrc = CalibData()

Definition at line 339 of file calibdata.py.

◆ t0_tube_grouping

calibdata.t0_tube_grouping

Definition at line 589 of file calibdata.py.

◆ tube

calibdata.tube = None

Definition at line 30 of file calibdata.py.

◆ tube_id

calibdata.tube_id = None

Definition at line 29 of file calibdata.py.

◆ tube_id_string

string calibdata.tube_id_string = rts[0] + "_" + rts[1] + "_" + rts[2] + "-" + rts[4] + "-" + rts[5] + "-" + rts[6]

Definition at line 584 of file calibdata.py.

◆ type

calibdata.type

Definition at line 554 of file calibdata.py.

◆ upload

string calibdata.upload = False

Definition at line 22 of file calibdata.py.

◆ upload_args

list calibdata.upload_args = []

Definition at line 46 of file calibdata.py.

◆ upload_date

def calibdata.upload_date = parse_date_dir(upload_arg)

Definition at line 402 of file calibdata.py.

◆ uprun

calibdata.uprun = None

Definition at line 33 of file calibdata.py.

◆ uptime

string calibdata.uptime = None

Definition at line 35 of file calibdata.py.

◆ usedb

calibdata.usedb = CalibDbInfo.calibdb

Definition at line 16 of file calibdata.py.

◆ valid

calibdata.valid = []

Definition at line 44 of file calibdata.py.

calibdata.pout
def pout(output, newline=True)
Definition: calibdata.py:129
calibdata.perr
def perr(error, exc=None, exit=False)
Definition: calibdata.py:116
calibdata.check_algo_type
def check_algo_type(type)
Definition: calibdata.py:143
calibdata.parse_date_dir
def parse_date_dir(upload_arg)
Definition: calibdata.py:159
calibdata.check_path
def check_path(path)
Definition: calibdata.py:135
calibdata.summary
def summary(cd)
Definition: calibdata.py:181
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
calibdata.checktypes
def checktypes(arg)
Definition: calibdata.py:153
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
calibdata.usage
def usage()
Definition: calibdata.py:56
calibdata.ask_confirm
def ask_confirm()
Definition: calibdata.py:106