Functions | Variables
OnMonTriggerRateStudy Namespace Reference

Functions

def GetDataFromInputFile (filepath)
 
def GetInputFilePaths (filepath)
 
def main ()
 

Variables

 parser = argparse.ArgumentParser(description='Extract the subrun-averaged trigger rate for a list of OnMon files')
 
 type
 
 str
 
 help
 
 args = parser.parse_args()
 

Function Documentation

def OnMonTriggerRateStudy.GetDataFromInputFile (   filepath)

Definition at line 13 of file OnMonTriggerRateStudy.py.

References makeTrainCVSamples.int.

Referenced by main().

13 def GetDataFromInputFile(filepath):
14  file = ROOT.TFile(filepath, 'READ')
15 
16  # Get subrun duration and date from Header
17  header = file.Get('Header')
18  header.LoadTree(0)
19  header.GetEntry(0)
20  year = header.StartYear
21  month = header.StartMonth
22  day = header.StartDay
23  dayEnd = header.EndDay
24  Hour = header.StartHour
25  HourEnd = header.EndHour
26  run = header.Run
27  subrun = header.Subrun
28 
29  # NOTE: This may look confusing, but the Hour variable is a float, so we
30  # need to extract the minute and second components by taking the difference
31  # between the variable and its integer form.
32  Min = (Hour-int(Hour)) * 60.0
33  Sec = (Min-int(Min)) * 60.0
34 
35  # This handles the situation where a subrun spans two dates
36  if (dayEnd == day):
37  SRduration = 3600.0 * (HourEnd - Hour)
38  else:
39  SRduration = 3600.0 * (HourEnd + 24.0 - Hour)
40 
41  # If the subrun duration is zero, bail on this
42  if (SRduration == 0):
43  return None
44 
45  # NOTE: I have to admit, I don't completely understand the arguments passed
46  # to the Integral(...) function, but this is what is done in the OnMonPlotMaker,
47  # so it is replicated verbatim here.
48  hTrig = file.Get('TriggerVsHourGeneral')
49  nTrigs = hTrig.Integral(61, 1500, 1, 1)
50  trigRate = nTrigs / SRduration
51 
52  unixtime = datetime(year, month, day, int(Hour), int(Min), int(Sec)).strftime("%s")
53 
54  file.Close()
55 
56  return (run, subrun, unixtime, trigRate)
57 
58 # .............................................................................
def GetDataFromInputFile(filepath)
def OnMonTriggerRateStudy.GetInputFilePaths (   filepath)

Definition at line 59 of file OnMonTriggerRateStudy.py.

References open().

Referenced by main().

59 def GetInputFilePaths(filepath):
60  file_paths = []
61 
62  file = open(filepath, 'r')
63  for line in file:
64  file_paths.append(line.rstrip('\n'))
65 
66  return file_paths
67 
68 
69 # .............................................................................
procfile open("FD_BRL_v0.txt")
def OnMonTriggerRateStudy.main ( )

1D plots hits vs w //

Definition at line 70 of file OnMonTriggerRateStudy.py.

References novadaq::HexUtils.format(), GetDataFromInputFile(), GetInputFilePaths(), open(), and print.

70 def main():
71  FILE_LIST = args.filelist
72  OUT_FILE_PATH = args.outfile
73 
74  # Extract a list of input file paths
75  file_paths = GetInputFilePaths(FILE_LIST)
76 
77  # Open the out file and write a header
78  out_file = open(OUT_FILE_PATH, "w")
79  out_file.write("run, subrun, unixtime, rate\n")
80 
81  # Loop over input file paths, process the files, and write results to out file
82  file_idx = 0
83  for file in file_paths:
84  file_idx += 1
85  print('Processing file {}/{}: {}'.format(file_idx, len(file_paths), file))
86  data = GetDataFromInputFile(file)
87  if (data is not None):
88  out_file.write('{}, {}, {}, {}\n'.format(data[0], data[1], data[2], data[3]))
89 
90  out_file.close()
91 
92  return
93 
94 
95 # .............................................................................
def GetDataFromInputFile(filepath)
bool print
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
procfile open("FD_BRL_v0.txt")

Variable Documentation

OnMonTriggerRateStudy.args = parser.parse_args()

Definition at line 10 of file OnMonTriggerRateStudy.py.

OnMonTriggerRateStudy.help

Definition at line 8 of file OnMonTriggerRateStudy.py.

OnMonTriggerRateStudy.parser = argparse.ArgumentParser(description='Extract the subrun-averaged trigger rate for a list of OnMon files')

Definition at line 7 of file OnMonTriggerRateStudy.py.

OnMonTriggerRateStudy.str

Definition at line 8 of file OnMonTriggerRateStudy.py.

OnMonTriggerRateStudy.type

Definition at line 8 of file OnMonTriggerRateStudy.py.