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

Glast.cxx

Go to the documentation of this file.
00001 // $Id: Glast.cxx,v 1.3 2000/11/22 16:19:16 jrb Exp $
00002 
00003 #include "instrument/Glast.h"
00004 
00005 #include "instrument/Tower.h"
00006 #include "instrument/MCTruth.h"
00007 #include "instrument/Scintillator.h"
00008 #include "xml/IFile.h"
00009 #include "xml/IFileManager.h"
00010 
00011 #include <strstream>
00012 #include <fstream>
00013 #include <cassert>
00014 
00015 int Glast::xNum = 1;
00016 int Glast::yNum = 1;
00017 double Glast::wall_gap = 0;
00018 double Glast::ke_cutoff = .0005;
00019 double Glast::zModDepth;
00020 double Glast::zModCntr;
00021 double Glast::Width;
00022 
00023 Glast *Glast::s_instance = 0;
00024 
00025 const GlastDetector::_PersistKey
00026 Glast::classPersistKey = GlastDetector::_PersistKey("Glast");
00027 
00028 namespace {
00029     
00030   // register with the IFileManager
00031   bool glastLoadParams = xml::IFileManager::loadParams(Glast::loadParameters);
00032   bool glastpersistValid = 
00033     GlastDetector::addPersistence(Glast::classPersistKey, new Glast::_Factory);
00034     
00035 };
00036 
00037 
00038 // constructor
00039 Glast::Glast () : GlastDetector() {
00040   s_instance = this;
00041 }
00042 // destructor
00043 Glast::~Glast () {
00044   s_instance = 0;
00045 }
00046 
00047 // persistence constructor - XML (DOM api)
00048 Glast::Glast (const DOM_Element& elem) : GlastDetector(elem) {
00049   s_instance = this;
00050 }
00051 
00052 // "persist" using XML (DOM api)
00053 // DOM_Element&    Glast::persist (DOM_Element& parent) const {
00054 //  DOM_Element& selem = GlastDetector::persist(parent);
00055 DOM_Element    Glast::persist (DOM_Element& parent) const {
00056   DOM_Element selem = GlastDetector::persist(parent);
00057     
00058   return selem;
00059 }
00060 
00061 //  setup parameters, done once
00062 void Glast::loadParameters(xml::IFile& ini)
00063 {
00064   // get basic parameters from the ini file
00065   xNum = ini.getInt("glast","xNum"),
00066     yNum = ini.getInt("glast","yNum");
00067   wall_gap=   ini.getDouble("walls", "gap");
00068   ke_cutoff=  ini.getDouble("glast", "ke_cutoff", .0005);
00069     
00070 }
00071 
00072 void
00073 Glast::printOn (std::ostream& out) const
00074 {
00075   GlastDetector::printOn (out);
00076 }
00077 
00078 void Glast::accept (DetectorVisitor& v)
00079 {
00080   m_visit_flag = true;
00081   v.visit(this); // allows visitor to initialize, since this would be first
00082   v.visit(&m_truth);  // allow visitor to get the MCTruth
00083 
00084   // now go thru children unless aborted
00085   if(m_visit_flag) GlastDetector::accept(v);
00086 }
00087 
00088 void Glast::write(std::ostream & os) const
00089 {
00090   GlastDetector::write (os);
00091 }
00092 
00093 void Glast::read(std::istream & is)
00094 {
00095   GlastDetector::read (is);
00096 }
00097 
00098 void
00099 Glast::visit(Tower* t) 
00100 {
00101   addChild(t); // keep track of towers
00102 }
00103 
00104 void
00105 Glast::visit(Scintillator* s)
00106 {
00107   addChild (s); // keep track of scintillators
00108 }
00109 
00110 Glast::iterator Glast::begin () {
00111   return iterator(begin());
00112 }
00113 Glast::iterator Glast::end () {
00114   return iterator(end());
00115 }
00116 Glast::const_iterator Glast::begin () const {
00117   return const_iterator(begin());
00118 }
00119 Glast::const_iterator Glast::end () const {
00120   return const_iterator(end());
00121 }
00122 const Tower*    Glast::tower (const unsigned int& i) const {
00123   if (i >= nChildren())   return 0;
00124   return static_cast<const Tower*>(*(begin() + i));
00125 }

Generated at Wed Nov 21 12:22:39 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000