]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New scripts, and script updates
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 13 May 2011 14:45:46 +0000 (14:45 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 13 May 2011 14:45:46 +0000 (14:45 +0000)
PWG2/FORWARD/analysis2/scripts/CompELossFits.C [new file with mode: 0644]
PWG2/FORWARD/analysis2/scripts/DrawBeforeAfter.C [new file with mode: 0644]
PWG2/FORWARD/analysis2/scripts/DrawELossPoisson.C
PWG2/FORWARD/analysis2/scripts/DrawNeighbors.C
PWG2/FORWARD/analysis2/scripts/DrawRecAnaEloss.C
PWG2/FORWARD/analysis2/scripts/DrawSteps.C
PWG2/FORWARD/analysis2/scripts/MakeChain.C

diff --git a/PWG2/FORWARD/analysis2/scripts/CompELossFits.C b/PWG2/FORWARD/analysis2/scripts/CompELossFits.C
new file mode 100644 (file)
index 0000000..966c787
--- /dev/null
@@ -0,0 +1,86 @@
+void
+CompELossFits(const char* fname1, const char* fname2)
+{
+
+  TFile* file1 = TFile::Open(fname1, "READ");
+  if (!file1) { 
+    Error("CompELossFits", "Couldn't open %s", fname1);
+    return;
+  }
+
+  TFile* file2 = TFile::Open(fname2, "READ");
+  if (!file2) { 
+    Error("CompELossFits", "Couldn't open %s", fname2);
+    return;
+  }
+
+  AliFMDCorrELossFit* fit1 = 
+    static_cast<AliFMDCorrELossFit*>(file1->Get("elossfits"));
+  if (!fit1) { 
+    Error("CompELossFits", "Couldn't get elossfits from %s", fname1);
+    return;
+  }
+
+  AliFMDCorrELossFit* fit2 = 
+    static_cast<AliFMDCorrELossFit*>(file2->Get("elossfits"));
+  if (!fit2) { 
+    Error("CompELossFits", "Couldn't get elossfits from %s", fname2);
+    return;
+  }
+
+
+  TList* stacks1 = fit1->GetStacks(true, false, 4);
+  TList* stacks2 = fit2->GetStacks(true, false, 4);
+
+  Int_t nStacks = stacks1->GetEntries();
+
+  TCanvas* c = new TCanvas("c", "c", 900, 1200);
+  c->SetRightMargin(0.02);
+  c->SetTopMargin(0.02);
+  c->SetFillColor(0);
+  c->SetBorderSize(0);
+  c->SetBorderMode(0);
+
+  c->cd();
+  TPad* top = new TPad("top", "Top", 0, .95, 1, 1, 0, 0, 0);
+  top->Draw();
+  top->cd();
+  TLatex* l = new TLatex(.5,.5, Form("%s / %s", fname1, fname2));
+  l->SetTextSize(0.3);
+  l->SetNDC();
+  l->SetTextAlign(22);
+  l->Draw();
+
+  c->cd();
+  TPad* body = new TPad("body", "body", 0, 0, 1, .95, 0, 0, 0);
+  body->Draw();
+  body->cd();
+  body->Divide(2, (nStacks+1)/2, 0, 0);
+
+  Int_t nPad2 = nStacks;
+  for (Int_t i = 0; i < nStacks; i++) {
+    Int_t iPad = 1 + i/nPad2 + 2 * (i % nPad2);
+    TVirtualPad* p = body->cd(i+1);
+    p->SetLeftMargin(0.15);
+    p->SetRightMargin(0.01);
+    THStack* stack1 = static_cast<THStack*>(stacks1->At(i));
+    THStack* stack2 = static_cast<THStack*>(stacks2->At(i));
+
+    THStack* ratio  = static_cast<THStack*>(stack1->Clone());
+    Int_t    nHists = stack1->GetHists()->GetEntries();
+    for (Int_t j = 0; j < nHists; j++) { 
+      TH1* h1 = static_cast<TH1*>(stack1->GetHists()->At(j));
+      TH1* h2 = static_cast<TH1*>(stack2->GetHists()->At(j));
+      TH1* hr = static_cast<TH1*>(ratio->GetHists()->At(j));
+      hr->Divide(h1, h2);
+    }
+    ratio->Draw("nostack");
+  }
+}
+
+  
+
+
+  
+
+  
diff --git a/PWG2/FORWARD/analysis2/scripts/DrawBeforeAfter.C b/PWG2/FORWARD/analysis2/scripts/DrawBeforeAfter.C
new file mode 100644 (file)
index 0000000..6b6df6e
--- /dev/null
@@ -0,0 +1,87 @@
+void
+DrawRingBeforeAfter(TList* p, UShort_t d, Char_t r)
+{
+  if (!p) return;
+
+  TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
+  if (!ring) { 
+    Error("DrawBeforeAfter", "List FMD%d%c not found in %s",d,r,p->GetName());
+    return;
+  }
+  
+  TH2* corr = static_cast<TH2D*>(ring->FindObject("beforeAfter"));
+  if (!corr) { 
+    Error("DrawRingBeforeAfter", "Histogram esdEloss not found in FMD%d%c",
+         d, r);
+    return;
+  }
+  // gPad->SetLogz();
+  gPad->SetFillColor(0);
+  corr->SetTitle(Form("FMD%d%c",d,r));
+  corr->Draw("colz");
+
+  corr->GetXaxis()->SetRangeUser(-.5, 4);
+  corr->GetYaxis()->SetRangeUser(-.5, 4);
+  gPad->cd();
+}
+
+
+void
+DrawBeforeAfter(const char* filename="forward.root")
+{
+  gStyle->SetPalette(1);
+  gStyle->SetOptFit(0);
+  gStyle->SetOptStat(0);
+  gStyle->SetOptTitle(1);
+  gStyle->SetTitleW(.4);
+  gStyle->SetTitleH(.1);
+  gStyle->SetTitleColor(0);
+  gStyle->SetTitleStyle(0);
+  gStyle->SetTitleBorderSize(0);
+  gStyle->SetTitleX(.6);
+  
+  TFile* file = TFile::Open(filename, "READ");
+  if (!file) { 
+    Error("DrawBeforeAfter", "failed to open %s", filename);
+    return;
+  }
+
+  TList* forward = static_cast<TList*>(file->Get("Forward"));
+  if (!forward) { 
+    Error("DrawBeforeAfter", "List Forward not found in %s", filename);
+    return;
+  }
+
+  TList* sf = static_cast<TList*>(forward->FindObject("fmdSharingFilter"));
+  if (!sf) { 
+    Error("DrawBeforeAfter", "List fmdSharingFilter not found in Forward");
+    return;
+  }
+  
+  TCanvas* c = new TCanvas("beforeAfter", 
+                          "Signals before and after merging", 900, 700);
+  c->SetFillColor(0);
+  c->SetBorderSize(0);
+  c->SetLeftMargin(0.15);
+  c->SetRightMargin(0.02);
+  c->SetTopMargin(0.02);
+  c->Divide(3, 2, 0, 0);
+  
+  c->cd(1); DrawRingBeforeAfter(sf, 1, 'I');
+  c->cd(2); DrawRingBeforeAfter(sf, 2, 'I');
+  c->cd(5); DrawRingBeforeAfter(sf, 2, 'O');
+  c->cd(3); DrawRingBeforeAfter(sf, 3, 'I');
+  c->cd(6); DrawRingBeforeAfter(sf, 3, 'O');
+  TVirtualPad* p = c->cd(4);
+  // p->SetTopMargin(0.05);
+  p->SetRightMargin(0.15);
+  p->SetFillColor(0);
+  TH2D* highCuts = static_cast<TH2D*>(sf->FindObject("highCuts"));
+  if (highCuts) highCuts->Draw("colz");
+  c->cd();
+  
+}
+
+  
+  
index 3b475a34ae2d50904a86b7a1265725c752c928ce..8c8a0195d9341abb215fad008b00b82da4640496 100644 (file)
@@ -17,14 +17,21 @@ DrawRingELossPoisson(TList* p, UShort_t d, Char_t r,
          d, r);
     return;
   }
-  gPad->SetGridy();
-  gPad->SetGridx();
-  gPad->SetLogz();
-  gPad->SetFillColor(0);
+  TPad* pad = static_cast<TPad*>(gPad);
+  pad->SetGridy();
+  pad->SetGridx();
+  pad->SetLogz();
+  if (d == 3) { 
+    pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99, 
+                pad->GetYlowNDC()+pad->GetHNDC());
+    pad->SetRightMargin(0.15);
+  }
+  pad->SetFillColor(0);
   if (xmax < 0) xmax = corr->GetXaxis()->GetXmax();
   corr->GetXaxis()->SetRangeUser(xmin,xmax);
   corr->GetYaxis()->SetRangeUser(xmin,xmax);
   corr->SetTitle(Form("FMD%d%c",d,r));
+  Info("", "Entries: %d, integral: %f", corr->GetEntries(), corr->Integral()); 
   corr->Draw("colz");
 
   // Calculate the linear regression 
@@ -63,18 +70,21 @@ DrawRingELossPoisson(TList* p, UShort_t d, Char_t r,
   Info("", "FMD%d%c correlation coefficient: %9.5f%% "
        "line y = %f + %f * x", d, r, 100*rxy, alpha, beta);
 
-  Double_t x = xmin + dx * .1;
-  Double_t y = xmax - dx * .2;
-  TLatex* ltx = new TLatex(x, y, "Deming regression: y=#alpha+#beta x");
+  Double_t x = pad->GetLeftMargin()+.01;
+  Double_t y = 1-pad->GetTopMargin()-.01;
+  TLatex* ltx = new TLatex(x, y, Form("FMD%d%c", d, r));
+  ltx->SetNDC();
   ltx->SetTextAlign(13);
-  ltx->SetTextSize(0.06);
-  // ltx->SetNDC();
+  ltx->SetTextSize(0.08);
   ltx->Draw();
+  y -= 0.12;
+  ltx->SetTextSize(0.06);
+  ltx->DrawLatex(x,y,"Deming regression: y=#alpha+#beta x");
+  x += .02;
+  y -= .06;
   ltx->SetTextSize(0.05);
-  x = xmin + dx / 8;
-  y = xmax - dx * .25;
   ltx->DrawLatex(x, y, Form("#alpha=%5.3f", alpha));
-  y = xmax - dx * .3;
+  y -= .06;
   ltx->DrawLatex(x, y, Form("#beta= %5.3f", beta));
 
   TLinearFitter* fitter = new TLinearFitter(1);
@@ -106,9 +116,11 @@ DrawRingELossPoisson(TList* p, UShort_t d, Char_t r,
   Double_t chi2 = fitter->GetChisquare();
   Int_t    ndf  = (fitter->GetNpoints() - 
                   fitter->GetNumberFreeParameters() );
-  std::cout << chi2 << '/' << ndf << '=' << chi2 / ndf << std::endl;
+  std::cout << "chi2/ndf: " << chi2 << '/' << ndf 
+           << '=' << chi2 / ndf << std::endl;
 
-  gPad->cd();
+  // corr->Scale(1. / corr->GetMaximum());
+  pad->cd();
   return corr->GetCorrelationFactor();
 }
 
@@ -116,17 +128,19 @@ DrawRingELossPoisson(TList* p, UShort_t d, Char_t r,
 void
 DrawELossPoisson(const char* filename="forward.root", 
                 Double_t xmax=-1,
-                Double_t xmin=0)
+                Double_t xmin=-1)
 {
   gStyle->SetPalette(1);
   gStyle->SetOptFit(0);
   gStyle->SetOptStat(0);
+  gStyle->SetOptTitle(0);
   gStyle->SetTitleW(.4);
   gStyle->SetTitleH(.1);
+  gStyle->SetTitleX(.4);
+  // gStyle->SetTitleY(.1);
   gStyle->SetTitleColor(0);
   gStyle->SetTitleStyle(0);
   gStyle->SetTitleBorderSize(0);
-  gStyle->SetTitleX(.6);
   
   TFile* file = TFile::Open(filename, "READ");
   if (!file) { 
index cbabee5e55a9c3e1da66bd2a7cbb74b60558327b..1c2b9207a446c1013116f1b975603ba2f5afd329 100644 (file)
@@ -23,12 +23,28 @@ DrawRingNeighbors(TList* p, UShort_t d, Char_t r)
   }
   gPad->SetLogz();
   gPad->SetFillColor(0);
+  TPad* pad = (TPad*)gPad;
+  if (d == 3) { 
+    pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99, 
+                pad->GetYlowNDC()+pad->GetHNDC());
+    pad->SetRightMargin(0.15);
+  }
+  // gStyle->SetTitleY(gPad->GetBottomMargin());
+
   before->SetTitle(Form("FMD%d%c",d,r));
   before->Draw("colz");
   after->Draw("same box");
 
   before->GetXaxis()->SetRangeUser(-.5, 2);
   before->GetYaxis()->SetRangeUser(-.5, 2);
+
+  TLatex* ltx = new TLatex(gPad->GetLeftMargin()+.01, 
+                          gPad->GetBottomMargin()+.01, 
+                          before->GetTitle());
+  ltx->SetNDC();
+  ltx->SetTextSize(.07);
+  ltx->Draw();
+
   gPad->cd();
 }
 
@@ -41,10 +57,12 @@ DrawNeighbors(const char* filename="forward.root")
   gStyle->SetOptStat(0);
   gStyle->SetTitleW(.4);
   gStyle->SetTitleH(.1);
+  gStyle->SetTitleX(.1);
+  gStyle->SetTitleY(.1);
   gStyle->SetTitleColor(0);
   gStyle->SetTitleStyle(0);
   gStyle->SetTitleBorderSize(0);
-  gStyle->SetTitleX(.6);
+  gStyle->SetOptTitle(0);
 
   TFile* file = TFile::Open(filename, "READ");
   if (!file) { 
index 43be4ce3ace14948d6d799265bb96fb6e4150691..96e75d499dd58e265467aa6daa7f335779b81acc 100644 (file)
@@ -1,5 +1,28 @@
+#ifndef __CINT__
+#include <TList.h>
+#include <TH1.h>
+#include <TH2.h>
+#include <TCanvas.h>
+#include <TLatex.h>
+#include <TLine.h>
+#include <TFile.h>
+#include <TError.h>
+#include <TParameter.h>
+#include <TStyle.h>
+#else
+class TLatex;
+#endif
+
+void 
+DrawText(TLatex* l, Double_t x, Double_t& y, const char* c1, const char* c2)
+{
+  y -= 1.2*l->GetTextSize();
+  l->DrawLatex(x,    y, c1);
+  l->DrawLatex(x+.4, y, c2);
+}
+
 void
-DrawRingRecAnaEloss(TList* p, UShort_t d, Char_t r)
+DrawRingRecAnaEloss(TList* p, TList* p2, Double_t lowCut, UShort_t d, Char_t r)
 {
   if (!p) return;
 
@@ -8,26 +31,85 @@ DrawRingRecAnaEloss(TList* p, UShort_t d, Char_t r)
     Error("DrawRecAnaEloss", "List FMD%d%c not found in %s",d,r,p->GetName());
     return;
   }
-  
-  TH1* before = static_cast<TH2D*>(ring->FindObject("esdEloss"));
+  TList* ring2 = static_cast<TList*>(p2->FindObject(Form("FMD%d%c",d,r)));
+  if (!ring2){
+    Error("DrawRecAnaEloss","List FMD%d%c not found in %s",d,r,p2->GetName());
+    return;
+  }
+
+  TH1* before = static_cast<TH1D*>(ring->FindObject("esdEloss"));
   if (!before) { 
     Error("DrawRingRecAnaEloss", "Histogram esdEloss not found in FMD%d%c",
          d, r);
     return;
   }
-  TH1* after = static_cast<TH2D*>(ring->FindObject("anaEloss"));
+  TH1* after = static_cast<TH1D*>(ring->FindObject("anaEloss"));
   if (!after) { 
     Error("DrawRingRecAnaEloss", "Histogram anaEloss not found in FMD%d%c",
          d, r);
     return;
   }
+  TH1* presented = static_cast<TH1D*>(ring2->FindObject("eloss"));
+  if (!presented) {
+    Error("DrawRingRecAnaEloss", "Histogram eloss not found in FMD%d%c",
+         d, r);
+    return;
+  }
+  TH1* used = static_cast<TH1D*>(ring2->FindObject("elossUsed"));
+  if (!used) {
+    Error("DrawRingRecAnaEloss", "Histogram elossUsed not found in FMD%d%c",
+         d, r);
+    return;
+  }
+
+
+  Int_t low = before->GetXaxis()->FindBin(lowCut);
+  Int_t ib  = Int_t(before->Integral(low,before->GetNbinsX()));
+  Int_t ia  = Int_t(after->Integral(low,after->GetNbinsX()));
+  Int_t ip  = Int_t(presented->Integral(low,presented->GetNbinsX()));
+  Int_t iu  = Int_t(used->Integral(low,used->GetNbinsX()));
+  // before->Scale(1. / ib);
+  // after->Scale(1. / ib);
+  // presented->Scale(1. / ib);
+  // used->Scale(1. / ib);
+  
   gPad->SetLogy();
   gPad->SetFillColor(0);
   before->SetTitle(Form("FMD%d%c",d,r));
   before->Draw("");
   after->Draw("same");
-
-  before->GetXaxis()->SetRangeUser(0, 2);
+  presented->Draw("same");
+  used->Draw("same");
+  
+  // ib           = before->Integral(low,before->GetNbinsX());
+  // ia           = after->Integral(low,after->GetNbinsX());
+  // ip           = presented->Integral(low,presented->GetNbinsX());
+  // iu           = used->Integral(low,used->GetNbinsX());
+  Double_t ts  = 0.03;
+  Double_t x   = gPad->GetLeftMargin() + .25;
+  Double_t y   = 1-gPad->GetTopMargin()-gStyle->GetTitleH()+ts;
+  TLatex*  ltx = new TLatex(x, y, Form("FMD%d%c", d, r));
+  ltx->SetNDC();
+  ltx->SetTextAlign(13);
+  ltx->SetTextSize(ts);
+  // ltx->Draw();
+  // ltx->SetTextSize(.05);
+  TString inte(Form("Integral [%4.2f,#infty]", lowCut));
+  DrawText(ltx, x, y, Form("%s before:", inte.Data()), Form("%9d", ib));
+  DrawText(ltx, x, y, Form("%s after:",  inte.Data()), Form("%9d", ia));
+  DrawText(ltx, x, y, Form("%s input:",  inte.Data()), Form("%9d", ip));
+  DrawText(ltx, x, y, Form("%s user:",   inte.Data()), Form("%9d", iu));
+  TLine* l = new TLine;
+  l->SetLineWidth(1);
+  l->DrawLineNDC(x, y-0.9*ts, 1-gPad->GetRightMargin()-0.01, y-0.9*ts);
+  DrawText(ltx, x, y, "Change (merging)", Form("%5.1f%%", (100.*(ia-ib))/ib));
+  DrawText(ltx, x, y, "Change (input)",   Form("%5.1f%% (%5.1f%%)", 
+                                              (100.*(ip-ia))/ia,
+                                              (100.*(ip-ib))/ib));
+  DrawText(ltx, x, y, "Change (use)",     Form("%5.1f%% (%5.1f%%)", 
+                                              (100.*(iu-ip))/ip,
+                                              (100.*(iu-ib))/ib));
+  before->GetXaxis()->SetRangeUser(0, 4);
   gPad->cd();
 }
 
@@ -38,6 +120,7 @@ DrawRecAnaEloss(const char* filename="forward.root")
   gStyle->SetPalette(1);
   gStyle->SetOptFit(0);
   gStyle->SetOptStat(0);
+  gStyle->SetOptTitle(1);
   gStyle->SetTitleW(.4);
   gStyle->SetTitleH(.1);
   gStyle->SetTitleColor(0);
@@ -62,18 +145,32 @@ DrawRecAnaEloss(const char* filename="forward.root")
     Error("DrawRecAnaEloss", "List fmdSharingFilter not found in Forward");
     return;
   }
-  
+  TList* dc = static_cast<TList*>(forward->FindObject("fmdDensityCalculator"));
+  if (!dc) {
+    Error("DrawRecAnaEloss","List fmdDensityCalculator not found in Forward");
+    return;
+  }
+
+  TParameter<double>* lowCut = 
+    static_cast<TParameter<double>*>(sf->FindObject("lowCut"));
+  Double_t low = (lowCut ? lowCut->GetVal() : 0.15);
+  if (!lowCut)
+    Warning("DrawRecAnaEloss", "Low cut not found in %s, assuming %f",
+           sf->GetName(), low);
   TCanvas* c = new TCanvas("recAnaELoss", 
                           "Reconstructed and Analysed energy loss", 900, 700);
   c->SetFillColor(0);
   c->SetBorderSize(0);
+  c->SetLeftMargin(0.15);
+  c->SetRightMargin(0.02);
+  c->SetTopMargin(0.02);
   c->Divide(3, 2, 0, 0);
   
-  c->cd(1); DrawRingRecAnaEloss(sf, 1, 'I');
-  c->cd(2); DrawRingRecAnaEloss(sf, 2, 'I');
-  c->cd(5); DrawRingRecAnaEloss(sf, 2, 'O');
-  c->cd(3); DrawRingRecAnaEloss(sf, 3, 'I');
-  c->cd(6); DrawRingRecAnaEloss(sf, 3, 'O');
+  c->cd(1); DrawRingRecAnaEloss(sf, dc, low, 1, 'I');
+  c->cd(2); DrawRingRecAnaEloss(sf, dc, low, 2, 'I');
+  c->cd(5); DrawRingRecAnaEloss(sf, dc, low, 2, 'O');
+  c->cd(3); DrawRingRecAnaEloss(sf, dc, low, 3, 'I');
+  c->cd(6); DrawRingRecAnaEloss(sf, dc, low, 3, 'O');
   TVirtualPad* p = c->cd(4);
   // p->SetTopMargin(0.05);
   p->SetRightMargin(0.15);
index fadebf0a084d68080a447b82879ca588a73ea8b9..0856ea866b24ca2ec43fb85293eecb98c451f29a 100644 (file)
@@ -209,7 +209,7 @@ DrawStep(THStack* deltas, THStack* nchs, THStack* prims,
 }
 
 
-void DrawSteps(const char* filename, Bool_t single)
+void DrawSteps(const char* filename="forward.root", Bool_t single=true)
 {
   gStyle->SetPalette(1);
   gStyle->SetOptFit(0);
@@ -259,6 +259,7 @@ void DrawSteps(const char* filename, Bool_t single)
   gStyle->SetTitleY(.95);
   gStyle->SetTitleH(.1);
   gStyle->SetTitleW(.25);
+  gStyle->SetOptTitle(1);
   // gStyle->SetTitleColor(kBlack);
 
 
@@ -271,6 +272,7 @@ void DrawSteps(const char* filename, Bool_t single)
     c->SetRightMargin(0.05);
 
     DrawStep(deltas, nchs, prims, dndeta, 0);
+    c->SaveAs("steps_all.png");
     return;
   }
   Int_t nSteps = 0;
@@ -303,7 +305,10 @@ void DrawSteps(const char* filename, Bool_t single)
 
     DrawStep(deltas, nchs, prims, dndeta, i);
   }
-  c->SaveAs("steps.png");
+  c->SaveAs("steps_comic.png");
 }
+//
+// EOF
+//
 
     
index e412dfa9dba78c8fdf91980ca291f53ce564b8e2..ecbaa0bcb326b4520819c2cfe8c246529de41fd1 100644 (file)
@@ -31,7 +31,8 @@ ScanDirectory(TSystemDirectory* dir, TChain* chain,
     // Check if this is a directory 
     if (file->IsDirectory()) { 
       if (recursive) 
-       ScanDirectory(static_cast<TSystemDirectory*>(file),chain,pattern,recursive);
+       ScanDirectory(static_cast<TSystemDirectory*>(file),chain,
+                     pattern,recursive);
       continue;
     }
     
@@ -40,10 +41,17 @@ ScanDirectory(TSystemDirectory* dir, TChain* chain,
 
     // If this file does not contain the pattern, ignore 
     if (!name.Contains(pattern)) continue;
+    if (name.Contains("friends")) continue;
     
     // Get the path 
     TString data(Form("%s/%s", file->GetTitle(), name.Data()));
 
+    TFile* test = TFile::Open(data.Data(), "READ");
+    if (!test || test->IsZombie()) { 
+      Warning("ScanDirectory", "Failed to open file %s", data.Data());
+      continue;
+    }
+    test->Close();
     chain->Add(data);
 
   }