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


C++ TDirectory::Close方法代码示例

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


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

示例1: DoCompareDirectories

void TDirectoryDiffDocument::DoCompareDirectories(TDirectory& directory1, TDirectory& directory2)
{
	directory1.Open();
	directory2.Open();
	
	// iterate through directory 1
	int	count = directory1.GetFileCount();
	for (int i = 0; i < count; i++)
	{
		TString	name;
		bool	isDirectory;
		
		directory1.GetFile(i, name, isDirectory);
		if (isDirectory)
		{
			// ignore CVS, subversion and directories
			if (Tstrcmp(name, "CVS") != 0 && Tstrcmp(name, ".svn") != 0 && Tstrcmp(name, ".git") != 0)
			{
				TDirectory	subDir2(directory2, name);
				
				if (subDir2.Exists())
				{
					TDirectory	subDir1(directory1, name);
					DoCompareDirectories(subDir1, subDir2);
				}
			}
		}
		else
		{
			TFile	file2(directory2, name);
			
			if (file2.Exists())
			{
				TFile	file1(directory1, name);
				
				// ignore class files and compiled python files
				const char* extension = file1.GetFileExtension();
				if (Tstrcmp(extension, "class") != 0 && Tstrcmp(extension, "pyc") != 0)
				{
					if (!TFile::FilesAreEqual(file1, file2, true))
					{
						TString* path = new TString;;
						
						TFile::ComputeRelativePath(file1.GetPath(), fDirectory1.GetPath(), *path);
						fDiffList.InsertLast(path);
					}
				}
			}
		}
	}

	directory1.Close();
	directory2.Close();
}
开发者ID:mikevoydanoff,项目名称:zoinks,代码行数:54,代码来源:TDirectoryDiffDocument.cpp

示例2: FillHistograms

void FillHistograms(TString SAMPLE)
{
  cout<<"Processing sample "<<SAMPLE<<endl;
  //TString PATH("root://eoscms//eos/cms/store/cmst3/user/kkousour/ttH/flat/");
  TString PATH("/afs/cern.ch/work/k/kkousour/private/CMSSW_7_4_12/src/KKousour/TopAnalysis/prod/ttH/");
  TFile *inf  = TFile::Open(PATH+"flatTree_"+SAMPLE+".root");
  TFile *outf = TFile::Open(TString::Format("Histo_%s.root",SAMPLE.Data()),"RECREATE");

  TIter nextKey(inf->GetListOfKeys());
  TKey *key;
  while ((key = (TKey*)nextKey())) {
    TString dirName(key->GetName());
    cout<<"Found directory "<<dirName<<endl;
    
    TH1F *hPass = (TH1F*)inf->Get(dirName+"/TriggerPass");
    outf->mkdir(dirName);  
    TDirectory *dir = (TDirectory*)outf->Get(dirName); 
    TTree *tr   = (TTree*)inf->Get(dirName+"/events");
    
    TreeClass myTree(tr);
    dir->cd();
    hPass->Write("TriggerPass");
    myTree.Loop(dir);
    cout<<"Loop finished"<<endl;
    dir->Close();
    delete tr;
  }
  outf->Close();
  inf->Close();
}
开发者ID:isildakbora,项目名称:UserCode,代码行数:30,代码来源:FillHistograms.C

示例3: looperCR2lep


//.........这里部分代码省略.........
				h_chi2[i]->Fill(    hadronic_top_chi2(),                   fillWeight );
				h_htratio[i]->Fill( context::ak4_htratiom(),               fillWeight );
				h_mindphi[i]->Fill( context::Mindphi_met_j1_j2(),          fillWeight );
				h_ptb1[i]->Fill( context::ak4pfjets_leadMEDbjet_p4().pt(), fillWeight );
				h_drlb1[i]->Fill(   drLepLeadb,                            fillWeight );
				h_ptlep[i]->Fill(   lep1_p4().pt(),                        fillWeight );
				h_metht[i]->Fill(   metSqHT,                               fillWeight );
				h_dphilw[i]->Fill(  dPhiLepW,                              fillWeight );
				h_njets[i]->Fill(   context::ngoodjets(),                  fillWeight );
				h_nbtags[i]->Fill(  context::ngoodbtags(),                 fillWeight );
				h_ptj1[i]->Fill(    j1pt,                                  fillWeight );
				h_j1btag[i]->Fill(  j1_isBtag,                             fillWeight );
				h_modtop[i]->Fill(  context::TopnessMod(),                 fillWeight );
				h_dphilmet[i]->Fill( context::lep1_dphiMET(),              fillWeight );
				h_mlb[i]->Fill(     myMlb,                                 fillWeight );

				h_yields->Fill(     double(i+1),                           fillWeight );

				// Special systematic variation histograms
				for( int j=1; j<=nVariations; j++ ) {
					h_bkgtype[i][j]->Fill( bkgType,  fillWeight * variations.at(j-1)->GetWeight() );
					h_evttype[i][j]->Fill( evtType,  fillWeight * variations.at(j-1)->GetWeight() );
					if( mySample->IsSignal() ) h_sigyields[i][j]->Fill( mass_stop(), mass_lsp(), fillWeight * variations.at(j-1)->GetWeight() );
				}

			}

			// ---------------------------------------------------------------------------------------------------//
			////////////////////////////////////////////////////////////////////////////////////////////////////////
		} //End of loop over events in file

		// Clean Up
		delete tree;
		file.Close();

		// Zero negative values in each signal region
		for( int i=0; i<nSigRegs; i++ ) {
			for( int j=0; j<=nVariations; j++ ) {
				bool negsFound = false;

				// First zero any decay modes with negative yields
				for( int k=1; k<= h_bkgtype[i][j]->GetNbinsX(); k++ ) {
					if( h_bkgtype[i][j]->GetBinContent(k) < 0.0 ) {
						h_bkgtype[i][j]->SetBinContent(k, 0.);
						h_bkgtype[i][j]->SetBinError(k, 0.);
						negsFound = true;
					}
					if( h_evttype[i][j]->GetBinContent(k+2) < 0.0 ) {
						h_evttype[i][j]->SetBinContent(k+2, 0.);
						h_evttype[i][j]->SetBinError(k+2, 0.);
					}
				}
				// If any negative yields were found in any decay mode, recalculate the total yield
				if( j==0 && negsFound ) {
					double newYield, newErr;
					newYield = h_bkgtype[i][0]->IntegralAndError( 0, -1, newErr );
					h_yields->SetBinContent(i+1, newYield);
					h_yields->SetBinError(i+1, newErr);
				}
				// Add zeroed histograms to total histograms
				h_bkgtype_sum[i][j]->Add( h_bkgtype[i][j] );
				h_evttype_sum[i][j]->Add( h_evttype[i][j] );
			}
		}
		h_yields_sum->Add( h_yields );
开发者ID:dsklein,项目名称:StopLooper,代码行数:66,代码来源:looperCR2lep.C

示例4: main


//.........这里部分代码省略.........

  std::string usage = "\nSample multiPlotter usage::\n" ; 
  usage += "\"multiPlotter -o validation-canvas -i validation.root\"\n " ; 
  usage += "\t input= validation.root\n" ;
  usage += "\t output= validation-canvas.root\n" ;
  usage += "\"multiPlotter -g -p -o validation-canvas -i \"validation_01.root validation_02.root\" \"\n" ;
  usage += "\t input= validation_01.root AND validation_02.root\n" ;
  usage += "\t output= validation-canvas.root\n" ;
  usage += "\t         validation-canvas.pdf\n" ;
  usage += "\t         gif files in validation-canvas/ \n\t\t\t (a directory tree which has the same \n\t\t\t directory structure as validation-canvas.root\n" ;
  usage += "\n" ; 

  boost::program_options::positional_options_description pos ; 
  boost::program_options::variables_map vmap ;
  
  try {
    boost::program_options::store(boost::program_options::command_line_parser(argc,argv).
				  options(desc).positional(pos).run(), vmap) ; 
  } catch (boost::program_options::error const& x) {
    std::cerr << "Unable to parse options:\n"
	      << x.what() << "\n\n" ;
    std::cerr << desc << usage << std::endl ;
    return 1 ; 
  }
  
  boost::program_options::notify(vmap) ; 
  if (vmap.count("help")) {
    std::cout << desc << usage <<  std::endl ;
    return 1 ;
  }
  if (vmap.count("outfile")) {
    outbase = vmap["outfile"].as<std::string>() ; 
    outname = outbase + ".root" ;
    pdfname = outbase + ".pdf" ;
  }
  if (vmap.count("pdf")) {
    makePdf = true ; 
  } 
  if (vmap.count("graphic")) {
    makeGraphic = true ; 
  } 
  if (vmap.count("infile")) {
    infileName = vmap["infile"].as<std::string>() ;
    /*
    std::ifstream inFile(infileName.c_str()) ;
    if (inFile.is_open()) { //--- input files listed in a file ---//
      while ( !inFile.eof() ) {
	std::string skipped ;
	getline(inFile,skipped) ; 
	inFileVector.push_back( skipped ) ;
      }
    } else 
    */
    { //--- Assume the file is a space-separated list of files -//
      size_t strStart = 0 ; 
      for (size_t itr=infileName.find(" ",0); itr!=std::string::npos;
	   itr=infileName.find(" ",itr)) {
	std::string skipped = infileName.substr(strStart,(itr-strStart)) ; 
	itr++ ; strStart = itr ; 
	inFileVector.push_back( skipped ) ;
      }
      //--- Fill the last entry ---//
      inFileVector.push_back( infileName.substr(strStart,infileName.length()) ); 
    }
  }
  else {
    std::cout << " *** No input file given: please define one " << std::endl;
    return 0;
  }

  TDirectory *target = TFile::Open(TString(outname),"RECREATE");
  
  baseName = new TString(outbase);
  baseName->Append("/");
  
  TList *sourcelist = new TList();  
  for (std::vector<std::string>::size_type i = 0; i < inFileVector.size(); i++) {
    std::cout << inFileVector[i] << " " << std::endl;
    sourcelist->Add(TFile::Open(TString(inFileVector[i])));
  }

  TCanvas* c1 = new TCanvas("c1") ;
  pdf = 0 ;
  if (makePdf) pdf = new TPDF(TString(pdfname)) ;
  //  int pageNumber = 2 ;
  // double titleSize = 0.050 ; 
  
  gROOT->SetStyle("Plain") ; 
  gStyle->SetPalette(1) ; 
  //gStyle->SetOptStat(111111) ;
  gStyle->SetOptStat(0) ;
  c1->UseCurrentStyle() ; 
  gROOT->ForceStyle() ;
  
  drawLoop(target,sourcelist,c1);
  
  if (makePdf) pdf->Close();
  target->Close();
  return 0;
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:101,代码来源:multiPlotter.cpp


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