]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDRaw2Digits.C
New macro converting RAW to digits
[u/mrichter/AliRoot.git] / TRD / AliTRDRaw2Digits.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TH1.h>
3 #include <TCanvas.h>
4 #include "AliTRDrawData.h"
5 #include "AliTRDdigitsManager.h"
6 #include "AliTRDdigit.h"
7 #include "AliTRDgeometryFull.h"
8 #include "AliTRDparameter.h"
9 #include "AliTRDmatrix.h"
10 #include "AliRawReaderFile.h"
11 #include "AliRunLoader.h"
12 #endif
13
14 void AliTRDRaw2Digits(Int_t iEvent = 0, Int_t iDet = 0)
15 {
16
17   AliTRDrawData *raw = new AliTRDrawData();
18   raw->SetDebug(1);
19   AliRawReaderFile rawReader(iEvent);
20   AliTRDdigitsManager *digitsManagerRaw = raw->Raw2Digits(&rawReader);
21
22   // The geometry object
23   AliTRDgeometryFull *geo = new AliTRDgeometryFull();
24
25   // The parameter object
26   AliTRDparameter    *par = new AliTRDparameter("TRDparameter"
27                                                ,"TRD parameter class");
28
29   // Print the event and detector number
30   cout << " iEvent = " << iEvent << endl;
31   cout << " iDet = " << iDet << endl;
32
33   // Define the detector matrix for one chamber
34   const Int_t iSec = geo->GetSector(iDet);
35   const Int_t iCha = geo->GetChamber(iDet);
36   const Int_t iPla = geo->GetPlane(iDet);
37   Int_t  rowMax = par->GetRowMax(iPla,iCha,iSec);
38   Int_t  colMax = par->GetColMax(iPla);
39   Int_t timeMax = par->GetTimeMax();
40   cout << "Geometry: rowMax = "  <<  rowMax
41                 << " colMax = "  <<  colMax
42                 << " timeMax = " << timeMax << endl;
43   AliTRDmatrix *matrix = new AliTRDmatrix(rowMax,colMax,timeMax,iSec,iCha,iPla);
44
45   AliRunLoader* rl = AliRunLoader::Open("galice.root");
46   AliLoader* loader = rl->GetLoader("TRDLoader");
47   rl->GetEvent(iEvent);
48   loader->LoadDigits();
49   
50   // Create the digits manager
51   AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
52   digitsManager->SetDebug(1);
53
54   // Read the digits from the file
55   digitsManager->ReadDigits(loader->TreeD());
56
57   TH1F *DigDiff = new TH1F("DigDiff","DigDiff",100,-10,+10);
58   Int_t DigAmpRaw, DigAmp;
59
60   // Loop through the detector pixel
61   for (Int_t time = 0; time < timeMax; time++) {
62     for (Int_t  col = 0;  col <  colMax;  col++) {
63       for (Int_t  row = 0;  row <  rowMax;  row++) {
64
65         AliTRDdigit* digit = digitsManagerRaw->GetDigit(row,col,time,iDet);
66         
67         matrix->SetSignal(row,col,time,digit->GetAmp());
68
69         DigAmpRaw = digit->GetAmp();
70
71         digit = digitsManager->GetDigit(row,col,time,iDet);
72
73         DigAmp = digit->GetAmp();
74
75         DigDiff->Fill((Float_t)DigAmp-(Float_t)DigAmpRaw);
76
77         delete digit;
78
79       }
80     }
81   }
82
83   // Display the detector matrix
84   matrix->Draw();
85   matrix->ProjRow();
86   matrix->ProjCol();
87   matrix->ProjTime();
88
89   TCanvas *c1 = new TCanvas("c1","Canvas 1",10,10,600,500);
90   DigDiff->Draw();
91
92 }
93
94