136#pragma warning ( disable : 4355 )
171 std::cerr << kERROR <<
"IPythonInteractive::Init: already initialized..." << std::endl;
175 for(
auto& title : graphTitles){
177 fGraphs.back()->SetTitle(title);
178 fGraphs.back()->SetName(title);
179 fGraphs.back()->SetFillColor(color);
180 fGraphs.back()->SetLineColor(color);
181 fGraphs.back()->SetMarkerColor(color);
479 if (
DataInfo().GetClassInfo(
"Signal") != 0) {
482 if (
DataInfo().GetClassInfo(
"Background") != 0) {
510 DeclareOptionRef(
fVerbose,
"V",
"Verbose output (short form of \"VerbosityLevel\" below - overrides the latter one)" );
526 DeclareOptionRef(
fVarTransformString,
"VarTransform",
"List of variable transformations performed before training, e.g., \"D_Background,P_Signal,G,N_AllClasses\" for: \"Decorrelation, PCA-transformation, Gaussianisation, Normalisation, each for the given class of events ('AllClasses' denotes all events of all classes, if no class indication is given, 'All' is assumed)\"" );
533 "Events with negative weights are ignored in the training (but are included for testing and performance evaluation)" );
575 Log().SetMinType( kVERBOSE );
584 Log() << kFATAL <<
"<ProcessOptions> Verbosity level type '"
600 "Use signal or background events to derive for variable transformation (the transformation is applied on both types of, course)" );
628 Log() << kWARNING <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"Parameter optimization is not yet implemented for method "
630 Log() << kWARNING <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"Currently we need to set hardcoded which parameter is tuned in which ranges"<<
Endl;
632 return std::map<TString,Double_t>();
663 <<
"Begin training" <<
Endl;
668 <<
"\tEnd of training " <<
Endl;
671 <<
"Elapsed time for training with " << nEvents <<
" events: "
675 <<
"\tCreate MVA output for ";
725 bool truncate =
false;
726 TH1F*
h1 = regRes->QuadraticDeviation( tgtNum , truncate, 1.);
727 stddev = sqrt(
h1->GetMean());
730 h1->GetQuantiles(1,yq,xq);
731 TH1F* h2 = regRes->QuadraticDeviation( tgtNum , truncate, yq[0]);
732 stddev90Percent = sqrt(h2->
GetMean());
748 Int_t totalProgressDraws = 100;
749 Int_t drawProgressEvery = 1;
750 if(nEvents >= totalProgressDraws) drawProgressEvery = nEvents/totalProgressDraws;
752 size_t ntargets =
Data()->GetEvent(0)->GetNTargets();
753 std::vector<float> output(nEvents*ntargets);
754 auto itr = output.begin();
755 for (
Int_t ievt=0; ievt<nEvents; ievt++) {
757 Data()->SetCurrentEvent(ievt);
759 if (vals.size() != ntargets)
760 Log() << kFATAL <<
"Output regression vector with size " << vals.size() <<
" is not consistent with target size of "
761 << ntargets << std::endl;
763 std::copy(vals.begin(), vals.end(), itr);
767 if(ievt % drawProgressEvery == 0 || ievt==nEvents-1) timer.
DrawProgressBar( ievt );
778 Data()->SetCurrentType(type);
792 regRes->Resize( nEvents );
796 Data()->SetCurrentEvent(0);
797 size_t nTargets =
GetEvent()->GetNTargets();
798 auto regValuesBegin = output.begin();
799 auto regValuesEnd = regValuesBegin + nTargets;
801 if (output.size() != nTargets *
size_t(nEvents))
802 Log() << kFATAL <<
"Output regression vector with size " << output.size() <<
" is not consistent with target size of "
803 << nTargets <<
" and number of events " << nEvents << std::endl;
806 for (
Int_t ievt=0; ievt<nEvents; ievt++) {
808 std::vector< Float_t > vals(regValuesBegin, regValuesEnd);
809 regRes->SetValue( vals, ievt );
811 regValuesBegin += nTargets;
812 regValuesEnd += nTargets;
816 <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
825 regRes->CreateDeviationHistograms( histNamePrefix );
838 Data()->SetCurrentEvent(0);
840 std::vector<float> output(nEvents * vals.size());
841 auto itr = output.begin();
842 std::copy(vals.begin(), vals.end(), itr);
843 for (
Int_t ievt=1; ievt<nEvents; ievt++) {
845 Data()->SetCurrentEvent(ievt);
848 std::copy(vals.begin(), vals.end(), itr);
859 Data()->SetCurrentType(type);
864 if (!resMulticlass)
Log() << kFATAL<<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"unable to create pointer in AddMulticlassOutput, exiting."<<
Endl;
874 resMulticlass->Resize( nEvents );
876 size_t nClasses = output.size()/nEvents;
877 for (
Int_t ievt=0; ievt<nEvents; ievt++) {
878 std::vector< Float_t > vals(output.begin()+ievt*nClasses, output.begin()+(ievt+1)*nClasses);
879 resMulticlass->SetValue( vals, ievt );
884 <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
895 resMulticlass->CreateMulticlassPerformanceHistos(histNamePrefix);
902 if (errUpper) *errUpper=-1;
934 Data()->SetCurrentType(type);
948 <<
" sample (" << nEvents <<
" events)" <<
Endl;
950 std::vector<Double_t> mvaValues =
GetMvaValues(0, nEvents,
true);
953 <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
961 for (
Int_t ievt = 0; ievt < nEvents; ievt++) {
964 auto ev =
Data()->GetEvent(ievt);
975 if (firstEvt > lastEvt || lastEvt > nEvents) lastEvt = nEvents;
976 if (firstEvt < 0) firstEvt = 0;
977 std::vector<Double_t> values(lastEvt-firstEvt);
979 nEvents = values.size();
988 <<
" sample (" << nEvents <<
" events)" <<
Endl;
990 for (
Int_t ievt=firstEvt; ievt<lastEvt; ievt++) {
991 Data()->SetCurrentEvent(ievt);
997 if (modulo <= 0 ) modulo = 1;
1003 <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
1016 auto result =
GetMvaValues(firstEvt, lastEvt, logProgress);
1026 Data()->SetCurrentType(type);
1039 mvaProb->
Resize( nEvents );
1041 if (modulo <= 0 ) modulo = 1;
1042 for (
Int_t ievt=0; ievt<nEvents; ievt++) {
1044 Data()->SetCurrentEvent(ievt);
1046 if (proba < 0)
break;
1054 <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
1073 Data()->SetCurrentType(type);
1075 bias = 0; biasT = 0; dev = 0; devT = 0; rms = 0; rmsT = 0;
1077 Double_t m1 = 0, m2 = 0,
s1 = 0, s2 = 0, s12 = 0;
1083 Log() << kINFO <<
"Calculate regression for all events" <<
Endl;
1087 int ntargets =
Data()->GetEvent(0)->GetNTargets();
1088 for (
Long64_t ievt=0; ievt<nevt; ievt++) {
1089 const Event* ev =
Data()->GetEvent(ievt);
1111 m1 += t*w;
s1 += t*t*w;
1112 m2 +=
r*w; s2 +=
r*
r*w;
1115 if (ievt % modulo == 0)
1119 Log() << kINFO <<
"Elapsed time for evaluation of " << nevt <<
" events: "
1131 corr = s12/sumw - m1*m2;
1132 corr /=
TMath::Sqrt( (
s1/sumw - m1*m1) * (s2/sumw - m2*m2) );
1142 for (
Long64_t ievt=0; ievt<nevt; ievt++) {
1144 hist->
Fill( rV[ievt], tV[ievt], wV[ievt] );
1145 if (
d >= devMin &&
d <= devMax) {
1147 biasT += wV[ievt] *
d;
1149 rmsT += wV[ievt] *
d *
d;
1150 histT->
Fill( rV[ievt], tV[ievt], wV[ievt] );
1167 Data()->SetCurrentType(savedType);
1177 if (!resMulticlass)
Log() << kFATAL<<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"unable to create pointer in TestMulticlass, exiting."<<
Endl;
1187 TString histNamePrefixTest{histNamePrefix +
"_Test"};
1188 TString histNamePrefixTrain{histNamePrefix +
"_Train"};
1213 <<
" not found in tree" <<
Endl;
1243 mvaRes->
Store(mva_s,
"MVA_S");
1244 mvaRes->
Store(mva_b,
"MVA_B");
1254 proba_s =
new TH1D( TestvarName +
"_Proba_S", TestvarName +
"_Proba_S",
fNbinsMVAoutput, 0.0, 1.0 );
1255 proba_b =
new TH1D( TestvarName +
"_Proba_B", TestvarName +
"_Proba_B",
fNbinsMVAoutput, 0.0, 1.0 );
1256 mvaRes->
Store(proba_s,
"Prob_S");
1257 mvaRes->
Store(proba_b,
"Prob_B");
1262 rarity_s =
new TH1D( TestvarName +
"_Rarity_S", TestvarName +
"_Rarity_S",
fNbinsMVAoutput, 0.0, 1.0 );
1263 rarity_b =
new TH1D( TestvarName +
"_Rarity_B", TestvarName +
"_Rarity_B",
fNbinsMVAoutput, 0.0, 1.0 );
1264 mvaRes->
Store(rarity_s,
"Rar_S");
1265 mvaRes->
Store(rarity_b,
"Rar_B");
1271 TH1* mva_eff_s =
new TH1D( TestvarName +
"_S_high", TestvarName +
"_S_high",
fNbinsH,
fXmin, sxmax );
1272 TH1* mva_eff_b =
new TH1D( TestvarName +
"_B_high", TestvarName +
"_B_high",
fNbinsH,
fXmin, sxmax );
1273 mvaRes->
Store(mva_eff_s,
"MVA_HIGHBIN_S");
1274 mvaRes->
Store(mva_eff_b,
"MVA_HIGHBIN_B");
1283 Log() << kHEADER <<
Form(
"[%s] : ",
DataInfo().
GetName())<<
"Loop over test events and fill histograms with classifier response..." <<
Endl <<
Endl;
1284 if (mvaProb)
Log() << kINFO <<
"Also filling probability and rarity histograms (on request)..." <<
Endl;
1301 mva_s ->
Fill(
v, w );
1303 proba_s->
Fill( (*mvaProb)[ievt][0], w );
1307 mva_eff_s ->
Fill(
v, w );
1311 mva_b ->
Fill(
v, w );
1313 proba_b->
Fill( (*mvaProb)[ievt][0], w );
1316 mva_eff_b ->
Fill(
v, w );
1346 tf << prefix <<
"#GEN -*-*-*-*-*-*-*-*-*-*-*- general info -*-*-*-*-*-*-*-*-*-*-*-" << std::endl << prefix << std::endl;
1348 tf.setf(std::ios::left);
1353 tf << prefix <<
"Creator : " << userInfo->
fUser << std::endl;
1354 tf << prefix <<
"Date : ";
TDatime *
d =
new TDatime; tf <<
d->AsString() << std::endl;
delete d;
1355 tf << prefix <<
"Host : " <<
gSystem->GetBuildNode() << std::endl;
1356 tf << prefix <<
"Dir : " <<
gSystem->WorkingDirectory() << std::endl;
1357 tf << prefix <<
"Training events: " <<
Data()->GetNTrainingEvents() << std::endl;
1362 tf << prefix << std::endl;
1367 tf << prefix << std::endl << prefix <<
"#OPT -*-*-*-*-*-*-*-*-*-*-*-*- options -*-*-*-*-*-*-*-*-*-*-*-*-" << std::endl << prefix << std::endl;
1369 tf << prefix << std::endl;
1372 tf << prefix << std::endl << prefix <<
"#VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*-" << std::endl << prefix << std::endl;
1374 tf << prefix << std::endl;
1407 if (!parent)
return;
1483 <<
"Creating xml weight file: "
1504 <<
"Reading weight file: "
1510 Log() << kFATAL <<
"Error parsing XML file " << tfname <<
Endl;
1518 fb.open(tfname.
Data(),std::ios::in);
1519 if (!fb.is_open()) {
1521 <<
"Unable to open input weight file: " << tfname <<
Endl;
1523 std::istream fin(&fb);
1572 if (nodeName==
"GeneralInfo") {
1577 while (antypeNode) {
1580 if (
name ==
"TrainingTime")
1583 if (
name ==
"AnalysisType") {
1592 if (
name ==
"TMVA Release" ||
name ==
"TMVA") {
1599 if (
name ==
"ROOT Release" ||
name ==
"ROOT") {
1609 else if (nodeName==
"Options") {
1614 else if (nodeName==
"Variables") {
1617 else if (nodeName==
"Spectators") {
1620 else if (nodeName==
"Classes") {
1623 else if (nodeName==
"Targets") {
1626 else if (nodeName==
"Transformations") {
1629 else if (nodeName==
"MVAPdfs") {
1644 else if (nodeName==
"Weights") {
1675 methodType = methodType(methodType.
Last(
' '),methodType.
Length());
1680 if (methodName ==
"") methodName = methodType;
1705 fin.getline(buf,512);
1706 while (!
TString(buf).BeginsWith(
"#VAR")) fin.getline(buf,512);
1738 fin.getline(buf,512);
1739 while (!
TString(buf).BeginsWith(
"#MAT")) fin.getline(buf,512);
1742 varTrafo->ReadTransformationFromStream(fin, trafo );
1753 fin.getline(buf,512);
1754 while (!
TString(buf).BeginsWith(
"#MVAPDFS")) fin.getline(buf,512);
1767 fin.getline(buf,512);
1768 while (!
TString(buf).BeginsWith(
"#WGT")) fin.getline(buf,512);
1769 fin.getline(buf,512);
1783 o << prefix <<
"NVar " <<
DataInfo().GetNVariables() << std::endl;
1784 std::vector<VariableInfo>::const_iterator varIt =
DataInfo().GetVariableInfos().begin();
1785 for (; varIt!=
DataInfo().GetVariableInfos().end(); ++varIt) { o << prefix; varIt->WriteToStream(o); }
1786 o << prefix <<
"NSpec " <<
DataInfo().GetNSpectators() << std::endl;
1787 varIt =
DataInfo().GetSpectatorInfos().begin();
1788 for (; varIt!=
DataInfo().GetSpectatorInfos().end(); ++varIt) { o << prefix; varIt->WriteToStream(o); }
1800 istr >> dummy >> readNVar;
1804 <<
" while there are " << readNVar <<
" variables declared in the file"
1810 std::vector<VariableInfo>::iterator varIt =
DataInfo().GetVariableInfos().begin();
1812 for (; varIt!=
DataInfo().GetVariableInfos().end(); ++varIt, ++varIdx) {
1820 Log() << kINFO <<
"The definition (or the order) of the variables found in the input file is" <<
Endl;
1821 Log() << kINFO <<
"is not the same as the one declared in the Reader (which is necessary for" <<
Endl;
1822 Log() << kINFO <<
"the correct working of the method):" <<
Endl;
1823 Log() << kINFO <<
" var #" << varIdx <<
" declared in Reader: " << varIt->GetExpression() <<
Endl;
1824 Log() << kINFO <<
" var #" << varIdx <<
" declared in file : " << varInfo.
GetExpression() <<
Endl;
1825 Log() << kFATAL <<
"The expression declared to the Reader needs to be checked (name or order are wrong)" <<
Endl;
1838 for (
UInt_t idx=0; idx<
DataInfo().GetVariableInfos().size(); idx++) {
1854 for (
UInt_t idx=0; idx<
DataInfo().GetSpectatorInfos().size(); idx++) {
1879 for (
UInt_t iCls=0; iCls<nClasses; ++iCls) {
1897 for (
UInt_t idx=0; idx<
DataInfo().GetTargetInfos().size(); idx++) {
1915 <<
" while there are " << readNVar <<
" variables declared in the file"
1925 existingVarInfo =
DataInfo().GetVariableInfos()[varIdx];
1930 existingVarInfo = readVarInfo;
1934 Log() << kINFO <<
"The definition (or the order) of the variables found in the input file is" <<
Endl;
1935 Log() << kINFO <<
"not the same as the one declared in the Reader (which is necessary for the" <<
Endl;
1936 Log() << kINFO <<
"correct working of the method):" <<
Endl;
1937 Log() << kINFO <<
" var #" << varIdx <<
" declared in Reader: " << existingVarInfo.
GetExpression() <<
Endl;
1938 Log() << kINFO <<
" var #" << varIdx <<
" declared in file : " << readVarInfo.
GetExpression() <<
Endl;
1939 Log() << kFATAL <<
"The expression declared to the Reader needs to be checked (name or order are wrong)" <<
Endl;
1955 <<
" while there are " << readNSpec <<
" spectators declared in the file"
1965 existingSpecInfo =
DataInfo().GetSpectatorInfos()[specIdx];
1970 existingSpecInfo = readSpecInfo;
1974 Log() << kINFO <<
"The definition (or the order) of the spectators found in the input file is" <<
Endl;
1975 Log() << kINFO <<
"not the same as the one declared in the Reader (which is necessary for the" <<
Endl;
1976 Log() << kINFO <<
"correct working of the method):" <<
Endl;
1977 Log() << kINFO <<
" spec #" << specIdx <<
" declared in Reader: " << existingSpecInfo.
GetExpression() <<
Endl;
1978 Log() << kINFO <<
" spec #" << specIdx <<
" declared in file : " << readSpecInfo.
GetExpression() <<
Endl;
1979 Log() << kFATAL <<
"The expression declared to the Reader needs to be checked (name or order are wrong)" <<
Endl;
1998 for (
UInt_t icls = 0; icls<readNCls;++icls) {
2015 if (
DataInfo().GetClassInfo(
"Signal") != 0) {
2020 if (
DataInfo().GetClassInfo(
"Background") != 0) {
2041 DataInfo().AddTarget(expression,
"",
"",0,0);
2058 <<
"MethodBase::BaseDir() - No directory exists when running a Method without output file. Enable the "
2059 "output when creating the factory"
2065 Log() << kFATAL <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"MethodBase::BaseDir() - MethodBaseDir() return a NULL pointer!" <<
Endl;
2072 sdir = methodDir->
mkdir(defaultDir);
2078 wfilePath.
Write(
"TrainingPath" );
2079 wfileName.
Write(
"WeightFileName" );
2097 const char *datasetName =
DataInfo().GetName();
2100 <<
" not set yet --> check if already there.." <<
Endl;
2103 if (!factoryBaseDir)
return nullptr;
2108 Log() << kFATAL <<
"Can not create dir " << datasetName;
2118 Log() << kDEBUG <<
Form(
"Dataset[%s] : ", datasetName) <<
" Base Directory for " <<
GetMethodName()
2119 <<
" does not exist yet--> created it" <<
Endl;
2122 Log() << kDEBUG <<
Form(
"Dataset[%s] : ", datasetName)
2123 <<
"Return from MethodBaseDir() after creating base directory " <<
Endl;
2157 if (wFileDir.
IsNull() )
return wFileName;
2159 return ( wFileDir + (wFileDir[wFileDir.
Length()-1]==
'/' ?
"" :
"/")
2172 fMVAPdfS->GetOriginalHist()->Write();
2173 fMVAPdfS->GetSmoothedHist()->Write();
2177 fMVAPdfB->GetOriginalHist()->Write();
2178 fMVAPdfB->GetSmoothedHist()->Write();
2185 Log() << kFATAL <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"<WriteEvaluationHistosToFile> Unknown result: "
2187 <<
"/kMaxAnalysisType" <<
Endl;
2195 <<
" variable plots are not produces ! The number of variables is " <<
DataInfo().GetNVariables()
2215 fin.getline(buf,512);
2217 if (
line.BeginsWith(
"TMVA Release")) {
2221 std::stringstream s(code.
Data());
2225 if (
line.BeginsWith(
"ROOT Release")) {
2229 std::stringstream s(code.
Data());
2233 if (
line.BeginsWith(
"Analysis type")) {
2237 std::stringstream s(code.
Data());
2238 std::string analysisType;
2243 else Log() << kFATAL <<
"Analysis type " << analysisType <<
" from weight-file not known!" << std::endl;
2265 if (mvaRes==0 || mvaRes->
GetSize()==0) {
2266 Log() << kERROR<<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"<CreateMVAPdfs> No result of classifier testing available" <<
Endl;
2280 histMVAPdfS->
Sumw2();
2281 histMVAPdfB->
Sumw2();
2286 Double_t theWeight =
Data()->GetEvent(ievt)->GetWeight();
2289 else histMVAPdfB->
Fill( theVal, theWeight );
2298 histMVAPdfS->
Write();
2299 histMVAPdfB->
Write();
2302 fMVAPdfS->BuildPDF ( histMVAPdfS );
2303 fMVAPdfB->BuildPDF ( histMVAPdfB );
2304 fMVAPdfS->ValidatePDF( histMVAPdfS );
2305 fMVAPdfB->ValidatePDF( histMVAPdfB );
2307 if (
DataInfo().GetNClasses() == 2) {
2309 <<
TString::Format(
"<CreateMVAPdfs> Separation from histogram (PDF): %1.3f (%1.3f)",
2323 Log() << kINFO<<
Form(
"Dataset[%s] : ",
DataInfo().
GetName()) <<
"<GetProba> MVA PDFs for Signal and Background don't exist yet, we'll create them on demand" <<
Endl;
2329 return GetProba(mvaVal,sigFraction);
2338 Log() << kWARNING <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"<GetProba> MVA PDFs for Signal and Background don't exist" <<
Endl;
2344 Double_t denom = p_s*ap_sig + p_b*(1 - ap_sig);
2346 return (denom > 0) ? (p_s*ap_sig) / denom : -1;
2359 Log() << kWARNING <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"<GetRarity> Required MVA PDF for Signal or Background does not exist: "
2360 <<
"select option \"CreateMVAPdfs\"" <<
Endl;
2375 Data()->SetCurrentType(type);
2384 if (!list || list->GetSize() < 2) computeArea =
kTRUE;
2385 else if (list->GetSize() > 2) {
2386 Log() << kFATAL <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"<GetEfficiency> Wrong number of arguments"
2387 <<
" in string: " << theString
2388 <<
" | required format, e.g., Efficiency:0.05, or empty string" <<
Endl;
2396 Log() << kFATAL <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"<GetEfficiency> Binning mismatch between signal and background histos" <<
Endl;
2404 TH1 * effhist = results->
GetHist(
"MVA_HIGHBIN_S");
2411 if (results->
DoesExist(
"MVA_EFF_S")==0) {
2416 results->
Store(eff_s,
"MVA_EFF_S");
2417 results->
Store(eff_b,
"MVA_EFF_B");
2424 for (
UInt_t ievt=0; ievt<
Data()->GetNEvents(); ievt++) {
2429 Float_t theVal = (*mvaRes)[ievt];
2432 TH1* theHist = isSignal ? eff_s : eff_b;
2435 if (isSignal) nevtS+=theWeight;
2439 if (sign > 0 && maxbin >
fNbinsH)
continue;
2440 if (sign < 0 && maxbin < 1 )
continue;
2441 if (sign > 0 && maxbin < 1 ) maxbin = 1;
2461 results->
Store(eff_BvsS,
"MVA_EFF_BvsS");
2467 results->
Store(rej_BvsS);
2469 rej_BvsS->
SetYTitle(
"Backgr rejection (1-eff)" );
2474 results->
Store(inveff_BvsS);
2476 inveff_BvsS->
SetYTitle(
"Inverse backgr. eff (1/eff)" );
2510 if (effB>std::numeric_limits<double>::epsilon())
2519 Double_t effS = 0., rejB, effS_ = 0., rejB_ = 0.;
2520 Int_t nbins_ = 5000;
2521 for (
Int_t bini=1; bini<=nbins_; bini++) {
2524 effS = (bini - 0.5)/
Float_t(nbins_);
2528 if ((effS - rejB)*(effS_ - rejB_) < 0)
break;
2546 Double_t effS = 0, effB = 0, effS_ = 0, effB_ = 0;
2547 Int_t nbins_ = 1000;
2553 for (
Int_t bini=1; bini<=nbins_; bini++) {
2556 effS = (bini - 0.5)/
Float_t(nbins_);
2558 integral += (1.0 - effB);
2572 for (
Int_t bini=1; bini<=nbins_; bini++) {
2575 effS = (bini - 0.5)/
Float_t(nbins_);
2579 if ((effB - effBref)*(effB_ - effBref) <= 0)
break;
2585 effS = 0.5*(effS + effS_);
2588 if (nevtS > 0) effSerr =
TMath::Sqrt( effS*(1.0 - effS)/nevtS );
2612 if (list->GetSize() != 2) {
2613 Log() << kFATAL <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"<GetTrainingEfficiency> Wrong number of arguments"
2614 <<
" in string: " << theString
2615 <<
" | required format, e.g., Efficiency:0.05" <<
Endl;
2628 Log() << kFATAL <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"<GetTrainingEfficiency> Binning mismatch between signal and background histos"
2636 TH1 * effhist = results->
GetHist(
"MVA_HIGHBIN_S");
2641 if (results->
DoesExist(
"MVA_TRAIN_S")==0) {
2649 results->
Store(mva_s_tr,
"MVA_TRAIN_S");
2650 results->
Store(mva_b_tr,
"MVA_TRAIN_B");
2659 results->
Store(mva_eff_tr_s,
"MVA_TRAINEFF_S");
2660 results->
Store(mva_eff_tr_b,
"MVA_TRAINEFF_B");
2669 for (
Int_t ievt=0; ievt<
Data()->GetNEvents(); ievt++) {
2671 Data()->SetCurrentEvent(ievt);
2677 TH1* theEffHist =
DataInfo().IsSignal(ev) ? mva_eff_tr_s : mva_eff_tr_b;
2678 TH1* theClsHist =
DataInfo().IsSignal(ev) ? mva_s_tr : mva_b_tr;
2680 theClsHist->
Fill( theVal, theWeight );
2684 if (sign > 0 && maxbin >
fNbinsH)
continue;
2685 if (sign < 0 && maxbin < 1 )
continue;
2686 if (sign > 0 && maxbin < 1 ) maxbin = 1;
2689 if (sign > 0)
for (
Int_t ibin=1; ibin<=maxbin; ibin++) theEffHist->
AddBinContent( ibin , theWeight );
2706 results->
Store(eff_bvss,
"EFF_BVSS_TR");
2707 results->
Store(rej_bvss,
"REJ_BVSS_TR");
2755 Double_t effS = 0., effB, effS_ = 0., effB_ = 0.;
2756 Int_t nbins_ = 1000;
2757 for (
Int_t bini=1; bini<=nbins_; bini++) {
2760 effS = (bini - 0.5)/
Float_t(nbins_);
2764 if ((effB - effBref)*(effB_ - effBref) <= 0)
break;
2769 return 0.5*(effS + effS_);
2778 if (!resMulticlass)
Log() << kFATAL<<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"unable to create pointer in GetMulticlassEfficiency, exiting."<<
Endl;
2790 if (!resMulticlass)
Log() << kFATAL<<
"unable to create pointer in GetMulticlassTrainingEfficiency, exiting."<<
Endl;
2792 Log() << kINFO <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"Determine optimal multiclass cuts for training data..." <<
Endl;
2824 Log() << kFATAL <<
"Cannot get confusion matrix for non-multiclass analysis." << std::endl;
2828 Data()->SetCurrentType(type);
2832 if (resMulticlass ==
nullptr) {
2834 <<
"unable to create pointer in GetMulticlassEfficiency, exiting." <<
Endl;
2875 if ((!pdfS && pdfB) || (pdfS && !pdfB))
2877 if (!pdfS) pdfS =
fSplS;
2878 if (!pdfB) pdfB =
fSplB;
2881 Log()<<kDEBUG<<
Form(
"[%s] : ",
DataInfo().
GetName())<<
"could not calculate the separation, distributions"
2882 <<
" fSplS or fSplB are not yet filled" <<
Endl;
2897 if ((!histS && histB) || (histS && !histB))
2900 if (histS==0 || histB==0)
return 0.;
2913 for (
UInt_t i=0; i<nsteps; i++) {
2919 return integral*step;
2931 if ((!pdfS && pdfB) || (pdfS && !pdfB))
2933 if (!pdfS) pdfS =
fSplS;
2934 if (!pdfB) pdfB =
fSplB;
2936 if (pdfS==0 || pdfB==0)
return 0.;
2945 for (
UInt_t i=0; i<nsteps; i++) {
2949 return integral*step;
2959 Double_t& max_significance_value )
const
2964 Double_t effS(0),effB(0),significance(0);
2967 if (SignalEvents <= 0 || BackgroundEvents <= 0) {
2969 <<
"Number of signal or background events is <= 0 ==> abort"
2973 Log() << kINFO <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"Using ratio SignalEvents/BackgroundEvents = "
2974 << SignalEvents/BackgroundEvents <<
Endl;
2979 if ( (eff_s==0) || (eff_b==0) ) {
2990 significance = sqrt(SignalEvents)*( effS )/sqrt( effS + ( BackgroundEvents / SignalEvents) * effB );
3000 delete temp_histogram;
3005 return max_significance;
3019 Data()->SetCurrentType(treeType);
3025 Log() << kFATAL <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"<CalculateEstimator> Wrong tree type: " << treeType <<
Endl;
3042 for (
Int_t ievt = 0; ievt < entries; ievt++) {
3051 meanS += weight*theVar;
3052 rmsS += weight*theVar*theVar;
3056 meanB += weight*theVar;
3057 rmsB += weight*theVar*theVar;
3063 meanS = meanS/sumwS;
3064 meanB = meanB/sumwB;
3068 Data()->SetCurrentType(previousTreeType);
3078 if (theClassFileName ==
"")
3081 classFileName = theClassFileName;
3085 TString tfname( classFileName );
3087 <<
"Creating standalone class: "
3090 std::ofstream fout( classFileName );
3092 Log() << kFATAL <<
"<MakeClass> Unable to open file: " << classFileName <<
Endl;
3097 fout <<
"// Class: " << className << std::endl;
3098 fout <<
"// Automatically generated by MethodBase::MakeClass" << std::endl <<
"//" << std::endl;
3102 fout <<
"/* configuration options =====================================================" << std::endl << std::endl;
3105 fout <<
"============================================================================ */" << std::endl;
3108 fout <<
"" << std::endl;
3109 fout <<
"#include <array>" << std::endl;
3110 fout <<
"#include <vector>" << std::endl;
3111 fout <<
"#include <cmath>" << std::endl;
3112 fout <<
"#include <string>" << std::endl;
3113 fout <<
"#include <iostream>" << std::endl;
3114 fout <<
"" << std::endl;
3119 fout <<
"#ifndef IClassifierReader__def" << std::endl;
3120 fout <<
"#define IClassifierReader__def" << std::endl;
3122 fout <<
"class IClassifierReader {" << std::endl;
3124 fout <<
" public:" << std::endl;
3126 fout <<
" // constructor" << std::endl;
3127 fout <<
" IClassifierReader() : fStatusIsClean( true ) {}" << std::endl;
3128 fout <<
" virtual ~IClassifierReader() {}" << std::endl;
3130 fout <<
" // return classifier response" << std::endl;
3132 fout <<
" virtual std::vector<double> GetMulticlassValues( const std::vector<double>& inputValues ) const = 0;" << std::endl;
3134 fout <<
" virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0;" << std::endl;
3137 fout <<
" // returns classifier status" << std::endl;
3138 fout <<
" bool IsStatusClean() const { return fStatusIsClean; }" << std::endl;
3140 fout <<
" protected:" << std::endl;
3142 fout <<
" bool fStatusIsClean;" << std::endl;
3143 fout <<
"};" << std::endl;
3145 fout <<
"#endif" << std::endl;
3147 fout <<
"class " << className <<
" : public IClassifierReader {" << std::endl;
3149 fout <<
" public:" << std::endl;
3151 fout <<
" // constructor" << std::endl;
3152 fout <<
" " << className <<
"( std::vector<std::string>& theInputVars )" << std::endl;
3153 fout <<
" : IClassifierReader()," << std::endl;
3154 fout <<
" fClassName( \"" << className <<
"\" )," << std::endl;
3155 fout <<
" fNvars( " <<
GetNvar() <<
" )" << std::endl;
3156 fout <<
" {" << std::endl;
3157 fout <<
" // the training input variables" << std::endl;
3158 fout <<
" const char* inputVars[] = { ";
3161 if (ivar<
GetNvar()-1) fout <<
", ";
3163 fout <<
" };" << std::endl;
3165 fout <<
" // sanity checks" << std::endl;
3166 fout <<
" if (theInputVars.size() <= 0) {" << std::endl;
3167 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": empty input vector\" << std::endl;" << std::endl;
3168 fout <<
" fStatusIsClean = false;" << std::endl;
3169 fout <<
" }" << std::endl;
3171 fout <<
" if (theInputVars.size() != fNvars) {" << std::endl;
3172 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": mismatch in number of input values: \"" << std::endl;
3173 fout <<
" << theInputVars.size() << \" != \" << fNvars << std::endl;" << std::endl;
3174 fout <<
" fStatusIsClean = false;" << std::endl;
3175 fout <<
" }" << std::endl;
3177 fout <<
" // validate input variables" << std::endl;
3178 fout <<
" for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) {" << std::endl;
3179 fout <<
" if (theInputVars[ivar] != inputVars[ivar]) {" << std::endl;
3180 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": mismatch in input variable names\" << std::endl" << std::endl;
3181 fout <<
" << \" for variable [\" << ivar << \"]: \" << theInputVars[ivar].c_str() << \" != \" << inputVars[ivar] << std::endl;" << std::endl;
3182 fout <<
" fStatusIsClean = false;" << std::endl;
3183 fout <<
" }" << std::endl;
3184 fout <<
" }" << std::endl;
3186 fout <<
" // initialize min and max vectors (for normalisation)" << std::endl;
3188 fout <<
" fVmin[" << ivar <<
"] = " << std::setprecision(15) <<
GetXmin( ivar ) <<
";" << std::endl;
3189 fout <<
" fVmax[" << ivar <<
"] = " << std::setprecision(15) <<
GetXmax( ivar ) <<
";" << std::endl;
3192 fout <<
" // initialize input variable types" << std::endl;
3194 fout <<
" fType[" << ivar <<
"] = \'" <<
DataInfo().GetVariableInfo(ivar).GetVarType() <<
"\';" << std::endl;
3197 fout <<
" // initialize constants" << std::endl;
3198 fout <<
" Initialize();" << std::endl;
3201 fout <<
" // initialize transformation" << std::endl;
3202 fout <<
" InitTransform();" << std::endl;
3204 fout <<
" }" << std::endl;
3206 fout <<
" // destructor" << std::endl;
3207 fout <<
" virtual ~" << className <<
"() {" << std::endl;
3208 fout <<
" Clear(); // method-specific" << std::endl;
3209 fout <<
" }" << std::endl;
3211 fout <<
" // the classifier response" << std::endl;
3212 fout <<
" // \"inputValues\" is a vector of input values in the same order as the" << std::endl;
3213 fout <<
" // variables given to the constructor" << std::endl;
3215 fout <<
" std::vector<double> GetMulticlassValues( const std::vector<double>& inputValues ) const override;" << std::endl;
3217 fout <<
" double GetMvaValue( const std::vector<double>& inputValues ) const override;" << std::endl;
3220 fout <<
" private:" << std::endl;
3222 fout <<
" // method-specific destructor" << std::endl;
3223 fout <<
" void Clear();" << std::endl;
3226 fout <<
" // input variable transformation" << std::endl;
3228 fout <<
" void InitTransform();" << std::endl;
3229 fout <<
" void Transform( std::vector<double> & iv, int sigOrBgd ) const;" << std::endl;
3232 fout <<
" // common member variables" << std::endl;
3233 fout <<
" const char* fClassName;" << std::endl;
3235 fout <<
" const size_t fNvars;" << std::endl;
3236 fout <<
" size_t GetNvar() const { return fNvars; }" << std::endl;
3237 fout <<
" char GetType( int ivar ) const { return fType[ivar]; }" << std::endl;
3239 fout <<
" // normalisation of input variables" << std::endl;
3240 fout <<
" double fVmin[" <<
GetNvar() <<
"];" << std::endl;
3241 fout <<
" double fVmax[" <<
GetNvar() <<
"];" << std::endl;
3242 fout <<
" double NormVariable( double x, double xmin, double xmax ) const {" << std::endl;
3243 fout <<
" // normalise to output range: [-1, 1]" << std::endl;
3244 fout <<
" return 2*(x - xmin)/(xmax - xmin) - 1.0;" << std::endl;
3245 fout <<
" }" << std::endl;
3247 fout <<
" // type of input variable: 'F' or 'I'" << std::endl;
3248 fout <<
" char fType[" <<
GetNvar() <<
"];" << std::endl;
3250 fout <<
" // initialize internal variables" << std::endl;
3251 fout <<
" void Initialize();" << std::endl;
3253 fout <<
" std::vector<double> GetMulticlassValues__( const std::vector<double>& inputValues ) const;" << std::endl;
3255 fout <<
" double GetMvaValue__( const std::vector<double>& inputValues ) const;" << std::endl;
3257 fout <<
"" << std::endl;
3258 fout <<
" // private members (method specific)" << std::endl;
3264 fout <<
"inline std::vector<double> " << className <<
"::GetMulticlassValues( const std::vector<double>& inputValues ) const" << std::endl;
3266 fout <<
"inline double " << className <<
"::GetMvaValue( const std::vector<double>& inputValues ) const" << std::endl;
3268 fout <<
"{" << std::endl;
3269 fout <<
" // classifier response value" << std::endl;
3271 fout <<
" std::vector<double> retval;" << std::endl;
3273 fout <<
" double retval = 0;" << std::endl;
3276 fout <<
" // classifier response, sanity check first" << std::endl;
3277 fout <<
" if (!IsStatusClean()) {" << std::endl;
3278 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": cannot return classifier response\"" << std::endl;
3279 fout <<
" << \" because status is dirty\" << std::endl;" << std::endl;
3280 fout <<
" }" << std::endl;
3281 fout <<
" else {" << std::endl;
3283 fout <<
" // normalise variables" << std::endl;
3284 fout <<
" std::vector<double> iV;" << std::endl;
3285 fout <<
" iV.reserve(inputValues.size());" << std::endl;
3286 fout <<
" int ivar = 0;" << std::endl;
3287 fout <<
" for (std::vector<double>::const_iterator varIt = inputValues.begin();" << std::endl;
3288 fout <<
" varIt != inputValues.end(); varIt++, ivar++) {" << std::endl;
3289 fout <<
" iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));" << std::endl;
3290 fout <<
" }" << std::endl;
3293 fout <<
" Transform( iV, -1 );" << std::endl;
3297 fout <<
" retval = GetMulticlassValues__( iV );" << std::endl;
3299 fout <<
" retval = GetMvaValue__( iV );" << std::endl;
3304 fout <<
" std::vector<double> iV(inputValues);" << std::endl;
3305 fout <<
" Transform( iV, -1 );" << std::endl;
3307 fout <<
" retval = GetMulticlassValues__( iV );" << std::endl;
3309 fout <<
" retval = GetMvaValue__( iV );" << std::endl;
3313 fout <<
" retval = GetMulticlassValues__( inputValues );" << std::endl;
3315 fout <<
" retval = GetMvaValue__( inputValues );" << std::endl;
3319 fout <<
" }" << std::endl;
3321 fout <<
" return retval;" << std::endl;
3322 fout <<
"}" << std::endl;
3338 std::streambuf* cout_sbuf = std::cout.rdbuf();
3339 std::ofstream* o = 0;
3340 if (
gConfig().WriteOptionsReference()) {
3346 std::cout.rdbuf( o->rdbuf() );
3353 <<
"================================================================"
3357 <<
"H e l p f o r M V A m e t h o d [ " <<
GetName() <<
" ] :"
3362 Log() <<
"Help for MVA method [ " <<
GetName() <<
" ] :" <<
Endl;
3370 Log() <<
"<Suppress this message by specifying \"!H\" in the booking option>" <<
Endl;
3372 <<
"================================================================"
3379 Log() <<
"# End of Message___" <<
Endl;
3382 std::cout.rdbuf( cout_sbuf );
3399 else retval =
fEffS->GetBinContent(
fEffS->FindBin( theCut ) );
3467 if (mvaRes != NULL) {
3470 TH1D *mva_s_tr =
dynamic_cast<TH1D*
> (mvaRes->
GetHist(
"MVA_TRAIN_S"));
3471 TH1D *mva_b_tr =
dynamic_cast<TH1D*
> (mvaRes->
GetHist(
"MVA_TRAIN_B"));
3473 if ( !mva_s || !mva_b || !mva_s_tr || !mva_b_tr)
return -1;
3475 if (SorB ==
's' || SorB ==
'S')
const Bool_t Use_Splines_for_Eff_
const Int_t NBIN_HIST_HIGH
#define ROOT_VERSION_CODE
int Int_t
Signed integer 4 bytes (int).
int Ssiz_t
String size (currently int).
char Char_t
Character 1 byte (char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
float Float_t
Float 4 bytes (float).
TMatrixT< Double_t > TMatrixD
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
#define TMVA_VERSION_CODE
Class to manage histogram axis.
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) override
Write all objects in this collection.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
const char * AsString() const
Return the date & time as a string (ctime() format).
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
virtual Bool_t cd()
Change current directory to "this" directory.
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void Close(Option_t *option="") override
Close a file.
1-D histogram with a double per channel (see TH1 documentation)
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
virtual Double_t GetMean(Int_t axis=1) const
For axis = 1,2 or 3 returns the mean value of the histogram along X,Y or Z axis.
virtual void SetXTitle(const char *title)
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
virtual Int_t GetNbinsX() const
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual Int_t GetMaximumBin() const
Return location of bin with maximum value in the range.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void SetYTitle(const char *title)
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
Return Global bin number corresponding to x,y,z.
virtual void AddBinContent(Int_t bin)=0
Increment bin content by 1.
virtual Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const
Statistical test of compatibility in shape between this histogram and h2, using Kolmogorov test.
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
2-D histogram with a float per channel (see TH1 documentation)
Int_t Fill(Double_t) override
Invalid Fill method.
Class that contains all the information of a class.
TString fWeightFileExtension
Int_t fMaxNumOfAllowedVariables
VariablePlotting & GetVariablePlotting()
class TMVA::Config::VariablePlotting fVariablePlotting
void SetConfigDescription(const char *d)
const TString & GetReferenceFile() const
void ReadOptionsFromXML(void *node)
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
void AddPreDefVal(const T &)
void SetConfigName(const char *n)
void WriteOptionsToStream(std::ostream &o, const TString &prefix) const
write options to output stream (e.g. in writing the MVA weight files
Configurable(const TString &theOption="")
constructor
virtual void ParseOptions()
options parser
const TString & GetOptions() const
MsgLogger * fLogger
! message logger
void CheckForUnusedOptions() const
checks for unused options in option string
void ReadOptionsFromStream(std::istream &istr)
read option back from the weight file
void AddOptionsXMLTo(void *parent) const
write options to XML file
void SetOptions(const TString &s)
Class that contains all the data information.
Class that contains all the data information.
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
Double_t GetWeight() const
return the event weight - depending on whether the flag IgnoreNegWeightsInTraining is or not.
static void SetIsTraining(Bool_t)
when this static function is called, it sets the flag whether events with negative event weight shoul...
Float_t GetTarget(UInt_t itgt) const
static void SetIgnoreNegWeightsInTraining(Bool_t)
when this static function is called, it sets the flag whether events with negative event weight shoul...
virtual void GetHelpMessage() const =0
void Init(std::vector< TString > &graphTitles)
This function gets some title and it creates a TGraph for every title.
IPythonInteractive()
standard constructor
TMultiGraph * fMultiGraph
std::vector< TGraph * > fGraphs
~IPythonInteractive()
standard destructor
void ClearGraphs()
This function sets the point number to 0 for all graphs.
void AddPoint(Double_t x, Double_t y1, Double_t y2)
This function is used only in 2 TGraph case, and it will add new data points to graphs.
Virtual base Class for all MVA method.
TransformationHandler * fTransformationPointer
pointer to the rest of transformations
void ProcessOptions() override=0
virtual void MakeClassSpecificHeader(std::ostream &, const TString &="") const
TString fVerbosityLevelString
verbosity level (user input string)
TDirectory * MethodBaseDir() const
returns the ROOT directory where all instances of the corresponding MVA method are stored
const std::vector< Float_t > & GetRegressionValues(const TMVA::Event *const ev)
PDF * fSplB
PDFs of MVA distribution (background).
Bool_t fVerbose
verbose flag
virtual Double_t GetKSTrainingVsTest(Char_t SorB, TString opt="X")
MethodBase(const TString &jobName, Types::EMVA methodType, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="")
standard constructor
void PrintHelpMessage() const override
prints out method-specific help method
virtual std::vector< Float_t > GetAllMulticlassValues()
Get all multi-class values.
virtual Double_t GetSeparation(TH1 *, TH1 *) const
compute "separation" defined as
TString fFileDir
unix sub-directory for weight files (default: DataLoader's Name + "weights")
DataSet * fTmpData
! temporary dataset used when evaluating on a different data (used by MethodCategory::GetMvaValues)
const char * GetName() const override
void ReadClassesFromXML(void *clsnode)
read number of classes from XML
void SetWeightFileDir(TString fileDir)
set directory of weight file
void WriteStateToXML(void *parent) const
general method used in writing the header of the weight files where the used variables,...
void DeclareBaseOptions()
define the options (their key words) that can be set in the option string here the options valid for ...
Double_t fRmsB
RMS (background).
Double_t GetXmin(Int_t ivar) const
virtual void TestRegression(Double_t &bias, Double_t &biasT, Double_t &dev, Double_t &devT, Double_t &rms, Double_t &rmsT, Double_t &mInf, Double_t &mInfT, Double_t &corr, Types::ETreeType type)
calculate <sum-of-deviation-squared> of regression output versus "true" value from test sample
virtual void DeclareCompatibilityOptions()
options that are used ONLY for the READER to ensure backward compatibility they are hence without any...
PDF * fSplTrainB
PDFs of training MVA distribution (background).
TString GetMethodTypeName() const
Bool_t DoMulticlass() const
virtual Double_t GetSignificance() const
compute significance of mean difference
virtual void ReadWeightsFromXML(void *wghtnode)=0
virtual Double_t GetProba(const Event *ev)
TH1 * fEffS
efficiency histogram for rootfinder
virtual const std::vector< Float_t > & GetMulticlassValues()
TSpline * fSplTrainEffBvsS
splines for training signal eff. versus background eff.
Types::EAnalysisType GetAnalysisType() const
virtual TMatrixD GetMulticlassConfusionMatrix(Double_t effB, Types::ETreeType type)
Construct a confusion matrix for a multiclass classifier.
UInt_t GetTrainingTMVAVersionCode() const
UInt_t fTMVATrainingVersion
Double_t fXmax
maximum (signal and background)
Double_t fMeanS
mean (signal)
Types::ESBType fVariableTransformType
PDF * fSplTrainS
PDFs of training MVA distribution (signal).
const TString & GetJobName() const
virtual void WriteEvaluationHistosToFile(Types::ETreeType treetype)
writes all MVA evaluation histograms to file
virtual void TestMulticlass()
test multiclass classification
const TString & GetTestvarName() const
const std::vector< TMVA::Event * > & GetEventCollection(Types::ETreeType type)
returns the event collection (i.e.
virtual std::vector< Double_t > GetDataMvaValues(DataSet *data=nullptr, Long64_t firstEvt=0, Long64_t lastEvt=-1, Bool_t logProgress=false)
get all the MVA values for the events of the given Data type
void SetupMethod()
setup of methods
TDirectory * BaseDir() const
returns the ROOT directory where info/histograms etc of the corresponding MVA method instance are sto...
virtual std::vector< Float_t > GetMulticlassEfficiency(std::vector< std::vector< Float_t > > &purity)
UInt_t GetNTargets() const
TransformationHandler fTransformation
the list of transformations
void AddInfoItem(void *gi, const TString &name, const TString &value) const
xml writing
TDirectory * fMethodBaseDir
virtual void AddClassifierOutputProb(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
PDF * fSplS
PDFs of MVA distribution (signal).
Double_t fSignalReferenceCutOrientation
virtual Double_t GetEfficiency(const TString &, Types::ETreeType, Double_t &err)
fill background efficiency (resp.
TString GetTrainingTMVAVersionString() const
calculates the TMVA version string from the training version code on the fly
TSpline * fSpleffBvsS
splines for signal eff. versus background eff.
TString fVariableTransformTypeString
const TString & GetWeightFileDir() const
virtual void SetAnalysisType(Types::EAnalysisType type)
const TString & GetMethodName() const
void Statistics(Types::ETreeType treeType, const TString &theVarName, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &)
calculates rms,mean, xmin, xmax of the event variable this can be either done for the variables as th...
UInt_t GetNEvents() const
Bool_t DoRegression() const
std::vector< Float_t > * fRegressionReturnVal
std::vector< Float_t > * fMulticlassReturnVal
Double_t fRmsS
RMS (signal).
Bool_t GetLine(std::istream &fin, char *buf)
reads one line from the input stream checks for certain keywords and interprets the line if keywords ...
const Event * GetEvent() const
TString fVarTransformString
labels variable transform method
void ProcessSetup()
process all options the "CheckForUnusedOptions" is done in an independent call, since it may be overr...
virtual std::vector< Double_t > GetMvaValues(Long64_t firstEvt=0, Long64_t lastEvt=-1, Bool_t logProgress=false)
get all the MVA values for the events of the current Data type
virtual Bool_t IsSignalLike()
uses a pre-set cut on the MVA output (SetSignalReferenceCut and SetSignalReferenceCutOrientation) for...
virtual ~MethodBase()
destructor
Bool_t HasMVAPdfs() const
PDF * fMVAPdfS
signal MVA PDF
void WriteMonitoringHistosToFile() const override
write special monitoring histograms to file dummy implementation here --------------—
virtual Double_t GetMaximumSignificance(Double_t SignalEvents, Double_t BackgroundEvents, Double_t &optimal_significance_value) const
plot significance, , curve for given number of signal and background events; returns cut for maximum ...
virtual Double_t GetTrainingEfficiency(const TString &)
void SetWeightFileName(TString)
set the weight file name (depreciated)
DataSetInfo & DataInfo() const
TString GetWeightFileName() const
retrieve weight file name
void SetTestTime(Double_t testTime)
virtual void TestClassification()
initialization
void AddOutput(Types::ETreeType type, Types::EAnalysisType analysisType)
UInt_t GetNVariables() const
Types::EAnalysisType fAnalysisType
virtual void AddRegressionOutput(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
void InitBase()
default initialization called by all constructors
std::vector< const std::vector< TMVA::Event * > * > fEventCollections
virtual void GetRegressionDeviation(UInt_t tgtNum, Types::ETreeType type, Double_t &stddev, Double_t &stddev90Percent) const
void ReadStateFromXMLString(const char *xmlstr)
for reading from memory
void MakeClass(const TString &classFileName=TString("")) const override
create reader class for method (classification only at present)
void CreateMVAPdfs()
Create PDFs of the MVA output variables.
TString GetTrainingROOTVersionString() const
calculates the ROOT version string from the training version code on the fly
virtual Double_t GetValueForRoot(Double_t)
returns efficiency as function of cut
UInt_t GetTrainingROOTVersionCode() const
void ReadStateFromFile()
Function to write options and weights to file.
void WriteVarsToStream(std::ostream &tf, const TString &prefix="") const
write the list of variables (name, min, max) for a given data transformation method to the stream
void ReadVarsFromStream(std::istream &istr)
Read the variables (name, min, max) for a given data transformation method from the stream.
virtual void AddWeightsXMLTo(void *parent) const =0
void ReadSpectatorsFromXML(void *specnode)
read spectator info from XML
const Event * fTmpEvent
! temporary event when testing on a different DataSet than the own one
void SetTestvarName(const TString &v="")
void ReadVariablesFromXML(void *varnode)
read variable info from XML
Bool_t fConstructedFromWeightFile
virtual std::map< TString, Double_t > OptimizeTuningParameters(TString fomType="ROCIntegral", TString fitType="FitGA")
call the Optimizer with the set of parameters and ranges that are meant to be tuned.
void SetTrainTime(Double_t trainTime)
Double_t GetXmax(Int_t ivar) const
virtual std::vector< Float_t > GetMulticlassTrainingEfficiency(std::vector< std::vector< Float_t > > &purity)
DataSetInfo & fDataSetInfo
! the data set information (sometimes needed)
Bool_t fHasMVAPdfs
MVA Pdfs are created for this classifier.
void WriteStateToStream(std::ostream &tf) const
general method used in writing the header of the weight files where the used variables,...
virtual Double_t GetRarity(Double_t mvaVal, Types::ESBType reftype=Types::kBackground) const
compute rarity:
virtual void SetTuneParameters(std::map< TString, Double_t > tuneParameters)
set the tuning parameters according to the argument This is just a dummy .
Double_t GetTrainTime() const
void ReadStateFromStream(std::istream &tf)
read the header from the weight files of the different MVA methods
void AddVarsXMLTo(void *parent) const
write variable info to XML
TransformationHandler & GetTransformationHandler(Bool_t takeReroutedIfAvailable=true)
Double_t GetMvaValue(Double_t *errLower=nullptr, Double_t *errUpper=nullptr) override=0
Bool_t IsSilentFile() const
Types::EMVA GetMethodType() const
void AddTargetsXMLTo(void *parent) const
write target info to XML
void MakeClassSpecific(std::ostream &, const TString &="") const override
Double_t fXmin
minimum (signal and background)
PDF * fDefaultPDF
default PDF definitions
void ReadTargetsFromXML(void *tarnode)
read target info from XML
void ProcessBaseOptions()
the option string is decoded, for available options see "DeclareOptions"
UInt_t fROOTTrainingVersion
void ReadWeightsFromStream(std::istream &) override=0
void ReadStateFromXML(void *parent)
Double_t GetSignalReferenceCutOrientation() const
void SetSignalReferenceCut(Double_t cut)
virtual std::vector< Float_t > GetAllRegressionValues()
Get al regression values in one call.
std::vector< TString > * fInputVars
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
Double_t fSignalReferenceCut
Double_t fMeanB
mean (background)
Bool_t fIgnoreNegWeightsInTraining
If true, events with negative weights are not used in training.
void WriteStateToFile() const
write options and weights to file note that each one text file for the main configuration information...
void DeclareOptions() override=0
void AddClassesXMLTo(void *parent) const
write class info to XML
ECutOrientation GetCutOrientation() const
virtual void AddClassifierOutput(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
PDF * fMVAPdfB
background MVA PDF
void AddSpectatorsXMLTo(void *parent) const
write spectator info to XML
TString fWeightFile
weight file name
Bool_t IsNormalised() const
Double_t GetSignalReferenceCut() const
virtual Double_t GetROCIntegral(TH1D *histS, TH1D *histB) const
calculate the area (integral) under the ROC curve as a overall quality measure of the classification
ECutOrientation fCutOrientation
const TString & GetOriginalVarName(Int_t ivar) const
virtual void AddMulticlassOutput(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
virtual void CheckSetup()
check may be overridden by derived class (sometimes, eg, fitters are used which can only be implement...
PDF wrapper for histograms; uses user-defined spline interpolation.
Double_t GetVal(Double_t x) const
returns value PDF(x)
Double_t GetIntegral(Double_t xmin, Double_t xmax)
computes PDF integral within given ranges
Class that is the base-class for a vector of result.
void Resize(Int_t entries)
std::vector< Float_t > * GetValueVector()
void SetValue(Float_t value, Int_t ievt, Bool_t type)
set MVA response
Class which takes the results of a multiclass classification.
TMatrixD GetConfusionMatrix(Double_t effB)
Returns a confusion matrix where each class is pitted against each other.
Float_t GetAchievablePur(UInt_t cls)
std::vector< Double_t > GetBestMultiClassCuts(UInt_t targetClass)
calculate the best working point (optimal cut values) for the multiclass classifier
void CreateMulticlassHistos(TString prefix, Int_t nbins, Int_t nbins_high)
this function fills the mva response histos for multiclass classification
Float_t GetAchievableEff(UInt_t cls)
void CreateMulticlassPerformanceHistos(TString prefix)
Create performance graphs for this classifier a multiclass setting.
Class that is the base-class for a vector of result.
Class that is the base-class for a vector of result.
Bool_t DoesExist(const TString &alias) const
Returns true if there is an object stored in the result for a given alias, false otherwise.
void Store(TObject *obj, const char *alias=nullptr)
TH1 * GetHist(const TString &alias) const
TList * GetStorage() const
Double_t Root(Double_t refValue)
Root finding using Brents algorithm; taken from CERNLIB function RZERO.
Linear interpolation of TGraph.
Timing information for training and evaluation of MVA methods.
Double_t ElapsedSeconds(void)
computes elapsed tim in seconds
TString GetElapsedTime(Bool_t Scientific=kTRUE)
returns pretty string with elapsed time
void DrawProgressBar(Int_t, const TString &comment="")
draws progress bar in color or B&W caution:
Singleton class for Global types used by TMVA.
@ kSignal
Never change this number - it is elsewhere assumed to be zero !
Class for type info of MVA input variable.
void ReadFromXML(void *varnode)
read VariableInfo from stream
const TString & GetExpression() const
void ReadFromStream(std::istream &istr)
read VariableInfo from stream
void AddToXML(void *varnode)
write class to XML
void SetExternalLink(void *p)
void * GetExternalLink() const
const char * GetName() const override
Returns name of object.
Collectable string class.
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
void ToLower()
Change string to lower-case.
Int_t Atoi() const
Return integer value of string.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void SaveDoc(XMLDocPointer_t xmldoc, const char *filename, Int_t layout=1)
store document content to file if layout<=0, no any spaces or newlines will be placed between xmlnode...
void FreeDoc(XMLDocPointer_t xmldoc)
frees allocated document data and deletes document itself
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
XMLDocPointer_t NewDoc(const char *version="1.0")
creates new xml document with provided version
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
XMLDocPointer_t ParseString(const char *xmlstring)
parses content of string and tries to produce xml structures
void DocSetRootElement(XMLDocPointer_t xmldoc, XMLNodePointer_t xmlnode)
set main (root) node for document
void CreateVariableTransforms(const TString &trafoDefinition, TMVA::DataSetInfo &dataInfo, TMVA::TransformationHandler &transformationHandler, TMVA::MsgLogger &log)
MsgLogger & Endl(MsgLogger &ml)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.