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 = kMagenta-7
 
int pidColor = kAzure+1
 
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 197 of file TB_WatchdogFx.py.

Referenced by plotNueSystBandForTheseSystematics(), and plotSystBandForTheseSystematics().

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

Definition at line 92 of file TB_WatchdogFx.py.

Referenced by getDBRunsHist(), and getMaxMinRunNumDB().

92 def fetchTable(cur, query):
93  cur.execute(query)
94  return cur.fetchall()
95 
96 
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 132 of file TB_WatchdogFx.py.

References check_time_usage.float, and isNumber().

Referenced by getSAMRunsHist().

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

Definition at line 183 of file TB_WatchdogFx.py.

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

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

References fetchTable(), and runNovaSAM.str.

174 def getMaxMinRunNumDB(detector="testbeam", maxTime="CURRENT_TIMESTAMP", interval=7):
175  # Get maximum run
176  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
177  #Get run from 7 days ago
178  #cur.execute("select min(run) from fardet.runs where tstart >= (CURRENT_TIMESTAMP - interval '7' day);")
179 
180  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
181  return (maxRunNumDB, minRunNumDB)
182 
def fetchTable(cur, query)
def getMaxMinRunNumDB(detector="testbeam", maxTime="CURRENT_TIMESTAMP", interval=7)
def TB_WatchdogFx.getSAMRunsHist (   name,
  maxRunNum,
  minRunNum,
  dataSet 
)

Definition at line 108 of file TB_WatchdogFx.py.

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

Referenced by TB_WatchdogFx.Tier.getHist().

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

Definition at line 97 of file TB_WatchdogFx.py.

References check_time_usage.float.

Referenced by getCompletedRunsHist().

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

Variable Documentation

int TB_WatchdogFx.cafColor = kTeal+9

Definition at line 35 of file TB_WatchdogFx.py.

TB_WatchdogFx.db = OrderedDict()

Definition at line 79 of file TB_WatchdogFx.py.

TB_WatchdogFx.dbColor = kBlack

Definition at line 36 of file TB_WatchdogFx.py.

TB_WatchdogFx.dbConfig = OrderedDict()

Definition at line 76 of file TB_WatchdogFx.py.

TB_WatchdogFx.dbPort = OrderedDict()

Definition at line 73 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 37 of file TB_WatchdogFx.py.

TB_WatchdogFx.onMonDirs = OrderedDict()

Definition at line 85 of file TB_WatchdogFx.py.

TB_WatchdogFx.onMonTriggerDirs = OrderedDict()

Definition at line 88 of file TB_WatchdogFx.py.

TB_WatchdogFx.paths = OrderedDict()
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 71 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 = kMagenta-7

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 43 of file TB_WatchdogFx.py.

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

Definition at line 50 of file TB_WatchdogFx.py.

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

Definition at line 40 of file TB_WatchdogFx.py.

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

Definition at line 47 of file TB_WatchdogFx.py.

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

Definition at line 42 of file TB_WatchdogFx.py.

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

Definition at line 49 of file TB_WatchdogFx.py.

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

Definition at line 41 of file TB_WatchdogFx.py.

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

Definition at line 48 of file TB_WatchdogFx.py.

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

Definition at line 56 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 325 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 320 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)',
3  color=rootColor )

Definition at line 329 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 343 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 338 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)',
3  color=rootColor )

Definition at line 347 of file TB_WatchdogFx.py.

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

Definition at line 44 of file TB_WatchdogFx.py.

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

Definition at line 51 of file TB_WatchdogFx.py.