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 107 of file calibdata.py.

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

◆ check_algo_type()

def calibdata.check_algo_type (   type)

Definition at line 144 of file calibdata.py.

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

◆ check_path()

def calibdata.check_path (   path)

Definition at line 136 of file calibdata.py.

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

◆ checktypes()

def calibdata.checktypes (   arg)

Definition at line 154 of file calibdata.py.

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

◆ parse_date_dir()

def calibdata.parse_date_dir (   upload_arg)

Definition at line 160 of file calibdata.py.

160 def parse_date_dir(upload_arg):
161  global lowtime
162  global uptime
163  # try to parse a date from dirname and figure out IOV
164  check = re.compile('.*2[0-9][0-9][0-9][0-1][0-9][0-3][0-9]\/*')
165  find = re.compile('2[0-9][0-9][0-9][0-1][0-9][0-3][0-9]')
166  check_date = check.match(upload_arg)
167  if check_date != None and (lowtime == None and uptime == None):
168  upload_date = find.findall(upload_arg)
169  # calculate times for IOV from date found in upload_arg
170  lowtime = upload_date[0] + " 00:00:00"
171  uptime = upload_date[0] + " 23:59:59"
172  elif (lowtime != None and uptime != None):
173  upload_date = find.findall(uptime)
174  else:
175  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.")
176  today = time.strftime('%Y%m%d')
177  lowtime = today + " 00:00:00"
178  uptime = today + " 23:59:59"
179  return [today]
180  return upload_date
181 

◆ perr()

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

Definition at line 117 of file calibdata.py.

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

◆ pout()

def calibdata.pout (   output,
  newline = True 
)

Definition at line 130 of file calibdata.py.

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

◆ summary()

def calibdata.summary (   cd)

Definition at line 182 of file calibdata.py.

182 def summary(cd):
183  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']))
184 
185 # TODO: Rewrite all this to use argparse and
186 # consolidate some options into argument-optional
187 # versions (like --db to list db, --db= to set db, and then can remove --listdb)
188 # (getopt cannot handle optional arguments)
189 
190 # options
191 try:
192  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 57 of file calibdata.py.

57 def usage():
58  print("\n --yes to avoid being asked for confirmation (-y)")
59  print("\n --quiet (-q) to run with no output. Will return 0 if no errors, 1 if any problem.")
60  print("\n --force (-F) to force delete of existing data attached to head id before upload or copy")
61  print("\n --list to list head id information from database (-l)")
62  print("\n --listdb to list available databases.")
63  print("\n--db=DATABASE to specify database to operate on (or to be used as destination in case of copy commands)")
64  print("\t If --db not specified actions will apply to default set by calibdb variable in CalibDbInfo.py")
65  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")
66  print("\n --upload (-u) --path=/path/to/files [--path=/path/to/files] (-p)")
67  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.")
68  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")
69  print(" --implementation='implementation string'\n")
70  print("\tImplementation is ignored for RT as it is derived from type and path")
71  print("\n --type=[GTPM][T0BS][T0MT] (-t)")
72  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:")
73  print(" \tG = Gasmon RT")
74  print(" \tT = temperature-corrected")
75  print(" \tP = pressure-corrected")
76  print(" \tM = magnetic-field corrected")
77  print("\tFor T0 or ADC spectra types are:")
78  print(" \tT0BS = T0 Beam Splash")
79  print(" \tT0MT = T0 Mag,Temp corrected (also will accept T0CalibrationMT)")
80  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.")
81  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.")
82  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")
83  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")
84  print("\n --tube=tubeid (-b tubeid) \n\tNumeric ID (321937408) or tube name string (BIL1C01) to apply operations to")
85  print(" --chamber=chamberid (-c chamberid) \n\tChamber id or string to apply operations to.")
86  print("\n\tTube and chamber arguments can be applied to limit scope of any relevant operation.");
87  print("\tIf no tube or chamber is provided, operations effect all data for head id.")
88  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.")
89  print("\n --modifyhead --implementation='string' (only implementation,rootfile,statusflag supported). \n\tUse alone or in conjunction with 'copy' commands to modify existing head ids")
90  print("\n --newid to create a new headid from command line arguments (-n)")
91  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")
92  print("\tFile format is 5 columns ordered: \n\tIMPLEMENTATION LOWRUN UPRUN LOWTIME UPTIME\n\tFile can contain any number of rows to insert")
93  print("\n--lowrun (-L)")
94  print(" --uprun (-U)")
95  print("\tlowrun/uprun are required for new head ids")
96  print("\n --lowtime (-W) format: '20101231 23:59:00'")
97  print(" --uptime (-P) format '20101231 23:59:00'")
98  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. ")
99  print("\n --luminosity (optional, defaults to 1.0)")
100  print("\n --rootfile (optional, defaults to 'none')")
101  print("\n --statusflag (optional, defaults to NULL")
102  print("\n --implementation (required for new head id)")
103  print("\tNOTE: Modifying other values is implemented internally but there is no option available to specify them - if needed please request.")
104  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.")
105  print("\n --setvalid [rt,t0,adc] (-z) sets data as valid for chamber or head id, requires --id and optionally --chamber args.\n")
106 

Variable Documentation

◆ arg

calibdata.arg

Definition at line 233 of file calibdata.py.

◆ autoimpl

bool calibdata.autoimpl = False

Definition at line 52 of file calibdata.py.

◆ cd

calibdata.cd = None

Definition at line 51 of file calibdata.py.

◆ cdsource

calibdata.cdsource = CalibData(copysrc)

Definition at line 484 of file calibdata.py.

◆ chamber

calibdata.chamber = None

Definition at line 32 of file calibdata.py.

◆ chamber_id

calibdata.chamber_id = CalibData.get_tube_id(chamber_string)

Definition at line 536 of file calibdata.py.

◆ chamber_string

calibdata.chamber_string = CalibData.extract_tubestring(filename)

Definition at line 532 of file calibdata.py.

◆ commit

def calibdata.commit = True

Definition at line 832 of file calibdata.py.

◆ constant_arg

calibdata.constant_arg = None

Definition at line 40 of file calibdata.py.

◆ constant_type

string calibdata.constant_type = None

Definition at line 39 of file calibdata.py.

◆ copy

bool calibdata.copy = False

Definition at line 27 of file calibdata.py.

◆ copydata

calibdata.copydata = []

Definition at line 28 of file calibdata.py.

◆ copysrc

calibdata.copysrc = None

Definition at line 37 of file calibdata.py.

◆ count_files

int calibdata.count_files = 0

Definition at line 386 of file calibdata.py.

◆ createid

bool calibdata.createid = False

Definition at line 24 of file calibdata.py.

◆ ct

calibdata.ct = rts[3]

Definition at line 418 of file calibdata.py.

◆ datatypes

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

Definition at line 55 of file calibdata.py.

◆ debug

bool calibdata.debug = False

Definition at line 20 of file calibdata.py.

◆ delete

calibdata.delete = []

Definition at line 46 of file calibdata.py.

◆ dirprep

string calibdata.dirprep = ''

Definition at line 397 of file calibdata.py.

◆ dst_ids

list calibdata.dst_ids = []

Definition at line 349 of file calibdata.py.

◆ dstdata

calibdata.dstdata = cd.fetch_head_data()

Definition at line 348 of file calibdata.py.

◆ error

calibdata.error

Definition at line 496 of file calibdata.py.

◆ exception

calibdata.exception

Definition at line 496 of file calibdata.py.

◆ exit

calibdata.exit

Definition at line 236 of file calibdata.py.

◆ f

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

Definition at line 411 of file calibdata.py.

◆ f_start

calibdata.f_start = f.tell()

Definition at line 413 of file calibdata.py.

◆ fieldcount

int calibdata.fieldcount = 19

Definition at line 427 of file calibdata.py.

◆ fields

Definition at line 672 of file calibdata.py.

◆ file

calibdata.file

Definition at line 194 of file calibdata.py.

◆ filename

calibdata.filename

Definition at line 526 of file calibdata.py.

◆ files

list calibdata.files = ["copyloop"]

Definition at line 391 of file calibdata.py.

◆ flags

calibdata.flags

Definition at line 233 of file calibdata.py.

◆ force

bool calibdata.force = False

Definition at line 19 of file calibdata.py.

◆ head_id

calibdata.head_id = None

Definition at line 29 of file calibdata.py.

◆ idfile

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

Definition at line 378 of file calibdata.py.

◆ idlines

calibdata.idlines = line.split()

Definition at line 471 of file calibdata.py.

◆ ignore_missing

calibdata.ignore_missing

Definition at line 370 of file calibdata.py.

◆ implementation

string calibdata.implementation = None

Definition at line 43 of file calibdata.py.

◆ insert_time

calibdata.insert_time = None

Definition at line 41 of file calibdata.py.

◆ lowrun

calibdata.lowrun = None

Definition at line 33 of file calibdata.py.

◆ lowtime

string calibdata.lowtime = None

Definition at line 35 of file calibdata.py.

◆ luminosity

calibdata.luminosity = None

Definition at line 49 of file calibdata.py.

◆ match_type

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

Definition at line 445 of file calibdata.py.

◆ modified

bool calibdata.modified = False

Definition at line 673 of file calibdata.py.

◆ modifyhead

bool calibdata.modifyhead = False

Definition at line 26 of file calibdata.py.

◆ newidfile

calibdata.newidfile = None

Definition at line 50 of file calibdata.py.

◆ newline

calibdata.newline

Definition at line 526 of file calibdata.py.

◆ noask

bool calibdata.noask = False

Definition at line 18 of file calibdata.py.

◆ nobatch

bool calibdata.nobatch = False

Definition at line 22 of file calibdata.py.

◆ output

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

Definition at line 491 of file calibdata.py.

◆ point_nr

int calibdata.point_nr = 0

Definition at line 575 of file calibdata.py.

◆ quiet

bool calibdata.quiet = False

Definition at line 21 of file calibdata.py.

◆ rootfile

calibdata.rootfile = None

Definition at line 48 of file calibdata.py.

◆ rts

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

Definition at line 414 of file calibdata.py.

◆ scount

int calibdata.scount = 0

Definition at line 355 of file calibdata.py.

◆ showlist

bool calibdata.showlist = False

Definition at line 25 of file calibdata.py.

◆ sitename

calibdata.sitename = None

Definition at line 42 of file calibdata.py.

◆ srcdata

calibdata.srcdata = syncsrc.fetch_head_data()

Definition at line 347 of file calibdata.py.

◆ status_flag

calibdata.status_flag = "NULL"

Definition at line 44 of file calibdata.py.

◆ sync_ids

list calibdata.sync_ids = []

Definition at line 350 of file calibdata.py.

◆ syncdb

bool calibdata.syncdb = False

Definition at line 38 of file calibdata.py.

◆ synclimit

calibdata.synclimit = 1

Definition at line 53 of file calibdata.py.

◆ syncsrc

calibdata.syncsrc = CalibData()

Definition at line 340 of file calibdata.py.

◆ t0_tube_grouping

calibdata.t0_tube_grouping

Definition at line 590 of file calibdata.py.

◆ tube

calibdata.tube = None

Definition at line 31 of file calibdata.py.

◆ tube_id

calibdata.tube_id = None

Definition at line 30 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 585 of file calibdata.py.

◆ type

calibdata.type

Definition at line 555 of file calibdata.py.

◆ upload

string calibdata.upload = False

Definition at line 23 of file calibdata.py.

◆ upload_args

list calibdata.upload_args = []

Definition at line 47 of file calibdata.py.

◆ upload_date

def calibdata.upload_date = parse_date_dir(upload_arg)

Definition at line 403 of file calibdata.py.

◆ uprun

calibdata.uprun = None

Definition at line 34 of file calibdata.py.

◆ uptime

string calibdata.uptime = None

Definition at line 36 of file calibdata.py.

◆ usedb

calibdata.usedb = CalibDbInfo.calibdb

Definition at line 17 of file calibdata.py.

◆ valid

calibdata.valid = []

Definition at line 45 of file calibdata.py.

calibdata.pout
def pout(output, newline=True)
Definition: calibdata.py:130
calibdata.perr
def perr(error, exc=None, exit=False)
Definition: calibdata.py:117
calibdata.check_algo_type
def check_algo_type(type)
Definition: calibdata.py:144
calibdata.parse_date_dir
def parse_date_dir(upload_arg)
Definition: calibdata.py:160
calibdata.check_path
def check_path(path)
Definition: calibdata.py:136
calibdata.summary
def summary(cd)
Definition: calibdata.py:182
calibdata.checktypes
def checktypes(arg)
Definition: calibdata.py:154
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:224
python.KeyStore.list
def list(self, key=None)
Definition: KeyStore.py:318
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
calibdata.usage
def usage()
Definition: calibdata.py:57
calibdata.ask_confirm
def ask_confirm()
Definition: calibdata.py:107