/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/src/BDSSDManager.cc

00001 #include "BDSSDManager.hh"
00002 
00003 #include "globals.hh"              // geant4 types / globals
00004 #include "G4SDManager.hh"
00005 
00006 #include "BDSDebug.hh"
00007 #include "BDSEnergyCounterSD.hh"
00008 #include "BDSSamplerSD.hh"
00009 #include "BDSReadOutGeometry.hh"
00010 
00011 #include "G4VReadOutGeometry.hh"
00012 
00013 BDSSDManager* BDSSDManager::_instance = 0;
00014 
00015 BDSSDManager* BDSSDManager::Instance()
00016 {
00017   if (_instance == 0)
00018     {_instance = new BDSSDManager();}
00019   return _instance;
00020 }
00021 
00022 BDSSDManager::~BDSSDManager()
00023 {;}
00024 
00025 BDSSDManager::BDSSDManager()
00026 {
00027 #ifdef BDSDEBUG
00028   G4cout << __METHOD_NAME__ << " Constructor - creating all necessary Sensitive Detectors" << G4endl;
00029 #endif
00030   //instantiate all necessary SD classes
00031   G4SDManager* SDMan = G4SDManager::GetSDMpointer();
00032 
00033   //read out geometry SD - construct on demand
00034   eCounterOnAxisRO = NULL;
00035 
00036   //sampler plane
00037   samplerPlane = new BDSSamplerSD("sampler_plane","plane");
00038   SDMan->AddNewDetector(samplerPlane);
00039 
00040   //sampler cylindrical
00041   samplerCylinder = new BDSSamplerSD("sampler_cylinder","cylinder");
00042   SDMan->AddNewDetector(samplerCylinder);
00043 
00044   //on axis energy counter - uses read out geometry
00045   eCounterOnAxis = new BDSEnergyCounterSD("ec_on_axis");
00046   SDMan->AddNewDetector(eCounterOnAxis);
00047 }
00048 
00049 BDSEnergyCounterSD* BDSSDManager::GetEnergyCounterOnAxisSDRO()
00050 {
00051   if (!eCounterOnAxisRO)
00052     {ConstructECounterSDOnAxisOnDemand();}
00053 
00054   return eCounterOnAxisRO;
00055 }
00056 
00057 void BDSSDManager::ConstructECounterSDOnAxisOnDemand()
00058 {
00059   // this CANNOT be used until the beamline has been
00060   // placed in detector construction and therefore the readout
00061   // geometry also exists - hence make this on demand
00062   // the SDManager will be called early on to make samplers during
00063   // object construction
00064   //on axis energy counter - uses read out geometry
00065   eCounterOnAxisRO = new BDSEnergyCounterSD("ec_on_axis_read_out");
00066   G4VReadOutGeometry* roGeom = new BDSReadOutGeometry("readOutGeometry");
00067   // although unnecessary for bdsim this MUST be called for geant4 to
00068   // register things properly
00069   // this method actually invokes roGeom->Build() which we have to implement
00070   // but geant4 must do this - so messy!  
00071   roGeom->BuildROGeometry();
00072   eCounterOnAxisRO->SetROgeometry(roGeom); // attach the read out geometry to this SD
00073   G4SDManager* SDMan = G4SDManager::GetSDMpointer();
00074   SDMan->AddNewDetector(eCounterOnAxisRO);
00075 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7