#include <TNtuple.h>
#include <TParticle.h>
+#include "AliLog.h"
#include "AliRun.h"
-#include "AliPMD.h"
-#include "AliPMDhit.h"
#include "AliHit.h"
#include "AliDetector.h"
#include "AliRunLoader.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 "AliMC.h"
+
ClassImp(AliPMDDigitizer)
fSDigits(0),
fDigits(0),
fCell(0),
- fDebug(0),
fNsdigit(0),
fNdigit(0),
fDetNo(0),
}
}
}
+ fCalibData = GetCalibData();
}
//____________________________________________________________________________
fSDigits(new TClonesArray("AliPMDsdigit", 1000)),
fDigits(new TClonesArray("AliPMDdigit", 1000)),
fCell(0),
- fDebug(0),
fNsdigit(0),
fNdigit(0),
fDetNo(0),
{
// ctor which should be used
+ fCalibData = GetCalibData();
+
for (Int_t i = 0; i < fgkTotUM; i++)
{
for (Int_t j = 0; j < fgkRow; j++)
if (!fRunLoader)
{
- Error("Open","Can not open session for file %s.",file);
+ AliError(Form("Can not open session for file %s.",file));
}
if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice();
gAlice = fRunLoader->GetAliRun();
- if (fDebug) {
- if (gAlice)
- {
- printf("<AliPMDdigitizer::Open> ");
- printf("AliRun object found on file.\n");
- }
- else
- {
- printf("<AliPMDdigitizer::Open> ");
- printf("Could not find AliRun object.\n");
- }
- }
+ if (gAlice)
+ {
+ AliDebug(1,"Alirun object found");
+ }
+ else
+ {
+ AliError("Could not found Alirun object");
+ }
fPMD = (AliPMD*)gAlice->GetDetector("PMD");
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");
// This reads the PMD Hits tree and assigns the right track number
// to a cell and stores in the summable digits tree
//
- // cout << " -------- Beginning of Hits2SDigits ----------- " << endl;
const Int_t kPi0 = 111;
const Int_t kGamma = 22;
if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
ResetSDigit();
- if (fDebug) printf("Event Number = %d \n",ievt);
+ AliDebug(1,Form("Event Number = %d",ievt));
Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
- if (fDebug) printf("Number of Particles = %d \n", nparticles);
+ AliDebug(1,Form("Number of Particles = %d",nparticles));
fRunLoader->GetEvent(ievt);
// ------------------------------------------------------- //
// Pointer to specific detector hits.
TTree* treeH = fPMDLoader->TreeH();
Int_t ntracks = (Int_t) treeH->GetEntries();
- if (fDebug) printf("Number of Tracks in the TreeH = %d \n", ntracks);
-
+ AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks));
TTree* treeS = fPMDLoader->TreeS();
if (treeS == 0x0)
{
ypad = vol1;
}
- //cout << "zpos = " << zPos << " edep = " << edep << endl;
-
+ AliDebug(2,Form("Zposition = %f Edeposition = %f",zPos,edep));
Float_t zposition = TMath::Abs(zPos);
if (zposition < fZPos)
{
fPMDLoader->WriteSDigits("OVERWRITE");
ResetCellADC();
- // cout << " -------- End of Hits2SDigit ----------- " << endl;
}
//____________________________________________________________________________
if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
ResetDigit();
- if (fDebug) printf("Event Number = %d \n",ievt);
-
+ AliDebug(1,Form("Event Number = %d",ievt));
Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
- if (fDebug) printf("Number of Particles = %d \n", nparticles);
+ AliDebug(1,Form("Number of Particles = %d", nparticles));
fRunLoader->GetEvent(ievt);
// ------------------------------------------------------- //
// Pointer to specific detector hits.
if (fPMDLoader == 0x0)
{
- cerr<<"Hits2Digits method : Can not find PMD or PMDLoader\n";
+ AliError("Can not find PMD or PMDLoader");
}
TTree* treeH = fPMDLoader->TreeH();
Int_t ntracks = (Int_t) treeH->GetEntries();
- if (fDebug) printf("Number of Tracks in the TreeH = %d \n", ntracks);
+ AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks));
fPMDLoader->LoadDigits("recreate");
TTree* treeD = fPMDLoader->TreeD();
if (treeD == 0x0)
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 vol3 = fPMDHit->GetVolume(3); // UnitModule
Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
+ edep = fPMDHit->GetEnergy();
// -----------------------------------------//
// For Super Module 1 & 2 //
ypad = vol1;
}
- //cout << "-zpos = " << -zPos << endl;
-
+ AliDebug(2,Form("ZPosition = %f Edeposition = %d",zPos,edep));
Float_t zposition = TMath::Abs(zPos);
if (zposition < fZPos)
TrackAssignment2Cell();
ResetCell();
+ Float_t gain1,gain2;
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++)
{
if (idet == 0)
{
- deltaE = fPRE[ism][jrow][kcol];
+ gain1 =Gain(idet,ism,jrow,kcol);
+ // cout<<"The gain Factor is"<<gain1<<endl;
+ deltaE = fPRE[ism][jrow][kcol]*gain1;
trno = fPRETrackNo[ism][jrow][kcol];
detno = 0;
}
else if (idet == 1)
{
- deltaE = fCPV[ism][jrow][kcol];
+ gain2 =Gain(idet,ism,jrow,kcol);
+ // cout<<"The Gain factor is"<<gain2<<endl;
+ deltaE = fCPV[ism][jrow][kcol]*gain2;
trno = fCPVTrackNo[ism][jrow][kcol];
detno = 1;
}
}
} // column loop
} // row loop
+ treeD->Fill();
+ ResetDigit();
} // supermodule loop
- treeD->Fill();
- ResetDigit();
} // detector loop
-
+
fPMDLoader->WriteDigits("OVERWRITE");
ResetCellADC();
-
- // cout << " -------- End of Hits2Digit ----------- " << endl;
+
}
//____________________________________________________________________________
// This reads the PMD sdigits tree and converts energy deposition
// in a cell to ADC and stores in the digits tree
//
- // cout << " -------- Beginning of SDigits2Digit ----------- " << endl;
+
fRunLoader->GetEvent(ievt);
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);
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);
ResetDigit();
}
fPMDLoader->WriteDigits("OVERWRITE");
- // cout << " -------- End of SDigits2Digit ----------- " << endl;
+
}
//____________________________________________________________________________
void AliPMDDigitizer::Exec(Option_t *option)
{
// Does the event merging and digitization
-
- fDebug = 0;
const char *cdeb = strstr(option,"deb");
if(cdeb)
{
- cout << "**************** PMD Exec *************** " << endl;
- fDebug = 1;
+ AliDebug(100," *** PMD Exec is called ***");
}
-
+
Int_t ninputs = fManager->GetNinputs();
- if(fDebug)
- {
- cout << " Number of files = " << ninputs << endl;
- }
+ AliDebug(1,Form("Number of files to be processed = %d",ninputs));
ResetCellADC();
for (Int_t i = 0; i < ninputs; i++)
fPMDLoader = fRunLoader->GetLoader("PMDLoader");
if (fPMDLoader == 0x0)
{
- cerr<<"AliPMDDigitizer::Exec : Can not find PMD or PMDLoader\n";
+ AliError("Can not find PMD or PMDLoader");
}
fPMDLoader->LoadDigits("update");
TTree* treeD = fPMDLoader->TreeD();
Int_t itrackno, idet, ism;
Int_t ixp, iyp;
Float_t edep;
-
Int_t nmodules = (Int_t) treeS->GetEntries();
- if(fDebug)
- {
- cout << " nmodules = " << nmodules << endl;
- cout << " tr offset = " << troffset << endl;
- }
+ 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();
- if(fDebug)
- {
- cout << " nentries = " << nentries << endl;
- }
+ AliDebug(2,Form("Number of Entries per Module = %d",nentries));
for (Int_t ient = 0; ient < nentries+1; ient++)
{
pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient);
ixp = pmdsdigit->GetRow();
iyp = pmdsdigit->GetColumn();
edep = pmdsdigit->GetCellEdep();
-
if (idet == 0)
{
if (fPRE[ism][ixp][iyp] < edep)
iyp = cell->GetY();
edep = cell->GetEdep();
Int_t nn = fPRECounter[ism][ixp][iyp];
- // cout << " nn = " << nn << endl;
pmdTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno;
pmdEdep[ism][ixp][iyp][nn] = edep;
fPRECounter[ism][ixp][iyp]++;
// Test Beam Data
// To be done
//
- adc = mev*1.;
+
+ // 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;
+ }
+
}
//____________________________________________________________________________
void AliPMDDigitizer::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber,
}
}
}
+//------------------------------------------------------
//____________________________________________________________________________
void AliPMDDigitizer::UnLoad(Option_t *option)
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 "<<fCalibData<< "smn,row, col "<<smn
+ //<<" "<<row<<" "<<col<<endl;
+
+ if(!fCalibData) {
+ AliError("No calibration data loaded from CDB!!!");
+ return -1;
+ }
+
+ Float_t GainFact;
+ GainFact = fCalibData->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;
+}