当前位置: 首页>>代码示例>>C++>>正文


C++ TFile::IsOpen方法代码示例

本文整理汇总了C++中TFile::IsOpen方法的典型用法代码示例。如果您正苦于以下问题:C++ TFile::IsOpen方法的具体用法?C++ TFile::IsOpen怎么用?C++ TFile::IsOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TFile的用法示例。


在下文中一共展示了TFile::IsOpen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TPCPropagateBack

Bool_t TPCPropagateBack(Int_t nEvents, Int_t firstEvent,
			const char* fileNameClusters,
			const char* fileNameTracks,
			const char* fileNameITSBackTracks,
			const char* fileNameBackTracks)
{
  const char *name="TPCPropagateBack";
  if (gDEBUG>1) cout<<name<<" starts...\n";
  if (gDEBUG>1) gBenchmark->Start(name);

  TFile* clustersFile = TFile::Open(fileNameClusters);
  if (!clustersFile->IsOpen()) {
    cerr<<"Cannot open "<<fileNameClusters<<" !\n"; 
    return kFALSE;
  }
  TFile* itsBackFile = NULL;
  if (fileNameITSBackTracks) {
    itsBackFile = TFile::Open(fileNameITSBackTracks);
    if (!itsBackFile->IsOpen()) {
      cerr<<"Cannot open "<<fileNameITSBackTracks<<" !\n"; 
      return kFALSE;
    }
  }
  TFile* tracksFile = NULL;
  TFile* backTracksFile = NULL;
  if (strcmp(fileNameTracks, fileNameBackTracks) == 0) {
    tracksFile = backTracksFile = TFile::Open(fileNameTracks, "UPDATE");
  } else {
    backTracksFile = TFile::Open(fileNameBackTracks, "RECREATE");
    tracksFile = TFile::Open(fileNameTracks);
  }
  if (!tracksFile->IsOpen()) {
    cerr<<"Cannot open "<<fileNameTracks<<" !\n"; 
    return kFALSE;
  }

  gROOT->cd();
  AliTPCParam* tpcParam = (AliTPCParam*) 
    clustersFile->Get("75x40_100x60_150x60");
  if (!tpcParam) tpcParam = new AliTPCParamSR;
  AliTPCtracker tracker(tpcParam);
  clustersFile->cd();

  for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++) {
    tracker.SetEventNumber(iEvent);
    tracker.PropagateBack(tracksFile, itsBackFile, backTracksFile);
  }

  if (tracksFile != backTracksFile) {
    backTracksFile->Close();
    delete backTracksFile;
  }
  tracksFile->Close();
  delete tracksFile;
  clustersFile->Close();
  delete clustersFile;

  if (gDEBUG>1) gBenchmark->Show(name);
  return kTRUE;
}
开发者ID:alisw,项目名称:AliRoot,代码行数:60,代码来源:AliTRDTracking.C

示例2: OpenDataThisFile

//_______________________________________ 
 int OpenDataThisFile(TString fname ) {
 
 	int success = 0 ;

       // open the ROOT file to process
   TString path ="./data1/moukaddam/SpiceTestSep2014/Calibration/Files/";
   TString inFileName = fname+".root";
   TFile *inFile = new TFile(path + inFileName);
   
   if ( !inFile->IsOpen() )  { //try present directory
   cout << "File doesn't exist in the directory  : " << path << endl ; 
   cout << "Trying the present working directory : ./" << endl ; 
   path ="./";
   inFile = new TFile(path + inFileName);
   }
   
   if ( inFile->IsOpen() ) {
       success = 1 ;
   	   cout << "Opening the root file and grabing the histograms from " << inFile->GetName() << endl ; 
   	   inFile->ls(); 
   }
   else {
   cout << "File is not found.. EXIT!"<< endl;
   exit(-1);
   } 
	   
	 gFolderHistos = (TFolder*)(inFile->FindObjectAny("histos"));
	 
	 return success ;
   }  
开发者ID:moukaddam,项目名称:SPICEAnalysis,代码行数:31,代码来源:PeakSearch_207Bi_interactive.C

示例3: ITSPropagateBack

Bool_t ITSPropagateBack(Int_t nEvents, Int_t firstEvent,
			const char* fileNameClusters,
			const char* fileNameTracks,
			const char* fileNameBackTracks)
{
  const char *name="ITSPropagateBack";
  if (gDEBUG>1) cout<<name<<" starts...\n";
  if (gDEBUG>1) gBenchmark->Start(name);

  TFile* clustersFile = TFile::Open(fileNameClusters);
  if (!clustersFile->IsOpen()) {
    cerr<<"Cannot open "<<fileNameClusters<<" !\n"; 
    return kFALSE;
  }
  TFile* tracksFile = NULL;
  TFile* backTracksFile = NULL;
  if (strcmp(fileNameTracks, fileNameBackTracks) == 0) {
    tracksFile = backTracksFile = TFile::Open(fileNameTracks, "UPDATE");
  } else {
    backTracksFile = TFile::Open(fileNameBackTracks, "RECREATE");
    tracksFile = TFile::Open(fileNameTracks);
  }
  if (!tracksFile->IsOpen()) {
    cerr<<"Cannot open "<<fileNameTracks<<" !\n"; 
    return kFALSE;
  }

  gROOT->cd();
  AliITSgeom* geom = (AliITSgeom*) clustersFile->Get("AliITSgeom");
  AliITStrackerV2 tracker(geom);
  clustersFile->cd();

  for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++) {
    tracker.SetEventNumber(iEvent);
    tracker.PropagateBack(tracksFile, backTracksFile);
  }

  if (tracksFile != backTracksFile) {
    backTracksFile->Close();
    delete backTracksFile;
  }
  tracksFile->Close();
  delete tracksFile;
  clustersFile->Close();
  delete clustersFile;

  if (gDEBUG>1) gBenchmark->Show(name);
  return kTRUE;
}
开发者ID:alisw,项目名称:AliRoot,代码行数:49,代码来源:AliTRDTracking.C

示例4: overwriteRootFile

void overwriteRootFile()
{

    TFile* pRootFile = new TFile("myfile.root", "UPDATE");

    if (pRootFile != NULL) {
        TDirectory* pTestDir = (TDirectory*)pRootFile->Get("TestDir");
        if (pTestDir != NULL) {
            pTestDir->cd();

												pTestDir->Delete("testobj;*");

												std::string name = "testobj";
												MyROOTObject* pNewObj = NULL;
												int ival = rand() % 100 + 1;
												double dval = (double)(rand() % 1000 + 1)/1000.0;
												pNewObj = new MyROOTObject(ival, dval, name);
            if (pNewObj != NULL) {
                std::cout << *pNewObj << std::endl;
																pNewObj->Write(pNewObj->GetName(), TObject::kOverwrite);
                delete pNewObj;
            }
        }

        if (pRootFile->IsOpen() && !pRootFile->IsZombie()) {
            pRootFile->Close();
            delete pRootFile;
        }
    }    

}
开发者ID:niklask,项目名称:ROOTexample,代码行数:31,代码来源:rootExample.cpp

示例5: trigtime

void trigtime(int run, float tmax =160) {
  ostingstream ssrun;
  ssrun << run;
  string srun = srun;
  ssfname << "run" << run << "evt.root";
  string fname = "run" + srun + "evt.root";
  TFile* pfile = new TFile(fname.c_str(), "READ");
  if ( pfile == 0 || !pfile->IsOpen()) {
    cout << "File not found: " << fname << endl;
    return;
  }
  TTree* ptree = dynamic_cast<TTree*>(pfile->Get("DXDisplay/EventTree"));
  if ( ptree == 0 ) {
    cout << "Tree not found." << endl;
    return;
  }
  new TCanvas;
  string stit = "Trigger times; Time [sec]; Trigger (109 is ghost)";
  string sarg = "trigger-(trigger>100)*109+109:tlo-1456885145";
  string sarg = "trigger-(trigger>100)*109+109:tlo-1456885145";
  TH2* ph2 = new TH2F("h2", stit.c_str(), 100, 0, tmax, 8, 107.5, 116.5);
  ph2->SetStats(0);
  ph2->Draw();
  ptree->SetMarkerStyle(2);
  ptree->Draw(sarg.c_str(), "", "same");
}
开发者ID:dladams,项目名称:dune_extensions,代码行数:26,代码来源:trigtime.C

示例6: appendRootFile

void appendRootFile()
{

    TFile* pRootFile = new TFile("myfile.root", "UPDATE");

    if (pRootFile != NULL) {
        TDirectory* pTestDir = (TDirectory*)pRootFile->Get("TestDir");
        if (pTestDir != NULL) {
            pTestDir->cd();

            MyROOTObject* pMyObj = NULL;
            std::string name = "testobj";
            pMyObj = (MyROOTObject*)pTestDir->Get(name.c_str());
            if (pMyObj != NULL) {
                std::cout << *pMyObj << std::endl;
                delete pMyObj;
            }

												name = "newobj";
												MyROOTObject* pNewObj = NULL;
												pNewObj = new MyROOTObject(42, 5.9e2, name);
            if (pNewObj != NULL) {
                std::cout << *pMyObj << std::endl;
																pNewObj->Write(pNewObj->GetName());
                delete pNewObj;
            }
        }

        if (pRootFile->IsOpen() && !pRootFile->IsZombie()) {
            pRootFile->Close();
            delete pRootFile;
        }
    }    

}
开发者ID:niklask,项目名称:ROOTexample,代码行数:35,代码来源:rootExample.cpp

示例7: loadRootFile

void loadRootFile()
{

    TFile* pRootFile = new TFile("myfile.root", "READ");

    if (pRootFile != NULL) {
        TDirectory* pTestDir = (TDirectory*)pRootFile->Get("TestDir");
        if (pTestDir != NULL) {
            pTestDir->cd();

            MyROOTObject* pMyObj = NULL;
            std::string name = "testobj";
            pMyObj = (MyROOTObject*)pTestDir->Get(name.c_str());
            if (pMyObj != NULL) {
                std::cout << *pMyObj << std::endl;
                delete pMyObj;
            }
        }

        if (pRootFile->IsOpen() && !pRootFile->IsZombie()) {
            delete pTestDir;
            pRootFile->Close();
            delete pRootFile;
        }
    }    

}
开发者ID:niklask,项目名称:ROOTexample,代码行数:27,代码来源:rootExample.cpp

示例8: fill_data

void fill_data(double e_min, double e_max, int mask)
{
	const char name_pattern[] = "danss_report_v4n-sect%d-calc.root";
	const char pos[3][20] = {"hUp_%d", "hMid_%d", "hDown_%d"};
	char fname[1024];
	char cpos[32];
	int i, j;
	TFile *f;
	TH1* h;
	double val, err;
	
	for (i=0; i<3; i++) {
		sprintf(fname, name_pattern, 3-i);
		f = new TFile(fname);
		if (!f->IsOpen()) return;
		for (j=0; j<3; j++) {
			sprintf(cpos, pos[j], mask);
			h = (TH1*) f->Get(cpos);
			if (!h) {
				printf("Something is wrong: %d %d %s.\n", i, j, cpos);
				return;
			}
			val = h->IntegralAndError(h->FindBin(e_min), h->FindBin(e_max), err);
			DataArray.cnt[3*i+j] = val;
			DataArray.ecnt[3*i+j] = err;
			printf("%d %d %f +- %f\n", i, j, val, err);
		}
		f->Close();
	}
}
开发者ID:lab305itep,项目名称:digi,代码行数:30,代码来源:draw_R2m.C

示例9: addFileToList

void EventListHelper::addFileToList  ( const char * file_name, const char * tree_name ) { 
  if(std::string(file_name).find(".root") != std::string::npos) {
    std::cout << "INFO: Adding root file " << file_name << " containing tree named " << tree_name << " to event list...";

    TFile* file = TFile::Open(file_name);
    if(file->IsOpen()) {
      TTreeReader reader(tree_name,file);
      TTreeReaderValue<UInt_t> run(reader,"run"); // aka unsigned int
      TTreeReaderValue<UInt_t> lumi(reader,"lumi"); // aka unsigned int
      TTreeReaderValue<ULong64_t> event(reader,"event"); // aka unsigned long long
      while(reader.Next()) {
        addEventToList (*run, *lumi, *event);
      }
      file->Close();
    }
    else {
      std::cout << "ERROR: could not open event list file " << file_name << " Cowardly exiting." << std::endl;
      exit(-1);
    }
  }
  else {
    std::cout << "ERROR: event list file " << file_name << " does not end with .root. We don't know how to handle this.  Cowardly exiting." << std::endl;
    exit(-1);
  }
  if(m_set.size() < 1) {
    std::cout << "ERROR: event list has size < 1.  Did something go wrong when reading it?  Cowardly exiting." << std::endl;
    exit(-1);
  }
  std::cout << "INFO: added " << m_set.size() << " events." << std::endl;
}
开发者ID:CMSLQ,项目名称:rootNtupleAnalyzerV2,代码行数:30,代码来源:eventListHelper.C

示例10: LoadDomainsNacionales

//-----------------------------------------------------------------------------
void TAdministradora :: LoadDomainsNacionales(AnsiString pDomainNacional)
{
  TFile* TreeFile = new TFile(pDomainNacional);
  TreeFile->Open("rb+");
  TreeFile->SeekTo(0);

  if(TreeFile->IsOpen())
  {
    TSDomainInfo SDominio;
    TreeFile->Read(&SDominio,sizeof(TSServerInfo));

    while(!TreeFile->Eof())
    {
      TPreOrderNode* node = new  TPreOrderNode();
      TDomain* domain = new TDomain();
      node->End(SDominio.End);
      node->RightLink(SDominio.LinkedRight);
      domain->NameDomain(SDominio.Name);
      node->Info(domain);
      aDomainsPreOrderList->Insert(node);
      TreeFile->Read(&SDominio,sizeof(TSDomainInfo));
    }
  }
  TreeFile->Close();
  delete TreeFile;
}
开发者ID:sharstream,项目名称:MailServer-C,代码行数:27,代码来源:Administradora.cpp

示例11: TDCacheFile

TFile *openRootFile(const std::string& rootfn, const std::string& option="")
{
  TFile *rootfile = NULL;

  // Now check to see if this file has already been opened...
  map<string,TFile*>::const_iterator it = glmap_id2rootfile.find(rootfn);
  if( it != glmap_id2rootfile.end() ) {
    rootfile = it->second;
    if (!rootfile->IsOpen())
      rootfile->Open(rootfn.c_str(),option.c_str());
    else
      rootfile->cd();
  }  else {

    if (strstr(rootfn.c_str(),"dcache") ||
	strstr(rootfn.c_str(),"dcap")      ) {
      rootfile = new TDCacheFile(rootfn.c_str(),option.c_str());
    } else
      rootfile = new TFile(rootfn.c_str(),option.c_str());
  
    if( rootfile->IsZombie() ) {
      cerr << "File failed to open, " << rootfn << endl;
      rootfile = NULL;
    } else {
      glmap_id2rootfile.insert(pair<string,TFile*>(rootfn,rootfile));
    }
  }
  return rootfile;
}
开发者ID:trigrass2,项目名称:usercode,代码行数:29,代码来源:spRootFile.C

示例12: GetGraph

TGraph2DErrors* GetGraph(std::string fname)
{
    TGraph2DErrors* gr = 0;

    std::string fGrName = "mygraph";

    TFile *f = new TFile(fname.data());
    if (!f->IsOpen())
    {
        std::cerr << "Failed to open " << fname << std::endl;
        return gr;
    }

    f->ls();

    std::cout << "Enter name of graph : ";
    if (std::cin.peek()=='\n') std::cin.get();
    std::getline(std::cin, fGrName);

    f->GetObject(fGrName.data(), gr);
    if (gr!=NULL)
    {

        TGraph2DErrors* tgr = (TGraph2DErrors*) gr->Clone("mygraph_0");
        gr=tgr;
        gr->SetDirectory(0);
    }

    return gr;
}
开发者ID:jrtomps,项目名称:phdwork,代码行数:30,代码来源:VisualizeRegionIntegratedSurface.cpp

示例13: createRootFile

int createRootFile()
{

    TFile* pRootFile = new TFile("myfile.root", "RECREATE");
    if (pRootFile == NULL) {
        std::cout << "Error creating ROOT file" << std::endl;
        return 1;
    }

    TDirectory* pTestDir = pRootFile->mkdir("TestDir");
    if (pTestDir == NULL) {
        std::cout << "Error creating directory in ROOT file" << std::endl;
        delete pRootFile;
        return 1;
    }
    
    std::string name = "testobj";
    MyROOTObject* pMyObj = new MyROOTObject(17, 1.2e3, name);
    std::cout << *pMyObj << std::endl;

    pTestDir->cd();
    pMyObj->Write(pMyObj->GetName());

    if (pMyObj != NULL) {
        delete pMyObj;
    }

    if (pRootFile != NULL) {
        if (pRootFile->IsOpen() && !pRootFile->IsZombie()) {
            pRootFile->Close();
            delete pRootFile;
        }
    }

}
开发者ID:niklask,项目名称:ROOTexample,代码行数:35,代码来源:rootExample.cpp

示例14: efficiencies

void efficiencies( TString fin = "TMVA.root", Int_t type = 2, Bool_t useTMVAStyle = kTRUE )
{
   // argument: type = 1 --> plot efficiency(B) versus eff(S)
   //           type = 2 --> plot rejection (B) versus efficiency (S)

   // set style and remove existing canvas'
   TMVAGlob::Initialize( useTMVAStyle );

   // checks if file with name "fin" is already open, and if not opens one
   TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(fin);
   if (!file || !file->IsOpen()) {
         file = new TFile(fin);
   }

   // check if multi-cut MVA or only one set of MVAs
//   Bool_t multiMVA=kFALSE;
   TIter nextDir(file->GetListOfKeys());
   TKey *key;
   // loop over all directories and check if
   // one contains the key word 'multicutMVA'
   while ((key = (TKey*)nextDir())) {
      TClass *cl = gROOT->GetClass(key->GetClassName());
      if (!cl->InheritsFrom("TDirectory")) continue;
      TDirectory *d = (TDirectory*)key->ReadObj();
      TString path(d->GetPath());
      if (path.Contains("multicutMVA")){
//         multiMVA=kTRUE;
         plot_efficiencies( file, type, d );
      }
   }
   plot_efficiencies( file, type, gDirectory );

   return;
}
开发者ID:chunjie-sam-liu,项目名称:genome_resequencing_pipeline,代码行数:34,代码来源:efficiencies.C

示例15: macro

void macro()
{
    cout << "Example macro for testing the ROOTobject library from CINT"
         << endl;

    TFile* pRootFile = new TFile("myfile.root", "READ");

    if (pRootFile != NULL) {
        TDirectory* pTestDir = (TDirectory*)pRootFile->Get("TestDir");
        if (pTestDir != NULL) {
            pTestDir->cd();

            MyROOTObject* pMyObj = NULL;
            std::string name = "testobj";
            pMyObj = (MyROOTObject*)pTestDir->Get(name.c_str());
            if (pMyObj != NULL) {
                std::cout << *pMyObj << std::endl;
            }
        }

        if (pRootFile->IsOpen() && !pRootFile->IsZombie()) {
            pRootFile->Close();
            delete pRootFile;
        }
    }

}
开发者ID:niklask,项目名称:ROOTexample,代码行数:27,代码来源:macro.C


注:本文中的TFile::IsOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。