typo corrected
[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),
44455047 43 fReadOutCard(-1),
1ee299a5 44 fEvType(0),
45 fPosition(0),
46 fIsCalib(kFALSE),
47 fIsDARCHeader(kFALSE),
c3986754 48 fIsHeaderMapping(kFALSE),
1ee299a5 49 fIsChMapping(kFALSE),
50 fIsADCDataWord(kFALSE),
51 fIsADCHeader(kFALSE),
52 fIsADCEOB(kFALSE),
fee50699 53 fSODReading(kFALSE),
54 fIsMapRead(kFALSE),
219591da 55 fReadCDH(kFALSE),
44455047 56 fDeadfaceOffset(-1),
57 fDeadbeefOffset(-1),
1ee299a5 58 fDataOffset(0),
59 fModType(-1),
60 fADCModule(-1),
61 fADCNChannels(-1),
786b72f5 62 fADCChannel(-1),
cc2abffd 63 fADCValue(-1),
1ee299a5 64 fADCGain(-1),
c33b6ca6 65 fIsUnderflow(kFALSE),
66 fIsOverflow(kFALSE),
fee50699 67 fScGeo(0),
c083685e 68 fScNWords(0),
69 fScTriggerSource(0),
e42bdf10 70 fScTriggerNumber(0),
c083685e 71 fIsScEventGood(kTRUE),
72 fIsScHeaderRead(kFALSE),
73 fScStartCounter(0),
74 fScEvCounter(0),
ad3a602e 75 fIsScalerWord(kFALSE),
da090841 76 fDetPattern(0),
77 fTrigCountNWords(0),
f70a5526 78 fIsTriggerScaler(kFALSE),
da090841 79 fTrigCountStart(0),
80 fMBTrigInput(0),
81 fCentralTrigInput(0),
82 fSCentralTrigInput(0),
83 fEMDTrigInput(0),
84 fL0Received(0),
85 fMBtrig2CTP(0),
86 fCentralTrig2CTP(0),
87 fSCentralTrig2CTP(0),
88 fEMDTrig2CTP(0),
89 fTrigHistNWords(0),
f70a5526 90 fIsTriggerHistory(kFALSE),
91 fTrigHistStart(0),
da090841 92 fPileUpBit1stWord(0),
93 fL0Bit1stWord(0),
94 fCentralTrigHist(0),
95 fMBTrigHist(0),
96 fPileUpBit2ndWord(0),
97 fL0Bit2ndWord(0),
98 fSCentralTrigHist(0),
99 fEMDTrigHist(0),
58671297 100 fNChannelsOn(0),
c3986754 101 fCurrentCh(-1),
102 fCabledSignal(-1),
103 fCurrScCh(-1),
82dffa48 104 fCurrTDCCh(-1),
da090841 105 fIsADCEventGood(kTRUE),
c3986754 106 fIsL0BitSet(kTRUE),
198f612a 107 fIsPileUpEvent(kFALSE),
8c76923f 108 fIsADDChannel(kFALSE),
109 fADDADCdatum(0),
198f612a 110 fIsTDCHeaderRead(kFALSE),
111 fTDCStartCounter(0),
8c76923f 112 fIsZDCTDCHeader(kFALSE),
113 fIsZDCTDCdatum(kFALSE),
114 fZDCTDCdatum(0),
198f612a 115 fIsADDTDCHeader(kFALSE),
8c76923f 116 fIsADDTDCdatum(kFALSE),
117 fADDTDCdatum(0)
8309c1ab 118{
abf60186 119 // Create an object to read ZDC raw digits
1ee299a5 120 fRawReader->Reset();
362c9d61 121 fRawReader->Select("ZDC");
1ee299a5 122 //
58671297 123 const int kNch = 48;
124 for(Int_t i=0; i<kNch; i++){
c3986754 125 for(Int_t j=0; j<5; j++){
126 fMapADC[i][j]=-1;
82dffa48 127 if(i<32){
128 fScalerMap[i][j]=-1;
129 if(j<3) fTDCMap[i][j]=-1;
130 }
c3986754 131 }
1ee299a5 132 }
da090841 133
134 for(Int_t k=0; k<4; k++) fCPTInput[k] = 0;
1ee299a5 135
8309c1ab 136}
137
138//_____________________________________________________________________________
139AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) :
a718c993 140 TObject(stream),
c61a7285 141 fRawReader(stream.fRawReader),
1ee299a5 142 fBuffer(stream.GetRawBuffer()),
44455047 143 fReadOutCard(stream.GetReadOutCard()),
1ee299a5 144 fEvType(stream.fEvType),
145 fPosition(stream.fPosition),
146 fIsCalib(stream.fIsCalib),
147 fIsDARCHeader(stream.fIsDARCHeader),
c3986754 148 fIsHeaderMapping(stream.fIsHeaderMapping),
1ee299a5 149 fIsChMapping(stream.fIsChMapping),
150 fIsADCDataWord(stream.fIsADCDataWord),
151 fIsADCHeader(stream.fIsADCHeader),
152 fIsADCEOB(stream.fIsADCEOB),
fee50699 153 fSODReading(stream.fSODReading),
154 fIsMapRead(stream.fIsMapRead),
a27ef05f 155 fReadCDH(stream.fReadCDH),
1ee299a5 156 fDeadfaceOffset(stream.GetDeadfaceOffset()),
157 fDeadbeefOffset(stream.GetDeadbeefOffset()),
158 fDataOffset(stream.GetDataOffset()),
159 fModType(stream.GetModType()),
a718c993 160 fADCModule(stream.GetADCModule()),
1ee299a5 161 fADCNChannels(stream.GetADCNChannels()),
a718c993 162 fADCChannel(stream.GetADCChannel()),
163 fADCValue(stream.GetADCValue()),
164 fADCGain(stream.GetADCGain()),
c33b6ca6 165 fIsUnderflow(stream.fIsUnderflow),
166 fIsOverflow(stream.fIsOverflow),
e42bdf10 167 fScGeo(stream.GetScGeo()),
c083685e 168 fScNWords(stream.GetScNWords()),
169 fScTriggerSource(stream.GetScTriggerSource()),
22fe5e66 170 fScTriggerNumber(stream.fScTriggerNumber),
e42bdf10 171 fIsScEventGood(stream.fIsScEventGood),
c083685e 172 fIsScHeaderRead(stream.fIsScHeaderRead),
173 fScStartCounter(stream.fScStartCounter),
174 fScEvCounter(stream.fScEvCounter),
ad3a602e 175 fIsScalerWord(stream.fIsScalerWord),
da090841 176 fDetPattern(stream.fDetPattern),
177 fTrigCountNWords(stream.fTrigCountNWords),
f70a5526 178 fIsTriggerScaler(stream.fIsTriggerScaler),
da090841 179 fTrigCountStart(stream.fTrigCountStart),
180 fMBTrigInput(stream.fMBTrigInput),
181 fCentralTrigInput(stream.fCentralTrigInput),
182 fSCentralTrigInput(stream.fSCentralTrigInput),
183 fEMDTrigInput(stream.fEMDTrigInput),
184 fL0Received(stream.fL0Received),
185 fMBtrig2CTP(stream.fMBtrig2CTP),
186 fCentralTrig2CTP(stream.fCentralTrig2CTP),
187 fSCentralTrig2CTP(stream.fSCentralTrig2CTP),
188 fEMDTrig2CTP(stream.fEMDTrig2CTP),
189 fTrigHistNWords(stream.fTrigHistNWords),
f70a5526 190 fIsTriggerHistory(stream.fIsTriggerHistory),
191 fTrigHistStart(stream.fTrigHistStart),
da090841 192 fPileUpBit1stWord(stream.fPileUpBit1stWord),
193 fL0Bit1stWord(stream.fL0Bit1stWord),
194 fCentralTrigHist(stream.fCentralTrigHist),
195 fMBTrigHist(stream.fMBTrigHist),
196 fPileUpBit2ndWord(stream.fPileUpBit2ndWord),
197 fL0Bit2ndWord(stream.fL0Bit2ndWord),
198 fSCentralTrigHist(stream.fSCentralTrigHist),
199 fEMDTrigHist(stream.fEMDTrigHist),
9d0b658a 200 fNChannelsOn(stream.fNChannelsOn),
c3986754 201 fCurrentCh(stream.fCurrentCh),
202 fCabledSignal(stream.GetCabledSignal()),
203 fCurrScCh(stream.fCurrScCh),
82dffa48 204 fCurrTDCCh(stream.fCurrTDCCh),
da090841 205 fIsADCEventGood(stream.fIsADCEventGood),
c3986754 206 fIsL0BitSet(stream.fIsL0BitSet),
198f612a 207 fIsPileUpEvent(stream.fIsPileUpEvent),
8c76923f 208 fIsADDChannel(stream.fIsADDChannel),
209 fADDADCdatum(stream.fADDADCdatum),
198f612a 210 fIsTDCHeaderRead(stream.fIsTDCHeaderRead),
211 fTDCStartCounter(stream.fTDCStartCounter),
8c76923f 212 fIsZDCTDCHeader(stream.fIsZDCTDCHeader),
213 fIsZDCTDCdatum(stream.fIsZDCTDCdatum),
214 fZDCTDCdatum(stream.fZDCTDCdatum),
198f612a 215 fIsADDTDCHeader(stream.fIsADDTDCHeader),
8c76923f 216 fIsADDTDCdatum(stream.fIsADDTDCdatum),
217 fADDTDCdatum(stream.fADDTDCdatum)
8309c1ab 218{
abf60186 219 // Copy constructor
58671297 220 const int kNch = 48;
c0aec6f6 221 for(Int_t j=0; j<2; j++) fSector[j] = stream.GetSector(j);
58671297 222 for(Int_t i=0; i<kNch; i++){
c3986754 223 for(Int_t j=0; j<5; j++){
224 fMapADC[i][j] = stream.fMapADC[i][j];
225 if(i<32) fScalerMap[i][j] = stream.fMapADC[i][j];
226 }
1ee299a5 227 }
da090841 228
229 for(Int_t k=0; k<4; k++) fCPTInput[k] = stream.fCPTInput[k];
8309c1ab 230}
231
232//_____________________________________________________________________________
233AliZDCRawStream& AliZDCRawStream::operator = (const AliZDCRawStream&
234 /* stream */)
235{
abf60186 236 // Assignment operator
8309c1ab 237 Fatal("operator =", "assignment operator not implemented");
238 return *this;
239}
240
241//_____________________________________________________________________________
242AliZDCRawStream::~AliZDCRawStream()
243{
abf60186 244// Destructor
8309c1ab 245
246}
247
1ee299a5 248//_____________________________________________________________________________
c93c022b 249void AliZDCRawStream::ReadChMap()
250{
251 // Reading channel map
58671297 252 const int kNch = 48;
27afc0c8 253 AliDebug(2,"\t Reading ZDC ADC mapping from OCDB\n");
fee50699 254 AliZDCChMap * chMap = GetChMap();
6d653649 255 //chMap->Print("");
58671297 256 for(Int_t i=0; i<kNch; i++){
fee50699 257 fMapADC[i][0] = chMap->GetADCModule(i);
258 fMapADC[i][1] = chMap->GetADCChannel(i);
a27ef05f 259 fMapADC[i][2] = chMap->GetADCSignalCode(i);
fee50699 260 fMapADC[i][3] = chMap->GetDetector(i);
261 fMapADC[i][4] = chMap->GetSector(i);
262 }
263 fIsMapRead = kTRUE;
c93c022b 264}
265
266//_____________________________________________________________________________
1ee299a5 267void AliZDCRawStream::ReadCDHHeader()
268{
269 // Reading CDH
270 const AliRawDataHeader* header = fRawReader->GetDataHeader();
e6b990fa 271 const AliRawDataHeaderV3* headerV3 = fRawReader->GetDataHeaderV3();
272 if(!header && !headerV3) {
9d0b658a 273 AliError(" No CDH in raw data streaming");
1ee299a5 274 fRawReader->AddMajorErrorLog(kCDHError);
fee50699 275 return;
1ee299a5 276 }
e6b990fa 277
27afc0c8 278 //printf("\t AliZDCRawStream::ReadCDHHeader -> Data Size = %x\n",fRawReader->GetDataSize());
1ee299a5 279
e6b990fa 280 UChar_t message = header ? header->GetAttributes() : headerV3->GetAttributes();
27afc0c8 281 //printf("\t AliZDCRawStream::ReadCDHHeader -> Attributes %x\n",message);
1ee299a5 282
910216a3 283 if((message & 0xf0) == 0x0){ // PHYSICS RUN
58671297 284 //printf("\t PHYSICS RUN raw data found\n");
285 }
910216a3 286 else if((message & 0xf0) == 0x10){ // COSMIC RUN
65448375 287 //printf("\t STANDALONE_COSMIC RUN raw data found\n");
1ee299a5 288 }
910216a3 289 else if((message & 0xf0) == 0x20){ // PEDESTAL RUN
65448375 290 //printf("\t STANDALONE_PEDESTAL RUN raw data found\n");
1ee299a5 291 }
910216a3 292 else if((message & 0xf0) == 0x30){ // LASER RUN
65448375 293 //printf("\t STANDALONE_LASER RUN raw data found\n");
ac84d2fc 294 }
910216a3 295 else if((message & 0xf0) == 0x40){ // CALIBRATION_CENTRAL RUN
58671297 296 //printf("\t CALIBRATION_CENTRAL RUN raw data found\n");
297 }
910216a3 298 else if((message & 0xf0) == 0x50){ // CALIBRATION_SEMICENTRAL
58671297 299 //printf("\t CALIBRATION_SEMICENTRAL RUN raw data found\n");
300 }
910216a3 301 else if((message & 0xf0) == 0x60){ // CALIBRATION_MB
58671297 302 //printf("\t CALIBRATION_MB RUN raw data found\n");
303 }
910216a3 304 else if((message & 0xf0) == 0x70){ // CALIBRATION_EMD
58671297 305 //printf("\t CALIBRATION_EMD RUN raw data found\n");
306 }
44455047 307 // *** Checking the bit indicating the used readout card
308 // (the payload is different in the 2 cases!)
309 if((message & 0x08) == 0){ // ** DARC card
310 fReadOutCard = 0;
311 fIsDARCHeader = kTRUE;
198f612a 312 //AliInfo("\t ZDC readout card used: DARC");
44455047 313 }
13390187 314 else if((message & 0x08) == 0x08){ // ** ZRC card
44455047 315 fReadOutCard = 1;
198f612a 316 //AliInfo("\t ZDC readout card used: ZRC");
44455047 317 }
318
e6b990fa 319 fIsCalib = (header ? header->GetL1TriggerMessage() : headerV3->GetL1TriggerMessage()) & 0x1;
320
27afc0c8 321 //printf("\t AliZDCRawStream::ReadCDHHeader -> L1TriggerMessage %x\n",header->GetL1TriggerMessage());
322 //printf("\t AliZDCRawStream::ReadCDHHeader -> Calibration bit = %d\n",fIsCalib);
1ee299a5 323
90936733 324/* UInt_t status = header->GetStatus();
1ee299a5 325 //printf("\t AliZDCRawStream::ReadCDHHeader -> status = %d\n",status);
90936733 326 if((status & 0x000f) == 0x0001){
c083685e 327 AliDebug(2,"CDH -> DARC trg0 overlap error");
1ee299a5 328 fRawReader->AddMajorErrorLog(kDARCError);
329 }
f9f99efb 330 if((status & 0x000f) == 0x0002){
c083685e 331 AliDebug(2,"CDH -> DARC trg0 missing error");
1ee299a5 332 fRawReader->AddMajorErrorLog(kDARCError);
333 }
f9f99efb 334 if((status & 0x000f) == 0x0004){
c083685e 335 AliDebug(2,"CDH -> DARC data parity error");
1ee299a5 336 fRawReader->AddMajorErrorLog(kDARCError);
337 }
f9f99efb 338 if((status & 0x000f) == 0x0008){
c083685e 339 AliDebug(2,"CDH -> DARC ctrl parity error");
1ee299a5 340 fRawReader->AddMajorErrorLog(kDARCError);
341 }
342 //
f9f99efb 343 if((status & 0x00f0) == 0x0010){
c083685e 344 AliDebug(2,"CDH -> DARC trg unavailable");
1ee299a5 345 fRawReader->AddMajorErrorLog(kDARCError);
346 }
f9f99efb 347 if((status & 0x00f0) == 0x0020){
c3986754 348 AliDebug(2,"CDH -> DARC FEE error");
1ee299a5 349 fRawReader->AddMajorErrorLog(kDARCError);
350 }
351 //
f9f99efb 352 if((status & 0x0f00) == 0x0200){
c083685e 353 AliDebug(2,"CDH -> DARC L1 time violation");
1ee299a5 354 fRawReader->AddMajorErrorLog(kDARCError);
355 }
f9f99efb 356 if((status & 0x0f00) == 0x0400){
c3986754 357 AliDebug(2,"CDH -> DARC L2 time-out");
1ee299a5 358 fRawReader->AddMajorErrorLog(kDARCError);
359 }
f9f99efb 360 if((status & 0x0f00) == 0x0800){
c3986754 361 AliDebug(2,"CDH -> DARC prepulse time violation");
1ee299a5 362 fRawReader->AddMajorErrorLog(kDARCError);
363 }
364 //
f9f99efb 365 if((status & 0xf000) == 0x1000){
c083685e 366 AliDebug(2,"CDH -> DARC other error");
1ee299a5 367 fRawReader->AddMajorErrorLog(kDARCError);
368 }
198f612a 369 */
44455047 370
1ee299a5 371}
372
8309c1ab 373//_____________________________________________________________________________
374Bool_t AliZDCRawStream::Next()
375{
abf60186 376 // Read the next raw digit
377 // Returns kFALSE if there is no digit left
8309c1ab 378
1ee299a5 379 if(!fRawReader->ReadNextInt((UInt_t&) fBuffer)) return kFALSE;
58671297 380 const int kNch = 48;
198f612a 381 //
c3986754 382 fIsHeaderMapping = kFALSE; fIsChMapping = kFALSE;
383 fIsADCHeader = kFALSE; fIsADCDataWord = kFALSE; fIsADCEOB = kFALSE;
2d9c70ab 384 fIsZDCTDCdatum = kFALSE; fIsADDChannel = kFALSE; fIsADDTDCdatum=kFALSE;
ad3a602e 385 fIsUnderflow = kFALSE; fIsOverflow = kFALSE; fIsScalerWord = kFALSE;
58671297 386 fSector[0] = fSector[1] = -1;
da090841 387 for(Int_t kl=0; kl<4; kl++) fCPTInput[kl] = 0;
388
1ee299a5 389 fEvType = fRawReader->GetType();
219591da 390 if(fPosition==0){
391 ReadCDHHeader();
392 // Needed to read simulated raw data (temporary solution?)
393 if(!fReadCDH) fReadOutCard=1;
82dffa48 394 fCurrentCh=0; fCurrScCh=0; fCurrTDCCh=0;fNChannelsOn=0;
c3986754 395 // Ch. debug
396 //printf("\n AliZDCRawStream::Next() - ev. type %d",fEvType);
1ee299a5 397 }
c3986754 398 // Ch. debug
399 //printf("\n AliZDCRawStream::Next() - fBuffer[%d] = %x\n",fPosition, fBuffer);
400
9d0b658a 401 // *** End of ZDC event
ac84d2fc 402 if(fBuffer == 0xcafefade){
27afc0c8 403 //printf("\n AliZDCRawStream::Next() ***** End of ZDC event *****\n\n");
ac84d2fc 404 return kFALSE;
405 }
1ee299a5 406
407 // -------------------------------------------
1069e28d 408 // --- DARC header
1ee299a5 409 // -------------------------------------------
fee50699 410 // If the CDH has been read then
411 // the DARC header must follow
44455047 412 if(fReadOutCard==0 && fIsDARCHeader){
84d2abc2 413 //printf("\t ---- DARC header ----\n");
1ee299a5 414 if(fIsCalib){
415 fDeadfaceOffset = 9;
416 fDeadbeefOffset = 25;
417 }
418 else{
419 fDeadfaceOffset = 1;
420 fDeadbeefOffset = 7;
421 }
422 fDataOffset = 1+fDeadbeefOffset;
423 fIsDARCHeader = kFALSE;
abf60186 424 }
1ee299a5 425
44455047 426 // ---------------------------------------------
427 // --- Start of data event (SOD) ---
428 // --- decoding mapping of connected ADC ch. ---
429 // ---------------------------------------------
fee50699 430 // In the SOD event ADC ch. mapping is written
1e85619e 431 if(fEvType==10){
432 if(fSODReading){
fee50699 433
13390187 434 if(fPosition>=fDataOffset){
c3986754 435 if((fBuffer&0xff000001) == 0xff000001){ // ************** Mapping
8700404e 436 // DARC 1st datum @ fDataOffset+1 \ ZRC 1st valid datum @ fDataOffset=0
13390187 437 if((fPosition==fDataOffset+1) || (fPosition==fDataOffset)){
f9bf3278 438 printf("\n\n ------ AliZDCRawStream -> Reading mapping from StartOfData event ------\n");
82dffa48 439 fCurrentCh=0; fCurrScCh=0; fCurrTDCCh=0;
6006df88 440 }
1ee299a5 441 else{
f9bf3278 442 printf(" ------ AliZDCRawStream -> End of ZDC StartOfData event ------\n\n");
1e85619e 443 fSODReading = kFALSE;
fee50699 444 return kFALSE;
1ee299a5 445 }
446 }
c3986754 447 else if((fBuffer&0xff000002) == 0xff000002){ // ************** Threshold settings
448 fPosition++;
27afc0c8 449 return kFALSE; // !!!!!!!!!!!!!!!!!!!!! For the moment thresholds are not read
c3986754 450 }
451 else if((fBuffer&0x80000000)>>31 == 1){ // --- Mapping header
452 fIsHeaderMapping = kTRUE;
453 fADCModule = ((fBuffer & 0x7f000000)>>24); // GEO address!!!
454 fModType = ((fBuffer & 0x7ff00)>>8);
455 fADCNChannels = (fBuffer & 0xff); // # of channels following the header
1ee299a5 456 //
c083685e 457 printf(" ******** GEO %d, mod. type %d, #ch. %d\n",fADCModule,fModType,fADCNChannels);
6006df88 458 }
c3986754 459 else if((fBuffer&0x80000000)>>31 == 0){ // --- Mapping channel
460 fADCChannel = ((fBuffer & 0x3fff0000)>>16);
461 fCabledSignal = (fBuffer&0xffff);
462 //
27afc0c8 463 if(fModType == kV965){ // ******** ADCs ********************************
480ac371 464 // Channel signal
465 if((fBuffer&0x40000000)>>30==0 && fADCModule<=kLastADCGeo){ // *ZDC* high range chain ADC
c3986754 466 fIsChMapping = kTRUE;
467 fMapADC[fCurrentCh][0] = fADCModule;
468 fMapADC[fCurrentCh][1] = fADCChannel;
469 fMapADC[fCurrentCh][2] = fCabledSignal;
470 // - No. of channels on
471 fNChannelsOn++;
472 //
473 // Determining detector and sector
474 // -----------------------------------------
475 // For the decoding of the following lines
476 // look the enum in AliZDCRawStream.h file
477 // -----------------------------------------
478 if((fCabledSignal>=2 && fCabledSignal<=6) || (fCabledSignal>=26 && fCabledSignal<=30)
479 || fCabledSignal==24 || fCabledSignal==48){
480 fMapADC[fCurrentCh][3] = 4; //ZNA
481 //
8c76923f 482 if(fCabledSignal==kZNAC || fCabledSignal==kZNACoot) fMapADC[fCurrentCh][4]=0;
483 else if(fCabledSignal==kZNA1 || fCabledSignal==kZNA1oot) fMapADC[fCurrentCh][4]=1;
484 else if(fCabledSignal==kZNA2 || fCabledSignal==kZNA2oot) fMapADC[fCurrentCh][4]=2;
485 else if(fCabledSignal==kZNA3 || fCabledSignal==kZNA3oot) fMapADC[fCurrentCh][4]=3;
486 else if(fCabledSignal==kZNA4 || fCabledSignal==kZNA4oot) fMapADC[fCurrentCh][4]=4;
487 else if(fCabledSignal==kZDCAMon || fCabledSignal==kZDCAMonoot) fMapADC[fCurrentCh][4]=5; //Reference PTM
c3986754 488 }
489 else if((fCabledSignal>=7 && fCabledSignal<=11) || (fCabledSignal>=31 && fCabledSignal<=35)){
490 fMapADC[fCurrentCh][3] = 5; //ZPA
491 //
8c76923f 492 if(fCabledSignal==kZPAC || fCabledSignal==kZPACoot) fMapADC[fCurrentCh][4]=0;
493 else if(fCabledSignal==kZPA1 || fCabledSignal==kZPA1oot) fMapADC[fCurrentCh][4]=1;
494 else if(fCabledSignal==kZPA2 || fCabledSignal==kZPA2oot) fMapADC[fCurrentCh][4]=2;
495 else if(fCabledSignal==kZPA3 || fCabledSignal==kZPA3oot) fMapADC[fCurrentCh][4]=3;
496 else if(fCabledSignal==kZPA4 || fCabledSignal==kZPA4oot) fMapADC[fCurrentCh][4]=4;
c3986754 497 }
498 else if((fCabledSignal>=12 && fCabledSignal<=16) || (fCabledSignal>=36 && fCabledSignal<=40)
499 || fCabledSignal==25 || fCabledSignal==49){
500 fMapADC[fCurrentCh][3] = 1; //ZNC
501 //
8c76923f 502 if(fCabledSignal==kZNCC || fCabledSignal==kZNCCoot) fMapADC[fCurrentCh][4]=0;
503 else if(fCabledSignal==kZNC1 || fCabledSignal==kZNC1oot) fMapADC[fCurrentCh][4]=1;
504 else if(fCabledSignal==kZNC2 || fCabledSignal==kZNC2oot) fMapADC[fCurrentCh][4]=2;
505 else if(fCabledSignal==kZNC3 || fCabledSignal==kZNC3oot) fMapADC[fCurrentCh][4]=3;
506 else if(fCabledSignal==kZNC4 || fCabledSignal==kZNC4oot) fMapADC[fCurrentCh][4]=4;
507 else if(fCabledSignal==kZDCCMon || fCabledSignal==kZDCCMonoot) fMapADC[fCurrentCh][4]=5; //Reference PTM
c3986754 508 }
509 else if((fCabledSignal>=17 && fCabledSignal<=21) || (fCabledSignal>=41 && fCabledSignal<=45)){
510 fMapADC[fCurrentCh][3] = 2; //ZPC
511 //
8c76923f 512 if(fCabledSignal==kZPCC || fCabledSignal==kZPCCoot) fMapADC[fCurrentCh][4]=0;
513 else if(fCabledSignal==kZPC1 || fCabledSignal==kZPC1oot) fMapADC[fCurrentCh][4]=1;
514 else if(fCabledSignal==kZPC2 || fCabledSignal==kZPC2oot) fMapADC[fCurrentCh][4]=2;
515 else if(fCabledSignal==kZPC3 || fCabledSignal==kZPC3oot) fMapADC[fCurrentCh][4]=3;
516 else if(fCabledSignal==kZPC4 || fCabledSignal==kZPC4oot) fMapADC[fCurrentCh][4]=4;
c3986754 517 }
518 else if(fCabledSignal==22 || fCabledSignal==23 || fCabledSignal==46 || fCabledSignal==47){
519 fMapADC[fCurrentCh][3] = 3; // ZEM
520 //
8c76923f 521 if(fCabledSignal==kZEM1 || fCabledSignal==kZEM1oot) fMapADC[fCurrentCh][4]=1;
522 else if(fCabledSignal==kZEM2 || fCabledSignal==kZEM2oot) fMapADC[fCurrentCh][4]=2;
c3986754 523 }
524 //Ch. debug
525 //printf("\tADC mod. %d ch. %d signal %d ",fADCModule,fADCChannel,fCabledSignal);
526 //printf(" det. %d sec. %d\n",fMapADC[fCurrentCh][3],fMapADC[fCurrentCh][4]);
527 //
528 fCurrentCh++;
529 //
530 } // high range channels
531 }// ModType=1 (ADC mapping)
27afc0c8 532 else if(fModType == kV830){ // ******** VME scaler **************************
c3986754 533 fIsChMapping = kTRUE;
534 fScalerMap[fCurrScCh][0] = fADCModule;
535 fScalerMap[fCurrScCh][1] = fADCChannel;
536 fScalerMap[fCurrScCh][2] = fCabledSignal;
c93c022b 537 //
538 // Determining detector and sector
539 // -----------------------------------------
540 // For the decoding of the following lines
541 // look the enum in AliZDCRawStream.h file
542 // -----------------------------------------
c3986754 543 // NOT CONSIDERING OUT OF TIME OR REFERENCE SIGNALS FOR SCALER!!!!!
90936733 544 if((fCabledSignal>=2 && fCabledSignal<=6) ||
545 (fCabledSignal>=61 && fCabledSignal<=65)){
c3986754 546 fScalerMap[fCurrScCh][3] = 4; //ZNA
c93c022b 547 //
8c76923f 548 if(fCabledSignal==kZNAC || fCabledSignal==kZNACD) fScalerMap[fCurrScCh][4]=0;
549 else if(fCabledSignal==kZNA1 || fCabledSignal==kZNA1D) fScalerMap[fCurrScCh][4]=1;
550 else if(fCabledSignal==kZNA2 || fCabledSignal==kZNA2D) fScalerMap[fCurrScCh][4]=2;
551 else if(fCabledSignal==kZNA3 || fCabledSignal==kZNA3D) fScalerMap[fCurrScCh][4]=3;
552 else if(fCabledSignal==kZNA4 || fCabledSignal==kZNA4D) fScalerMap[fCurrScCh][4]=4;
c93c022b 553 }
90936733 554 else if((fCabledSignal>=7 && fCabledSignal<=11) ||
555 (fCabledSignal>=66 && fCabledSignal<=70)){
c3986754 556 fScalerMap[fCurrScCh][3] = 5; //ZPA
c93c022b 557 //
8c76923f 558 if(fCabledSignal==kZPAC || fCabledSignal==kZPACD) fScalerMap[fCurrScCh][4]=0;
559 else if(fCabledSignal==kZPA1 || fCabledSignal==kZPA1D) fScalerMap[fCurrScCh][4]=1;
560 else if(fCabledSignal==kZPA2 || fCabledSignal==kZPA2D) fScalerMap[fCurrScCh][4]=2;
561 else if(fCabledSignal==kZPA3 || fCabledSignal==kZPA3D) fScalerMap[fCurrScCh][4]=3;
562 else if(fCabledSignal==kZPA4 || fCabledSignal==kZPA4D) fScalerMap[fCurrScCh][4]=4;
c93c022b 563 }
90936733 564 else if((fCabledSignal>=12 && fCabledSignal<=16) ||
565 (fCabledSignal>=71 && fCabledSignal<=75)){
c3986754 566 fScalerMap[fCurrScCh][3] = 1; //ZNC
c93c022b 567 //
8c76923f 568 if(fCabledSignal==kZNCC || fCabledSignal==kZNCCD) fScalerMap[fCurrScCh][4]=0;
569 else if(fCabledSignal==kZNC1 || fCabledSignal==kZNC1D) fScalerMap[fCurrScCh][4]=1;
570 else if(fCabledSignal==kZNC2 || fCabledSignal==kZNC2D) fScalerMap[fCurrScCh][4]=2;
571 else if(fCabledSignal==kZNC3 || fCabledSignal==kZNC3D) fScalerMap[fCurrScCh][4]=3;
572 else if(fCabledSignal==kZNC4 || fCabledSignal==kZNC4D) fScalerMap[fCurrScCh][4]=4;
c93c022b 573 }
90936733 574 else if((fCabledSignal>=17 && fCabledSignal<=21) ||
575 (fCabledSignal>=76 && fCabledSignal<=80)){
c3986754 576 fScalerMap[fCurrScCh][3] = 2; //ZPC
c93c022b 577 //
8c76923f 578 if(fCabledSignal==kZPCC || fCabledSignal==kZPCCD) fScalerMap[fCurrScCh][4]=0;
579 else if(fCabledSignal==kZPC1 || fCabledSignal==kZPC1D) fScalerMap[fCurrScCh][4]=1;
580 else if(fCabledSignal==kZPC2 || fCabledSignal==kZPC2D) fScalerMap[fCurrScCh][4]=2;
581 else if(fCabledSignal==kZPC3 || fCabledSignal==kZPC3D) fScalerMap[fCurrScCh][4]=3;
582 else if(fCabledSignal==kZPC4 || fCabledSignal==kZPC4D) fScalerMap[fCurrScCh][4]=4;
c93c022b 583 }
480ac371 584 else if(fCabledSignal==22 || fCabledSignal==23 ||
585 fCabledSignal==81 || fCabledSignal==82){
c3986754 586 fScalerMap[fCurrScCh][3] = 3; // ZEM
c93c022b 587 //
8c76923f 588 if(fCabledSignal==kZEM1 || fCabledSignal==kZEM1D) fScalerMap[fCurrScCh][4]=1;
589 else if(fCabledSignal==kZEM2 || fCabledSignal==kZEM2D) fScalerMap[fCurrScCh][4]=2;
c93c022b 590 }
c3986754 591 // Ch debug.
a27ef05f 592 /*printf("\t VME scaler mod. %d ch. %d, signal %d",fScalerMap[fCurrScCh][0],fADCChannel,fCabledSignal);
82dffa48 593 if(fCabledSignal!=0 && fCabledSignal!=1) printf(" det. %d sec. %d\n",fScalerMap[fCurrScCh][3],fScalerMap[fCurrScCh][4]);
a27ef05f 594 else printf(" Signal void/not connected\n");*/
c3986754 595
596 fCurrScCh++;
597 }
82dffa48 598 else if(fModType==KV1290 && fADCModule==kZDCTDCGeo){ // ******** ZDC TDC **************************
599 fIsChMapping = kTRUE;
600 fTDCMap[fCurrTDCCh][0] = fADCModule;
601 fTDCMap[fCurrTDCCh][1] = fADCChannel;
602 fTDCMap[fCurrTDCCh][2] = fCabledSignal;
603
604 fCurrTDCCh++;
605
a27ef05f 606 // Ch debug.
607 //printf("\tZDC TDC: mod. %d ch. %d, signal %d\n",fADCModule,fADCChannel,fCabledSignal);
82dffa48 608 }
27afc0c8 609 /*else if(fModType == kTRG){ // **** scalers from trigger card
c3986754 610 //printf("\t Trigger scaler mod. %d ch. %d, signal %d\n",fADCModule,fADCChannel,fCabledSignal);
611 }
27afc0c8 612 else if(fModType == kTRGI){ // **** trigger history from trigger card
c3986754 613 //printf("\t Trigger card ch. %d, signal %d\n",fADCChannel,fCabledSignal);
614 }
27afc0c8 615 else if(fModType == kPU){ // **** pattern unit
c3986754 616 //printf("\t P.U. mod. %d ch. %d, signal %d\n",fADCModule,fADCChannel,fCabledSignal);
27afc0c8 617 }*/
c3986754 618 }//reading channel mapping
1ee299a5 619 }
1e85619e 620 } // if fSODREading
621 fPosition++;
622 return kTRUE;
44455047 623 } // ------------------------------- SOD event
1ee299a5 624
625 // -------------------------------------------
626 // --- DARC data
627 // -------------------------------------------
a5747d8f 628 if(fPosition<fDeadfaceOffset && fReadOutCard==0){
629 fPosition++;
630 return kTRUE;
631 }
632 else if(fPosition==fDeadfaceOffset && fReadOutCard==0){
633 if(fBuffer != 0xdeadface){
a44b6e36 634 //AliWarning(" NO deadface after DARC data");
a5747d8f 635 fRawReader->AddMajorErrorLog(kDARCError);
636 }
637 else{
1ee299a5 638 fPosition++;
639 return kTRUE;
640 }
a5747d8f 641 }
642 else if(fPosition>fDeadfaceOffset && fPosition<fDeadbeefOffset && fReadOutCard==0){
643 fPosition++;
644 return kTRUE;
645 }
646 else if(fPosition==fDeadbeefOffset && fReadOutCard==0){
647 if(fBuffer != 0xdeadbeef){
a44b6e36 648 //AliWarning(" NO deadbeef after DARC global data");
a5747d8f 649 fRawReader->AddMajorErrorLog(kDARCError);
650 fPosition++;
651 return kFALSE;
1ee299a5 652 }
a5747d8f 653 else{
1ee299a5 654 fPosition++;
655 return kTRUE;
656 }
1e85619e 657 } // ------------------------------- End of DARC data
44455047 658
1e85619e 659 // ---------------------------------------------
1ee299a5 660 // --- ZDC data
c3986754 661 // --- ADCs + VME scaler + trigger card + P.U.
1e85619e 662 // ---------------------------------------------
1ee299a5 663 else if(fPosition>=fDataOffset){
fee50699 664
fee50699 665 if(!fSODReading && !fIsMapRead) ReadChMap();
666
44455047 667 // !!!!!!!!!!!!!!! DARC readout card only !!!!!!!!!!!
1ee299a5 668 // Not valid datum before the event
669 // there MUST be a NOT valid datum before the event!!!
44455047 670 if(fReadOutCard==0){
a5747d8f 671 if(fPosition==fDataOffset){
44455047 672 //printf("\t **** ZDC data begin ****\n");
673 if((fBuffer & 0x07000000) != 0x06000000){
674 fRawReader->AddMajorErrorLog(kZDCDataError);
675 }
83534754 676 //else if((fBuffer & 0x07000000) == 0x06000001){ // Corrupted event!!!
677 // fIsADCEventGood = kFALSE;
678 //}
c3986754 679 }
1ee299a5 680
44455047 681 // If the not valid datum isn't followed by the 1st ADC header
682 // the event is corrupted (i.e., 2 gates arrived before trigger)
a5747d8f 683 else if(fPosition==fDataOffset+1){
44455047 684 if((fBuffer & 0x07000000) != 0x02000000){
685 AliWarning("ZDC ADC -> The not valid datum is NOT followed by an ADC header!");
686 fRawReader->AddMajorErrorLog(kZDCDataError);
687 fIsADCEventGood = kFALSE;
688 fPosition++;
689 return kFALSE;
690 }
1ee299a5 691 }
692 }
693
c3986754 694 // Get geo address of current word
8c76923f 695 if(fIsTDCHeaderRead && fIsZDCTDCHeader) fADCModule = kZDCTDCGeo;
696 else if(fIsTDCHeaderRead && fIsADDTDCHeader) fADCModule = kADDTDCGeo;
697 else fADCModule = (Int_t) ((fBuffer & 0xf8000000)>>27);
c083685e 698
c3986754 699 // ************************************ ADC MODULES ************************************
f9bf3278 700 if(fADCModule>=kFirstADCGeo && fADCModule<=kLastADCGeo &&
701 !fIsTriggerHistory && !fIsScHeaderRead && !fIsTriggerScaler){
1ee299a5 702 // *** ADC header
ac84d2fc 703 if((fBuffer & 0x07000000) == 0x02000000){
1ee299a5 704 fIsADCHeader = kTRUE;
705 fADCNChannels = ((fBuffer & 0x00003f00)>>8);
58671297 706 //printf(" AliZDCRawStream -> ADC HEADER: mod.%d has %d ch. \n",fADCModule,fADCNChannels);
1ee299a5 707 }
708 // *** ADC data word
709 else if((fBuffer & 0x07000000) == 0x00000000){
710 fIsADCDataWord = kTRUE;
711 fADCChannel = ((fBuffer & 0x1e0000) >> 17);
712 fADCGain = ((fBuffer & 0x10000) >> 16);
713 fADCValue = (fBuffer & 0xfff);
c3986754 714 //
715 //printf(" AliZDCRawStream -> ADC DATUM: mod. %d ch. %d gain %d value %d\n",
f9bf3278 716 //fADCModule,fADCChannel,fADCGain,fADCValue);
c93c022b 717
c33b6ca6 718 // Checking if the channel map for the ADCs has been provided/read
719 if(fMapADC[0][0]==-1){
720 printf("\t ATTENTION!!! No ADC mapping has been found/provided!!!\n");
721 return kFALSE;
722 }
723 //
58671297 724 /*for(Int_t ci=0; ci<kNch; ci++){
9d0b658a 725 printf(" %d mod %d ch %d det %d sec %d\n",ci,fMapADC[ci][0],
c33b6ca6 726 fMapADC[ci][1], fMapADC[ci][3], fMapADC[ci][4]);
727 }*/
728
729 // Scan of the map to assign the correct volumes
730 Int_t foundMapEntry = kFALSE;
58671297 731 for(Int_t k=0; k<kNch; k++){
c33b6ca6 732 if(fADCModule==fMapADC[k][0] && fADCChannel==fMapADC[k][1]){
733 fSector[0] = fMapADC[k][3];
734 fSector[1] = fMapADC[k][4];
735 foundMapEntry = kTRUE;
736 break;
737 }
738 }
b6cab1d8 739 if(foundMapEntry==kFALSE && fEvType==7){
c3986754 740 AliWarning(Form(" No valid entry in ADC mapping for raw data %d ADCmod. %d ch. %d\n",
741 fPosition,fADCModule,fADCChannel));
c33b6ca6 742 }
a27ef05f 743
c33b6ca6 744 // Final checks
b6cab1d8 745 if(foundMapEntry==kTRUE && fEvType==7){
6d653649 746 if(fSector[0]<1 || fSector[0]>5){
747 AliWarning(Form(" No valid detector assignment: %d",fSector[0]));
748 fRawReader->AddMajorErrorLog(kInvalidSector);
749 }
750 //
751 if(fSector[1]<0 || fSector[1]>5){
752 AliWarning(Form(" No valid sector assignment: %d",fSector[1]));
753 fRawReader->AddMajorErrorLog(kInvalidSector);
754 }
755 //
756 if(fADCModule<0 || fADCModule>3){
757 AliError(Form(" No valid ADC module: %d",fADCModule));
758 fRawReader->AddMajorErrorLog(kInvalidADCModule);
759 }
c33b6ca6 760 }
1ee299a5 761
c33b6ca6 762 // Checking the underflow and overflow bits
763 if(fBuffer & 0x1000) fIsUnderflow = kTRUE;
764 else if (fBuffer & 0x2000) fIsOverflow = kTRUE;
765
1ee299a5 766 }//ADC data word
767 // *** ADC EOB
768 else if((fBuffer & 0x07000000) == 0x04000000){
769 fIsADCEOB = kTRUE;
f9bf3278 770 //printf(" AliZDCRawStream -> ADC EOB --------------------------\n");
1ee299a5 771 }
c083685e 772 }//ADC module
25930b52 773 // ********************************* ADD ADC *********************************
198f612a 774 else if(fADCModule == kADDADCGeo){
25930b52 775 // *** ADC header
776 if((fBuffer & 0x07000000) == 0x02000000){
777 fIsADCHeader = kTRUE;
778 fADCNChannels = ((fBuffer & 0x00003f00)>>8);
198f612a 779 //printf(" AliZDCRawStream -> ADD ADC HEADER: mod.%d has %d ch. \n",fADCModule,fADCNChannels);
25930b52 780 }
781 // *** ADC data word
782 else if((fBuffer & 0x07000000) == 0x00000000){
1fd73fdc 783 fIsADDChannel = kTRUE;
25930b52 784 fADCChannel = ((fBuffer & 0x1e0000) >> 17);
785 fADCGain = ((fBuffer & 0x10000) >> 16);
786 fADCValue = (fBuffer & 0xfff);
787 //
788 //printf(" ADD ADC DATUM -> mod. %d ch. %d gain %d value %d\n",
789 // fADCModule,fADCChannel,fADCGain,fADCValue);
790 }
198f612a 791 // *** ADC EOB
792 else if((fBuffer & 0x07000000) == 0x04000000){
793 fIsADCEOB = kTRUE;
f9bf3278 794 //printf(" AliZDCRawStream -> ADD ADC EOB --------------------------\n");
198f612a 795 }
796 }
8c76923f 797 // ********************************* TDC *********************************
798 else if(fADCModule==kTDCFakeGeo && fIsTDCHeaderRead==kFALSE){
799 // *** TDC header
198f612a 800 fIsTDCHeaderRead = kTRUE;
801 fTDCStartCounter = fPosition;
8c76923f 802 // GEO address from TDC header
803 fADCModule = (Int_t) (fBuffer & 0x1f);
804 if(fADCModule==kZDCTDCGeo){ // *** ZDC TDC
805 fIsZDCTDCHeader = kTRUE;
806 //Ch. debug
f9bf3278 807 //printf(" AliZDCRawStream -> ZDC TDC header: mod.%d\n",fADCModule);
198f612a 808 }
82dffa48 809 else if(fADCModule==kADDTDCGeo){ // *** ADD TDC
8c76923f 810 fIsADDTDCHeader = kTRUE;
811 //Ch. debug
812 //printf(" AliZDCRawStream -> ADD TDC: mod.%d\n",fADCModule);
198f612a 813 }
8c76923f 814 }
da090841 815 // ********************************* VME SCALER HEADER *********************************
c3986754 816 else if(fADCModule == kScalerGeo){
c083685e 817 if(fBuffer & 0x04000000 && fIsScHeaderRead==kFALSE){ // *** Scaler header
818 fScGeo = (fBuffer & 0xf8000000)>>27;
819 fScNWords = (fBuffer & 0x00fc0000)>>18;
820 fScTriggerSource = (fBuffer & 0x00030000)>>16;
821 fScTriggerNumber = (fBuffer & 0x0000ffff);
822 fIsScHeaderRead = kTRUE;
f70a5526 823 fScStartCounter = fPosition;
c083685e 824 //Ch. debug
f70a5526 825 //printf(" AliZDCRawStream -> VME SCALER HEADER: geo %d Nwords %d TrigSource %d TrigNo. %d\n",
c083685e 826 // fScGeo,fScNWords,fScTriggerSource,fScTriggerNumber);
827 }
27d1ff1f 828 // Commented by C.O. & M.G. (23/09/2011)
829 //else if(!(fBuffer & 0x04000000) && fIsScHeaderRead==kFALSE){
830 // fIsScEventGood = kFALSE;
831 //}
c3986754 832 }
da090841 833 // *********************************** PATTERN UNIT ***********************************
c3986754 834 else if(fADCModule == kPUGeo){
835 // still to be implemented!!! Not yet in data!!!
da090841 836 fDetPattern = (fBuffer & 0x0000003f);
f70a5526 837 // Ch. debug
838 //printf(" AliZDCRawStream -> Pattern Unit\n");
839
c3986754 840 }
da090841 841 // ******************************** TRIGGER CARD COUNTS ********************************
c3986754 842 else if(fADCModule == kTrigScales){
f70a5526 843 if(fIsTriggerScaler == kFALSE){
844 fTrigCountNWords = (Int_t) ((fBuffer & 0xfc0000)>>17);
da090841 845 fTrigCountStart = fPosition;
f70a5526 846 fIsTriggerScaler = kTRUE;
da090841 847 }
f70a5526 848 // Ch. debug
849 //printf(" AliZDCRawStream -> Trigger Scaler header\n");
c3986754 850 }
da090841 851 // ********************************** TRIGGER HISTORY **********************************
c3986754 852 else if(fADCModule == kTrigHistory){
f70a5526 853 if(fIsTriggerHistory == kFALSE){
854 fTrigHistNWords = (Int_t) ((fBuffer & 0xfc0000)>>17);
855 fTrigHistStart = fPosition;
856 fIsTriggerHistory = kTRUE;
da090841 857 }
f70a5526 858 // Ch. debug
859 //printf(" AliZDCRawStream -> Trigger History header\n");
860
c3986754 861 }
da090841 862 // ********************************** VME SCALER DATA **********************************
c3986754 863 // Reading VME scaler data
c083685e 864 if(fIsScHeaderRead && fPosition>=fScStartCounter+1){ // *** Scaler word
27d1ff1f 865 fADCModule=kScalerGeo;
866 fIsADCDataWord=kFALSE;
867 fIsScalerWord=kTRUE;
c083685e 868 fScEvCounter = fBuffer;
869 Int_t nWords = (Int_t) (fScNWords);
870 if(fPosition == fScStartCounter+nWords) fIsScHeaderRead = kFALSE;
871 //Ch. debug
27d1ff1f 872 //printf(" AliZDCRawStream -> scaler datum %x \n", fScEvCounter);
c083685e 873 }
198f612a 874 // ********************************** ZDC TDC DATA **********************************
875 // ZDC TDC data
8c76923f 876 if(fIsTDCHeaderRead && fIsZDCTDCHeader && fPosition>=fTDCStartCounter+1){
877 fIsADCDataWord=kFALSE; fIsScalerWord=kFALSE;
878 if(((fBuffer & 0xf0000000)==0x00000000) && (((fBuffer & 0x08000000) >> 27) == 0)){ // TDC datum
879 fADCChannel = (Int_t) ((fBuffer & 0x3e00000) >> 21);
2d9c70ab 880 fIsZDCTDCdatum = kTRUE;
8c76923f 881 fZDCTDCdatum = (Int_t) (fBuffer & 0x1fffff);
882 // Ch. debug
883 //printf(" AliZDCRawStream -> ZDC TDC mod. %d ch. %d datum %d\n",fADCModule,fADCChannel,fZDCTDCdatum);
884 }
885 if(((fBuffer & 0xf0000000) == 0x80000000) && ((fBuffer & 0x08000000) >> 27) == 0){
886 // Trailer
887 fIsTDCHeaderRead = kFALSE;
888 // Ch. debug
889 //printf(" AliZDCRawStream -> ZDC TDC global trailer\n");
890 }
891 }
892 // ********************************** ADD TDC DATA **********************************
893 // ADD TDC data
894 if(fIsTDCHeaderRead && fIsADDTDCHeader && fPosition>=fTDCStartCounter+1){
198f612a 895 fIsADCDataWord=kFALSE; fIsScalerWord=kFALSE;
8c76923f 896 if(((fBuffer & 0xf0000000)==0x00000000) && (((fBuffer & 0x08000000) >> 27) == 0)){ // TDC datum
897 fADCChannel = (Int_t) ((fBuffer & 0x3e00000) >> 21);
2d9c70ab 898 fIsADDTDCdatum = kTRUE;
8c76923f 899 fADDTDCdatum = (Int_t) (fBuffer & 0x1fffff);
900 // Ch. debug
901 //printf(" AliZDCRawStream -> ADD TDC mod. %d ch. %d datum %d\n",fADCModule,fADCChannel,fADDTDCdatum);
902 }
198f612a 903 if(((fBuffer & 0xf0000000) == 0x80000000) && ((fBuffer & 0x08000000) >> 27) == 0){
8c76923f 904 // Trailer
198f612a 905 fIsTDCHeaderRead = kFALSE;
906 // Ch. debug
8c76923f 907 //printf(" AliZDCRawStream -> ADD TDC global trailer\n");
198f612a 908 }
909 }
f70a5526 910 // ******************************** TRIGGER SCALER DATA ********************************
911 // Reading trigger scaler data
912 if(fIsTriggerScaler && fPosition>=fTrigCountStart+1){
8700404e 913 fADCModule = kTrigScales; fIsADCDataWord = kFALSE;
f70a5526 914 if(fPosition == fTrigCountStart+1) fMBTrigInput = fBuffer;
915 else if(fPosition == fTrigCountStart+2) fCentralTrigInput = fBuffer;
916 else if(fPosition == fTrigCountStart+3) fSCentralTrigInput = fBuffer;
917 else if(fPosition == fTrigCountStart+4) fEMDTrigInput = fBuffer;
918 else if(fPosition == fTrigCountStart+5) fL0Received = fBuffer;
919 else if(fPosition == fTrigCountStart+6) fMBtrig2CTP = fBuffer;
920 else if(fPosition == fTrigCountStart+7) fCentralTrig2CTP = fBuffer;
921 else if(fPosition == fTrigCountStart+8) fSCentralTrig2CTP = fBuffer;
922 else if(fPosition == fTrigCountStart+9){
923 fEMDTrig2CTP = fBuffer;
924 fIsTriggerScaler = kFALSE;
925 }
926 // Ch. debug
927 //printf(" AliZDCRawStream -> Trigger Scaler datum %d\n", fPosition-fTrigCountStart);
928 }
929 // ******************************* TRIGGER HISTORY WORDS ******************************
930 // Reading trigger history
931 if(fIsTriggerHistory && fPosition>=fTrigHistStart+1){
8700404e 932 fADCModule = kTrigHistory; fIsADCDataWord = kFALSE;
f70a5526 933 if(fPosition == fTrigHistStart+1){
934 fPileUpBit1stWord = (fBuffer & 0x80000000) >> 31;
935 fL0Bit1stWord = (fBuffer & 0x40000000) >> 30;
936 fCentralTrigHist = (fBuffer & 0x3fff8000) >> 14;
937 fMBTrigHist = (fBuffer & 0x00007fff);
938 //
939 fCPTInput[0] = (fBuffer & 0x00000080) >> 6; // MB bit
940 fCPTInput[1] = (fBuffer & 0x00400000) >> 21; // CENTRAL bit
941 }
942
943 else if(fPosition == fTrigHistStart+fTrigHistNWords){
944 fPileUpBit2ndWord = (fBuffer & 0x80000000) >> 31;
945 fL0Bit2ndWord = (fBuffer & 0x40000000) >> 30;
946 fSCentralTrigHist = (fBuffer & 0x3fff8000) >> 14;
947 fEMDTrigHist = (fBuffer & 0x00007fff);
948 //
949 fCPTInput[2] = (fBuffer & 0x00000080) >> 6; // SEMICENTRAL bit
950 fCPTInput[3] = (fBuffer & 0x00400000) >> 21; // EMD bit
951 //
952 fIsTriggerHistory = kFALSE;
953
954 // Checking if the event is good
955 // (1) both history word pile up bits must be = 0
956 if(fPileUpBit1stWord==0 && fPileUpBit2ndWord==0) fIsPileUpEvent = kFALSE;
957 else{
958 fIsPileUpEvent = kTRUE;
959 printf(" AliZDCRawStream -> PILE UP EVENT: bitPileUp0 %d bitPileUp1 %d\n",
13390187 960 fPileUpBit1stWord, fPileUpBit2ndWord);
f70a5526 961 }
962 // (2) both history word L0 bits must be = 1
963 if(fL0Bit1stWord==1 && fL0Bit2ndWord==1) fIsL0BitSet = kTRUE;
964 else{
965 fIsL0BitSet = kFALSE;
966 printf(" AliZDCRawStream -> L0 wrongly set: bitL0word0 %d bitL0word1 %d\n",
967 fL0Bit1stWord, fL0Bit2ndWord);
968 }
969 }
970 // Ch. debug
27d1ff1f 971 //printf(" AliZDCRawStream -> Trigger history word[%d] %x\n", fPosition, fBuffer);
f70a5526 972 }
1ee299a5 973
974 }
f70a5526 975
1ee299a5 976 fPosition++;
83347831 977
8309c1ab 978 return kTRUE;
979}
e42bdf10 980
981//_____________________________________________________________________________
fee50699 982AliCDBStorage* AliZDCRawStream::SetStorage(const char *uri)
983{
984 // Setting the storage
985
986 AliCDBStorage *storage = AliCDBManager::Instance()->GetStorage(uri);
987
988 return storage;
989}
990
991
992//_____________________________________________________________________________
993AliZDCChMap* AliZDCRawStream::GetChMap() const
994{
995
996 // Getting calibration object for ZDC
997
998 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/ChMap");
999 if(!entry) AliFatal("No calibration data loaded!");
1000
1001 AliZDCChMap *calibdata = dynamic_cast<AliZDCChMap*> (entry->GetObject());
1002 if(!calibdata) AliFatal("Wrong calibration object in calibration file!");
1003
1004 return calibdata;
1005}