2 // This macro reads the Hits Tree
4 void AliPMDHitsRead(Int_t nevt = 1)
10 // FILE *fpw = fopen("alipmdhits.dat","w");
12 AliRunLoader *fRunLoader = AliRunLoader::Open("galice.root");
16 printf("Can not open session for file ");
19 if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice();
20 if (!fRunLoader->TreeE()) fRunLoader->LoadHeader();
21 if (!fRunLoader->TreeK()) fRunLoader->LoadKinematics();
23 gAlice = fRunLoader->GetAliRun();
27 printf("Alirun object found\n");
31 printf("Could not found Alirun object\n");
34 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
35 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
36 if (fPMDLoader == 0x0)
38 printf("Can not find PMDLoader\n");
42 fPMDLoader->LoadHits("READ");
44 // This reads the PMD Hits tree and assigns the right track number
45 // to a cell and stores in the summable digits tree
48 const Int_t kPi0 = 111;
49 const Int_t kGamma = 22;
57 Float_t xPos, yPos, zPos;
58 Int_t xpad = -1, ypad = -1;
60 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
62 for (Int_t ievt = 0; ievt < nevt; ievt++)
65 printf("Event Number = %d\n",ievt);
66 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
67 printf("Number of Particles = %d\n",nparticles);
68 fRunLoader->GetEvent(ievt);
69 // ------------------------------------------------------- //
70 // Pointer to specific detector hits.
71 // Get pointers to Alice detectors and Hits containers
73 TTree* treeH = fPMDLoader->TreeH();
75 Int_t ntracks = (Int_t) treeH->GetEntries();
76 printf("Number of Tracks in the TreeH = %d\n", ntracks);
79 TClonesArray* hits = 0;
80 if (fPMD) hits = fPMD->Hits();
82 // Start loop on tracks in the hits containers
84 for (Int_t track=0; track<ntracks;track++)
87 treeH->GetEvent(track);
90 npmd = hits->GetEntriesFast();
91 for (int ipmd = 0; ipmd < npmd; ipmd++)
93 fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd);
94 trackno = fPMDHit->GetTrack();
96 //fprintf(fpw,"trackno = %d\n",trackno);
98 // get kinematics of the particles
100 TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno);
101 trackpid = mparticle->GetPdgCode();
110 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
111 if (mparticle->GetFirstMother() == -1)
113 tracknoOld = trackno;
114 trackpidOld = trackpid;
117 vx = mparticle->Vx();
118 vy = mparticle->Vy();
119 vz = mparticle->Vz();
121 //fprintf(fpw,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, -1, trackpid, vx, vy, vz);
125 while((imo = mparticle->GetFirstMother()) >= 0)
129 mparticle = gAlice->GetMCApp()->Particle(imo);
130 idmo = mparticle->GetPdgCode();
132 vx = mparticle->Vx();
133 vy = mparticle->Vy();
134 vz = mparticle->Vz();
136 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
137 //fprintf(fpw,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
139 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
147 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
154 } // end of while loop
156 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
168 mtrackno = tracknoOld;
169 mtrackpid = trackpidOld;
176 edep = fPMDHit->GetEnergy();
177 Int_t vol1 = fPMDHit->GetVolume(1); // Column
178 Int_t vol2 = fPMDHit->GetVolume(2); // Row
179 Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule
180 Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
182 // -----------------------------------------//
183 // For Super Module 1 & 2 //
184 // nrow = 96, ncol = 48 //
185 // For Super Module 3 & 4 //
186 // nrow = 48, ncol = 96 //
187 // -----------------------------------------//
189 smnumber = (vol6-1)*6 + vol3;
191 if (vol6 == 1 || vol6 == 2)
196 else if (vol6 == 3 || vol6 == 4)
202 //printf("Zposition = %f Edeposition = %f",zPos,edep);
203 Float_t zposition = TMath::Abs(zPos);
207 } // Track Loop ended
210 fRunLoader->UnloadgAlice();
211 fRunLoader->UnloadHeader();
212 fRunLoader->UnloadKinematics();
214 fPMDLoader->UnloadHits();