]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDRawStream.cxx
Bigger memory allocation to allow derootification of the non-zero-suppressed TPC...
[u/mrichter/AliRoot.git] / PMD / AliPMDRawStream.cxx
index 885f9c937fac146ceaf56d37256a4e0ed6f29503..b3c893faf91ffe29d0e12791c8193fbd519c9c97 100644 (file)
@@ -88,16 +88,16 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
 
   AliPMDddldata *pmdddldata;
 
-  fRawReader->ReadHeader();
+  if (!fRawReader->ReadHeader()) return kFALSE;
   Int_t  iddl  = fRawReader->GetDDLID();
   Int_t dataSize = fRawReader->GetDataSize();
   Int_t totaldataword = dataSize/4;
-  Int_t equipId = fRawReader->GetEquipmentId();
 
   if (dataSize <= 0) return kFALSE;
   if (indexDDL != iddl)
     {
-      AliError("Mismatch in the DDL index");
+      AliWarning("Mismatch in the DDL index");
+      fRawReader->AddFatalErrorLog(kDDLIndexMismatch);
       return kFALSE;
     }
 
@@ -140,8 +140,10 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
 
   ifstream infile;
   infile.open(fileName.Data(), ios::in); // ascii file
-  if(!infile)
+  if(!infile) {
     AliError(Form("Could not read the mapping file for DDL No = %d",iddl));
+    fRawReader->AddFatalErrorLog(kNoMappingFile,Form("ddl=%d",iddl));
+  }
   
   Int_t modulePerDDL = 0;
   if (iddl < 4)
@@ -161,7 +163,6 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
   Int_t startRowBus[kNPatchBus], endRowBus[kNPatchBus];
   Int_t startColBus[kNPatchBus], endColBus[kNPatchBus];
 
-
   for (Int_t ibus = 0; ibus < kNPatchBus; ibus++)
     {
       mcmperBus[ibus]   = -1;
@@ -171,7 +172,6 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
       endColBus[ibus]   = -1;
     }
 
-
   for (Int_t im = 0; im < modulePerDDL; im++)
     {
       infile >> modno;
@@ -190,11 +190,8 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
        }
     }
 
-
-
   infile.close();
 
-
   AliPMDBlockHeader    blockHeader;
   AliPMDDspHeader      dspHeader;
   AliPMDPatchBusHeader pbusHeader;
@@ -203,7 +200,7 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
   const Int_t kdspHLen  = dspHeader.GetHeaderLength();
   const Int_t kpbusHLen = pbusHeader.GetHeaderLength();
   
-
+  Int_t parity;
   Int_t idet, ismn;
   Int_t irow = -1;
   Int_t icol = -1;
@@ -212,11 +209,10 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
   Int_t dspHeaderWord[10];
   Int_t pbusHeaderWord[4];
 
-  Int_t ilowLimit = 0;
-  Int_t iuppLimit = 0;
-
+  Int_t ilowLimit       = 0;
+  Int_t iuppLimit       = 0;
   Int_t blRawDataLength = 0;
-  Int_t iwordcount = 0;
+  Int_t iwordcount      = 0;
 
 
   for (Int_t iblock = 0; iblock < 2; iblock++)
@@ -224,7 +220,6 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
       ilowLimit = iuppLimit;
       iuppLimit = ilowLimit + kblHLen;
 
-
       for (Int_t i = ilowLimit; i < iuppLimit; i++)
        {
          blHeaderWord[i-ilowLimit] = (Int_t) buffer[i];
@@ -248,7 +243,6 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
 
          for (Int_t ibus = 0; ibus < 5; ibus++)
            {
-
              ilowLimit = iuppLimit;
              iuppLimit = ilowLimit + kpbusHLen;
 
@@ -276,7 +270,12 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
                  Int_t ich  = (data >> 12) & 0x003F;
                  Int_t imcm = (data >> 18) & 0x07FF;
                  Int_t ibit = (data >> 31) & 0x0001;
-
+                 parity = ComputeParity(data);
+                 if (ibit != parity)
+                   {
+                     AliWarning("ComputeParity:: Parity Error");
+                     fRawReader->AddMajorErrorLog(kParityError);
+                   }
                  GetRowCol(iddl, pbusid, imcm, ich, 
                            startRowBus, endRowBus,
                            startColBus, endColBus,
@@ -313,7 +312,6 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
       if (iwordcount == blRawDataLength) break;
 
     } // end of BLOCK
-
   
   delete [] buffer;
 
@@ -343,116 +341,96 @@ void AliPMDRawStream::GetRowCol(Int_t ddlno, Int_t pbusid,
   Int_t irownew = rowcol/4;
   Int_t icolnew = rowcol%4;
 
-  if (ddlno == 0)
+  if (ddlno == 0 )
     {
-      if (pbusid  <= 2)
-       {
-         if (mcmno >= 12)
-           {
-             row = startRowBus[pbusid] + irownew;
-             col = startColBus[pbusid] + (mcmno-12)*4 + icolnew;
-           }
-         else
-           {
-             // Add 16 to skip the 1st 15 rows
-             row = startRowBus[pbusid] + irownew + 16;
-             col = startColBus[pbusid] + mcmno*4 + icolnew;
-           }
-       }
-      else if (pbusid > 2)
-       {
-         row = startRowBus[pbusid] + irownew;
-         col = startColBus[pbusid] + mcmno*4 + icolnew;
-         
-       }
+      row = startRowBus[pbusid] + irownew;
+      col = startColBus[pbusid] + mcmno*4 + icolnew;
     }
   else if (ddlno == 1)
     {
-      if (pbusid  <= 2)
-       {
-         if (mcmno >= 12)
-           {
-             row = endRowBus[pbusid] - (15 - irownew);
-             col = startColBus[pbusid] + (mcmno-12)*4 + icolnew;
-           }
-         else
-           {
-             // Subtract 16 to skip the 1st 15 rows
-             row = endRowBus[pbusid] - 16 - (15 - irownew) ;
-             col = startColBus[pbusid] + mcmno*4 + icolnew;
-           }
-       }
-      else if (pbusid > 2)
-       {
-         row = endRowBus[pbusid] - (15 - irownew);
-         col = startColBus[pbusid] + mcmno*4 + icolnew;
-       }
+    row = endRowBus[pbusid] - (15 - irownew);
+    col = startColBus[pbusid] + mcmno*4 + icolnew;
+    
     }
-  else if (ddlno == 2)
+  else if (ddlno == 2 )
     {
       row = startRowBus[pbusid] + irownew;
       col = endColBus[pbusid] - mcmno*4 - (3 - icolnew);
     }
   else if (ddlno == 3)
     {
-      row = endRowBus[pbusid] - (15 - irownew);
-      col = endColBus[pbusid] - mcmno*4 - (3 - icolnew);
+    row = endRowBus[pbusid] - (15 - irownew);
+    col = endColBus[pbusid] - mcmno*4 - (3 - icolnew);
     }
-  else if (ddlno == 4)
+  else if (ddlno == 4 )
     {
-      if (pbusid  <= 16)
+      if (pbusid  < 18)
        {
-         if (mcmno >= 12)
-           {
-             row = startRowBus[pbusid] + irownew;
-             col = startColBus[pbusid] + (mcmno-12)*4 + icolnew;
-           }
-         else
+         if (mcmno <= 11)
            {
              // Add 16 to skip the 1st 15 rows
              row = startRowBus[pbusid] + irownew + 16;
-             col = startColBus[pbusid] + mcmno*4 + icolnew;
+             col = startColBus[pbusid] + (mcmno)*4 + icolnew;
+           }
+         else if(mcmno > 11)
+           {
+             row = startRowBus[pbusid] + irownew;
+             col = startColBus[pbusid] + (mcmno-12)*4 + icolnew;
            }
        }
-      else if (pbusid > 16 && pbusid <= 20)
-       {
-         row = startRowBus[pbusid] + irownew;
-         col = startColBus[pbusid] + mcmno*4 + icolnew;
-         
-       }
-      else if(pbusid > 20)
+      else if(pbusid > 17)
        {
-         row = endRowBus[pbusid] - (15 - irownew);
-         col = endColBus[pbusid] - mcmno*4 - (3 - icolnew);
+         if (mcmno <= 11)
+           {
+             col = endColBus[pbusid] - mcmno*4 - (3 - icolnew); 
+
+             if(endRowBus[pbusid] - startRowBus[pbusid] > 16)
+               row = endRowBus[pbusid] - (15 - irownew) - 16 ;
+             else
+               row = endRowBus[pbusid] - (15 - irownew) ;
+             
+
+           }
+         else if(mcmno > 11)
+           {
+             row = endRowBus[pbusid] - (15 - irownew)  ;
+             col = endColBus[pbusid] - (mcmno - 12)*4 - (3 - icolnew);
+           }
        }
     }
   else if (ddlno == 5)
     {
-      if (pbusid  <= 16)
+      if (pbusid  <= 17)
        {
-         if (mcmno >= 12)
+         if (mcmno > 11)
            {
-             row = endRowBus[pbusid] - (15 - irownew);
+             // Subtract 16 to skip the 1st 15 rows
+             row = endRowBus[pbusid] - 16 -(15 - irownew);
              col = startColBus[pbusid] + (mcmno-12)*4 + icolnew;
            }
          else
            {
-             // Subtract 16 to skip the 1st 15 rows
-             row = endRowBus[pbusid] - 16 - (15 - irownew) ;
+             row = endRowBus[pbusid]  - (15 - irownew) ;
              col = startColBus[pbusid] + mcmno*4 + icolnew;
            }
        }
-      else if (pbusid > 16 && pbusid <= 20)
-       {
-         row = endRowBus[pbusid] - (15 - irownew);
-         col = startColBus[pbusid] + mcmno*4 + icolnew;
-       }
-      else if (pbusid > 20)
+      
+      else if (pbusid > 17)
        {
-         row = startRowBus[pbusid] + irownew;
-         col = endColBus[pbusid] - mcmno*4 - (3 - icolnew);
+         if(mcmno > 11)
+           {
+             // Add 16 to skip the 1st 15 rows
+             row = startRowBus[pbusid] + irownew + 16;
+             col = endColBus[pbusid] - (mcmno - 12)*4 - (3 - icolnew);
+           }
+         else 
+           {
+             row = startRowBus[pbusid] + irownew ;
+             col = endColBus[pbusid] - mcmno*4 - (3 - icolnew); 
+           }
        }
     }
+  
 }
 //_____________________________________________________________________________
 void AliPMDRawStream::ConvertDDL2SMN(Int_t iddl, Int_t imodule,
@@ -499,3 +477,20 @@ void AliPMDRawStream::TransformH2S(Int_t smn, Int_t &row, Int_t &col) const
   col = icolnew;
 }
 //_____________________________________________________________________________
+Int_t AliPMDRawStream::ComputeParity(Int_t data)
+{
+// Calculate the parity bit
+
+  Int_t count = 0;
+  for(Int_t j = 0; j<29; j++)
+    {
+      if (data & 0x01 ) count++;
+      data >>= 1;
+    }
+  
+  Int_t parity = count%2;
+
+  return parity;
+}
+
+//_____________________________________________________________________________