34 opts, args = getopt.getopt(argv[1:],
"ho:v", [
"help",
"output="])
35 except getopt.error
as msg:
39 for option, value
in opts:
42 if option
in (
"-h",
"--help"):
43 raise Usage(help_message)
44 if option
in (
"-o",
"--output"):
48 print (sys.argv[0].
split(
"/")[-1] +
": " +
str(err.msg),file=sys.stderr)
49 print (
"\t for help use --help", file=sys.stderr)
57 for iarg
in range(len(argv)) :
58 if argv[iarg].
find(
'files') >= 0:
59 inputfiles = argv[iarg]
60 elif argv[iarg].
find(
'trees') >= 0:
61 inputtrees = argv[iarg]
62 elif argv[iarg].
find(
'params') >= 0:
63 inputparams = argv[iarg]
64 elif argv[iarg].
find(
'saveas') >= 0:
65 saveasfiles = argv[iarg]
73 if len(saveaslist) > 0:
74 if not os.path.isdir(
'./output/'):
77 outputdir =
'./output/mval_'+
str(time.time())+
'/'
78 if not os.path.isdir(outputdir):
81 for saveas
in saveaslist :
83 if not os.path.isdir(outputdir+saveas+
'/'):
84 os.mkdir(outputdir+saveas+
'/')
87 numPlots = len(parslist)
92 numCols = numPlots//2 + numPlots%2
94 print (
'[>] Files to be processed :', filelist)
95 print (
'[>] Trees to be drawn :', len(treelist))
96 print (
'[>] Profiles to be made :', parslist)
97 print (
'[>] Going to be saved as :', saveaslist )
98 print (
'[>] Number of cols/rows :',numCols,
', ',numRows)
106 for filename
in filelist :
108 singleSelector = TTreeSelector(filename)
109 singleDict = singleSelector.loadTrees(treelist[0])
112 for entry
in singleDict :
113 iden = entry.lstrip(
'TVolume_').
replace(
'::',
'_')
115 if iden
not in canvasDict :
116 canvas = TCanvas(iden,
'TrackingVolume:'+iden,100,100,numCols*300,numRows*300)
118 canvas.Divide(numCols,numRows)
120 canvasDict[iden] = canvas
122 canvas = canvasDict[iden]
126 if len(parslist) > 1 : pad = 1
128 for par
in parslist :
129 tree = singleDict[entry]
134 for saveas
in saveaslist :
135 canvas.SaveAs(outputdir+saveas+
'/'+iden+
'.'+saveas)
138 for entry
in singleDict :
139 iden = entry.lstrip(
'TVolume_').
replace(
'::',
'_') +
'_TOTAL'
141 if '_UNMAPPED' in entry :
continue
143 if (entry+
'_UNMAPPED')
not in singleDict :
continue
145 if iden
not in canvasTotalDict :
146 canvas = TCanvas(iden,
'TrackingVolume:'+iden,100,100,numCols*300,numRows*300)
148 canvas.Divide(numCols,numRows)
150 canvasTotalDict[iden] = canvas
152 canvas = canvasTotalDict[iden]
156 if len(parslist) > 1 : pad = 1
158 for par
in parslist :
159 tree1 = singleDict[entry]
160 tree2 = singleDict[entry+
'_UNMAPPED']
162 outpath = outputdir+saveas+
'/'+iden+
'.'+saveas
163 plotStack(canvas,pad,tree1,tree2,par,fileNum,outpath)
169 print (
'[>] Next file, switching to same option (',fileNum,
')')