10 import simplejson
as json
15 pp = pprint.PrettyPrinter(indent=2)
19 "map_DTvsphi_dxdz.png" :
"map of dxdz residual vs phi",
20 "map_DTvsphi_dydz.png" :
"map of dydz residual vs phi",
21 "map_DTvsphi_x.png" :
"map of x residual vs phi",
22 "map_DTvsphi_y.png" :
"map of y residual vs phi",
23 "map_DTvsz_dxdz.png" :
"map of dxdz residual vs z",
24 "map_DTvsz_dydz.png" :
"map of dydz residual vs z",
25 "map_DTvsz_x.png" :
"map of x residual vs z",
26 "map_DTvsz_y.png" :
"map of y residual vs z",
27 "map_CSCvsphi_dxdz.png" :
"map of d(rphi)/dz residual vs phi",
28 "map_CSCvsphi_x.png" :
"map of rphi residual vs phi",
29 "map_CSCvsr_dxdz.png" :
"map of d(rphi)/dz residual vs r",
30 "map_CSCvsr_x.png" :
"map of rphi residual vs r",
31 "segdifphi_dt13_resid.png" :
"segdiff in x residuals vs phi",
32 "segdifphi_dt13_slope.png" :
"segdiff in dxdz residuals vs phi",
33 "segdifphi_dt2_resid.png" :
"segdiff in y residuals vs phi",
34 "segdifphi_dt2_slope.png" :
"segdiff in dydz residuals vs phi",
35 "segdif_dt13_resid.png" :
"segdiff in x residuals",
36 "segdif_dt13_slope.png" :
"segdiff in dxdz residuals",
37 "segdif_dt2_resid.png" :
"segdiff in y residuals",
38 "segdif_dt2_slope.png" :
"segdiff in dydz residuals",
39 "segdifphi_csc_resid.png" :
"segdiff in rphi residuals vs phi",
40 "segdifphi_csc_slope.png" :
"segdiff in d(rphi)/dz residuals vs phi",
41 "segdif_csc_resid.png" :
"segdiff in rphi residuals",
42 "segdif_csc_slope.png" :
"segdiff in d(rphi)/dz residuals",
43 "dt_bellcurves.png" :
"residuals distributions",
44 "dt_polynomials.png" :
"residuals relations to misalignments",
45 "csc_bellcurves.png" :
"residuals distributions",
46 "csc_polynomials.png" :
"residuals relations to misalignments",
47 'dt_curvature_deltax.png' :
'Delta x residuals vs. curvature',
48 'dt_curvature_deltadxdz.png' :
'Delta dxdz residuals vs. curvature',
49 "medians.png" :
"medians distribution"
57 usage=
'%prog [options]\n'+\
58 'Creates a tree_items.js data file for a browsable JavaScript tree using results produced '+\
59 'by running alignment_validation_plots.py.'
61 parser=optparse.OptionParser(usage)
63 parser.add_option(
"-i",
"--inputDir",
64 help=
"[REQUIRED] input directory: should contain 'iter1', 'iterN' and 'common' directories filled with alignment_validation_plots.py. The resulting tree_items.js is also dumped into this directory",
69 parser.add_option(
"-v",
"--verbose",
70 help=
"Degree of debug info verbosity",
75 options,args=parser.parse_args()
77 if options.inputDir==
'':
78 print "\nOne or more of REQUIRED options is missing!\n"
95 os.chdir(options.inputDir)
108 iteration_directory = iterationN
112 """it1 and itN are the first and the last iterations' directory names
113 dir is some directory with the results from for the LAST
114 iteration, so it must contain a itN substring
115 label is a label for tree's folder for this directory"""
116 if len(itN)>0
and dir.find(itN)==-1:
117 print "directory ", dir,
"has no ", itN,
" in it!!"
118 return [
"problem!!!",
""]
120 files = os.listdir(dir)
123 if re.match(
".+\.png", f):
124 if len(it1)>0
and len(itN)>0:
125 lnN = [itN,dir+
'/'+f]
126 dir1 = dir.replace(itN,it1)
127 if not os.access(dir1+
'/'+f,os.F_OK):
128 print "WARNING: no ",dir1+
'/'+f,
" file found!!!"
129 ln1 = [it1,dir1+
'/'+f]
130 ln = [NAME_TO_TITLE[f],dir+
'/'+f,ln1,lnN]
133 ln = [NAME_TO_TITLE[f],dir+
'/'+f]
141 tree_level1 = [
'test',
'']
144 dt_basedir = iteration_directory+
'/MB/'
145 tree_level2 =
parseDir(dt_basedir,
"MB",iteration1,iterationN)
146 for wheel
in DT_TYPES:
147 dd = dt_basedir + wheel[0]
149 tree_level3 =
parseDir(dd,wheel[0],iteration1,iterationN)
150 for station
in wheel[2]:
151 dd = dt_basedir + wheel[0]+
'/'+station[1]
153 tree_level4 =
parseDir(dd,station[0],iteration1,iterationN)
154 for sector
in range(1,station[2]+1):
155 ssector =
"%02d" % sector
156 dd = dt_basedir+wheel[0]+
'/'+station[1]+
'/'+ssector
158 tree_level5 =
parseDir(dd,
"%s/%d" % (station[0],sector),iteration1,iterationN)
159 if len(tree_level5) == 2: tree_level5.append([
'none',
''])
160 tree_level4.append(tree_level5)
161 if len(tree_level4) == 2: tree_level4.append([
'none',
''])
162 tree_level3.append(tree_level4)
163 if len(tree_level3) == 2: tree_level3.append([
'none',
''])
164 tree_level2.append(tree_level3)
165 if len(tree_level2) == 2: tree_level2.append([
'none',
''])
166 tree_level1.append(tree_level2)
169 csc_basedir = iteration_directory+
'/'
170 for endcap
in CSC_TYPES:
171 dd = csc_basedir+endcap[0]
173 tree_level2 =
parseDir(dd,endcap[0],iteration1,iterationN)
174 for station
in endcap[2]:
175 dd = csc_basedir+endcap[0]+
'/'+station[1]
177 tree_level3 =
parseDir(dd,station[0],iteration1,iterationN)
178 for ring
in station[2]:
179 dd = csc_basedir+endcap[0]+
'/'+station[1]+
'/'+ring[1]
181 tree_level4 =
parseDir(dd,
"%s/%s" % (station[0],ring[1]),iteration1,iterationN)
182 for chamber
in range(1,ring[2]+1):
183 schamber =
"%02d" % chamber
184 dd = csc_basedir+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'+schamber
186 tree_level5 =
parseDir(dd,
"%s/%s/%d" % (station[0],ring[1],chamber),iteration1,iterationN)
187 tree_level4.append(tree_level5)
188 if len(tree_level4) == 2: tree_level4.append([
'none',
''])
189 tree_level3.append(tree_level4)
190 if len(tree_level3) == 2: tree_level3.append([
'none',
''])
191 tree_level2.append(tree_level3)
192 if len(tree_level2) == 2: tree_level2.append([
'none',
''])
193 tree_level1.append(tree_level2)
196 common_basedir = comdir
197 tree_level2 =
parseDir(common_basedir,
"All")
198 tree_level1.append(tree_level2)
201 mytree.append(tree_level1)
206 ff = open(
"tree_items.js",mode=
"w")
207 print >>ff,
"var TREE_ITEMS = "