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