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() :
66 fCalibData(GetCalibData()),
73 fZPos(361.5) // in units of cm, default position of PMD
75 // Default Constructor
77 for (Int_t i = 0; i < fgkTotUM; i++)
79 for (Int_t j = 0; j < fgkRow; j++)
81 for (Int_t k = 0; k < fgkCol; k++)
85 fPRECounter[i][j][k] = 0;
86 fPRETrackNo[i][j][k] = -1;
87 fCPVTrackNo[i][j][k] = -1;
94 //____________________________________________________________________________
95 AliPMDDigitizer::AliPMDDigitizer(const AliPMDDigitizer& digitizer):
96 AliDigitizer(digitizer),
101 fCalibData(GetCalibData()),
108 fZPos(361.5) // in units of cm, default position of PMD
111 AliError("Copy constructor not allowed ");
114 //____________________________________________________________________________
116 AliPMDDigitizer & AliPMDDigitizer::operator=(const AliPMDDigitizer& /*digitizer*/)
118 // Assignment operator
119 AliError("Assignement operator not allowed ");
123 //____________________________________________________________________________
124 AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager):
125 AliDigitizer(manager),
130 fCalibData(GetCalibData()),
131 fSDigits(new TClonesArray("AliPMDsdigit", 1000)),
132 fDigits(new TClonesArray("AliPMDdigit", 1000)),
137 fZPos(361.5)// in units of cm, This is the default position of PMD
139 // ctor which should be used
142 for (Int_t i = 0; i < fgkTotUM; i++)
144 for (Int_t j = 0; j < fgkRow; j++)
146 for (Int_t k = 0; k < fgkCol; k++)
150 fPRECounter[i][j][k] = 0;
151 fPRETrackNo[i][j][k] = -1;
152 fCPVTrackNo[i][j][k] = -1;
158 //____________________________________________________________________________
159 AliPMDDigitizer::~AliPMDDigitizer()
161 // Default Destructor
178 //____________________________________________________________________________
179 void AliPMDDigitizer::OpengAliceFile(const char *file, Option_t *option)
181 // Loads galice.root file and corresponding header, kinematics
182 // hits and sdigits or digits depending on the option
185 TString evfoldname = AliConfig::GetDefaultEventFolderName();
186 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
188 fRunLoader = AliRunLoader::Open(file,AliConfig::GetDefaultEventFolderName(),
193 AliError(Form("Can not open session for file %s.",file));
196 if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice();
197 if (!fRunLoader->TreeE()) fRunLoader->LoadHeader();
198 if (!fRunLoader->TreeK()) fRunLoader->LoadKinematics();
200 gAlice = fRunLoader->GetAliRun();
204 AliDebug(1,"Alirun object found");
208 AliError("Could not found Alirun object");
211 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
212 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
213 if (fPMDLoader == 0x0)
215 AliError("Can not find PMDLoader");
218 const char *cHS = strstr(option,"HS");
219 const char *cHD = strstr(option,"HD");
220 const char *cSD = strstr(option,"SD");
224 fPMDLoader->LoadHits("READ");
225 fPMDLoader->LoadSDigits("recreate");
229 fPMDLoader->LoadHits("READ");
230 fPMDLoader->LoadDigits("recreate");
234 fPMDLoader->LoadSDigits("READ");
235 fPMDLoader->LoadDigits("recreate");
238 //____________________________________________________________________________
239 void AliPMDDigitizer::Hits2SDigits(Int_t ievt)
241 // This reads the PMD Hits tree and assigns the right track number
242 // to a cell and stores in the summable digits tree
245 const Int_t kPi0 = 111;
246 const Int_t kGamma = 22;
254 Float_t xPos, yPos, zPos;
255 Int_t xpad = -1, ypad = -1;
257 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
260 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
263 AliDebug(1,Form("Event Number = %d",ievt));
264 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
265 AliDebug(1,Form("Number of Particles = %d",nparticles));
266 fRunLoader->GetEvent(ievt);
267 // ------------------------------------------------------- //
268 // Pointer to specific detector hits.
269 // Get pointers to Alice detectors and Hits containers
271 TTree* treeH = fPMDLoader->TreeH();
273 Int_t ntracks = (Int_t) treeH->GetEntries();
274 AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks));
275 TTree* treeS = fPMDLoader->TreeS();
278 fPMDLoader->MakeTree("S");
279 treeS = fPMDLoader->TreeS();
281 Int_t bufsize = 16000;
282 treeS->Branch("PMDSDigit", &fSDigits, bufsize);
284 TClonesArray* hits = 0;
285 if (fPMD) hits = fPMD->Hits();
287 // Start loop on tracks in the hits containers
289 for (Int_t track=0; track<ntracks;track++)
292 treeH->GetEvent(track);
295 npmd = hits->GetEntriesFast();
296 for (int ipmd = 0; ipmd < npmd; ipmd++)
298 fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd);
299 trackno = fPMDHit->GetTrack();
300 // get kinematics of the particles
302 TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno);
303 trackpid = mparticle->GetPdgCode();
312 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
313 if (mparticle->GetFirstMother() == -1)
315 tracknoOld = trackno;
316 trackpidOld = trackpid;
320 while((imo = mparticle->GetFirstMother()) >= 0)
324 mparticle = gAlice->GetMCApp()->Particle(imo);
325 idmo = mparticle->GetPdgCode();
327 vx = mparticle->Vx();
328 vy = mparticle->Vy();
329 vz = mparticle->Vz();
331 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
332 //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
333 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
341 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
350 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
362 mtrackno = tracknoOld;
363 mtrackpid = trackpidOld;
369 edep = fPMDHit->GetEnergy();
370 Int_t vol1 = fPMDHit->GetVolume(1); // Column
371 Int_t vol2 = fPMDHit->GetVolume(2); // Row
372 Int_t vol7 = fPMDHit->GetVolume(7); // UnitModule
373 Int_t vol8 = fPMDHit->GetVolume(8); // SuperModule
376 // -----------------------------------------//
377 // In new geometry after adding electronics //
378 // For Super Module 1 & 2 //
379 // nrow = 48, ncol = 96 //
380 // For Super Module 3 & 4 //
381 // nrow = 96, ncol = 48 //
382 // -----------------------------------------//
386 smnumber = (vol8-1)*6 + vol7;
388 if (vol8 == 1 || vol8 == 2)
393 else if (vol8 == 3 || vol8 == 4)
399 AliDebug(2,Form("Zposition = %f Edeposition = %f",zPos,edep));
400 //Float_t zposition = TMath::Abs(zPos);
406 else if (zPos > fZPos)
411 Int_t smn = smnumber - 1;
412 Int_t ixx = xpad - 1;
413 Int_t iyy = ypad - 1;
416 fPRE[smn][ixx][iyy] += edep;
417 fPRECounter[smn][ixx][iyy]++;
419 AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep);
425 fCPV[smn][ixx][iyy] += edep;
426 fCPVTrackNo[smn][ixx][iyy] = mtrackno;
430 } // Track Loop ended
432 TrackAssignment2Cell();
439 for (Int_t idet = 0; idet < 2; idet++)
441 for (Int_t ism = 0; ism < fgkTotUM; ism++)
443 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
445 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
449 deltaE = fPRE[ism][jrow][kcol];
450 trno = fPRETrackNo[ism][jrow][kcol];
455 deltaE = fCPV[ism][jrow][kcol];
456 trno = fCPVTrackNo[ism][jrow][kcol];
461 AddSDigit(trno,detno,ism,jrow,kcol,deltaE);
469 fPMDLoader->WriteSDigits("OVERWRITE");
472 //____________________________________________________________________________
474 void AliPMDDigitizer::Hits2Digits(Int_t ievt)
476 // This reads the PMD Hits tree and assigns the right track number
477 // to a cell and stores in the digits tree
479 const Int_t kPi0 = 111;
480 const Int_t kGamma = 22;
488 Float_t xPos, yPos, zPos;
489 Int_t xpad = -1, ypad = -1;
491 Float_t vx = -999.0, vy = -999.0, vz = -999.0;
493 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
496 AliDebug(1,Form("Event Number = %d",ievt));
497 Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
498 AliDebug(1,Form("Number of Particles = %d", nparticles));
499 fRunLoader->GetEvent(ievt);
500 // ------------------------------------------------------- //
501 // Pointer to specific detector hits.
502 // Get pointers to Alice detectors and Hits containers
504 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
505 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
507 if (fPMDLoader == 0x0)
509 AliError("Can not find PMD or PMDLoader");
511 TTree* treeH = fPMDLoader->TreeH();
512 Int_t ntracks = (Int_t) treeH->GetEntries();
513 AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks));
514 fPMDLoader->LoadDigits("recreate");
515 TTree* treeD = fPMDLoader->TreeD();
518 fPMDLoader->MakeTree("D");
519 treeD = fPMDLoader->TreeD();
521 Int_t bufsize = 16000;
522 treeD->Branch("PMDDigit", &fDigits, bufsize);
524 TClonesArray* hits = 0;
525 if (fPMD) hits = fPMD->Hits();
527 // Start loop on tracks in the hits containers
529 for (Int_t track=0; track<ntracks;track++)
532 treeH->GetEvent(track);
536 npmd = hits->GetEntriesFast();
537 for (int ipmd = 0; ipmd < npmd; ipmd++)
539 fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd);
540 trackno = fPMDHit->GetTrack();
542 // get kinematics of the particles
544 TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno);
545 trackpid = mparticle->GetPdgCode();
554 Int_t tracknoOld=0, trackpidOld=0, statusOld = 0;
555 if (mparticle->GetFirstMother() == -1)
557 tracknoOld = trackno;
558 trackpidOld = trackpid;
563 while((imo = mparticle->GetFirstMother()) >= 0)
567 mparticle = gAlice->GetMCApp()->Particle(imo);
568 idmo = mparticle->GetPdgCode();
570 vx = mparticle->Vx();
571 vy = mparticle->Vy();
572 vz = mparticle->Vz();
574 //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
575 //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz);
576 if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.)
584 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
593 if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.)
605 mtrackno = tracknoOld;
606 mtrackpid = trackpidOld;
612 edep = fPMDHit->GetEnergy();
613 Int_t vol1 = fPMDHit->GetVolume(1); // Column
614 Int_t vol2 = fPMDHit->GetVolume(2); // Row
615 Int_t vol7 = fPMDHit->GetVolume(7); // UnitModule
616 Int_t vol8 = fPMDHit->GetVolume(8); // SuperModule
619 // -----------------------------------------//
620 // In new geometry after adding electronics //
621 // For Super Module 1 & 2 //
622 // nrow = 48, ncol = 96 //
623 // For Super Module 3 & 4 //
624 // nrow = 96, ncol = 48 //
625 // -----------------------------------------//
627 smnumber = (vol8-1)*6 + vol7;
629 if (vol8 == 1 || vol8 == 2)
634 else if (vol8 == 3 || vol8 == 4)
640 AliDebug(2,Form("ZPosition = %f Edeposition = %d",zPos,edep));
641 //Float_t zposition = TMath::Abs(zPos);
648 else if (zPos > fZPos)
654 Int_t smn = smnumber - 1;
655 Int_t ixx = xpad - 1;
656 Int_t iyy = ypad - 1;
659 fPRE[smn][ixx][iyy] += edep;
660 fPRECounter[smn][ixx][iyy]++;
662 AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep);
668 fCPV[smn][ixx][iyy] += edep;
669 fCPVTrackNo[smn][ixx][iyy] = mtrackno;
673 } // Track Loop ended
675 TrackAssignment2Cell();
683 for (Int_t idet = 0; idet < 2; idet++)
685 for (Int_t ism = 0; ism < fgkTotUM; ism++)
687 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
689 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
693 gain1 = Gain(idet,ism,jrow,kcol);
695 deltaE = fPRE[ism][jrow][kcol]*gain1;
696 trno = fPRETrackNo[ism][jrow][kcol];
701 gain1 = Gain(idet,ism,jrow,kcol);
702 deltaE = fCPV[ism][jrow][kcol]*gain1;
703 trno = fCPVTrackNo[ism][jrow][kcol];
709 AddDigit(trno,detno,ism,jrow,kcol,adc);
715 } // supermodule loop
718 fPMDLoader->WriteDigits("OVERWRITE");
722 //____________________________________________________________________________
725 void AliPMDDigitizer::SDigits2Digits(Int_t ievt)
727 // This reads the PMD sdigits tree and converts energy deposition
728 // in a cell to ADC and stores in the digits tree
731 fRunLoader->GetEvent(ievt);
733 TTree* treeS = fPMDLoader->TreeS();
734 AliPMDsdigit *pmdsdigit;
735 TBranch *branch = treeS->GetBranch("PMDSDigit");
738 AliError("PMD Sdigit branch does not exist");
741 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
742 branch->SetAddress(&fSDigits);
744 TTree* treeD = fPMDLoader->TreeD();
747 fPMDLoader->MakeTree("D");
748 treeD = fPMDLoader->TreeD();
750 Int_t bufsize = 16000;
751 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
752 treeD->Branch("PMDDigit", &fDigits, bufsize);
754 Int_t trno, det, smn;
758 Int_t nmodules = (Int_t) treeS->GetEntries();
759 AliDebug(1,Form("Number of modules = %d",nmodules));
761 for (Int_t imodule = 0; imodule < nmodules; imodule++)
763 treeS->GetEntry(imodule);
764 Int_t nentries = fSDigits->GetLast();
765 AliDebug(2,Form("Number of entries per module = %d",nentries+1));
766 for (Int_t ient = 0; ient < nentries+1; ient++)
768 pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
769 trno = pmdsdigit->GetTrackNumber();
770 det = pmdsdigit->GetDetector();
771 smn = pmdsdigit->GetSMNumber();
772 irow = pmdsdigit->GetRow();
773 icol = pmdsdigit->GetColumn();
774 edep = pmdsdigit->GetCellEdep();
777 AddDigit(trno,det,smn,irow,icol,adc);
782 fPMDLoader->WriteDigits("OVERWRITE");
785 //____________________________________________________________________________
786 void AliPMDDigitizer::Exec(Option_t *option)
788 // Does the event merging and digitization
789 const char *cdeb = strstr(option,"deb");
792 AliDebug(100," *** PMD Exec is called ***");
795 Int_t ninputs = fManager->GetNinputs();
796 AliDebug(1,Form("Number of files to be processed = %d",ninputs));
799 for (Int_t i = 0; i < ninputs; i++)
801 Int_t troffset = fManager->GetMask(i);
802 MergeSDigits(i, troffset);
805 fRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
806 fPMD = (AliPMD*)gAlice->GetDetector("PMD");
807 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
808 if (fPMDLoader == 0x0)
810 AliError("Can not find PMD or PMDLoader");
812 fPMDLoader->LoadDigits("update");
813 TTree* treeD = fPMDLoader->TreeD();
816 fPMDLoader->MakeTree("D");
817 treeD = fPMDLoader->TreeD();
819 Int_t bufsize = 16000;
820 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
821 treeD->Branch("PMDDigit", &fDigits, bufsize);
828 for (Int_t idet = 0; idet < 2; idet++)
830 for (Int_t ism = 0; ism < fgkTotUM; ism++)
832 for (Int_t jrow = 0; jrow < fgkRow; jrow++)
834 for (Int_t kcol = 0; kcol < fgkCol; kcol++)
838 deltaE = fPRE[ism][jrow][kcol];
839 trno = fPRETrackNo[ism][jrow][kcol];
844 deltaE = fCPV[ism][jrow][kcol];
845 trno = fCPVTrackNo[ism][jrow][kcol];
851 AddDigit(trno,detno,ism,jrow,kcol,adc);
857 } // supermodule loop
859 fPMDLoader->WriteDigits("OVERWRITE");
860 fPMDLoader->UnloadDigits();
863 //____________________________________________________________________________
865 void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset)
868 fRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(filenumber));
869 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
870 fPMDLoader->LoadSDigits("read");
871 TTree* treeS = fPMDLoader->TreeS();
872 AliPMDsdigit *pmdsdigit;
873 TBranch *branch = treeS->GetBranch("PMDSDigit");
874 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
875 branch->SetAddress(&fSDigits);
877 Int_t itrackno, idet, ism;
880 Int_t nmodules = (Int_t) treeS->GetEntries();
881 AliDebug(1,Form("Number of Modules in the treeS = %d",nmodules));
882 AliDebug(1,Form("Track Offset = %d",troffset));
883 for (Int_t imodule = 0; imodule < nmodules; imodule++)
885 treeS->GetEntry(imodule);
886 Int_t nentries = fSDigits->GetLast();
887 AliDebug(2,Form("Number of Entries per Module = %d",nentries));
888 for (Int_t ient = 0; ient < nentries+1; ient++)
890 pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
891 itrackno = pmdsdigit->GetTrackNumber();
892 idet = pmdsdigit->GetDetector();
893 ism = pmdsdigit->GetSMNumber();
894 ixp = pmdsdigit->GetRow();
895 iyp = pmdsdigit->GetColumn();
896 edep = pmdsdigit->GetCellEdep();
899 if (fPRE[ism][ixp][iyp] < edep)
901 fPRETrackNo[ism][ixp][iyp] = troffset + itrackno;
903 fPRE[ism][ixp][iyp] += edep;
907 if (fCPV[ism][ixp][iyp] < edep)
909 fCPVTrackNo[ism][ixp][iyp] = troffset + itrackno;
911 fCPV[ism][ixp][iyp] += edep;
917 // ----------------------------------------------------------------------
918 void AliPMDDigitizer::TrackAssignment2Cell()
921 // This block assigns the cell id when there are
922 // multiple tracks in a cell according to the
925 Bool_t jsort = false;
937 pmdTrack = new Int_t ***[fgkTotUM];
938 pmdEdep = new Float_t ***[fgkTotUM];
939 for (i=0; i<fgkTotUM; i++)
941 pmdTrack[i] = new Int_t **[fgkRow];
942 pmdEdep[i] = new Float_t **[fgkRow];
945 for (i = 0; i < fgkTotUM; i++)
947 for (j = 0; j < fgkRow; j++)
949 pmdTrack[i][j] = new Int_t *[fgkCol];
950 pmdEdep[i][j] = new Float_t *[fgkCol];
954 for (i = 0; i < fgkTotUM; i++)
956 for (j = 0; j < fgkRow; j++)
958 for (k = 0; k < fgkCol; k++)
960 Int_t nn = fPRECounter[i][j][k];
963 pmdTrack[i][j][k] = new Int_t[nn];
964 pmdEdep[i][j][k] = new Float_t[nn];
969 pmdTrack[i][j][k] = new Int_t[nn];
970 pmdEdep[i][j][k] = new Float_t[nn];
972 fPRECounter[i][j][k] = 0;
978 Int_t nentries = fCell.GetEntries();
980 Int_t mtrackno, ism, ixp, iyp;
983 for (i = 0; i < nentries; i++)
985 AliPMDcell* cell = (AliPMDcell*)fCell.UncheckedAt(i);
987 mtrackno = cell->GetTrackNumber();
988 ism = cell->GetSMNumber();
991 edep = cell->GetEdep();
992 Int_t nn = fPRECounter[ism][ixp][iyp];
993 pmdTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno;
994 pmdEdep[ism][ixp][iyp][nn] = edep;
995 fPRECounter[ism][ixp][iyp]++;
1002 for (im=0; im<fgkTotUM; im++)
1004 for (ix=0; ix<fgkRow; ix++)
1006 for (iy=0; iy<fgkCol; iy++)
1008 nn = fPRECounter[im][ix][iy];
1011 // This block handles if a cell is fired
1012 // many times by many tracks
1013 status1 = new Int_t[nn];
1014 status2 = new Int_t[nn];
1015 trnarray = new Int_t[nn];
1016 for (iz = 0; iz < nn; iz++)
1018 status1[iz] = pmdTrack[im][ix][iy][iz];
1020 TMath::Sort(nn,status1,status2,jsort);
1021 Int_t trackOld = -99999;
1022 Int_t track, trCount = 0;
1023 for (iz = 0; iz < nn; iz++)
1025 track = status1[status2[iz]];
1026 if (trackOld != track)
1028 trnarray[trCount] = track;
1035 Float_t totEdp = 0.;
1036 trEdp = new Float_t[trCount];
1037 fracEdp = new Float_t[trCount];
1038 for (il = 0; il < trCount; il++)
1041 track = trnarray[il];
1042 for (iz = 0; iz < nn; iz++)
1044 if (track == pmdTrack[im][ix][iy][iz])
1046 trEdp[il] += pmdEdep[im][ix][iy][iz];
1049 totEdp += trEdp[il];
1052 Float_t fracOld = 0.;
1054 for (il = 0; il < trCount; il++)
1056 fracEdp[il] = trEdp[il]/totEdp;
1057 if (fracOld < fracEdp[il])
1059 fracOld = fracEdp[il];
1063 fPRETrackNo[im][ix][iy] = trnarray[ilOld];
1070 // This only handles if a cell is fired
1071 // by only one track
1073 fPRETrackNo[im][ix][iy] = pmdTrack[im][ix][iy][0];
1078 // This is if no cell is fired
1079 fPRETrackNo[im][ix][iy] = -999;
1085 // Delete all the pointers
1087 for (i = 0; i < fgkTotUM; i++)
1089 for (j = 0; j < fgkRow; j++)
1091 for (k = 0; k < fgkCol; k++)
1093 delete [] pmdTrack[i][j][k];
1094 delete [] pmdEdep[i][j][k];
1099 for (i = 0; i < fgkTotUM; i++)
1101 for (j = 0; j < fgkRow; j++)
1103 delete [] pmdTrack[i][j];
1104 delete [] pmdEdep[i][j];
1108 for (i = 0; i < fgkTotUM; i++)
1110 delete [] pmdTrack[i];
1111 delete [] pmdEdep[i];
1116 // End of the cell id assignment
1119 //____________________________________________________________________________
1120 void AliPMDDigitizer::MeV2ADC(Float_t mev, Float_t & adc) const
1122 // This converts the simulated edep to ADC according to the
1127 // PS Test in September 2003
1128 // MeV - ADC conversion for 10bit ADC
1130 const Float_t kConstant = 7.181;
1131 const Float_t kErConstant = 0.6899;
1132 const Float_t kSlope = 35.93;
1133 const Float_t kErSlope = 0.306;
1135 //gRandom->SetSeed();
1137 Float_t cons = gRandom->Gaus(kConstant,kErConstant);
1138 Float_t slop = gRandom->Gaus(kSlope,kErSlope);
1140 Float_t adc10bit = slop*mev*0.001 + cons;
1144 Int_t adc12bit = (Int_t) (4.0*adc10bit);
1148 adc = (Float_t) adc12bit;
1150 else if (adc12bit >= 3000)
1156 //____________________________________________________________________________
1157 void AliPMDDigitizer::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber,
1158 Int_t irow, Int_t icol, Float_t adc)
1162 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
1163 TClonesArray &lsdigits = *fSDigits;
1164 new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc);
1166 //____________________________________________________________________________
1168 void AliPMDDigitizer::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber,
1169 Int_t irow, Int_t icol, Float_t adc)
1173 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
1174 TClonesArray &ldigits = *fDigits;
1175 new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc);
1177 //____________________________________________________________________________
1179 void AliPMDDigitizer::SetZPosition(Float_t zpos)
1183 //____________________________________________________________________________
1184 Float_t AliPMDDigitizer::GetZPosition() const
1188 //____________________________________________________________________________
1190 void AliPMDDigitizer::ResetCell()
1192 // clears the cell array and also the counter
1196 for (Int_t i = 0; i < fgkTotUM; i++)
1198 for (Int_t j = 0; j < fgkRow; j++)
1200 for (Int_t k = 0; k < fgkCol; k++)
1202 fPRECounter[i][j][k] = 0;
1207 //____________________________________________________________________________
1208 void AliPMDDigitizer::ResetSDigit()
1212 if (fSDigits) fSDigits->Delete();
1214 //____________________________________________________________________________
1215 void AliPMDDigitizer::ResetDigit()
1219 if (fDigits) fDigits->Delete();
1221 //____________________________________________________________________________
1223 void AliPMDDigitizer::ResetCellADC()
1225 // Clears individual cells edep and track number
1226 for (Int_t i = 0; i < fgkTotUM; i++)
1228 for (Int_t j = 0; j < fgkRow; j++)
1230 for (Int_t k = 0; k < fgkCol; k++)
1234 fPRETrackNo[i][j][k] = 0;
1235 fCPVTrackNo[i][j][k] = 0;
1240 //------------------------------------------------------
1241 //____________________________________________________________________________
1243 void AliPMDDigitizer::UnLoad(Option_t *option)
1245 // Unloads all the root files
1247 const char *cS = strstr(option,"S");
1248 const char *cD = strstr(option,"D");
1250 fRunLoader->UnloadgAlice();
1251 fRunLoader->UnloadHeader();
1252 fRunLoader->UnloadKinematics();
1256 fPMDLoader->UnloadHits();
1260 fPMDLoader->UnloadHits();
1261 fPMDLoader->UnloadSDigits();
1265 //----------------------------------------------------------------------
1266 Float_t AliPMDDigitizer::Gain(Int_t det, Int_t smn, Int_t row, Int_t col) const
1268 // returns of the gain of the cell
1269 // Added this method by ZA
1271 //cout<<" I am here in gain "<<fCalibData<< "smn,row, col "<<smn
1272 //<<" "<<row<<" "<<col<<endl;
1275 AliError("No calibration data loaded from CDB!!!");
1280 GainFact = fCalibData->GetGainFact(det,smn,row,col);
1281 printf("\t gain=%10.3f\n",GainFact);
1284 //----------------------------------------------------------------------
1285 AliPMDCalibData* AliPMDDigitizer::GetCalibData() const
1287 // The run number will be centralized in AliCDBManager,
1288 // you don't need to set it here!
1289 // Added this method by ZA
1290 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
1293 AliWarning("Calibration object retrieval failed! Dummy calibration will be used.");
1295 // this just remembers the actual default storage. No problem if it is null.
1296 AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage();
1297 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
1299 entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
1301 // now reset the original default storage to AliCDBManager...
1302 AliCDBManager::Instance()->SetDefaultStorage(origStorage);
1305 AliPMDCalibData *calibdata=0;
1306 if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
1308 if (!calibdata) AliError("No calibration data from calibration database !");