• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TSystemFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: dir

void PValueCorrection::readFiles(TString name, int id, bool isPlugin){

	// read coverage test files
	name = "root/"+name;
	TSystemDirectory dir(name,name);
	TList *files = dir.GetListOfFiles();
	TChain *fChain = new TChain("tree");
	int foundFiles=0;
	if (files){
		TSystemFile *file;
		TString fname;
		TIter next(files);
		while ((file=(TSystemFile*)next())) {
			fname = file->GetName();
			if (!file->IsDirectory() && fname.Contains(Form("id%d",id)) && fname.EndsWith(".root")) {
				//cout << fname << endl;
				fChain->Add(name+"/"+fname);
				foundFiles++;
			}
		}
	}

	cout << "PValueCorrector::readFiles() -- found " << foundFiles << " files in " << dir.GetName() << " with total of " << fChain->GetEntries() << " entries" << endl;
	cout << "PValueCorrector::readFiles() -- will apply on the fly correction of type ";
	isPlugin ? cout << " plugin"<< endl : cout << " prob" << endl;

	// fill histogram from tree
	h_pvalue_before = new TH1F("h_pvalue_before","p-value",50,0.,1.);
	h_pvalue_after = new TH1F("h_pvalue_after","p-value",50,0.,1.);


	// set up root tree for reading
  float tSol = 0.0;
  float tChi2free = 0.0;
  float tChi2scan = 0.0;
  float tSolGen = 0.0;
  float tPvalue = 0.0;
  fChain->SetBranchAddress("sol",      &tSol);
  fChain->SetBranchAddress("chi2free", &tChi2free);
  fChain->SetBranchAddress("chi2scan", &tChi2scan);
  fChain->SetBranchAddress("solGen",   &tSolGen);
  fChain->SetBranchAddress("pvalue",   &tPvalue);

	// initialize loop variables
  Long64_t nentries = fChain->GetEntries();
  Long64_t nfailed = 0;
  float n68 =0.;
  float n95 =0.;
  float n99 =0.;

	for (Long64_t i = 0; i < nentries; i++)
	{
		fChain->GetEntry(i);
    // apply cuts (we'll count the failed ones later)
    if ( ! (tChi2free > -1e10 && tChi2scan > -1e10
         && tChi2scan-tChi2free>0
         && tSol != 0.0 ///< exclude some pathological jobs from when tSol wasn't set yet
         && tChi2free < 500 && tChi2scan < 500
      )){
			nfailed++;
      continue;
    }
		float pvalue = -999.;
		if (isPlugin) {
			pvalue = tPvalue;
		}
		else {
			pvalue = TMath::Prob(tChi2scan-tChi2free,1);
		}

		if ( pvalue > TMath::Prob(1,1) ) n68++;
		if ( pvalue > TMath::Prob(4,1) ) n95++;
		if ( pvalue > TMath::Prob(9,1) ) n99++;

		h_pvalue_before->Fill(pvalue);
	}

	fitHist(h_pvalue_before);
	if (verbose) printCoverage(n68,n95,n99,float(nentries-nfailed),"Before Correction");

	n68=0.;
	n95=0.;
	n99=0.;
	for (Long64_t i = 0; i < nentries; i++)
	{
		fChain->GetEntry(i);
    // apply cuts (we'll count the failed ones later)
    if ( ! (tChi2free > -1e10 && tChi2scan > -1e10
         && tChi2scan-tChi2free>0
         && tSol != 0.0 ///< exclude some pathological jobs from when tSol wasn't set yet
         && tChi2free < 500 && tChi2scan < 500
      )){
      continue;
    }
		float pvalue = -999.;
		if (isPlugin) {
			pvalue = transform(tPvalue);
		}
		else {
			pvalue = transform(TMath::Prob(tChi2scan-tChi2free,1));
//.........这里部分代码省略.........
开发者ID:KonstantinSchubert,项目名称:gammacombo,代码行数:101,代码来源:PValueCorrection.cpp


示例17: recupThePlots

void recupThePlots(){
//	TDirectory *theDr = (TDirectory*) myFile->Get("eleIDdir");///denom_pt/fit_eff_plots");
	//theDr->ls();
	cout << "coucou" << theOutFileName << endl;
	
	TFile *myOutFile = new TFile(theOutFileName,"RECREATE");
	
	TSystemDirectory dir(thePath, thePath);
	TSystemFile *file;
	TString fname;
	TIter next(dir.GetListOfFiles());
	while (((file=(TSystemFile*)next()))) {
		fname = file->GetName();
		if ((fname.BeginsWith("TnP"))&&fname.Contains("data")) {
                        cout <<  "--------------------"<< "\n";
                        cout << fname << "\n";
			TFile *myFile = new TFile(fname);
			TIter nextkey(myFile->GetListOfKeys());                   
			TKey *key;
			while ((key = (TKey*)nextkey())) {
                                // cout << key << "\n";
				TString theTypeClasse = key->GetClassName();
				TString theNomClasse = key->GetTitle();
                                   cout << "theTypeClasse:  "<< theTypeClasse << " ,  " << theNomClasse << "\n";
				if ( theTypeClasse == "TDirectoryFile" ){
                                        //    cout << "we are here 1" << "\n";
					TDirectory *theDr = (TDirectory*) myFile->Get(theNomClasse);
					TIter nextkey2(theDr->GetListOfKeys());
					TKey *key2;
					while ((key2 = (TKey*)nextkey2())) {
						TString theTypeClasse2 = key2->GetClassName();
						TString theNomClasse2 = key2->GetTitle();	
						if ( theTypeClasse == "TDirectoryFile" || theTypeClasse == "TGraphAsymmErrors" ){
							TDirectory *theDr2 = (TDirectory*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/fit_eff_plots");
							TIter nextkey3(theDr2->GetListOfKeys());
							TKey *key3;
							while ((key3 = (TKey*)nextkey3())) {
								TString theTypeClasse3 = key3->GetClassName();
								TString theNomClasse3 = key3->GetName();	
				 				cout << "type = " << theTypeClasse3 << " nom = " << theNomClasse3 << endl;
						
								TCanvas *theCanvas = (TCanvas*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/fit_eff_plots/"+theNomClasse3);
								TIter nextObject(theCanvas->GetListOfPrimitives());
								TObject *obj;
								while ((obj = (TObject*)nextObject())) {
									if (obj->InheritsFrom("TGraphAsymmErrors")) {
					        				cout << "histo: " << obj->GetName() << endl;
										myOutFile->cd();
										obj->Write(theNomClasse2+"_"+theNomClasse3);
										myFile->cd();
									}
									if (obj->InheritsFrom("TH2F")) {
										cout << "the TH2F = " << obj->GetName() << endl;
										myOutFile->cd();
										obj->Write(theNomClasse2+"_"+theNomClasse3);
										myFile->cd();
									}
								}
							}
						}

					}
			
				}
			}
			delete myFile;
		}
	
	}
	myOutFile->Close();

}
开发者ID:AnastasiaGrebenyuk,项目名称:DiMu-efficiencies,代码行数:72,代码来源:recupThePlots_bef.C


示例18: CreateAODChain

TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
{
  // creates chain of files in a given directory or file containing a list.
  // In case of directory the structure is expected as:
  // <aDataDir>/<dir0>/AliAOD.root
  // <aDataDir>/<dir1>/AliAOD.root
  // ...

  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("aodTree");
  TChain* chaingAlice = 0;

  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 + "/AliAOD.root/aodTree");
      // cerr<<presentDirName<<endl;
    }

  }
  else
  {
    // Open the input stream
    ifstream in;
    in.open(aDataDir);

    Int_t count = 0;

    // Read the input list of files and add them to the chain
    TString aodfile;
    while(in.good())
    {
      in >> aodfile;
      if (!aodfile.Contains("root")) continue; // protection

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

      if (count++ == aRuns)
        break;

      // add aod file
      chain->Add(aodfile);
    }

    in.close();
  }

  return chain;

} // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
开发者ID:ktf,项目名称:AliPhysics,代码行数:88,代码来源:runFlowTaskCentralityKinkTrain.C


示例19: prepDataFiles

prepDataFiles(){
//	TDirectory *theDr = (TDirectory*) myFile->Get("eleIDdir");///denom_pt/fit_eff_plots");
	//theDr->ls();
	int myIndex;	
	
	TSystemDirectory dir(thePath, thePath);
	TSystemFile *file;
	TString fname;
	TIter next(dir.GetListOfFiles());
	while ((file=(TSystemFile*)next())) {
		fname = file->GetName();
		if (fname.BeginsWith("TnP")&& fname.Contains("mc")) {
	
			ofstream myfile;

			TFile *myFile = new TFile(fname);
			TIter nextkey(myFile->GetListOfKeys());
			TKey *key;
			while (key = (TKey*)nextkey()) {
				TString theTypeClasse = key->GetClassName();
				TString theNomClasse = key->GetTitle();
				if ( theTypeClasse == "TDirectoryFile"){
					TDirectory *theDr = (TDirectory*) myFile->Get(theNomClasse);
					TIter nextkey2(theDr->GetListOfKeys());
					TKey *key2;
					while (key2 = (TKey*)nextkey2()) {
			 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TTAddress类代码示例发布时间:2022-05-31
下一篇:
C++ TSymbolTable类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap