]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDanalyzeDigits.C
correct access to digits in SetBit()
[u/mrichter/AliRoot.git] / TRD / AliTRDanalyzeDigits.C
1 Int_t AliTRDanalyzeDigits()
2 {
3   //
4   // Analyzes the digits
5   //
6
7   Int_t rc = 0;
8
9   if (!gAlice) {
10     cout << "<AliTRDanalyzeDigits> No AliRun object found" << endl;
11     rc = 1;
12     return rc;
13   }
14   gAlice->GetEvent(0);
15
16   // Get the pointer to the TRD detector 
17   AliTRD *TRD = (AliTRD *) gAlice->GetDetector("TRD");
18   if (!TRD) {
19     cout << "<AliTRDanalyzeDigits> No TRD detector found" << endl;
20     rc = 2;
21     return rc;
22   }
23
24   // Define the histograms
25   TH1F *hAmp = new TH1F("hAmp","Amplitude of the digits",256,-0.5,255.5);
26
27   // Get the pointer to the geometry object
28   AliTRDgeometry *TRDgeometry;
29   if (TRD) {
30     TRDgeometry = TRD->GetGeometry();
31   }
32   else {
33     cout << "<AliTRDanalyzeDigits> No TRD geometry found" << endl;
34     rc = 3;
35     return rc;
36   }
37
38   // Create the digits manager
39   AliTRDdigitsManager *DigitsManager = new AliTRDdigitsManager();
40
41   // Read the digits from the file
42   if (!(DigitsManager->ReadDigits())) {
43     cout << "<AliTRDanalyzeDigits> Cannot read the digits" << endl;
44     rc = 4;
45     return rc;
46   }
47   
48   // Define the detector matrix for one chamber
49   Int_t iSec = TRD->GetSensSector();
50   Int_t iCha = TRD->GetSensChamber();
51   Int_t iPla = 0;
52   Int_t  rowMax = TRDgeometry->GetRowMax(iPla,iCha,iSec);
53   Int_t  colMax = TRDgeometry->GetColMax(iPla);
54   Int_t timeMax = TRDgeometry->GetTimeMax();
55   cout << "<AliTRDanalyzeDigits> Geometry: rowMax = "  <<  rowMax
56                                       << " colMax = "  <<  colMax
57                                       << " timeMax = " << timeMax << endl;
58   AliTRDmatrix *TRDmatrix = new AliTRDmatrix(rowMax,colMax,timeMax,iSec,iCha,iPla);
59   // Get the detector number
60   Int_t iDet = TRDgeometry->GetDetector(iPla,iCha,iSec);
61   cout << "<AliTRDanalyzeDigits> iSec = " << iSec
62                             << " iCha = " << iCha 
63                             << " iPla = " << iPla 
64                             << " iDet = " << iDet << endl;
65
66   // Loop through the detector pixel
67   Int_t countDigits = 0;
68   for (Int_t time = 0; time < timeMax; time++) {
69     for (Int_t  col = 0;  col <  colMax;  col++) {
70       for (Int_t  row = 0;  row <  rowMax;  row++) {
71
72         AliTRDdigit *Digit = DigitsManager->GetDigit(row,col,time,iDet);
73         Int_t amp = Digit->GetAmp();
74
75         if (amp > 0) {
76           countDigits++;
77           hAmp->Fill(amp);
78           TRDmatrix->SetSignal(row,col,time,amp);
79         }
80
81         delete Digit;
82
83       }
84     }
85   }
86
87   cout << "<AliTRDanalyzeDigits> Found " << countDigits << " digits in total" << endl;
88
89   // Display the detector matrix
90   TRDmatrix->Draw();
91   TRDmatrix->ProjRow();
92   TRDmatrix->ProjCol();
93   TRDmatrix->ProjTime();
94
95   TCanvas *cDigits = new TCanvas("cDigits","AliTRDanalyzeDigits",50,50,600,600);
96   gPad->SetLogy();
97   hAmp->Draw();
98
99   return rc;
100
101 }