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


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

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


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

示例1: writeObjsInFolder

void FileSaver::writeObjsInFolder(string folder, bool recreate)
{
	cout<<"*** Updating "<<filename.c_str()<<" file in "<< folder << endl;
	TFile * fileFinalPlots;

	if(recreate) fileFinalPlots=TFile::Open(filename.c_str(), "RECREATE");
	else fileFinalPlots=TFile::Open(filename.c_str(), "UPDATE");

	if (!fileFinalPlots->GetDirectory(folder.c_str()))
		fileFinalPlots->mkdir(folder.c_str());
	fileFinalPlots->cd   (folder.c_str());
	cout<<"vrce: "<<fArr->At(0)<<endl;
	if(fArr->At(0)){
		cout<<fArr->At(0)->GetName()<<endl; 	
		for (int i = 0; i <= fArr->GetLast(); i++){
			cout<<fArr->At(i)<<" "<<fArr->At(i)->GetName()<<endl;
			fArr->At(i)->Write(fArr->At(i)->GetName(),2);
			cout<<"Object saved ..."<<endl;
		}
	}
	fileFinalPlots->Flush();
	fileFinalPlots->Write();
        fileFinalPlots->Close();
        fArr->Clear();
        return;
}
开发者ID:francescodimiccoli,项目名称:Deutons,代码行数:26,代码来源:filesaver.cpp

示例2: Terminate

void rdphi::Terminate()
{
//cout << "total event: " << NevtAll << "rejected: " << rejected_events << endl; 

  TFile *f = new TFile("output.root","RECREATE");

  //Write output Histograms
  TList *tl = GetOutputList();
  int l = tl->GetEntries();
  for ( int i = 0 ; i < l ; i++ )
  {
    TObject *o = tl->At(i);

    if ( o->InheritsFrom("TH1") )
    {
      cout << "TresChorros: Saving Histogram: "
          << "  Class: " << o->ClassName()  
          << "  Name: "<< o->GetName() 
          << "  Title: " << o->GetTitle()
          << " " 
          << endl << flush;
      o->Write();
    }
    }
  f->Flush();
  f->Close();  

}
开发者ID:affablelochan,项目名称:DataAnalysis,代码行数:28,代码来源:rdphi_v1.C

示例3: while

bool                              // returns true if success
processTreeSection(FILE *fp,
		   string& theline,
		   bool& new_section)
{
  string *tid  = NULL;
  TChain  *t1   = NULL;
  vector<string> v_tokens;

  string treename;

  if (gl_verbose)
    cout << "Processing Tree section" << endl;

  new_section=false;

  while (getLine(fp,theline,"Tree")) {
    if (!theline.size()) continue;
    if (theline[0] == '#') continue; // comments are welcome

    if (theline[0] == '[') {
      new_section=true;
      break;
    }

    string key, value;
    if (!getKeyValue(theline,key,value)) continue;

    //--------------------
    if (key == "id") {
    //--------------------
      if (tid != NULL) {
	cerr << "no more than one id per F1 section allowed " << value << endl;
	break;
      }
      tid = new string(value);
      
      map<string, TChain *>::const_iterator tit = glmap_id2chain.find(*tid);
      if (tit != glmap_id2chain.end()) {
	cerr << "Tree id " << *tid << " already defined" << endl;
	break;
      }
    //------------------------------
    } else if( key == "treename" ) {
    //------------------------------
      if( !tid ) {
	cerr << "id key must be defined first in the section" << endl; continue;
      }
      if( t1 ) {
	cerr << "Tree already defined" << endl; continue;
      }
      treename = value;

    //------------------------------
    } else if( key == "globslist" ) {
    //------------------------------
      t1 = getChainFromGlobslist(*tid,treename,value);
      if( !t1 )
	exit(-1);

    //------------------------------
    } else if( key == "copytree" ) {
    //------------------------------
      if( !tid ) {
	cerr << "id key must be defined first in the section" << endl; continue;      }
    
      Tokenize(value,v_tokens,",");
      
      if (v_tokens.size() != 2) {
	cerr << "copytree syntax expected: copytree=treeid,cutstring: " << value << endl; continue; }

      TChain *t2 = findChain(v_tokens[0]);
      if (!t2) {
	cerr << "tree " << v_tokens[0] << " must be defined previously" << endl; continue;    }
      if (gl_verbose)
	cout<<"Begin CopyTree of "<<v_tokens[0]<<" with selection "<<v_tokens[1]<<flush;
      
      t1 = (TChain *)(t2->CopyTree(v_tokens[1].c_str()));

      if( !t1 ) {
	cerr << "CopyTree failed" << endl; exit(-1); }

      if (gl_verbose)
	cout<<"...Done."<<endl;

    //------------------------------
    } else if( key == "save2file" ) {
    //------------------------------
      if( !t1 ) {
	cerr << "save2file: must define tree first" << endl; continue; }

      TFile *rootfile = openRootFile(value,"RECREATE");
      
      t1->SetDirectory(rootfile);
      t1->Write();
      rootfile->Flush();

      if (gl_verbose)
	cout << "Tree written to file " << value << endl;

//.........这里部分代码省略.........
开发者ID:pdudero,项目名称:usercode,代码行数:101,代码来源:spTree.C


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