]>
Commit | Line | Data |
---|---|---|
31d9405a | 1 | //$Id$ |
2 | ||
b661165c | 3 | // Author: Uli Frankenfeld <mailto:franken@fi.uib.no> |
4 | //*-- Copyright © Uli | |
108615fc | 5 | |
6 | #include <math.h> | |
7 | #include <iostream.h> | |
108615fc | 8 | |
9 | #include "AliL3Transform.h" | |
10 | #include "AliL3Logging.h" | |
11 | #include "AliL3MemHandler.h" | |
12 | #include "AliL3FileHandler.h" | |
13 | ||
0d319e67 | 14 | #include "AliTPCDigitsArray.h" |
108615fc | 15 | #include "AliTPCClustersArray.h" |
16 | #include "AliTPCcluster.h" | |
17 | #include "AliTPCClustersRow.h" | |
108615fc | 18 | |
19 | #include "AliL3DigitData.h" | |
20 | #include "AliL3TrackSegmentData.h" | |
21 | #include "AliL3SpacePointData.h" | |
22 | #include "AliL3TrackArray.h" | |
b661165c | 23 | |
108615fc | 24 | //_____________________________________________________________ |
b661165c | 25 | // AliL3FileHandler |
108615fc | 26 | // |
27 | // The L3 Binary File handler | |
28 | // | |
29 | ||
30 | ClassImp(AliL3FileHandler) | |
31 | ||
32 | AliL3FileHandler::AliL3FileHandler(){ | |
33 | //Default constructor | |
34 | fInAli = 0; | |
35 | fParam = 0; | |
36 | fTransformer = 0; | |
37 | fMC =0; | |
a6e4f9d6 | 38 | fLastIndex=0; |
39 | fDigits=0; | |
40 | fDigitsTree=0; | |
108615fc | 41 | } |
42 | ||
108615fc | 43 | AliL3FileHandler::~AliL3FileHandler(){ |
44 | //Destructor | |
45 | if(fTransformer) delete fTransformer; | |
46 | if(fMC) CloseMCOutput(); | |
a6e4f9d6 | 47 | if(fDigitsTree) delete fDigitsTree; |
8f1a9904 | 48 | if(fInAli) CloseAliInput(); |
a6e4f9d6 | 49 | |
108615fc | 50 | } |
51 | ||
52 | Bool_t AliL3FileHandler::SetMCOutput(char *name){ | |
53 | fMC = fopen(name,"w"); | |
54 | if(!fMC){ | |
55 | LOG(AliL3Log::kWarning,"AliL3FileHandler::SetMCOutput","File Open") | |
56 | <<"Pointer to File = 0x0 "<<ENDLOG; | |
57 | return kFALSE; | |
58 | } | |
59 | return kTRUE; | |
60 | } | |
61 | ||
62 | Bool_t AliL3FileHandler::SetMCOutput(FILE *file){ | |
63 | fMC = file; | |
64 | if(!fMC){ | |
65 | LOG(AliL3Log::kWarning,"AliL3FileHandler::SetMCOutput","File Open") | |
66 | <<"Pointer to File = 0x0 "<<ENDLOG; | |
67 | return kFALSE; | |
68 | } | |
69 | return kTRUE; | |
70 | } | |
71 | ||
72 | void AliL3FileHandler::CloseMCOutput(){ | |
73 | if(!fMC){ | |
74 | LOG(AliL3Log::kWarning,"AliL3FileHandler::CloseMCOutPut","File Close") | |
75 | <<"Nothing to Close"<<ENDLOG; | |
76 | return; | |
77 | } | |
78 | fclose(fMC); | |
79 | fMC =0; | |
80 | } | |
81 | ||
82 | Bool_t AliL3FileHandler::SetAliInput(){ | |
83 | if(!fInAli->IsOpen()){ | |
84 | LOG(AliL3Log::kError,"AliL3FileHandler::SetAliInput","File Open") | |
85 | <<"Ali File "<<fInAli->GetName()<<" does not exist"<<ENDLOG; | |
86 | return kFALSE; | |
87 | } | |
88 | fParam = (AliTPCParam*)fInAli->Get("75x40_100x60"); | |
89 | if(!fParam){ | |
90 | LOG(AliL3Log::kError,"AliL3FileHandler::SetAliInput","File Open") | |
91 | <<"No AliTPCParam 75x40_100x60 in File "<<fInAli->GetName()<<ENDLOG; | |
92 | return kFALSE; | |
93 | } | |
94 | fTransformer = new AliL3Transform(); | |
95 | return kTRUE; | |
96 | } | |
97 | ||
98 | Bool_t AliL3FileHandler::SetAliInput(char *name){ | |
99 | fInAli= new TFile(name,"READ"); | |
100 | if(!fInAli){ | |
101 | LOG(AliL3Log::kWarning,"AliL3FileHandler::SetAliInput","File Open") | |
102 | <<"Pointer to TFile = 0x0 "<<ENDLOG; | |
103 | return kFALSE; | |
104 | } | |
105 | return SetAliInput(); | |
106 | } | |
107 | ||
108 | Bool_t AliL3FileHandler::SetAliInput(TFile *file){ | |
109 | fInAli=file; | |
110 | if(!fInAli){ | |
111 | LOG(AliL3Log::kWarning,"AliL3FileHandler::SetAliInput","File Open") | |
112 | <<"Pointer to TFile = 0x0 "<<ENDLOG; | |
113 | return kFALSE; | |
114 | } | |
115 | return SetAliInput(); | |
116 | } | |
117 | ||
118 | void AliL3FileHandler::CloseAliInput(){ | |
119 | if(!fInAli){ | |
120 | LOG(AliL3Log::kWarning,"AliL3FileHandler::CloseAliInput","File Close") | |
121 | <<"Nothing to Close"<<ENDLOG; | |
122 | return; | |
123 | } | |
124 | if(fInAli->IsOpen()) fInAli->Close(); | |
125 | delete fInAli; | |
126 | fInAli = 0; | |
8f1a9904 | 127 | |
108615fc | 128 | } |
129 | ||
130 | Bool_t AliL3FileHandler::IsDigit(){ | |
131 | if(!fInAli){ | |
132 | LOG(AliL3Log::kWarning,"AliL3FileHandler::IsDigit","File") | |
133 | <<"Pointer to TFile = 0x0 "<<ENDLOG; | |
134 | return kTRUE; //may you are use binary input which is Digits!! | |
135 | } | |
03b6adf7 | 136 | TTree *t=(TTree*)fInAli->Get("TreeD_75x40_100x60_0"); |
108615fc | 137 | if(t){ |
138 | LOG(AliL3Log::kInformational,"AliL3FileHandler::IsDigit","File Type") | |
139 | <<"Found Digit Tree -> Use Fast Cluster Finder"<<ENDLOG; | |
140 | return kTRUE; | |
141 | } | |
142 | else{ | |
143 | LOG(AliL3Log::kInformational,"AliL3FileHandler::IsDigit","File Type") | |
144 | <<"No Digit Tree -> Use Cluster Tree"<<ENDLOG; | |
145 | return kFALSE; | |
146 | } | |
147 | } | |
148 | ||
149 | ///////////////////////////////////////// Digit IO | |
31d9405a | 150 | Bool_t AliL3FileHandler::AliDigits2Binary(Int_t event){ |
108615fc | 151 | Bool_t out = kTRUE; |
152 | UInt_t nrow; | |
31d9405a | 153 | AliL3DigitRowData* data = AliDigits2Memory(nrow,event); |
108615fc | 154 | out = Memory2Binary(nrow,data); |
155 | Free(); | |
156 | return out; | |
157 | } | |
158 | ||
159 | ||
31d9405a | 160 | Bool_t AliL3FileHandler::AliDigits2CompBinary(Int_t event){ |
108615fc | 161 | Bool_t out = kTRUE; |
162 | UInt_t ndigits=0; | |
31d9405a | 163 | AliL3DigitRowData* digits = AliDigits2Memory(ndigits,event); |
108615fc | 164 | out = Memory2CompBinary(ndigits,digits); |
165 | Free(); | |
166 | return out; | |
167 | } | |
168 | ||
169 | ||
31d9405a | 170 | AliL3DigitRowData * AliL3FileHandler::AliDigits2Memory(UInt_t & nrow,Int_t event){ |
108615fc | 171 | AliL3DigitRowData *data = 0; |
172 | nrow=0; | |
173 | if(!fInAli){ | |
174 | LOG(AliL3Log::kWarning,"AliL3FileHandler::AliDigits2Memory","File") | |
175 | <<"No Input avalible: no object TFile"<<ENDLOG; | |
176 | return 0; | |
177 | } | |
178 | if(!fInAli->IsOpen()){ | |
179 | LOG(AliL3Log::kWarning,"AliL3FileHandler::AliDigits2Memory","File") | |
180 | <<"No Input avalible: TFile not opend"<<ENDLOG; | |
181 | return 0; | |
182 | } | |
183 | ||
a6e4f9d6 | 184 | if(!fDigitsTree) |
185 | GetDigitsTree(event); | |
186 | ||
108615fc | 187 | UShort_t dig; |
188 | Int_t time,pad,sector,row; | |
189 | Int_t nrows=0; | |
190 | Int_t ndigitcount=0; | |
a6e4f9d6 | 191 | Int_t entries = (Int_t)fDigitsTree->GetEntries(); |
108615fc | 192 | Int_t ndigits[entries]; |
193 | Int_t lslice,lrow; | |
a6e4f9d6 | 194 | |
195 | for(Int_t n=fLastIndex; n<fDigitsTree->GetEntries(); n++) | |
108615fc | 196 | { |
a6e4f9d6 | 197 | fDigitsTree->GetEvent(n); |
198 | fParam->AdjustSectorRow(fDigits->GetID(),sector,row); | |
108615fc | 199 | fTransformer->Sector2Slice(lslice,lrow,sector,row); |
a6e4f9d6 | 200 | //if(fSlice != lslice || lrow<fRowMin || lrow>fRowMax) continue; |
201 | if(lslice < fSlice) continue; | |
202 | if(lslice != fSlice) break; | |
203 | if(lrow < fRowMin) continue; | |
204 | if(lrow > fRowMax) break; | |
108615fc | 205 | |
206 | Float_t xyz[3]; | |
207 | ndigits[lrow] = 0; | |
a6e4f9d6 | 208 | fDigits->First(); |
108615fc | 209 | do { |
a6e4f9d6 | 210 | time=fDigits->CurrentRow(); |
211 | pad=fDigits->CurrentColumn(); | |
212 | dig = fDigits->GetDigit(time,pad); | |
108615fc | 213 | if(dig<=fParam->GetZeroSup()) continue; |
214 | if(time < fParam->GetMaxTBin()-1 && time > 0) | |
a6e4f9d6 | 215 | if(fDigits->GetDigit(time+1,pad) <= fParam->GetZeroSup() |
216 | && fDigits->GetDigit(time-1,pad) <= fParam->GetZeroSup()) | |
108615fc | 217 | continue; |
218 | ||
219 | fTransformer->Raw2Local(xyz,sector,row,pad,time); | |
220 | if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) | |
221 | continue; | |
222 | ||
223 | ndigits[lrow]++; //for this row only | |
224 | ndigitcount++; //total number of digits to be published | |
225 | ||
a6e4f9d6 | 226 | } while (fDigits->Next()); |
108615fc | 227 | |
228 | nrows++; | |
229 | } | |
230 | Int_t size = sizeof(AliL3DigitData)*ndigitcount | |
8f1a9904 | 231 | + nrows*sizeof(AliL3DigitRowData); |
108615fc | 232 | |
233 | LOG(AliL3Log::kDebug,"AliL3FileHandler::AliDigits2Memory","Digits") | |
a6e4f9d6 | 234 | <<AliL3Log::kDec<<"Found "<<ndigitcount<<" Digits"<<ENDLOG; |
235 | ||
108615fc | 236 | data=(AliL3DigitRowData*) Allocate(size); |
237 | nrow = (UInt_t)nrows; | |
238 | AliL3DigitRowData *tempPt = data; | |
a6e4f9d6 | 239 | for(Int_t n=fLastIndex; n<fDigitsTree->GetEntries(); n++) |
108615fc | 240 | { |
a6e4f9d6 | 241 | fDigitsTree->GetEvent(n); |
108615fc | 242 | Float_t xyz[3]; |
a6e4f9d6 | 243 | fParam->AdjustSectorRow(fDigits->GetID(),sector,row); |
108615fc | 244 | fTransformer->Sector2Slice(lslice,lrow,sector,row); |
a6e4f9d6 | 245 | //if(fSlice != lslice || lrow<fRowMin || lrow>fRowMax) continue; |
246 | if(lslice < fSlice) continue; | |
247 | if(lslice != fSlice) break; | |
248 | if(lrow < fRowMin) continue; | |
249 | if(lrow > fRowMax) break; | |
250 | ||
108615fc | 251 | tempPt->fRow = lrow; |
252 | tempPt->fNDigit = ndigits[lrow]; | |
253 | ||
254 | Int_t localcount=0; | |
a6e4f9d6 | 255 | fDigits->First(); |
108615fc | 256 | do { |
a6e4f9d6 | 257 | //dig=fDigits->CurrentDigit(); |
03b6adf7 | 258 | //if (dig<=fParam->GetZeroSup()) continue; |
a6e4f9d6 | 259 | time=fDigits->CurrentRow(); |
260 | pad=fDigits->CurrentColumn(); | |
261 | dig = fDigits->GetDigit(time,pad); | |
03b6adf7 | 262 | if (dig <= fParam->GetZeroSup()) continue; |
263 | if(time < fParam->GetMaxTBin()-1 && time > 0) | |
a6e4f9d6 | 264 | if(fDigits->GetDigit(time-1,pad) <= fParam->GetZeroSup() && |
265 | fDigits->GetDigit(time+1,pad) <= fParam->GetZeroSup()) continue; | |
108615fc | 266 | |
267 | //Exclude data outside cone: | |
268 | fTransformer->Raw2Local(xyz,sector,row,pad,time); | |
269 | if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) | |
270 | continue; | |
271 | ||
272 | if(localcount >= ndigits[lrow]) | |
273 | LOG(AliL3Log::kFatal,"AliL3FileHandler::AliDigits2Binary","Memory") | |
03b6adf7 | 274 | <<AliL3Log::kDec<<"Mismatch: localcount "<<localcount<<" ndigits " |
275 | <<ndigits[lrow]<<ENDLOG; | |
276 | ||
108615fc | 277 | tempPt->fDigitData[localcount].fCharge=dig; |
278 | tempPt->fDigitData[localcount].fPad=pad; | |
279 | tempPt->fDigitData[localcount].fTime=time; | |
10f815d9 | 280 | #ifdef do_mc |
281 | tempPt->fDigitData[localcount].fTrackID[0] = fDigits->GetTrackID(time,pad,0); | |
282 | tempPt->fDigitData[localcount].fTrackID[1] = fDigits->GetTrackID(time,pad,1); | |
283 | tempPt->fDigitData[localcount].fTrackID[2] = fDigits->GetTrackID(time,pad,2); | |
284 | #endif | |
108615fc | 285 | localcount++; |
a6e4f9d6 | 286 | } while (fDigits->Next()); |
108615fc | 287 | |
288 | Byte_t *tmp = (Byte_t*)tempPt; | |
289 | Int_t size = sizeof(AliL3DigitRowData) | |
290 | + ndigits[lrow]*sizeof(AliL3DigitData); | |
291 | tmp += size; | |
292 | tempPt = (AliL3DigitRowData*)tmp; | |
a6e4f9d6 | 293 | //fLastIndex=n; |
108615fc | 294 | } |
a6e4f9d6 | 295 | //fLastIndex++; |
108615fc | 296 | return data; |
297 | } | |
298 | ||
a6e4f9d6 | 299 | Bool_t AliL3FileHandler::GetDigitsTree(Int_t event) |
300 | { | |
301 | ||
302 | fInAli->cd(); | |
303 | Char_t dname[100]; | |
304 | sprintf(dname,"TreeD_75x40_100x60_%d",event); | |
305 | fDigitsTree = (TTree*)fInAli->Get("TreeD_75x40_100x60_0"); | |
306 | if(!fDigitsTree) | |
307 | { | |
308 | LOG(AliL3Log::kError,"AliL3FileHandler::GetDigitsTree","Digits Tree") | |
309 | <<AliL3Log::kHex<<"Error getting digitstree "<<(Int_t)fDigitsTree<<ENDLOG; | |
310 | return kFALSE; | |
311 | } | |
312 | fDigitsTree->GetBranch("Segment")->SetAddress(&fDigits); | |
313 | return kTRUE; | |
314 | } | |
315 | ||
0d319e67 | 316 | void AliL3FileHandler::AliDigits2RootFile(AliL3DigitRowData *rowPt,Char_t *new_digitsfile) |
317 | { | |
318 | //Write digits to a new alirootfile. | |
319 | ||
320 | if(!fInAli) | |
321 | { | |
8f1a9904 | 322 | printf("AliL3FileHandler::AliDigits2RootFile : No rootfile\n"); |
0d319e67 | 323 | return; |
324 | } | |
325 | if(!fParam) | |
326 | { | |
327 | printf("AliL3FileHandler::AliDigits2RootFile : No parameter object. Run on rootfile\n"); | |
328 | return; | |
329 | } | |
330 | if(!fTransformer) | |
331 | { | |
332 | printf("AliL3FileHandler::AliDigits2RootFile : No transform object\n"); | |
333 | return; | |
334 | } | |
335 | ||
336 | //Get the original digitstree: | |
337 | fInAli->cd(); | |
338 | AliTPCDigitsArray *old_array = new AliTPCDigitsArray(); | |
339 | old_array->Setup(fParam); | |
340 | old_array->SetClass("AliSimDigits"); | |
03b6adf7 | 341 | Bool_t ok = old_array->ConnectTree("TreeD_75x40_100x60_0"); |
0d319e67 | 342 | if(!ok) |
343 | { | |
344 | printf("AliL3FileHandler::AliDigits2RootFile : No digits tree object\n"); | |
345 | return; | |
346 | } | |
0d319e67 | 347 | |
03b6adf7 | 348 | Bool_t create=kFALSE; |
349 | TFile *digFile; | |
350 | ||
8f1a9904 | 351 | digFile = TFile::Open(new_digitsfile,"NEW"); |
352 | if(digFile->IsOpen()) | |
03b6adf7 | 353 | { |
03b6adf7 | 354 | create = kTRUE; |
355 | fParam->Write(fParam->GetTitle()); | |
356 | } | |
357 | else | |
358 | { | |
8f1a9904 | 359 | LOG(AliL3Log::kDebug,"AliL3FileHandler::AliDigits2RootFile","Rootfile") |
360 | <<"Rootfile did already exist, so I will just open it for updates"<<ENDLOG; | |
03b6adf7 | 361 | digFile = TFile::Open(new_digitsfile,"UPDATE"); |
362 | create=kFALSE; | |
363 | } | |
364 | if(!digFile->IsOpen()) | |
365 | { | |
8f1a9904 | 366 | LOG(AliL3Log::kError,"AliL3FileHandler::AliDigits2RootFile","Rootfile") |
367 | <<"Error opening rootfile "<<new_digitsfile<<ENDLOG; | |
03b6adf7 | 368 | return; |
369 | } | |
370 | ||
371 | digFile->cd(); | |
372 | ||
373 | //setup a new one, or connect it to the existing one: | |
0d319e67 | 374 | AliTPCDigitsArray *arr = new AliTPCDigitsArray; |
375 | arr->SetClass("AliSimDigits"); | |
376 | arr->Setup(fParam); | |
03b6adf7 | 377 | if(create) |
378 | arr->MakeTree(); | |
379 | else | |
380 | { | |
381 | Bool_t ok = arr->ConnectTree("TreeD_75x40_100x60_0"); | |
382 | if(!ok) | |
383 | { | |
384 | printf("AliL3FileHandler::AliDigits2RootFile : No digits tree object in existing file\n"); | |
385 | return; | |
386 | } | |
387 | } | |
54efe57a | 388 | Int_t digcounter=0; |
0d319e67 | 389 | for(Int_t i=fRowMin; i<=fRowMax; i++) |
390 | { | |
03b6adf7 | 391 | |
392 | if(rowPt->fRow != i) printf("AliL3FileHandler::AliDigits2RootFile : Mismatching row numbering!!!\n"); | |
393 | ||
0d319e67 | 394 | Int_t sector,row; |
395 | fTransformer->Slice2Sector(fSlice,i,sector,row); | |
396 | AliDigits * dig = arr->CreateRow(sector,row); | |
397 | AliDigits *old_dig = old_array->LoadRow(sector,row); | |
398 | if(!old_dig) | |
399 | printf("AliL3FileHandler::AliDigits2RootFile : No padrow %d %d\n",sector,row); | |
400 | ||
401 | AliL3DigitData *digPt = rowPt->fDigitData; | |
54efe57a | 402 | digcounter=0; |
0d319e67 | 403 | for(UInt_t j=0; j<rowPt->fNDigit; j++) |
404 | { | |
405 | UShort_t charge = digPt[j].fCharge; | |
406 | UChar_t pad = digPt[j].fPad; | |
407 | UShort_t time = digPt[j].fTime; | |
03b6adf7 | 408 | |
409 | if(charge == 0) //Only write the digits that has not been removed | |
410 | continue; | |
54efe57a | 411 | //dig->SetDigitFast(old_dig->GetDigit(time,pad),time,pad); |
412 | digcounter++; | |
413 | dig->SetDigitFast(charge,time,pad); | |
0d319e67 | 414 | ((AliSimDigits*)dig)->SetTrackIDFast(((AliSimDigits*)old_dig)->GetTrackID((Int_t)time,(Int_t)pad,0),time,pad,0); |
415 | ((AliSimDigits*)dig)->SetTrackIDFast(((AliSimDigits*)old_dig)->GetTrackID((Int_t)time,(Int_t)pad,1),time,pad,1); | |
416 | ((AliSimDigits*)dig)->SetTrackIDFast(((AliSimDigits*)old_dig)->GetTrackID((Int_t)time,(Int_t)pad,2),time,pad,2); | |
417 | ||
418 | } | |
54efe57a | 419 | //cout<<"Wrote "<<digcounter<<" on row "<<i<<endl; |
0d319e67 | 420 | UpdateRowPointer(rowPt); |
421 | arr->StoreRow(sector,row); | |
422 | arr->ClearRow(sector,row); | |
423 | old_array->ClearRow(sector,row); | |
424 | } | |
425 | digFile->cd(); | |
426 | char treeName[100]; | |
03b6adf7 | 427 | sprintf(treeName,"TreeD_%s_0",fParam->GetTitle()); |
8f1a9904 | 428 | printf("Writing tree to file....."); |
0d319e67 | 429 | arr->GetTree()->Write(treeName,TObject::kOverwrite); |
8f1a9904 | 430 | printf("done\n"); |
0d319e67 | 431 | digFile->Close(); |
03b6adf7 | 432 | //arr->GetTree()->Delete(); |
433 | //delete arr; | |
0d319e67 | 434 | } |
435 | ||
108615fc | 436 | ///////////////////////////////////////// Point IO |
437 | Bool_t AliL3FileHandler::AliPoints2Binary(){ | |
438 | Bool_t out = kTRUE; | |
439 | UInt_t npoint; | |
440 | AliL3SpacePointData *data = AliPoints2Memory(npoint); | |
441 | out = Memory2Binary(npoint,data); | |
442 | Free(); | |
443 | return out; | |
444 | } | |
445 | ||
446 | AliL3SpacePointData * AliL3FileHandler::AliPoints2Memory(UInt_t & npoint){ | |
447 | AliL3SpacePointData *data = 0; | |
448 | npoint=0; | |
449 | if(!fInAli){ | |
450 | LOG(AliL3Log::kWarning,"AliL3FileHandler::AliPoints2Memory","File") | |
451 | <<"No Input avalible: no object TFile"<<ENDLOG; | |
452 | return 0; | |
453 | } | |
454 | if(!fInAli->IsOpen()){ | |
455 | LOG(AliL3Log::kWarning,"AliL3FileHandler::AliPoints2Memory","File") | |
456 | <<"No Input avalible: TFile not opend"<<ENDLOG; | |
457 | return 0; | |
458 | } | |
459 | TDirectory *savedir = gDirectory; | |
460 | fInAli->cd(); | |
8f1a9904 | 461 | |
462 | Char_t cname[100]; | |
463 | Int_t eventn = 0; | |
464 | sprintf(cname,"TreeC_TPC_%d",eventn); | |
108615fc | 465 | AliTPCClustersArray carray; |
466 | carray.Setup(fParam); | |
467 | carray.SetClusterType("AliTPCcluster"); | |
8f1a9904 | 468 | Bool_t clusterok = carray.ConnectTree(cname); |
108615fc | 469 | if(!clusterok) return 0; |
470 | ||
471 | AliTPCClustersRow ** clusterrow = | |
472 | new AliTPCClustersRow*[ (int)carray.GetTree()->GetEntries()]; | |
473 | Int_t *rows = new int[ (int)carray.GetTree()->GetEntries()]; | |
474 | Int_t *sects = new int[ (int)carray.GetTree()->GetEntries()]; | |
475 | Int_t sum=0; | |
476 | ||
477 | Int_t lslice,lrow; | |
478 | for(Int_t i=0; i<carray.GetTree()->GetEntries(); i++){ | |
479 | AliSegmentID *s = carray.LoadEntry(i); | |
480 | Int_t sector,row; | |
481 | fParam->AdjustSectorRow(s->GetID(),sector,row); | |
482 | rows[i] = row; | |
483 | sects[i] = sector; | |
484 | clusterrow[i] = 0; | |
485 | fTransformer->Sector2Slice(lslice,lrow,sector,row); | |
486 | if(fSlice != lslice || lrow<fRowMin || lrow>fRowMax) continue; | |
487 | clusterrow[i] = carray.GetRow(sector,row); | |
488 | if(clusterrow[i]) | |
489 | sum+=clusterrow[i]->GetArray()->GetEntriesFast(); | |
490 | } | |
491 | UInt_t size = sum*sizeof(AliL3SpacePointData); | |
492 | ||
493 | LOG(AliL3Log::kDebug,"AliL3FileHandler::AliPoints2Memory","File") | |
494 | <<AliL3Log::kDec<<"Found "<<sum<<" SpacePoints"<<ENDLOG; | |
495 | ||
496 | data = (AliL3SpacePointData *) Allocate(size); | |
497 | npoint = sum; | |
498 | UInt_t n=0; | |
499 | for(Int_t i=0; i<carray.GetTree()->GetEntries(); i++){ | |
500 | if(!clusterrow[i]) continue; | |
501 | Int_t row = rows[i]; | |
502 | Int_t sector = sects[i]; | |
503 | fTransformer->Sector2Slice(lslice,lrow,sector,row); | |
504 | Int_t entries_in_row = clusterrow[i]->GetArray()->GetEntriesFast(); | |
505 | for(Int_t j = 0;j<entries_in_row;j++){ | |
506 | AliTPCcluster *c = (AliTPCcluster*)(*clusterrow[i])[j]; | |
507 | data[n].fZ = c->GetZ(); | |
508 | data[n].fY = c->GetY(); | |
509 | data[n].fX = fParam->GetPadRowRadii(sector,row); | |
510 | data[n].fID = n+((fSlice&0x7f)<<25)+((fPatch&0x7)<<22);//uli | |
511 | data[n].fPadRow = lrow; | |
512 | data[n].fXYErr = c->GetSigmaY2(); | |
513 | data[n].fZErr = c->GetSigmaZ2(); | |
514 | if(fMC) fprintf(fMC,"%d %d\n",data[n].fID,c->GetLabel(0)); | |
515 | n++; | |
516 | } | |
517 | } | |
518 | for(Int_t i=0;i<carray.GetTree()->GetEntries();i++){ | |
519 | Int_t row = rows[i]; | |
520 | Int_t sector = sects[i]; | |
521 | if(carray.GetRow(sector,row)) | |
522 | carray.ClearRow(sector,row); | |
523 | } | |
524 | ||
525 | delete [] clusterrow; | |
526 | delete [] rows; | |
527 | delete [] sects; | |
528 | savedir->cd(); | |
529 | ||
530 | return data; | |
531 | } | |
532 |