00001
00002 #include "GaudiKernel/Algorithm.h"
00003
00004 #include "GaudiKernel/MsgStream.h"
00005 #include "GaudiKernel/AlgFactory.h"
00006 #include "GaudiKernel/IDataProviderSvc.h"
00007 #include "GaudiKernel/DataObject.h"
00008 #include "GaudiKernel/SmartDataPtr.h"
00009 #include "GaudiKernel/DataSvc.h"
00010 #include "ntupleWriterSvc/INTupleWriterSvc.h"
00011
00012
00013
00014
00020 class WriteTupleAlg : public Algorithm
00021 {
00022 public:
00023 WriteTupleAlg(const std::string& name, ISvcLocator* pSvcLocator);
00024 StatusCode initialize();
00025 StatusCode execute();
00026 StatusCode finalize();
00027 private:
00028 INTupleWriterSvc* m_ntupleWriterSvc;
00029 int m_count;
00030
00031
00032 };
00033
00034
00035
00036 static const AlgFactory<WriteTupleAlg> Factory;
00037 const IAlgFactory& WriteTupleAlgFactory = Factory;
00038
00039
00040
00041 WriteTupleAlg::WriteTupleAlg(const std::string& name, ISvcLocator* pSvcLocator)
00042 :Algorithm(name, pSvcLocator)
00043 {
00044 m_count =0;
00045 }
00046
00047
00048 StatusCode WriteTupleAlg::initialize() {
00049 MsgStream log(msgSvc(), name());
00050 log << MSG::INFO << "initialize" << endreq;
00051 StatusCode sc =StatusCode::SUCCESS;
00052
00053
00054 setProperties();
00055
00056
00057 sc = service("ntupleWriterSvc", m_ntupleWriterSvc);
00058
00059 if(sc.isFailure())
00060 {
00061 log << MSG::ERROR << "Could not locate the ntupleSvc" <<endreq;
00062 }
00063
00064
00065 return sc;
00066
00067 }
00068
00069
00070 StatusCode WriteTupleAlg::execute() {
00071
00072
00073 MsgStream log( msgSvc(), name() );
00074 StatusCode sc = StatusCode::SUCCESS;
00075
00076 sc = m_ntupleWriterSvc->saveNTuples();
00077 if(sc.isFailure())
00078 {
00079 log << MSG::ERROR << "Failed to save the ntuples" << endreq;
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089 return sc;
00090 }
00091
00092
00093
00094 StatusCode WriteTupleAlg::finalize() {
00095
00096 MsgStream log(msgSvc(), name());
00097 return StatusCode::SUCCESS;
00098 }
00099