Public Member Functions | Public Attributes | List of all members
checkCalibrationCSV.NovaCalibTest Class Reference

Public Member Functions

def __init__ (self, newDir)
 
def checkForTrailingCommas (self, fileName)
 
def checkAbsFilesForTrailingCommas (self)
 
def checkAttenFilesForTrailingCommas (self)
 
def checkAbsRunCoverage (self)
 
def checkAttenRunCoverage (self)
 
def checkRunCoverage (self, dictList)
 
def getAbsFileForThisRun (self, whichDet, dataOrMC, thisRun)
 
def getAttenFileForThisRun (self, whichDet, dataOrMC, thisRun, whichFb=-1)
 
def parseRunString (self, runString)
 
def getAbsFiles (self, whichDet, dataOrMC)
 
def getAttenFiles (self, whichDet, dataOrMC)
 
def printSummary (self)
 

Public Attributes

 dirName
 
 ndDataAbsDict
 
 fdDataAbsDict
 
 ndMCAbsDict
 
 fdMCAbsDict
 
 ndDataAttenDict
 
 fdDataAttenDict
 
 ndMCAttenDict
 
 fdMCAttenDict
 
 badTrailingCommas
 
 badMissingRuns
 

Detailed Description

Definition at line 13 of file checkCalibrationCSV.py.

Constructor & Destructor Documentation

def checkCalibrationCSV.NovaCalibTest.__init__ (   self,
  newDir 
)

Definition at line 15 of file checkCalibrationCSV.py.

Referenced by PandAna.core.core.spectrum.fill().

15  def __init__(self, newDir):
16  self.dirName = newDir
17  self.ndDataAbsDict={}
18  self.fdDataAbsDict={}
19  self.ndMCAbsDict={}
20  self.fdMCAbsDict={}
23  self.ndMCAttenDict={}
24  self.fdMCAttenDict={}
25 
26  self.getAbsFiles('nd','data')
27  self.getAbsFiles('fd','data')
28  self.getAbsFiles('nd','mc')
29  self.getAbsFiles('fd','mc')
30  self.getAttenFiles('fd','data')
31  self.getAttenFiles('fd','mc')
32  self.getAttenFiles('nd','data')
33  self.getAttenFiles('nd','mc')
34 
35  self.badTrailingCommas=False
36  self.badMissingRuns=False
37 
38 
def getAttenFiles(self, whichDet, dataOrMC)
def getAbsFiles(self, whichDet, dataOrMC)

Member Function Documentation

def checkCalibrationCSV.NovaCalibTest.checkAbsFilesForTrailingCommas (   self)

Definition at line 50 of file checkCalibrationCSV.py.

References checkCalibrationCSV.NovaCalibTest.badTrailingCommas, checkCalibrationCSV.NovaCalibTest.checkForTrailingCommas(), checkCalibrationCSV.NovaCalibTest.fdDataAbsDict, checkCalibrationCSV.NovaCalibTest.fdMCAbsDict, if(), checkCalibrationCSV.NovaCalibTest.ndDataAbsDict, checkCalibrationCSV.NovaCalibTest.ndMCAbsDict, and print.

def checkCalibrationCSV.NovaCalibTest.checkAbsRunCoverage (   self)
def checkCalibrationCSV.NovaCalibTest.checkAttenFilesForTrailingCommas (   self)

Definition at line 57 of file checkCalibrationCSV.py.

References checkCalibrationCSV.NovaCalibTest.badTrailingCommas, checkCalibrationCSV.NovaCalibTest.checkForTrailingCommas(), checkCalibrationCSV.NovaCalibTest.fdDataAttenDict, checkCalibrationCSV.NovaCalibTest.fdMCAttenDict, if(), checkCalibrationCSV.NovaCalibTest.ndDataAttenDict, checkCalibrationCSV.NovaCalibTest.ndMCAttenDict, and print.

def checkCalibrationCSV.NovaCalibTest.checkAttenRunCoverage (   self)
def checkCalibrationCSV.NovaCalibTest.checkForTrailingCommas (   self,
  fileName 
)

Definition at line 39 of file checkCalibrationCSV.py.

References open(), and print.

Referenced by checkCalibrationCSV.NovaCalibTest.checkAbsFilesForTrailingCommas(), and checkCalibrationCSV.NovaCalibTest.checkAttenFilesForTrailingCommas().

39  def checkForTrailingCommas(self,fileName):
40  gotTrailingCommas=False
41  with open(fileName) as fp:
42  line = fp.readline()
43  while line:
44  line = fp.readline()
45  if "," in line[len(line)-2:]:
46  gotTrailingCommas=True
47  print("Oh no the line ends in a comma: "+line)
48  return gotTrailingCommas
49 
def checkForTrailingCommas(self, fileName)
bool print
procfile open("FD_BRL_v0.txt")
def checkCalibrationCSV.NovaCalibTest.checkRunCoverage (   self,
  dictList 
)

Definition at line 70 of file checkCalibrationCSV.py.

References abs(), checkCalibrationCSV.NovaCalibTest.badMissingRuns, if(), print, and submit_syst.str.

Referenced by checkCalibrationCSV.NovaCalibTest.checkAbsRunCoverage(), and checkCalibrationCSV.NovaCalibTest.checkAttenRunCoverage().

70  def checkRunCoverage(self,dictList):
71  countBad=0
72  for dict in dictList:
73  lastRun=-1;
74  countFb=0
75  for tuple in sorted (dict.keys()) :
76  checkThis=True
77  if(len(tuple)==2):
78  (first,last)=tuple
79  else:
80  (first,last,fb)=tuple
81  if(fb!=0):
82  checkThis=False
83  countFb=countFb+1
84  else:
85  if(countFb>0):
86  print("Fibre brightness bins "+str(countFb))
87  print("in dictionary: "+str(dict[tuple]))
88  countFb=1
89  if(checkThis and first!=lastRun+1):
90  print("Missing run gap: "+str(lastRun)+" to "+str(first)+" before "+dict[tuple])
91  countBad+=abs(first-(lastRun+1))
92  lastRun=last
93  if(countFb>0):
94  print("Fibre brightness bins "+str(countFb))
95  print("in dictionary: "+str(dict[tuple]))
96 
97  if(countBad==0):
98  print("Found CSV files for all runs in range ")
99  else:
100  print("Missing "+str(countBad)+" files")
101  self.badMissingRuns=True
102 
103 
104 
void abs(TH1 *hist)
if(dump)
bool print
def checkCalibrationCSV.NovaCalibTest.getAbsFileForThisRun (   self,
  whichDet,
  dataOrMC,
  thisRun 
)

Definition at line 105 of file checkCalibrationCSV.py.

References checkCalibrationCSV.NovaCalibTest.fdDataAbsDict, checkCalibrationCSV.NovaCalibTest.fdMCAbsDict, if(), checkCalibrationCSV.NovaCalibTest.ndDataAbsDict, and checkCalibrationCSV.NovaCalibTest.ndMCAbsDict.

105  def getAbsFileForThisRun(self,whichDet,dataOrMC,thisRun):
106  thisDict={}
107  if whichDet == 'nd' and dataOrMC=='data':
108  thisDict=self.ndDataAbsDict
109  elif whichDet == 'nd' and dataOrMC=='mc':
110  thisDict=self.ndMCAbsDict
111  elif whichDet == 'fd' and dataOrMC=='data':
112  thisDict=self.fdDataAbsDict
113  elif whichDet == 'fd' and dataOrMC=='mc':
114  thisDict=self.fdMCAbsDict
115  for (k1,k2) in thisDict:
116  if(k1<=thisRun and k2>=thisRun):
117  return thisDict[(k1,k2)]
118 
if(dump)
def getAbsFileForThisRun(self, whichDet, dataOrMC, thisRun)
def checkCalibrationCSV.NovaCalibTest.getAbsFiles (   self,
  whichDet,
  dataOrMC 
)

Definition at line 153 of file checkCalibrationCSV.py.

References checkCalibrationCSV.NovaCalibTest.dirName, checkCalibrationCSV.NovaCalibTest.fdDataAbsDict, checkCalibrationCSV.NovaCalibTest.fdMCAbsDict, checkCalibrationCSV.NovaCalibTest.ndDataAbsDict, checkCalibrationCSV.NovaCalibTest.ndMCAbsDict, checkCalibrationCSV.NovaCalibTest.parseRunString(), print, and split().

153  def getAbsFiles(self,whichDet,dataOrMC):
154  preString=self.dirName+'/calib_abs_consts.'+whichDet+'.'+dataOrMC
155  absFiles=glob.glob(preString+'*.csv')
156  for absFile in absFiles:
157  verString=absFile[len(preString)+1:].split('.')[0]
158  runString=absFile[len(preString)+1:].split('.')[1]
159  runTuple=self.parseRunString(runString)
160  if whichDet == 'nd' and dataOrMC=='data':
161  self.ndDataAbsDict[runTuple]=absFile
162  elif whichDet == 'nd' and dataOrMC=='mc':
163  self.ndMCAbsDict[runTuple]=absFile
164  elif whichDet == 'fd' and dataOrMC=='data':
165  self.fdDataAbsDict[runTuple]=absFile
166  elif whichDet == 'fd' and dataOrMC=='mc':
167  self.fdMCAbsDict[runTuple]=absFile
168  else:
169  print("Nothing defined for "+whichDet+ ' with '+dataOrMC)
170 
void split(double tt, double *fr)
bool print
def getAbsFiles(self, whichDet, dataOrMC)
def checkCalibrationCSV.NovaCalibTest.getAttenFileForThisRun (   self,
  whichDet,
  dataOrMC,
  thisRun,
  whichFb = -1 
)

Definition at line 119 of file checkCalibrationCSV.py.

References checkCalibrationCSV.NovaCalibTest.fdDataAttenDict, checkCalibrationCSV.NovaCalibTest.fdMCAttenDict, if(), checkCalibrationCSV.NovaCalibTest.ndDataAttenDict, and checkCalibrationCSV.NovaCalibTest.ndMCAttenDict.

119  def getAttenFileForThisRun(self,whichDet,dataOrMC,thisRun,whichFb=-1):
120  thisDict={}
121  if whichDet == 'nd' and dataOrMC=='data':
122  thisDict=self.ndDataAttenDict
123  elif whichDet == 'nd' and dataOrMC=='mc':
124  thisDict=self.ndMCAttenDict
125  elif whichDet == 'fd' and dataOrMC=='data':
126  thisDict=self.fdDataAttenDict
127  elif whichDet == 'fd' and dataOrMC=='mc':
128  thisDict=self.fdMCAttenDict
129  if(whichFb<0):
130  for (k1,k2) in thisDict:
131  if(k1<=thisRun and k2>=thisRun):
132  return thisDict[(k1,k2)]
133  else:
134  for (k1,k2,k3) in thisDict:
135  if(k1<=thisRun and k2>=thisRun and k3==whichFb):
136  return thisDict[(k1,k2,k3)]
137 
138 
139 
if(dump)
def getAttenFileForThisRun(self, whichDet, dataOrMC, thisRun, whichFb=-1)
def checkCalibrationCSV.NovaCalibTest.getAttenFiles (   self,
  whichDet,
  dataOrMC 
)

Definition at line 171 of file checkCalibrationCSV.py.

References checkCalibrationCSV.NovaCalibTest.dirName, checkCalibrationCSV.NovaCalibTest.fdDataAttenDict, checkCalibrationCSV.NovaCalibTest.fdMCAttenDict, makeTrainCVSamples.int, checkCalibrationCSV.NovaCalibTest.ndDataAttenDict, checkCalibrationCSV.NovaCalibTest.ndMCAttenDict, checkCalibrationCSV.NovaCalibTest.parseRunString(), print, and split().

171  def getAttenFiles(self,whichDet,dataOrMC):
172  preString=self.dirName+'/calib_atten_consts.'+whichDet+'.'+dataOrMC
173  attenFiles=glob.glob(preString+'*.csv')
174  for attenFile in attenFiles:
175  verString=attenFile[len(preString)+1:].split('.')[0]
176  runString=attenFile[len(preString)+1:].split('.')[1]
177  fbString=attenFile[len(preString)+1:].split('.')[2]
178  hasFb=False
179  runTuple=self.parseRunString(runString)
180  if "fb" in fbString:
181  hasFb=True
182  runTuple=runTuple+(int(fbString[2:]),)
183  if whichDet == 'nd' and dataOrMC=='data':
184  self.ndDataAttenDict[runTuple]=attenFile
185  elif whichDet == 'nd' and dataOrMC=='mc':
186  self.ndMCAttenDict[runTuple]=attenFile
187  elif whichDet == 'fd' and dataOrMC=='data':
188  self.fdDataAttenDict[runTuple]=attenFile
189  elif whichDet == 'fd' and dataOrMC=='mc':
190  self.fdMCAttenDict[runTuple]=attenFile
191  else:
192  print("Nothing defined for "+whichDet+ ' with '+dataOrMC)
193 
void split(double tt, double *fr)
def getAttenFiles(self, whichDet, dataOrMC)
bool print
def checkCalibrationCSV.NovaCalibTest.parseRunString (   self,
  runString 
)

Definition at line 140 of file checkCalibrationCSV.py.

References if(), and makeTrainCVSamples.int.

Referenced by checkCalibrationCSV.NovaCalibTest.getAbsFiles(), and checkCalibrationCSV.NovaCalibTest.getAttenFiles().

140  def parseRunString(self,runString):
141  runBoundsList=runString.split('-')
142  minStr=runBoundsList[0]
143  maxStr=runBoundsList[1]
144  minRun=0
145  maxRun=sys.maxint
146  if(len(minStr[1:])>0):
147  minRun=int(minStr[1:])
148  if(len(maxStr[1:])>0):
149  maxRun=int(maxStr[1:])
150  return (minRun,maxRun)
151 
152 
if(dump)
def checkCalibrationCSV.NovaCalibTest.printSummary (   self)

Definition at line 194 of file checkCalibrationCSV.py.

References checkCalibrationCSV.NovaCalibTest.badMissingRuns, checkCalibrationCSV.NovaCalibTest.badTrailingCommas, print, and PandAna.Demos.demo1.range.

194  def printSummary(self):
195  if self.badMissingRuns:
196  for i in range(0,10):
197  print("There are missing runs!!!!!!!!!!!!!!!!")
198 
199  if self.badTrailingCommas:
200  for i in range(0,10):
201  print("There are traling commas!!!!!!!!!!!!!!!!")
202 
203 
bool print

Member Data Documentation

checkCalibrationCSV.NovaCalibTest.badMissingRuns
checkCalibrationCSV.NovaCalibTest.badTrailingCommas
checkCalibrationCSV.NovaCalibTest.dirName
checkCalibrationCSV.NovaCalibTest.fdDataAbsDict
checkCalibrationCSV.NovaCalibTest.fdDataAttenDict
checkCalibrationCSV.NovaCalibTest.fdMCAbsDict
checkCalibrationCSV.NovaCalibTest.fdMCAttenDict
checkCalibrationCSV.NovaCalibTest.ndDataAbsDict
checkCalibrationCSV.NovaCalibTest.ndDataAttenDict
checkCalibrationCSV.NovaCalibTest.ndMCAbsDict
checkCalibrationCSV.NovaCalibTest.ndMCAttenDict

The documentation for this class was generated from the following file: