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() :
67 fZPos(361.5)// in units of cm, This is the default position of PMD
69 // Default Constructor
71 for (Int_t i = 0; i < fgkTotUM; i++)
73 for (Int_t j = 0; j < fgkRow; j++)
75 for (Int_t k = 0; k < fgkCol; k++)
79 fPRECounter[i][j][k] = 0;
80 fPRETrackNo[i][j][k] = -1;
81 fCPVTrackNo[i][j][k] = -1;
87 //____________________________________________________________________________
88 AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager)
89 :AliDigitizer(manager),
94 fSDigits(new TClonesArray("AliPMDsdigit", 1000)),
95 fDigits(new TClonesArray("AliPMDdigit", 1000)),
101 fZPos(361.5)// in units of cm, This is the default position of PMD
103 // ctor which should be used
105 for (Int_t i = 0; i < fgkTotUM; i++)
107 for (Int_t j = 0; j < fgkRow; j++)
109 for (Int_t k = 0; k < fgkCol; k++)
113 fPRECounter[i][j][k] = 0;
114 fPRETrackNo[i][j][k] = -1;
115 fCPVTrackNo[i][j][k] = -1;
120 //____________________________________________________________________________
121 AliPMDDigitizer::~AliPMDDigitizer()
123 // Default Destructor
140 //____________________________________________________________________________
141 void AliPMDDigitizer::OpengAliceFile(const char *file, Option_t *option)
143 // Loads galice.root file and corresponding header, kinematics
144 // hits and sdigits or digits depending on the option
147 TString evfoldname = AliConfig::GetDefaultEventFolderName();
148 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
150 fRunLoader = AliRunLoader::Open(file,AliConfig::GetDefaultEventFolderName(),
155 Error("Open","Can not open session for file %s.",file);
158 if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice();
159 if (!fRunLoader->TreeE()) fRunLoader->LoadHeader();
160 if (!fRunLoader->TreeK()) fRunLoader->LoadKinematics();
162 gAlice = fRunLoader->GetAliRun();
167 printf("<AliPMDdigitizer::Open> ");
168 printf("AliRun object found on file.\n");
172 printf("<AliPMDdigitizer::Open> ");
173 printf("Could not find AliRun object.\n");
177 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
178 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
179 if (fPMDLoader == 0x0)
181 cerr<<"Hits2Digits : Can not find PMD or PMDLoader\n";
184 const char *cHS = strstr(option,"HS");
185 const char *cHD = strstr(option,"HD");
186 const char *cSD = strstr(option,"SD");
190 fPMDLoader->LoadHits("READ");
191 fPMDLoader->LoadSDigits("recreate");
195 fPMDLoader->LoadHits("READ");
196 fPMDLoader->LoadDigits("recreate");
200 fPMDLoader->LoadSDigits("READ");
201 fPMDLoader->LoadDigits("recreate");
204 //____________________________________________________________________________
205 void AliPMDDigitizer::Hits2SDigits(Int_t ievt)
207 // This reads the PMD Hits tree and assigns the right track number
208 // to a cell and stores in the summable digits tree
210 // cout << " -------- Beginning of Hits2SDigits ----------- " << endl;
212 const Int_t kPi0 = 111;
213 const Int_t kGamma = 22;
221 Float_t xPos, yPos, zPos;
222 Int_t xpad = -1, ypad = -1;
224 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
227 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
230 if (fDebug) printf("Event Number = %d \n",ievt);
231 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
232 if (fDebug) printf("Number of Particles = %d \n", nparticles);
233 fRunLoader->GetEvent(ievt);
234 // ------------------------------------------------------- //
235 // Pointer to specific detector hits.
236 // Get pointers to Alice detectors and Hits containers
238 TTree* treeH = fPMDLoader->TreeH();
240 Int_t ntracks = (Int_t) treeH->GetEntries();
241 if (fDebug) printf("Number of Tracks in the TreeH = %d \n", ntracks);
243 TTree* treeS = fPMDLoader->TreeS();
246 fPMDLoader->MakeTree("S");
247 treeS = fPMDLoader->TreeS();
249 Int_t bufsize = 16000;
250 treeS->Branch("PMDSDigit", &fSDigits, bufsize);
252 TClonesArray* hits = 0;
253 if (fPMD) hits = fPMD->Hits();
255 // Start loop on tracks in the hits containers
257 for (Int_t track=0; track<ntracks;track++)
260 treeH->GetEvent(track);
263 npmd = hits->GetEntriesFast();
264 for (int ipmd = 0; ipmd < npmd; ipmd++)
266 fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd);
267 trackno = fPMDHit->GetTrack();
268 // get kinematics of the particles
270 TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno);
271 trackpid = mparticle->GetPdgCode();
280 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
281 if (mparticle->GetFirstMother() == -1)
283 tracknoOld = trackno;
284 trackpidOld = trackpid;
288 while((imo = mparticle->GetFirstMother()) >= 0)
292 mparticle = gAlice->GetMCApp()->Particle(imo);
293 idmo = mparticle->GetPdgCode();
295 vx = mparticle->Vx();
296 vy = mparticle->Vy();
297 vz = mparticle->Vz();
299 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
300 //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
301 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
309 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
318 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
330 mtrackno = tracknoOld;
331 mtrackpid = trackpidOld;
337 edep = fPMDHit->GetEnergy();
338 Int_t vol1 = fPMDHit->GetVolume(1); // Column
339 Int_t vol2 = fPMDHit->GetVolume(2); // Row
340 Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule
341 Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
343 // -----------------------------------------//
344 // For Super Module 1 & 2 //
345 // nrow = 96, ncol = 48 //
346 // For Super Module 3 & 4 //
347 // nrow = 48, ncol = 96 //
348 // -----------------------------------------//
350 smnumber = (vol6-1)*6 + vol3;
352 if (vol6 == 1 || vol6 == 2)
357 else if (vol6 == 3 || vol6 == 4)
363 //cout << "zpos = " << zPos << " edep = " << edep << endl;
365 Float_t zposition = TMath::Abs(zPos);
366 if (zposition < fZPos)
371 else if (zposition > fZPos)
376 Int_t smn = smnumber - 1;
377 Int_t ixx = xpad - 1;
378 Int_t iyy = ypad - 1;
381 fPRE[smn][ixx][iyy] += edep;
382 fPRECounter[smn][ixx][iyy]++;
384 AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep);
390 fCPV[smn][ixx][iyy] += edep;
391 fCPVTrackNo[smn][ixx][iyy] = mtrackno;
395 } // Track Loop ended
397 TrackAssignment2Cell();
404 for (Int_t idet = 0; idet < 2; idet++)
406 for (Int_t ism = 0; ism < fgkTotUM; ism++)
408 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
410 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
414 deltaE = fPRE[ism][jrow][kcol];
415 trno = fPRETrackNo[ism][jrow][kcol];
420 deltaE = fCPV[ism][jrow][kcol];
421 trno = fCPVTrackNo[ism][jrow][kcol];
426 AddSDigit(trno,detno,ism,jrow,kcol,deltaE);
434 fPMDLoader->WriteSDigits("OVERWRITE");
437 // cout << " -------- End of Hits2SDigit ----------- " << endl;
439 //____________________________________________________________________________
441 void AliPMDDigitizer::Hits2Digits(Int_t ievt)
443 // This reads the PMD Hits tree and assigns the right track number
444 // to a cell and stores in the digits tree
446 const Int_t kPi0 = 111;
447 const Int_t kGamma = 22;
455 Float_t xPos, yPos, zPos;
456 Int_t xpad = -1, ypad = -1;
458 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
460 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
463 if (fDebug) printf("Event Number = %d \n",ievt);
465 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
466 if (fDebug) printf("Number of Particles = %d \n", nparticles);
467 fRunLoader->GetEvent(ievt);
468 // ------------------------------------------------------- //
469 // Pointer to specific detector hits.
470 // Get pointers to Alice detectors and Hits containers
472 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
473 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
475 if (fPMDLoader == 0x0)
477 cerr<<"Hits2Digits method : Can not find PMD or PMDLoader\n";
479 TTree* treeH = fPMDLoader->TreeH();
480 Int_t ntracks = (Int_t) treeH->GetEntries();
481 if (fDebug) printf("Number of Tracks in the TreeH = %d \n", ntracks);
482 fPMDLoader->LoadDigits("recreate");
483 TTree* treeD = fPMDLoader->TreeD();
486 fPMDLoader->MakeTree("D");
487 treeD = fPMDLoader->TreeD();
489 Int_t bufsize = 16000;
490 treeD->Branch("PMDDigit", &fDigits, bufsize);
492 TClonesArray* hits = 0;
493 if (fPMD) hits = fPMD->Hits();
495 // Start loop on tracks in the hits containers
497 for (Int_t track=0; track<ntracks;track++)
500 treeH->GetEvent(track);
504 npmd = hits->GetEntriesFast();
505 for (int ipmd = 0; ipmd < npmd; ipmd++)
507 fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd);
508 trackno = fPMDHit->GetTrack();
510 // get kinematics of the particles
512 TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno);
513 trackpid = mparticle->GetPdgCode();
522 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
523 if (mparticle->GetFirstMother() == -1)
525 tracknoOld = trackno;
526 trackpidOld = trackpid;
531 while((imo = mparticle->GetFirstMother()) >= 0)
535 mparticle = gAlice->GetMCApp()->Particle(imo);
536 idmo = mparticle->GetPdgCode();
538 vx = mparticle->Vx();
539 vy = mparticle->Vy();
540 vz = mparticle->Vz();
542 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
543 //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
544 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
552 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
561 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
573 mtrackno = tracknoOld;
574 mtrackpid = trackpidOld;
581 edep = fPMDHit->GetEnergy();
582 Int_t vol1 = fPMDHit->GetVolume(1); // Column
583 Int_t vol2 = fPMDHit->GetVolume(2); // Row
584 Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule
585 Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
587 // -----------------------------------------//
588 // For Super Module 1 & 2 //
589 // nrow = 96, ncol = 48 //
590 // For Super Module 3 & 4 //
591 // nrow = 48, ncol = 96 //
592 // -----------------------------------------//
594 smnumber = (vol6-1)*6 + vol3;
596 if (vol6 == 1 || vol6 == 2)
601 else if (vol6 == 3 || vol6 == 4)
607 //cout << "-zpos = " << -zPos << endl;
609 Float_t zposition = TMath::Abs(zPos);
611 if (zposition < fZPos)
616 else if (zposition > fZPos)
622 Int_t smn = smnumber - 1;
623 Int_t ixx = xpad - 1;
624 Int_t iyy = ypad - 1;
627 fPRE[smn][ixx][iyy] += edep;
628 fPRECounter[smn][ixx][iyy]++;
630 AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep);
636 fCPV[smn][ixx][iyy] += edep;
637 fCPVTrackNo[smn][ixx][iyy] = mtrackno;
641 } // Track Loop ended
643 TrackAssignment2Cell();
651 for (Int_t idet = 0; idet < 2; idet++)
653 for (Int_t ism = 0; ism < fgkTotUM; ism++)
655 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
657 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
661 deltaE = fPRE[ism][jrow][kcol];
662 trno = fPRETrackNo[ism][jrow][kcol];
667 deltaE = fCPV[ism][jrow][kcol];
668 trno = fCPVTrackNo[ism][jrow][kcol];
674 AddDigit(trno,detno,ism,jrow,kcol,adc);
680 } // supermodule loop
683 fPMDLoader->WriteDigits("OVERWRITE");
686 // cout << " -------- End of Hits2Digit ----------- " << endl;
688 //____________________________________________________________________________
691 void AliPMDDigitizer::SDigits2Digits(Int_t ievt)
693 // This reads the PMD sdigits tree and converts energy deposition
694 // in a cell to ADC and stores in the digits tree
696 // cout << " -------- Beginning of SDigits2Digit ----------- " << endl;
697 fRunLoader->GetEvent(ievt);
699 TTree* treeS = fPMDLoader->TreeS();
700 AliPMDsdigit *pmdsdigit;
701 TBranch *branch = treeS->GetBranch("PMDSDigit");
702 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
703 branch->SetAddress(&fSDigits);
705 TTree* treeD = fPMDLoader->TreeD();
708 fPMDLoader->MakeTree("D");
709 treeD = fPMDLoader->TreeD();
711 Int_t bufsize = 16000;
712 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
713 treeD->Branch("PMDDigit", &fDigits, bufsize);
715 Int_t trno, det, smn;
719 Int_t nmodules = (Int_t) treeS->GetEntries();
721 for (Int_t imodule = 0; imodule < nmodules; imodule++)
723 treeS->GetEntry(imodule);
724 Int_t nentries = fSDigits->GetLast();
725 //cout << " nentries = " << nentries << endl;
726 for (Int_t ient = 0; ient < nentries+1; ient++)
728 pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
729 trno = pmdsdigit->GetTrackNumber();
730 det = pmdsdigit->GetDetector();
731 smn = pmdsdigit->GetSMNumber();
732 irow = pmdsdigit->GetRow();
733 icol = pmdsdigit->GetColumn();
734 edep = pmdsdigit->GetCellEdep();
737 AddDigit(trno,det,smn,irow,icol,adc);
742 fPMDLoader->WriteDigits("OVERWRITE");
743 // cout << " -------- End of SDigits2Digit ----------- " << endl;
745 //____________________________________________________________________________
746 void AliPMDDigitizer::Exec(Option_t *option)
748 // Does the event merging and digitization
751 const char *cdeb = strstr(option,"deb");
754 cout << "**************** PMD Exec *************** " << endl;
758 Int_t ninputs = fManager->GetNinputs();
761 cout << " Number of files = " << ninputs << endl;
765 for (Int_t i = 0; i < ninputs; i++)
767 Int_t troffset = fManager->GetMask(i);
768 MergeSDigits(i, troffset);
771 fRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
772 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
773 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
774 if (fPMDLoader == 0x0)
776 cerr<<"AliPMDDigitizer::Exec : Can not find PMD or PMDLoader\n";
778 fPMDLoader->LoadDigits("update");
779 TTree* treeD = fPMDLoader->TreeD();
782 fPMDLoader->MakeTree("D");
783 treeD = fPMDLoader->TreeD();
785 Int_t bufsize = 16000;
786 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
787 treeD->Branch("PMDDigit", &fDigits, bufsize);
794 for (Int_t idet = 0; idet < 2; idet++)
796 for (Int_t ism = 0; ism < fgkTotUM; ism++)
798 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
800 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
804 deltaE = fPRE[ism][jrow][kcol];
805 trno = fPRETrackNo[ism][jrow][kcol];
810 deltaE = fCPV[ism][jrow][kcol];
811 trno = fCPVTrackNo[ism][jrow][kcol];
817 AddDigit(trno,detno,ism,jrow,kcol,adc);
823 } // supermodule loop
825 fPMDLoader->WriteDigits("OVERWRITE");
826 fPMDLoader->UnloadDigits();
829 //____________________________________________________________________________
831 void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset)
834 fRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(filenumber));
835 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
836 fPMDLoader->LoadSDigits("read");
837 TTree* treeS = fPMDLoader->TreeS();
838 AliPMDsdigit *pmdsdigit;
839 TBranch *branch = treeS->GetBranch("PMDSDigit");
840 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
841 branch->SetAddress(&fSDigits);
843 Int_t itrackno, idet, ism;
847 Int_t nmodules = (Int_t) treeS->GetEntries();
850 cout << " nmodules = " << nmodules << endl;
851 cout << " tr offset = " << troffset << endl;
853 for (Int_t imodule = 0; imodule < nmodules; imodule++)
855 treeS->GetEntry(imodule);
856 Int_t nentries = fSDigits->GetLast();
859 cout << " nentries = " << nentries << endl;
861 for (Int_t ient = 0; ient < nentries+1; ient++)
863 pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
864 itrackno = pmdsdigit->GetTrackNumber();
865 idet = pmdsdigit->GetDetector();
866 ism = pmdsdigit->GetSMNumber();
867 ixp = pmdsdigit->GetRow();
868 iyp = pmdsdigit->GetColumn();
869 edep = pmdsdigit->GetCellEdep();
873 if (fPRE[ism][ixp][iyp] < edep)
875 fPRETrackNo[ism][ixp][iyp] = troffset + itrackno;
877 fPRE[ism][ixp][iyp] += edep;
881 if (fCPV[ism][ixp][iyp] < edep)
883 fCPVTrackNo[ism][ixp][iyp] = troffset + itrackno;
885 fCPV[ism][ixp][iyp] += edep;
891 // ----------------------------------------------------------------------
892 void AliPMDDigitizer::TrackAssignment2Cell()
895 // This block assigns the cell id when there are
896 // multiple tracks in a cell according to the
899 Bool_t jsort = false;
911 pmdTrack = new Int_t ***[fgkTotUM];
912 pmdEdep = new Float_t ***[fgkTotUM];
913 for (i=0; i<fgkTotUM; i++)
915 pmdTrack[i] = new Int_t **[fgkRow];
916 pmdEdep[i] = new Float_t **[fgkRow];
919 for (i = 0; i < fgkTotUM; i++)
921 for (j = 0; j < fgkRow; j++)
923 pmdTrack[i][j] = new Int_t *[fgkCol];
924 pmdEdep[i][j] = new Float_t *[fgkCol];
928 for (i = 0; i < fgkTotUM; i++)
930 for (j = 0; j < fgkRow; j++)
932 for (k = 0; k < fgkCol; k++)
934 Int_t nn = fPRECounter[i][j][k];
937 pmdTrack[i][j][k] = new Int_t[nn];
938 pmdEdep[i][j][k] = new Float_t[nn];
943 pmdTrack[i][j][k] = new Int_t[nn];
944 pmdEdep[i][j][k] = new Float_t[nn];
946 fPRECounter[i][j][k] = 0;
952 Int_t nentries = fCell.GetEntries();
954 Int_t mtrackno, ism, ixp, iyp;
957 for (i = 0; i < nentries; i++)
959 AliPMDcell* cell = (AliPMDcell*)fCell.UncheckedAt(i);
961 mtrackno = cell->GetTrackNumber();
962 ism = cell->GetSMNumber();
965 edep = cell->GetEdep();
966 Int_t nn = fPRECounter[ism][ixp][iyp];
967 // cout << " nn = " << nn << endl;
968 pmdTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno;
969 pmdEdep[ism][ixp][iyp][nn] = edep;
970 fPRECounter[ism][ixp][iyp]++;
977 for (im=0; im<fgkTotUM; im++)
979 for (ix=0; ix<fgkRow; ix++)
981 for (iy=0; iy<fgkCol; iy++)
983 nn = fPRECounter[im][ix][iy];
986 // This block handles if a cell is fired
987 // many times by many tracks
988 status1 = new Int_t[nn];
989 status2 = new Int_t[nn];
990 trnarray = new Int_t[nn];
991 for (iz = 0; iz < nn; iz++)
993 status1[iz] = pmdTrack[im][ix][iy][iz];
995 TMath::Sort(nn,status1,status2,jsort);
996 Int_t trackOld = -99999;
997 Int_t track, trCount = 0;
998 for (iz = 0; iz < nn; iz++)
1000 track = status1[status2[iz]];
1001 if (trackOld != track)
1003 trnarray[trCount] = track;
1010 Float_t totEdp = 0.;
1011 trEdp = new Float_t[trCount];
1012 fracEdp = new Float_t[trCount];
1013 for (il = 0; il < trCount; il++)
1016 track = trnarray[il];
1017 for (iz = 0; iz < nn; iz++)
1019 if (track == pmdTrack[im][ix][iy][iz])
1021 trEdp[il] += pmdEdep[im][ix][iy][iz];
1024 totEdp += trEdp[il];
1027 Float_t fracOld = 0.;
1029 for (il = 0; il < trCount; il++)
1031 fracEdp[il] = trEdp[il]/totEdp;
1032 if (fracOld < fracEdp[il])
1034 fracOld = fracEdp[il];
1038 fPRETrackNo[im][ix][iy] = trnarray[ilOld];
1045 // This only handles if a cell is fired
1046 // by only one track
1048 fPRETrackNo[im][ix][iy] = pmdTrack[im][ix][iy][0];
1053 // This is if no cell is fired
1054 fPRETrackNo[im][ix][iy] = -999;
1060 // Delete all the pointers
1062 for (i = 0; i < fgkTotUM; i++)
1064 for (j = 0; j < fgkRow; j++)
1066 for (k = 0; k < fgkCol; k++)
1068 delete [] pmdTrack[i][j][k];
1069 delete [] pmdEdep[i][j][k];
1074 for (i = 0; i < fgkTotUM; i++)
1076 for (j = 0; j < fgkRow; j++)
1078 delete [] pmdTrack[i][j];
1079 delete [] pmdEdep[i][j];
1083 for (i = 0; i < fgkTotUM; i++)
1085 delete [] pmdTrack[i];
1086 delete [] pmdEdep[i];
1091 // End of the cell id assignment
1094 //____________________________________________________________________________
1095 void AliPMDDigitizer::MeV2ADC(Float_t mev, Float_t & adc) const
1097 // This converts the simulated edep to ADC according to the
1105 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //
1106 // PS Test in September 2003
1107 // MeV - ADC conversion for 10bit ADC
1109 const Float_t kConstant = 7.181;
1110 const Float_t kErConstant = 0.6899;
1111 const Float_t kSlope = 35.93;
1112 const Float_t kErSlope = 0.306;
1114 //gRandom->SetSeed();
1116 Float_t cons = gRandom->Gaus(kConstant,kErConstant);
1117 Float_t slop = gRandom->Gaus(kSlope,kErSlope);
1119 Float_t adc10bit = slop*mev*0.001 + cons;
1123 Int_t adc12bit = (Int_t) (4.0*adc10bit);
1127 adc = (Float_t) adc12bit;
1129 else if (adc12bit >= 3000)
1134 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //
1137 //____________________________________________________________________________
1138 void AliPMDDigitizer::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber,
1139 Int_t irow, Int_t icol, Float_t adc)
1143 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
1144 TClonesArray &lsdigits = *fSDigits;
1145 new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc);
1147 //____________________________________________________________________________
1149 void AliPMDDigitizer::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber,
1150 Int_t irow, Int_t icol, Float_t adc)
1154 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
1155 TClonesArray &ldigits = *fDigits;
1156 new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc);
1158 //____________________________________________________________________________
1160 void AliPMDDigitizer::SetZPosition(Float_t zpos)
1164 //____________________________________________________________________________
1165 Float_t AliPMDDigitizer::GetZPosition() const
1169 //____________________________________________________________________________
1171 void AliPMDDigitizer::ResetCell()
1173 // clears the cell array and also the counter
1177 for (Int_t i = 0; i < fgkTotUM; i++)
1179 for (Int_t j = 0; j < fgkRow; j++)
1181 for (Int_t k = 0; k < fgkCol; k++)
1183 fPRECounter[i][j][k] = 0;
1188 //____________________________________________________________________________
1189 void AliPMDDigitizer::ResetSDigit()
1193 if (fSDigits) fSDigits->Delete();
1195 //____________________________________________________________________________
1196 void AliPMDDigitizer::ResetDigit()
1200 if (fDigits) fDigits->Delete();
1202 //____________________________________________________________________________
1204 void AliPMDDigitizer::ResetCellADC()
1206 // Clears individual cells edep and track number
1207 for (Int_t i = 0; i < fgkTotUM; i++)
1209 for (Int_t j = 0; j < fgkRow; j++)
1211 for (Int_t k = 0; k < fgkCol; k++)
1215 fPRETrackNo[i][j][k] = 0;
1216 fCPVTrackNo[i][j][k] = 0;
1221 //____________________________________________________________________________
1223 void AliPMDDigitizer::UnLoad(Option_t *option)
1225 // Unloads all the root files
1227 const char *cS = strstr(option,"S");
1228 const char *cD = strstr(option,"D");
1230 fRunLoader->UnloadgAlice();
1231 fRunLoader->UnloadHeader();
1232 fRunLoader->UnloadKinematics();
1236 fPMDLoader->UnloadHits();
1240 fPMDLoader->UnloadHits();
1241 fPMDLoader->UnloadSDigits();