]> git.uio.no Git - u/mrichter/AliRoot.git/blob - test/vmctest/scripts/digitsEMCAL.C
Update master to aliroot
[u/mrichter/AliRoot.git] / test / vmctest / scripts / digitsEMCAL.C
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // $Id$
17
18 // Macro to generate histograms from digits
19 // By E. Sicking, CERN
20
21 TTree* GetTreeD(Int_t ievent, const TString& detName, Int_t nfiles) 
22 {
23   for (Int_t file =0; file<nfiles; file++) {
24     TString filename(detName);
25     if ( file == 0 ) {
26       filename += ".Digits.root";
27     }  
28     else { 
29       filename += TString(Form(".Digits%d.root",file));
30     }
31
32     TFile* file0 = TFile::Open(filename.Data());
33
34     TTree* treeD = (TTree*)file0->Get(Form("Event%d/TreeD",ievent));
35     if (treeD)  return treeD;
36   }
37   return 0;
38 }  
39     
40 void digitsEMCAL(Int_t nevents, Int_t nfiles) {
41
42   TH1F *hadc     = new TH1F("hadc","EMCAL digit",200, -10., 200.);
43   TH1F *hadclog     = new TH1F("hadclog","EMCAL digit",200, 0.5, 3.);
44   
45     TTree *treeD=0x0;
46   
47     TClonesArray *digits =0x0;
48   
49     for (Int_t event=0; event<nevents; event++) {
50       cout << "Event " << event << endl;
51
52       treeD = GetTreeD(event, "EMCAL", nfiles);
53       if ( ! treeD ) {
54         cerr << "Event directory not found in " << nfiles <<  " files" << endl;
55         exit(1);
56       }      
57
58       digits = NULL;
59       treeD->SetBranchAddress("EMCAL", &digits);
60
61       for(Int_t iev=0; iev<treeD->GetEntries(); iev++){
62         treeD->GetEntry(iev);
63
64       
65         for (Int_t j = 0; j < digits->GetEntries(); j++) {
66           AliDigitNew* dig = dynamic_cast<AliDigitNew*> (digits->At(j));
67           hadc->Fill(dig->GetAmp());
68           if(dig->GetAmp()>0)hadclog->Fill(TMath::Log10(dig->GetAmp()));
69         }
70
71       }
72     }
73
74    TFile fc("digits.EMCAL.root","RECREATE");
75    fc.cd();
76    
77    hadc->Write();
78    hadclog->Write();
79
80    fc.Close();
81 }
82
83
84
85
86
87
88