LCOV - code coverage report
Current view: top level - RAW/RAWDatarec - AliAltroRawStream.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 14 40 35.0 %
Date: 2016-06-14 17:26:59 Functions: 15 44 34.1 %

          Line data    Source code
       1             : #ifndef ALIALTRORAWSTREAM_H
       2             : #define ALIALTRORAWSTREAM_H
       3             : /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       4             :  * See cxx source for full Copyright notice                               */
       5             : 
       6             : /* $Id$ */
       7             : 
       8             : ///////////////////////////////////////////////////////////////////////////////
       9             : ///
      10             : /// This is a base class for reading raw data digits in Altro format
      11             : /// The class is able to read both old and new RCU trailer formats
      12             : /// Switch between formats is done automatically using the last payload word.
      13             : /// In case the Common Data Header is 7 32-bit words long, one
      14             : /// can use the fIsShortDataHeader flag.
      15             : ///
      16             : ///////////////////////////////////////////////////////////////////////////////
      17             : 
      18             : #include <TObject.h>
      19             : 
      20             : class AliRawReader;
      21             : 
      22             : class AliAltroRawStream: public TObject {
      23             :   public :
      24             :     AliAltroRawStream(AliRawReader* rawReader);
      25             :     virtual ~AliAltroRawStream();
      26             : 
      27             :     virtual void             Reset();
      28             :     virtual Bool_t           Next();
      29             : 
      30             :     virtual Bool_t NextDDL(UChar_t* data = NULL);              // Iterate over DDLs/RCUs
      31             :     virtual Bool_t NextChannel();                              // Iterate over altro channels
      32             :     virtual Bool_t NextBunch(UShort_t *bunchData,
      33             :                              Int_t &bunchLength,
      34             :                              Int_t &startTimeBin);             // Iterate over altro bunches
      35             : 
      36           0 :     Int_t GetDDLNumber()  const { return fDDLNumber; }  // Provide current DDL number
      37           0 :     Int_t GetPrevDDLNumber() const { return fPrevDDLNumber; }// Provide previous DDL number
      38           0 :     Bool_t  IsNewDDLNumber() const {return (fDDLNumber != fPrevDDLNumber);};
      39         148 :     Int_t GetRCUId()      const { return fRCUId; }      // Provide current RCU identifier
      40           0 :     Int_t GetPrevRCUId()  const { return fPrevRCUId; }  // Provide previous RCU identifier
      41           0 :     Bool_t  IsNewRCUId() const {return (fRCUId != fPrevRCUId);};
      42         790 :     Int_t GetHWAddress()  const { return fHWAddress; }  // Provide current hardware address
      43           0 :     Int_t GetPrevHWAddress() const { return fPrevHWAddress; }  // Provide previous hardware address
      44           0 :     Bool_t  IsNewHWAddress() const {return (fHWAddress != fPrevHWAddress) || IsNewDDLNumber();};
      45           0 :     Int_t GetTime()       const { return fTime; }       // Provide index of current time bin
      46           0 :     Int_t GetPrevTime()   const { return fPrevTime; }   // Provide index of previous time bin
      47           0 :     Bool_t  IsNewTime()   const {return (fTime != fPrevTime) || IsNewHWAddress();};
      48           0 :     Int_t GetSignal()     const { return fSignal; }     // Provide signal in ADC counts
      49           0 :     Int_t GetTimeLength() const { return fTimeBunch; }  // Provide total length of current time bunch
      50             : 
      51         790 :     Int_t GetChannelPayloadSize() const { return fChannelPayloadSize; }
      52             :     Int_t GetRCUPayloadSizeInSOD() const;
      53             : 
      54             :     Int_t GetBranch()     const; // Provide the branch index for the current hardware address
      55             :     Int_t GetFEC()        const; // Provide the front-end card index for the current hardware address
      56             :     Int_t GetAltro()      const; // Provide the altro chip index for the current hardware address
      57             :     Int_t GetChannel()    const; // Provide the channel index for the current hardware address
      58             : 
      59             :     Bool_t  GetRCUTrailerData(UChar_t*& data) const;              // Provide a pointer to RCU trailer
      60         148 :     Int_t   GetRCUTrailerSize() const { return fRCUTrailerSize; } // Provide size of RCU trailer
      61             : 
      62             :     // RCU trailer related getters
      63         148 :     UInt_t  GetFECERRA() const { return fFECERRA; }
      64         148 :     UInt_t  GetFECERRB() const { return fFECERRB; }
      65         148 :     UShort_t GetERRREG2() const { return fERRREG2; }
      66         148 :     UShort_t GetNChAddrMismatch() const { return fERRREG3; }
      67         148 :     UShort_t GetNChLengthMismatch() const { return fERRREG4; }
      68             : 
      69         148 :     UShort_t GetActiveFECsA() const { return fActiveFECsA; }
      70         148 :     UShort_t GetActiveFECsB() const { return fActiveFECsB; }
      71             : 
      72         148 :     UInt_t  GetAltroCFG1() const { return fAltroCFG1; }
      73           0 :     UChar_t GetBaselineCorr() const { return fAltroCFG1 & 0xF; }
      74           0 :     Bool_t  GetPolarity() const { return (fAltroCFG1 >> 4) & 0x1; }
      75           0 :     UChar_t GetNPresamples() const  { return (fAltroCFG1 >> 5) & 0x3; }
      76           0 :     UChar_t GetNPostsamples() const { return (fAltroCFG1 >> 7) & 0xF; }
      77           0 :     Bool_t  GetSecondBaselineCorr() const { return (fAltroCFG1 >> 11) & 0x1; }
      78           0 :     UChar_t GetGlitchFilter() const { return (fAltroCFG1 >> 12) & 0x3; }
      79           0 :     UChar_t GetNNonZSPostsamples() const { return (fAltroCFG1 >> 14) & 0x7; }
      80           0 :     UChar_t GetNNonZSPresamples() const  { return (fAltroCFG1 >> 17) & 0x3; }
      81           0 :     Bool_t  GetZeroSupp() const          { return (fAltroCFG1 >> 19) & 0x1; }
      82             :     
      83         148 :     UInt_t   GetAltroCFG2() const { return fAltroCFG2; }
      84           0 :     Bool_t   GetNAltroBuffers() const     { return (fAltroCFG2 >> 24) & 0x1; }
      85           0 :     UChar_t  GetNPretriggerSamples() const{ return (fAltroCFG2 >> 20) & 0xF; }
      86           0 :     UShort_t GetNSamplesPerCh() const     { return (fAltroCFG2 >> 10) & 0x3FF; }
      87           0 :     Bool_t   GetSparseRO() const          { return (fAltroCFG2 >> 9) & 0x1; }
      88             :     Double_t GetTSample() const;
      89             :     Double_t GetL1Phase() const;
      90             :     void     PrintRCUTrailer() const;
      91             :  
      92             :     void SelectRawData(Int_t detId);                           // Select raw data for specific detector id
      93             :     void SelectRawData(const char *detName);                   // Select raw data for specific detector name
      94             : 
      95           0 :     void  SetShortDataHeader(Bool_t flag) { fIsShortDataHeader = flag; } // Specify whenever to assume or not a short CDH format
      96             : 
      97             :     void PrintDebug() const; // Print debug information in case of decoding errors
      98             :     void AddMappingErrorLog(const char *message = NULL);
      99             : 
     100             :     enum EAltroRawStreamError {
     101             :       kRCUTrailerSizeErr = 1,
     102             :       kAltroTrailerErr = 2,
     103             :       kBunchLengthReadErr = 3,
     104             :       kTimeBinReadErr = 4,
     105             :       kAmplitudeReadErr = 5,
     106             :       k32bitWordReadErr = 6,
     107             :       kBadAltroMapping = 7,
     108             :       kRCUTrailerErr = 8
     109             :     };
     110             : 
     111             :     AliAltroRawStream& operator = (const AliAltroRawStream& stream);
     112             :     AliAltroRawStream(const AliAltroRawStream& stream);
     113             : 
     114             :   protected:
     115             : 
     116             :     Bool_t           fIsShortDataHeader; // flag used to select between normal and short CDH format
     117             : 
     118             :   private :
     119             : 
     120             :     UShort_t         GetNextWord();
     121             :     Bool_t           ReadTrailer();
     122             :     void             ReadBunch();
     123             :     void             ReadAmplitude();
     124             :     Int_t            GetPosition();
     125             :     UInt_t           Get32bitWord(Int_t &index);
     126             :     Int_t            ReadRCUTrailer(Int_t &index, Int_t trailerSize);
     127             : 
     128             :     Int_t            fDDLNumber;    // index of current DDL number
     129             :     Int_t            fPrevDDLNumber;// index of previous DDL number
     130             :     Int_t            fRCUId;        // current RCU identifier
     131             :     Int_t            fPrevRCUId;    // previous RCU identifier
     132             :     Short_t          fHWAddress;    // current hardware address
     133             :     Short_t          fPrevHWAddress;// previous hardware address
     134             :     Int_t            fTime;         // index of current time bin
     135             :     Int_t            fPrevTime;     // index of previous time bin
     136             :     Int_t            fSignal;       // signal in ADC counts
     137             :     Int_t            fTimeBunch;    // total length of the current time bunch
     138             : 
     139             :     AliRawReader*    fRawReader;    // object for reading the raw data
     140             : 
     141             : 
     142             :     UChar_t*         fData;         // raw data
     143             : 
     144             :     Int_t            fPosition;     // current (10 bit) position in fData
     145             :     Int_t            fCount;        // counter of words to be read for current trailer
     146             :     Int_t            fChannelPayloadSize;        //
     147             :     Int_t            fBunchLength;  // remaining number of signal bins in the current bunch
     148             : 
     149             :     UChar_t*         fRCUTrailerData; // pointer to RCU trailer data
     150             :     Int_t            fRCUTrailerSize; // size of RCU trailer data in bytes
     151             : 
     152             :     // RCU trailer contents
     153             :     UInt_t           fFECERRA;      // contains errors related to ALTROBUS transactions
     154             :     UInt_t           fFECERRB;      // contains errors related to ALTROBUS transactions
     155             :     UShort_t         fERRREG2;      // contains errors related to ALTROBUS transactions or trailer of ALTRO channel block
     156             :     UShort_t         fERRREG3;      // contains number of altro channels skipped due to an address mismatch 
     157             :     UShort_t         fERRREG4;      // contains number of altro channels skipped due to a block length mismatch 
     158             :     UShort_t         fActiveFECsA;  // bit pattern of active FECs in branch A
     159             :     UShort_t         fActiveFECsB;  // bit pattern of active FECs in branch B
     160             :     UInt_t           fAltroCFG1;    // ALTROCFG1 register
     161             :     UInt_t           fAltroCFG2;    // ALTROCFG2 and ALTROIF registers
     162             : 
     163         440 :     ClassDef(AliAltroRawStream, 0)  // base class for reading Altro raw digits
     164             : };
     165             : 
     166             : #endif

Generated by: LCOV version 1.11