/[PAMELA software]/PadmeAmidala/src/RunGlue.cpp
ViewVC logotype

Diff of /PadmeAmidala/src/RunGlue.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.23