Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

AltNeuralNetFunc.cxx

Go to the documentation of this file.
00001 
00002 // $Id: AltNeuralNetFunc.cxx,v 1.1 2003/10/22 18:18:01 costas Exp $
00003 //
00004 // AltNeuralNetFunc.cxx
00005 //
00006 //   -- Generic Interface to a Neural Network Function
00007 //   -- This is adapted for AltReco from my Neural Network Foundation Classes
00008 //      (NNFC) package that I use for some of my Neural Net analyses.
00009 //      NNFC is not intended to be part of the minos offline, so I just adapted
00010 //      this single file here.
00011 //
00012 // Costas Andreopoulos <C.V.Andreopoulos@rl.ac.uk>
00013 // CCLRC, Rutherford Appleton Laboratory
00014 // July 01, 2003
00016 
00017 #ifndef __CINT__
00018 #include "Api.h"
00019 #endif
00020 
00021 #include<sstream>
00022 
00023 #include "AltNeuralNetFunc.h"
00024 
00025 #include "LeakChecker/Lea.h"
00026 #include "MessageService/MsgService.h"
00027 
00028 ClassImp(AltNeuralNetFunc)
00029 
00030 //_______________________________________________________________________________
00031 CVSID("$Id: AltNeuralNetFunc.cxx,v 1.1 2003/10/22 18:18:01 costas Exp $");
00032 //_______________________________________________________________________________
00033 AltNeuralNetFunc::AltNeuralNetFunc() :
00034 TNamed()
00035 {
00036   MSG("AltNeuralNet",Msg::kDebug) 
00037                  << "Begin of AltNeuralNetFunc::AltNeuralNetFunc() ctor" << endl;
00038   LEA_CTOR;
00039 }
00040 //_______________________________________________________________________________
00041 AltNeuralNetFunc::AltNeuralNetFunc(const char * name, const char * title) :
00042 TNamed(name, title)
00043 {
00044   MSG("AltNeuralNet",Msg::kDebug) 
00045      << "Begin of AltNeuralNetFunc::AltNeuralNetFunc("
00046                                  << "const char *, const char * ) ctor" << endl;
00047 
00048   fTitle = std::string(title);
00049       
00050   LEA_CTOR;
00051 }
00052 //_______________________________________________________________________________
00053 AltNeuralNetFunc::~AltNeuralNetFunc()
00054 {
00055   MSG("AltNeuralNet",Msg::kDebug) 
00056                 << "Begin of AltNeuralNetFunc::~AltNeuralNetFunc() dtor" << endl;
00057                            
00058   LEA_DTOR;
00059 }
00060 //_______________________________________________________________________________
00061 double AltNeuralNetFunc::run( 
00062                         double (*neural_net)(double *), AltNeuralNetI * pattern )
00063 {
00064   float network_out = -1;
00065 
00066   const int kInputs = pattern->getNumberOfInputs();  
00067   float * inputs = new float[kInputs];  
00068   
00069   pattern->copyInputsToArray(inputs);
00070 
00071 #ifndef __CINT__
00072   G__CallFunc func;
00073   switch(G__isinterpretedp2f( (void*)neural_net )) {
00074   
00075   //using interface method
00076   case G__COMPILEDINTERFACEMETHOD:
00077      func.SetFunc( (G__InterfaceMethod)neural_net );
00078      func.SetArg((long)inputs);
00079      network_out = func.ExecDouble( (void*)NULL );
00080      break;
00081   default:
00082      exit(1);   
00083   }  
00084 #else
00085   network_out = neural_net(inputs);
00086 #endif
00087   
00088   return network_out;
00089 }
00090 //_______________________________________________________________________________

Generated on Mon Feb 15 11:06:21 2010 for loon by  doxygen 1.3.9.1