Classes | Functions | Variables
TB_WatchdogFx Namespace Reference

Classes

class  Connection
 
class  Path
 
class  Tier
 

Functions

def fetchTable (cur, query)
 
def isNumber (s)
 
def getSAMRunsHist (name, maxRunNum, minRunNum, dataSet)
 
def getCompletedRunsHist (path, name, maxRunNum, minRunNum, testStr="", skipStr=None, additionalDir="", checkKeys=False, printRunNum=False, lineStyle=1, lineColor=kBlack)
 
def getMaxMinRunNumDB (detector="testbeam", maxTime="CURRENT_TIMESTAMP", interval=7)
 
def getDBRunsHist (minRun, maxRun, table="testbeam", lineStyle=1, lineColor=dbColor)
 
def countFiles (dir, testStrs=[])
 

Variables

 pubContext = os.environ["SRT_PUBLIC_CONTEXT"]
 
 priContext = os.environ["SRT_PRIVATE_CONTEXT"]
 
 rootLogon = os.path.join(pubContext,"Utilities/rootlogon.C")
 
int emptyFileColor = kGreen-9
 
int rawColor = kRed-3
 
int rootColor = kOrange+1
 
int recoColor = kBlue-3
 
int pidColor = kAzure+1
 
int pcColor = kAzure+2
 
int cafColor = kTeal+9
 
 dbColor = kBlack
 
int onMonColor = kGray+2
 
list runHistoryFillStyles = [1001, 1001, 1001, 1001, 1001, 0, 0]
 
list runHistoryLineWidths = [1, 1, 1, 1, 1, 2, 2]
 
list runHistoryLineStyles = [0, 1, 0, 0, 0, 1, 7]
 
list runHistoryColors = [emptyFileColor, rawColor, rootColor, recoColor, cafColor, dbColor, onMonColor]
 
list varOpts = ["][", "][", "][", "][", "][", "", "]["]
 
list runHistoryFillStylesWithExtra = [1001, 1001, 1001, 1001, 1001, 1001, 0, 0]
 
list runHistoryLineWidthsWithExtra = [1, 1, 1, 1, 1, 0, 2, 2]
 
list runHistoryLineStylesWithExtra = [0, 0, 0, 0, 0, 0, 1, 7]
 
list runHistoryColorsWithExtra = [emptyFileColor, rawColor, rootColor, recoColor, pidColor, cafColor, dbColor, onMonColor]
 
list varOptsWithExtra = ["][", "][", "][", "][", "][", "][", "", "]["]
 
 samweb = samweb_client.SAMWebClient(experiment="nova")
 
 pw = open(os.environ['NOVADBPWDFILE'], 'r').readlines()[0].strip()
 
 dbPort = OrderedDict()
 
 dbConfig = OrderedDict()
 
 db = OrderedDict()
 
 onMonDirs = OrderedDict()
 
 onMonTriggerDirs = OrderedDict()
 
 paths = OrderedDict()
 
 tbBeamlineRawEmpty
 
 tbBeamlineRaw
 
 tbBeamlineRoot
 
 tbSpillRawEmpty
 
 tbSpillRaw
 
 tbSpillRoot
 

Function Documentation

def TB_WatchdogFx.countFiles (   dir,
  testStrs = [] 
)

Definition at line 198 of file TB_WatchdogFx.py.

198 def countFiles(dir, testStrs=[]):
199  files = os.listdir(dir)
200  count = 0
201  for file in files:
202  failed = False
203  for str in testStrs:
204  if not str in file:
205  failed = True
206  break
207  if not failed:
208  count += 1
209  return count
210 
211 
def countFiles(dir, testStrs=[])
def TB_WatchdogFx.fetchTable (   cur,
  query 
)

Definition at line 93 of file TB_WatchdogFx.py.

Referenced by getDBRunsHist(), and getMaxMinRunNumDB().

93 def fetchTable(cur, query):
94  cur.execute(query)
95  return cur.fetchall()
96 
97 
def fetchTable(cur, query)
def TB_WatchdogFx.getCompletedRunsHist (   path,
  name,
  maxRunNum,
  minRunNum,
  testStr = "",
  skipStr = None,
  additionalDir = "",
  checkKeys = False,
  printRunNum = False,
  lineStyle = 1,
  lineColor = kBlack 
)

Definition at line 133 of file TB_WatchdogFx.py.

References check_time_usage.float, and isNumber().

Referenced by getSAMRunsHist().

133  additionalDir="", checkKeys=False, printRunNum=False, lineStyle=1, lineColor=kBlack):
134 
135  hist = TH1F(name, ";Run Number;Number of Subruns", maxRunNum - minRunNum + 1 , minRunNum, maxRunNum + 1)
136  hist.SetLineStyle(lineStyle)
137  hist.SetLineColor(lineColor)
138 
139  multiRunDirs = sorted(os.listdir(path))
140  # Loop to get info on recent runs
141  for multiRunDir in multiRunDirs:
142  if not isNumber(multiRunDir):
143  continue
144  multiRunPath = path + multiRunDir + "/"
145  if not os.path.isdir(multiRunPath):
146  continue
147  runDirs = sorted(os.listdir(multiRunPath))
148  for runDir in runDirs:
149  try:
150  runNum = float(runDir)
151  except:
152  print "Could not parse runDir", runDir
153  continue
154  if runNum >= minRunNum and runNum <= maxRunNum:
155  runPath = multiRunPath + runDir + "/" + additionalDir
156  if not os.path.isdir(runPath):
157  continue
158  fileNames = sorted(os.listdir(runPath))
159  for fileName in fileNames:
160  if checkKeys:
161  filePath = runPath + fileName
162  rootFile = TFile(filePath)
163  if rootFile.IsZombie() or rootFile.TestBit(TFile.kRecovered):
164  continue
165  if not testStr in fileName:
166  continue
167  if skipStr:
168  if skipStr in fileName:
169  continue
170  hist.Fill(runNum)
171  if printRunNum:
172  print runNum
173  return hist
174 
def TB_WatchdogFx.getDBRunsHist (   minRun,
  maxRun,
  table = "testbeam",
  lineStyle = 1,
  lineColor = dbColor 
)

Definition at line 184 of file TB_WatchdogFx.py.

References fetchTable(), check_time_usage.float, and submit_syst.str.

184 def getDBRunsHist(minRun, maxRun,table="testbeam", lineStyle=1, lineColor=dbColor):
185  dbRunData = fetchTable(db[table].cur, "select run, nsubruns from "+table+".runs where run >= "+str(minRun)+" and run <=" + str(maxRun) + " order by run asc;")
186  dbRunsHist = TH1F("Number of Subruns in DB", ";Run Number;Number of Subruns", maxRun - minRun+1, minRun, maxRun+1)
187  dbRunsHist.SetLineStyle(lineStyle)
188  dbRunsHist.SetLineColor(lineColor)
189  for line in dbRunData:
190  run = line[0]
191  subrun = line[1]
192  if run and subrun: dbRunsHist.Fill(float(run), float(subrun))
193  return dbRunsHist
194 
195 
196 
197 
def fetchTable(cur, query)
def getDBRunsHist(minRun, maxRun, table="testbeam", lineStyle=1, lineColor=dbColor)
def TB_WatchdogFx.getMaxMinRunNumDB (   detector = "testbeam",
  maxTime = "CURRENT_TIMESTAMP",
  interval = 7 
)

Definition at line 175 of file TB_WatchdogFx.py.

References fetchTable(), and submit_syst.str.

175 def getMaxMinRunNumDB(detector="testbeam", maxTime="CURRENT_TIMESTAMP", interval=7):
176  # Get maximum run
177  maxRunNumDB = fetchTable(db[detector].cur, "select max(run) from "+detector+".runs")[0][0] #This returns a two by two table, get the 0,0 entry
178  #Get run from 7 days ago
179  #cur.execute("select min(run) from fardet.runs where tstart >= (CURRENT_TIMESTAMP - interval '7' day);")
180 
181  minRunNumDB = fetchTable(db[detector].cur, "select min(run) from "+detector+".runs where tstart >= ("+maxTime+" - interval '"+str(interval)+"' day);")[0][0] #This returns a two by two table, get the 0,0 entry
182  return (maxRunNumDB, minRunNumDB)
183 
def fetchTable(cur, query)
def getMaxMinRunNumDB(detector="testbeam", maxTime="CURRENT_TIMESTAMP", interval=7)
def TB_WatchdogFx.getSAMRunsHist (   name,
  maxRunNum,
  minRunNum,
  dataSet 
)

Definition at line 109 of file TB_WatchdogFx.py.

References getCompletedRunsHist(), makeTrainCVSamples.int, and submit_syst.str.

Referenced by TB_WatchdogFx.Tier.getHist().

109 def getSAMRunsHist(name, maxRunNum, minRunNum, dataSet):
110 
111  hist = TH1F(name, ";Run Number;Number of Subruns", maxRunNum - minRunNum + 1, minRunNum, maxRunNum + 1)
112 
113 
114  command = dataSet + " " + " AND Online.RunNumber >= " + str(minRunNum) + " AND Online.RunNumber <= " + str(maxRunNum)
115  print "about to make samweb query:", command
116  files = samweb.listFiles(command)
117  print "done"
118  for file in files:
119  if len(file) <= 0:
120  continue
121  try:
122  begRun = file.find("_r")
123  endRun = file.find("_", begRun + 1)
124  run = int(file[begRun+2:endRun])
125  hist.Fill(run)
126  except:
127  print "oops : ", file
128  print "number of files returned: ", len(files)
129  return hist
130 
131 
def getSAMRunsHist(name, maxRunNum, minRunNum, dataSet)
def TB_WatchdogFx.isNumber (   s)

Definition at line 98 of file TB_WatchdogFx.py.

References check_time_usage.float.

Referenced by getCompletedRunsHist().

98 def isNumber(s):
99  try:
100  float(s)
101  return True
102  except ValueError:
103  return False
104 
105 
106 
107 
108 

Variable Documentation

int TB_WatchdogFx.cafColor = kTeal+9

Definition at line 36 of file TB_WatchdogFx.py.

TB_WatchdogFx.db = OrderedDict()

Definition at line 80 of file TB_WatchdogFx.py.

TB_WatchdogFx.dbColor = kBlack

Definition at line 37 of file TB_WatchdogFx.py.

TB_WatchdogFx.dbConfig = OrderedDict()

Definition at line 77 of file TB_WatchdogFx.py.

TB_WatchdogFx.dbPort = OrderedDict()

Definition at line 74 of file TB_WatchdogFx.py.

int TB_WatchdogFx.emptyFileColor = kGreen-9

Definition at line 30 of file TB_WatchdogFx.py.

int TB_WatchdogFx.onMonColor = kGray+2

Definition at line 38 of file TB_WatchdogFx.py.

TB_WatchdogFx.onMonDirs = OrderedDict()

Definition at line 86 of file TB_WatchdogFx.py.

TB_WatchdogFx.onMonTriggerDirs = OrderedDict()

Definition at line 89 of file TB_WatchdogFx.py.

TB_WatchdogFx.paths = OrderedDict()
int TB_WatchdogFx.pcColor = kAzure+2

Definition at line 35 of file TB_WatchdogFx.py.

int TB_WatchdogFx.pidColor = kAzure+1

Definition at line 34 of file TB_WatchdogFx.py.

TB_WatchdogFx.priContext = os.environ["SRT_PRIVATE_CONTEXT"]

Definition at line 15 of file TB_WatchdogFx.py.

TB_WatchdogFx.pubContext = os.environ["SRT_PUBLIC_CONTEXT"]

Definition at line 14 of file TB_WatchdogFx.py.

TB_WatchdogFx.pw = open(os.environ['NOVADBPWDFILE'], 'r').readlines()[0].strip()

Definition at line 72 of file TB_WatchdogFx.py.

Referenced by trk::WindowTrackingAlg.FitWindow().

int TB_WatchdogFx.rawColor = kRed-3

Definition at line 31 of file TB_WatchdogFx.py.

int TB_WatchdogFx.recoColor = kBlue-3

Definition at line 33 of file TB_WatchdogFx.py.

int TB_WatchdogFx.rootColor = kOrange+1

Definition at line 32 of file TB_WatchdogFx.py.

TB_WatchdogFx.rootLogon = os.path.join(pubContext,"Utilities/rootlogon.C")

Definition at line 16 of file TB_WatchdogFx.py.

list TB_WatchdogFx.runHistoryColors = [emptyFileColor, rawColor, rootColor, recoColor, cafColor, dbColor, onMonColor]

Definition at line 44 of file TB_WatchdogFx.py.

list TB_WatchdogFx.runHistoryColorsWithExtra = [emptyFileColor, rawColor, rootColor, recoColor, pidColor, cafColor, dbColor, onMonColor]

Definition at line 51 of file TB_WatchdogFx.py.

list TB_WatchdogFx.runHistoryFillStyles = [1001, 1001, 1001, 1001, 1001, 0, 0]

Definition at line 41 of file TB_WatchdogFx.py.

list TB_WatchdogFx.runHistoryFillStylesWithExtra = [1001, 1001, 1001, 1001, 1001, 1001, 0, 0]

Definition at line 48 of file TB_WatchdogFx.py.

list TB_WatchdogFx.runHistoryLineStyles = [0, 1, 0, 0, 0, 1, 7]

Definition at line 43 of file TB_WatchdogFx.py.

list TB_WatchdogFx.runHistoryLineStylesWithExtra = [0, 0, 0, 0, 0, 0, 1, 7]

Definition at line 50 of file TB_WatchdogFx.py.

list TB_WatchdogFx.runHistoryLineWidths = [1, 1, 1, 1, 1, 2, 2]

Definition at line 42 of file TB_WatchdogFx.py.

list TB_WatchdogFx.runHistoryLineWidthsWithExtra = [1, 1, 1, 1, 1, 0, 2, 2]

Definition at line 49 of file TB_WatchdogFx.py.

TB_WatchdogFx.samweb = samweb_client.SAMWebClient(experiment="nova")

Definition at line 57 of file TB_WatchdogFx.py.

TB_WatchdogFx.tbBeamlineRaw
Initial value:
1 = Tier("Beamline Raw Files",
2  'Online.Detector="testbeam" AND data_tier="raw" AND Online.Stream=Beamline AND Online.TotalEvents > 0',
3  color=rawColor )

Definition at line 330 of file TB_WatchdogFx.py.

TB_WatchdogFx.tbBeamlineRawEmpty
Initial value:
1 = Tier("Beamline Empty Raw Files",
2  'Online.Detector="testbeam" AND data_tier="raw" AND Online.Stream=Beamline',
3  color=emptyFileColor )

Definition at line 325 of file TB_WatchdogFx.py.

TB_WatchdogFx.tbBeamlineRoot
Initial value:
1 = Tier("Beamline ROOT Files",
2  'Online.Detector="testbeam" AND data_tier="artdaq" AND Online.Stream=Beamline AND (daq2rawdigit.base_release R19-09-24-testbeam-production.a OR daq2rawdigit.base_release R19-09-24-testbeam-production.b OR daq2rawdigit.base_release R19-09-24-testbeam-production.c OR daq2rawdigit.base_release R21-01-28-testbeam-production.a)',
3  color=rootColor )

Definition at line 334 of file TB_WatchdogFx.py.

TB_WatchdogFx.tbSpillRaw
Initial value:
1 = Tier("TBSpill Raw Files",
2  'Online.Detector="testbeam" AND data_tier="raw" AND Online.Stream=Spill AND Online.TotalEvents > 0',
3  color=rawColor )

Definition at line 350 of file TB_WatchdogFx.py.

TB_WatchdogFx.tbSpillRawEmpty
Initial value:
1 = Tier("TBSpill Empty Raw Files",
2  'Online.Detector="testbeam" AND data_tier="raw" AND Online.Stream=Spill',
3  color=emptyFileColor )

Definition at line 345 of file TB_WatchdogFx.py.

TB_WatchdogFx.tbSpillRoot
Initial value:
1 = Tier("TBSpill ROOT Files",
2  'Online.Detector="testbeam" AND data_tier="artdaq" AND Online.Stream=Spill AND (daq2rawdigit.base_release R19-09-24-testbeam-production.a OR daq2rawdigit.base_release R19-09-24-testbeam-production.b OR daq2rawdigit.base_release R19-09-24-testbeam-production.c OR daq2rawdigit.base_release R21-01-28-testbeam-production.a)',
3  color=rootColor )

Definition at line 354 of file TB_WatchdogFx.py.

list TB_WatchdogFx.varOpts = ["][", "][", "][", "][", "][", "", "]["]

Definition at line 45 of file TB_WatchdogFx.py.

list TB_WatchdogFx.varOptsWithExtra = ["][", "][", "][", "][", "][", "][", "", "]["]

Definition at line 52 of file TB_WatchdogFx.py.