]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCRawStream.cxx
e8333942c0900cd172c2a901a964af57a53675a7
[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   fIsADCDataWord(kFALSE)
44 {
45   // Create an object to read ZDC raw digits
46
47   fRawReader->Select("ZDC");
48 }
49
50 //_____________________________________________________________________________
51 AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) :
52   TObject(stream)
53 {
54   // Copy constructor
55   fRawADC = stream.GetADCRaw();  
56   for(Int_t j=0; j<2; j++) fSector[j] = stream.GetSector(j);     
57   fADCModule = stream.GetADCModule();    
58   fADCValue = stream.GetADCValue();      
59   fADCGain = stream.GetADCGain();        
60   fIsADCDataWord = stream.IsADCDataWord(); 
61     
62 }
63
64 //_____________________________________________________________________________
65 AliZDCRawStream& AliZDCRawStream::operator = (const AliZDCRawStream& 
66                                               /* stream */)
67 {
68   // Assignment operator
69   Fatal("operator =", "assignment operator not implemented");
70   return *this;
71 }
72
73 //_____________________________________________________________________________
74 AliZDCRawStream::~AliZDCRawStream()
75 {
76 // Destructor
77
78 }
79
80
81 //_____________________________________________________________________________
82 Bool_t AliZDCRawStream::Next()
83 {
84   // Read the next raw digit
85   // Returns kFALSE if there is no digit left
86
87   if(!fRawReader->ReadNextInt((UInt_t&) fRawADC)) return kFALSE;
88   fIsADCDataWord = kFALSE;
89   
90   //
91   // --- DARC header
92   if((fRawADC == 0xe52b6300) || (fRawADC == 0xe52c0300) ||  (fRawADC == 0xffffffff) ||
93      (fRawADC == 0xdeadface) || (fRawADC == 0xdeadbeef)){
94     //printf("    This is a DARC header!!!\n");
95   }
96   // --- End of data
97   else if(fRawADC == 0xcafefade){
98     //printf("    End of data!\n");
99   } 
100   // --- ADC buffer
101   else{
102     if((fRawADC & 0x6000000) == 0x6000000){ // Not valid datum
103       //printf("    AliZDCRawStream -> Not valid datum in ADC module!!! %d\n",fADCModule);
104     }
105     else if((fRawADC & 0x4000000) == 0x4000000){ // ADC EOB
106       //printf("    AliZDCRawStream -> ADC %d End Of Block - Event no. %d\n\n",fADCModule, (fRawADC & 0xffffff));
107       fSector[0] = fSector[1] = 99;
108     } 
109     else if((fRawADC & 0x2000000) == 0x2000000){ // ADC Header
110       //printf("  fRawADC %x\n",fRawADC);
111       // Reading the GEO address to determine ADC module
112       fADCModule = (fRawADC & 0xf8000000) >> 27;
113       fADCModule ++;
114       //printf("    AliZDCRawStream -> HEADER: ADC mod. %d contains %d data words \n",fADCModule,((fRawADC & 0x3f00) >> 8));
115     }
116     else{ // ADC data word
117       fIsADCDataWord = kTRUE;
118       //printf(" \t \t ADC Data Word");
119       //
120       if(!(fRawADC & 0x1000) && !(fRawADC & 0x2000)){ // Valid ADC data
121         fADCGain = (fRawADC & 0x10000) >> 16;
122         fADCValue = (fRawADC & 0xfff);   
123         //
124         Int_t vADCChannel = (fRawADC & 0x1e0000) >> 17;
125         if(fADCModule==1 || fADCModule==3){  //1st & 3rd ADC modules
126           if(vADCChannel >= 0 && vADCChannel <= 4){ 
127             fSector[0] = 1; // ZN1
128             fSector[1] = vADCChannel;
129           } 
130           else if(vADCChannel >= 8 && vADCChannel <= 12){
131             fSector[0] = 2; // ZP1
132             fSector[1] = vADCChannel-8;
133           } 
134           else if(vADCChannel == 5 || vADCChannel == 13){
135             fSector[0] = 3; // ZEM 1,2
136             fSector[1] = ((vADCChannel-5)/8)+1;
137           }
138         }
139         else if(fADCModule==2 || fADCModule==4){  //2nd & 4rth ADC modules
140           if(vADCChannel >= 0 && vADCChannel <= 4){ 
141             fSector[0] = 4; // ZN2
142           fSector[1] = vADCChannel;
143           } 
144           else if(vADCChannel >= 8 && vADCChannel <= 12){
145             fSector[0] = 5; // ZP2
146             fSector[1] = vADCChannel-8;
147           } 
148           else if(vADCChannel == 5 || vADCChannel == 13){
149             fSector[0] = (vADCChannel-5)*3/8+1; // PM Ref 1,2
150             fSector[1] = 5;
151           }
152         }
153         else{
154           AliWarning("    AliZDCRawStream -> No valid ADC module\n");
155           fRawReader->AddMajorErrorLog(kInvalidADCModule);
156         }
157         //printf("  ADC %d ch %d range %d -> det %d quad %d value %x\n",
158         //   fADCModule, vADCChannel, fADCGain, fSector[0], fSector[1], fADCValue);//Chiara debugging
159       
160       }// Valid ADC data
161       else if(fRawADC & 0x1000){ 
162         //printf("  ADC %d ch %d range %d  overflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Overflow
163       }
164       else if(fRawADC & 0x2000){ 
165         //printf("  ADC %d ch %d range %d  underflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Underflow
166       }
167     }// ADC word
168   }//Not DARC Header
169
170   return kTRUE;
171 }