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 vol7 = fPMDHit->GetVolume(7); // UnitModule
342 Int_t vol8 = fPMDHit->GetVolume(8); // SuperModule
345 // -----------------------------------------//
346 // In new geometry after adding electronics //
347 // For Super Module 1 & 2 //
348 // nrow = 48, ncol = 96 //
349 // For Super Module 3 & 4 //
350 // nrow = 96, ncol = 48 //
351 // -----------------------------------------//
355 smnumber = (vol8-1)*6 + vol7;
357 if (vol8 == 1 || vol8 == 2)
362 else if (vol8 == 3 || vol8 == 4)
368 AliDebug(2,Form("Zposition = %f Edeposition = %f",zPos,edep));
369 //Float_t zposition = TMath::Abs(zPos);
375 else if (zPos > fZPos)
380 Int_t smn = smnumber - 1;
381 Int_t ixx = xpad - 1;
382 Int_t iyy = ypad - 1;
385 fPRE[smn][ixx][iyy] += edep;
386 fPRECounter[smn][ixx][iyy]++;
388 AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep);
394 fCPV[smn][ixx][iyy] += edep;
395 fCPVTrackNo[smn][ixx][iyy] = mtrackno;
399 } // Track Loop ended
401 TrackAssignment2Cell();
408 for (Int_t idet = 0; idet < 2; idet++)
410 for (Int_t ism = 0; ism < fgkTotUM; ism++)
412 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
414 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
418 deltaE = fPRE[ism][jrow][kcol];
419 trno = fPRETrackNo[ism][jrow][kcol];
424 deltaE = fCPV[ism][jrow][kcol];
425 trno = fCPVTrackNo[ism][jrow][kcol];
430 AddSDigit(trno,detno,ism,jrow,kcol,deltaE);
438 fPMDLoader->WriteSDigits("OVERWRITE");
441 //____________________________________________________________________________
443 void AliPMDDigitizer::Hits2Digits(Int_t ievt)
445 // This reads the PMD Hits tree and assigns the right track number
446 // to a cell and stores in the digits tree
448 const Int_t kPi0 = 111;
449 const Int_t kGamma = 22;
457 Float_t xPos, yPos, zPos;
458 Int_t xpad = -1, ypad = -1;
460 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
462 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
465 AliDebug(1,Form("Event Number = %d",ievt));
466 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
467 AliDebug(1,Form("Number of Particles = %d", nparticles));
468 fRunLoader->GetEvent(ievt);
469 // ------------------------------------------------------- //
470 // Pointer to specific detector hits.
471 // Get pointers to Alice detectors and Hits containers
473 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
474 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
476 if (fPMDLoader == 0x0)
478 AliError("Can not find PMD or PMDLoader");
480 TTree* treeH = fPMDLoader->TreeH();
481 Int_t ntracks = (Int_t) treeH->GetEntries();
482 AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks));
483 fPMDLoader->LoadDigits("recreate");
484 TTree* treeD = fPMDLoader->TreeD();
487 fPMDLoader->MakeTree("D");
488 treeD = fPMDLoader->TreeD();
490 Int_t bufsize = 16000;
491 treeD->Branch("PMDDigit", &fDigits, bufsize);
493 TClonesArray* hits = 0;
494 if (fPMD) hits = fPMD->Hits();
496 // Start loop on tracks in the hits containers
498 for (Int_t track=0; track<ntracks;track++)
501 treeH->GetEvent(track);
505 npmd = hits->GetEntriesFast();
506 for (int ipmd = 0; ipmd < npmd; ipmd++)
508 fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd);
509 trackno = fPMDHit->GetTrack();
511 // get kinematics of the particles
513 TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno);
514 trackpid = mparticle->GetPdgCode();
523 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
524 if (mparticle->GetFirstMother() == -1)
526 tracknoOld = trackno;
527 trackpidOld = trackpid;
532 while((imo = mparticle->GetFirstMother()) >= 0)
536 mparticle = gAlice->GetMCApp()->Particle(imo);
537 idmo = mparticle->GetPdgCode();
539 vx = mparticle->Vx();
540 vy = mparticle->Vy();
541 vz = mparticle->Vz();
543 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
544 //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
545 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
553 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
562 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
574 mtrackno = tracknoOld;
575 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 vol7 = fPMDHit->GetVolume(7); // UnitModule
585 Int_t vol8 = fPMDHit->GetVolume(8); // SuperModule
588 // -----------------------------------------//
589 // In new geometry after adding electronics //
590 // For Super Module 1 & 2 //
591 // nrow = 48, ncol = 96 //
592 // For Super Module 3 & 4 //
593 // nrow = 96, ncol = 48 //
594 // -----------------------------------------//
596 smnumber = (vol8-1)*6 + vol7;
598 if (vol8 == 1 || vol8 == 2)
603 else if (vol8 == 3 || vol8 == 4)
609 AliDebug(2,Form("ZPosition = %f Edeposition = %d",zPos,edep));
610 //Float_t zposition = TMath::Abs(zPos);
617 else if (zPos > fZPos)
623 Int_t smn = smnumber - 1;
624 Int_t ixx = xpad - 1;
625 Int_t iyy = ypad - 1;
628 fPRE[smn][ixx][iyy] += edep;
629 fPRECounter[smn][ixx][iyy]++;
631 AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep);
637 fCPV[smn][ixx][iyy] += edep;
638 fCPVTrackNo[smn][ixx][iyy] = mtrackno;
642 } // Track Loop ended
644 TrackAssignment2Cell();
652 for (Int_t idet = 0; idet < 2; idet++)
654 for (Int_t ism = 0; ism < fgkTotUM; ism++)
656 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
658 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
662 gain1 = Gain(idet,ism,jrow,kcol);
664 deltaE = fPRE[ism][jrow][kcol]*gain1;
665 trno = fPRETrackNo[ism][jrow][kcol];
670 gain1 = Gain(idet,ism,jrow,kcol);
671 deltaE = fCPV[ism][jrow][kcol]*gain1;
672 trno = fCPVTrackNo[ism][jrow][kcol];
678 AddDigit(trno,detno,ism,jrow,kcol,adc);
684 } // supermodule loop
687 fPMDLoader->WriteDigits("OVERWRITE");
691 //____________________________________________________________________________
694 void AliPMDDigitizer::SDigits2Digits(Int_t ievt)
696 // This reads the PMD sdigits tree and converts energy deposition
697 // in a cell to ADC and stores in the digits tree
700 fRunLoader->GetEvent(ievt);
702 TTree* treeS = fPMDLoader->TreeS();
703 AliPMDsdigit *pmdsdigit;
704 TBranch *branch = treeS->GetBranch("PMDSDigit");
707 AliError("PMD Sdigit branch does not exist");
710 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
711 branch->SetAddress(&fSDigits);
713 TTree* treeD = fPMDLoader->TreeD();
716 fPMDLoader->MakeTree("D");
717 treeD = fPMDLoader->TreeD();
719 Int_t bufsize = 16000;
720 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
721 treeD->Branch("PMDDigit", &fDigits, bufsize);
723 Int_t trno, det, smn;
727 Int_t nmodules = (Int_t) treeS->GetEntries();
728 AliDebug(1,Form("Number of modules = %d",nmodules));
730 for (Int_t imodule = 0; imodule < nmodules; imodule++)
732 treeS->GetEntry(imodule);
733 Int_t nentries = fSDigits->GetLast();
734 AliDebug(2,Form("Number of entries per module = %d",nentries+1));
735 for (Int_t ient = 0; ient < nentries+1; ient++)
737 pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
738 trno = pmdsdigit->GetTrackNumber();
739 det = pmdsdigit->GetDetector();
740 smn = pmdsdigit->GetSMNumber();
741 irow = pmdsdigit->GetRow();
742 icol = pmdsdigit->GetColumn();
743 edep = pmdsdigit->GetCellEdep();
746 AddDigit(trno,det,smn,irow,icol,adc);
751 fPMDLoader->WriteDigits("OVERWRITE");
754 //____________________________________________________________________________
755 void AliPMDDigitizer::Exec(Option_t *option)
757 // Does the event merging and digitization
758 const char *cdeb = strstr(option,"deb");
761 AliDebug(100," *** PMD Exec is called ***");
764 Int_t ninputs = fManager->GetNinputs();
765 AliDebug(1,Form("Number of files to be processed = %d",ninputs));
768 for (Int_t i = 0; i < ninputs; i++)
770 Int_t troffset = fManager->GetMask(i);
771 MergeSDigits(i, troffset);
774 fRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
775 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
776 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
777 if (fPMDLoader == 0x0)
779 AliError("Can not find PMD or PMDLoader");
781 fPMDLoader->LoadDigits("update");
782 TTree* treeD = fPMDLoader->TreeD();
785 fPMDLoader->MakeTree("D");
786 treeD = fPMDLoader->TreeD();
788 Int_t bufsize = 16000;
789 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
790 treeD->Branch("PMDDigit", &fDigits, bufsize);
797 for (Int_t idet = 0; idet < 2; idet++)
799 for (Int_t ism = 0; ism < fgkTotUM; ism++)
801 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
803 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
807 deltaE = fPRE[ism][jrow][kcol];
808 trno = fPRETrackNo[ism][jrow][kcol];
813 deltaE = fCPV[ism][jrow][kcol];
814 trno = fCPVTrackNo[ism][jrow][kcol];
820 AddDigit(trno,detno,ism,jrow,kcol,adc);
826 } // supermodule loop
828 fPMDLoader->WriteDigits("OVERWRITE");
829 fPMDLoader->UnloadDigits();
832 //____________________________________________________________________________
834 void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset)
837 fRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(filenumber));
838 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
839 fPMDLoader->LoadSDigits("read");
840 TTree* treeS = fPMDLoader->TreeS();
841 AliPMDsdigit *pmdsdigit;
842 TBranch *branch = treeS->GetBranch("PMDSDigit");
843 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
844 branch->SetAddress(&fSDigits);
846 Int_t itrackno, idet, ism;
849 Int_t nmodules = (Int_t) treeS->GetEntries();
850 AliDebug(1,Form("Number of Modules in the treeS = %d",nmodules));
851 AliDebug(1,Form("Track Offset = %d",troffset));
852 for (Int_t imodule = 0; imodule < nmodules; imodule++)
854 treeS->GetEntry(imodule);
855 Int_t nentries = fSDigits->GetLast();
856 AliDebug(2,Form("Number of Entries per Module = %d",nentries));
857 for (Int_t ient = 0; ient < nentries+1; ient++)
859 pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
860 itrackno = pmdsdigit->GetTrackNumber();
861 idet = pmdsdigit->GetDetector();
862 ism = pmdsdigit->GetSMNumber();
863 ixp = pmdsdigit->GetRow();
864 iyp = pmdsdigit->GetColumn();
865 edep = pmdsdigit->GetCellEdep();
868 if (fPRE[ism][ixp][iyp] < edep)
870 fPRETrackNo[ism][ixp][iyp] = troffset + itrackno;
872 fPRE[ism][ixp][iyp] += edep;
876 if (fCPV[ism][ixp][iyp] < edep)
878 fCPVTrackNo[ism][ixp][iyp] = troffset + itrackno;
880 fCPV[ism][ixp][iyp] += edep;
886 // ----------------------------------------------------------------------
887 void AliPMDDigitizer::TrackAssignment2Cell()
890 // This block assigns the cell id when there are
891 // multiple tracks in a cell according to the
894 Bool_t jsort = false;
906 pmdTrack = new Int_t ***[fgkTotUM];
907 pmdEdep = new Float_t ***[fgkTotUM];
908 for (i=0; i<fgkTotUM; i++)
910 pmdTrack[i] = new Int_t **[fgkRow];
911 pmdEdep[i] = new Float_t **[fgkRow];
914 for (i = 0; i < fgkTotUM; i++)
916 for (j = 0; j < fgkRow; j++)
918 pmdTrack[i][j] = new Int_t *[fgkCol];
919 pmdEdep[i][j] = new Float_t *[fgkCol];
923 for (i = 0; i < fgkTotUM; i++)
925 for (j = 0; j < fgkRow; j++)
927 for (k = 0; k < fgkCol; k++)
929 Int_t nn = fPRECounter[i][j][k];
932 pmdTrack[i][j][k] = new Int_t[nn];
933 pmdEdep[i][j][k] = new Float_t[nn];
938 pmdTrack[i][j][k] = new Int_t[nn];
939 pmdEdep[i][j][k] = new Float_t[nn];
941 fPRECounter[i][j][k] = 0;
947 Int_t nentries = fCell.GetEntries();
949 Int_t mtrackno, ism, ixp, iyp;
952 for (i = 0; i < nentries; i++)
954 AliPMDcell* cell = (AliPMDcell*)fCell.UncheckedAt(i);
956 mtrackno = cell->GetTrackNumber();
957 ism = cell->GetSMNumber();
960 edep = cell->GetEdep();
961 Int_t nn = fPRECounter[ism][ixp][iyp];
962 pmdTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno;
963 pmdEdep[ism][ixp][iyp][nn] = edep;
964 fPRECounter[ism][ixp][iyp]++;
971 for (im=0; im<fgkTotUM; im++)
973 for (ix=0; ix<fgkRow; ix++)
975 for (iy=0; iy<fgkCol; iy++)
977 nn = fPRECounter[im][ix][iy];
980 // This block handles if a cell is fired
981 // many times by many tracks
982 status1 = new Int_t[nn];
983 status2 = new Int_t[nn];
984 trnarray = new Int_t[nn];
985 for (iz = 0; iz < nn; iz++)
987 status1[iz] = pmdTrack[im][ix][iy][iz];
989 TMath::Sort(nn,status1,status2,jsort);
990 Int_t trackOld = -99999;
991 Int_t track, trCount = 0;
992 for (iz = 0; iz < nn; iz++)
994 track = status1[status2[iz]];
995 if (trackOld != track)
997 trnarray[trCount] = track;
1004 Float_t totEdp = 0.;
1005 trEdp = new Float_t[trCount];
1006 fracEdp = new Float_t[trCount];
1007 for (il = 0; il < trCount; il++)
1010 track = trnarray[il];
1011 for (iz = 0; iz < nn; iz++)
1013 if (track == pmdTrack[im][ix][iy][iz])
1015 trEdp[il] += pmdEdep[im][ix][iy][iz];
1018 totEdp += trEdp[il];
1021 Float_t fracOld = 0.;
1023 for (il = 0; il < trCount; il++)
1025 fracEdp[il] = trEdp[il]/totEdp;
1026 if (fracOld < fracEdp[il])
1028 fracOld = fracEdp[il];
1032 fPRETrackNo[im][ix][iy] = trnarray[ilOld];
1039 // This only handles if a cell is fired
1040 // by only one track
1042 fPRETrackNo[im][ix][iy] = pmdTrack[im][ix][iy][0];
1047 // This is if no cell is fired
1048 fPRETrackNo[im][ix][iy] = -999;
1054 // Delete all the pointers
1056 for (i = 0; i < fgkTotUM; i++)
1058 for (j = 0; j < fgkRow; j++)
1060 for (k = 0; k < fgkCol; k++)
1062 delete [] pmdTrack[i][j][k];
1063 delete [] pmdEdep[i][j][k];
1068 for (i = 0; i < fgkTotUM; i++)
1070 for (j = 0; j < fgkRow; j++)
1072 delete [] pmdTrack[i][j];
1073 delete [] pmdEdep[i][j];
1077 for (i = 0; i < fgkTotUM; i++)
1079 delete [] pmdTrack[i];
1080 delete [] pmdEdep[i];
1085 // End of the cell id assignment
1088 //____________________________________________________________________________
1089 void AliPMDDigitizer::MeV2ADC(Float_t mev, Float_t & adc) const
1091 // This converts the simulated edep to ADC according to the
1096 // PS Test in September 2003
1097 // MeV - ADC conversion for 10bit ADC
1099 const Float_t kConstant = 7.181;
1100 const Float_t kErConstant = 0.6899;
1101 const Float_t kSlope = 35.93;
1102 const Float_t kErSlope = 0.306;
1104 //gRandom->SetSeed();
1106 Float_t cons = gRandom->Gaus(kConstant,kErConstant);
1107 Float_t slop = gRandom->Gaus(kSlope,kErSlope);
1109 Float_t adc10bit = slop*mev*0.001 + cons;
1113 Int_t adc12bit = (Int_t) (4.0*adc10bit);
1117 adc = (Float_t) adc12bit;
1119 else if (adc12bit >= 3000)
1125 //____________________________________________________________________________
1126 void AliPMDDigitizer::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber,
1127 Int_t irow, Int_t icol, Float_t adc)
1131 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
1132 TClonesArray &lsdigits = *fSDigits;
1133 new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc);
1135 //____________________________________________________________________________
1137 void AliPMDDigitizer::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber,
1138 Int_t irow, Int_t icol, Float_t adc)
1142 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
1143 TClonesArray &ldigits = *fDigits;
1144 new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc);
1146 //____________________________________________________________________________
1148 void AliPMDDigitizer::SetZPosition(Float_t zpos)
1152 //____________________________________________________________________________
1153 Float_t AliPMDDigitizer::GetZPosition() const
1157 //____________________________________________________________________________
1159 void AliPMDDigitizer::ResetCell()
1161 // clears the cell array and also the counter
1165 for (Int_t i = 0; i < fgkTotUM; i++)
1167 for (Int_t j = 0; j < fgkRow; j++)
1169 for (Int_t k = 0; k < fgkCol; k++)
1171 fPRECounter[i][j][k] = 0;
1176 //____________________________________________________________________________
1177 void AliPMDDigitizer::ResetSDigit()
1181 if (fSDigits) fSDigits->Delete();
1183 //____________________________________________________________________________
1184 void AliPMDDigitizer::ResetDigit()
1188 if (fDigits) fDigits->Delete();
1190 //____________________________________________________________________________
1192 void AliPMDDigitizer::ResetCellADC()
1194 // Clears individual cells edep and track number
1195 for (Int_t i = 0; i < fgkTotUM; i++)
1197 for (Int_t j = 0; j < fgkRow; j++)
1199 for (Int_t k = 0; k < fgkCol; k++)
1203 fPRETrackNo[i][j][k] = 0;
1204 fCPVTrackNo[i][j][k] = 0;
1209 //------------------------------------------------------
1210 //____________________________________________________________________________
1212 void AliPMDDigitizer::UnLoad(Option_t *option)
1214 // Unloads all the root files
1216 const char *cS = strstr(option,"S");
1217 const char *cD = strstr(option,"D");
1219 fRunLoader->UnloadgAlice();
1220 fRunLoader->UnloadHeader();
1221 fRunLoader->UnloadKinematics();
1225 fPMDLoader->UnloadHits();
1229 fPMDLoader->UnloadHits();
1230 fPMDLoader->UnloadSDigits();
1234 //----------------------------------------------------------------------
1235 Float_t AliPMDDigitizer::Gain(Int_t det, Int_t smn, Int_t row, Int_t col) const
1237 // returns of the gain of the cell
1238 // Added this method by ZA
1240 //cout<<" I am here in gain "<<fCalibData<< "smn,row, col "<<smn
1241 //<<" "<<row<<" "<<col<<endl;
1244 AliError("No calibration data loaded from CDB!!!");
1249 GainFact = fCalibData->GetGainFact(det,smn,row,col);
1250 printf("\t gain=%10.3f\n",GainFact);
1253 //----------------------------------------------------------------------
1254 AliPMDCalibData* AliPMDDigitizer::GetCalibData() const
1256 // The run number will be centralized in AliCDBManager,
1257 // you don't need to set it here!
1258 // Added this method by ZA
1259 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
1262 AliWarning("Calibration object retrieval failed! Dummy calibration will be used.");
1264 // this just remembers the actual default storage. No problem if it is null.
1265 AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage();
1266 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
1268 entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
1270 // now reset the original default storage to AliCDBManager...
1271 AliCDBManager::Instance()->SetDefaultStorage(origStorage);
1274 AliPMDCalibData *calibdata=0;
1275 if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
1277 if (!calibdata) AliError("No calibration data from calibration database !");