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

ExposureAlg Class Reference

This is an Algorithm designed to get information about LAT position, from FluxSvc and use it to put information onto the TDS about LAT pointing and location characteristics, effectively generating the D2 database. The "TimeTick" Spectrum is included (and can be used in jobOptions with this algorithm) in order to provide a constant time reference. More...

Collaboration diagram for ExposureAlg:

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

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

StatusCode execute ()
 process a tick

StatusCode finalize ()
 clean up, summarize


Private Member Functions

int askGPS ()
 notified when position changes

void createEntry ()

Private Attributes

double m_lasttime
double m_last_livetime
double m_initial_time
StringProperty m_root_tree
StringProperty m_pointing_history_input_file
StringProperty m_clockName
IntegerProperty m_print_frequency
IFluxSvcm_fluxSvc
int m_tickCount
INTupleWriterSvc * m_rootTupleSvc
ILivetimeSvc * m_livetimeSvc
PointingInfo m_history
bool m_insideSAA
ObserverAdapter< ExposureAlgm_observer
astro::GPS * m_gps
std::map< std::string, int > m_ticks

Detailed Description

This is an Algorithm designed to get information about LAT position, from FluxSvc and use it to put information onto the TDS about LAT pointing and location characteristics, effectively generating the D2 database. The "TimeTick" Spectrum is included (and can be used in jobOptions with this algorithm) in order to provide a constant time reference.

Author:
Sean Robinson
Header
/nfs/slac/g/glast/ground/cvs/FluxSvc/src/ExposureAlg.cxx,v 1.47 2008/11/10 16:06:26 burnett Exp

Definition at line 54 of file ExposureAlg.cxx.


Constructor & Destructor Documentation

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

ctor

Definition at line 100 of file ExposureAlg.cxx.

References m_clockName, m_print_frequency, and m_root_tree.

00101 : Algorithm(name, pSvcLocator)
00102 , m_lasttime(0)
00103 , m_tickCount(0)
00104 , m_insideSAA(false)
00105 {
00106     // declare properties with setProperties calls
00107     declareProperty("root_tree",m_root_tree="pointing_history"); //doesn't work???
00108 
00109     declareProperty("PrintFrequency", m_print_frequency=1);
00110     declareProperty("clockName"    , m_clockName = "clock" );// the name to check for
00111 }


Member Function Documentation

int ExposureAlg::askGPS  )  [private]
 

notified when position changes

Definition at line 168 of file ExposureAlg.cxx.

References createEntry(), and m_insideSAA.

Referenced by initialize().

00169 {
00170     // callback from GPS when position has been updated
00171     astro::EarthCoordinate pos = astro::GPS::instance()->earthpos();
00172     bool inside = pos.insideSAA();
00173     if( inside != m_insideSAA){
00174         // changed: 
00175 
00176         m_insideSAA= inside;
00177         createEntry();
00178     }
00179 
00180     return 0; // can't be void in observer pattern
00181 }

void ExposureAlg::createEntry  )  [private]
 

Definition at line 206 of file ExposureAlg.cxx.

References PointingInfo::finish(), PointingInfo::in_saa, PointingInfo::lat_geo, PointingInfo::lat_mag, PointingInfo::lon_geo, m_history, m_initial_time, m_last_livetime, m_lasttime, m_livetimeSvc, m_print_frequency, m_rootTupleSvc, m_tickCount, PointingInfo::set(), PointingInfo::start_time(), and PointingInfo::zenith_scz.

Referenced by askGPS(), execute(), and finalize().

00207 {
00208     m_lasttime = astro::GPS::instance()->time();
00209     if( m_tickCount!=0){
00210         double interval = m_lasttime - m_history.start_time();
00211         if( interval<=1e-10) return;
00212         m_history.finish( m_lasttime, m_livetimeSvc->livetime()-m_last_livetime);
00213 
00214         m_rootTupleSvc->saveRow(this->m_root_tree.value());
00215     }
00216     m_last_livetime = m_livetimeSvc->livetime();
00217 
00218     // start new entry
00219     m_history.set();
00220 
00221     if(  m_tickCount% m_print_frequency==0){
00222         MsgStream   log( msgSvc(), name() );
00223         log << MSG::INFO;
00224         if( log.isActive() ){
00225             std::stringstream t;
00226             t   << "tick at " << std::setprecision(10)
00227                 << m_lasttime - m_initial_time << " sec"
00228                 << std::setprecision(3)
00229                 << ", lat, lon, magLat, zenithTheta, SAA = " 
00230                 << m_history.lat_geo << ", " 
00231                 << m_history.lon_geo << ", "
00232                 << m_history.lat_mag << ", " 
00233                 << ( fabs(m_history.zenith_scz)<1e-8? 0: m_history.zenith_scz) << ", "
00234                 << m_history.in_saa;
00235             log << t.str();
00236         }
00237         log << endreq;
00238     }
00239 
00240     m_tickCount++;
00241 }

StatusCode ExposureAlg::execute  ) 
 

process a tick

Definition at line 185 of file ExposureAlg.cxx.

References createEntry(), IFluxSvc::currentFlux(), m_clockName, m_fluxSvc, m_gps, m_ticks, and IFlux::name().

00186 {
00187     StatusCode  sc = StatusCode::SUCCESS;
00188     MsgStream log(msgSvc(), name());
00189 
00190     IFlux* flux=m_fluxSvc->currentFlux();
00191         
00192     std::string name( flux->name());
00193 
00194     log << MSG::DEBUG << "Clock tick at "<< m_gps->time()<<", clock: "<<name << endreq;
00195 
00196     m_ticks[name]++;
00197 
00198     if(m_clockName.value() == name){
00199         createEntry();
00200         setFilterPassed(false); // since this is on a branch, and we want the sequence to fail
00201     } 
00202 
00203     return sc;
00204 }

StatusCode ExposureAlg::finalize  ) 
 

clean up, summarize

Definition at line 245 of file ExposureAlg.cxx.

References createEntry(), m_tickCount, and m_ticks.

00245                                 {
00246     // finish up
00247     if( m_tickCount>0 ) createEntry();
00248 
00249     StatusCode  sc = StatusCode::SUCCESS;
00250     MsgStream log(msgSvc(), name());
00251 
00252     log << MSG::INFO <<" clock Name     ticks"<<endreq;;
00253     for(std::map<std::string,int>::const_iterator im=m_ticks.begin(); im !=m_ticks.end(); ++im) {
00254         log<< MSG::INFO 
00255             <<std::setw(15) << std::left  << im->first
00256             << std::setw(10)<< std::right << im->second << endreq;
00257     }
00258     log << std::endl;
00259 
00260     return sc;
00261 }

StatusCode ExposureAlg::initialize  ) 
 

set parameters and attach to various perhaps useful services.

Definition at line 115 of file ExposureAlg.cxx.

References askGPS(), IFluxSvc::attachGpsObserver(), m_clockName, m_fluxSvc, m_gps, m_history, m_initial_time, m_lasttime, m_livetimeSvc, m_observer, m_root_tree, m_rootTupleSvc, and PointingInfo::setFT2Tuple().

00115                                   {
00116     StatusCode  sc = StatusCode::SUCCESS;
00117     MsgStream log(msgSvc(), name());
00118 
00119     // Use the Job options service to set the Algorithm's parameters
00120     setProperties();
00121 
00122     if ( service("FluxSvc", m_fluxSvc).isFailure() ){
00123         log << MSG::ERROR << "Couldn't find the FluxSvc!" << endreq;
00124         return StatusCode::FAILURE;
00125     }
00126 
00127     // access the properties of FluxSvc
00128     IProperty* propMgr=0;
00129     sc = serviceLocator()->service("FluxSvc", propMgr );
00130     if( sc.isFailure()) {
00131         log << MSG::ERROR << "Unable to locate PropertyManager Service" << endreq;
00132         return sc;
00133     }
00134 
00135 
00136     DoubleProperty startTime("StartTime",0);
00137     sc = propMgr->getProperty( &startTime );
00138     if (sc.isFailure()) return sc;
00139 
00140     m_initial_time =m_lasttime = startTime.value();
00141 
00142     // get a pointer to RootTupleSvc 
00143     if( (sc = service("RootTupleSvc", m_rootTupleSvc, true) ). isFailure() ) {
00144             log << MSG::ERROR << " failed to get the RootTupleSvc" << endreq;
00145             return sc;
00146     }
00147     // get a pointer to LivetimeSvc 
00148     if( (service("LivetimeSvc", m_livetimeSvc, true) ). isFailure() ) {
00149         log << MSG::ERROR << " LivetimeSvc is not available" << endreq;
00150         return StatusCode::FAILURE;
00151     }
00152 
00153     m_history.setFT2Tuple(m_rootTupleSvc, m_root_tree.value());
00154 
00155     log << MSG::INFO << "Using the clock \""<< m_clockName<< "\" to generate FT2 entries" << endreq;
00156 
00157     // attach an observer to be notified when orbital position changes
00158         // set callback to be notified when the position changes
00159     m_observer.setAdapter( new ActionAdapter<ExposureAlg>
00160         (this, &ExposureAlg::askGPS) );
00161 
00162     m_fluxSvc->attachGpsObserver(&m_observer);
00163     m_gps = astro::GPS::instance();
00164 
00165     return sc;
00166 }


Member Data Documentation

StringProperty ExposureAlg::m_clockName [private]
 

Definition at line 72 of file ExposureAlg.cxx.

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

IFluxSvc* ExposureAlg::m_fluxSvc [private]
 

Definition at line 75 of file ExposureAlg.cxx.

Referenced by execute(), and initialize().

astro::GPS* ExposureAlg::m_gps [private]
 

Definition at line 90 of file ExposureAlg.cxx.

Referenced by execute(), and initialize().

PointingInfo ExposureAlg::m_history [private]
 

Definition at line 81 of file ExposureAlg.cxx.

Referenced by createEntry(), and initialize().

double ExposureAlg::m_initial_time [private]
 

Definition at line 68 of file ExposureAlg.cxx.

Referenced by createEntry(), and initialize().

bool ExposureAlg::m_insideSAA [private]
 

Definition at line 84 of file ExposureAlg.cxx.

Referenced by askGPS().

double ExposureAlg::m_last_livetime [private]
 

Definition at line 67 of file ExposureAlg.cxx.

Referenced by createEntry().

double ExposureAlg::m_lasttime [private]
 

Definition at line 66 of file ExposureAlg.cxx.

Referenced by createEntry(), and initialize().

ILivetimeSvc* ExposureAlg::m_livetimeSvc [private]
 

Definition at line 79 of file ExposureAlg.cxx.

Referenced by createEntry(), and initialize().

ObserverAdapter< ExposureAlg > ExposureAlg::m_observer [private]
 

Definition at line 85 of file ExposureAlg.cxx.

Referenced by initialize().

StringProperty ExposureAlg::m_pointing_history_input_file [private]
 

Definition at line 71 of file ExposureAlg.cxx.

IntegerProperty ExposureAlg::m_print_frequency [private]
 

Definition at line 74 of file ExposureAlg.cxx.

Referenced by createEntry(), and ExposureAlg().

StringProperty ExposureAlg::m_root_tree [private]
 

Definition at line 70 of file ExposureAlg.cxx.

Referenced by ExposureAlg(), and initialize().

INTupleWriterSvc* ExposureAlg::m_rootTupleSvc [private]
 

Definition at line 78 of file ExposureAlg.cxx.

Referenced by createEntry(), and initialize().

int ExposureAlg::m_tickCount [private]
 

Definition at line 77 of file ExposureAlg.cxx.

Referenced by createEntry(), and finalize().

std::map<std::string, int> ExposureAlg::m_ticks [private]
 

Definition at line 91 of file ExposureAlg.cxx.

Referenced by execute(), and finalize().


The documentation for this class was generated from the following file:
Generated on Mon Dec 1 13:30:00 2008 by doxygen 1.3.3