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

ObfCoordsAlg.cxx

Go to the documentation of this file.
00001 
00006 // Include files
00007 
00008 #include "GaudiKernel/Algorithm.h"
00009 #include "GaudiKernel/MsgStream.h"
00010 #include "GaudiKernel/AlgFactory.h"
00011 #include "GaudiKernel/SmartDataPtr.h"
00012 
00013 #include "astro/GPS.h"
00014 #include "geometry/Vector.h"
00015 
00016 #include "ntupleWriterSvc/INTupleWriterSvc.h"
00017 
00018 #include <cassert>
00019 #include <map>
00020 
00021 // forward declatation of the worker
00022 class ObfCworker;
00023 
00024 namespace { // anonymous namespace for file-global
00025     std::string treename("MeritTuple");
00026     astro::GPS* gps(0);
00027 #include "Item.h"
00028 }
00029 
00030 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00034 class ObfCoordsAlg : public Algorithm {
00035 
00036 public:
00037     ObfCoordsAlg(const std::string& name, ISvcLocator* pSvcLocator); 
00038 
00039     StatusCode initialize();
00040     StatusCode execute();
00041     StatusCode finalize();
00042 private:
00044     ObfCworker * m_worker;
00045     //counter
00046     int m_count;
00047 };
00048 
00049 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00050 
00051 static const AlgFactory<ObfCoordsAlg>  Factory;
00052 const IAlgFactory& ObfCoordsAlgFactory = Factory;
00053 
00054 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00055 
00056 class ObfCworker{ 
00057 public:
00058     ObfCworker();
00059 
00060     void evaluate();
00061 
00062 private:
00063     // tuple items expect to find
00064     //TypedItem<unsigned int, 'i'> EvtRun, EvtEventId;
00065 
00066     // These will replace Filter%Dir's above
00067     Item GrbXDir;
00068     Item GrbYDir;
00069     Item GrbZDir;
00070 
00071     //ObfCoords entries to create
00072     float m_grbRa,m_grbDec,m_grbL,m_grbB;
00073     //float m_obfZen,m_obfAzim;
00074 };
00075 
00076 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00077 ObfCoordsAlg::ObfCoordsAlg(const std::string& name, ISvcLocator* pSvcLocator)
00078 : Algorithm(name, pSvcLocator)
00079 , m_count(0)
00080 {
00081     declareProperty("TreeName",  treename="MeritTuple");
00082 }
00083 
00084 StatusCode ObfCoordsAlg::initialize()
00085 {
00086     StatusCode  sc = StatusCode::SUCCESS;
00087 
00088     MsgStream log(msgSvc(), name());
00089 
00090     // Use the Job options service to get the Algorithm's parameters
00091     setProperties();
00092 
00093     // get a pointer to RootTupleSvc 
00094     if( (sc = service("RootTupleSvc", rootTupleSvc, true) ). isFailure() ) {
00095         log << MSG::ERROR << " failed to get the RootTupleSvc" << endreq;
00096         return sc;
00097     }
00098     m_worker = new ObfCworker();
00099 
00100     // get the GPS instance
00101     gps = astro::GPS::instance();
00102 
00103     return sc;
00104 }
00105 
00106 StatusCode ObfCoordsAlg::execute()
00107 {
00108     StatusCode sc = StatusCode::SUCCESS;
00109 
00110     MsgStream log(msgSvc(), name());
00111 
00112     m_count++;
00113 
00114     // now have the worker do it
00115     m_worker->evaluate();
00116 
00117     return sc;
00118 }
00119 
00120 StatusCode ObfCoordsAlg::finalize()
00121 {
00122     return StatusCode::SUCCESS;
00123 }
00124 
00125 
00126 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00127 
00142 ObfCworker::ObfCworker()
00143 // initialize pointers to current items
00144 : GrbXDir("GrbXDir")
00145 , GrbYDir("GrbYDir")
00146 , GrbZDir("GrbZDir")
00147 {
00148     //now create new items 
00149     addItem( "GrbRa",     m_grbRa);
00150     addItem( "GrbDec",    m_grbDec);
00151     addItem( "GrbL",      m_grbL);
00152     addItem( "GrbB",      m_grbB);
00153 }
00154 
00155 
00156 void ObfCworker::evaluate()
00157 {
00158     m_grbRa = m_grbDec = m_grbL = m_grbB = 0;
00159 
00160     Vector grbDir(GrbXDir, GrbYDir, GrbZDir);
00161     if (grbDir.mag()==0) return;
00162     astro::SkyDir skyGrbdir( gps->toSky(-grbDir) );
00163     m_grbRa  = skyGrbdir.ra();
00164     m_grbDec = skyGrbdir.dec();
00165     m_grbL   = skyGrbdir.l();
00166     m_grbB   = skyGrbdir.b();
00167 
00168     return;
00169 }
00170 //------------------------------------------------------------------------------
00171 

Generated on Mon Dec 1 20:09:05 2008 by doxygen 1.3.3