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