77 fNumC = (
dsi.GetNClasses()<= 1) ? 1 :
dsi.GetNClasses()+1;
88 std::vector<Ranking*>::const_iterator it = fRanking.begin();
89 for (; it != fRanking.end(); ++it)
delete *it;
91 fTransformations.SetOwner();
100 fLogger->SetSource(
TString(
"TFHandler_" + fCallerName).Data() );
109 fTransformations.Add(
trf);
110 fTransformationsReferenceClasses.push_back(
cls );
127 Log() << kWARNING <<
"Variable \"" << Variable(
ivar).GetExpression()
128 <<
"\" has zero, negative, or NaN RMS^2: "
130 <<
" ==> set to zero. Please check the variable content" <<
Endl;
135 fVariableStats.at(k).at(
ivar) = stat;
144 for (
UInt_t i = 0; i < fTransformationsReferenceClasses.size(); i++) {
145 fTransformationsReferenceClasses.at( i ) =
cls;
155 std::vector<Int_t>::const_iterator
rClsIt = fTransformationsReferenceClasses.
begin();
158 if (
rClsIt == fTransformationsReferenceClasses.
end()) Log() << kFATAL<<
"invalid read in TransformationHandler::Transform " <<
Endl;
169 if (fTransformationsReferenceClasses.empty()){
175 std::vector< Int_t >::const_iterator
rClsIt = fTransformationsReferenceClasses.
end();
176 std::vector<Int_t>::const_iterator
rClsBegin = fTransformationsReferenceClasses.
begin();
181 if (
trf->IsCreated()) {
216 if (fTransformations.GetEntries() <= 0)
223 std::vector<Event*> *
transformedEvents =
new std::vector<TMVA::Event*>(events.size());
228 std::vector< Int_t >::iterator
rClsIt = fTransformationsReferenceClasses.
begin();
264 Log() << kFATAL <<
"No events available to find min, max, mean and rms" <<
Endl;
267 const UInt_t nvar = events[0]->GetNVariables();
349 Log() << std::setw(
maxL) <<
"Variable";
350 Log() <<
" " << std::setw(
maxV) <<
"Mean";
351 Log() <<
" " << std::setw(
maxV) <<
"RMS";
352 Log() <<
" " << std::setw(
maxV) <<
"[ Min ";
353 Log() <<
" " << std::setw(
maxV) <<
" Max ]"<<
Endl;
361 Log() << std::setw(
maxL) << Variable(
ivar).GetLabel() <<
":";
363 Log() << std::setw(
maxL) << Target(
ivar-nvar).GetLabel() <<
":";
393 std::vector< Int_t >::const_iterator
rClsIt = fTransformationsReferenceClasses.
begin();
400 for (
Int_t i=0; i<fTransformations.GetSize(); i++) {
401 fout <<
" void InitTransform_"<<i+1<<
"();" << std::endl;
402 fout <<
" void Transform_"<<i+1<<
"( std::vector<double> & iv, int sigOrBgd ) const;" << std::endl;
407 fout <<
"//_______________________________________________________________________" << std::endl;
408 fout <<
"inline void " <<
fncName <<
"::InitTransform()" << std::endl;
409 fout <<
"{" << std::endl;
410 for (
Int_t i=0; i<fTransformations.GetSize(); i++)
411 fout <<
" InitTransform_"<<i+1<<
"();" << std::endl;
412 fout <<
"}" << std::endl;
414 fout <<
"//_______________________________________________________________________" << std::endl;
415 fout <<
"inline void " <<
fncName <<
"::Transform( std::vector<double>& iv, int sigOrBgd ) const" << std::endl;
416 fout <<
"{" << std::endl;
417 for (
Int_t i=0; i<fTransformations.GetSize(); i++)
418 fout <<
" Transform_"<<i+1<<
"( iv, sigOrBgd );" << std::endl;
420 fout <<
"}" << std::endl;
446 if (fTransformations.GetSize() >= 1) {
447 if (fTransformations.GetSize() > 1 ||
449 xtit +=
" (" + GetName() +
")";
465 Log() << kDEBUG <<
"Plot event variables for ";
467 else Log() << GetName() <<
Endl;
478 const UInt_t nvar = fDataSetInfo.GetNVariables();
479 const UInt_t ntgt = fDataSetInfo.GetNTargets();
480 const Int_t ncls = fDataSetInfo.GetNClasses();
484 std::vector<std::vector<TH1*> >
hVars(
ncls );
485 std::vector<std::vector<std::vector<TH2F*> > >
mycorr(
ncls );
486 std::vector<std::vector<std::vector<TProfile*> > >
myprof(
ncls );
504 if (nvar+
ntgt > (
UInt_t)
gConfig().GetVariablePlotting().fMaxNumOfAllowedVariablesForScatterPlots) {
507 Log() << kINFO <<
"<PlotVariables> Will not produce scatter plots ==> " <<
Endl;
509 <<
"| The number of " << nvar <<
" input variables and " <<
ntgt <<
" target values would require "
512 <<
"| histograms, which would occupy the computer's memory. Note that this" <<
Endl;
514 <<
"| suppression does not have any consequences for your analysis, other" <<
Endl;
516 <<
"| than not disposing of these scatter plots. You can modify the maximum" <<
Endl;
518 <<
"| number of input variables allowed to generate scatter plots in your" <<
Endl;
519 Log() <<
"| script via the command line:" <<
Endl;
521 <<
"| \"(TMVA::gConfig().GetVariablePlotting()).fMaxNumOfAllowedVariablesForScatterPlots = <some int>;\""
524 Log() << kINFO <<
"Some more output" <<
Endl;
542 TString className = fDataSetInfo.GetClassInfo(
cls)->GetName();
545 className += (
ntgt == 1 &&
var_tgt == 1 ?
"_target" :
"");
549 if (
info.GetVarType() ==
'I') {
573 h->GetXaxis()->SetTitle(
gTools().GetXTitleWithUnit( GetVariableAxisTitle(
info ),
info.GetUnit() ) );
578 if (nvar+
ntgt <= (
UInt_t)
gConfig().GetVariablePlotting().fMaxNumOfAllowedVariablesForScatterPlots) {
601 h2->GetXaxis()->SetTitle(
gTools().GetXTitleWithUnit( GetVariableAxisTitle(
info ),
info .GetUnit() ) );
602 h2->GetYaxis()->SetTitle(
gTools().GetXTitleWithUnit( GetVariableAxisTitle(
infoj ),
infoj.GetUnit() ) );
615 p->GetXaxis()->SetTitle(
gTools().GetXTitleWithUnit( GetVariableAxisTitle(
info ),
info .GetUnit() ) );
616 p->GetYaxis()->SetTitle(
gTools().GetXTitleWithUnit( GetVariableAxisTitle(
infoj ),
infoj.GetUnit() ) );
628 std::vector<Double_t>
xregmean ( nvar+1, 0 );
629 std::vector<Double_t>
x2regmean( nvar+1, 0 );
630 std::vector<Double_t>
xCregmean( nvar+1, 0 );
690 fRanking.push_back(
new Ranking( GetName() +
"Transformation",
"|Correlation with target|" ) );
693 fRanking.back()->AddRank(
Rank( fDataSetInfo.GetVariableInfo(
ivar).GetLabel(),
abscor ) );
696 if (nvar+
ntgt <= (
UInt_t)
gConfig().GetVariablePlotting().fMaxNumOfAllowedVariablesForScatterPlots) {
699 fRanking.push_back(
new Ranking( GetName() +
"Transformation",
"Mutual information" ) );
703 fRanking.back()->AddRank(
Rank( fDataSetInfo.GetVariableInfo(
ivar).GetLabel(),
mi ) );
707 fRanking.push_back(
new Ranking( GetName() +
"Transformation",
"Correlation Ratio" ) );
711 fRanking.back()->AddRank(
Rank( fDataSetInfo.GetVariableInfo(
ivar).GetLabel(),
cr ) );
715 fRanking.push_back(
new Ranking( GetName() +
"Transformation",
"Correlation Ratio (T)" ) );
719 fRanking.back()->AddRank(
Rank( fDataSetInfo.GetVariableInfo(
ivar).GetLabel(),
cr ) );
726 else if (fDataSetInfo.GetNClasses() == 2
727 && fDataSetInfo.GetClassInfo(
"Signal") !=
NULL
728 && fDataSetInfo.GetClassInfo(
"Background") !=
NULL
730 fRanking.push_back(
new Ranking( GetName() +
"Transformation",
"Separation" ) );
731 for (
UInt_t i=0; i<nvar; i++) {
733 hVars.at(fDataSetInfo.GetClassInfo(
"Background")->GetNumber()).at(i) );
734 fRanking.back()->AddRank(
Rank(
hVars.at(fDataSetInfo.GetClassInfo(
"Signal")->GetNumber()).at(i)->GetTitle(),
757 Log() << kINFO <<
"A " << o->
ClassName() <<
" with name " << o->
GetName() <<
" already exists in "
770 Log() << kVERBOSE <<
"Create and switch to directory " <<
localDir->GetPath() <<
Endl;
780 hVars.at(
cls).at(i)->SetDirectory(
nullptr);
787 if (nvar+
ntgt <= (
UInt_t)
gConfig().GetVariablePlotting().fMaxNumOfAllowedVariablesForScatterPlots) {
791 Log() << kDEBUG <<
"Create scatter and profile plots in target-file directory: " <<
Endl;
800 mycorr.at(
cls).at(i).at(
j)->SetDirectory(
nullptr);
805 myprof.at(
cls).at(i).at(
j)->SetDirectory(
nullptr);
813 else fRootBaseDir->cd();
823 else return trf->GetTransformationStrings( fTransformationsReferenceClasses.back() );
833 else return trf->GetName();
842 std::vector< Int_t >::const_iterator
rClsIt = fTransformationsReferenceClasses.
begin();
844 o <<
"NTransformtations " << fTransformations.GetSize() << std::endl << std::endl;
849 o <<
"#TR -*-*-*-*-*-*-* transformation " << i++ <<
": " <<
trf->GetName() <<
" -*-*-*-*-*-*-*-" << std::endl;
850 trf->WriteTransformationToStream(o);
851 ci = fDataSetInfo.GetClassInfo( (*
rClsIt) );
855 o <<
"ReferenceClass " <<
clsName << std::endl;
877 Log() << kFATAL <<
"Read transformations not implemented" <<
Endl;
893 if (
trfname ==
"Decorrelation" ) {
899 else if (
trfname ==
"Gauss" ) {
902 else if (
trfname ==
"Uniform" ) {
905 else if (
trfname ==
"Normalize" ) {
908 else if (
trfname ==
"Rearrange" ) {
914 Log() << kFATAL <<
"<ReadFromXML> Variable transform '"
917 newtrf->ReadFromXML( ch );
929 Log() << kINFO <<
"Ranking input variables (method unspecific)..." <<
Endl;
930 std::vector<Ranking*>::const_iterator it = fRanking.begin();
931 for (; it != fRanking.end(); ++it) (*it)->
Print();
939 return fVariableStats.at(
cls).at(
ivar).fMean;
943 return fVariableStats.at(fNumC-1).at(
ivar).fMean;
946 Log() << kWARNING <<
"Inconsistent variable state when reading the mean value. " <<
Endl;
949 Log() << kWARNING <<
"Inconsistent variable state when reading the mean value. Value 0 given back" <<
Endl;
958 return fVariableStats.at(
cls).at(
ivar).fRMS;
962 return fVariableStats.at(fNumC-1).at(
ivar).fRMS;
965 Log() << kWARNING <<
"Inconsistent variable state when reading the RMS value. " <<
Endl;
968 Log() << kWARNING <<
"Inconsistent variable state when reading the RMS value. Value 0 given back" <<
Endl;
977 return fVariableStats.at(
cls).at(
ivar).fMin;
981 return fVariableStats.at(fNumC-1).at(
ivar).fMin;
984 Log() << kWARNING <<
"Inconsistent variable state when reading the minimum value. " <<
Endl;
987 Log() << kWARNING <<
"Inconsistent variable state when reading the minimum value. Value 0 given back" <<
Endl;
996 return fVariableStats.at(
cls).at(
ivar).fMax;
1000 return fVariableStats.at(fNumC-1).at(
ivar).fMax;
1003 Log() << kWARNING <<
"Inconsistent variable state when reading the maximum value. " <<
Endl;
1006 Log() << kWARNING <<
"Inconsistent variable state when reading the maximum value. Value 0 given back" <<
Endl;
const Bool_t kIterBackward
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char x2
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 format
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
const_iterator begin() const
const_iterator end() const
Describe directory structure in memory.
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
2-D histogram with a float per channel (see TH1 documentation)
Class that contains all the information of a class.
Int_t fMaxNumOfAllowedVariablesForScatterPlots
VariablePlotting & GetVariablePlotting()
Class that contains all the data information.
ostringstream derivative to redirect and format output
Ranking for variables in method (implementation)
Class for type info of MVA input variable.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
MsgLogger & Endl(MsgLogger &ml)
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
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.