1 #include "AliSTARTRawReader.h"
2 #include "AliSTARTRawData.h"
3 #include "AliSTARTdigit.h"
4 #include "AliBitPacking.h"
13 ClassImp(AliSTARTRawReader)
15 AliSTARTRawReader::AliSTARTRawReader (AliRawReader *rawReader, TTree* tree)
16 : TTask("STARTRawReader","read raw START data"),
22 // create an object to read STARTraw digits
24 if (fDigits == 0x0) fDigits = new AliSTARTdigit();
25 fTree->Branch("START","AliSTARTdigit",&fDigits,405,1);
28 fRawReader->Select(13,0,1);
32 AliSTARTRawReader::~AliSTARTRawReader ()
37 Bool_t AliSTARTRawReader::Next()
39 // read the next raw digit
40 // returns kFALSE if there is no digit left
43 UInt_t word, unpackword;
45 TArrayI *timeTDC1 = new TArrayI(24);
46 TArrayI * chargeTDC1 = new TArrayI(24);
47 TArrayI *timeTDC2 = new TArrayI(24);
48 TArrayI *chargeTDC2 = new TArrayI(24);
51 if (!fRawReader->ReadNextData(fData)) return kFALSE;
52 } while (fRawReader->GetDataSize() == 0);
54 fPosition = GetPosition();
56 for( Int_t i=0; i<11; i++) word = GetNextWord();
61 unpackword=pack->UnpackWord(word,0,8);
66 unpackword=pack->UnpackWord(word,8,31);
68 fDigits->SetSumMult(time);
70 // best time differece
74 unpackword=pack->UnpackWord(word,0,8);
80 unpackword=pack->UnpackWord(word,8,31);
82 fDigits->SetDiffTime(time);
87 unpackword=pack->UnpackWord(word,0,8);
92 unpackword=pack->UnpackWord(word,8,31);
94 fDigits->SetTimeBestLeft(time);
96 // Best time right &left
100 unpackword=pack->UnpackWord(word,0,8);
106 word = GetNextWord();
107 unpackword=pack->UnpackWord(word,8,31);
109 fDigits->SetTimeBestRight(time);
113 word = GetNextWord();
114 unpackword=pack->UnpackWord(word,0,8);
118 word = GetNextWord();
119 unpackword=pack->UnpackWord(word,8,31);
121 fDigits->SetMeanTime(time);
123 for (Int_t i=0; i<24; i++) //QTC amplified
128 word = GetNextWord();
129 unpackword=pack->UnpackWord(word,0,8);
133 word = GetNextWord();
134 unpackword= pack->UnpackWord(word,8,31);
136 chargeTDC2->AddAt(adc,pmt-72);
139 for (Int_t i=0; i<24; i++)
144 word = GetNextWord();
145 unpackword=pack->UnpackWord(word,0,8);
149 word = GetNextWord();
150 unpackword= pack->UnpackWord(word,8,31);
152 chargeTDC1->AddAt(adc,pmt-48);
155 for (Int_t i=0; i<24; i++) //time CFD
159 word = GetNextWord();
160 unpackword=pack->UnpackWord(word,0,8);
164 word = GetNextWord();
165 unpackword=pack->UnpackWord(word,8,31);
167 timeTDC2->AddAt(time,pmt-24);
171 for (Int_t i=0; i<24; i++) //time LED
175 word = GetNextWord();
176 unpackword=pack->UnpackWord(word,0,31);
181 word = GetNextWord();
182 unpackword=pack->UnpackWord(word,8,31);
184 timeTDC1->AddAt(time,i);
188 fDigits->SetTime(*timeTDC2);
189 fDigits->SetADC(*chargeTDC1);
191 fDigits->SetTimeAmp(*timeTDC1);
192 fDigits->SetADCAmp(*chargeTDC2);
203 //_____________________________________________________________________________
204 Int_t AliSTARTRawReader::GetPosition()
206 // Sets the position in the
208 if (((fRawReader->GetDataSize() * 8) % 32) != 0)
209 AliFatal(Form("Incorrect raw data size ! %d words are found !",fRawReader->GetDataSize()));
210 return (fRawReader->GetDataSize() * 8) / 32;
212 //_____________________________________________________________________________
213 UInt_t AliSTARTRawReader::GetNextWord()
215 // Read the next 32 bit word in backward direction
216 // The input stream access is given by fData and fPosition
220 Int_t iBit = fPosition * 32;
221 Int_t iByte = iBit / 8;
224 word = fData[iByte+3]<<24;
225 word |= fData[iByte+2]<<16;
226 word |= fData[iByte+1]<<8;
227 word |= fData[iByte];