ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
RunLumiTime.RunLumiTime Class Reference
Collaboration diagram for RunLumiTime.RunLumiTime:

Public Member Functions

def __init__ (self)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_value, exc_traceback)
 
def __del__ (self)
 
def closeDb (self)
 
def parseArgs (self)
 
def execute (self)
 

Public Attributes

 onlLumiDB
 
 onlLBLBFolder
 
 dbHandler
 
 verbose
 
 outFile
 
 runList
 

Detailed Description

Definition at line 17 of file RunLumiTime.py.

Constructor & Destructor Documentation

◆ __init__()

def RunLumiTime.RunLumiTime.__init__ (   self)

Definition at line 19 of file RunLumiTime.py.

19  def __init__(self):
20 
21  # online luminosity database
22  self.onlLumiDB = 'COOLONL_TRIGGER/CONDBR2'
23 
24  # folder with LB -> time conversion
25  self.onlLBLBFolder = '/TRIGGER/LUMI/LBLB'
26 
27  # the LumiDBHandler
28  self.dbHandler = None
29 
30  # parse command-line input
31  args = self.parseArgs()
32 
33  # output level
34  self.verbose = args.verbose
35 
36  # output file (default stdout)
37  self.outFile = args.outfile
38 
39  # List of (integer) run numbers specified on the command line
40  self.runList = args.runlist
41 
42  print(f"Finished parsing run list: {', '.join([str(run) for run in self.runList])}")
43 

◆ __del__()

def RunLumiTime.RunLumiTime.__del__ (   self)

Definition at line 52 of file RunLumiTime.py.

52  def __del__(self):
53  self.closeDb()
54 

Member Function Documentation

◆ __enter__()

def RunLumiTime.RunLumiTime.__enter__ (   self)

Definition at line 44 of file RunLumiTime.py.

44  def __enter__(self):
45  # Instantiate the LumiDBHandler, so we can cleanup all COOL connections at exit
46  self.dbHandler = LumiDBHandler()
47  return self
48 

◆ __exit__()

def RunLumiTime.RunLumiTime.__exit__ (   self,
  exc_type,
  exc_value,
  exc_traceback 
)

Definition at line 49 of file RunLumiTime.py.

49  def __exit__(self, exc_type, exc_value, exc_traceback):
50  self.closeDb()
51 

◆ closeDb()

def RunLumiTime.RunLumiTime.closeDb (   self)

Definition at line 55 of file RunLumiTime.py.

55  def closeDb(self):
56  if self.dbHandler is not None:
57  self.dbHandler.closeAllDB()
58 

◆ execute()

def RunLumiTime.RunLumiTime.execute (   self)

Definition at line 76 of file RunLumiTime.py.

76  def execute(self):
77  # Instantiate the LumiDBHandler, so we can cleanup all COOL connections in the destructor
78  if self.dbHandler is None:
79  self.dbHandler = LumiDBHandler()
80 
81  # Open outfile if desired
82  fp = None
83  format = "stdout"
84  if self.outFile is not None:
85  fp = open(self.outFile, 'w')
86  format = "txt"
87  if self.outFile.endswith(".json"):
88  format = "json"
89  output = {}
90  if self.outFile.endswith(".csv"):
91  format = "csv"
92 
93 
94  # Get our COOL folder
95  lblb = CoolDataReader(self.onlLumiDB, self.onlLBLBFolder)
96 
97  # Load data for each run specified
98  for run in self.runList:
99 
100  lblb.setIOVRangeFromRun(run)
101  if not lblb.readData():
102  print(f'RunLumiTime - No LBLB data found for run {run}!')
103  continue
104 
105  for obj in lblb.data:
106  # IOV is equal to (Run << 32) + LB number.
107  run = obj.since() >> 32
108  lb = obj.since() & 0xFFFFFFFF
109  # Time is UTC nanoseconds
110  startTime = obj.payload()['StartTime']
111  endTime = obj.payload()['EndTime']
112  if format == "json":
113  if not run in output:
114  output[run] = []
115  output[run] += [{
116  "lb":lb,
117  "begin": startTime/1.e9,
118  "end": endTime/1.e9
119  }]
120  else:
121  entry = (run, lb, startTime/1.e9, endTime/1.e9)
122  separator = ',' if format=='csv' else ' '
123  print(separator.join([str(v) for v in entry]), file=fp)
124 
125  if format=="json":
126  import json
127  json.dump(output, fp, indent=4)
128 
129  # close the file
130  if fp is not None:
131  fp.close()
132  print(f"Wrote file {self.outFile}")
133 
134 # Executed from the command line

◆ parseArgs()

def RunLumiTime.RunLumiTime.parseArgs (   self)

Definition at line 59 of file RunLumiTime.py.

59  def parseArgs(self):
60  parser = ArgumentParser()
61 
62  parser.add_argument("-v", "--verbose",
63  action="store_true", dest="verbose",
64  help="turn on verbose output")
65 
66  parser.add_argument("-r", "--run", nargs='*', required=True, type=int,
67  dest="runlist", metavar="RUN",
68  help="show specific run(s)")
69 
70  parser.add_argument('-o', '--output',
71  dest='outfile', metavar = "FILE", default=None, type=str,
72  help="write results to output file (default stdout). If filename ends in csv or json those formats are used.")
73 
74  return parser.parse_args()
75 

Member Data Documentation

◆ dbHandler

RunLumiTime.RunLumiTime.dbHandler

Definition at line 28 of file RunLumiTime.py.

◆ onlLBLBFolder

RunLumiTime.RunLumiTime.onlLBLBFolder

Definition at line 25 of file RunLumiTime.py.

◆ onlLumiDB

RunLumiTime.RunLumiTime.onlLumiDB

Definition at line 22 of file RunLumiTime.py.

◆ outFile

RunLumiTime.RunLumiTime.outFile

Definition at line 37 of file RunLumiTime.py.

◆ runList

RunLumiTime.RunLumiTime.runList

Definition at line 40 of file RunLumiTime.py.

◆ verbose

RunLumiTime.RunLumiTime.verbose

Definition at line 34 of file RunLumiTime.py.


The documentation for this class was generated from the following file:
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::open
@ open
Definition: BinningType.h:40
python.AthDsoLogger.__del__
def __del__(self)
Definition: AthDsoLogger.py:82
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
str
Definition: BTagTrackIpAccessor.cxx:11