]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCRawStream.h
Removal of another bug in DCS DP processing...
[u/mrichter/AliRoot.git] / ZDC / AliZDCRawStream.h
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
8 //////////////////////////////////////////////////
9 //                                              //
10 //  Class to provide access to ZDC raw data     //
11 //  Author: Chiara Oppedisano                   //
12 //                                              //
13 //////////////////////////////////////////////////
14
15 #include <TObject.h>
16 #include "AliCDBManager.h"
17 #include "AliCDBStorage.h"
18 #include "AliZDCChMap.h"
19
20 class AliRawReader;
21 class AliRawDataHeader;
22
23
24 class AliZDCRawStream: public TObject {
25   public :
26     AliZDCRawStream(AliRawReader* rawReader); 
27     virtual ~AliZDCRawStream();
28     virtual Bool_t   Next();
29     
30     virtual void ReadChMap();
31
32     virtual void ReadCDHHeader();
33
34     UInt_t GetRawBuffer()       const {return fBuffer;}
35     
36     Int_t  GetDeadfaceOffset() const {return fDeadfaceOffset;}
37     Int_t  GetDeadbeefOffset() const {return fDeadbeefOffset;}
38     Int_t  GetDataOffset()     const {return fDataOffset;}
39
40     Int_t  GetSector(Int_t i) const {return fSector[i];}
41     Int_t  GetModType()       const {return fModType;}
42     Int_t  GetADCModule()     const {return fADCModule;}
43     Int_t  GetADCNChannels()  const {return fADCNChannels;}
44     Int_t  GetADCChannel()    const {return fADCChannel;}
45     Int_t  GetADCValue()      const {return fADCValue;}
46     Int_t  GetADCGain()       const {return fADCGain;}
47     
48     AliCDBStorage *SetStorage(const char* uri);
49
50     // Map from OCDB
51     AliZDCChMap   *GetChMap() const;
52     //  ADC map
53     Int_t  GetNChannelsOn()            const {return fNChannelsOn;}
54     Int_t  GetCabledSignal()           const {return fCabledSignal;}
55     Int_t  GetADCModFromMap(Int_t i)   const {return fMapADC[i][0];}
56     Int_t  GetADCChFromMap(Int_t i)    const {return fMapADC[i][1];}
57     Int_t  GetADCSignFromMap(Int_t i)  const {return fMapADC[i][2];}
58     Int_t  GetDetectorFromMap(Int_t i) const {return fMapADC[i][3];}
59     Int_t  GetTowerFromMap(Int_t i)    const {return fMapADC[i][4];}
60     //  Scaler map
61     Int_t  GetScalerModFromMap(Int_t i)  const {return fScalerMap[i][0];}
62     Int_t  GetScalerChFromMap(Int_t i)   const {return fScalerMap[i][1];}
63     Int_t  GetScalerSignFromMap(Int_t i) const {return fScalerMap[i][2];}
64     Int_t  GetScDetectorFromMap(Int_t i) const {return fScalerMap[i][3];}
65     Int_t  GetScTowerFromMap(Int_t i)    const {return fScalerMap[i][4];}
66     
67     Bool_t IsCalibration()   const {return fIsCalib;}
68     Bool_t IsDARCHeader()    const {return fIsDARCHeader;}
69     Bool_t IsHeaderMapping() const {return fIsHeaderMapping;}
70     Bool_t IsChMapping()     const {return fIsChMapping;}
71     Bool_t IsADCDataWord()   const {return fIsADCDataWord;}
72     Bool_t IsADCHeader()     const {return fIsADCHeader;}
73     Bool_t IsADCEOB()        const {return fIsADCEOB;}
74     Bool_t IsUnderflow()     const {return fIsUnderflow;}
75     Bool_t IsOverflow()      const {return fIsOverflow;}
76     
77     UInt_t GetScGeo()           const {return fScGeo;}      
78     UInt_t GetScNWords()        const {return fScNWords;}           
79     UInt_t GetScTriggerSource() const {return fScTriggerSource;}            
80     UInt_t GetTriggerNumber()   const {return fScTriggerNumber;}
81     UInt_t GetTriggerCount()    const {return fScEvCounter;}
82     Bool_t IsScHeaderRead()     const {return fIsScHeaderRead;}
83     
84     UInt_t GetDetectorPattern() const {return fDetPattern;}
85     
86     Int_t  GetTriggerInput2CTP() const {return *fCPTInput;}
87     Bool_t IsCPTInputMBTrigger() 
88         {if(fCPTInput[0]==1) return kTRUE; else return kFALSE;}
89     Bool_t IsCPTInputCentralTrigger()
90         {if(fCPTInput[1]==1) return kTRUE; else return kFALSE;}
91     Bool_t IsCPTInputSemiCentralTrigger()
92         {if(fCPTInput[2]==1) return kTRUE; else return kFALSE;}
93     Bool_t IsCPTInputEMDTrigger()
94         {if(fCPTInput[3]==1) return kTRUE; else return kFALSE;}
95     
96     Bool_t IsADCEventGood() const {return fIsADCEventGood;} 
97     Bool_t IsL0BitSet()     const {return fIsL0BitSet;}  
98     Bool_t IsPileUpEvent()  const {return fIsPileUpEvent;} 
99     
100     void SetNChannelsOn(Int_t val) {fNChannelsOn = val;}
101     void SetSector(Int_t i, Int_t val) {fSector[i] = val;}
102     void SetMapADCMod(Int_t iraw, Int_t imod) {fMapADC[iraw][0]=imod;}
103     void SetMapADCCh(Int_t iraw, Int_t ich)   {fMapADC[iraw][1]=ich;}
104     void SetMapADCSig(Int_t iraw, Int_t isig) {fMapADC[iraw][2]=isig;}
105     void SetMapDet(Int_t iraw, Int_t idet)    {fMapADC[iraw][3]=idet;}
106     void SetMapTow(Int_t iraw, Int_t itow)    {fMapADC[iraw][4]=itow;}
107     
108     void SetSODReading(Bool_t iset) {fSODReading = iset;}
109     
110     // Error codes in raw data streaming
111     enum EZDCRawStreamError{
112        kCDHError = 1,
113        kDARCError = 2,
114        kZDCDataError = 3,
115        kInvalidADCModule = 4,
116        kInvalidSector = 5};
117     
118     // Module type codes
119     enum{kV965=1, kV830=2, kTRG=3, kTRGI=4, kPU=5}; 
120     
121     // Signal codes for ZDC 
122     // Same codes used in DAQ configuration file
123     // To be changed ONLY IF this file is changed!!! 
124     // **** DO NOT CHANGE THE FOLLOWING LINES!!! ****
125     enum ZDCSignal{kNotConnected=0, kVoid=1,
126          kZNAC=2, kZNA1=3, kZNA2=4, kZNA3=5, kZNA4=6,
127          kZPAC=7, kZPA1=8, kZPA2=9, kZPA3=10, kZPA4=11,
128          kZNCC=12, kZNC1=13, kZNC2=14, kZNC3=15, kZNC4=16,
129          kZPCC=17, kZPC1=18, kZPC2=19, kZPC3=20, kZPC4=21,
130          kZEM1=22, kZEM2=23,
131          kZDCAMon=24, kZDCCMon=25,
132          kZNACoot=26, kZNA1oot=27, kZNA2oot=28, kZNA3oot=29, kZNA4oot=30,
133          kZPACoot=31, kZPA1oot=32, kZPA2oot=33, kZPA3oot=34, kZPA4oot=35,
134          kZNCCoot=36, kZNC1oot=37, kZNC2oot=38, kZNC3oot=39, kZNC4oot=40,
135          kZPCCoot=41, kZPC1oot=42, kZPC2oot=43, kZPC3oot=44, kZPC4oot=45,
136          kZEM1oot=46, kZEM2oot=47,
137          kZDCAMonoot=48, kZDCCMonoot=49,
138          kL1MBI=50, kL1CNI=51, kL1SCI=52, kL1EMDI=53, kL0I=54, 
139          kL1MBO=55, kL1CNO=56, kL1SCO=57, kL1EMDO=58, 
140          kHMBCN=59, kHSCEMD=60};
141     
142   private :
143     AliZDCRawStream(const AliZDCRawStream& stream);
144     AliZDCRawStream& operator = (const AliZDCRawStream& stream);
145
146     AliRawReader* fRawReader;    // object for reading the raw data
147     
148     // Data for buffer decoding
149     UInt_t fBuffer;           // DARC header + ADC buffer
150     UInt_t fEvType;           // Event type
151     Int_t  fPosition;         // bit position in buffer data word
152     
153     // Boolean variables indicating data type
154     Bool_t fIsCalib;          // True when calibration run
155     Bool_t fIsDARCHeader;     // True when DARC header
156     Bool_t fIsHeaderMapping;  // True when reading header mapping
157     Bool_t fIsChMapping;      // True when reading ch. mapping
158     Bool_t fIsADCDataWord;    // True when data word
159     Bool_t fIsADCHeader;      // True when ADC header
160     Bool_t fIsADCEOB;         // True when EOB
161     Bool_t fSODReading;       // True when reading SOD (DA)
162     Bool_t fIsMapRead;        // True if map is already read
163     
164     // From CDH
165     UInt_t fDARCEvBlockLenght;  // DARC block length
166     UInt_t fDARCBlockAttributes;// DARC block attributes
167
168     Int_t  fDeadfaceOffset;   // deadface offset
169     Int_t  fDeadbeefOffset;   // deadbeef offset
170     Int_t  fDataOffset;       // data offset
171         
172     // ADC signal
173     Int_t  fSector[2];    // [detector, sector]
174     Int_t  fModType;      // Module type
175     Int_t  fADCModule;    // ADC module = GEO address for scaler, trigger card, P.U.
176     Int_t  fADCNChannels; // number of ADC ch.
177     Int_t  fADCChannel;   // ADC channel = ch. for scaler, trigger card, P.U.
178     Int_t  fADCValue;     // ADC channel
179     Int_t  fADCGain;      // ADC gain (0=high range; 1=low range)
180     Bool_t fIsUnderflow;  // ADC underflow
181     Bool_t fIsOverflow;   // ADC overflow
182     
183     // Scaler
184     UInt_t fScGeo;           // scaler GEO address
185     UInt_t fScNWords;        // no. of words in scaler event
186     UInt_t fScTriggerSource; // Trigger source 
187     UInt_t fScTriggerNumber; // no. of triggers
188     Bool_t fIsScEventGood;   // true if scaler event is good
189     Bool_t fIsScHeaderRead;  // true if scaler header is read
190     Int_t  fScStartCounter;  // position in the buffer where scaler data begins
191     UInt_t fScEvCounter;     // event counter
192     
193     // Pattern Unit
194     UInt_t fDetPattern;  // word from the pattern unit
195     
196     // Trigger card
197     // (1) trigger counts
198     Int_t  fTrigCountNWords;  // no. of words to read from trigger card scalers
199     Bool_t fIsTriggerScaler;// Trigger card scalers - 1st word read
200     Int_t  fTrigCountStart;   // Trigger card scalers - counter
201     Int_t  fMBTrigInput;      // MB          trigger input to trigger card
202     Int_t  fCentralTrigInput; // CENTRAL     trigger input to trigger card
203     Int_t  fSCentralTrigInput;// SEMICENTRAL trigger input to trigger card
204     Int_t  fEMDTrigInput;     // EMD         trigger input to trigger card
205     Int_t  fL0Received;       // L0 received by the trigger card
206     Int_t  fMBtrig2CTP;       // trigger input to the CTP for MB
207     Int_t  fCentralTrig2CTP;  // trigger input to the CTP for CENTRAL
208     Int_t  fSCentralTrig2CTP; // trigger input to the CTP for SEMICENTRAL
209     Int_t  fEMDTrig2CTP;      // trigger input to the CTP for EMD
210     // (2) trigger history
211     Int_t  fTrigHistNWords;   // no. of words to read from trigger history data
212     Bool_t fIsTriggerHistory; // Trigger history - 1st word read
213     Int_t  fTrigHistStart;    // Trigger card history - counter
214     Int_t  fPileUpBit1stWord; // Pile up bit from 1st word
215     Int_t  fL0Bit1stWord;     // L0 bit from 1st word
216     UInt_t fCentralTrigHist;  // history for CENTRAL trigger
217     UInt_t fMBTrigHist;       // history for CENTRAL trigger
218     Int_t  fPileUpBit2ndWord; // Pile up bit from 2nd word
219     Int_t  fL0Bit2ndWord;     // L0 bit from 2nd word
220     UInt_t fSCentralTrigHist; // history for SEMICENTRAL trigger
221     UInt_t fEMDTrigHist;      // history for EMD trigger
222     Int_t  fCPTInput[4];      // Trigger sent to the CTP
223     
224     // Channel mapping 
225     Int_t fNChannelsOn;      // No. of signals/ADC ch. used
226     Int_t fCurrentCh;        // current mapped ADC ch.
227     Int_t fCabledSignal;     // physics signal (from enum)
228     Int_t fMapADC[48][5];    // ADC map {ADC mod., ch., signal, det., sec.}
229     Int_t fCurrScCh;         // current mapped scaler ch.
230     Int_t fScalerMap[32][5]; // Scaler map {Scaler mod., ch., signal, det., sec.}
231     
232     // Checks over raw data event quality
233     Bool_t fIsADCEventGood; // true if not valid datum not corrupted
234     Bool_t fIsL0BitSet;    // true if L0 bit in history words = 1 
235     Bool_t fIsPileUpEvent; // true if pile up bits in history words = 0
236     
237     ClassDef(AliZDCRawStream, 14)    // class for reading ZDC raw data
238 };
239
240 #endif