...also histos are now correctly booked
[u/mrichter/AliRoot.git] / ZDC / AliZDCRawStream.h
CommitLineData
8309c1ab 1#ifndef ALIZDCRAWSTREAM_H
2#define ALIZDCRAWSTREAM_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
1ee299a5 8//////////////////////////////////////////////////
9// //
10// Class to provide access to ZDC raw data //
11// Author: Chiara Oppedisano //
12// //
13//////////////////////////////////////////////////
8309c1ab 14
15#include <TObject.h>
fee50699 16#include "AliCDBManager.h"
17#include "AliCDBStorage.h"
18#include "AliZDCChMap.h"
8309c1ab 19
20class AliRawReader;
1ee299a5 21class AliRawDataHeader;
8309c1ab 22
23
24class AliZDCRawStream: public TObject {
25 public :
27afc0c8 26
27 // Module type codes
8c76923f 28 enum ZDCModules{kV965=1, kV830=2, kTRG=3, kTRGI=4, kPU=5, KV1290=6, kV775N=7};
29
30 // Module type codes
31 enum ZDCGeoAddr{kFirstADCGeo=0, kLastADCGeo=3, kADDADCGeo=5,
32 kTDCFakeGeo=8, kZDCTDCGeo=4, kADDTDCGeo=6,
33 kScalerGeo=16, kPUGeo=29, kTrigScales=30, kTrigHistory=31};
27afc0c8 34
35 // Signal codes for ZDC
36 // Same codes used in DAQ configuration file
37 // To be changed ONLY IF this file is changed!!!
38 // **** DO NOT CHANGE THE FOLLOWING LINES!!! ****
198f612a 39 enum ZDCSignal{
40 kNotConnected=0, kVoid=1,
27afc0c8 41 kZNAC=2, kZNA1=3, kZNA2=4, kZNA3=5, kZNA4=6,
42 kZPAC=7, kZPA1=8, kZPA2=9, kZPA3=10, kZPA4=11,
43 kZNCC=12, kZNC1=13, kZNC2=14, kZNC3=15, kZNC4=16,
44 kZPCC=17, kZPC1=18, kZPC2=19, kZPC3=20, kZPC4=21,
45 kZEM1=22, kZEM2=23,
46 kZDCAMon=24, kZDCCMon=25,
47 kZNACoot=26, kZNA1oot=27, kZNA2oot=28, kZNA3oot=29, kZNA4oot=30,
48 kZPACoot=31, kZPA1oot=32, kZPA2oot=33, kZPA3oot=34, kZPA4oot=35,
49 kZNCCoot=36, kZNC1oot=37, kZNC2oot=38, kZNC3oot=39, kZNC4oot=40,
50 kZPCCoot=41, kZPC1oot=42, kZPC2oot=43, kZPC3oot=44, kZPC4oot=45,
51 kZEM1oot=46, kZEM2oot=47,
52 kZDCAMonoot=48, kZDCCMonoot=49,
53 kL1MBI=50, kL1CNI=51, kL1SCI=52, kL1EMDI=53, kL0I=54,
54 kL1MBO=55, kL1CNO=56, kL1SCO=57, kL1EMDO=58,
55 kHMBCN=59, kHSCEMD=60,
8c76923f 56 kZNACD=61, kZNA1D=62, kZNA2D=63, kZNA3D=64, kZNA4D=65,
57 kZPACD=66, kZPA1D=67, kZPA2D=68, kZPA3D=69, kZPA4D=70,
58 kZNCCD=71, kZNC1D=72, kZNC2D=73, kZNC3D=74, kZNC4D=75,
59 kZPCCD=76, kZPC1D=77, kZPC2D=78, kZPC3D=79, kZPC4D=80,
27afc0c8 60 kZEM1D=81, kZEM2D=82,
61 kZDCAMonD=83, kZDCCMonD=84,
910216a3 62 kZNAD=85, kZPAD=86, kZNCD=87, kZPCD=88, kZEMD=89,
198f612a 63 kZNA0D=90, kZPA0D=91, kZNC0D=92, kZPC0D=93, k1kHzD=94, kGate=95, kAD=96, kCD=97,
64 kAorCD=98, kAandCD=99, kZEMORD=100, kAorCorZEMORD=101, kAorCorZEMD=102, kAD0=103, kAD1=104, kAD2=105,
65 kAD3=106, kAD4=107, kAD5=108, kAD6=109, kAD7=110, kAD8=111, kAD9=112, kAD10=113,
66 kAD11=114, kAD12=115, kAD13=116, kAD14=117, kAD15=118, kAD0D=119, kAD1D=120, kAD2D=121,
67 kAD3D=122, kAD4D=123, kAD5D=124, kAD6D=125, kAD7D=126, kAD8D=127, kAD9D=128, kAD10D=129,
68 kAD11D=130, kAD12D=131, kAD13D=132, kAD14D=133, kAD15D=134
69 };
27afc0c8 70
71 // Error codes in raw data streaming
72 enum EZDCRawStreamError{
73 kCDHError = 1,
74 kDARCError = 2,
75 kZDCDataError = 3,
76 kInvalidADCModule = 4,
77 kInvalidSector = 5};
78
cc2abffd 79 AliZDCRawStream(AliRawReader* rawReader);
8309c1ab 80 virtual ~AliZDCRawStream();
8309c1ab 81 virtual Bool_t Next();
c93c022b 82
83 virtual void ReadChMap();
8309c1ab 84
1ee299a5 85 virtual void ReadCDHHeader();
198f612a 86
44455047 87 UInt_t GetRawBuffer() const {return fBuffer;}
88 Int_t GetReadOutCard() const {return fReadOutCard;}
1ee299a5 89
c93c022b 90 Int_t GetDeadfaceOffset() const {return fDeadfaceOffset;}
91 Int_t GetDeadbeefOffset() const {return fDeadbeefOffset;}
92 Int_t GetDataOffset() const {return fDataOffset;}
93
94 Int_t GetSector(Int_t i) const {return fSector[i];}
95 Int_t GetModType() const {return fModType;}
96 Int_t GetADCModule() const {return fADCModule;}
97 Int_t GetADCNChannels() const {return fADCNChannels;}
98 Int_t GetADCChannel() const {return fADCChannel;}
99 Int_t GetADCValue() const {return fADCValue;}
100 Int_t GetADCGain() const {return fADCGain;}
8c76923f 101
102 Int_t GetModuleGEO() const {return fADCModule;}
103 Int_t GetChannel() const {return fADCChannel;}
104
105 Bool_t IsZDCTDCHeader() const {return fIsZDCTDCHeader;}
106 Bool_t IsZDCTDCDatum() const {return fIsZDCTDCdatum;}
107 Int_t GetZDCTDCDatum() const {return fZDCTDCdatum;}
108
109 Bool_t IsADDADCChannel() const {return fIsADDChannel;}
110 Int_t GetADDADCDatum() const {return fADDADCdatum;}
111 Bool_t IsADDTDCdatum() const {return fIsADDTDCdatum;}
112 Int_t GetADDTDCDatum() const {return fADDTDCdatum;}
fee50699 113
fee50699 114 AliCDBStorage *SetStorage(const char* uri);
c3986754 115
116 // Map from OCDB
fee50699 117 AliZDCChMap *GetChMap() const;
c3986754 118 // ADC map
9d0b658a 119 Int_t GetNChannelsOn() const {return fNChannelsOn;}
fee50699 120 Int_t GetCabledSignal() const {return fCabledSignal;}
c93c022b 121 Int_t GetADCModFromMap(Int_t i) const {return fMapADC[i][0];}
122 Int_t GetADCChFromMap(Int_t i) const {return fMapADC[i][1];}
123 Int_t GetADCSignFromMap(Int_t i) const {return fMapADC[i][2];}
124 Int_t GetDetectorFromMap(Int_t i) const {return fMapADC[i][3];}
125 Int_t GetTowerFromMap(Int_t i) const {return fMapADC[i][4];}
c3986754 126 // Scaler map
127 Int_t GetScalerModFromMap(Int_t i) const {return fScalerMap[i][0];}
128 Int_t GetScalerChFromMap(Int_t i) const {return fScalerMap[i][1];}
129 Int_t GetScalerSignFromMap(Int_t i) const {return fScalerMap[i][2];}
130 Int_t GetScDetectorFromMap(Int_t i) const {return fScalerMap[i][3];}
131 Int_t GetScTowerFromMap(Int_t i) const {return fScalerMap[i][4];}
82dffa48 132 // TDC map
133 Int_t GetTDCModFromMap(Int_t i) const {return fTDCMap[i][0];}
134 Int_t GetTDCChFromMap(Int_t i) const {return fTDCMap[i][1];}
135 Int_t GetTDCSignFromMap(Int_t i) const {return fTDCMap[i][2];}
c3986754 136
137 Bool_t IsCalibration() const {return fIsCalib;}
138 Bool_t IsDARCHeader() const {return fIsDARCHeader;}
139 Bool_t IsHeaderMapping() const {return fIsHeaderMapping;}
140 Bool_t IsChMapping() const {return fIsChMapping;}
141 Bool_t IsADCDataWord() const {return fIsADCDataWord;}
142 Bool_t IsADCHeader() const {return fIsADCHeader;}
143 Bool_t IsADCEOB() const {return fIsADCEOB;}
144 Bool_t IsUnderflow() const {return fIsUnderflow;}
145 Bool_t IsOverflow() const {return fIsOverflow;}
e42bdf10 146
da090841 147 UInt_t GetScGeo() const {return fScGeo;}
148 UInt_t GetScNWords() const {return fScNWords;}
c083685e 149 UInt_t GetScTriggerSource() const {return fScTriggerSource;}
da090841 150 UInt_t GetTriggerNumber() const {return fScTriggerNumber;}
151 UInt_t GetTriggerCount() const {return fScEvCounter;}
f70a5526 152 Bool_t IsScHeaderRead() const {return fIsScHeaderRead;}
81f09162 153 Bool_t IsScEventGood() const {return fIsScEventGood;}
ad3a602e 154 Bool_t IsScalerWord() const {return fIsScalerWord;}
da090841 155
156 UInt_t GetDetectorPattern() const {return fDetPattern;}
157
81f09162 158 Bool_t IstriggerHistoryWord() const {return fIsTriggerHistory;}
da090841 159 Int_t GetTriggerInput2CTP() const {return *fCPTInput;}
160 Bool_t IsCPTInputMBTrigger()
161 {if(fCPTInput[0]==1) return kTRUE; else return kFALSE;}
162 Bool_t IsCPTInputCentralTrigger()
163 {if(fCPTInput[1]==1) return kTRUE; else return kFALSE;}
164 Bool_t IsCPTInputSemiCentralTrigger()
165 {if(fCPTInput[2]==1) return kTRUE; else return kFALSE;}
166 Bool_t IsCPTInputEMDTrigger()
167 {if(fCPTInput[3]==1) return kTRUE; else return kFALSE;}
168
f70a5526 169 Bool_t IsADCEventGood() const {return fIsADCEventGood;}
170 Bool_t IsL0BitSet() const {return fIsL0BitSet;}
171 Bool_t IsPileUpEvent() const {return fIsPileUpEvent;}
9d0b658a 172
a27ef05f 173 void SetReadOutCard(Int_t icard) {fReadOutCard=icard;}
174 void SetDataOffset(Int_t iOffset) {fDataOffset=iOffset;}
9d0b658a 175 void SetNChannelsOn(Int_t val) {fNChannelsOn = val;}
1ee299a5 176 void SetSector(Int_t i, Int_t val) {fSector[i] = val;}
a27ef05f 177 void SetMapRead(Bool_t value) {fIsMapRead=value;}
1ee299a5 178 void SetMapADCMod(Int_t iraw, Int_t imod) {fMapADC[iraw][0]=imod;}
fee50699 179 void SetMapADCCh(Int_t iraw, Int_t ich) {fMapADC[iraw][1]=ich;}
1ee299a5 180 void SetMapADCSig(Int_t iraw, Int_t isig) {fMapADC[iraw][2]=isig;}
fee50699 181 void SetMapDet(Int_t iraw, Int_t idet) {fMapADC[iraw][3]=idet;}
182 void SetMapTow(Int_t iraw, Int_t itow) {fMapADC[iraw][4]=itow;}
a27ef05f 183 void SetReadCDH(Bool_t value) {fReadCDH=value;}
fee50699 184 void SetSODReading(Bool_t iset) {fSODReading = iset;}
27afc0c8 185
8309c1ab 186 private :
187 AliZDCRawStream(const AliZDCRawStream& stream);
188 AliZDCRawStream& operator = (const AliZDCRawStream& stream);
189
1ee299a5 190 AliRawReader* fRawReader; // object for reading the raw data
f9f99efb 191
192 // Data for buffer decoding
44455047 193 UInt_t fBuffer; // [DARC header +] ADC buffer
194 Int_t fReadOutCard; // 0 for DARC, 1 for ZRC
1ee299a5 195 UInt_t fEvType; // Event type
196 Int_t fPosition; // bit position in buffer data word
197
f9f99efb 198 // Boolean variables indicating data type
1ee299a5 199 Bool_t fIsCalib; // True when calibration run
200 Bool_t fIsDARCHeader; // True when DARC header
c3986754 201 Bool_t fIsHeaderMapping; // True when reading header mapping
1ee299a5 202 Bool_t fIsChMapping; // True when reading ch. mapping
203 Bool_t fIsADCDataWord; // True when data word
204 Bool_t fIsADCHeader; // True when ADC header
205 Bool_t fIsADCEOB; // True when EOB
fee50699 206 Bool_t fSODReading; // True when reading SOD (DA)
207 Bool_t fIsMapRead; // True if map is already read
a27ef05f 208 Bool_t fReadCDH; // False for sim raw data (uncorrect CDH!)
1ee299a5 209
1ee299a5 210 Int_t fDeadfaceOffset; // deadface offset
211 Int_t fDeadbeefOffset; // deadbeef offset
212 Int_t fDataOffset; // data offset
213
214 // ADC signal
215 Int_t fSector[2]; // [detector, sector]
216 Int_t fModType; // Module type
c3986754 217 Int_t fADCModule; // ADC module = GEO address for scaler, trigger card, P.U.
1ee299a5 218 Int_t fADCNChannels; // number of ADC ch.
c3986754 219 Int_t fADCChannel; // ADC channel = ch. for scaler, trigger card, P.U.
1ee299a5 220 Int_t fADCValue; // ADC channel
221 Int_t fADCGain; // ADC gain (0=high range; 1=low range)
c33b6ca6 222 Bool_t fIsUnderflow; // ADC underflow
223 Bool_t fIsOverflow; // ADC overflow
1ee299a5 224
e42bdf10 225 // Scaler
e42bdf10 226 UInt_t fScGeo; // scaler GEO address
c083685e 227 UInt_t fScNWords; // no. of words in scaler event
228 UInt_t fScTriggerSource; // Trigger source
e42bdf10 229 UInt_t fScTriggerNumber; // no. of triggers
f70a5526 230 Bool_t fIsScEventGood; // true if scaler event is good
231 Bool_t fIsScHeaderRead; // true if scaler header is read
c083685e 232 Int_t fScStartCounter; // position in the buffer where scaler data begins
233 UInt_t fScEvCounter; // event counter
ad3a602e 234 Bool_t fIsScalerWord; // is scaler word (not header)
e42bdf10 235
da090841 236 // Pattern Unit
237 UInt_t fDetPattern; // word from the pattern unit
238
239 // Trigger card
240 // (1) trigger counts
241 Int_t fTrigCountNWords; // no. of words to read from trigger card scalers
81f09162 242 Bool_t fIsTriggerScaler; // Trigger card scalers - 1st word read
da090841 243 Int_t fTrigCountStart; // Trigger card scalers - counter
244 Int_t fMBTrigInput; // MB trigger input to trigger card
245 Int_t fCentralTrigInput; // CENTRAL trigger input to trigger card
246 Int_t fSCentralTrigInput;// SEMICENTRAL trigger input to trigger card
247 Int_t fEMDTrigInput; // EMD trigger input to trigger card
248 Int_t fL0Received; // L0 received by the trigger card
249 Int_t fMBtrig2CTP; // trigger input to the CTP for MB
250 Int_t fCentralTrig2CTP; // trigger input to the CTP for CENTRAL
251 Int_t fSCentralTrig2CTP; // trigger input to the CTP for SEMICENTRAL
252 Int_t fEMDTrig2CTP; // trigger input to the CTP for EMD
253 // (2) trigger history
254 Int_t fTrigHistNWords; // no. of words to read from trigger history data
f70a5526 255 Bool_t fIsTriggerHistory; // Trigger history - 1st word read
256 Int_t fTrigHistStart; // Trigger card history - counter
da090841 257 Int_t fPileUpBit1stWord; // Pile up bit from 1st word
258 Int_t fL0Bit1stWord; // L0 bit from 1st word
259 UInt_t fCentralTrigHist; // history for CENTRAL trigger
260 UInt_t fMBTrigHist; // history for CENTRAL trigger
261 Int_t fPileUpBit2ndWord; // Pile up bit from 2nd word
262 Int_t fL0Bit2ndWord; // L0 bit from 2nd word
263 UInt_t fSCentralTrigHist; // history for SEMICENTRAL trigger
264 UInt_t fEMDTrigHist; // history for EMD trigger
265 Int_t fCPTInput[4]; // Trigger sent to the CTP
266
1ee299a5 267 // Channel mapping
c3986754 268 Int_t fNChannelsOn; // No. of signals/ADC ch. used
269 Int_t fCurrentCh; // current mapped ADC ch.
270 Int_t fCabledSignal; // physics signal (from enum)
271 Int_t fMapADC[48][5]; // ADC map {ADC mod., ch., signal, det., sec.}
272 Int_t fCurrScCh; // current mapped scaler ch.
273 Int_t fScalerMap[32][5]; // Scaler map {Scaler mod., ch., signal, det., sec.}
82dffa48 274 Int_t fCurrTDCCh; // current mapped TDC ch.
275 Int_t fTDCMap[32][3]; // TDC map {Scaler mod., ch., signal}
c3986754 276
277 // Checks over raw data event quality
da090841 278 Bool_t fIsADCEventGood; // true if not valid datum not corrupted
25930b52 279 Bool_t fIsL0BitSet; // true if L0 bit in history words = 1
280 Bool_t fIsPileUpEvent; // true if pile up bits in history words = 0
281
8c76923f 282 // ADD ADC
25930b52 283 Bool_t fIsADDChannel; // true if datum is an ADD ADC channel
8c76923f 284 Int_t fADDADCdatum; // ADD ADC datum
285
286 // TDCs
287 Bool_t fIsTDCHeaderRead; // true when streaming one of the 2 TDCs
288 Int_t fTDCStartCounter; // counts after a TDC header
289 //
290 Bool_t fIsZDCTDCHeader; // true if datum is a ZDC TDC header
291 Bool_t fIsZDCTDCdatum; // true if the current is a TDC datum
292 Int_t fZDCTDCdatum; // datum for ZDC TDC
293 //
294 Bool_t fIsADDTDCHeader; // true if datum is an ADD TDC channel
295 Bool_t fIsADDTDCdatum; // true when streaming ADD TDC data
296 Int_t fADDTDCdatum; // datum for ADD TDC
198f612a 297
a27ef05f 298 ClassDef(AliZDCRawStream, 20) // class for reading ZDC raw data
8309c1ab 299};
300
301#endif