33 #ifndef ROOT_TMVA_Config
36 #ifndef ROOT_TMVA_Event
39 #ifndef ROOT_TMVA_Version
45 #ifndef ROOT_TMVA_MsgLogger
73 #if __cplusplus > 199711L
81 #if __cplusplus > 199711L
85 if(! fgTools.compare_exchange_strong(expected,tmp)) {
92 return fgTools?*(fgTools): *(fgTools =
new Tools());
98 #if __cplusplus > 199711L
99 if (fgTools != 0) {
delete fgTools.load(); fgTools=0; }
101 if (fgTools != 0) {
delete fgTools; fgTools=0; }
109 fRegexp(
"$&|!%^&()'<>?= "),
129 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
144 Log() <<
kFATAL <<
"<GetSeparation> signal and background"
145 <<
" histograms have different number of bins: "
155 Log() <<
kFATAL <<
"<GetSeparation> signal and background"
156 <<
" histograms have different or invalid dimensions:" <<
Endl;
164 if (nS > 0 && nB > 0) {
165 for (
Int_t bin=0; bin<nstep; bin++) {
169 if (s + b > 0) separation += 0.5*(s - b)*(s - b)/(s + b);
171 separation *= intBin;
174 Log() <<
kWARNING <<
"<GetSeparation> histograms with zero entries: "
175 << nS <<
" : " << nB <<
" cannot compute separation"
193 Log() <<
kFATAL <<
"<GetSeparation> Mismatch in PDF limits: "
200 for (
Int_t bin=0; bin<nstep; bin++) {
205 if (s + b > 0) separation += (s - b)*(s - b)/(s + b);
207 separation *= (0.5*intBin);
222 Log() <<
kFATAL <<
"<Tools::ComputeStat> value vector is zero pointer" <<
Endl;
224 if ( events.size() != valVec->size() )
225 Log() <<
kWARNING <<
"<Tools::ComputeStat> event and value vector have different lengths "
226 << events.size() <<
"!=" << valVec->size() <<
Endl;
242 xmin_ = *
std::min( valVec->begin(), valVec->end() );
243 xmax_ = *
std::max( valVec->begin(), valVec->end() );
246 for (
Int_t ievt=0; ievt<entries; ievt++) {
251 wgtVecS[nEventsS] = events[ievt]->GetWeight();
252 varVecS[nEventsS++] = theVar;
255 wgtVecB[nEventsB] = events[ievt]->GetWeight();
256 varVecB[nEventsB++] = theVar;
259 if (theVar > xmax) xmax = theVar;
260 if (theVar < xmin) xmin = theVar;
298 d->
Mult( (*si), (*symMat) ); (*d) *= (*s);
303 for (i=0; i<
n; i++) {
304 for (j=0; j<
n; j++) {
306 (i == j && (*d)(i,i) < 0)) {
308 Log() <<
kWARNING <<
"<GetSQRootMatrix> error in matrix diagonalization; printed S and B" <<
Endl;
314 for (i=0; i<
n; i++)
for (j=0; j<
n; j++)
if (j != i) (*d)(i,j) = 0;
320 sqrtMat->
Mult( (*s), (*d) );
339 if (covMat == 0)
return 0;
344 Log() <<
kFATAL <<
"<GetCorrelationMatrix> input matrix not quadratic" <<
Endl;
348 for (
Int_t ivar=0; ivar<nvar; ivar++) {
349 for (
Int_t jvar=0; jvar<nvar; jvar++) {
351 Double_t d = (*covMat)(ivar, ivar)*(*covMat)(jvar, jvar);
352 if (d > 1
E-20) (*corrMat)(ivar, jvar) = (*covMat)(ivar, jvar)/
TMath::Sqrt(d);
354 Log() <<
kWARNING <<
"<GetCorrelationMatrix> zero variances for variables "
355 <<
"(" << ivar <<
", " << jvar <<
")" <<
Endl;
356 (*corrMat)(ivar, jvar) = 0;
360 <<
" Element corr("<<ivar<<
","<<ivar<<
")=" << (*corrMat)(ivar,jvar)
362 <<
" cov("<<ivar<<
","<<ivar<<
")=" <<(*covMat)(ivar, ivar)
363 <<
" cov("<<jvar<<
","<<jvar<<
")=" <<(*covMat)(jvar, jvar)
368 else (*corrMat)(ivar, ivar) = 1.0;
385 TH1* hist =
new TH1F( name, name, nbins, xmin, xmax );
387 theTree->
Project( name, theVarName, cut );
397 if (!theHist)
return 0;
403 if (w > 0) theHist->
Scale( norm/w );
417 while (formatString.
First(sep)==0) formatString.
Remove(0,1);
419 while (formatString.
Length()>0) {
420 if (formatString.
First(sep) == -1) {
428 formatString.
Remove(0,posSep+1);
430 while (formatString.
First(sep)==0) formatString.
Remove(0,1);
441 vector<Int_t>* nodes )
462 Log() <<
kFATAL <<
"<ParseANNOptionString> unrecognized option string: " << theOptions <<
Endl;
466 nodes->push_back( atoi( ((
TObjString*)list->
At(0))->GetString() ) );
474 if (s.
Length() > 1) nodes->push_back( nvar + atoi(&s[1]) );
475 else nodes->push_back( nvar );
477 else if ((a = atoi( s )) > 0) nodes->push_back( atoi(s ) );
479 Log() <<
kFATAL <<
"<ParseANNOptionString> unrecognized option string: " << theOptions <<
Endl;
499 Double_t dev = 0.5*(ys - yh)/(ys + yh);
501 Log() <<
kFATAL <<
"<CheckSplines> Spline failed sanity criterion; "
502 <<
" relative deviation from histogram: " << dev
503 <<
" in (bin, value): (" << ibin <<
", " << x <<
")" <<
Endl;
517 if (a.size() != b.size()) {
520 vector<Double_t>
result(a.size());
530 for (
UInt_t i=0; i<v.size();i++) v[i]*=f;
538 for (
UInt_t i=0; i<v.size();i++) v[i]*=f;
551 UInt_t sizeofarray=
v[0].size();
552 for (
UInt_t i=0; i<sizeofarray; i++) {
553 for (
UInt_t j=sizeofarray-1; j>i; j--) {
554 if (
v[0][j-1] >
v[0][j]) {
555 for (
UInt_t k=0; k< nArrays; k++) {
556 temp =
v[k][j-1];
v[k][j-1] =
v[k][j];
v[k][j] = temp;
559 TString temps = (*vs)[j-1]; (*vs)[j-1] = (*vs)[j]; (*vs)[j] = temps;
578 UInt_t sizeofarray=
v[0].size();
579 for (
UInt_t i=0; i<sizeofarray; i++) {
580 for (
UInt_t j=sizeofarray-1; j>i; j--) {
581 if (
v[0][j-1] <
v[0][j]) {
582 for (
UInt_t k=0; k< nArrays; k++) {
583 temp =
v[k][j-1];
v[k][j-1] =
v[k][j];
v[k][j] = temp;
586 TString temps = (*vs)[j-1]; (*vs)[j-1] = (*vs)[j]; (*vs)[j] = temps;
601 if (hi == 0)
return -1;
609 Int_t maxBinX = h.GetNbinsX();
610 Int_t maxBinY = h.GetNbinsY();
611 for (
Int_t x = 1;
x <= maxBinX;
x++) {
612 for (
Int_t y = 1;
y <= maxBinY;
y++) {
616 if (p_x > 0. && p_y > 0. && p_xy > 0.){
617 mutualInfo += p_xy*
TMath::Log(p_xy / (p_x * p_y));
632 if (hi == 0.)
return -1;
640 Double_t y_mean = h.ProjectionY()->GetMean();
641 for (
Int_t ix=1; ix<=h.GetNbinsX(); ix++) {
642 corrRatio += (h.Integral(ix,ix,1,h.GetNbinsY())/hi)*
pow((GetYMean_binX(h,ix)-y_mean),2);
644 corrRatio /=
pow(h.ProjectionY()->GetRMS(),2);
669 if (h.GetNbinsX() != h.GetNbinsY()) {
670 Log() <<
kFATAL <<
"<TransposeHist> cannot transpose non-quadratic histogram" <<
Endl;
673 TH2F *transposedHisto =
new TH2F( h );
674 for (
Int_t ix=1; ix <= h.GetNbinsX(); ix++){
675 for (
Int_t iy=1; iy <= h.GetNbinsY(); iy++){
676 transposedHisto->SetBinContent(iy,ix,h.GetBinContent(ix,iy));
684 h.GetStats(stats_old);
685 stats_new[0] = stats_old[0];
686 stats_new[1] = stats_old[1];
687 stats_new[2] = stats_old[4];
688 stats_new[3] = stats_old[5];
689 stats_new[4] = stats_old[2];
690 stats_new[5] = stats_old[3];
691 stats_new[6] = stats_old[6];
692 transposedHisto->PutStats(stats_new);
694 return transposedHisto;
724 std::vector<TString>
v = SplitString( s,
':' );
725 for (std::vector<TString>::iterator it = v.begin(); it != v.end(); it++) {
726 if ((*it ==
"v" || *it ==
"verbose") && !it->Contains(
"!")) isVerbose =
kTRUE;
737 vector< vector<Double_t> > vtemp;
739 UsefulSortDescending(vtemp);
748 vector<vector<Double_t> > vtemp;
750 UsefulSortAscending(vtemp);
759 if (v.empty())
return -1;
762 for (
UInt_t i=0; i<v.size(); i++){
776 if (v.empty())
return -1;
779 for (
UInt_t i=0; i<v.size(); i++){
839 static const TString gClr_none =
"" ;
840 static const TString gClr_white =
"\033[1;37m";
841 static const TString gClr_black =
"\033[30m";
842 static const TString gClr_blue =
"\033[34m";
843 static const TString gClr_red =
"\033[1;31m" ;
844 static const TString gClr_yellow =
"\033[1;33m";
845 static const TString gClr_darkred =
"\033[31m";
846 static const TString gClr_darkgreen =
"\033[32m";
847 static const TString gClr_darkyellow =
"\033[33m";
849 static const TString gClr_bold =
"\033[1m" ;
850 static const TString gClr_black_b =
"\033[30m" ;
851 static const TString gClr_lblue_b =
"\033[1;34m" ;
852 static const TString gClr_cyan_b =
"\033[0;36m" ;
853 static const TString gClr_lgreen_b =
"\033[1;32m";
855 static const TString gClr_blue_bg =
"\033[44m";
856 static const TString gClr_red_bg =
"\033[1;41m";
857 static const TString gClr_whiteonblue =
"\033[1;44m";
858 static const TString gClr_whiteongreen =
"\033[1;42m";
859 static const TString gClr_grey_bg =
"\033[47m";
861 static const TString gClr_reset =
"\033[0m";
863 if (!
gConfig().UseColor())
return gClr_none;
865 if (c ==
"white" )
return gClr_white;
866 if (c ==
"blue" )
return gClr_blue;
867 if (c ==
"black" )
return gClr_black;
868 if (c ==
"lightblue")
return gClr_cyan_b;
869 if (c ==
"yellow")
return gClr_yellow;
870 if (c ==
"red" )
return gClr_red;
871 if (c ==
"dred" )
return gClr_darkred;
872 if (c ==
"dgreen")
return gClr_darkgreen;
873 if (c ==
"lgreenb")
return gClr_lgreen_b;
874 if (c ==
"dyellow")
return gClr_darkyellow;
876 if (c ==
"bold")
return gClr_bold;
877 if (c ==
"bblack")
return gClr_black_b;
879 if (c ==
"blue_bgd")
return gClr_blue_bg;
880 if (c ==
"red_bgd" )
return gClr_red_bg;
882 if (c ==
"white_on_blue" )
return gClr_whiteonblue;
883 if (c ==
"white_on_green")
return gClr_whiteongreen;
885 if (c ==
"reset")
return gClr_reset;
887 std::cout <<
"Unknown color " << c << std::endl;
902 if ((
UInt_t)values.size() != nvar) {
903 logger <<
kFATAL <<
"<FormattedOutput> fatal error with dimensions: "
904 << values.size() <<
" OR " <<
" != " << nvar <<
Endl;
909 std::vector<UInt_t> vLengths;
918 UInt_t clen = maxL + maxV + 3;
921 for (
UInt_t i=0; i<clen; i++) logger <<
"-";
925 logger << setw(maxL) << titleVars <<
":";
926 logger << setw(maxV+1) << titleValues <<
":";
928 for (
UInt_t i=0; i<clen; i++) logger <<
"-";
932 for (
UInt_t irow=0; irow<nvar; irow++) {
933 logger << setw(maxL) << V[irow] <<
":";
934 logger << setw(maxV+1) <<
Form( format.
Data(), values[irow] );
939 for (
UInt_t i=0; i<clen; i++) logger <<
"-";
951 logger <<
kFATAL <<
"<FormattedOutput> fatal error with dimensions: "
958 std::vector<UInt_t> vLengths;
959 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
966 for (
UInt_t icol=0; icol<nvar; icol++) clen += vLengths[icol]+1;
969 for (
UInt_t i=0; i<clen; i++) logger <<
"-";
973 logger << setw(maxL+1) <<
" ";
974 for (
UInt_t icol=0; icol<nvar; icol++) logger << setw(vLengths[icol]+1) << V[icol];
978 for (
UInt_t irow=0; irow<nvar; irow++) {
979 logger << setw(maxL) << V[irow] <<
":";
980 for (
UInt_t icol=0; icol<nvar; icol++) {
981 logger << setw(vLengths[icol]+1) <<
Form(
"%+1.3f", M(irow,icol) );
987 for (
UInt_t i=0; i<clen; i++) logger <<
"-";
995 const std::vector<TString>& vert,
const std::vector<TString>& horiz,
999 UInt_t nvvar = vert.size();
1000 UInt_t nhvar = horiz.size();
1005 std::vector<UInt_t> vLengths;
1006 for (
UInt_t ivar=0; ivar<nvvar; ivar++) {
1014 std::vector<UInt_t> hLengths;
1015 for (
UInt_t ivar=0; ivar<nhvar; ivar++) {
1017 maxLh =
TMath::Max( hLengths.back(), maxLh );
1021 for (
UInt_t icol=0; icol<nhvar; icol++) clen += hLengths[icol]+1;
1024 for (
UInt_t i=0; i<clen; i++) logger <<
"-";
1028 logger << setw(maxL+1) <<
" ";
1029 for (
UInt_t icol=0; icol<nhvar; icol++) logger << setw(hLengths[icol]+1) << horiz[icol];
1033 for (
UInt_t irow=0; irow<nvvar; irow++) {
1034 logger << setw(maxL) << vert[irow] <<
":";
1035 for (
UInt_t icol=0; icol<nhvar; icol++) {
1036 logger << setw(hLengths[icol]+1) <<
Form(
"%+1.3f", M(irow,icol) );
1042 for (
UInt_t i=0; i<clen; i++) logger <<
"-";
1051 return ( unit ==
"" ? title : ( title +
" [" + unit +
"]" ) );
1059 TString retval = ( normalised ?
"(1/N) " :
"" );
1069 os << val <<
" :: ";
1071 for (
int i=0; i<4; i++) {
1072 Int_t ic = *((
char*)c+i)-
'\0';
1090 for (
int i=0; i<4; i++) {
1092 *((
char*)ap+i) =
'\0'+c[i];
1106 return xmlengine().HasAttr(node, attrname);
1114 if (!HasAttr(node, attrname)) {
1115 const char * nodename = xmlengine().GetNodeName(node);
1116 Log() <<
kFATAL <<
"Trying to read non-existing attribute '" << attrname <<
"' from xml node '" << nodename <<
"'" <<
Endl;
1118 const char* val = xmlengine().GetAttr(node, attrname);
1127 if( node == 0 )
return;
1136 if( !isRootNode && parent == 0 )
return 0;
1143 if( node == 0 )
return kFALSE;
1151 void*
par = xmlengine().GetParent(child);
1160 void* ch = xmlengine().GetChild(parent);
1161 if (childname != 0) {
1162 while (ch!=0 && strcmp(xmlengine().GetNodeName(ch),childname) != 0) ch = xmlengine().GetNext(ch);
1172 void* ch = xmlengine().GetNext(prevchild);
1173 if (childname != 0) {
1174 while (ch!=0 && strcmp(xmlengine().GetNodeName(ch),childname)!=0) ch = xmlengine().GetNext(ch);
1184 return xmlengine().GetNodeContent(node);
1192 return xmlengine().GetNodeName(node);
1200 return xmlengine().AddRawLine( node, raw );
1209 std::vector<TString> splitV;
1213 while (splitOpt.
Length()>0) {
1214 if ( !splitOpt.
Contains(separator) ) {
1215 splitV.push_back(splitOpt);
1219 TString toSave = splitOpt(0,splitOpt.
First(separator));
1220 splitV.push_back(toSave);
1221 splitOpt = splitOpt(splitOpt.
First(separator),splitOpt.
Length());
1233 std::stringstream s;
1235 return TString(s.str().c_str());
1243 std::stringstream s;
1244 s <<
Form(
"%5.8e", d );
1245 return TString(s.str().c_str());
1253 void* matnode = xmlengine().NewChild(node, 0, name);
1254 xmlengine().NewAttr(matnode,0,
"Rows", StringFromInt(mat->
GetNrows()) );
1255 xmlengine().NewAttr(matnode,0,
"Columns", StringFromInt(mat->
GetNcols()) );
1256 std::stringstream s;
1259 s <<
Form(
"%5.15e ", (*mat)[
row][col] );
1262 xmlengine().AddRawLine( matnode, s.str().c_str() );
1270 WriteTMatrixDToXML( node, name, &mat );
1278 ReadTMatrixDFromXML( node, name, &mat );
1279 for (
int i=0;i<vec->
GetNoElements();++i) (*vec)[i] = mat[0][i];
1286 if (strcmp(xmlengine().GetNodeName(node),name)!=0){
1287 Log() <<
kWARNING <<
"Possible Error: Name of matrix in weight file"
1288 <<
" does not match name of matrix passed as argument!" <<
Endl;
1291 ReadAttr( node,
"Rows", nrows );
1292 ReadAttr( node,
"Columns", ncols );
1294 Log() <<
kWARNING <<
"Possible Error: Dimension of matrix in weight file"
1295 <<
" does not match dimension of matrix passed as argument!" <<
Endl;
1298 const char* content = xmlengine().GetNodeContent(node);
1299 std::stringstream s(content);
1301 for (
Int_t col = 0; col<ncols; col++) {
1302 s >> (*mat)[
row][col];
1312 std::cout << std::endl;
1313 std::cout <<
Color(
"bold") <<
"TMVA -- Toolkit for Multivariate Data Analysis" <<
Color(
"reset") << std::endl;
1315 std::cout <<
" " <<
"Copyright (C) 2005-2010 CERN, MPI-K Heidelberg, Us of Bonn and Victoria" << std::endl;
1316 std::cout <<
" " <<
"Home page: http://tmva.sf.net" << std::endl;
1317 std::cout <<
" " <<
"Citation info: http://tmva.sf.net/citeTMVA.html" << std::endl;
1318 std::cout <<
" " <<
"License: http://tmva.sf.net/LICENSE" << std::endl << std::endl;
1335 static const char *
const months[] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
1336 "Jun",
"Jul",
"Aug",
"Sep",
"Oct",
1339 Int_t iday = idatqq%100;
1340 Int_t imonth = (idatqq/100)%100;
1341 Int_t iyear = (idatqq/10000);
1342 TString versionDate =
Form(
"%s %d, %4d",months[imonth-1],iday,iyear);
1344 logger <<
"You are running ROOT Version: " <<
gROOT->GetVersion() <<
", " << versionDate <<
Endl;
1355 case kStandardWelcomeMsg:
1356 logger <<
Color(
"white") <<
"TMVA -- Toolkit for Multivariate Analysis" <<
Color(
"reset") <<
Endl;
1357 logger <<
"Copyright (C) 2005-2006 CERN, LAPP & MPI-K Heidelberg and Victoria U." <<
Endl;
1358 logger <<
"Home page http://tmva.sourceforge.net" <<
Endl;
1359 logger <<
"All rights reserved, please read http://tmva.sf.net/license.txt" << Endl <<
Endl;
1362 case kIsometricWelcomeMsg:
1363 logger <<
" ___ ___ ___ ___ " <<
Endl;
1364 logger <<
" /\\ \\ /\\__\\ /\\__\\ /\\ \\ " <<
Endl;
1365 logger <<
" \\:\\ \\ /::| | /:/ / /::\\ \\ " <<
Endl;
1366 logger <<
" \\:\\ \\ /:|:| | /:/ / /:/\\:\\ \\ " <<
Endl;
1367 logger <<
" /::\\ \\ /:/|:|__|__ /:/__/ ___ /::\\~\\:\\ \\ " <<
Endl;
1368 logger <<
" /:/\\:\\__\\ /:/ |::::\\__\\ |:| | /\\__\\ /:/\\:\\ \\:\\__\\ " <<
Endl;
1369 logger <<
" /:/ \\/__/ \\/__/~~/:/ / |:| |/:/ / \\/__\\:\\/:/ / " <<
Endl;
1370 logger <<
"/:/ / /:/ / |:|__/:/ / \\::/ / " <<
Endl;
1371 logger <<
"\\/__/ /:/ / \\::::/__/ /:/ / " <<
Endl;
1372 logger <<
" /:/ / ~~~~ /:/ / " <<
Endl;
1373 logger <<
" \\/__/ \\/__/ " << Endl <<
Endl;
1376 case kBlockWelcomeMsg:
1378 logger <<
"_|_|_|_|_| _| _| _| _| _|_| " <<
Endl;
1379 logger <<
" _| _|_| _|_| _| _| _| _| " <<
Endl;
1380 logger <<
" _| _| _| _| _| _| _|_|_|_| " <<
Endl;
1381 logger <<
" _| _| _| _| _| _| _| " <<
Endl;
1382 logger <<
" _| _| _| _| _| _| " << Endl <<
Endl;
1385 case kLeanWelcomeMsg:
1387 logger <<
"_/_/_/_/_/ _/ _/ _/ _/ _/_/ " <<
Endl;
1388 logger <<
" _/ _/_/ _/_/ _/ _/ _/ _/ " <<
Endl;
1389 logger <<
" _/ _/ _/ _/ _/ _/ _/_/_/_/ " <<
Endl;
1390 logger <<
" _/ _/ _/ _/ _/ _/ _/ " <<
Endl;
1391 logger <<
"_/ _/ _/ _/ _/ _/ " << Endl <<
Endl;
1394 case kLogoWelcomeMsg:
1396 logger <<
"_/_/_/_/_/ _| _| _| _| _|_| " <<
Endl;
1397 logger <<
" _/ _|_| _|_| _| _| _| _| " <<
Endl;
1398 logger <<
" _/ _| _| _| _| _| _|_|_|_| " <<
Endl;
1399 logger <<
" _/ _| _| _| _| _| _| " <<
Endl;
1400 logger <<
"_/ _| _| _| _| _| " << Endl <<
Endl;
1403 case kSmall1WelcomeMsg:
1404 logger <<
" _____ __ ____ ___ " <<
Endl;
1405 logger <<
"|_ _| \\/ \\ \\ / /_\\ " <<
Endl;
1406 logger <<
" | | | |\\/| |\\ V / _ \\ " <<
Endl;
1407 logger <<
" |_| |_| |_| \\_/_/ \\_\\" << Endl <<
Endl;
1410 case kSmall2WelcomeMsg:
1411 logger <<
" _____ __ ____ ___ " <<
Endl;
1412 logger <<
"|_ _| \\/ \\ \\ / / \\ " <<
Endl;
1413 logger <<
" | | | |\\/| |\\ \\ / / _ \\ " <<
Endl;
1414 logger <<
" | | | | | | \\ V / ___ \\ " <<
Endl;
1415 logger <<
" |_| |_| |_| \\_/_/ \\_\\ " << Endl <<
Endl;
1418 case kOriginalWelcomeMsgColor:
1420 <<
"_______________________________________" <<
Color(
"reset") <<
Endl;
1424 <<
"|\\ /|| \\ // /\\\\\\\\\\\\\\\\\\\\\\\\ \\ \\ \\ " <<
Color(
"reset") <<
Endl;
1428 <<
"| \\/ || \\// /--\\\\\\\\\\\\\\\\\\\\\\\\ \\ \\ \\" <<
Color(
"reset") <<
Endl;
1431 case kOriginalWelcomeMsgBW:
1432 logger <<
kINFO <<
""
1433 <<
"_______________________________________" <<
Endl;
1434 logger <<
kINFO <<
" // "
1435 <<
"|\\ /|| \\ // /\\\\\\\\\\\\\\\\\\\\\\\\ \\ \\ \\ " <<
Endl;
1436 logger <<
kINFO <<
"// "
1437 <<
"| \\/ || \\// /--\\\\\\\\\\\\\\\\\\\\\\\\ \\ \\ \\" <<
Endl;
1441 logger <<
kFATAL <<
"unknown message type: " << msgType <<
Endl;
1453 logger <<
"A. Hoecker, P. Speckmayer, J. Stelzer, J. Therhaag, E. von Toerne, H. Voss" <<
Endl;
1454 logger <<
"\"TMVA - Toolkit for Multivariate Data Analysis\" PoS ACAT:040,2007. e-Print: physics/0703039" <<
Endl;
1458 logger <<
"@Article{TMVA2007," <<
Endl;
1459 logger <<
" author = \"Hoecker, Andreas and Speckmayer, Peter and Stelzer, Joerg " <<
Endl;
1460 logger <<
" and Therhaag, Jan and von Toerne, Eckhard and Voss, Helge\"," <<
Endl;
1461 logger <<
" title = \"{TMVA: Toolkit for multivariate data analysis}\"," <<
Endl;
1462 logger <<
" journal = \"PoS\"," <<
Endl;
1463 logger <<
" volume = \"ACAT\"," <<
Endl;
1464 logger <<
" year = \"2007\"," <<
Endl;
1465 logger <<
" pages = \"040\"," <<
Endl;
1466 logger <<
" eprint = \"physics/0703039\"," <<
Endl;
1467 logger <<
" archivePrefix = \"arXiv\"," <<
Endl;
1468 logger <<
" SLACcitation = \"%%CITATION = PHYSICS/0703039;%%\"" <<
Endl;
1469 logger <<
"}" <<
Endl;
1473 logger <<
"%\\cite{TMVA2007}" <<
Endl;
1474 logger <<
"\\bibitem{TMVA2007}" <<
Endl;
1475 logger <<
" A.~Hoecker, P.~Speckmayer, J.~Stelzer, J.~Therhaag, E.~von Toerne, H.~Voss" <<
Endl;
1476 logger <<
" %``TMVA: Toolkit for multivariate data analysis,''" <<
Endl;
1477 logger <<
" PoS A {\\bf CAT} (2007) 040" <<
Endl;
1478 logger <<
" [arXiv:physics/0703039]." <<
Endl;
1479 logger <<
" %%CITATION = POSCI,ACAT,040;%%" <<
Endl;
1487 <<
"For citation information, please visit: http://tmva.sf.net/citeTMVA.html"
1501 std::vector<TMatrixDSym*>*
1504 std::vector<Event*> eventVector;
1505 for (std::vector<const Event*>::const_iterator it = events.begin(), itEnd = events.end(); it != itEnd; ++it)
1507 eventVector.push_back (
new Event(*(*it)));
1509 std::vector<TMatrixDSym*>* returnValue = CalcCovarianceMatrices (eventVector, maxCls, transformBase);
1510 for (std::vector<Event*>::const_iterator it = eventVector.begin(), itEnd = eventVector.end(); it != itEnd; ++it)
1520 std::vector<TMatrixDSym*>*
1523 if (events.empty()) {
1524 Log() <<
kWARNING <<
" Asked to calculate a covariance matrix for an empty event vectors.. sorry cannot do that -> return NULL"<<
Endl;
1528 UInt_t nvars=0, ntgts=0, nspcts=0;
1532 nvars =events.at(0)->GetNVariables ();
1533 ntgts =events.at(0)->GetNTargets ();
1534 nspcts=events.at(0)->GetNSpectators();
1539 Int_t matNum = maxCls;
1540 if (maxCls > 1 ) matNum++;
1542 std::vector<TVectorD*>* vec =
new std::vector<TVectorD*>(matNum);
1543 std::vector<TMatrixD*>* mat2 =
new std::vector<TMatrixD*>(matNum);
1544 std::vector<Double_t> count(matNum);
1545 count.assign(matNum,0);
1551 for (cls = 0; cls < matNum ; cls++) {
1552 vec->at(cls) =
new TVectorD(nvars);
1553 mat2->at(cls) =
new TMatrixD(nvars,nvars);
1557 for (ivar=0; ivar<nvars; ivar++) {
1559 for (jvar=0; jvar<nvars; jvar++) {
1560 (*m)(ivar, jvar) = 0;
1566 for (
UInt_t i=0; i<events.size(); i++) {
1569 const Event * ev = events[i];
1573 std::vector<Float_t> input;
1574 std::vector<Char_t> mask;
1576 if (transformBase) {
1577 transformBase->
GetInput (ev, input, mask);
1579 for (ivar=0; ivar<nvars; ++ivar) {
1580 input.push_back (ev->
GetValue(ivar));
1585 v = vec->at(matNum-1);
1586 m = mat2->at(matNum-1);
1588 count.at(matNum-1)+=weight;
1589 for (ivar=0; ivar<nvars; ivar++) {
1592 (*v)(ivar) += xi*weight;
1593 (*m)(ivar, ivar) += (xi*xi*weight);
1595 for (jvar=ivar+1; jvar<nvars; jvar++) {
1597 (*m)(ivar, jvar) += (xi*xj*weight);
1598 (*m)(jvar, ivar) = (*m)(ivar, jvar);
1603 count.at(cls)+=weight;
1606 for (ivar=0; ivar<nvars; ivar++) {
1608 (*v)(ivar) += xi*weight;
1609 (*m)(ivar, ivar) += (xi*xi*weight);
1611 for (jvar=ivar+1; jvar<nvars; jvar++) {
1613 (*m)(ivar, jvar) += (xi*xj*weight);
1614 (*m)(jvar, ivar) = (*m)(ivar, jvar);
1620 std::vector<TMatrixDSym*>* mat =
new std::vector<TMatrixDSym*>(matNum);
1621 for (cls = 0; cls < matNum; cls++) {
1628 for (ivar=0; ivar<nvars; ivar++) {
1629 for (jvar=0; jvar<nvars; jvar++) {
1630 (*(mat->at(cls)))(ivar, jvar) = (*m)(ivar, jvar)/n - (*v)(ivar)*(*v)(jvar)/(n*n);
1643 template <
typename Iterator,
typename WeightIterator>
1655 while ( first != last )
1667 ::Error(
"TMVA::Tools::Mean",
"sum of weights <= 0 ?! that's a bit too much of negative event weights :) ");
1673 while ( first != last )
1679 sum += (*w) * (*first);
1686 ::Error(
"TMVA::Tools::Mean",
"sum of weights <= 0 ?! that's a bit too much of negative event weights :) ");
1693 template <
typename T>
1705 template <
typename Iterator,
typename WeightIterator>
1719 while ( first != last ) {
1722 sum2 += adouble*adouble;
1729 while ( first != last ) {
1731 sum += adouble * (*w);
1732 sum2 += adouble*adouble * (*w);
1744 template <
typename T>
1769 for (
Int_t ibinEnd=1, ibin=cumulativeDist->
GetNbinsX(); ibin >=ibinEnd ; ibin--){
1771 if (val>0) inverseSum += val;
1773 inverseSum = 1/inverseSum;
1775 for (
Int_t ibinEnd=1, ibin=cumulativeDist->
GetNbinsX(); ibin >=ibinEnd ; ibin--){
1777 if (val>0) partialSum += val;
1780 return cumulativeDist;
virtual const char * GetTitle() const
Returns title of object.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
MsgLogger & Endl(MsgLogger &ml)
TMatrixT< Element > & Transpose(const TMatrixT< Element > &source)
Transpose matrix source.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Collectable string class.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Base class for spline implementation containing the Draw/Paint methods //.
std::vector< double > values
void ToUpper()
Change string to upper case.
void ToLower()
Change string to lower-case.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Double_t GetWeight() const
return the event weight - depending on whether the flag IgnoreNegWeightsInTraining is or not...
Bool_t AddComment(XMLNodePointer_t parent, const char *comment)
Adds comment line to the node.
virtual Int_t GetNbinsX() const
static std::string format(double x, double y, int digits, int width)
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1)
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
const char * Data() const
Double_t RMS(Long64_t n, const T *a, const Double_t *w=0)
RooCmdArg Color(Color_t color)
double pow(double, double)
std::vector< std::vector< double > > Data
TH1D * ProjectionY(const char *name="_py", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const
Project a 2-D histogram into a 1-D histogram along Y.
void Error(const char *location, const char *msgfmt,...)
TVectorT< Double_t > TVectorD
TMatrixT< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
TMatrixT< Double_t > TMatrixD
virtual Double_t GetBinCenter(Int_t bin) const
return bin center for 1D historam Better to use h1.GetXaxis().GetBinCenter(bin)
Service class for 2-Dim histogram classes.
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
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...
Double_t Mean(Long64_t n, const T *a, const Double_t *w=0)
char * Form(const char *fmt,...)
virtual Double_t GetSumOfWeights() const
Return the sum of weights excluding under/overflows.
virtual Int_t GetSumw2N() const
TSubString Strip(EStripType s=kTrailing, char c= ' ') const
Return a substring of self stripped at beginning and/or end.
virtual Double_t Eval(Double_t x) const =0
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
TString & Remove(Ssiz_t pos)
XMLAttrPointer_t NewAttr(XMLNodePointer_t xmlnode, XMLNsPointer_t, const char *name, const char *value)
creates new attribute for xmlnode, namespaces are not supported for attributes
virtual Int_t GetSize() const
Double_t GetVal(Double_t x) const
returns value PDF(x)
const TMatrixD & GetEigenVectors() const
TMatrixTSym< Double_t > TMatrixDSym
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
#define TMVA_RELEASE_DATE
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
virtual Int_t GetNbinsY() const
Int_t GetNoElements() const
virtual void Add(TObject *obj)
Short_t Max(Short_t a, Short_t b)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
XMLNodePointer_t NewChild(XMLNodePointer_t parent, XMLNsPointer_t ns, const char *name, const char *content=0)
create new child element for parent node
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
ClassImp(TSlaveInfo) Int_t TSlaveInfo const TSlaveInfo * si
Used to sort slaveinfos by ordinal.
TString()
TString default ctor.
A TTree object has a header with a name and a title.
float type_of_call hi(const int &, const int &)
const TArrayD * GetXbins() const
void Mult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Create a matrix C such that C = A * B.
Double_t Sqrt(Double_t x)
double norm(double *x, double *p)
virtual Long64_t Project(const char *hname, const char *varexp, const char *selection="", Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Make a projection of a tree using selections.
Ssiz_t First(char c) const
Find first occurrence of a character c.