ROOT logo
/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/////////////////////////////////////////////////////
// Class used for read-write the ALTRO data format //
/////////////////////////////////////////////////////

/*This class is an interface between the altro format file and the 
  user, and can be used in write or read mode
  In the write mode a new altro file is created and filled using the method FillBuffer().
  The name of the file is specified as parameter in the constructor as well as the type mode.
  In the Read mode the specified file is open and the values can be read using the
  methods GetNext() and GetNextBackWord().
  The first method is used to read the file forward while the second is used to read backward 
*/

#ifndef AliALTROBUFFERV3_H
#define AliALTROBUFFERV3_H

#include "AliAltroBuffer.h"

class AliAltroBufferV3: public AliAltroBuffer {
 public:
  AliAltroBufferV3(const char* fileName, AliAltroMapping *mapping = NULL);
  virtual ~AliAltroBufferV3();

  virtual void  FillBuffer(Int_t val);
  //this method stores a word into the buffer

  virtual void  WriteTrailer(Int_t wordsNumber, Short_t hwAddress); 
  //this method is used to write the trailer

  virtual UChar_t WriteRCUTrailer(Int_t rcuId);
  //this method is used to write the RCU trailer

  void  SetFECERRA(UInt_t v) { fFECERRA = v; }
  void  SetFECERRB(UInt_t v) { fFECERRB = v; }
  void  SetERRREG2(UInt_t v) { fERRREG2 = v; }
  void  SetERRREG3(UInt_t v) { fERRREG3 = v; }
  void  SetActiveFECsA(UShort_t m) { fActiveFECsA = m; }
  void  SetActiveFECsB(UShort_t m) { fActiveFECsB = m; }
  void  SetALTROCFG1(UInt_t cfg1) { fALTROCFG1 = cfg1; }
  void  SetALTROCFG2(UInt_t cfg2) { fALTROCFG2 = cfg2; }
  void  SetTSample(Double_t v) { fTSample = v; }
  void  SetL1Phase(Double_t v) { fL1Phase = v; }

  void SetNChAddrMismatch(UShort_t v) { SetField(fERRREG3, 0, 0xFFF, v); }
  void SetNChLengthMismatch(UShort_t v) { SetField(fERRREG3, 12, 0x1FFF, v); }
  
  void SetBaselineCorr(UChar_t v) { SetField(fALTROCFG1, 0, 0xF, v); }
  void SetPolarity(Bool_t v) { SetField(fALTROCFG1, 4, 0x1, v); }
  void SetNPresamples(UChar_t v) { SetField(fALTROCFG1, 5, 0x3, v); }
  void SetNPostsamples(UChar_t v) { SetField(fALTROCFG1, 7, 0xF, v); }
  void SetSecondBaselineCorr(Bool_t v) { SetField(fALTROCFG1, 11, 0x1, v); }
  void SetGlitchFilter(UChar_t v) { SetField(fALTROCFG1, 12, 0x3, v); }
  void SetNNonZSPostsamples(UChar_t v) { SetField(fALTROCFG1, 14, 0x7, v); }
  void SetNNonZSPresamples(UChar_t v) { SetField(fALTROCFG1, 17, 0x3, v); }
  void SetZeroSupp(Bool_t v) { SetField(fALTROCFG1, 19, 0x1, v); }
  void SetNAltroBuffers(Bool_t v) { SetField(fALTROCFG2, 24, 0x1, v); }
  void SetNPretriggerSamples(UChar_t  v) { SetField(fALTROCFG2, 20, 0xF, v); }
  void SetNSamplesPerCh(UShort_t v) { SetField(fALTROCFG2, 10, 0x3FF, v); }
  void SetSparseRO(Bool_t v) { SetField(fALTROCFG2, 9, 0x1, v); }


  enum { kMaxWords = 1024 };

 protected:
  UInt_t        SetField(UInt_t& input, UShort_t start, UInt_t mask, UInt_t val) const;
  void          ReverseAndWrite();
  //this method reverse the altro data order and write the buffer to the file

  AliAltroBufferV3(const AliAltroBufferV3& source);
  AliAltroBufferV3& operator = (const AliAltroBufferV3& source);

  UShort_t fArray[kMaxWords]; // Temporary array needed in reverting data order
  Int_t    fN;                // Size of the temporary array
  UInt_t   fFECERRA;	// FECERRA
  UInt_t   fFECERRB;	// FECERRB
  UInt_t   fERRREG2;	// ERRREG2
  UInt_t   fERRREG3;	// ERRREG3
  UShort_t fActiveFECsA;// ActiveFECsA
  UShort_t fActiveFECsB;// ActiveFECsB
  UInt_t   fALTROCFG1;	// ALTROCFG1
  UInt_t   fALTROCFG2;	// ALTROCFG2
  Double_t fTSample;	// TSample
  Double_t fL1Phase;	// L1Phase

  ClassDef(AliAltroBufferV3,0)  // Interface to the Altro format
};

#endif
 AliAltroBufferV3.h:1
 AliAltroBufferV3.h:2
 AliAltroBufferV3.h:3
 AliAltroBufferV3.h:4
 AliAltroBufferV3.h:5
 AliAltroBufferV3.h:6
 AliAltroBufferV3.h:7
 AliAltroBufferV3.h:8
 AliAltroBufferV3.h:9
 AliAltroBufferV3.h:10
 AliAltroBufferV3.h:11
 AliAltroBufferV3.h:12
 AliAltroBufferV3.h:13
 AliAltroBufferV3.h:14
 AliAltroBufferV3.h:15
 AliAltroBufferV3.h:16
 AliAltroBufferV3.h:17
 AliAltroBufferV3.h:18
 AliAltroBufferV3.h:19
 AliAltroBufferV3.h:20
 AliAltroBufferV3.h:21
 AliAltroBufferV3.h:22
 AliAltroBufferV3.h:23
 AliAltroBufferV3.h:24
 AliAltroBufferV3.h:25
 AliAltroBufferV3.h:26
 AliAltroBufferV3.h:27
 AliAltroBufferV3.h:28
 AliAltroBufferV3.h:29
 AliAltroBufferV3.h:30
 AliAltroBufferV3.h:31
 AliAltroBufferV3.h:32
 AliAltroBufferV3.h:33
 AliAltroBufferV3.h:34
 AliAltroBufferV3.h:35
 AliAltroBufferV3.h:36
 AliAltroBufferV3.h:37
 AliAltroBufferV3.h:38
 AliAltroBufferV3.h:39
 AliAltroBufferV3.h:40
 AliAltroBufferV3.h:41
 AliAltroBufferV3.h:42
 AliAltroBufferV3.h:43
 AliAltroBufferV3.h:44
 AliAltroBufferV3.h:45
 AliAltroBufferV3.h:46
 AliAltroBufferV3.h:47
 AliAltroBufferV3.h:48
 AliAltroBufferV3.h:49
 AliAltroBufferV3.h:50
 AliAltroBufferV3.h:51
 AliAltroBufferV3.h:52
 AliAltroBufferV3.h:53
 AliAltroBufferV3.h:54
 AliAltroBufferV3.h:55
 AliAltroBufferV3.h:56
 AliAltroBufferV3.h:57
 AliAltroBufferV3.h:58
 AliAltroBufferV3.h:59
 AliAltroBufferV3.h:60
 AliAltroBufferV3.h:61
 AliAltroBufferV3.h:62
 AliAltroBufferV3.h:63
 AliAltroBufferV3.h:64
 AliAltroBufferV3.h:65
 AliAltroBufferV3.h:66
 AliAltroBufferV3.h:67
 AliAltroBufferV3.h:68
 AliAltroBufferV3.h:69
 AliAltroBufferV3.h:70
 AliAltroBufferV3.h:71
 AliAltroBufferV3.h:72
 AliAltroBufferV3.h:73
 AliAltroBufferV3.h:74
 AliAltroBufferV3.h:75
 AliAltroBufferV3.h:76
 AliAltroBufferV3.h:77
 AliAltroBufferV3.h:78
 AliAltroBufferV3.h:79
 AliAltroBufferV3.h:80
 AliAltroBufferV3.h:81
 AliAltroBufferV3.h:82
 AliAltroBufferV3.h:83
 AliAltroBufferV3.h:84
 AliAltroBufferV3.h:85
 AliAltroBufferV3.h:86
 AliAltroBufferV3.h:87
 AliAltroBufferV3.h:88
 AliAltroBufferV3.h:89
 AliAltroBufferV3.h:90
 AliAltroBufferV3.h:91