LCOV - code coverage report
Current view: top level - AD/ADbase - AliADRawStream.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 112 0.9 %
Date: 2016-06-14 17:26:59 Functions: 1 10 10.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : ///////////////////////////////////////////////////////////////////////////////
      17             : ///
      18             : /// This is a class for reading the AD DDL raw data
      19             : /// The format of the raw data corresponds to the one
      20             : /// implemented in AliADBuffer class. 
      21             : ///
      22             : ///////////////////////////////////////////////////////////////////////////////
      23             : 
      24             : #include "AliADRawStream.h"
      25             : #include "AliRawReader.h"
      26             : #include "AliLog.h"
      27             : #include "AliDAQ.h"
      28             : #include "AliADCalibData.h"
      29          16 : ClassImp(AliADRawStream)
      30             : 
      31             : //_____________________________________________________________________________
      32           0 : AliADRawStream::AliADRawStream(AliRawReader* rawReader) :
      33           0 :   fTrigger(0),
      34           0 :   fTriggerMask(0),
      35           0 :   fPosition(-1),
      36           0 :   fRawReader(rawReader),
      37           0 :   fData(NULL)
      38           0 : {
      39             :   // create an object to read AD raw data
      40             :   //
      41             :   // select the raw data corresponding to
      42             :   // the AD detector id
      43           0 :   fRawReader->Reset();
      44           0 :   AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("AD")));
      45           0 :   fRawReader->Select("AD");
      46             : 
      47             :   // Initalize the containers
      48           0 :   for(Int_t i = 0; i < kNChannels; i++) {
      49           0 :     fTime[i] = fWidth[i] = 0;
      50           0 :     for(Int_t j = 0; j < kNEvOfInt; j++) {
      51           0 :       fADC[i][j] = 0;
      52           0 :       fIsInt[i][j] = fIsBB[i][j] = fIsBG[i][j] = kFALSE;
      53             :     }
      54           0 :     fBBScalers[i] = fBGScalers[i] = 0;
      55           0 :     for(Int_t j = 0; j < kNBunches; j++) {
      56           0 :       fChargeMB[i][j] = 0;
      57           0 :       fIsIntMB[i][j] = fIsBBMB[i][j] = fIsBGMB[i][j] = kFALSE;
      58             :     }
      59             :   }
      60           0 :   for(Int_t i = 0; i < kNScalers; i++) fScalers[i] = 0;
      61           0 :   for(Int_t i = 0; i < kNBunches; i++) fBunchNumbers[i] = 0;
      62           0 : }
      63             : 
      64             : //_____________________________________________________________________________
      65             : AliADRawStream::~AliADRawStream()
      66           0 : {
      67             :   // destructor
      68           0 : }
      69             : 
      70             : //_____________________________________________________________________________
      71             : void AliADRawStream::Reset()
      72             : {
      73             :   // reset raw stream params
      74             : 
      75             :   // Reinitalize the containers
      76           0 :   for(Int_t i = 0; i < kNChannels; i++) {
      77           0 :     fTime[i] = fWidth[i] = 0;
      78           0 :     for(Int_t j = 0; j < kNEvOfInt; j++) {
      79           0 :       fADC[i][j] = 0;
      80           0 :       fIsInt[i][j] = fIsBB[i][j] = fIsBG[i][j] = kFALSE;
      81             :     }
      82           0 :     fBBScalers[i] = fBGScalers[i] = 0;
      83           0 :     for(Int_t j = 0; j < kNBunches; j++) {
      84           0 :       fChargeMB[i][j] = 0;
      85           0 :       fIsIntMB[i][j] = fIsBBMB[i][j] = fIsBGMB[i][j] = kFALSE;
      86             :     }
      87             :   }
      88           0 :   for(Int_t i = 0; i < kNScalers; i++) fScalers[i] = 0;
      89           0 :   for(Int_t i = 0; i < kNBunches; i++) fBunchNumbers[i] = 0;
      90             : 
      91           0 :   fTrigger = fTriggerMask = 0;
      92           0 :   fPosition = -1;
      93           0 :   fData = NULL;
      94             : 
      95           0 :   if (fRawReader) fRawReader->Reset();
      96           0 : }
      97             : 
      98             : //_____________________________________________________________________________
      99             : Bool_t AliADRawStream::Next()
     100             : {
     101             :   // read next digit from the AD raw data stream
     102             :   // return kFALSE in case of error or no digits left
     103             : 
     104           0 :   if (fPosition >= 0) return kFALSE;
     105             : 
     106           0 :   if (!fRawReader->ReadNextData(fData)) return kFALSE;
     107           0 :   if (fRawReader->GetDataSize() == 0) return kFALSE;
     108             :      
     109           0 :   if (fRawReader->GetDataSize() != 5936) {
     110           0 :      fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 5936",fRawReader->GetDataSize()));
     111           0 :      AliWarning(Form("Wrong AD raw data size: %d, expected 5936 bytes!",fRawReader->GetDataSize()));
     112           0 :      return kFALSE;
     113             :   }
     114             : 
     115           0 :   fPosition = 0;
     116             : 
     117           0 :   fTrigger = GetNextWord() & 0xffff;
     118           0 :   fTriggerMask = GetNextWord() & 0xffff;
     119             : 
     120           0 :   for(Int_t iScaler = 0; iScaler < kNScalers; iScaler++)
     121           0 :      fScalers[iScaler] = GetNextWord();
     122             : 
     123           0 :   for(Int_t iBunch = 0; iBunch < kNBunches; iBunch++)
     124           0 :      fBunchNumbers[iBunch] = GetNextWord();
     125             :   
     126             :   Int_t iCIU=0;
     127           0 :   for (Int_t  iV0CIU = 0; iV0CIU < 8; iV0CIU++) {
     128             :     
     129           0 :     if(iV0CIU != 2 && iV0CIU != 5) {
     130           0 :       for(Int_t iWord = 0; iWord<182; iWord++) GetNextWord();
     131           0 :       continue;
     132             :         }
     133             :  
     134             :   // decoding of one Channel Interface Unit numbered iCIU - there are 8 channels per CIU (and 2 CIUs) :
     135             :   
     136           0 :     for (Int_t iChannel_Offset = iCIU*8; iChannel_Offset < (iCIU*8)+8; iChannel_Offset=iChannel_Offset+4) { 
     137           0 :       for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {
     138           0 :         for(Int_t iEvOfInt = 0; iEvOfInt < kNEvOfInt; iEvOfInt++) {
     139           0 :           UShort_t data = GetNextShort();
     140           0 :           fADC[iChannel][iEvOfInt] = data & 0x3ff;
     141           0 :           fIsInt[iChannel][iEvOfInt] = (data >> 10) & 0x1;
     142             :         }
     143             :       }
     144           0 :       for(Int_t iEvOfInt = 0; iEvOfInt < kNEvOfInt; iEvOfInt=iEvOfInt+2) {
     145           0 :         UShort_t data = GetNextShort();
     146           0 :         for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {          
     147           0 :           fIsBB[iChannel][iEvOfInt] = (data >>  2*(iChannel-iChannel_Offset)) & 0x1;
     148           0 :           fIsBG[iChannel][iEvOfInt] = (data >> (2*(iChannel-iChannel_Offset)+1)) & 0x1; 
     149           0 :           if(iEvOfInt < (kNEvOfInt - 1)) {      
     150           0 :              fIsBB[iChannel][iEvOfInt+1] = (data >> (8+ 2*(iChannel-iChannel_Offset))) & 0x1;
     151           0 :              fIsBG[iChannel][iEvOfInt+1] = (data >> (8+ 2*(iChannel-iChannel_Offset)+1)) & 0x1;
     152           0 :           }
     153             :         }
     154             :       }
     155             : 
     156           0 :       GetNextShort();
     157             : 
     158           0 :       for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {
     159           0 :         for(Int_t iBunch = 0; iBunch < kNBunches; iBunch++) {
     160           0 :           UShort_t data = GetNextShort();
     161           0 :           fChargeMB[iChannel][iBunch] = data & 0x3ff;
     162           0 :           fIsIntMB[iChannel][iBunch] = (data >> 10) & 0x1;
     163             :         } 
     164             :       }
     165             :    
     166           0 :       for(Int_t iBunch = 0; iBunch < kNBunches; iBunch=iBunch+2) {
     167           0 :         UShort_t data = GetNextShort();
     168           0 :         for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {  
     169           0 :           fIsBBMB[iChannel][iBunch] = (data >>  2*iBunch) & 0x1;
     170           0 :           fIsBGMB[iChannel][iBunch] = (data >> (2*iBunch+1)) & 0x1;
     171           0 :           if(iBunch < (kNBunches - 1)) {
     172           0 :              fIsBBMB[iChannel][iBunch+1] = (data >> (8+2*iBunch)) & 0x1;
     173           0 :              fIsBGMB[iChannel][iBunch+1] = (data >> (8+2*iBunch+1)) & 0x1;
     174           0 :           }       
     175             :         }
     176             :       }
     177             :   
     178           0 :       GetNextShort();
     179             :    
     180           0 :       for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {
     181           0 :         fBBScalers[iChannel] = ((ULong64_t)GetNextWord()) << 32;
     182           0 :         fBBScalers[iChannel] |= GetNextWord();
     183           0 :         fBGScalers[iChannel] = ((ULong64_t)GetNextWord()) << 32;
     184           0 :         fBGScalers[iChannel] |= GetNextWord();
     185             :       }
     186             : 
     187             :     } 
     188             : 
     189           0 :     for(Int_t iChannel = (iCIU*8) + 7; iChannel >= iCIU*8; iChannel--) { 
     190           0 :       UInt_t time = GetNextWord();
     191           0 :       fTime[iChannel]  = time & 0xfff;
     192           0 :       fWidth[iChannel] = ((time >> 12) & 0x7f); // HPTDC used in pairing mode
     193             :     }
     194           0 :     iCIU++;
     195             :     // End of decoding of one CIU card
     196             :     //AliWarning(Form("Number of bytes used at end of reading CIU card number %d %d", iCIU+1, fPosition)); 
     197             :     
     198           0 :   } // end of decoding the eight CIUs
     199             :     
     200             :   return kTRUE;
     201           0 : }
     202             : 
     203             : //_____________________________________________________________________________
     204             : UInt_t AliADRawStream::GetNextWord()
     205             : {
     206             :   // This method returns the next 32 bit word
     207             :   // inside the raw data payload.
     208             :   // The method is supposed to be endian (platform)
     209             :   // independent.
     210           0 :   if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");
     211             : 
     212             :   UInt_t word = 0;
     213           0 :   word |= fData[fPosition++];
     214           0 :   word |= fData[fPosition++] << 8;
     215           0 :   word |= fData[fPosition++] << 16;
     216           0 :   word |= fData[fPosition++] << 24;
     217             : 
     218           0 :   return word;
     219             : }
     220             : 
     221             : //_____________________________________________________________________________
     222             : UShort_t AliADRawStream::GetNextShort()
     223             : {
     224             :   // This method returns the next 16 bit word
     225             :   // inside the raw data payload.
     226             :   // The method is supposed to be endian (platform)
     227             :   // independent.
     228           0 :   if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");
     229             : 
     230             :   UShort_t word = 0;
     231           0 :   word |= fData[fPosition++];
     232           0 :   word |= fData[fPosition++] << 8;
     233             : 
     234           0 :   return word;
     235             : }

Generated by: LCOV version 1.11