本文整理汇总了C++中Factory::AddSignalTree方法的典型用法代码示例。如果您正苦于以下问题:C++ Factory::AddSignalTree方法的具体用法?C++ Factory::AddSignalTree怎么用?C++ Factory::AddSignalTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::AddSignalTree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeFactory
void makeFactory(TTree* signalTree, TTree* backTree,std::string outfile,std::string factoryname, TTree* bgTree2=NULL)
{
using namespace TMVA;
TString jobname(factoryname.c_str());
TFile *targetFile = new TFile(outfile.c_str(),"RECREATE");
Factory *factory = new Factory(jobname,targetFile);
factory->AddSignalTree(signalTree,1.0);
factory->AddBackgroundTree(backTree,1.0);
if(bgTree2){
factory->AddBackgroundTree(bgTree2,1.0);
}
factory->AddVariable("track_deta",'F');
factory->AddVariable("track_dlayer",'I');
factory->AddVariable("track_layer",'I');
factory->AddVariable("track_pT",'F');
// factory->AddVariable("approach_dist",'F');
factory->AddVariable("vtx_radius",'F');
//factory->AddVariable("vtx_chi2",'F'); //until reco vtx works this is meaningless
factory->AddVariable("vtxTrack_dist",'F');
//factory->AddVariable("photon_m",'F');
//factory->AddVariable("photon_pT",'F');
factory->AddVariable("cluster_prob",'F');
factory->AddSpectator("vtx_chi2",'F'); //until reco vtx works this is meaningless
string track_pT_cut = "track_pT>0";
string vtx_radius_cut = "vtx_radius>0";
string em_prob_cut = "cluster_prob>=0";
//do I need photon cuts?
string tCutInitializer = em_prob_cut+"&&"+ vtx_radius_cut+"&&"+track_pT_cut+"&&track_dlayer>=0&&track_layer>=0&&approach_dist>0&&vtxTrack_dist>0&&photon_m>0&&photon_pT>0";
TCut preTraingCuts(tCutInitializer.c_str());
factory->PrepareTrainingAndTestTree(preTraingCuts,"nTrain_Signal=0:nTrain_Background=0:nTest_Signal=0:nTest_Background=0");
factory->BookMethod( TMVA::Types::kLikelihood, "LikelihoodD",
"!H:!V:!TransformOutput:PDFInterpol=Spline2:NSmoothSig[0]=20:NSmoothBkg[0]=20:NSmooth=5:NAvEvtPerBin=50:VarTransform=Decorrelate" );
factory->BookMethod(Types::kCuts,"Cuts","");
/*factory->BookMethod( Types::kKNN, "kNN", "" ); //>100k events
factory->BookMethod( Types::kPDERS, "PDERS", "" );//>100k events*/
/*factory->BookMethod( Types::kPDEFoam, "PDEFoam", "VolFrac=.0588i:SigBgSeparate=True" );//>10k events
factory->BookMethod( Types::kFisher, "Fisher", "" );
factory->BookMethod( Types::kLD, "LD" );*/
/*would need to have the options tuned
* factory->BookMethod( Types::kFDA, "FDA", "Formula=(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3:\
ParRanges=(-1,1);(-10,10);(-10,10);(-10,10);(-10,10):\
FitMethod=MINUIT:\
ErrorLevel=1:PrintLevel=-1:FitStrategy=2:UseImprove:UseMinos:SetBatch" );*/
/* nerual network that would need to be worked on
* factory->BookMethod( Types::kMLP, "MLP_ANN", "<options>" );*/
factory->TrainAllMethods();
factory->TestAllMethods();
factory->EvaluateAllMethods();
targetFile->Write();
targetFile->Close();
}
示例2: mkFactory
int mkFactory(const char *fileName="../QG_QCD_Pt-15to3000_TuneZ2_Flat_7TeV_pythia6_Fall11-PU_S6_START42_V14B-v1_fix_new_TREE.root",const char*treeName="tree_passedEvents")
{
TFile *f=TFile::Open(fileName);
if(f==NULL){fprintf(stderr,"No such file or Directory: %s\n",fileName);return 1;}
TTree *t=(TTree*)f->Get(treeName);
if(t==NULL){fprintf(stderr,"No such tree: %s\n",treeName);return 2;}
using namespace TMVA;
TCut mycuts = "abs(pdgIdPartJet0)<4 && 30<ptJet0 && ptJet0<40 && 8<rhoPF && rhoPF<10 && abs(etaJet0)<2"; // for example: TCut mycuts = "abs(var1)<0.5 && abs(var2-0.5)<1";
TCut mycutb = "pdgIdPartJet0==21 && 30<ptJet0 && ptJet0<40 && 8<rhoPF && rhoPF<10 && abs(etaJet0)<2"; //
TFile *out =TFile::Open("TMVA1_30_40.root","RECREATE");
if(out==NULL){fprintf(stderr,"Unable to create TMVA.root\n");return 3;}
Factory *fac =new Factory( "TMVAClassification", out, "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D" );
fac->AddVariable("ptD_QCJet0",'F');
fac->AddVariable("(nChargedJet0+nNeutralJet0)",'F');
//fac->AddVariable("nNeutralJet0",'F');
//fac->AddVariable("rmsCandJet0",'F');
//fac->AddVariable("axis1Jet0",'F');
//fac->AddVariable("axis2Jet0",'F');
//fac->AddVariable("pullJet0",'F');
//fac->AddVariable("RJet0",'F');
//fac->AddVariable("pull_QCJet0",'F');
fac->AddVariable("axis1_QCJet0",'F');
fac->AddVariable("TMath::Max(axis2_QCJet0,0)",'F');
//fac->AddVariable("ptD_QCJet0",'F');
//fac->AddVariable("rmsCand_QCJet0",'F');
fac->AddSignalTree(t);
fac->AddBackgroundTree(t);
fac->PrepareTrainingAndTestTree(mycuts,mycutb,"!V:SplitMode=Random");
fac->BookMethod(TMVA::Types::kBDT, "BDT",
"!H:!V:NTrees=850:nEventsMin=150:MaxDepth=6:BoostType=AdaBoost:AdaBoostBeta=0.5:SeparationType=GiniIndex:nCuts=20:PruneMethod=NoPruning");
fac->BookMethod(TMVA::Types::kLikelihood, "Likelihood","!H:!V");
fac->TrainAllMethods();
fac->TestAllMethods();
fac->EvaluateAllMethods();
//
TFile *out2=TFile::Open("TMVA2_30_40.root","RECREATE");
Factory *fac2=new Factory( "TMVAClassification2", out2, "!V:!Silent:Color:DrawProgressBar" );
// PAOLO
//fac2->AddVariable("qglPaoloJet0",'F');
fac2->AddVariable("nChargedJet0",'F');
fac2->AddVariable("axis1_QCJet0",'F');
fac2->AddVariable("TMath::Max(axis2_QCJet0,0)",'F');
fac2->AddVariable("RJet0",'F');
fac2->AddVariable("pullJet0",'F');
fac2->AddSignalTree(t);
fac2->AddBackgroundTree(t);
fac2->PrepareTrainingAndTestTree(mycuts,mycutb,"!V:SplitMode=Random");
fac2->BookMethod(TMVA::Types::kBDT, "BDT",
"!H:!V:NTrees=850:nEventsMin=150:MaxDepth=6:BoostType=AdaBoost:AdaBoostBeta=0.5:SeparationType=GiniIndex:nCuts=20:PruneMethod=NoPruning");
fac2->BookMethod(TMVA::Types::kLikelihood, "Likelihood","!H:!V");
fac2->TrainAllMethods();
fac2->TestAllMethods();
fac2->EvaluateAllMethods();
//
TFile *out3=TFile::Open("TMVA3_30_40.root","RECREATE");
Factory *fac3=new Factory( "TMVAClassification3", out3, "!V:!Silent:Color:DrawProgressBar" );
//QGL
fac3->AddVariable("qglJet0",'F');
fac3->AddSignalTree(t);
fac3->AddBackgroundTree(t);
fac3->PrepareTrainingAndTestTree(mycuts,mycutb,"!V:SplitMode=Random");
fac3->BookMethod(TMVA::Types::kBDT, "BDT",
"!H:!V:NTrees=10:nEventsMin=150:MaxDepth=1:BoostType=AdaBoost:AdaBoostBeta=0.5:SeparationType=GiniIndex:nCuts=20:PruneMethod=NoPruning");
fac3->BookMethod(TMVA::Types::kLikelihood, "Likelihood","!H:!V");
fac3->TrainAllMethods();
fac3->TestAllMethods();
fac3->EvaluateAllMethods();
TFile *out4=TFile::Open("TMVA4_30_40.root","RECREATE");
Factory *fac4=new Factory( "TMVAClassification4", out4, "!V:!Silent:Color:DrawProgressBar" );
//QGL
fac4->AddVariable("ptD_QCJet0",'F');
fac4->AddVariable("nChargedJet0",'F');
fac4->AddVariable("axis1_QCJet0",'F');
fac4->AddVariable("TMath::Max(axis2_QCJet0,0)",'F');
fac4->AddSignalTree(t);
fac4->AddBackgroundTree(t);
fac4->PrepareTrainingAndTestTree(mycuts,mycutb,"!V:SplitMode=Random");
//fac4->BookMethod(TMVA::Types::kBDT, "BDT",
// "!H:!V:NTrees=10:nEventsMin=150:MaxDepth=1:BoostType=AdaBoost:AdaBoostBeta=0.5:SeparationType=GiniIndex:nCuts=20:PruneMethod=NoPruning");
fac4->BookMethod(TMVA::Types::kLikelihood, "Likelihood","!H:!V");
//.........这里部分代码省略.........