Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MethodPlugins.cxx
Go to the documentation of this file.
1// @(#)root/tmva $Id$
2// Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss
3
4/**********************************************************************************
5 * Project: TMVA - a Root-integrated toolkit for multivariate Data analysis *
6 * Package: TMVA *
7 * Class : TMVA::MethodPlugins *
8 * *
9 * *
10 * Description: *
11 * Implementation (see header for description) *
12 * *
13 * Authors (alphabetical): *
14 * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15 * Joerg Stelzer <stelzer@cern.ch> - DESY, Germany *
16 * Peter Speckmayer <peter.speckmayer@cern.ch> - CERN, Switzerland *
17 * Jan Therhaag <Jan.Therhaag@cern.ch> - U of Bonn, Germany *
18 * Eckhard v. Toerne <evt@uni-bonn.de> - U of Bonn, Germany *
19 * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
20 * Daniel Martscheit <martschei@ekp.uni-karlsruhe.de> -KIT Karlsruhe, Ger. *
21 * *
22 * Copyright (c) 2005-2011: *
23 * CERN, Switzerland *
24 * U. of Victoria, Canada *
25 * MPI-K Heidelberg, Germany *
26 * U. of Bonn, Germany *
27 * *
28 * Redistribution and use in source and binary forms, with or without *
29 * modification, are permitted according to the terms listed in LICENSE *
30 * (see tmva/doc/LICENSE) *
31 **********************************************************************************/
32
33/*! \class TMVA::CreateMethodPlugins
34\ingroup TMVA
35
36Plugins analysis
37
38The MethodPlugins is actually not a real method, but it is just a wrapper to call
39the TPluginsManager of ROOT and find a external method which can be used to extend
40TMVA by another classifier. The only methods which are actually really implemented
41are the constructors which fulfill the plugins handling. The others will produce
42FATAL warnings and stop TMVA execution.
43
44Right after the constructor, the additional method 'getPlugedinMethod()' is called,
45which returns the method loaded by the plugin manager, and the MethodPlugins object
46is already deleted.
47
48*/
49
50#include "TPluginManager.h"
51#include "TROOT.h"
52
54#include "TMVA/Ranking.h"
55#include "TMVA/Tools.h"
56#include "TMVA/Types.h"
57
58#include <cstdio>
59#include <iostream>
60
61namespace
62{
64 {
65 //std::cout << "CreateMethodPlugins is called with options : '" << jobName << "', '" << methodTitle<< "', " << theOption<< "'" << std::endl;
68 pluginManager = gROOT->GetPluginManager();
69 //An empty methodTitle is a Problem for the PluginHandler, so we need to fiddle it out of the weightsfilename
71 if(jobName=="" && methodTitle=="") { //This is most likely a call to the Classifier (not for training)
72 myMethodTitle = theOption.Copy();
76 myMethodTitle.Remove(0,firstUnderscore-1); //leave the underscore
77 }
78 else myMethodTitle = methodTitle;
79 pluginHandler = pluginManager->FindHandler("TMVA@@MethodBase", myMethodTitle);
80 if(!pluginHandler)
81 {
82 std::cerr << "Couldn't find plugin handler for TMVA@@MethodBase and " << methodTitle << std::endl;
83 return 0;
84 }
85 //std::cout << "pluginHandler found myMethodTitle=" << myMethodTitle<<std::endl;
86 if (pluginHandler->LoadPlugin() == 0) {
87 if(jobName=="" && methodTitle=="") {
88 //std::cout << "Calling ExpertPlugin " << std::endl;
89 return (TMVA::IMethod*) pluginHandler->ExecPlugin(2, &theData, &theOption);
90 } else {
91 //std::cout << "Calling TeacherPlugin " << std::endl;
92 // pluginHandler->Print("a");
93 return (TMVA::IMethod*) pluginHandler->ExecPlugin(4, &jobName, &methodTitle, &theData, &theOption);
94 }
95 }
96 //std::cout << "plugin done" << std::endl;
97 return 0; // end of function should never be reached. This is here to silence the compiler
98 }
99
100 struct registration {
101 registration() {
103 TMVA::Types::Instance().AddTypeMapping(TMVA::Types::kPlugins, "Plugins");
104 }
105 } instance;
106}
107
static Roo_reg_AGKInteg1D instance
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gROOT
Definition TROOT.h:406
static ClassifierFactory & Instance()
access to the ClassifierFactory singleton creates the instance if needed
Plugins analysis.
Class that contains all the data information.
Definition DataSetInfo.h:62
Interface for all concrete MVA method implementations.
Definition IMethod.h:53
static Types & Instance()
The single instance of "Types" if existing already, or create it (Singleton)
Definition Types.cxx:70
@ kPlugins
Definition Types.h:96
This class implements a plugin library manager.
Basic string class.
Definition TString.h:139