23 |
|
#load config |
24 |
|
config = BetterConfigParser() |
25 |
|
#config.read('./config') |
26 |
< |
config.read('./config7TeV') |
26 |
> |
#config.read('./config7TeV') |
27 |
> |
config.read('./config7TeV_ZZ') |
28 |
|
|
29 |
|
|
30 |
|
#GLOABAL rescale from Train/Test Spliiting: |
51 |
|
|
52 |
|
|
53 |
|
if subsample>-1: |
54 |
+ |
#print 'cut: (%s) & (%s)'%(cut,job.subcuts[subsample]) |
55 |
|
CuttedTree=Tree.CopyTree('(%s) & (%s)'%(cut,job.subcuts[subsample])) |
56 |
|
#print '\t--> read in %s'%job.group[subsample] |
57 |
|
|
58 |
|
else: |
59 |
|
CuttedTree=Tree.CopyTree(cut) |
60 |
|
#print '\t--> read in %s'%job.name |
61 |
< |
|
61 |
> |
newinput.Close() |
62 |
|
|
63 |
|
#CuttedTree.SetDirectory(0) |
64 |
|
return CuttedTree |
130 |
|
|
131 |
|
output = ROOT.TFile.Open(fnameOutput, "RECREATE") |
132 |
|
|
133 |
< |
print '\n*** TRAINING EVENTS ***\n' |
133 |
> |
print '\n\t>>> TRAINING EVENTS <<<\n' |
134 |
|
|
135 |
|
for job in info: |
136 |
|
if eval(job.active): |
137 |
< |
if job.name in signals: |
138 |
< |
print '\tREADING IN %s AS SIG'%job.name |
139 |
< |
Tsignal = getTree(job,TrainCut) |
140 |
< |
ROOT.gDirectory.Cd(workdir) |
141 |
< |
TsScale = getScale(job,global_rescale) |
142 |
< |
Tsignals.append(Tsignal) |
143 |
< |
TsScales.append(TsScale) |
144 |
< |
|
145 |
< |
if job.name in backgrounds: |
146 |
< |
if job.subsamples: |
147 |
< |
print '\tREADING IN SUBSAMPLES of %s AS BKG'%job.name |
148 |
< |
for subsample in range(0,len(job.group)): |
149 |
< |
print '\t- %s'%job.group[subsample] |
137 |
> |
|
138 |
> |
if job.subsamples: |
139 |
> |
print '\tREADING IN SUBSAMPLES of %s'%job.name |
140 |
> |
for subsample in range(0,len(job.group)): |
141 |
> |
if job.subnames[subsample] in signals: |
142 |
> |
print '\t- %s as SIG'%job.group[subsample] |
143 |
> |
Tsignal = getTree(job,TrainCut,subsample) |
144 |
> |
ROOT.gDirectory.Cd(workdir) |
145 |
> |
TsScale = getScale(job,global_rescale,subsample) |
146 |
> |
Tsignals.append(Tsignal) |
147 |
> |
TsScales.append(TsScale) |
148 |
> |
print '\t\t\t%s events'%Tsignal.GetEntries() |
149 |
> |
elif job.subnames[subsample] in backgrounds: |
150 |
> |
print '\t- %s as BKG'%job.group[subsample] |
151 |
|
Tbackground = getTree(job,TrainCut,subsample) |
152 |
|
ROOT.gDirectory.Cd(workdir) |
153 |
|
TbScale = getScale(job,global_rescale,subsample) |
154 |
|
Tbackgrounds.append(Tbackground) |
155 |
|
TbScales.append(TbScale) |
156 |
< |
|
157 |
< |
|
158 |
< |
else: |
156 |
> |
print '\t\t\t%s events'%Tbackground.GetEntries() |
157 |
> |
|
158 |
> |
else: |
159 |
> |
if job.name in signals: |
160 |
> |
print '\tREADING IN %s AS SIG'%job.name |
161 |
> |
Tsignal = getTree(job,TrainCut) |
162 |
> |
ROOT.gDirectory.Cd(workdir) |
163 |
> |
TsScale = getScale(job,global_rescale) |
164 |
> |
Tsignals.append(Tsignal) |
165 |
> |
TsScales.append(TsScale) |
166 |
> |
print '\t\t\t%s events'%Tsignal.GetEntries() |
167 |
> |
elif job.name in backgrounds: |
168 |
|
print '\tREADING IN %s AS BKG'%job.name |
169 |
|
Tbackground = getTree(job,TrainCut) |
170 |
|
ROOT.gDirectory.Cd(workdir) |
171 |
|
TbScale = getScale(job,global_rescale) |
172 |
|
Tbackgrounds.append(Tbackground) |
173 |
|
TbScales.append(TbScale) |
174 |
< |
|
174 |
> |
print '\t\t\t%s events'%Tbackground.GetEntries() |
175 |
> |
|
176 |
> |
|
177 |
|
#load EVALUATE trees |
178 |
|
Ebackgrounds = [] |
179 |
|
EbScales = [] |
180 |
|
Esignals = [] |
181 |
|
EsScales = [] |
182 |
|
|
183 |
< |
print '\n*** TESTING EVENTS ***\n' |
183 |
> |
print '\n\t>>> TESTING EVENTS <<<\n' |
184 |
|
|
185 |
|
|
186 |
|
for job in info: |
187 |
|
if eval(job.active): |
188 |
< |
|
189 |
< |
if job.name in signals: |
190 |
< |
print '\tREADING IN %s AS SIG'%job.name |
191 |
< |
Esignal = getTree(job,EvalCut) |
192 |
< |
ROOT.gDirectory.Cd(workdir) |
193 |
< |
EsScale = getScale(job,global_rescale) |
194 |
< |
Esignals.append(Esignal) |
195 |
< |
EsScales.append(EsScale) |
196 |
< |
|
197 |
< |
if job.name in backgrounds: |
198 |
< |
if job.subsamples: |
199 |
< |
print '\tREADING IN SUBSAMPLES of %s AS BKG'%job.name |
200 |
< |
for subsample in range(0,len(job.group)): |
201 |
< |
print '\t- %s'%job.group[subsample] |
188 |
> |
|
189 |
> |
if job.subsamples: |
190 |
> |
print '\tREADING IN SUBSAMPLES of %s'%job.name |
191 |
> |
for subsample in range(0,len(job.group)): |
192 |
> |
if job.subnames[subsample] in signals: |
193 |
> |
print '\t- %s as SIG'%job.group[subsample] |
194 |
> |
Esignal = getTree(job,EvalCut,subsample) |
195 |
> |
ROOT.gDirectory.Cd(workdir) |
196 |
> |
EsScale = getScale(job,global_rescale,subsample) |
197 |
> |
Esignals.append(Esignal) |
198 |
> |
EsScales.append(EsScale) |
199 |
> |
print '\t\t\t%s events'%Esignal.GetEntries() |
200 |
> |
elif job.subnames[subsample] in backgrounds: |
201 |
> |
print '\t- %s as BKG'%job.group[subsample] |
202 |
|
Ebackground = getTree(job,EvalCut,subsample) |
203 |
|
ROOT.gDirectory.Cd(workdir) |
204 |
|
EbScale = getScale(job,global_rescale,subsample) |
205 |
|
Ebackgrounds.append(Ebackground) |
206 |
|
EbScales.append(EbScale) |
207 |
< |
|
208 |
< |
|
209 |
< |
else: |
207 |
> |
print '\t\t\t%s events'%Ebackground.GetEntries() |
208 |
> |
|
209 |
> |
else: |
210 |
> |
if job.name in signals: |
211 |
> |
print '\tREADING IN %s AS SIG'%job.name |
212 |
> |
Esignal = getTree(job,EvalCut) |
213 |
> |
ROOT.gDirectory.Cd(workdir) |
214 |
> |
EsScale = getScale(job,global_rescale) |
215 |
> |
Esignals.append(Esignal) |
216 |
> |
EsScales.append(EsScale) |
217 |
> |
print '\t\t\t%s events'%Esignal.GetEntries() |
218 |
> |
elif job.name in backgrounds: |
219 |
|
print '\tREADING IN %s AS BKG'%job.name |
220 |
|
Ebackground = getTree(job,EvalCut) |
221 |
|
ROOT.gDirectory.Cd(workdir) |
222 |
|
EbScale = getScale(job,global_rescale) |
223 |
|
Ebackgrounds.append(Ebackground) |
224 |
|
EbScales.append(EbScale) |
225 |
< |
|
225 |
> |
print '\t\t\t%s events'%Ebackground.GetEntries() |
226 |
|
|
227 |
|
|
228 |
|
#output = ROOT.TFile.Open(fnameOutput, "RECREATE") |
231 |
|
#set input trees |
232 |
|
for i in range(len(Tsignals)): |
233 |
|
|
234 |
+ |
#print 'Number of SIG entries: %s'%Tsignals[i].GetEntries() |
235 |
|
factory.AddSignalTree(Tsignals[i], TsScales[i], ROOT.TMVA.Types.kTraining) |
236 |
+ |
#print 'Number of SIG entries: %s'%Esignals[i].GetEntries() |
237 |
|
factory.AddSignalTree(Esignals[i], EsScales[i], ROOT.TMVA.Types.kTesting) |
238 |
|
|
239 |
|
for i in range(len(Tbackgrounds)): |
240 |
|
if (Tbackgrounds[i].GetEntries()>0): |
241 |
+ |
#print 'Number of BKG entries: %s'%Tbackgrounds[i].GetEntries() |
242 |
|
factory.AddBackgroundTree(Tbackgrounds[i], TbScales[i], ROOT.TMVA.Types.kTraining) |
243 |
|
|
244 |
|
if (Ebackgrounds[i].GetEntries()>0): |
245 |
+ |
#print 'Number of BKG entries: %s'%Ebackgrounds[i].GetEntries() |
246 |
|
factory.AddBackgroundTree(Ebackgrounds[i], EbScales[i], ROOT.TMVA.Types.kTesting) |
247 |
|
|
248 |
|
|