]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCRawStream.cxx
Minor changes
[u/mrichter/AliRoot.git] / ZDC / AliZDCRawStream.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 // This class provides access to ZDC digits in raw data.                     //
21 //                                                                           //
22 // It loops over all ZDC digits in the raw data given by the AliRawReader.   //
23 // The Next method goes to the next digit. If there are no digits left       //
24 // it returns kFALSE.                                                        //
25 // Getters provide information about the current digit.                      //
26 //                                                                           //
27 ///////////////////////////////////////////////////////////////////////////////
28
29 #include <TSystem.h>
30 #include "AliZDCRawStream.h"
31 #include "AliRawReader.h"
32 #include "AliRawDataHeader.h"
33 #include "AliRawEventHeaderBase.h"
34 #include "AliLog.h"
35
36 ClassImp(AliZDCRawStream)
37
38
39 //_____________________________________________________________________________
40 AliZDCRawStream::AliZDCRawStream(AliRawReader* rawReader) :
41   fRawReader(rawReader),
42   fBuffer(0),
43   fEvType(0),
44   fPosition(0),
45   fIsCalib(kFALSE),
46   fIsDARCHeader(kFALSE),
47   fIsChMapping(kFALSE),
48   fIsADCDataWord(kFALSE),
49   fIsADCHeader(kFALSE),
50   fIsADCEOB(kFALSE),
51   fSODReading(kFALSE),
52   fIsMapRead(kFALSE),
53   fDARCEvBlockLenght(0),  
54   fDARCBlockAttributes(0),
55   fDeadfaceOffset(0),
56   fDeadbeefOffset(0),
57   fDataOffset(0),
58   fModType(-1),
59   fADCModule(-1),
60   fADCNChannels(-1),     
61   fADCChannel(-1),       
62   fADCValue(-1),         
63   fADCGain(-1),
64   fIsUnderflow(kFALSE),
65   fIsOverflow(kFALSE),
66   fScNWords(0),   
67   fScGeo(0),      
68   fScTS(0),       
69   fScTriggerNumber(0),
70   fIsScEventGood(kFALSE),
71   fNChannelsOn(48),
72   fNConnCh(-1),
73   fCabledSignal(-1)
74 {
75   // Create an object to read ZDC raw digits
76   fRawReader->Reset();
77   fRawReader->Select("ZDC");
78   //
79   for(Int_t i=0; i<fNChannelsOn; i++){
80     for(Int_t j=0; j<5; j++) fMapADC[i][j]=-1;
81   }
82
83 }
84
85 //_____________________________________________________________________________
86 AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) :
87   TObject(stream),
88   fRawReader(stream.fRawReader),
89   fBuffer(stream.GetRawBuffer()),
90   fEvType(stream.fEvType),
91   fPosition(stream.fPosition),
92   fIsCalib(stream.fIsCalib),
93   fIsDARCHeader(stream.fIsDARCHeader), 
94   fIsChMapping(stream.fIsChMapping),
95   fIsADCDataWord(stream.fIsADCDataWord), 
96   fIsADCHeader(stream.fIsADCHeader), 
97   fIsADCEOB(stream.fIsADCEOB), 
98   fSODReading(stream.fSODReading),
99   fIsMapRead(stream.fIsMapRead),
100   fDARCEvBlockLenght(stream.fDARCEvBlockLenght),  
101   fDARCBlockAttributes(stream.fDARCBlockAttributes),
102   fDeadfaceOffset(stream.GetDeadfaceOffset()),
103   fDeadbeefOffset(stream.GetDeadbeefOffset()),
104   fDataOffset(stream.GetDataOffset()),
105   fModType(stream.GetModType()),
106   fADCModule(stream.GetADCModule()),     
107   fADCNChannels(stream.GetADCNChannels()),       
108   fADCChannel(stream.GetADCChannel()),   
109   fADCValue(stream.GetADCValue()),       
110   fADCGain(stream.GetADCGain()),
111   fIsUnderflow(stream.fIsUnderflow),
112   fIsOverflow(stream.fIsOverflow),
113   fScNWords(stream.GetScNWords()),        
114   fScGeo(stream.GetScGeo()),      
115   fScTS(stream.GetScTS()),        
116   fScTriggerNumber(stream.fScTriggerNumber),
117   fIsScEventGood(stream.fIsScEventGood),
118   fNChannelsOn(stream.fNChannelsOn),
119   fNConnCh(stream.fNConnCh),
120   fCabledSignal(stream.GetCabledSignal())
121 {
122   // Copy constructor
123   for(Int_t j=0; j<2; j++) fSector[j] = stream.GetSector(j);     
124   for(Int_t i=0; i<fNChannelsOn; i++){
125     for(Int_t j=0; j<5; j++) fMapADC[i][j] = stream.fMapADC[i][j];
126   }
127 }
128
129 //_____________________________________________________________________________
130 AliZDCRawStream& AliZDCRawStream::operator = (const AliZDCRawStream& 
131                                               /* stream */)
132 {
133   // Assignment operator
134   Fatal("operator =", "assignment operator not implemented");
135   return *this;
136 }
137
138 //_____________________________________________________________________________
139 AliZDCRawStream::~AliZDCRawStream()
140 {
141 // Destructor
142
143 }
144
145 //_____________________________________________________________________________
146 void AliZDCRawStream::ReadChMap()
147 {
148   // Reading channel map
149   printf("\n\t Reading ADC mapping from OCDB\n");
150   AliZDCChMap * chMap = GetChMap();
151   chMap->Print("");
152   for(Int_t i=0; i<fNChannelsOn; i++){
153     fMapADC[i][0] = chMap->GetADCModule(i);
154     fMapADC[i][1] = chMap->GetADCChannel(i);
155     fMapADC[i][2] = -1;
156     fMapADC[i][3] = chMap->GetDetector(i);
157     fMapADC[i][4] = chMap->GetSector(i);
158   }
159   fIsMapRead = kTRUE;
160 }
161
162 //_____________________________________________________________________________
163 void AliZDCRawStream::ReadCDHHeader()
164 {
165   // Reading CDH 
166   const AliRawDataHeader* header = fRawReader->GetDataHeader();
167   if(!header) {
168       AliError(" No CDH in raw data streaming");
169       fRawReader->AddMajorErrorLog(kCDHError);
170       return;
171   }
172   else{
173     //printf("\t AliZDCRawStream::ReadCDHHeader -> Data Size = %d\n",fRawReader->GetDataSize());
174
175     fDARCEvBlockLenght = header->fSize;
176     //printf("\t AliZDCRawStream::ReadCDHHeader -> fDARCEvBlockLenght = %d\n",fDARCEvBlockLenght);
177     
178     UChar_t message = header->GetAttributes();
179     //printf("\t AliZDCRawStream::ReadCDHHeader -> Attributes %x\n",message);
180     
181     if(message & 0x10){ // COSMIC RUN
182        //printf("\t STANDALONE_COSMIC RUN raw data found\n");
183     }
184     else if(message & 0x20){ // PEDESTAL RUN
185        //printf("\t STANDALONE_PEDESTAL RUN raw data found\n");
186     }
187     else if(message & 0x30){ // LASER RUN
188        //printf("\t STANDALONE_LASER RUN raw data found\n");
189     }
190     
191     if(header->GetL1TriggerMessage() & 0x1){ // Calibration bit set in CDH
192       fIsCalib = kTRUE;
193     }
194     //printf("\t AliZDCRawStream::ReadCDHHeader -> L1TriggerMessage %x\n",header->GetL1TriggerMessage());
195     //printf("\t AliZDCRawStream::ReadCDHHeader -> Calibration bit = %d\n",fIsCalib);    
196     
197     UInt_t status = header->GetStatus();
198     //printf("\t AliZDCRawStream::ReadCDHHeader -> status = %d\n",status);
199     if((status & 0x000f) == 0x0001){
200       AliWarning("CDH -> DARC trg0 overlap error");
201       fRawReader->AddMajorErrorLog(kDARCError);
202     }
203     if((status & 0x000f) == 0x0002){
204       AliWarning("CDH -> DARC trg0 missing error");
205       fRawReader->AddMajorErrorLog(kDARCError);
206     }
207     if((status & 0x000f) == 0x0004){
208       AliWarning("CDH -> DARC data parity error");
209       fRawReader->AddMajorErrorLog(kDARCError);
210     }
211     if((status & 0x000f) == 0x0008){
212       AliWarning("CDH -> DARC ctrl parity error");
213       fRawReader->AddMajorErrorLog(kDARCError);
214     }
215     //
216     if((status & 0x00f0) == 0x0010){
217       AliWarning("CDH -> DARC trg unavailable");
218       fRawReader->AddMajorErrorLog(kDARCError);
219     }
220     if((status & 0x00f0) == 0x0020){
221       AliWarning("CDH -> DARC FEE error");
222       fRawReader->AddMajorErrorLog(kDARCError);
223     }
224     //
225     if((status & 0x0f00) == 0x0200){
226       AliWarning("CDH -> DARC L1 time violation");
227       fRawReader->AddMajorErrorLog(kDARCError);
228     }
229     if((status & 0x0f00) == 0x0400){
230       AliWarning("CDH -> DARC L2 time-out");
231       fRawReader->AddMajorErrorLog(kDARCError);
232     }
233     if((status & 0x0f00) == 0x0800){
234       AliWarning("CDH -> DARC prepulse time violation");
235       fRawReader->AddMajorErrorLog(kDARCError);
236     }
237     //
238     if((status & 0xf000) == 0x1000){
239       AliWarning("CDH -> DARC other error");
240       fRawReader->AddMajorErrorLog(kDARCError);
241     }
242   }
243   //
244   fIsDARCHeader = kTRUE;
245 }
246
247 //_____________________________________________________________________________
248 Bool_t AliZDCRawStream::Next()
249 {
250   // Read the next raw digit
251   // Returns kFALSE if there is no digit left
252
253   if(!fRawReader->ReadNextInt((UInt_t&) fBuffer)) return kFALSE;
254   fIsChMapping = kFALSE; fIsADCHeader = kFALSE; 
255   fIsADCDataWord = kFALSE; fIsADCEOB = kFALSE;
256   fIsUnderflow = kFALSE;
257   fIsOverflow = kFALSE; 
258   fSector[0]=fSector[1] = -1;
259   
260   fEvType = fRawReader->GetType();
261   //printf("\n\t AliZDCRawStream::Next() -> ev. type %d\n",fEvType);
262   //printf("\n  AliZDCRawStream::Next() - fBuffer[%d] = %x\n",fPosition, fBuffer);
263   
264   if(fPosition==0){
265     //if(fEvType==7 || fEvType ==8){ //Physics or calibration event
266       //ReadEventHeader();
267       ReadCDHHeader();
268     //}
269     fNConnCh=0;
270   }
271   
272   // *** End of ZDC event
273   if(fBuffer == 0xcafefade){
274     //printf("\n-> AliZDCRawStream::Next() ***** End of ZDC event *****\n\n");
275     return kFALSE;
276   }
277   
278   // -------------------------------------------
279   // --- DARC header
280   // -------------------------------------------
281   // If the CDH has been read then 
282   // the DARC header must follow
283   if(fIsDARCHeader){
284     //printf("\t ---- DARC header ----\n");
285     if(fIsCalib){
286       fDeadfaceOffset = 9;
287       fDeadbeefOffset = 25;
288     }
289     else{
290       fDeadfaceOffset = 1;
291       fDeadbeefOffset = 7;
292     }
293     fDataOffset = 1+fDeadbeefOffset;
294     fIsDARCHeader = kFALSE;
295   }
296
297     
298   // -------------------------------------------
299   // --- Start of data event
300   // --- decoding mapping of connected ADC ch.
301   // -------------------------------------------
302   // In the SOD event ADC ch. mapping is written
303   if(fEvType==10 && fSODReading){
304     //printf("\n-> AliZDCRawStream::Next() - fBuffer[%d] = %x\n",fPosition, fBuffer);
305     
306     if(fPosition>fDataOffset){
307       if((fBuffer&0xff000000) == 0xff000000){
308         if(fPosition==(fDataOffset+1)){ 
309            printf("\n\n\t AliZDCRawStream -> Reading mapping from StartOfData event\n");
310            fNConnCh=0;  
311         }
312         else{
313           printf("\n\t AliZDCRawStream -> End of ZDC StartOfData event\n\n");
314           //printf("AliZDCRawStream: fSODReading after SOD reading set to %d\n", fSODReading);
315           return kFALSE;
316         }
317       }
318       else if((fBuffer&0x80000000)>>31 == 1){
319         // Mapping identification
320         fADCModule = ((fBuffer & 0x7f000000)>>24);
321         fModType = ((fBuffer & 0x7ff00)>>8);
322         fADCNChannels = (fBuffer & 0xff);
323         //
324         //printf("  ******** GEO %d, mod. type %d, #ch. %d\n",fADCModule,fModType,fADCNChannels);
325       }
326       else if(fModType==1 && (fBuffer&0x80000000)>>31 == 0){
327         // Channel signal
328         if((fBuffer&0x40000000)>>30==0){ // high range chain ADC
329           fIsChMapping = kTRUE;
330           fADCChannel = ((fBuffer & 0x3fff0000)>>16);
331           fCabledSignal = (fBuffer&0xffff);
332           //printf("\tADC ch. %d, signal %d\n",fADCChannel,fCabledSignal);
333           //
334           fMapADC[fNConnCh][0] = fADCModule;
335           fMapADC[fNConnCh][1] = fADCChannel;
336           fMapADC[fNConnCh][2] = fCabledSignal;
337           //
338           // Determining detector and sector
339           // -----------------------------------------
340           //  For the decoding of the following lines 
341           //  look the enum in AliZDCRawStream.h file
342           // -----------------------------------------
343           if((fCabledSignal>=2 && fCabledSignal<=6) || (fCabledSignal>=26 && fCabledSignal<=30)
344              || fCabledSignal==24 || fCabledSignal==48){
345             fMapADC[fNConnCh][3] = 4; //ZNA
346             //
347             if(fCabledSignal==2 || fCabledSignal==26)       fMapADC[fNConnCh][4]=0;
348             else if(fCabledSignal==3 || fCabledSignal==27)  fMapADC[fNConnCh][4]=1;
349             else if(fCabledSignal==4 || fCabledSignal==28)  fMapADC[fNConnCh][4]=2;
350             else if(fCabledSignal==5 || fCabledSignal==29)  fMapADC[fNConnCh][4]=3;
351             else if(fCabledSignal==6 || fCabledSignal==30)  fMapADC[fNConnCh][4]=4;
352             else if(fCabledSignal==24 || fCabledSignal==48) fMapADC[fNConnCh][4]=5;
353           }
354           else if((fCabledSignal>=7 && fCabledSignal<=11) || (fCabledSignal>=31 && fCabledSignal<=35)){
355             fMapADC[fNConnCh][3] = 5; //ZPA
356             //
357             if(fCabledSignal==7 || fCabledSignal==31)       fMapADC[fNConnCh][4]=0;
358             else if(fCabledSignal==8 || fCabledSignal==32)  fMapADC[fNConnCh][4]=1;
359             else if(fCabledSignal==9 || fCabledSignal==33)  fMapADC[fNConnCh][4]=2;
360             else if(fCabledSignal==10 || fCabledSignal==34) fMapADC[fNConnCh][4]=3;
361             else if(fCabledSignal==11 || fCabledSignal==35) fMapADC[fNConnCh][4]=4;
362           }
363           else if((fCabledSignal>=12 && fCabledSignal<=16) || (fCabledSignal>=36 && fCabledSignal<=40)
364              || fCabledSignal==25 || fCabledSignal==49){
365             fMapADC[fNConnCh][3] = 1; //ZNC
366             //
367             if(fCabledSignal==12 || fCabledSignal==36)      fMapADC[fNConnCh][4]=0;
368             else if(fCabledSignal==13 || fCabledSignal==37) fMapADC[fNConnCh][4]=1;
369             else if(fCabledSignal==14 || fCabledSignal==38) fMapADC[fNConnCh][4]=2;
370             else if(fCabledSignal==15 || fCabledSignal==39) fMapADC[fNConnCh][4]=3;
371             else if(fCabledSignal==16 || fCabledSignal==40) fMapADC[fNConnCh][4]=4;
372             else if(fCabledSignal==25 || fCabledSignal==49) fMapADC[fNConnCh][4]=5;
373           }
374           else if((fCabledSignal>=17 && fCabledSignal<=21) || (fCabledSignal>=41 && fCabledSignal<=45)){
375             fMapADC[fNConnCh][3] = 2; //ZPC
376             //
377             if(fCabledSignal==17 || fCabledSignal==41)      fMapADC[fNConnCh][4]=0;
378             else if(fCabledSignal==18 || fCabledSignal==42) fMapADC[fNConnCh][4]=1;
379             else if(fCabledSignal==19 || fCabledSignal==43) fMapADC[fNConnCh][4]=2;
380             else if(fCabledSignal==20 || fCabledSignal==44) fMapADC[fNConnCh][4]=3;
381             else if(fCabledSignal==21 || fCabledSignal==45) fMapADC[fNConnCh][4]=4;
382           }
383           else if(fCabledSignal==22 || fCabledSignal==23 || fCabledSignal==46 || fCabledSignal==47){
384             fMapADC[fNConnCh][3] = 3;
385             //
386             if(fCabledSignal==22 || fCabledSignal==46)      fMapADC[fNConnCh][4]=1;
387             else if(fCabledSignal==23 || fCabledSignal==47) fMapADC[fNConnCh][4]=2;
388           }
389           //
390           //if(fNConnCh<fNChannelsOn) printf("                    %d mod %d ch %d code %d det %d sec %d\n",
391           //   fNConnCh,fADCModule,fADCChannel,fBuffer&0xffff,fMapADC[fNConnCh][3],fMapADC[fNConnCh][4]);
392           //
393           fNConnCh++;
394           if(fNConnCh>=fNChannelsOn){
395             // Protection manually set since it returns:
396             // RawData48 mod. 3 ch. 2048 signal 515
397             // to be checked with Pietro!!!!!!!!!!!!!!!!!!!!!!!
398             //AliDebug(2," No. of cabled channels > fNChannelsOn!!!");
399             fPosition++;
400             return kTRUE;
401           }
402         }
403       }// ModType=1 (ADC mapping)
404     }
405     fPosition++;
406     return kTRUE;
407   } // SOD event
408   
409   // -------------------------------------------
410   // --- DARC data
411   // -------------------------------------------
412   if(fPosition<fDeadfaceOffset){
413     fPosition++;
414     return kTRUE;
415   }
416   else if(fPosition==fDeadfaceOffset){
417     if(fBuffer != 0xdeadface){
418       AliError(" NO deadface after DARC data");
419       fRawReader->AddMajorErrorLog(kDARCError);  
420     }
421     else{
422       fPosition++;
423       return kTRUE;
424     }
425   }
426   
427   // -------------------------------------------
428   // --- DARC global data
429   // -------------------------------------------
430   else if(fPosition>fDeadfaceOffset && fPosition<fDeadbeefOffset){
431     fPosition++;
432     return kTRUE;
433   }
434   else if(fPosition==fDeadbeefOffset){
435     if(fBuffer != 0xdeadbeef){
436       AliError(" NO deadbeef after DARC global data");
437       fRawReader->AddMajorErrorLog(kDARCError);  
438     }
439     else{
440       fPosition++;
441       return kTRUE;
442     }
443   }
444
445   // -------------------------------------------
446   // --- ZDC data
447   // --- ADC buffer + scaler
448   // -------------------------------------------
449   else if(fPosition>=fDataOffset){
450     
451     //printf("AliZDCRawStream: fSODReading = %d\n", fSODReading);
452     if(!fSODReading && !fIsMapRead) ReadChMap();
453     
454     // Not valid datum before the event 
455     // there MUST be a NOT valid datum before the event!!!
456     if(fPosition==fDataOffset){
457       //printf("\t **** ZDC data begin ****\n");
458       if((fBuffer & 0x07000000) == 0x06000000){
459         //printf("    AliZDCRawStream -> Not valid datum in ADC %d,"
460         //       "position %d in word data buffer\n",fADCModule,fPosition);
461       }
462       else fRawReader->AddMajorErrorLog(kZDCDataError);
463     }
464     
465     // If the not valid datum isn't followed by the 1st ADC header
466     // the event is corrupted (i.e., 2 gates arrived before trigger)
467     else if(fPosition==fDataOffset+1){
468       if((fBuffer & 0x07000000) != 0x02000000){
469         AliWarning("ZDC ADC -> The not valid datum is NOT followed by an ADC header!");
470         fRawReader->AddMajorErrorLog(kZDCDataError);
471       }
472     }
473      
474     // Get geo address of current word to determine
475     // if it is a scaler word (geo address == kScalerAddress)
476     // if it is an ADC word (geo address != 8)
477     Int_t kScalerAddress=8;
478     fADCModule = ((fBuffer & 0xf8000000)>>27);
479     if(fADCModule == kScalerAddress){
480       DecodeScaler();
481     } 
482     else{//ADC module
483       // *** ADC header
484       if((fBuffer & 0x07000000) == 0x02000000){
485         fIsADCHeader = kTRUE;
486         fADCNChannels = ((fBuffer & 0x00003f00)>>8);
487         //printf("  AliZDCRawStream -> HEADER: ADC mod.%d has %d ch. \n",fADCModule,fADCNChannels);
488       }
489       // *** ADC data word
490       else if((fBuffer & 0x07000000) == 0x00000000){
491         fIsADCDataWord = kTRUE;
492         fADCChannel = ((fBuffer & 0x1e0000) >> 17);
493         fADCGain = ((fBuffer & 0x10000) >> 16);       
494         fADCValue = (fBuffer & 0xfff);  
495         
496         //printf("  AliZDCRawStream -> DATA: ADC mod. %d ch. %d gain %d value %d\n",
497         //  fADCModule,fADCChannel,fADCGain,fADCValue);
498         
499         // Checking if the channel map for the ADCs has been provided/read
500         if(fMapADC[0][0]==-1){
501           printf("\t ATTENTION!!! No ADC mapping has been found/provided!!!\n");
502           return kFALSE;
503         }
504         //
505         /*for(Int_t ci=0; ci<fNChannelsOn; ci++){
506           printf("  %d mod %d ch %d det %d sec %d\n",ci,fMapADC[ci][0],
507           fMapADC[ci][1], fMapADC[ci][3], fMapADC[ci][4]);
508         }*/
509                 
510         // Scan of the map to assign the correct volumes
511         Int_t foundMapEntry = kFALSE;
512         for(Int_t k=0; k<fNChannelsOn; k++){
513            if(fADCModule==fMapADC[k][0] && fADCChannel==fMapADC[k][1]){
514              fSector[0] = fMapADC[k][3];
515              fSector[1] = fMapADC[k][4];
516              foundMapEntry = kTRUE;
517              break;
518            } 
519         }
520         if(foundMapEntry==kFALSE){
521           AliWarning(Form(" No valid entry found in ADC mapping for raw data %d ADCmod. %d ch. %d gain %d\n",
522               fPosition,fADCModule,fADCChannel,fADCGain));
523         }
524         //
525         //printf("AliZDCRawStream -> ADCmod. %d ch. %d gain %d -> det %d sec %d\n",
526         //  fADCModule,fADCChannel,fADCGain,fSector[0],fSector[1]);
527         
528         // Final checks
529         if(fSector[0]<1 || fSector[0]>5){
530           AliWarning(Form(" No valid detector assignment: %d",fSector[0]));
531           fRawReader->AddMajorErrorLog(kInvalidSector);
532         }
533         //
534         if(fSector[1]<0 || fSector[1]>5){
535           AliWarning(Form(" No valid sector assignment: %d",fSector[1]));
536           fRawReader->AddMajorErrorLog(kInvalidSector);
537         }
538         //
539         if(fADCModule<0 || fADCModule>3){
540           AliError(Form(" No valid ADC module: %d",fADCModule));
541           fRawReader->AddMajorErrorLog(kInvalidADCModule);
542         }
543
544         // Checking the underflow and overflow bits
545         if(fBuffer & 0x1000)       fIsUnderflow = kTRUE;
546         else if (fBuffer & 0x2000) fIsOverflow = kTRUE; 
547                 
548       }//ADC data word
549       // *** ADC EOB
550       else if((fBuffer & 0x07000000) == 0x04000000){
551         fIsADCEOB = kTRUE;
552         //printf("  AliZDCRawStream -> EOB --------------------------\n");
553       }
554      }//ADC module
555         
556     
557   }
558   fPosition++;
559
560   return kTRUE;
561 }
562
563 //_____________________________________________________________________________
564 void AliZDCRawStream::DecodeScaler()
565 {
566   // Decoding scaler event
567   
568   if(!fBuffer & 0x04000000){
569     AliWarning(" Scaler header corrupted");
570     fIsScEventGood = kFALSE; 
571   }
572   Int_t scNwords = (Int_t) fScNWords;
573   if(fPosition==scNwords && fBuffer != 0x0){
574     AliWarning(" Scaler trailer corrupted");
575     fIsScEventGood = kFALSE; 
576   }
577   fIsScEventGood = kTRUE;
578   
579   if(fPosition==0){
580     fScNWords = (fBuffer & 0x00fc0000)>>18;        
581     fScGeo = (fBuffer & 0xf8000000)>>27;           
582     fScTS = (fBuffer & 0x00030000)>>16;    
583     fScTriggerNumber = (fBuffer & 0x0000ffff);
584   }
585    
586   fPosition++;
587   
588 }
589
590 //_____________________________________________________________________________
591 AliCDBStorage* AliZDCRawStream::SetStorage(const char *uri) 
592 {
593   // Setting the storage
594   
595   AliCDBStorage *storage = AliCDBManager::Instance()->GetStorage(uri); 
596
597   return storage; 
598 }
599
600
601 //_____________________________________________________________________________
602 AliZDCChMap* AliZDCRawStream::GetChMap() const
603 {
604
605   // Getting calibration object for ZDC
606
607   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("ZDC/Calib/ChMap");
608   if(!entry) AliFatal("No calibration data loaded!");  
609
610   AliZDCChMap *calibdata = dynamic_cast<AliZDCChMap*> (entry->GetObject());
611   if(!calibdata) AliFatal("Wrong calibration object in calibration  file!");
612
613   return calibdata;
614 }