本文整理汇总了C++中tmva::Reader::AddVariable方法的典型用法代码示例。如果您正苦于以下问题:C++ Reader::AddVariable方法的具体用法?C++ Reader::AddVariable怎么用?C++ Reader::AddVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tmva::Reader
的用法示例。
在下文中一共展示了Reader::AddVariable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bookReader
int reader_wrapper::bookReader( TString xml_file_name) {
m_reader = new TMVA::Reader("!Color:Silent");
for (auto var : m_spectators) {
m_reader->AddSpectator(var.formula, &var.value);
}
for (auto& var : m_variables) {
m_reader->AddVariable(var.formula, &var.value);
}
m_reader->BookMVA( m_methodName, xml_file_name );
return 0;
}
示例2: makeclassification
void makeclassification() {
Float_t *vars = new Float_t[10];
//initialize TMVA Reader (example here is diphoton mva from higgs->gamma gamma mva analysis)
TMVA::Reader* tmva = new TMVA::Reader();
tmva->AddVariable("masserrsmeared/mass", &vars[0]);
tmva->AddVariable("masserrsmearedwrongvtx/mass", &vars[1]);
tmva->AddVariable("vtxprob", &vars[2]);
tmva->AddVariable("ph1.pt/mass", &vars[3]);
tmva->AddVariable("ph2.pt/mass", &vars[4]);
tmva->AddVariable("ph1.eta", &vars[5]);
tmva->AddVariable("ph2.eta", &vars[6]);
tmva->AddVariable("TMath::Cos(ph1.phi-ph2.phi)" , &vars[7]);
tmva->AddVariable("ph1.idmva", &vars[8]);
tmva->AddVariable("ph2.idmva", &vars[9]);
tmva->BookMVA("BDTG","/afs/cern.ch/user/b/bendavid/cmspublic/diphotonmvaApr1/HggBambu_SMDipho_Jan16_BDTG.weights.xml");
//tmva->BookMVA("BDTG","/scratch/bendavid/root/HggBambu_SMDipho_Jan16_BDTG.weights.xml");
TMVA::MethodBDT *bdt = dynamic_cast<TMVA::MethodBDT*>(tmva->FindMVA("BDTG"));
//enable root i/o for objects with reflex dictionaries in standalone root mode
ROOT::Cintex::Cintex::Enable();
//open output root file
TFile *fout = new TFile("gbrtest.root","RECREATE");
//create GBRForest from tmva object
GBRForest *gbr = new GBRForest(bdt);
//write to file
fout->WriteObject(gbr,"gbrtest");
fout->Close();
}
示例3: TMVAPredict
void TMVAPredict()
{
std::ofstream outfile ("baseline_c.csv");
outfile << "id,prediction\n";
TMVA::Tools::Instance();
std::cout << "==> Start TMVAPredict" << std::endl;
TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
string variables_name[3] = {"LifeTime",
"FlightDistance",
"pt"}
Float_t variables[3];
for (int i=0; i < 3; i++){
reader->AddVariable(variables_name[i].c_str(), &variables[i]);
variables[i] = 0.0;
}
TString dir = "weights/";
TString prefix = "TMVAClassification";
TString method_name = "GBDT";
TString weightfile = dir + prefix + TString("_") + method_name + TString(".weights.xml");
reader->BookMVA( method_name, weightfile );
TFile *input(0);
input = TFile::Open("../tau_data/test.root");
TTree* tree = (TTree*)input->Get("data");
Int_t ids;
Float_t prediction;
tree->SetBranchAddress("id", &ids);
for (int i=0; i < 3; i++){
tree->SetBranchAddress(variables_name[i].c_str(), &variables[i]);
}
for (Long64_t ievt=0; ievt < tree->GetEntries(); ievt++) {
tree->GetEntry(ievt);
prediction = reader->EvaluateMVA(method_name);
outfile << ids << "," << (prediction + 1.) / 2. << "\n";
}
outfile.close();
input->Close();
delete reader;
}
示例4: TMVAClassificationApplication_tW
void TMVAClassificationApplication_tW(TString signal = "data")
{
#ifdef __CINT__
gROOT->ProcessLine( ".O0" ); // turn off optimization in CINT
#endif
//---------------------------------------------------------------
// This loads the library
TMVA::Tools::Instance();
// --------------------------------------------------------------------------------------------------
// --- Create the Reader object
TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
// Create a set of variables and declare them to the reader
// - the variable names MUST corresponds in name and type to those given in the weight file(s) used
Float_t jetpt;
Float_t jeteta;
Float_t jetphi;
Float_t metpt;
Float_t metpro;
Float_t lep0pt;
Float_t lep1pt;
Float_t lep0eta;
Float_t lep1eta;
Float_t lep0phi;
Float_t lep1phi;
Float_t ptsys;
Float_t ht;
Float_t oblateness;
Float_t sphericity;
Float_t aplanarity;
Float_t njetw;
Float_t sqrts;
Float_t deltarleps;
Float_t deltaphileps;
Float_t deltaetaleps;
Float_t philepmetclose;
Float_t philepmetfar;
Float_t rlepmetclose;
Float_t rlepmetfar;
Float_t philepjetclose;
Float_t philepjetfar;
Float_t rlepjetclose;
Float_t rlepjetfar;
Float_t phijetmet;
Float_t rjetmet;
Float_t mll;
Float_t htnomet;
Float_t ptsysnomet;
Float_t metphi;
Float_t metminusptsysnomet;
reader->AddVariable ("jetpt", &jetpt);
reader->AddVariable ("jeteta", &jeteta);
reader->AddVariable ("jetphi", &jetphi);
reader->AddVariable ("metpt", &metpt);
reader->AddVariable ("metpro",&metpro);
reader->AddVariable ("lep0pt",&lep0pt);
reader->AddVariable ("lep1pt",&lep1pt);
reader->AddVariable ("lep0eta",&lep0eta);
reader->AddVariable ("lep1eta",&lep1eta);
reader->AddVariable ("lep0phi",&lep0phi);
reader->AddVariable ("lep1phi",&lep1phi);
reader->AddVariable ("ptsys",&ptsys);
reader->AddVariable ("ht",&ht);
reader->AddVariable ("oblateness", &oblateness);
reader->AddVariable ("sphericity", &sphericity);
reader->AddVariable ("aplanarity", &aplanarity);
reader->AddVariable ("njetw", &njetw);
reader->AddVariable ("sqrts", &sqrts);
reader->AddVariable ("deltarleps", &deltarleps);
reader->AddVariable ("deltaphileps", &deltaphileps);
reader->AddVariable ("deltaetaleps", &deltaetaleps);
reader->AddVariable ("philepmetclose", &philepmetclose);
reader->AddVariable ("philepmetfar", &philepmetfar);
reader->AddVariable ("rlepmetclose", &rlepmetclose);
reader->AddVariable ("rlepmetfar", &rlepmetfar);
reader->AddVariable ("philepjetclose", &philepjetclose);
reader->AddVariable ("philepjetfar", &philepjetfar);
reader->AddVariable ("rlepjetclose", &rlepjetclose);
reader->AddVariable ("rlepjetfar", &rlepjetfar);
reader->AddVariable ("phijetmet", &phijetmet);
reader->AddVariable ("rjetmet", &rjetmet);
reader->AddVariable ("mll", &mll);
reader->AddVariable ("htnomet", &htnomet);
reader->AddVariable ("ptsysnomet", &ptsysnomet);
reader->AddVariable ("metphi", &metphi);
reader->AddVariable ("metminusptsysnomet", &metminusptsysnomet);
// *************************************************
// --- Book the MVA methods
TString dir = "weights/";
TString prefix = "test_tw_00";
TString name = "BDT_"+prefix;
//.........这里部分代码省略.........
示例5: apply
void apply(std::string iName="train/OutputTmp.root") {
TMVA::Tools::Instance();
TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
float lPt = 0; reader->AddVariable("pt" , &lPt);
//float lEta = 0; reader->AddVariable("eta" , &lEta);
//float lDR = 0; reader->AddVariable("dR" , &lDR);
//float lPtc = 0; reader->AddVariable("ptc" , &lPtc);
// float lPtdR = 0; reader->AddVariable("ptdR" , &lPtdR);
//float lPuppi = 0; reader->AddVariable("puppi" , &lPuppi);
float lPtODR = 0; reader->AddVariable("ptodR" , &lPtODR);
//float lPtODRS = 0; reader->AddVariable("ptodRS" , &lPtODRS);
float lPtODRSO = 0; reader->AddVariable("ptodRSO" , &lPtODRSO);
//float lDRLV = 0; reader->AddVariable("dR_lv" , &lDRLV);
//float lPtcLV = 0; reader->AddVariable("ptc_lv" , &lPtcLV);
//float lPtdRLV = 0; reader->AddVariable("ptdR_lv" , &lPtdRLV);
//float lPuppiLV = 0; reader->AddVariable("puppi_lv" , &lPuppiLV);
float lPtODRLV = 0; reader->AddVariable("ptodR_lv" , &lPtODRLV);
//float lPtODRSLV = 0; reader->AddVariable("ptodRS_lv" , &lPtODRSLV);
float lPtODRSOLV = 0; reader->AddVariable("ptodRSO_lv" , &lPtODRSOLV);
//float lDRPU = 0; reader->AddVariable("dR_pu" , &lDRPU);
//float lPtcPU = 0; reader->AddVariable("pt_pu" , &lPtcPU);
//float lPtdRPU = 0; reader->AddVariable("ptdR_pu" , &lPtdRPU);
//float lPuppiPU = 0; reader->AddVariable("puppi_pu" , &lPuppiPU);
//float lPtODRPU = 0; reader->AddVariable("ptodR_pu" , &lPtODRPU);
//float lPtODRSPU = 0; reader->AddVariable("ptodRS_pu" , &lPtODRSPU);
//float lPtODRSOPU = 0; reader->AddVariable("ptodRSO_pu" , &lPtODRSOPU);
std::string lJetName = "BDT";
reader->BookMVA(lJetName .c_str(),(std::string("weights/TMVAClassificationCategory_PUDisc_v1")+std::string(".weights.xml")).c_str());
TFile *lFile = new TFile(iName.c_str());
TTree *lTree = (TTree*) lFile->Get("tree");
lTree->SetBranchAddress("pt" , &lPt);
//lTree->SetBranchAddress("eta" , &lEta);
//lTree->SetBranchAddress("dR" , &lDR);
//lTree->SetBranchAddress("ptc" , &lPtc);
//lTree->SetBranchAddress("ptdR" , &lPtdR);
//lTree->SetBranchAddress("puppi" , &lPuppi);
lTree->SetBranchAddress("ptodR" , &lPtODR);
//lTree->SetBranchAddress("ptodRS" , &lPtODRS);
lTree->SetBranchAddress("ptodRSO" , &lPtODRSO);
//lTree->SetBranchAddress("dR_lv" , &lDRLV);
// lTree->SetBranchAddress("ptc_lv" , &lPtcLV);
//lTree->SetBranchAddress("ptdR_lv" , &lPtdRLV);
//lTree->SetBranchAddress("puppi_lv" , &lPuppiLV);
lTree->SetBranchAddress("ptodR_lv" , &lPtODRLV);
//lTree->SetBranchAddress("ptodRS_lv" , &lPtODRSLV);
lTree->SetBranchAddress("ptodRSO_lv" , &lPtODRSOLV);
//lTree->SetBranchAddress("dR_pu" , &lDRPU);
//lTree->SetBranchAddress("pt_pu" , &lPtcPU);
//lTree->SetBranchAddress("ptdR_pu" , &lPtdRPU);
//lTree->SetBranchAddress("puppi_pu" , &lPuppiPU);
//lTree->SetBranchAddress("ptodR_pu" , &lPtODRPU);
//lTree->SetBranchAddress("ptodRS_pu" , &lPtODRSPU);
//lTree->SetBranchAddress("ptodRSO_pu" , &lPtODRSOPU);
int lNEvents = lTree->GetEntries();
TFile *lOFile = new TFile("Output.root","RECREATE");
TTree *lOTree = lTree->CloneTree(0);
float lMVA = 0; lOTree->Branch("bdt" ,&lMVA ,"lMVA/F");
for (Long64_t i0=0; i0<lNEvents;i0++) {
if (i0 % 10000 == 0) std::cout << "--- ... Processing event: " << double(i0)/double(lNEvents) << std::endl;
lTree->GetEntry(i0);
lMVA = float(reader->EvaluateMVA(lJetName.c_str()));
lOTree->Fill();
}
lOTree->Write();
lOFile->Close();
delete reader;
}
示例6: TMVAReader
//.........这里部分代码省略.........
float SubJet2_JP;
float SubJet2_JBP;
float SubJet2_CSV;
float SubJet2_CSVIVF;
// CSV TaggingVariables
// per jet
float TagVarCSV2_jetNTracks; // tracks associated to jet
float TagVarCSV2_jetNTracksEtaRel; // tracks associated to jet for which trackEtaRel is calculated
float TagVarCSV2_trackSumJetEtRatio; // ratio of track sum transverse energy over jet energy
float TagVarCSV2_trackSumJetDeltaR; // pseudoangular distance between jet axis and track fourvector sum
float TagVarCSV2_trackSip2dValAboveCharm; // track 2D signed impact parameter of first track lifting mass above charm
float TagVarCSV2_trackSip2dSigAboveCharm; // track 2D signed impact parameter significance of first track lifting mass above charm
float TagVarCSV2_trackSip3dValAboveCharm; // track 3D signed impact parameter of first track lifting mass above charm
float TagVarCSV2_trackSip3dSigAboveCharm; // track 3D signed impact parameter significance of first track lifting mass above charm
float TagVarCSV2_vertexCategory; // category of secondary vertex (Reco, Pseudo, No)
float TagVarCSV2_jetNSecondaryVertices; // number of reconstructed possible secondary vertices in jet
float TagVarCSV2_vertexMass; // mass of track sum at secondary vertex
float TagVarCSV2_vertexNTracks; // number of tracks at secondary vertex
float TagVarCSV2_vertexEnergyRatio; // ratio of energy at secondary vertex over total energy
float TagVarCSV2_vertexJetDeltaR; // pseudoangular distance between jet axis and secondary vertex direction
float TagVarCSV2_flightDistance2dVal; // transverse distance between primary and secondary vertex
float TagVarCSV2_flightDistance2dSig; // transverse distance significance between primary and secondary vertex
float TagVarCSV2_flightDistance3dVal; // distance between primary and secondary vertex
float TagVarCSV2_flightDistance3dSig; // distance significance between primary and secondary vertex
// per jet per etaRel track
float TagVarCSV2_trackEtaRel_0; // lowest track eta relative to jet axis
float TagVarCSV2_trackEtaRel_1; // second lowest track eta relative to jet axis
float TagVarCSV2_trackEtaRel_2; // third lowest track eta relative to jet axis
TMVA::Reader *reader = new TMVA::Reader( "!Color" );
reader->AddVariable("TagVarCSV_vertexCategory",&TagVarCSV_vertexCategory);
reader->AddVariable("TagVarCSV_jetNTracks",&TagVarCSV_jetNTracks);
//reader->AddVariable("TagVarCSV_trackSip2dSig_0",&TagVarCSV_trackSip2dSig_0);
//reader->AddVariable("TagVarCSV_trackSip2dSig_1",&TagVarCSV_trackSip2dSig_1);
//reader->AddVariable("TagVarCSV_trackSip2dSig_2",&TagVarCSV_trackSip2dSig_2);
//reader->AddVariable("TagVarCSV_trackSip2dSig_3",&TagVarCSV_trackSip2dSig_3);
reader->AddVariable("TagVarCSV_trackSip3dSig_0",&TagVarCSV_trackSip3dSig_0);
reader->AddVariable("TagVarCSV_trackSip3dSig_1",&TagVarCSV_trackSip3dSig_1);
reader->AddVariable("TagVarCSV_trackSip3dSig_2",&TagVarCSV_trackSip3dSig_2);
reader->AddVariable("TagVarCSV_trackSip3dSig_3",&TagVarCSV_trackSip3dSig_3);
//reader->AddVariable("TagVarCSV_trackPtRel_0",&TagVarCSV_trackPtRel_0);
//reader->AddVariable("TagVarCSV_trackPtRel_1",&TagVarCSV_trackPtRel_1);
//reader->AddVariable("TagVarCSV_trackPtRel_2",&TagVarCSV_trackPtRel_2);
//reader->AddVariable("TagVarCSV_trackPtRel_3",&TagVarCSV_trackPtRel_3);
reader->AddVariable("TagVarCSV_trackSip2dSigAboveCharm",&TagVarCSV_trackSip2dSigAboveCharm);
//reader->AddVariable("TagVarCSV_trackSip3dSigAboveCharm",&TagVarCSV_trackSip3dSigAboveCharm);
//reader->AddVariable("TagVarCSV_trackSumJetEtRatio",&TagVarCSV_trackSumJetEtRatio);
//reader->AddVariable("TagVarCSV_trackSumJetDeltaR",&TagVarCSV_trackSumJetDeltaR);
reader->AddVariable("TagVarCSV_jetNTracksEtaRel",&TagVarCSV_jetNTracksEtaRel);
reader->AddVariable("TagVarCSV_trackEtaRel_0",&TagVarCSV_trackEtaRel_0);
reader->AddVariable("TagVarCSV_trackEtaRel_1",&TagVarCSV_trackEtaRel_1);
reader->AddVariable("TagVarCSV_trackEtaRel_2",&TagVarCSV_trackEtaRel_2);
reader->AddVariable("TagVarCSV_jetNSecondaryVertices",&TagVarCSV_jetNSecondaryVertices);
reader->AddVariable("TagVarCSV_vertexMass",&TagVarCSV_vertexMass);
reader->AddVariable("TagVarCSV_vertexNTracks",&TagVarCSV_vertexNTracks);
reader->AddVariable("TagVarCSV_vertexEnergyRatio",&TagVarCSV_vertexEnergyRatio);
reader->AddVariable("TagVarCSV_vertexJetDeltaR",&TagVarCSV_vertexJetDeltaR);
reader->AddVariable("TagVarCSV_flightDistance2dSig",&TagVarCSV_flightDistance2dSig);
//reader->AddVariable("TagVarCSV_flightDistance3dSig",&TagVarCSV_flightDistance3dSig);
reader->AddSpectator("Jet_pt", &Jet_pt);
reader->AddSpectator("Jet_eta", &Jet_eta);
reader->AddSpectator("Jet_phi", &Jet_phi);
示例7: TMVAClassificationApplicationLambda
//.........这里部分代码省略.........
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
std::vector<TString> mlist = 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 the Reader object
TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
// Create a set of variables and declare them to the reader
// - the variable names MUST corresponds in name and type to those given in the weight file(s) used
//Float_t var1, var2;
//Float_t var3, var4;
Float_t la_agl, la_dlos, la_dau1_dzos, la_dau1_dxyos, la_dau2_dzos, la_dau2_dxyos;
Float_t la_vtxChi2, la_dau1_nhit, la_dau2_nhit;
reader->AddVariable( "la_agl", &la_agl );
reader->AddVariable( "la_dlos", &la_dlos );
reader->AddVariable( "la_dau1_dzos", &la_dau1_dzos );
reader->AddVariable( "la_dau2_dzos",&la_dau2_dzos);
reader->AddVariable( "la_dau1_dxyos", &la_dau1_dxyos );
reader->AddVariable( "la_dau2_dxyos",&la_dau2_dxyos);
reader->AddVariable( "la_vtxChi2",&la_vtxChi2);
reader->AddVariable( "la_dau1_nhit",&la_dau1_nhit);
reader->AddVariable( "la_dau2_nhit",&la_dau2_nhit);
// Spectator variables declared in the training have to be added to the reader, too
Float_t la_mass;
reader->AddSpectator( "la_mass", &la_mass );
//reader->AddSpectator( "spec2 := var1*3", &spec2 );
/*
Float_t Category_cat1, Category_cat2, Category_cat3;
if (Use["Category"]){
// Add artificial spectators for distinguishing categories
reader->AddSpectator( "Category_cat1 := var3<=0", &Category_cat1 );
reader->AddSpectator( "Category_cat2 := (var3>0)&&(var4<0)", &Category_cat2 );
reader->AddSpectator( "Category_cat3 := (var3>0)&&(var4>=0)", &Category_cat3 );
}
*/
// --- Book the MVA methods
TString dir = "weights/";
TString prefix = "TMVAClassification";
// Book method(s)
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
if (it->second) {
示例8: TMVAClassificationApplication_new
void TMVAClassificationApplication_new(TString myMethodList = "" , TString iFileName = "", TString bkgSample = "", TString sampleLocation = "", TString massPoint = "", TString oFileLocation = "")
{
#ifdef __CINT__
gROOT->ProcessLine( ".O0" ); // turn off optimization in CINT
#endif
//---------------------------------------------------------------
// This loads the library
TMVA::Tools::Instance();
// Default MVA methods to be trained + tested
std::map<std::string,int> Use;
// --- Cut optimisation
Use["Cuts"] = 0;
Use["CutsD"] = 0;
Use["CutsPCA"] = 0;
Use["CutsGA"] = 0;
Use["CutsSA"] = 0;
//
//
// --- Boosted Decision Trees
Use["BDT"] = 1; // uses Adaptive Boost
std::cout << std::endl;
std::cout << "==> Start TMVAClassificationApplication" << std::endl;
// Select methods (don't look at this code - not of interest)
if (myMethodList != "") {
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
std::vector<TString> mlist = 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 the Reader object
TMVA::Reader *reader = new TMVA::Reader("!Color:!Silent" );
TString weightTail = "_";
weightTail = weightTail + massPoint;
// Create a set of variables and declare them to the reader
// - the variable names MUST corresponds in name and type to those given in the weight file(s) used
Float_t var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16, var17, var18;
reader->AddVariable( "svMass", &var1);
reader->AddVariable( "dRTauTau", &var3 );
reader->AddVariable( "dRJJ", &var4 );
// reader->AddVariable( "svPt", &var5 );
// reader->AddVariable( "dRhh", &var6 );
reader->AddVariable( "met", &var7 );
reader->AddVariable( "mJJ", &var8 );
// reader->AddVariable( "metTau1DPhi", &var9 );
// reader->AddVariable( "metTau2DPhi", &var10);
// reader->AddVariable( "metJ1DPhi", &var11);
// reader->AddVariable( "metJ2DPhi", &var12 );
// reader->AddVariable( "metTauPairDPhi", &var13 );
// reader->AddVariable( "metSvTauPairDPhi", &var14 );
// reader->AddVariable( "metJetPairDPhi", &var15 );
// reader->AddVariable( "CSVJ1", &var16 );
// reader->AddVariable( "CSVJ2", &var17 );
reader->AddVariable( "fMassKinFit", &var2 );
reader->AddVariable( "chi2KinFit2", &var18 );
// Spectator variables declared in the training have to be added to the reader, too
// Float_t spec1,spec2;
// reader->AddSpectator( "spec1 := var1*2", &spec1 );
// reader->AddSpectator( "spec2 := var1*3", &spec2 );
// Float_t Category_cat1, Category_cat2, Category_cat3;
// if (Use["Category"]){
// // Add artificial spectators for distinguishing categories
// reader->AddSpectator( "Category_cat1 := var3<=0", &Category_cat1 );
// reader->AddSpectator( "Category_cat2 := (var3>0)&&(var4<0)", &Category_cat2 );
// reader->AddSpectator( "Category_cat3 := (var3>0)&&(var4>=0)", &Category_cat3 );
// }
// --- Book the MVA methods
// Book method(s)
TString weightFileName = "/nfs_scratch/zmao/test/CMSSW_5_3_15/src/TMVA-v4.2.0/test/weights/TMVAClassification_BDT.weights_";
weightFileName += bkgSample;
weightFileName += weightTail;
reader->BookMVA("BDT method", weightFileName+".xml" );
// Book output histograms
//.........这里部分代码省略.........
示例9: TMVARegressionApplication
void TMVARegressionApplication( int wMs,int wM, string st,string st2,string option="",TString myMethodList = "" )
{
//---------------------------------------------------------------
// This loads the library
TMVA::Tools::Instance();
// Default MVA methods to be trained + tested
std::map<std::string,int> Use;
// --- Mutidimensional likelihood and Nearest-Neighbour methods
Use["PDERS"] = 0;
Use["PDEFoam"] = 0;
Use["KNN"] = 0;
//
// --- Linear Discriminant Analysis
Use["LD"] = 0;
//
// --- Function Discriminant analysis
Use["FDA_GA"] = 0;
Use["FDA_MC"] = 0;
Use["FDA_MT"] = 0;
Use["FDA_GAMT"] = 0;
//
// --- Neural Network
Use["MLP"] = 0;
//
// --- Support Vector Machine
Use["SVM"] = 0;
//
// --- Boosted Decision Trees
Use["BDT"] = 0;
Use["BDTG"] = 1;
// ---------------------------------------------------------------
std::cout << std::endl;
std::cout << "==> Start TMVARegressionApplication" << std::endl;
// Select methods (don't look at this code - not of interest)
if (myMethodList != "") {
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
std::vector<TString> mlist = 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 the Reader object
TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
// Create a set of variables and declare them to the reader
// - the variable names MUST corresponds in name and type to those given in the weight file(s) used
//Float_t var1, var2;
//reader->AddVariable( "var1", &var1 );
//reader->AddVariable( "var2", &var2 );
Float_t pt_AK8MatchedToHbb,eta_AK8MatchedToHbb,nsv_AK8MatchedToHbb,sv0mass_AK8MatchedToHbb,sv1mass_AK8MatchedToHbb,
nch_AK8MatchedToHbb,nmu_AK8MatchedToHbb,nel_AK8MatchedToHbb,muenfr_AK8MatchedToHbb,emenfr_AK8MatchedToHbb;
reader->AddVariable( "pt_AK8MatchedToHbb", &pt_AK8MatchedToHbb );
reader->AddVariable( "eta_AK8MatchedToHbb", &eta_AK8MatchedToHbb );
reader->AddVariable( "nsv_AK8MatchedToHbb", &nsv_AK8MatchedToHbb );
reader->AddVariable( "sv0mass_AK8MatchedToHbb", &sv0mass_AK8MatchedToHbb );
reader->AddVariable( "sv1mass_AK8MatchedToHbb", &sv1mass_AK8MatchedToHbb );
reader->AddVariable( "nch_AK8MatchedToHbb", &nch_AK8MatchedToHbb );
reader->AddVariable( "nmu_AK8MatchedToHbb", &nmu_AK8MatchedToHbb );
reader->AddVariable( "nel_AK8MatchedToHbb", &nel_AK8MatchedToHbb );
reader->AddVariable( "muenfr_AK8MatchedToHbb", &muenfr_AK8MatchedToHbb );
reader->AddVariable( "emenfr_AK8MatchedToHbb", &emenfr_AK8MatchedToHbb );
// Spectator variables declared in the training have to be added to the reader, too
Float_t spec1,spec2;
reader->AddSpectator( "spec1:=n_pv", &spec1 );
reader->AddSpectator( "spec2:=msoftdrop_AK8MatchedToHbb", &spec2 );
// --- Book the MVA methods
TString dir = "weights/";
TString prefix = "TMVARegression";
// Book method(s)
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
if (it->second) {
TString methodName = it->first + " method";
TString weightfile = dir + prefix + "_" + TString(it->first) + ".weights.xml";
reader->BookMVA( methodName, weightfile );
}
}
TH1* hists[100];
//.........这里部分代码省略.........
示例10: main
//.........这里部分代码省略.........
std::cout << " vectorMyMethodMassList[" << iMVAMass << "] = " << vectorMyMethodMassList.at(iMVAMass) << std::endl;
TMVA::Reader *TMVAreader = new TMVA::Reader( "!Color:!Silent" );
// TMVAreader->AddVariable("jetpt1", &jetpt1);
// TMVAreader->AddVariable("jetpt2", &jetpt2);
// TMVAreader->AddVariable("mjj", &mjj);
// TMVAreader->AddVariable("detajj", &detajj);
// TMVAreader->AddVariable("dphilljetjet", &dphilljetjet);
// TMVAreader->AddVariable("pt1", &pt1);
// TMVAreader->AddVariable("pt2", &pt2);
// TMVAreader->AddVariable("mll", &mll);
// TMVAreader->AddVariable("dphill", &dphill);
// TMVAreader->AddVariable("mth", &mth);
// TMVAreader->AddVariable("dphillmet", &dphillmet);
// TMVAreader->AddVariable("mpmet", &mpmet);
Float_t input_variables[1000];
// float input_variables[1000];
// TMVAreader->AddVariable("jetpt1", &(input_variables[0]));
// TMVAreader->AddVariable("jetpt2", &(input_variables[1]));
// TMVAreader->AddVariable("mjj", &(input_variables[2]));
// TMVAreader->AddVariable("detajj", &(input_variables[3]));
// TMVAreader->AddVariable("dphilljetjet", &(input_variables[4]));
// TMVAreader->AddVariable("pt1", &(input_variables[5]));
// TMVAreader->AddVariable("pt2", &(input_variables[6]));
// TMVAreader->AddVariable("mll", &(input_variables[7]));
// TMVAreader->AddVariable("dphill", &(input_variables[8]));
// TMVAreader->AddVariable("mth", &(input_variables[9]));
// TMVAreader->AddVariable("dphillmet", &(input_variables[10]));
// TMVAreader->AddVariable("mpmet", &(input_variables[11]));
TMVAreader->AddVariable("jetpt1", &input_variables[0]);
TMVAreader->AddVariable("jetpt2", &input_variables[1]);
TMVAreader->AddVariable("mjj", &input_variables[2]);
TMVAreader->AddVariable("detajj", &input_variables[3]);
TMVAreader->AddVariable("dphilljetjet", &input_variables[4]);
TMVAreader->AddVariable("pt1", &input_variables[5]);
TMVAreader->AddVariable("pt2", &input_variables[6]);
TMVAreader->AddVariable("mll", &input_variables[7]);
TMVAreader->AddVariable("dphill", &input_variables[8]);
TMVAreader->AddVariable("mth", &input_variables[9]);
TMVAreader->AddVariable("dphillmet", &input_variables[10]);
TMVAreader->AddVariable("mpmet", &input_variables[11]);
TMVAreader->AddSpectator("channel", &input_variables[12]);
TString myMethodMassList = Form ("%s",vectorMyMethodMassList.at(iMVAMass).c_str());
TString weightfile = Form ("%s/weights_%s_testVariables/TMVAMulticlass_%s.weights.xml",MVADirectory.c_str(),myMethodMassList.Data(),myMethodList.Data());
std::cout << " myMethodList = " << myMethodList.Data() << std::endl;
std::cout << " weightfile = " << weightfile.Data() << std::endl;
// TString myMethodListBook = Form ("%s",vectorMyMethodList.at(iMVA).c_str());
// TMVAreader->BookMVA( myMethodListBook, weightfile );
TMVAreader->BookMVA( myMethodList, weightfile );
for (int iSample=0; iSample<numberOfSamples; iSample++){
std::cout << " iSample = " << iSample << " :: " << numberOfSamples << std::endl;
file[iSample] -> cd();
Double_t MVA_Value;
TBranch *newBranch;
示例11: ZTMVAClassificationApplication
//.........这里部分代码省略.........
Use["SVM_Poly"] = 0;
Use["SVM_Lin"] = 0;
std::cout << std::endl;
std::cout << "==> Start TMVAClassificationApplication" << std::endl;
// Select methods (don't look at this code - not of interest)
if (myMethodList != "") {
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
std::vector<TString> mlist = 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 the Reader object
TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
Float_t B_s0_ln_FDCHI2; reader->AddVariable("B_s0_ln_FDCHI2", &B_s0_ln_FDCHI2 );
Float_t B_s0_ln_IPCHI2; reader->AddVariable("B_s0_ln_IPCHI2", &B_s0_ln_IPCHI2 );
Float_t B_s0_ln_EVCHI2; reader->AddVariable("B_s0_ln_EVCHI2", &B_s0_ln_EVCHI2 );
Float_t B_s0_PT_fiveGeV;reader->AddVariable("B_s0_PT_fiveGeV",&B_s0_PT_fiveGeV);
Float_t B_s0_Eta; reader->AddVariable("B_s0_Eta", &B_s0_Eta );
Float_t minK_PT_GeV; reader->AddVariable("minK_PT_GeV", &minK_PT_GeV );
Float_t minK_ln_IPCHI2; reader->AddVariable("minK_ln_IPCHI2", &minK_ln_IPCHI2 );
Float_t Category_cat1, Category_cat2, Category_cat3;
if (Use["Category"]){
// Add artificial spectators for distinguishing categories
reader->AddSpectator( "Category_cat1 := var3<=0", &Category_cat1 );
reader->AddSpectator( "Category_cat2 := (var3>0)&&(var4<0)", &Category_cat2 );
reader->AddSpectator( "Category_cat3 := (var3>0)&&(var4>=0)", &Category_cat3 );
}
// --- Book the MVA methods
TString dir = "weights/";
TString prefix = "TMVAClassification";
// Book method(s)
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
if (it->second) {
TString methodName = TString(it->first) + TString(" method");
TString weightfile = dir + prefix + TString("_") + TString(it->first) + TString(".weights.xml");
reader->BookMVA( methodName, weightfile );
}
}
// Book output histograms
UInt_t nbin = 100;
TH1F *histLk(0), *histLkD(0), *histLkPCA(0), *histLkKDE(0), *histLkMIX(0), *histPD(0), *histPDD(0);
示例12: main
//.........这里部分代码省略.........
outputRootFile[iSample] = new TFile ( nameFile, "RECREATE") ;
outputRootFile[iSample] -> cd () ;
cloneTreeJetLepVect[iSample] = treeJetLepVect[iSample] -> CloneTree (0) ;
}
for (int iSample=0; iSample<numberOfSamples; iSample++){
file[iSample] -> cd();
///==== loop ====
Long64_t nentries = treeJetLepVect[iSample]->GetEntries();
for (Long64_t iEntry = 0; iEntry < nentries; iEntry++){
treeJetLepVect[iSample]->GetEntry(iEntry);
cloneTreeJetLepVect[iSample] -> Fill () ;
}
}
/**
* cycle on MVA (method-mass)
* * cycle on samples
* * * cycle on events
*/
for (int iMVA = 0; iMVA < vectorMyMethodList.size(); iMVA++) {
std::cout << " vectorMyMethodList[" << iMVA << "] = " << vectorMyMethodList.at(iMVA) << std::endl;
TString myMethodList = Form ("%s",vectorMyMethodList.at(iMVA).c_str());
for (int iMVAMass = 0; iMVAMass < vectorMyMethodMassList.size(); iMVAMass++) {
std::cout << " vectorMyMethodMassList[" << iMVAMass << "] = " << vectorMyMethodMassList.at(iMVAMass) << std::endl;
TMVA::Reader *TMVAreader = new TMVA::Reader( "!Color:!Silent" );
Float_t input_variables[1000];
TMVAreader->AddVariable("lep1pt", &input_variables[0]);
TMVAreader->AddVariable("lep2pt", &input_variables[1]);
TMVAreader->AddVariable("dPhi", &input_variables[2]);
TMVAreader->AddVariable("dR", &input_variables[3]);
TMVAreader->AddVariable("dilmass", &input_variables[4]);
TMVAreader->AddVariable("type", &input_variables[5]);
TMVAreader->AddVariable("mt", &input_variables[6]);
TMVAreader->AddVariable("mjj", &input_variables[7]);
TMVAreader->AddVariable("detajj", &input_variables[8]);
TMVAreader->AddVariable("jet1eta", &input_variables[9]);
TString myMethodMassList = Form ("%s",vectorMyMethodMassList.at(iMVAMass).c_str());
TString weightfile = Form ("%s/weights_%s_testVariables/TMVAClassification_%s.weights.xml",MVADirectory.c_str(),myMethodMassList.Data(),myMethodList.Data());
std::cout << " myMethodList = " << myMethodList.Data() << std::endl;
std::cout << " weightfile = " << weightfile.Data() << std::endl;
TMVAreader->BookMVA( myMethodList, weightfile );
for (int iSample=0; iSample<numberOfSamples; iSample++){
std::cout << " iSample = " << iSample << " :: " << numberOfSamples << std::endl;
file[iSample] -> cd();
Double_t MVA_Value;
TBranch *newBranch;
TString methodName4Tree = Form ("%s_%s_MVAHiggs",myMethodList.Data(),myMethodMassList.Data());
TString methodName4Tree2 = Form ("%s_%s_MVAHiggs_2JVBF/D",myMethodList.Data(),myMethodMassList.Data());
newBranch = cloneTreeJetLepVect[iSample]->Branch(methodName4Tree,&MVA_Value,methodName4Tree2);
///==== loop ====
Long64_t nentries = treeJetLepVect[iSample]->GetEntries();
示例13: TMVAClassificationApplication
void TMVAClassificationApplication( TString SampleName = "" )
{
#ifdef __CINT__
gROOT->ProcessLine( ".O0" ); // turn off optimization in CINT
#endif
//---------------------------------------------------------------
// This loads the library
TMVA::Tools::Instance();
// Default MVA methods to be trained + tested
std::map<std::string,int> Use;
// --- Cut optimisation
Use["Cuts"] = 0;
Use["CutsD"] = 1;
Use["CutsPCA"] = 0;
Use["CutsGA"] = 0;
Use["CutsSA"] = 0;
//
// --- 1-dimensional likelihood ("naive Bayes estimator")
Use["Likelihood"] = 0;
Use["LikelihoodD"] = 1; // the "D" extension indicates decorrelated input variables (see option strings)
Use["LikelihoodPCA"] = 0; // the "PCA" extension indicates PCA-transformed input variables (see option strings)
Use["LikelihoodKDE"] = 0;
Use["LikelihoodMIX"] = 0;
//
// --- Mutidimensional likelihood and Nearest-Neighbour methods
Use["PDERS"] = 0;
Use["PDERSD"] = 0;
Use["PDERSPCA"] = 0;
Use["PDEFoam"] = 0;
Use["PDEFoamBoost"] = 0; // uses generalised MVA method boosting
Use["KNN"] = 0; // k-nearest neighbour method
//
// --- Linear Discriminant Analysis
Use["LD"] = 0; // Linear Discriminant identical to Fisher
Use["Fisher"] = 0;
Use["FisherG"] = 0;
Use["BoostedFisher"] = 0; // uses generalised MVA method boosting
Use["HMatrix"] = 0;
//
// --- Function Discriminant analysis
Use["FDA_GA"] = 0; // minimisation of user-defined function using Genetics Algorithm
Use["FDA_SA"] = 0;
Use["FDA_MC"] = 0;
Use["FDA_MT"] = 0;
Use["FDA_GAMT"] = 0;
Use["FDA_MCMT"] = 0;
//
// --- Neural Networks (all are feed-forward Multilayer Perceptrons)
Use["MLP"] = 1; // Recommended ANN
Use["MLPBFGS"] = 1; // Recommended ANN with optional training method
Use["MLPBNN"] = 1; // Recommended ANN with BFGS training method and bayesian regulator
Use["CFMlpANN"] = 0; // Depreciated ANN from ALEPH
Use["TMlpANN"] = 0; // ROOT's own ANN
//
// --- Support Vector Machine
Use["SVM"] = 0;
//
// --- Boosted Decision Trees
Use["BDT"] = 1; // uses Adaptive Boost
Use["BDTG"] = 1; // uses Gradient Boost
Use["BDTB"] = 0; // uses Bagging
Use["BDTD"] = 1; // decorrelation + Adaptive Boost
//
// --- Friedman's RuleFit method, ie, an optimised series of cuts ("rules")
Use["RuleFit"] = 0;
// ---------------------------------------------------------------
Use["Plugin"] = 0;
Use["Category"] = 0;
Use["SVM_Gauss"] = 0;
Use["SVM_Poly"] = 0;
Use["SVM_Lin"] = 0;
std::cout << std::endl;
std::cout << "==> Start TMVAClassificationApplication" << std::endl;
// --- Create the Reader object
TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
// Create a set of variables and declare them to the reader
// - the variable names MUST corresponds in name and type to those given in the weight file(s) used
Float_t var1, var2;
Float_t var3, var4;
reader->AddVariable( "jet_csv[0]", &var1 );
reader->AddVariable( "jet_csv[1]", &var2 );
reader->AddVariable( "jet_csv[2]", &var3 );
reader->AddVariable( "jet_csv[3]", &var4 );
// --- Book the MVA methods
TString dir = "weights/";
TString prefix = "TMVAClassification";
// Book method(s)
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
if (it->second) {
TString methodName = TString(it->first) + TString(" method");
//.........这里部分代码省略.........
示例14: tmva_reader
//.........这里部分代码省略.........
TEvent->Branch("run",&run,"run/I");
TEvent->Branch("evtn",&evtn,"evtn/I");
TEvent->Branch("b0f",&b0f,"b0f/I");
TEvent->Branch("d0f",&d0f,"d0f/I");
TEvent->Branch("mbc",&mbc,"mbc/D");
TEvent->Branch("de",&de,"de/D");
TEvent->Branch("bdt",&bdt,"bdt/D");
TEvent->Branch("bdtg",&bdtg,"bdtg/D");
TEvent->Branch("bdts",&bdts,"bdts/D");
TEvent->Branch("bdtgs",&bdtgs,"bdtgs/D");
TEvent->Branch("bdtlh",&bdtlh,"bdtlh/D");
TEvent->Branch("bdtglh",&bdtglh,"bdtglh/D");
TEvent->Branch("bdtlhs",&bdtlhs,"bdtlhs/D");
TEvent->Branch("bdtglhs",&bdtglhs,"bdtglhs/D");
TEvent->Branch("lh",&lh,"lh/D");
TEvent->Branch("mp",&mp,"mp/D");
TEvent->Branch("mm",&mm,"mm/D");
TEvent->Branch("bin",&bin,"bin/I");
TEvent->Branch("dz",&dz,"dz/D");
TEvent->Branch("dt",&dt,"dt/D");
TEvent->Branch("tag_LH",&tag_LH,"tag_LH/D");
TEvent->Branch("tag_LH_err",&tag_LH_err,"tag_LH_err/D");
TEvent->Branch("atckpi_max",&atckpi_max,"atckpi_max/D");
TEvent->Branch("mpi0",&mpi0,"mpi0/D");
TEvent->Branch("mk",&mk,"mk/D");
TEvent->Branch("md",&md,"md/D");
reader->AddVariable("abs(cos_b0)",&m_cos_b0);
// reader->AddVariable("p_ks",&m_p_ks);
reader->AddVariable("log(chi2_ndf_D0)",&m_chi2_ndf_D0);
// reader->AddVariable("log(chi2_ndf_B0)",&m_chi2_ndf_B0);
// reader->AddVariable("log(chi2_tag_vtx/ndf_tag_vtx)",&m_chi2_ndf_tag_vtx);
reader->AddVariable("abs(cos_thr)",&m_cos_thr);
reader->AddVariable("abs(thr_sig-0.885)",&m_thr_sig);
reader->AddVariable("thr_oth",&m_thr_oth);
reader->AddVariable("log(tag_LH_err)",&m_tag_LH_err);
reader->AddVariable("log(dzerr)",&m_dzerr);
reader->AddVariable("log(pi0_chi2)",&m_pi0_chi2);
reader->AddVariable("log(egamma)",&m_egamma);
reader->AddVariable("k1mm2",&m_k1mm2);
reader->AddVariable("k1et",&m_k1et);
reader->AddVariable("k1hso00",&m_k1hso00);
reader->AddVariable("k1hso02",&m_k1hso02);
reader->AddVariable("k1hso04",&m_k1hso04);
reader->AddVariable("k1hso10",&m_k1hso10);
reader->AddVariable("k1hso12",&m_k1hso12);
reader->AddVariable("k1hso14",&m_k1hso14);
reader->AddVariable("k1hso20",&m_k1hso20);
reader->AddVariable("k1hso22",&m_k1hso22);
reader->AddVariable("k1hso24",&m_k1hso24);
reader->AddVariable("k1hoo0",&m_k1hoo0);
reader->AddVariable("k1hoo1",&m_k1hoo1);
reader->AddVariable("k1hoo2",&m_k1hoo2);
reader->AddVariable("k1hoo3",&m_k1hoo3);
reader->AddVariable("k1hoo4",&m_k1hoo4);
reader->BookMVA("BDT","weights/MVAnalysis_BDT.weights.xml");
reader->BookMVA("BDTG","weights/MVAnalysis_BDTG.weights.xml");
reader->BookMVA("BDTs","weights/MVAnalysis_sig_BDT.weights.xml");
示例15: TMVAClassificationApplication_cc1pcoh_bdt_ver3noveractFFFSI
void TMVAClassificationApplication_cc1pcoh_bdt_ver3noveractFFFSI( TString myMethodList = "", TString fname)
{
#ifdef __CINT__
gROOT->ProcessLine( ".O0" ); // turn off optimization in CINT
#endif
//---------------------------------------------------------------
// This loads the library
TMVA::Tools::Instance();
// Default MVA methods to be trained + tested
std::map<std::string,int> Use;
//
// --- Boosted Decision Trees
Use["BDT"] = 1; // uses Adaptive Boost
std::cout << std::endl;
std::cout << "==> Start TMVAClassificationApplication" << std::endl;
// Select methods (don't look at this code - not of interest)
if (myMethodList != "") {
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
std::vector<TString> mlist = 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 the Reader object
TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
// Create a set of variables and declare them to the reader
// - the variable names MUST corresponds in name and type to those given in the weight file(s) used
Float_t mumucl, pmucl;
Float_t pang_t, muang_t;
Float_t veract;
Float_t ppe, mupe;
Float_t range, coplanarity;
Float_t opening;//newadd
reader->AddVariable( "mumucl", &mumucl );
reader->AddVariable( "pmucl", &pmucl );
reader->AddVariable( "pang_t", &pang_t );
reader->AddVariable( "muang_t", &muang_t );
//reader->AddVariable( "veract", &veract );
reader->AddVariable( "ppe", &ppe);
reader->AddVariable( "mupe", &mupe);
reader->AddVariable( "range", &range);
reader->AddVariable( "coplanarity", &coplanarity);
reader->AddVariable( "opening", &opening);//newadd
// Spectator variables declared in the training have to be added to the reader, too
Int_t fileIndex, inttype;
Float_t nuE, norm, totcrsne;
reader->AddSpectator( "fileIndex", &fileIndex );
reader->AddSpectator( "nuE", &nuE );
reader->AddSpectator( "inttype", &inttype );
reader->AddSpectator( "norm", &norm );
reader->AddSpectator( "totcrsne", &totcrsne );
reader->AddSpectator( "veract", &veract );
// --- Book the MVA methods
TString dir = "weights/";
TString prefix = "TMVAClassification_ver3noveractFFFSI";//newchange
// Book method(s)
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
if (it->second) {
TString methodName = TString(it->first) + TString(" method");
TString weightfile = dir + prefix + TString("_") + TString(it->first) + TString(".weights.xml");
reader->BookMVA( methodName, weightfile );
}
}
// Prepare input tree (this must be replaced by your data source)
// in this example, there is a toy tree with signal and one with background events
// we'll later on use only the "signal" events for the test in this example.
//
//.........这里部分代码省略.........
开发者ID:cvson,项目名称:tmvaccohPM,代码行数:101,代码来源:TMVAClassificationApplication_cc1pcoh_bdt_ver3noveractFFFSI.C