12 #include <TObjectTable.h>
23 #include "AliModule.h"
24 #include "AliRunLoader.h"
25 #include "AliHeader.h"
26 #include "AliDetector.h"
27 #include "AliConfig.h"
29 #include "AliRunLoader.h"
30 #include <TParticle.h>
31 #include "TBranchClones.h"
32 #include "TBranchElement.h"
34 #include "PHOS/AliPHOSClusterizerv1.h"
35 #include "PHOS/AliPHOSDigitizer.h"
36 #include "PHOS/AliPHOSSDigitizer.h"
37 #include "PHOS/AliPHOSTrackSegmentMakerv1.h"
38 #include "PHOS/AliPHOSPIDv1.h"
43 void ConvertPHOSToNewIO(const char* name = "galice.root", TString branch ="Event" )
45 // AliLoader::SetDebug();
46 AliConfig* conf = AliConfig::Instance();
47 TClass* detclass = AliDetector::Class();
49 TBranch* branches[100];
51 // AliLoader::SetDebug(5);
52 AliRunLoader* rl = AliRunLoader::Open("galiceNewIO.root",branch,"recreate");
53 rl->SetCompressionLevel(2);
54 rl->SetNumberOfEventsPerFile(1000);
60 outAliRun = new AliRun("OutgAlice","Output gAlice");
68 outAliRun->SetRunLoader(rl);
69 TString fSdig = "PHOS.SDigits."+branch+".root";
70 TString fDig = "PHOS.Digits."+branch+".root";
71 TString fRec = "PHOS.RecData."+branch+".root";
73 TFile* insdfile = TFile::Open(fSdig);
74 TFile* indigfile = TFile::Open(fDig);
75 TFile* inrecfile = TFile::Open(fRec);
76 TFile* infile = TFile::Open(name);
80 ::Error("ConvertToNewIO.C","Can not open input file %s",name);
84 AliRun* inAliRun = (AliRun*)infile->Get("gAlice");
88 ::Error("ConvertToNewIO.C","Can not find gAlice in input file");
93 TObjArray* modules = inAliRun->Modules();
96 ::Error("ConvertToNewIO.C","Can not get array with modules from AliRun");
101 while ((module = (AliModule*)next()))
103 outAliRun->AddModule(module);
105 TClass* modclass = module->IsA();
106 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
109 ////::Info("ConvertToNewIO.C"," Adding %s to RL.",det->GetName());
110 conf->Add(det,branch);
115 TParticle* particleBuffer = new TParticle();
116 /***************************************************/
117 /**** Event to Event **************/
118 /***************************************************/
120 TTree* treeE = (TTree*)infile->Get("TE");
124 ::Error("ConvertToNewIO.C","Can not get TreeE from AliRun");
129 AliHeader* inheader = new AliHeader();
130 treeE->SetBranchAddress("Header",&inheader);
132 Int_t nevents = (Int_t)treeE->GetEntries();
133 for (Int_t i = 0; i<nevents; i++)
135 ::Info("ConvertToNewIO.C","Converting Event %d.",i);
136 rl->SetEventNumber(i);
138 /*****************************************/
140 /*****************************************/
142 ////::Info("ConvertToNewIO.C","Copying Header");
143 AliHeader* outheader = rl->GetHeader();
145 outheader->SetEvent(inheader->GetEvent());
146 outheader->SetNvertex(inheader->GetNvertex());
147 outheader->SetNprimary(inheader->GetNprimary());
148 outheader->SetNtrack(inheader->GetNtrack());
149 outheader->SetRun(inheader->GetRun());
150 outheader->SetEventNrInRun(inheader->GetEventNrInRun());
151 outheader->SetStack(inheader->Stack());
152 outheader->SetGenEventHeader(inheader->GenEventHeader());
154 rl->SetNumberOfEventsPerFile(1000);
155 /*****************************************/
156 /* K I N E M A T I C S */
157 /*****************************************/
158 ////::Info("ConvertToNewIO.C","Copying Kinematics.");
159 TString treeKname("TreeK");
161 TTree* treeK = (TTree*)infile->Get(treeKname);
164 if (treeK->GetEntries() > 0)
166 //I do this gimnastics to set directory correctly, without changing NewIO code
167 //only for this purpose
168 rl->SetNumberOfEventsPerFile(1000);
169 rl->LoadKinematics("update");
171 rl->GetEventFolder()->Remove(rl->TreeK());
174 treeK->SetBranchAddress("Particles",&particleBuffer);
175 ////::Info("ConvertToNewIO.C","Cloning TreeK ...");
176 TTree* tk = treeK->CloneTree();
177 ////::Info("ConvertToNewIO.C","Cloning TreeK ... Done");
178 tk->SetName(AliRunLoader::fgkKineContainerName);
179 rl->GetEventFolder()->Add(tk);
180 rl->WriteKinematics("OVERWRITE");
181 rl->UnloadKinematics();
185 Info("ConvertToNewIO.C","Kinematics Tree is Empty");
190 Error("ConvertToNewIO.C","Could not find Kinematics tree named %s",treeKname.Data());
193 /*****************************************/
194 /* T R A C K R E F E R E N C E S */
195 /*****************************************/
196 ////::Info("ConvertToNewIO.C","Copying Track Refs.");
197 TString treeTRname("TreeTR");
199 TTree* treeTR = (TTree*)infile->Get(treeTRname);
202 if (treeTR->GetEntries() > 0)
205 while ((module = (AliModule*)next()))
207 TClass* modclass = module->IsA();
208 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
211 TClonesArray* trbuffer = new TClonesArray("AliTrackReference", 100);
212 treeTR->SetBranchAddress(det->GetName(),&trbuffer);
216 //I do this gimnastics to set directory correctly, without changing NewIO code
217 //only for this purpose
218 rl->SetNumberOfEventsPerFile(1000);
219 rl->LoadTrackRefs("update");
220 rl->MakeTrackRefsContainer();
221 rl->GetEventFolder()->Remove(rl->TreeTR());
224 ////::Info("ConvertToNewIO.C","Cloning TreeTR ...");
225 TTree* tr = treeTR->CloneTree();
226 ////::Info("ConvertToNewIO.C","Cloning TreeTR ... Done");
228 tr->SetName(AliRunLoader::fgkTrackRefsContainerName);
229 rl->GetEventFolder()->Add(tr);
230 rl->WriteTrackRefs("OVERWRITE");
231 rl->UnloadTrackRefs();
235 Info("ConvertToNewIO.C","Track References Tree is Empty");
240 Error("ConvertToNewIO.C","Could not find Track Refs tree named %s",treeTRname.Data());
244 /*****************************************/
246 /*****************************************/
247 ////::Info("ConvertToNewIO.C","Copying Hits.");
248 TString treeHname("TreeH");
250 TTree* treeH = (TTree*)infile->Get(treeHname);
254 if (treeH->GetEntries() > 0)
256 TObjArray* lob = treeH->GetListOfBranches();
257 TObjArray* loaders = new TObjArray();
258 TIter nextnewmodule(outAliRun->Modules());
260 while ((module = (AliModule*)nextnewmodule()))
262 TClass* modclass = module->IsA();
263 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
264 //TClonesArray* ca = 0;
267 AliLoader* loader = det->GetLoader();
270 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
274 TString mask(det->GetName());
276 loader->LoadHits("update");
277 loader->MakeTree("H");
278 loaders->Add(loader);
279 for(Int_t b=0; b<lob->GetEntries();b++)
281 TBranch* branch = (TBranch*)lob->At(b);
282 TString bname(branch->GetName());//
283 if ( bname.BeginsWith(det->GetName()) )
285 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
286 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
287 TString contname(branch->GetClassName());
289 Int_t splitlvl = branch->GetSplitLevel();
290 // if (splitlvl) splitlvl = 99;
292 if( contname.CompareTo("TClonesArray") == 0)
294 TBranchElement* belem = (TBranchElement*)branch;
295 //::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
297 TClonesArray *ca = new TClonesArray(belem->GetClonesName());
298 pbuf[nbranches] = ca;
300 branch->SetAddress(&(pbuf[nbranches]));
301 //::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
303 //::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
304 branches[nbranches] = loader->TreeH()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
309 //::Info("ConvertToNewIO.C","Class Nmme is %s",branch->GetClassName());
310 TClass* bcl = gROOT->GetClass(branch->GetClassName());
313 ::Error("ConvertToNewIO.C","Can not get TClass object of class named %s",branch->GetClassName());
316 pbuf[nbranches] = bcl->New();
317 //::Info("ConvertToNewIO.C","Dumping buffer:");
318 //((TObject*)pbuf[nbranches])->Dump();
319 //::Info("ConvertToNewIO.C","Setting Adress:");
320 branch->SetAddress(&(pbuf[nbranches]));
321 //::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
322 branches[nbranches] =loader->TreeH()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
326 }//loop over branches
327 }//if module is detector
328 }//while loop over modules
329 Int_t nentr = (Int_t)treeH->GetEntries();
330 //::Info("ConvertToNewIO.C","Copying Hits . Number of entries %d ... ",nentr);
333 Int_t nl = loaders->GetEntries();
334 for (Int_t e = 0; e < nentr; e++)
339 for (Int_t l = 0; l < nbranches; l++)
341 //printf("Branch %d addr %#x\n",l,pbuf[l]);
342 //printf("%s %#x \n", branches[l]->GetName(),pbuf[l]);
343 branches[l]->SetAddress(&(pbuf[l]));
346 for (Int_t l = 0; l < nl; l++)
348 AliLoader* loader = (AliLoader*)loaders->At(l);
349 //printf("Filling %s\n",loader->GetName());
350 loader->TreeH()->Fill();
360 ////::Info("ConvertToNewIO.C","Copying Hits ... Done");
361 for (Int_t l = 0; l < nl; l++)
363 AliLoader* loader = (AliLoader*)loaders->At(l);
364 loader->WriteHits("OVERWRITE");
365 loader->UnloadHits();
368 for (Int_t l = 0; l < nbranches; l++)
370 delete (TObject*)pbuf[l];
374 else //tree has any entries
376 Info("ConvertToNewIO.C","Hits Tree is Empty");
381 ::Warning("ConvertToNewIO.C","Could not get TreeH from in AliRun.");
385 /*****************************************/
387 /*****************************************/
388 //::Info("ConvertToNewIO.C","Copying S Digits.\n\n\n");
389 TString treeSname("TreeS");
392 TTree* treeS = (TTree*)insdfile->Get(treeSname);
395 TObjArray* lob = treeS->GetListOfBranches();
396 TObjArray* loaders = new TObjArray();
397 TIter nextnewmodule(outAliRun->Modules());
399 while ((module = (AliModule*)nextnewmodule()))
401 TClass* modclass = module->IsA();
402 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
403 //TClonesArray* ca = 0;
406 AliLoader* loader = det->GetLoader();
409 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
413 TString mask(det->GetName());
415 loader->LoadSDigits("update");
416 loader->MakeTree("S");
417 loaders->Add(loader);
418 for(Int_t b=0; b<lob->GetEntries();b++)
420 TBranch* branch = (TBranch*)lob->At(b);
422 TString bname(branch->GetName());//
423 if ( bname.BeginsWith(det->GetName()) )
426 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
427 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
428 TString contname(branch->GetClassName());
430 Int_t splitlvl = branch->GetSplitLevel();
431 // if (splitlvl) splitlvl = 99;
433 if ( contname.CompareTo("TClonesArray") == 0)
435 TBranchElement* belem = (TBranchElement*)branch;
436 //::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
438 TClonesArray * ca = new TClonesArray(belem->GetClonesName());
439 pbuf[nbranches] = ca;
441 branch->SetAddress(&(pbuf[nbranches]));
442 //::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
444 //::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
445 branches[nbranches] = loader->TreeS()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
450 TClass* bcl = gROOT->GetClass(branch->GetClassName());
451 pbuf[nbranches] = bcl->New();
452 //::Info("ConvertToNewIO.C","Dumping buffer:");
453 //((TObject*)pbuf[nbranches])->Dump();
454 //::Info("ConvertToNewIO.C","Setting Adress:");
455 branch->SetAddress(&(pbuf[nbranches]));
456 //::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
457 branches[nbranches] =loader->TreeS()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
461 }//loop over branches
462 }//if module is detector
463 }//while loop over modules
464 TBranch* bbb = treeS->GetBranch("PHOS");
465 Int_t nentr = (Int_t)bbb->GetEntries();
466 ////::Info("ConvertToNewIO.C","Copying SDigits. Number of entries in PHSO branch %d ... ",nentr);
468 Int_t nl = loaders->GetEntries();
469 for (Int_t e = 0; e < nentr; e++)
471 ////printf("%d\r",e);
472 // treeS->GetEntry(e);
475 for (Int_t l = 0; l < nbranches; l++)
477 // //printf("%s %#x \n", branches[l]->GetName(),pbuf[l]);
478 branches[l]->SetAddress(&(pbuf[l]));
481 for (Int_t l = 0; l < nl; l++)
483 AliLoader* loader = (AliLoader*)loaders->At(l);
484 // //printf("Filling %s\n",loader->GetName());
485 loader->TreeS()->Fill();
495 ////::Info("ConvertToNewIO.C","Copying SDigits ... Done");
496 for (Int_t l = 0; l < nl; l++)
498 AliLoader* loader = (AliLoader*)loaders->At(l);
499 loader->WriteSDigits("OVERWRITE");
500 loader->UnloadSDigits();
503 for (Int_t l = 0; l < nbranches; l++)
505 delete (TObject*)pbuf[l];
512 ::Warning("ConvertToNewIO.C","Could not get TreeS from in AliRun.");
516 /*****************************************/
518 /*****************************************/
519 //::Info("ConvertToNewIO.C","Copying Digits.\n\n\n");
520 TString treeDname("TreeD");
523 TTree* treeD = (TTree*)indigfile->Get(treeDname);
526 TObjArray* lob = treeD->GetListOfBranches();
527 TObjArray* loaders = new TObjArray();
528 TIter nextnewmodule(outAliRun->Modules());
530 while ((module = (AliModule*)nextnewmodule()))
532 TClass* modclass = module->IsA();
533 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
534 //TClonesArray* ca = 0;
537 AliLoader* loader = det->GetLoader();
540 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
544 TString mask(det->GetName());
546 loader->LoadDigits("update");
547 loader->MakeTree("D");
548 loaders->Add(loader);
549 for(Int_t b=0; b<lob->GetEntries();b++)
551 TBranch* branch = (TBranch*)lob->At(b);
553 TString bname(branch->GetName());//
554 if ( bname.BeginsWith(det->GetName()) )
557 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
558 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
559 TString contname(branch->GetClassName());
561 Int_t splitlvl = branch->GetSplitLevel();
562 // if (splitlvl) splitlvl = 99;
564 if ( contname.CompareTo("TClonesArray") == 0)
566 TBranchElement* belem = (TBranchElement*)branch;
567 ////::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
569 TClonesArray * ca = new TClonesArray(belem->GetClonesName());
570 pbuf[nbranches] = ca;
572 branch->SetAddress(&(pbuf[nbranches]));
573 ////::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
575 ////::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
576 branches[nbranches] = loader->TreeD()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
581 TClass* bcl = gROOT->GetClass(branch->GetClassName());
582 pbuf[nbranches] = bcl->New();
583 ////::Info("ConvertToNewIO.C","Dumping buffer:");
584 //((TObject*)pbuf[nbranches])->Dump();
585 ////::Info("ConvertToNewIO.C","Setting Adress:");
586 branch->SetAddress(&(pbuf[nbranches]));
587 ////::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
588 branches[nbranches] =loader->TreeD()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
592 }//loop over branches
593 }//if module is detector
594 }//while loop over modules
595 TBranch* bbb = treeD->GetBranch("PHOS");
596 Int_t nentr = (Int_t)bbb->GetEntries();
597 ////::Info("ConvertToNewIO.C","Copying Digits. Number of entries %d ... ",nentr);
599 Int_t nl = loaders->GetEntries();
600 for (Int_t e = 0; e < nentr; e++)
602 ////printf("%d\r",e);
603 //treeD->GetEntry(e);
606 for (Int_t l = 0; l < nbranches; l++)
608 // //printf("%s %#x \n", branches[l]->GetName(),pbuf[l]);
609 branches[l]->SetAddress(&(pbuf[l]));
612 for (Int_t l = 0; l < nl; l++)
614 AliLoader* loader = (AliLoader*)loaders->At(l);
615 // //printf("Filling %s\n",loader->GetName());
616 loader->TreeD()->Fill();
626 ////::Info("ConvertToNewIO.C","Copying Digits ... Done");
627 for (Int_t l = 0; l < nl; l++)
629 AliLoader* loader = (AliLoader*)loaders->At(l);
630 loader->WriteDigits("OVERWRITE");
631 loader->UnloadDigits();
634 for (Int_t l = 0; l < nbranches; l++)
636 delete (TObject*)pbuf[l];
642 ::Warning("ConvertToNewIO.C","Could not get TreeD from in AliRun.");
647 /*****************************************/
648 /* R e c P o i n t s */
649 /*****************************************/
650 ////::Info("ConvertToNewIO.C","Copying RecPoints.");
651 TString treeRname("TreeR");
654 TTree* treeR = (TTree*)inrecfile->Get(treeRname);
657 TObjArray* lob = treeR->GetListOfBranches();
658 TObjArray* loaders = new TObjArray();
659 TIter nextnewmodule(outAliRun->Modules());
661 while ((module = (AliModule*)nextnewmodule()))
663 TClass* modclass = module->IsA();
664 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
668 AliLoader* loader = det->GetLoader();
671 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
675 TString mask(det->GetName());
677 loader->LoadRecPoints("update");
678 loader->MakeTree("R");
679 loaders->Add(loader);
680 for(Int_t b=0; b<lob->GetEntries();b++)
682 TBranch* branch = (TBranch*)lob->At(b);
684 TString bname(branch->GetName());//
685 if ( bname.Contains(det->GetName()) )
687 if(bname.Contains("Emc")||bname.Contains("Cpv"))
689 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
690 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
691 TString contname(branch->GetClassName());
693 Int_t splitlvl = branch->GetSplitLevel();
694 // if (splitlvl) splitlvl = 99;
696 if ( contname.CompareTo("TClonesArray") == 0)
698 TBranchElement* belem = (TBranchElement*)branch;
699 ////::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
701 TClonesArray * ca = new TClonesArray(belem->GetClonesName());
702 pbuf[nbranches] = ca;
704 branch->SetAddress(&(pbuf[nbranches]));
705 ////::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
707 ////::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
708 branches[nbranches] = loader->TreeR()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
713 TClass* bcl = gROOT->GetClass(branch->GetClassName());
714 pbuf[nbranches] = bcl->New();
715 ////::Info("ConvertToNewIO.C","Dumping buffer:");
716 //((TObject*)pbuf[nbranches])->Dump();
717 ////::Info("ConvertToNewIO.C","Setting Adress:");
718 branch->SetAddress(&(pbuf[nbranches]));
719 ////::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
720 branches[nbranches] =loader->TreeR()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
725 }//loop over branches
726 }//if module is detector
727 }//while loop over modules
728 TBranch* bbb = treeR->GetBranch("PHOSEmcRP");
729 Int_t nentr = (Int_t)bbb->GetEntries();
730 ////::Info("ConvertToNewIO.C","Copying RecPoints. Number of entries %d ... ",nentr);
733 //Int_t nl = loaders->GetEntries();
734 // //printf(">>>>>>>>>>>>>>>>>>>>%d\n",nl);
735 bbb->SetAddress(&(pbuf[0]));
737 for (Int_t e = 0; e < nentr; e++)
739 ////printf("%d\r",e);
742 AliLoader* loader = (AliLoader*)loaders->At(0);
744 TBranch* bbb = treeR->GetBranch("PHOSCpvRP");
745 Int_t nentr = (Int_t)bbb->GetEntries();
746 ////::Info("ConvertToNewIO.C","Copying RecPoints. Number of entries %d ... ",nentr);
748 bbb->SetAddress(&(pbuf[1]));
750 for (Int_t e = 0; e < nentr; e++)
752 // //printf("%d\r",e);
754 // AliLoader* loader = (AliLoader*)loaders->At(0);
756 ////printf("Filling %s\n",loader->GetName());
757 loader->TreeR()->Fill();
768 ////::Info("ConvertToNewIO.C","Copying RecPoints ... Done");
769 Int_t nl = loaders->GetEntries();
770 for (Int_t l = 0; l < nl; l++)
773 AliLoader* loader = (AliLoader*)loaders->At(l);
774 loader->WriteRecPoints("OVERWRITE");
775 loader->UnloadRecPoints();
778 for (Int_t l = 0; l < nbranches; l++)
780 delete (TObject*)pbuf[l];//delete branches buffers
787 ::Warning("ConvertToNewIO.C","Could not get TreeR from in AliRun.");
791 /*****************************************/
793 /*****************************************/
794 ////::Info("ConvertToNewIO.C","Copying Tracks.");
795 TString treeTname("TreeR");
798 TTree* treeT = (TTree*)inrecfile->Get(treeTname);
801 TObjArray* lob = treeT->GetListOfBranches();
802 TObjArray* loaders = new TObjArray();
803 TIter nextnewmodule(outAliRun->Modules());
805 while ((module = (AliModule*)nextnewmodule()))
807 TClass* modclass = module->IsA();
808 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
809 //TClonesArray* ca = 0;
812 AliLoader* loader = det->GetLoader();
815 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
819 TString mask(det->GetName());
821 loader->LoadTracks("update");
822 loader->MakeTree("T");
823 loaders->Add(loader);
824 for(Int_t b=0; b<lob->GetEntries();b++)
826 TBranch* branch = (TBranch*)lob->At(b);
828 TString bname(branch->GetName());//
829 if ( bname.Contains(det->GetName()) )
831 if(bname.Contains("TS"))
833 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
834 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
835 TString contname(branch->GetClassName());
837 Int_t splitlvl = branch->GetSplitLevel();
838 // if (splitlvl) splitlvl = 99;
840 if ( contname.CompareTo("TClonesArray") == 0)
842 TBranchElement* belem = (TBranchElement*)branch;
843 ////::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
845 TClonesArray * ca = new TClonesArray(belem->GetClonesName());
846 pbuf[nbranches] = ca;
848 branch->SetAddress(&(pbuf[nbranches]));
849 ////::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
851 ////::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
852 branches[nbranches] = loader->TreeT()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
857 TClass* bcl = gROOT->GetClass(branch->GetClassName());
858 pbuf[nbranches] = bcl->New();
859 ////::Info("ConvertToNewIO.C","Dumping buffer:");
860 //((TObject*)pbuf[nbranches])->Dump();
861 ////::Info("ConvertToNewIO.C","Setting Adress:");
862 branch->SetAddress(&(pbuf[nbranches]));
863 ////::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
864 branches[nbranches] =loader->TreeT()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
869 }//loop over branches
870 }//if module is detector
871 }//while loop over modules
872 TBranch* bbb = treeT->GetBranch("PHOSTS");
873 Int_t nentr = (Int_t)bbb->GetEntries();
874 ////::Info("ConvertToNewIO.C","Copying Tracks. Number of entries %d ... ",nentr);
877 Int_t nl = loaders->GetEntries();
878 for (Int_t e = 0; e < nentr; e++)
880 // //printf("%d\r",e);
882 //treeR->GetEntry(e);
884 for (Int_t l = 0; l < nbranches; l++)
886 // //printf("%s %#x \n", branches[l]->GetName(),pbuf[l]);
887 branches[l]->SetAddress(&(pbuf[l]));
890 for (Int_t l = 0; l < nl; l++)
892 AliLoader* loader = (AliLoader*)loaders->At(l);
893 ////printf("Filling %s\n",loader->GetName());
894 loader->TreeT()->Fill();
906 ////::Info("ConvertToNewIO.C","Copying Tracks ... Done");
907 for (Int_t l = 0; l < nl; l++)
909 AliLoader* loader = (AliLoader*)loaders->At(l);
910 loader->WriteTracks("OVERWRITE");
911 loader->UnloadTracks();
914 for (Int_t l = 0; l < nbranches; l++)
916 delete (TObject*)pbuf[l];//delete branches buffers
923 ::Warning("ConvertToNewIO.C","Could not get TreeR from in AliRun.");
931 /*****************************************/
933 /*****************************************/
934 ////::Info("ConvertToNewIO.C","Copying RecParticles.");
935 TString treePname("TreeR");
938 TTree* treeP = (TTree*)inrecfile->Get(treeTname);
941 TObjArray* lob = treeP->GetListOfBranches();
942 TObjArray* loaders = new TObjArray();
943 TIter nextnewmodule(outAliRun->Modules());
945 while ((module = (AliModule*)nextnewmodule()))
947 TClass* modclass = module->IsA();
948 AliDetector *det = (AliDetector*)(modclass->DynamicCast(detclass,module));
949 //TClonesArray* ca = 0;
952 AliLoader* loader = det->GetLoader();
955 ::Error("ConvertToNewIO.C","Can not find loader from %s.",det->GetName());
959 TString mask(det->GetName());
961 loader->LoadRecParticles("update");
962 loader->MakeTree("P");
963 loaders->Add(loader);
964 for(Int_t b=0; b<lob->GetEntries();b++)
966 TBranch* branch = (TBranch*)lob->At(b);
968 TString bname(branch->GetName());//
969 if ( bname.Contains(det->GetName()) )
971 if(bname.Contains("PHOSRP"))
973 ////::Info("ConvertToNewIO.C","Found branch %s.",branch->GetName());
974 ////::Info("ConvertToNewIO.C","Buffer Class Name %s.",branch->GetClassName());
975 TString contname(branch->GetClassName());
977 Int_t splitlvl = branch->GetSplitLevel();
978 // if (splitlvl) splitlvl = 99;
980 if ( contname.CompareTo("TClonesArray") == 0)
982 TBranchElement* belem = (TBranchElement*)branch;
983 ////::Info("ConvertToNewIO.C","Clones Class Name %s.",belem->GetClonesName());
985 TClonesArray * ca = new TClonesArray(belem->GetClonesName());
986 pbuf[nbranches] = ca;
988 branch->SetAddress(&(pbuf[nbranches]));
989 ////::Info("ConvertToNewIO.C","Buffer addrss %#x",pbuf[nbranches]);
991 ////::Info("ConvertToNewIO.C","Creating branch for Clones SpliLvl = %d",splitlvl);
992 branches[nbranches] = loader->TreeP()->Branch(branch->GetName(),&(pbuf[nbranches]),4000,splitlvl);
997 TClass* bcl = gROOT->GetClass(branch->GetClassName());
998 pbuf[nbranches] = bcl->New();
999 ////::Info("ConvertToNewIO.C","Dumping buffer:");
1000 //((TObject*)pbuf[nbranches])->Dump();
1001 ////::Info("ConvertToNewIO.C","Setting Adress:");
1002 branch->SetAddress(&(pbuf[nbranches]));
1003 ////::Info("ConvertToNewIO.C","Creating branch SpliLvl = %d",splitlvl);
1004 branches[nbranches] =loader->TreeP()->Branch(branch->GetName(),branch->GetClassName(),&(pbuf[nbranches]),4000,splitlvl);
1009 }//loop over branches
1010 }//if module is detector
1011 }//while loop over modules
1012 TBranch* bbb = treeP->GetBranch("PHOSRP");
1013 Int_t nentr = (Int_t)bbb->GetEntries();
1014 ////::Info("ConvertToNewIO.C","Copying RecParticles. Number of entries %d ... ",nentr);
1017 Int_t nl = loaders->GetEntries();
1018 for (Int_t e = 0; e < nentr; e++)
1020 ////printf("%d\r",e);
1022 //treeR->GetEntry(e);
1024 for (Int_t l = 0; l < nbranches; l++)
1026 // //printf("%s %#x \n", branches[l]->GetName(),pbuf[l]);
1027 branches[l]->SetAddress(&(pbuf[l]));
1030 for (Int_t l = 0; l < nl; l++)
1032 AliLoader* loader = (AliLoader*)loaders->At(l);
1033 ////printf("Filling %s\n",loader->GetName());
1034 loader->TreeP()->Fill();
1038 #ifndef __MAKECINT__
1046 ////::Info("ConvertToNewIO.C","Copying RecParticles ... Done");
1047 for (Int_t l = 0; l < nl; l++)
1049 AliLoader* loader = (AliLoader*)loaders->At(l);
1050 loader->WriteRecParticles("OVERWRITE");
1051 loader->UnloadRecParticles();
1054 for (Int_t l = 0; l < nbranches; l++)
1056 delete (TObject*)pbuf[l];//delete branches buffers
1063 ::Warning("ConvertToNewIO.C","Could not get TreeR from in AliRun.");
1069 }//end of loop over events
1070 /***************************************************/
1071 /**** Write Tasks *************/
1072 /***************************************************/
1074 AliLoader * loader = rl->GetLoader("PHOSLoader");
1075 /**** S Digits *************/
1076 TTree * s = (TTree*)insdfile->Get("TreeS0");
1077 TBranch * bsd = s->GetBranch("AliPHOSSDigitizer");
1078 AliPHOSSDigitizer * sdig = 0;
1079 bsd->SetAddress(&sdig);
1081 sdig->SetEventFolderName(sdig->GetName()) ;
1082 sdig->SetName("PHOSSDigitizer");
1084 TFile fsd(loader->GetSDigitsFileName(), "update") ;
1090 /**** Digits *************/
1091 TTree * d = (TTree*)indigfile->Get("TreeD0");
1092 TBranch * bd = d->GetBranch("AliPHOSDigitizer");
1093 AliPHOSDigitizer * dig = 0 ;
1094 bd->SetAddress(&dig) ;
1096 dig->SetEventFolderName(dig->GetName()) ;
1097 dig->SetName("PHOSDigitizer");
1100 ////::Info("Digitizer","Print done");
1101 TFile fd(loader->GetDigitsFileName(), "update") ;
1106 /**** Rec Data *************/
1107 TTree * t = (TTree*)inrecfile->Get("TreeR0");
1108 /**** Clusterizer *************/
1109 TBranch * bclu = t->GetBranch("AliPHOSClusterizer");
1110 AliPHOSClusterizerv1 * clu = 0;
1111 bclu->SetAddress(&clu);
1113 clu->SetEventFolderName(clu->GetName()) ;
1114 clu->SetName("PHOSReconstructioner");
1116 TFile fclu(loader->GetRecPointsFileName(), "update") ;
1120 /**** TrackSegmentMaker *************/
1121 TBranch * btr = t->GetBranch("AliPHOSTrackSegmentMaker");
1122 AliPHOSTrackSegmentMakerv1 * tra = 0 ;
1123 btr->SetAddress(&tra);
1125 tra->SetEventFolderName(tra->GetName()) ;
1126 tra->SetName("PHOSTracker");
1128 TFile ftr(loader->GetTracksFileName(), "update") ;
1133 /**** PID *************/
1135 TBranch * bpid = t->GetBranch("AliPHOSPID");
1136 AliPHOSPIDv1 * pid = 0 ;
1137 bpid->SetAddress(&pid);
1139 pid->SetEventFolderName(pid->GetName()) ;
1140 pid->SetName("PHOSPIDTask");
1142 TFile fpid(loader->GetRecParticlesFileName(), "update") ;
1150 /***************************************************/
1151 /**** Run to Run *************/
1152 /***************************************************/
1154 rl->WriteHeader("OVERWRITE");
1157 TGeometry* geo = inAliRun->GetGeometry();
1162 rl->WriteRunLoader();
1164 ////::Info("ConvertToNewIO.C","Done");