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 */
8 ///////////////////////////////////////////////////////////////////////////////
10 /// This is a base class for reading raw data digits in Altro format
11 /// The class is able to read both old and new RCU trailer formats
12 /// Switch between formats is done automatically using the last payload word.
13 /// In case the Common Data Header is 7 32-bit words long, one
14 /// can use the fIsShortDataHeader flag.
16 ///////////////////////////////////////////////////////////////////////////////
22 class AliAltroRawStream: public TObject {
24 AliAltroRawStream(AliRawReader* rawReader);
25 virtual ~AliAltroRawStream();
28 virtual Bool_t Next();
30 Int_t GetDDLNumber() const { return fDDLNumber; } // Provide current DDL number
31 Int_t GetPrevDDLNumber() const { return fPrevDDLNumber; }// Provide previous DDL number
32 Bool_t IsNewDDLNumber() const {return (fDDLNumber != fPrevDDLNumber);};
33 Int_t GetRCUId() const { return fRCUId; } // Provide current RCU identifier
34 Int_t GetPrevRCUId() const { return fPrevRCUId; } // Provide previous RCU identifier
35 Bool_t IsNewRCUId() const {return (fRCUId != fPrevRCUId);};
36 Int_t GetHWAddress() const { return fHWAddress; } // Provide current hardware address
37 Int_t GetPrevHWAddress() const { return fPrevHWAddress; } // Provide previous hardware address
38 Bool_t IsNewHWAddress() const {return (fHWAddress != fPrevHWAddress) || IsNewDDLNumber();};
39 Int_t GetTime() const { return fTime; } // Provide index of current time bin
40 Int_t GetPrevTime() const { return fPrevTime; } // Provide index of previous time bin
41 Bool_t IsNewTime() const {return (fTime != fPrevTime) || IsNewHWAddress();};
42 Int_t GetSignal() const { return fSignal; } // Provide signal in ADC counts
43 Int_t GetTimeLength() const { return fTimeBunch; } // Provide total length of current time bunch
45 Int_t GetBranch() const; // Provide the branch index for the current hardware address
46 Int_t GetFEC() const; // Provide the front-end card index for the current hardware address
47 Int_t GetAltro() const; // Provide the altro chip index for the current hardware address
48 Int_t GetChannel() const; // Provide the channel index for the current hardware address
50 Bool_t GetRCUTrailerData(UChar_t*& data) const; // Provide a pointer to RCU trailer
51 Int_t GetRCUTrailerSize() const { return fRCUTrailerSize; } // Provide size of RCU trailer
53 // RCU trailer related getters
54 UInt_t GetFECERRA() const { return fFECERRA; }
55 UInt_t GetFECERRB() const { return fFECERRB; }
56 UShort_t GetERRREG2() const { return fERRREG2; }
57 UShort_t GetNChAddrMismatch() const { return fERRREG3; }
58 UShort_t GetNChLengthMismatch() const { return fERRREG4; }
60 UShort_t GetActiveFECsA() const { return fActiveFECsA; }
61 UShort_t GetActiveFECsB() const { return fActiveFECsB; }
63 UInt_t GetAltroCFG1() const { return fAltroCFG1; }
64 UChar_t GetBaselineCorr() const { return fAltroCFG1 & 0xF; }
65 Bool_t GetPolarity() const { return (fAltroCFG1 >> 4) & 0x1; }
66 UChar_t GetNPresamples() const { return (fAltroCFG1 >> 5) & 0x3; }
67 UChar_t GetNPostsamples() const { return (fAltroCFG1 >> 7) & 0xF; }
68 Bool_t GetSecondBaselineCorr() const { return (fAltroCFG1 >> 11) & 0x1; }
69 UChar_t GetGlitchFilter() const { return (fAltroCFG1 >> 12) & 0x3; }
70 UChar_t GetNNonZSPostsamples() const { return (fAltroCFG1 >> 14) & 0x7; }
71 UChar_t GetNNonZSPresamples() const { return (fAltroCFG1 >> 17) & 0x3; }
72 Bool_t GetZeroSupp() const { return (fAltroCFG1 >> 19) & 0x1; }
74 UInt_t GetAltroCFG2() const { return fAltroCFG2; }
75 Bool_t GetNAltroBuffers() const { return (fAltroCFG2 >> 24) & 0x1; }
76 UChar_t GetNPretriggerSamples() const{ return (fAltroCFG2 >> 20) & 0xF; }
77 UShort_t GetNSamplesPerCh() const { return (fAltroCFG2 >> 10) & 0x3FF; }
78 Bool_t GetSparseRO() const { return (fAltroCFG2 >> 9) & 0x1; }
79 Double_t GetTSample() const;
80 Double_t GetL1Phase() const;
81 void PrintRCUTrailer() const;
83 void SelectRawData(Int_t detId); // Select raw data for specific detector id
84 void SelectRawData(const char *detName); // Select raw data for specific detector name
86 void SetNoAltroMapping(Bool_t flag) { fNoAltroMapping = flag; } // Specify whenever to use or not the altro mapping
87 void SetShortDataHeader(Bool_t flag) { fIsShortDataHeader = flag; } // Specify whenever to assume or not a short CDH format
89 void PrintDebug() const; // Print debug information in case of decoding errors
90 void AddMappingErrorLog(const char *message = NULL);
92 enum EAltroRawStreamError {
93 kRCUTrailerSizeErr = 1,
95 kBunchLengthReadErr = 3,
97 kAmplitudeReadErr = 5,
98 k32bitWordReadErr = 6,
103 AliAltroRawStream& operator = (const AliAltroRawStream& stream);
104 AliAltroRawStream(const AliAltroRawStream& stream);
108 Bool_t fNoAltroMapping; // temporary flag in case of no altro mapping is provided
109 Short_t fSegmentation[3]; // temporary container for the dummy trailer, to be removed
111 Bool_t fIsShortDataHeader; // flag used to select between normal and short CDH format
115 UShort_t GetNextWord();
116 Bool_t ReadTrailer();
117 Bool_t ReadDummyTrailer();
119 void ReadAmplitude();
121 UInt_t Get32bitWord(Int_t &index);
122 Int_t ReadRCUTrailer(Int_t &index, Int_t trailerSize);
124 Int_t fDDLNumber; // index of current DDL number
125 Int_t fPrevDDLNumber;// index of previous DDL number
126 Int_t fRCUId; // current RCU identifier
127 Int_t fPrevRCUId; // previous RCU identifier
128 Short_t fHWAddress; // current hardware address
129 Short_t fPrevHWAddress;// previous hardware address
130 Int_t fTime; // index of current time bin
131 Int_t fPrevTime; // index of previous time bin
132 Int_t fSignal; // signal in ADC counts
133 Int_t fTimeBunch; // total length of the current time bunch
135 AliRawReader* fRawReader; // object for reading the raw data
138 UChar_t* fData; // raw data
140 Int_t fPosition; // current (10 bit) position in fData
141 Int_t fCount; // counter of words to be read for current trailer
142 Int_t fBunchLength; // remaining number of signal bins in the current bunch
144 UChar_t* fRCUTrailerData; // pointer to RCU trailer data
145 Int_t fRCUTrailerSize; // size of RCU trailer data in bytes
147 // RCU trailer contents
148 UInt_t fFECERRA; // contains errors related to ALTROBUS transactions
149 UInt_t fFECERRB; // contains errors related to ALTROBUS transactions
150 UShort_t fERRREG2; // contains errors related to ALTROBUS transactions or trailer of ALTRO channel block
151 UShort_t fERRREG3; // contains number of altro channels skipped due to an address mismatch
152 UShort_t fERRREG4; // contains number of altro channels skipped due to a block length mismatch
153 UShort_t fActiveFECsA; // bit pattern of active FECs in branch A
154 UShort_t fActiveFECsB; // bit pattern of active FECs in branch B
155 UInt_t fAltroCFG1; // ALTROCFG1 register
156 UInt_t fAltroCFG2; // ALTROCFG2 and ALTROIF registers
158 ClassDef(AliAltroRawStream, 0) // base class for reading Altro raw digits