// $Id: OpticsFactory.cc,v 1.22 2005/04/08 17:40:24 thea Exp $
// Author: M.Pallavicini, D.Demarco
/*****************************************************************************
* ESAF: Euso Simulation and Analysis Framework *
* *
* Id: OpticsFactory *
* Package: Optics *
* Coordinator: Alessandro.Thea *
* *
*****************************************************************************/
//_____________________________________________________________________________
//
// Optics Subsystem Factory
// ========================
//
// Factory used to create the optical parts of the detector (main optics,
// photon generator, focalplane and walls). Using OpticsFactory the
// DetectorTransportManager is decoupled from the actual inplementation of
// the various part of the simulation and these can be changed at runtime
//
#include "OpticsFactory.hh"
#include "PolarFocalPlane.hh"
#include "CartesianFocalPlane.hh"
#include "IdealFocalSurface.hh"
#include "JIdealFocalSurface.hh"
#include "KIdealFocalSurface.hh"
#include "TestOpticalAdaptor.hh"
#include "FakeOpticalAdaptor.hh"
#include "IdealOpticalAdaptor.hh"
#include "PipesOpticalAdaptor.hh"
#include "JOpticalSystem.hh"
#include "KOpticalSystem.hh"
#include "ConicBaffle.hh"
#include "ParamOpticalSystem.hh"
#include "DatabaseOpticalSystem.hh"
#include "ElecTestDetTransManager.hh"
ClassImp(OpticsFactory)
OpticsFactory *OpticsFactory::fgMe=0;
//______________________________________________________________________________
OpticsFactory *OpticsFactory::Get() {
//
// Static getter
//
if(fgMe==0)
fgMe = new OpticsFactory;
return fgMe;
}
//______________________________________________________________________________
OpticsFactory::OpticsFactory(): fOptics(0), fFocalPlane(0), fIdealFocalSurface(0),
fWalls(0), fBaffle(0), fTransportManager(0) {
//
// Constructor
//
Build();
}
//______________________________________________________________________________
void OpticsFactory::Build() {
//
// Build child-parent associations
//
Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fWalls"),"WallInteraction");
Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fBaffle"),"Baffle");
// Not necessary any more
// Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fFocalPlane"),"FocalPlane");
// Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fOpticalSystem"),"OpticalSystem");
// Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fIdealFocalSurface"),"IdealFocalSurface");
// Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fOpticalAdaptor"),"OpticalAdaptor");
}
//______________________________________________________________________________
OpticalSystem *OpticsFactory::GetOpticalSystem() {
if(fOptics==0) {
string g=Conf()->GetStr("OpticsFactory.fOpticalSystem");
if( g == "TestOpticalSystem" ) fOptics = new TestOpticalSystem;
else if ( g == "JOpticalSystem") fOptics = new JOpticalSystem;
else if ( g == "KOpticalSystem") fOptics = new KOpticalSystem;
else if ( g == "ParamOpticalSystem") fOptics = new ParamOpticalSystem;
else if ( g == "DatabaseOpticalSystem") fOptics = new DatabaseOpticalSystem;
// other opticalsystems go here
else throw invalid_argument("invalid opticalsystem: "+g);
}
return fOptics;
}
//______________________________________________________________________________
FocalPlane *OpticsFactory::GetFocalPlane() {
if(fFocalPlane==0) {
string g=Conf()->GetStr("OpticsFactory.fFocalPlane");
if( g == "TestFocalPlane") fFocalPlane = new TestFocalPlane;
else if( g == "PolarFocalPlane" ) fFocalPlane = new PolarFocalPlane;
else if( g == "CartesianFocalPlane" ) fFocalPlane = new CartesianFocalPlane;
// other focalplanes go here
else throw invalid_argument("invalid fFocalPlane: "+g);
}
return fFocalPlane;
}
//______________________________________________________________________________
IdealFocalSurface *OpticsFactory::GetIdealFocalSurface() {
if(fIdealFocalSurface==0) {
string g=Conf()->GetStr("OpticsFactory.fIdealFocalSurface");
if(g=="TestIdealFocalSurface") fIdealFocalSurface=new TestIdealFocalSurface;
else if(g=="JIdealFocalSurface") fIdealFocalSurface=new JIdealFocalSurface;
else if(g=="KIdealFocalSurface") fIdealFocalSurface=new KIdealFocalSurface;
// other focalplanes go here
else throw invalid_argument("invalid fIdealFocalSurface: "+g);
}
return fIdealFocalSurface;
}
//______________________________________________________________________________
WallInteraction *OpticsFactory::GetWalls() {
if(fWalls==0) {
string g=Conf()->GetStr("OpticsFactory.fWalls");
if(g=="WallInteraction") fWalls=new WallInteraction;
// other fWalls go here
else throw invalid_argument("invalid fWalls: "+g);
}
return fWalls;
}
//______________________________________________________________________________
Baffle *OpticsFactory::GetBaffle() {
if(fBaffle==0) {
string g=Conf()->GetStr("OpticsFactory.fBaffle");
if(g=="TestBaffle") fBaffle = new TestBaffle;
if(g=="ConicBaffle") fBaffle = new ConicBaffle;
// other baffles go here
else throw invalid_argument("invalid fBaffle: "+g);
}
return fBaffle;
}
//______________________________________________________________________________
OpticalAdaptor *OpticsFactory::GetOA() {
string g=Conf()->GetStr("OpticsFactory.fOpticalAdaptor");
OpticalAdaptor *oa = NULL;
if(g=="TestOpticalAdaptor") oa = new TestOpticalAdaptor();
else if(g=="FakeOpticalAdaptor") oa = new FakeOpticalAdaptor();
else if(g=="IdealOpticalAdaptor") oa = new IdealOpticalAdaptor();
else if(g=="PipesOpticalAdaptor") oa = new PipesOpticalAdaptor();
// other adaptors go here
else throw invalid_argument("invalid OpticalAdaptor: "+g);
return oa;
}
//______________________________________________________________________________
DetectorTransportManager *OpticsFactory::GetTransportManager() {
if ( fTransportManager == 0) {
string g=Conf()->GetStr("OpticsFactory.fTransportManager");
if ( g == "Standard" )
fTransportManager = new DetectorTransportManager();
else if ( g == "ElectronicsTest")
fTransportManager = new ElecTestDetTransManager();
else
throw invalid_argument("invalid DetectorTransportManager: "+g);
}
return fTransportManager;
}