]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCRawStream.cxx
52099f55241c97528ba547b8fcf853a301886ffa
[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
32 ClassImp(AliZDCRawStream)
33
34
35 //_____________________________________________________________________________
36 AliZDCRawStream::AliZDCRawStream(AliRawReader* rawReader) :
37   fRawReader(rawReader),
38   fADCValue(-1)
39 {
40 // create an object to read ZDC raw digits
41
42   fSector[0] = 1;
43   fSector[1] = -1;
44   fRawReader->Select("ZDC");
45 }
46
47 //_____________________________________________________________________________
48 AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) :
49   TObject(stream),
50   fADCValue(-1)
51 {
52 // copy constructor
53
54   Fatal("AliZDCRawStream", "copy constructor not implemented");
55 }
56
57 //_____________________________________________________________________________
58 AliZDCRawStream& AliZDCRawStream::operator = (const AliZDCRawStream& 
59                                               /* stream */)
60 {
61 // assignment operator
62
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   //ADC Header
85   if (fRawADC & 0x2000000) {
86     //printf("This is the ADC Header\n");
87     //printf("%d data words will follow \n",2*((fRawADC & 0x3f00) >> 8));
88   } 
89   //ADC EOB
90   else if (fRawADC & 0x4000000) {
91     //printf("This is the ADC End Of Block\n");
92     //printf("This was event number %d\n",(fRawADC & 0xffffff));
93   } 
94   else 
95   //ADC Data Words
96   {
97     //printf("This is an ADC Data Word\n");
98     //printf("Channel %d range %d\n",(fRawADC & 0x1e0000) >> 17, (fRawADC & 0x10000) >> 16);
99     //if(fRawADC & 0x1000) printf("Data = overflow\n");
100     fADCGain = (fRawADC & 0x10000) >> 16;
101     fADCValue = (fRawADC & 0xfff);   
102     fIsADCDataWord = kTRUE;
103
104     Int_t vADCChannel = (fRawADC & 0x1e0000) >> 17;
105     if (vADCChannel >= 0 && vADCChannel <= 4) { 
106       fSector[0] = 1;
107       fSector[1] = vADCChannel;
108     } else if (vADCChannel >= 8 && vADCChannel <= 12) {
109       fSector[0] = 2;
110       fSector[1] = vADCChannel-8;
111     } else if (vADCChannel == 5 || vADCChannel == 13){
112       fSector[0] = 3;
113       fSector[1] = (vADCChannel-5)/8;
114     }
115   }
116   return kTRUE;
117 }