X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TPC%2FAliTPCAltroMapping.cxx;h=546b3c3c5b016c0e8c4083e22f0ed3491908ab53;hb=32743cf4287cd34b2f0ce64268bdf3154a0ea133;hp=ba391b19930d2c9f96c96c9159ef48338d695570;hpb=dc43b139bfbacac831ee1008ebb04b3b01858ee0;p=u%2Fmrichter%2FAliRoot.git diff --git a/TPC/AliTPCAltroMapping.cxx b/TPC/AliTPCAltroMapping.cxx index ba391b19930..546b3c3c5b0 100644 --- a/TPC/AliTPCAltroMapping.cxx +++ b/TPC/AliTPCAltroMapping.cxx @@ -25,13 +25,23 @@ ClassImp(AliTPCAltroMapping) +//_____________________________________________________________________________ +AliTPCAltroMapping::AliTPCAltroMapping(): + AliAltroMapping(), + fMinPadRow(0), + fMaxPadRow(0), + fMaxPad(0), + fInvMapping(NULL) +{ + // Default constructor +} + //_____________________________________________________________________________ AliTPCAltroMapping::AliTPCAltroMapping(const char *mappingFile): AliAltroMapping(mappingFile), fMinPadRow(0), fMaxPadRow(0), fMaxPad(0), - fMapping(NULL), fInvMapping(NULL) { // Constructor @@ -43,30 +53,7 @@ AliTPCAltroMapping::AliTPCAltroMapping(const char *mappingFile): AliTPCAltroMapping::~AliTPCAltroMapping() { // destructor - DeleteMappingArrays(); -} - -//_____________________________________________________________________________ -AliTPCAltroMapping::AliTPCAltroMapping(const AliTPCAltroMapping& mapping): - AliAltroMapping(mapping), - fMinPadRow(mapping.fMinPadRow), - fMaxPadRow(mapping.fMaxPadRow), - fMaxPad(mapping.fMaxPad), - fMapping(mapping.fMapping), - fInvMapping(mapping.fInvMapping) -{ -// Copy Constructor - - Fatal("AliTPCAltroMapping", "copy constructor not implemented"); -} - -//_____________________________________________________________________________ -AliTPCAltroMapping& AliTPCAltroMapping::operator = (const AliTPCAltroMapping& /*mapping*/) -{ -//Assigment operator - - Fatal("operator =", "assignment operator not implemented"); - return *this; + if (fInvMapping) delete [] fInvMapping; } //_____________________________________________________________________________ @@ -83,20 +70,20 @@ Bool_t AliTPCAltroMapping::ReadMapping() fMinPadRow = 0x7fffffff; fMaxPadRow = 0; fMaxPad = 0; - fMapping = new Short_t*[fMaxHWAdress+1]; - for (Int_t i = 0; i <= fMaxHWAdress; i++) { - fMapping[i] = new Short_t[2]; - fMapping[i][0] = fMapping[i][1] = -1; + fMappingSize = 2*(fMaxHWAddress+1); + fMapping = new Short_t[fMappingSize]; + for (Int_t i = 0; i <= fMaxHWAddress; i++) { + fMapping[2*i] = fMapping[2*i+1] = -1; } for(Int_t i = 0; i < fNumberOfChannels ; i++) { //5504 is size of irorc mapping at ther moment only for irorc - Int_t hwAdress; - if (!(*fIn >> hwAdress)) { + Int_t hwAddress; + if (!(*fIn >> hwAddress)) { AliFatal("Syntax of the mapping file is wrong !"); return kFALSE; } - if (hwAdress > fMaxHWAdress) { - AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAdress,fMaxHWAdress)); + if (hwAddress > fMaxHWAddress) { + AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress)); return kFALSE; } Int_t padrow,pad; @@ -105,39 +92,57 @@ Bool_t AliTPCAltroMapping::ReadMapping() return kFALSE; } - fMapping[hwAdress][0] = padrow; - fMapping[hwAdress][1] = pad; + fMapping[2*hwAddress] = padrow; + fMapping[2*hwAddress+1] = pad; if (padrow > fMaxPadRow) fMaxPadRow = padrow; if (padrow < fMinPadRow) fMinPadRow = padrow; if (pad > fMaxPad) fMaxPad = pad; } - fInvMapping = new Short_t*[fMaxPadRow - fMinPadRow + 1]; + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliTPCAltroMapping::CreateInvMapping() +{ + // Create the inverse mapping + // needed for the simulation of + // raw data + if (fInvMapping) return kTRUE; + + if (!fMapping) { + AliWarning("Mapping array was not initalized correctly ! Impossible to create the inverse mapping !"); + return kFALSE; + } + + Int_t nRows = fMaxPadRow - fMinPadRow + 1; + Int_t nPads = fMaxPad + 1; + Int_t invMappingSize = nRows*nPads; + + fInvMapping = new Short_t[invMappingSize]; for (Int_t i = 0; i <= (fMaxPadRow - fMinPadRow); i++) { - fInvMapping[i] = new Short_t[fMaxPad + 1]; - for (Int_t j = 0; j <= fMaxPad; j++) fInvMapping[i][j] = -1; + for (Int_t j = 0; j <= fMaxPad; j++) fInvMapping[nPads*i+j] = -1; } - for(Int_t i = 0; i <= fMaxHWAdress; i++) { - Int_t padrow = fMapping[i][0]; - Int_t pad = fMapping[i][1]; + for(Int_t i = 0; i <= fMaxHWAddress; i++) { + Int_t padrow = fMapping[2*i]; + Int_t pad = fMapping[2*i+1]; if(padrow != -1 && pad != -1) - fInvMapping[padrow-fMinPadRow][pad] = i; + fInvMapping[nPads*(padrow-fMinPadRow)+pad] = i; } return kTRUE; } //_____________________________________________________________________________ -Int_t AliTPCAltroMapping::GetHWAdress(Int_t padrow, Int_t pad, Int_t /* sector */) const +Int_t AliTPCAltroMapping::GetHWAddress(Int_t padrow, Int_t pad, Int_t /* sector */) { // Get the content of the mapping array // return -1 in case there is no hardware // adress defined for these pad-row and pad if (!fInvMapping) { - AliWarning("Mapping array was not initalized correctly !"); - return -1; + if (!CreateInvMapping()) return -1; } if (padrow < fMinPadRow || padrow > fMaxPadRow) { AliWarning(Form("Index of pad-row (%d) outside the range (%d -> %d) !",padrow,fMinPadRow,fMaxPadRow)); @@ -147,70 +152,52 @@ Int_t AliTPCAltroMapping::GetHWAdress(Int_t padrow, Int_t pad, Int_t /* sector * AliWarning(Form("Index of pad (%d) outside the range (0 -> %d) !",pad,fMaxPad)); return -1; } - Int_t hwAdress = fInvMapping[padrow-fMinPadRow][pad]; - if (hwAdress == -1) + Int_t hwAddress = fInvMapping[(fMaxPad+1)*(padrow-fMinPadRow)+pad]; + if (hwAddress == -1) AliWarning(Form("Hardware (ALTRO) adress is not defined for these pad-row (%d) and pad (%d) !",padrow,pad)); - return hwAdress; + return hwAddress; } //_____________________________________________________________________________ -Int_t AliTPCAltroMapping::GetPadRow(Int_t hwAdress) const +Int_t AliTPCAltroMapping::GetPadRow(Int_t hwAddress) const { if (!fMapping) { AliWarning("Mapping array was not initalized correctly !"); return -1; } - if (hwAdress > fMaxHWAdress) { - AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAdress,fMaxHWAdress)); + if (hwAddress > fMaxHWAddress) { + AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress)); return -1; } - Int_t padrow = fMapping[hwAdress][0]; + Int_t padrow = fMapping[2*hwAddress]; if (padrow == -1) - AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAdress)); + AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress)); return padrow; } //_____________________________________________________________________________ -Int_t AliTPCAltroMapping::GetPad(Int_t hwAdress) const +Int_t AliTPCAltroMapping::GetPad(Int_t hwAddress) const { if (!fMapping) { AliWarning("Mapping array was not initalized correctly !"); return -1; } - if (hwAdress > fMaxHWAdress) { - AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAdress,fMaxHWAdress)); + if (hwAddress > fMaxHWAddress) { + AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress)); return -1; } - Int_t pad = fMapping[hwAdress][1]; + Int_t pad = fMapping[2*hwAddress+1]; if (pad == -1) - AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAdress)); + AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress)); return pad; } //_____________________________________________________________________________ -Int_t AliTPCAltroMapping::GetSector(Int_t /* hwAdress */) const +Int_t AliTPCAltroMapping::GetSector(Int_t /* hwAddress */) const { AliWarning("Sector index is not contained in the TPC altro mapping !"); return -1; } - -//_____________________________________________________________________________ -void AliTPCAltroMapping::DeleteMappingArrays() -{ - // Deletes the arrays which have been - // allocated during the reading of the - // mapping file - if (fMapping) { - for (Int_t i = 0; i <= fMaxHWAdress; i++) delete [] fMapping[i]; - delete [] fMapping; - } - - if (fInvMapping) { - for (Int_t i = 0; i <= (fMaxPadRow - fMinPadRow); i++) - delete [] fInvMapping[i]; - delete [] fInvMapping; - } -}