71 fBackTransformedEvent(0),
72 fVariableTransform(
tf),
77 fVariableTypesAreCounted(
false),
101 if (fTransformedEvent!=0)
delete fTransformedEvent;
102 if (fBackTransformedEvent!=0)
delete fBackTransformedEvent;
117 UInt_t nvars = GetNVariables();
146 fGet.push_back( std::pair<Char_t,UInt_t>(
'v',
ivar) );
152 Log() << kFATAL <<
"You selected variable with index : " << idx <<
" of only " << nvars <<
" variables." <<
Endl;
153 fGet.push_back( std::pair<Char_t,UInt_t>(
'v',idx) );
160 fGet.push_back( std::pair<Char_t,UInt_t>(
't',
itgt) );
166 Log() << kFATAL <<
"You selected target with index : " << idx <<
" of only " <<
ntgts <<
" targets." <<
Endl;
167 fGet.push_back( std::pair<Char_t,UInt_t>(
't',idx) );
174 fGet.push_back( std::pair<Char_t,UInt_t>(
's',
ispct) );
180 Log() << kFATAL <<
"You selected spectator with index : " << idx <<
" of only " <<
nspcts <<
" spectators." <<
Endl;
181 fGet.push_back( std::pair<Char_t,UInt_t>(
's',idx) );
185 ToggleInputSortOrder(
kFALSE );
187 Log() << kINFO <<
"Variable rearrangement set true: Variable order given in transformation option is used for input to transformation!" <<
Endl;
194 fGet.push_back( std::pair<Char_t,UInt_t>(
'v',
ivar) );
201 fGet.push_back( std::pair<Char_t,UInt_t>(
't',
itgt) );
208 fGet.push_back( std::pair<Char_t,UInt_t>(
's',
ispct) );
215 Log() << kWARNING <<
"Error at parsing the options for the variable transformations: Variable/Target/Spectator '" <<
variables.Data() <<
"' not found." <<
Endl;
224 fPut.push_back( std::pair<Char_t,UInt_t>(
'v',idx) );
228 fPut.push_back( std::pair<Char_t,UInt_t>(
't',idx) );
232 fPut.push_back( std::pair<Char_t,UInt_t>(
's',idx) );
238 fPut.push_back( std::pair<Char_t,UInt_t>(
'v',idx) );
242 fPut.push_back( std::pair<Char_t,UInt_t>(
't',idx) );
246 fPut.push_back( std::pair<Char_t,UInt_t>(
's',idx) );
252 fGet.assign( fPut.begin(), fPut.end() );
256 Log() << kHEADER <<
"Transformation, Variable selection : " <<
Endl;
326 input.reserve(fPut.size());
331 input.reserve(fGet.size() );
338 Int_t idx = (*itEntry).second;
352 Log() << kFATAL <<
"VariableTransformBase/GetInput : unknown type '" <<
type <<
"'." <<
Endl;
356 catch(std::out_of_range& ){
357 input.push_back(0.f);
371 std::vector<Char_t>::iterator
itMask =
mask.begin();
398 Int_t idx = (*itEntry).second;
399 if (
itOutput ==
output.
end()) Log() << kFATAL <<
"Read beyond array boundaries in VariableTransformBase::SetOutput"<<
Endl;
404 event->SetVal( idx,
value );
407 event->SetTarget( idx,
value );
410 event->SetSpectator( idx,
value );
413 Log() << kFATAL <<
"VariableTransformBase/GetInput : unknown type '" <<
type <<
"'." <<
Endl;
419 }
catch( std::exception&
except ){
420 Log() << kFATAL <<
"VariableTransformBase/SetOutput : exception/" <<
except.what() <<
Endl;
431 if( fVariableTypesAreCounted ){
454 Log() << kFATAL <<
"VariableTransformBase/GetVariableTypeNumbers : unknown type '" <<
type <<
"'." <<
Endl;
462 fVariableTypesAreCounted =
true;
472 if (!IsCreated())
return;
474 const UInt_t nvars = GetNVariables();
492 Variables().at(
ivar).SetMin(
x);
493 Variables().at(
ivar).SetMax(
x);
496 UpdateNorm(
ivar,
x );
498 x0(
ivar) +=
x*weight;
504 Targets().at(
itgt).SetMin(
x);
505 Targets().at(
itgt).SetMax(
x);
508 UpdateNorm( nvars+
itgt,
x );
510 x0(nvars+
itgt) +=
x*weight;
516 Log() << kFATAL <<
" the sum of event weights calculated for your input is == 0"
517 <<
" or exactly: " <<
sumOfWeights <<
" there is obviously some problem..."<<
Endl;
524 Variables().at(
ivar).SetMean( mean );
526 Log() << kFATAL <<
" the RMS of your input variable " <<
ivar
528 <<
") .. sometimes related to a problem with outliers and negative event weights"
535 Targets().at(
itgt).SetMean( mean );
537 Log() << kFATAL <<
" the RMS of your target variable " <<
itgt
538 <<
" evaluates to an imaginary number: sqrt(" <<
x2(nvars+
itgt)/
sumOfWeights - mean*mean
539 <<
") .. sometimes related to a problem with outliers and negative event weights"
551 v0(
ivar) += weight*(
x-mean)*(
x-mean);
556 v0(nvars+
itgt) += weight*(
x-mean)*(
x-mean);
565 Log() << kINFO <<
"Variable " << Variables().at(
ivar).GetExpression() <<
" variance = " <<
variance <<
Endl;
570 Log() << kINFO <<
"Target " << Targets().at(
itgt).GetExpression() <<
" variance = " <<
variance <<
Endl;
573 Log() << kVERBOSE <<
"Set minNorm/maxNorm for variables to: " <<
Endl;
574 Log() << std::setprecision(3);
576 Log() <<
" " << Variables().at(
ivar).GetInternalName()
577 <<
"\t: [" << Variables().at(
ivar).GetMin() <<
"\t, " << Variables().at(
ivar).GetMax() <<
"\t] " <<
Endl;
578 Log() << kVERBOSE <<
"Set minNorm/maxNorm for targets to: " <<
Endl;
579 Log() << std::setprecision(3);
581 Log() <<
" " << Targets().at(
itgt).GetInternalName()
582 <<
"\t: [" << Targets().at(
itgt).GetMin() <<
"\t, " << Targets().at(
itgt).GetMax() <<
"\t] " <<
Endl;
583 Log() << std::setprecision(5);
593 std::vector<TString>*
strVec =
new std::vector<TString>;
595 strVec->push_back( Variables()[
ivar].GetLabel() +
"_[transformed]");
607 Int_t nvars = fDsi.GetNVariables();
609 if (
x < Variables().at(
ivar).GetMin()) Variables().at(
ivar).SetMin(
x);
610 if (
x > Variables().at(
ivar).GetMax()) Variables().at(
ivar).SetMax(
x);
612 if (
x < Targets().at(
ivar-nvars).GetMin()) Targets().at(
ivar-nvars).SetMin(
x);
613 if (
x > Targets().at(
ivar-nvars).GetMax()) Targets().at(
ivar-nvars).SetMax(
x);
631 UInt_t idx = (*itGet).second;
640 label = fDsi.GetVariableInfo( idx ).GetLabel();
641 expression = fDsi.GetVariableInfo( idx ).GetExpression();
645 label = fDsi.GetTargetInfo( idx ).GetLabel();
646 expression = fDsi.GetTargetInfo( idx ).GetExpression();
650 label = fDsi.GetSpectatorInfo( idx ).GetLabel();
651 expression = fDsi.GetSpectatorInfo( idx ).GetExpression();
654 Log() << kFATAL <<
"VariableTransformBase/AttachXMLTo unknown variable type '" <<
type <<
"'." <<
Endl;
669 UInt_t idx = (*itPut).second;
678 label =
outputDsiPtr->GetVariableInfo( idx ).GetLabel();
679 expression =
outputDsiPtr->GetVariableInfo( idx ).GetExpression();
684 expression =
outputDsiPtr->GetTargetInfo( idx ).GetExpression();
688 label =
outputDsiPtr->GetSpectatorInfo( idx ).GetLabel();
689 expression =
outputDsiPtr->GetSpectatorInfo( idx ).GetExpression();
692 Log() << kFATAL <<
"VariableTransformBase/AttachXMLTo unknown variable type '" <<
type <<
"'." <<
Endl;
713 UInt_t nvars = GetNVariables();
735 if( fDsi.GetVariableInfo(
ivar ).GetLabel() == label ||
736 fDsi.GetVariableInfo(
ivar ).GetExpression() == expression) {
737 fGet.push_back( std::pair<Char_t,UInt_t>(
'v',
ivar) );
743 if( fDsi.GetTargetInfo(
itgt ).GetLabel() == label ||
744 fDsi.GetTargetInfo(
itgt ).GetExpression() == expression ) {
745 fGet.push_back( std::pair<Char_t,UInt_t>(
't',
itgt) );
751 if( fDsi.GetSpectatorInfo(
ispct ).GetLabel() == label ||
752 fDsi.GetSpectatorInfo(
ispct ).GetExpression() == expression ) {
753 fGet.push_back( std::pair<Char_t,UInt_t>(
's',
ispct) );
758 Log() << kFATAL <<
"VariableTransformationBase/ReadFromXML : unknown type '" <<
typeString <<
"'." <<
Endl;
783 if( fDsi.GetVariableInfo(
ivar ).GetLabel() == label ||
784 fDsi.GetVariableInfo(
ivar ).GetExpression() == expression ) {
785 fPut.push_back( std::pair<Char_t,UInt_t>(
'v',
ivar) );
791 if( fDsi.GetTargetInfo(
itgt ).GetLabel() == label ||
792 fDsi.GetTargetInfo(
itgt ).GetExpression() == expression ) {
793 fPut.push_back( std::pair<Char_t,UInt_t>(
't',
itgt) );
799 if( fDsi.GetSpectatorInfo(
ispct ).GetLabel() == label ||
800 fDsi.GetSpectatorInfo(
ispct ).GetExpression() == expression ) {
801 fPut.push_back( std::pair<Char_t,UInt_t>(
's',
ispct) );
806 Log() << kFATAL <<
"VariableTransformationBase/ReadFromXML : unknown type '" <<
typeString <<
"'." <<
Endl;
822 fout <<
" // define the indices of the variables which are transformed by this transformation" << std::endl;
823 fout <<
" static std::vector<int> indicesGet;" << std::endl;
824 fout <<
" static std::vector<int> indicesPut;" << std::endl << std::endl;
825 fout <<
" if ( indicesGet.empty() ) {" << std::endl;
826 fout <<
" indicesGet.reserve(fNvars);" << std::endl;
830 Int_t idx = (*itEntry).second;
834 fout <<
" indicesGet.push_back( " << idx <<
");" << std::endl;
837 Log() << kWARNING <<
"MakeClass doesn't work with transformation of targets. The results will be wrong!" <<
Endl;
840 Log() << kWARNING <<
"MakeClass doesn't work with transformation of spectators. The results will be wrong!" <<
Endl;
843 Log() << kFATAL <<
"VariableTransformBase/GetInput : unknown type '" <<
type <<
"'." <<
Endl;
846 fout <<
" }" << std::endl;
847 fout <<
" if ( indicesPut.empty() ) {" << std::endl;
848 fout <<
" indicesPut.reserve(fNvars);" << std::endl;
852 Int_t idx = (*itEntry).second;
856 fout <<
" indicesPut.push_back( " << idx <<
");" << std::endl;
859 Log() << kWARNING <<
"MakeClass doesn't work with transformation of targets. The results will be wrong!" <<
Endl;
862 Log() << kWARNING <<
"MakeClass doesn't work with transformation of spectators. The results will be wrong!" <<
Endl;
865 Log() << kFATAL <<
"VariableTransformBase/PutInput : unknown type '" <<
type <<
"'." <<
Endl;
869 fout <<
" }" << std::endl;
872 }
else if(
part == 1){
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.