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


C++ TKey::GetCycle方法代码示例

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


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

示例1: next

 std::vector<TString> GetInputVariableNames(TDirectory *dir )
 {
    TIter next(dir->GetListOfKeys());
    TKey* key = 0;
    //set<std::string> varnames;
    std::vector<TString> names;
    
    while ((key = (TKey*)next())) {
       if (key->GetCycle() != 1) continue;
       TClass *cl = gROOT->GetClass(key->GetClassName());
       if (!cl->InheritsFrom("TH1")) continue;
       TString name(key->GetName());
       Int_t pos = name.First("__");
       name.Remove(pos);
       Bool_t hasname = false;
       std::vector<TString>::const_iterator iter = names.begin();
       while(iter != names.end()){
          if(name.CompareTo(*iter)==0)
             hasname=true;
          iter++;
       }
       if(!hasname)
          names.push_back(name);
    }
    return names;
 }
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:26,代码来源:tmvaglob.C

示例2: GetNumberOfTargets

 Int_t GetNumberOfTargets( TDirectory *dir )
 {
    TIter next(dir->GetListOfKeys());
    TKey* key    = 0;
    Int_t noTrgts = 0;
       
    while ((key = (TKey*)next())) {
       if (key->GetCycle() != 1) continue;        
       if (TString(key->GetName()).Contains("__Regression_target")) noTrgts++;
    }
    return noTrgts;
 }
开发者ID:abmorris,项目名称:BsphiKK,代码行数:12,代码来源:tmvaglob.C

示例3: GetNumberOfInputVariables

 Int_t GetNumberOfInputVariables( TDirectory *dir )
 {
    TIter next(dir->GetListOfKeys());
    TKey* key    = 0;
    Int_t noVars = 0;
       
    while ((key = (TKey*)next())) {
       if (key->GetCycle() != 1) continue;
       
       // count number of variables (signal is sufficient), exclude target(s)
       if (TString(key->GetName()).Contains("__Signal") || (TString(key->GetName()).Contains("__Regression") && !(TString(key->GetName()).Contains("__Regression_target")))) noVars++;
    }
    
    return noVars;
 }
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:15,代码来源:tmvaglob.C

示例4: GetNumberOfTargets

 Int_t GetNumberOfTargets( TDirectory *dir )
 {
    if (!dir) {
       cout << "tmvaglob::GetNumberOfTargets is called with *dir==NULL :( " << endl;
       return 0;
    }
    TIter next(dir->GetListOfKeys());
    TKey* key    = 0;
    Int_t noTrgts = 0;
    
    while ((key = (TKey*)next())) {
       if (key->GetCycle() != 1) continue;        
       if (TString(key->GetName()).Contains("__Regression_target")) noTrgts++;
    }
    return noTrgts;
 }
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:16,代码来源:tmvaglob.C

示例5: namesMatchingClass

///////////////////////////////
// Return matching key names
SEXP namesMatchingClass(SEXP fileForHists, SEXP directoryR, SEXP classTypeR)
{
  TFile* f = checkForFileForHistsWrapper(fileForHists);

  const char* oldDirectory = setFileDirectory(f, directoryR);

  // Get the class type
	std::string classType = CHAR( STRING_ELT(classTypeR, 0) );
  
  // Keep track of the ones we want
  std::vector<const char*> names;
  std::vector<int> cycles;
  
  // Loop over keys in this directory -- pull out names and cycles for classes
  // that match the ones we want.
  TList* l = gDirectory->GetListOfKeys();
  for ( unsigned int i = 0; i < l->GetEntries(); ++i ) {
    TKey* k = (TKey*) l->At(i);
    if ( strcmp( k->GetClassName(), classType.c_str() ) == 0 ) {
      names.push_back( k->GetName() );
      cycles.push_back( k->GetCycle() );
    }
  }

  // Now we loop over the vectors to get the list of names
  SEXP rNames;
  PROTECT( rNames = NEW_CHARACTER( names.size() ) );

  for ( unsigned int i = 0; i < names.size(); ++i ) {
    // Form the string
    char buf[BUFSIZE];
    snprintf(buf, BUFSIZE, "%s;%d", names[i], cycles[i]);
    
    // Save this away
    SET_STRING_ELT( rNames, i, mkChar( buf ) );
  }

  UNPROTECT(1);

  // Restore the old directory
  if ( ! f->cd(oldDirectory) ) {
    error("namesMatchingClass: cd to old directory failed");
  }
  
  return rNames;
}
开发者ID:lyonsquark,项目名称:RootTreeToR,代码行数:48,代码来源:fileForHistsWrapper.cpp

示例6: get_var_names

TString* get_var_names( Int_t nVars )
{
   const TString directories[6] = { "InputVariables_NoTransform",
                                    "InputVariables_DecorrTransform",
                                    "InputVariables_PCATransform",
				    "InputVariables_Id",
				    "InputVariables_Norm",
				    "InputVariables_Deco"};

   TDirectory* dir = 0;
   for (Int_t i=0; i<6; i++) {
      dir = (TDirectory*)Network_GFile->Get( directories[i] );
      if (dir != 0) break;
   }
   if (dir==0) {
      cout << "*** Big troubles in macro \"network.C\": could not find directory for input variables, "
           << "and hence could not determine variable names --> abort" << endl;
      return 0;
   }
   cout << "--> go into directory: " << dir->GetName() << endl;
   dir->cd();

   TString* vars = new TString[nVars];
   Int_t ivar = 0;

   // loop over all objects in directory
   TIter next(dir->GetListOfKeys());
   TKey* key = 0;
   while ((key = (TKey*)next())) {
      if (key->GetCycle() != 1) continue;

      if(!TString(key->GetName()).Contains("__S") &&
	 !TString(key->GetName()).Contains("__r")) continue;

      // make sure, that we only look at histograms
      TClass *cl = gROOT->GetClass(key->GetClassName());
      if (!cl->InheritsFrom("TH1")) continue;
      TH1 *sig = (TH1*)key->ReadObj();
      TString hname = sig->GetTitle();
      
      vars[ivar] = hname; ivar++;

      if (ivar > nVars-1) break;
   }      
   
   if (ivar != nVars-1) { // bias layer is also in nVars counts
      cout << "*** Troubles in \"network.C\": did not reproduce correct number of "
           << "input variables: " << ivar << " != " << nVars << endl;
   }

   return vars;

   // ------------- old way (not good) -------------

   //    TString fname = "weights/TMVAnalysis_MLP.weights.txt";
   //    ifstream fin( fname );
   //    if (!fin.good( )) { // file not found --> Error
   //       cout << "Error opening " << fname << endl;
   //       exit(1);
   //    }
   
   //    Int_t   idummy;
   //    Float_t fdummy;
   //    TString dummy = "";
   
   //    // file header with name
   //    while (!dummy.Contains("#VAR")) fin >> dummy;
   //    fin >> dummy >> dummy >> dummy; // the rest of header line
   
   //    // number of variables
   //    fin >> dummy >> idummy;
   //    // at this point, we should have idummy == nVars
   
   //    // variable mins and maxes
   //    TString* vars = new TString[nVars];
   //    for (Int_t i = 0; i < idummy; i++) fin >> vars[i] >> dummy >> dummy >> dummy;
   
   //    fin.close();
   
   //    return vars;
}
开发者ID:TopBrussels,项目名称:TopTreeAnalysisBase,代码行数:81,代码来源:network.C

示例7: variables

// input: - Input file (result from TMVA),
//        - normal/decorrelated/PCA
//        - use of TMVA plotting TStyle
void variables( TString fin = "TMVA.root", TString dirName = "InputVariables_Id", TString title = "TMVA Input Variables",
                Bool_t isRegression = kFALSE, Bool_t useTMVAStyle = kTRUE )
{
   TString outfname = dirName;
   outfname.ToLower(); outfname.ReplaceAll( "input", ""  );

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

   // obtain shorter histogram title 
   TString htitle = title; 
   htitle.ReplaceAll("variables ","variable");
   htitle.ReplaceAll("and target(s)","");
   htitle.ReplaceAll("(training sample)","");

   // checks if file with name "fin" is already open, and if not opens one
   TFile* file = TMVAGlob::OpenFile( fin );

   TDirectory* dir = (TDirectory*)file->Get( dirName );
   if (dir==0) {
      cout << "No information about " << title << " available in directory " << dirName << " of file " << fin << endl;
      return;
   }
   dir->cd();

   // how many plots are in the directory?
   Int_t noPlots = TMVAGlob::GetNumberOfInputVariables( dir ) +
      TMVAGlob::GetNumberOfTargets( dir );

   // define Canvas layout here!
   // default setting
   Int_t xPad;  // no of plots in x
   Int_t yPad;  // no of plots in y
   Int_t width; // size of canvas
   Int_t height;
   switch (noPlots) {
   case 1:
      xPad = 1; yPad = 1; width = 550; height = 0.90*width; break;
   case 2:
      xPad = 2; yPad = 1; width = 600; height = 0.50*width; break;
   case 3:
      xPad = 3; yPad = 1; width = 900; height = 0.4*width; break;
   case 4:
      xPad = 2; yPad = 2; width = 600; height = width; break;
   default:
//       xPad = 3; yPad = 2; width = 800; height = 0.55*width; break;
     xPad = 1; yPad = 1; width = 550; height = 0.90*width; break;
   }

   Int_t noPadPerCanv = xPad * yPad ;

   // counter variables
   Int_t countCanvas = 0;
   Int_t countPad    = 0;

   // loop over all objects in directory
   TCanvas* canv = 0;
   TKey*    key  = 0;
   Bool_t   createNewFig = kFALSE;
   TIter next(dir->GetListOfKeys());
   while ((key = (TKey*)next())) {
      if (key->GetCycle() != 1) continue;

      if (!TString(key->GetName()).Contains("__Signal") && 
          !(isRegression && TString(key->GetName()).Contains("__Regression"))) continue;

      // make sure, that we only look at histograms
      TClass *cl = gROOT->GetClass(key->GetClassName());
      if (!cl->InheritsFrom("TH1")) continue;
      TH1 *sig = (TH1*)key->ReadObj();
      TString hname(sig->GetName());

      //normalize to 1
      NormalizeHist(sig);      

      // create new canvas
      if (countPad%noPadPerCanv==0) {
         ++countCanvas;
         canv = new TCanvas( Form("canvas%d", countCanvas), title,
                             countCanvas*50+50, countCanvas*20, width, height );
         canv->Divide(xPad,yPad);
         canv->SetFillColor(kWhite);
         canv->Draw();
      }

      TPad* cPad = (TPad*)canv->cd(countPad++%noPadPerCanv+1);
      cPad->SetFillColor(kWhite);

      // find the corredponding backgrouns histo
      TString bgname = hname;
      bgname.ReplaceAll("__Signal","__Background");
      TH1 *bgd = (TH1*)dir->Get(bgname);
      if (bgd == NULL) {
         cout << "ERROR!!! couldn't find background histo for" << hname << endl;
         exit;
      }
      //normalize to 1
//.........这里部分代码省略.........
开发者ID:sixie,项目名称:EWKAna,代码行数:101,代码来源:variables.C


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