Compilation warning removed
[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
29#include "AliZDCRawStream.h"
30#include "AliRawReader.h"
cc2abffd 31#include "AliLog.h"
8309c1ab 32
33ClassImp(AliZDCRawStream)
34
35
36//_____________________________________________________________________________
37AliZDCRawStream::AliZDCRawStream(AliRawReader* rawReader) :
38 fRawReader(rawReader),
cc2abffd 39 fRawADC(0),
786b72f5 40 fADCModule(0),
41 fADCChannel(-1),
cc2abffd 42 fADCValue(-1),
c0aec6f6 43 fADCGain(0),
44 fIsADCDataWord(kFALSE)
8309c1ab 45{
abf60186 46 // Create an object to read ZDC raw digits
8309c1ab 47
362c9d61 48 fRawReader->Select("ZDC");
8309c1ab 49}
50
51//_____________________________________________________________________________
52AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) :
a718c993 53 TObject(stream),
54 fRawADC(stream.GetADCRaw()),
55 fADCModule(stream.GetADCModule()),
56 fADCChannel(stream.GetADCChannel()),
57 fADCValue(stream.GetADCValue()),
58 fADCGain(stream.GetADCGain()),
59 fIsADCDataWord(stream.IsADCDataWord())
8309c1ab 60{
abf60186 61 // Copy constructor
c0aec6f6 62 for(Int_t j=0; j<2; j++) fSector[j] = stream.GetSector(j);
c0aec6f6 63
8309c1ab 64}
65
66//_____________________________________________________________________________
67AliZDCRawStream& AliZDCRawStream::operator = (const AliZDCRawStream&
68 /* stream */)
69{
abf60186 70 // Assignment operator
8309c1ab 71 Fatal("operator =", "assignment operator not implemented");
72 return *this;
73}
74
75//_____________________________________________________________________________
76AliZDCRawStream::~AliZDCRawStream()
77{
abf60186 78// Destructor
8309c1ab 79
80}
81
82
83//_____________________________________________________________________________
84Bool_t AliZDCRawStream::Next()
85{
abf60186 86 // Read the next raw digit
87 // Returns kFALSE if there is no digit left
8309c1ab 88
abf60186 89 if(!fRawReader->ReadNextInt((UInt_t&) fRawADC)) return kFALSE;
8309c1ab 90 fIsADCDataWord = kFALSE;
6006df88 91 //
1069e28d 92 // --- DARC header
93 if((fRawADC == 0xe52b6300) || (fRawADC == 0xe52c0300) || (fRawADC == 0xffffffff) ||
94 (fRawADC == 0xdeadface) || (fRawADC == 0xdeadbeef)){
95 //printf(" This is a DARC header!!!\n");
abf60186 96 }
1069e28d 97 // --- End of data
98 else if(fRawADC == 0xcafefade){
99 //printf(" End of data!\n");
100 }
101 // --- ADC buffer
6006df88 102 else{
786b72f5 103 Bool_t firstADCHeader = kTRUE;
104 //
105 if((fRawADC & 0x6000000) == 0x6000000){ // Not valid datum BEFORE valid data!
106 firstADCHeader = kFALSE;
1069e28d 107 //printf(" AliZDCRawStream -> Not valid datum in ADC module!!! %d\n",fADCModule);
6006df88 108 }
1069e28d 109 else if((fRawADC & 0x4000000) == 0x4000000){ // ADC EOB
110 //printf(" AliZDCRawStream -> ADC %d End Of Block - Event no. %d\n\n",fADCModule, (fRawADC & 0xffffff));
6006df88 111 fSector[0] = fSector[1] = 99;
112 }
1069e28d 113 else if((fRawADC & 0x2000000) == 0x2000000){ // ADC Header
41f31182 114 //printf(" fRawADC %x\n",fRawADC);
1069e28d 115 // Reading the GEO address to determine ADC module
116 fADCModule = (fRawADC & 0xf8000000) >> 27;
117 fADCModule ++;
786b72f5 118 // If the not valid datum isn't followed by the 1st ADC header
119 // the event is corrupted (i.e., 2 gates arrived before trigger)
120 if(fADCModule == 1) firstADCHeader = kTRUE;
121 //if(fADCModule == 1) printf(" fADCModule %d, firstADCHeader %d\n",fADCModule,firstADCHeader);
122 //printf(" AliZDCRawStream -> HEADER: ADC mod. %d contains %d data words \n",fADCModule,((fRawADC & 0x3f00) >> 8));
6006df88 123 }
1069e28d 124 else{ // ADC data word
6006df88 125 fIsADCDataWord = kTRUE;
786b72f5 126 //printf(" fRawADC = %x firstADCHeader %d\n",fRawADC,firstADCHeader);
1069e28d 127 //
786b72f5 128 if(!(fRawADC & 0x1000) && !(fRawADC & 0x2000) && firstADCHeader){ // Valid ADC data
6006df88 129 fADCGain = (fRawADC & 0x10000) >> 16;
130 fADCValue = (fRawADC & 0xfff);
131 //
786b72f5 132 fADCChannel = (fRawADC & 0x1e0000) >> 17;
133 //
134 // If raw data corresponds to an ADC ch. without physical signal
135 // fsector[0] = fSector[1] = -1
136 for(Int_t i=0; i<2; i++)fSector[i] = -1;
137 //if(fSector[0]!=-1) printf(" \t \t ADC Data Word: ADC ch. %d",fADCChannel);
138 //
6006df88 139 if(fADCModule==1 || fADCModule==3){ //1st & 3rd ADC modules
786b72f5 140 if(fADCChannel >= 0 && fADCChannel <= 4){
6006df88 141 fSector[0] = 1; // ZN1
786b72f5 142 fSector[1] = fADCChannel;
6006df88 143 }
786b72f5 144 else if(fADCChannel >= 8 && fADCChannel <= 12){
6006df88 145 fSector[0] = 2; // ZP1
786b72f5 146 fSector[1] = fADCChannel-8;
6006df88 147 }
786b72f5 148 else if(fADCChannel == 5 || fADCChannel == 13){
6006df88 149 fSector[0] = 3; // ZEM 1,2
786b72f5 150 fSector[1] = ((fADCChannel-5)/8)+1;
6006df88 151 }
83347831 152 }
6006df88 153 else if(fADCModule==2 || fADCModule==4){ //2nd & 4rth ADC modules
786b72f5 154 if(fADCChannel >= 0 && fADCChannel <= 4){
6006df88 155 fSector[0] = 4; // ZN2
786b72f5 156 fSector[1] = fADCChannel;
6006df88 157 }
786b72f5 158 else if(fADCChannel >= 8 && fADCChannel <= 12){
6006df88 159 fSector[0] = 5; // ZP2
786b72f5 160 fSector[1] = fADCChannel-8;
6006df88 161 }
786b72f5 162 else if(fADCChannel == 5 || fADCChannel == 13){
163 fSector[0] = (fADCChannel-5)*3/8+1; // PM Ref 1,2
6006df88 164 fSector[1] = 5;
165 }
83347831 166 }
6006df88 167 else{
1069e28d 168 AliWarning(" AliZDCRawStream -> No valid ADC module\n");
6006df88 169 fRawReader->AddMajorErrorLog(kInvalidADCModule);
170 }
1069e28d 171 //printf(" ADC %d ch %d range %d -> det %d quad %d value %x\n",
786b72f5 172 // fADCModule, fADCChannel, fADCGain, fSector[0], fSector[1], fADCValue);//Chiara debugging
6006df88 173
1069e28d 174 }// Valid ADC data
175 else if(fRawADC & 0x1000){
176 //printf(" ADC %d ch %d range %d overflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Overflow
6006df88 177 }
1069e28d 178 else if(fRawADC & 0x2000){
179 //printf(" ADC %d ch %d range %d underflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Underflow
180 }
181 }// ADC word
6006df88 182 }//Not DARC Header
83347831 183
8309c1ab 184 return kTRUE;
185}