]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding scripts directory including:
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 6 Nov 2009 14:18:47 +0000 (14:18 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 6 Nov 2009 14:18:47 +0000 (14:18 +0000)
- macros for extracting and plotting detector digits
- program for plotting Geant4 cuts
(Eva, Ivana)

13 files changed:
test/vmctest/scripts/build_cuts.sh [new file with mode: 0755]
test/vmctest/scripts/cuts.cxx [new file with mode: 0644]
test/vmctest/scripts/digits.sh [new file with mode: 0755]
test/vmctest/scripts/digitsEMCAL.C [new file with mode: 0644]
test/vmctest/scripts/digitsHMPID.C [new file with mode: 0644]
test/vmctest/scripts/digitsPHOS.C [new file with mode: 0644]
test/vmctest/scripts/digitsSDD.C [new file with mode: 0644]
test/vmctest/scripts/digitsSPD.C [new file with mode: 0644]
test/vmctest/scripts/digitsSSD.C [new file with mode: 0644]
test/vmctest/scripts/digitsTOF.C [new file with mode: 0644]
test/vmctest/scripts/digitsTPC.C [new file with mode: 0644]
test/vmctest/scripts/digitsTRD.C [new file with mode: 0644]
test/vmctest/scripts/plotDigits.C [new file with mode: 0644]

diff --git a/test/vmctest/scripts/build_cuts.sh b/test/vmctest/scripts/build_cuts.sh
new file mode 100755 (executable)
index 0000000..a1fd716
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+# $Id$
+
+# Script for installation of cuts.cxx program
+
+CURDIR=`pwd`
+
+echo "... Installing cuts program"
+
+g++ -I$ROOTSYS/include \
+    `root-config --glibs` -lGeomPainter -lGeom cuts.cxx \
+    -o cuts2
+
+echo "... Installing cuts program finished"
+
+cd $CURDIR
diff --git a/test/vmctest/scripts/cuts.cxx b/test/vmctest/scripts/cuts.cxx
new file mode 100644 (file)
index 0000000..8107eb9
--- /dev/null
@@ -0,0 +1,265 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Program to generate the plots with energy cuts and corresponding
+// cuts in range for all materials per detector.
+// The program uses a text file output from geant4_vmc
+// (in development version only).
+//
+// By I.Hrivnacova, IPN Orsay
+
+#include <Rtypes.h>
+#include <TPaveText.h>
+#include <TString.h>
+#include <TGraph.h>
+#include <TCanvas.h>
+#include <TAxis.h>
+#include <TLegend.h>
+
+#include <map>
+#include <vector>
+#include <string>
+#include <fstream>
+#include <iostream>
+
+using namespace std;
+
+struct MaterialData {
+  MaterialData(string name, 
+               Double_t x1, Double_t x2, Double_t x3, 
+               Double_t x4, Double_t x5, Double_t x6)
+    : matName(name), 
+      rangeGam(x1), 
+      rangeEle(x2), 
+      cutGam(x3), 
+      cutEle(x4),
+      cutGamLimit(x5), 
+      cutEleLimit(x6) {}
+  string matName;
+  Double_t rangeGam;
+  Double_t rangeEle;
+  Double_t cutGam;
+  Double_t cutEle;
+  Double_t cutGamLimit;
+  Double_t cutEleLimit;
+};  
+  
+map<string, vector<MaterialData> > materialDataMap;  
+
+void readCuts() 
+{
+  std::ifstream input("cuts.txt");
+  while ( ! input.eof() ) {
+    string matName;
+    Int_t number;
+    Double_t x1, x2, x3, x4, x5, x6;
+    input >> number;
+    if ( input.eof() ) break;
+    input  >> matName >> x1 >> x2 >> x3 >> x4 >> x5 >> x6;
+    // cout << ".. reading " << number << " " << matName << endl;
+    
+    if ( x1 > 1e10 ) x1 = 1e04;
+    if ( x2 > 1e10 ) x2 = 1e04;
+    if ( x3 > 1e10 ) x3 = 1e04;
+    if ( x4 > 1e10 ) x4 = 1e04;
+    if ( x5 > 1e10 ) x5 = 1e04;
+    if ( x6 > 1e10 ) x6 = 1e04;
+    
+    string detName = matName;
+    detName.erase(detName.find('_'), detName.size()-detName.find('_'));
+
+    std::map<string, std::vector<MaterialData> >::iterator it
+      = materialDataMap.find(detName);
+    if ( it == materialDataMap.end() ) {
+      materialDataMap.insert(
+        std::pair<string, vector<MaterialData> >(detName, vector<MaterialData>()));
+    }
+    materialDataMap[detName].
+      push_back(MaterialData(matName, x1, x2, x3, x4, x5, x6));
+  }
+}        
+  
+void plotCuts(const string& detName) 
+{
+  cout << "Processing " << detName << " ..." << endl;
+  
+  //if ( detName == "DIPO" ) return;
+  //if ( detName == "HALL" ) return;
+  //if ( detName == "SHIL" ) return;
+  //if ( detName == "ZDC" ) return;
+
+  TPaveText* paveText = new TPaveText(0.1, 0.1, 0.98, 0.98);
+  paveText->SetTextAlign(11);
+
+  std::vector<MaterialData> materialData 
+    = materialDataMap[detName];
+
+  Double_t matNumber[300];
+  Double_t rangeGam[300];
+  Double_t rangeEle[300];
+  Double_t cutGam[300];
+  Double_t cutEle[300];
+  Double_t cutGamLimit[300];
+  Double_t cutEleLimit[300];
+  std::vector<string> matNames;
+  for (UInt_t i=0; i<materialData.size(); i++ ) {
+  
+    matNumber[i] = i;
+    rangeGam[i] = materialData[i].rangeGam;  
+    rangeEle[i] = materialData[i].rangeEle;
+    cutGam[i] = materialData[i].cutGam;
+    cutEle[i] = materialData[i].cutEle;
+    cutGamLimit[i] = materialData[i].cutGamLimit;
+    cutEleLimit[i] = materialData[i].cutEleLimit;
+   
+    TString legend;
+    legend += i;
+    legend += "  ";
+    legend += materialData[i].matName.data();    
+    paveText->AddText(legend.Data());
+  }
+  
+  TGraph* gr1 = new TGraph(materialData.size(), matNumber, rangeGam); 
+  TGraph* gr2 = new TGraph(materialData.size(), matNumber, cutGam); 
+  TGraph* gr3 = new TGraph(materialData.size(), matNumber, cutGamLimit); 
+  TGraph* gr4 = new TGraph(materialData.size(), matNumber, rangeEle); 
+  TGraph* gr5 = new TGraph(materialData.size(), matNumber, cutEle); 
+  TGraph* gr6 = new TGraph(materialData.size(), matNumber, cutEleLimit); 
+
+  // gamma range cut
+  gr1->SetMarkerColor(kBlue);
+  gr1->SetMarkerStyle(22);
+  gr1->SetTitle("Range cut for gamma");
+  gr1->GetXaxis()->SetTitle("Material number");
+  gr1->GetYaxis()->SetTitle("Range [mm]");
+  gr1->SetMinimum(1e-03);
+  gr1->SetMaximum(1e+04);
+
+  // gamma energy threshold
+  gr2->SetMarkerColor(kBlue);
+  gr2->SetMarkerStyle(22);
+  gr2->SetTitle("Energy threshold for gamma");
+  gr2->GetXaxis()->SetTitle("Material number");
+  gr2->GetYaxis()->SetTitle("Energy [MeV]");
+  gr2->SetMinimum(1e-04);
+  gr2->SetMaximum(1e+04);
+
+  // gamma user limit
+  gr3->SetMarkerColor(kBlack);
+  gr3->SetMarkerStyle(23);
+  gr3->SetTitle("User limit for gamma (GUTGAM)");
+  gr3->GetXaxis()->SetTitle("Material number");
+  gr3->GetYaxis()->SetTitle("Energy [MeV]");
+  gr3->SetMinimum(1e-04);
+  gr3->SetMaximum(1e+04);
+
+  // e- range cut
+  gr4->SetMarkerColor(kRed);
+  gr4->SetMarkerStyle(22);
+  gr4->SetTitle("Range cut for e-");
+  gr4->GetXaxis()->SetTitle("Material number");
+  gr4->GetYaxis()->SetTitle("Range [mm]");
+  gr4->GetYaxis()->SetRange(1e-03, 1e+04);
+  gr4->SetMinimum(1e-03);
+  gr4->SetMaximum(1e+04);
+
+  // e- energy threshold
+  gr5->SetMarkerColor(kRed);
+  gr5->SetMarkerStyle(22);
+  gr5->SetTitle("Energy threshold for e-");
+  gr5->GetXaxis()->SetTitle("Material number");
+  gr5->GetYaxis()->SetTitle("Energy [MeV]");
+  gr5->SetMinimum(1e-04);
+  gr5->SetMaximum(1e+04);
+
+  // e- user limit
+  gr6->SetMarkerColor(kBlack);
+  gr6->SetMarkerStyle(23);
+  gr6->SetTitle("User limit for e- (CUTELE)");
+  gr6->GetXaxis()->SetTitle("Material number");
+  gr6->GetYaxis()->SetTitle("Energy [MeV]");
+  gr6->SetMinimum(1e-04);
+  gr6->SetMaximum(1e+04);
+
+  //TLegend* leg = new TLegend(0.1,0.7,0.48,0.9);
+  TLegend* leg = new TLegend(0.1, 0.1, 0.98, 0.98);
+  leg->SetHeader("Energy threshold/User cuts");
+  leg->AddEntry(gr2,"Energy threshold for gamma","P");
+  leg->AddEntry(gr3,"User cut for gamma (CUGAM)","P");
+  leg->AddEntry(gr5,"Energy threshold for e-","P");
+  leg->AddEntry(gr6,"User cut for e- (CUTELE)","P");
+
+  TCanvas* canvas = new TCanvas("Range cuts", "Range cuts", 1200, 800);
+  canvas->Divide(3,2);
+  
+  // Draw graph using the function Draw()
+  canvas->cd(1);
+  canvas->cd(1)->SetLogy();
+  gr1->Draw("AP");
+  canvas->cd(2);
+  canvas->cd(2)->SetLogy();
+  gr2->Draw("AP");
+
+  //canvas->cd(3);
+  //canvas->cd(3)->SetLogy();
+  gr3->Draw("P");
+  canvas->cd(3);
+  leg->Draw();
+
+  canvas->cd(4);
+  canvas->cd(4)->SetLogy();
+  gr4->Draw("AP");
+
+  canvas->cd(5);
+  canvas->cd(5)->SetLogy();
+  gr5->Draw("AP");
+  //canvas->cd(6);
+  //canvas->cd(6)->SetLogy();
+  gr6->Draw("P");
+
+  canvas->cd(6);
+
+  //TCanvas* canvas2 = new TCanvas("Materials", "Materials", 200, 800);
+  //canvas2->cd();
+  paveText->Draw();
+  
+  string outName = detName;
+  outName += "_cuts.gif";
+  canvas->SaveAs(outName.data());
+  
+  //string outName2 = detName;
+  //outName2 += "_cuts_legend.gif";
+  //canvas2->SaveAs(outName2.data());
+}
+
+int main() {
+  
+  readCuts();
+  
+  std::map<string, std::vector<MaterialData> >::iterator it;
+  for ( it= materialDataMap.begin(); it != materialDataMap.end(); it++ )
+    plotCuts(it->first);
+    
+  return 0;  
+}  
+
+
+
diff --git a/test/vmctest/scripts/digits.sh b/test/vmctest/scripts/digits.sh
new file mode 100755 (executable)
index 0000000..f47e05a
--- /dev/null
@@ -0,0 +1,24 @@
+#/bin/sh
+#set -x
+
+# Script for processing DETdigits.C (or digitITSDET.C) macros 
+# and generating files with histograms.
+# Generated histograms can be then plot with plotDigits2.C.
+# Currently the macro has to be run in the directory
+# with the aliroot output, and one has to specify the 
+# number of events and the number of files in the chain
+# to be prcessed.
+#
+# By E.Sicking, CERN; I. Hrivnacova, IPN Orsay
+
+
+scriptdir=$ALICE_ROOT/test/vmctest/scripts
+
+export NEVENTS=10
+export NFILES=4
+
+for DET in SDD SSD SPD TPC TRD TOF EMCAL HMPID PHOS; do
+  echo Processing $DET digits
+  aliroot -b -q $scriptdir/digits${DET}.C\($NEVENTS,$NFILES\)
+done
+
diff --git a/test/vmctest/scripts/digitsEMCAL.C b/test/vmctest/scripts/digitsEMCAL.C
new file mode 100644 (file)
index 0000000..864d725
--- /dev/null
@@ -0,0 +1,88 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Macro to generate histograms from digits
+// By E. Sicking, CERN
+
+TTree* GetTreeD(Int_t ievent, const TString& detName, Int_t nfiles) 
+{
+  for (Int_t file =0; file<nfiles; file++) {
+    TString filename(detName);
+    if ( file == 0 ) {
+      filename += ".Digits.root";
+    }  
+    else { 
+      filename += TString(Form(".Digits%d.root",file));
+    }
+
+    TFile* file0 = TFile::Open(filename.Data());
+
+    TTree* treeD = (TTree*)file0->Get(Form("Event%d/TreeD",ievent));
+    if (treeD)  return treeD;
+  }
+  return 0;
+}  
+    
+void digitsEMCAL(Int_t nevents, Int_t nfiles) {
+
+  TH1F *hadc     = new TH1F("hadc","EMCAL digit",200, -10., 200.);
+  TH1F *hadclog     = new TH1F("hadclog","EMCAL digit",200, 0.5, 3.);
+  
+    TTree *treeD=0x0;
+  
+    TClonesArray *digits =0x0;
+  
+    for (Int_t event=0; event<nevents; event++) {
+      cout << "Event " << event << endl;
+
+      treeD = GetTreeD(event, "EMCAL", nfiles);
+      if ( ! treeD ) {
+        cerr << "Event directory not found in " << nfiles <<  " files" << endl;
+        exit(1);
+      }      
+
+      digits = NULL;
+      treeD->SetBranchAddress("EMCAL", &digits);
+
+      for(Int_t iev=0; iev<treeD->GetEntries(); iev++){
+       treeD->GetEntry(iev);
+
+      
+       for (Int_t j = 0; j < digits->GetEntries(); j++) {
+         AliDigitNew* dig = dynamic_cast<AliDigitNew*> (digits->At(j));
+         hadc->Fill(dig->GetAmp());
+         if(dig->GetAmp()>0)hadclog->Fill(TMath::Log10(dig->GetAmp()));
+       }
+
+      }
+    }
+
+   TFile fc("digits.EMCAL.root","RECREATE");
+   fc.cd();
+   
+   hadc->Write();
+   hadclog->Write();
+
+   fc.Close();
+}
+
+
+
+
+
+
+
diff --git a/test/vmctest/scripts/digitsHMPID.C b/test/vmctest/scripts/digitsHMPID.C
new file mode 100644 (file)
index 0000000..0e39c2c
--- /dev/null
@@ -0,0 +1,89 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Macro to generate histograms from digits
+// By E. Sicking, CERN
+
+TTree* GetTreeD(Int_t ievent, const TString& detName, Int_t nfiles) 
+{
+  for (Int_t file =0; file<nfiles; file++) {
+    TString filename(detName);
+    if ( file == 0 ) {
+      filename += ".Digits.root";
+    }  
+    else { 
+      filename += TString(Form(".Digits%d.root",file));
+    }
+
+    TFile* file0 = TFile::Open(filename.Data());
+
+    TTree* treeD = (TTree*)file0->Get(Form("Event%d/TreeD",ievent));
+    if (treeD)  return treeD;
+  }
+  return 0;
+}  
+    
+void digitsHMPID(Int_t nevents, Int_t nfiles){
+
+
+  TH1F *hadc     = new TH1F("hadc","HMPID digit",200, -100., 3000.);
+  TH1F *hadclog     = new TH1F("hadclog","HMPID digit",200, -0., 4.);
+  
+    TTree *treeD=0x0;
+  
+    TClonesArray *digits =0x0;
+  
+    for (Int_t event=0; event<nevents; event++) {
+      cout << "Event " << event << endl;
+
+      treeD = GetTreeD(event, "HMPID", nfiles);
+      if ( ! treeD ) {
+        cerr << "Event directory not found in " << nfiles <<  " files" << endl;
+        exit(1);
+      }      
+
+      digits = NULL;
+      treeD->SetBranchAddress("HMPID4", &digits);
+
+      for(Int_t iev=0; iev<treeD->GetEntries(); iev++){
+       treeD->GetEntry(iev);
+
+      
+       for (Int_t j = 0; j < digits->GetEntries(); j++) {
+         AliHMPIDDigit* dig = dynamic_cast<AliHMPIDDigit*> (digits->At(j));
+         hadc->Fill(dig->Q());
+         if(dig->Q()>0.)hadclog->Fill(TMath::Log10(dig->Q()));
+       }
+      }
+    }
+
+   TFile fc("digits.HMPID.root","RECREATE");
+   fc.cd();
+   
+   hadc->Write();
+   hadclog->Write();
+
+   fc.Close();
+
+}
+
+
+
+
+
+
+
diff --git a/test/vmctest/scripts/digitsPHOS.C b/test/vmctest/scripts/digitsPHOS.C
new file mode 100644 (file)
index 0000000..16ac5f6
--- /dev/null
@@ -0,0 +1,58 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Macro to generate histograms from digits
+// By E. Sicking, CERN
+
+
+void digitsPHOS(Int_t nevents, Int_t nfiles)
+{
+
+ TH1F * hadc = new TH1F ("hadc", "hadc", 100, -10, 200);
+ TH1F * hadcLog = new TH1F ("hadclog", "hadclog", 100, -2, 4);
+ AliRunLoader* runLoader = AliRunLoader::Open("galice.root","Event","READ");
+ AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(runLoader->GetLoader("PHOSLoader"));
+ for (Int_t ievent=0; ievent <nevents; ievent++) {
+  // for (Int_t ievent = 0; ievent < runLoader->GetNumberOfEvents(); ievent++) {
+   runLoader->GetEvent(ievent) ;
+   phosLoader->CleanDigits() ; 
+   phosLoader->LoadDigits("READ") ;
+   TClonesArray * digits    = phosLoader->Digits() ;
+   printf("Event %d contains %d digits\n",ievent,digits->GetEntriesFast());
+   
+   
+   for (Int_t j = 0; j < digits->GetEntries(); j++) {
+     
+     AliPHOSDigit* dig = dynamic_cast<AliPHOSDigit*> (digits->At(j));
+     //cout << dig->GetEnergy() << endl;
+     hadc->Fill(dig->GetEnergy());
+     if(dig->GetEnergy()>0)
+       hadcLog->Fill(TMath::Log10(dig->GetEnergy()));
+     
+   }
+   
+ }
+ TFile fc("digits.PHOS.root","RECREATE");
+ fc.cd();
+ hadc->Write();
+ hadcLog->Write();
+ fc.Close();
+
+
+}
diff --git a/test/vmctest/scripts/digitsSDD.C b/test/vmctest/scripts/digitsSDD.C
new file mode 100644 (file)
index 0000000..9f97702
--- /dev/null
@@ -0,0 +1,118 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Macro to generate histograms from digits
+// By E. Sicking, CERN
+
+TDirectoryFile* GetDirectory(Int_t ievent, const TString& detName, Int_t nfiles) 
+{
+  for (Int_t file =0; file<nfiles; file++) {
+    TString filename(detName);
+    if ( file == 0 ) {
+      filename += ".Digits.root";
+    }  
+    else { 
+      filename += TString(Form(".Digits%d.root",file));
+    }
+
+    TFile* file0 = TFile::Open(filename.Data());
+
+    TDirectoryFile* dir = (TDirectoryFile*)file0->Get(Form("Event%d",ievent));
+    if (dir)  return dir;
+  }
+  return 0;
+}  
+    
+void digitsSDD(Int_t nevents, Int_t nfiles)
+{
+
+  TH1F * hadc = new TH1F ("hadc", "hadc",200, 0, 1300);   
+  TH1F * hadclog = new TH1F ("hadclog", "hadclog",200, 1, 3.5);   
+
+  TDirectoryFile *tdf[100];     
+  TDirectoryFile *tdfKine[100] ;
+
+  TTree *ttree[100];     
+  TTree *ttreeKine[100]; 
+
+  TClonesArray *arr= NULL; // 
+  //Run loader------------
+  TString name;
+  name = "galice.root";
+  AliRunLoader* rlSig = AliRunLoader::Open(name.Data());
+
+  // gAlice
+  rlSig->LoadgAlice();
+  gAlice = rlSig->GetAliRun();
+
+  // Now load kinematics and event header
+  rlSig->LoadKinematics();
+  rlSig->LoadHeader();
+  cout <<  rlSig->GetNumberOfEvents()<< endl;
+  //----------------------
+
+  
+  //loop over events in the files
+  for(Int_t event=0; event<nevents; event++){
+    printf("###event= %d\n", event);
+
+    tdf[event] = GetDirectory(event, "ITS", nfiles);
+    if ( ! tdf[event] ) {
+      cerr << "Event directory not found in " << nfiles <<  " files" << endl;
+      exit(1);
+    }      
+    
+    ttree[event] = (TTree*)tdf[event]->Get("TreeD");
+          
+    arr = NULL;
+    ttree[event]->SetBranchAddress("ITSDigitsSDD", &arr);
+
+    rlSig->GetEvent(event);
+    AliStack * stack = rlSig->Stack(); 
+   
+
+
+    // loop over tracks
+    Int_t NumberPrim=0;
+    for(Int_t iev=0; iev<ttree[event]->GetEntries(); iev++){
+      ttree[event]->GetEntry(iev);
+  
+       
+      for (Int_t j = 0; j < arr->GetEntries(); j++) {
+       AliITSdigit* digit = dynamic_cast<AliITSdigit*> (arr->At(j));
+       if (digit){
+         Int_t label = digit->GetHits();
+        
+         hadc->Fill(digit->GetSignal());
+         hadclog->Fill(TMath::Log10(digit->GetSignal()));
+
+       }
+      }
+    }
+
+  }
+  
+  TFile fc("digits.ITS.SDD.root","RECREATE");
+  fc.cd();
+   
+  hadc->Write();
+  hadclog->Write();
+
+  fc.Close();
+
+}
diff --git a/test/vmctest/scripts/digitsSPD.C b/test/vmctest/scripts/digitsSPD.C
new file mode 100644 (file)
index 0000000..54e8eed
--- /dev/null
@@ -0,0 +1,120 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Macro to generate histograms from digits
+// By E. Sicking, CERN
+
+TDirectoryFile* GetDirectory(Int_t ievent, const TString& detName, Int_t nfiles) 
+{
+  for (Int_t file =0; file<nfiles; file++) {
+    TString filename(detName);
+    if ( file == 0 ) {
+      filename += ".Digits.root";
+    }  
+    else { 
+      filename += TString(Form(".Digits%d.root",file));
+    }
+
+    TFile* file0 = TFile::Open(filename.Data());
+
+    TDirectoryFile* dir = (TDirectoryFile*)file0->Get(Form("Event%d",ievent));
+    if (dir)  return dir;
+  }
+  return 0;
+}  
+    
+void digitsSPD(Int_t nevents, Int_t nfiles)
+{
+
+  TH1F * hadc = new TH1F ("hadc", "hadc",100, 0, 2);   
+  TH1F * hadclog = new TH1F ("hadclog", "hadclog",100, -1, 1);   
+
+  TDirectoryFile *tdf[100];      
+  TDirectoryFile *tdfKine[100] ; 
+
+  TTree *ttree[100];      
+  TTree *ttreeKine[100];  
+
+
+  TClonesArray *arr= NULL; // 
+
+  //Run loader------------
+  TString name;
+  name = "galice.root";
+  AliRunLoader* rlSig = AliRunLoader::Open(name.Data());
+
+  // gAlice
+  rlSig->LoadgAlice();
+  gAlice = rlSig->GetAliRun();
+
+  // Now load kinematics and event header
+  rlSig->LoadKinematics();
+  rlSig->LoadHeader();
+  cout <<  rlSig->GetNumberOfEvents()<< endl;
+  //----------------------
+
+  
+     //loop over events in the files
+    for(Int_t event=0; event<nevents; event++){
+      //printf("###event= %d\n", event + file*100);
+      printf("###event= %d\n", event);
+
+    tdf[event] = GetDirectory(event, "ITS", nfiles);
+    if ( ! tdf[event] ) {
+      cerr << "Event directory not found in " << nfiles <<  " files" << endl;
+      exit(1);
+    }      
+    
+      ttree[event] = (TTree*)tdf[event]->Get("TreeD");
+          
+      arr = NULL;
+      ttree[event]->SetBranchAddress("ITSDigitsSPD", &arr);
+   
+
+      // Runloader -> gives particle Stack
+      rlSig->GetEvent(event);
+      AliStack * stack = rlSig->Stack(); 
+      //stack->DumpPStack();
+
+
+      // loop over tracks
+      Int_t NumberPrim=0;
+      for(Int_t iev=0; iev<ttree[event]->GetEntries(); iev++){
+       ttree[event]->GetEntry(iev);
+
+       
+       for (Int_t j = 0; j < arr->GetEntries(); j++) {
+         AliITSdigit* digit = dynamic_cast<AliITSdigit*> (arr->At(j));
+         if (digit){
+           hadc->Fill(digit->GetSignal());
+           hadclog->Fill(TMath::Log10(digit->GetSignal()));
+       
+         }
+       }
+      }
+
+    }
+
+  TFile fc("digits.ITS.SPD.root","RECREATE");
+  fc.cd();
+   
+  hadc->Write();
+  hadclog->Write();
+
+  fc.Close();
+
+}
diff --git a/test/vmctest/scripts/digitsSSD.C b/test/vmctest/scripts/digitsSSD.C
new file mode 100644 (file)
index 0000000..bd7ebdc
--- /dev/null
@@ -0,0 +1,124 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Macro to generate histograms from digits
+// By E. Sicking, CERN
+
+TDirectoryFile* GetDirectory(Int_t ievent, const TString& detName, Int_t nfiles) 
+{
+  for (Int_t file =0; file<nfiles; file++) {
+    TString filename(detName);
+    if ( file == 0 ) {
+      filename += ".Digits.root";
+    }  
+    else { 
+      filename += TString(Form(".Digits%d.root",file));
+    }
+
+    TFile* file0 = TFile::Open(filename.Data());
+
+    TDirectoryFile* dir = (TDirectoryFile*)file0->Get(Form("Event%d",ievent));
+    if (dir)  return dir;
+  }
+  return 0;
+}  
+    
+void digitsSSD(Int_t nevents, Int_t nfiles)
+{
+
+  TH1F * hadc = new TH1F ("hadc", "hadc",200, 0, 4500);   
+  TH1F * hadclog = new TH1F ("hadclog", "hadclog",200, -1, 4);   
+
+  TDirectoryFile *tdf[100];     
+  TDirectoryFile *tdfKine[100] ;
+
+  TTree *ttree[100];     
+  TTree *ttreeKine[100]; 
+
+
+  TClonesArray *arr= NULL; // 
+  
+
+
+  //Run loader------------
+  TString name;
+  name = "galice.root";
+  AliRunLoader* rlSig = AliRunLoader::Open(name.Data());
+
+  // gAlice
+  rlSig->LoadgAlice();
+  gAlice = rlSig->GetAliRun();
+
+  // Now load kinematics and event header
+  rlSig->LoadKinematics();
+  rlSig->LoadHeader();
+  cout <<  rlSig->GetNumberOfEvents()<< endl;
+  //----------------------
+
+    //loop over events in the files
+    for(Int_t event=0; event<nevents; event++){
+      //printf("###event= %d\n", event +file*100);
+      printf("###event= %d\n", event);
+
+      // tdf[event] = (TDirectoryFile*)file0->Get(Form("Event%d",event+file*100));
+    tdf[event] = GetDirectory(event, "ITS", nfiles);
+    if ( ! tdf[event] ) {
+      cerr << "Event directory not found in " << nfiles <<  " files" << endl;
+      exit(1);
+    }      
+
+      ttree[event] = (TTree*)tdf[event]->Get("TreeD");
+          
+      arr = NULL;
+      ttree[event]->SetBranchAddress("ITSDigitsSSD", &arr);
+   
+
+      // Runloader -> gives particle Stack
+      rlSig->GetEvent(event);
+      AliStack * stack = rlSig->Stack(); 
+      //stack->DumpPStack();
+
+
+      // loop over tracks
+      Int_t NumberPrim=0;
+      for(Int_t iev=0; iev<ttree[event]->GetEntries(); iev++){
+       ttree[event]->GetEntry(iev);
+
+       
+       for (Int_t j = 0; j < arr->GetEntries(); j++) {
+         AliITSdigit* digit = dynamic_cast<AliITSdigit*> (arr->At(j));
+         if (digit){
+
+           hadc->Fill(digit->GetSignal());
+           hadclog->Fill(TMath::Log10(digit->GetSignal()));
+         }
+       }
+      }
+
+
+
+    }
+  
+  TFile fc("digits.ITS.SSD.root","RECREATE");
+  fc.cd();
+   
+  hadc->Write();
+  hadclog->Write();
+
+  fc.Close();
+
+}
diff --git a/test/vmctest/scripts/digitsTOF.C b/test/vmctest/scripts/digitsTOF.C
new file mode 100644 (file)
index 0000000..fedd946
--- /dev/null
@@ -0,0 +1,89 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Macro to generate histograms from digits
+// By E. Sicking, CERN
+
+TTree* GetTreeD(Int_t ievent, const TString& detName, Int_t nfiles) 
+{
+  for (Int_t file =0; file<nfiles; file++) {
+    TString filename(detName);
+    if ( file == 0 ) {
+      filename += ".Digits.root";
+    }  
+    else { 
+      filename += TString(Form(".Digits%d.root",file));
+    }
+
+    TFile* file0 = TFile::Open(filename.Data());
+
+    TTree* treeD = (TTree*)file0->Get(Form("Event%d/TreeD",ievent));
+    if (treeD)  return treeD;
+  }
+  return 0;
+}  
+    
+void digitsTOF(Int_t nevents, Int_t nfiles){
+
+
+  TH1F *hadc     = new TH1F("hadc","ADC [bin]",200, -100., 10000.);
+  TH1F *hadclog     = new TH1F("hadclog","ADC [bin]",200, -1., 7.);
+  
+    TTree *treeD=0x0;
+  
+    TClonesArray *digits =0x0;
+  
+    for (Int_t event=0; event<nevents; event++) {
+      cout << "Event " << event << endl;
+
+      treeD = GetTreeD(event, "TOF", nfiles);
+      if ( ! treeD ) {
+        cerr << "Event directory not found in " << nfiles <<  " files" << endl;
+        exit(1);
+      }      
+
+      digits = NULL;
+      treeD->SetBranchAddress("TOF", &digits);
+
+      for(Int_t iev=0; iev<treeD->GetEntries(); iev++){
+       treeD->GetEntry(iev);
+
+       for (Int_t j = 0; j < digits->GetEntries(); j++) {
+         AliTOFdigit* dig = dynamic_cast<AliTOFdigit*> (digits->At(j));
+         hadc->Fill(dig->GetAdc());
+         if(dig->GetAdc()>0)hadclog->Fill(TMath::Log10(dig->GetAdc()));
+       }
+
+      }
+    }
+
+   TFile fc("digits.TOF.root","RECREATE");
+   fc.cd();
+   
+   hadc->Write();
+   hadclog->Write();
+
+   fc.Close();
+
+}
+
+
+
+
+
+
+
diff --git a/test/vmctest/scripts/digitsTPC.C b/test/vmctest/scripts/digitsTPC.C
new file mode 100644 (file)
index 0000000..47c0c93
--- /dev/null
@@ -0,0 +1,154 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Macro to generate histograms from digits
+// By E. Sicking, CERN
+
+TDirectoryFile* GetDirectory(Int_t ievent, const TString& detName, Int_t nfiles) 
+{
+  for (Int_t file =0; file<nfiles; file++) {
+    TString filename(detName);
+    if ( file == 0 ) {
+      filename += ".Digits.root";
+    }  
+    else { 
+      filename += TString(Form(".Digits%d.root",file));
+    }
+
+    TFile* file0 = TFile::Open(filename.Data());
+
+    TDirectoryFile* dir = (TDirectoryFile*)file0->Get(Form("Event%d",ievent));
+    if (dir)  return dir;
+  }
+  return 0;
+}  
+    
+void digitsTPC(Int_t nevents, Int_t nfiles)
+{
+
+  TH1F * hadclog = new TH1F ("hadclog", "hadclog",100, -1,3.5 );
+  TH1F * hadc = new TH1F ("hadc", "hadc",200, -100,1100 );
+
+  TH1F * hRow = new TH1F ("hRow", "hRow",120, -100, 1100);
+  TH1F * hCol = new TH1F ("hCol", "hCol",100, -5, 194);
+  TH1F * hndig = new TH1F ("hndig", "hndig",120, -100000, 100000);
+  TH1F * hSize = new TH1F ("hSize", "hSize",100, 1000, 5000);
+
+
+  TDirectoryFile *tdf[100];     
+  TDirectoryFile *tdfKine[100] ;
+
+  TTree *ttree[100];      
+  TTree *ttreeKine[100];  
+
+  AliSimDigits *digits= NULL;  
+
+
+  Int_t numberhits=0;
+
+
+  //Run loader------------
+  TString name;
+  name = "galice.root";
+  AliRunLoader* rlSig = AliRunLoader::Open(name.Data());
+
+  // gAlice
+  rlSig->LoadgAlice();
+  gAlice = rlSig->GetAliRun();
+
+  // Now load kinematics and event header
+  rlSig->LoadKinematics();
+  rlSig->LoadHeader();
+  cout <<  rlSig->GetNumberOfEvents()<< endl;
+  //----------------------
+
+    //loop over events in the files
+    for(Int_t event=0; event<nevents; event++){
+      printf("###event= %d\n", event);
+
+    tdf[event] = GetDirectory(event, "TPC", nfiles);
+    if ( ! tdf[event] ) {
+      cerr << "Event directory not found in " << nfiles <<  " files" << endl;
+      exit(1);
+    }      
+
+      ttree[event] = (TTree*)tdf[event]->Get("TreeD");
+          
+      digits = NULL;
+      ttree[event]->SetBranchAddress("Segment", &digits);
+
+      // Runloader -> gives particle Stack
+      rlSig->GetEvent(event);
+      AliStack * stack = rlSig->Stack(); 
+      //stack->DumpPStack();
+
+      Short_t digitValue=0;
+      Int_t iRow=0;
+      Int_t iColumn=0;
+      Short_t ndig =0;
+      Int_t digSize =0;
+
+      // loop over tracks
+      for(Int_t iev=0; iev<ttree[event]->GetEntries(); iev++){
+       ttree[event]->GetEntry(iev);
+       digits->First();    
+       
+       iRow=digits->CurrentRow();
+       digitValue = digits->CurrentDigit();
+       iColumn=digits->CurrentColumn();
+       ndig=digits->GetDigits();
+       digSize=digits->GetDigitSize();
+
+       if(digitValue>0.)hadclog->Fill(TMath::Log10(digitValue));
+       hadc->Fill(digitValue);
+       hRow->Fill(iRow);
+       hCol->Fill(iColumn);
+       hndig->Fill(ndig);
+       hSize->Fill(digSize);
+
+       while (digits->Next()){
+
+         digitValue = digits->CurrentDigit();
+         iRow=digits->CurrentRow();
+         iColumn=digits->CurrentColumn();
+         ndig=digits->GetDigits();
+         digSize=digits->GetDigitSize();
+         
+         if(digitValue>0.)hadclog->Fill(TMath::Log10(digitValue));
+         hadc->Fill(digitValue);
+         hRow->Fill(iRow);
+         hCol->Fill(iColumn);
+         hndig->Fill(ndig);
+         hSize->Fill(digSize);
+         //cout << digSize << endl;
+       }
+      }
+    }
+  
+   TFile fc("digits.TPC.root","RECREATE");
+   fc.cd();
+
+   hadclog->Write();
+   hadc->Write();
+   hRow->Write();
+   hCol->Write();
+   hndig->Write();
+   hSize->Write();
+
+   fc.Close();
+
+}
diff --git a/test/vmctest/scripts/digitsTRD.C b/test/vmctest/scripts/digitsTRD.C
new file mode 100644 (file)
index 0000000..0a89bc5
--- /dev/null
@@ -0,0 +1,113 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Macro to generate histograms from digits
+// By E. Sicking, CERN
+
+TTree* GetTreeD(Int_t ievent, const TString& detName, Int_t nfiles) 
+{
+  for (Int_t file =0; file<nfiles; file++) {
+    TString filename(detName);
+    if ( file == 0 ) {
+      filename += ".Digits.root";
+    }  
+    else { 
+      filename += TString(Form(".Digits%d.root",file));
+    }
+
+    TFile* file0 = TFile::Open(filename.Data());
+
+    TTree* treeD = (TTree*)file0->Get(Form("Event%d/TreeD",ievent));
+    if (treeD)  return treeD;
+  }
+  return 0;
+}  
+    
+void digitsTRD(Int_t nevents, Int_t nfiles)
+{
+
+
+  TH1F * hadc = new TH1F("hadc", "hadc", 260, -99, 1200);
+  TH1F * hadcLow = new TH1F("hadcLow", "hadcLow", 100, -5, 5);
+
+  TH1F * hadclog = new TH1F("hadclog", "hadclog", 100, -1, 4);
+
+    TTree *treeD=0x0;
+    AliTRDdigitsManager manD;
+
+    for (Int_t event=0; event<nevents; event++) {
+      cout << "Event " << event << endl;
+  
+      treeD = GetTreeD(event, "TRD", nfiles);
+      if ( ! treeD ) {
+        cerr << "Event directory not found in " << nfiles <<  " files" << endl;
+        exit(1);
+      }      
+      manD.ReadDigits(treeD);
+    
+      AliTRDarrayADC *digitsD = 0;
+
+    
+      Int_t maxDet = 540;
+      Int_t rowMax  = 0;
+      Int_t colMax  = 0;
+      Int_t timeMax = 0;
+      Double_t signal=0;
+
+      for (Int_t idet = 0; idet<maxDet; idet++)
+       {
+         digitsD = manD.GetDigits(idet);
+         digitsD->Expand();
+       
+         rowMax = digitsD->GetNrow();
+         colMax = digitsD->GetNcol();
+         timeMax = digitsD->GetNtime();        
+       
+         //cout << "Detector " << idet << endl;
+         cout << "\r Detector " << idet; cout.flush();
+       
+         for (Int_t irow = 0; irow < rowMax; irow++)
+           {
+             for (Int_t icol = 0; icol < colMax; icol++)
+               {
+                 for (Int_t itime = 0; itime < timeMax; itime++)
+                   {
+                   
+                     signal= digitsD->GetData(irow, icol, itime);
+
+                     hadc-> Fill(signal);
+                     hadcLow-> Fill(signal);
+                     if(signal>0.) hadclog-> Fill(TMath::Log10(signal));
+                   
+                   
+                   
+                   } //time
+               } //col
+           } //row
+       }//detector chamber
+      cout << "\n \r Event " << event << endl;
+    }//event
+  
+  TFile fc("digits.TRD.root","RECREATE");
+  fc.cd();
+  hadcLow->Write();
+  hadc->Write();
+  hadclog->Write();
+
+  fc.Close();
+
+}
diff --git a/test/vmctest/scripts/plotDigits.C b/test/vmctest/scripts/plotDigits.C
new file mode 100644 (file)
index 0000000..ef66d7c
--- /dev/null
@@ -0,0 +1,187 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+// Macro to process the files with histograms generated by 
+// digitsDET.C macros for all included detectors and to produce plots 
+// with histograms. 
+// The histogram files are aerched in the directories,
+// which names are specified in label[] array;
+// the labels will be then used at the histogram titles.
+// 
+// By E. Sicking, CERN; I. Hrivnacova, IPN Orsay
+
+void plotDetDigits(string a = "ITS", string b = "")
+{
+  string label[10];
+  string histoName[10];
+  string histoTitle[10];
+  TFile* file[10];
+  Int_t color[10];
+  TH1F* histo[10][10];
+
+  // Fill values by hand
+  //
+  Int_t ndirs = 3;  
+  Int_t nhistos = 2;
+
+  // Histogram labels (per directory)
+  label[0] = "g3";    
+  label[1] = "g4_sc";
+  label[2] = "g4";
+
+  // Histogram names & title (per histogram)
+  histoName[0] = "hadc"; 
+  histoName[1] = "hadclog"; 
+  histoTitle[0] = "Number of ADC in "; 
+  histoTitle[1] = "Log_{10}(Number of ADC in "; 
+  
+  // The histogram colors (per directory)
+  color[0] = kBlack;
+  color[1] = kRed;
+  color[2] = kBlue;
+  //
+  // end hand made definitions
+  
+  // generate detname
+  string detname = a;
+  if ( b.size() > 0 ) { 
+    detname.append(".");
+    detname.append(b);
+  }
+
+  cout << "Processing " << detname << " ... " << endl;
+  // generate filename
+  string filename = "digits.";
+  filename.append(detname);
+  filename.append(".root");
+  
+  // label for all histos
+  string labelall;
+  for ( Int_t i=0; i<ndirs; i++ ) {
+    labelall.append(label[i]);
+    if (i<ndirs-1) labelall.append("+");
+  }  
+
+  // open files
+  for ( Int_t i=0; i<ndirs; i++ ) {
+    string filepath = label[i];
+    filepath.append("/");
+    filepath.append(filename);
+    file[i] = TFile::Open(filepath.data());
+    if ( ! file[i] ) { 
+      cerr << "Cannot open " << file[i] << endl;
+    }  
+  }  
+
+  double scale=1.5;
+
+  //extract histograms
+  for ( Int_t j=0; j<nhistos; j++ ) {
+    for ( Int_t i=0; i<ndirs; i++ ) {
+      histo[i][j] = (TH1F *)file[i]->Get(histoName[j].data());
+      if ( ! histo[i][j] ) {
+        histo[i][j] = (TH1F *)file[i]->Get("hadcLog");
+      }  
+      //histo[i][j]->SetLineWidth(3);
+      //histo[i][j]->SetLineStyle(3+i);
+      histo[i][j]->SetLineColor(color[i]);
+      //histo[i][j]->Sumw2();
+    }
+  }  
+
+  // style & legend
+  gROOT->SetStyle("Plain");
+  //gStyle->SetOptStat(0);
+
+  // ???
+  TLegend *legp;
+  TF1 *fun1p;
+  TF1 *fun2p;
+  TF1 *fun3p;
+  legp= new TLegend(0.9,0.75,0.7,0.9);
+  fun1p= new TF1("fun1p","gaus",-5.0,5.0);
+  fun2p= new TF1("fun2p","gaus",-5.0,5.0);
+  fun3p= new TF1("fun3p","gaus",-5.0,5.0);
+  fun1p->SetLineColor(kBlue);
+  fun2p->SetLineColor(kRed);
+  fun2p->SetLineStyle(2);
+  fun3p->SetLineColor(kBlack);
+  fun3p->SetLineStyle(3);
+  legp->SetFillColor(kWhite);
+  legp->AddEntry(fun1p,"Geant3","l");   
+  legp->AddEntry(fun2p,"Geant4","l"); 
+  legp->AddEntry(fun3p,"Fluka","l"); 
+  
+  //Draw
+  TCanvas* c1 
+    = new TCanvas (detname.data(), detname.data(), 100, 100, 1000,1560);
+  c1->Divide(nhistos, ndirs+1 );
+  // All plots
+  Int_t counter = 0;
+  for ( Int_t j=0; j<nhistos ; ++j ) {
+    c1->cd(++counter);
+    for ( Int_t i=0; i<ndirs; i++ ) {
+      histo[i][j]->SetTitle(labelall.data());
+      string xtitle = histoTitle[j];
+      xtitle.append(detname);
+      histo[i][j]->SetXTitle(xtitle.data());
+      string option("");
+      if ( i>0 ) option = "same";
+      histo[i][j]->Draw(option.data());
+      histo[i][j]->SetMaximum(histo[i][j]->GetMaximum()*scale);
+      //histo[i][j]->Sumw2();
+      gPad->SetLogy();
+      //legp->Draw();
+    } 
+  }   
+
+  // Plots per case
+  for ( Int_t i=0; i<ndirs; i++ ) {
+    for ( Int_t j=0; j<nhistos ; ++j ) {
+      c1->cd(++counter);
+      // gPad->SetLeftMargin(0.15);
+      // gPad->SetBottomMargin(0.15);
+      histo[i][j]->SetTitle(label[i].data());
+      string xtitle = histoTitle[j];
+      xtitle.append(detname);
+      histo[i][j]->SetXTitle(xtitle.data());
+      histo[i][j]->Draw("");
+      histo[i][j]->SetMaximum(histo[i][j]->GetMaximum()*scale);
+      //histo[i][j]->Sumw2();
+      gPad->SetLogy();
+     //legp->Draw();
+    } 
+  }   
+  
+  string outName = detname;
+  outName += ".gif";
+  c1->SaveAs(outName.data());
+}
+
+void plotDigits() {
+  plotDetDigits("ITS","SDD");
+  plotDetDigits("ITS","SPD");
+  plotDetDigits("ITS","SSD");
+  plotDetDigits("TPC");
+  plotDetDigits("TRD");
+  plotDetDigits("TOF");
+  plotDetDigits("EMCAL");
+  plotDetDigits("HMPID");
+  plotDetDigits("PHOS");
+}