2 // This macro reads the Hits Tree
4 void AliPMDHitsRead(Int_t nevt = 1)
9 TH2F *h2 = new TH2F("h2"," Y vs. X",200,-100.,100.,200,-100.,100.);
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");
36 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
38 if (fPMDLoader == 0x0)
40 printf("Can not find PMDLoader\n");
44 fPMDLoader->LoadHits("READ");
46 // This reads the PMD Hits tree and assigns the right track number
47 // to a cell and stores in the summable digits tree
50 const Int_t kPi0 = 111;
51 const Int_t kGamma = 22;
58 Int_t xpad = -1, ypad = -1;
60 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
61 Float_t xPos, yPos, zPos;
66 for (Int_t ievt = 0; ievt < nevt; ievt++)
69 printf("Event Number = %d\n",ievt);
70 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
71 printf("Number of Particles = %d\n",nparticles);
72 fRunLoader->GetEvent(ievt);
73 // ------------------------------------------------------- //
74 // Pointer to specific detector hits.
75 // Get pointers to Alice detectors and Hits containers
77 TTree* treeH = fPMDLoader->TreeH();
79 Int_t ntracks = (Int_t) treeH->GetEntries();
80 printf("Number of Tracks in the TreeH = %d\n", ntracks);
83 TClonesArray* hits = 0;
84 if (fPMD) hits = fPMD->Hits();
86 // Start loop on tracks in the hits containers
88 for (Int_t track=0; track<ntracks;track++)
90 gAlice->GetMCApp()->ResetHits();
91 treeH->GetEvent(track);
94 npmd = hits->GetEntriesFast();
95 for (int ipmd = 0; ipmd < npmd; ipmd++)
97 fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd);
98 trackno = fPMDHit->GetTrack();
100 //fprintf(fpw,"trackno = %d\n",trackno);
102 // get kinematics of the particles
104 TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno);
105 trackpid = mparticle->GetPdgCode();
114 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
115 if (mparticle->GetFirstMother() == -1)
117 tracknoOld = trackno;
118 trackpidOld = trackpid;
121 vx = mparticle->Vx();
122 vy = mparticle->Vy();
123 vz = mparticle->Vz();
125 //fprintf(fpw,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, -1, trackpid, vx, vy, vz);
129 while((imo = mparticle->GetFirstMother()) >= 0)
133 mparticle = gAlice->GetMCApp()->Particle(imo);
134 idmo = mparticle->GetPdgCode();
136 vx = mparticle->Vx();
137 vy = mparticle->Vy();
138 vz = mparticle->Vz();
140 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
141 //fprintf(fpw,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
143 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
151 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
158 } // end of while loop
160 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
172 mtrackno = tracknoOld;
173 mtrackpid = trackpidOld;
176 //printf("mtrackno = %d mtrackpid = %d\n",mtrackno,mtrackpid);
182 Float_t time = fPMDHit->GetTime();
184 printf("++++++++++ time = %f\n",time);
186 edep = fPMDHit->GetEnergy();
187 Int_t vol1 = fPMDHit->GetVolume(1); // Column
188 Int_t vol2 = fPMDHit->GetVolume(2); // Row
190 Int_t vol3 = fPMDHit->GetVolume(4); // UnitModule
193 // -----------------------------------------//
194 // For Super Module 1 & 2 //
195 // nrow = 96, ncol = 48 //
196 // For Super Module 3 & 4 //
197 // nrow = 48, ncol = 96 //
198 // -----------------------------------------//
206 smnumber = vol3 - 24;
214 cc.RectGeomCellPos(smnumber,xpad,ypad,xx,yy);
220 } // Track Loop ended
226 fRunLoader->UnloadgAlice();
227 fRunLoader->UnloadHeader();
228 fRunLoader->UnloadKinematics();
229 fPMDLoader->UnloadHits();