/[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.3 by mocchiut, Wed Dec 6 11:01:52 2006 UTC revision 1.10 by mocchiut, Fri Sep 7 13:26:11 2007 UTC
# Line 5  Line 5 
5   * The file contains implementation of the methods to query the DB.   * The file contains implementation of the methods to query the DB.
6   */   */
7  //  //
 #include <sstream>  
 #include <iostream>  
 //  
 #include <TFile.h>  
 #include <TTree.h>  
 #include <TTimeStamp.h>  
8  #include <RunGlue.h>  #include <RunGlue.h>
9  //  //
10  ClassImp(RunGlue);  ClassImp(RunGlue);
# Line 21  RunGlue::RunGlue() { Line 15  RunGlue::RunGlue() {
15    this->Clear();    this->Clear();
16  }  }
17    
18  RunGlue::RunGlue(TSQLServer *da, UInt_t ru, TString di, TString wrkdi) {  RunGlue::RunGlue(TSQLServer *da, UInt_t ru, TString di, TString wrkdi, Bool_t fcas) {
19    fDBG = false;    fDBG = false;
20      castor = fcas;
21    li = new PamLevel2();    li = new PamLevel2();
22    this->Clear();    this->Clear();
23    dbc = da;    dbc = da;
# Line 85  TList *RunGlue::GetRunList(){ Line 80  TList *RunGlue::GetRunList(){
80    lList = new TList();    lList = new TList();
81    lList->Clear();    lList->Clear();
82    TString thisrun;    TString thisrun;
83      //  TFile *su;
84    TFile *su;    TFile *su;
85    //    //
86    TSQLResult *pResult;    TSQLResult *pResult;
# Line 115  TList *RunGlue::GetRunList(){ Line 111  TList *RunGlue::GetRunList(){
111      UInt_t lowerlimit = llim->GetSec();      UInt_t lowerlimit = llim->GetSec();
112      UInt_t upperlimit = lowerlimit + 86401;      UInt_t upperlimit = lowerlimit + 86401;
113      //      //
     stringstream myquery;  
     myquery.str("");  
     myquery << "SELECT ID FROM GL_RUN WHERE RUNHEADER_TIME>=" << (UInt_t)lowerlimit  
             << " AND RUNHEADER_TIME<" << (UInt_t)upperlimit << " ORDER BY RUNHEADER_TIME ASC;";  
     //  
     pResult = dbc->Query(myquery.str().c_str());  
     for( UInt_t r=0; r < 1000; r++){  
       Row = pResult->Next();        
       if( Row == NULL ) break;  
       if ( DebugMode() ) printf(" %u RUN %s \n",r,Row->GetField(0));  
       //  
       thisrun=dir+(TString)Row->GetField(0)+".Level2.root";        
       //  
       if ( DebugMode() ) printf(" Filename is %s \n",thisrun.Data());  
       //  
       su = TFile::Open(thisrun);  
       if ( li->CheckLevel2File(thisrun) ){  
         lList->Add(su);  
       } else {  
         if ( DebugMode() ) printf(" RUN %s DISCARDED \n",Row->GetField(0));  
       };  
       //  
     };  
     //  
114      if ( DebugMode() ) printf(" YY %u MM %u DD %u ll %u ul %u \n",YY,MM,DD,lowerlimit,upperlimit);      if ( DebugMode() ) printf(" YY %u MM %u DD %u ll %u ul %u \n",YY,MM,DD,lowerlimit,upperlimit);
115      //      //
116      YY -= 2000;      YY -= 2000;
# Line 172  TList *RunGlue::GetRunList(){ Line 144  TList *RunGlue::GetRunList(){
144      //      //
145      printf(" Output filename is %s \n",fFilename.Data());      printf(" Output filename is %s \n",fFilename.Data());
146      //      //
147        if ( !this->OpenFile() ){
148             fEnd = true;
149             return(0);
150        };
151        //
152        stringstream myquery;
153        myquery.str("");
154        myquery << "SELECT ID FROM GL_RUN WHERE RUNHEADER_TIME>=" << (UInt_t)lowerlimit
155                << " AND RUNHEADER_TIME<" << (UInt_t)upperlimit << " ORDER BY RUNHEADER_TIME ASC;";
156        //
157        pResult = dbc->Query(myquery.str().c_str());
158        for( UInt_t r=0; r < 1000; r++){
159          Row = pResult->Next();      
160          if( Row == NULL ) break;
161          if ( DebugMode() ) printf(" %u RUN %s \n",r,Row->GetField(0));
162          //
163          thisrun=dir+(TString)Row->GetField(0)+".Level2.root";      
164          //
165          if ( DebugMode() ) printf(" Filename is %s \n",thisrun.Data());
166          //
167          //su = TFile::Open(thisrun);
168          su = TFile::Open(thisrun);
169          if ( li->CheckLevel2File(thisrun) ){
170            lList->Add(su);
171          } else {
172            if ( DebugMode() ) printf(" RUN %s DISCARDED \n",Row->GetField(0));
173          };
174          //
175        };
176        //
177        //
178      delete glrun;      delete glrun;
179      delete dbtime;      delete dbtime;
180      //      //
# Line 205  TList *RunGlue::GetRunList(){ Line 208  TList *RunGlue::GetRunList(){
208            if ( DebugMode() ) printf(" fullpath = %s     name %s \n",fullpath.Data(),name.Data());            if ( DebugMode() ) printf(" fullpath = %s     name %s \n",fullpath.Data(),name.Data());
209            //            //
210            //            //
211              //su = TFile::Open(fullpath);
212            su = TFile::Open(fullpath);            su = TFile::Open(fullpath);
213            if ( li->CheckLevel2File((TString)fullpath) ){            if ( li->CheckLevel2File((TString)fullpath) ){
214              fList->Add(su);              fList->Add(su);
# Line 276  TList *RunGlue::GetRunList(){ Line 280  TList *RunGlue::GetRunList(){
280      UInt_t lowerlimit = llim->GetSec();      UInt_t lowerlimit = llim->GetSec();
281      UInt_t upperlimit = lowerlimit + 86401;      UInt_t upperlimit = lowerlimit + 86401;
282      //      //
     stringstream myquery;  
     myquery.str("");  
     myquery << "SELECT ID FROM GL_RUN WHERE RUNHEADER_TIME>=" << (UInt_t)lowerlimit  
             << " AND RUNHEADER_TIME<" << (UInt_t)upperlimit << " ORDER BY RUNHEADER_TIME ASC;";  
     //  
     pResult = dbc->Query(myquery.str().c_str());  
     for( UInt_t r=0; r < 1000; r++){  
       Row = pResult->Next();        
       if( Row == NULL ) break;  
       if ( DebugMode() ) printf(" %u RUN %s \n",r,Row->GetField(0));  
       //  
       thisrun=dir+(TString)Row->GetField(0)+".Level2.root";        
       //  
       if ( DebugMode() ) printf(" Filename is %s \n",thisrun.Data());  
       //  
       su = TFile::Open(thisrun);  
       if ( su ){  
         TFile *su0 = TFile::Open(thisrun);  
         fDoneList->Add(su0);  
         fNlistdone++;  
       };  
       if ( li->CheckLevel2File(thisrun) ){  
         lList->Add(su);  
         if ( DebugMode() ) printf(" RUN %s ADDED \n",Row->GetField(0));  
       } else {  
         if ( DebugMode() ) printf(" RUN %s DISCARDED \n",Row->GetField(0));  
       };  
       //  
     };  
     //  
283      if ( DebugMode() ) printf(" YY %u MM %u DD %u ll %u ul %u \n",YY,MM,DD,lowerlimit,upperlimit);      if ( DebugMode() ) printf(" YY %u MM %u DD %u ll %u ul %u \n",YY,MM,DD,lowerlimit,upperlimit);
284      //      //
285      YY -= 2000;      YY -= 2000;
# Line 339  TList *RunGlue::GetRunList(){ Line 313  TList *RunGlue::GetRunList(){
313      //      //
314      printf(" Output filename is %s \n",fFilename.Data());      printf(" Output filename is %s \n",fFilename.Data());
315      //      //
316        if ( !this->OpenFile() ) return(0);
317        //
318        stringstream myquery;
319        myquery.str("");
320        myquery << "SELECT ID FROM GL_RUN WHERE RUNHEADER_TIME>=" << (UInt_t)lowerlimit
321                << " AND RUNHEADER_TIME<" << (UInt_t)upperlimit << " ORDER BY RUNHEADER_TIME ASC;";
322        //
323        pResult = dbc->Query(myquery.str().c_str());
324        for( UInt_t r=0; r < 1000; r++){
325          Row = pResult->Next();      
326          if( Row == NULL ) break;
327          if ( DebugMode() ) printf(" %u RUN %s \n",r,Row->GetField(0));
328          //
329          thisrun=dir+(TString)Row->GetField(0)+".Level2.root";      
330          //
331          if ( DebugMode() ) printf(" Filename is %s \n",thisrun.Data());
332          //
333          su = TFile::Open(thisrun);
334          if ( su ){
335            //      TFile *su0 = TFile::Open(thisrun);
336            TFile *su0 = TFile::Open(thisrun);
337            fDoneList->Add(su0);
338            fNlistdone++;
339          };
340          if ( li->CheckLevel2File(thisrun) ){
341            lList->Add(su);
342            if ( DebugMode() ) printf(" RUN %s ADDED \n",Row->GetField(0));
343          } else {
344            if ( DebugMode() ) printf(" RUN %s DISCARDED \n",Row->GetField(0));
345          };
346          //
347        };
348        //
349      if ( DebugMode() ){      if ( DebugMode() ){
350        UInt_t ll = 0;        UInt_t ll = 0;
351        while ( (TFile*)lList->At(ll) ){        while ( (TFile*)lList->At(ll) ){
# Line 371  TList *RunGlue::GetRunList(){ Line 378  TList *RunGlue::GetRunList(){
378    
379  Bool_t RunGlue::OpenFile(){  Bool_t RunGlue::OpenFile(){
380    //    //
381    printf(" Check if output file already exists \n");    ifstream myfile;
382    Target = TFile::Open((this->GetFilename()).Data(), "READ" );    TString thename;
383    //    //
384    if ( Target ){    Bool_t exi = false;
385      Target->Close();    fOpen = false;
386      printf("Error opening target file, %s  already exist!\n",(this->GetFilename()).Data());    thename = Form("rfio://%s",(this->GetFilename()).Data());
387      Target = 0;
388      if ( castor ){
389        Target = new TRFIOFile(thename.Data(),"READ","",1);
390        if ( !Target->IsZombie()) exi = true;
391      } else {
392        //    thename = Form("rfio://%s",(this->GetFilename()).Data());
393        printf(" Check if output file already exists \n");
394        myfile.open((this->GetFilename()).Data());
395        if ( myfile ) exi = true;
396      };
397      if ( exi ){
398        //  Target = TFile::Open((this->GetFilename()).Data(), "READ" );
399        //
400        //  if ( Target ){
401        //    Target->Close();
402        if ( myfile ) myfile.close();
403        //
404        if ( Target ) Target->Close();
405        //
406        printf("Error opening target file, %s  already exist!\n",thename.Data());
407      return(false);      return(false);
408        //
409    } else {    } else {
410      //      //
411      printf(" Output file does not exist, creating it\n");      printf(" Output file does not exist, creating it\n");
412      //      //
413      Long64_t maxsize = 10000000000LL;        Long64_t maxsize = 99900000000LL;  
414        //
415        Target = new TRFIOFile(thename.Data(), "RECREATE", "", 2 );
416        //      Target = TFile::Open((this->GetFilename()).Data(), "RECREATE" );
417      //      //
     Target = TFile::Open((this->GetFilename()).Data(), "RECREATE" );  
418      //fastMethod = kTRUE;      //fastMethod = kTRUE;
419      fastMethod = kFALSE;      fastMethod = kFALSE;
420      //          //    
421      //          //    
422      if ( !Target || Target->IsZombie()) {      if ( !Target || Target->IsZombie()) {
423        printf("Error opening target file (does %s exist?)\n",(this->GetFilename()).Data());        printf("Error opening target file (does %s exist?)\n",thename.Data());
424        exit(1);        exit(1);
425      }      }
426      //      //
427      TTree::SetMaxTreeSize(maxsize);      TTree::SetMaxTreeSize(maxsize);
428        Target->SetCompressionLevel(2);
429      //      //
430        fOpen = true;
431      return(true);      return(true);
432      //      //
433    };    };
# Line 455  void RunGlue::UpdateDB(TList *dlist){ Line 487  void RunGlue::UpdateDB(TList *dlist){
487    };    };
488    //    //
489    myquery.str("");    myquery.str("");
490    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() << "');";
491      myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'$PAM_L2','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');";
492    if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str());    if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str());
493    //    //
494    pResult = dbc->Query(myquery.str().c_str());    pResult = dbc->Query(myquery.str().c_str());
# Line 517  void RunGlue::MergeRootfile(TList *sourc Line 550  void RunGlue::MergeRootfile(TList *sourc
550    //    //
551    if ( DebugMode() ) printf("\nTarget path is: %s \n",target->GetPath());    if ( DebugMode() ) printf("\nTarget path is: %s \n",target->GetPath());
552    //    //
553    TString path( (char*)strstr( target->GetPath(), ":" ) );    TString path;
554      //if ( castor ){
555        path = TString(":/");
556        //  } else {
557        //    path = TString( (char*)strstr( target->GetPath(), ":" ) );
558        //  };
559    path.Remove(0,2);    path.Remove(0,2);
560      if ( DebugMode() ) printf("path is %s \n",path.Data());
561    //    //
562    TDirectory *first_source = (TDirectory*)sourcelist->First();    TDirectory *first_source = (TDirectory*)sourcelist->First();
563    THashList allNames;    THashList allNames;
# Line 534  void RunGlue::MergeRootfile(TList *sourc Line 573  void RunGlue::MergeRootfile(TList *sourc
573      //      //
574      // loop over all keys in this directory      // loop over all keys in this directory
575      //      //
576      TChain *globChain = 0;      TChain *globChain = 0;    
577      TIter nextkey( current_sourcedir->GetListOfKeys() );      TIter nextkey( current_sourcedir->GetListOfKeys() );
578      TKey *key, *oldkey=0;      TKey *key = 0;
579        TKey *oldkey = 0;
580      TH1::AddDirectory(kFALSE); // gain time, do not add the objects in the list in memory      TH1::AddDirectory(kFALSE); // gain time, do not add the objects in the list in memory
581      //      //
582      while ( (key = (TKey*)nextkey()) ) {      while ( (key = (TKey*)nextkey()) ) {
583        //        //
584          //      printf(" target ls \n");
585          //      Target->ls();
586          //
587        if ( current_sourcedir == target ) break;        if ( current_sourcedir == target ) break;
588        //        //
589        if (oldkey && !strcmp(oldkey->GetName(),key->GetName())) continue; //keep only the highest cycle number for each key        if ( oldkey && !strcmp(oldkey->GetName(),key->GetName()) ) continue; //keep only the highest cycle number for each key
590        //        //
591        if (allNames.FindObject(key->GetName())) continue;        if ( allNames.FindObject(key->GetName()) ) continue;
592        //        //
593        if ( DebugMode() ) printf(" Key name is -%s- \n",key->GetName());        if ( DebugMode() ) printf(" Key name is -%s- \n",key->GetName());
594        //        //
595        //        //
596        //        //
597        if ( !strcmp(key->GetName(),"Tracker") && !li->TRK2 && !li->TRK1 && !li->TRKh ) continue;        if ( !strcmp(key->GetName(),"Tracker") && !li->IsTRK2() && !li->IsTRK1() && !li->IsTRKh() ) continue;
598        //        //
599        if ( !strcmp(key->GetName(),"Calorimeter") && !li->CAL2 && !li->CAL1 ) continue;        if ( !strcmp(key->GetName(),"Calorimeter") && !li->IsCAL2() && !li->IsCAL1() ) continue;
600        //        //
601        if ( !strcmp(key->GetName(),"ToF") && !li->TOF ) continue;        if ( !strcmp(key->GetName(),"ToF") && !li->IsTOF() ) continue;
602        //        //
603        if ( !strcmp(key->GetName(),"Trigger") && !li->TRG ) continue;        if ( !strcmp(key->GetName(),"Trigger") && !li->IsTRG() ) continue;
604        //        //
605        if ( !strcmp(key->GetName(),"Anticounter") && !li->AC ) continue;        if ( !strcmp(key->GetName(),"Anticounter") && !li->IsAC() ) continue;
606        //        //
607        if ( !strcmp(key->GetName(),"S4") && !li->S4 ) continue;        if ( !strcmp(key->GetName(),"S4") && !li->IsS4() ) continue;
608        //        //
609        if ( !strcmp(key->GetName(),"NeutronD") && !li->ND ) continue;        if ( !strcmp(key->GetName(),"NeutronD") && !li->IsND() ) continue;
610        //        //
611        if ( !strcmp(key->GetName(),"OrbitalInfo") && !li->ORB ) continue;        if ( !strcmp(key->GetName(),"OrbitalInfo") && !li->IsORB() ) continue;
612        //        //
613        if ( !strcmp(key->GetName(),"Run") && !RUN ) continue;        if ( !strcmp(key->GetName(),"Run") && !li->IsRUN() ) continue;
614        //        //
615        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 ( 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") ){
616          if ( DebugMode() ) printf(" ERROR UNKNOWN KEY %s !\n",key->GetName());          if ( DebugMode() ) printf(" ERROR UNKNOWN KEY %s !\n",key->GetName());
# Line 595  void RunGlue::MergeRootfile(TList *sourc Line 638  void RunGlue::MergeRootfile(TList *sourc
638          //          //
639          globChain = new TChain(obj_name);          globChain = new TChain(obj_name);
640          //          //
641            globChain->SetCacheSize(0);
642            //
643          globChain->Add(first_source->GetName());          globChain->Add(first_source->GetName());
644          //          //
645            //      TFile *nextsource = (TFile*)sourcelist->After( first_source );
646          TFile *nextsource = (TFile*)sourcelist->After( first_source );          TFile *nextsource = (TFile*)sourcelist->After( first_source );
647          //          //
648          while ( nextsource ) {                      while ( nextsource ) {            
# Line 604  void RunGlue::MergeRootfile(TList *sourc Line 650  void RunGlue::MergeRootfile(TList *sourc
650            //do not add to the list a file that does not contain this Tree            //do not add to the list a file that does not contain this Tree
651            //            //
652            TFile *curf = TFile::Open(nextsource->GetName());            TFile *curf = TFile::Open(nextsource->GetName());
653              //      TFile *curf = TFile::Open(nextsource->GetName());
654            //            //
655            if ( curf ) {            if ( curf ) {
656              //              //
# Line 633  void RunGlue::MergeRootfile(TList *sourc Line 680  void RunGlue::MergeRootfile(TList *sourc
680            nextsource = (TFile*)sourcelist->After(nextsource);            nextsource = (TFile*)sourcelist->After(nextsource);
681          };          };
682          //          //
683            delete nextsource;
684            //
685        } else {        } else {
686          //          //
687          // object is of no type that we know or can handle          // object is of no type that we know or can handle
# Line 652  void RunGlue::MergeRootfile(TList *sourc Line 701  void RunGlue::MergeRootfile(TList *sourc
701          //          //
702          if( obj->IsA()->InheritsFrom("TTree") ) {          if( obj->IsA()->InheritsFrom("TTree") ) {
703            //            //
704            //            Long64_t nfiles = 0;
705            if ( fastMethod ){            if ( fastMethod ){
706              globChain->Merge(target->GetFile(),0,"keep fast");              //      globChain->Merge(target->GetFile(),0,"C keep fast");
707                nfiles=this->Mergy((TChain*)globChain,target->GetFile(),0,"C keep fast");
708            } else {            } else {
709              globChain->Merge(target->GetFile(),0,"keep");              //globChain->Merge(target->GetFile(),0,"C keep");
710                nfiles=this->Mergy((TChain*)globChain,target->GetFile(),0,"C keep");
711            };            };
712            //            //
713            merged = true;            merged = true;
714            //            //
715            if ( DebugMode() ) globChain->ls();            if ( DebugMode() ){
716                printf(" Merged %i files\n",(int)nfiles);
717                globChain->ls();
718              };
719            //            //
720            delete globChain;            delete globChain;
721              //      return;
722            //            //
723          } else {          } else {
724            //            //
# Line 671  void RunGlue::MergeRootfile(TList *sourc Line 726  void RunGlue::MergeRootfile(TList *sourc
726            //            //
727          };          };
728        };        };
729          delete obj;
730        oldkey = key;        oldkey = key;
731      };      };
732      //      //
# Line 678  void RunGlue::MergeRootfile(TList *sourc Line 734  void RunGlue::MergeRootfile(TList *sourc
734      //      //
735    };    };
736    // save modifications to target file    // save modifications to target file
737      //
738    target->SaveSelf(kTRUE);    target->SaveSelf(kTRUE);
739    //    //
740    };
741    
742    
743    //Long64_t RunGlue::Mergy(TChain *mychain, TFile* file, Int_t basketsize, Option_t* option){
744    Long64_t RunGlue::Mergy(TChain *mychain, TFile* file, Int_t basketsize, Option_t* option){
745       // We must have been passed a file, we will use it
746       // later to reset the compression level of the branches.
747       if (!file) {
748          // FIXME: We need an error message here.
749         return 0;
750       }
751    
752       // Options
753       Bool_t fastClone = kFALSE;
754       TString opt = option;
755       opt.ToLower();
756       if (opt.Contains("fast")) {
757          fastClone = kTRUE;
758       }
759    
760       // The chain tree must have a list of branches
761       // because we may try to change their basket
762       // size later.
763       TObjArray* lbranches = mychain->GetListOfBranches();
764       if (!lbranches) {
765          // FIXME: We need an error message here.
766          return 0;
767       }
768    
769       // The chain must have a current tree because
770       // that is the one we will clone.
771       //   if (!fTree) {
772          // -- LoadTree() has not yet been called, no current tree.
773          // FIXME: We need an error message here.
774       //      return 0;
775       //   }
776    
777       // Copy the chain's current tree without
778       // copying any entries, we will do that later.
779       TTree* newTree = mychain->CloneTree(0);
780       if (!newTree) {
781          // FIXME: We need an error message here.
782          return 0;
783       }
784    
785       // Strip out the (potential) directory name.
786       // FIXME: The merged chain may or may not have the
787       //        same name as the original chain.  This is
788       //        bad because the chain name determines the
789       //        names of the trees in the chain by default.
790       newTree->SetName(gSystem->BaseName(mychain->GetName()));
791    
792       // FIXME: Why do we do this?
793       //   newTree->SetAutoSave(-1);
794       newTree->SetAutoSave(900000000000000LL);
795    
796       // Circularity is incompatible with merging, it may
797       // force us to throw away entries, which is not what
798       // we are supposed to do.
799       newTree->SetCircular(0);
800    
801       // Reset the compression level of the branches.
802       if (opt.Contains("c")) {
803          TBranch* branch = 0;
804          TIter nextb(newTree->GetListOfBranches());
805          while ((branch = (TBranch*) nextb())) {
806             branch->SetCompressionLevel(file->GetCompressionLevel());
807          }
808       }
809    
810       // Reset the basket size of the branches.
811       if (basketsize > 1000) {
812          TBranch* branch = 0;
813          TIter nextb(newTree->GetListOfBranches());
814          while ((branch = (TBranch*) nextb())) {
815             branch->SetBasketSize(basketsize);
816          }
817       }
818    
819       Long64_t nentries = mychain->GetEntriesFast();
820    
821       // Copy the entries.
822       if (fastClone) {
823          // For each tree in the chain.
824          for (Long64_t i = 0; i < nentries; i += mychain->GetTree()->GetEntries()) {
825             if (mychain->LoadTree(i) < 0) {
826                break;
827             }
828             TTreeCloner cloner(mychain->GetTree(), newTree, option);
829             if (cloner.IsValid()) {
830                newTree->SetEntries(newTree->GetEntries() + mychain->GetTree()->GetEntries());
831                cloner.Exec();
832             } else {
833                if (mychain->GetFile()) {
834                  printf("Merge Skipped file %s\n", mychain->GetFile()->GetName());
835                   //            } else {
836                   //               Warning("Merge", "Skipped file number %d\n", fTreeNumber);
837                }
838             }
839          }
840       } else {
841          for (Long64_t i = 0; i < nentries; i++) {
842             if (mychain->GetEntry(i) <= 0) {
843                break;
844             }
845             newTree->Fill();
846          }
847       }
848    
849       // Write the new tree header.
850       newTree->Write();
851    
852       // Get our return value.
853       Int_t nfiles = newTree->GetFileNumber() + 1;
854    
855       // Close and delete the current file of the new tree.
856       if (!opt.Contains("keep")) {
857          // FIXME: What happens to fDirectory in newTree here?
858          delete newTree->GetCurrentFile();
859       }
860       return nfiles;
861  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.23