]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMDRootDataRead.C
reading macro for rootified PMD data
[u/mrichter/AliRoot.git] / PMD / AliPMDRootDataRead.C
1 // To read PMD raw root data and fetch the adc value for each cell
2 void AliPMDRootDataRead(Int_t NEVT = 10)
3 {
4   TObjArray pmdddlcont;
5
6   gBenchmark->Start("");
7   gStyle->SetOptStat(0);
8
9   TFile *pedfile = new TFile("PMD_PED.root");
10
11   if(!pedfile)
12     {
13       printf("ERROR --- NO PEDESTAL (PMD_PED.root) FILE IS FOUND IN THE CURRENT DIRECTORY--- STOP GAIN DA\n");
14       return -3;
15     }
16
17
18   Float_t fPedMeanRMS[2][24][48][96];
19
20   for(Int_t i = 0; i < 2; i++)
21   {
22       for(Int_t j = 0; j < 24; j++)
23       {
24           for(Int_t k = 0; k < 48; k++)
25           {
26               for(Int_t l = 0; l < 96; l++)
27               {
28                   fPedMeanRMS[i][j][k][l] = 0.;
29               }
30           }
31       }
32   }
33
34   Int_t det, sm, row, col;
35   Float_t mean, rms;
36
37   TTree *ped =(TTree*)pedfile->Get("ped");
38
39   ped->SetBranchAddress("det",&det);
40   ped->SetBranchAddress("sm",&sm);
41   ped->SetBranchAddress("row",&row);
42   ped->SetBranchAddress("col",&col);
43   ped->SetBranchAddress("mean",&mean);
44   ped->SetBranchAddress("rms",&rms);
45
46   Int_t nentries = (Int_t)ped->GetEntries();
47
48   for (Int_t ient = 0; ient < nentries; ient++)
49   {
50       ped->GetEntry(ient);
51       fPedMeanRMS[det][sm][row][col] = mean + 10.*rms;
52       //printf("Mean= %f, RMS= %f, PedMeanRMS=%f\n",mean,rms,fPedMeanRMS[det][sm][row][col]);
53
54     }
55
56
57   pedfile->Close();
58   delete pedfile;
59   pedfile = 0x0;
60
61
62
63   Int_t   xpad, ypad;
64   Float_t xx, yy;
65
66   AliPMDUtility cc;
67   TH2F *h2 = new TH2F("h2","Y vs. X",200,-100.,100.,200,-100.,100.);
68
69   TH1F *h1 = new TH1F("h1","",200,0.,200.);
70
71
72   for(Int_t ievt=3; ievt < NEVT; ievt++)
73   {
74   
75   AliRawReaderRoot reader("08000042184000.10.root",ievt);
76
77   cout<<" Processing Event No  : "<<ievt<<endl;
78
79   AliPMDRawStream stream(&reader);
80
81   Int_t iddl = -1;
82
83   while((iddl = stream.DdlData(&pmdddlcont)) >= 0)
84   {
85
86       Int_t ientries = pmdddlcont.GetEntries();
87
88       //cout << "iddl = " << iddl << " ientries = " << ientries << endl;
89
90       for (Int_t ient = 0; ient < ientries; ient++)
91         {
92           AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
93           
94           det = pmdddl->GetDetector();
95           Int_t smn = pmdddl->GetSMN();
96           Int_t mcm = pmdddl->GetMCM();
97           Int_t pbus = pmdddl->GetPatchBusId();
98           //Int_t chno = pmdddl->GetChannel();
99
100           row = pmdddl->GetRow();
101           col = pmdddl->GetColumn();
102           Int_t sig = pmdddl->GetSignal();
103
104           if(mcm == 0) continue;
105
106           Int_t sig1 = sig - (Int_t)fPedMeanRMS[det][smn][row][col];
107
108
109           if (sig1 > 0)
110               sig = sig1;
111           else
112               sig = 0;
113
114           if (ievt == 159 && sig > 0) cout << row << " " << col << " " << sig << endl;
115
116
117           if(smn <12)
118           {
119               xpad = col;
120               ypad = row;
121           }
122           else if(smn >=12 && smn < 24)
123           {
124               xpad = row;
125               ypad = col;
126           }
127           
128           if (det == 0)
129           {
130               cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
131               h2->Fill(xx,yy,sig); 
132               h1->Fill(sig);
133           }
134           
135         }
136
137       pmdddlcont.Delete();
138     }
139
140   }//event loop
141   h2->Draw();
142   cc.SetWriteModule(1);
143   cc.DrawPMDModule();
144   gBenchmark->Show("");
145 }