70 fBackTransformedEvent(0),
71 fVariableTransform(
tf),
76 fVariableTypesAreCounted(
false),
100 if (fTransformedEvent!=0)
delete fTransformedEvent;
101 if (fBackTransformedEvent!=0)
delete fBackTransformedEvent;
116 UInt_t nvars = GetNVariables();
145 fGet.push_back( std::pair<Char_t,UInt_t>(
'v',
ivar) );
151 Log() << kFATAL <<
"You selected variable with index : " << idx <<
" of only " << nvars <<
" variables." <<
Endl;
152 fGet.push_back( std::pair<Char_t,UInt_t>(
'v',idx) );
159 fGet.push_back( std::pair<Char_t,UInt_t>(
't',
itgt) );
165 Log() << kFATAL <<
"You selected target with index : " << idx <<
" of only " <<
ntgts <<
" targets." <<
Endl;
166 fGet.push_back( std::pair<Char_t,UInt_t>(
't',idx) );
173 fGet.push_back( std::pair<Char_t,UInt_t>(
's',
ispct) );
179 Log() << kFATAL <<
"You selected spectator with index : " << idx <<
" of only " <<
nspcts <<
" spectators." <<
Endl;
180 fGet.push_back( std::pair<Char_t,UInt_t>(
's',idx) );
184 ToggleInputSortOrder(
kFALSE );
186 Log() << kINFO <<
"Variable rearrangement set true: Variable order given in transformation option is used for input to transformation!" <<
Endl;
193 fGet.push_back( std::pair<Char_t,UInt_t>(
'v',
ivar) );
200 fGet.push_back( std::pair<Char_t,UInt_t>(
't',
itgt) );
207 fGet.push_back( std::pair<Char_t,UInt_t>(
's',
ispct) );
214 Log() << kWARNING <<
"Error at parsing the options for the variable transformations: Variable/Target/Spectator '" <<
variables.Data() <<
"' not found." <<
Endl;
223 fPut.push_back( std::pair<Char_t,UInt_t>(
'v',idx) );
227 fPut.push_back( std::pair<Char_t,UInt_t>(
't',idx) );
231 fPut.push_back( std::pair<Char_t,UInt_t>(
's',idx) );
237 fPut.push_back( std::pair<Char_t,UInt_t>(
'v',idx) );
241 fPut.push_back( std::pair<Char_t,UInt_t>(
't',idx) );
245 fPut.push_back( std::pair<Char_t,UInt_t>(
's',idx) );
251 fGet.assign( fPut.begin(), fPut.end() );
255 Log() << kHEADER <<
"Transformation, Variable selection : " <<
Endl;
325 input.reserve(fPut.size());
330 input.reserve(fGet.size() );
337 Int_t idx = (*itEntry).second;
351 Log() << kFATAL <<
"VariableTransformBase/GetInput : unknown type '" <<
type <<
"'." <<
Endl;
355 catch(std::out_of_range& ){
356 input.push_back(0.f);
370 std::vector<Char_t>::iterator
itMask =
mask.begin();
397 Int_t idx = (*itEntry).second;
398 if (
itOutput ==
output.
end()) Log() << kFATAL <<
"Read beyond array boundaries in VariableTransformBase::SetOutput"<<
Endl;
403 event->SetVal( idx,
value );
406 event->SetTarget( idx,
value );
409 event->SetSpectator( idx,
value );
412 Log() << kFATAL <<
"VariableTransformBase/GetInput : unknown type '" <<
type <<
"'." <<
Endl;
418 }
catch( std::exception&
except ){
419 Log() << kFATAL <<
"VariableTransformBase/SetOutput : exception/" <<
except.what() <<
Endl;
430 if( fVariableTypesAreCounted ){
453 Log() << kFATAL <<
"VariableTransformBase/GetVariableTypeNumbers : unknown type '" <<
type <<
"'." <<
Endl;
461 fVariableTypesAreCounted =
true;
471 if (!IsCreated())
return;
473 const UInt_t nvars = GetNVariables();
491 Variables().at(
ivar).SetMin(
x);
492 Variables().at(
ivar).SetMax(
x);
495 UpdateNorm(
ivar,
x );
497 x0(
ivar) +=
x*weight;
503 Targets().at(
itgt).SetMin(
x);
504 Targets().at(
itgt).SetMax(
x);
507 UpdateNorm( nvars+
itgt,
x );
509 x0(nvars+
itgt) +=
x*weight;
515 Log() << kFATAL <<
" the sum of event weights calculated for your input is == 0"
516 <<
" or exactly: " <<
sumOfWeights <<
" there is obviously some problem..."<<
Endl;
523 Variables().at(
ivar).SetMean( mean );
525 Log() << kFATAL <<
" the RMS of your input variable " <<
ivar
527 <<
") .. sometimes related to a problem with outliers and negative event weights"
534 Targets().at(
itgt).SetMean( mean );
536 Log() << kFATAL <<
" the RMS of your target variable " <<
itgt
537 <<
" evaluates to an imaginary number: sqrt(" <<
x2(nvars+
itgt)/
sumOfWeights - mean*mean
538 <<
") .. sometimes related to a problem with outliers and negative event weights"
550 v0(
ivar) += weight*(
x-mean)*(
x-mean);
555 v0(nvars+
itgt) += weight*(
x-mean)*(
x-mean);
564 Log() << kINFO <<
"Variable " << Variables().at(
ivar).GetExpression() <<
" variance = " <<
variance <<
Endl;
569 Log() << kINFO <<
"Target " << Targets().at(
itgt).GetExpression() <<
" variance = " <<
variance <<
Endl;
572 Log() << kVERBOSE <<
"Set minNorm/maxNorm for variables to: " <<
Endl;
573 Log() << std::setprecision(3);
575 Log() <<
" " << Variables().at(
ivar).GetInternalName()
576 <<
"\t: [" << Variables().at(
ivar).GetMin() <<
"\t, " << Variables().at(
ivar).GetMax() <<
"\t] " <<
Endl;
577 Log() << kVERBOSE <<
"Set minNorm/maxNorm for targets to: " <<
Endl;
578 Log() << std::setprecision(3);
580 Log() <<
" " << Targets().at(
itgt).GetInternalName()
581 <<
"\t: [" << Targets().at(
itgt).GetMin() <<
"\t, " << Targets().at(
itgt).GetMax() <<
"\t] " <<
Endl;
582 Log() << std::setprecision(5);
592 std::vector<TString>*
strVec =
new std::vector<TString>;
594 strVec->push_back( Variables()[
ivar].GetLabel() +
"_[transformed]");
606 Int_t nvars = fDsi.GetNVariables();
608 if (
x < Variables().at(
ivar).GetMin()) Variables().at(
ivar).SetMin(
x);
609 if (
x > Variables().at(
ivar).GetMax()) Variables().at(
ivar).SetMax(
x);
611 if (
x < Targets().at(
ivar-nvars).GetMin()) Targets().at(
ivar-nvars).SetMin(
x);
612 if (
x > Targets().at(
ivar-nvars).GetMax()) Targets().at(
ivar-nvars).SetMax(
x);
630 UInt_t idx = (*itGet).second;
639 label = fDsi.GetVariableInfo( idx ).GetLabel();
640 expression = fDsi.GetVariableInfo( idx ).GetExpression();
644 label = fDsi.GetTargetInfo( idx ).GetLabel();
645 expression = fDsi.GetTargetInfo( idx ).GetExpression();
649 label = fDsi.GetSpectatorInfo( idx ).GetLabel();
650 expression = fDsi.GetSpectatorInfo( idx ).GetExpression();
653 Log() << kFATAL <<
"VariableTransformBase/AttachXMLTo unknown variable type '" <<
type <<
"'." <<
Endl;
668 UInt_t idx = (*itPut).second;
677 label =
outputDsiPtr->GetVariableInfo( idx ).GetLabel();
678 expression =
outputDsiPtr->GetVariableInfo( idx ).GetExpression();
683 expression =
outputDsiPtr->GetTargetInfo( idx ).GetExpression();
687 label =
outputDsiPtr->GetSpectatorInfo( idx ).GetLabel();
688 expression =
outputDsiPtr->GetSpectatorInfo( idx ).GetExpression();
691 Log() << kFATAL <<
"VariableTransformBase/AttachXMLTo unknown variable type '" <<
type <<
"'." <<
Endl;
712 UInt_t nvars = GetNVariables();
734 if( fDsi.GetVariableInfo(
ivar ).GetLabel() == label ||
735 fDsi.GetVariableInfo(
ivar ).GetExpression() == expression) {
736 fGet.push_back( std::pair<Char_t,UInt_t>(
'v',
ivar) );
742 if( fDsi.GetTargetInfo(
itgt ).GetLabel() == label ||
743 fDsi.GetTargetInfo(
itgt ).GetExpression() == expression ) {
744 fGet.push_back( std::pair<Char_t,UInt_t>(
't',
itgt) );
750 if( fDsi.GetSpectatorInfo(
ispct ).GetLabel() == label ||
751 fDsi.GetSpectatorInfo(
ispct ).GetExpression() == expression ) {
752 fGet.push_back( std::pair<Char_t,UInt_t>(
's',
ispct) );
757 Log() << kFATAL <<
"VariableTransformationBase/ReadFromXML : unknown type '" <<
typeString <<
"'." <<
Endl;
782 if( fDsi.GetVariableInfo(
ivar ).GetLabel() == label ||
783 fDsi.GetVariableInfo(
ivar ).GetExpression() == expression ) {
784 fPut.push_back( std::pair<Char_t,UInt_t>(
'v',
ivar) );
790 if( fDsi.GetTargetInfo(
itgt ).GetLabel() == label ||
791 fDsi.GetTargetInfo(
itgt ).GetExpression() == expression ) {
792 fPut.push_back( std::pair<Char_t,UInt_t>(
't',
itgt) );
798 if( fDsi.GetSpectatorInfo(
ispct ).GetLabel() == label ||
799 fDsi.GetSpectatorInfo(
ispct ).GetExpression() == expression ) {
800 fPut.push_back( std::pair<Char_t,UInt_t>(
's',
ispct) );
805 Log() << kFATAL <<
"VariableTransformationBase/ReadFromXML : unknown type '" <<
typeString <<
"'." <<
Endl;
821 fout <<
" // define the indices of the variables which are transformed by this transformation" << std::endl;
822 fout <<
" static std::vector<int> indicesGet;" << std::endl;
823 fout <<
" static std::vector<int> indicesPut;" << std::endl << std::endl;
824 fout <<
" if ( indicesGet.empty() ) {" << std::endl;
825 fout <<
" indicesGet.reserve(fNvars);" << std::endl;
829 Int_t idx = (*itEntry).second;
833 fout <<
" indicesGet.push_back( " << idx <<
");" << std::endl;
836 Log() << kWARNING <<
"MakeClass doesn't work with transformation of targets. The results will be wrong!" <<
Endl;
839 Log() << kWARNING <<
"MakeClass doesn't work with transformation of spectators. The results will be wrong!" <<
Endl;
842 Log() << kFATAL <<
"VariableTransformBase/GetInput : unknown type '" <<
type <<
"'." <<
Endl;
845 fout <<
" }" << std::endl;
846 fout <<
" if ( indicesPut.empty() ) {" << std::endl;
847 fout <<
" indicesPut.reserve(fNvars);" << std::endl;
851 Int_t idx = (*itEntry).second;
855 fout <<
" indicesPut.push_back( " << idx <<
");" << std::endl;
858 Log() << kWARNING <<
"MakeClass doesn't work with transformation of targets. The results will be wrong!" <<
Endl;
861 Log() << kWARNING <<
"MakeClass doesn't work with transformation of spectators. The results will be wrong!" <<
Endl;
864 Log() << kFATAL <<
"VariableTransformBase/PutInput : unknown type '" <<
type <<
"'." <<
Endl;
868 fout <<
" }" << std::endl;
871 }
else if(
part == 1){
char Char_t
Character 1 byte (char)
float Float_t
Float 4 bytes (float)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
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 mask
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 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 type
#define TMVA_VERSION_CODE
const_iterator begin() const
const_iterator end() const
Class that contains all the data information.
UInt_t GetNVariables() const
UInt_t GetNSpectators(bool all=kTRUE) const
UInt_t GetNTargets() const
VariableInfo & GetVariableInfo(Int_t i)
VariableInfo & GetTargetInfo(Int_t i)
VariableInfo & GetSpectatorInfo(Int_t i)
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
Float_t GetSpectator(UInt_t ivar) const
return spectator content
Float_t GetTarget(UInt_t itgt) const
ostringstream derivative to redirect and format output
Class for type info of MVA input variable.
Collectable string class.
Mother of all ROOT objects.
void variables(TString dataset, TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
MsgLogger & Endl(MsgLogger &ml)
Double_t Sqrt(Double_t x)
Returns the square root of x.