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