]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCRawStream.cxx
Digits and raw data updated for commissioning
[u/mrichter/AliRoot.git] / ZDC / AliZDCRawStream.cxx
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 ///////////////////////////////////////////////////////////////////////////////
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 //                                                                           //
27 ///////////////////////////////////////////////////////////////////////////////
28
29 #include "AliZDCRawStream.h"
30 #include "AliRawReader.h"
31 #include "AliLog.h"
32
33 ClassImp(AliZDCRawStream)
34
35
36 //_____________________________________________________________________________
37 AliZDCRawStream::AliZDCRawStream(AliRawReader* rawReader) :
38   fRawReader(rawReader),
39   fRawADC(0),    
40   fADCModule(0),         
41   fADCValue(-1),         
42   fADCGain(0)
43 {
44   // Create an object to read ZDC raw digits
45
46   fRawReader->Select("ZDC");
47 }
48
49 //_____________________________________________________________________________
50 AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) :
51   TObject(stream),
52   fADCValue(-1)
53 {
54   // Copy constructor
55   Fatal("AliZDCRawStream", "copy constructor not implemented");
56 }
57
58 //_____________________________________________________________________________
59 AliZDCRawStream& AliZDCRawStream::operator = (const AliZDCRawStream& 
60                                               /* stream */)
61 {
62   // Assignment operator
63   Fatal("operator =", "assignment operator not implemented");
64   return *this;
65 }
66
67 //_____________________________________________________________________________
68 AliZDCRawStream::~AliZDCRawStream()
69 {
70 // Destructor
71
72 }
73
74
75 //_____________________________________________________________________________
76 Bool_t AliZDCRawStream::Next()
77 {
78   // Read the next raw digit
79   // Returns kFALSE if there is no digit left
80
81   if(!fRawReader->ReadNextInt((UInt_t&) fRawADC)) return kFALSE;
82   fIsADCDataWord = kFALSE;
83   
84   if(fRawADC & 0x2000000){//ADC Header
85     fADCModule++;
86     //printf(" \t AliZDCRawStream -> Header ADC %d -> ADC datum contains %d data words \n",fADCModule,((fRawADC & 0x3f00) >> 8));
87   }
88   else if((fRawADC & 0x4000000)){//ADC EOB
89     //printf(" \t AliZDCRawStream -> ADC %d End Of Block - event number %d\n\n",fADCModule, (fRawADC & 0xffffff));
90     fSector[0] = fSector[1] = 99;
91   } 
92   else if((fRawADC & 0x6000000)){//Not valid datum
93     printf(" \t AliZDCRawStream -> Not valid datum in ADC module %d\n",fADCModule);
94   }
95   else{//ADC data word
96     fIsADCDataWord = kTRUE;
97     //printf(" \t \t ADC Data Word");
98     if(!(fRawADC & 0x1000) && !(fRawADC & 0x2000)){ // Valid ADC data
99       fADCGain = (fRawADC & 0x10000) >> 16;
100       fADCValue = (fRawADC & 0xfff);   
101       //
102       Int_t vADCChannel = (fRawADC & 0x1e0000) >> 17;
103       if(fADCModule==1 || fADCModule==3){  //1st & 3rd ADC modules
104         if(vADCChannel >= 0 && vADCChannel <= 4){ 
105           fSector[0] = 1; // ZN1
106           fSector[1] = vADCChannel;
107         } 
108         else if(vADCChannel >= 8 && vADCChannel <= 12){
109           fSector[0] = 2; // ZP1
110           fSector[1] = vADCChannel-8;
111         } 
112         else if(vADCChannel == 5 || vADCChannel == 13){
113           fSector[0] = 3; // ZEM 1,2
114           fSector[1] = ((vADCChannel-5)/8)+1;
115         }
116       }
117       else if(fADCModule==2 || fADCModule==4){  //2nd & 4rth ADC modules
118         if(vADCChannel >= 0 && vADCChannel <= 4){ 
119           fSector[0] = 4; // ZN2
120           fSector[1] = vADCChannel;
121         } 
122         else if(vADCChannel >= 8 && vADCChannel <= 12){
123           fSector[0] = 5; // ZP2
124           fSector[1] = vADCChannel-8;
125         } 
126         else if(vADCChannel == 5 || vADCChannel == 13){
127           fSector[0] = (vADCChannel-5)/8+1; // PM Ref 1,2
128           fSector[1] = 5;
129         }
130       }
131       else{
132         AliWarning(" \t AliZDCRawStream -> No valid ADC module!");
133         printf(" ADCmod = %d\n", fADCModule);
134         fRawReader->AddMajorErrorLog(kInvalidADCModule);
135       }
136       /*printf(" \t \tADC %d ch %d range %d -> det %d quad %d value %x\n",
137            fADCModule, vADCChannel, fADCGain, fSector[0], fSector[1], fADCValue);//Chiara debugging
138       */
139     }
140     else if(fRawADC & 0x1000) 
141       printf(" \t \tADC %d ch %d range %d  overflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Overflow
142     else if(fRawADC & 0x2000) 
143       printf(" \t \tADC %d ch %d range %d  underflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Underflow
144   }
145
146   return kTRUE;
147 }