00001
00002
00003
00004 #include "FluxSvc/IFluxSvc.h"
00005 #include "FluxSvc/IFlux.h"
00006
00007 #include "GaudiKernel/MsgStream.h"
00008 #include "GaudiKernel/AlgFactory.h"
00009 #include "GaudiKernel/Algorithm.h"
00010 #include <list>
00011 #include <string>
00017 class FluxTestAlg : public Algorithm {
00018
00019 public:
00021 FluxTestAlg(const std::string& name, ISvcLocator* pSvcLocator);
00022
00023 StatusCode initialize();
00024 StatusCode execute();
00025 StatusCode finalize();
00026
00027 private:
00028 IFlux* m_flux;
00029 std::string m_source_name;
00030 };
00031
00032
00033 static const AlgFactory<FluxTestAlg> Factory;
00034 const IAlgFactory& FluxTestAlgFactory = Factory;
00035
00036 void WARNING (const char * text ){ std::cerr << "WARNING: " << text << '\n';}
00037 void FATAL(const char* s){std::cerr << "\nERROR: "<< s;}
00038
00039
00040
00041
00042 FluxTestAlg::FluxTestAlg(const std::string& name, ISvcLocator* pSvcLocator) :
00043 Algorithm(name, pSvcLocator){
00044
00045 declareProperty("source_name", m_source_name="default");
00046 }
00047
00048
00049
00051 StatusCode FluxTestAlg::initialize() {
00052
00053
00054 MsgStream log(msgSvc(), name());
00055 log << MSG::INFO << "initializing..." << endreq;
00056
00057
00058 setProperties();
00059
00060
00061 IFluxSvc* fsvc;
00062
00063
00064 StatusCode sc = service("FluxSvc", fsvc);
00065
00066 if( sc.isFailure()) {
00067 log << MSG::ERROR << "Could not find FluxSvc" << endreq;
00068 return sc;
00069 }
00070
00071
00072 log << MSG::INFO << "loading source..." << endreq;
00073
00074
00075
00076 sc = fsvc->source(m_source_name, m_flux);
00077 if( sc.isFailure()) {
00078 log << MSG::ERROR << "Could not find flux " << m_source_name << endreq;
00079 return sc;
00080 }
00081
00082 log << MSG::INFO << "start of other loops" << endreq;
00083 log << MSG::INFO << "Source title: " << m_flux->title() << endreq;
00084 log << MSG::INFO << " area: " << m_flux->targetArea() << endreq;
00085 log << MSG::INFO << " rate: " << m_flux->rate() << endreq;
00086
00087
00088 return sc;
00089 }
00090
00091
00092
00093 StatusCode FluxTestAlg::execute() {
00094
00095 StatusCode sc = StatusCode::SUCCESS;
00096 MsgStream log( msgSvc(), name() );
00097
00098 m_flux->generate();
00099 HepPoint3D p = m_flux->launchPoint();
00100 HepPoint3D d = m_flux->launchDir();
00101
00102 log << MSG::INFO << m_flux->particleName()
00103 << "(" << m_flux->energy()
00104 << " GeV), Launch: "
00105 << "(" << p.x() <<", "<< p.y() <<", "<<p.z()<<")"
00106 << " Dir "
00107 << "(" << d.x() <<", "<< d.y() <<", "<<d.z()<<")"
00108 << endreq;
00109
00110
00111 return sc;
00112 }
00113
00114
00115
00116 StatusCode FluxTestAlg::finalize() {
00117
00118 return StatusCode::SUCCESS;
00119 }
00120
00121
00122
00123
00124
00125