73 UInt_t inputSize = fGet.size();
75 if (GetNClasses() <= 1 )
numC = 1;
80 fMin.at(i).resize(inputSize);
81 fMax.at(i).resize(inputSize);
82 fMin.at(i).assign(inputSize, 0);
83 fMax.at(i).assign(inputSize, 0);
92 if (!IsEnabled() || IsCreated())
return kTRUE;
94 Log() << kDEBUG <<
"\tPreparing the transformation." <<
Endl;
98 CalcNormalizationParams( events );
110 if (!IsCreated()) Log() << kFATAL <<
"Transformation not yet created" <<
Endl;
124 std::vector<Char_t>
mask;
127 if (fTransformedEvent==0) fTransformedEvent =
new Event();
134 std::vector<Char_t>::iterator
itMask =
mask.begin();
158 return fTransformedEvent;
166 if (!IsCreated()) Log() << kFATAL <<
"Transformation not yet created" <<
Endl;
171 if (GetNClasses() > 1 )
cls = GetNClasses();
177 std::vector<Char_t>
mask;
180 if (fBackTransformedEvent==0) fBackTransformedEvent =
new Event( *
ev );
203 return fBackTransformedEvent;
211 if (events.size() <= 1)
212 Log() << kFATAL <<
"Not enough events (found " << events.size() <<
") to calculate the normalization" <<
Endl;
215 std::vector<Char_t>
mask;
217 UInt_t inputSize = fGet.size();
234 std::vector<Event*>::const_iterator
evIt = events.begin();
277 std::vector<TString>*
strVec =
new std::vector<TString>(
size);
285 UInt_t idx = (*itGet).second;
293 (*strVec)[
iinp] = str;
306 o <<
"# min max for all variables for all classes one after the other and as a last entry for all classes together" << std::endl;
309 if (GetNClasses() <= 1 )
numC = 1;
311 UInt_t nvars = GetNVariables();
315 o <<
icls << std::endl;
317 o << std::setprecision(12) << std::setw(20) << fMin.at(
icls).at(
ivar) <<
" "
318 << std::setprecision(12) << std::setw(20) << fMax.at(
icls).at(
ivar) << std::endl;
320 o << std::setprecision(12) << std::setw(20) << fMin.at(
icls).at(nvars+
itgt) <<
" "
321 << std::setprecision(12) << std::setw(20) << fMax.at(
icls).at(nvars+
itgt) << std::endl;
323 o <<
"##" << std::endl;
335 Int_t numC = (GetNClasses()<= 1)?1:GetNClasses()+1;
416 fGet.push_back(std::pair<Char_t,UInt_t>(
'v',
ivar));
419 fGet.push_back(std::pair<Char_t,UInt_t>(
't',
itgt));
464 UInt_t nvars = GetNVariables();
466 if(var.size() != nvars)
467 Log() << kFATAL <<
"<BuildTransformationFromVarInfo> can't build transformation,"
468 <<
" since the number of variables disagree" <<
Endl;
470 UInt_t numC = (GetNClasses()<=1)?1:GetNClasses()+1;
471 fMin.clear();fMin.resize(
numC );
472 fMax.clear();fMax.resize(
numC );
476 fMin[
cls].resize(nvars+GetNTargets(),0);
477 fMax[
cls].resize(nvars+GetNTargets(),0);
479 for(std::vector<TMVA::VariableInfo>::const_iterator
v = var.begin();
v!=var.end(); ++
v, ++
vidx) {
482 fGet.push_back(std::pair<Char_t,UInt_t>(
'v',
vidx));
493 UInt_t nvars = GetNVariables();
496 fGet.push_back(std::pair<Char_t,UInt_t>(
'v',
ivar));
499 fGet.push_back(std::pair<Char_t,UInt_t>(
't',
itgt));
503 istr.getline(buf,512);
507 while (!(buf[0]==
'#'&& buf[1]==
'#')) {
509 while (*
p==
' ' || *
p==
'\t')
p++;
510 if (*
p==
'#' || *
p==
'\0') {
511 istr.getline(buf,512);
514 std::stringstream
sstr(buf);
526 istr.getline(buf,512);
541 Log() << kINFO <<
"Transformation for all classes based on these ranges:" <<
Endl;
543 Log() << kINFO <<
"Transformation for class " <<
icls <<
" based on these ranges:" <<
Endl;
546 UInt_t idx = (*itGet).second;
549 Log() <<
typeString.Data() << std::setw(20) << fMin[
icls][idx] << std::setw(20) << fMax[
icls][idx] <<
Endl;
572 fout <<
"//_______________________________________________________________________" << std::endl;
574 fout <<
"{" << std::endl;
577 fout <<
" // Normalization transformation, initialisation" << std::endl;
582 fout <<
" fMin_" <<
trCounter <<
"[" <<
icls <<
"][" <<
ivar <<
"] = " << std::setprecision(12) << min
584 fout <<
" fMax_" <<
trCounter <<
"[" <<
icls <<
"][" <<
ivar <<
"] = " << std::setprecision(12) << max
592 fout <<
"}" << std::endl;
594 fout <<
"//_______________________________________________________________________" << std::endl;
595 fout <<
"inline void " <<
fcncName <<
"::Transform_" <<
trCounter <<
"( std::vector<double>& iv, int cls) const"
597 fout <<
"{" << std::endl;
598 fout <<
" // Normalization transformation" << std::endl;
599 fout <<
" if (cls < 0 || cls > " << GetNClasses() <<
") {" << std::endl;
600 fout <<
" if (" << GetNClasses() <<
" > 1 ) cls = " << GetNClasses() <<
";" << std::endl;
601 fout <<
" else cls = " << (fMin.size() == 1 ? 0 : 2) <<
";" << std::endl;
602 fout <<
" }" << std::endl;
603 fout <<
" const int nVar = " <<
nVar <<
";" << std::endl << std::endl;
604 fout <<
" // get indices of used variables" << std::endl;
606 fout <<
" static std::vector<double> dv;"
608 fout <<
" dv.resize(nVar);" << std::endl;
609 fout <<
" for (int ivar=0; ivar<nVar; ivar++) dv[ivar] = iv[indicesGet.at(ivar)];" << std::endl;
611 fout <<
" for (int ivar=0;ivar<" <<
nVar <<
";ivar++) {" << std::endl;
612 fout <<
" double offset = fOff_" <<
trCounter <<
"[cls][ivar];" << std::endl;
613 fout <<
" double scale = fScal_" <<
trCounter <<
"[cls][ivar];" << std::endl;
614 fout <<
" iv[indicesPut.at(ivar)] = scale*dv[ivar]-offset;" << std::endl;
615 fout <<
" }" << std::endl;
616 fout <<
"}" << std::endl;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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 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 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 offset
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
const_iterator begin() const
const_iterator end() const
Class that contains all the data information.
Singleton class for Global types used by TMVA.
Class for type info of MVA input variable.
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)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.