]>
Commit | Line | Data |
---|---|---|
f8e5b5a0 | 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 | ||
21 | class AliRawReader; | |
0148e633 | 22 | class AliAltroRawStream; |
f8e5b5a0 | 23 | |
24 | class AliAltroRawStreamV3: public TObject { | |
25 | public : | |
26 | AliAltroRawStreamV3(AliRawReader* rawReader); | |
27 | virtual ~AliAltroRawStreamV3(); | |
28 | ||
29 | AliAltroRawStreamV3& operator = (const AliAltroRawStreamV3& stream); | |
30 | AliAltroRawStreamV3(const AliAltroRawStreamV3& stream); | |
31 | ||
32 | void SelectRawData(Int_t detId); // Select raw data for specific detector id | |
33 | void SelectRawData(const char *detName); // Select raw data for specific detector name | |
34 | ||
35 | virtual void Reset(); // Reset the raw-stream object | |
36 | ||
37 | virtual Bool_t NextDDL(); // Iterate over DDLs/RCUs | |
38 | virtual Bool_t NextChannel(); // Iterate over altro channels | |
39 | virtual Bool_t NextBunch(); // Iterate over altro bunches | |
40 | ||
41 | Int_t GetDDLNumber() const { return fDDLNumber; } // Provide current DDL number | |
42 | Int_t GetHWAddress() const { return fHWAddress; } // Provide current hardware address | |
43 | Int_t GetRCUId() const { return fRCUId; } // Provide current RCU identifier | |
44 | ||
45 | UInt_t GetStartTimeBin() const { return fStartTimeBin; } // Provide the index if the first time-bin in current bunch | |
6d4dd848 | 46 | UInt_t GetEndTimeBin() const { return fStartTimeBin-fBunchLength+1; } // Provide the index of the last time-bin in current bunch |
f8e5b5a0 | 47 | Int_t GetBunchLength() const { return fBunchLength; } // Provide the current bunch length |
6d4dd848 | 48 | const UShort_t* GetSignals() const { return fBunchDataPointer; } // Provide access to altro data itself |
f8e5b5a0 | 49 | Bool_t IsChannelBad() const { return fBadChannel; } // Is the channel data bad or not |
50 | ||
e76a0935 | 51 | Int_t GetChannelPayloadSize() const { return fChannelPayloadSize; } |
eae29211 | 52 | UChar_t *GetRCUPayloadInSOD() const; |
53 | Int_t GetRCUPayloadSizeInSOD() const; | |
f8e5b5a0 | 54 | |
55 | Int_t GetBranch() const; // Provide the branch index for the current hardware address | |
56 | Int_t GetFEC() const; // Provide the front-end card index for the current hardware address | |
57 | Int_t GetAltro() const; // Provide the altro chip index for the current hardware address | |
58 | Int_t GetChannel() const; // Provide the channel index for the current hardware address | |
59 | ||
60 | Bool_t GetRCUTrailerData(UChar_t*& data) const; // Provide a pointer to RCU trailer | |
61 | Int_t GetRCUTrailerSize() const { return fRCUTrailerSize; } // Provide size of RCU trailer | |
62 | ||
63 | // RCU trailer related getters | |
64 | UInt_t GetFECERRA() const { return fFECERRA; } | |
65 | UInt_t GetFECERRB() const { return fFECERRB; } | |
66 | UShort_t GetERRREG2() const { return fERRREG2; } | |
9283f3a5 | 67 | UShort_t GetNChAddrMismatch() const { return (fERRREG3 & 0xFFF); } |
68 | UShort_t GetNChLengthMismatch() const { return ((fERRREG3 >> 12) & 0x1FFF); } | |
f8e5b5a0 | 69 | |
70 | UShort_t GetActiveFECsA() const { return fActiveFECsA; } | |
71 | UShort_t GetActiveFECsB() const { return fActiveFECsB; } | |
72 | ||
73 | UInt_t GetAltroCFG1() const { return fAltroCFG1; } | |
74 | UChar_t GetBaselineCorr() const { return fAltroCFG1 & 0xF; } | |
75 | Bool_t GetPolarity() const { return (fAltroCFG1 >> 4) & 0x1; } | |
76 | UChar_t GetNPresamples() const { return (fAltroCFG1 >> 5) & 0x3; } | |
77 | UChar_t GetNPostsamples() const { return (fAltroCFG1 >> 7) & 0xF; } | |
78 | Bool_t GetSecondBaselineCorr() const { return (fAltroCFG1 >> 11) & 0x1; } | |
79 | UChar_t GetGlitchFilter() const { return (fAltroCFG1 >> 12) & 0x3; } | |
80 | UChar_t GetNNonZSPostsamples() const { return (fAltroCFG1 >> 14) & 0x7; } | |
81 | UChar_t GetNNonZSPresamples() const { return (fAltroCFG1 >> 17) & 0x3; } | |
82 | Bool_t GetZeroSupp() const { return (fAltroCFG1 >> 19) & 0x1; } | |
83 | ||
84 | UInt_t GetAltroCFG2() const { return fAltroCFG2; } | |
85 | Bool_t GetNAltroBuffers() const { return (fAltroCFG2 >> 24) & 0x1; } | |
86 | UChar_t GetNPretriggerSamples() const{ return (fAltroCFG2 >> 20) & 0xF; } | |
87 | UShort_t GetNSamplesPerCh() const { return (fAltroCFG2 >> 10) & 0x3FF; } | |
88 | Bool_t GetSparseRO() const { return (fAltroCFG2 >> 9) & 0x1; } | |
89 | Double_t GetTSample() const; | |
90 | Double_t GetL1Phase() const; | |
91 | void PrintRCUTrailer() const; | |
92 | ||
93 | void SetShortDataHeader(Bool_t flag) { fIsShortDataHeader = flag; } // Specify whenever to assume or not a short CDH format | |
94 | ||
3ce326c0 | 95 | void SetCheckAltroPayload(Bool_t check) { fCheckAltroPayload = check; } |
96 | ||
f8e5b5a0 | 97 | enum EAltroRawStreamV3Error { |
98 | kRCUTrailerErr = 1, | |
99 | kRCUVerErr = 2, | |
100 | kRCUTrailerSizeErr = 3, | |
101 | kAltroBunchHeadErr = 4, | |
102 | kBunchLengthErr = 5, | |
103 | kAltroPayloadErr = 6, | |
104 | kBadAltroMapping = 7 | |
105 | }; | |
106 | ||
107 | enum {kMaxNTimeBins = 1024}; | |
108 | ||
109 | protected: | |
110 | ||
111 | void AddMappingErrorLog(const char *message = NULL); | |
112 | ||
113 | Bool_t fIsShortDataHeader; // flag used to select between normal and short CDH format | |
114 | ||
115 | private: | |
116 | ||
117 | UInt_t Get32bitWord(Int_t index) const; | |
118 | Bool_t ReadRCUTrailer(UChar_t rcuVer); | |
119 | ||
120 | Int_t fDDLNumber; // index of current DDL number | |
121 | Int_t fRCUId; // current RCU identifier | |
122 | Short_t fHWAddress; // current hardware address | |
123 | ||
124 | AliRawReader* fRawReader; // object for reading the raw data | |
125 | ||
126 | UChar_t* fData; // raw data | |
127 | ||
128 | Int_t fPosition; // current position (32-bit words) in fData | |
129 | Int_t fCount; // | |
130 | Int_t fStartTimeBin; // | |
131 | Int_t fBunchLength; // | |
132 | ||
133 | Bool_t fBadChannel; // | |
134 | Int_t fPayloadSize; // | |
135 | ||
e76a0935 | 136 | Int_t fChannelPayloadSize; // |
137 | ||
6d4dd848 | 138 | UShort_t fBunchData[kMaxNTimeBins]; // cache for the decoded altro payload |
139 | UShort_t* fBunchDataPointer; // pointer to the current bunch samples | |
140 | Int_t fBunchDataIndex; // current position in the payload | |
f8e5b5a0 | 141 | |
142 | UChar_t* fRCUTrailerData; // pointer to RCU trailer data | |
143 | Int_t fRCUTrailerSize; // size of RCU trailer data in bytes | |
144 | ||
145 | // RCU trailer contents | |
146 | UInt_t fFECERRA; // contains errors related to ALTROBUS transactions | |
147 | UInt_t fFECERRB; // contains errors related to ALTROBUS transactions | |
148 | UShort_t fERRREG2; // contains errors related to ALTROBUS transactions or trailer of ALTRO channel block | |
9283f3a5 | 149 | UInt_t fERRREG3; // contains number of altro channels skipped due to an address mismatch |
f8e5b5a0 | 150 | UShort_t fActiveFECsA; // bit pattern of active FECs in branch A |
151 | UShort_t fActiveFECsB; // bit pattern of active FECs in branch B | |
152 | UInt_t fAltroCFG1; // ALTROCFG1 register | |
153 | UInt_t fAltroCFG2; // ALTROCFG2 and ALTROIF registers | |
154 | ||
0148e633 | 155 | AliAltroRawStream* fOldStream; // streamer for old altro format |
156 | ||
3ce326c0 | 157 | Bool_t fCheckAltroPayload; // check altro payload correctness or not? |
158 | ||
f8e5b5a0 | 159 | ClassDef(AliAltroRawStreamV3, 0) // base class for reading Altro raw digits |
160 | }; | |
161 | ||
162 | #endif |