]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Putting the ALTRO mapping in RAW as a base class. TPC,PHOS and FMD mapping classes...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 17 Mar 2006 10:43:53 +0000 (10:43 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 17 Mar 2006 10:43:53 +0000 (10:43 +0000)
RAW/AliAltroBuffer.cxx
RAW/AliAltroBuffer.h
RAW/AliAltroMapping.cxx
RAW/AliAltroMapping.h

index 33a3263719bca574793b0c66a97fd3661a373929..d9e6350a236b6b5a5ae6bb050866d5c586be6917 100644 (file)
@@ -300,12 +300,12 @@ void AliAltroBuffer::WriteTrailer(Int_t wordsNumber, Int_t padNumber,
   temp = 0x2AA;
   FillBuffer(temp);
   temp = 0xA << 6;
-  temp |= (wordsNumber >> 4);
+  temp |= ((wordsNumber & 0x3FF) >> 4);
   FillBuffer(temp);
   temp = (wordsNumber << 6) & 0x3FF;
   temp |= (0xA << 2);
 
-  Short_t hwAdress = fMapping->GetHWAdress(rowNumber,padNumber);
+  Short_t hwAdress = fMapping->GetHWAdress(rowNumber,padNumber,secNumber);
   if (hwAdress == -1)
     AliFatal(Form("No hardware (ALTRO) adress found for these pad-row (%d) and pad (%d) indeces !",rowNumber,padNumber));
       
@@ -316,10 +316,10 @@ void AliAltroBuffer::WriteTrailer(Int_t wordsNumber, Int_t padNumber,
 }
 
 //_____________________________________________________________________________
-Bool_t AliAltroBuffer::ReadTrailer(Int_t& wordsNumber, Int_t& padNumber,
-                                  Int_t& rowNumber, Int_t& secNumber)
+Bool_t AliAltroBuffer::ReadDummyTrailer(Int_t& wordsNumber, Int_t& padNumber,
+                                       Int_t& rowNumber, Int_t& secNumber)
 {
-//Read a trailer of 40 bits in the forward reading mode
+//Read a dummy trailer of 40 bits in the forward reading mode
 
   wordsNumber = GetNext();
   if (wordsNumber == -1) return kFALSE;
@@ -332,6 +332,41 @@ Bool_t AliAltroBuffer::ReadTrailer(Int_t& wordsNumber, Int_t& padNumber,
   return kTRUE;
 }
 
+//_____________________________________________________________________________
+Bool_t AliAltroBuffer::ReadTrailer(Int_t& wordsNumber, Int_t& padNumber,
+                                  Int_t& rowNumber, Int_t& secNumber)
+{
+//Read a trailer of 40 bits in the forward reading mode
+  if (!fMapping) {
+    AliError("No ALTRO mapping information is loaded! Reading a dummy trailer!");
+    return ReadDummyTrailer(wordsNumber,padNumber,
+                           rowNumber,secNumber);
+  }
+
+  Int_t temp = GetNext();
+  if (temp != 0x2AA)
+    AliFatal(Form("Incorrect trailer found ! Expecting 0x2AA but found %x !",temp));
+
+  temp = GetNext();
+  if ((temp >> 6) != 0xA)
+    AliFatal(Form("Incorrect trailer found ! Expecting 0xA but found %x !",temp >> 6));
+  wordsNumber = (temp << 4) & 0x3FF;
+
+  temp = GetNext();
+  wordsNumber |= (temp >> 6);
+  if ((temp & 0xF) != 0xA)
+    AliFatal(Form("Incorrect trailer found ! Expecting second 0xA but found %x !",temp >> 6));
+  Int_t hwAdress = (temp & 0x3) << 10;
+
+  temp = GetNext();
+  hwAdress |= temp;
+
+  rowNumber = fMapping->GetPadRow(hwAdress);
+  padNumber = fMapping->GetPad(hwAdress);
+  secNumber = fMapping->GetSector(hwAdress);
+  return kTRUE;
+}
+
 //_____________________________________________________________________________
 Bool_t AliAltroBuffer::ReadTrailerBackward(Int_t& wordsNumber, 
                                           Int_t& padNumber,
index 5f08b91f961d8e52c05d9dce861a126e53371e77..9cb46b62922a724abe52c523dbf57c62ff6cac8e 100644 (file)
@@ -49,6 +49,9 @@ class AliAltroBuffer: public TObject {
   Bool_t ReadTrailer(Int_t& wordsNumber, Int_t& padNumber, 
                     Int_t& rowNumber, Int_t &secNumber);
   //this method is used to read the trailer when the file is read forward
+  Bool_t ReadDummyTrailer(Int_t& wordsNumber, Int_t& padNumber, 
+                         Int_t& rowNumber, Int_t &secNumber);
+  //this method is used to read the trailer when the file is read forward
   Bool_t ReadTrailerBackward(Int_t& wordsNumber, Int_t& padNumber, 
                             Int_t& rowNumber, Int_t& secNumber);
   //this method is used to read the trailer when the file is read backward
@@ -70,6 +73,8 @@ class AliAltroBuffer: public TObject {
   //this method is used to fill the buffer with 2AA hexadecimal value and save it into the output file
   Int_t GetFillWordsNum() const {return fEndingFillWords;}
 
+  void  SetMapping(AliAltroMapping *mapping) { fMapping = mapping; }
+
  private:
   AliAltroBuffer(const AliAltroBuffer& source);
   AliAltroBuffer& operator = (const AliAltroBuffer& source);
index 54bc0d00befaa193012b5c725c37080cfd06af1f..eaee471126f2b49e3225ef5a9b99b5231263b56d 100644 (file)
@@ -15,7 +15,7 @@
 
 // This class handles the mapping of the Altro channels
 // The mapping is read from an external mapping files
-// The class is used by TPC,PHOS and FMD
+// The class is used as a base class by TPC,PHOS and FMD
 // Author: C.Cheshkov
 
 #include "AliAltroMapping.h"
@@ -28,18 +28,14 @@ ClassImp(AliAltroMapping)
 
 //_____________________________________________________________________________
 AliAltroMapping::AliAltroMapping(const char *mappingFile):
+  fIn(NULL),
   fNumberOfChannels(0),
-  fMaxHWAdress(0),
-  fMinPadRow(0),
-  fMaxPadRow(0),
-  fMaxPad(0),
-  fMapping(NULL),
-  fInvMapping(NULL)
+  fMaxHWAdress(0)
 {
   // Constructor
   // Reads the mapping from an external file
   if (mappingFile)
-    ReadMapping(mappingFile);
+    OpenMappingFile(mappingFile);
   else
     AliFatal("Mapping file not specified !");
 }
@@ -48,29 +44,14 @@ AliAltroMapping::AliAltroMapping(const char *mappingFile):
 AliAltroMapping::~AliAltroMapping()
 {
   // destructor
-  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;
-  }
-
 }
 
 //_____________________________________________________________________________
 AliAltroMapping::AliAltroMapping(const AliAltroMapping& mapping):
   TObject(mapping),
+  fIn(mapping.fIn),
   fNumberOfChannels(mapping.fNumberOfChannels),
-  fMaxHWAdress(mapping.fMaxHWAdress),
-  fMinPadRow(mapping.fMinPadRow),
-  fMaxPadRow(mapping.fMaxPadRow),
-  fMaxPad(mapping.fMaxPad),
-  fMapping(mapping.fMapping),
-  fInvMapping(mapping.fInvMapping)
+  fMaxHWAdress(mapping.fMaxHWAdress)
 {
 // Copy Constructor
 
@@ -87,141 +68,37 @@ AliAltroMapping& AliAltroMapping::operator = (const AliAltroMapping& /*mapping*/
 }
 
 //_____________________________________________________________________________
-Bool_t AliAltroMapping::ReadMapping(const char *mappingFile)
+Bool_t AliAltroMapping::OpenMappingFile(const char *mappingFile)
 {
   // Initalizes the ALTRO mapping from a file
   // Look at the TPC module for the format of
   // the mapping file
-  ifstream in(mappingFile);
-  if (!in) {
+  fIn = new ifstream(mappingFile);
+  if (!*fIn) {
     AliFatal(Form("Missing mapping file (%s) !",mappingFile));
     return kFALSE;
   }
-  if (!(in >> fNumberOfChannels)) {
+  if (!(*fIn >> fNumberOfChannels)) {
     AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile));
     return kFALSE;
   }
-  if (!(in >> fMaxHWAdress)) {
+  if (!(*fIn >> fMaxHWAdress)) {
     AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile));
     return kFALSE;
   }
-//   if (!(in >> fMinPadRow >> fMaxPadRow)) {
-//     AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile));
-//     return kFALSE;
-//   }
-//   if (!(in >> fMaxPad)) {
-//     AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile));
-//     return kFALSE;
-//   }
-
-  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;
-  }
-  for(Int_t i = 0; i < fNumberOfChannels ; i++) { //5504 is size of irorc mapping at ther moment only for irorc
-    Int_t hwAdress;
-    if (!(in >> hwAdress)) {
-      AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile));
-      return kFALSE;
-    }
-    if (hwAdress > fMaxHWAdress) {
-      AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAdress,fMaxHWAdress));
-      return kFALSE;
-    }
-    Int_t padrow,pad;
-    if (!(in >> padrow >> pad)) {
-      AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile));
-      return kFALSE;
-    }
-    fMapping[hwAdress][0] = padrow;
-    fMapping[hwAdress][1] = pad;
-
-    if (padrow > fMaxPadRow) fMaxPadRow = padrow;
-    if (padrow < fMinPadRow) fMinPadRow = padrow;
-    if (pad > fMaxPad) fMaxPad = pad;
-  }
 
-  fInvMapping = new Short_t*[fMaxPadRow - fMinPadRow + 1];
-  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 i = 0; i <= fMaxHWAdress; i++) {
-    Int_t padrow = fMapping[i][0];
-    Int_t pad = fMapping[i][1];
-    if(padrow != -1 && pad != -1)
-      fInvMapping[padrow-fMinPadRow][pad] = i;
-  }
-
-  in.close();
   return kTRUE;
 }
 
 //_____________________________________________________________________________
-Int_t AliAltroMapping::GetHWAdress(Int_t padrow, Int_t pad) const
+Bool_t AliAltroMapping::CloseMappingFile()
 {
-  // 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;
+  // Closes the external mapping
+  // file
+  if (fIn) {
+    fIn->close();
+    fIn = NULL;
   }
-  if (padrow < fMinPadRow || padrow > fMaxPadRow) {
-    AliWarning(Form("Index of pad-row (%d) outside the range (%d -> %d) !",padrow,fMinPadRow,fMaxPadRow));
-    return -1;
-  }
-  if (pad > fMaxPad) {
-    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)
-    AliWarning(Form("Hardware (ALTRO) adress is not defined for these pad-row (%d) and pad (%d) !",padrow,pad));
 
-  return hwAdress;
-}
-
-//_____________________________________________________________________________
-Int_t AliAltroMapping::GetPadRow(Int_t hwAdress) 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));
-    return -1;
-  }
-  Int_t padrow = fMapping[hwAdress][0];
-  if (padrow == -1)
-    AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAdress));
-
-  return padrow;
-}
-
-//_____________________________________________________________________________
-Int_t AliAltroMapping::GetPad(Int_t hwAdress) 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));
-    return -1;
-  }
-  Int_t pad = fMapping[hwAdress][1];
-  if (pad == -1)
-    AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAdress));
-
-  return pad;
+  return kTRUE;
 }
index cdaabc704006ba3821e5e22defa8001ecbc61617..4082d58067380b5ae6f5248a703bf49f8ce2eb6a 100644 (file)
@@ -20,20 +20,20 @@ class AliAltroMapping: public TObject {
   AliAltroMapping(const AliAltroMapping& mapping);
   AliAltroMapping& operator = (const AliAltroMapping& mapping);
 
-  Int_t GetHWAdress(Int_t padrow, Int_t pad) const;
-  Int_t GetPadRow(Int_t hwAdress) const;
-  Int_t GetPad(Int_t hwAdress) const;
-
- private:
-  Bool_t ReadMapping(const char *mappingFile);
-
+  virtual Int_t GetHWAdress(Int_t padrow, Int_t pad, Int_t sector) const = 0;
+  virtual Int_t GetPadRow(Int_t hwAdress) const = 0;
+  virtual Int_t GetPad(Int_t hwAdress) const = 0;
+  virtual Int_t GetSector(Int_t hwAdress) const = 0;
+
+ protected:
+  Bool_t OpenMappingFile(const char *mappingFile);
+  Bool_t CloseMappingFile();
+  virtual Bool_t ReadMapping() = 0;
+  virtual void   DeleteMappingArrays() = 0;
+
+  ifstream *fIn;               // External mapping file
   Int_t     fNumberOfChannels; // Number of ALTRO channels
   Int_t     fMaxHWAdress;      // Maximum HW adress
-  Int_t     fMinPadRow;        // Minimum Index of pad-row
-  Int_t     fMaxPadRow;        // Maximum Index of pad-row
-  Int_t     fMaxPad;           // Maximum Index of pad inside row
-  Short_t **fMapping;          // Array which connects hardware adresses to pad and pad-row indeces
-  Short_t **fInvMapping;       // Inverse of fMapping
 
   ClassDef(AliAltroMapping,0)  // Altro mapping handler class
 };