]> git.uio.no Git - u/mrichter/AliRoot.git/blob - test/vmctest/scripts/digitsTOF.C
Adding scripts directory including:
[u/mrichter/AliRoot.git] / test / vmctest / scripts / digitsTOF.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 digitsTOF(Int_t nevents, Int_t nfiles){
41
42
43   TH1F *hadc     = new TH1F("hadc","ADC [bin]",200, -100., 10000.);
44   TH1F *hadclog     = new TH1F("hadclog","ADC [bin]",200, -1., 7.);
45   
46     TTree *treeD=0x0;
47   
48     TClonesArray *digits =0x0;
49   
50     for (Int_t event=0; event<nevents; event++) {
51       cout << "Event " << event << endl;
52
53       treeD = GetTreeD(event, "TOF", nfiles);
54       if ( ! treeD ) {
55         cerr << "Event directory not found in " << nfiles <<  " files" << endl;
56         exit(1);
57       }      
58
59       digits = NULL;
60       treeD->SetBranchAddress("TOF", &digits);
61
62       for(Int_t iev=0; iev<treeD->GetEntries(); iev++){
63         treeD->GetEntry(iev);
64
65         for (Int_t j = 0; j < digits->GetEntries(); j++) {
66           AliTOFdigit* dig = dynamic_cast<AliTOFdigit*> (digits->At(j));
67           hadc->Fill(dig->GetAdc());
68           if(dig->GetAdc()>0)hadclog->Fill(TMath::Log10(dig->GetAdc()));
69         }
70
71       }
72     }
73
74    TFile fc("digits.TOF.root","RECREATE");
75    fc.cd();
76    
77    hadc->Write();
78    hadclog->Write();
79
80    fc.Close();
81
82 }
83
84
85
86
87
88
89