Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

OrbitSvc.cxx

Go to the documentation of this file.
00001 
00008 // Include files
00009 // Gaudi system includes
00010 #include "GaudiKernel/Service.h"
00011 #include "GaudiKernel/MsgStream.h"
00012 #include "GaudiKernel/SvcFactory.h"
00013 #include "GaudiKernel/Property.h"
00014 
00015 
00016 #include "facilities/Util.h"
00017 #include "facilities/Timestamp.h"
00018 
00019 #include "astro/GPS.h"
00020 
00021 
00027 // Declaration of the interface ID ( interface id, major version, minor version) 
00028 static const InterfaceID IID_IOrbitSvc("OrbitSvc", 0, 0); 
00029 
00030 
00031 class OrbitSvc : virtual public Service  {
00032 public:
00033     OrbitSvc(const std::string& name, ISvcLocator* pSvcLocator);
00034 
00035 
00036     //------------------------------------------------------------------
00037     //  stuff required by a Service
00038 
00040     virtual StatusCode initialize ();
00041 
00043     virtual StatusCode finalize ();
00044 
00046     virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvUnknown );
00047 
00048 private: 
00049 
00050     StringArrayProperty m_pointingHistory;
00051     DoubleArrayProperty m_pointingDirection; 
00052     DoubleProperty m_zenithTheta; 
00053     DoubleProperty m_rocking_angle; // x-axis
00054 
00055 };
00056 //------------------------------------------------------------------------
00057 
00058 
00059 static const SvcFactory<OrbitSvc>  Factory;
00060 const ISvcFactory& OrbitSvcFactory = Factory;
00061 
00062 //------------------------------------------------------------------------
00064 OrbitSvc::OrbitSvc(const std::string& name, ISvcLocator* svc)
00065 : Service(name,svc)
00066 {
00067 
00068     declareProperty("PointingHistory",   m_pointingHistory); // doublet, filename and launch date
00069     declareProperty("pointingDirection", m_pointingDirection);
00070     declareProperty("zenithTheta",       m_zenithTheta=-99);
00071     declareProperty("rocking_angle", m_rocking_angle=0); // set non-zero to enable rocking
00072 
00073 
00074 
00075 }
00076 //------------------------------------------------------------------------
00078 StatusCode OrbitSvc::initialize(){
00079     StatusCode  sc = StatusCode::SUCCESS;
00080     MsgStream log(msgSvc(), name());
00081     using astro::GPS;
00082 
00083     // Use the Job options service to set the Algorithm's parameters
00084     setProperties();
00085 
00086 
00087     //set the input file to be used as the pointing database, if used
00088     if(! m_pointingHistory.value().empty()){
00089         std::string filename(m_pointingHistory.value()[0]);
00090         facilities::Util::expandEnvVar(&filename);
00091         double offset = 0;
00092         bool horizontalflag(false);
00093         if( m_pointingHistory.value().size()>1){
00094             std::string field(m_pointingHistory.value()[1]);
00095             if(! field.empty() ) { // allow null string
00096                 facilities::Timestamp jt(m_pointingHistory.value()[1]);
00097                 offset = (astro::JulianDate(jt.getJulian())-astro::JulianDate::missionStart())*astro::JulianDate::secondsPerDay;
00098             }
00099         }
00100 
00101         if( m_pointingHistory.value().size()>2){
00102             std::string field(m_pointingHistory.value()[2]);
00103             horizontalflag =! field.empty();
00104         }
00105         log << MSG::INFO << "Loading Pointing History File : " << filename 
00106             << " with MET offset "<< offset <<  endreq;
00107         if( horizontalflag){
00108             log << MSG::INFO << "Will override x-direction to be horizontal"<<endreq;
00109         }
00110 
00111         astro::GPS::instance()->setPointingHistoryFile(filename, offset, horizontalflag);
00112     }
00113     else if( m_pointingDirection.value().size()==2 ) {
00114         // if direction set, ignore everything else!
00115         double ra(m_pointingDirection.value()[0]), dec(m_pointingDirection.value()[1]);
00116         astro::GPS::instance()->setPointingDirection(astro::SkyDir(ra, dec));
00117         log << MSG::INFO << "set to point at ra,dec= " << ra << ", "<<dec << endreq;
00118 
00119     }else if( m_zenithTheta>=0) {
00120         // if set from defalt, set to this value
00121         //m_fluxSvc->setRockType(astro::GPS::EXPLICIT, m_zenithTheta);
00122         GPS::instance()->setRockType(GPS::EXPLICIT);
00123         GPS::instance()->rockingDegrees(m_zenithTheta);
00124 
00125         log << MSG::INFO << "set to zenith angle " << m_zenithTheta << " degrees" << endreq;
00126     }else if(m_rocking_angle >0 ){
00127         //output to record the pointing settings
00128         //then this line sets the rocking type, as well as the rocking angle.
00129         //m_fluxSvc->setRockType(GPS::ONEPERORBIT ,m_rocking_angle);
00130         GPS::instance()->setRockType(GPS::ONEPERORBIT);
00131         GPS::instance()->rockingDegrees(m_zenithTheta);
00132         log << MSG::INFO << "Once per orbit rocking Angle: " << m_rocking_angle << " degrees" << endreq;
00133 
00134     }
00135 
00136 
00137     return sc;
00138 }
00139 
00141 StatusCode OrbitSvc::queryInterface(const InterfaceID& riid, void** ppvInterface)  {
00142     if ( IID_IOrbitSvc.versionMatch(riid) )  {
00143         *ppvInterface = (OrbitSvc*)this;
00144     } else  {
00145         return Service::queryInterface(riid, ppvInterface);
00146     }
00147 
00148     addRef();
00149     return SUCCESS;
00150 }
00151 
00152 StatusCode OrbitSvc::finalize()
00153 {
00154     return StatusCode::SUCCESS;
00155 }
00156 

Generated on Wed Nov 26 20:29:31 2008 by doxygen 1.3.3