ClassImp(AliCaloAltroMapping)
+//_____________________________________________________________________________
+AliCaloAltroMapping::AliCaloAltroMapping():
+ AliAltroMapping(),
+ fMinRow(0),
+ fMaxRow(0),
+ fMinCol(0),
+ fMaxCol(0),
+ fInvMappingLow(NULL),
+ fInvMappingHigh(NULL)
+{
+ // Default constructor
+}
+
//_____________________________________________________________________________
AliCaloAltroMapping::AliCaloAltroMapping(const char *mappingFile):
AliAltroMapping(mappingFile),
fMaxRow(0),
fMinCol(0),
fMaxCol(0),
- fMapping(NULL),
fInvMappingLow(NULL),
fInvMappingHigh(NULL)
{
AliCaloAltroMapping::~AliCaloAltroMapping()
{
// destructor
- DeleteMappingArrays();
-}
-
-//_____________________________________________________________________________
-AliCaloAltroMapping::AliCaloAltroMapping(const AliCaloAltroMapping& mapping):
- AliAltroMapping(mapping),
- fMinRow(mapping.fMinRow),
- fMaxRow(mapping.fMaxRow),
- fMinCol(mapping.fMinCol),
- fMaxCol(mapping.fMaxCol),
- fMapping(mapping.fMapping),
- fInvMappingLow(mapping.fInvMappingLow),
- fInvMappingHigh(mapping.fInvMappingHigh)
-{
-// Copy Constructor
-
- Fatal("AliCaloAltroMapping", "copy constructor not implemented");
-}
-
-//_____________________________________________________________________________
-AliCaloAltroMapping& AliCaloAltroMapping::operator = (const AliCaloAltroMapping& /*mapping*/)
-{
-//Assigment operator
+ // Deletes the arrays which have been
+ // allocated during the reading of the
+ // mapping file
+ if (fInvMappingLow) delete [] fInvMappingLow;
- Fatal("operator =", "assignment operator not implemented");
- return *this;
+ if (fInvMappingHigh) delete [] fInvMappingHigh;
}
//_____________________________________________________________________________
fMaxRow = 0;
fMinCol = 0x7fffffff;
fMaxCol = 0;
- fMapping = new Short_t*[fMaxHWAddress+1];
+ fMappingSize = 3*(fMaxHWAddress+1);
+ fMapping = new Short_t[fMappingSize];
for (Int_t i = 0; i <= fMaxHWAddress; i++) {
- fMapping[i] = new Short_t[3];
- fMapping[i][0] = fMapping[i][1] = fMapping[i][2] = -1;
+ fMapping[3*i] = fMapping[3*i+1] = fMapping[3*i+2] = -1;
}
for(Int_t i = 0; i < fNumberOfChannels ; i++) { // 1792 = 2*896 channels connected to each RCU
AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
return kFALSE;
}
- Int_t row,col,gain;
- if (!(*fIn >> row >> col >> gain)) {
+ Int_t row,col,caloFlag;
+ if (!(*fIn >> row >> col >> caloFlag)) {
AliFatal("Syntax of the mapping file is wrong !");
return kFALSE;
}
- if (gain < 0 || gain > 1) {
- AliFatal(Form("Wrong gain value found (%d)! Should be 0 or 1 !",gain));
+ if (caloFlag < 0 || caloFlag > 3) {
+ AliFatal(Form("Wrong CaloFlag value found (%d)! Should be 0 ,1, 2 or 3 !",caloFlag));
return kFALSE;
}
- fMapping[hwAddress][0] = row;
- fMapping[hwAddress][1] = col;
- fMapping[hwAddress][2] = gain;
+ fMapping[3*hwAddress] = row;
+ fMapping[3*hwAddress+1] = col;
+ fMapping[3*hwAddress+2] = caloFlag;
if (row > fMaxRow) fMaxRow = row;
if (row < fMinRow) fMinRow = row;
}
- fInvMappingLow = new Short_t*[fMaxRow - fMinRow + 1];
- fInvMappingHigh = new Short_t*[fMaxRow - fMinRow + 1];
- for (Int_t i = 0; i <= (fMaxRow - fMinRow); i++) {
- fInvMappingLow[i] = new Short_t[fMaxCol - fMinCol + 1];
- fInvMappingHigh[i] = new Short_t[fMaxCol - fMinCol + 1];
- for (Int_t j = 0; j <= (fMaxCol - fMinCol); j++) {
- fInvMappingLow[i][j] = -1;
- fInvMappingHigh[i][j] = -1;
- }
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliCaloAltroMapping::CreateInvMapping()
+{
+ // Create the inverse mapping
+ // needed for the simulation of
+ // raw data
+ if (fInvMappingLow) return kTRUE;
+
+ if (!fMapping) {
+ AliWarning("Mapping array was not initalized correctly ! Impossible to create the inverse mapping !");
+ return kFALSE;
}
+ Int_t nRows = fMaxRow - fMinRow + 1;
+ Int_t nCols = fMaxCol - fMinCol + 1;
+ Int_t invMappingSize = nRows*nCols;
+
+ fInvMappingLow = new Short_t[invMappingSize];
+ fInvMappingHigh = new Short_t[invMappingSize];
+ for (Int_t i = 0; i < nRows; i++) {
+ for (Int_t j = 0; j < nCols; j++) {
+ fInvMappingLow[nCols*i+j] = -1;
+ fInvMappingHigh[nCols*i+j] = -1;
+ }
+ }
for(Int_t i = 0; i <= fMaxHWAddress; i++) {
- Int_t row = fMapping[i][0];
- Int_t col = fMapping[i][1];
- Int_t gain = fMapping[i][2];
+ Int_t row = fMapping[3*i];
+ Int_t col = fMapping[3*i+1];
+ Int_t caloFlag = fMapping[3*i+2];
if(row != -1 && col != -1) {
- if (gain == 0)
- fInvMappingLow[row-fMinRow][col-fMinCol] = i;
- if (gain == 1)
- fInvMappingHigh[row-fMinRow][col-fMinCol] = i;
+ if (caloFlag == 0)
+ fInvMappingLow[nCols*(row-fMinRow)+(col-fMinCol)] = i;
+ if (caloFlag == 1)
+ fInvMappingHigh[nCols*(row-fMinRow)+(col-fMinCol)] = i;
}
}
}
//_____________________________________________________________________________
-Int_t AliCaloAltroMapping::GetHWAddress(Int_t row, Int_t col, Int_t gain) const
+Int_t AliCaloAltroMapping::GetHWAddress(Int_t row, Int_t col, Int_t caloFlag)
{
// Get the content of the mapping array
// return -1 in case there is no hardware
- // adress defined for these row-column-gain
+ // adress defined for these row-column-caloFlag
if (!fInvMappingLow || !fInvMappingHigh) {
- AliWarning("Mapping array was not initalized correctly !");
- return -1;
+ if (!CreateInvMapping()) return -1;
}
if (row < fMinRow || row > fMaxRow) {
AliWarning(Form("Index of row (%d) outside the range (%d -> %d) !",row,fMinRow,fMaxRow));
AliWarning(Form("Index of column (%d) outside the range (0 -> %d) !",col,fMinCol,fMaxCol));
return -1;
}
- if (gain < 0 || gain > 1) {
- AliWarning(Form("Invalid gain (%d)! Should be 0 or 1 !",gain));
+ if (caloFlag < 0 || caloFlag > 3) {
+ AliWarning(Form("Invalid caloFlag (%d)! Should be 0, 1, 2 or 3 !",caloFlag));
return -1;
}
Int_t hwAddress = -1;
- if (gain == 0)
- hwAddress = fInvMappingLow[row-fMinRow][col-fMinCol];
- if (gain == 1)
- hwAddress = fInvMappingHigh[row-fMinRow][col-fMinCol];
+ if (caloFlag == 0)
+ hwAddress = fInvMappingLow[(fMaxCol - fMinCol + 1)*(row-fMinRow)+(col-fMinCol)];
+ if (caloFlag == 1)
+ hwAddress = fInvMappingHigh[(fMaxCol - fMinCol + 1)*(row-fMinRow)+(col-fMinCol)];
if (hwAddress == -1)
- AliWarning(Form("Hardware (ALTRO) adress is not defined for these row (%d), column (%d) and gain (%d) !",row,col,gain));
+ AliWarning(Form("Hardware (ALTRO) adress is not defined for these row (%d), column (%d) and caloFlag (%d) !",row,col,caloFlag));
return hwAddress;
}
AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
return -1;
}
- Int_t row = fMapping[hwAddress][0];
+ Int_t row = fMapping[3*hwAddress];
if (row == -1)
AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
return -1;
}
- Int_t col = fMapping[hwAddress][1];
+ Int_t col = fMapping[3*hwAddress+1];
if (col == -1)
AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
//_____________________________________________________________________________
Int_t AliCaloAltroMapping::GetSector(Int_t hwAddress) const
{
- // Return the gain factor (0/1)
+ // Return the caloFlag factor (0/1)
// Note the difference w.r.t to the base class notation
if (!fMapping) {
AliWarning("Mapping array was not initalized correctly !");
AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
return -1;
}
- Int_t gain = fMapping[hwAddress][2];
- if (gain == -1)
+ Int_t caloFlag = fMapping[3*hwAddress+2];
+ if (caloFlag == -1)
AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
- return gain;
-}
-
-//_____________________________________________________________________________
-void AliCaloAltroMapping::DeleteMappingArrays()
-{
- // Deletes the arrays which have been
- // allocated during the reading of the
- // mapping file
- if (fMapping) {
- for (Int_t i = 0; i <= fMaxHWAddress; i++) delete [] fMapping[i];
- delete [] fMapping;
- }
-
- if (fInvMappingLow) {
- for (Int_t i = 0; i <= (fMaxRow - fMinRow); i++)
- delete [] fInvMappingLow[i];
- delete [] fInvMappingLow;
- }
-
- if (fInvMappingHigh) {
- for (Int_t i = 0; i <= (fMaxRow - fMinRow); i++)
- delete [] fInvMappingHigh[i];
- delete [] fInvMappingHigh;
- }
+ return caloFlag;
}