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