Classes | Functions | Variables
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="fardet", maxTime="CURRENT_TIMESTAMP", interval=7)
 
def getDBRunsHist (minRun, maxRun, table="fardet", lineStyle=1, lineColor=dbColor)
 
def countFiles (dir, testStrs=[])
 

Variables

 pubContext = os.environ["SRT_PUBLIC_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()
 
 fdCosmicRawEmpty
 
 fdCosmicRaw
 
 fdCosmicRoot
 
 ndCosmicRawEmpty
 
 ndCosmicRaw
 
 ndCosmicRoot
 

Function Documentation

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

Definition at line 200 of file WatchdogFx.py.

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

Definition at line 95 of file WatchdogFx.py.

Referenced by getDBRunsHist(), and getMaxMinRunNumDB().

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

Definition at line 135 of file WatchdogFx.py.

References check_time_usage.float, and isNumber().

Referenced by getSAMRunsHist().

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

Definition at line 186 of file WatchdogFx.py.

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

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

Definition at line 177 of file WatchdogFx.py.

References fetchTable(), and runNovaSAM.str.

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

Definition at line 111 of file WatchdogFx.py.

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

Referenced by WatchdogFx.Tier.getHist().

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

Definition at line 100 of file WatchdogFx.py.

References check_time_usage.float.

Referenced by getCompletedRunsHist().

100 def isNumber(s):
101  try:
102  float(s)
103  return True
104  except ValueError:
105  return False
106 
107 
108 
109 
110 
def isNumber(s)
Definition: WatchdogFx.py:100

Variable Documentation

int WatchdogFx.cafColor = kTeal+9

Definition at line 34 of file WatchdogFx.py.

WatchdogFx.db = OrderedDict()

Definition at line 80 of file WatchdogFx.py.

WatchdogFx.dbColor = kBlack

Definition at line 35 of file WatchdogFx.py.

WatchdogFx.dbConfig = OrderedDict()

Definition at line 76 of file WatchdogFx.py.

WatchdogFx.dbPort = OrderedDict()

Definition at line 72 of file WatchdogFx.py.

int WatchdogFx.emptyFileColor = kGreen-9

Definition at line 29 of file WatchdogFx.py.

WatchdogFx.fdCosmicRaw
Initial value:
1 = Tier("Cosmic Raw Files",
2  'Online.Detector="fardet" AND data_tier="raw" AND Online.Stream=2 AND Online.TotalEvents > 0',
3  color=rawColor )

Definition at line 337 of file WatchdogFx.py.

WatchdogFx.fdCosmicRawEmpty
Initial value:
1 = Tier("Cosmic Empty Raw Files",
2  'Online.Detector="fardet" AND data_tier="raw" AND Online.Stream=2',
3  color=emptyFileColor )

Definition at line 332 of file WatchdogFx.py.

WatchdogFx.fdCosmicRoot
Initial value:
1 = Tier("Cosmic ROOT Files",
2  'Online.Detector="fardet" AND data_tier="artdaq" AND Online.Stream=2 AND (daq2rawdigit.base_release S16-10-07 OR daq2rawdigit.base_release S16-11-02 OR daq2rawdigit.base_release S17-02-21 OR daq2rawdigit.base_release S17-10-30)',
3  color=rootColor )

Definition at line 341 of file WatchdogFx.py.

WatchdogFx.ndCosmicRaw
Initial value:
1 = Tier("Cosmic Raw Files",
2  'Online.Detector="neardet" AND data_tier="raw" AND Online.Stream=2 AND Online.TotalEvents > 0',
3  color=rawColor )

Definition at line 409 of file WatchdogFx.py.

WatchdogFx.ndCosmicRawEmpty
Initial value:
1 = Tier("Cosmic Empty Raw Files",
2  'Online.Detector="neardet" AND data_tier="raw" AND Online.Stream=2',
3  color=emptyFileColor )

Definition at line 404 of file WatchdogFx.py.

WatchdogFx.ndCosmicRoot
Initial value:
1 = Tier("Cosmic ROOT Files",
2  'Online.Detector="neardet" AND data_tier="artdaq" AND (DAQ2RawDigit.base_release FA14-10-03 OR DAQ2RawDigit.base_release S15-08-12 OR DAQ2RawDigit.base_release S16-02-02 OR daq2rawdigit.base_release S16-10-07 OR daq2rawdigit.base_release S16-11-02 OR daq2rawdigit.base_release S17-02-21 OR daq2rawdigit.base_release S17-10-30) AND Online.Stream=2',
3  color=rootColor )

Definition at line 413 of file WatchdogFx.py.

int WatchdogFx.onMonColor = kGray+2

Definition at line 36 of file WatchdogFx.py.

WatchdogFx.onMonDirs = OrderedDict()

Definition at line 86 of file WatchdogFx.py.

WatchdogFx.onMonTriggerDirs = OrderedDict()

Definition at line 90 of file WatchdogFx.py.

WatchdogFx.paths = OrderedDict()

Definition at line 306 of file WatchdogFx.py.

int WatchdogFx.pidColor = kAzure+1

Definition at line 33 of file WatchdogFx.py.

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

Definition at line 14 of file WatchdogFx.py.

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

Definition at line 70 of file WatchdogFx.py.

int WatchdogFx.rawColor = kRed-3

Definition at line 30 of file WatchdogFx.py.

int WatchdogFx.recoColor = kMagenta-7

Definition at line 32 of file WatchdogFx.py.

int WatchdogFx.rootColor = kOrange+1

Definition at line 31 of file WatchdogFx.py.

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

Definition at line 15 of file WatchdogFx.py.

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

Definition at line 42 of file WatchdogFx.py.

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

Definition at line 49 of file WatchdogFx.py.

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

Definition at line 39 of file WatchdogFx.py.

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

Definition at line 46 of file WatchdogFx.py.

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

Definition at line 41 of file WatchdogFx.py.

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

Definition at line 48 of file WatchdogFx.py.

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

Definition at line 40 of file WatchdogFx.py.

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

Definition at line 47 of file WatchdogFx.py.

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

Definition at line 55 of file WatchdogFx.py.

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

Definition at line 43 of file WatchdogFx.py.

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

Definition at line 50 of file WatchdogFx.py.