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


C++ TSystemFile类代码示例

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


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

示例1: NtupleChecker

void NtupleChecker(){
  TString path = "/uscms_data/d2/uplegger/CMSSW/CMSSW_3_8_0_pre7/src/RecoVertex/BeamSpotProducer/test/scripts/Ntuples/";
  TSystemDirectory sourceDir("fileDir",path); 
  TList* fileList = sourceDir.GetListOfFiles(); 
  TIter next(fileList);
  TSystemFile* fileName;
  int fileNumber = 1;
  int maxFiles = 1000;
  BeamSpotTreeData aData;
  while ((fileName = (TSystemFile*)next()) && fileNumber <= maxFiles){
    if(TString(fileName->GetName()) == "." || TString(fileName->GetName()) == ".."  ){
      continue;
    }
    TTree* aTree = 0;
    TFile file(path+fileName->GetName(),"READ");//STARTUP
    cout << "Opening file: " << path+fileName->GetName() << endl;
    file.cd();
//    aTree = (TTree*)file.Get("PrimaryVertices");
    aTree = (TTree*)file.Get("BeamSpotTree");
    cout << (100*fileNumber)/(fileList->GetSize()-2) << "% of files done." << endl;
    ++fileNumber;
    if(aTree == 0){
      cout << "Can't find the tree" << endl;
      continue;
    }
    aData.setBranchAddress(aTree);
    for(unsigned int entry=0; entry<aTree->GetEntries(); entry++){
      aTree->GetEntry(entry);
      cout << aData.getRun() << endl;
    }
    
  }
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:33,代码来源:NtupleChecker.C

示例2: create_file

void create_file(const char *dirname, TString filename, TString histoname, TString Prefix){
  
  TSystemDirectory dir(dirname, dirname);
  TList *fileslist = dir.GetListOfFiles();
  if (fileslist) {
    TSystemFile *systemfile;
    TString fname;
    TIter next(fileslist);
    while ((systemfile=(TSystemFile*)next())) {
      fname = systemfile->GetName();
      //cout<<fname<<endl;
      if (!systemfile->IsDirectory() && fname.Contains(filename+".root")) {
	cout<<Prefix<<endl;
	TFile* file  = new TFile(dirname+fname,"READ");
	TH1F* h1 = (TH1F*)file->Get(histoname);
	//if(!fname.Contains("Bpb_TW")) h1->Scale(0.25);
	//h1->Scale(15);
	TFile* file2  = new TFile("/nfs/dust/cms/user/multh/RunII_76X_v1/Limit/Tstar_comb.root","UPDATE");
	TString histname = h1->GetName();
	h1->SetName(Prefix+"__"+filename);
	h1->Write();
	file->Close();
	file2->Close();
      }
    }
  }
}
开发者ID:multh,项目名称:TstarSemiLeptonic,代码行数:27,代码来源:limit.C

示例3: Info

void KVSimDir::AnalyseDirectory()
{
   // Read contents of directory given to ctor.
   // Each ROOT file will be analysed by AnalyseFile().

   Info("AnalyseDirectory", "Analysing %s...", GetDirectory());
   fSimData.Clear();
   fFiltData.Clear();
   //loop over files in current directory
   TSystemDirectory thisDir(".", GetDirectory());
   TList* fileList = thisDir.GetListOfFiles();
   TIter nextFile(fileList);
   TSystemFile* aFile = 0;
   while ((aFile = (TSystemFile*)nextFile())) {

      if (aFile->IsDirectory()) continue;

      KVString fileName = aFile->GetName();
      if (!fileName.EndsWith(".root"))  continue; /* skip non-ROOT files */

      AnalyseFile(fileName);

   }
   delete fileList;
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:25,代码来源:KVSimDir.cpp

示例4: runSelector

void runSelector(TString runNumber = "30496", TString myPath = "/sciclone/data10/jrstevens01/RunPeriod-2017-01/analysis/ver08/tree_pi0pi0pimpip__B3/merged/") 

{
  // Load DSelector library
  gROOT->ProcessLine(".x $(ROOT_ANALYSIS_HOME)/scripts/Load_DSelector.C");
  int Proof_Nthreads = 8;

  // process signal 
  TString sampleDir = myPath;
  //sampleDir += Form("0%s/", runNumber.Data());
  cout<<"running selector on files in: "<<sampleDir.Data()<<endl;
  
  TChain *chain = new TChain("pi0pi0pimpip__B3_Tree");
  TSystemDirectory dir(sampleDir, sampleDir);
  TList *files = dir.GetListOfFiles();
  int ifile = 0;
  if(files) {
	  TSystemFile *file;
	  TString fileName;
	  TIter next(files);
	  
	  // loop over files
	  while ((file=(TSystemFile*)next())) {
		  fileName = file->GetName();
		  if(fileName.Contains(runNumber)) {
			  cout<<fileName.Data()<<endl;
			  
			  // check if file corrupted
			  TFile f(sampleDir+fileName);
			  if(f.TestBit(TFile::kRecovered)) {
				  cout<<"file corrupted -> skipping"<<endl;
				  continue;
			  }
			  if(f.IsZombie()) {
				  cout<<"file is a Zombie -> skipping"<<endl;
				  continue;
			  }
			  
			  // add file to chain
			  chain->Add(sampleDir+fileName);
			  ifile++;
		  }
	  }

	  cout<<"total entries in TChain = "<<chain->GetEntries()<<" from "<<ifile<<" files"<<endl;
	  DPROOFLiteManager::Process_Chain(chain, "DSelector_pomegapi.C+", Proof_Nthreads, Form("hist_pomegapi_%s.acc.root", runNumber.Data()));
  }

  return;
}
开发者ID:billlee77,项目名称:wm_gluex,代码行数:50,代码来源:runSelector.C

示例5: get_filenames

void get_filenames(vector<TString> &names, const char *dirname=".", const char *ext=".root", const char *prefix = "uhh2")
{
  TSystemDirectory dir(dirname, dirname);
  TList *files = dir.GetListOfFiles();
  if (files) {
    TSystemFile *file;
    TString fname;
    TIter next(files);
    while ((file=(TSystemFile*)next())) {
      fname = file->GetName();
      if (!file->IsDirectory() && fname.EndsWith(ext) && fname.BeginsWith(prefix)) {
	names.push_back(TString(fname.Data()));
      }
    }
  }
}
开发者ID:isando3,项目名称:ThetaScripts,代码行数:16,代码来源:write_test_theta_file.C

示例6: BrowseHistograms

void BrowseHistograms(const char* histname) {

    fHistName=histname;

  TSystemDirectory dir(".",".");
  TList *files = dir.GetListOfFiles();
  if (!files) {
    cerr << "Error: No files found in " << fFileDir << endl;
    return;
  }
  files->Sort();


  histograms = new TList();
  saved = new TList();

  c = new TCanvas("canvas","Browse Histograms");

  TSystemFile *file;
  TIter next(files);
  Int_t n=0;
  TString fname;
  while ((file=(TSystemFile*)next())) {
    fname = file->GetName();
    if (!file->IsDirectory() && fname.EndsWith(".root")) {

      histograms->Add(new TObjString(fname));
      n++;
      //if(n>10)
      //	break;
    }
  }

  DrawCurrHistogram();

  TControlBar *bar = new TControlBar("vertical", "Control", 10, 10);
  bar->AddButton("Next","ProcessClick(1);", "Show next run");
  bar->AddButton("Next And Save","NextAndSave();", "Show previous run");
  bar->AddButton("Next And Forget","NextAndForget();", "Show previous run");
  bar->AddButton("Prev","ProcessClick(-1);", "Show previous run");
  bar->AddButton("Print saved","PrintSaved();", "Show previous run");
  bar->SetButtonWidth(90);
  bar->Show();
}
开发者ID:A2-Collaboration-dev,项目名称:ant,代码行数:44,代码来源:BrowseHistograms.C

示例7: list_files

vector<TString> list_files(const char *dirname, const char *exp=".*HiForestAOD.*\\.root")
{
  vector<TString> names;
  TSystemDirectory dir(dirname, dirname);
  TList *files = dir.GetListOfFiles();
  if (files) {
    TSystemFile *file;
    TString fname;
    TIter next(files);
    while ((file=(TSystemFile*)next())) {
      fname = file->GetName();
      if (!file->IsDirectory() && fname.Contains(TRegexp(exp))) {
        names.push_back(TString(dirname)+"/"+fname);
      }
    }
  }
  if (names.size()==0) return {dirname};

  return names;
}
开发者ID:Jelov,项目名称:JetEnergy_SR,代码行数:20,代码来源:buildtupledata.C

示例8: addfiles

void addfiles(TChain *ch, const TString dirname=".", const TString ext=".root")
{
	bool verbose(false);
	TSystemDirectory dir(dirname, dirname);
	TList *files = dir.GetListOfFiles();
	if (files) {
		if (verbose) std::cout << "Found files" << std::endl;
		TSystemFile *file;
		TString fname;
		TIter next(files);
		while ((file=(TSystemFile*)next())) {
			fname = file->GetName();
			if (verbose) std::cout << "found fname " << fname << std::endl;
			if (!file->IsDirectory() && fname.BeginsWith(ext)) {
				if (verbose) std::cout << "adding fname " << fname << std::endl;
				ch->Add(fname);
			}
		}
	}
}
开发者ID:cms-tamu,项目名称:MuJetAnalysis,代码行数:20,代码来源:TrigEff.C

示例9: dirlist

// Returns list of directorites or files in folder
vector<TString> dirlist(const TString &folder,
                        const TString &inname,
                        const TString &tag) {
    TString pwd(gSystem->pwd());
    vector<TString> v_dirs;
    TSystemDirectory dir(folder, folder);
    TList *files = dir.GetListOfFiles();
    if (files) {
        TSystemFile *file;
        TString fname;
        TIter next(files);
        while ((file=static_cast<TSystemFile*>(next()))) {
            fname = file->GetName();
            if (inname=="dir") {
                if ((file->IsDirectory() && !fname.Contains(".") && fname.Contains(tag))) v_dirs.push_back(fname);
            } else  if(fname.Contains(inname)) v_dirs.push_back(fname);
        }
    } // if(files)
    gSystem->cd(pwd); // The TSystemDirectory object seems to change current folder
    return v_dirs;
}
开发者ID:manuelfs,项目名称:analysis_code,代码行数:22,代码来源:utilities.cpp

示例10: add_periods

void add_periods(const char *newname, const char *perioddir)
{
	int i, j, K, N, L;
	char str[1024];
	TList *keys;
	TFile *fIn;
	TFile *f0;
	TSystemFile *fSys;
	char prefix[128];
	char *ptr;
	TNamed *obj;
	TH1D *h;
	TH1D *hist[MAXHIST];
	
	TSystemDirectory *dir = new TSystemDirectory("MyDir", perioddir);
	TList *files = dir->GetListOfFiles();
	if (!files) {
		printf("%s - nothing to do(files)\n", perioddir);
		delete dir;
		return;
	}
	N = files->GetEntries() - 2;
	if (N <= 1) {
		printf("%s - nothing to do\n", perioddir);
		delete dir;
		return;
	}
	
	TFile *fNew = new TFile(newname, "RECREATE");
	if (!fNew->IsOpen()) {
	    delete dir;
	    delete files;
	    return;
	}
	
	fSys = (TSystemFile *) files->At(2);
	if (!fSys) {
		printf("Can not open the first file\n");
		delete dir;
		delete files;
		return;
	}
	sprintf(str, "%s/%s", perioddir, fSys->GetName());
	f0 = new TFile(str);
	if (!f0->IsOpen()) {
		printf("Can not open the first file\n");
		delete dir;
		delete files;
		return;
	}
	keys = f0->GetListOfKeys();
	K = keys->GetEntries();
	if (K <= 0) {
		printf("Nothing to do: K=0\n");
		delete dir;
		delete files;
		return;
	}
	L = 0;
	for (j=0; j<K; j++) {
		obj = (TNamed *) keys->At(j);
		if (!obj) continue;
		obj = (TNamed *) f0->Get(obj->GetName());
		if (!obj) continue;
		if (strcmp(obj->ClassName(), "TH1D")) continue;
		hist[L] = (TH1D *)obj;
		L++;
	}
	if (!L) {
		printf("Nothing to do: L=0\n");
		f0->Close();
		delete dir;
		delete files;
		return;
	}
	
	for (i=1; i<N; i++) {
		fSys = (TSystemFile *) files->At(i+2);	// skip . and ..
		if (!fSys) continue;
		sprintf(str, "%s/%s", perioddir, fSys->GetName());
		fIn = new TFile(str);
		if (!fIn->IsOpen()) continue;
		for (j=0; j<L; j++) {
			h = (TH1D *) fIn->Get(hist[j]->GetName());
			if (!h) continue;
			hist[j]->Add(h);
		}
//		printf("%s\n", fSys->GetName());
		fIn->Close();
	}

	fNew->cd();
	for (j=0; j<L; j++) hist[j]->Write();
	fNew->Close();
	
	f0->Close();
	delete files;
	delete dir;
}
开发者ID:lab305itep,项目名称:digi,代码行数:99,代码来源:add_periods.C

示例11: eff

int eff(){


        cout << "Starting Efficency Script" << endl;

        cout << "Usage:  eff( module_name_string , starting_hr_file_string )" << endl;
        cout << "for defaults enter \"hr\" for starting hr file designator. " << endl;

        char chpath[256];
        getcwd(chpath, 255);
        std::string path = chpath;
        std::string mod("paxxx");//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
        //if( newmod != "" )  mod = newmod;
        // <<<<<< change folder/module name to run in 
        //std::string mod("yhc691015sn3p35");
        
        std::string dataPath =  path + "/" + mod + "data";
        //std::string measurementFolder =  mod + "data";
        //std::string configPath = path + "/" + mod;
        std::string configPath = path;
        std::string HighRateSaveFileName( "Results_Hr" );
        std::string HighRateFileName( "hr" );//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
        //if( fileDesg != "" ) HighRateFileName = fileDesg;
        int namelength = HighRateFileName.length();

	// <<<<<<<<<<<<<<<<<<<  change Highrate File name to use
    	//  assumes something like hr08ma_pa225_082715.root
    	//  10 or 08 or 06 or 04 or 02 required after hr
    	//      --   looks for a root file  with "HighRateFileName" followed by 10 or 08 or ect....
    	//      --   so will parse hr10****.root and hr08**********.root ect...  with above settings
    	std::string moduleName = mod;

	std::string maskFileName("defaultMaskFile.dat");

    //phrun files here
    
    std::string phLowName("dc05_mn325_0503.root");
    std::string phHighName("dc15_mn325_0503.root");
    
    
    //
    
	const bool FIDUCIAL_ONLY = true; // don't change
	const bool VERBOSE = true;

	int nTrigPerPixel = 50; // will be read from testParameters.dat
	int nPixels = 4160;
	int nTrig = nTrigPerPixel * nPixels;
	float pixelArea = 0.01 * 0.015; // cm^2
	float triggerDuration = 25e-9; //s

	const int nRocs = 16;
	const int nDCol = 25;
	
	double worstDCol[nRocs];
	for( int i = 0; i<nRocs; i++) worstDCol[i] = -1;
	double worstDColEff[nRocs];
        for( int i = 0; i<nRocs; i++) worstDColEff[i] = 10;

	double bestDCol[nRocs];
        for( int i = 0; i<nRocs; i++) bestDCol[i] = -1;
        double bestDColEff[nRocs];
        for( int i = 0; i<nRocs; i++) bestDColEff[i] = 10;

	double lowestdceff = 10;
        int lowestdc = -1;
        int lowestroc = 25;

        double highdceff = -10;
        int highdc = -1;
        int highroc = 25;

	std::string directoryList = mod;

	std::string outFileName = dataPath + "/" + HighRateFileName + "Efficiency.log";
        std::ofstream log(outFileName.c_str());


	cout << "search for HREfficiency folders in elComandante folder structure" << endl;
    	log << "High Rate Efficency Log File Module: "<< mod << endl << endl;
	TSystemDirectory dir(dataPath.c_str(), dataPath.c_str());
    	TList *files = dir.GetListOfFiles();
    	std::vector<std::string> fileList;
    	if (files) {
      		TSystemFile *file;
      		TString fname;
      		TIter next(files);
      		while (file=(TSystemFile*)next()) {
        		fname = file->GetName();
			std::cout << fname << endl;
         		std::string filename = fname.Data();
			if (filename.substr(0,namelength) == HighRateFileName ) {
				if( filename.substr(( filename.length() - 4 ), 4)  == "root" ){
         				fileList.push_back(filename);
					std::cout << "---Added to fileList" << endl;
				}
         		}
      		}
    	}

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

示例12: CreateESDChain

TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0, Bool_t addFileName = kFALSE, Bool_t addFriend = kFALSE, const char* check = 0)
{
  // creates chain of files in a given directory or file containing a list.
  // In case of directory the structure is expected as:
  // <aDataDir>/<dir0>/AliESDs.root
  // <aDataDir>/<dir1>/AliESDs.root
  // ...
  //
  // if addFileName is true the list only needs to contain the directories that contain the AliESDs.root files
  // if addFriend is true a file AliESDfriends.root is expected in the same directory and added to the chain as friend
  // if check is != 0 the files that work are written back into the textfile with the name check

  if (!aDataDir)
    return 0;

  Long_t id, size, flags, modtime;
  if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
  {
    printf("%s not found.\n", aDataDir);
    return 0;
  }

  TChain* chain = new TChain("esdTree");
  TChain* chainFriend = 0;
  
  if (addFriend)
    chainFriend = new TChain("esdFriendTree");

  if (flags & 2)
  {
    TString execDir(gSystem->pwd());
    TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
    TList* dirList            = baseDir->GetListOfFiles();
    Int_t nDirs               = dirList->GetEntries();
    gSystem->cd(execDir);

    Int_t count = 0;

    for (Int_t iDir=0; iDir<nDirs; ++iDir)
    {
      TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
      if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
        continue;

      if (offset > 0)
      {
        --offset;
        continue;
      }

      if (count++ == aRuns)
        break;

      TString presentDirName(aDataDir);
      presentDirName += "/";
      presentDirName += presentDir->GetName();

      chain->Add(presentDirName + "/AliESDs.root/esdTree");
    }
  }
  else
  {
    // Open the input stream
    ifstream in;
    in.open(aDataDir);

    ofstream outfile;
    if (check)
      outfile.open(check);

    Int_t count = 0;

    // Read the input list of files and add them to the chain
    TString line;
    while (in.good())
    {
      in >> line;

      if (line.Length() == 0)
        continue;

      if (offset > 0)
      {
        offset--;
        continue;
      }

      if (count++ == aRuns)
        break;

      TString esdFile(line);

      if (addFileName)
        esdFile += "/AliESDs.root";
        
      TString esdFileFriend(esdFile);
      esdFileFriend.ReplaceAll("AliESDs.root", "AliESDfriends.root");
        
      if (check)
      {
//.........这里部分代码省略.........
开发者ID:alisw,项目名称:AliRoot,代码行数:101,代码来源:runPmdTask.C

示例13: tmvaClassifier


//.........这里部分代码省略.........
  // the only TMVA object you have to interact with
  //
  // The first argument is the base of the name of all the
  // weightfiles in the directory weight/
  //
  // The second argument is the output file for the training results
  // All TMVA output can be suppressed by removing the "!" (not) in
  // front of the "Silent" argument in the option string
  TMVA::Factory *factory = new TMVA::Factory( "TMVAClassification", outputFile,
					      "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=Classification" );

  // You can add so-called "Spectator variables", which are not used in the MVA training,
  // but will appear in the final "TestTree" produced by TMVA. This TestTree will contain the
  // input variables, the response values of all trained MVAs, and the spectator variables
  //   factory->AddSpectator( "spec1 := var1*2",  "Spectator 1", "units", 'F' );
  // factory->AddSpectator( "spec2 := var1*3",  "Spectator 2", "units", 'F' );

  // Read training and test data
  // (it is also possible to use ASCII format as input -> see TMVA Users Guide)
  //   TString fname = "./tmva_class_example.root";
   
  //if (gSystem->AccessPathName( fname ))  // file does not exist in local directory
  //   gSystem->Exec("wget http://root.cern.ch/files/tmva_class_example.root");
   
  
  //   std::cout << "--- TMVAClassification       : Using input file: " << input->GetName() << std::endl;
   
  // --- Register the training and test trees
  TChain *signal     = new TChain("ewkzp2j");
  TChain *background = new TChain("ewkzp2j");
  TSystemDirectory dir(inputDir,inputDir);
  TList *files = dir.GetListOfFiles();
  if (files) {
    TSystemFile *file;
    TString fname;
    TIter next(files);
    while ((file=(TSystemFile*)next())) {
      fname = file->GetName();
      if(!fname.EndsWith("_summary.root")) continue;
      if(fname.Contains("Data")) continue;
      if(!fname.Contains("DY")) continue;
      bool isSignal(false);
      if(fname.Contains("JJ")) { signal->Add(fname); isSignal=true; }
      else if(fname.Contains("50toInf") && fname.Contains("DY")) background->Add(fname);
      cout << fname << " added as " << (isSignal ? "signal" : "background") << endl;
    }
  }else{
    cout << "[Error] no files found in " << inputDir << endl;
  }
  cout << "Signal has " << signal->GetEntries() << " raw events" << endl
       << "Background has " << background->GetEntries() << " raw events"<< endl;

  // global event weights per tree
  Double_t signalWeight     = 1.0;
  Double_t backgroundWeight = 1.0;
  factory->AddSignalTree    ( signal,     signalWeight     );
  factory->AddBackgroundTree( background, backgroundWeight );
  // event-per-event weights per tree
  factory->SetBackgroundWeightExpression( "weight/cnorm" );
  factory->SetSignalWeightExpression( "weight/cnorm" );

  //define variables for the training
  if(minimalTrain)
    {
      factory->AddVariable( "mjj",     "M_{jj}"              "GeV", 'F' );
      factory->AddVariable( "detajj",  "#Delta#eta_{jj}",     "",    'F' );
开发者ID:amagitte,项目名称:2l2v_fwk,代码行数:67,代码来源:tmvaClassifier.C

示例14: TMVAClassification


//.........这里部分代码省略.........
  Use["Plugin"]          = 0;
  // ---------------------------------------------------------------

  std::cout << std::endl;
  std::cout << "==> Start TMVAClassification" << std::endl;

  if (myMethodList != "") {
    for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;

    std::vector<TString> mlist = TMVA::gTools().SplitString( myMethodList, ',' );
    for (UInt_t i=0; i<mlist.size(); i++) {
      std::string regMethod(mlist[i]);

      if (Use.find(regMethod) == Use.end()) {
        std::cout << "Method \"" << regMethod << "\" not known in TMVA under this name. Choose among the following:" << std::endl;
        for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first << " ";
        std::cout << std::endl;
        return;
      }
      Use[regMethod] = 1;
    }
  }

  // Create a new root output file.
  TString outfileName = "TMVA";
  int toAppNum = 1;
  char name[1024];

  TSystemDirectory dir("",".");
  TList *files = dir.GetListOfFiles();
  vector<string> vfname;
  if (files) {
     TIter next(files);
     TSystemFile *file;
     TString fname;
     
     while ((file=(TSystemFile*)next())) {
        fname = file->GetName();
        if (!file->IsDirectory() && fname.EndsWith(".root") && fname.BeginsWith("TMVA")) {
           vfname.push_back(string(fname));
        }
      }
     delete files;
     if (vfname.size()>0) {
        std::sort(vfname.begin(),vfname.end());
        TString num = TString(vfname[vfname.size()-1]);
        num.ReplaceAll(".root","");
        num.ReplaceAll("TMVA","");
        toAppNum = num.Atoi()+1;
     }
  }
  sprintf(name,"%d",toAppNum);
  outfileName = outfileName + name + ".root";
  //TString outfileName( "TMVA.root" );
  TFile* outputFile = TFile::Open( outfileName, "RECREATE" );

  // Create the factory object. Later you can choose the methods
  // whose performance you'd like to investigate. The factory will
  // then run the performance analysis for you.
  //
  // The first argument is the base of the name of all the
  // weightfiles in the directory weight/ 
  //
  // The second argument is the output file for the training results
  // All TMVA output can be suppressed by removing the "!" (not) in 
  // front of the "Silent" argument in the option string
开发者ID:aperloff,项目名称:TAMUWW,代码行数:67,代码来源:TMVAClassification.C

示例15: efficiency

int efficiency(char* path0) {
	char the_path[256];
    getcwd(the_path, 255);

    std::string path(path0);


  	unsigned found = path.find_last_of("/\\", path.size()-2);

    std::string dataPath(path.substr(0,found));
    std::string measurementFolder(path.substr(found+1));

	std::stringstream ss1(measurementFolder);
    std::string moduleName;
    std::getline(ss1, moduleName, '_');

	std::string rootFileName("commander_HREfficiency.root");
	std::string maskFileName("defaultMaskFile.dat");

	const bool FIDUCIAL_ONLY = true;
	const bool VERBOSE = true;

	int nTrigPerPixel = 50;
	int nPixels = 4160;
	int nTrig = nTrigPerPixel * nPixels;
	float pixelArea = 0.01 * 0.015; // cm^2
	float triggerDuration = 25e-9; //s

	int nRocs = 16;
	
	//search for XrarSpectrum folders in elComandante folder structure
    TSystemDirectory dir(path.c_str(), path.c_str());
    TList *files = dir.GetListOfFiles();
    std::vector<std::string> directoryList;
    if (files) {
      TSystemFile *file;
      TString fname;
      TIter next(files);
      while (file=(TSystemFile*)next()) {
         fname = file->GetName();
         if (file->IsDirectory()) {
         	std::string dirname(fname.Data());
         	if (dirname.find("HREfficiency") != std::string::npos) {
         		directoryList.push_back(dirname);
         	}
         }
      }
    }

    std::vector< std::vector< std::pair< int,int > > > maskedPixels;

    //sort!
	std::sort(directoryList.begin(), directoryList.end());

	std::vector< std::vector< double > > efficiencies;
	std::vector< std::vector< double > > efficiencyErrors;
	std::vector< std::vector< double > > rates;
	std::vector< std::vector< double > > rateErrors;


	for (int i=0;i<nRocs;i++) {
		std::vector< double > empty;
		efficiencies.push_back(empty);
		efficiencyErrors.push_back(empty);
		rates.push_back(empty);
		rateErrors.push_back(empty);
	}

	// loop over all commander_HREfficiency.root root files
	for (int i=0;i<directoryList.size();++i) {
		chdir(path.c_str());
		std::cout << "looking in directory <" << directoryList[i] << ">" << std::endl;

		std::ifstream testParameters(Form("%s/testParameters.dat", directoryList[i].c_str()));
		std::string line2;
		while (getline(testParameters, line2)) {
			std::transform(line2.begin(), line2.end(), line2.begin(), ::tolower);
			if (line2.find("highrate") != std::string::npos) {
				while (getline(testParameters, line2)) {
					if (line2.size() < 1) break;
					std::transform(line2.begin(), line2.end(), line2.begin(), ::tolower);
					size_t pos = line2.find("ntrig");
					if (pos != std::string::npos) {
						nTrigPerPixel = atoi(line2.substr(pos+6).c_str());
						nTrig = nTrigPerPixel * nPixels;
						std::cout << ">" << line2 << "< pos:" << pos << std::endl;
						std::cout << "number of triggers per pixel: " << nTrigPerPixel << std::endl;
					}
				}

			}
		}
		testParameters.close();


		// read masked pixels
	    maskedPixels.clear();
		for (int j=0;j<nRocs;j++) {
			std::vector< std::pair<int,int> > rocMaskedPixels;
			maskedPixels.push_back(rocMaskedPixels);
//.........这里部分代码省略.........
开发者ID:piberger,项目名称:pixelScripts,代码行数:101,代码来源:efficiency.cpp


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