11 print(
"Usage:\n"+sys.argv[0]+
" <new dir> <old dir>[Optional]")
40 gotTrailingCommas=
False 41 with
open(fileName)
as fp:
45 if "," in line[len(line)-2:]:
46 gotTrailingCommas=
True 47 print(
"Oh no the line ends in a comma: "+line)
48 return gotTrailingCommas
52 for i
in sorted (dict.keys()) :
54 print(
"Broken file is "+dict[i])
59 for i
in sorted (dict.keys()) :
61 print(
"Broken file is "+dict[i])
75 for tuple
in sorted (dict.keys()) :
86 print(
"Fibre brightness bins "+
str(countFb))
87 print(
"in dictionary: "+
str(dict[tuple]))
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))
94 print(
"Fibre brightness bins "+
str(countFb))
95 print(
"in dictionary: "+
str(dict[tuple]))
98 print(
"Found CSV files for all runs in range ")
100 print(
"Missing "+
str(countBad)+
" files")
107 if whichDet ==
'nd' and dataOrMC==
'data':
109 elif whichDet ==
'nd' and dataOrMC==
'mc':
111 elif whichDet ==
'fd' and dataOrMC==
'data':
113 elif whichDet ==
'fd' and dataOrMC==
'mc':
115 for (k1,k2)
in thisDict:
116 if(k1<=thisRun
and k2>=thisRun):
117 return thisDict[(k1,k2)]
121 if whichDet ==
'nd' and dataOrMC==
'data':
123 elif whichDet ==
'nd' and dataOrMC==
'mc':
125 elif whichDet ==
'fd' and dataOrMC==
'data':
127 elif whichDet ==
'fd' and dataOrMC==
'mc':
130 for (k1,k2)
in thisDict:
131 if(k1<=thisRun
and k2>=thisRun):
132 return thisDict[(k1,k2)]
134 for (k1,k2,k3)
in thisDict:
135 if(k1<=thisRun
and k2>=thisRun
and k3==whichFb):
136 return thisDict[(k1,k2,k3)]
141 runBoundsList=runString.split(
'-')
142 minStr=runBoundsList[0]
143 maxStr=runBoundsList[1]
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)
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]
160 if whichDet ==
'nd' and dataOrMC==
'data':
162 elif whichDet ==
'nd' and dataOrMC==
'mc':
164 elif whichDet ==
'fd' and dataOrMC==
'data':
166 elif whichDet ==
'fd' and dataOrMC==
'mc':
169 print(
"Nothing defined for "+whichDet+
' with '+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]
182 runTuple=runTuple+(
int(fbString[2:]),)
183 if whichDet ==
'nd' and dataOrMC==
'data':
185 elif whichDet ==
'nd' and dataOrMC==
'mc':
187 elif whichDet ==
'fd' and dataOrMC==
'data':
189 elif whichDet ==
'fd' and dataOrMC==
'mc':
192 print(
"Nothing defined for "+whichDet+
' with '+dataOrMC)
196 for i
in range(0,10):
197 print(
"There are missing runs!!!!!!!!!!!!!!!!")
200 for i
in range(0,10):
201 print(
"There are traling commas!!!!!!!!!!!!!!!!")
210 print(
"Using files from: "+newDir)
212 nct.checkAbsRunCoverage()
213 nct.checkAttenRunCoverage()
214 nct.checkAbsFilesForTrailingCommas()
215 nct.checkAttenFilesForTrailingCommas()
218 return nct.badMissingRuns+nct.badTrailingCommas
220 if __name__ ==
"__main__":
void split(double tt, double *fr)
def checkAbsFilesForTrailingCommas(self)
def checkRunCoverage(self, dictList)
def getAttenFiles(self, whichDet, dataOrMC)
def checkAttenFilesForTrailingCommas(self)
def parseRunString(self, runString)
def checkForTrailingCommas(self, fileName)
def checkAttenRunCoverage(self)
def __init__(self, newDir)
procfile open("FD_BRL_v0.txt")
def getAbsFiles(self, whichDet, dataOrMC)
def getAbsFileForThisRun(self, whichDet, dataOrMC, thisRun)
def checkAbsRunCoverage(self)
def getAttenFileForThisRun(self, whichDet, dataOrMC, thisRun, whichFb=-1)