/[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.15 by mocchiut, Tue Jan 16 13:00:26 2007 UTC revision 1.18 by pam-fi, Thu Jan 18 08:51:16 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 915  TList*  PamLevel2::GetListOfLevel2Files( Line 920  TList*  PamLevel2::GetListOfLevel2Files(
920      TList *contents  = new TList; // create output list      TList *contents  = new TList; // create output list
921      contents->SetOwner();      contents->SetOwner();
922            
923      char *fullpath;  //    char *fullpath;
924    //    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              cout <<"File "<<flisttxt<<" not found"<<endl;  //      if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){
931              return 0;  //          cout <<"File "<<flisttxt<<" not found"<<endl;
932          }        //          return 0;
933  //              flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));  //      }      
934          flisttxt = fullpath;  //      flisttxt = fullpath;
935            
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;
940              return 0;              return 0;
# Line 935  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 948  TList*  PamLevel2::GetListOfLevel2Files( Line 961  TList*  PamLevel2::GetListOfLevel2Files(
961              }              }
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)) ){
966                  contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list              char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(file));
967                contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list
968              }else{              delete fullpath;
969    //          }else{
970  //              if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl;  //              if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl;
971              };  //          };
972          };          };
973          in.close();          in.close();
974                    
# Line 976  TList*  PamLevel2::GetListOfLevel2Files( Line 990  TList*  PamLevel2::GetListOfLevel2Files(
990          while ( (questo = (TSystemFile*) next()) ) {          while ( (questo = (TSystemFile*) next()) ) {
991              TString name =  questo-> GetName();              TString name =  questo-> GetName();
992              if( name.EndsWith(".root") ){              if( name.EndsWith(".root") ){
993                  char *fullpath;  //              const char *fullpath = gSystem->FindFile(ddir,name);
994                  gSystem->IsFileInIncludePath(name,&fullpath);  //              char *fullpath;
995    //              gSystem->IsFileInIncludePath(name,&fullpath);
996                    char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(name));
997                  contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));                  contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));
998                    delete fullpath;
999              };              };
1000          }          }
1001          delete temp;          delete temp;
# Line 988  TList*  PamLevel2::GetListOfLevel2Files( Line 1005  TList*  PamLevel2::GetListOfLevel2Files(
1005      gSystem->ChangeDirectory(wdir); // back to the working directory      gSystem->ChangeDirectory(wdir); // back to the working directory
1006  //      cout << endl << "Selected files:" << endl;  //      cout << endl << "Selected files:" << endl;
1007  //      contents->Print();  //      contents->Print();
1008      cout << contents->GetEntries()<<" files selected\n";      cout << contents->GetEntries()<<" files \n";
1009  //      cout << endl;  //      cout << endl;
1010  //      cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl;  //      cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl;
1011      return contents;      return contents;
# Line 1407  TTree *PamLevel2::GetRunTree(TFile *f){ Line 1424  TTree *PamLevel2::GetRunTree(TFile *f){
1424      return R;      return R;
1425            
1426  }  }
1427    /**
1428     * Update the runinfo informations (to be used to have Run infos event by event basis)
1429     * @param run Pointer to the chain/tree which contains run infos
1430     * @return true if a new run has been read, false if it is still the same run
1431     */
1432    Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev){
1433      //
1434      // check if we have already called once GetEntry, if not call it
1435      //
1436      if ( run->GetEntries() <= 0 ) return(false);
1437      //
1438      Int_t oldrun = irun;
1439      if ( irun < 0 ){
1440        irun = 0;
1441        run->GetEntry(0);
1442        runfirstentry = 0ULL;
1443        runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL;
1444      };
1445      while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){
1446        //    printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS)));
1447        irun++;
1448        run->GetEntry(irun);
1449        runfirstentry = runlastentry+1ULL;
1450        runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS);
1451      };
1452      //
1453      if ( irun == oldrun || irun >= run->GetEntries() ) return(false);
1454      //
1455      //  printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry);
1456      //
1457      return(true);    
1458      //
1459    };
1460    /**
1461     * Update the runinfo informations (to be used to have Run infos event by event basis)
1462     * @param run Pointer to the chain/tree which contains run infos
1463     * @return true if a new run has been read, false if it is still the same run
1464     */
1465    Bool_t PamLevel2::UpdateRunInfo(TTree *run, ULong64_t iev){
1466      return(UpdateRunInfo((TChain*)run,iev));
1467    };
1468    
1469  //--------------------------------------  //--------------------------------------
1470  //  //
1471  //  //

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.23