]>
Commit | Line | Data |
---|---|---|
d810d0de | 1 | // $Id$ |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
3 | ||
4 | /************************************************************************** | |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
51346b82 | 7 | * full copyright notice. * |
d810d0de | 8 | **************************************************************************/ |
8616d353 | 9 | // |
d810d0de | 10 | // AliEveTOFDigitsInfo |
8616d353 | 11 | // |
12 | ||
545d5001 | 13 | #include "fcntl.h" |
14 | ||
84aff7a4 | 15 | #include <TEveTreeTools.h> |
8616d353 | 16 | |
d810d0de | 17 | #include "AliEveTOFDigitsInfo.h" |
ee9d8eca | 18 | |
19 | #include <AliDAQ.h> | |
20 | ||
545d5001 | 21 | #include <AliTOFCableLengthMap.h> |
8616d353 | 22 | #include <AliTOFdigit.h> |
28a21457 | 23 | #include <AliTOFGeometry.h> |
ee9d8eca | 24 | #include <AliTOFrawData.h> |
25 | #include <AliTOFRawStream.h> | |
8616d353 | 26 | |
27 | //_________________________________________________________ | |
28 | ||
d810d0de | 29 | ClassImp(AliEveTOFDigitsInfo) |
8616d353 | 30 | |
ee9d8eca | 31 | AliEveTOFDigitsInfo::AliEveTOFDigitsInfo(): |
8616d353 | 32 | TObject(), |
84aff7a4 | 33 | TEveRefCnt(), |
8616d353 | 34 | fTree (0), |
35 | fNewTree (0), | |
545d5001 | 36 | fGeom (new AliTOFGeometry()), |
8616d353 | 37 | fTOFdigitMap(new AliTOFDigitMap()) |
38 | {} | |
39 | /* ******************************************************* */ | |
40 | ||
ee9d8eca | 41 | AliEveTOFDigitsInfo:: ~AliEveTOFDigitsInfo() |
8616d353 | 42 | { |
43 | ||
44 | delete fGeom; | |
45 | delete fTree; | |
46 | delete fNewTree; | |
47 | delete fTOFdigitMap; | |
48 | ||
49 | } | |
50 | /* ******************************************************* */ | |
51 | ||
d810d0de | 52 | void AliEveTOFDigitsInfo::SetTree(TTree* tree) |
8616d353 | 53 | { |
a15e6d7d | 54 | static const TEveException kEH("AliEveTOFDigitsInfo::SetTree "); |
ee9d8eca | 55 | |
8616d353 | 56 | if(fGeom == 0) { |
28a21457 | 57 | fGeom = new AliTOFGeometry(); |
8616d353 | 58 | } |
51346b82 | 59 | |
8616d353 | 60 | fTree = tree; |
61 | /* | |
62 | DecRefCount(); | |
63 | IncRefCount(); | |
64 | */ | |
65 | } | |
66 | /* ******************************************************* */ | |
06b27cbf | 67 | void AliEveTOFDigitsInfo::ReadRaw(AliRawReader* rawReader, Int_t nEvent, Bool_t newDecoder) |
ee9d8eca | 68 | { |
69 | // Read raw-data. AliTOFdigit is used to | |
70 | // store raw-adata for all sub-detectors. | |
71 | ||
545d5001 | 72 | AliTOFCableLengthMap *cableLength = new AliTOFCableLengthMap(); |
73 | ||
ee9d8eca | 74 | //ofstream ftxt; |
75 | //Char_t fileName[100]; | |
76 | //sprintf(fileName,"TOFrawDataReadingFromEVE%d.txt",nEvent); | |
77 | ||
78 | //ftxt.open(fileName,ios::app); | |
79 | //ftxt << endl; | |
80 | //ftxt << " " << nEvent << endl; | |
81 | ||
d12dcb66 | 82 | if (nEvent<0) printf("%3i\n", nEvent); // only to use nEvent variable |
83 | ||
ee9d8eca | 84 | const Int_t kDDL = AliDAQ::NumberOfDdls("TOF"); |
85 | ||
86 | TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000); | |
87 | fTree = new TTree(); | |
39590252 | 88 | fTree->Branch("TOF", &tofDigits, 32000); |
ee9d8eca | 89 | fTree->GetEntry(0); |
90 | ||
91 | TClonesArray * clonesRawData = 0x0; | |
92 | ||
93 | Int_t detectorIndex[5]; | |
94 | Int_t digit[4]; | |
95 | ||
96 | AliTOFRawStream stream(rawReader); | |
97 | ||
98 | for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++) { | |
99 | ||
100 | rawReader->Reset(); | |
06b27cbf | 101 | if (!newDecoder) stream.LoadRawData(indexDDL); |
102 | else stream.LoadRawDataBuffers(indexDDL); | |
ee9d8eca | 103 | |
104 | clonesRawData = (TClonesArray*)stream.GetRawData(); | |
105 | ||
545d5001 | 106 | if (clonesRawData->GetEntriesFast()) AliDebug(2, Form(" Number of TOF digits in the sector number %2i: 5i", indexDDL, clonesRawData->GetEntriesFast())); |
06b27cbf | 107 | |
ee9d8eca | 108 | for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) { |
109 | ||
110 | AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); | |
111 | ||
112 | if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; | |
113 | ||
545d5001 | 114 | Int_t cLenInt = Int_t(cableLength->GetCableTimeShift(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),tofRawDatum->GetTDC())*1000./AliTOFGeometry::TdcBinWidth()); |
115 | digit[0] = tofRawDatum->GetTOF() - cLenInt; | |
ee9d8eca | 116 | digit[1] = tofRawDatum->GetTOT(); |
117 | digit[2] = tofRawDatum->GetTOT(); | |
118 | digit[3] = -1; | |
06b27cbf | 119 | |
ee9d8eca | 120 | /* |
121 | if (indexDDL<10) ftxt << " " << indexDDL; | |
122 | else ftxt << " " << indexDDL; | |
123 | if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM(); | |
124 | else ftxt << " " << tofRawDatum->GetTRM(); | |
125 | ftxt << " " << tofRawDatum->GetTRMchain(); | |
126 | if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC(); | |
127 | else ftxt << " " << tofRawDatum->GetTDC(); | |
128 | ftxt << " " << tofRawDatum->GetTDCchannel(); | |
129 | */ | |
130 | stream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
06b27cbf | 131 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); |
545d5001 | 132 | |
133 | if (detectorIndex[0]==0 || detectorIndex[0]==10) | |
134 | AliDebug(2, Form(" %2i %2i %1i %2i %1i --- %2i %1i %2i %1i %2i %5i - %4i = %5i (%f ns)\n", | |
135 | indexDDL, | |
136 | tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
137 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), | |
138 | detectorIndex[0], detectorIndex[1], | |
139 | detectorIndex[2], detectorIndex[3], | |
140 | detectorIndex[4], tofRawDatum->GetTOF(), | |
141 | cLenInt, tofRawDatum->GetTOF()-cLenInt, | |
142 | (tofRawDatum->GetTOF()-cLenInt)* | |
143 | AliTOFGeometry::TdcBinWidth()/1000.)); | |
144 | ||
ee9d8eca | 145 | /* |
146 | if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0]; | |
147 | else ftxt << " -> " << detectorIndex[0]; | |
148 | ftxt << " " << detectorIndex[1]; | |
149 | if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2]; | |
150 | else ftxt << " " << detectorIndex[2]; | |
151 | ftxt << " " << detectorIndex[3]; | |
152 | if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4]; | |
153 | else ftxt << " " << detectorIndex[4]; | |
154 | ||
155 | if (tofRawDatum->GetTOT()<10) ftxt << " " << tofRawDatum->GetTOT(); | |
156 | else if (tofRawDatum->GetTOT()>=10 && tofRawDatum->GetTOT()<100) ftxt << " " << tofRawDatum->GetTOT(); | |
157 | else if (tofRawDatum->GetTOT()>=100 && tofRawDatum->GetTOT()<1000) ftxt << " " << tofRawDatum->GetTOT(); | |
158 | else if (tofRawDatum->GetTOT()>=1000 && tofRawDatum->GetTOT()<10000) ftxt << " " << tofRawDatum->GetTOT(); | |
159 | else if (tofRawDatum->GetTOT()>=10000 && tofRawDatum->GetTOT()<100000) ftxt << " " << tofRawDatum->GetTOT(); | |
160 | else if (tofRawDatum->GetTOT()>=100000 && tofRawDatum->GetTOT()<1000000) ftxt << " " << tofRawDatum->GetTOT(); | |
161 | else ftxt << " " << tofRawDatum->GetTOT(); | |
162 | if (tofRawDatum->GetTOF()<10) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
163 | else if (tofRawDatum->GetTOF()>=10 && tofRawDatum->GetTOF()<100) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
164 | else if (tofRawDatum->GetTOF()>=100 && tofRawDatum->GetTOF()<1000) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
165 | else if (tofRawDatum->GetTOF()>=1000 && tofRawDatum->GetTOF()<10000) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
166 | else if (tofRawDatum->GetTOF()>=10000 && tofRawDatum->GetTOF()<100000) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
167 | else if (tofRawDatum->GetTOF()>=100000 && tofRawDatum->GetTOF()<1000000) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
168 | else ftxt << " " << tofRawDatum->GetTOF() << endl; | |
169 | */ | |
170 | ||
171 | TClonesArray &aDigits = *tofDigits; | |
172 | Int_t last = tofDigits->GetEntriesFast(); | |
173 | ||
174 | fTOFdigitMap->AddDigit(detectorIndex, last); | |
175 | ||
176 | AliDebug(2,Form(" %3i -> %2i %2i %2i %2i %2i %i %i\n", | |
39590252 | 177 | last, detectorIndex[0], detectorIndex[1], |
178 | detectorIndex[2], detectorIndex[4], detectorIndex[3], | |
ee9d8eca | 179 | digit[1], digit[0])); |
180 | ||
181 | Int_t tracknum[3]={-1,-1,-1}; | |
182 | new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit); | |
183 | ||
184 | } // while loop | |
185 | ||
186 | clonesRawData->Clear(); | |
187 | ||
188 | } // DDL Loop | |
189 | ||
190 | fTree->Fill(); | |
191 | ||
192 | //ftxt.close(); | |
8616d353 | 193 | |
545d5001 | 194 | cableLength = 0x0; |
195 | delete cableLength; | |
196 | ||
ee9d8eca | 197 | } |
198 | ||
06b27cbf | 199 | |
ee9d8eca | 200 | /* ******************************************************* */ |
d810d0de | 201 | void AliEveTOFDigitsInfo::LoadDigits() |
8616d353 | 202 | { |
203 | ||
204 | TClonesArray *digitsTOF = 0x0; | |
205 | AliTOFdigit *digs; | |
206 | ||
207 | fTree->SetBranchAddress("TOF",&digitsTOF); | |
208 | fTree->GetEntry(0); | |
209 | ||
210 | Int_t vol[5] = {-1,-1,-1,-1,-1}; | |
211 | ||
212 | for (Int_t digitNumber=0; digitNumber<digitsTOF->GetEntries(); digitNumber++) { | |
213 | ||
39590252 | 214 | if (digitNumber==digitsTOF->GetEntries()-1) |
215 | AliDebug(2,Form(" Hello 4 -> %3i digit of %i \n", digitNumber+1, digitsTOF->GetEntries())); | |
51346b82 | 216 | |
8616d353 | 217 | digs = (AliTOFdigit*)digitsTOF->UncheckedAt(digitNumber); |
218 | ||
219 | vol[0] = digs->GetSector(); // Sector Number (0-17) | |
220 | vol[1] = digs->GetPlate(); // Plate Number (0-4) | |
221 | vol[2] = digs->GetStrip(); // Strip Number (0-14/18) | |
ee9d8eca | 222 | vol[3] = digs->GetPadx(); // Pad Number in x direction (0-47) |
223 | vol[4] = digs->GetPadz(); // Pad Number in z direction (0-1) | |
8616d353 | 224 | |
225 | fTOFdigitMap->AddDigit(vol, digitNumber); | |
39590252 | 226 | if (digitNumber==digitsTOF->GetEntries()-1) |
227 | AliDebug(2,Form(" I am inside LoadDigits %3i \n", digitNumber)); | |
8616d353 | 228 | |
229 | } | |
230 | ||
231 | } | |
232 | ||
233 | /* ******************************************************* */ | |
234 | ||
d810d0de | 235 | void AliEveTOFDigitsInfo::GetDigits(Int_t nSector, Int_t nPlate, |
39590252 | 236 | Int_t nStrip, Int_t nPadZ, Int_t nPadX, |
237 | Int_t indexDigit[3]) | |
8616d353 | 238 | { |
239 | ||
240 | Int_t vol[5] = {nSector,nPlate,nStrip,nPadX,nPadZ}; | |
241 | ||
242 | fTOFdigitMap->GetDigitIndex(vol, indexDigit); | |
545d5001 | 243 | //for (Int_t ii=1; ii<3; ii++) indexDigit[ii]=-1; |
8616d353 | 244 | |
245 | } | |
246 | /* ******************************************************* */ | |
247 | ||
d810d0de | 248 | TClonesArray* AliEveTOFDigitsInfo::GetDigits(Int_t nSector, Int_t nPlate, |
39590252 | 249 | Int_t nStrip) |
8616d353 | 250 | { |
251 | ||
252 | Int_t newCounter = 0; | |
253 | Int_t nDigitsInVolume[3] = {-1, -1, -1}; | |
254 | Int_t dummy[3] = {-1, -1, -1}; | |
255 | Int_t informations[4] = {-1, -1, -1, -1}; | |
256 | ||
257 | TClonesArray* digitsTOFnew = new TClonesArray("AliTOFdigit", 300); | |
258 | TClonesArray &ldigits = *digitsTOFnew; | |
259 | ||
260 | AliTOFdigit *digs; | |
261 | ||
262 | TClonesArray *digitsTOF = 0x0; | |
263 | fTree->SetBranchAddress("TOF",&digitsTOF); | |
264 | fTree->GetEntry(0); | |
265 | ||
8616d353 | 266 | Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1}; |
267 | ||
268 | for(Int_t iPadZ=0; iPadZ<fGeom->NpadZ(); iPadZ++){ | |
269 | vol[4] = iPadZ; | |
270 | for(Int_t iPadX=0; iPadX<fGeom->NpadX(); iPadX++) { | |
271 | vol[3] = iPadX; | |
272 | ||
8616d353 | 273 | fTOFdigitMap->GetDigitIndex(vol, nDigitsInVolume); |
274 | ||
275 | for (Int_t ii=0; ii<3; ii++) { | |
545d5001 | 276 | //if (ii!=0) continue; |
8616d353 | 277 | if (nDigitsInVolume[ii]>=0 ) { |
39590252 | 278 | AliDebug(2,Form(" nDigitsInVolume[%2i] = %3i\n ", ii, nDigitsInVolume[ii])); |
8616d353 | 279 | digs = (AliTOFdigit*)digitsTOF->UncheckedAt(nDigitsInVolume[ii]); |
280 | informations[0] = digs->GetTdc(); | |
281 | informations[1] = digs->GetAdc(); | |
282 | informations[2] = digs->GetToT(); | |
283 | informations[3] = digs->GetTdcND(); | |
284 | new (ldigits[newCounter++]) AliTOFdigit(dummy, vol, informations); | |
285 | } | |
286 | ||
287 | } | |
288 | ||
289 | for (Int_t ii=0; ii<4; ii++) informations[ii]=-1; | |
290 | for (Int_t ii=0; ii<3; ii++) dummy[ii]=-1; | |
291 | for (Int_t ii=0; ii<3; ii++) nDigitsInVolume[ii]=-1; | |
292 | ||
293 | } | |
294 | } | |
295 | ||
8616d353 | 296 | if (digitsTOFnew) |
545d5001 | 297 | AliDebug(2, Form("Sector %2i Plate %1i Strip %2i -> number of digits %3i \n", |
298 | nSector, nPlate, nStrip, digitsTOFnew->GetEntries())); | |
39590252 | 299 | |
8616d353 | 300 | return digitsTOFnew; |
301 | ||
302 | } | |
303 | /* ******************************************************* */ | |
304 | ||
d810d0de | 305 | TClonesArray* AliEveTOFDigitsInfo::GetDigits(Int_t nSector) |
8616d353 | 306 | { |
307 | ||
308 | Int_t newCounter = 0; | |
309 | Int_t nDigitsInVolume[3] = {-1, -1, -1}; | |
310 | Int_t dummy[3] = {-1, -1, -1}; | |
311 | Int_t informations[4] = {-1, -1, -1, -1}; | |
312 | ||
313 | Int_t nStrips=19; | |
314 | ||
315 | TClonesArray* digitsTOFnew = new TClonesArray("AliTOFdigit", 300); | |
316 | TClonesArray &ldigits = *digitsTOFnew; | |
317 | ||
318 | AliTOFdigit *digs; | |
319 | ||
320 | TClonesArray *digitsTOF = 0x0; | |
321 | fTree->SetBranchAddress("TOF",&digitsTOF); | |
322 | fTree->GetEntry(0); | |
323 | ||
324 | //Int_t nSector = 1; | |
325 | Int_t vol[5] = {nSector,-1,-1,-1,-1}; | |
ee9d8eca | 326 | |
8616d353 | 327 | for(Int_t iPlate=0; iPlate<fGeom->NPlates(); iPlate++){ |
328 | vol[1] = iPlate; | |
329 | if(iPlate==2) nStrips=15; | |
330 | else nStrips=19; | |
51346b82 | 331 | |
8616d353 | 332 | for(Int_t iStrip=0; iStrip<nStrips; iStrip++){ |
333 | vol[2] = iStrip; | |
51346b82 | 334 | |
8616d353 | 335 | for(Int_t iPadZ=0; iPadZ<fGeom->NpadZ(); iPadZ++){ |
336 | vol[4] = iPadZ; | |
337 | ||
338 | for(Int_t iPadX=0; iPadX<fGeom->NpadX(); iPadX++) { | |
339 | vol[3] = iPadX; | |
340 | ||
8616d353 | 341 | fTOFdigitMap->GetDigitIndex(vol, nDigitsInVolume); |
342 | ||
343 | for (Int_t ii=0; ii<3; ii++) { | |
545d5001 | 344 | //if (ii!=0) continue; |
8616d353 | 345 | if (nDigitsInVolume[ii]>=0 ) { |
ee9d8eca | 346 | |
8616d353 | 347 | digs = (AliTOFdigit*)digitsTOF->UncheckedAt(nDigitsInVolume[ii]); |
348 | informations[0] = digs->GetTdc(); | |
349 | informations[1] = digs->GetAdc(); | |
350 | informations[2] = digs->GetToT(); | |
351 | informations[3] = digs->GetTdcND(); | |
352 | new (ldigits[newCounter++]) AliTOFdigit(dummy, vol, informations); | |
ee9d8eca | 353 | |
354 | AliDebug(2,Form(" %2i -> %2i %2i %2i %2i %2i %7i %7i\n", | |
545d5001 | 355 | nDigitsInVolume[ii], |
356 | vol[0], vol[1], vol[2], vol[4], vol[3], | |
39590252 | 357 | informations[1], informations[0])); |
ee9d8eca | 358 | |
8616d353 | 359 | } |
360 | ||
361 | } | |
362 | ||
363 | for (Int_t ii=0; ii<4; ii++) informations[ii]=-1; | |
364 | for (Int_t ii=0; ii<3; ii++) dummy[ii]=-1; | |
365 | for (Int_t ii=0; ii<3; ii++) nDigitsInVolume[ii]=-1; | |
51346b82 | 366 | |
8616d353 | 367 | } |
368 | } | |
369 | } | |
370 | } | |
371 | ||
8616d353 | 372 | if (digitsTOFnew) |
39590252 | 373 | AliDebug(2,Form("Sector %2i -> number of digits %3i \n", |
374 | nSector, digitsTOFnew->GetEntries())); | |
375 | ||
8616d353 | 376 | return digitsTOFnew; |
377 | ||
378 | } | |
379 | /* ******************************************************* */ | |
380 | ||
ee9d8eca | 381 | Int_t AliEveTOFDigitsInfo::GetTOFInfos() const |
382 | { | |
383 | ||
384 | return fTOFdigitMap->GetFilledCellNumber(); | |
385 | ||
386 | } | |
387 | ||
388 | /* ******************************************************* */ | |
389 | Int_t AliEveTOFDigitsInfo::IsStripFilled(Int_t iSector, Int_t iPlate, Int_t iStrip) | |
390 | { | |
391 | ||
392 | Int_t vol[5] = {iSector, iPlate, iStrip, -1, -1}; | |
393 | ||
394 | Int_t index = 0; | |
395 | ||
396 | for (Int_t iPadZ=0; iPadZ<fGeom->NpadZ(); iPadZ++) | |
397 | for (Int_t iPadX=0; iPadX<fGeom->NpadX(); iPadX++) | |
398 | { | |
399 | vol[3] = iPadX; | |
400 | vol[4] = iPadZ; | |
401 | if (fTOFdigitMap->GetDigitIndex(vol,0)>=0) index++; | |
402 | } | |
403 | ||
404 | return index; | |
405 | ||
406 | } | |
407 | ||
408 | /* ******************************************************* */ | |
39590252 | 409 | /* |
d810d0de | 410 | void AliEveTOFDigitsInfo::GetDigits() |
8616d353 | 411 | { |
412 | ||
413 | for (Int_t iSector=0; iSector<fGeom->NSectors(); iSector++) { | |
414 | ||
415 | fNewTree = new TTree(); | |
416 | ||
417 | ||
418 | ||
419 | ||
420 | } | |
421 | ||
422 | } | |
39590252 | 423 | */ |