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