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

PtValsAlg Class Reference

This is an Algorithm designed to store pointing information in the tuple. More...

Collaboration diagram for PtValsAlg:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PtValsAlg (const std::string &name, ISvcLocator *pSvcLocator)
 ctor

StatusCode initialize ()
 set parameters and attach to various perhaps useful services.

StatusCode execute ()
 process an event

StatusCode finalize ()
 clean up, summarize


Private Attributes

PointingInfo m_pointingInfo
StringProperty m_root_tree
StringArrayProperty m_pointingHistory
 history file name and launch date

INTupleWriterSvc * m_rootTupleSvc
IDataProviderSvc * m_pEventSvc
astro::PointingHistory * m_history
bool m_horizontal
bool m_fillNtuple

Detailed Description

This is an Algorithm designed to store pointing information in the tuple.

Author:
Toby Burnett

Definition at line 52 of file PtValsAlg.cxx.


Constructor & Destructor Documentation

PtValsAlg::PtValsAlg const std::string &  name,
ISvcLocator *  pSvcLocator
 

ctor

Definition at line 83 of file PtValsAlg.cxx.

References m_fillNtuple, m_pointingHistory, and m_root_tree.

00084 :Algorithm(name, pSvcLocator) , m_horizontal(false)
00085 {
00086     // declare properties with setProperties calls
00087 
00088     declareProperty("pointing_info_tree_name",  m_root_tree="MeritTuple");
00089     // doublet, filename and launch date
00090     declareProperty("PointingHistory",   m_pointingHistory); 
00091     declareProperty("FillNtuple",        m_fillNtuple=true);
00092 
00093 }


Member Function Documentation

StatusCode PtValsAlg::execute  ) 
 

process an event

Definition at line 171 of file PtValsAlg.cxx.

References m_fillNtuple, m_pEventSvc, m_pointingInfo, m_root_tree, and m_rootTupleSvc.

00172 {
00173     StatusCode  sc = StatusCode::SUCCESS;
00174     MsgStream   log( msgSvc(), name() );
00175     //
00176     // Purpose: set tuple items
00177  
00178    SmartDataPtr<Event::EventHeader> header(m_pEventSvc, EventModel::EventHeader);
00179 
00180    // get event time from header or merit 
00181    // and look up position info from the history  
00182 
00183    double etime;
00184 
00185    if(header==0) {
00186        void* ptr;
00187        m_rootTupleSvc->getItem(m_root_tree,"PtTime",ptr);
00188        etime = *reinterpret_cast<double*>(ptr);
00189    } else {
00190        etime = header->time();
00191    }
00192     gps->time(etime);
00193 
00194     // and create the tuple
00195     if (m_fillNtuple) m_pointingInfo.execute( *gps );
00196     
00197     return StatusCode::SUCCESS;
00198 }

StatusCode PtValsAlg::finalize  ) 
 

clean up, summarize

Definition at line 202 of file PtValsAlg.cxx.

00202                               {
00203     StatusCode  sc = StatusCode::SUCCESS;
00204     return sc;
00205 }

StatusCode PtValsAlg::initialize  ) 
 

set parameters and attach to various perhaps useful services.

Definition at line 96 of file PtValsAlg.cxx.

References m_fillNtuple, m_horizontal, m_pEventSvc, m_pointingHistory, m_pointingInfo, m_root_tree, and m_rootTupleSvc.

00096                                 {
00097     StatusCode  sc = StatusCode::SUCCESS;
00098     MsgStream log(msgSvc(), name());
00099     // Use the Job options service to set the Algorithm's parameters
00100     setProperties();
00101 
00102     // get a pointer to RootTupleSvc
00103     if( (service("RootTupleSvc", m_rootTupleSvc, true) ). isFailure() ) {
00104         log << MSG::ERROR << " RootTupleSvc is not available" << endreq;
00105         m_rootTupleSvc=0;
00106         sc = StatusCode::FAILURE;
00107     } else if( !m_root_tree.value().empty() ) {   
00108      
00109           if(m_fillNtuple) m_pointingInfo.setPtTuple(m_rootTupleSvc, m_root_tree.value()); 
00110     }
00111 
00112 
00113     // get the GPS instance: 
00114 
00115     gps = astro::GPS::instance();
00116 
00117     //set the input file to be used as the pointing database, if used
00118     if( m_pointingHistory.value().empty()){
00119         log << MSG::WARNING << "No history file specified, using default" << endreq;
00120     }else{
00121         std::string filename(m_pointingHistory.value()[0]);
00122         facilities::Util::expandEnvVar(&filename);
00123         double offset = 0;
00124         std::string jStr;
00125         if( m_pointingHistory.value().size()>1){
00126             std::string field(m_pointingHistory.value()[1]);
00127             if(! field.empty() ) { // allow null string
00128                 facilities::Timestamp jt(m_pointingHistory.value()[1]);
00129                 offset = (astro::JulianDate(jt.getJulian())
00130                     - astro::JulianDate::missionStart())
00131                     *astro::JulianDate::secondsPerDay;
00132                 astro::JulianDate jDate(astro::JulianDate(jt.getJulian()));
00133                 jStr = jDate.getGregorianDate();
00134             }
00135         }
00136 
00137         if( m_pointingHistory.value().size()>2){
00138             std::string field(m_pointingHistory.value()[2]);
00139             m_horizontal =! field.empty();
00140         }
00141         log << MSG::INFO << "Loading Pointing History File : " << filename <<endreq;
00142         if( offset>0 ){
00143             log << MSG::INFO   << " with MET offset " ;
00144             log.precision(12);
00145             log << offset << " ";
00146             log.precision(6);
00147             log << jStr << endreq;
00148         }
00149         if( m_horizontal){
00150             log << MSG::INFO 
00151                 << "   Will override x-direction to be horizontal"<<endreq;
00152         }
00153         gps->setPointingHistoryFile(filename, offset, m_horizontal);
00154     }
00155 
00156 
00157 
00158     IDataProviderSvc* eventsvc = 0;
00159     sc = serviceLocator()->service( "EventDataSvc", eventsvc, true );
00160     if(sc.isFailure()){
00161         log << MSG::ERROR << "Could not find EventDataSvc" << std::endl;
00162         return sc;
00163     }
00164     m_pEventSvc = eventsvc;
00165    
00166     return sc;
00167 }


Member Data Documentation

bool PtValsAlg::m_fillNtuple [private]
 

Definition at line 72 of file PtValsAlg.cxx.

Referenced by execute(), initialize(), and PtValsAlg().

astro::PointingHistory* PtValsAlg::m_history [private]
 

Definition at line 70 of file PtValsAlg.cxx.

bool PtValsAlg::m_horizontal [private]
 

Definition at line 71 of file PtValsAlg.cxx.

Referenced by initialize().

IDataProviderSvc* PtValsAlg::m_pEventSvc [private]
 

Definition at line 68 of file PtValsAlg.cxx.

Referenced by execute(), and initialize().

StringArrayProperty PtValsAlg::m_pointingHistory [private]
 

history file name and launch date

Definition at line 65 of file PtValsAlg.cxx.

Referenced by initialize(), and PtValsAlg().

PointingInfo PtValsAlg::m_pointingInfo [private]
 

Definition at line 62 of file PtValsAlg.cxx.

Referenced by execute(), and initialize().

StringProperty PtValsAlg::m_root_tree [private]
 

Definition at line 64 of file PtValsAlg.cxx.

Referenced by execute(), initialize(), and PtValsAlg().

INTupleWriterSvc* PtValsAlg::m_rootTupleSvc [private]
 

Definition at line 67 of file PtValsAlg.cxx.

Referenced by execute(), and initialize().


The documentation for this class was generated from the following file:
Generated on Tue Nov 18 14:08:53 2008 by doxygen 1.3.3