]>
Commit | Line | Data |
---|---|---|
88cb7938 | 1 | #ifndef __MAKECINT__ |
2 | #ifndef __CINT__ | |
3 | #include "alles.h" | |
4 | #include "TInterpreter.h" | |
5 | #include "TBranchClones.h" | |
6 | #include "TBranchElement.h" | |
7 | #include "AliTPCTrackHits.h" | |
8 | #include "AliTRDtrackHits.h" | |
9 | #endif | |
10 | #endif | |
11 | ||
12 | void ConvertToNewIO(const char* name) | |
13 | { | |
14 | // AliLoader::SetDebug(); | |
15 | AliConfig* conf = AliConfig::Instance(); | |
16 | TClass* detclass = AliDetector::Class(); | |
17 | void* buff; | |
18 | Bool_t skipit = kFALSE; | |
19 | void * pbuf[100]; | |
20 | TBranch* branches[100]; | |
21 | Int_t nbranches = 0; | |
22 | ||
23 | AliRunLoader* rl = AliRunLoader::Open("galiceNewIO.root","Event","recreate"); | |
24 | rl->SetCompressionLevel(2); | |
25 | ||
26 | AliRun* outAliRun; | |
27 | ||
28 | if (gAlice == 0x0) | |
29 | { | |
30 | outAliRun = new AliRun("OutgAlice","Output gAlice"); | |
31 | } | |
32 | else | |
33 | { | |
34 | outAliRun = gAlice; | |
35 | } | |
36 | gAlice = 0x0; | |
37 | ||
38 | outAliRun->SetRunLoader(rl); | |
39 | ||
40 | TFile* infile = TFile::Open(name); | |
41 | ||
42 | if (infile == 0x0) | |
43 | { | |
44 | ::Error("ConvertToNewIO.C","Can not open input file %s",name); | |
45 | return; | |
46 | } | |
47 | ||
48 | AliRun* inAliRun = (AliRun*)infile->Get("gAlice"); | |
49 | ||
50 | if(inAliRun == 0x0) | |
51 | { | |
52 | ::Error("ConvertToNewIO.C","Can not find gAlice in input file"); | |
53 | return; | |
54 | } | |
55 | gAlice = inAliRun; | |
56 | // inAliRun->GetEvent(0); | |
57 | ||
58 | TObjArray* modules = inAliRun->Modules(); | |
59 | if (modules == 0x0) | |
60 | { | |
61 | ::Error("ConvertToNewIO.C","Can not get array with modules from AliRun"); | |
62 | return; | |
63 | } | |
64 | TIter next(modules); | |
65 | AliModule* module; | |
66 | while ((module = (AliModule*)next())) | |
67 | { | |
68 | outAliRun->AddModule(module); | |
69 | ||
70 | TClass* modclass = module->IsA(); | |
71 | AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module)); | |
72 | if (det) | |
73 | { | |
74 | ::Info("ConvertToNewIO.C"," Adding %s to RL.",det->GetName()); | |
75 | conf->Add(det,"Event"); | |
76 | rl->AddLoader(det); | |
77 | } | |
78 | } | |
79 | ||
80 | TParticle* particleBuffer = new TParticle(); | |
81 | /***************************************************/ | |
82 | /**** Event to Event **************/ | |
83 | /***************************************************/ | |
84 | ||
85 | TTree* treeE = (TTree*)infile->Get("TE"); | |
86 | if (treeE == 0x0) | |
87 | { | |
88 | ::Error("ConvertToNewIO.C","Can not get TreeE from AliRun"); | |
89 | return; | |
90 | } | |
91 | rl->MakeTree("E"); | |
92 | ||
93 | AliHeader* inheader = new AliHeader(); | |
94 | treeE->SetBranchAddress("Header",&inheader); | |
95 | ||
96 | Int_t nevents = (Int_t)treeE->GetEntries(); | |
97 | for (Int_t i = 0; i<nevents; i++) | |
98 | { | |
99 | ::Info("ConvertToNewIO.C","Converting Event %d.",i); | |
100 | rl->SetEventNumber(i); | |
101 | treeE->GetEvent(i); | |
102 | /*****************************************/ | |
103 | /* H E A D E R */ | |
104 | /*****************************************/ | |
105 | ||
106 | ::Info("ConvertToNewIO.C","Copying Header"); | |
107 | AliHeader* outheader = rl->GetHeader(); | |
108 | ||
109 | ||
110 | outheader->SetEvent(inheader->GetEvent()); | |
111 | outheader->SetNvertex(inheader->GetNvertex()); | |
112 | outheader->SetNprimary(inheader->GetNprimary()); | |
113 | outheader->SetNtrack(inheader->GetNtrack()); | |
114 | outheader->SetRun(inheader->GetRun()); | |
115 | outheader->SetEventNrInRun(inheader->GetEventNrInRun()); | |
116 | outheader->SetStack(inheader->Stack()); | |
117 | outheader->SetGenEventHeader(inheader->GenEventHeader()); | |
118 | rl->TreeE()->Fill(); | |
119 | ||
120 | /*****************************************/ | |
121 | /* K I N E M A T I C S */ | |
122 | /*****************************************/ | |
123 | ::Info("ConvertToNewIO.C","Copying Kinematics."); | |
124 | TString treeKname("TreeK"); | |
125 | treeKname+=i; | |
126 | TTree* treeK = (TTree*)infile->Get(treeKname); | |
127 | if (treeK) | |
128 | { | |
129 | if (treeK->GetEntries() > 0) | |
130 | { | |
131 | //I do this gimnastics to set directory correctly, without changing NewIO code | |
132 | //only for this purpose | |
133 | rl->LoadKinematics("update"); | |
134 | rl->MakeTree("K"); | |
135 | rl->GetEventFolder()->Remove(rl->TreeK()); | |
136 | delete rl->TreeK(); | |
137 | ||
138 | treeK->SetBranchAddress("Particles",&particleBuffer); | |
139 | ::Info("ConvertToNewIO.C","Cloning TreeK ..."); | |
140 | TTree* tk = treeK->CloneTree(); | |
141 | ::Info("ConvertToNewIO.C","Cloning TreeK ... Done"); | |
142 | tk->SetName(AliRunLoader::fgkKineContainerName); | |
143 | rl->GetEventFolder()->Add(tk); | |
144 | rl->WriteKinematics("OVERWRITE"); | |
145 | rl->UnloadKinematics(); | |
146 | } | |
147 | else | |
148 | { | |
149 | Info("ConvertToNewIO.C","Kinematics Tree is Empty"); | |
150 | } | |
151 | } | |
152 | else | |
153 | { | |
154 | Error("ConvertToNewIO.C","Could not find Kinematics tree named %s",treeKname.Data()); | |
155 | } | |
156 | delete treeK; | |
157 | /*****************************************/ | |
158 | /* T R A C K R E F E R E N C E S */ | |
159 | /*****************************************/ | |
160 | ::Info("ConvertToNewIO.C","Copying Track Refs."); | |
161 | TString treeTRname("TreeTR"); | |
162 | treeTRname+=i; | |
163 | TTree* treeTR = (TTree*)infile->Get(treeTRname); | |
164 | if (treeTR) | |
165 | { | |
166 | if (treeTR->GetEntries() > 0) | |
167 | { | |
168 | next.Reset(); | |
169 | while ((module = (AliModule*)next())) | |
170 | { | |
171 | TClass* modclass = module->IsA(); | |
172 | AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module)); | |
173 | if (det) | |
174 | { | |
175 | TClonesArray* trbuffer = new TClonesArray("AliTrackReference", 100); | |
176 | treeTR->SetBranchAddress(det->GetName(),&trbuffer); | |
177 | } | |
178 | } | |
179 | ||
180 | //I do this gimnastics to set directory correctly, without changing NewIO code | |
181 | //only for this purpose | |
182 | rl->LoadTrackRefs("update"); | |
183 | rl->MakeTrackRefsContainer(); | |
184 | rl->GetEventFolder()->Remove(rl->TreeTR()); | |
185 | delete rl->TreeTR(); | |
186 | ||
187 | ::Info("ConvertToNewIO.C","Cloning TreeTR ..."); | |
188 | TTree* tr = treeTR->CloneTree(); | |
189 | ::Info("ConvertToNewIO.C","Cloning TreeTR ... Done"); | |
190 | ||
191 | tr->SetName(AliRunLoader::fgkTrackRefsContainerName); | |
192 | rl->GetEventFolder()->Add(tr); | |
193 | rl->WriteTrackRefs("OVERWRITE"); | |
194 | rl->UnloadTrackRefs(); | |
195 | } | |
196 | else | |
197 | { | |
198 | Info("ConvertToNewIO.C","Track References Tree is Empty"); | |
199 | } | |
200 | } | |
201 | else | |
202 | { | |
203 | Error("ConvertToNewIO.C","Could not find Track Refs tree named %s",treeTRname.Data()); | |
204 | } | |
205 | delete treeTR; | |
206 | ||
207 | /*****************************************/ | |
208 | /* H I T S */ | |
209 | /*****************************************/ | |
210 | ::Info("ConvertToNewIO.C","Copying Hits."); | |
211 | TString treeHname("TreeH"); | |
212 | treeHname+=i; | |
213 | TTree* treeH = (TTree*)infile->Get(treeHname); | |
214 | ||
215 | if (treeH) | |
216 | { | |
217 | if (treeH->GetEntries() > 0) | |
218 | { | |
219 | TObjArray* lob = treeH->GetListOfBranches(); | |
220 | TObjArray* loaders = new TObjArray(); | |
221 | TIter nextnewmodule(outAliRun->Modules()); | |
222 | ||
223 | while ((module = (AliModule*)nextnewmodule())) | |
224 | { | |
225 | TClass* modclass = module->IsA(); | |
226 | AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module)); | |
227 | TClonesArray* ca = 0; | |
228 | if (det) | |
229 | { | |
230 | AliLoader* loader = det->GetLoader(); | |
231 | if (loader == 0x0) | |
232 | { | |
233 | ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName()); | |
234 | continue; | |
235 | } | |
236 | ||
237 | TString mask(det->GetName()); | |
238 | ||
239 | loader->LoadHits("update"); | |
240 | loader->MakeTree("H"); | |
241 | loaders->Add(loader); | |
242 | for(Int_t b=0; b<lob->GetEntries();b++) | |
243 | { | |
244 | TBranch* branch = (TBranch*)lob->At(b); | |
245 | TString bname(branch->GetName());// | |
246 | if ( bname.BeginsWith(det->GetName()) ) | |
247 | { | |
248 | ::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName()); | |
249 | ::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName()); | |
250 | TString contname(branch->GetClassName()); | |
251 | ||
252 | Int_t splitlvl = branch->GetSplitLevel(); | |
253 | // if (splitlvl) splitlvl = 99; | |
254 | ||
255 | if( contname.CompareTo("TClonesArray") == 0) | |
256 | { | |
257 | TBranchElement* belem = (TBranchElement*)branch; | |
258 | ::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName()); | |
259 | ||
260 | ca = new TClonesArray(belem->GetClonesName()); | |
261 | pbuf[nbranches] = ca; | |
262 | ||
263 | branch->SetAddress(&(pbuf[nbranches])); | |
264 | ::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]); | |
265 | ||
266 | ::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl); | |
267 | branches[nbranches] = loader->TreeH()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl); | |
268 | nbranches++; | |
269 | } | |
270 | else | |
271 | { | |
272 | TClass* bcl = gROOT->GetClass(branch->GetClassName()); | |
273 | pbuf[nbranches] = bcl->New(); | |
274 | ::Info("ConvertToNewIO.C","Dumping buffer:"); | |
275 | ((TObject*)pbuf[nbranches])->Dump(); | |
276 | ::Info("ConvertToNewIO.C","Setting Adress:"); | |
277 | branch->SetAddress(&(pbuf[nbranches])); | |
278 | ::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl); | |
279 | branches[nbranches] =loader->TreeH()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl); | |
280 | nbranches++; | |
281 | } | |
282 | } | |
283 | }//loop over branches | |
284 | }//if module is detector | |
285 | }//while loop over modules | |
286 | Int_t nentr = (Int_t)treeH->GetEntries(); | |
287 | ::Info("ConvertToNewIO.C","Copying Hits . Number of entries %d ... ",nentr); | |
288 | ||
289 | // ::Info("ConvertToNewIO.C","Getting event:"); | |
290 | // nentr = 100; | |
291 | Int_t nl = loaders->GetEntries(); | |
292 | for (Int_t e = 0; e < nentr; e++) | |
293 | { | |
294 | printf("%d\r",e); | |
295 | treeH->GetEntry(e); | |
296 | ||
297 | for (Int_t l = 0; l < nbranches; l++) | |
298 | { | |
299 | // printf("%s %#x \n", branches[l]->GetName(),pbuf[l]); | |
300 | branches[l]->SetAddress(&(pbuf[l])); | |
301 | } | |
302 | ||
303 | for (Int_t l = 0; l < nl; l++) | |
304 | { | |
305 | AliLoader* loader = (AliLoader*)loaders->At(l); | |
306 | // printf("Filling %s\n",loader->GetName()); | |
307 | loader->TreeH()->Fill(); | |
308 | } | |
309 | #ifndef __MAKECINT__ | |
310 | #ifndef __CINT__ | |
311 | fflush(0); | |
312 | #endif | |
313 | #endif | |
314 | } | |
315 | printf("\n"); | |
316 | ||
317 | ::Info("ConvertToNewIO.C","Copying Hits ... Done"); | |
318 | for (Int_t l = 0; l < nl; l++) | |
319 | { | |
320 | AliLoader* loader = (AliLoader*)loaders->At(l); | |
321 | loader->WriteHits("OVERWRITE"); | |
322 | loader->UnloadHits(); | |
323 | } | |
324 | delete loaders; | |
325 | for (Int_t l = 0; l < nbranches; l++) | |
326 | { | |
327 | delete (TObject*)pbuf[l]; | |
328 | } | |
329 | nbranches = 0; | |
330 | } | |
331 | else //tree has any entries | |
332 | { | |
333 | Info("ConvertToNewIO.C","Hits Tree is Empty"); | |
334 | } | |
335 | } | |
336 | else //treeH | |
337 | { | |
338 | ::Warning("ConvertToNewIO.C","Could not get TreeH from in AliRun."); | |
339 | } | |
340 | delete treeH; | |
341 | ||
342 | /*****************************************/ | |
343 | /* S D i g i t s */ | |
344 | /*****************************************/ | |
345 | ::Info("ConvertToNewIO.C","Copying S Digits."); | |
346 | TString treeSname("TreeS"); | |
347 | treeSname+=i; | |
348 | TTree* treeS = (TTree*)infile->Get(treeSname); | |
349 | if (treeS) | |
350 | { | |
351 | if (treeS->GetEntries() > 0) | |
352 | { | |
353 | TObjArray* lob = treeS->GetListOfBranches(); | |
354 | TObjArray* loaders = new TObjArray(); | |
355 | TIter nextnewmodule(outAliRun->Modules()); | |
356 | ||
357 | while ((module = (AliModule*)nextnewmodule())) | |
358 | { | |
359 | TClass* modclass = module->IsA(); | |
360 | AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module)); | |
361 | TClonesArray* ca = 0; | |
362 | if (det) | |
363 | { | |
364 | AliLoader* loader = det->GetLoader(); | |
365 | if (loader == 0x0) | |
366 | { | |
367 | ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName()); | |
368 | continue; | |
369 | } | |
370 | ||
371 | TString mask(det->GetName()); | |
372 | ||
373 | loader->LoadSDigits("update"); | |
374 | loader->MakeTree("S"); | |
375 | loaders->Add(loader); | |
376 | for(Int_t b=0; b<lob->GetEntries();b++) | |
377 | { | |
378 | TBranch* branch = (TBranch*)lob->At(b); | |
379 | TString bname(branch->GetName());// | |
380 | if ( bname.BeginsWith(det->GetName()) ) | |
381 | { | |
382 | ||
383 | ::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName()); | |
384 | ::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName()); | |
385 | TString contname(branch->GetClassName()); | |
386 | ||
387 | Int_t splitlvl = branch->GetSplitLevel(); | |
388 | // if (splitlvl) splitlvl = 99; | |
389 | ||
390 | if ( contname.CompareTo("TClonesArray") == 0) | |
391 | { | |
392 | TBranchElement* belem = (TBranchElement*)branch; | |
393 | ::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName()); | |
394 | ||
395 | ca = new TClonesArray(belem->GetClonesName()); | |
396 | pbuf[nbranches] = ca; | |
397 | ||
398 | branch->SetAddress(&(pbuf[nbranches])); | |
399 | ::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]); | |
400 | ||
401 | ::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl); | |
402 | branches[nbranches] = loader->TreeS()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl); | |
403 | nbranches++; | |
404 | } | |
405 | else | |
406 | { | |
407 | TClass* bcl = gROOT->GetClass(branch->GetClassName()); | |
408 | pbuf[nbranches] = bcl->New(); | |
409 | ::Info("ConvertToNewIO.C","Dumping buffer:"); | |
410 | ((TObject*)pbuf[nbranches])->Dump(); | |
411 | ::Info("ConvertToNewIO.C","Setting Adress:"); | |
412 | branch->SetAddress(&(pbuf[nbranches])); | |
413 | ::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl); | |
414 | branches[nbranches] =loader->TreeS()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl); | |
415 | nbranches++; | |
416 | } | |
417 | } | |
418 | }//loop over branches | |
419 | }//if module is detector | |
420 | }//while loop over modules | |
421 | Int_t nentr = (Int_t)treeS->GetEntries(); | |
422 | ::Info("ConvertToNewIO.C","Copying SDigits. Number of entries %d ... ",nentr); | |
423 | ||
424 | // ::Info("ConvertToNewIO.C","Getting event:"); | |
425 | // nentr = 100; | |
426 | Int_t nl = loaders->GetEntries(); | |
427 | for (Int_t e = 0; e < nentr; e++) | |
428 | { | |
429 | printf("%d\r",e); | |
430 | treeS->GetEntry(e); | |
431 | ||
432 | for (Int_t l = 0; l < nbranches; l++) | |
433 | { | |
434 | // printf("%s %#x \n", branches[l]->GetName(),pbuf[l]); | |
435 | branches[l]->SetAddress(&(pbuf[l])); | |
436 | } | |
437 | ||
438 | for (Int_t l = 0; l < nl; l++) | |
439 | { | |
440 | AliLoader* loader = (AliLoader*)loaders->At(l); | |
441 | // printf("Filling %s\n",loader->GetName()); | |
442 | loader->TreeS()->Fill(); | |
443 | } | |
444 | #ifndef __MAKECINT__ | |
445 | #ifndef __CINT__ | |
446 | fflush(0); | |
447 | #endif | |
448 | #endif | |
449 | } | |
450 | printf("\n"); | |
451 | ||
452 | ::Info("ConvertToNewIO.C","Copying SDigits ... Done"); | |
453 | for (Int_t l = 0; l < nl; l++) | |
454 | { | |
455 | AliLoader* loader = (AliLoader*)loaders->At(l); | |
456 | loader->WriteSDigits("OVERWRITE"); | |
457 | loader->UnloadSDigits(); | |
458 | } | |
459 | delete loaders; | |
460 | for (Int_t l = 0; l < nbranches; l++) | |
461 | { | |
462 | delete (TObject*)pbuf[l]; | |
463 | } | |
464 | nbranches = 0; | |
465 | } | |
466 | else //tree has any entries | |
467 | { | |
468 | Info("ConvertToNewIO.C","S Digits Tree is Empty"); | |
469 | } | |
470 | } | |
471 | else //treeS | |
472 | { | |
473 | ::Warning("ConvertToNewIO.C","Could not get TreeS from in AliRun."); | |
474 | } | |
475 | delete treeS; | |
476 | ||
477 | /*****************************************/ | |
478 | /* D i g i t s */ | |
479 | /*****************************************/ | |
480 | ::Info("ConvertToNewIO.C","Copying Digits."); | |
481 | TString treeDname("TreeD"); | |
482 | treeDname+=i; | |
483 | TTree* treeD = (TTree*)infile->Get(treeDname); | |
484 | if (treeD) | |
485 | { | |
486 | if (treeD->GetEntries() > 0) | |
487 | { | |
488 | ||
489 | TObjArray* lob = treeD->GetListOfBranches(); | |
490 | TObjArray* loaders = new TObjArray(); | |
491 | TIter nextnewmodule(outAliRun->Modules()); | |
492 | ||
493 | while ((module = (AliModule*)nextnewmodule())) | |
494 | { | |
495 | TClass* modclass = module->IsA(); | |
496 | AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module)); | |
497 | TClonesArray* ca = 0; | |
498 | if (det) | |
499 | { | |
500 | AliLoader* loader = det->GetLoader(); | |
501 | if (loader == 0x0) | |
502 | { | |
503 | ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName()); | |
504 | continue; | |
505 | } | |
506 | ||
507 | TString mask(det->GetName()); | |
508 | ||
509 | loader->LoadDigits("update"); | |
510 | loader->MakeTree("D"); | |
511 | loaders->Add(loader); | |
512 | for(Int_t b=0; b<lob->GetEntries();b++) | |
513 | { | |
514 | TBranch* branch = (TBranch*)lob->At(b); | |
515 | TString bname(branch->GetName());// | |
516 | if ( bname.BeginsWith(det->GetName()) ) | |
517 | { | |
518 | ||
519 | ::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName()); | |
520 | ::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName()); | |
521 | TString contname(branch->GetClassName()); | |
522 | ||
523 | Int_t splitlvl = branch->GetSplitLevel(); | |
524 | // if (splitlvl) splitlvl = 99; | |
525 | ||
526 | if ( contname.CompareTo("TClonesArray") == 0) | |
527 | { | |
528 | TBranchElement* belem = (TBranchElement*)branch; | |
529 | ::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName()); | |
530 | ||
531 | ca = new TClonesArray(belem->GetClonesName()); | |
532 | pbuf[nbranches] = ca; | |
533 | ||
534 | branch->SetAddress(&(pbuf[nbranches])); | |
535 | ::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]); | |
536 | ||
537 | ::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl); | |
538 | branches[nbranches] = loader->TreeD()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl); | |
539 | nbranches++; | |
540 | } | |
541 | else | |
542 | { | |
543 | TClass* bcl = gROOT->GetClass(branch->GetClassName()); | |
544 | pbuf[nbranches] = bcl->New(); | |
545 | ::Info("ConvertToNewIO.C","Dumping buffer:"); | |
546 | ((TObject*)pbuf[nbranches])->Dump(); | |
547 | ::Info("ConvertToNewIO.C","Setting Adress:"); | |
548 | branch->SetAddress(&(pbuf[nbranches])); | |
549 | ::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl); | |
550 | branches[nbranches] =loader->TreeD()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl); | |
551 | nbranches++; | |
552 | } | |
553 | } | |
554 | }//loop over branches | |
555 | }//if module is detector | |
556 | }//while loop over modules | |
557 | Int_t nentr = (Int_t)treeD->GetEntries(); | |
558 | ::Info("ConvertToNewIO.C","Copying Digits. Number of entries %d ... ",nentr); | |
559 | ||
560 | // ::Info("ConvertToNewIO.C","Getting event:"); | |
561 | // nentr = 100; | |
562 | Int_t nl = loaders->GetEntries(); | |
563 | for (Int_t e = 0; e < nentr; e++) | |
564 | { | |
565 | printf("%d\r",e); | |
566 | treeD->GetEntry(e); | |
567 | ||
568 | for (Int_t l = 0; l < nbranches; l++) | |
569 | { | |
570 | // printf("%s %#x \n", branches[l]->GetName(),pbuf[l]); | |
571 | branches[l]->SetAddress(&(pbuf[l])); | |
572 | } | |
573 | ||
574 | for (Int_t l = 0; l < nl; l++) | |
575 | { | |
576 | AliLoader* loader = (AliLoader*)loaders->At(l); | |
577 | // printf("Filling %s\n",loader->GetName()); | |
578 | loader->TreeD()->Fill(); | |
579 | } | |
580 | #ifndef __MAKECINT__ | |
581 | #ifndef __CINT__ | |
582 | fflush(0); | |
583 | #endif | |
584 | #endif | |
585 | } | |
586 | printf("\n"); | |
587 | ||
588 | ::Info("ConvertToNewIO.C","Copying Digits ... Done"); | |
589 | for (Int_t l = 0; l < nl; l++) | |
590 | { | |
591 | AliLoader* loader = (AliLoader*)loaders->At(l); | |
592 | loader->WriteDigits("OVERWRITE"); | |
593 | loader->UnloadDigits(); | |
594 | } | |
595 | delete loaders; | |
596 | } | |
597 | else //tree has any entries | |
598 | { | |
599 | Info("ConvertToNewIO.C","S Digits Tree is Empty"); | |
600 | } | |
601 | } | |
602 | else //treeD | |
603 | { | |
604 | ::Warning("ConvertToNewIO.C","Could not get TreeD from in AliRun."); | |
605 | } | |
606 | delete treeD; | |
607 | for (Int_t l = 0; l < nbranches; l++) | |
608 | { | |
609 | delete (TObject*)pbuf[l]; | |
610 | } | |
611 | nbranches = 0; | |
612 | ||
613 | /*****************************************/ | |
614 | /* R e c P o i n t s */ | |
615 | /*****************************************/ | |
616 | ::Info("ConvertToNewIO.C","Copying RecPoints."); | |
617 | TString treeRname("TreeR"); | |
618 | treeRname+=i; | |
619 | TTree* treeR = (TTree*)infile->Get(treeRname); | |
620 | if (treeR) | |
621 | { | |
622 | if (treeR->GetEntries() > 0) | |
623 | { | |
624 | TObjArray* lob = treeR->GetListOfBranches(); | |
625 | TObjArray* loaders = new TObjArray(); | |
626 | TIter nextnewmodule(outAliRun->Modules()); | |
627 | ||
628 | while ((module = (AliModule*)nextnewmodule())) | |
629 | { | |
630 | TClass* modclass = module->IsA(); | |
631 | AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module)); | |
632 | TClonesArray* ca = 0; | |
633 | if (det) | |
634 | { | |
635 | AliLoader* loader = det->GetLoader(); | |
636 | if (loader == 0x0) | |
637 | { | |
638 | ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName()); | |
639 | continue; | |
640 | } | |
641 | ||
642 | TString mask(det->GetName()); | |
643 | ||
644 | loader->LoadRecPoints("update"); | |
645 | loader->MakeTree("R"); | |
646 | loaders->Add(loader); | |
647 | for(Int_t b=0; b<lob->GetEntries();b++) | |
648 | { | |
649 | TBranch* branch = (TBranch*)lob->At(b); | |
650 | TString bname(branch->GetName());// | |
651 | if ( bname.BeginsWith(det->GetName()) ) | |
652 | { | |
653 | ||
654 | ::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName()); | |
655 | ::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName()); | |
656 | TString contname(branch->GetClassName()); | |
657 | ||
658 | Int_t splitlvl = branch->GetSplitLevel(); | |
659 | // if (splitlvl) splitlvl = 99; | |
660 | ||
661 | if ( contname.CompareTo("TClonesArray") == 0) | |
662 | { | |
663 | TBranchElement* belem = (TBranchElement*)branch; | |
664 | ::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName()); | |
665 | ||
666 | ca = new TClonesArray(belem->GetClonesName()); | |
667 | pbuf[nbranches] = ca; | |
668 | ||
669 | branch->SetAddress(&(pbuf[nbranches])); | |
670 | ::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]); | |
671 | ||
672 | ::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl); | |
673 | branches[nbranches] = loader->TreeR()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl); | |
674 | nbranches++; | |
675 | } | |
676 | else | |
677 | { | |
678 | TClass* bcl = gROOT->GetClass(branch->GetClassName()); | |
679 | pbuf[nbranches] = bcl->New(); | |
680 | ::Info("ConvertToNewIO.C","Dumping buffer:"); | |
681 | ((TObject*)pbuf[nbranches])->Dump(); | |
682 | ::Info("ConvertToNewIO.C","Setting Adress:"); | |
683 | branch->SetAddress(&(pbuf[nbranches])); | |
684 | ::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl); | |
685 | branches[nbranches] =loader->TreeR()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl); | |
686 | nbranches++; | |
687 | } | |
688 | } | |
689 | }//loop over branches | |
690 | }//if module is detector | |
691 | }//while loop over modules | |
692 | Int_t nentr = (Int_t)treeR->GetEntries(); | |
693 | ::Info("ConvertToNewIO.C","Copying RecPoints. Number of entries %d ... ",nentr); | |
694 | ||
695 | // ::Info("ConvertToNewIO.C","Getting event:"); | |
696 | // nentr = 100; | |
697 | Int_t nl = loaders->GetEntries(); | |
698 | for (Int_t e = 0; e < nentr; e++) | |
699 | { | |
700 | printf("%d\r",e); | |
701 | treeR->GetEntry(e); | |
702 | ||
703 | for (Int_t l = 0; l < nbranches; l++) | |
704 | { | |
705 | // printf("%s %#x \n", branches[l]->GetName(),pbuf[l]); | |
706 | branches[l]->SetAddress(&(pbuf[l])); | |
707 | } | |
708 | ||
709 | for (Int_t l = 0; l < nl; l++) | |
710 | { | |
711 | AliLoader* loader = (AliLoader*)loaders->At(l); | |
712 | // printf("Filling %s\n",loader->GetName()); | |
713 | loader->TreeR()->Fill(); | |
714 | } | |
715 | #ifndef __MAKECINT__ | |
716 | #ifndef __CINT__ | |
717 | fflush(0); | |
718 | #endif | |
719 | #endif | |
720 | } | |
721 | printf("\n"); | |
722 | ||
723 | ::Info("ConvertToNewIO.C","Copying RecPoints ... Done"); | |
724 | for (Int_t l = 0; l < nl; l++) | |
725 | { | |
726 | AliLoader* loader = (AliLoader*)loaders->At(l); | |
727 | loader->WriteRecPoints("OVERWRITE"); | |
728 | loader->UnloadRecPoints(); | |
729 | } | |
730 | delete loaders; | |
731 | for (Int_t l = 0; l < nbranches; l++) | |
732 | { | |
733 | delete (TObject*)pbuf[l];//delete branches buffers | |
734 | } | |
735 | nbranches = 0; | |
736 | } | |
737 | else //tree has any entries | |
738 | { | |
739 | Info("ConvertToNewIO.C","Rec Points Tree is Empty"); | |
740 | } | |
741 | } | |
742 | else //treeR | |
743 | { | |
744 | ::Warning("ConvertToNewIO.C","Could not get TreeR from in AliRun."); | |
745 | } | |
746 | delete treeR; | |
747 | ||
748 | }//end of loop over events | |
749 | ||
750 | /***************************************************/ | |
751 | /**** Run to Run *************/ | |
752 | /***************************************************/ | |
753 | ||
754 | rl->WriteHeader("OVERWRITE"); | |
755 | ||
756 | infile->cd(); | |
757 | TGeometry* geo = inAliRun->GetGeometry(); | |
758 | rl->CdGAFile(); | |
759 | geo->Write(); | |
760 | ||
761 | rl->WriteAliRun(); | |
762 | rl->WriteRunLoader(); | |
763 | ||
764 | ::Info("ConvertToNewIO.C","Done"); | |
765 | ||
766 | } | |
767 |