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>
37 #include "AliDetector.h"
38 #include "AliRunLoader.h"
39 #include "AliLoader.h"
40 #include "AliConfig.h"
42 #include "AliRunDigitizer.h"
43 #include "AliDigitizer.h"
44 #include "AliHeader.h"
45 #include "AliCDBManager.h"
46 #include "AliCDBStorage.h"
47 #include "AliCDBEntry.h"
51 #include "AliPMDhit.h"
52 #include "AliPMDcell.h"
53 #include "AliPMDsdigit.h"
54 #include "AliPMDdigit.h"
55 #include "AliPMDCalibData.h"
56 #include "AliPMDDigitizer.h"
59 ClassImp(AliPMDDigitizer)
61 AliPMDDigitizer::AliPMDDigitizer() :
72 fZPos(361.5)// in units of cm, This is the default position of PMD
74 // Default Constructor
76 for (Int_t i = 0; i < fgkTotUM; i++)
78 for (Int_t j = 0; j < fgkRow; j++)
80 for (Int_t k = 0; k < fgkCol; k++)
84 fPRECounter[i][j][k] = 0;
85 fPRETrackNo[i][j][k] = -1;
86 fCPVTrackNo[i][j][k] = -1;
90 fCalibData = GetCalibData();
93 //____________________________________________________________________________
94 AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager)
95 :AliDigitizer(manager),
100 fSDigits(new TClonesArray("AliPMDsdigit", 1000)),
101 fDigits(new TClonesArray("AliPMDdigit", 1000)),
106 fZPos(361.5)// in units of cm, This is the default position of PMD
108 // ctor which should be used
110 fCalibData = GetCalibData();
112 for (Int_t i = 0; i < fgkTotUM; i++)
114 for (Int_t j = 0; j < fgkRow; j++)
116 for (Int_t k = 0; k < fgkCol; k++)
120 fPRECounter[i][j][k] = 0;
121 fPRETrackNo[i][j][k] = -1;
122 fCPVTrackNo[i][j][k] = -1;
127 //____________________________________________________________________________
128 AliPMDDigitizer::~AliPMDDigitizer()
130 // Default Destructor
147 //____________________________________________________________________________
148 void AliPMDDigitizer::OpengAliceFile(const char *file, Option_t *option)
150 // Loads galice.root file and corresponding header, kinematics
151 // hits and sdigits or digits depending on the option
154 TString evfoldname = AliConfig::GetDefaultEventFolderName();
155 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
157 fRunLoader = AliRunLoader::Open(file,AliConfig::GetDefaultEventFolderName(),
162 AliError(Form("Can not open session for file %s.",file));
165 if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice();
166 if (!fRunLoader->TreeE()) fRunLoader->LoadHeader();
167 if (!fRunLoader->TreeK()) fRunLoader->LoadKinematics();
169 gAlice = fRunLoader->GetAliRun();
173 AliDebug(1,"Alirun object found");
177 AliError("Could not found Alirun object");
180 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
181 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
182 if (fPMDLoader == 0x0)
184 AliError("Can not find PMDLoader");
187 const char *cHS = strstr(option,"HS");
188 const char *cHD = strstr(option,"HD");
189 const char *cSD = strstr(option,"SD");
193 fPMDLoader->LoadHits("READ");
194 fPMDLoader->LoadSDigits("recreate");
198 fPMDLoader->LoadHits("READ");
199 fPMDLoader->LoadDigits("recreate");
203 fPMDLoader->LoadSDigits("READ");
204 fPMDLoader->LoadDigits("recreate");
207 //____________________________________________________________________________
208 void AliPMDDigitizer::Hits2SDigits(Int_t ievt)
210 // This reads the PMD Hits tree and assigns the right track number
211 // to a cell and stores in the summable digits tree
214 const Int_t kPi0 = 111;
215 const Int_t kGamma = 22;
223 Float_t xPos, yPos, zPos;
224 Int_t xpad = -1, ypad = -1;
226 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
229 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
232 AliDebug(1,Form("Event Number = %d",ievt));
233 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
234 AliDebug(1,Form("Number of Particles = %d",nparticles));
235 fRunLoader->GetEvent(ievt);
236 // ------------------------------------------------------- //
237 // Pointer to specific detector hits.
238 // Get pointers to Alice detectors and Hits containers
240 TTree* treeH = fPMDLoader->TreeH();
242 Int_t ntracks = (Int_t) treeH->GetEntries();
243 AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks));
244 TTree* treeS = fPMDLoader->TreeS();
247 fPMDLoader->MakeTree("S");
248 treeS = fPMDLoader->TreeS();
250 Int_t bufsize = 16000;
251 treeS->Branch("PMDSDigit", &fSDigits, bufsize);
253 TClonesArray* hits = 0;
254 if (fPMD) hits = fPMD->Hits();
256 // Start loop on tracks in the hits containers
258 for (Int_t track=0; track<ntracks;track++)
261 treeH->GetEvent(track);
264 npmd = hits->GetEntriesFast();
265 for (int ipmd = 0; ipmd < npmd; ipmd++)
267 fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd);
268 trackno = fPMDHit->GetTrack();
269 // get kinematics of the particles
271 TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno);
272 trackpid = mparticle->GetPdgCode();
281 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
282 if (mparticle->GetFirstMother() == -1)
284 tracknoOld = trackno;
285 trackpidOld = trackpid;
289 while((imo = mparticle->GetFirstMother()) >= 0)
293 mparticle = gAlice->GetMCApp()->Particle(imo);
294 idmo = mparticle->GetPdgCode();
296 vx = mparticle->Vx();
297 vy = mparticle->Vy();
298 vz = mparticle->Vz();
300 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
301 //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
302 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
310 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
319 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
331 mtrackno = tracknoOld;
332 mtrackpid = trackpidOld;
338 edep = fPMDHit->GetEnergy();
339 Int_t vol1 = fPMDHit->GetVolume(1); // Column
340 Int_t vol2 = fPMDHit->GetVolume(2); // Row
341 Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule
342 Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
344 // -----------------------------------------//
345 // For Super Module 1 & 2 //
346 // nrow = 96, ncol = 48 //
347 // For Super Module 3 & 4 //
348 // nrow = 48, ncol = 96 //
349 // -----------------------------------------//
351 smnumber = (vol6-1)*6 + vol3;
353 if (vol6 == 1 || vol6 == 2)
358 else if (vol6 == 3 || vol6 == 4)
364 AliDebug(2,Form("Zposition = %f Edeposition = %f",zPos,edep));
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");
438 //____________________________________________________________________________
440 void AliPMDDigitizer::Hits2Digits(Int_t ievt)
442 // This reads the PMD Hits tree and assigns the right track number
443 // to a cell and stores in the digits tree
445 const Int_t kPi0 = 111;
446 const Int_t kGamma = 22;
454 Float_t xPos, yPos, zPos;
455 Int_t xpad = -1, ypad = -1;
457 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
459 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
462 AliDebug(1,Form("Event Number = %d",ievt));
463 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
464 AliDebug(1,Form("Number of Particles = %d", nparticles));
465 fRunLoader->GetEvent(ievt);
466 // ------------------------------------------------------- //
467 // Pointer to specific detector hits.
468 // Get pointers to Alice detectors and Hits containers
470 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
471 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
473 if (fPMDLoader == 0x0)
475 AliError("Can not find PMD or PMDLoader");
477 TTree* treeH = fPMDLoader->TreeH();
478 Int_t ntracks = (Int_t) treeH->GetEntries();
479 AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks));
480 fPMDLoader->LoadDigits("recreate");
481 TTree* treeD = fPMDLoader->TreeD();
484 fPMDLoader->MakeTree("D");
485 treeD = fPMDLoader->TreeD();
487 Int_t bufsize = 16000;
488 treeD->Branch("PMDDigit", &fDigits, bufsize);
490 TClonesArray* hits = 0;
491 if (fPMD) hits = fPMD->Hits();
493 // Start loop on tracks in the hits containers
495 for (Int_t track=0; track<ntracks;track++)
498 treeH->GetEvent(track);
502 npmd = hits->GetEntriesFast();
503 for (int ipmd = 0; ipmd < npmd; ipmd++)
505 fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd);
506 trackno = fPMDHit->GetTrack();
508 // get kinematics of the particles
510 TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno);
511 trackpid = mparticle->GetPdgCode();
520 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
521 if (mparticle->GetFirstMother() == -1)
523 tracknoOld = trackno;
524 trackpidOld = trackpid;
529 while((imo = mparticle->GetFirstMother()) >= 0)
533 mparticle = gAlice->GetMCApp()->Particle(imo);
534 idmo = mparticle->GetPdgCode();
536 vx = mparticle->Vx();
537 vy = mparticle->Vy();
538 vz = mparticle->Vz();
540 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
541 //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
542 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
550 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
559 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
571 mtrackno = tracknoOld;
572 mtrackpid = trackpidOld;
579 Int_t vol1 = fPMDHit->GetVolume(1); // Column
580 Int_t vol2 = fPMDHit->GetVolume(2); // Row
581 Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule
582 Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
583 edep = fPMDHit->GetEnergy();
585 // -----------------------------------------//
586 // For Super Module 1 & 2 //
587 // nrow = 96, ncol = 48 //
588 // For Super Module 3 & 4 //
589 // nrow = 48, ncol = 96 //
590 // -----------------------------------------//
592 smnumber = (vol6-1)*6 + vol3;
594 if (vol6 == 1 || vol6 == 2)
599 else if (vol6 == 3 || vol6 == 4)
605 AliDebug(2,Form("ZPosition = %f Edeposition = %d",zPos,edep));
606 Float_t zposition = TMath::Abs(zPos);
608 if (zposition < fZPos)
613 else if (zposition > fZPos)
619 Int_t smn = smnumber - 1;
620 Int_t ixx = xpad - 1;
621 Int_t iyy = ypad - 1;
624 fPRE[smn][ixx][iyy] += edep;
625 fPRECounter[smn][ixx][iyy]++;
627 AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep);
633 fCPV[smn][ixx][iyy] += edep;
634 fCPVTrackNo[smn][ixx][iyy] = mtrackno;
638 } // Track Loop ended
640 TrackAssignment2Cell();
648 for (Int_t idet = 0; idet < 2; idet++)
650 for (Int_t ism = 0; ism < fgkTotUM; ism++)
652 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
654 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
658 gain1 = Gain(idet,ism,jrow,kcol);
660 deltaE = fPRE[ism][jrow][kcol]*gain1;
661 trno = fPRETrackNo[ism][jrow][kcol];
666 gain1 = Gain(idet,ism,jrow,kcol);
667 deltaE = fCPV[ism][jrow][kcol]*gain1;
668 trno = fCPVTrackNo[ism][jrow][kcol];
674 AddDigit(trno,detno,ism,jrow,kcol,adc);
680 } // supermodule loop
683 fPMDLoader->WriteDigits("OVERWRITE");
687 //____________________________________________________________________________
690 void AliPMDDigitizer::SDigits2Digits(Int_t ievt)
692 // This reads the PMD sdigits tree and converts energy deposition
693 // in a cell to ADC and stores in the digits tree
696 fRunLoader->GetEvent(ievt);
698 TTree* treeS = fPMDLoader->TreeS();
699 AliPMDsdigit *pmdsdigit;
700 TBranch *branch = treeS->GetBranch("PMDSDigit");
703 AliError("PMD Sdigit branch does not exist");
706 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
707 branch->SetAddress(&fSDigits);
709 TTree* treeD = fPMDLoader->TreeD();
712 fPMDLoader->MakeTree("D");
713 treeD = fPMDLoader->TreeD();
715 Int_t bufsize = 16000;
716 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
717 treeD->Branch("PMDDigit", &fDigits, bufsize);
719 Int_t trno, det, smn;
723 Int_t nmodules = (Int_t) treeS->GetEntries();
724 AliDebug(1,Form("Number of modules = %d",nmodules));
726 for (Int_t imodule = 0; imodule < nmodules; imodule++)
728 treeS->GetEntry(imodule);
729 Int_t nentries = fSDigits->GetLast();
730 AliDebug(2,Form("Number of entries per module = %d",nentries+1));
731 for (Int_t ient = 0; ient < nentries+1; ient++)
733 pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
734 trno = pmdsdigit->GetTrackNumber();
735 det = pmdsdigit->GetDetector();
736 smn = pmdsdigit->GetSMNumber();
737 irow = pmdsdigit->GetRow();
738 icol = pmdsdigit->GetColumn();
739 edep = pmdsdigit->GetCellEdep();
742 AddDigit(trno,det,smn,irow,icol,adc);
747 fPMDLoader->WriteDigits("OVERWRITE");
750 //____________________________________________________________________________
751 void AliPMDDigitizer::Exec(Option_t *option)
753 // Does the event merging and digitization
754 const char *cdeb = strstr(option,"deb");
757 AliDebug(100," *** PMD Exec is called ***");
760 Int_t ninputs = fManager->GetNinputs();
761 AliDebug(1,Form("Number of files to be processed = %d",ninputs));
764 for (Int_t i = 0; i < ninputs; i++)
766 Int_t troffset = fManager->GetMask(i);
767 MergeSDigits(i, troffset);
770 fRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
771 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
772 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
773 if (fPMDLoader == 0x0)
775 AliError("Can not find PMD or PMDLoader");
777 fPMDLoader->LoadDigits("update");
778 TTree* treeD = fPMDLoader->TreeD();
781 fPMDLoader->MakeTree("D");
782 treeD = fPMDLoader->TreeD();
784 Int_t bufsize = 16000;
785 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
786 treeD->Branch("PMDDigit", &fDigits, bufsize);
793 for (Int_t idet = 0; idet < 2; idet++)
795 for (Int_t ism = 0; ism < fgkTotUM; ism++)
797 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
799 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
803 deltaE = fPRE[ism][jrow][kcol];
804 trno = fPRETrackNo[ism][jrow][kcol];
809 deltaE = fCPV[ism][jrow][kcol];
810 trno = fCPVTrackNo[ism][jrow][kcol];
816 AddDigit(trno,detno,ism,jrow,kcol,adc);
822 } // supermodule loop
824 fPMDLoader->WriteDigits("OVERWRITE");
825 fPMDLoader->UnloadDigits();
828 //____________________________________________________________________________
830 void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset)
833 fRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(filenumber));
834 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
835 fPMDLoader->LoadSDigits("read");
836 TTree* treeS = fPMDLoader->TreeS();
837 AliPMDsdigit *pmdsdigit;
838 TBranch *branch = treeS->GetBranch("PMDSDigit");
839 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
840 branch->SetAddress(&fSDigits);
842 Int_t itrackno, idet, ism;
845 Int_t nmodules = (Int_t) treeS->GetEntries();
846 AliDebug(1,Form("Number of Modules in the treeS = %d",nmodules));
847 AliDebug(1,Form("Track Offset = %d",troffset));
848 for (Int_t imodule = 0; imodule < nmodules; imodule++)
850 treeS->GetEntry(imodule);
851 Int_t nentries = fSDigits->GetLast();
852 AliDebug(2,Form("Number of Entries per Module = %d",nentries));
853 for (Int_t ient = 0; ient < nentries+1; ient++)
855 pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
856 itrackno = pmdsdigit->GetTrackNumber();
857 idet = pmdsdigit->GetDetector();
858 ism = pmdsdigit->GetSMNumber();
859 ixp = pmdsdigit->GetRow();
860 iyp = pmdsdigit->GetColumn();
861 edep = pmdsdigit->GetCellEdep();
864 if (fPRE[ism][ixp][iyp] < edep)
866 fPRETrackNo[ism][ixp][iyp] = troffset + itrackno;
868 fPRE[ism][ixp][iyp] += edep;
872 if (fCPV[ism][ixp][iyp] < edep)
874 fCPVTrackNo[ism][ixp][iyp] = troffset + itrackno;
876 fCPV[ism][ixp][iyp] += edep;
882 // ----------------------------------------------------------------------
883 void AliPMDDigitizer::TrackAssignment2Cell()
886 // This block assigns the cell id when there are
887 // multiple tracks in a cell according to the
890 Bool_t jsort = false;
902 pmdTrack = new Int_t ***[fgkTotUM];
903 pmdEdep = new Float_t ***[fgkTotUM];
904 for (i=0; i<fgkTotUM; i++)
906 pmdTrack[i] = new Int_t **[fgkRow];
907 pmdEdep[i] = new Float_t **[fgkRow];
910 for (i = 0; i < fgkTotUM; i++)
912 for (j = 0; j < fgkRow; j++)
914 pmdTrack[i][j] = new Int_t *[fgkCol];
915 pmdEdep[i][j] = new Float_t *[fgkCol];
919 for (i = 0; i < fgkTotUM; i++)
921 for (j = 0; j < fgkRow; j++)
923 for (k = 0; k < fgkCol; k++)
925 Int_t nn = fPRECounter[i][j][k];
928 pmdTrack[i][j][k] = new Int_t[nn];
929 pmdEdep[i][j][k] = new Float_t[nn];
934 pmdTrack[i][j][k] = new Int_t[nn];
935 pmdEdep[i][j][k] = new Float_t[nn];
937 fPRECounter[i][j][k] = 0;
943 Int_t nentries = fCell.GetEntries();
945 Int_t mtrackno, ism, ixp, iyp;
948 for (i = 0; i < nentries; i++)
950 AliPMDcell* cell = (AliPMDcell*)fCell.UncheckedAt(i);
952 mtrackno = cell->GetTrackNumber();
953 ism = cell->GetSMNumber();
956 edep = cell->GetEdep();
957 Int_t nn = fPRECounter[ism][ixp][iyp];
958 pmdTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno;
959 pmdEdep[ism][ixp][iyp][nn] = edep;
960 fPRECounter[ism][ixp][iyp]++;
967 for (im=0; im<fgkTotUM; im++)
969 for (ix=0; ix<fgkRow; ix++)
971 for (iy=0; iy<fgkCol; iy++)
973 nn = fPRECounter[im][ix][iy];
976 // This block handles if a cell is fired
977 // many times by many tracks
978 status1 = new Int_t[nn];
979 status2 = new Int_t[nn];
980 trnarray = new Int_t[nn];
981 for (iz = 0; iz < nn; iz++)
983 status1[iz] = pmdTrack[im][ix][iy][iz];
985 TMath::Sort(nn,status1,status2,jsort);
986 Int_t trackOld = -99999;
987 Int_t track, trCount = 0;
988 for (iz = 0; iz < nn; iz++)
990 track = status1[status2[iz]];
991 if (trackOld != track)
993 trnarray[trCount] = track;
1000 Float_t totEdp = 0.;
1001 trEdp = new Float_t[trCount];
1002 fracEdp = new Float_t[trCount];
1003 for (il = 0; il < trCount; il++)
1006 track = trnarray[il];
1007 for (iz = 0; iz < nn; iz++)
1009 if (track == pmdTrack[im][ix][iy][iz])
1011 trEdp[il] += pmdEdep[im][ix][iy][iz];
1014 totEdp += trEdp[il];
1017 Float_t fracOld = 0.;
1019 for (il = 0; il < trCount; il++)
1021 fracEdp[il] = trEdp[il]/totEdp;
1022 if (fracOld < fracEdp[il])
1024 fracOld = fracEdp[il];
1028 fPRETrackNo[im][ix][iy] = trnarray[ilOld];
1035 // This only handles if a cell is fired
1036 // by only one track
1038 fPRETrackNo[im][ix][iy] = pmdTrack[im][ix][iy][0];
1043 // This is if no cell is fired
1044 fPRETrackNo[im][ix][iy] = -999;
1050 // Delete all the pointers
1052 for (i = 0; i < fgkTotUM; i++)
1054 for (j = 0; j < fgkRow; j++)
1056 for (k = 0; k < fgkCol; k++)
1058 delete [] pmdTrack[i][j][k];
1059 delete [] pmdEdep[i][j][k];
1064 for (i = 0; i < fgkTotUM; i++)
1066 for (j = 0; j < fgkRow; j++)
1068 delete [] pmdTrack[i][j];
1069 delete [] pmdEdep[i][j];
1073 for (i = 0; i < fgkTotUM; i++)
1075 delete [] pmdTrack[i];
1076 delete [] pmdEdep[i];
1081 // End of the cell id assignment
1084 //____________________________________________________________________________
1085 void AliPMDDigitizer::MeV2ADC(Float_t mev, Float_t & adc) const
1087 // This converts the simulated edep to ADC according to the
1092 // PS Test in September 2003
1093 // MeV - ADC conversion for 10bit ADC
1095 const Float_t kConstant = 7.181;
1096 const Float_t kErConstant = 0.6899;
1097 const Float_t kSlope = 35.93;
1098 const Float_t kErSlope = 0.306;
1100 //gRandom->SetSeed();
1102 Float_t cons = gRandom->Gaus(kConstant,kErConstant);
1103 Float_t slop = gRandom->Gaus(kSlope,kErSlope);
1105 Float_t adc10bit = slop*mev*0.001 + cons;
1109 Int_t adc12bit = (Int_t) (4.0*adc10bit);
1113 adc = (Float_t) adc12bit;
1115 else if (adc12bit >= 3000)
1121 //____________________________________________________________________________
1122 void AliPMDDigitizer::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber,
1123 Int_t irow, Int_t icol, Float_t adc)
1127 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
1128 TClonesArray &lsdigits = *fSDigits;
1129 new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc);
1131 //____________________________________________________________________________
1133 void AliPMDDigitizer::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber,
1134 Int_t irow, Int_t icol, Float_t adc)
1138 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
1139 TClonesArray &ldigits = *fDigits;
1140 new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc);
1142 //____________________________________________________________________________
1144 void AliPMDDigitizer::SetZPosition(Float_t zpos)
1148 //____________________________________________________________________________
1149 Float_t AliPMDDigitizer::GetZPosition() const
1153 //____________________________________________________________________________
1155 void AliPMDDigitizer::ResetCell()
1157 // clears the cell array and also the counter
1161 for (Int_t i = 0; i < fgkTotUM; i++)
1163 for (Int_t j = 0; j < fgkRow; j++)
1165 for (Int_t k = 0; k < fgkCol; k++)
1167 fPRECounter[i][j][k] = 0;
1172 //____________________________________________________________________________
1173 void AliPMDDigitizer::ResetSDigit()
1177 if (fSDigits) fSDigits->Delete();
1179 //____________________________________________________________________________
1180 void AliPMDDigitizer::ResetDigit()
1184 if (fDigits) fDigits->Delete();
1186 //____________________________________________________________________________
1188 void AliPMDDigitizer::ResetCellADC()
1190 // Clears individual cells edep and track number
1191 for (Int_t i = 0; i < fgkTotUM; i++)
1193 for (Int_t j = 0; j < fgkRow; j++)
1195 for (Int_t k = 0; k < fgkCol; k++)
1199 fPRETrackNo[i][j][k] = 0;
1200 fCPVTrackNo[i][j][k] = 0;
1205 //------------------------------------------------------
1206 //____________________________________________________________________________
1208 void AliPMDDigitizer::UnLoad(Option_t *option)
1210 // Unloads all the root files
1212 const char *cS = strstr(option,"S");
1213 const char *cD = strstr(option,"D");
1215 fRunLoader->UnloadgAlice();
1216 fRunLoader->UnloadHeader();
1217 fRunLoader->UnloadKinematics();
1221 fPMDLoader->UnloadHits();
1225 fPMDLoader->UnloadHits();
1226 fPMDLoader->UnloadSDigits();
1230 //----------------------------------------------------------------------
1231 Float_t AliPMDDigitizer::Gain(Int_t det, Int_t smn, Int_t row, Int_t col) const
1233 // returns of the gain of the cell
1234 // Added this method by ZA
1236 //cout<<" I am here in gain "<<fCalibData<< "smn,row, col "<<smn
1237 //<<" "<<row<<" "<<col<<endl;
1240 AliError("No calibration data loaded from CDB!!!");
1245 GainFact = fCalibData->GetGainFact(det,smn,row,col);
1246 printf("\t gain=%10.3f\n",GainFact);
1249 //----------------------------------------------------------------------
1250 AliPMDCalibData* AliPMDDigitizer::GetCalibData() const
1252 // The run number will be centralized in AliCDBManager,
1253 // you don't need to set it here!
1254 // Added this method by ZA
1255 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
1258 AliWarning("Calibration object retrieval failed! Dummy calibration will be used.");
1260 // this just remembers the actual default storage. No problem if it is null.
1261 AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage();
1262 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
1264 entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
1266 // now reset the original default storage to AliCDBManager...
1267 AliCDBManager::Instance()->SetDefaultStorage(origStorage);
1270 AliPMDCalibData *calibdata=0;
1271 if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
1273 if (!calibdata) AliError("No calibration data from calibration database !");