include AliRawReaderFile removed
[u/mrichter/AliRoot.git] / START / AliSTARTRawReader.cxx
CommitLineData
ee74718b 1#include "AliSTARTRawReader.h"
2#include "AliSTARTRawData.h"
db173afc 3#include "AliSTARTdigit.h"
ee74718b 4
5#include <Riostream.h>
6#include "TMath.h"
7#include "TH1F.h"
8#include "TArrayI.h"
9#include "AliLog.h"
10
11ClassImp(AliSTARTRawReader)
db173afc 12
13 AliSTARTRawReader::AliSTARTRawReader (AliRawReader *rawReader, TTree* tree)
14 : TTask("STARTRawReader","read raw START data"),
15 fTree(tree),
16 fRawReader(rawReader)
ee74718b 17{
18 //
19// create an object to read STARTraw digits
20 AliDebug(1,"Start ");
db173afc 21
ee74718b 22
23}
24 AliSTARTRawReader::~AliSTARTRawReader ()
25{
db173afc 26 //
ee74718b 27}
28//------------------------------------------------------------------------------------------------
29
30UInt_t AliSTARTRawReader::UnpackWord(UInt_t packedWord, Int_t startBit, Int_t stopBit)
31{
32 //This method unpacks a words of StopBit-StartBit+1 bits starting from "StopBits"
33 UInt_t word;
34 UInt_t offSet;
35 Int_t length;
36 length=stopBit-startBit+1;
37 offSet=(UInt_t)TMath::Power(2,length)-1;
38 offSet<<=startBit;
39 word=packedWord&offSet;
40 word>>=startBit;
41 return word;
42}
43//---------------------------------------------------------------------------------------
db173afc 44void AliSTARTRawReader::NextThing()
ee74718b 45{
46// read the next raw digit
47// returns kFALSE if there is no digit left
ee74718b 48 UInt_t word, unpackword;
db173afc 49 Int_t time, adc, pmt;
50 TArrayI *timeTDC1 = new TArrayI(24);
51 TArrayI * chargeTDC1 = new TArrayI(24);
52 TArrayI *timeTDC2 = new TArrayI(24);
53 TArrayI *chargeTDC2 = new TArrayI(24);
54 TArrayI *sumMult = new TArrayI(6);
55
ee74718b 56 fRawReader->Select(13);
57
db173afc 58 if (!fRawReader->ReadHeader()){
59 Error("ReadSTARTRaw","Couldn't read header");
60 return;
61 }
62 AliSTARTdigit *fDigits = new AliSTARTdigit();
63 fTree->Branch("START","AliSTARTdigit",&fDigits,400,1);
ee74718b 64
db173afc 65 fRawReader->ReadNextInt(word);
66 for (Int_t i=0; i<24; i++)
ee74718b 67 {
68 word=0;
69 unpackword=0;
70 fRawReader->ReadNextInt(word);
71 unpackword=UnpackWord(word,0,5);
db173afc 72 pmt=unpackword;
ee74718b 73 word=0;
74 unpackword=0;
ee74718b 75 fRawReader->ReadNextInt(word);
76 unpackword=UnpackWord(word,8,31);
db173afc 77 time=unpackword;
78 timeTDC1->AddAt(time,pmt);
79
ee74718b 80 word=0;
81 unpackword=0;
ee74718b 82 fRawReader->ReadNextInt(word);
83 unpackword=UnpackWord(word,0,5);
db173afc 84 pmt=unpackword;
ee74718b 85 word=0;
86 unpackword=0;
ee74718b 87 fRawReader->ReadNextInt(word);
ee74718b 88 unpackword=UnpackWord(word,8,31);
db173afc 89 time=unpackword;
90 timeTDC2->AddAt(time,pmt);
91
92 // QTC
ee74718b 93 word=0;
94 unpackword=0;
95 fRawReader->ReadNextInt(word);
96 unpackword=UnpackWord(word,0,5);
db173afc 97 pmt=unpackword;
ee74718b 98 word=0;
99 unpackword=0;
ee74718b 100 fRawReader->ReadNextInt(word);
101 unpackword= UnpackWord(word,8,31);
db173afc 102 time=unpackword; //T1
103
ee74718b 104 word=0;
105 unpackword=0;
106
107 fRawReader->ReadNextInt(word);
108 unpackword=UnpackWord(word,0,5);
db173afc 109 pmt=unpackword;
110 word=0;
111 unpackword=0;
112 fRawReader->ReadNextInt(word);
113 unpackword= UnpackWord(word,8,31);
114 adc=unpackword-time; // T1+ T2 (A)
115 chargeTDC1->AddAt(adc,pmt);
116 //QTC amplified
ee74718b 117
118 word=0;
119 unpackword=0;
120 fRawReader->ReadNextInt(word);
db173afc 121 unpackword=UnpackWord(word,0,5);
122 pmt=unpackword;
123 word=0;
124 unpackword=0;
125 fRawReader->ReadNextInt(word);
ee74718b 126 unpackword= UnpackWord(word,8,31);
db173afc 127 time=unpackword; //T1
128
129 word=0;
130 unpackword=0;
ee74718b 131
db173afc 132 fRawReader->ReadNextInt(word);
133 unpackword=UnpackWord(word,0,5);
134 pmt=unpackword;
135 word=0;
136 unpackword=0;
137 fRawReader->ReadNextInt(word);
138 unpackword= UnpackWord(word,8,31);
139 adc=unpackword-time; // T1+ T2 (A)
140 chargeTDC2->AddAt(adc,pmt);
ee74718b 141
db173afc 142
ee74718b 143 }
db173afc 144 fDigits->SetTime(*timeTDC1);
145 fDigits->SetADC(*chargeTDC1);
146
147
148 word=0;
149 unpackword=0;
150
151 fRawReader->ReadNextInt(word);
152 unpackword=UnpackWord(word,0,5);
153 pmt=unpackword;
154
155 word=0;
156 unpackword=0;
157
158 fRawReader->ReadNextInt(word);
159 unpackword=UnpackWord(word,8,31);
160 time=unpackword;
161 fDigits->SetMeanTime(time);
162
163 // Best time right &left
164 word=0;
165 unpackword=0;
166
167 fRawReader->ReadNextInt(word);
168 unpackword=UnpackWord(word,0,5);
169 pmt=unpackword;
170
171 word=0;
172 unpackword=0;
173
174 fRawReader->ReadNextInt(word);
175 unpackword=UnpackWord(word,8,31);
176 time=unpackword;
177 fDigits->SetTimeBestRight(time);
178
179
180 // best time left
181 word=0;
182 unpackword=0;
183
184 fRawReader->ReadNextInt(word);
185 unpackword=UnpackWord(word,0,5);
186 pmt=unpackword;
187
188 word=0;
189 unpackword=0;
190
191 fRawReader->ReadNextInt(word);
192 unpackword=UnpackWord(word,8,31);
193 time=unpackword;
194 fDigits->SetTimeBestLeft(time);
195
196
197 // best time differece
198 word=0;
199 unpackword=0;
200
201 fRawReader->ReadNextInt(word);
202 unpackword=UnpackWord(word,0,5);
203 pmt=unpackword;
204
205 word=0;
206 unpackword=0;
207
208 fRawReader->ReadNextInt(word);
209 unpackword=UnpackWord(word,8,31);
210 time=unpackword;
211 fDigits->SetDiffTime(time);
212
213 // multiplicity
214 for (Int_t im=0; im<6; im++)
215 {
216 word=0;
217 unpackword=0;
218 fRawReader->ReadNextInt(word);
219 unpackword=UnpackWord(word,0,5);
220 pmt=unpackword;
221 word=0;
222 unpackword=0;
223 fRawReader->ReadNextInt(word);
224 unpackword=UnpackWord(word,8,31);
225 time=unpackword;
226 sumMult->AddAt(time,im);
227 }
228 fDigits->SetSumMult(*sumMult);
229
230 fTree->Fill();
231
ee74718b 232}
db173afc 233