ClassImp(AliEMCALBiasAPD)
//____________________________________________________________________________
-AliEMCALBiasAPD::AliEMCALBiasAPD() :
- fNSuperModule(0),
- fSuperModuleData(0)
+AliEMCALBiasAPD::AliEMCALBiasAPD(const int nSM) :
+ fNSuperModule(nSM), // make space for everyone
+ fSuperModuleData()
{
//Default constructor.
+ for (int i=0; i<fNSuperModule; i++) {
+ fSuperModuleData.Add(new AliEMCALSuperModuleBiasAPD(i));
+ }
+ fSuperModuleData.Compress(); // compress the TObjArray
+ fSuperModuleData.SetOwner(kTRUE);
}
//____________________________________________________________________________
}
fNSuperModule = nSM;
- if (fSuperModuleData) delete [] fSuperModuleData;
- fSuperModuleData = new AliEMCALSuperModuleBiasAPD[fNSuperModule];
Int_t iSM = 0; // SuperModule index
Int_t iCol = 0;
Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
for (Int_t i = 0; i < fNSuperModule; i++) {
- AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[i];
+ AliEMCALSuperModuleBiasAPD * t = (AliEMCALSuperModuleBiasAPD*) fSuperModuleData[i];
+
if (!inputFile) {
- printf("AliEMCALBiasAPD::ReadBiasAPDInfo - Error while reading input file; likely EOF..");
+ printf("AliEMCALBiasAPD::ReadBiasAPDInfo - Error while reading input file; likely EOF..\n");
return;
}
inputFile >> iSM;
- t.fSuperModuleNum = iSM;
+ t->SetSuperModuleNum(iSM);
for (Int_t j=0; j<nAPDPerSM; j++) {
inputFile >> iCol >> iRow >> iElecId >> iDAC >> voltage;
+ // check that input values are not out bounds
+ if (iCol<0 || iCol>(AliEMCALGeoParams::fgkEMCALCols-1) ||
+ iRow<0 || iRow>(AliEMCALGeoParams::fgkEMCALRows-1) ) {
+ printf("AliEMCALBiasAPD::ReadBiasAPDInfo - Error while reading input file; j %d iCol %d iRow %d\n", j, iCol, iRow);
+ return;
+ }
+
// assume that this info is already swapped and done for this basis?
if (swapSides) {
// C side, oriented differently than A side: swap is requested
iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
}
- t.fElecId[iCol][iRow] = iElecId;
- t.fDAC[iCol][iRow] = iDAC;
- t.fVoltage[iCol][iRow] = voltage;
+ t->SetElecId(iCol, iRow, iElecId);
+ t->SetDAC(iCol, iRow, iDAC);
+ t->SetVoltage(iCol, iRow, voltage);
}
} // i, SuperModule
Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
for (Int_t i = 0; i < fNSuperModule; i++) {
- AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[i];
- outputFile << t.fSuperModuleNum << endl;
+ AliEMCALSuperModuleBiasAPD * t = (AliEMCALSuperModuleBiasAPD*) fSuperModuleData[i];
+ outputFile << t->GetSuperModuleNum() << endl;
for (Int_t j=0; j<nAPDPerSM; j++) {
iCol = j / AliEMCALGeoParams::fgkEMCALRows;
iRow = j % AliEMCALGeoParams::fgkEMCALRows;
- iElecId = t.fElecId[iCol][iRow];
- iDAC = t.fDAC[iCol][iRow];
- voltage = t.fVoltage[iCol][iRow];
+ iElecId = t->GetElecId(iCol, iRow);
+ iDAC = t->GetDAC(iCol, iRow);
+ voltage = t->GetVoltage(iCol, iRow);
if (swapSides) {
// C side, oriented differently than A side: swap is requested
Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
fNSuperModule = tree->GetEntries() / nAPDPerSM;
- if (fSuperModuleData) delete [] fSuperModuleData;
- fSuperModuleData = new AliEMCALSuperModuleBiasAPD[fNSuperModule];
-
Int_t iSM = 0; // SuperModule index
Int_t iCol = 0;
Int_t iRow = 0;
tree->GetEntry(ient);
// assume the index SuperModules come in order: i=iSM
- AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[iSM];
- t.fSuperModuleNum = iSM;
+ AliEMCALSuperModuleBiasAPD * t = (AliEMCALSuperModuleBiasAPD*) fSuperModuleData[iSM];
+ t->SetSuperModuleNum(iSM);
// assume that this info is already swapped and done for this basis?
if (swapSides) {
iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
}
- t.fElecId[iCol][iRow] = iElecId;
- t.fDAC[iCol][iRow] = iDAC;
- t.fVoltage[iCol][iRow] = voltage;
+ t->SetElecId(iCol, iRow, iElecId);
+ t->SetDAC(iCol, iRow, iDAC);
+ t->SetVoltage(iCol, iRow, voltage);
} //
Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
for (iSM = 0; iSM < fNSuperModule; iSM++) {
- AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[iSM];
+ AliEMCALSuperModuleBiasAPD * t = (AliEMCALSuperModuleBiasAPD*) fSuperModuleData[iSM];
for (Int_t j=0; j<nAPDPerSM; j++) {
iCol = j / AliEMCALGeoParams::fgkEMCALRows;
iRow = j % AliEMCALGeoParams::fgkEMCALRows;
- iElecId = t.fElecId[iCol][iRow];
- iDAC = t.fDAC[iCol][iRow];
- voltage = t.fVoltage[iCol][iRow];
+ iElecId = t->GetElecId(iCol, iRow);
+ iDAC = t->GetDAC(iCol, iRow);
+ voltage = t->GetVoltage(iCol, iRow);
if (swapSides) {
// C side, oriented differently than A side: swap is requested
//____________________________________________________________________________
AliEMCALBiasAPD::~AliEMCALBiasAPD()
{
- delete [] fSuperModuleData;
+ fSuperModuleData.Delete();
}
//____________________________________________________________________________
-AliEMCALSuperModuleBiasAPD AliEMCALBiasAPD::GetSuperModuleBiasAPDId(Int_t supModIndex)const
+AliEMCALSuperModuleBiasAPD * AliEMCALBiasAPD::GetSuperModuleBiasAPDNum(Int_t supModIndex)const
{
- AliEMCALSuperModuleBiasAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
- if (!fSuperModuleData)
- return t;
-
- return fSuperModuleData[supModIndex];
-}
-
-//____________________________________________________________________________
-AliEMCALSuperModuleBiasAPD AliEMCALBiasAPD::GetSuperModuleBiasAPDNum(Int_t supModIndex)const
-{
- AliEMCALSuperModuleBiasAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
- if (!fSuperModuleData)
- return t;
-
for (int i=0; i<fNSuperModule; i++) {
- if (fSuperModuleData[i].fSuperModuleNum == supModIndex) {
- return fSuperModuleData[i];
+ AliEMCALSuperModuleBiasAPD * t = (AliEMCALSuperModuleBiasAPD*) fSuperModuleData[i];
+ if (t->GetSuperModuleNum() == supModIndex) {
+ return t;
}
}
- return t;
+ // if we arrived here, then nothing was found.. just return a NULL pointer
+ return NULL;
}