]> git.uio.no Git - u/mrichter/AliRoot.git/blame - test/vmctest/scripts/digitsTRD.C
Update master to aliroot
[u/mrichter/AliRoot.git] / test / vmctest / scripts / digitsTRD.C
CommitLineData
0866e534 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
21TTree* 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
40void digitsTRD(Int_t nevents, Int_t nfiles)
41{
42
43
44 TH1F * hadc = new TH1F("hadc", "hadc", 260, -99, 1200);
45 TH1F * hadcLow = new TH1F("hadcLow", "hadcLow", 100, -5, 5);
46
47 TH1F * hadclog = new TH1F("hadclog", "hadclog", 100, -1, 4);
48
49 TTree *treeD=0x0;
50 AliTRDdigitsManager manD;
51
52 for (Int_t event=0; event<nevents; event++) {
53 cout << "Event " << event << endl;
54
55 treeD = GetTreeD(event, "TRD", nfiles);
56 if ( ! treeD ) {
57 cerr << "Event directory not found in " << nfiles << " files" << endl;
58 exit(1);
59 }
60 manD.ReadDigits(treeD);
61
62 AliTRDarrayADC *digitsD = 0;
63
64
65 Int_t maxDet = 540;
66 Int_t rowMax = 0;
67 Int_t colMax = 0;
68 Int_t timeMax = 0;
69 Double_t signal=0;
70
71 for (Int_t idet = 0; idet<maxDet; idet++)
72 {
73 digitsD = manD.GetDigits(idet);
74 digitsD->Expand();
75
76 rowMax = digitsD->GetNrow();
77 colMax = digitsD->GetNcol();
78 timeMax = digitsD->GetNtime();
79
80 //cout << "Detector " << idet << endl;
81 cout << "\r Detector " << idet; cout.flush();
82
83 for (Int_t irow = 0; irow < rowMax; irow++)
84 {
85 for (Int_t icol = 0; icol < colMax; icol++)
86 {
87 for (Int_t itime = 0; itime < timeMax; itime++)
88 {
89
90 signal= digitsD->GetData(irow, icol, itime);
91
92 hadc-> Fill(signal);
93 hadcLow-> Fill(signal);
94 if(signal>0.) hadclog-> Fill(TMath::Log10(signal));
95
96
97
98 } //time
99 } //col
100 } //row
101 }//detector chamber
102 cout << "\n \r Event " << event << endl;
103 }//event
104
105 TFile fc("digits.TRD.root","RECREATE");
106 fc.cd();
107 hadcLow->Write();
108 hadc->Write();
109 hadclog->Write();
110
111 fc.Close();
112
113}