00001
00009
00010
00011 #include "GaudiKernel/MsgStream.h"
00012 #include "GaudiKernel/AlgFactory.h"
00013 #include "GaudiKernel/Algorithm.h"
00014 #include "GaudiKernel/Property.h"
00015 #include "GaudiKernel/SmartDataPtr.h"
00016
00017
00018 #include "Event/TopLevel/EventModel.h"
00019 #include "Event/TopLevel/Event.h"
00020 #include "Event/TopLevel/MCEvent.h"
00021 #include "Event/MonteCarlo/Exposure.h"
00022
00023
00024 #include "ntupleWriterSvc/INTupleWriterSvc.h"
00025
00026
00027
00028 #include "FluxSvc/PointingInfo.h"
00029
00030
00031
00042 class PointInfoAlg : public Algorithm {
00043 public:
00044 PointInfoAlg(const std::string& name, ISvcLocator* pSvcLocator);
00045
00046 StatusCode initialize();
00047 StatusCode execute();
00048 StatusCode finalize();
00049
00050
00051 private:
00052 PointingInfo m_pointing_info;
00053
00054 StringProperty m_root_tree;
00055 BooleanProperty m_save_tuple;
00056
00057 INTupleWriterSvc* m_rootTupleSvc;
00058
00059 };
00060
00061
00062
00063 static const AlgFactory<PointInfoAlg> Factory;
00064 const IAlgFactory& PointInfoAlgFactory = Factory;
00065
00066
00068 PointInfoAlg::PointInfoAlg(const std::string& name, ISvcLocator* pSvcLocator)
00069 :Algorithm(name, pSvcLocator)
00070 {
00071
00072
00073 declareProperty("pointing_info_tree_name", m_root_tree="MeritTuple");
00074 declareProperty("save_pointing_info", m_save_tuple=false);
00075
00076 }
00077
00079 StatusCode PointInfoAlg::initialize(){
00080 StatusCode sc = StatusCode::SUCCESS;
00081 MsgStream log(msgSvc(), name());
00082
00083 setProperties();
00084
00085
00086
00087 if( (service("RootTupleSvc", m_rootTupleSvc, true) ). isFailure() ) {
00088 log << MSG::ERROR << " RootTupleSvc is not available" << endreq;
00089 m_rootTupleSvc=0;
00090 sc = StatusCode::FAILURE;
00091 }else if( !m_root_tree.value().empty() ) {
00092
00093 m_pointing_info.setPtTuple(m_rootTupleSvc, m_root_tree.value());
00094 }
00095
00096
00097 return sc;
00098 }
00099
00100
00102 StatusCode PointInfoAlg::execute()
00103 {
00104 StatusCode sc = StatusCode::SUCCESS;
00105 MsgStream log( msgSvc(), name() );
00106
00107
00108
00109 m_pointing_info.set();
00110
00111
00112
00113 if( m_rootTupleSvc!=0 && !m_root_tree.value().empty()){
00114 m_rootTupleSvc->storeRowFlag(this->m_root_tree.value(), m_save_tuple);
00115 }
00116
00117
00118
00119 Event::ExposureCol* exposureDBase = new Event::ExposureCol;
00120 sc=eventSvc()->registerObject(EventModel::MC::ExposureCol , exposureDBase);
00121 if(sc.isFailure()) {
00122 log << MSG::ERROR << EventModel::MC::ExposureCol
00123 <<" could not be entered into existing data store" << endreq;
00124 return sc;
00125 }
00126 exposureDBase->push_back(m_pointing_info.forTDS());
00127
00128 return StatusCode::SUCCESS;
00129 }
00130
00131
00133 StatusCode PointInfoAlg::finalize(){
00134 StatusCode sc = StatusCode::SUCCESS;
00135 return sc;
00136 }
00137
00138