1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 //-----------------------------------------------------//
17 // Source File : PMDDigitizer.cxx, Version 00 //
19 // Date : September 20 2002 //
21 //-----------------------------------------------------//
23 #include <Riostream.h>
27 #include <TGeometry.h>
28 #include <TObjArray.h>
29 #include <TClonesArray.h>
32 #include <TParticle.h>
36 #include "AliPMDhit.h"
38 #include "AliDetector.h"
39 #include "AliRunLoader.h"
40 #include "AliLoader.h"
41 #include "AliConfig.h"
43 #include "AliRunDigitizer.h"
44 #include "AliDigitizer.h"
45 #include "AliHeader.h"
47 #include "AliPMDcell.h"
48 #include "AliPMDsdigit.h"
49 #include "AliPMDdigit.h"
50 #include "AliPMDDigitizer.h"
53 ClassImp(AliPMDDigitizer)
55 AliPMDDigitizer::AliPMDDigitizer() :
66 fSDigits(new TClonesArray("AliPMDsdigit", 1000)),
67 fDigits(new TClonesArray("AliPMDdigit", 1000)),
68 fCell(new TObjArray()),
74 fZPos(361.5)// in units of cm, This is the default position of PMD
76 // Default Constructor
78 for (Int_t i = 0; i < fgkTotUM; i++)
80 for (Int_t j = 0; j < fgkRow; j++)
82 for (Int_t k = 0; k < fgkCol; k++)
86 fPRECounter[i][j][k] = 0;
87 fPRETrackNo[i][j][k] = -1;
88 fCPVTrackNo[i][j][k] = -1;
94 //____________________________________________________________________________
95 AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager)
96 :AliDigitizer(manager)
98 // ctor which should be used
100 cerr<<"AliPMDDigitizer::AliPMDDigitizer"
101 <<"(AliRunDigitizer* manager) was processed"<<endl;
103 //____________________________________________________________________________
104 AliPMDDigitizer::~AliPMDDigitizer()
106 // Default Destructor
127 //____________________________________________________________________________
128 void AliPMDDigitizer::OpengAliceFile(const char *file, Option_t *option)
130 // Loads galice.root file and corresponding header, kinematics
131 // hits and sdigits or digits depending on the option
134 TString evfoldname = AliConfig::GetDefaultEventFolderName();
135 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
137 fRunLoader = AliRunLoader::Open(file,AliConfig::GetDefaultEventFolderName(),
142 Error("Open","Can not open session for file %s.",file);
145 if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice();
146 if (!fRunLoader->TreeE()) fRunLoader->LoadHeader();
147 if (!fRunLoader->TreeK()) fRunLoader->LoadKinematics();
149 gAlice = fRunLoader->GetAliRun();
154 printf("<AliPMDdigitizer::Open> ");
155 printf("AliRun object found on file.\n");
159 printf("<AliPMDdigitizer::Open> ");
160 printf("Could not find AliRun object.\n");
164 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
165 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
166 if (fPMDLoader == 0x0)
168 cerr<<"Hits2Digits : Can not find PMD or PMDLoader\n";
171 const char *cHS = strstr(option,"HS");
172 const char *cHD = strstr(option,"HD");
173 const char *cSD = strstr(option,"SD");
177 fPMDLoader->LoadHits("READ");
178 fPMDLoader->LoadSDigits("recreate");
182 fPMDLoader->LoadHits("READ");
183 fPMDLoader->LoadDigits("recreate");
187 fPMDLoader->LoadSDigits("READ");
188 fPMDLoader->LoadDigits("recreate");
191 //____________________________________________________________________________
192 void AliPMDDigitizer::Hits2SDigits(Int_t ievt)
194 // This reads the PMD Hits tree and assigns the right track number
195 // to a cell and stores in the summable digits tree
197 // cout << " -------- Beginning of Hits2SDigits ----------- " << endl;
199 const Int_t kPi0 = 111;
200 const Int_t kGamma = 22;
208 Float_t xPos, yPos, zPos;
209 Int_t xpad = -1, ypad = -1;
211 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
216 if (fDebug) printf("Event Number = %d \n",ievt);
217 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
218 if (fDebug) printf("Number of Particles = %d \n", nparticles);
219 fRunLoader->GetEvent(ievt);
220 // ------------------------------------------------------- //
221 // Pointer to specific detector hits.
222 // Get pointers to Alice detectors and Hits containers
224 fTreeH = fPMDLoader->TreeH();
226 Int_t ntracks = (Int_t) fTreeH->GetEntries();
227 if (fDebug) printf("Number of Tracks in the TreeH = %d \n", ntracks);
229 fTreeS = fPMDLoader->TreeS();
232 fPMDLoader->MakeTree("S");
233 fTreeS = fPMDLoader->TreeS();
235 Int_t bufsize = 16000;
236 fTreeS->Branch("PMDSDigit", &fSDigits, bufsize);
238 if (fPMD) fHits = fPMD->Hits();
240 // Start loop on tracks in the hits containers
242 for (Int_t track=0; track<ntracks;track++)
245 fTreeH->GetEvent(track);
248 npmd = fHits->GetEntriesFast();
249 for (int ipmd = 0; ipmd < npmd; ipmd++)
251 fPMDHit = (AliPMDhit*) fHits->UncheckedAt(ipmd);
252 trackno = fPMDHit->GetTrack();
253 // get kinematics of the particles
255 fParticle = gAlice->GetMCApp()->Particle(trackno);
256 trackpid = fParticle->GetPdgCode();
265 TParticle* mparticle = fParticle;
266 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
267 if (mparticle->GetFirstMother() == -1)
269 tracknoOld = trackno;
270 trackpidOld = trackpid;
274 while((imo = mparticle->GetFirstMother()) >= 0)
278 mparticle = gAlice->GetMCApp()->Particle(imo);
279 idmo = mparticle->GetPdgCode();
281 vx = mparticle->Vx();
282 vy = mparticle->Vy();
283 vz = mparticle->Vz();
285 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
286 //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
287 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
295 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
304 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
316 mtrackno = tracknoOld;
317 mtrackpid = trackpidOld;
323 edep = fPMDHit->GetEnergy();
324 Int_t vol1 = fPMDHit->GetVolume(1); // Column
325 Int_t vol2 = fPMDHit->GetVolume(2); // Row
326 Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule
327 Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
329 // -----------------------------------------//
330 // For Super Module 1 & 2 //
331 // nrow = 96, ncol = 48 //
332 // For Super Module 3 & 4 //
333 // nrow = 48, ncol = 96 //
334 // -----------------------------------------//
336 smnumber = (vol6-1)*6 + vol3;
338 if (vol6 == 1 || vol6 == 2)
343 else if (vol6 == 3 || vol6 == 4)
349 //cout << "zpos = " << zPos << " edep = " << edep << endl;
351 Float_t zposition = TMath::Abs(zPos);
352 if (zposition < fZPos)
357 else if (zposition > fZPos)
362 Int_t smn = smnumber - 1;
363 Int_t ixx = xpad - 1;
364 Int_t iyy = ypad - 1;
367 fPRE[smn][ixx][iyy] += edep;
368 fPRECounter[smn][ixx][iyy]++;
370 fPMDcell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep);
372 fCell->Add(fPMDcell);
376 fCPV[smn][ixx][iyy] += edep;
377 fCPVTrackNo[smn][ixx][iyy] = mtrackno;
381 } // Track Loop ended
383 TrackAssignment2Cell();
390 for (Int_t idet = 0; idet < 2; idet++)
392 for (Int_t ism = 0; ism < fgkTotUM; ism++)
394 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
396 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
400 deltaE = fPRE[ism][jrow][kcol];
401 trno = fPRETrackNo[ism][jrow][kcol];
406 deltaE = fCPV[ism][jrow][kcol];
407 trno = fCPVTrackNo[ism][jrow][kcol];
412 AddSDigit(trno,detno,ism,jrow,kcol,deltaE);
420 fPMDLoader->WriteSDigits("OVERWRITE");
423 // cout << " -------- End of Hits2SDigit ----------- " << endl;
425 //____________________________________________________________________________
427 void AliPMDDigitizer::Hits2Digits(Int_t ievt)
429 // This reads the PMD Hits tree and assigns the right track number
430 // to a cell and stores in the digits tree
432 const Int_t kPi0 = 111;
433 const Int_t kGamma = 22;
441 Float_t xPos, yPos, zPos;
442 Int_t xpad = -1, ypad = -1;
444 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
448 if (fDebug) printf("Event Number = %d \n",ievt);
450 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
451 if (fDebug) printf("Number of Particles = %d \n", nparticles);
452 fRunLoader->GetEvent(ievt);
453 // ------------------------------------------------------- //
454 // Pointer to specific detector hits.
455 // Get pointers to Alice detectors and Hits containers
457 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
458 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
460 if (fPMDLoader == 0x0)
462 cerr<<"Hits2Digits method : Can not find PMD or PMDLoader\n";
464 fTreeH = fPMDLoader->TreeH();
465 Int_t ntracks = (Int_t) fTreeH->GetEntries();
466 if (fDebug) printf("Number of Tracks in the TreeH = %d \n", ntracks);
467 fPMDLoader->LoadDigits("recreate");
468 fTreeD = fPMDLoader->TreeD();
471 fPMDLoader->MakeTree("D");
472 fTreeD = fPMDLoader->TreeD();
474 Int_t bufsize = 16000;
475 fTreeD->Branch("PMDDigit", &fDigits, bufsize);
477 if (fPMD) fHits = fPMD->Hits();
479 // Start loop on tracks in the hits containers
481 for (Int_t track=0; track<ntracks;track++)
484 fTreeH->GetEvent(track);
488 npmd = fHits->GetEntriesFast();
489 for (int ipmd = 0; ipmd < npmd; ipmd++)
491 fPMDHit = (AliPMDhit*) fHits->UncheckedAt(ipmd);
492 trackno = fPMDHit->GetTrack();
494 // get kinematics of the particles
496 fParticle = gAlice->GetMCApp()->Particle(trackno);
497 trackpid = fParticle->GetPdgCode();
506 TParticle* mparticle = fParticle;
507 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
508 if (mparticle->GetFirstMother() == -1)
510 tracknoOld = trackno;
511 trackpidOld = trackpid;
516 while((imo = mparticle->GetFirstMother()) >= 0)
520 mparticle = gAlice->GetMCApp()->Particle(imo);
521 idmo = mparticle->GetPdgCode();
523 vx = mparticle->Vx();
524 vy = mparticle->Vy();
525 vz = mparticle->Vz();
527 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
528 //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
529 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
537 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
546 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
558 mtrackno = tracknoOld;
559 mtrackpid = trackpidOld;
566 edep = fPMDHit->GetEnergy();
567 Int_t vol1 = fPMDHit->GetVolume(1); // Column
568 Int_t vol2 = fPMDHit->GetVolume(2); // Row
569 Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule
570 Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
572 // -----------------------------------------//
573 // For Super Module 1 & 2 //
574 // nrow = 96, ncol = 48 //
575 // For Super Module 3 & 4 //
576 // nrow = 48, ncol = 96 //
577 // -----------------------------------------//
579 smnumber = (vol6-1)*6 + vol3;
581 if (vol6 == 1 || vol6 == 2)
586 else if (vol6 == 3 || vol6 == 4)
592 //cout << "-zpos = " << -zPos << endl;
594 Float_t zposition = TMath::Abs(zPos);
596 if (zposition < fZPos)
601 else if (zposition > fZPos)
607 Int_t smn = smnumber - 1;
608 Int_t ixx = xpad - 1;
609 Int_t iyy = ypad - 1;
612 fPRE[smn][ixx][iyy] += edep;
613 fPRECounter[smn][ixx][iyy]++;
615 fPMDcell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep);
617 fCell->Add(fPMDcell);
621 fCPV[smn][ixx][iyy] += edep;
622 fCPVTrackNo[smn][ixx][iyy] = mtrackno;
626 } // Track Loop ended
628 TrackAssignment2Cell();
636 for (Int_t idet = 0; idet < 2; idet++)
638 for (Int_t ism = 0; ism < fgkTotUM; ism++)
640 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
642 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
646 deltaE = fPRE[ism][jrow][kcol];
647 trno = fPRETrackNo[ism][jrow][kcol];
652 deltaE = fCPV[ism][jrow][kcol];
653 trno = fCPVTrackNo[ism][jrow][kcol];
659 AddDigit(trno,detno,ism,jrow,kcol,adc);
663 } // supermodule loop
668 fPMDLoader->WriteDigits("OVERWRITE");
671 // cout << " -------- End of Hits2Digit ----------- " << endl;
673 //____________________________________________________________________________
676 void AliPMDDigitizer::SDigits2Digits(Int_t ievt)
678 // This reads the PMD sdigits tree and converts energy deposition
679 // in a cell to ADC and stores in the digits tree
681 // cout << " -------- Beginning of SDigits2Digit ----------- " << endl;
682 fRunLoader->GetEvent(ievt);
684 fTreeS = fPMDLoader->TreeS();
685 AliPMDsdigit *pmdsdigit;
686 TBranch *branch = fTreeS->GetBranch("PMDSDigit");
687 branch->SetAddress(&fSDigits);
689 fTreeD = fPMDLoader->TreeD();
692 fPMDLoader->MakeTree("D");
693 fTreeD = fPMDLoader->TreeD();
695 Int_t bufsize = 16000;
696 fTreeD->Branch("PMDDigit", &fDigits, bufsize);
698 Int_t trno, det, smn;
702 Int_t nmodules = (Int_t) fTreeS->GetEntries();
704 for (Int_t imodule = 0; imodule < nmodules; imodule++)
706 fTreeS->GetEntry(imodule);
707 Int_t nentries = fSDigits->GetLast();
708 //cout << " nentries = " << nentries << endl;
709 for (Int_t ient = 0; ient < nentries+1; ient++)
711 pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
712 trno = pmdsdigit->GetTrackNumber();
713 det = pmdsdigit->GetDetector();
714 smn = pmdsdigit->GetSMNumber();
715 irow = pmdsdigit->GetRow();
716 icol = pmdsdigit->GetColumn();
717 edep = pmdsdigit->GetCellEdep();
720 AddDigit(trno,det,smn,irow,icol,adc);
725 fPMDLoader->WriteDigits("OVERWRITE");
726 // cout << " -------- End of SDigits2Digit ----------- " << endl;
728 //____________________________________________________________________________
729 void AliPMDDigitizer::Exec(Option_t *option)
731 // Does the event merging and digitization
734 const char *cdeb = strstr(option,"deb");
737 cout << "**************** PMD Exec *************** " << endl;
740 fDigits = new TClonesArray("AliPMDdigit", 1000);
742 Int_t ninputs = fManager->GetNinputs();
745 cout << " Number of files = " << ninputs << endl;
749 for (Int_t i = 0; i < ninputs; i++)
751 Int_t troffset = fManager->GetMask(i);
752 MergeSDigits(i, troffset);
755 fRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
756 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
757 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
758 if (fPMDLoader == 0x0)
760 cerr<<"AliPMDDigitizer::Exec : Can not find PMD or PMDLoader\n";
762 fPMDLoader->LoadDigits("recreate");
763 fTreeD = fPMDLoader->TreeD();
766 fPMDLoader->MakeTree("D");
767 fTreeD = fPMDLoader->TreeD();
769 Int_t bufsize = 16000;
770 fTreeD->Branch("PMDDigit", &fDigits, bufsize);
777 for (Int_t idet = 0; idet < 2; idet++)
779 for (Int_t ism = 0; ism < fgkTotUM; ism++)
781 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
783 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
787 deltaE = fPRE[ism][jrow][kcol];
788 trno = fPRETrackNo[ism][jrow][kcol];
793 deltaE = fCPV[ism][jrow][kcol];
794 trno = fCPVTrackNo[ism][jrow][kcol];
800 AddDigit(trno,detno,ism,jrow,kcol,adc);
806 } // supermodule loop
810 fPMDLoader->WriteDigits("OVERWRITE");
812 //____________________________________________________________________________
814 void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset)
817 fRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(filenumber));
818 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
819 fPMDLoader->LoadSDigits("read");
820 fTreeS = fPMDLoader->TreeS();
821 AliPMDsdigit *pmdsdigit;
822 TBranch *branch = fTreeS->GetBranch("PMDSDigit");
823 branch->SetAddress(&fSDigits);
825 Int_t itrackno, idet, ism;
829 Int_t nmodules = (Int_t) fTreeS->GetEntries();
832 cout << " nmodules = " << nmodules << endl;
833 cout << " tr offset = " << troffset << endl;
835 for (Int_t imodule = 0; imodule < nmodules; imodule++)
837 fTreeS->GetEntry(imodule);
838 Int_t nentries = fSDigits->GetLast();
841 cout << " nentries = " << nentries << endl;
843 for (Int_t ient = 0; ient < nentries+1; ient++)
845 pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
846 itrackno = pmdsdigit->GetTrackNumber();
847 idet = pmdsdigit->GetDetector();
848 ism = pmdsdigit->GetSMNumber();
849 ixp = pmdsdigit->GetRow();
850 iyp = pmdsdigit->GetColumn();
851 edep = pmdsdigit->GetCellEdep();
855 if (fPRE[ism][ixp][iyp] < edep)
857 fPRETrackNo[ism][ixp][iyp] = troffset + itrackno;
859 fPRE[ism][ixp][iyp] += edep;
863 if (fCPV[ism][ixp][iyp] < edep)
865 fCPVTrackNo[ism][ixp][iyp] = troffset + itrackno;
867 fCPV[ism][ixp][iyp] += edep;
873 // ----------------------------------------------------------------------
874 void AliPMDDigitizer::TrackAssignment2Cell()
877 // This block assigns the cell id when there are
878 // multiple tracks in a cell according to the
881 Bool_t jsort = false;
893 pmdTrack = new Int_t ***[fgkTotUM];
894 pmdEdep = new Float_t ***[fgkTotUM];
895 for (i=0; i<fgkTotUM; i++)
897 pmdTrack[i] = new Int_t **[fgkRow];
898 pmdEdep[i] = new Float_t **[fgkRow];
901 for (i = 0; i < fgkTotUM; i++)
903 for (j = 0; j < fgkRow; j++)
905 pmdTrack[i][j] = new Int_t *[fgkCol];
906 pmdEdep[i][j] = new Float_t *[fgkCol];
910 for (i = 0; i < fgkTotUM; i++)
912 for (j = 0; j < fgkRow; j++)
914 for (k = 0; k < fgkCol; k++)
916 Int_t nn = fPRECounter[i][j][k];
919 pmdTrack[i][j][k] = new Int_t[nn];
920 pmdEdep[i][j][k] = new Float_t[nn];
925 pmdTrack[i][j][k] = new Int_t[nn];
926 pmdEdep[i][j][k] = new Float_t[nn];
928 fPRECounter[i][j][k] = 0;
934 Int_t nentries = fCell->GetEntries();
936 Int_t mtrackno, ism, ixp, iyp;
939 for (i = 0; i < nentries; i++)
941 fPMDcell = (AliPMDcell*)fCell->UncheckedAt(i);
943 mtrackno = fPMDcell->GetTrackNumber();
944 ism = fPMDcell->GetSMNumber();
945 ixp = fPMDcell->GetX();
946 iyp = fPMDcell->GetY();
947 edep = fPMDcell->GetEdep();
948 Int_t nn = fPRECounter[ism][ixp][iyp];
949 // cout << " nn = " << nn << endl;
950 pmdTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno;
951 pmdEdep[ism][ixp][iyp][nn] = edep;
952 fPRECounter[ism][ixp][iyp]++;
959 for (im=0; im<fgkTotUM; im++)
961 for (ix=0; ix<fgkRow; ix++)
963 for (iy=0; iy<fgkCol; iy++)
965 nn = fPRECounter[im][ix][iy];
968 // This block handles if a cell is fired
969 // many times by many tracks
970 status1 = new Int_t[nn];
971 status2 = new Int_t[nn];
972 trnarray = new Int_t[nn];
973 for (iz = 0; iz < nn; iz++)
975 status1[iz] = pmdTrack[im][ix][iy][iz];
977 TMath::Sort(nn,status1,status2,jsort);
978 Int_t trackOld = -99999;
979 Int_t track, trCount = 0;
980 for (iz = 0; iz < nn; iz++)
982 track = status1[status2[iz]];
983 if (trackOld != track)
985 trnarray[trCount] = track;
993 trEdp = new Float_t[trCount];
994 fracEdp = new Float_t[trCount];
995 for (il = 0; il < trCount; il++)
998 track = trnarray[il];
999 for (iz = 0; iz < nn; iz++)
1001 if (track == pmdTrack[im][ix][iy][iz])
1003 trEdp[il] += pmdEdep[im][ix][iy][iz];
1006 totEdp += trEdp[il];
1009 Float_t fracOld = 0.;
1011 for (il = 0; il < trCount; il++)
1013 fracEdp[il] = trEdp[il]/totEdp;
1014 if (fracOld < fracEdp[il])
1016 fracOld = fracEdp[il];
1020 fPRETrackNo[im][ix][iy] = trnarray[ilOld];
1027 // This only handles if a cell is fired
1028 // by only one track
1030 fPRETrackNo[im][ix][iy] = pmdTrack[im][ix][iy][0];
1035 // This is if no cell is fired
1036 fPRETrackNo[im][ix][iy] = -999;
1042 // Delete all the pointers
1044 for (i = 0; i < fgkTotUM; i++)
1046 for (j = 0; j < fgkRow; j++)
1048 for (k = 0; k < fgkCol; k++)
1050 delete [] pmdTrack[i][j][k];
1051 delete [] pmdEdep[i][j][k];
1056 for (i = 0; i < fgkTotUM; i++)
1058 for (j = 0; j < fgkRow; j++)
1060 delete [] pmdTrack[i][j];
1061 delete [] pmdEdep[i][j];
1065 for (i = 0; i < fgkTotUM; i++)
1067 delete [] pmdTrack[i];
1068 delete [] pmdEdep[i];
1073 // End of the cell id assignment
1076 //____________________________________________________________________________
1077 void AliPMDDigitizer::MeV2ADC(Float_t mev, Float_t & adc) const
1079 // This converts the simulated edep to ADC according to the
1085 //____________________________________________________________________________
1086 void AliPMDDigitizer::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber,
1087 Int_t irow, Int_t icol, Float_t adc)
1091 TClonesArray &lsdigits = *fSDigits;
1092 new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc);
1094 //____________________________________________________________________________
1096 void AliPMDDigitizer::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber,
1097 Int_t irow, Int_t icol, Float_t adc)
1101 TClonesArray &ldigits = *fDigits;
1102 new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc);
1104 //____________________________________________________________________________
1106 void AliPMDDigitizer::SetZPosition(Float_t zpos)
1110 //____________________________________________________________________________
1111 Float_t AliPMDDigitizer::GetZPosition() const
1115 //____________________________________________________________________________
1117 void AliPMDDigitizer::ResetCell()
1119 // clears the cell array and also the counter
1123 for (Int_t i = 0; i < fgkTotUM; i++)
1125 for (Int_t j = 0; j < fgkRow; j++)
1127 for (Int_t k = 0; k < fgkCol; k++)
1129 fPRECounter[i][j][k] = 0;
1134 //____________________________________________________________________________
1135 void AliPMDDigitizer::ResetSDigit()
1139 if (fSDigits) fSDigits->Clear();
1141 //____________________________________________________________________________
1142 void AliPMDDigitizer::ResetDigit()
1146 if (fDigits) fDigits->Clear();
1148 //____________________________________________________________________________
1150 void AliPMDDigitizer::ResetCellADC()
1152 // Clears individual cells edep and track number
1153 for (Int_t i = 0; i < fgkTotUM; i++)
1155 for (Int_t j = 0; j < fgkRow; j++)
1157 for (Int_t k = 0; k < fgkCol; k++)
1161 fPRETrackNo[i][j][k] = 0;
1162 fCPVTrackNo[i][j][k] = 0;
1167 //____________________________________________________________________________
1169 void AliPMDDigitizer::UnLoad(Option_t *option)
1171 // Unloads all the root files
1173 const char *cS = strstr(option,"S");
1174 const char *cD = strstr(option,"D");
1176 fRunLoader->UnloadgAlice();
1177 fRunLoader->UnloadHeader();
1178 fRunLoader->UnloadKinematics();
1182 fPMDLoader->UnloadHits();
1186 fPMDLoader->UnloadHits();
1187 fPMDLoader->UnloadSDigits();