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