]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMDDigitsRead.C
Track references for PMD
[u/mrichter/AliRoot.git] / PMD / AliPMDDigitsRead.C
1 // ----------------------------------------------------//
2 //                                                     //
3 //    This is a macro  to read PMD.Digits.root         //
4 //                                                     //
5 // ----------------------------------------------------//
6
7 void AliPMDDigitsRead(Int_t nevt = 1) 
8 {
9   TStopwatch timer;
10   timer.Start();
11   
12   AliRunLoader *fRunLoader = AliRunLoader::Open("galice.root");
13                                   
14   if (!fRunLoader)
15     {
16       Error("Open","Can not open session for file %s.",file);
17     }
18   
19   fRunLoader->LoadgAlice();
20   fRunLoader->LoadHeader();
21   gAlice = fRunLoader->GetAliRun();
22   
23   if (gAlice)
24     {
25       printf("AliRun object found on file.\n");
26     }
27   else
28     {
29       printf("Could not find AliRun object.\n");
30     }
31   fPMD  = (AliPMD*)gAlice->GetDetector("PMD");
32   fPMDLoader = fRunLoader->GetLoader("PMDLoader");
33   if (fPMDLoader == 0x0)
34     {
35       cerr<<"OpengAlice : Can not find PMD or PMDLoader\n";
36     }
37   
38   fPMDLoader->LoadDigits("READ");
39   TClonesArray *fDigits; 
40   AliPMDUtility cc;
41
42   TH2F *h2 = new TH2F("h2","Y vs. X",200,-100.,100.,200,-100.,100.);
43
44   // -------------------------------------------------------------- //
45
46   Int_t    det = 0,smn = 0;
47   Int_t    xpos, ypos, xpad, ypad;
48   Float_t  adc;
49   Float_t  xx,yy;
50
51   for (Int_t ievt = 2; ievt <nevt; ievt++)
52     {
53       fRunLoader->GetEvent(ievt);
54   
55       fTreeD = fPMDLoader->TreeD();
56       if (fTreeD == 0x0)
57         {
58           cout << " Can not get TreeD" << endl;
59         }
60       AliPMDdigit  *pmddigit;
61       TBranch *branch = fTreeD->GetBranch("PMDDigit");
62       branch->SetAddress(&fDigits);
63   
64       Int_t nmodules = (Int_t) fTreeD->GetEntries();
65
66       cout << " Total number of modules in an event = " << nmodules << endl;
67
68       for (Int_t imodule = 0; imodule < nmodules; imodule++)
69         {
70           fTreeD->GetEntry(imodule); 
71           Int_t nentries = fDigits->GetLast();
72           cout << "nentries = " << nentries << endl;
73           for (Int_t ient = 0; ient < nentries+1; ient++)
74             {
75               pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
76               
77               det    = pmddigit->GetDetector();
78               smn    = pmddigit->GetSMNumber();
79               xpos   = pmddigit->GetRow();
80               ypos   = pmddigit->GetColumn();
81               adc    = pmddigit->GetADC();
82               Int_t trno   = pmddigit->GetTrackNumber();
83               if(smn <12)
84                 {
85                   xpad = ypos;
86                   ypad = xpos;
87                 }
88               else if(smn >=12 && smn < 24)
89                 {
90                   xpad = xpos;
91                   ypad = ypos;
92                 }
93               
94               if(det==1)
95                 {
96                   cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
97                   h2->Fill(xx,yy); 
98                 }
99             }
100         } // modules
101     }
102
103   h2->Draw();
104   timer.Stop();
105   timer.Print();
106 }
107