X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=PMD%2FAliPMDDigitizer.cxx;h=0a1edd6efdd7dec25bdefa9ab7d843f0a1291ccd;hb=d2af5f819135cad2ec55c92f6532ee8a2608352c;hp=743a0142adaa8e08e0c467e40b192858bf7a24ad;hpb=5d12ce3847b64498d417a697c24fb86f715f2752;p=u%2Fmrichter%2FAliRoot.git diff --git a/PMD/AliPMDDigitizer.cxx b/PMD/AliPMDDigitizer.cxx index 743a0142ada..0a1edd6efdd 100644 --- a/PMD/AliPMDDigitizer.cxx +++ b/PMD/AliPMDDigitizer.cxx @@ -1,3 +1,17 @@ +/*************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ //-----------------------------------------------------// // // // Source File : PMDDigitizer.cxx, Version 00 // @@ -6,6 +20,7 @@ // // //-----------------------------------------------------// +#include #include #include #include @@ -15,9 +30,10 @@ #include #include #include +#include +#include "AliLog.h" #include "AliRun.h" -#include "AliPMD.h" #include "AliHit.h" #include "AliDetector.h" #include "AliRunLoader.h" @@ -25,113 +41,215 @@ #include "AliConfig.h" #include "AliMagF.h" #include "AliRunDigitizer.h" +#include "AliDigitizer.h" #include "AliHeader.h" +#include "AliCDBManager.h" +#include "AliCDBStorage.h" +#include "AliCDBEntry.h" +#include "AliMC.h" +#include "AliPMD.h" +#include "AliPMDhit.h" #include "AliPMDcell.h" #include "AliPMDsdigit.h" #include "AliPMDdigit.h" +#include "AliPMDCalibData.h" #include "AliPMDDigitizer.h" -#include "AliPMDClustering.h" -#include "AliMC.h" + ClassImp(AliPMDDigitizer) -// -// Constructor -// -AliPMDDigitizer::AliPMDDigitizer() -{ - if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); - fNsdigit = 0; - if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); - fNdigit = 0; - for (Int_t i = 0; i < fTotUM; i++) +AliPMDDigitizer::AliPMDDigitizer() : + fRunLoader(0), + fPMDHit(0), + fPMD(0), + fPMDLoader(0), + fCalibData(GetCalibData()), + fSDigits(0), + fDigits(0), + fCell(0), + fNsdigit(0), + fNdigit(0), + fDetNo(0), + fZPos(361.5) // in units of cm, default position of PMD +{ + // Default Constructor + // + for (Int_t i = 0; i < fgkTotUM; i++) { - for (Int_t j = 0; j < fRow; j++) + for (Int_t j = 0; j < fgkRow; j++) { - for (Int_t k = 0; k < fCol; k++) + for (Int_t k = 0; k < fgkCol; k++) { fCPV[i][j][k] = 0.; - fPMD[i][j][k] = 0.; + fPRE[i][j][k] = 0.; + fPRECounter[i][j][k] = 0; + fPRETrackNo[i][j][k] = -1; + fCPVTrackNo[i][j][k] = -1; } } } - if (!fCell) fCell = new TObjArray(); - fZPos = 361.5; // in units of cm, This is the default position of PMD } +//____________________________________________________________________________ +AliPMDDigitizer::AliPMDDigitizer(const AliPMDDigitizer& digitizer): + AliDigitizer(digitizer), + fRunLoader(0), + fPMDHit(0), + fPMD(0), + fPMDLoader(0), + fCalibData(GetCalibData()), + fSDigits(0), + fDigits(0), + fCell(0), + fNsdigit(0), + fNdigit(0), + fDetNo(0), + fZPos(361.5) // in units of cm, default position of PMD +{ + // copy constructor + AliError("Copy constructor not allowed "); + +} +//____________________________________________________________________________ + +AliPMDDigitizer & AliPMDDigitizer::operator=(const AliPMDDigitizer& /*digitizer*/) +{ + // Assignment operator + AliError("Assignement operator not allowed "); + + return *this; +} +//____________________________________________________________________________ +AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager): + AliDigitizer(manager), + fRunLoader(0), + fPMDHit(0), + fPMD(0), + fPMDLoader(0), + fCalibData(GetCalibData()), + fSDigits(new TClonesArray("AliPMDsdigit", 1000)), + fDigits(new TClonesArray("AliPMDdigit", 1000)), + fCell(0), + fNsdigit(0), + fNdigit(0), + fDetNo(0), + fZPos(361.5)// in units of cm, This is the default position of PMD +{ + // ctor which should be used + + + for (Int_t i = 0; i < fgkTotUM; i++) + { + for (Int_t j = 0; j < fgkRow; j++) + { + for (Int_t k = 0; k < fgkCol; k++) + { + fCPV[i][j][k] = 0.; + fPRE[i][j][k] = 0.; + fPRECounter[i][j][k] = 0; + fPRETrackNo[i][j][k] = -1; + fCPVTrackNo[i][j][k] = -1; + } + } + } +} + +//____________________________________________________________________________ AliPMDDigitizer::~AliPMDDigitizer() { - delete fSDigits; - delete fDigits; - delete fCell; + // Default Destructor + // + if (fSDigits) { + fSDigits->Delete(); + delete fSDigits; + fSDigits=0; + } + if (fDigits) { + fDigits->Delete(); + delete fDigits; + fDigits=0; + } + fCell.Delete(); } // // Member functions // -void AliPMDDigitizer::OpengAliceFile(Char_t *file, Option_t *option) +//____________________________________________________________________________ +void AliPMDDigitizer::OpengAliceFile(const char *file, Option_t *option) { + // Loads galice.root file and corresponding header, kinematics + // hits and sdigits or digits depending on the option + // - fRunLoader = AliRunLoader::Open(file,AliConfig::fgkDefaultEventFolderName, - "UPDATE"); + TString evfoldname = AliConfig::GetDefaultEventFolderName(); + fRunLoader = AliRunLoader::GetRunLoader(evfoldname); + if (!fRunLoader) + fRunLoader = AliRunLoader::Open(file,AliConfig::GetDefaultEventFolderName(), + "UPDATE"); if (!fRunLoader) { - Error("Open","Can not open session for file %s.",file); + AliError(Form("Can not open session for file %s.",file)); } - - fRunLoader->LoadgAlice(); - fRunLoader->LoadHeader(); - fRunLoader->LoadKinematics(); - gAlice = fRunLoader->GetAliRun(); + const char *cHS = strstr(option,"HS"); + const char *cHD = strstr(option,"HD"); + const char *cSD = strstr(option,"SD"); - if (gAlice) + if(cHS || cHD) { - printf(" "); - printf("AliRun object found on file.\n"); - } - else - { - printf(" "); - printf("Could not find AliRun object.\n"); + if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice(); + if (!fRunLoader->TreeE()) fRunLoader->LoadHeader(); + if (!fRunLoader->TreeK()) fRunLoader->LoadKinematics(); + + gAlice = fRunLoader->GetAliRun(); + + if (gAlice) + { + AliDebug(1,"Alirun object found"); + } + else + { + AliError("Could not found Alirun object"); + } + + fPMD = (AliPMD*)gAlice->GetDetector("PMD"); } - PMD = (AliPMD*)gAlice->GetDetector("PMD"); - pmdloader = fRunLoader->GetLoader("PMDLoader"); - if (pmdloader == 0x0) + fPMDLoader = fRunLoader->GetLoader("PMDLoader"); + if (fPMDLoader == 0x0) { - cerr<<"Hits2Digits : Can not find PMD or PMDLoader\n"; + AliError("Can not find PMDLoader"); } - const char *cHS = strstr(option,"HS"); - const char *cHD = strstr(option,"HD"); - const char *cSD = strstr(option,"SD"); if (cHS) { - pmdloader->LoadHits("READ"); - pmdloader->LoadSDigits("recreate"); + fPMDLoader->LoadHits("READ"); + fPMDLoader->LoadSDigits("recreate"); } else if (cHD) { - pmdloader->LoadHits("READ"); - pmdloader->LoadDigits("recreate"); + fPMDLoader->LoadHits("READ"); + fPMDLoader->LoadDigits("recreate"); } else if (cSD) { - pmdloader->LoadSDigits("READ"); - pmdloader->LoadDigits("recreate"); + fPMDLoader->LoadSDigits("READ"); + fPMDLoader->LoadDigits("recreate"); } - } +//____________________________________________________________________________ void AliPMDDigitizer::Hits2SDigits(Int_t ievt) { - cout << " -------- Beginning of Hits2SDigits ----------- " << endl; + // This reads the PMD Hits tree and assigns the right track number + // to a cell and stores in the summable digits tree + // - Int_t kPi0 = 111; - Int_t kGamma = 22; + const Int_t kPi0 = 111; + const Int_t kGamma = 22; Int_t npmd; Int_t trackno; Int_t smnumber; @@ -144,102 +262,98 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt) Float_t edep; Float_t vx = -999.0, vy = -999.0, vz = -999.0; - + + if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); ResetSDigit(); - printf("Event Number = %d \n",ievt); + AliDebug(1,Form("Event Number = %d",ievt)); Int_t nparticles = fRunLoader->GetHeader()->GetNtrack(); - printf("Number of Particles = %d \n", nparticles); + AliDebug(1,Form("Number of Particles = %d",nparticles)); fRunLoader->GetEvent(ievt); - Particles = gAlice->GetMCApp()->Particles(); // ------------------------------------------------------- // // Pointer to specific detector hits. // Get pointers to Alice detectors and Hits containers - treeH = pmdloader->TreeH(); + TTree* treeH = fPMDLoader->TreeH(); Int_t ntracks = (Int_t) treeH->GetEntries(); - printf("Number of Tracks in the TreeH = %d \n", ntracks); - - treeS = pmdloader->TreeS(); + AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks)); + TTree* treeS = fPMDLoader->TreeS(); if (treeS == 0x0) { - pmdloader->MakeTree("S"); - treeS = pmdloader->TreeS(); + fPMDLoader->MakeTree("S"); + treeS = fPMDLoader->TreeS(); } Int_t bufsize = 16000; treeS->Branch("PMDSDigit", &fSDigits, bufsize); - if (PMD) PMDhits = PMD->Hits(); + TClonesArray* hits = 0; + if (fPMD) hits = fPMD->Hits(); // Start loop on tracks in the hits containers - for (Int_t track=0; trackResetHits(); treeH->GetEvent(track); - - if (PMD) + if (fPMD) { - npmd = PMDhits->GetEntriesFast(); + npmd = hits->GetEntriesFast(); for (int ipmd = 0; ipmd < npmd; ipmd++) { - pmdHit = (AliPMDhit*) PMDhits->UncheckedAt(ipmd); - trackno = pmdHit->GetTrack(); - + fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd); + trackno = fPMDHit->GetTrack(); // get kinematics of the particles - - particle = gAlice->GetMCApp()->Particle(trackno); - trackpid = particle->GetPdgCode(); + + TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno); + trackpid = mparticle->GetPdgCode(); Int_t igatr = -999; Int_t ichtr = -999; Int_t igapid = -999; Int_t imo; Int_t igen = 0; - Int_t id_mo = -999; + Int_t idmo = -999; - TParticle* mparticle = particle; - Int_t trackno_old=0, trackpid_old=0, status_old = 0; + Int_t tracknoOld=0, trackpidOld=0, statusOld = 0; if (mparticle->GetFirstMother() == -1) { - trackno_old = trackno; - trackpid_old = trackpid; - status_old = -1; + tracknoOld = trackno; + trackpidOld = trackpid; + statusOld = -1; } - Int_t igstatus = 0; while((imo = mparticle->GetFirstMother()) >= 0) { igen++; + mparticle = gAlice->GetMCApp()->Particle(imo); - id_mo = mparticle->GetPdgCode(); + idmo = mparticle->GetPdgCode(); vx = mparticle->Vx(); vy = mparticle->Vy(); vz = mparticle->Vz(); - //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, id_mo, vx, vy, vz); - //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, id_mo, vx, vy, vz); - if ((id_mo == kGamma || id_mo == -11 || id_mo == 11) && vx == 0. && vy == 0. && vz == 0.) + //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz); + //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz); + if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.) { igatr = imo; - igapid = id_mo; + igapid = idmo; igstatus = 1; } if(igstatus == 0) { - if (id_mo == kPi0 && vx == 0. && vy == 0. && vz == 0.) + if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.) { igatr = imo; - igapid = id_mo; + igapid = idmo; } } ichtr = imo; } - if (id_mo == kPi0 && vx == 0. && vy == 0. && vz == 0.) + if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.) { mtrackno = igatr; mtrackpid = igapid; @@ -247,51 +361,55 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt) else { mtrackno = ichtr; - mtrackpid = id_mo; + mtrackpid = idmo; } - if (status_old == -1) + if (statusOld == -1) { - mtrackno = trackno_old; - mtrackpid = trackpid_old; + mtrackno = tracknoOld; + mtrackpid = trackpidOld; } + xPos = fPMDHit->X(); + yPos = fPMDHit->Y(); + zPos = fPMDHit->Z(); - xPos = pmdHit->X(); - yPos = pmdHit->Y(); - zPos = pmdHit->Z(); - edep = pmdHit->fEnergy; - Int_t Vol1 = pmdHit->fVolume[1]; // Column - Int_t Vol2 = pmdHit->fVolume[2]; // Row - Int_t Vol3 = pmdHit->fVolume[3]; // UnitModule - Int_t Vol6 = pmdHit->fVolume[6]; // SuperModule + edep = fPMDHit->GetEnergy(); + Int_t vol1 = fPMDHit->GetVolume(1); // Column + Int_t vol2 = fPMDHit->GetVolume(2); // Row + Int_t vol7 = fPMDHit->GetVolume(7); // UnitModule + Int_t vol8 = fPMDHit->GetVolume(8); // SuperModule + + // -----------------------------------------// + // In new geometry after adding electronics // // For Super Module 1 & 2 // - // nrow = 96, ncol = 48 // - // For Super Module 3 & 4 // // nrow = 48, ncol = 96 // + // For Super Module 3 & 4 // + // nrow = 96, ncol = 48 // // -----------------------------------------// + + - smnumber = (Vol6-1)*6 + Vol3; + smnumber = (vol8-1)*6 + vol7; - if (Vol6 == 1 || Vol6 == 2) + if (vol8 == 1 || vol8 == 2) { - xpad = Vol1; - ypad = Vol2; + xpad = vol2; + ypad = vol1; } - else if (Vol6 == 3 || Vol6 == 4) + else if (vol8 == 3 || vol8 == 4) { - xpad = Vol2; - ypad = Vol1; + xpad = vol1; + ypad = vol2; } - //cout << "zpos = " << zPos << " edep = " << edep << endl; - - Float_t zposition = TMath::Abs(zPos); - if (zposition < fZPos) + AliDebug(2,Form("Zposition = %f Edeposition = %f",zPos,edep)); + //Float_t zposition = TMath::Abs(zPos); + if (zPos < fZPos) { // CPV fDetNo = 1; } - else if (zposition > fZPos) + else if (zPos > fZPos) { // PMD fDetNo = 0; @@ -301,12 +419,12 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt) Int_t iyy = ypad - 1; if (fDetNo == 0) { - fPMD[smn][ixx][iyy] += edep; - fPMDCounter[smn][ixx][iyy]++; + fPRE[smn][ixx][iyy] += edep; + fPRECounter[smn][ixx][iyy]++; - pmdcell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep); + AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep); - fCell->Add(pmdcell); + fCell.Add(cell); } else if(fDetNo == 1) { @@ -323,21 +441,19 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt) Float_t deltaE = 0.; Int_t detno = 0; Int_t trno = -1; - Int_t cellno = 0; for (Int_t idet = 0; idet < 2; idet++) { - for (Int_t ism = 0; ism < fTotUM; ism++) + for (Int_t ism = 0; ism < fgkTotUM; ism++) { - for (Int_t jrow = 0; jrow < fRow; jrow++) + for (Int_t jrow = 0; jrow < fgkRow; jrow++) { - for (Int_t kcol = 0; kcol < fCol; kcol++) + for (Int_t kcol = 0; kcol < fgkCol; kcol++) { - cellno = jrow*fCol + kcol; if (idet == 0) { - deltaE = fPMD[ism][jrow][kcol]; - trno = fPMDTrackNo[ism][jrow][kcol]; + deltaE = fPRE[ism][jrow][kcol]; + trno = fPRETrackNo[ism][jrow][kcol]; detno = 0; } else if (idet == 1) @@ -348,7 +464,7 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt) } if (deltaE > 0.) { - AddSDigit(trno,detno,ism,cellno,deltaE); + AddSDigit(trno,detno,ism,jrow,kcol,deltaE); } } } @@ -356,16 +472,18 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt) ResetSDigit(); } } - pmdloader->WriteSDigits("OVERWRITE"); + fPMDLoader->WriteSDigits("OVERWRITE"); ResetCellADC(); - - // cout << " -------- End of Hits2SDigit ----------- " << endl; } +//____________________________________________________________________________ void AliPMDDigitizer::Hits2Digits(Int_t ievt) { - Int_t kPi0 = 111; - Int_t kGamma = 22; + // This reads the PMD Hits tree and assigns the right track number + // to a cell and stores in the digits tree + // + const Int_t kPi0 = 111; + const Int_t kGamma = 22; Int_t npmd; Int_t trackno; Int_t smnumber; @@ -378,40 +496,39 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt) Float_t edep; Float_t vx = -999.0, vy = -999.0, vz = -999.0; - + if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); ResetDigit(); - printf("Event Number = %d \n",ievt); - + AliDebug(1,Form("Event Number = %d",ievt)); Int_t nparticles = fRunLoader->GetHeader()->GetNtrack(); - printf("Number of Particles = %d \n", nparticles); + AliDebug(1,Form("Number of Particles = %d", nparticles)); fRunLoader->GetEvent(ievt); - Particles = gAlice->GetMCApp()->Particles(); // ------------------------------------------------------- // // Pointer to specific detector hits. // Get pointers to Alice detectors and Hits containers - PMD = (AliPMD*)gAlice->GetDetector("PMD"); - pmdloader = fRunLoader->GetLoader("PMDLoader"); + fPMD = (AliPMD*)gAlice->GetDetector("PMD"); + fPMDLoader = fRunLoader->GetLoader("PMDLoader"); - if (pmdloader == 0x0) + if (fPMDLoader == 0x0) { - cerr<<"Hits2Digits method : Can not find PMD or PMDLoader\n"; + AliError("Can not find PMD or PMDLoader"); } - treeH = pmdloader->TreeH(); + TTree* treeH = fPMDLoader->TreeH(); Int_t ntracks = (Int_t) treeH->GetEntries(); - printf("Number of Tracks in the TreeH = %d \n", ntracks); - pmdloader->LoadDigits("recreate"); - treeD = pmdloader->TreeD(); + AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks)); + fPMDLoader->LoadDigits("recreate"); + TTree* treeD = fPMDLoader->TreeD(); if (treeD == 0x0) { - pmdloader->MakeTree("D"); - treeD = pmdloader->TreeD(); + fPMDLoader->MakeTree("D"); + treeD = fPMDLoader->TreeD(); } Int_t bufsize = 16000; treeD->Branch("PMDDigit", &fDigits, bufsize); - if (PMD) PMDhits = PMD->Hits(); + TClonesArray* hits = 0; + if (fPMD) hits = fPMD->Hits(); // Start loop on tracks in the hits containers @@ -420,66 +537,66 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt) gAlice->ResetHits(); treeH->GetEvent(track); - if (PMD) + if (fPMD) { - npmd = PMDhits->GetEntriesFast(); + npmd = hits->GetEntriesFast(); for (int ipmd = 0; ipmd < npmd; ipmd++) { - pmdHit = (AliPMDhit*) PMDhits->UncheckedAt(ipmd); - trackno = pmdHit->GetTrack(); + fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd); + trackno = fPMDHit->GetTrack(); // get kinematics of the particles - particle = gAlice->GetMCApp()->Particle(trackno); - trackpid = particle->GetPdgCode(); + TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno); + trackpid = mparticle->GetPdgCode(); Int_t igatr = -999; Int_t ichtr = -999; Int_t igapid = -999; Int_t imo; Int_t igen = 0; - Int_t id_mo = -999; + Int_t idmo = -999; - TParticle* mparticle = particle; - Int_t trackno_old=0, trackpid_old=0, status_old = 0; + Int_t tracknoOld=0, trackpidOld=0, statusOld = 0; if (mparticle->GetFirstMother() == -1) { - trackno_old = trackno; - trackpid_old = trackpid; - status_old = -1; + tracknoOld = trackno; + trackpidOld = trackpid; + statusOld = -1; } Int_t igstatus = 0; while((imo = mparticle->GetFirstMother()) >= 0) { igen++; + mparticle = gAlice->GetMCApp()->Particle(imo); - id_mo = mparticle->GetPdgCode(); + idmo = mparticle->GetPdgCode(); vx = mparticle->Vx(); vy = mparticle->Vy(); vz = mparticle->Vz(); - //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, id_mo, vx, vy, vz); - //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, id_mo, vx, vy, vz); - if ((id_mo == kGamma || id_mo == -11 || id_mo == 11) && vx == 0. && vy == 0. && vz == 0.) + //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz); + //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz); + if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.) { igatr = imo; - igapid = id_mo; + igapid = idmo; igstatus = 1; } if(igstatus == 0) { - if (id_mo == kPi0 && vx == 0. && vy == 0. && vz == 0.) + if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.) { igatr = imo; - igapid = id_mo; + igapid = idmo; } } ichtr = imo; } - if (id_mo == kPi0 && vx == 0. && vy == 0. && vz == 0.) + if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.) { mtrackno = igatr; mtrackpid = igapid; @@ -487,53 +604,54 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt) else { mtrackno = ichtr; - mtrackpid = id_mo; + mtrackpid = idmo; } - if (status_old == -1) + if (statusOld == -1) { - mtrackno = trackno_old; - mtrackpid = trackpid_old; + mtrackno = tracknoOld; + mtrackpid = trackpidOld; } - xPos = pmdHit->X(); - yPos = pmdHit->Y(); - zPos = pmdHit->Z(); - edep = pmdHit->fEnergy; - Int_t Vol1 = pmdHit->fVolume[1]; // Column - Int_t Vol2 = pmdHit->fVolume[2]; // Row - Int_t Vol3 = pmdHit->fVolume[3]; // UnitModule - Int_t Vol6 = pmdHit->fVolume[6]; // SuperModule + xPos = fPMDHit->X(); + yPos = fPMDHit->Y(); + zPos = fPMDHit->Z(); + edep = fPMDHit->GetEnergy(); + Int_t vol1 = fPMDHit->GetVolume(1); // Column + Int_t vol2 = fPMDHit->GetVolume(2); // Row + Int_t vol7 = fPMDHit->GetVolume(7); // UnitModule + Int_t vol8 = fPMDHit->GetVolume(8); // SuperModule + // -----------------------------------------// + // In new geometry after adding electronics // // For Super Module 1 & 2 // - // nrow = 96, ncol = 48 // - // For Super Module 3 & 4 // // nrow = 48, ncol = 96 // + // For Super Module 3 & 4 // + // nrow = 96, ncol = 48 // // -----------------------------------------// - smnumber = (Vol6-1)*6 + Vol3; + smnumber = (vol8-1)*6 + vol7; - if (Vol6 == 1 || Vol6 == 2) + if (vol8 == 1 || vol8 == 2) { - xpad = Vol1; - ypad = Vol2; + xpad = vol2; + ypad = vol1; } - else if (Vol6 == 3 || Vol6 == 4) + else if (vol8 == 3 || vol8 == 4) { - xpad = Vol2; - ypad = Vol1; + xpad = vol1; + ypad = vol2; } - //cout << "-zpos = " << -zPos << endl; + AliDebug(2,Form("ZPosition = %f Edeposition = %d",zPos,edep)); + //Float_t zposition = TMath::Abs(zPos); - Float_t zposition = TMath::Abs(zPos); - - if (zposition < fZPos) + if (zPos < fZPos) { // CPV fDetNo = 1; } - else if (zposition > fZPos) + else if (zPos > fZPos) { // PMD fDetNo = 0; @@ -544,12 +662,12 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt) Int_t iyy = ypad - 1; if (fDetNo == 0) { - fPMD[smn][ixx][iyy] += edep; - fPMDCounter[smn][ixx][iyy]++; + fPRE[smn][ixx][iyy] += edep; + fPRECounter[smn][ixx][iyy]++; - pmdcell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep); + AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep); - fCell->Add(pmdcell); + fCell.Add(cell); } else if(fDetNo == 1) { @@ -563,99 +681,246 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt) TrackAssignment2Cell(); ResetCell(); + Float_t gain1; + Float_t adc; Float_t deltaE = 0.; Int_t detno = 0; Int_t trno = 1; - Int_t cellno; - for (Int_t idet = 0; idet < 2; idet++) { - for (Int_t ism = 0; ism < fTotUM; ism++) + for (Int_t ism = 0; ism < fgkTotUM; ism++) { - for (Int_t jrow = 0; jrow < fRow; jrow++) + for (Int_t jrow = 0; jrow < fgkRow; jrow++) { - for (Int_t kcol = 0; kcol < fCol; kcol++) + for (Int_t kcol = 0; kcol < fgkCol; kcol++) { - cellno = jrow*fCol + kcol; if (idet == 0) { - deltaE = fPMD[ism][jrow][kcol]; - trno = fPMDTrackNo[ism][jrow][kcol]; + gain1 = Gain(idet,ism,jrow,kcol); + + deltaE = fPRE[ism][jrow][kcol]*gain1; + trno = fPRETrackNo[ism][jrow][kcol]; detno = 0; } else if (idet == 1) { - deltaE = fCPV[ism][jrow][kcol]; + gain1 = Gain(idet,ism,jrow,kcol); + deltaE = fCPV[ism][jrow][kcol]*gain1; trno = fCPVTrackNo[ism][jrow][kcol]; detno = 1; } if (deltaE > 0.) { - AddDigit(trno,detno,ism,cellno,deltaE); + MeV2ADC(deltaE,adc); + AddDigit(trno,detno,ism,jrow,kcol,adc); } } // column loop } // row loop + treeD->Fill(); + ResetDigit(); } // supermodule loop - treeD->Fill(); - ResetDigit(); } // detector loop - - pmdloader->WriteDigits("OVERWRITE"); + + fPMDLoader->WriteDigits("OVERWRITE"); ResetCellADC(); - // cout << " -------- End of Hits2Digit ----------- " << endl; } +//____________________________________________________________________________ void AliPMDDigitizer::SDigits2Digits(Int_t ievt) { - // cout << " -------- Beginning of SDigits2Digit ----------- " << endl; + // This reads the PMD sdigits tree and converts energy deposition + // in a cell to ADC and stores in the digits tree + // + fRunLoader->GetEvent(ievt); - treeS = pmdloader->TreeS(); + TTree* treeS = fPMDLoader->TreeS(); AliPMDsdigit *pmdsdigit; TBranch *branch = treeS->GetBranch("PMDSDigit"); + if(!branch) + { + AliError("PMD Sdigit branch does not exist"); + return; + } + if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); branch->SetAddress(&fSDigits); - treeD = pmdloader->TreeD(); + TTree* treeD = fPMDLoader->TreeD(); if (treeD == 0x0) { - pmdloader->MakeTree("D"); - treeD = pmdloader->TreeD(); + fPMDLoader->MakeTree("D"); + treeD = fPMDLoader->TreeD(); } Int_t bufsize = 16000; + if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); treeD->Branch("PMDDigit", &fDigits, bufsize); Int_t trno, det, smn; - Int_t cellno; + Int_t irow, icol; Float_t edep, adc; Int_t nmodules = (Int_t) treeS->GetEntries(); + AliDebug(1,Form("Number of modules = %d",nmodules)); for (Int_t imodule = 0; imodule < nmodules; imodule++) { treeS->GetEntry(imodule); Int_t nentries = fSDigits->GetLast(); - //cout << " nentries = " << nentries << endl; + AliDebug(2,Form("Number of entries per module = %d",nentries+1)); for (Int_t ient = 0; ient < nentries+1; ient++) { pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient); trno = pmdsdigit->GetTrackNumber(); det = pmdsdigit->GetDetector(); smn = pmdsdigit->GetSMNumber(); - cellno = pmdsdigit->GetCellNumber(); + irow = pmdsdigit->GetRow(); + icol = pmdsdigit->GetColumn(); edep = pmdsdigit->GetCellEdep(); MeV2ADC(edep,adc); - AddDigit(trno,det,smn,cellno,adc); + AddDigit(trno,det,smn,irow,icol,adc); } treeD->Fill(); ResetDigit(); } - pmdloader->WriteDigits("OVERWRITE"); - // cout << " -------- End of SDigits2Digit ----------- " << endl; + fPMDLoader->WriteDigits("OVERWRITE"); + +} +//____________________________________________________________________________ +void AliPMDDigitizer::Exec(Option_t *option) +{ + // Does the event merging and digitization + const char *cdeb = strstr(option,"deb"); + if(cdeb) + { + AliDebug(100," *** PMD Exec is called ***"); + } + + Int_t ninputs = fManager->GetNinputs(); + AliDebug(1,Form("Number of files to be processed = %d",ninputs)); + ResetCellADC(); + + for (Int_t i = 0; i < ninputs; i++) + { + Int_t troffset = fManager->GetMask(i); + MergeSDigits(i, troffset); + } + + fRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); + fPMD = (AliPMD*)gAlice->GetDetector("PMD"); + fPMDLoader = fRunLoader->GetLoader("PMDLoader"); + if (fPMDLoader == 0x0) + { + AliError("Can not find PMD or PMDLoader"); + } + fPMDLoader->LoadDigits("update"); + TTree* treeD = fPMDLoader->TreeD(); + if (treeD == 0x0) + { + fPMDLoader->MakeTree("D"); + treeD = fPMDLoader->TreeD(); + } + Int_t bufsize = 16000; + if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); + treeD->Branch("PMDDigit", &fDigits, bufsize); + + Float_t adc; + Float_t deltaE = 0.; + Int_t detno = 0; + Int_t trno = 1; + + for (Int_t idet = 0; idet < 2; idet++) + { + for (Int_t ism = 0; ism < fgkTotUM; ism++) + { + for (Int_t jrow = 0; jrow < fgkRow; jrow++) + { + for (Int_t kcol = 0; kcol < fgkCol; kcol++) + { + if (idet == 0) + { + deltaE = fPRE[ism][jrow][kcol]; + trno = fPRETrackNo[ism][jrow][kcol]; + detno = 0; + } + else if (idet == 1) + { + deltaE = fCPV[ism][jrow][kcol]; + trno = fCPVTrackNo[ism][jrow][kcol]; + detno = 1; + } + if (deltaE > 0.) + { + MeV2ADC(deltaE,adc); + AddDigit(trno,detno,ism,jrow,kcol,adc); + } + } // column loop + } // row loop + treeD->Fill(); + ResetDigit(); + } // supermodule loop + } // detector loop + fPMDLoader->WriteDigits("OVERWRITE"); + fPMDLoader->UnloadDigits(); + ResetCellADC(); } +//____________________________________________________________________________ + +void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset) +{ + // merging sdigits + fRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(filenumber)); + fPMDLoader = fRunLoader->GetLoader("PMDLoader"); + fPMDLoader->LoadSDigits("read"); + TTree* treeS = fPMDLoader->TreeS(); + AliPMDsdigit *pmdsdigit; + TBranch *branch = treeS->GetBranch("PMDSDigit"); + if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); + branch->SetAddress(&fSDigits); + Int_t itrackno, idet, ism; + Int_t ixp, iyp; + Float_t edep; + Int_t nmodules = (Int_t) treeS->GetEntries(); + AliDebug(1,Form("Number of Modules in the treeS = %d",nmodules)); + AliDebug(1,Form("Track Offset = %d",troffset)); + for (Int_t imodule = 0; imodule < nmodules; imodule++) + { + treeS->GetEntry(imodule); + Int_t nentries = fSDigits->GetLast(); + AliDebug(2,Form("Number of Entries per Module = %d",nentries)); + for (Int_t ient = 0; ient < nentries+1; ient++) + { + pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient); + itrackno = pmdsdigit->GetTrackNumber(); + idet = pmdsdigit->GetDetector(); + ism = pmdsdigit->GetSMNumber(); + ixp = pmdsdigit->GetRow(); + iyp = pmdsdigit->GetColumn(); + edep = pmdsdigit->GetCellEdep(); + if (idet == 0) + { + if (fPRE[ism][ixp][iyp] < edep) + { + fPRETrackNo[ism][ixp][iyp] = troffset + itrackno; + } + fPRE[ism][ixp][iyp] += edep; + } + else if (idet == 1) + { + if (fCPV[ism][ixp][iyp] < edep) + { + fCPVTrackNo[ism][ixp][iyp] = troffset + itrackno; + } + fCPV[ism][ixp][iyp] += edep; + } + } + } + +} +// ---------------------------------------------------------------------- void AliPMDDigitizer::TrackAssignment2Cell() { // @@ -667,87 +932,86 @@ void AliPMDDigitizer::TrackAssignment2Cell() Int_t i, j, k; - Float_t *frac_edp; - Float_t *tr_edp; + Float_t *fracEdp; + Float_t *trEdp; Int_t *status1; Int_t *status2; Int_t *trnarray; - Int_t ****PMDTrack; - Float_t ****PMDEdep; + Int_t ****pmdTrack; + Float_t ****pmdEdep; - PMDTrack = new Int_t ***[fTotUM]; - PMDEdep = new Float_t ***[fTotUM]; - for (i=0; i 0) { - PMDTrack[i][j][k] = new Int_t[nn]; - PMDEdep[i][j][k] = new Float_t[nn]; + pmdTrack[i][j][k] = new Int_t[nn]; + pmdEdep[i][j][k] = new Float_t[nn]; } else { nn = 1; - PMDTrack[i][j][k] = new Int_t[nn]; - PMDEdep[i][j][k] = new Float_t[nn]; + pmdTrack[i][j][k] = new Int_t[nn]; + pmdEdep[i][j][k] = new Float_t[nn]; } - fPMDCounter[i][j][k] = 0; + fPRECounter[i][j][k] = 0; } } } - Int_t nentries = fCell->GetEntries(); + Int_t nentries = fCell.GetEntries(); Int_t mtrackno, ism, ixp, iyp; Float_t edep; for (i = 0; i < nentries; i++) { - pmdcell = (AliPMDcell*)fCell->UncheckedAt(i); + AliPMDcell* cell = (AliPMDcell*)fCell.UncheckedAt(i); - mtrackno = pmdcell->GetTrackNumber(); - ism = pmdcell->GetSMNumber(); - ixp = pmdcell->GetX(); - iyp = pmdcell->GetY(); - edep = pmdcell->GetEdep(); - Int_t nn = fPMDCounter[ism][ixp][iyp]; - // cout << " nn = " << nn << endl; - PMDTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno; - PMDEdep[ism][ixp][iyp][nn] = edep; - fPMDCounter[ism][ixp][iyp]++; + mtrackno = cell->GetTrackNumber(); + ism = cell->GetSMNumber(); + ixp = cell->GetX(); + iyp = cell->GetY(); + edep = cell->GetEdep(); + Int_t nn = fPRECounter[ism][ixp][iyp]; + pmdTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno; + pmdEdep[ism][ixp][iyp][nn] = edep; + fPRECounter[ism][ixp][iyp]++; } Int_t iz, il; Int_t im, ix, iy; Int_t nn; - for (im=0; im 1) { // This block handles if a cell is fired @@ -757,68 +1021,68 @@ void AliPMDDigitizer::TrackAssignment2Cell() trnarray = new Int_t[nn]; for (iz = 0; iz < nn; iz++) { - status1[iz] = PMDTrack[im][ix][iy][iz]; + status1[iz] = pmdTrack[im][ix][iy][iz]; } TMath::Sort(nn,status1,status2,jsort); - Int_t track_old = -99999; - Int_t track, tr_count = 0; + Int_t trackOld = -99999; + Int_t track, trCount = 0; for (iz = 0; iz < nn; iz++) { track = status1[status2[iz]]; - if (track_old != track) + if (trackOld != track) { - trnarray[tr_count] = track; - tr_count++; + trnarray[trCount] = track; + trCount++; } - track_old = track; + trackOld = track; } - delete status1; - delete status2; - Float_t tot_edp = 0.; - tr_edp = new Float_t[tr_count]; - frac_edp = new Float_t[tr_count]; - for (il = 0; il < tr_count; il++) + delete [] status1; + delete [] status2; + Float_t totEdp = 0.; + trEdp = new Float_t[trCount]; + fracEdp = new Float_t[trCount]; + for (il = 0; il < trCount; il++) { - tr_edp[il] = 0.; + trEdp[il] = 0.; track = trnarray[il]; for (iz = 0; iz < nn; iz++) { - if (track == PMDTrack[im][ix][iy][iz]) + if (track == pmdTrack[im][ix][iy][iz]) { - tr_edp[il] += PMDEdep[im][ix][iy][iz]; + trEdp[il] += pmdEdep[im][ix][iy][iz]; } } - tot_edp += tr_edp[il]; + totEdp += trEdp[il]; } - Int_t il_old = 0; - Float_t frac_old = 0.; + Int_t ilOld = 0; + Float_t fracOld = 0.; - for (il = 0; il < tr_count; il++) + for (il = 0; il < trCount; il++) { - frac_edp[il] = tr_edp[il]/tot_edp; - if (frac_old < frac_edp[il]) + fracEdp[il] = trEdp[il]/totEdp; + if (fracOld < fracEdp[il]) { - frac_old = frac_edp[il]; - il_old = il; + fracOld = fracEdp[il]; + ilOld = il; } } - fPMDTrackNo[im][ix][iy] = trnarray[il_old]; - delete frac_edp; - delete tr_edp; - delete trnarray; + fPRETrackNo[im][ix][iy] = trnarray[ilOld]; + delete [] fracEdp; + delete [] trEdp; + delete [] trnarray; } else if (nn == 1) { // This only handles if a cell is fired // by only one track - fPMDTrackNo[im][ix][iy] = PMDTrack[im][ix][iy][0]; + fPRETrackNo[im][ix][iy] = pmdTrack[im][ix][iy][0]; } else if (nn ==0) { // This is if no cell is fired - fPMDTrackNo[im][ix][iy] = -999; + fPRETrackNo[im][ix][iy] = -999; } } // end of iy } // end of ix @@ -826,154 +1090,166 @@ void AliPMDDigitizer::TrackAssignment2Cell() // Delete all the pointers - for (i = 0; i < fTotUM; i++) + for (i = 0; i < fgkTotUM; i++) { - for (j = 0; j < fRow; j++) + for (j = 0; j < fgkRow; j++) { - for (k = 0; k < fCol; k++) + for (k = 0; k < fgkCol; k++) { - delete [] PMDTrack[i][j][k]; - delete [] PMDEdep[i][j][k]; + delete [] pmdTrack[i][j][k]; + delete [] pmdEdep[i][j][k]; } } } - for (i = 0; i < fTotUM; i++) + for (i = 0; i < fgkTotUM; i++) { - for (j = 0; j < fRow; j++) + for (j = 0; j < fgkRow; j++) { - delete [] PMDTrack[i][j]; - delete [] PMDEdep[i][j]; + delete [] pmdTrack[i][j]; + delete [] pmdEdep[i][j]; } } - for (i = 0; i < fTotUM; i++) + for (i = 0; i < fgkTotUM; i++) { - delete [] PMDTrack[i]; - delete [] PMDEdep[i]; + delete [] pmdTrack[i]; + delete [] pmdEdep[i]; } - delete PMDTrack; - delete PMDEdep; + delete [] pmdTrack; + delete [] pmdEdep; // // End of the cell id assignment // } - - -void AliPMDDigitizer::MeV2ADC(Float_t mev, Float_t & adc) +//____________________________________________________________________________ +void AliPMDDigitizer::MeV2ADC(Float_t mev, Float_t & adc) const { + // This converts the simulated edep to ADC according to the + // Test Beam Data // To be done + // + + // PS Test in September 2003 + // MeV - ADC conversion for 10bit ADC + + const Float_t kConstant = 7.181; + const Float_t kErConstant = 0.6899; + const Float_t kSlope = 35.93; + const Float_t kErSlope = 0.306; + + //gRandom->SetSeed(); + + Float_t cons = gRandom->Gaus(kConstant,kErConstant); + Float_t slop = gRandom->Gaus(kSlope,kErSlope); + + Float_t adc10bit = slop*mev*0.001 + cons; + + // 12 bit adc + + Int_t adc12bit = (Int_t) (4.0*adc10bit); + + if(adc12bit < 3000) + { + adc = (Float_t) adc12bit; + } + else if (adc12bit >= 3000) + { + adc = 3000.0; + } - adc = mev*1.; } +//____________________________________________________________________________ void AliPMDDigitizer::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber, - Int_t cellnumber, Float_t adc) + Int_t irow, Int_t icol, Float_t adc) { + // Add SDigit + // + if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); TClonesArray &lsdigits = *fSDigits; - AliPMDsdigit *newcell; - newcell = new AliPMDsdigit(trnumber,det,smnumber,cellnumber,adc); - new(lsdigits[fNsdigit++]) AliPMDsdigit(newcell); - delete newcell; + new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc); } +//____________________________________________________________________________ void AliPMDDigitizer::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber, - Int_t cellnumber, Float_t adc) + Int_t irow, Int_t icol, Float_t adc) { + // Add Digit + // + if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); TClonesArray &ldigits = *fDigits; - AliPMDdigit *newcell; - newcell = new AliPMDdigit(trnumber,det,smnumber,cellnumber,adc); - new(ldigits[fNdigit++]) AliPMDdigit(newcell); - delete newcell; + new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc); } +//____________________________________________________________________________ -Int_t AliPMDDigitizer::Convert2RealSMNumber(Int_t smnumber1) -{ - Int_t smnumber = -999; - - if (smnumber1==1) smnumber = 1; - if (smnumber1==2) smnumber = 10; - if (smnumber1==3) smnumber = 19; - if (smnumber1==4) smnumber = 1; - if (smnumber1==5) smnumber = 10; - if (smnumber1==6) smnumber = 19; - if (smnumber1==7) smnumber = 2; - if (smnumber1==8) smnumber = 3; - if (smnumber1==9) smnumber = 4; - if (smnumber1==10) smnumber = 5; - if (smnumber1==11) smnumber = 6; - if (smnumber1==12) smnumber = 7; - if (smnumber1==13) smnumber = 8; - if (smnumber1==14) smnumber = 9; - if (smnumber1==15) smnumber = 11; - if (smnumber1==16) smnumber = 12; - if (smnumber1==17) smnumber = 13; - if (smnumber1==18) smnumber = 14; - if (smnumber1==19) smnumber = 15; - if (smnumber1==20) smnumber = 16; - if (smnumber1==21) smnumber = 17; - if (smnumber1==22) smnumber = 18; - if (smnumber1==23) smnumber = 20; - if (smnumber1==24) smnumber = 21; - if (smnumber1==25) smnumber = 22; - if (smnumber1==26) smnumber = 23; - if (smnumber1==27) smnumber = 24; - if (smnumber1==28) smnumber = 25; - if (smnumber1==29) smnumber = 26; - if (smnumber1==30) smnumber = 27; - - return smnumber; -} void AliPMDDigitizer::SetZPosition(Float_t zpos) { fZPos = zpos; } +//____________________________________________________________________________ Float_t AliPMDDigitizer::GetZPosition() const { return fZPos; } +//____________________________________________________________________________ void AliPMDDigitizer::ResetCell() { - fCell->Clear(); - for (Int_t i = 0; i < fTotUM; i++) + // clears the cell array and also the counter + // for each cell + // + fCell.Delete(); + for (Int_t i = 0; i < fgkTotUM; i++) { - for (Int_t j = 0; j < fRow; j++) + for (Int_t j = 0; j < fgkRow; j++) { - for (Int_t k = 0; k < fCol; k++) + for (Int_t k = 0; k < fgkCol; k++) { - fPMDCounter[i][j][k] = 0; + fPRECounter[i][j][k] = 0; } } } } +//____________________________________________________________________________ void AliPMDDigitizer::ResetSDigit() { + // Clears SDigits fNsdigit = 0; - if (fSDigits) fSDigits->Clear(); + if (fSDigits) fSDigits->Delete(); } +//____________________________________________________________________________ void AliPMDDigitizer::ResetDigit() { + // Clears Digits fNdigit = 0; - if (fDigits) fDigits->Clear(); + if (fDigits) fDigits->Delete(); } +//____________________________________________________________________________ void AliPMDDigitizer::ResetCellADC() { - for (Int_t i = 0; i < fTotUM; i++) + // Clears individual cells edep and track number + for (Int_t i = 0; i < fgkTotUM; i++) { - for (Int_t j = 0; j < fRow; j++) + for (Int_t j = 0; j < fgkRow; j++) { - for (Int_t k = 0; k < fCol; k++) + for (Int_t k = 0; k < fgkCol; k++) { fCPV[i][j][k] = 0.; - fPMD[i][j][k] = 0.; + fPRE[i][j][k] = 0.; + fPRETrackNo[i][j][k] = 0; + fCPVTrackNo[i][j][k] = 0; } } } } +//------------------------------------------------------ +//____________________________________________________________________________ void AliPMDDigitizer::UnLoad(Option_t *option) { + // Unloads all the root files + // const char *cS = strstr(option,"S"); const char *cD = strstr(option,"D"); @@ -983,11 +1259,59 @@ void AliPMDDigitizer::UnLoad(Option_t *option) if (cS) { - pmdloader->UnloadHits(); + fPMDLoader->UnloadHits(); } if (cD) { - pmdloader->UnloadHits(); - pmdloader->UnloadSDigits(); + fPMDLoader->UnloadHits(); + fPMDLoader->UnloadSDigits(); } } + +//---------------------------------------------------------------------- +Float_t AliPMDDigitizer::Gain(Int_t det, Int_t smn, Int_t row, Int_t col) const +{ + // returns of the gain of the cell + // Added this method by ZA + + //cout<<" I am here in gain "<GetGainFact(det,smn,row,col); + printf("\t gain=%10.3f\n",GainFact); + return GainFact; +} +//---------------------------------------------------------------------- +AliPMDCalibData* AliPMDDigitizer::GetCalibData() const +{ + // The run number will be centralized in AliCDBManager, + // you don't need to set it here! + // Added this method by ZA + AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data"); + + if(!entry){ + AliWarning("Calibration object retrieval failed! Dummy calibration will be used."); + + // this just remembers the actual default storage. No problem if it is null. + AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage(); + AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); + + entry = AliCDBManager::Instance()->Get("PMD/Calib/Data"); + + // now reset the original default storage to AliCDBManager... + AliCDBManager::Instance()->SetDefaultStorage(origStorage); + } + + AliPMDCalibData *calibdata=0; + if (entry) calibdata = (AliPMDCalibData*) entry->GetObject(); + + if (!calibdata) AliError("No calibration data from calibration database !"); + + return calibdata; +}