ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/FGolf/tcmet/histtools.C
Revision: 1.2
Committed: Tue Jan 26 06:46:07 2010 UTC (15 years, 3 months ago) by benhoob
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +808 -644 lines
Log Message:
Added function to get TGraph from TH2

File Contents

# User Rev Content
1 fgolf 1.1 #include "TList.h"
2     #include "TObjArray.h"
3     #include "TH1.h"
4     #include "TH2.h"
5     #include "TLegend.h"
6     #include "THStack.h"
7     #include "TCanvas.h"
8     #include "TFile.h"
9     #include "TRegexp.h"
10     #include "TKey.h"
11     #include "TROOT.h"
12     #include <iostream>
13     #include "histtools.h"
14 benhoob 1.2 #include <vector>
15 fgolf 1.1 namespace hist {
16    
17 benhoob 1.2 /*
18     void plotHistos(vector<TH1F*> h, vector<char*> c,
19     char* title,char* xtitle, float min,
20     bool drawLeg, bool log, bool norm){
21    
22     if(log){
23     gPad->SetLogy(1);
24     if(min == 0.) cout<<"ERROR LOG PLOT WITH MIN SET TO ZERO"<<endl;
25     }
26 fgolf 1.1
27 benhoob 1.2 int nh = (int)h.size();
28     if(nh.size()!=c.size()) cout<<"ERROR HIST SIZE NOT EQUAL TO CHAR SIZE"<<endl;
29 fgolf 1.1
30 benhoob 1.2 int colors[]={1,2,4,5,6,7,8};
31    
32     for(int i=0;i<nh;i++){
33     h.at(i)->SetFillColor(0);
34     h.at(i)->SetLineWidth(2);
35     h.at(i)->SetLineColor(colors[i]);
36     h.at(i)->SetMarkerColor(colors[i]);
37    
38     if(norm){
39     if(h.at(i)->GetEntries() > 0) h.at(i)->Scale(1./h.at(i)->GetEntries());
40     }
41     }
42     h.at(0)->SetTitle(title);
43     h.at(0)->GetXaxis()->SetTitle(xtitle);
44     h.at(0)->Draw();
45     float max=h.at(0)->GetMaximum();
46    
47     for(int i=1;i<nh;i++){
48     h.at(i)->Draw();
49     if(h.at(i)->GetMaximum() > max) max=h.at(i)->GetMaximum();
50     }
51    
52     if(log) h.at(0)->SetMaximum(1.5*max);
53     else h.at(0)->SetMaximum(1.1*max);
54     h.at(0)->SetMinimum(min);
55    
56     if(drawLeg){
57     TLegend *leg=new TLegend(0.6,0.6,0.85,0.85);
58     for(int i=0;i<nh;i++) leg->AddEntry(h.at(i),c.at(i));
59     leg->SetFillColor(0);
60     leg->SetBorderSize(1);
61     leg->Draw();
62     }
63    
64     }
65     */
66    
67     void plotHistos(TH1F* h1, TH1F* h2,TH1F* h3,
68     char* c1, char* c2, char* c3,
69     char* title,char* xtitle, float min,
70     bool drawLeg, bool log, bool norm){
71    
72     if(log){
73     gPad->SetLogy(1);
74     if(min == 0.) cout<<"ERROR LOG PLOT WITH MIN SET TO ZERO"<<endl;
75     }
76 fgolf 1.1
77 benhoob 1.2 h1->SetFillColor(0);
78     h2->SetFillColor(0);
79     h3->SetFillColor(0);
80     h1->SetLineWidth(2);
81     h2->SetLineWidth(2);
82     h3->SetLineWidth(2);
83     h1->SetLineColor(1);
84     h2->SetLineColor(2);
85     h3->SetLineColor(4);
86     h2->SetMarkerColor(2);
87     h3->SetMarkerColor(4);
88     h1->SetTitle(title);
89     h1->GetXaxis()->SetTitle(xtitle);
90    
91     if(norm){
92     if(h1->GetEntries() > 0) h1->Scale(1./h1->GetEntries());
93     if(h2->GetEntries() > 0) h2->Scale(1./h2->GetEntries());
94     if(h3->GetEntries() > 0) h3->Scale(1./h3->GetEntries());
95     }
96 fgolf 1.1
97 benhoob 1.2 h1->Draw();
98     h2->Draw("same");
99     h3->Draw("same");
100    
101     float max=h1->GetMaximum();
102     if(h2->GetMaximum()>max) max=h2->GetMaximum();
103     if(h3->GetMaximum()>max) max=h3->GetMaximum();
104    
105     if(log) h1->SetMaximum(1.5*max);
106     else h1->SetMaximum(1.1*max);
107     h1->SetMinimum(min);
108    
109     if(drawLeg){
110     TLegend *leg=new TLegend(0.6,0.6,0.85,0.85);
111     leg->AddEntry(h1,c1);
112     leg->AddEntry(h2,c2);
113     leg->AddEntry(h3,c3);
114     leg->SetFillColor(0);
115     leg->SetBorderSize(1);
116     leg->Draw();
117     }
118    
119     }
120 fgolf 1.1
121    
122 benhoob 1.2
123     TGraphErrors *getTGraphFromTH2(TH2* h,vector<float> xbins, int method){
124    
125     const int nbins = (int)xbins.size()-1;
126     TH2* htemp[nbins];
127     TH1* hx[nbins];
128     TH1* hy[nbins];
129    
130     float x[nbins];
131     float y[nbins];
132     float xerr[nbins];
133     float yerr[nbins];
134    
135     for(int ibin=0;ibin<nbins;ibin++){
136    
137     htemp[ibin] = hist::suppressHist(h,ibin,xbins.at(ibin),xbins.at(ibin+1));
138     float width = xbins.at(ibin+1) - xbins.at(ibin);
139     hx[ibin] = htemp[ibin]->ProjectionX();
140     hy[ibin] = htemp[ibin]->ProjectionY();
141    
142     x[ibin] = hx[ibin]->GetMean(1);
143     xerr[ibin] = width/2.;
144    
145     if(method == 0){
146     y[ibin] = hy[ibin]->GetMean(1);
147     yerr[ibin] = (hy[ibin]->GetEntries()>0) ?
148     hy[ibin]->GetRMS(1)/sqrt(hy[ibin]->GetEntries()) : 0.;
149     }
150     if(method == 1){
151     y[ibin] = hy[ibin]->GetRMS(1);
152     yerr[ibin] = 0.;
153 fgolf 1.1 }
154    
155 benhoob 1.2 }
156 fgolf 1.1
157 benhoob 1.2 TGraphErrors *g=new TGraphErrors(nbins,x,y,xerr,yerr);
158     g->GetXaxis()->SetLimits(xbins.at(0),xbins.at(nbins));
159    
160     return g;
161     }
162    
163     TH2* suppressHist(TH2* hist,int iclone,float xmin,float xmax){
164    
165     TH2F* h=new TH2F(Form("%s_%s%i",hist->GetName(),"clone",iclone),hist->GetTitle(),
166     hist->GetNbinsX(),hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax(),
167     hist->GetNbinsY(),hist->GetYaxis()->GetXmin(),hist->GetYaxis()->GetXmax());
168    
169     for(int ibinx=1;ibinx<=hist->GetNbinsX();ibinx++){
170     for(int ibiny=1;ibiny<=hist->GetNbinsY();ibiny++){
171     if(hist->GetBinCenter(ibinx)>xmin && hist->GetBinCenter(ibinx)<xmax){
172     h->SetBinContent(ibinx,ibiny,hist->GetBinContent(ibinx,ibiny));
173     }else{
174     h->SetBinContent(ibinx,ibiny,0);
175     }
176     }
177     }
178     return h;
179     }
180    
181     //Add all histograms whose names match one of ten possible regular expression
182     //patterns or begin with one of ten possible given prefixes. Feel free to
183     //mix and match regular expression patterns and prefixes. If the final hist-
184     //ogram named outHistName does not exist it is created.
185    
186     void add(const char* outHistName, const char* patORpfx0, const char* patORpfx1, const char* patORpfx2, const char* patORpfx3, const char* patORpfx4, const char* patORpfx5, const char* patORpfx6, const char* patORpfx7, const char* patORpfx8, const char* patORpfx9)
187     {
188     add(outHistName, patORpfx0);
189     add(outHistName, patORpfx1);
190     if (patORpfx2) add(outHistName, patORpfx2);
191     if (patORpfx3) add(outHistName, patORpfx3);
192     if (patORpfx4) add(outHistName, patORpfx4);
193     if (patORpfx5) add(outHistName, patORpfx5);
194     if (patORpfx6) add(outHistName, patORpfx6);
195     if (patORpfx7) add(outHistName, patORpfx7);
196     if (patORpfx8) add(outHistName, patORpfx8);
197     if (patORpfx9) add(outHistName, patORpfx9);
198     }
199 fgolf 1.1
200 benhoob 1.2 //Add all histograms whose names match the given regular expression pattern
201     //or begin with the given prefix. If the final histogram named outHistName
202     //does not exist it is created.
203 fgolf 1.1
204 benhoob 1.2 void add(const char* outHistName, const char* patORpfx) {
205     TRegexp reg(patORpfx, kFALSE);
206 fgolf 1.1
207 benhoob 1.2 TList* list = gDirectory->GetList() ;
208     TIterator* iter = list->MakeIterator();
209 fgolf 1.1
210 benhoob 1.2 TObject* obj = 0;
211     TObject* hist = 0;
212     Bool_t makeOutHist = false;
213 fgolf 1.1
214 benhoob 1.2 hist = gDirectory->Get(outHistName);
215     //If out hist does not exist, remember to create it
216     if (! hist) makeOutHist = true;
217 fgolf 1.1
218 benhoob 1.2 cout << "Adding to " << outHistName << endl;
219 fgolf 1.1
220 benhoob 1.2 while (obj = iter->Next()) {
221     if (! obj->InheritsFrom(TH1::Class())) continue;
222     TString name = obj->GetName();
223 fgolf 1.1
224 benhoob 1.2 //Don't add out hist
225     if (name == TString(outHistName)) continue;
226 fgolf 1.1
227 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
228     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
229     } else if (! name.BeginsWith(patORpfx)) continue;
230 fgolf 1.1
231 benhoob 1.2 if (makeOutHist) {
232     hist = obj->Clone(outHistName);
233 fgolf 1.1
234 benhoob 1.2 if (hist->InheritsFrom(TH2::Class()))
235     ((TH2*)hist)->Reset();
236     else
237     ((TH1*)hist)->Reset();
238 fgolf 1.1
239 benhoob 1.2 ((TH1*)hist)->SetTitle(outHistName);
240     ((TH1*)hist)->Sumw2();
241     makeOutHist = false;
242 fgolf 1.1 }
243    
244 benhoob 1.2 cout << "Adding " << name << endl;
245     ((TH1*)hist)->Add((TH1*)obj);
246     }
247     }
248 fgolf 1.1
249 benhoob 1.2 //For all histograms whose names match the given regular expression pattern
250     //or begin with the given prefix, set the fill, line and marker colors to the
251     //given value.
252    
253     void color(const char* patORpfx, Color_t color) {
254     TRegexp reg(patORpfx, kFALSE);
255 fgolf 1.1
256 benhoob 1.2 TList* list = gDirectory->GetList() ;
257     TIterator* iter = list->MakeIterator();
258 fgolf 1.1
259 benhoob 1.2 TObject* obj = 0;
260 fgolf 1.1
261 benhoob 1.2 while (obj = iter->Next()) {
262     if (! obj->InheritsFrom(TH1::Class())) continue;
263 fgolf 1.1
264 benhoob 1.2 TString name = obj->GetName();
265 fgolf 1.1
266 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
267     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
268     } else if (! name.BeginsWith(patORpfx)) continue;
269 fgolf 1.1
270 benhoob 1.2 ((TH1*)obj)->SetFillColor(color);
271     ((TH1*)obj)->SetLineColor(color);
272     ((TH1*)obj)->SetMarkerColor(color);
273     }
274     }
275 fgolf 1.1
276 benhoob 1.2 void invertx(const char* patORpfx) {
277     TRegexp reg(patORpfx, kFALSE);
278 fgolf 1.1
279 benhoob 1.2 TList* list = gDirectory->GetList() ;
280     TIterator* iter = list->MakeIterator();
281 fgolf 1.1
282 benhoob 1.2 TObject* obj = 0;
283     TH1* h = 0;
284     TH1* htemp = 0;
285 fgolf 1.1
286 benhoob 1.2 while (obj = iter->Next()) {
287     if (! obj->InheritsFrom(TH1::Class())) continue;
288 fgolf 1.1
289 benhoob 1.2 TString name = obj->GetName();
290 fgolf 1.1
291 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
292     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
293     } else if (! name.BeginsWith(patORpfx)) continue;
294 fgolf 1.1
295 benhoob 1.2 cout << "Inverting " << name.Data() << endl;
296 fgolf 1.1
297 benhoob 1.2 h = (TH1*)obj;
298     htemp = (TH1*)h->Clone("htemp");
299 fgolf 1.1
300 benhoob 1.2 unsigned int nbinsp2 = h->GetNbinsX()+2;
301     for(unsigned int i = 0; i < nbinsp2; i++) {
302     h->SetBinContent(i, htemp->GetBinContent(nbinsp2-1-i));
303     h->SetBinError(i, htemp->GetBinError(nbinsp2-1-i));
304 fgolf 1.1 }
305 benhoob 1.2 }
306 fgolf 1.1
307 benhoob 1.2 delete htemp;
308     }
309 fgolf 1.1
310 benhoob 1.2 //For all histograms drawn on a given TCanvas, set the fill, line and marker
311     //colors in ascending order starting from the given color.
312 fgolf 1.1
313 benhoob 1.2 void colors(TCanvas* canvas, Color_t color) {
314     if(! canvas) return;
315 fgolf 1.1
316 benhoob 1.2 TList* list = canvas->GetListOfPrimitives();
317     TIterator* iter = list->MakeIterator();
318 fgolf 1.1
319 benhoob 1.2 TObject* obj = 0;
320 fgolf 1.1
321 benhoob 1.2 //Hist color iterator
322     Int_t colorIt = color;
323 fgolf 1.1
324 benhoob 1.2 while (obj = iter->Next()) {
325     if (! obj->InheritsFrom(TH1::Class())) continue;
326 fgolf 1.1
327 benhoob 1.2 //yellow
328     if (colorIt == 5)
329     ++colorIt;
330 fgolf 1.1
331 benhoob 1.2 hist::color(obj->GetName(), colorIt);
332     if (colorIt == 7)
333     colorIt = 1;
334     else
335     ++colorIt;
336     }
337     }
338 fgolf 1.1
339 benhoob 1.2 //For all histograms added to a given THStack, set the fill, line and marker
340     //colors in ascending order starting from the given color.
341 fgolf 1.1
342 benhoob 1.2 void colors(THStack* stack, Color_t color) {
343     if(! stack) return;
344 fgolf 1.1
345 benhoob 1.2 TList* list = stack->GetHists();
346     TIterator* iter = list->MakeIterator();
347 fgolf 1.1
348 benhoob 1.2 TObject* obj = 0;
349 fgolf 1.1
350 benhoob 1.2 //Hist color iterator
351     Int_t colorIt = color;
352 fgolf 1.1
353 benhoob 1.2 while (obj = iter->Next()) {
354     if (! obj->InheritsFrom(TH1::Class())) continue;
355 fgolf 1.1
356 benhoob 1.2 hist::color(obj->GetName(), colorIt);
357     if (colorIt == 7)
358     colorIt = 1;
359     else
360     ++colorIt;
361     }
362     }
363 fgolf 1.1
364 benhoob 1.2 //Create a canvas and Draw("same") all histograms whose names match the given
365     //regular expression pattern or begin with the given prefix. If the TCanvas
366     //named canvasName does not exist it is created. Optionally apply colors and
367     //styles to all histograms.
368 fgolf 1.1
369 benhoob 1.2 void drawsame(const char* canvasName, const char* patORpfx, Bool_t addColor, Bool_t addStyle, Option_t* drawOption) {
370     TRegexp reg(patORpfx, kFALSE);
371 fgolf 1.1
372 benhoob 1.2 TList* list = gDirectory->GetList() ;
373     TIterator* iter = list->MakeIterator();
374 fgolf 1.1
375 benhoob 1.2 TObject* obj = 0;
376     TObject* canvas = 0;
377     Bool_t makeCanvas = false;
378 fgolf 1.1
379 benhoob 1.2 canvas = gROOT->GetListOfCanvases()->FindObject(canvasName);
380     //If canvas does not exist, remember to create it
381     if (! canvas) makeCanvas = true;
382 fgolf 1.1
383 benhoob 1.2 while (obj = iter->Next()) {
384     if (! obj->InheritsFrom(TH1::Class())) continue;
385 fgolf 1.1
386 benhoob 1.2 TString name = obj->GetName();
387 fgolf 1.1
388 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
389     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
390     } else if (! name.BeginsWith(patORpfx)) continue;
391 fgolf 1.1
392 benhoob 1.2 if (makeCanvas) {
393     canvas = new TCanvas(canvasName, canvasName);
394     makeCanvas = false;
395     }
396 fgolf 1.1
397 benhoob 1.2 ((TCanvas*)canvas)->cd();
398     if (!((TCanvas*)canvas)->GetListOfPrimitives()->GetEntries())
399     ((TH1*)obj)->Draw(Form("%s", drawOption));
400     else
401     ((TH1*)obj)->Draw(Form("SAME%s", drawOption));
402     }
403 fgolf 1.1
404 benhoob 1.2 if (addColor)
405     hist::colors((TCanvas*)canvas);
406     if (addStyle)
407     hist::styles((TCanvas*)canvas);
408     }
409 fgolf 1.1
410 benhoob 1.2 //Return a pointer to a TLegend with an entry for each histogram drawn on a
411     //given TCanvas. Display either the line, point or fill values. Optionally
412     //apply colors to all histograms. By default, entry labels are the names of
413     //their respective histograms. Optionally, if histogram names are of the
414     //form XX_YY_ZZ_WW, entry labels can be XX (token=0), YY (token=1), etc.
415    
416     TLegend* legend(const char* canvasName, Option_t* option, Bool_t addColor, Int_t token, Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax) {
417     if(! canvasName) return 0;
418    
419     TCanvas* canvas = 0;
420     TObject* obj = 0;
421     obj = gROOT->FindObjectAny(canvasName);
422    
423     if(obj && obj->InheritsFrom(TCanvas::Class()))
424     canvas = (TCanvas*)obj;
425     else
426     return 0;
427    
428     TLegend* leg = new TLegend(xmin, ymin, xmax, ymax);
429     TList* list = canvas->GetListOfPrimitives();
430     TIterator* iter = list->MakeIterator();
431    
432     //Hist color iterator
433     Int_t colorIt = 1;
434    
435     while (obj = iter->Next()) {
436     if (! obj->InheritsFrom(TH1::Class())) continue;
437    
438     if (addColor) {
439     hist::color(obj->GetName(), colorIt);
440     ++colorIt;
441     }
442    
443     if (token == -1)
444     leg->AddEntry(obj, obj->GetName(), option);
445     else {
446     TString name(obj->GetName());
447     TObjArray* a = name.Tokenize("_");
448     if (a->GetEntries() <= token)
449     leg->AddEntry(obj, obj->GetName(), option);
450     else
451     leg->AddEntry(obj, a->At(token)->GetName(), option);
452 fgolf 1.1 }
453 benhoob 1.2 }
454 fgolf 1.1
455 benhoob 1.2 return leg;
456     }
457 fgolf 1.1
458 benhoob 1.2 //Return a pointer to a TLegend with an entry for each histogram drawn on a
459     //given TCanvas. Display either the line, point or fill values. Optionally
460     //apply colors to all histograms. By default, entry labels are the names of
461     //their respective histograms. Optionally, if histogram names are of the
462     //form XX_YY_ZZ_WW, entry labels can be XX (token=0), YY (token=1), etc.
463    
464     TLegend* legend(TCanvas* canvas, Option_t* option, Bool_t addColor, Int_t token, Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax) {
465     if(! canvas) return 0;
466    
467     TLegend* leg = new TLegend(xmin, ymin, xmax, ymax);
468     TList* list = canvas->GetListOfPrimitives();
469     TIterator* iter = list->MakeIterator();
470    
471     TObject* obj = 0;
472    
473     //Hist color iterator
474     Int_t colorIt = 1;
475    
476     while (obj = iter->Next()) {
477     if (! obj->InheritsFrom(TH1::Class())) continue;
478    
479     if (addColor) {
480     hist::color(obj->GetName(), colorIt);
481     ++colorIt;
482     }
483    
484     if (token == -1)
485     leg->AddEntry(obj, obj->GetName(), option);
486     else {
487     TString name(obj->GetName());
488     TObjArray* a = name.Tokenize("_");
489     if (a->GetEntries() <= token)
490     leg->AddEntry(obj, obj->GetName(), option);
491     else
492     leg->AddEntry(obj, a->At(token)->GetName(), option);
493     }
494     }
495 fgolf 1.1
496 benhoob 1.2 return leg;
497     }
498 fgolf 1.1
499 benhoob 1.2 //Return a pointer to a TLegend with an entry for each histogram added to a
500     //given THStack. Display either the line, point or fill values. Optionally
501     //apply colors to all histograms. By default, entry labels are the names of
502     //their respective histograms. Optionally, if histogram names are of the
503     //form XX_YY_ZZ_WW, entry labels can be XX (token=0), YY (token=1), etc.
504    
505     TLegend* legend(THStack* stack, Option_t* option, Bool_t addColor, Int_t token, Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax) {
506     if(! stack) return 0;
507    
508     TLegend* leg = new TLegend(xmin, ymin, xmax, ymax);
509     TList* list = stack->GetHists();
510     TIterator* iter = list->MakeIterator();
511    
512     TObject* obj = 0;
513    
514     //Hist color iterator
515     Int_t colorIt = 1;
516    
517     while (obj = iter->Next()) {
518     if (! obj->InheritsFrom(TH1::Class())) continue;
519    
520     if (addColor) {
521     hist::color(obj->GetName(), colorIt);
522     ++colorIt;
523     }
524    
525     if (token == -1)
526     leg->AddEntry(obj, obj->GetName(), option);
527     else {
528     TString name(obj->GetName());
529     TObjArray* a = name.Tokenize("_");
530     if (a->GetEntries() <= token)
531     leg->AddEntry(obj, obj->GetName(), option);
532     else
533     leg->AddEntry(obj, a->At(token)->GetName(), option);
534     }
535     }
536 fgolf 1.1
537 benhoob 1.2 return leg;
538     }
539 fgolf 1.1
540 benhoob 1.2 //Normalize to one all histograms whose names match the given regular exp-
541     //ression pattern or begin with the given prefix.
542 fgolf 1.1
543 benhoob 1.2 void normalize(const char* patORpfx) {
544     TRegexp reg(patORpfx, kFALSE);
545 fgolf 1.1
546 benhoob 1.2 TList* list = gDirectory->GetList() ;
547     TIterator* iter = list->MakeIterator();
548 fgolf 1.1
549 benhoob 1.2 TObject* obj = 0;
550 fgolf 1.1
551 benhoob 1.2 while (obj = iter->Next()) {
552     if (! obj->InheritsFrom(TH1::Class())) continue;
553 fgolf 1.1
554 benhoob 1.2 TString name = obj->GetName();
555 fgolf 1.1
556 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
557     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
558     } else if (! name.BeginsWith(patORpfx)) continue;
559 fgolf 1.1
560 benhoob 1.2 Double_t integral = 0;
561 fgolf 1.1
562 benhoob 1.2 if (obj->InheritsFrom(TH2::Class()))
563     integral = ((TH2*)obj)->Integral();
564     else
565     integral = ((TH1*)obj)->Integral();
566 fgolf 1.1
567 benhoob 1.2 if (integral) {
568     ((TH1*)obj)->Sumw2();
569     ((TH1*)obj)->Scale(1./integral);
570 fgolf 1.1 }
571 benhoob 1.2 }
572     }
573 fgolf 1.1
574 benhoob 1.2 //Scale by the given value all histograms whose names match the given regular
575     //expression pattern or begin with the given prefix.
576 fgolf 1.1
577 benhoob 1.2 void scale(const char* patORpfx, Double_t scale) {
578     TRegexp reg(patORpfx, kFALSE);
579 fgolf 1.1
580 benhoob 1.2 TList* list = gDirectory->GetList() ;
581     TIterator* iter = list->MakeIterator();
582 fgolf 1.1
583 benhoob 1.2 TObject* obj = 0;
584 fgolf 1.1
585 benhoob 1.2 while (obj = iter->Next()) {
586     if (! obj->InheritsFrom(TH1::Class())) continue;
587 fgolf 1.1
588 benhoob 1.2 TString name = obj->GetName();
589 fgolf 1.1
590 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
591     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
592     } else if (! name.BeginsWith(patORpfx)) continue;
593 fgolf 1.1
594 benhoob 1.2 ((TH1*)obj)->Sumw2();
595     ((TH1*)obj)->Scale(scale);
596     }
597     }
598 fgolf 1.1
599 benhoob 1.2 //Scale bins to given value of x-axis units for all histograms whose names
600     //match the given regular expression pattern or begin with the given prefix.
601 fgolf 1.1
602 benhoob 1.2 void scalebins(const char* patORpfx, Double_t scale) {
603     TRegexp reg(patORpfx, kFALSE);
604 fgolf 1.1
605 benhoob 1.2 TList* list = gDirectory->GetList() ;
606     TIterator* iter = list->MakeIterator();
607 fgolf 1.1
608 benhoob 1.2 TObject* obj = 0;
609 fgolf 1.1
610 benhoob 1.2 while (obj = iter->Next()) {
611     if (! obj->InheritsFrom(TH1::Class())) continue;
612 fgolf 1.1
613 benhoob 1.2 TString name = obj->GetName();
614 fgolf 1.1
615 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
616     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
617     } else if (! name.BeginsWith(patORpfx)) continue;
618 fgolf 1.1
619 benhoob 1.2 Double_t binWidth, binContent, binError, newBinContent, newBinError;
620     for (Int_t i = 1; i <= ((TH1*)obj)->GetNbinsX(); ++i) {
621     binWidth = ((TH1*)obj)->GetBinWidth(i);
622     binContent = ((TH1*)obj)->GetBinContent(i);
623     binError = ((TH1*)obj)->GetBinError(i);
624     newBinContent = (binContent*scale)/binWidth;
625     newBinError = (binError*scale)/binWidth;
626 fgolf 1.1
627 benhoob 1.2 ((TH1*)obj)->SetBinContent(i, newBinContent);
628     ((TH1*)obj)->SetBinError(i, newBinContent);
629     // Rename y axis with scale
630     }
631     }
632     }
633 fgolf 1.1
634 benhoob 1.2 //Don't you hate it when you draw multiple histograms on the same canvas only
635     //to find that the bottom histogram's range does not encompass those of the
636     //histograms drawn on top? This method determines the maximum and minimum y
637     //range of all the histograms drawn on a given TCanvas and appropriately re-
638     //sizes the bottom histogram.
639 fgolf 1.1
640 benhoob 1.2 void setrangey(const char* canvasName, Double_t maxy, Double_t miny) {
641     if(! canvasName) return;
642 fgolf 1.1
643 benhoob 1.2 TCanvas* canvas = 0;
644     TObject* obj = 0;
645     obj = gROOT->FindObjectAny(canvasName);
646 fgolf 1.1
647 benhoob 1.2 if(obj && obj->InheritsFrom(TCanvas::Class()))
648     canvas = (TCanvas*)obj;
649     else
650     return;
651 fgolf 1.1
652 benhoob 1.2 TList* list = canvas->GetListOfPrimitives();
653     TIterator* iter = list->MakeIterator();
654 fgolf 1.1
655 benhoob 1.2 TObject* top = 0;
656 fgolf 1.1
657 benhoob 1.2 while (obj = iter->Next()) {
658     if (! obj->InheritsFrom(TH1::Class())) continue;
659 fgolf 1.1
660 benhoob 1.2 if (! top) top = obj;
661 fgolf 1.1
662 benhoob 1.2 if (((TH1*)obj)->GetMaximum() > maxy) maxy = ((TH1*)obj)->GetMaximum();
663 fgolf 1.1
664 benhoob 1.2 // JAKE Set to log scale if max/min > 10
665 fgolf 1.1
666 benhoob 1.2 if (canvas->GetLogy()) {
667     //protect against user supplied argument
668     if (miny == 0) miny = 999999;
669 fgolf 1.1
670 benhoob 1.2 for(Int_t bin = 1; bin <= ((TH1*)obj)->GetNbinsX(); ++bin) {
671     Double_t binContent = ((TH1*)obj)->GetBinContent(bin);
672     if (binContent != 0 && binContent < miny)
673     miny = binContent;
674     }
675     } else if (((TH1*)obj)->GetMinimum() < miny) miny = ((TH1*)obj)->GetMinimum();
676     }
677 fgolf 1.1
678 benhoob 1.2 ((TH1*)top)->SetMaximum(maxy*1.1);
679     ((TH1*)top)->SetMinimum(miny*0.9);
680     }
681 fgolf 1.1
682 benhoob 1.2 //Create a stacked histogram consisting of all histograms whose names match
683     //the given regular expression pattern or begin with the given prefix. If
684     //the THStack named stackHistName does not exist it is created. Optionally
685     //apply colors to all histograms. Set drawOption to "nostack" if you do not
686     //want to stack, to "hist" to display histograms without errors, to "histe"
687     //to display histograms with errors, etc.
688    
689     //Don't you hate it when you draw multiple histograms on the same canvas only
690     //to find that the bottom histogram's range does not encompass those of the
691     //histograms drawn on top? This method determines the maximum and minimum y
692     //range of all the histograms drawn on a given TCanvas and appropriately re-
693     //sizes the bottom histogram.
694    
695     void setrangey(TCanvas* canvas, Double_t maxy, Double_t miny) {
696     if(! canvas) return;
697    
698     TList* list = canvas->GetListOfPrimitives();
699     TIterator* iter = list->MakeIterator();
700    
701     TObject* obj = 0;
702     TObject* top = 0;
703    
704     while (obj = iter->Next()) {
705     if (! obj->InheritsFrom(TH1::Class())) continue;
706    
707     if (! top) top = obj;
708    
709     if (((TH1*)obj)->GetMaximum() > maxy) maxy = ((TH1*)obj)->GetMaximum();
710    
711     // JAKE Set to log scale if max/min > 10
712    
713     if (canvas->GetLogy()) {
714     //protect against user supplied argument
715     if (miny == 0) miny = 999999;
716    
717     for(Int_t bin = 1; bin <= ((TH1*)obj)->GetNbinsX(); ++bin) {
718     Double_t binContent = ((TH1*)obj)->GetBinContent(bin);
719     if (binContent != 0 && binContent < miny)
720     miny = binContent;
721     }
722     } else if (((TH1*)obj)->GetMinimum() < miny) miny = ((TH1*)obj)->GetMinimum();
723     }
724 fgolf 1.1
725 benhoob 1.2 ((TH1*)top)->SetMaximum(maxy*1.1);
726     ((TH1*)top)->SetMinimum(miny*0.9);
727     }
728 fgolf 1.1
729 benhoob 1.2 //Create a stacked histogram consisting of all histograms whose names match
730     //the given regular expression pattern or begin with the given prefix. If
731     //the THStack named stackHistName does not exist it is created. Optionally
732     //apply colors to all histograms. Set drawOption to "nostack" if you do not
733     //want to stack, to "hist" to display histograms without errors, to "histe"
734     //to display histograms with errors, etc.
735 fgolf 1.1
736 benhoob 1.2 void stack(const char* stackHistName, const char* patORpfx, Bool_t addColor, Option_t* drawOption) {
737     TRegexp reg(patORpfx, kFALSE);
738 fgolf 1.1
739 benhoob 1.2 TList* list = gDirectory->GetList() ;
740     TIterator* iter = list->MakeIterator();
741 fgolf 1.1
742 benhoob 1.2 TObject* obj = 0;
743     TObject* stack = 0;
744     Bool_t makeStackHist = false;
745 fgolf 1.1
746 benhoob 1.2 stack = gDirectory->Get(stackHistName);
747     //If stack hist does not exist, remember to create it
748     if (! stack) makeStackHist = true;
749 fgolf 1.1
750 benhoob 1.2 //Hist color iterator
751     Int_t colorIt = 1;
752 fgolf 1.1
753 benhoob 1.2 while (obj = iter->Next()) {
754     if (! obj->InheritsFrom(TH1::Class())) continue;
755 fgolf 1.1
756 benhoob 1.2 TString name = obj->GetName();
757 fgolf 1.1
758 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
759     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
760     } else if (! name.BeginsWith(patORpfx)) continue;
761 fgolf 1.1
762 benhoob 1.2 if (makeStackHist) {
763     stack = new THStack(stackHistName, stackHistName);
764     makeStackHist = false;
765     }
766 fgolf 1.1
767 benhoob 1.2 if (addColor) {
768     hist::color(obj->GetName(), colorIt);
769     ++colorIt;
770     }
771 fgolf 1.1
772 benhoob 1.2 ((THStack*)stack)->Add((TH1*)obj, drawOption);
773     }
774 fgolf 1.1
775 benhoob 1.2 // Currently breaks .ls
776     //gDirectory->Append(stack);
777     }
778 fgolf 1.1
779 benhoob 1.2 //For all histograms whose names match the given regular expression pattern
780     //or begin with the given prefix, set the marker style.
781 fgolf 1.1
782 benhoob 1.2 void style(const char* patORpfx, Style_t style) {
783     TRegexp reg(patORpfx, kFALSE);
784 fgolf 1.1
785 benhoob 1.2 TList* list = gDirectory->GetList() ;
786     TIterator* iter = list->MakeIterator();
787 fgolf 1.1
788 benhoob 1.2 TObject* obj = 0;
789 fgolf 1.1
790 benhoob 1.2 while (obj = iter->Next()) {
791     if (! obj->InheritsFrom(TH1::Class())) continue;
792 fgolf 1.1
793 benhoob 1.2 TString name = obj->GetName();
794 fgolf 1.1
795 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
796     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
797     } else if (! name.BeginsWith(patORpfx)) continue;
798 fgolf 1.1
799 benhoob 1.2 ((TH1*)obj)->SetMarkerStyle(style);
800     }
801     }
802 fgolf 1.1
803 benhoob 1.2 //For all histograms drawn on a given TCanvas, set the marker styles in
804     //ascending order starting from the given style.
805 fgolf 1.1
806 benhoob 1.2 void styles(TCanvas* canvas, Style_t style) {
807     if(! canvas) return;
808 fgolf 1.1
809 benhoob 1.2 TList* list = canvas->GetListOfPrimitives();
810     TIterator* iter = list->MakeIterator();
811 fgolf 1.1
812 benhoob 1.2 TObject* obj = 0;
813 fgolf 1.1
814 benhoob 1.2 //Hist style iterator
815     Int_t styleIt = style;
816 fgolf 1.1
817 benhoob 1.2 while (obj = iter->Next()) {
818     if (! obj->InheritsFrom(TH1::Class())) continue;
819 fgolf 1.1
820 benhoob 1.2 ((TH1*)obj)->SetMarkerStyle(styleIt);
821     ++styleIt;
822     }
823     }
824 fgolf 1.1
825 benhoob 1.2 //For all histograms drawn on a given THStack, set the marker styles in
826     //ascending order starting from the given style.
827 fgolf 1.1
828 benhoob 1.2 void styles(THStack* stack, Style_t style) {
829     if(! stack) return;
830 fgolf 1.1
831 benhoob 1.2 TList* list = stack->GetHists();
832     TIterator* iter = list->MakeIterator();
833 fgolf 1.1
834 benhoob 1.2 TObject* obj = 0;
835 fgolf 1.1
836 benhoob 1.2 //Hist style iterator
837     Int_t styleIt = style;
838 fgolf 1.1
839 benhoob 1.2 while (obj = iter->Next()) {
840     if (! obj->InheritsFrom(TH1::Class())) continue;
841 fgolf 1.1
842 benhoob 1.2 ((TH1*)obj)->SetMarkerStyle(styleIt);
843     ++styleIt;
844     }
845     }
846 fgolf 1.1
847 benhoob 1.2 //Set the x-axis title of all histograms whose names match the given regular
848     //expression pattern or begin with the given prefix.
849 fgolf 1.1
850 benhoob 1.2 void xaxis(const char* patORpfx, const char* title) {
851     TRegexp reg(patORpfx, kFALSE);
852 fgolf 1.1
853 benhoob 1.2 TList* list = gDirectory->GetList() ;
854     TIterator* iter = list->MakeIterator();
855 fgolf 1.1
856 benhoob 1.2 TObject* obj = 0;
857 fgolf 1.1
858 benhoob 1.2 while (obj = iter->Next()) {
859     if (! (obj->InheritsFrom(TH1::Class()) || obj->InheritsFrom(THStack::Class()))) continue;
860 fgolf 1.1
861 benhoob 1.2 TString name = obj->GetName();
862 fgolf 1.1
863 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
864     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
865     } else if (! name.BeginsWith(patORpfx)) continue;
866 fgolf 1.1
867 benhoob 1.2 if (obj->InheritsFrom(TH1::Class()))
868     ((TH1*)obj)->GetXaxis()->SetTitle(title);
869     if (obj->InheritsFrom(THStack::Class())) {
870     ((THStack*)obj)->Draw();
871     ((THStack*)obj)->GetXaxis()->SetTitle(title);
872 fgolf 1.1 }
873 benhoob 1.2 }
874     }
875 fgolf 1.1
876 benhoob 1.2 //Set the y-axis title of all histograms whose names match the given regular
877     //expression pattern or begin with the given prefix.
878 fgolf 1.1
879 benhoob 1.2 void yaxis(const char* patORpfx, const char* title) {
880     TRegexp reg(patORpfx, kFALSE);
881 fgolf 1.1
882 benhoob 1.2 TList* list = gDirectory->GetList() ;
883     TIterator* iter = list->MakeIterator();
884 fgolf 1.1
885 benhoob 1.2 TObject* obj = 0;
886 fgolf 1.1
887 benhoob 1.2 while (obj = iter->Next()) {
888     if (! (obj->InheritsFrom(TH1::Class()) || obj->InheritsFrom(THStack::Class()))) continue;
889 fgolf 1.1
890 benhoob 1.2 TString name = obj->GetName();
891 fgolf 1.1
892 benhoob 1.2 if (TString(patORpfx).MaybeRegexp()) {
893     if (TString(obj->GetName()).Index(reg) < 0 ) continue;
894     } else if (! name.BeginsWith(patORpfx)) continue;
895 fgolf 1.1
896 benhoob 1.2 if (obj->InheritsFrom(TH1::Class()))
897     ((TH1*)obj)->GetYaxis()->SetTitle(title);
898     if (obj->InheritsFrom(THStack::Class())) {
899     ((THStack*)obj)->Draw();
900     ((THStack*)obj)->GetYaxis()->SetTitle(title);
901 fgolf 1.1 }
902 benhoob 1.2 }
903     }
904 fgolf 1.1 }
905    
906     // Input: 2 histogram
907     // Output: one histogram which is the efficiency:
908     // h1 : TOTAL NUMBER OF EVENTS
909     // h2 : NUMBER OF EVENTS THAT PASS
910    
911     #include "TH1.h"
912    
913     // Method by pointer
914     TH1F* eff(TH1F* h1, TH1F* h2, const char* name){
915    
916     // first, verify that all histograms have same binning
917     // nx is the number of visible bins
918     // nxtot = nx+2 includes underflow and overflow
919     Int_t nx = h1->GetNbinsX();
920     if (h2->GetNbinsX() != nx) {
921     cout << "Histograms must have same number of bins" << endl;
922     return 0;
923     }
924    
925     // get the new histogram
926     TH1F* temp = (TH1F*) h1->Clone(name);
927     temp->SetTitle(name);
928     temp->Reset();
929     temp->Sumw2();
930    
931     // Do the calculation
932     temp->Divide(h2,h1,1.,1.,"B");
933    
934     // Done
935     return temp;
936     }
937    
938    
939     // Method by name
940     TH1F* eff(const char* name1, const char* name2, const char* name){
941    
942     // Get a list of object and their iterator
943     TList* list = gDirectory->GetList() ;
944     TIterator* iter = list->MakeIterator();
945    
946     // Loop over objects, set the pointers
947     TObject* obj;
948     TH1F* h1=0;
949     TH1F* h2=0;
950     TString str1 = Form("%s",name1);
951     TString str2 = Form("%s",name2);
952     while(obj=iter->Next()) {
953     TString objName = obj->GetName();
954     if (objName == str1) h1 = (TH1F*) obj;
955     if (objName == str2) h2 = (TH1F*) obj;
956     }
957    
958     // quit if not found
959     if (h1 == 0) {
960     cout << "Histogram " << name1 << " not found" << endl;
961     return 0;
962     }
963     if (h2 == 0) {
964     cout << "Histogram " << name2 << " not found" << endl;
965     return 0;
966     }
967    
968     // Call the method by pointer
969     TH1F* temp = eff(h1, h2, name);
970     return temp;
971     }
972     // Input: 4 histogram
973     // Output: one histogram which is the BG subtracted efficiency:
974     // h1 : TOTAL NUMBER OF EVENTS, SIGNAL REGION
975     // h2 : NUMBER OF EVENTS THAT PASS, SIGNAL REGION
976     // h3 : TOTAL NUMBER OF EVENTS, SIDE BAND
977     // h4 : NUMBER OF EVENTS THAT PASS, SIDE BAND
978    
979     #include "TH1.h"
980    
981    
982     TH1F* eff_bg(TH1F* h1, TH1F* h2, TH1F* h3, TH1F* h4, const char* name){
983    
984     // first, verify that all histograms have same binning
985     // nx is the number of visible bins
986     // nxtot = nx+2 includes underflow and overflow
987     Int_t nx = h1->GetNbinsX();
988     Int_t nxtot = nx + 2;
989     if (h2->GetNbinsX() != nx) {
990     cout << "Histograms must have same number of bins" << endl;
991     return 0;
992     }
993     if (h3->GetNbinsX() != nx) {
994     cout << "Histograms must have same number of bins" << endl;
995     return 0;
996     }
997     if (h3->GetNbinsX() != nx) {
998     cout << "Histograms must have same number of bins" << endl;
999     return 0;
1000     }
1001    
1002     // get the new histogram
1003     TH1F* temp = (TH1F*) h1->Clone(name);
1004     temp->SetTitle(name);
1005     temp->Reset();
1006     temp->Sumw2();
1007    
1008     // Loop over bins, calculate efficiency and error, put it in histogram
1009     for (Int_t i=0; i<nxtot; i++) {
1010     Double_t x1 = h1->GetBinContent(i);
1011     Double_t x2 = h2->GetBinContent(i);
1012     Double_t x3 = h3->GetBinContent(i);
1013     Double_t x4 = h4->GetBinContent(i);
1014     Double_t denom = x1 - x3;
1015     Double_t eff;
1016     if (denom == 0.) {
1017     eff = 0;
1018     } else {
1019     eff = (x2-x4)/denom;
1020     }
1021     Double_t failSig = x1 - x2;
1022     Double_t failBg = x3 - x4;
1023     Double_t blah = (1-eff)*(1-eff)*(x2+x4) + eff*eff*(failSig+failBg);
1024     if (blah <= 0.) blah=0.0;
1025     Double_t err;
1026     if (denom == 0) {
1027     err = 0.;
1028     } else {
1029     err = sqrt(blah)/denom;
1030     }
1031     temp->SetBinContent(i,eff);
1032     temp->SetBinError(i,err);
1033     }
1034    
1035     // Done
1036     return temp;
1037     }
1038    
1039     #include <TList.h>
1040     #include <TIterator.h>
1041    
1042     void deleteHistos() {
1043 benhoob 1.2 // Delete all existing histograms in memory
1044     TObject* obj;
1045     TList* list = gDirectory->GetList() ;
1046     TIterator* iter = list->MakeIterator();
1047     while (obj=iter->Next()) {
1048     if (obj->IsA()->InheritsFrom(TH1::Class()) ||
1049     obj->IsA()->InheritsFrom(TH2::Class()) ) {delete obj;}
1050     }
1051 fgolf 1.1 }
1052    
1053     void saveHist(const char* filename, const char* pat)
1054     {
1055 benhoob 1.2 TList* list = gDirectory->GetList() ;
1056     TIterator* iter = list->MakeIterator();
1057 fgolf 1.1
1058 benhoob 1.2 TRegexp re(pat,kTRUE) ;
1059     TObject *obj;
1060 fgolf 1.1
1061 benhoob 1.2 TFile outf(filename,"RECREATE") ;
1062     while(obj=iter->Next()) {
1063     if (TString(obj->GetName()).Index(re)>=0) {
1064     obj->Write() ;
1065     cout << "." ;
1066     cout.flush() ;
1067     }
1068     }
1069     cout << endl ;
1070     outf.Close() ;
1071 fgolf 1.1
1072 benhoob 1.2 delete iter ;
1073 fgolf 1.1 }
1074    
1075    
1076     void loadHist(const char* filename, const char* directory, const char* pfx, const char* pat, Bool_t doAdd)
1077     {
1078 benhoob 1.2 TFile inf(filename) ;
1079     //inf.ReadAll() ;
1080     TDirectory* dir;
1081     if (directory)
1082     dir = (TDirectory*)inf.Get(directory);
1083     else
1084     dir = &inf;
1085     TList* list = dir->GetListOfKeys() ;
1086     TIterator* iter = list->MakeIterator();
1087 fgolf 1.1
1088 benhoob 1.2 TRegexp re(pat,kTRUE) ;
1089     cout << "pat = " << pat << endl ;
1090 fgolf 1.1
1091 benhoob 1.2 gDirectory->cd("Rint:") ;
1092    
1093     TObject* obj ;
1094     TKey* key ;
1095     cout << "doAdd = " << (doAdd?"T":"F") << endl ;
1096     cout << "loadHist: reading." ;
1097     while(key=(TKey*)iter->Next()) {
1098    
1099     Int_t ridx = TString(key->GetName()).Index(re) ;
1100     if (ridx==-1) {
1101     continue ;
1102     }
1103    
1104     obj = dir->Get(key->GetName()) ;
1105     TObject* clone ;
1106     if (pfx) {
1107    
1108     // Find existing TH1-derived objects
1109     TObject* oldObj = 0 ;
1110     if (doAdd){
1111     oldObj = gDirectory->Get(Form("%s_%s",pfx,obj->GetName())) ;
1112     if (oldObj && !oldObj->IsA()->InheritsFrom(TH1::Class())) {
1113     oldObj = 0 ;
1114     }
1115     }
1116     if (oldObj) {
1117     clone = oldObj ;
1118     ((TH1*)clone)->Add((TH1*)obj) ;
1119 fgolf 1.1 } else {
1120 benhoob 1.2 clone = obj->Clone(Form("%s_%s",pfx,obj->GetName())) ;
1121     }
1122    
1123    
1124     } else {
1125 fgolf 1.1
1126 benhoob 1.2 // Find existing TH1-derived objects
1127     TObject* oldObj = 0 ;
1128     if (doAdd){
1129     oldObj = gDirectory->Get(key->GetName()) ;
1130     if (oldObj && !oldObj->IsA()->InheritsFrom(TH1::Class())) {
1131     oldObj = 0 ;
1132     }
1133 fgolf 1.1 }
1134 benhoob 1.2
1135     if (oldObj) {
1136     clone = oldObj ;
1137     ((TH1*)clone)->Add((TH1*)obj) ;
1138     } else {
1139     clone = obj->Clone() ;
1140 fgolf 1.1 }
1141 benhoob 1.2 }
1142     if (!gDirectory->GetList()->FindObject(clone)) {
1143     gDirectory->Append(clone) ;
1144     }
1145     cout << "." ;
1146     cout.flush() ;
1147     }
1148     cout << endl;
1149     inf.Close() ;
1150     delete iter ;
1151 fgolf 1.1 }