]>
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 | /* ******************************************************* */ | |
82dabae7 | 67 | void AliEveTOFDigitsInfo::ReadRaw(AliRawReader* rawReader, 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 | ||
82dabae7 | 82 | //if (nEvent<0) printf("%3i\n", nEvent); // only to use nEvent variable |
d12dcb66 | 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 | ||
82dabae7 | 112 | if (tofRawDatum->GetTOF()==-1) continue; |
ee9d8eca | 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 | */ | |
82dabae7 | 130 | |
ee9d8eca | 131 | stream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), |
06b27cbf | 132 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); |
545d5001 | 133 | |
134 | if (detectorIndex[0]==0 || detectorIndex[0]==10) | |
135 | AliDebug(2, Form(" %2i %2i %1i %2i %1i --- %2i %1i %2i %1i %2i %5i - %4i = %5i (%f ns)\n", | |
136 | indexDDL, | |
137 | tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), | |
138 | tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), | |
139 | detectorIndex[0], detectorIndex[1], | |
140 | detectorIndex[2], detectorIndex[3], | |
141 | detectorIndex[4], tofRawDatum->GetTOF(), | |
142 | cLenInt, tofRawDatum->GetTOF()-cLenInt, | |
143 | (tofRawDatum->GetTOF()-cLenInt)* | |
144 | AliTOFGeometry::TdcBinWidth()/1000.)); | |
145 | ||
ee9d8eca | 146 | /* |
147 | if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0]; | |
148 | else ftxt << " -> " << detectorIndex[0]; | |
149 | ftxt << " " << detectorIndex[1]; | |
150 | if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2]; | |
151 | else ftxt << " " << detectorIndex[2]; | |
152 | ftxt << " " << detectorIndex[3]; | |
153 | if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4]; | |
154 | else ftxt << " " << detectorIndex[4]; | |
155 | ||
156 | if (tofRawDatum->GetTOT()<10) ftxt << " " << tofRawDatum->GetTOT(); | |
157 | else if (tofRawDatum->GetTOT()>=10 && tofRawDatum->GetTOT()<100) ftxt << " " << tofRawDatum->GetTOT(); | |
158 | else if (tofRawDatum->GetTOT()>=100 && tofRawDatum->GetTOT()<1000) ftxt << " " << tofRawDatum->GetTOT(); | |
159 | else if (tofRawDatum->GetTOT()>=1000 && tofRawDatum->GetTOT()<10000) ftxt << " " << tofRawDatum->GetTOT(); | |
160 | else if (tofRawDatum->GetTOT()>=10000 && tofRawDatum->GetTOT()<100000) ftxt << " " << tofRawDatum->GetTOT(); | |
161 | else if (tofRawDatum->GetTOT()>=100000 && tofRawDatum->GetTOT()<1000000) ftxt << " " << tofRawDatum->GetTOT(); | |
162 | else ftxt << " " << tofRawDatum->GetTOT(); | |
163 | if (tofRawDatum->GetTOF()<10) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
164 | else if (tofRawDatum->GetTOF()>=10 && tofRawDatum->GetTOF()<100) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
165 | else if (tofRawDatum->GetTOF()>=100 && tofRawDatum->GetTOF()<1000) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
166 | else if (tofRawDatum->GetTOF()>=1000 && tofRawDatum->GetTOF()<10000) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
167 | else if (tofRawDatum->GetTOF()>=10000 && tofRawDatum->GetTOF()<100000) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
168 | else if (tofRawDatum->GetTOF()>=100000 && tofRawDatum->GetTOF()<1000000) ftxt << " " << tofRawDatum->GetTOF() << endl; | |
169 | else ftxt << " " << tofRawDatum->GetTOF() << endl; | |
170 | */ | |
171 | ||
172 | TClonesArray &aDigits = *tofDigits; | |
173 | Int_t last = tofDigits->GetEntriesFast(); | |
174 | ||
175 | fTOFdigitMap->AddDigit(detectorIndex, last); | |
176 | ||
177 | AliDebug(2,Form(" %3i -> %2i %2i %2i %2i %2i %i %i\n", | |
39590252 | 178 | last, detectorIndex[0], detectorIndex[1], |
179 | detectorIndex[2], detectorIndex[4], detectorIndex[3], | |
ee9d8eca | 180 | digit[1], digit[0])); |
181 | ||
182 | Int_t tracknum[3]={-1,-1,-1}; | |
183 | new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit); | |
184 | ||
185 | } // while loop | |
186 | ||
187 | clonesRawData->Clear(); | |
188 | ||
189 | } // DDL Loop | |
190 | ||
191 | fTree->Fill(); | |
192 | ||
193 | //ftxt.close(); | |
8616d353 | 194 | |
545d5001 | 195 | cableLength = 0x0; |
196 | delete cableLength; | |
197 | ||
ee9d8eca | 198 | } |
199 | ||
06b27cbf | 200 | |
ee9d8eca | 201 | /* ******************************************************* */ |
d810d0de | 202 | void AliEveTOFDigitsInfo::LoadDigits() |
8616d353 | 203 | { |
204 | ||
205 | TClonesArray *digitsTOF = 0x0; | |
206 | AliTOFdigit *digs; | |
207 | ||
208 | fTree->SetBranchAddress("TOF",&digitsTOF); | |
209 | fTree->GetEntry(0); | |
210 | ||
211 | Int_t vol[5] = {-1,-1,-1,-1,-1}; | |
212 | ||
213 | for (Int_t digitNumber=0; digitNumber<digitsTOF->GetEntries(); digitNumber++) { | |
214 | ||
39590252 | 215 | if (digitNumber==digitsTOF->GetEntries()-1) |
216 | AliDebug(2,Form(" Hello 4 -> %3i digit of %i \n", digitNumber+1, digitsTOF->GetEntries())); | |
51346b82 | 217 | |
8616d353 | 218 | digs = (AliTOFdigit*)digitsTOF->UncheckedAt(digitNumber); |
219 | ||
220 | vol[0] = digs->GetSector(); // Sector Number (0-17) | |
221 | vol[1] = digs->GetPlate(); // Plate Number (0-4) | |
222 | vol[2] = digs->GetStrip(); // Strip Number (0-14/18) | |
ee9d8eca | 223 | vol[3] = digs->GetPadx(); // Pad Number in x direction (0-47) |
224 | vol[4] = digs->GetPadz(); // Pad Number in z direction (0-1) | |
8616d353 | 225 | |
226 | fTOFdigitMap->AddDigit(vol, digitNumber); | |
39590252 | 227 | if (digitNumber==digitsTOF->GetEntries()-1) |
228 | AliDebug(2,Form(" I am inside LoadDigits %3i \n", digitNumber)); | |
8616d353 | 229 | |
230 | } | |
231 | ||
232 | } | |
233 | ||
234 | /* ******************************************************* */ | |
235 | ||
d810d0de | 236 | void AliEveTOFDigitsInfo::GetDigits(Int_t nSector, Int_t nPlate, |
39590252 | 237 | Int_t nStrip, Int_t nPadZ, Int_t nPadX, |
238 | Int_t indexDigit[3]) | |
8616d353 | 239 | { |
240 | ||
241 | Int_t vol[5] = {nSector,nPlate,nStrip,nPadX,nPadZ}; | |
242 | ||
243 | fTOFdigitMap->GetDigitIndex(vol, indexDigit); | |
545d5001 | 244 | //for (Int_t ii=1; ii<3; ii++) indexDigit[ii]=-1; |
8616d353 | 245 | |
246 | } | |
247 | /* ******************************************************* */ | |
248 | ||
d810d0de | 249 | TClonesArray* AliEveTOFDigitsInfo::GetDigits(Int_t nSector, Int_t nPlate, |
39590252 | 250 | Int_t nStrip) |
8616d353 | 251 | { |
252 | ||
253 | Int_t newCounter = 0; | |
254 | Int_t nDigitsInVolume[3] = {-1, -1, -1}; | |
255 | Int_t dummy[3] = {-1, -1, -1}; | |
256 | Int_t informations[4] = {-1, -1, -1, -1}; | |
257 | ||
258 | TClonesArray* digitsTOFnew = new TClonesArray("AliTOFdigit", 300); | |
259 | TClonesArray &ldigits = *digitsTOFnew; | |
260 | ||
261 | AliTOFdigit *digs; | |
262 | ||
263 | TClonesArray *digitsTOF = 0x0; | |
264 | fTree->SetBranchAddress("TOF",&digitsTOF); | |
265 | fTree->GetEntry(0); | |
266 | ||
8616d353 | 267 | Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1}; |
268 | ||
269 | for(Int_t iPadZ=0; iPadZ<fGeom->NpadZ(); iPadZ++){ | |
270 | vol[4] = iPadZ; | |
271 | for(Int_t iPadX=0; iPadX<fGeom->NpadX(); iPadX++) { | |
272 | vol[3] = iPadX; | |
273 | ||
8616d353 | 274 | fTOFdigitMap->GetDigitIndex(vol, nDigitsInVolume); |
275 | ||
276 | for (Int_t ii=0; ii<3; ii++) { | |
545d5001 | 277 | //if (ii!=0) continue; |
8616d353 | 278 | if (nDigitsInVolume[ii]>=0 ) { |
39590252 | 279 | AliDebug(2,Form(" nDigitsInVolume[%2i] = %3i\n ", ii, nDigitsInVolume[ii])); |
8616d353 | 280 | digs = (AliTOFdigit*)digitsTOF->UncheckedAt(nDigitsInVolume[ii]); |
281 | informations[0] = digs->GetTdc(); | |
282 | informations[1] = digs->GetAdc(); | |
283 | informations[2] = digs->GetToT(); | |
284 | informations[3] = digs->GetTdcND(); | |
82dabae7 | 285 | for(Int_t kk=0; kk<3; kk++) dummy[kk] = digs->GetTrack(kk); |
8616d353 | 286 | new (ldigits[newCounter++]) AliTOFdigit(dummy, vol, informations); |
287 | } | |
288 | ||
289 | } | |
290 | ||
291 | for (Int_t ii=0; ii<4; ii++) informations[ii]=-1; | |
292 | for (Int_t ii=0; ii<3; ii++) dummy[ii]=-1; | |
293 | for (Int_t ii=0; ii<3; ii++) nDigitsInVolume[ii]=-1; | |
294 | ||
295 | } | |
296 | } | |
297 | ||
8616d353 | 298 | if (digitsTOFnew) |
545d5001 | 299 | AliDebug(2, Form("Sector %2i Plate %1i Strip %2i -> number of digits %3i \n", |
300 | nSector, nPlate, nStrip, digitsTOFnew->GetEntries())); | |
39590252 | 301 | |
8616d353 | 302 | return digitsTOFnew; |
303 | ||
304 | } | |
305 | /* ******************************************************* */ | |
306 | ||
d810d0de | 307 | TClonesArray* AliEveTOFDigitsInfo::GetDigits(Int_t nSector) |
8616d353 | 308 | { |
309 | ||
310 | Int_t newCounter = 0; | |
311 | Int_t nDigitsInVolume[3] = {-1, -1, -1}; | |
312 | Int_t dummy[3] = {-1, -1, -1}; | |
313 | Int_t informations[4] = {-1, -1, -1, -1}; | |
314 | ||
315 | Int_t nStrips=19; | |
316 | ||
317 | TClonesArray* digitsTOFnew = new TClonesArray("AliTOFdigit", 300); | |
318 | TClonesArray &ldigits = *digitsTOFnew; | |
319 | ||
320 | AliTOFdigit *digs; | |
321 | ||
322 | TClonesArray *digitsTOF = 0x0; | |
323 | fTree->SetBranchAddress("TOF",&digitsTOF); | |
324 | fTree->GetEntry(0); | |
325 | ||
326 | //Int_t nSector = 1; | |
327 | Int_t vol[5] = {nSector,-1,-1,-1,-1}; | |
ee9d8eca | 328 | |
8616d353 | 329 | for(Int_t iPlate=0; iPlate<fGeom->NPlates(); iPlate++){ |
330 | vol[1] = iPlate; | |
331 | if(iPlate==2) nStrips=15; | |
332 | else nStrips=19; | |
51346b82 | 333 | |
8616d353 | 334 | for(Int_t iStrip=0; iStrip<nStrips; iStrip++){ |
335 | vol[2] = iStrip; | |
51346b82 | 336 | |
8616d353 | 337 | for(Int_t iPadZ=0; iPadZ<fGeom->NpadZ(); iPadZ++){ |
338 | vol[4] = iPadZ; | |
339 | ||
340 | for(Int_t iPadX=0; iPadX<fGeom->NpadX(); iPadX++) { | |
341 | vol[3] = iPadX; | |
342 | ||
8616d353 | 343 | fTOFdigitMap->GetDigitIndex(vol, nDigitsInVolume); |
344 | ||
345 | for (Int_t ii=0; ii<3; ii++) { | |
545d5001 | 346 | //if (ii!=0) continue; |
8616d353 | 347 | if (nDigitsInVolume[ii]>=0 ) { |
ee9d8eca | 348 | |
8616d353 | 349 | digs = (AliTOFdigit*)digitsTOF->UncheckedAt(nDigitsInVolume[ii]); |
350 | informations[0] = digs->GetTdc(); | |
351 | informations[1] = digs->GetAdc(); | |
352 | informations[2] = digs->GetToT(); | |
353 | informations[3] = digs->GetTdcND(); | |
82dabae7 | 354 | for(Int_t kk=0; kk<3; kk++) dummy[kk] = digs->GetTrack(kk); |
8616d353 | 355 | new (ldigits[newCounter++]) AliTOFdigit(dummy, vol, informations); |
ee9d8eca | 356 | |
357 | AliDebug(2,Form(" %2i -> %2i %2i %2i %2i %2i %7i %7i\n", | |
545d5001 | 358 | nDigitsInVolume[ii], |
359 | vol[0], vol[1], vol[2], vol[4], vol[3], | |
39590252 | 360 | informations[1], informations[0])); |
ee9d8eca | 361 | |
8616d353 | 362 | } |
363 | ||
364 | } | |
365 | ||
366 | for (Int_t ii=0; ii<4; ii++) informations[ii]=-1; | |
367 | for (Int_t ii=0; ii<3; ii++) dummy[ii]=-1; | |
368 | for (Int_t ii=0; ii<3; ii++) nDigitsInVolume[ii]=-1; | |
51346b82 | 369 | |
8616d353 | 370 | } |
371 | } | |
372 | } | |
373 | } | |
374 | ||
8616d353 | 375 | if (digitsTOFnew) |
39590252 | 376 | AliDebug(2,Form("Sector %2i -> number of digits %3i \n", |
377 | nSector, digitsTOFnew->GetEntries())); | |
378 | ||
8616d353 | 379 | return digitsTOFnew; |
380 | ||
381 | } | |
382 | /* ******************************************************* */ | |
383 | ||
ee9d8eca | 384 | Int_t AliEveTOFDigitsInfo::GetTOFInfos() const |
385 | { | |
386 | ||
387 | return fTOFdigitMap->GetFilledCellNumber(); | |
388 | ||
389 | } | |
390 | ||
391 | /* ******************************************************* */ | |
392 | Int_t AliEveTOFDigitsInfo::IsStripFilled(Int_t iSector, Int_t iPlate, Int_t iStrip) | |
393 | { | |
394 | ||
395 | Int_t vol[5] = {iSector, iPlate, iStrip, -1, -1}; | |
396 | ||
397 | Int_t index = 0; | |
398 | ||
399 | for (Int_t iPadZ=0; iPadZ<fGeom->NpadZ(); iPadZ++) | |
400 | for (Int_t iPadX=0; iPadX<fGeom->NpadX(); iPadX++) | |
401 | { | |
402 | vol[3] = iPadX; | |
403 | vol[4] = iPadZ; | |
404 | if (fTOFdigitMap->GetDigitIndex(vol,0)>=0) index++; | |
405 | } | |
406 | ||
407 | return index; | |
408 | ||
409 | } | |
410 | ||
411 | /* ******************************************************* */ | |
39590252 | 412 | /* |
d810d0de | 413 | void AliEveTOFDigitsInfo::GetDigits() |
8616d353 | 414 | { |
415 | ||
416 | for (Int_t iSector=0; iSector<fGeom->NSectors(); iSector++) { | |
417 | ||
418 | fNewTree = new TTree(); | |
419 | ||
420 | ||
421 | ||
422 | ||
423 | } | |
424 | ||
425 | } | |
39590252 | 426 | */ |