Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

meritAlg.cxx

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/merit/src/meritAlg/meritAlg.cxx,v 1.1 2001/03/23 19:52:02 burnett Exp $
00002 
00003 // Include files
00004 
00005 #include "Gaudi/Algorithm/Algorithm.h"
00006 #include "Gaudi/MessageSvc/MsgStream.h"
00007 #include "Gaudi/Kernel/AlgFactory.h"
00008 #include "Gaudi/Interfaces/IDataProviderSvc.h"
00009 #include "Gaudi/DataSvc/SmartDataPtr.h"
00010 #include "Gaudi/NTupleSvc/NTuple.h"
00011 #include "Gaudi/Interfaces/INTupleSvc.h"
00012 #include "GaudiTuple.h"
00013 
00014 #include "merit/FigureOfMerit.h"
00015 #include "analysis/Tuple.h"
00016 
00017 static std::string  default_cuts("12rbA");
00018 
00019 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00020 class meritAlg : public Algorithm {
00021     
00022 public:
00023     meritAlg(const std::string& name, ISvcLocator* pSvcLocator); 
00024     
00025     StatusCode initialize();
00026     StatusCode execute();
00027     StatusCode finalize();
00028 private:
00029     FigureOfMerit* m_fm;
00030     GaudiTuple* m_tuple;
00031     std::string m_cuts;    
00032     std::string m_tuple_file;
00033 };
00034 
00035 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00036 
00037 static const AlgFactory<meritAlg>  Factory;
00038 const IAlgFactory& meritAlgFactory = Factory;
00039 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00040 meritAlg::meritAlg(const std::string& name, ISvcLocator* pSvcLocator) :
00041 Algorithm(name, pSvcLocator) {
00042     declareProperty("cuts" , m_cuts=default_cuts);
00043     declareProperty("tuple_path", m_tuple_file="AORECON");
00044 }
00045 
00046 StatusCode meritAlg::initialize() {
00047     StatusCode  sc = StatusCode::SUCCESS;
00048     
00049     MsgStream log(msgSvc(), name());
00050     log << MSG::INFO << "initialize" << endreq;
00051     
00052     // Use the Job options service to get the Algorithm's parameters
00053     setProperties();
00054     
00055     // setup the tuple somehow
00056     
00057     std::string top = "/NTUPLES/FILE1";
00058     NTupleDirPtr dir(ntupleSvc(), top );
00059     
00060     NTuplePtr nt(dir, "/1");
00061     if( 0==nt) {
00062         log << MSG::ERROR << "Could not open the tuple file" << endreq;
00063         return StatusCode::FAILURE;
00064     }
00065     
00066     // make the wrapper for access from all the cuts
00067     m_tuple = new GaudiTuple(nt->title(), &nt);
00068     
00069     m_fm= new FigureOfMerit(*m_tuple, m_cuts);
00070     
00071        
00072     // Access the N tuple event by event
00073     while ( sc.isSuccess() ) {
00074         sc = ntupleSvc()->readRecord(nt.ptr());
00075         if ( sc.isSuccess() ) {
00076             m_fm->execute();
00077         }
00078     }
00079     m_fm->report(std::cout);
00080     
00081     return sc;
00082 }
00083 
00084 
00085 //------------------------------------------------------------------------------
00086 StatusCode meritAlg::execute() {
00087     
00088     StatusCode  sc = StatusCode::SUCCESS;
00089    
00090     return sc;
00091 }
00092 
00093 
00094 //------------------------------------------------------------------------------
00095 StatusCode meritAlg::finalize() {
00096     
00097     MsgStream log(msgSvc(), name());
00098     log << MSG::INFO << "finalize" << endreq;
00099     
00100     delete m_fm;
00101     return StatusCode::SUCCESS;
00102 }
00103 

Generated at Wed Nov 21 12:20:39 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000