MUON DAs
[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(Char_t *file="rawfile.root",Int_t runNr = 0,
3                         Int_t NEVT = 10)
4 {
5   TObjArray pmdddlcont;
6
7   AliCDBManager *man = AliCDBManager::Instance();
8   man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
9   man->SetRun(runNr);
10
11   gBenchmark->Start("");
12   gStyle->SetOptStat(0);
13
14   Int_t   xpad, ypad;
15   Float_t xx, yy;
16
17   AliPMDUtility cc;
18   TH2F *h2 = new TH2F("h2","Y vs. X",200,-100.,100.,200,-100.,100.);
19
20   TH1F *h1 = new TH1F("h1","",200,0.,200.);
21
22
23   for(Int_t ievt=495; ievt < NEVT; ievt++)
24     {
25   
26       //AliRawReaderRoot reader("09000095029017.10.root",ievt);
27       AliRawReaderRoot reader(file,ievt);
28
29       cout<<" Processing Event No  : "<<ievt<<endl;
30
31       AliPMDRawStream stream(&reader);
32       
33       Int_t iddl = -1;
34       
35       while((iddl = stream.DdlData(&pmdddlcont)) >= 0)
36         {
37
38           Int_t ientries = pmdddlcont.GetEntries();
39           
40           cout << "iddl = " << iddl << " ientries = " << ientries << endl;
41           
42           for (Int_t ient = 0; ient < ientries; ient++)
43             {
44               AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
45           
46               Int_t det = pmdddl->GetDetector();
47               Int_t smn = pmdddl->GetSMN();
48               Int_t mcm = pmdddl->GetMCM();
49               Int_t pbus = pmdddl->GetPatchBusId();
50               //Int_t chno = pmdddl->GetChannel();
51               
52               Int_t row = pmdddl->GetRow();
53               Int_t col = pmdddl->GetColumn();
54               Int_t sig = pmdddl->GetSignal();
55
56               //if (iddl == 5)
57               //printf("%d %d %d %d %d %d\n",iddl,det,smn,pbus,row,col);
58               
59               if(mcm == 0) continue;
60               
61
62               if(smn <12)
63                 {
64                   xpad = col;
65                   ypad = row;
66                 }
67               else if(smn >=12 && smn < 24)
68                 {
69                   xpad = row;
70                   ypad = col;
71                 }
72               
73               if (det == 0)
74                 {
75                   cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
76                   h2->Fill(xx,yy,sig); 
77                   h1->Fill(sig);
78                 }
79               
80             }
81           
82       pmdddlcont.Delete();
83         }
84       
85     }//event loop
86   h2->Draw();
87   cc.SetWriteModule(1);  // set here 0 not to print the module no
88   cc.DrawPMDModule(0);   // 0 : for preshower, 1:for CPV plane
89   gBenchmark->Show("");
90 }