/[PAMELA software]/PamelaLevel2/src/PamLevel2.cpp
ViewVC logotype

Diff of /PamelaLevel2/src/PamLevel2.cpp

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

revision 1.16 by pam-fi, Tue Jan 16 13:19:58 2007 UTC revision 1.19 by pam-fi, Thu Jan 18 11:56:12 2007 UTC
# Line 114  PamLevel2::PamLevel2(){ Line 114  PamLevel2::PamLevel2(){
114    
115      run_obj   = 0;//new GL_RUN();      run_obj   = 0;//new GL_RUN();
116      soft_obj   = 0;// Emiliano      soft_obj   = 0;// Emiliano
117            irun = -1;
118        runfirstentry = 0ULL;
119        runlastentry = 0ULL;
120    
121      for(Int_t i=0; i<8; i++ )tree_clone[i]=NULL;      for(Int_t i=0; i<8; i++ )tree_clone[i]=NULL;
122    
# Line 177  void PamLevel2::Clear(){ Line 179  void PamLevel2::Clear(){
179  //    cout << "void PamLevel2::Clear()"<<endl;  //    cout << "void PamLevel2::Clear()"<<endl;
180    
181  //  //
182    // This method is called once for every entry but RunInfo and SoftInfo do not change until the next run so we cannot clear them here unless we don't
183    // want to load them for each event even if they are the same...
184    //
185  //    if(run_obj)delete run_obj;  //    if(run_obj)delete run_obj;
186      if(run_obj) run_obj->Clear();  // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead  //    if(run_obj) run_obj->Clear();  // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead
187      if(soft_obj) soft_obj->Clear();  //    if(soft_obj) soft_obj->Clear();
188    
189      if(trk1_obj) trk1_obj->Clear();          if(trk1_obj) trk1_obj->Clear();    
190      if(trk2_obj) trk2_obj->Clear();      if(trk2_obj) trk2_obj->Clear();
# Line 916  TList*  PamLevel2::GetListOfLevel2Files( Line 921  TList*  PamLevel2::GetListOfLevel2Files(
921      contents->SetOwner();      contents->SetOwner();
922            
923  //    char *fullpath;  //    char *fullpath;
924      const char *fullpath;  //    const char *fullpath;
925            
926      // if no input file list is given:        // if no input file list is given:  
927      if ( flisttxt != "" ){      if ( flisttxt != "" ){
928                    
929  //      if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){          //      if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){        
930          if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){  //      if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){
931              cout <<"File "<<flisttxt<<" not found"<<endl;  //          cout <<"File "<<flisttxt<<" not found"<<endl;
932              return 0;  //          return 0;
933          }        //      }      
934  //              flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));  //      flisttxt = fullpath;
935          flisttxt = fullpath;  
936            flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));
937    
938          if( !gSystem->ChangeDirectory(ddir) ){          if( !gSystem->ChangeDirectory(ddir) ){
939              cout << "Cannot change directory : "<<ddir<<endl;              cout << "Cannot change directory : "<<ddir<<endl;
# Line 937  TList*  PamLevel2::GetListOfLevel2Files( Line 943  TList*  PamLevel2::GetListOfLevel2Files(
943          cout <<"Input file list : " << flisttxt <<endl;          cout <<"Input file list : " << flisttxt <<endl;
944          ifstream in;          ifstream in;
945          in.open(flisttxt, ios::in); //open input file list          in.open(flisttxt, ios::in); //open input file list
946            if(!in.good()){
947                cout <<" ERROR opening the file "<<endl;
948                gSystem->ChangeDirectory(wdir); // back to the working directory
949                return 0;
950            }      
951          int line=0;          int line=0;
952          while (1) {          while (1) {
953              TString file;              TString file;
# Line 951  TList*  PamLevel2::GetListOfLevel2Files( Line 962  TList*  PamLevel2::GetListOfLevel2Files(
962              if(file.Contains("#"))file = file(0,file.First("#"));              if(file.Contains("#"))file = file(0,file.First("#"));
963  //          cout <<"(2) " << file << endl;  //          cout <<"(2) " << file << endl;
964  //          if( gSystem->IsFileInIncludePath(file,&fullpath) ){  //          if( gSystem->IsFileInIncludePath(file,&fullpath) ){
965              if( (fullpath = gSystem->FindFile(ddir,file)) ){  //          if( (fullpath = gSystem->FindFile(ddir,file)) ){
966                if( file.EndsWith(".root") ){
967                    char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(file));
968                  contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list                  contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list
969                    delete fullpath;
970              }else{              }
971    //          }else{
972  //              if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl;  //              if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl;
973              };  //          };
974          };          };
975          in.close();          in.close();
976                    
# Line 979  TList*  PamLevel2::GetListOfLevel2Files( Line 992  TList*  PamLevel2::GetListOfLevel2Files(
992          while ( (questo = (TSystemFile*) next()) ) {          while ( (questo = (TSystemFile*) next()) ) {
993              TString name =  questo-> GetName();              TString name =  questo-> GetName();
994              if( name.EndsWith(".root") ){              if( name.EndsWith(".root") ){
995                  const char *fullpath = gSystem->FindFile(ddir,name);  //              const char *fullpath = gSystem->FindFile(ddir,name);
996  //              char *fullpath;  //              char *fullpath;
997  //              gSystem->IsFileInIncludePath(name,&fullpath);  //              gSystem->IsFileInIncludePath(name,&fullpath);
998                    char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(name));
999                  contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));                  contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));
1000                    delete fullpath;
1001              };              };
1002          }          }
1003          delete temp;          delete temp;
# Line 992  TList*  PamLevel2::GetListOfLevel2Files( Line 1007  TList*  PamLevel2::GetListOfLevel2Files(
1007      gSystem->ChangeDirectory(wdir); // back to the working directory      gSystem->ChangeDirectory(wdir); // back to the working directory
1008  //      cout << endl << "Selected files:" << endl;  //      cout << endl << "Selected files:" << endl;
1009  //      contents->Print();  //      contents->Print();
1010      cout << contents->GetEntries()<<" files selected\n";      cout << contents->GetEntries()<<" files \n";
1011  //      cout << endl;  //      cout << endl;
1012  //      cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl;  //      cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl;
1013      return contents;      return contents;
# Line 1411  TTree *PamLevel2::GetRunTree(TFile *f){ Line 1426  TTree *PamLevel2::GetRunTree(TFile *f){
1426      return R;      return R;
1427            
1428  }  }
1429    /**
1430     * Update the runinfo informations (to be used to have Run infos event by event basis)
1431     * @param run Pointer to the chain/tree which contains run infos
1432     * @return true if a new run has been read, false if it is still the same run
1433     */
1434    Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev){
1435      //
1436      // check if we have already called once GetEntry, if not call it
1437      //
1438      if ( run->GetEntries() <= 0 ) return(false);
1439      //
1440      Int_t oldrun = irun;
1441      if ( irun < 0 ){
1442        irun = 0;
1443        run->GetEntry(0);
1444        runfirstentry = 0ULL;
1445        runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL;
1446      };
1447      while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){
1448        //    printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS)));
1449        irun++;
1450        run->GetEntry(irun);
1451        runfirstentry = runlastentry+1ULL;
1452        runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS);
1453      };
1454      //
1455      if ( irun == oldrun || irun >= run->GetEntries() ) return(false);
1456      //
1457      //  printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry);
1458      //
1459      return(true);    
1460      //
1461    };
1462    /**
1463     * Update the runinfo informations (to be used to have Run infos event by event basis)
1464     * @param run Pointer to the chain/tree which contains run infos
1465     * @return true if a new run has been read, false if it is still the same run
1466     */
1467    Bool_t PamLevel2::UpdateRunInfo(TTree *run, ULong64_t iev){
1468      return(UpdateRunInfo((TChain*)run,iev));
1469    };
1470    
1471  //--------------------------------------  //--------------------------------------
1472  //  //
1473  //  //

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.19

  ViewVC Help
Powered by ViewVC 1.1.23