25 |
RunGlue::RunGlue(TSQLServer *da, UInt_t ru, TString di, TString wrkdi) { |
RunGlue::RunGlue(TSQLServer *da, UInt_t ru, TString di, TString wrkdi) { |
26 |
fDBG = false; |
fDBG = false; |
27 |
li = new PamLevel2(); |
li = new PamLevel2(); |
28 |
|
// li = 0; |
29 |
this->Clear(); |
this->Clear(); |
30 |
dbc = da; |
dbc = da; |
31 |
run = ru; |
run = ru; |
32 |
dir = di; |
dir = di; |
33 |
// |
// |
34 |
TString wd = gSystem->WorkingDirectory(); |
wd = gSystem->WorkingDirectory(); |
35 |
// |
// |
36 |
outdir = wrkdi; |
outdir = wrkdi; |
37 |
if ( !strcmp(outdir.Data(),"") ) outdir = wd; |
if ( !strcmp(outdir.Data(),"") ) outdir = wd; |
47 |
// |
// |
48 |
}; |
}; |
49 |
|
|
|
|
|
50 |
void RunGlue::Clear() { |
void RunGlue::Clear() { |
51 |
fEnd = false; |
fEnd = false; |
52 |
run = 0; |
run = 0; |
75 |
if (list.Contains("+ALL", TString::kIgnoreCase)) RUN = true; |
if (list.Contains("+ALL", TString::kIgnoreCase)) RUN = true; |
76 |
// |
// |
77 |
fDList = list; |
fDList = list; |
78 |
li->SetWhichTrees(fDList); |
// li->SetWhichTrees(fDList); |
79 |
// |
// |
80 |
if ( DebugMode() ) printf(" Detector list is %s \n",fDList.Data()); |
if ( DebugMode() ) printf(" Detector list is %s \n",fDList.Data()); |
81 |
// |
// |
82 |
}; |
}; |
83 |
|
|
84 |
TList *RunGlue::GetRunList(){ |
TList *RunGlue::GetRunList(){ |
85 |
// |
// |
86 |
lList = new TList(); |
lList = new TList(); |
87 |
lList->Clear(); |
lList->Clear(); |
88 |
TString thisrun; |
TString thisrun; |
173 |
if ( li->CheckLevel2File(thisrun) ){ |
if ( li->CheckLevel2File(thisrun) ){ |
174 |
lList->Add(su); |
lList->Add(su); |
175 |
} else { |
} else { |
176 |
if ( DebugMode() ) printf(" RUN %s DISCARDED \n",Row->GetField(0)); |
if ( DebugMode() ) printf(" RUN %s DISCARDED \n",Row->GetField(0)); |
177 |
}; |
}; |
178 |
// |
// |
179 |
}; |
}; |
410 |
// |
// |
411 |
TTree::SetMaxTreeSize(maxsize); |
TTree::SetMaxTreeSize(maxsize); |
412 |
Target->SetCompressionLevel(2); |
Target->SetCompressionLevel(2); |
413 |
|
//Target->SetCompressionLevel(5); |
414 |
// |
// |
415 |
fOpen = true; |
fOpen = true; |
416 |
return(true); |
return(true); |
472 |
}; |
}; |
473 |
// |
// |
474 |
myquery.str(""); |
myquery.str(""); |
475 |
myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'" << outdir.Data() << "','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
// myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'" << outdir.Data() << "','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
476 |
|
myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'$PAM_L2','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
477 |
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
478 |
// |
// |
479 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
529 |
// |
// |
530 |
void RunGlue::MergeRootfile(TList *sourcelist) { |
void RunGlue::MergeRootfile(TList *sourcelist) { |
531 |
// |
// |
532 |
merged = false; |
merged = true; |
|
// |
|
|
TDirectory *target = Target; |
|
|
// |
|
|
if ( DebugMode() ) printf("\nTarget path is: %s \n",target->GetPath()); |
|
533 |
// |
// |
534 |
TString path( (char*)strstr( target->GetPath(), ":" ) ); |
if ( li ) li->Delete(); |
535 |
path.Remove(0,2); |
li = new PamLevel2(wd,sourcelist,fDList); |
536 |
// |
// |
537 |
TDirectory *first_source = (TDirectory*)sourcelist->First(); |
Target->cd(); |
|
THashList allNames; |
|
|
// |
|
|
while ( first_source ){ |
|
|
// |
|
|
TDirectory *current_sourcedir = first_source->GetDirectory(path); |
|
|
// |
|
|
if ( !current_sourcedir ){ |
|
|
first_source = (TDirectory*)sourcelist->After(first_source); |
|
|
continue; |
|
|
} |
|
|
// |
|
|
// loop over all keys in this directory |
|
|
// |
|
|
TChain *globChain = 0; |
|
|
TIter nextkey( current_sourcedir->GetListOfKeys() ); |
|
|
TKey *key = 0; |
|
|
TKey *oldkey = 0; |
|
|
TH1::AddDirectory(kFALSE); // gain time, do not add the objects in the list in memory |
|
|
// |
|
|
while ( (key = (TKey*)nextkey()) ) { |
|
|
// |
|
|
// printf(" target ls \n"); |
|
|
// Target->ls(); |
|
|
// |
|
|
if ( current_sourcedir == target ) break; |
|
|
// |
|
|
if ( oldkey && !strcmp(oldkey->GetName(),key->GetName()) ) continue; //keep only the highest cycle number for each key |
|
|
// |
|
|
if ( allNames.FindObject(key->GetName()) ) continue; |
|
|
// |
|
|
if ( DebugMode() ) printf(" Key name is -%s- \n",key->GetName()); |
|
|
// |
|
|
// |
|
|
// |
|
|
if ( !strcmp(key->GetName(),"Tracker") && !li->TRK2 && !li->TRK1 && !li->TRKh ) continue; |
|
|
// |
|
|
if ( !strcmp(key->GetName(),"Calorimeter") && !li->CAL2 && !li->CAL1 ) continue; |
|
|
// |
|
|
if ( !strcmp(key->GetName(),"ToF") && !li->TOF ) continue; |
|
|
// |
|
|
if ( !strcmp(key->GetName(),"Trigger") && !li->TRG ) continue; |
|
|
// |
|
|
if ( !strcmp(key->GetName(),"Anticounter") && !li->AC ) continue; |
|
|
// |
|
|
if ( !strcmp(key->GetName(),"S4") && !li->S4 ) continue; |
|
|
// |
|
|
if ( !strcmp(key->GetName(),"NeutronD") && !li->ND ) continue; |
|
|
// |
|
|
if ( !strcmp(key->GetName(),"OrbitalInfo") && !li->ORB ) continue; |
|
|
// |
|
|
if ( !strcmp(key->GetName(),"Run") && !RUN ) continue; |
|
|
// |
|
|
if ( strcmp(key->GetName(),"Calorimeter") && strcmp(key->GetName(),"Tracker") && strcmp(key->GetName(),"ToF") && strcmp(key->GetName(),"Trigger") && strcmp(key->GetName(),"Anticounter") && strcmp(key->GetName(),"S4") && strcmp(key->GetName(),"NeutronD") && strcmp(key->GetName(),"OrbitalInfo") && strcmp(key->GetName(),"Run") && strcmp(key->GetName(),"ProcessID0") ){ |
|
|
if ( DebugMode() ) printf(" ERROR UNKNOWN KEY %s !\n",key->GetName()); |
|
|
continue; |
|
|
}; |
|
|
// |
|
|
allNames.Add(new TObjString(key->GetName())); |
|
|
// |
|
|
// read object from first source file |
|
|
// |
|
|
current_sourcedir->cd(); |
|
|
TObject *obj = key->ReadObj(); |
|
|
// |
|
|
if ( obj->IsA()->InheritsFrom("TTree") ){ |
|
|
// |
|
|
// loop over all source files create a chain of Trees "globChain" |
|
|
// |
|
|
TString obj_name; |
|
|
// |
|
|
if ( path.Length() ) { |
|
|
obj_name = path + "/" + obj->GetName(); |
|
|
} else { |
|
|
obj_name = obj->GetName(); |
|
|
}; |
|
|
// |
|
|
globChain = new TChain(obj_name); |
|
|
// |
|
|
globChain->SetCacheSize(0); |
|
|
// |
|
|
globChain->Add(first_source->GetName()); |
|
|
// |
|
|
TFile *nextsource = (TFile*)sourcelist->After( first_source ); |
|
|
// |
|
|
while ( nextsource ) { |
|
|
// |
|
|
//do not add to the list a file that does not contain this Tree |
|
|
// |
|
|
TFile *curf = TFile::Open(nextsource->GetName()); |
|
|
// |
|
|
if ( curf ) { |
|
|
// |
|
|
Bool_t mustAdd = kFALSE; |
|
|
// |
|
|
if (curf->FindKey(obj_name)) { |
|
|
// |
|
|
mustAdd = kTRUE; |
|
|
// |
|
|
} else { |
|
|
// |
|
|
//we could be more clever here. No need to import the object |
|
|
//we are missing a function in TDirectory |
|
|
// |
|
|
TObject *aobj = curf->Get(obj_name); |
|
|
// |
|
|
if ( aobj ){ |
|
|
mustAdd = kTRUE; |
|
|
delete aobj; |
|
|
}; |
|
|
}; |
|
|
if (mustAdd) { |
|
|
globChain->Add(nextsource->GetName()); |
|
|
}; |
|
|
}; |
|
|
delete curf; |
|
|
nextsource = (TFile*)sourcelist->After(nextsource); |
|
|
}; |
|
|
// |
|
|
delete nextsource; |
|
|
// |
|
|
} else { |
|
|
// |
|
|
// object is of no type that we know or can handle |
|
|
// |
|
|
if ( DebugMode() ) cout << "Unknown object type, name: " |
|
|
<< obj->GetName() << " title: " << obj->GetTitle() << endl; |
|
|
}; |
|
|
// |
|
|
// now write the merged histogram (which is "in" obj) to the target file |
|
|
// note that this will just store obj in the current directory level, |
|
|
// which is not persistent until the complete directory itself is stored |
|
|
// by "target->Write()" below |
|
|
// |
|
|
if ( obj ){ |
|
|
// |
|
|
target->cd(); |
|
|
// |
|
|
if( obj->IsA()->InheritsFrom("TTree") ) { |
|
|
// |
|
|
Long64_t nfiles = 0; |
|
|
if ( fastMethod ){ |
|
|
// globChain->Merge(target->GetFile(),0,"C keep fast"); |
|
|
nfiles=this->Mergy((TChain*)globChain,target->GetFile(),0,"C keep fast"); |
|
|
} else { |
|
|
//globChain->Merge(target->GetFile(),0,"C keep"); |
|
|
nfiles=this->Mergy((TChain*)globChain,target->GetFile(),0,"C keep"); |
|
|
}; |
|
|
// |
|
|
merged = true; |
|
|
// |
|
|
if ( DebugMode() ){ |
|
|
printf(" Merged %i files\n",(int)nfiles); |
|
|
globChain->ls(); |
|
|
}; |
|
|
// |
|
|
delete globChain; |
|
|
// return; |
|
|
// |
|
|
} else { |
|
|
// |
|
|
// obj->Write( key->GetName() ); // <================================================================================== |
|
|
// |
|
|
}; |
|
|
}; |
|
|
delete obj; |
|
|
oldkey = key; |
|
|
}; |
|
|
// |
|
|
first_source = (TDirectory*)sourcelist->After(first_source); |
|
|
// |
|
|
}; |
|
|
// save modifications to target file |
|
|
// |
|
|
target->SaveSelf(kTRUE); |
|
538 |
// |
// |
539 |
|
li->CreateCloneTrees(Target); |
540 |
|
ULong64_t nevents = li->GetEntries(); |
541 |
|
printf(" NEVENTS %llu \n",nevents); |
542 |
|
for(ULong64_t iev=0; iev<nevents; iev++){ |
543 |
|
li->Clear(); |
544 |
|
if( li->GetEntry(iev) ){ |
545 |
|
li->FillCloneTrees(); |
546 |
|
}; |
547 |
|
}; |
548 |
|
Target->cd(); |
549 |
|
li->WriteCloneTrees(); |
550 |
|
printf(" file %s \n",Target->GetName()); |
551 |
|
// Target->Write(); |
552 |
|
TTree *slist = (TTree*)Target->Get("SelectionList"); |
553 |
|
slist->Delete("all"); |
554 |
|
Target->Close(); |
555 |
|
|
556 |
|
// // |
557 |
|
// TDirectory *target = Target; |
558 |
|
// // |
559 |
|
// if ( DebugMode() ) printf("\nTarget path is: %s \n",target->GetPath()); |
560 |
|
// // |
561 |
|
// TString path( (char*)strstr( target->GetPath(), ":" ) ); |
562 |
|
// path.Remove(0,2); |
563 |
|
// // |
564 |
|
// TDirectory *first_source = (TDirectory*)sourcelist->First(); |
565 |
|
// THashList allNames; |
566 |
|
// // |
567 |
|
// while ( first_source ){ |
568 |
|
// // |
569 |
|
// TDirectory *current_sourcedir = first_source->GetDirectory(path); |
570 |
|
// // |
571 |
|
// if ( !current_sourcedir ){ |
572 |
|
// first_source = (TDirectory*)sourcelist->After(first_source); |
573 |
|
// continue; |
574 |
|
// } |
575 |
|
// // |
576 |
|
// // loop over all keys in this directory |
577 |
|
// // |
578 |
|
// TChain *globChain = 0; |
579 |
|
// TIter nextkey( current_sourcedir->GetListOfKeys() ); |
580 |
|
// TKey *key = 0; |
581 |
|
// TKey *oldkey = 0; |
582 |
|
// TH1::AddDirectory(kFALSE); // gain time, do not add the objects in the list in memory |
583 |
|
// // |
584 |
|
// while ( (key = (TKey*)nextkey()) ) { |
585 |
|
// // |
586 |
|
// // printf(" target ls \n"); |
587 |
|
// // Target->ls(); |
588 |
|
// // |
589 |
|
// if ( current_sourcedir == target ) break; |
590 |
|
// // |
591 |
|
// if ( oldkey && !strcmp(oldkey->GetName(),key->GetName()) ) continue; //keep only the highest cycle number for each key |
592 |
|
// // |
593 |
|
// if ( allNames.FindObject(key->GetName()) ) continue; |
594 |
|
// // |
595 |
|
// if ( DebugMode() ) printf(" Key name is -%s- \n",key->GetName()); |
596 |
|
// // |
597 |
|
// // |
598 |
|
// // |
599 |
|
// if ( !strcmp(key->GetName(),"Tracker") && !li->IsTRK2() && !li->IsTRK1() && !li->IsTRKh() ) continue; |
600 |
|
// // |
601 |
|
// if ( !strcmp(key->GetName(),"Calorimeter") && !li->IsCAL2() && !li->IsCAL1() ) continue; |
602 |
|
// // |
603 |
|
// if ( !strcmp(key->GetName(),"ToF") && !li->IsTOF() ) continue; |
604 |
|
// // |
605 |
|
// if ( !strcmp(key->GetName(),"Trigger") && !li->IsTRG() ) continue; |
606 |
|
// // |
607 |
|
// if ( !strcmp(key->GetName(),"Anticounter") && !li->IsAC() ) continue; |
608 |
|
// // |
609 |
|
// if ( !strcmp(key->GetName(),"S4") && !li->IsS4() ) continue; |
610 |
|
// // |
611 |
|
// if ( !strcmp(key->GetName(),"NeutronD") && !li->IsND() ) continue; |
612 |
|
// // |
613 |
|
// if ( !strcmp(key->GetName(),"OrbitalInfo") && !li->IsORB() ) continue; |
614 |
|
// // |
615 |
|
// if ( !strcmp(key->GetName(),"Run") && !li->IsRUN() ) continue; |
616 |
|
// // |
617 |
|
// if ( strcmp(key->GetName(),"Calorimeter") && strcmp(key->GetName(),"Tracker") && strcmp(key->GetName(),"ToF") && strcmp(key->GetName(),"Trigger") && strcmp(key->GetName(),"Anticounter") && strcmp(key->GetName(),"S4") && strcmp(key->GetName(),"NeutronD") && strcmp(key->GetName(),"OrbitalInfo") && strcmp(key->GetName(),"Run") && strcmp(key->GetName(),"ProcessID0") ){ |
618 |
|
// if ( DebugMode() ) printf(" ERROR UNKNOWN KEY %s !\n",key->GetName()); |
619 |
|
// continue; |
620 |
|
// }; |
621 |
|
// // |
622 |
|
// printf(" 1 \n"); |
623 |
|
// allNames.Add(new TObjString(key->GetName())); |
624 |
|
// printf(" 2 \n"); |
625 |
|
// // |
626 |
|
// // read object from first source file |
627 |
|
// // |
628 |
|
// current_sourcedir->cd(); |
629 |
|
// TObject *obj = key->ReadObj(); |
630 |
|
// printf(" 3 \n"); |
631 |
|
// // |
632 |
|
// if ( obj->IsA()->InheritsFrom("TTree") ){ |
633 |
|
// // |
634 |
|
// // loop over all source files create a chain of Trees "globChain" |
635 |
|
// // |
636 |
|
// TString obj_name; |
637 |
|
// printf(" 4 \n"); |
638 |
|
// // |
639 |
|
// if ( path.Length() ) { |
640 |
|
// obj_name = path + "/" + obj->GetName(); |
641 |
|
// } else { |
642 |
|
// obj_name = obj->GetName(); |
643 |
|
// }; |
644 |
|
// // |
645 |
|
// globChain = new TChain(obj_name); |
646 |
|
// // |
647 |
|
// globChain->SetCacheSize(0); |
648 |
|
// // |
649 |
|
// printf(" 5 \n"); |
650 |
|
// globChain->Add(first_source->GetName()); |
651 |
|
// printf(" 6 \n"); |
652 |
|
// // |
653 |
|
// TFile *nextsource = (TFile*)sourcelist->After( first_source ); |
654 |
|
// // |
655 |
|
// while ( nextsource ) { |
656 |
|
// // |
657 |
|
// //do not add to the list a file that does not contain this Tree |
658 |
|
// // |
659 |
|
// printf(" 7 \n"); |
660 |
|
// TFile *curf = TFile::Open(nextsource->GetName()); |
661 |
|
// // |
662 |
|
// if ( curf ) { |
663 |
|
// // |
664 |
|
// Bool_t mustAdd = kFALSE; |
665 |
|
// // |
666 |
|
// if (curf->FindKey(obj_name)) { |
667 |
|
// // |
668 |
|
// mustAdd = kTRUE; |
669 |
|
// // |
670 |
|
// } else { |
671 |
|
// // |
672 |
|
// //we could be more clever here. No need to import the object |
673 |
|
// //we are missing a function in TDirectory |
674 |
|
// // |
675 |
|
// TObject *aobj = curf->Get(obj_name); |
676 |
|
// // |
677 |
|
// if ( aobj ){ |
678 |
|
// mustAdd = kTRUE; |
679 |
|
// delete aobj; |
680 |
|
// }; |
681 |
|
// }; |
682 |
|
// if (mustAdd) { |
683 |
|
// printf(" 8 \n"); |
684 |
|
// globChain->Add(nextsource->GetName()); |
685 |
|
// printf(" 9 \n"); |
686 |
|
// }; |
687 |
|
// }; |
688 |
|
// delete curf; |
689 |
|
// nextsource = (TFile*)sourcelist->After(nextsource); |
690 |
|
// }; |
691 |
|
// // |
692 |
|
// printf(" 10 \n"); |
693 |
|
// delete nextsource; |
694 |
|
// printf(" 11 \n"); |
695 |
|
// // |
696 |
|
// } else { |
697 |
|
// // |
698 |
|
// // object is of no type that we know or can handle |
699 |
|
// // |
700 |
|
// if ( DebugMode() ) cout << "Unknown object type, name: " |
701 |
|
// << obj->GetName() << " title: " << obj->GetTitle() << endl; |
702 |
|
// }; |
703 |
|
// // |
704 |
|
// // now write the merged histogram (which is "in" obj) to the target file |
705 |
|
// // note that this will just store obj in the current directory level, |
706 |
|
// // which is not persistent until the complete directory itself is stored |
707 |
|
// // by "target->Write()" below |
708 |
|
// // |
709 |
|
// printf(" 12 \n"); |
710 |
|
// if ( obj ){ |
711 |
|
// // |
712 |
|
// target->cd(); |
713 |
|
// // |
714 |
|
// if( obj->IsA()->InheritsFrom("TTree") ) { |
715 |
|
// // |
716 |
|
// Long64_t nfiles = 0; |
717 |
|
// if ( fastMethod ){ |
718 |
|
// // globChain->Merge(target->GetFile(),0,"C keep fast"); |
719 |
|
// nfiles=this->Mergy((TChain*)globChain,target->GetFile(),0,"C keep fast"); |
720 |
|
// } else { |
721 |
|
// //globChain->Merge(target->GetFile(),0,"C keep"); |
722 |
|
// printf(" 13 %llu \n",globChain->GetEntries()); |
723 |
|
// nfiles=this->Mergy((TChain*)globChain,target->GetFile(),0,"C keep"); |
724 |
|
// printf(" 14 \n"); |
725 |
|
// }; |
726 |
|
// // |
727 |
|
// merged = true; |
728 |
|
// // |
729 |
|
// if ( DebugMode() ){ |
730 |
|
// printf(" Merged %i files\n",(int)nfiles); |
731 |
|
// globChain->ls(); |
732 |
|
// }; |
733 |
|
// // |
734 |
|
// delete globChain; |
735 |
|
// // return; |
736 |
|
// // |
737 |
|
// } else { |
738 |
|
// // |
739 |
|
// // obj->Write( key->GetName() ); // <================================================================================== |
740 |
|
// // |
741 |
|
// }; |
742 |
|
// }; |
743 |
|
// delete obj; |
744 |
|
// oldkey = key; |
745 |
|
// }; |
746 |
|
// // |
747 |
|
// first_source = (TDirectory*)sourcelist->After(first_source); |
748 |
|
// // |
749 |
|
// }; |
750 |
|
// // save modifications to target file |
751 |
|
// // |
752 |
|
// target->SaveSelf(kTRUE); |
753 |
|
// // |
754 |
}; |
}; |
755 |
|
|
756 |
|
|
759 |
// later to reset the compression level of the branches. |
// later to reset the compression level of the branches. |
760 |
if (!file) { |
if (!file) { |
761 |
// FIXME: We need an error message here. |
// FIXME: We need an error message here. |
762 |
|
printf(" 19 \n"); |
763 |
return 0; |
return 0; |
764 |
} |
} |
765 |
|
printf(" 20 \n"); |
766 |
|
|
767 |
// Options |
// Options |
768 |
Bool_t fastClone = kFALSE; |
Bool_t fastClone = kFALSE; |
770 |
opt.ToLower(); |
opt.ToLower(); |
771 |
if (opt.Contains("fast")) { |
if (opt.Contains("fast")) { |
772 |
fastClone = kTRUE; |
fastClone = kTRUE; |
773 |
|
printf(" 21 \n"); |
774 |
} |
} |
|
|
|
775 |
// The chain tree must have a list of branches |
// The chain tree must have a list of branches |
776 |
// because we may try to change their basket |
// because we may try to change their basket |
777 |
// size later. |
// size later. |
778 |
TObjArray* lbranches = mychain->GetListOfBranches(); |
TObjArray* lbranches = mychain->GetListOfBranches(); |
779 |
if (!lbranches) { |
if (!lbranches) { |
780 |
// FIXME: We need an error message here. |
// FIXME: We need an error message here. |
781 |
|
printf(" 22 \n"); |
782 |
return 0; |
return 0; |
783 |
} |
} |
784 |
|
|
785 |
|
// file->cd(); |
786 |
// The chain must have a current tree because |
// The chain must have a current tree because |
787 |
// that is the one we will clone. |
// that is the one we will clone. |
788 |
// if (!fTree) { |
// if (!fTree) { |
793 |
|
|
794 |
// Copy the chain's current tree without |
// Copy the chain's current tree without |
795 |
// copying any entries, we will do that later. |
// copying any entries, we will do that later. |
796 |
|
printf(" 23 \n"); |
797 |
TTree* newTree = mychain->CloneTree(0); |
TTree* newTree = mychain->CloneTree(0); |
798 |
if (!newTree) { |
if (!newTree) { |
799 |
// FIXME: We need an error message here. |
// FIXME: We need an error message here. |
800 |
|
printf(" 24 \n"); |
801 |
return 0; |
return 0; |
802 |
} |
} |
803 |
|
printf(" 25 \n"); |
804 |
|
|
805 |
|
|
806 |
// Strip out the (potential) directory name. |
// Strip out the (potential) directory name. |
807 |
// FIXME: The merged chain may or may not have the |
// FIXME: The merged chain may or may not have the |
808 |
// same name as the original chain. This is |
// same name as the original chain. This is |
809 |
// bad because the chain name determines the |
// bad because the chain name determines the |
810 |
// names of the trees in the chain by default. |
// names of the trees in the chain by default. |
811 |
|
printf(" 26 \n"); |
812 |
newTree->SetName(gSystem->BaseName(mychain->GetName())); |
newTree->SetName(gSystem->BaseName(mychain->GetName())); |
813 |
|
printf(" 27 \n"); |
814 |
|
|
815 |
// FIXME: Why do we do this? |
// FIXME: Why do we do this? |
816 |
// newTree->SetAutoSave(-1); |
// newTree->SetAutoSave(-1); |
817 |
newTree->SetAutoSave(900000000000000LL); |
newTree->SetAutoSave(900000000000000LL); |
818 |
|
|
819 |
|
printf(" 28 \n"); |
820 |
// Circularity is incompatible with merging, it may |
// Circularity is incompatible with merging, it may |
821 |
// force us to throw away entries, which is not what |
// force us to throw away entries, which is not what |
822 |
// we are supposed to do. |
// we are supposed to do. |
827 |
TBranch* branch = 0; |
TBranch* branch = 0; |
828 |
TIter nextb(newTree->GetListOfBranches()); |
TIter nextb(newTree->GetListOfBranches()); |
829 |
while ((branch = (TBranch*) nextb())) { |
while ((branch = (TBranch*) nextb())) { |
830 |
|
printf(" 29 \n"); |
831 |
branch->SetCompressionLevel(file->GetCompressionLevel()); |
branch->SetCompressionLevel(file->GetCompressionLevel()); |
832 |
} |
} |
833 |
} |
} |
834 |
|
|
835 |
|
printf(" 30 \n"); |
836 |
// Reset the basket size of the branches. |
// Reset the basket size of the branches. |
837 |
if (basketsize > 1000) { |
if (basketsize > 1000) { |
838 |
TBranch* branch = 0; |
TBranch* branch = 0; |
839 |
TIter nextb(newTree->GetListOfBranches()); |
TIter nextb(newTree->GetListOfBranches()); |
840 |
while ((branch = (TBranch*) nextb())) { |
while ((branch = (TBranch*) nextb())) { |
841 |
|
printf(" 31 \n"); |
842 |
branch->SetBasketSize(basketsize); |
branch->SetBasketSize(basketsize); |
843 |
} |
} |
844 |
} |
} |
845 |
|
|
846 |
|
printf(" 32 \n"); |
847 |
Long64_t nentries = mychain->GetEntriesFast(); |
Long64_t nentries = mychain->GetEntriesFast(); |
848 |
|
//Long64_t nentries = mychain->GetEntries(); |
849 |
|
|
850 |
// Copy the entries. |
// Copy the entries. |
851 |
if (fastClone) { |
if (fastClone) { |
867 |
} |
} |
868 |
} |
} |
869 |
} else { |
} else { |
870 |
for (Long64_t i = 0; i < nentries; i++) { |
printf(" 33 %llu \n",nentries); |
871 |
|
mychain->Print(); |
872 |
|
for (Long64_t i = 0; i < nentries; i++) { |
873 |
|
printf(" i %llu \n",i); |
874 |
|
// for (Long64_t i = 0; i < 1; i++) { |
875 |
if (mychain->GetEntry(i) <= 0) { |
if (mychain->GetEntry(i) <= 0) { |
876 |
break; |
break; |
877 |
} |
} |
878 |
newTree->Fill(); |
newTree->Fill(); |
879 |
} |
} |
880 |
|
printf(" 34 \n"); |
881 |
} |
} |
882 |
|
|
883 |
// Write the new tree header. |
// Write the new tree header. |
884 |
|
printf(" 35 \n"); |
885 |
newTree->Write(); |
newTree->Write(); |
886 |
|
|
887 |
|
printf(" 36 \n"); |
888 |
// Get our return value. |
// Get our return value. |
889 |
Int_t nfiles = newTree->GetFileNumber() + 1; |
Int_t nfiles = newTree->GetFileNumber() + 1; |
890 |
|
|