12 #include <TObjectTable.h>
24 #include "AliModule.h"
25 #include "AliRunLoader.h"
26 #include "AliHeader.h"
27 #include "AliDetector.h"
28 #include "AliConfig.h"
30 #include "AliRunLoader.h"
31 #include <TParticle.h>
32 #include "TBranchClones.h"
33 #include "TBranchElement.h"
35 #include "PHOS/AliPHOSClusterizerv1.h"
36 #include "PHOS/AliPHOSDigitizer.h"
37 #include "PHOS/AliPHOSSDigitizer.h"
38 #include "PHOS/AliPHOSTrackSegmentMakerv1.h"
39 #include "PHOS/AliPHOSPIDv1.h"
44 void ConvertPHOSToNewIO(const char* name = "galice.root", TString branch ="Event" )
46 // AliLoader::SetDebug();
47 AliConfig* conf = AliConfig::Instance();
48 TClass* detclass = AliDetector::Class();
50 TBranch* branches[100];
52 // AliLoader::SetDebug(5);
53 AliRunLoader* rl = AliRunLoader::Open("galiceNewIO.root",branch,"recreate");
54 rl->SetCompressionLevel(2);
55 rl->SetNumberOfEventsPerFile(1000);
61 outAliRun = new AliRun("OutgAlice","Output gAlice");
69 outAliRun->SetRunLoader(rl);
70 TString fSdig = "PHOS.SDigits."+branch+".root";
71 TString fDig = "PHOS.Digits."+branch+".root";
72 TString fRec = "PHOS.RecData."+branch+".root";
74 TFile* insdfile = TFile::Open(fSdig);
75 TFile* indigfile = TFile::Open(fDig);
76 TFile* inrecfile = TFile::Open(fRec);
77 TFile* infile = TFile::Open(name);
81 ::Error("ConvertToNewIO.C","Can not open input file %s",name);
85 AliRun* inAliRun = (AliRun*)infile->Get("gAlice");
89 ::Error("ConvertToNewIO.C","Can not find gAlice in input file");
94 TObjArray* modules = inAliRun->Modules();
97 ::Error("ConvertToNewIO.C","Can not get array with modules from AliRun");
102 while ((module = (AliModule*)next()))
104 outAliRun->AddModule(module);
106 TClass* modclass = module->IsA();
107 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
110 ////::Info("ConvertToNewIO.C"," Adding %s to RL.",det->GetName());
111 conf->Add(det,branch);
116 TParticle* particleBuffer = new TParticle();
117 /***************************************************/
118 /**** Event to Event **************/
119 /***************************************************/
121 TTree* treeE = (TTree*)infile->Get("TE");
125 ::Error("ConvertToNewIO.C","Can not get TreeE from AliRun");
130 AliHeader* inheader = new AliHeader();
131 treeE->SetBranchAddress("Header",&inheader);
133 Int_t nevents = (Int_t)treeE->GetEntries();
134 for (Int_t i = 0; i<nevents; i++)
136 ::Info("ConvertToNewIO.C","Converting Event %d.",i);
137 rl->SetEventNumber(i);
139 /*****************************************/
141 /*****************************************/
143 ////::Info("ConvertToNewIO.C","Copying Header");
144 AliHeader* outheader = rl->GetHeader();
146 outheader->SetEvent(inheader->GetEvent());
147 outheader->SetNvertex(inheader->GetNvertex());
148 outheader->SetNprimary(inheader->GetNprimary());
149 outheader->SetNtrack(inheader->GetNtrack());
150 outheader->SetRun(inheader->GetRun());
151 outheader->SetEventNrInRun(inheader->GetEventNrInRun());
152 outheader->SetStack(inheader->Stack());
153 outheader->SetGenEventHeader(inheader->GenEventHeader());
155 rl->SetNumberOfEventsPerFile(1000);
156 /*****************************************/
157 /* K I N E M A T I C S */
158 /*****************************************/
159 ////::Info("ConvertToNewIO.C","Copying Kinematics.");
160 TString treeKname("TreeK");
162 TTree* treeK = (TTree*)infile->Get(treeKname);
165 if (treeK->GetEntries() > 0)
167 //I do this gimnastics to set directory correctly, without changing NewIO code
168 //only for this purpose
169 rl->SetNumberOfEventsPerFile(1000);
170 rl->LoadKinematics("update");
172 rl->GetEventFolder()->Remove(rl->TreeK());
175 treeK->SetBranchAddress("Particles",&particleBuffer);
176 ////::Info("ConvertToNewIO.C","Cloning TreeK ...");
177 TTree* tk = treeK->CloneTree();
178 ////::Info("ConvertToNewIO.C","Cloning TreeK ... Done");
179 tk->SetName(AliRunLoader::fgkKineContainerName);
180 rl->GetEventFolder()->Add(tk);
181 rl->WriteKinematics("OVERWRITE");
182 rl->UnloadKinematics();
186 Info("ConvertToNewIO.C","Kinematics Tree is Empty");
191 Error("ConvertToNewIO.C","Could not find Kinematics tree named %s",treeKname.Data());
194 /*****************************************/
195 /* T R A C K R E F E R E N C E S */
196 /*****************************************/
197 ////::Info("ConvertToNewIO.C","Copying Track Refs.");
198 TString treeTRname("TreeTR");
200 TTree* treeTR = (TTree*)infile->Get(treeTRname);
203 if (treeTR->GetEntries() > 0)
206 while ((module = (AliModule*)next()))
208 TClass* modclass = module->IsA();
209 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
212 TClonesArray* trbuffer = new TClonesArray("AliTrackReference", 100);
213 treeTR->SetBranchAddress(det->GetName(),&trbuffer);
217 //I do this gimnastics to set directory correctly, without changing NewIO code
218 //only for this purpose
219 rl->SetNumberOfEventsPerFile(1000);
220 rl->LoadTrackRefs("update");
221 rl->MakeTrackRefsContainer();
222 rl->GetEventFolder()->Remove(rl->TreeTR());
225 ////::Info("ConvertToNewIO.C","Cloning TreeTR ...");
226 TTree* tr = treeTR->CloneTree();
227 ////::Info("ConvertToNewIO.C","Cloning TreeTR ... Done");
229 tr->SetName(AliRunLoader::fgkTrackRefsContainerName);
230 rl->GetEventFolder()->Add(tr);
231 rl->WriteTrackRefs("OVERWRITE");
232 rl->UnloadTrackRefs();
236 Info("ConvertToNewIO.C","Track References Tree is Empty");
241 Error("ConvertToNewIO.C","Could not find Track Refs tree named %s",treeTRname.Data());
245 /*****************************************/
247 /*****************************************/
248 ////::Info("ConvertToNewIO.C","Copying Hits.");
249 TString treeHname("TreeH");
251 TTree* treeH = (TTree*)infile->Get(treeHname);
255 if (treeH->GetEntries() > 0)
257 TObjArray* lob = treeH->GetListOfBranches();
258 TObjArray* loaders = new TObjArray();
259 TIter nextnewmodule(outAliRun->Modules());
261 while ((module = (AliModule*)nextnewmodule()))
263 TClass* modclass = module->IsA();
264 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
265 //TClonesArray* ca = 0;
268 AliLoader* loader = det->GetLoader();
271 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
275 TString mask(det->GetName());
277 loader->LoadHits("update");
278 loader->MakeTree("H");
279 loaders->Add(loader);
280 for(Int_t b=0; b<lob->GetEntries();b++)
282 TBranch* branch = (TBranch*)lob->At(b);
283 TString bname(branch->GetName());//
284 if ( bname.BeginsWith(det->GetName()) )
286 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
287 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
288 TString contname(branch->GetClassName());
290 Int_t splitlvl = branch->GetSplitLevel();
291 // if (splitlvl) splitlvl = 99;
293 if( contname.CompareTo("TClonesArray") == 0)
295 TBranchElement* belem = (TBranchElement*)branch;
296 //::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
298 TClonesArray *ca = new TClonesArray(belem->GetClonesName());
299 pbuf[nbranches] = ca;
301 branch->SetAddress(&(pbuf[nbranches]));
302 //::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
304 //::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
305 branches[nbranches] = loader->TreeH()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
310 //::Info("ConvertToNewIO.C","Class Nmme is %s",branch->GetClassName());
311 TClass* bcl = gROOT->GetClass(branch->GetClassName());
314 ::Error("ConvertToNewIO.C","Can not get TClass object of class named %s",branch->GetClassName());
317 pbuf[nbranches] = bcl->New();
318 //::Info("ConvertToNewIO.C","Dumping buffer:");
319 //((TObject*)pbuf[nbranches])->Dump();
320 //::Info("ConvertToNewIO.C","Setting Adress:");
321 branch->SetAddress(&(pbuf[nbranches]));
322 //::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
323 branches[nbranches] =loader->TreeH()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
327 }//loop over branches
328 }//if module is detector
329 }//while loop over modules
330 Int_t nentr = (Int_t)treeH->GetEntries();
331 //::Info("ConvertToNewIO.C","Copying Hits . Number of entries %d ... ",nentr);
334 Int_t nl = loaders->GetEntries();
335 for (Int_t e = 0; e < nentr; e++)
340 for (Int_t l = 0; l < nbranches; l++)
342 //printf("Branch %d addr %#x\n",l,pbuf[l]);
343 //printf("%s %#x \n", branches[l]->GetName(),pbuf[l]);
344 branches[l]->SetAddress(&(pbuf[l]));
347 for (Int_t l = 0; l < nl; l++)
349 AliLoader* loader = (AliLoader*)loaders->At(l);
350 //printf("Filling %s\n",loader->GetName());
351 loader->TreeH()->Fill();
361 ////::Info("ConvertToNewIO.C","Copying Hits ... Done");
362 for (Int_t l = 0; l < nl; l++)
364 AliLoader* loader = (AliLoader*)loaders->At(l);
365 loader->WriteHits("OVERWRITE");
366 loader->UnloadHits();
369 for (Int_t l = 0; l < nbranches; l++)
371 delete (TObject*)pbuf[l];
375 else //tree has any entries
377 Info("ConvertToNewIO.C","Hits Tree is Empty");
382 ::Warning("ConvertToNewIO.C","Could not get TreeH from in AliRun.");
386 /*****************************************/
388 /*****************************************/
389 //::Info("ConvertToNewIO.C","Copying S Digits.\n\n\n");
390 TString treeSname("TreeS");
393 TTree* treeS = (TTree*)insdfile->Get(treeSname);
396 TObjArray* lob = treeS->GetListOfBranches();
397 TObjArray* loaders = new TObjArray();
398 TIter nextnewmodule(outAliRun->Modules());
400 while ((module = (AliModule*)nextnewmodule()))
402 TClass* modclass = module->IsA();
403 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
404 //TClonesArray* ca = 0;
407 AliLoader* loader = det->GetLoader();
410 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
414 TString mask(det->GetName());
416 loader->LoadSDigits("update");
417 loader->MakeTree("S");
418 loaders->Add(loader);
419 for(Int_t b=0; b<lob->GetEntries();b++)
421 TBranch* branch = (TBranch*)lob->At(b);
423 TString bname(branch->GetName());//
424 if ( bname.BeginsWith(det->GetName()) )
427 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
428 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
429 TString contname(branch->GetClassName());
431 Int_t splitlvl = branch->GetSplitLevel();
432 // if (splitlvl) splitlvl = 99;
434 if ( contname.CompareTo("TClonesArray") == 0)
436 TBranchElement* belem = (TBranchElement*)branch;
437 //::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
439 TClonesArray * ca = new TClonesArray(belem->GetClonesName());
440 pbuf[nbranches] = ca;
442 branch->SetAddress(&(pbuf[nbranches]));
443 //::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
445 //::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
446 branches[nbranches] = loader->TreeS()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
451 TClass* bcl = gROOT->GetClass(branch->GetClassName());
452 pbuf[nbranches] = bcl->New();
453 //::Info("ConvertToNewIO.C","Dumping buffer:");
454 //((TObject*)pbuf[nbranches])->Dump();
455 //::Info("ConvertToNewIO.C","Setting Adress:");
456 branch->SetAddress(&(pbuf[nbranches]));
457 //::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
458 branches[nbranches] =loader->TreeS()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
462 }//loop over branches
463 }//if module is detector
464 }//while loop over modules
465 TBranch* bbb = treeS->GetBranch("PHOS");
466 Int_t nentr = (Int_t)bbb->GetEntries();
467 ////::Info("ConvertToNewIO.C","Copying SDigits. Number of entries in PHSO branch %d ... ",nentr);
469 Int_t nl = loaders->GetEntries();
470 for (Int_t e = 0; e < nentr; e++)
472 ////printf("%d\r",e);
473 // treeS->GetEntry(e);
476 for (Int_t l = 0; l < nbranches; l++)
478 // //printf("%s %#x \n", branches[l]->GetName(),pbuf[l]);
479 branches[l]->SetAddress(&(pbuf[l]));
482 for (Int_t l = 0; l < nl; l++)
484 AliLoader* loader = (AliLoader*)loaders->At(l);
485 // //printf("Filling %s\n",loader->GetName());
486 loader->TreeS()->Fill();
496 ////::Info("ConvertToNewIO.C","Copying SDigits ... Done");
497 for (Int_t l = 0; l < nl; l++)
499 AliLoader* loader = (AliLoader*)loaders->At(l);
500 loader->WriteSDigits("OVERWRITE");
501 loader->UnloadSDigits();
504 for (Int_t l = 0; l < nbranches; l++)
506 delete (TObject*)pbuf[l];
513 ::Warning("ConvertToNewIO.C","Could not get TreeS from in AliRun.");
517 /*****************************************/
519 /*****************************************/
520 //::Info("ConvertToNewIO.C","Copying Digits.\n\n\n");
521 TString treeDname("TreeD");
524 TTree* treeD = (TTree*)indigfile->Get(treeDname);
527 TObjArray* lob = treeD->GetListOfBranches();
528 TObjArray* loaders = new TObjArray();
529 TIter nextnewmodule(outAliRun->Modules());
531 while ((module = (AliModule*)nextnewmodule()))
533 TClass* modclass = module->IsA();
534 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
535 //TClonesArray* ca = 0;
538 AliLoader* loader = det->GetLoader();
541 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
545 TString mask(det->GetName());
547 loader->LoadDigits("update");
548 loader->MakeTree("D");
549 loaders->Add(loader);
550 for(Int_t b=0; b<lob->GetEntries();b++)
552 TBranch* branch = (TBranch*)lob->At(b);
554 TString bname(branch->GetName());//
555 if ( bname.BeginsWith(det->GetName()) )
558 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
559 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
560 TString contname(branch->GetClassName());
562 Int_t splitlvl = branch->GetSplitLevel();
563 // if (splitlvl) splitlvl = 99;
565 if ( contname.CompareTo("TClonesArray") == 0)
567 TBranchElement* belem = (TBranchElement*)branch;
568 ////::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
570 TClonesArray * ca = new TClonesArray(belem->GetClonesName());
571 pbuf[nbranches] = ca;
573 branch->SetAddress(&(pbuf[nbranches]));
574 ////::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
576 ////::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
577 branches[nbranches] = loader->TreeD()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
582 TClass* bcl = gROOT->GetClass(branch->GetClassName());
583 pbuf[nbranches] = bcl->New();
584 ////::Info("ConvertToNewIO.C","Dumping buffer:");
585 //((TObject*)pbuf[nbranches])->Dump();
586 ////::Info("ConvertToNewIO.C","Setting Adress:");
587 branch->SetAddress(&(pbuf[nbranches]));
588 ////::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
589 branches[nbranches] =loader->TreeD()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
593 }//loop over branches
594 }//if module is detector
595 }//while loop over modules
596 TBranch* bbb = treeD->GetBranch("PHOS");
597 Int_t nentr = (Int_t)bbb->GetEntries();
598 ////::Info("ConvertToNewIO.C","Copying Digits. Number of entries %d ... ",nentr);
600 Int_t nl = loaders->GetEntries();
601 for (Int_t e = 0; e < nentr; e++)
603 ////printf("%d\r",e);
604 //treeD->GetEntry(e);
607 for (Int_t l = 0; l < nbranches; l++)
609 // //printf("%s %#x \n", branches[l]->GetName(),pbuf[l]);
610 branches[l]->SetAddress(&(pbuf[l]));
613 for (Int_t l = 0; l < nl; l++)
615 AliLoader* loader = (AliLoader*)loaders->At(l);
616 // //printf("Filling %s\n",loader->GetName());
617 loader->TreeD()->Fill();
627 ////::Info("ConvertToNewIO.C","Copying Digits ... Done");
628 for (Int_t l = 0; l < nl; l++)
630 AliLoader* loader = (AliLoader*)loaders->At(l);
631 loader->WriteDigits("OVERWRITE");
632 loader->UnloadDigits();
635 for (Int_t l = 0; l < nbranches; l++)
637 delete (TObject*)pbuf[l];
643 ::Warning("ConvertToNewIO.C","Could not get TreeD from in AliRun.");
648 /*****************************************/
649 /* R e c P o i n t s */
650 /*****************************************/
651 ////::Info("ConvertToNewIO.C","Copying RecPoints.");
652 TString treeRname("TreeR");
655 TTree* treeR = (TTree*)inrecfile->Get(treeRname);
658 TObjArray* lob = treeR->GetListOfBranches();
659 TObjArray* loaders = new TObjArray();
660 TIter nextnewmodule(outAliRun->Modules());
662 while ((module = (AliModule*)nextnewmodule()))
664 TClass* modclass = module->IsA();
665 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
669 AliLoader* loader = det->GetLoader();
672 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
676 TString mask(det->GetName());
678 loader->LoadRecPoints("update");
679 loader->MakeTree("R");
680 loaders->Add(loader);
681 for(Int_t b=0; b<lob->GetEntries();b++)
683 TBranch* branch = (TBranch*)lob->At(b);
685 TString bname(branch->GetName());//
686 if ( bname.Contains(det->GetName()) )
688 if(bname.Contains("Emc")||bname.Contains("Cpv"))
690 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
691 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
692 TString contname(branch->GetClassName());
694 Int_t splitlvl = branch->GetSplitLevel();
695 // if (splitlvl) splitlvl = 99;
697 if ( contname.CompareTo("TClonesArray") == 0)
699 TBranchElement* belem = (TBranchElement*)branch;
700 ////::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
702 TClonesArray * ca = new TClonesArray(belem->GetClonesName());
703 pbuf[nbranches] = ca;
705 branch->SetAddress(&(pbuf[nbranches]));
706 ////::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
708 ////::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
709 branches[nbranches] = loader->TreeR()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
714 TClass* bcl = gROOT->GetClass(branch->GetClassName());
715 pbuf[nbranches] = bcl->New();
716 ////::Info("ConvertToNewIO.C","Dumping buffer:");
717 //((TObject*)pbuf[nbranches])->Dump();
718 ////::Info("ConvertToNewIO.C","Setting Adress:");
719 branch->SetAddress(&(pbuf[nbranches]));
720 ////::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
721 branches[nbranches] =loader->TreeR()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
726 }//loop over branches
727 }//if module is detector
728 }//while loop over modules
729 TBranch* bbb = treeR->GetBranch("PHOSEmcRP");
730 Int_t nentr = (Int_t)bbb->GetEntries();
731 ////::Info("ConvertToNewIO.C","Copying RecPoints. Number of entries %d ... ",nentr);
734 //Int_t nl = loaders->GetEntries();
735 // //printf(">>>>>>>>>>>>>>>>>>>>%d\n",nl);
736 bbb->SetAddress(&(pbuf[0]));
738 for (Int_t e = 0; e < nentr; e++)
740 ////printf("%d\r",e);
743 AliLoader* loader = (AliLoader*)loaders->At(0);
745 TBranch* bbb = treeR->GetBranch("PHOSCpvRP");
746 Int_t nentr = (Int_t)bbb->GetEntries();
747 ////::Info("ConvertToNewIO.C","Copying RecPoints. Number of entries %d ... ",nentr);
749 bbb->SetAddress(&(pbuf[1]));
751 for (Int_t e = 0; e < nentr; e++)
753 // //printf("%d\r",e);
755 // AliLoader* loader = (AliLoader*)loaders->At(0);
757 ////printf("Filling %s\n",loader->GetName());
758 loader->TreeR()->Fill();
769 ////::Info("ConvertToNewIO.C","Copying RecPoints ... Done");
770 Int_t nl = loaders->GetEntries();
771 for (Int_t l = 0; l < nl; l++)
774 AliLoader* loader = (AliLoader*)loaders->At(l);
775 loader->WriteRecPoints("OVERWRITE");
776 loader->UnloadRecPoints();
779 for (Int_t l = 0; l < nbranches; l++)
781 delete (TObject*)pbuf[l];//delete branches buffers
788 ::Warning("ConvertToNewIO.C","Could not get TreeR from in AliRun.");
792 /*****************************************/
794 /*****************************************/
795 ////::Info("ConvertToNewIO.C","Copying Tracks.");
796 TString treeTname("TreeR");
799 TTree* treeT = (TTree*)inrecfile->Get(treeTname);
802 TObjArray* lob = treeT->GetListOfBranches();
803 TObjArray* loaders = new TObjArray();
804 TIter nextnewmodule(outAliRun->Modules());
806 while ((module = (AliModule*)nextnewmodule()))
808 TClass* modclass = module->IsA();
809 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
810 //TClonesArray* ca = 0;
813 AliLoader* loader = det->GetLoader();
816 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
820 TString mask(det->GetName());
822 loader->LoadTracks("update");
823 loader->MakeTree("T");
824 loaders->Add(loader);
825 for(Int_t b=0; b<lob->GetEntries();b++)
827 TBranch* branch = (TBranch*)lob->At(b);
829 TString bname(branch->GetName());//
830 if ( bname.Contains(det->GetName()) )
832 if(bname.Contains("TS"))
834 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
835 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
836 TString contname(branch->GetClassName());
838 Int_t splitlvl = branch->GetSplitLevel();
839 // if (splitlvl) splitlvl = 99;
841 if ( contname.CompareTo("TClonesArray") == 0)
843 TBranchElement* belem = (TBranchElement*)branch;
844 ////::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
846 TClonesArray * ca = new TClonesArray(belem->GetClonesName());
847 pbuf[nbranches] = ca;
849 branch->SetAddress(&(pbuf[nbranches]));
850 ////::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
852 ////::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
853 branches[nbranches] = loader->TreeT()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
858 TClass* bcl = gROOT->GetClass(branch->GetClassName());
859 pbuf[nbranches] = bcl->New();
860 ////::Info("ConvertToNewIO.C","Dumping buffer:");
861 //((TObject*)pbuf[nbranches])->Dump();
862 ////::Info("ConvertToNewIO.C","Setting Adress:");
863 branch->SetAddress(&(pbuf[nbranches]));
864 ////::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
865 branches[nbranches] =loader->TreeT()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
870 }//loop over branches
871 }//if module is detector
872 }//while loop over modules
873 TBranch* bbb = treeT->GetBranch("PHOSTS");
874 Int_t nentr = (Int_t)bbb->GetEntries();
875 ////::Info("ConvertToNewIO.C","Copying Tracks. Number of entries %d ... ",nentr);
878 Int_t nl = loaders->GetEntries();
879 for (Int_t e = 0; e < nentr; e++)
881 // //printf("%d\r",e);
883 //treeR->GetEntry(e);
885 for (Int_t l = 0; l < nbranches; l++)
887 // //printf("%s %#x \n", branches[l]->GetName(),pbuf[l]);
888 branches[l]->SetAddress(&(pbuf[l]));
891 for (Int_t l = 0; l < nl; l++)
893 AliLoader* loader = (AliLoader*)loaders->At(l);
894 ////printf("Filling %s\n",loader->GetName());
895 loader->TreeT()->Fill();
907 ////::Info("ConvertToNewIO.C","Copying Tracks ... Done");
908 for (Int_t l = 0; l < nl; l++)
910 AliLoader* loader = (AliLoader*)loaders->At(l);
911 loader->WriteTracks("OVERWRITE");
912 loader->UnloadTracks();
915 for (Int_t l = 0; l < nbranches; l++)
917 delete (TObject*)pbuf[l];//delete branches buffers
924 ::Warning("ConvertToNewIO.C","Could not get TreeR from in AliRun.");
932 /*****************************************/
934 /*****************************************/
935 ////::Info("ConvertToNewIO.C","Copying RecParticles.");
936 TString treePname("TreeR");
939 TTree* treeP = (TTree*)inrecfile->Get(treeTname);
942 TObjArray* lob = treeP->GetListOfBranches();
943 TObjArray* loaders = new TObjArray();
944 TIter nextnewmodule(outAliRun->Modules());
946 while ((module = (AliModule*)nextnewmodule()))
948 TClass* modclass = module->IsA();
949 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
950 //TClonesArray* ca = 0;
953 AliLoader* loader = det->GetLoader();
956 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
960 TString mask(det->GetName());
962 loader->LoadRecParticles("update");
963 loader->MakeTree("P");
964 loaders->Add(loader);
965 for(Int_t b=0; b<lob->GetEntries();b++)
967 TBranch* branch = (TBranch*)lob->At(b);
969 TString bname(branch->GetName());//
970 if ( bname.Contains(det->GetName()) )
972 if(bname.Contains("PHOSRP"))
974 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
975 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
976 TString contname(branch->GetClassName());
978 Int_t splitlvl = branch->GetSplitLevel();
979 // if (splitlvl) splitlvl = 99;
981 if ( contname.CompareTo("TClonesArray") == 0)
983 TBranchElement* belem = (TBranchElement*)branch;
984 ////::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
986 TClonesArray * ca = new TClonesArray(belem->GetClonesName());
987 pbuf[nbranches] = ca;
989 branch->SetAddress(&(pbuf[nbranches]));
990 ////::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
992 ////::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
993 branches[nbranches] = loader->TreeP()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
998 TClass* bcl = gROOT->GetClass(branch->GetClassName());
999 pbuf[nbranches] = bcl->New();
1000 ////::Info("ConvertToNewIO.C","Dumping buffer:");
1001 //((TObject*)pbuf[nbranches])->Dump();
1002 ////::Info("ConvertToNewIO.C","Setting Adress:");
1003 branch->SetAddress(&(pbuf[nbranches]));
1004 ////::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
1005 branches[nbranches] =loader->TreeP()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
1010 }//loop over branches
1011 }//if module is detector
1012 }//while loop over modules
1013 TBranch* bbb = treeP->GetBranch("PHOSRP");
1014 Int_t nentr = (Int_t)bbb->GetEntries();
1015 ////::Info("ConvertToNewIO.C","Copying RecParticles. Number of entries %d ... ",nentr);
1018 Int_t nl = loaders->GetEntries();
1019 for (Int_t e = 0; e < nentr; e++)
1021 ////printf("%d\r",e);
1023 //treeR->GetEntry(e);
1025 for (Int_t l = 0; l < nbranches; l++)
1027 // //printf("%s %#x \n", branches[l]->GetName(),pbuf[l]);
1028 branches[l]->SetAddress(&(pbuf[l]));
1031 for (Int_t l = 0; l < nl; l++)
1033 AliLoader* loader = (AliLoader*)loaders->At(l);
1034 ////printf("Filling %s\n",loader->GetName());
1035 loader->TreeP()->Fill();
1039 #ifndef __MAKECINT__
1047 ////::Info("ConvertToNewIO.C","Copying RecParticles ... Done");
1048 for (Int_t l = 0; l < nl; l++)
1050 AliLoader* loader = (AliLoader*)loaders->At(l);
1051 loader->WriteRecParticles("OVERWRITE");
1052 loader->UnloadRecParticles();
1055 for (Int_t l = 0; l < nbranches; l++)
1057 delete (TObject*)pbuf[l];//delete branches buffers
1064 ::Warning("ConvertToNewIO.C","Could not get TreeR from in AliRun.");
1070 }//end of loop over events
1071 /***************************************************/
1072 /**** Write Tasks *************/
1073 /***************************************************/
1075 AliLoader * loader = rl->GetLoader("PHOSLoader");
1076 /**** S Digits *************/
1077 TTree * s = (TTree*)insdfile->Get("TreeS0");
1078 TBranch * bsd = s->GetBranch("AliPHOSSDigitizer");
1079 AliPHOSSDigitizer * sdig = 0;
1080 bsd->SetAddress(&sdig);
1082 sdig->SetEventFolderName(sdig->GetName()) ;
1083 sdig->SetName("PHOSSDigitizer");
1085 TFile fsd(loader->GetSDigitsFileName(), "update") ;
1091 /**** Digits *************/
1092 TTree * d = (TTree*)indigfile->Get("TreeD0");
1093 TBranch * bd = d->GetBranch("AliPHOSDigitizer");
1094 AliPHOSDigitizer * dig = 0 ;
1095 bd->SetAddress(&dig) ;
1097 dig->SetEventFolderName(dig->GetName()) ;
1098 dig->SetName("PHOSDigitizer");
1101 ////::Info("Digitizer","Print done");
1102 TFile fd(loader->GetDigitsFileName(), "update") ;
1107 /**** Rec Data *************/
1108 TTree * t = (TTree*)inrecfile->Get("TreeR0");
1109 /**** Clusterizer *************/
1110 TBranch * bclu = t->GetBranch("AliPHOSClusterizer");
1111 AliPHOSClusterizerv1 * clu = 0;
1112 bclu->SetAddress(&clu);
1114 clu->SetEventFolderName(clu->GetName()) ;
1115 clu->SetName("PHOSReconstructioner");
1117 TFile fclu(loader->GetRecPointsFileName(), "update") ;
1121 /**** TrackSegmentMaker *************/
1122 TBranch * btr = t->GetBranch("AliPHOSTrackSegmentMaker");
1123 AliPHOSTrackSegmentMakerv1 * tra = 0 ;
1124 btr->SetAddress(&tra);
1126 tra->SetEventFolderName(tra->GetName()) ;
1127 tra->SetName("PHOSTracker");
1129 TFile ftr(loader->GetTracksFileName(), "update") ;
1134 /**** PID *************/
1136 TBranch * bpid = t->GetBranch("AliPHOSPID");
1137 AliPHOSPIDv1 * pid = 0 ;
1138 bpid->SetAddress(&pid);
1140 pid->SetEventFolderName(pid->GetName()) ;
1141 pid->SetName("PHOSPIDTask");
1143 TFile fpid(loader->GetRecParticlesFileName(), "update") ;
1151 /***************************************************/
1152 /**** Run to Run *************/
1153 /***************************************************/
1155 rl->WriteHeader("OVERWRITE");
1158 TGeometry* geo = inAliRun->GetGeometry();
1163 rl->WriteRunLoader();
1165 ////::Info("ConvertToNewIO.C","Done");