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