Method CheckConsistency modified.
[u/mrichter/AliRoot.git] / ZDC / AliZDCRawStream.cxx
CommitLineData
8309c1ab 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///////////////////////////////////////////////////////////////////////////////
83347831 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// //
8309c1ab 27///////////////////////////////////////////////////////////////////////////////
28
11b06725 29#include <TSystem.h>
8309c1ab 30#include "AliZDCRawStream.h"
31#include "AliRawReader.h"
1ee299a5 32#include "AliRawDataHeader.h"
33#include "AliRawEventHeaderBase.h"
cc2abffd 34#include "AliLog.h"
8309c1ab 35
36ClassImp(AliZDCRawStream)
37
38
39//_____________________________________________________________________________
40AliZDCRawStream::AliZDCRawStream(AliRawReader* rawReader) :
41 fRawReader(rawReader),
1ee299a5 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),
fee50699 51 fSODReading(kFALSE),
52 fIsMapRead(kFALSE),
1ee299a5 53 fDARCEvBlockLenght(0),
54 fDARCBlockAttributes(0),
55 fDeadfaceOffset(0),
56 fDeadbeefOffset(0),
57 fDataOffset(0),
58 fModType(-1),
59 fADCModule(-1),
60 fADCNChannels(-1),
786b72f5 61 fADCChannel(-1),
cc2abffd 62 fADCValue(-1),
1ee299a5 63 fADCGain(-1),
c33b6ca6 64 fIsUnderflow(kFALSE),
65 fIsOverflow(kFALSE),
e42bdf10 66 fScNWords(0),
fee50699 67 fScGeo(0),
e42bdf10 68 fScTS(0),
69 fScTriggerNumber(0),
70 fIsScEventGood(kFALSE),
9d0b658a 71 fNChannelsOn(48),
1ee299a5 72 fNConnCh(-1),
73 fCabledSignal(-1)
8309c1ab 74{
abf60186 75 // Create an object to read ZDC raw digits
1ee299a5 76 fRawReader->Reset();
362c9d61 77 fRawReader->Select("ZDC");
1ee299a5 78 //
9d0b658a 79 for(Int_t i=0; i<fNChannelsOn; i++){
c93c022b 80 for(Int_t j=0; j<5; j++) fMapADC[i][j]=-1;
1ee299a5 81 }
82
8309c1ab 83}
84
85//_____________________________________________________________________________
86AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) :
a718c993 87 TObject(stream),
c61a7285 88 fRawReader(stream.fRawReader),
1ee299a5 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),
fee50699 98 fSODReading(stream.fSODReading),
99 fIsMapRead(stream.fIsMapRead),
1ee299a5 100 fDARCEvBlockLenght(stream.fDARCEvBlockLenght),
101 fDARCBlockAttributes(stream.fDARCBlockAttributes),
102 fDeadfaceOffset(stream.GetDeadfaceOffset()),
103 fDeadbeefOffset(stream.GetDeadbeefOffset()),
104 fDataOffset(stream.GetDataOffset()),
105 fModType(stream.GetModType()),
a718c993 106 fADCModule(stream.GetADCModule()),
1ee299a5 107 fADCNChannels(stream.GetADCNChannels()),
a718c993 108 fADCChannel(stream.GetADCChannel()),
109 fADCValue(stream.GetADCValue()),
110 fADCGain(stream.GetADCGain()),
c33b6ca6 111 fIsUnderflow(stream.fIsUnderflow),
112 fIsOverflow(stream.fIsOverflow),
e42bdf10 113 fScNWords(stream.GetScNWords()),
114 fScGeo(stream.GetScGeo()),
115 fScTS(stream.GetScTS()),
22fe5e66 116 fScTriggerNumber(stream.fScTriggerNumber),
e42bdf10 117 fIsScEventGood(stream.fIsScEventGood),
9d0b658a 118 fNChannelsOn(stream.fNChannelsOn),
1ee299a5 119 fNConnCh(stream.fNConnCh),
120 fCabledSignal(stream.GetCabledSignal())
8309c1ab 121{
abf60186 122 // Copy constructor
c0aec6f6 123 for(Int_t j=0; j<2; j++) fSector[j] = stream.GetSector(j);
9d0b658a 124 for(Int_t i=0; i<fNChannelsOn; i++){
c93c022b 125 for(Int_t j=0; j<5; j++) fMapADC[i][j] = stream.fMapADC[i][j];
1ee299a5 126 }
8309c1ab 127}
128
129//_____________________________________________________________________________
130AliZDCRawStream& AliZDCRawStream::operator = (const AliZDCRawStream&
131 /* stream */)
132{
abf60186 133 // Assignment operator
8309c1ab 134 Fatal("operator =", "assignment operator not implemented");
135 return *this;
136}
137
138//_____________________________________________________________________________
139AliZDCRawStream::~AliZDCRawStream()
140{
abf60186 141// Destructor
8309c1ab 142
143}
144
1ee299a5 145//_____________________________________________________________________________
c93c022b 146void AliZDCRawStream::ReadChMap()
147{
148 // Reading channel map
ac84d2fc 149 printf("\n\t Reading ADC mapping from OCDB\n");
fee50699 150 AliZDCChMap * chMap = GetChMap();
9d0b658a 151 chMap->Print("");
152 for(Int_t i=0; i<fNChannelsOn; i++){
fee50699 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;
c93c022b 160}
161
162//_____________________________________________________________________________
1ee299a5 163void AliZDCRawStream::ReadCDHHeader()
164{
165 // Reading CDH
166 const AliRawDataHeader* header = fRawReader->GetDataHeader();
167 if(!header) {
9d0b658a 168 AliError(" No CDH in raw data streaming");
1ee299a5 169 fRawReader->AddMajorErrorLog(kCDHError);
fee50699 170 return;
1ee299a5 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
ac84d2fc 178 UChar_t message = header->GetAttributes();
1ee299a5 179 //printf("\t AliZDCRawStream::ReadCDHHeader -> Attributes %x\n",message);
180
ac84d2fc 181 if(message & 0x10){ // COSMIC RUN
65448375 182 //printf("\t STANDALONE_COSMIC RUN raw data found\n");
1ee299a5 183 }
184 else if(message & 0x20){ // PEDESTAL RUN
65448375 185 //printf("\t STANDALONE_PEDESTAL RUN raw data found\n");
1ee299a5 186 }
187 else if(message & 0x30){ // LASER RUN
65448375 188 //printf("\t STANDALONE_LASER RUN raw data found\n");
ac84d2fc 189 }
1ee299a5 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());
c93c022b 195 //printf("\t AliZDCRawStream::ReadCDHHeader -> Calibration bit = %d\n",fIsCalib);
1ee299a5 196
197 UInt_t status = header->GetStatus();
198 //printf("\t AliZDCRawStream::ReadCDHHeader -> status = %d\n",status);
f9f99efb 199 if((status & 0x000f) == 0x0001){
9d0b658a 200 AliWarning("CDH -> DARC trg0 overlap error");
1ee299a5 201 fRawReader->AddMajorErrorLog(kDARCError);
202 }
f9f99efb 203 if((status & 0x000f) == 0x0002){
9d0b658a 204 AliWarning("CDH -> DARC trg0 missing error");
1ee299a5 205 fRawReader->AddMajorErrorLog(kDARCError);
206 }
f9f99efb 207 if((status & 0x000f) == 0x0004){
9d0b658a 208 AliWarning("CDH -> DARC data parity error");
1ee299a5 209 fRawReader->AddMajorErrorLog(kDARCError);
210 }
f9f99efb 211 if((status & 0x000f) == 0x0008){
9d0b658a 212 AliWarning("CDH -> DARC ctrl parity error");
1ee299a5 213 fRawReader->AddMajorErrorLog(kDARCError);
214 }
215 //
f9f99efb 216 if((status & 0x00f0) == 0x0010){
9d0b658a 217 AliWarning("CDH -> DARC trg unavailable");
1ee299a5 218 fRawReader->AddMajorErrorLog(kDARCError);
219 }
f9f99efb 220 if((status & 0x00f0) == 0x0020){
9d0b658a 221 AliWarning("CDH -> DARC FEE error");
1ee299a5 222 fRawReader->AddMajorErrorLog(kDARCError);
223 }
224 //
f9f99efb 225 if((status & 0x0f00) == 0x0200){
9d0b658a 226 AliWarning("CDH -> DARC L1 time violation");
1ee299a5 227 fRawReader->AddMajorErrorLog(kDARCError);
228 }
f9f99efb 229 if((status & 0x0f00) == 0x0400){
9d0b658a 230 AliWarning("CDH -> DARC L2 time-out");
1ee299a5 231 fRawReader->AddMajorErrorLog(kDARCError);
232 }
f9f99efb 233 if((status & 0x0f00) == 0x0800){
9d0b658a 234 AliWarning("CDH -> DARC prepulse time violation");
1ee299a5 235 fRawReader->AddMajorErrorLog(kDARCError);
236 }
237 //
f9f99efb 238 if((status & 0xf000) == 0x1000){
9d0b658a 239 AliWarning("CDH -> DARC other error");
1ee299a5 240 fRawReader->AddMajorErrorLog(kDARCError);
241 }
242 }
243 //
244 fIsDARCHeader = kTRUE;
245}
246
8309c1ab 247//_____________________________________________________________________________
248Bool_t AliZDCRawStream::Next()
249{
abf60186 250 // Read the next raw digit
251 // Returns kFALSE if there is no digit left
8309c1ab 252
1ee299a5 253 if(!fRawReader->ReadNextInt((UInt_t&) fBuffer)) return kFALSE;
254 fIsChMapping = kFALSE; fIsADCHeader = kFALSE;
255 fIsADCDataWord = kFALSE; fIsADCEOB = kFALSE;
c33b6ca6 256 fIsUnderflow = kFALSE;
257 fIsOverflow = kFALSE;
258 fSector[0]=fSector[1] = -1;
1ee299a5 259
260 fEvType = fRawReader->GetType();
261 //printf("\n\t AliZDCRawStream::Next() -> ev. type %d\n",fEvType);
ac84d2fc 262 //printf("\n AliZDCRawStream::Next() - fBuffer[%d] = %x\n",fPosition, fBuffer);
1ee299a5 263
264 if(fPosition==0){
265 //if(fEvType==7 || fEvType ==8){ //Physics or calibration event
266 //ReadEventHeader();
267 ReadCDHHeader();
268 //}
269 fNConnCh=0;
270 }
ac84d2fc 271
9d0b658a 272 // *** End of ZDC event
ac84d2fc 273 if(fBuffer == 0xcafefade){
274 //printf("\n-> AliZDCRawStream::Next() ***** End of ZDC event *****\n\n");
275 return kFALSE;
276 }
1ee299a5 277
278 // -------------------------------------------
1069e28d 279 // --- DARC header
1ee299a5 280 // -------------------------------------------
fee50699 281 // If the CDH has been read then
282 // the DARC header must follow
1ee299a5 283 if(fIsDARCHeader){
84d2abc2 284 //printf("\t ---- DARC header ----\n");
1ee299a5 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;
abf60186 295 }
ac84d2fc 296
1ee299a5 297
298 // -------------------------------------------
299 // --- Start of data event
300 // --- decoding mapping of connected ADC ch.
301 // -------------------------------------------
fee50699 302 // In the SOD event ADC ch. mapping is written
303 if(fEvType==10 && fSODReading){
ac84d2fc 304 //printf("\n-> AliZDCRawStream::Next() - fBuffer[%d] = %x\n",fPosition, fBuffer);
fee50699 305
1ee299a5 306 if(fPosition>fDataOffset){
307 if((fBuffer&0xff000000) == 0xff000000){
308 if(fPosition==(fDataOffset+1)){
9d0b658a 309 printf("\n\n\t AliZDCRawStream -> Reading mapping from StartOfData event\n");
1ee299a5 310 fNConnCh=0;
6006df88 311 }
1ee299a5 312 else{
9d0b658a 313 printf("\n\t AliZDCRawStream -> End of ZDC StartOfData event\n\n");
fee50699 314 //printf("AliZDCRawStream: fSODReading after SOD reading set to %d\n", fSODReading);
315 return kFALSE;
1ee299a5 316 }
317 }
318 else if((fBuffer&0x80000000)>>31 == 1){
319 // Mapping identification
320 fADCModule = ((fBuffer & 0x7f000000)>>24);
9d0b658a 321 fModType = ((fBuffer & 0x7ff00)>>8);
1ee299a5 322 fADCNChannels = (fBuffer & 0xff);
323 //
ac84d2fc 324 //printf(" ******** GEO %d, mod. type %d, #ch. %d\n",fADCModule,fModType,fADCNChannels);
6006df88 325 }
fee50699 326 else if(fModType==1 && (fBuffer&0x80000000)>>31 == 0){
1ee299a5 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);
fee50699 332 //printf("\tADC ch. %d, signal %d\n",fADCChannel,fCabledSignal);
333 //
1ee299a5 334 fMapADC[fNConnCh][0] = fADCModule;
335 fMapADC[fNConnCh][1] = fADCChannel;
336 fMapADC[fNConnCh][2] = fCabledSignal;
c93c022b 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){
c677d80e 345 fMapADC[fNConnCh][3] = 4; //ZNA
c93c022b 346 //
fee50699 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;
c93c022b 352 else if(fCabledSignal==24 || fCabledSignal==48) fMapADC[fNConnCh][4]=5;
353 }
354 else if((fCabledSignal>=7 && fCabledSignal<=11) || (fCabledSignal>=31 && fCabledSignal<=35)){
c677d80e 355 fMapADC[fNConnCh][3] = 5; //ZPA
c93c022b 356 //
fee50699 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;
c93c022b 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){
c677d80e 365 fMapADC[fNConnCh][3] = 1; //ZNC
c93c022b 366 //
fee50699 367 if(fCabledSignal==12 || fCabledSignal==36) fMapADC[fNConnCh][4]=0;
c93c022b 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)){
c677d80e 375 fMapADC[fNConnCh][3] = 2; //ZPC
c93c022b 376 //
fee50699 377 if(fCabledSignal==17 || fCabledSignal==41) fMapADC[fNConnCh][4]=0;
c93c022b 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){
c677d80e 384 fMapADC[fNConnCh][3] = 3;
c93c022b 385 //
fee50699 386 if(fCabledSignal==22 || fCabledSignal==46) fMapADC[fNConnCh][4]=1;
c93c022b 387 else if(fCabledSignal==23 || fCabledSignal==47) fMapADC[fNConnCh][4]=2;
388 }
389 //
9d0b658a 390 //if(fNConnCh<fNChannelsOn) printf(" %d mod %d ch %d code %d det %d sec %d\n",
c93c022b 391 // fNConnCh,fADCModule,fADCChannel,fBuffer&0xffff,fMapADC[fNConnCh][3],fMapADC[fNConnCh][4]);
1ee299a5 392 //
393 fNConnCh++;
9d0b658a 394 if(fNConnCh>=fNChannelsOn){
1ee299a5 395 // Protection manually set since it returns:
396 // RawData48 mod. 3 ch. 2048 signal 515
397 // to be checked with Pietro!!!!!!!!!!!!!!!!!!!!!!!
fea9b334 398 //AliDebug(2," No. of cabled channels > fNChannelsOn!!!");
ac84d2fc 399 fPosition++;
fee50699 400 return kTRUE;
1ee299a5 401 }
402 }
fee50699 403 }// ModType=1 (ADC mapping)
1ee299a5 404 }
405 fPosition++;
406 return kTRUE;
fee50699 407 } // SOD event
1ee299a5 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){
9d0b658a 418 AliError(" NO deadface after DARC data");
1ee299a5 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){
9d0b658a 436 AliError(" NO deadbeef after DARC global data");
1ee299a5 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){
fee50699 450
451 //printf("AliZDCRawStream: fSODReading = %d\n", fSODReading);
452 if(!fSODReading && !fIsMapRead) ReadChMap();
453
1ee299a5 454 // Not valid datum before the event
455 // there MUST be a NOT valid datum before the event!!!
456 if(fPosition==fDataOffset){
84d2abc2 457 //printf("\t **** ZDC data begin ****\n");
1ee299a5 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){
9d0b658a 469 AliWarning("ZDC ADC -> The not valid datum is NOT followed by an ADC header!");
1ee299a5 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();
c33b6ca6 481 }
1ee299a5 482 else{//ADC module
1ee299a5 483 // *** ADC header
ac84d2fc 484 if((fBuffer & 0x07000000) == 0x02000000){
1ee299a5 485 fIsADCHeader = kTRUE;
486 fADCNChannels = ((fBuffer & 0x00003f00)>>8);
84d2abc2 487 //printf(" AliZDCRawStream -> HEADER: ADC mod.%d has %d ch. \n",fADCModule,fADCNChannels);
1ee299a5 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
84d2abc2 496 //printf(" AliZDCRawStream -> DATA: ADC mod. %d ch. %d gain %d value %d\n",
497 // fADCModule,fADCChannel,fADCGain,fADCValue);
c93c022b 498
c33b6ca6 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 //
9d0b658a 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],
c33b6ca6 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;
9d0b658a 512 for(Int_t k=0; k<fNChannelsOn; k++){
c33b6ca6 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){
9d0b658a 521 AliWarning(Form(" No valid entry found in ADC mapping for raw data %d ADCmod. %d ch. %d gain %d\n",
c33b6ca6 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){
fea9b334 530 AliWarning(Form(" No valid detector assignment: %d",fSector[0]));
c33b6ca6 531 fRawReader->AddMajorErrorLog(kInvalidSector);
532 }
533 //
534 if(fSector[1]<0 || fSector[1]>5){
fea9b334 535 AliWarning(Form(" No valid sector assignment: %d",fSector[1]));
c33b6ca6 536 fRawReader->AddMajorErrorLog(kInvalidSector);
537 }
538 //
539 if(fADCModule<0 || fADCModule>3){
9d0b658a 540 AliError(Form(" No valid ADC module: %d",fADCModule));
c33b6ca6 541 fRawReader->AddMajorErrorLog(kInvalidADCModule);
542 }
1ee299a5 543
c33b6ca6 544 // Checking the underflow and overflow bits
545 if(fBuffer & 0x1000) fIsUnderflow = kTRUE;
546 else if (fBuffer & 0x2000) fIsOverflow = kTRUE;
547
1ee299a5 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++;
83347831 559
8309c1ab 560 return kTRUE;
561}
e42bdf10 562
563//_____________________________________________________________________________
564void AliZDCRawStream::DecodeScaler()
565{
566 // Decoding scaler event
567
568 if(!fBuffer & 0x04000000){
9d0b658a 569 AliWarning(" Scaler header corrupted");
e42bdf10 570 fIsScEventGood = kFALSE;
571 }
22fe5e66 572 Int_t scNwords = (Int_t) fScNWords;
573 if(fPosition==scNwords && fBuffer != 0x0){
9d0b658a 574 AliWarning(" Scaler trailer corrupted");
e42bdf10 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}
fee50699 589
590//_____________________________________________________________________________
591AliCDBStorage* 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//_____________________________________________________________________________
602AliZDCChMap* 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}