StandaloneClassExample.C

Go to the documentation of this file.
00001 #include <vector>;
00002 
00003 void StandaloneClassExample()
00004 {
00005    // A simple example of how the "standalone classes" can be used
00006       
00007    // Load the stand alone "trained LD class" 
00008    // if the example were not a ROOT macro but a stand alone program, you
00009    // would simplye "include" this file"
00010 
00011    gROOT->LoadMacro("weights/TMVAClassification_LD.class.C++");
00012 
00013    std::vector<string> inputVariableNames;
00014    // you need to use the same names as during traiing. Meant as a "consistency" check, that
00015    // makes you aware of what you are doing. You can find the names in the "xxx.class.C" file
00016    // just look for "training input variables". Obviously, you want to "apply" it using the
00017    // same variables.
00018 
00019    inputVariableNames.push_back("var1+var2");
00020    inputVariableNames.push_back("var1-var2");
00021    inputVariableNames.push_back("var3");
00022    inputVariableNames.push_back("var4");
00023    // instanticat the LD class and tell it about the variable names
00024    // to allow it to check internally that it has actually been trained with
00025    // THESE variables
00026    IClassifierReader* classReader = new ReadLD(inputVariableNames);
00027    
00028    // put your input variables into a std::vector 
00029    // (this would typically be inside an "event loop" of course..
00030    std::vector<double> inputVariableValues;
00031    inputVariableValues.push_back(1.);
00032    inputVariableValues.push_back(1.6);
00033    inputVariableValues.push_back(3.4);
00034    inputVariableValues.push_back(2.4);
00035 
00036    cout << "For input values: " ;
00037    for (int i=0; i<4; i++) cout << inputVariableValues[i] << "  ";
00038    cout << endl;
00039 
00040    // get the MVA output value for this particular event variables.
00041    cout << "The LD MVA value is: " << classReader->GetMvaValue(inputVariableValues) << endl;
00042 
00043 
00044 }

Generated on Tue Jul 5 15:26:36 2011 for ROOT_528-00b_version by  doxygen 1.5.1