memory leak fixed
[u/mrichter/AliRoot.git] / PMD / AliPMDDigitsRead.C
CommitLineData
caeddd4c 1// ----------------------------------------------------//
2// //
3// This is a macro to read PMD.Digits.root //
4// //
5// ----------------------------------------------------//
6
caeddd4c 7void AliPMDDigitsRead(Int_t nevt = 1)
8{
9 TStopwatch timer;
10 timer.Start();
11
caeddd4c 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;
9ebfe36a 40 AliPMDUtility cc;
41
42 TH2F *h2 = new TH2F("h2","Y vs. X",200,-100.,100.,200,-100.,100.);
caeddd4c 43
44 // -------------------------------------------------------------- //
45
46 Int_t det = 0,smn = 0;
9ebfe36a 47 Int_t xpos, ypos, xpad, ypad;
caeddd4c 48 Float_t adc;
9ebfe36a 49 Float_t xx,yy;
50
caeddd4c 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();
9ebfe36a 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 }
caeddd4c 93
9ebfe36a 94 if(det==1)
95 {
96 cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
97 h2->Fill(xx,yy);
98 }
caeddd4c 99 }
100 } // modules
101 }
102
9ebfe36a 103 h2->Draw();
caeddd4c 104 timer.Stop();
105 timer.Print();
106}
107