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