Changes to comply with coding convention
[u/mrichter/AliRoot.git] / START / AliSTARTRawReader.cxx
CommitLineData
ee74718b 1#include "AliSTARTRawReader.h"
2#include "AliSTARTRawData.h"
3#include "AliRawReaderFile.h"
4
5
6#include <Riostream.h>
7#include "TMath.h"
8#include "TH1F.h"
9#include "TArrayI.h"
10#include "AliLog.h"
11
12ClassImp(AliSTARTRawReader)
13
14 AliSTARTRawReader::AliSTARTRawReader (): TTask("STARTRawReader","read raw data"),
15 fPMTId(-1),
16 fTimeTDC1(0),
17 fChargeADC1(0),
18 fTimeTDC2(0),
19 fChargeADC2(0)
20{
21 //
22// create an object to read STARTraw digits
23 AliDebug(1,"Start ");
24 fTimeTDC1 = new TArrayI(24);
25 fChargeADC1 = new TArrayI(24);
26 fTimeTDC2 = new TArrayI(24);
27 fChargeADC2 = new TArrayI(24);
28
29}
30 AliSTARTRawReader::~AliSTARTRawReader ()
31{
32 delete fTimeTDC1;
33 delete fTimeTDC2;
34 delete fChargeADC1 ;
35 delete fChargeADC2;
36
37}
38//------------------------------------------------------------------------------------------------
39
40UInt_t AliSTARTRawReader::UnpackWord(UInt_t packedWord, Int_t startBit, Int_t stopBit)
41{
42 //This method unpacks a words of StopBit-StartBit+1 bits starting from "StopBits"
43 UInt_t word;
44 UInt_t offSet;
45 Int_t length;
46 length=stopBit-startBit+1;
47 offSet=(UInt_t)TMath::Power(2,length)-1;
48 offSet<<=startBit;
49 word=packedWord&offSet;
50 word>>=startBit;
51 return word;
52}
53//---------------------------------------------------------------------------------------
54Bool_t AliSTARTRawReader::NextThing( AliRawReader *fRawReader)
55{
56// read the next raw digit
57// returns kFALSE if there is no digit left
58
59 UInt_t word, unpackword;
60 UInt_t fADC, fTime;
61 fRawReader->Select(13);
62
63 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
64
65
66 Int_t size=fRawReader->GetDataSize();
67 for (Int_t i=0; i<size/32; i++)
68 {
69 word=0;
70 unpackword=0;
71 fRawReader->ReadNextInt(word);
72 unpackword=UnpackWord(word,0,5);
73 fPMTId=unpackword;
74 word=0;
75 unpackword=0;
76
77 fRawReader->ReadNextInt(word);
78 unpackword=UnpackWord(word,8,31);
79 fTime=unpackword;
80 fTimeTDC1->AddAt(fTime,fPMTId);
81 word=0;
82 unpackword=0;
83
84 fRawReader->ReadNextInt(word);
85 unpackword=UnpackWord(word,0,5);
86 fPMTId=unpackword;
87 word=0;
88 unpackword=0;
89
90 fRawReader->ReadNextInt(word);
91
92 unpackword=UnpackWord(word,8,31);
93 fTime=unpackword;
94 fTimeTDC2->AddAt(fTime,fPMTId);
95
96 word=0;
97 unpackword=0;
98 fRawReader->ReadNextInt(word);
99 unpackword=UnpackWord(word,0,5);
100 fPMTId=unpackword;
101 word=0;
102 unpackword=0;
103
104 fRawReader->ReadNextInt(word);
105 unpackword= UnpackWord(word,8,31);
106 fADC=unpackword;
107 fChargeADC1 -> AddAt(fADC, fPMTId);
108
109 word=0;
110 unpackword=0;
111
112 fRawReader->ReadNextInt(word);
113 unpackword=UnpackWord(word,0,5);
114 fPMTId=unpackword;
115
116 word=0;
117 unpackword=0;
118 fRawReader->ReadNextInt(word);
119
120 unpackword= UnpackWord(word,8,31);
121 fADC=unpackword;
122 fChargeADC2 -> AddAt(fADC, fPMTId);
123 }
124 return kTRUE;
125
126}
127
128//--------------------------------------------
129void AliSTARTRawReader::GetTime (TArrayI &o)
130{
131 //
132 Int_t i;
133 for (i=0; i<24; i++)
134 {
135 o[i]=fTimeTDC1->At(i);
136 }
137}
138//--------------------------------------------
139//--------------------------------------------
140void AliSTARTRawReader::GetADC (TArrayI &o)
141{
142 //
143 Int_t i;
144 for (i=0; i<24; i++)
145 {
146 o[i]=fChargeADC1->At(i);
147 }
148}