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