136#pragma warning ( disable : 4355 )
152 fAnalysisType (
Types::kNoAnalysisType ),
153 fRegressionReturnVal ( 0 ),
154 fMulticlassReturnVal ( 0 ),
155 fDataSetInfo ( dsi ),
156 fSignalReferenceCut ( 0.5 ),
157 fSignalReferenceCutOrientation( 1. ),
158 fVariableTransformType (
Types::kSignal ),
159 fJobName ( jobName ),
160 fMethodName ( methodTitle ),
161 fMethodType ( methodType ),
165 fConstructedFromWeightFile (
kFALSE ),
167 fMethodBaseDir ( 0 ),
170 fModelPersistence (
kTRUE),
181 fSplTrainEffBvsS ( 0 ),
182 fVarTransformString (
"None" ),
183 fTransformationPointer ( 0 ),
184 fTransformation ( dsi, methodTitle ),
186 fVerbosityLevelString (
"Default" ),
189 fIgnoreNegWeightsInTraining(
kFALSE ),
191 fBackgroundClass ( 0 ),
199 fLogger->SetSource(GetName());
216 fAnalysisType (
Types::kNoAnalysisType ),
217 fRegressionReturnVal ( 0 ),
218 fMulticlassReturnVal ( 0 ),
219 fDataSetInfo ( dsi ),
220 fSignalReferenceCut ( 0.5 ),
221 fVariableTransformType (
Types::kSignal ),
223 fMethodName (
"MethodBase" ),
224 fMethodType ( methodType ),
226 fTMVATrainingVersion ( 0 ),
227 fROOTTrainingVersion ( 0 ),
228 fConstructedFromWeightFile (
kTRUE ),
230 fMethodBaseDir ( 0 ),
233 fModelPersistence (
kTRUE),
234 fWeightFile ( weightFile ),
244 fSplTrainEffBvsS ( 0 ),
245 fVarTransformString (
"None" ),
246 fTransformationPointer ( 0 ),
247 fTransformation ( dsi,
"" ),
249 fVerbosityLevelString (
"Default" ),
252 fIgnoreNegWeightsInTraining(
kFALSE ),
254 fBackgroundClass ( 0 ),
272 if (!fSetupCompleted) Log() << kWARNING <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Calling destructor of method which got never setup" <<
Endl;
275 if (fInputVars != 0) { fInputVars->clear();
delete fInputVars; }
276 if (fRanking != 0)
delete fRanking;
279 if (fDefaultPDF!= 0) {
delete fDefaultPDF; fDefaultPDF = 0; }
280 if (fMVAPdfS != 0) {
delete fMVAPdfS; fMVAPdfS = 0; }
281 if (fMVAPdfB != 0) {
delete fMVAPdfB; fMVAPdfB = 0; }
284 if (fSplS) {
delete fSplS; fSplS = 0; }
285 if (fSplB) {
delete fSplB; fSplB = 0; }
286 if (fSpleffBvsS) {
delete fSpleffBvsS; fSpleffBvsS = 0; }
287 if (fSplRefS) {
delete fSplRefS; fSplRefS = 0; }
288 if (fSplRefB) {
delete fSplRefB; fSplRefB = 0; }
289 if (fSplTrainRefS) {
delete fSplTrainRefS; fSplTrainRefS = 0; }
290 if (fSplTrainRefB) {
delete fSplTrainRefB; fSplTrainRefB = 0; }
291 if (fSplTrainEffBvsS) {
delete fSplTrainEffBvsS; fSplTrainEffBvsS = 0; }
293 for (
size_t i = 0; i < fEventCollections.size(); i++ ) {
294 if (fEventCollections.at(i)) {
295 for (std::vector<Event*>::const_iterator it = fEventCollections.at(i)->begin();
296 it != fEventCollections.at(i)->end(); ++it) {
299 delete fEventCollections.at(i);
300 fEventCollections.at(i) =
nullptr;
304 if (fRegressionReturnVal)
delete fRegressionReturnVal;
305 if (fMulticlassReturnVal)
delete fMulticlassReturnVal;
315 if (fSetupCompleted) Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Calling SetupMethod for the second time" <<
Endl;
317 DeclareBaseOptions();
320 fSetupCompleted =
kTRUE;
330 ProcessBaseOptions();
340 CheckForUnusedOptions();
348 SetConfigDescription(
"Configuration options for classifier architecture and tuning" );
356 fSplTrainEffBvsS = 0;
363 fTxtWeightsOnly =
kTRUE;
373 fInputVars =
new std::vector<TString>;
374 for (
UInt_t ivar=0; ivar<GetNvar(); ivar++) {
375 fInputVars->push_back(DataInfo().GetVariableInfo(ivar).GetLabel());
377 fRegressionReturnVal = 0;
378 fMulticlassReturnVal = 0;
380 fEventCollections.resize( 2 );
381 fEventCollections.at(0) = 0;
382 fEventCollections.at(1) = 0;
385 if (DataInfo().GetClassInfo(
"Signal") != 0) {
386 fSignalClass = DataInfo().GetClassInfo(
"Signal")->GetNumber();
388 if (DataInfo().GetClassInfo(
"Background") != 0) {
389 fBackgroundClass = DataInfo().GetClassInfo(
"Background")->GetNumber();
392 SetConfigDescription(
"Configuration options for MVA method" );
393 SetConfigName(
TString(
"Method") + GetMethodTypeName() );
416 DeclareOptionRef( fVerbose,
"V",
"Verbose output (short form of \"VerbosityLevel\" below - overrides the latter one)" );
418 DeclareOptionRef( fVerbosityLevelString=
"Default",
"VerbosityLevel",
"Verbosity level" );
419 AddPreDefVal(
TString(
"Default") );
420 AddPreDefVal(
TString(
"Debug") );
421 AddPreDefVal(
TString(
"Verbose") );
422 AddPreDefVal(
TString(
"Info") );
423 AddPreDefVal(
TString(
"Warning") );
424 AddPreDefVal(
TString(
"Error") );
425 AddPreDefVal(
TString(
"Fatal") );
429 fTxtWeightsOnly =
kTRUE;
432 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)\"" );
434 DeclareOptionRef( fHelp,
"H",
"Print method-specific help message" );
436 DeclareOptionRef( fHasMVAPdfs,
"CreateMVAPdfs",
"Create PDFs for classifier outputs (signal and background)" );
438 DeclareOptionRef( fIgnoreNegWeightsInTraining,
"IgnoreNegWeightsInTraining",
439 "Events with negative weights are ignored in the training (but are included for testing and performance evaluation)" );
451 fDefaultPDF =
new PDF(
TString(GetName())+
"_PDF", GetOptions(),
"MVAPdf" );
452 fDefaultPDF->DeclareOptions();
453 fDefaultPDF->ParseOptions();
454 fDefaultPDF->ProcessOptions();
455 fMVAPdfB =
new PDF(
TString(GetName())+
"_PDFBkg", fDefaultPDF->GetOptions(),
"MVAPdfBkg", fDefaultPDF );
456 fMVAPdfB->DeclareOptions();
457 fMVAPdfB->ParseOptions();
458 fMVAPdfB->ProcessOptions();
459 fMVAPdfS =
new PDF(
TString(GetName())+
"_PDFSig", fMVAPdfB->GetOptions(),
"MVAPdfSig", fDefaultPDF );
460 fMVAPdfS->DeclareOptions();
461 fMVAPdfS->ParseOptions();
462 fMVAPdfS->ProcessOptions();
465 SetOptions( fMVAPdfS->GetOptions() );
470 GetTransformationHandler(),
474 if (fDefaultPDF!= 0) {
delete fDefaultPDF; fDefaultPDF = 0; }
475 if (fMVAPdfS != 0) {
delete fMVAPdfS; fMVAPdfS = 0; }
476 if (fMVAPdfB != 0) {
delete fMVAPdfB; fMVAPdfB = 0; }
480 fVerbosityLevelString =
TString(
"Verbose");
481 Log().SetMinType( kVERBOSE );
483 else if (fVerbosityLevelString ==
"Debug" ) Log().SetMinType( kDEBUG );
484 else if (fVerbosityLevelString ==
"Verbose" ) Log().SetMinType( kVERBOSE );
485 else if (fVerbosityLevelString ==
"Info" ) Log().SetMinType( kINFO );
486 else if (fVerbosityLevelString ==
"Warning" ) Log().SetMinType( kWARNING );
487 else if (fVerbosityLevelString ==
"Error" ) Log().SetMinType( kERROR );
488 else if (fVerbosityLevelString ==
"Fatal" ) Log().SetMinType( kFATAL );
489 else if (fVerbosityLevelString !=
"Default" ) {
490 Log() << kFATAL <<
"<ProcessOptions> Verbosity level type '"
491 << fVerbosityLevelString <<
"' unknown." <<
Endl;
503 DeclareOptionRef( fNormalise=
kFALSE,
"Normalise",
"Normalise input variables" );
504 DeclareOptionRef( fUseDecorr=
kFALSE,
"D",
"Use-decorrelated-variables flag" );
505 DeclareOptionRef( fVariableTransformTypeString=
"Signal",
"VarTransformType",
506 "Use signal or background events to derive for variable transformation (the transformation is applied on both types of, course)" );
507 AddPreDefVal(
TString(
"Signal") );
508 AddPreDefVal(
TString(
"Background") );
509 DeclareOptionRef( fTxtWeightsOnly=
kTRUE,
"TxtWeightFilesOnly",
"If True: write all training results (weights) as text files (False: some are written in ROOT format)" );
519 DeclareOptionRef( fNbinsMVAPdf = 60,
"NbinsMVAPdf",
"Number of bins used for the PDFs of classifier outputs" );
520 DeclareOptionRef( fNsmoothMVAPdf = 2,
"NsmoothMVAPdf",
"Number of smoothing iterations for classifier PDFs" );
534 Log() << kWARNING <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Parameter optimization is not yet implemented for method "
535 << GetName() <<
Endl;
536 Log() << kWARNING <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Currently we need to set hardcoded which parameter is tuned in which ranges"<<
Endl;
538 return std::map<TString,Double_t>();
558 if (Help()) PrintHelpMessage();
561 if(!IsSilentFile()) BaseDir()->cd();
565 GetTransformationHandler().CalcTransformations(Data()->GetEventCollection());
569 <<
"Begin training" <<
Endl;
570 Long64_t nEvents = Data()->GetNEvents();
571 Timer traintimer( nEvents, GetName(),
kTRUE );
574 <<
"\tEnd of training " <<
Endl;
577 <<
"Elapsed time for training with " << nEvents <<
" events: "
581 <<
"\tCreate MVA output for ";
584 if (DoMulticlass()) {
585 Log() <<
Form(
"[%s] : ",DataInfo().GetName())<<
"Multiclass classification on training sample" <<
Endl;
588 else if (!DoRegression()) {
590 Log() <<
Form(
"[%s] : ",DataInfo().GetName())<<
"classification on training sample" <<
Endl;
599 Log() <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"regression on training sample" <<
Endl;
603 Log() <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Create PDFs" <<
Endl;
610 if (fModelPersistence ) WriteStateToFile();
613 if ((!DoRegression()) && (fModelPersistence)) MakeClass();
620 WriteMonitoringHistosToFile();
628 if (!DoRegression()) Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Trying to use GetRegressionDeviation() with a classification job" <<
Endl;
629 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Create results for " << (
type==
Types::kTraining?
"training":
"testing") <<
Endl;
631 bool truncate =
false;
632 TH1F*
h1 = regRes->QuadraticDeviation( tgtNum , truncate, 1.);
637 TH1F* h2 = regRes->QuadraticDeviation( tgtNum , truncate, yq[0]);
638 stddev90Percent = sqrt(h2->
GetMean());
647 Long64_t nEvents = Data()->GetNEvents();
654 Int_t totalProgressDraws = 100;
655 Int_t drawProgressEvery = 1;
656 if(nEvents >= totalProgressDraws) drawProgressEvery = nEvents/totalProgressDraws;
658 size_t ntargets = Data()->GetEvent(0)->GetNTargets();
659 std::vector<float> output(nEvents*ntargets);
660 auto itr = output.begin();
661 for (
Int_t ievt=0; ievt<nEvents; ievt++) {
663 Data()->SetCurrentEvent(ievt);
664 std::vector< Float_t > vals = GetRegressionValues();
665 if (vals.size() != ntargets)
666 Log() << kFATAL <<
"Output regression vector with size " << vals.size() <<
" is not consistent with target size of "
667 << ntargets << std::endl;
669 std::copy(vals.begin(), vals.end(), itr);
673 if(ievt % drawProgressEvery == 0 || ievt==nEvents-1) timer.
DrawProgressBar( ievt );
684 Data()->SetCurrentType(
type);
686 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Create results for " << (
type==
Types::kTraining?
"training":
"testing") <<
Endl;
690 Long64_t nEvents = Data()->GetNEvents();
695 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName()) <<
"Evaluation of " << GetMethodName() <<
" on "
698 regRes->Resize( nEvents );
700 std::vector<float> output = GetAllRegressionValues();
702 Data()->SetCurrentEvent(0);
703 size_t nTargets = GetEvent()->GetNTargets();
707 if (output.size() != nTargets *
size_t(nEvents))
708 Log() << kFATAL <<
"Output regression vector with size " << output.size() <<
" is not consistent with target size of "
709 << nTargets <<
" and number of events " << nEvents << std::endl;
711 for (
Int_t ievt=0; ievt<nEvents; ievt++) {
713 auto valsBegin = output.begin() + size_t(ievt) * nTargets;
714 std::vector<Float_t> vals(valsBegin, valsBegin + nTargets);
715 regRes->SetValue(vals, ievt);
718 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())
719 <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
726 TString histNamePrefix(GetTestvarName());
728 regRes->CreateDeviationHistograms( histNamePrefix );
736 Long64_t nEvents = Data()->GetNEvents();
741 Data()->SetCurrentEvent(0);
742 std::vector< Float_t > vals = GetMulticlassValues();
743 std::vector<float> output(nEvents * vals.size());
744 auto itr = output.begin();
745 std::copy(vals.begin(), vals.end(), itr);
746 for (
Int_t ievt=1; ievt<nEvents; ievt++) {
748 Data()->SetCurrentEvent(ievt);
749 vals = GetMulticlassValues();
751 std::copy(vals.begin(), vals.end(), itr);
762 Data()->SetCurrentType(
type);
764 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Create results for " << (
type==
Types::kTraining?
"training":
"testing") <<
Endl;
767 if (!resMulticlass) Log() << kFATAL<<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"unable to create pointer in AddMulticlassOutput, exiting."<<
Endl;
769 Long64_t nEvents = Data()->GetNEvents();
774 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Multiclass evaluation of " << GetMethodName() <<
" on "
777 resMulticlass->Resize( nEvents );
778 std::vector<Float_t> output = GetAllMulticlassValues();
779 size_t nClasses = output.size()/nEvents;
780 for (
Int_t ievt=0; ievt<nEvents; ievt++) {
781 std::vector< Float_t > vals(output.begin()+ievt*nClasses, output.begin()+(ievt+1)*nClasses);
782 resMulticlass->SetValue( vals, ievt );
786 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())
787 <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
794 TString histNamePrefix(GetTestvarName());
797 resMulticlass->CreateMulticlassHistos( histNamePrefix, fNbinsMVAoutput, fNbinsH );
798 resMulticlass->CreateMulticlassPerformanceHistos(histNamePrefix);
805 if (errUpper) *errUpper=-1;
812 Double_t val = GetMvaValue(err, errUpper);
822 return GetMvaValue()*GetSignalReferenceCutOrientation() > GetSignalReferenceCut()*GetSignalReferenceCutOrientation() ?
kTRUE :
kFALSE;
829 return mvaVal*GetSignalReferenceCutOrientation() > GetSignalReferenceCut()*GetSignalReferenceCutOrientation() ?
kTRUE :
kFALSE;
837 Data()->SetCurrentType(
type);
842 Long64_t nEvents = Data()->GetNEvents();
848 Log() << kHEADER <<
Form(
"[%s] : ",DataInfo().GetName())
849 <<
"Evaluation of " << GetMethodName() <<
" on "
851 <<
" sample (" << nEvents <<
" events)" <<
Endl;
853 std::vector<Double_t> mvaValues = GetMvaValues(0, nEvents,
true);
856 <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
864 for (
Int_t ievt = 0; ievt < nEvents; ievt++) {
867 auto ev = Data()->GetEvent(ievt);
868 clRes->
SetValue(mvaValues[ievt], ievt, DataInfo().IsSignal(ev));
877 Long64_t nEvents = Data()->GetNEvents();
878 if (firstEvt > lastEvt || lastEvt > nEvents) lastEvt = nEvents;
879 if (firstEvt < 0) firstEvt = 0;
880 std::vector<Double_t> values(lastEvt-firstEvt);
882 nEvents = values.size();
888 Log() << kHEADER <<
Form(
"[%s] : ",DataInfo().GetName())
889 <<
"Evaluation of " << GetMethodName() <<
" on "
891 <<
" sample (" << nEvents <<
" events)" <<
Endl;
893 for (
Int_t ievt=firstEvt; ievt<lastEvt; ievt++) {
894 Data()->SetCurrentEvent(ievt);
895 values[ievt] = GetMvaValue();
900 if (modulo <= 0 ) modulo = 1;
906 <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
919 auto result = GetMvaValues(firstEvt, lastEvt, logProgress);
929 Data()->SetCurrentType(
type);
934 Long64_t nEvents = Data()->GetNEvents();
939 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName()) <<
"Evaluation of " << GetMethodName() <<
" on "
942 mvaProb->
Resize( nEvents );
944 if (modulo <= 0 ) modulo = 1;
945 for (
Int_t ievt=0; ievt<nEvents; ievt++) {
947 Data()->SetCurrentEvent(ievt);
949 if (proba < 0)
break;
950 mvaProb->
SetValue( proba, ievt, DataInfo().IsSignal( Data()->GetEvent()) );
956 Log() << kDEBUG <<
Form(
"Dataset[%s] : ",DataInfo().GetName())
957 <<
"Elapsed time for evaluation of " << nEvents <<
" events: "
976 Data()->SetCurrentType(
type);
978 bias = 0; biasT = 0; dev = 0; devT = 0; rms = 0; rmsT = 0;
980 Double_t m1 = 0, m2 = 0,
s1 = 0, s2 = 0, s12 = 0;
981 const Int_t nevt = GetNEvents();
986 Log() << kINFO <<
"Calculate regression for all events" <<
Endl;
989 auto output = GetAllRegressionValues();
990 int ntargets = Data()->GetEvent(0)->GetNTargets();
991 for (
Long64_t ievt=0; ievt<nevt; ievt++) {
992 const Event* ev = Data()->GetEvent(ievt);
1014 m1 += t*
w;
s1 += t*t*
w;
1015 m2 +=
r*
w; s2 +=
r*
r*
w;
1018 if (ievt % modulo == 0)
1022 Log() << kINFO <<
"Elapsed time for evaluation of " << nevt <<
" events: "
1034 corr = s12/sumw - m1*m2;
1035 corr /=
TMath::Sqrt( (
s1/sumw - m1*m1) * (s2/sumw - m2*m2) );
1045 for (
Long64_t ievt=0; ievt<nevt; ievt++) {
1047 hist->
Fill( rV[ievt], tV[ievt], wV[ievt] );
1048 if (
d >= devMin &&
d <= devMax) {
1050 biasT += wV[ievt] *
d;
1052 rmsT += wV[ievt] *
d *
d;
1053 histT->
Fill( rV[ievt], tV[ievt], wV[ievt] );
1070 Data()->SetCurrentType(savedType);
1080 if (!resMulticlass) Log() << kFATAL<<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"unable to create pointer in TestMulticlass, exiting."<<
Endl;
1089 TString histNamePrefix(GetTestvarName());
1090 TString histNamePrefixTest{histNamePrefix +
"_Test"};
1091 TString histNamePrefixTrain{histNamePrefix +
"_Train"};
1112 if (0==mvaRes && !(GetMethodTypeName().Contains(
"Cuts"))) {
1113 Log()<<
Form(
"Dataset[%s] : ",DataInfo().GetName()) <<
"mvaRes " << mvaRes <<
" GetMethodTypeName " << GetMethodTypeName()
1114 <<
" contains " << !(GetMethodTypeName().Contains(
"Cuts")) <<
Endl;
1115 Log() << kFATAL<<
Form(
"Dataset[%s] : ",DataInfo().GetName()) <<
"<TestInit> Test variable " << GetTestvarName()
1116 <<
" not found in tree" <<
Endl;
1121 fMeanS, fMeanB, fRmsS, fRmsB, fXmin, fXmax, fSignalClass );
1129 fCutOrientation = (fMeanS > fMeanB) ? kPositive : kNegative;
1139 if(IsSilentFile()) {
1140 TestvarName =
TString::Format(
"[%s]%s",DataInfo().GetName(),GetTestvarName().Data());
1142 TestvarName=GetTestvarName();
1144 TH1* mva_s =
new TH1D( TestvarName +
"_S",TestvarName +
"_S", fNbinsMVAoutput, fXmin, sxmax );
1145 TH1* mva_b =
new TH1D( TestvarName +
"_B",TestvarName +
"_B", fNbinsMVAoutput, fXmin, sxmax );
1146 mvaRes->
Store(mva_s,
"MVA_S");
1147 mvaRes->
Store(mva_b,
"MVA_B");
1157 proba_s =
new TH1D( TestvarName +
"_Proba_S", TestvarName +
"_Proba_S", fNbinsMVAoutput, 0.0, 1.0 );
1158 proba_b =
new TH1D( TestvarName +
"_Proba_B", TestvarName +
"_Proba_B", fNbinsMVAoutput, 0.0, 1.0 );
1159 mvaRes->
Store(proba_s,
"Prob_S");
1160 mvaRes->
Store(proba_b,
"Prob_B");
1165 rarity_s =
new TH1D( TestvarName +
"_Rarity_S", TestvarName +
"_Rarity_S", fNbinsMVAoutput, 0.0, 1.0 );
1166 rarity_b =
new TH1D( TestvarName +
"_Rarity_B", TestvarName +
"_Rarity_B", fNbinsMVAoutput, 0.0, 1.0 );
1167 mvaRes->
Store(rarity_s,
"Rar_S");
1168 mvaRes->
Store(rarity_b,
"Rar_B");
1174 TH1* mva_eff_s =
new TH1D( TestvarName +
"_S_high", TestvarName +
"_S_high", fNbinsH, fXmin, sxmax );
1175 TH1* mva_eff_b =
new TH1D( TestvarName +
"_B_high", TestvarName +
"_B_high", fNbinsH, fXmin, sxmax );
1176 mvaRes->
Store(mva_eff_s,
"MVA_HIGHBIN_S");
1177 mvaRes->
Store(mva_eff_b,
"MVA_HIGHBIN_B");
1186 Log() << kHEADER <<
Form(
"[%s] : ",DataInfo().GetName())<<
"Loop over test events and fill histograms with classifier response..." <<
Endl <<
Endl;
1187 if (mvaProb) Log() << kINFO <<
"Also filling probability and rarity histograms (on request)..." <<
Endl;
1191 if ( mvaRes->
GetSize() != GetNEvents() ) {
1192 Log() << kFATAL <<
TString::Format(
"Inconsistent result size %lld with number of events %u ", mvaRes->
GetSize() , GetNEvents() ) <<
Endl;
1193 assert(mvaRes->
GetSize() == GetNEvents());
1196 for (
Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
1198 const Event* ev = GetEvent(ievt);
1202 if (DataInfo().IsSignal(ev)) {
1206 proba_s->
Fill( (*mvaProb)[ievt][0],
w );
1207 rarity_s->
Fill( GetRarity(
v ),
w );
1210 mva_eff_s ->
Fill(
v,
w );
1216 proba_b->
Fill( (*mvaProb)[ievt][0],
w );
1217 rarity_b->
Fill( GetRarity(
v ),
w );
1219 mva_eff_b ->
Fill(
v,
w );
1234 if (fSplS) {
delete fSplS; fSplS = 0; }
1235 if (fSplB) {
delete fSplB; fSplB = 0; }
1249 tf << prefix <<
"#GEN -*-*-*-*-*-*-*-*-*-*-*- general info -*-*-*-*-*-*-*-*-*-*-*-" << std::endl << prefix << std::endl;
1250 tf << prefix <<
"Method : " << GetMethodTypeName() <<
"::" << GetMethodName() << std::endl;
1251 tf.setf(std::ios::left);
1252 tf << prefix <<
"TMVA Release : " << std::setw(10) << GetTrainingTMVAVersionString() <<
" ["
1253 << GetTrainingTMVAVersionCode() <<
"]" << std::endl;
1254 tf << prefix <<
"ROOT Release : " << std::setw(10) << GetTrainingROOTVersionString() <<
" ["
1255 << GetTrainingROOTVersionCode() <<
"]" << std::endl;
1256 tf << prefix <<
"Creator : " << userInfo->
fUser << std::endl;
1257 tf << prefix <<
"Date : ";
TDatime *
d =
new TDatime; tf <<
d->AsString() << std::endl;
delete d;
1260 tf << prefix <<
"Training events: " << Data()->GetNTrainingEvents() << std::endl;
1264 tf << prefix <<
"Analysis type : " <<
"[" << ((GetAnalysisType()==
Types::kRegression) ?
"Regression" :
"Classification") <<
"]" << std::endl;
1265 tf << prefix << std::endl;
1270 tf << prefix << std::endl << prefix <<
"#OPT -*-*-*-*-*-*-*-*-*-*-*-*- options -*-*-*-*-*-*-*-*-*-*-*-*-" << std::endl << prefix << std::endl;
1271 WriteOptionsToStream( tf, prefix );
1272 tf << prefix << std::endl;
1275 tf << prefix << std::endl << prefix <<
"#VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*-" << std::endl << prefix << std::endl;
1276 WriteVarsToStream( tf, prefix );
1277 tf << prefix << std::endl;
1294 AddRegressionOutput(
type );
1296 AddMulticlassOutput(
type );
1298 AddClassifierOutput(
type );
1300 AddClassifierOutputProb(
type );
1310 if (!parent)
return;
1315 AddInfoItem( gi,
"TMVA Release", GetTrainingTMVAVersionString() +
" [" +
gTools().StringFromInt(GetTrainingTMVAVersionCode()) +
"]" );
1316 AddInfoItem( gi,
"ROOT Release", GetTrainingROOTVersionString() +
" [" +
gTools().StringFromInt(GetTrainingROOTVersionCode()) +
"]");
1317 AddInfoItem( gi,
"Creator", userInfo->
fUser);
1321 AddInfoItem( gi,
"Training events",
gTools().StringFromInt(Data()->GetNTrainingEvents()));
1322 AddInfoItem( gi,
"TrainingTime",
gTools().StringFromDouble(
const_cast<TMVA::MethodBase*
>(
this)->GetTrainTime()));
1327 AddInfoItem( gi,
"AnalysisType", analysisType );
1331 AddOptionsXMLTo( parent );
1334 AddVarsXMLTo( parent );
1337 if (fModelPersistence)
1338 AddSpectatorsXMLTo( parent );
1341 AddClassesXMLTo(parent);
1344 if (DoRegression()) AddTargetsXMLTo(parent);
1347 GetTransformationHandler(
false).AddXMLTo( parent );
1351 if (fMVAPdfS) fMVAPdfS->AddXMLTo(pdfs);
1352 if (fMVAPdfB) fMVAPdfB->AddXMLTo(pdfs);
1355 AddWeightsXMLTo( parent );
1368 ReadWeightsFromStream( rf );
1381 TString tfname( GetWeightFileName() );
1386 <<
"Creating xml weight file: "
1391 gTools().
AddAttr(rootnode,
"Method", GetMethodTypeName() +
"::" + GetMethodName());
1392 WriteStateToXML(rootnode);
1404 TString tfname(GetWeightFileName());
1407 <<
"Reading weight file: "
1413 Log() << kFATAL <<
"Error parsing XML file " << tfname <<
Endl;
1416 ReadStateFromXML(rootnode);
1421 fb.open(tfname.
Data(),std::ios::in);
1422 if (!fb.is_open()) {
1423 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<ReadStateFromFile> "
1424 <<
"Unable to open input weight file: " << tfname <<
Endl;
1426 std::istream fin(&fb);
1427 ReadStateFromStream(fin);
1430 if (!fTxtWeightsOnly) {
1433 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Reading root weight file: "
1436 ReadStateFromStream( *rfile );
1446 ReadStateFromXML(rootnode);
1460 fMethodName = fullMethodName(fullMethodName.
Index(
"::")+2,fullMethodName.
Length());
1463 Log().SetSource( GetName() );
1465 <<
"Read method \"" << GetMethodName() <<
"\" of type \"" << GetMethodTypeName() <<
"\"" <<
Endl;
1475 if (nodeName==
"GeneralInfo") {
1480 while (antypeNode) {
1483 if (
name ==
"TrainingTime")
1486 if (
name ==
"AnalysisType") {
1492 else Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Analysis type " << val <<
" is not known." <<
Endl;
1495 if (
name ==
"TMVA Release" ||
name ==
"TMVA") {
1499 Log() << kDEBUG <<
Form(
"[%s] : ",DataInfo().GetName()) <<
"MVA method was trained with TMVA Version: " << GetTrainingTMVAVersionString() <<
Endl;
1502 if (
name ==
"ROOT Release" ||
name ==
"ROOT") {
1507 <<
"MVA method was trained with ROOT Version: " << GetTrainingROOTVersionString() <<
Endl;
1512 else if (nodeName==
"Options") {
1513 ReadOptionsFromXML(ch);
1517 else if (nodeName==
"Variables") {
1518 ReadVariablesFromXML(ch);
1520 else if (nodeName==
"Spectators") {
1521 ReadSpectatorsFromXML(ch);
1523 else if (nodeName==
"Classes") {
1524 if (DataInfo().GetNClasses()==0) ReadClassesFromXML(ch);
1526 else if (nodeName==
"Targets") {
1527 if (DataInfo().GetNTargets()==0 && DoRegression()) ReadTargetsFromXML(ch);
1529 else if (nodeName==
"Transformations") {
1530 GetTransformationHandler().ReadFromXML(ch);
1532 else if (nodeName==
"MVAPdfs") {
1534 if (fMVAPdfS) {
delete fMVAPdfS; fMVAPdfS=0; }
1535 if (fMVAPdfB) {
delete fMVAPdfB; fMVAPdfB=0; }
1539 fMVAPdfS =
new PDF(pdfname);
1540 fMVAPdfS->ReadXML(pdfnode);
1543 fMVAPdfB =
new PDF(pdfname);
1544 fMVAPdfB->ReadXML(pdfnode);
1547 else if (nodeName==
"Weights") {
1548 ReadWeightsFromXML(ch);
1551 Log() << kWARNING <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Unparsed XML node: '" << nodeName <<
"'" <<
Endl;
1558 if (GetTransformationHandler().GetCallerName() ==
"") GetTransformationHandler().SetCallerName( GetName() );
1574 while (!
TString(buf).BeginsWith(
"Method")) GetLine(fin,buf);
1578 methodType = methodType(methodType.
Last(
' '),methodType.
Length());
1583 if (methodName ==
"") methodName = methodType;
1584 fMethodName = methodName;
1586 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Read method \"" << GetMethodName() <<
"\" of type \"" << GetMethodTypeName() <<
"\"" <<
Endl;
1589 Log().SetSource( GetName() );
1603 while (!
TString(buf).BeginsWith(
"#OPT")) GetLine(fin,buf);
1604 ReadOptionsFromStream(fin);
1608 fin.getline(buf,512);
1609 while (!
TString(buf).BeginsWith(
"#VAR")) fin.getline(buf,512);
1610 ReadVarsFromStream(fin);
1615 if (IsNormalised()) {
1621 if ( fVarTransformString ==
"None") {
1624 }
else if ( fVarTransformString ==
"Decorrelate" ) {
1626 }
else if ( fVarTransformString ==
"PCA" ) {
1627 varTrafo = GetTransformationHandler().AddTransformation(
new VariablePCATransform(DataInfo()), -1 );
1628 }
else if ( fVarTransformString ==
"Uniform" ) {
1629 varTrafo = GetTransformationHandler().AddTransformation(
new VariableGaussTransform(DataInfo(),
"Uniform"), -1 );
1630 }
else if ( fVarTransformString ==
"Gauss" ) {
1632 }
else if ( fVarTransformString ==
"GaussDecorr" ) {
1636 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<ProcessOptions> Variable transform '"
1637 << fVarTransformString <<
"' unknown." <<
Endl;
1640 if (GetTransformationHandler().GetTransformationList().GetSize() > 0) {
1641 fin.getline(buf,512);
1642 while (!
TString(buf).BeginsWith(
"#MAT")) fin.getline(buf,512);
1645 varTrafo->ReadTransformationFromStream(fin, trafo );
1656 fin.getline(buf,512);
1657 while (!
TString(buf).BeginsWith(
"#MVAPDFS")) fin.getline(buf,512);
1658 if (fMVAPdfS != 0) {
delete fMVAPdfS; fMVAPdfS = 0; }
1659 if (fMVAPdfB != 0) {
delete fMVAPdfB; fMVAPdfB = 0; }
1660 fMVAPdfS =
new PDF(
TString(GetName()) +
" MVA PDF Sig");
1661 fMVAPdfB =
new PDF(
TString(GetName()) +
" MVA PDF Bkg");
1662 fMVAPdfS->SetReadingVersion( GetTrainingTMVAVersionCode() );
1663 fMVAPdfB->SetReadingVersion( GetTrainingTMVAVersionCode() );
1670 fin.getline(buf,512);
1671 while (!
TString(buf).BeginsWith(
"#WGT")) fin.getline(buf,512);
1672 fin.getline(buf,512);
1673 ReadWeightsFromStream( fin );
1676 if (GetTransformationHandler().GetCallerName() ==
"") GetTransformationHandler().SetCallerName( GetName() );
1686 o << prefix <<
"NVar " << DataInfo().GetNVariables() << std::endl;
1687 std::vector<VariableInfo>::const_iterator varIt = DataInfo().GetVariableInfos().begin();
1688 for (; varIt!=DataInfo().GetVariableInfos().end(); ++varIt) { o << prefix; varIt->WriteToStream(o); }
1689 o << prefix <<
"NSpec " << DataInfo().GetNSpectators() << std::endl;
1690 varIt = DataInfo().GetSpectatorInfos().begin();
1691 for (; varIt!=DataInfo().GetSpectatorInfos().end(); ++varIt) { o << prefix; varIt->WriteToStream(o); }
1703 istr >> dummy >> readNVar;
1705 if (readNVar!=DataInfo().GetNVariables()) {
1706 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"You declared "<< DataInfo().GetNVariables() <<
" variables in the Reader"
1707 <<
" while there are " << readNVar <<
" variables declared in the file"
1713 std::vector<VariableInfo>::iterator varIt = DataInfo().GetVariableInfos().begin();
1715 for (; varIt!=DataInfo().GetVariableInfos().end(); ++varIt, ++varIdx) {
1722 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"ERROR in <ReadVarsFromStream>" <<
Endl;
1723 Log() << kINFO <<
"The definition (or the order) of the variables found in the input file is" <<
Endl;
1724 Log() << kINFO <<
"is not the same as the one declared in the Reader (which is necessary for" <<
Endl;
1725 Log() << kINFO <<
"the correct working of the method):" <<
Endl;
1726 Log() << kINFO <<
" var #" << varIdx <<
" declared in Reader: " << varIt->GetExpression() <<
Endl;
1727 Log() << kINFO <<
" var #" << varIdx <<
" declared in file : " << varInfo.
GetExpression() <<
Endl;
1728 Log() << kFATAL <<
"The expression declared to the Reader needs to be checked (name or order are wrong)" <<
Endl;
1741 for (
UInt_t idx=0; idx<DataInfo().GetVariableInfos().size(); idx++) {
1757 for (
UInt_t idx=0; idx<DataInfo().GetSpectatorInfos().size(); idx++) {
1759 VariableInfo& vi = DataInfo().GetSpectatorInfos()[idx];
1777 UInt_t nClasses=DataInfo().GetNClasses();
1782 for (
UInt_t iCls=0; iCls<nClasses; ++iCls) {
1783 ClassInfo *classInfo=DataInfo().GetClassInfo (iCls);
1800 for (
UInt_t idx=0; idx<DataInfo().GetTargetInfos().size(); idx++) {
1816 if (readNVar!=DataInfo().GetNVariables()) {
1817 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"You declared "<< DataInfo().GetNVariables() <<
" variables in the Reader"
1818 <<
" while there are " << readNVar <<
" variables declared in the file"
1828 existingVarInfo = DataInfo().GetVariableInfos()[varIdx];
1833 existingVarInfo = readVarInfo;
1836 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"ERROR in <ReadVariablesFromXML>" <<
Endl;
1837 Log() << kINFO <<
"The definition (or the order) of the variables found in the input file is" <<
Endl;
1838 Log() << kINFO <<
"not the same as the one declared in the Reader (which is necessary for the" <<
Endl;
1839 Log() << kINFO <<
"correct working of the method):" <<
Endl;
1840 Log() << kINFO <<
" var #" << varIdx <<
" declared in Reader: " << existingVarInfo.
GetExpression() <<
Endl;
1841 Log() << kINFO <<
" var #" << varIdx <<
" declared in file : " << readVarInfo.
GetExpression() <<
Endl;
1842 Log() << kFATAL <<
"The expression declared to the Reader needs to be checked (name or order are wrong)" <<
Endl;
1856 if (readNSpec!=DataInfo().GetNSpectators(
kFALSE)) {
1857 Log() << kFATAL<<
Form(
"Dataset[%s] : ",DataInfo().GetName()) <<
"You declared "<< DataInfo().GetNSpectators(
kFALSE) <<
" spectators in the Reader"
1858 <<
" while there are " << readNSpec <<
" spectators declared in the file"
1868 existingSpecInfo = DataInfo().GetSpectatorInfos()[specIdx];
1873 existingSpecInfo = readSpecInfo;
1876 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"ERROR in <ReadSpectatorsFromXML>" <<
Endl;
1877 Log() << kINFO <<
"The definition (or the order) of the spectators found in the input file is" <<
Endl;
1878 Log() << kINFO <<
"not the same as the one declared in the Reader (which is necessary for the" <<
Endl;
1879 Log() << kINFO <<
"correct working of the method):" <<
Endl;
1880 Log() << kINFO <<
" spec #" << specIdx <<
" declared in Reader: " << existingSpecInfo.
GetExpression() <<
Endl;
1881 Log() << kINFO <<
" spec #" << specIdx <<
" declared in file : " << readSpecInfo.
GetExpression() <<
Endl;
1882 Log() << kFATAL <<
"The expression declared to the Reader needs to be checked (name or order are wrong)" <<
Endl;
1901 for (
UInt_t icls = 0; icls<readNCls;++icls) {
1903 DataInfo().AddClass(classname);
1911 DataInfo().AddClass(className);
1918 if (DataInfo().GetClassInfo(
"Signal") != 0) {
1919 fSignalClass = DataInfo().GetClassInfo(
"Signal")->GetNumber();
1923 if (DataInfo().GetClassInfo(
"Background") != 0) {
1924 fBackgroundClass = DataInfo().GetClassInfo(
"Background")->GetNumber();
1944 DataInfo().AddTarget(expression,
"",
"",0,0);
1956 if (fBaseDir != 0)
return fBaseDir;
1957 Log()<<kDEBUG<<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
" Base Directory for " << GetMethodName() <<
" not set yet --> check if already there.." <<
Endl;
1959 if (IsSilentFile()) {
1960 Log() << kFATAL <<
Form(
"Dataset[%s] : ", DataInfo().GetName())
1961 <<
"MethodBase::BaseDir() - No directory exists when running a Method without output file. Enable the "
1962 "output when creating the factory"
1968 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"MethodBase::BaseDir() - MethodBaseDir() return a NULL pointer!" <<
Endl;
1970 TString defaultDir = GetMethodName();
1974 Log()<<kDEBUG<<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
" Base Directory for " << GetMethodTypeName() <<
" does not exist yet--> created it" <<
Endl;
1975 sdir = methodDir->
mkdir(defaultDir);
1978 if (fModelPersistence) {
1981 wfilePath.
Write(
"TrainingPath" );
1982 wfileName.
Write(
"WeightFileName" );
1986 Log()<<kDEBUG<<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
" Base Directory for " << GetMethodTypeName() <<
" existed, return it.." <<
Endl;
1996 if (fMethodBaseDir != 0) {
1997 return fMethodBaseDir;
2000 const char *datasetName = DataInfo().
GetName();
2002 Log() << kDEBUG <<
Form(
"Dataset[%s] : ", datasetName) <<
" Base Directory for " << GetMethodTypeName()
2003 <<
" not set yet --> check if already there.." <<
Endl;
2006 if (!factoryBaseDir)
return nullptr;
2007 fMethodBaseDir = factoryBaseDir->
GetDirectory(datasetName);
2008 if (!fMethodBaseDir) {
2009 fMethodBaseDir = factoryBaseDir->
mkdir(datasetName,
TString::Format(
"Base directory for dataset %s", datasetName).Data());
2010 if (!fMethodBaseDir) {
2011 Log() << kFATAL <<
"Can not create dir " << datasetName;
2015 fMethodBaseDir = fMethodBaseDir->GetDirectory(methodTypeDir.
Data());
2017 if (!fMethodBaseDir) {
2019 TString methodTypeDirHelpStr =
TString::Format(
"Directory for all %s methods", GetMethodTypeName().Data());
2020 fMethodBaseDir = datasetDir->
mkdir(methodTypeDir.
Data(), methodTypeDirHelpStr);
2021 Log() << kDEBUG <<
Form(
"Dataset[%s] : ", datasetName) <<
" Base Directory for " << GetMethodName()
2022 <<
" does not exist yet--> created it" <<
Endl;
2025 Log() << kDEBUG <<
Form(
"Dataset[%s] : ", datasetName)
2026 <<
"Return from MethodBaseDir() after creating base directory " <<
Endl;
2027 return fMethodBaseDir;
2044 fWeightFile = theWeightFile;
2052 if (fWeightFile!=
"")
return fWeightFile;
2057 TString wFileDir(GetWeightFileDir());
2058 TString wFileName = GetJobName() +
"_" + GetMethodName() +
2060 if (wFileDir.
IsNull() )
return wFileName;
2062 return ( wFileDir + (wFileDir[wFileDir.
Length()-1]==
'/' ?
"" :
"/")
2074 if (0 != fMVAPdfS) {
2075 fMVAPdfS->GetOriginalHist()->Write();
2076 fMVAPdfS->GetSmoothedHist()->Write();
2077 fMVAPdfS->GetPDFHist()->Write();
2079 if (0 != fMVAPdfB) {
2080 fMVAPdfB->GetOriginalHist()->Write();
2081 fMVAPdfB->GetSmoothedHist()->Write();
2082 fMVAPdfB->GetPDFHist()->Write();
2088 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<WriteEvaluationHistosToFile> Unknown result: "
2089 << GetMethodName() << (treetype==
Types::kTraining?
"/kTraining":
"/kTesting")
2090 <<
"/kMaxAnalysisType" <<
Endl;
2095 GetTransformationHandler().PlotVariables (GetEventCollection(
Types::kTesting ), BaseDir() );
2097 Log() << kINFO <<
TString::Format(
"Dataset[%s] : ",DataInfo().GetName())
2098 <<
" variable plots are not produces ! The number of variables is " << DataInfo().GetNVariables()
2118 fin.getline(buf,512);
2120 if (
line.BeginsWith(
"TMVA Release")) {
2124 std::stringstream s(code.
Data());
2125 s >> fTMVATrainingVersion;
2126 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"MVA method was trained with TMVA Version: " << GetTrainingTMVAVersionString() <<
Endl;
2128 if (
line.BeginsWith(
"ROOT Release")) {
2132 std::stringstream s(code.
Data());
2133 s >> fROOTTrainingVersion;
2134 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"MVA method was trained with ROOT Version: " << GetTrainingROOTVersionString() <<
Endl;
2136 if (
line.BeginsWith(
"Analysis type")) {
2140 std::stringstream s(code.
Data());
2141 std::string analysisType;
2143 if (analysisType ==
"regression" || analysisType ==
"Regression") SetAnalysisType(
Types::kRegression );
2144 else if (analysisType ==
"classification" || analysisType ==
"Classification") SetAnalysisType(
Types::kClassification );
2145 else if (analysisType ==
"multiclass" || analysisType ==
"Multiclass") SetAnalysisType(
Types::kMulticlass );
2146 else Log() << kFATAL <<
"Analysis type " << analysisType <<
" from weight-file not known!" << std::endl;
2148 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Method was trained for "
2168 if (mvaRes==0 || mvaRes->
GetSize()==0) {
2169 Log() << kERROR<<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<CreateMVAPdfs> No result of classifier testing available" <<
Endl;
2176 TH1* histMVAPdfS =
new TH1D( GetMethodTypeName() +
"_tr_S", GetMethodTypeName() +
"_tr_S",
2177 fMVAPdfS->GetHistNBins( mvaRes->
GetSize() ), minVal, maxVal );
2178 TH1* histMVAPdfB =
new TH1D( GetMethodTypeName() +
"_tr_B", GetMethodTypeName() +
"_tr_B",
2179 fMVAPdfB->GetHistNBins( mvaRes->
GetSize() ), minVal, maxVal );
2183 histMVAPdfS->
Sumw2();
2184 histMVAPdfB->
Sumw2();
2189 Double_t theWeight = Data()->GetEvent(ievt)->GetWeight();
2191 if (DataInfo().IsSignal(Data()->GetEvent(ievt))) histMVAPdfS->
Fill( theVal, theWeight );
2192 else histMVAPdfB->
Fill( theVal, theWeight );
2201 histMVAPdfS->
Write();
2202 histMVAPdfB->
Write();
2205 fMVAPdfS->BuildPDF ( histMVAPdfS );
2206 fMVAPdfB->BuildPDF ( histMVAPdfB );
2207 fMVAPdfS->ValidatePDF( histMVAPdfS );
2208 fMVAPdfB->ValidatePDF( histMVAPdfB );
2210 if (DataInfo().GetNClasses() == 2) {
2211 Log() << kINFO<<
Form(
"Dataset[%s] : ",DataInfo().GetName())
2212 <<
TString::Format(
"<CreateMVAPdfs> Separation from histogram (PDF): %1.3f (%1.3f)",
2213 GetSeparation( histMVAPdfS, histMVAPdfB ), GetSeparation( fMVAPdfS, fMVAPdfB ) )
2225 if (!fMVAPdfS || !fMVAPdfB) {
2226 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;
2229 Double_t sigFraction = DataInfo().GetTrainingSumSignalWeights() / (DataInfo().GetTrainingSumSignalWeights() + DataInfo().GetTrainingSumBackgrWeights() );
2232 return GetProba(mvaVal,sigFraction);
2240 if (!fMVAPdfS || !fMVAPdfB) {
2241 Log() << kWARNING <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetProba> MVA PDFs for Signal and Background don't exist" <<
Endl;
2244 Double_t p_s = fMVAPdfS->GetVal( mvaVal );
2245 Double_t p_b = fMVAPdfB->GetVal( mvaVal );
2247 Double_t denom = p_s*ap_sig + p_b*(1 - ap_sig);
2249 return (denom > 0) ? (p_s*ap_sig) / denom : -1;
2262 Log() << kWARNING <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetRarity> Required MVA PDF for Signal or Background does not exist: "
2263 <<
"select option \"CreateMVAPdfs\"" <<
Endl;
2278 Data()->SetCurrentType(
type);
2287 if (!list || list->GetSize() < 2) computeArea =
kTRUE;
2288 else if (list->GetSize() > 2) {
2289 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetEfficiency> Wrong number of arguments"
2290 <<
" in string: " << theString
2291 <<
" | required format, e.g., Efficiency:0.05, or empty string" <<
Endl;
2299 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetEfficiency> Binning mismatch between signal and background histos" <<
Endl;
2307 TH1 * effhist = results->
GetHist(
"MVA_HIGHBIN_S");
2314 if (results->
DoesExist(
"MVA_EFF_S")==0) {
2317 TH1* eff_s =
new TH1D( GetTestvarName() +
"_effS", GetTestvarName() +
" (signal)", fNbinsH,
xmin,
xmax );
2318 TH1* eff_b =
new TH1D( GetTestvarName() +
"_effB", GetTestvarName() +
" (background)", fNbinsH,
xmin,
xmax );
2319 results->
Store(eff_s,
"MVA_EFF_S");
2320 results->
Store(eff_b,
"MVA_EFF_B");
2323 Int_t sign = (fCutOrientation == kPositive) ? +1 : -1;
2327 for (
UInt_t ievt=0; ievt<Data()->GetNEvents(); ievt++) {
2330 Bool_t isSignal = DataInfo().IsSignal(GetEvent(ievt));
2331 Float_t theWeight = GetEvent(ievt)->GetWeight();
2332 Float_t theVal = (*mvaRes)[ievt];
2335 TH1* theHist = isSignal ? eff_s : eff_b;
2338 if (isSignal) nevtS+=theWeight;
2342 if (sign > 0 && maxbin > fNbinsH)
continue;
2343 if (sign < 0 && maxbin < 1 )
continue;
2344 if (sign > 0 && maxbin < 1 ) maxbin = 1;
2345 if (sign < 0 && maxbin > fNbinsH) maxbin = fNbinsH;
2350 for (
Int_t ibin=maxbin+1; ibin<=fNbinsH; ibin++) theHist->
AddBinContent( ibin , theWeight );
2352 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetEfficiency> Mismatch in sign" <<
Endl;
2363 TH1* eff_BvsS =
new TH1D( GetTestvarName() +
"_effBvsS", GetTestvarName() +
"", fNbins, 0, 1 );
2364 results->
Store(eff_BvsS,
"MVA_EFF_BvsS");
2369 TH1* rej_BvsS =
new TH1D( GetTestvarName() +
"_rejBvsS", GetTestvarName() +
"", fNbins, 0, 1 );
2370 results->
Store(rej_BvsS);
2372 rej_BvsS->
SetYTitle(
"Backgr rejection (1-eff)" );
2375 TH1* inveff_BvsS =
new TH1D( GetTestvarName() +
"_invBeffvsSeff",
2376 GetTestvarName(), fNbins, 0, 1 );
2377 results->
Store(inveff_BvsS);
2379 inveff_BvsS->
SetYTitle(
"Inverse backgr. eff (1/eff)" );
2385 fSplRefS =
new TSpline1(
"spline2_signal",
new TGraph( eff_s ) );
2386 fSplRefB =
new TSpline1(
"spline2_background",
new TGraph( eff_b ) );
2400 for (
Int_t bini=1; bini<=fNbins; bini++) {
2413 if (effB>std::numeric_limits<double>::epsilon())
2422 Double_t effS = 0., rejB, effS_ = 0., rejB_ = 0.;
2423 Int_t nbins_ = 5000;
2424 for (
Int_t bini=1; bini<=nbins_; bini++) {
2427 effS = (bini - 0.5)/
Float_t(nbins_);
2428 rejB = 1.0 - fSpleffBvsS->Eval( effS );
2431 if ((effS - rejB)*(effS_ - rejB_) < 0)
break;
2438 SetSignalReferenceCut( cut );
2443 if (0 == fSpleffBvsS) {
2449 Double_t effS = 0, effB = 0, effS_ = 0, effB_ = 0;
2450 Int_t nbins_ = 1000;
2456 for (
Int_t bini=1; bini<=nbins_; bini++) {
2459 effS = (bini - 0.5)/
Float_t(nbins_);
2460 effB = fSpleffBvsS->Eval( effS );
2461 integral += (1.0 - effB);
2475 for (
Int_t bini=1; bini<=nbins_; bini++) {
2478 effS = (bini - 0.5)/
Float_t(nbins_);
2479 effB = fSpleffBvsS->Eval( effS );
2482 if ((effB - effBref)*(effB_ - effBref) <= 0)
break;
2488 effS = 0.5*(effS + effS_);
2491 if (nevtS > 0) effSerr =
TMath::Sqrt( effS*(1.0 - effS)/nevtS );
2515 if (list->GetSize() != 2) {
2516 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetTrainingEfficiency> Wrong number of arguments"
2517 <<
" in string: " << theString
2518 <<
" | required format, e.g., Efficiency:0.05" <<
Endl;
2531 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetTrainingEfficiency> Binning mismatch between signal and background histos"
2539 TH1 * effhist = results->
GetHist(
"MVA_HIGHBIN_S");
2544 if (results->
DoesExist(
"MVA_TRAIN_S")==0) {
2550 TH1* mva_s_tr =
new TH1D( GetTestvarName() +
"_Train_S",GetTestvarName() +
"_Train_S", fNbinsMVAoutput, fXmin, sxmax );
2551 TH1* mva_b_tr =
new TH1D( GetTestvarName() +
"_Train_B",GetTestvarName() +
"_Train_B", fNbinsMVAoutput, fXmin, sxmax );
2552 results->
Store(mva_s_tr,
"MVA_TRAIN_S");
2553 results->
Store(mva_b_tr,
"MVA_TRAIN_B");
2558 TH1* mva_eff_tr_s =
new TH1D( GetTestvarName() +
"_trainingEffS", GetTestvarName() +
" (signal)",
2560 TH1* mva_eff_tr_b =
new TH1D( GetTestvarName() +
"_trainingEffB", GetTestvarName() +
" (background)",
2562 results->
Store(mva_eff_tr_s,
"MVA_TRAINEFF_S");
2563 results->
Store(mva_eff_tr_b,
"MVA_TRAINEFF_B");
2566 Int_t sign = (fCutOrientation == kPositive) ? +1 : -1;
2568 std::vector<Double_t> mvaValues = GetMvaValues(0,Data()->GetNEvents());
2569 assert( (
Long64_t) mvaValues.size() == Data()->GetNEvents());
2572 for (
Int_t ievt=0; ievt<Data()->GetNEvents(); ievt++) {
2574 Data()->SetCurrentEvent(ievt);
2575 const Event* ev = GetEvent();
2580 TH1* theEffHist = DataInfo().IsSignal(ev) ? mva_eff_tr_s : mva_eff_tr_b;
2581 TH1* theClsHist = DataInfo().IsSignal(ev) ? mva_s_tr : mva_b_tr;
2583 theClsHist->
Fill( theVal, theWeight );
2587 if (sign > 0 && maxbin > fNbinsH)
continue;
2588 if (sign < 0 && maxbin < 1 )
continue;
2589 if (sign > 0 && maxbin < 1 ) maxbin = 1;
2590 if (sign < 0 && maxbin > fNbinsH) maxbin = fNbinsH;
2592 if (sign > 0)
for (
Int_t ibin=1; ibin<=maxbin; ibin++) theEffHist->
AddBinContent( ibin , theWeight );
2593 else for (
Int_t ibin=maxbin+1; ibin<=fNbinsH; ibin++) theEffHist->
AddBinContent( ibin , theWeight );
2606 TH1* eff_bvss =
new TH1D( GetTestvarName() +
"_trainingEffBvsS", GetTestvarName() +
"", fNbins, 0, 1 );
2608 TH1* rej_bvss =
new TH1D( GetTestvarName() +
"_trainingRejBvsS", GetTestvarName() +
"", fNbins, 0, 1 );
2609 results->
Store(eff_bvss,
"EFF_BVSS_TR");
2610 results->
Store(rej_bvss,
"REJ_BVSS_TR");
2616 if (fSplTrainRefS)
delete fSplTrainRefS;
2617 if (fSplTrainRefB)
delete fSplTrainRefB;
2618 fSplTrainRefS =
new TSpline1(
"spline2_signal",
new TGraph( mva_eff_tr_s ) );
2619 fSplTrainRefB =
new TSpline1(
"spline2_background",
new TGraph( mva_eff_tr_b ) );
2632 fEffS = results->
GetHist(
"MVA_TRAINEFF_S");
2633 for (
Int_t bini=1; bini<=fNbins; bini++) {
2651 fSplTrainEffBvsS =
new TSpline1(
"effBvsS",
new TGraph( eff_bvss ) );
2655 if (0 == fSplTrainEffBvsS)
return 0.0;
2658 Double_t effS = 0., effB, effS_ = 0., effB_ = 0.;
2659 Int_t nbins_ = 1000;
2660 for (
Int_t bini=1; bini<=nbins_; bini++) {
2663 effS = (bini - 0.5)/
Float_t(nbins_);
2664 effB = fSplTrainEffBvsS->Eval( effS );
2667 if ((effB - effBref)*(effB_ - effBref) <= 0)
break;
2672 return 0.5*(effS + effS_);
2681 if (!resMulticlass) Log() << kFATAL<<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"unable to create pointer in GetMulticlassEfficiency, exiting."<<
Endl;
2693 if (!resMulticlass) Log() << kFATAL<<
"unable to create pointer in GetMulticlassTrainingEfficiency, exiting."<<
Endl;
2695 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Determine optimal multiclass cuts for training data..." <<
Endl;
2696 for (
UInt_t icls = 0; icls<DataInfo().GetNClasses(); ++icls) {
2727 Log() << kFATAL <<
"Cannot get confusion matrix for non-multiclass analysis." << std::endl;
2731 Data()->SetCurrentType(
type);
2735 if (resMulticlass ==
nullptr) {
2736 Log() << kFATAL <<
Form(
"Dataset[%s] : ", DataInfo().GetName())
2737 <<
"unable to create pointer in GetMulticlassEfficiency, exiting." <<
Endl;
2752 Double_t rms = sqrt( fRmsS*fRmsS + fRmsB*fRmsB );
2754 return (rms > 0) ?
TMath::Abs(fMeanS - fMeanB)/rms : 0;
2778 if ((!pdfS && pdfB) || (pdfS && !pdfB))
2779 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetSeparation> Mismatch in pdfs" <<
Endl;
2780 if (!pdfS) pdfS = fSplS;
2781 if (!pdfB) pdfB = fSplB;
2783 if (!fSplS || !fSplB) {
2784 Log()<<kDEBUG<<
Form(
"[%s] : ",DataInfo().GetName())<<
"could not calculate the separation, distributions"
2785 <<
" fSplS or fSplB are not yet filled" <<
Endl;
2800 if ((!histS && histB) || (histS && !histB))
2801 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetROCIntegral(TH1D*, TH1D*)> Mismatch in hists" <<
Endl;
2803 if (histS==0 || histB==0)
return 0.;
2816 for (
UInt_t i=0; i<nsteps; i++) {
2822 return integral*step;
2834 if ((!pdfS && pdfB) || (pdfS && !pdfB))
2835 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetSeparation> Mismatch in pdfs" <<
Endl;
2836 if (!pdfS) pdfS = fSplS;
2837 if (!pdfB) pdfB = fSplB;
2839 if (pdfS==0 || pdfB==0)
return 0.;
2848 for (
UInt_t i=0; i<nsteps; i++) {
2852 return integral*step;
2862 Double_t& max_significance_value )
const
2867 Double_t effS(0),effB(0),significance(0);
2868 TH1D *temp_histogram =
new TH1D(
"temp",
"temp", fNbinsH, fXmin, fXmax );
2870 if (SignalEvents <= 0 || BackgroundEvents <= 0) {
2871 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<GetMaximumSignificance> "
2872 <<
"Number of signal or background events is <= 0 ==> abort"
2876 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Using ratio SignalEvents/BackgroundEvents = "
2877 << SignalEvents/BackgroundEvents <<
Endl;
2882 if ( (eff_s==0) || (eff_b==0) ) {
2883 Log() << kWARNING <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Efficiency histograms empty !" <<
Endl;
2884 Log() << kWARNING <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"no maximum cut found, return 0" <<
Endl;
2888 for (
Int_t bin=1; bin<=fNbinsH; bin++) {
2893 significance = sqrt(SignalEvents)*( effS )/sqrt( effS + ( BackgroundEvents / SignalEvents) * effB );
2903 delete temp_histogram;
2905 Log() << kINFO <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"Optimal cut at : " << max_significance <<
Endl;
2906 Log() << kINFO<<
Form(
"Dataset[%s] : ",DataInfo().GetName()) <<
"Maximum significance: " << max_significance_value <<
Endl;
2908 return max_significance;
2922 Data()->SetCurrentType(treeType);
2924 Long64_t entries = Data()->GetNEvents();
2928 Log() << kFATAL <<
Form(
"Dataset[%s] : ",DataInfo().GetName())<<
"<CalculateEstimator> Wrong tree type: " << treeType <<
Endl;
2931 UInt_t varIndex = DataInfo().FindVarIndex( theVarName );
2945 for (
Int_t ievt = 0; ievt < entries; ievt++) {
2947 const Event* ev = GetEvent(ievt);
2952 if (DataInfo().IsSignal(ev)) {
2954 meanS += weight*theVar;
2955 rmsS += weight*theVar*theVar;
2959 meanB += weight*theVar;
2960 rmsB += weight*theVar*theVar;
2966 meanS = meanS/sumwS;
2967 meanB = meanB/sumwB;
2971 Data()->SetCurrentType(previousTreeType);
2981 if (theClassFileName ==
"")
2982 classFileName = GetWeightFileDir() +
"/" + GetJobName() +
"_" + GetMethodName() +
".class.C";
2984 classFileName = theClassFileName;
2988 TString tfname( classFileName );
2990 <<
"Creating standalone class: "
2993 std::ofstream fout( classFileName );
2995 Log() << kFATAL <<
"<MakeClass> Unable to open file: " << classFileName <<
Endl;
3000 fout <<
"// Class: " << className << std::endl;
3001 fout <<
"// Automatically generated by MethodBase::MakeClass" << std::endl <<
"//" << std::endl;
3005 fout <<
"/* configuration options =====================================================" << std::endl << std::endl;
3006 WriteStateToStream( fout );
3008 fout <<
"============================================================================ */" << std::endl;
3011 fout <<
"" << std::endl;
3012 fout <<
"#include <array>" << std::endl;
3013 fout <<
"#include <vector>" << std::endl;
3014 fout <<
"#include <cmath>" << std::endl;
3015 fout <<
"#include <string>" << std::endl;
3016 fout <<
"#include <iostream>" << std::endl;
3017 fout <<
"" << std::endl;
3020 this->MakeClassSpecificHeader( fout, className );
3022 fout <<
"#ifndef IClassifierReader__def" << std::endl;
3023 fout <<
"#define IClassifierReader__def" << std::endl;
3025 fout <<
"class IClassifierReader {" << std::endl;
3027 fout <<
" public:" << std::endl;
3029 fout <<
" // constructor" << std::endl;
3030 fout <<
" IClassifierReader() : fStatusIsClean( true ) {}" << std::endl;
3031 fout <<
" virtual ~IClassifierReader() {}" << std::endl;
3033 fout <<
" // return classifier response" << std::endl;
3035 fout <<
" virtual std::vector<double> GetMulticlassValues( const std::vector<double>& inputValues ) const = 0;" << std::endl;
3037 fout <<
" virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0;" << std::endl;
3040 fout <<
" // returns classifier status" << std::endl;
3041 fout <<
" bool IsStatusClean() const { return fStatusIsClean; }" << std::endl;
3043 fout <<
" protected:" << std::endl;
3045 fout <<
" bool fStatusIsClean;" << std::endl;
3046 fout <<
"};" << std::endl;
3048 fout <<
"#endif" << std::endl;
3050 fout <<
"class " << className <<
" : public IClassifierReader {" << std::endl;
3052 fout <<
" public:" << std::endl;
3054 fout <<
" // constructor" << std::endl;
3055 fout <<
" " << className <<
"( std::vector<std::string>& theInputVars )" << std::endl;
3056 fout <<
" : IClassifierReader()," << std::endl;
3057 fout <<
" fClassName( \"" << className <<
"\" )," << std::endl;
3058 fout <<
" fNvars( " << GetNvar() <<
" )" << std::endl;
3059 fout <<
" {" << std::endl;
3060 fout <<
" // the training input variables" << std::endl;
3061 fout <<
" const char* inputVars[] = { ";
3062 for (
UInt_t ivar=0; ivar<GetNvar(); ivar++) {
3063 fout <<
"\"" << GetOriginalVarName(ivar) <<
"\"";
3064 if (ivar<GetNvar()-1) fout <<
", ";
3066 fout <<
" };" << std::endl;
3068 fout <<
" // sanity checks" << std::endl;
3069 fout <<
" if (theInputVars.size() <= 0) {" << std::endl;
3070 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": empty input vector\" << std::endl;" << std::endl;
3071 fout <<
" fStatusIsClean = false;" << std::endl;
3072 fout <<
" }" << std::endl;
3074 fout <<
" if (theInputVars.size() != fNvars) {" << std::endl;
3075 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": mismatch in number of input values: \"" << std::endl;
3076 fout <<
" << theInputVars.size() << \" != \" << fNvars << std::endl;" << std::endl;
3077 fout <<
" fStatusIsClean = false;" << std::endl;
3078 fout <<
" }" << std::endl;
3080 fout <<
" // validate input variables" << std::endl;
3081 fout <<
" for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) {" << std::endl;
3082 fout <<
" if (theInputVars[ivar] != inputVars[ivar]) {" << std::endl;
3083 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": mismatch in input variable names\" << std::endl" << std::endl;
3084 fout <<
" << \" for variable [\" << ivar << \"]: \" << theInputVars[ivar].c_str() << \" != \" << inputVars[ivar] << std::endl;" << std::endl;
3085 fout <<
" fStatusIsClean = false;" << std::endl;
3086 fout <<
" }" << std::endl;
3087 fout <<
" }" << std::endl;
3089 fout <<
" // initialize min and max vectors (for normalisation)" << std::endl;
3090 for (
UInt_t ivar = 0; ivar < GetNvar(); ivar++) {
3091 fout <<
" fVmin[" << ivar <<
"] = " << std::setprecision(15) << GetXmin( ivar ) <<
";" << std::endl;
3092 fout <<
" fVmax[" << ivar <<
"] = " << std::setprecision(15) << GetXmax( ivar ) <<
";" << std::endl;
3095 fout <<
" // initialize input variable types" << std::endl;
3096 for (
UInt_t ivar=0; ivar<GetNvar(); ivar++) {
3097 fout <<
" fType[" << ivar <<
"] = \'" << DataInfo().GetVariableInfo(ivar).GetVarType() <<
"\';" << std::endl;
3100 fout <<
" // initialize constants" << std::endl;
3101 fout <<
" Initialize();" << std::endl;
3103 if (GetTransformationHandler().GetTransformationList().GetSize() != 0) {
3104 fout <<
" // initialize transformation" << std::endl;
3105 fout <<
" InitTransform();" << std::endl;
3107 fout <<
" }" << std::endl;
3109 fout <<
" // destructor" << std::endl;
3110 fout <<
" virtual ~" << className <<
"() {" << std::endl;
3111 fout <<
" Clear(); // method-specific" << std::endl;
3112 fout <<
" }" << std::endl;
3114 fout <<
" // the classifier response" << std::endl;
3115 fout <<
" // \"inputValues\" is a vector of input values in the same order as the" << std::endl;
3116 fout <<
" // variables given to the constructor" << std::endl;
3118 fout <<
" std::vector<double> GetMulticlassValues( const std::vector<double>& inputValues ) const override;" << std::endl;
3120 fout <<
" double GetMvaValue( const std::vector<double>& inputValues ) const override;" << std::endl;
3123 fout <<
" private:" << std::endl;
3125 fout <<
" // method-specific destructor" << std::endl;
3126 fout <<
" void Clear();" << std::endl;
3128 if (GetTransformationHandler().GetTransformationList().GetSize()!=0) {
3129 fout <<
" // input variable transformation" << std::endl;
3130 GetTransformationHandler().MakeFunction(fout, className,1);
3131 fout <<
" void InitTransform();" << std::endl;
3132 fout <<
" void Transform( std::vector<double> & iv, int sigOrBgd ) const;" << std::endl;
3135 fout <<
" // common member variables" << std::endl;
3136 fout <<
" const char* fClassName;" << std::endl;
3138 fout <<
" const size_t fNvars;" << std::endl;
3139 fout <<
" size_t GetNvar() const { return fNvars; }" << std::endl;
3140 fout <<
" char GetType( int ivar ) const { return fType[ivar]; }" << std::endl;
3142 fout <<
" // normalisation of input variables" << std::endl;
3143 fout <<
" double fVmin[" << GetNvar() <<
"];" << std::endl;
3144 fout <<
" double fVmax[" << GetNvar() <<
"];" << std::endl;
3145 fout <<
" double NormVariable( double x, double xmin, double xmax ) const {" << std::endl;
3146 fout <<
" // normalise to output range: [-1, 1]" << std::endl;
3147 fout <<
" return 2*(x - xmin)/(xmax - xmin) - 1.0;" << std::endl;
3148 fout <<
" }" << std::endl;
3150 fout <<
" // type of input variable: 'F' or 'I'" << std::endl;
3151 fout <<
" char fType[" << GetNvar() <<
"];" << std::endl;
3153 fout <<
" // initialize internal variables" << std::endl;
3154 fout <<
" void Initialize();" << std::endl;
3156 fout <<
" std::vector<double> GetMulticlassValues__( const std::vector<double>& inputValues ) const;" << std::endl;
3158 fout <<
" double GetMvaValue__( const std::vector<double>& inputValues ) const;" << std::endl;
3160 fout <<
"" << std::endl;
3161 fout <<
" // private members (method specific)" << std::endl;
3164 MakeClassSpecific( fout, className );
3167 fout <<
"inline std::vector<double> " << className <<
"::GetMulticlassValues( const std::vector<double>& inputValues ) const" << std::endl;
3169 fout <<
"inline double " << className <<
"::GetMvaValue( const std::vector<double>& inputValues ) const" << std::endl;
3171 fout <<
"{" << std::endl;
3172 fout <<
" // classifier response value" << std::endl;
3174 fout <<
" std::vector<double> retval;" << std::endl;
3176 fout <<
" double retval = 0;" << std::endl;
3179 fout <<
" // classifier response, sanity check first" << std::endl;
3180 fout <<
" if (!IsStatusClean()) {" << std::endl;
3181 fout <<
" std::cout << \"Problem in class \\\"\" << fClassName << \"\\\": cannot return classifier response\"" << std::endl;
3182 fout <<
" << \" because status is dirty\" << std::endl;" << std::endl;
3183 fout <<
" }" << std::endl;
3184 fout <<
" else {" << std::endl;
3185 if (IsNormalised()) {
3186 fout <<
" // normalise variables" << std::endl;
3187 fout <<
" std::vector<double> iV;" << std::endl;
3188 fout <<
" iV.reserve(inputValues.size());" << std::endl;
3189 fout <<
" int ivar = 0;" << std::endl;
3190 fout <<
" for (std::vector<double>::const_iterator varIt = inputValues.begin();" << std::endl;
3191 fout <<
" varIt != inputValues.end(); varIt++, ivar++) {" << std::endl;
3192 fout <<
" iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));" << std::endl;
3193 fout <<
" }" << std::endl;
3194 if (GetTransformationHandler().GetTransformationList().GetSize() != 0 && GetMethodType() !=
Types::kLikelihood &&
3196 fout <<
" Transform( iV, -1 );" << std::endl;
3200 fout <<
" retval = GetMulticlassValues__( iV );" << std::endl;
3202 fout <<
" retval = GetMvaValue__( iV );" << std::endl;
3205 if (GetTransformationHandler().GetTransformationList().GetSize() != 0 && GetMethodType() !=
Types::kLikelihood &&
3207 fout <<
" std::vector<double> iV(inputValues);" << std::endl;
3208 fout <<
" Transform( iV, -1 );" << std::endl;
3210 fout <<
" retval = GetMulticlassValues__( iV );" << std::endl;
3212 fout <<
" retval = GetMvaValue__( iV );" << std::endl;
3216 fout <<
" retval = GetMulticlassValues__( inputValues );" << std::endl;
3218 fout <<
" retval = GetMvaValue__( inputValues );" << std::endl;
3222 fout <<
" }" << std::endl;
3224 fout <<
" return retval;" << std::endl;
3225 fout <<
"}" << std::endl;
3228 if (GetTransformationHandler().GetTransformationList().GetSize()!=0)
3229 GetTransformationHandler().MakeFunction(fout, className,2);
3241 std::streambuf* cout_sbuf = std::cout.rdbuf();
3242 std::ofstream* o = 0;
3243 if (
gConfig().WriteOptionsReference()) {
3244 Log() << kINFO <<
"Print Help message for class " << GetName() <<
" into file: " << GetReferenceFile() <<
Endl;
3245 o =
new std::ofstream( GetReferenceFile(), std::ios::app );
3247 Log() << kFATAL <<
"<PrintHelpMessage> Unable to append to output file: " << GetReferenceFile() <<
Endl;
3249 std::cout.rdbuf( o->rdbuf() );
3254 Log() << kINFO <<
Endl;
3256 <<
"================================================================"
3260 <<
"H e l p f o r M V A m e t h o d [ " << GetName() <<
" ] :"
3265 Log() <<
"Help for MVA method [ " << GetName() <<
" ] :" <<
Endl;
3273 Log() <<
"<Suppress this message by specifying \"!H\" in the booking option>" <<
Endl;
3275 <<
"================================================================"
3282 Log() <<
"# End of Message___" <<
Endl;
3285 std::cout.rdbuf( cout_sbuf );
3300 retval = fSplRefS->Eval( theCut );
3302 else retval = fEffS->GetBinContent( fEffS->FindBin( theCut ) );
3311 if (theCut-fXmin < eps) retval = (GetCutOrientation() == kPositive) ? 1.0 : 0.0;
3312 else if (fXmax-theCut < eps) retval = (GetCutOrientation() == kPositive) ? 0.0 : 1.0;
3325 if (GetTransformationHandler().GetTransformationList().GetEntries() <= 0) {
3326 return (Data()->GetEventCollection(
type));
3333 if (fEventCollections.at(idx) == 0) {
3334 fEventCollections.at(idx) = &(Data()->GetEventCollection(
type));
3335 fEventCollections.at(idx) = GetTransformationHandler().CalcTransformations(*(fEventCollections.at(idx)),
kTRUE);
3337 return *(fEventCollections.at(idx));
3345 UInt_t a = GetTrainingTMVAVersionCode() & 0xff0000;
a>>=16;
3346 UInt_t b = GetTrainingTMVAVersionCode() & 0x00ff00;
b>>=8;
3347 UInt_t c = GetTrainingTMVAVersionCode() & 0x0000ff;
3357 UInt_t a = GetTrainingROOTVersionCode() & 0xff0000;
a>>=16;
3358 UInt_t b = GetTrainingROOTVersionCode() & 0x00ff00;
b>>=8;
3359 UInt_t c = GetTrainingROOTVersionCode() & 0x0000ff;
3370 if (mvaRes != NULL) {
3373 TH1D *mva_s_tr =
dynamic_cast<TH1D*
> (mvaRes->
GetHist(
"MVA_TRAIN_S"));
3374 TH1D *mva_b_tr =
dynamic_cast<TH1D*
> (mvaRes->
GetHist(
"MVA_TRAIN_B"));
3376 if ( !mva_s || !mva_b || !mva_s_tr || !mva_b_tr)
return -1;
3378 if (SorB ==
's' || SorB ==
'S')
const Bool_t Use_Splines_for_Eff_
const Int_t NBIN_HIST_HIGH
#define ROOT_VERSION_CODE
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
char Char_t
Character 1 byte (char)
float Float_t
Float 4 bytes (float)
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
TMatrixT< Double_t > TMatrixD
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TSystem * gSystem
#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.
A TGraph is an object made of two arrays X and Y with npoints each.
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 Int_t GetQuantiles(Int_t n, Double_t *xp, const Double_t *p=nullptr)
Compute Quantiles for this histogram.
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
MsgLogger * fLogger
! message logger
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...
Interface for all concrete MVA method implementations.
Virtual base Class for all MVA method.
TDirectory * MethodBaseDir() const
returns the ROOT directory where all instances of the corresponding MVA method are stored
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
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 ...
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...
virtual Double_t GetSignificance() const
compute significance of mean difference
virtual Double_t GetProba(const Event *ev)
virtual TMatrixD GetMulticlassConfusionMatrix(Double_t effB, Types::ETreeType type)
Construct a confusion matrix for a multiclass classifier.
virtual void WriteEvaluationHistosToFile(Types::ETreeType treetype)
writes all MVA evaluation histograms to file
virtual void TestMulticlass()
test multiclass classification
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)
void AddInfoItem(void *gi, const TString &name, const TString &value) const
xml writing
virtual void AddClassifierOutputProb(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
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
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...
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 ...
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
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)
TString GetWeightFileName() const
retrieve weight file name
virtual void TestClassification()
initialization
void AddOutput(Types::ETreeType type, Types::EAnalysisType analysisType)
virtual void AddRegressionOutput(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
void InitBase()
default initialization called by all constructors
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
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.
void ReadSpectatorsFromXML(void *specnode)
read spectator info from XML
void ReadVariablesFromXML(void *varnode)
read variable info from XML
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.
virtual std::vector< Float_t > GetMulticlassTrainingEfficiency(std::vector< std::vector< Float_t > > &purity)
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 .
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
Double_t GetMvaValue(Double_t *errLower=nullptr, Double_t *errUpper=nullptr) override=0
void AddTargetsXMLTo(void *parent) const
write target info to XML
void ReadTargetsFromXML(void *tarnode)
read target info from XML
void ProcessBaseOptions()
the option string is decoded, for available options see "DeclareOptions"
void ReadStateFromXML(void *parent)
virtual std::vector< Float_t > GetAllRegressionValues()
Get al regression values in one call.
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
void WriteStateToFile() const
write options and weights to file note that each one text file for the main configuration information...
void AddClassesXMLTo(void *parent) const
write class info to XML
virtual void AddClassifierOutput(Types::ETreeType type)
prepare tree branch with the method's discriminating variable
void AddSpectatorsXMLTo(void *parent) const
write spectator info to XML
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
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...
void SetSource(const std::string &source)
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
Root finding using Brents algorithm (translated from CERNLIB function RZERO)
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
virtual const char * GetBuildNode() const
Return the build node name.
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
virtual const char * WorkingDirectory()
Return working directory.
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
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.