Revised TRD geometry with corrected positions of support rails and more detailed...
[u/mrichter/AliRoot.git] / RAW / AliAltroRawStreamV3.h
... / ...
CommitLineData
1#ifndef ALIALTRORAWSTREAMV3_H
2#define ALIALTRORAWSTREAMV3_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6///////////////////////////////////////////////////////////////////////////////
7///
8/// This is a base class for reading raw data digits in Altro format.
9/// The class is able to read the RCU v3 and above formats.
10/// The main difference between the format V3 and older ones is in
11/// the coding of the 10-bit Altro payload words. In V3 3 10-bit words
12/// are coded in one 32-bit word. The bits 30 and 31 are used to identify
13/// the payload, altro header and RCU trailer contents.
14///
15///
16/// cvetan.cheshkov@cern.ch 1/04/2009
17///////////////////////////////////////////////////////////////////////////////
18
19#include <TObject.h>
20
21class AliRawReader;
22
23class AliAltroRawStreamV3: public TObject {
24 public :
25 AliAltroRawStreamV3(AliRawReader* rawReader);
26 virtual ~AliAltroRawStreamV3();
27
28 AliAltroRawStreamV3& operator = (const AliAltroRawStreamV3& stream);
29 AliAltroRawStreamV3(const AliAltroRawStreamV3& stream);
30
31 void SelectRawData(Int_t detId); // Select raw data for specific detector id
32 void SelectRawData(const char *detName); // Select raw data for specific detector name
33
34 virtual void Reset(); // Reset the raw-stream object
35
36 virtual Bool_t NextDDL(); // Iterate over DDLs/RCUs
37 virtual Bool_t NextChannel(); // Iterate over altro channels
38 virtual Bool_t NextBunch(); // Iterate over altro bunches
39
40 Int_t GetDDLNumber() const { return fDDLNumber; } // Provide current DDL number
41 Int_t GetHWAddress() const { return fHWAddress; } // Provide current hardware address
42 Int_t GetRCUId() const { return fRCUId; } // Provide current RCU identifier
43
44 UInt_t GetStartTimeBin() const { return fStartTimeBin; } // Provide the index if the first time-bin in current bunch
45 UInt_t GetEndTimeBin() const { return fStartTimeBin-fBunchLength+1; } // Provide the index of the last time-bin in current bunch
46 Int_t GetBunchLength() const { return fBunchLength; } // Provide the current bunch length
47 const UShort_t* GetSignals() const { return fBunchDataPointer; } // Provide access to altro data itself
48 Bool_t IsChannelBad() const { return fBadChannel; } // Is the channel data bad or not
49
50
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
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
58
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; }
63 UShort_t GetNChAddrMismatch() const { return fERRREG3; }
64 UShort_t GetNChLengthMismatch() const { return fERRREG4; }
65
66 UShort_t GetActiveFECsA() const { return fActiveFECsA; }
67 UShort_t GetActiveFECsB() const { return fActiveFECsB; }
68
69 UInt_t GetAltroCFG1() const { return fAltroCFG1; }
70 UChar_t GetBaselineCorr() const { return fAltroCFG1 & 0xF; }
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; }
79
80 UInt_t GetAltroCFG2() const { return fAltroCFG2; }
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; }
85 Double_t GetTSample() const;
86 Double_t GetL1Phase() const;
87 void PrintRCUTrailer() const;
88
89 void SetShortDataHeader(Bool_t flag) { fIsShortDataHeader = flag; } // Specify whenever to assume or not a short CDH format
90
91 enum EAltroRawStreamV3Error {
92 kRCUTrailerErr = 1,
93 kRCUVerErr = 2,
94 kRCUTrailerSizeErr = 3,
95 kAltroBunchHeadErr = 4,
96 kBunchLengthErr = 5,
97 kAltroPayloadErr = 6,
98 kBadAltroMapping = 7
99 };
100
101 enum {kMaxNTimeBins = 1024};
102
103 protected:
104
105 void AddMappingErrorLog(const char *message = NULL);
106
107 Bool_t fIsShortDataHeader; // flag used to select between normal and short CDH format
108
109 private:
110
111 UInt_t Get32bitWord(Int_t index) const;
112 Bool_t ReadRCUTrailer(UChar_t rcuVer);
113
114 Int_t fDDLNumber; // index of current DDL number
115 Int_t fRCUId; // current RCU identifier
116 Short_t fHWAddress; // current hardware address
117
118 AliRawReader* fRawReader; // object for reading the raw data
119
120 UChar_t* fData; // raw data
121
122 Int_t fPosition; // current position (32-bit words) in fData
123 Int_t fCount; //
124 Int_t fStartTimeBin; //
125 Int_t fBunchLength; //
126
127 Bool_t fBadChannel; //
128 Int_t fPayloadSize; //
129
130 UShort_t fBunchData[kMaxNTimeBins]; // cache for the decoded altro payload
131 UShort_t* fBunchDataPointer; // pointer to the current bunch samples
132 Int_t fBunchDataIndex; // current position in the payload
133
134 UChar_t* fRCUTrailerData; // pointer to RCU trailer data
135 Int_t fRCUTrailerSize; // size of RCU trailer data in bytes
136
137 // RCU trailer contents
138 UInt_t fFECERRA; // contains errors related to ALTROBUS transactions
139 UInt_t fFECERRB; // contains errors related to ALTROBUS transactions
140 UShort_t fERRREG2; // contains errors related to ALTROBUS transactions or trailer of ALTRO channel block
141 UShort_t fERRREG3; // contains number of altro channels skipped due to an address mismatch
142 UShort_t fERRREG4; // contains number of altro channels skipped due to a block length mismatch
143 UShort_t fActiveFECsA; // bit pattern of active FECs in branch A
144 UShort_t fActiveFECsB; // bit pattern of active FECs in branch B
145 UInt_t fAltroCFG1; // ALTROCFG1 register
146 UInt_t fAltroCFG2; // ALTROCFG2 and ALTROIF registers
147
148 ClassDef(AliAltroRawStreamV3, 0) // base class for reading Altro raw digits
149};
150
151#endif