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

ExposureAlg Class Reference

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

#include <ExposureAlg.h>

List of all members.

Public Methods

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

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

StatusCode execute ()
 process an event. More...

StatusCode finalize ()
 clean up, summarize. More...


Private Attributes

double m_lasttime
StringProperty m_source_name
IFluxSvcm_fluxSvc
IFluxm_flux
unsigned long m_run
 Create the TimeCandle Spectrum. More...

unsigned long m_event
std::ostream * m_out
IDataProviderSvc * m_eds
IParticlePropertySvc * m_partSvc


Detailed Description

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

Author:
Sean Robinson
$Header $

Definition at line 32 of file ExposureAlg.h.


Constructor & Destructor Documentation

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

ctor.

Definition at line 49 of file ExposureAlg.cxx.

00050 :Algorithm(name, pSvcLocator), m_out(0)
00051 {
00052     // declare properties with setProperties calls
00053     declareProperty("source_name",  m_source_name="default");
00054     
00055 }


Member Function Documentation

StatusCode ExposureAlg::execute  
 

process an event.

Definition at line 82 of file ExposureAlg.cxx.

References GPS::DECX(), GPS::DECZ(), GPS::DECZenith(), GPS::getPointingCharacteristics(), GPS::instance(), GPS::position(), GPS::RAX(), GPS::RAZ(), and GPS::RAZenith().

00083 {
00084     using namespace astro;
00085     StatusCode  sc = StatusCode::SUCCESS;
00086     MsgStream   log( msgSvc(), name() );
00087     double currentTime;
00088     //-----------------------------------------------------------------------
00089     
00090     Event::McParticleCol* pcol = new Event::McParticleCol;
00091     eventSvc()->retrieveObject("/Event/MC/McParticleCol",(DataObject *&)pcol);
00092     //only make a new source if one does not already exist.
00093     if(pcol==0){
00094         //FluxAlg didn't do anything.  proceed.
00095         
00096         //if the flux had changed, something changed the source type.
00097         if(m_fluxSvc->currentFlux() == m_flux){
00098             m_flux->generate();
00099             currentTime = m_flux->time();
00100         }else{
00101             m_flux = m_fluxSvc->currentFlux();
00102             m_flux->generate();
00103             currentTime = m_flux->time();
00104         }
00105     }else{
00106         //FluxAlg is taking care of the particle, so do nothing but get the current time.
00107         currentTime = m_fluxSvc->currentFlux()->time();
00108     }   
00109 
00110     //now, only do the rest of this algorithm if we have a timetick particle.
00111     std::string particleName = m_fluxSvc->currentFlux()->particleName();
00112     if(particleName != "TimeTick"){
00113         log << MSG::DEBUG << particleName << " Not a timetick particle, no D2Database entry created, continuing..." << endreq;
00114         return StatusCode::SUCCESS;
00115     }
00116 
00117     //by now, we should know that we have the appropriate particle to make a D2Entry with.
00118     double secondsperday = 60.*60.*24.;
00119 
00120     // here we get the time characteristics
00121 
00122     
00123     EarthOrbit orb; //for the following line - this should have a better implementation.
00124     double julianDate = orb.dateFromSeconds(currentTime);
00125 
00126     //NOTE: this gets an interval from the last time that a TimeTick particle came to this one.
00127     //in other words, the timeTick particles define the beginning and ends of intervals.
00128     double intrvalstart = m_lasttime;
00129     //then get the end of the interval (this can be made into whatever).
00130     double intrvalend = currentTime;
00131     //get the livetime from the source itself.
00132     double livetime = intrvalend - m_lasttime;
00133     //..and reset the time of this event to be the "last time" for next time.
00134     m_lasttime = intrvalend;
00135 
00136     intrvalstart = orb.dateFromSeconds(intrvalstart);
00137     intrvalend = orb.dateFromSeconds(intrvalend);
00138 
00139     //and here the pointing characteristics of the LAT.
00140     GPS::instance()->getPointingCharacteristics(currentTime);
00141     //EarthOrbit orbt;
00142     Hep3Vector location = GPS::instance()->position(currentTime);
00143     
00144     // hold onto the cartesian location of the LAT
00145     double posx = location.x(); 
00146     double posy = location.y(); 
00147     double posz = location.z(); 
00148     std::cout << std::endl;
00149     double rax = GPS::instance()->RAX();
00150     double raz = GPS::instance()->RAZ();
00151     double decx = GPS::instance()->DECX();
00152     double decz = GPS::instance()->DECZ();
00153     double razenith = GPS::instance()->RAZenith();
00154     double deczenith = GPS::instance()->DECZenith();
00155     
00156     EarthCoordinate earthpos(location,julianDate);
00157     double lat = earthpos.latitude();
00158     double lon = earthpos.longitude();
00159     double alt = earthpos.altitude();
00160     bool SAA = earthpos.insideSAA();
00161     
00162     SolarSystem sstm;
00163     
00164     double ramoon = sstm.direction(astro::SolarSystem::Moon,julianDate).ra();
00165     double decmoon = sstm.direction(astro::SolarSystem::Moon,julianDate).dec();
00166     double rasun = sstm.direction(astro::SolarSystem::Sun,julianDate).ra();
00167     double decsun = sstm.direction(astro::SolarSystem::Sun,julianDate).dec();
00168     
00169     // Here the TDS is prepared to receive hits vectors
00170     // Check for the MC branch - it will be created if it is not available
00171     
00172     DataObject *mc = new Event::D2EntryCol;
00173     sc=eventSvc()->registerObject(EventModel::MC::Event , mc);
00174     //if(sc.isFailure()) {
00175     //    log << MSG::ERROR << EventModel::MC::Event  <<" could not be registered on data store" << endreq;
00176     //    return sc;
00177     //}
00178     
00179     // Here the TDS receives the exposure data
00180     Event::D2EntryCol* exposureDBase = new Event::D2EntryCol;
00181     sc=eventSvc()->registerObject(EventModel::MC::D2EntryCol , exposureDBase);
00182     if(sc.isFailure()) {
00183         log << MSG::ERROR << EventModel::MC::D2EntryCol  <<" could not be entered into existing data store" << endreq;
00184         return sc;
00185     }
00186     
00187     Event::D2Entry* entry = new Event::D2Entry;
00188     
00189     exposureDBase->push_back(entry);
00190 
00191     entry->init(posx, posy, posz,rax,raz,decx,decz,razenith,deczenith,lat,
00192         lon,alt,intrvalstart,intrvalend,
00193         livetime,ramoon,decmoon,rasun,decsun,
00194         SAA);
00195     
00196     // now we'll retreive the data from the TDS as a check.
00197     Event::D2EntryCol* elist = new Event::D2EntryCol;
00198     eventSvc()->retrieveObject("/Event/MC/D2EntryCol",(DataObject *&)elist);
00199     
00200     Event::D2EntryCol::iterator curEntry = (*elist).begin();
00201     //some test output - to show that the data got onto the TDS
00202     (*curEntry)->writeOut(log);
00203 
00204     SkyDir curDir(raz,decz);
00205     SkyDir xDir(rax,decx);
00206 
00207     SkyDir sunDir(rasun,decsun);
00208     //Rotation galtoglast(m_fluxSvc->transformGlastToGalactic(currentTime).inverse);
00209     sunDir()=(m_fluxSvc->transformGlastToGalactic(currentTime).inverse())*sunDir();
00210      
00211     //and here's the file output.
00212     std::ostream& out = *m_out;
00213         out<<intrvalstart <<'\t';
00214         out<<intrvalend <<'\t';
00215         out<< posx<<'\t';
00216         out<< posy<<'\t';
00217         out<< posz<<'\t';
00218         out<<raz<<'\t';
00219         out<<decz<<'\t';
00220         out<<rax<<'\t';
00221         out<<decx<<'\t';
00222         out<<razenith<<"\t";
00223         out<<deczenith <<'\t';
00224         out<<"1"<<'\t';
00225         out<<livetime <<'\t';
00226         out<<SAA<<'\t';
00227         out<<lon <<'\t';
00228         out<<lat <<'\t';
00229         out<<alt <<'\t';
00230         out<<curDir.l() <<'\t';
00231         out<<curDir.b()<<'\t';
00232         out<<xDir.l() <<'\t';
00233         out<<xDir.b()<<'\t';
00234         out<< rasun <<"\t"<<decsun  <<'\t';
00235         out<< sunDir().x() <<"\t"<< sunDir().y()  <<"\t"<< sunDir().z()  <<'\t';
00236         out<<ramoon <<"\t"<<decmoon   <<std::endl;
00237                                 
00238 
00239 
00240         setFilterPassed( false );
00241     log << MSG::DEBUG << "ExposureAlg found a TimeTick particle, ended this execution after making a record, filterpassed = " << filterPassed() << endreq;
00242 
00243     return sc;
00244 }

StatusCode ExposureAlg::finalize  
 

clean up, summarize.

Definition at line 248 of file ExposureAlg.cxx.

00248                                 {
00249     StatusCode  sc = StatusCode::SUCCESS;
00250     MsgStream log(msgSvc(), name());
00251     delete m_out;
00252     
00253     return sc;
00254 }

StatusCode ExposureAlg::initialize  
 

set parameters and attach to various perhaps useful services.

Definition at line 59 of file ExposureAlg.cxx.

References GPS::SLEWING.

00059                                   {
00060     StatusCode  sc = StatusCode::SUCCESS;
00061     MsgStream log(msgSvc(), name());
00062     log << MSG::INFO << "initialize" << endreq;
00063 
00064     // Use the Job options service to set the Algorithm's parameters
00065     setProperties();
00066     
00067     if ( service("FluxSvc", m_fluxSvc).isFailure() ){
00068         log << MSG::ERROR << "Couldn't find the FluxSvc!" << endreq;
00069         return StatusCode::FAILURE;
00070     }
00071 
00072     //TODO: set the file name from a property
00073     m_out = new std::ofstream("orbitFromAlg.out");
00074     m_fluxSvc->setRockType(GPS::SLEWING);
00075 
00076     return sc;
00077 }


Member Data Documentation

IDataProviderSvc* ExposureAlg::m_eds [private]
 

Definition at line 55 of file ExposureAlg.h.

unsigned long ExposureAlg::m_event [private]
 

Definition at line 52 of file ExposureAlg.h.

IFlux* ExposureAlg::m_flux [private]
 

Definition at line 46 of file ExposureAlg.h.

IFluxSvc* ExposureAlg::m_fluxSvc [private]
 

Definition at line 45 of file ExposureAlg.h.

double ExposureAlg::m_lasttime [private]
 

Definition at line 43 of file ExposureAlg.h.

std::ostream* ExposureAlg::m_out [private]
 

Definition at line 53 of file ExposureAlg.h.

IParticlePropertySvc* ExposureAlg::m_partSvc [private]
 

Definition at line 57 of file ExposureAlg.h.

unsigned long ExposureAlg::m_run [private]
 

Create the TimeCandle Spectrum.

Definition at line 51 of file ExposureAlg.h.

StringProperty ExposureAlg::m_source_name [private]
 

Definition at line 44 of file ExposureAlg.h.


The documentation for this class was generated from the following files:
Generated on Wed Oct 16 14:01:32 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001