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


C++ Factory::DefaultDataSetInfo方法代码示例

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


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

示例1: TMVAClassification


//.........这里部分代码省略.........
   // plugin mechanism
   if (Use["Plugin"]) {
         //
         // first the plugin has to be defined, which can happen either through the following line in the local or global .rootrc:
         //
         // # plugin handler          plugin name(regexp) class to be instanciated library        constructor format
         // [email protected]@MethodBase:  ^BDT                TMVA::MethodBDT          TMVA.1         "MethodBDT(TString,TString,DataSet&,TString)"
         // 
         // or by telling the global plugin manager directly
      gPluginMgr->AddHandler("[email protected]@MethodBase", "BDT", "TMVA::MethodBDT", "TMVA.1", "MethodBDT(TString,TString,DataSet&,TString)");
      factory->BookMethod( TMVA::Types::kPlugins, "BDT",
                           "!H:!V:NTrees=400:BoostType=AdaBoost:SeparationType=GiniIndex:nCuts=20:PruneMethod=CostComplexity:PruneStrength=50" );
   }

   // --------------------------------------------------------------------------------------------------

   // ---- Now you can tell the factory to train, test, and evaluate the MVAs

   // Train MVAs using the set of training events
   factory->TrainAllMethods();

   // ---- Evaluate all MVAs using the set of test events
   factory->TestAllMethods();

   // ----- Evaluate and compare performance of all configured MVAs
   factory->EvaluateAllMethods();    


   if (Use["Cuts"]) {

    for( unsigned iEff=1; iEff<11; ++iEff ) {

       TMVA::IMethod* method = (TMVA::IMethod*)factory->GetMethod("Cuts");
       TMVA::MethodCuts* cuts = dynamic_cast<TMVA::MethodCuts*>(method);

       std::string optcutsdir = "optcuts_" + selectionName + "_" + charge;
       std::string mkdir_command = "mkdir -p " + optcutsdir;
       system(mkdir_command.c_str());
       char cutsFileName[500];
       sprintf( cutsFileName, "%s/cuts_Seff%d.txt", optcutsdir.c_str(), 10*iEff );

       ofstream ofs(cutsFileName);

       std::vector<Double_t> cutsMin, cutsMax;
       cuts->GetCuts((float)iEff*0.10, cutsMin, cutsMax);

       bool found_pT1 = false;
       bool found_pT2 = false;
       bool found_NJ = false;
       bool found_NbJ = false;
       bool found_NbJmed = false;

       for( unsigned iCut=0; iCut<cutsMin.size(); ++iCut) {
         TString varName = factory->DefaultDataSetInfo().GetVariableInfo(iCut).GetInternalName();
         if( varName=="TMath_Min_pT1,pT2_") {
           ofs << "pT1 " << cutsMin[iCut] << " " << cutsMax[iCut] << std::endl;
           ofs << "pT2 " << cutsMin[iCut] << " " << cutsMax[iCut] << std::endl;
           found_pT1 = true;
           found_pT2 = true;
         } else {
           ofs << varName << " "  << cutsMin[iCut] << " " << cutsMax[iCut] << std::endl;
         }
         if( varName=="pT1" ) found_pT1 = true;
         if( varName=="pT2" ) found_pT2 = true;
         if( varName=="NJ" ) found_NJ = true;
         if( varName=="NbJ" ) found_NbJ = true;
         if( varName=="NbJmed" ) found_NbJmed = true;
       }

       // preselection cuts (if not optimized):
       if( !found_pT1 ) ofs << "pT1 20. 100000." << std::endl;
       if( !found_pT2 ) ofs << "pT2 20. 100000." << std::endl;
       if( !found_NJ )  ofs << "NJ 3 100000." << std::endl;
       if( !found_NbJ ) ofs << "NbJ 1 100000." << std::endl;
       if( !found_NbJmed && btagMed_presel_ ) ofs << "NbJmed 1 100000." << std::endl;

       if( charge=="plus" )
         ofs << "Charge 1 10" << std::endl;
       else if( charge=="minus" )
         ofs << "Charge -10 0" << std::endl;

       ofs.close();

     }  // for eff

   } // if cuts 

   // --------------------------------------------------------------
   
   // Save the output
   outputFile->Close();

   std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl;
   std::cout << "==> TMVAClassification is done!" << std::endl;      

   delete factory;

   // Launch the GUI for the root macros
   if (!gROOT->IsBatch()) TMVAGui( outfileName );
}
开发者ID:ETHZ,项目名称:ASAnalysis,代码行数:101,代码来源:TMVAClassification.C


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