source: JEM-EUSO/esaf_cc_at_lal/packages/simulation/detector/optics/src/OpticsFactory.cc @ 114

Last change on this file since 114 was 114, checked in by moretto, 11 years ago

actual version of ESAF at CCin2p3

File size: 7.6 KB
Line 
1// $Id: OpticsFactory.cc 2849 2010-11-11 11:59:41Z biktem $
2// Author: M.Pallavicini, D.Demarco
3
4/*****************************************************************************
5 * ESAF: Euso Simulation and Analysis Framework                              *
6 *                                                                           *
7 *  Id: OpticsFactory                                                        *
8 *  Package: Optics                                                          *
9 *  Coordinator: Alessandro.Thea                                             *
10 *                                                                           *
11 *****************************************************************************/
12
13//_____________________________________________________________________________
14//
15//   Optics Subsystem Factory
16//   ========================
17//
18//   Factory used to create the optical parts of the detector (main optics,
19//   photon generator, focalplane and walls).  Using OpticsFactory the
20//   DetectorTransportManager is decoupled from the actual inplementation of
21//   the various part of the simulation and these can be changed at runtime
22//
23
24#include "OpticsFactory.hh"
25#include "PolarFocalPlane.hh"
26#include "CartesianFocalPlane.hh"
27#include "IdealFocalSurface.hh"
28#include "JIdealFocalSurface.hh"
29#include "KIdealFocalSurface.hh"
30#include "LIdealFocalSurface.hh"
31#include "MIdealFocalSurface.hh"
32#include "NIdealFocalSurface.hh"
33#include "TestOpticalAdaptor.hh"
34#include "FakeOpticalAdaptor.hh"
35#include "IdealOpticalAdaptor.hh"
36#include "PipesOpticalAdaptor.hh"
37#include "JOpticalSystem.hh"
38#include "KOpticalSystem.hh"
39#include "LOpticalSystem.hh"
40#include "MOpticalSystem.hh"
41#include "NOpticalSystem.hh"
42#include "ConicBaffle.hh"
43#include "ParamOpticalSystem.hh"
44#include "DatabaseOpticalSystem.hh"
45
46#include "VirtualDetectorTransportManager.hh"
47#include "DetectorTransportManager.hh"
48#include "ElecTestDetTransManager.hh"
49
50#ifdef ___USING_GEANT4___
51#include "G4TransportManager.hh"
52#endif
53
54ClassImp(OpticsFactory)
55
56OpticsFactory *OpticsFactory::fgMe=0;
57
58//______________________________________________________________________________
59OpticsFactory *OpticsFactory::Get() {
60    //
61    // Static getter
62    //
63    if(fgMe==0)
64        fgMe = new OpticsFactory;
65    return fgMe;
66}
67
68//______________________________________________________________________________
69OpticsFactory::OpticsFactory() : fOptics(0) {
70    //
71    // Constructor
72    //
73
74    Build();
75}
76//______________________________________________________________________________
77OpticsFactory::~OpticsFactory() {
78    //
79    // Destructor
80    //
81    if(fOptics) delete fOptics;
82
83}
84
85//______________________________________________________________________________
86void OpticsFactory::Build() {
87    //
88    // Build child-parent associations
89    //
90    Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fWalls"),"WallInteraction");
91    Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fBaffle"),"Baffle");
92
93    // Not necessary any more
94    // Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fFocalPlane"),"FocalPlane");
95    // Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fOpticalSystem"),"OpticalSystem");
96    // Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fIdealFocalSurface"),"IdealFocalSurface");
97    // Config::Get()->AssociateParent(Conf()->GetStr("OpticsFactory.fOpticalAdaptor"),"OpticalAdaptor");
98}
99
100//______________________________________________________________________________
101OpticalSystem *OpticsFactory::MakeOpticalSystem() {
102    // avoid double creation. For example with DiffusePhotonOnPupil+DetectorTransportManager
103    if ( fOptics ) return fOptics;
104
105    string g=Conf()->GetStr("OpticsFactory.fOpticalSystem");
106    if( g == "TestOpticalSystem" )          fOptics = new TestOpticalSystem;
107    else if ( g == "JOpticalSystem")        fOptics = new JOpticalSystem;
108    else if ( g == "KOpticalSystem")        fOptics = new KOpticalSystem;
109    else if ( g == "LOpticalSystem")        fOptics = new LOpticalSystem;
110    else if ( g == "MOpticalSystem")        fOptics = new MOpticalSystem;
111    else if ( g == "NOpticalSystem")        fOptics = new NOpticalSystem;
112    else if ( g == "ParamOpticalSystem")    fOptics = new ParamOpticalSystem;
113    else if ( g == "DatabaseOpticalSystem") fOptics = new DatabaseOpticalSystem;
114    // other opticalsystems go here
115    else throw invalid_argument("invalid opticalsystem: "+g);
116
117    return fOptics;
118}
119
120//______________________________________________________________________________
121FocalPlane *OpticsFactory::MakeFocalPlane() {
122
123    FocalPlane* fp(0);
124    string g=Conf()->GetStr("OpticsFactory.fFocalPlane");
125    if( g == "TestFocalPlane")            fp = new TestFocalPlane;
126    else if( g == "PolarFocalPlane" )     fp = new PolarFocalPlane;
127    else if( g == "CartesianFocalPlane" ) fp = new CartesianFocalPlane;
128    // other focalplanes go here
129    else throw invalid_argument("invalid fFocalPlane: "+g);
130
131    fFocalPlane = fp;
132    return fp;
133}
134
135//______________________________________________________________________________
136IdealFocalSurface *OpticsFactory::MakeIdealFocalSurface() {
137
138    IdealFocalSurface* ifs(0);
139    string g=Conf()->GetStr("OpticsFactory.fIdealFocalSurface");
140    if(g=="TestIdealFocalSurface")   ifs=new TestIdealFocalSurface;
141    else if(g=="JIdealFocalSurface") ifs=new JIdealFocalSurface;
142    else if(g=="KIdealFocalSurface") ifs=new KIdealFocalSurface;
143    else if(g=="LIdealFocalSurface") ifs=new LIdealFocalSurface;
144    else if(g=="MIdealFocalSurface") ifs=new MIdealFocalSurface;
145    else if(g=="NIdealFocalSurface") ifs=new NIdealFocalSurface;
146    // other focalplanes go here
147    else throw invalid_argument("invalid fIdealFocalSurface: "+g);
148
149    return ifs;
150}
151
152//______________________________________________________________________________
153WallInteraction *OpticsFactory::MakeWalls() {
154
155    WallInteraction* w(0);
156
157    string g=Conf()->GetStr("OpticsFactory.fWalls");
158    if(g=="WallInteraction") w=new WallInteraction;
159    // other fWalls go here
160    else throw invalid_argument("invalid fWalls: "+g);
161
162    return w;
163}
164
165//______________________________________________________________________________
166Baffle *OpticsFactory::MakeBaffle() {
167
168    Baffle* b(0);
169    string g=Conf()->GetStr("OpticsFactory.fBaffle");
170    if(g=="TestBaffle")  b = new TestBaffle;
171    if(g=="ConicBaffle") b = new ConicBaffle;
172    // other baffles go here
173    else throw invalid_argument("invalid fBaffle: "+g);
174
175    return b;
176}
177
178//______________________________________________________________________________
179OpticalAdaptor *OpticsFactory::MakeOA() {
180
181    OpticalAdaptor *oa = NULL;
182    string g=Conf()->GetStr("OpticsFactory.fOpticalAdaptor");
183    if(g=="TestOpticalAdaptor")       oa = new TestOpticalAdaptor();
184    else if(g=="FakeOpticalAdaptor")  oa = new FakeOpticalAdaptor();
185    else if(g=="IdealOpticalAdaptor") oa = new IdealOpticalAdaptor();
186    else if(g=="PipesOpticalAdaptor") oa = new PipesOpticalAdaptor();
187    // other adaptors go here
188    else throw invalid_argument("invalid OpticalAdaptor: "+g);
189
190    return oa;
191}
192
193//______________________________________________________________________________
194VirtualDetectorTransportManager *OpticsFactory::MakeTransportManager() {
195
196    VirtualDetectorTransportManager* tm = NULL;
197
198        string g=Conf()->GetStr("OpticsFactory.fTransportManager");
199        if (g=="Standard")            tm = new DetectorTransportManager();
200        else if(g=="ElectronicsTest") tm = new ElecTestDetTransManager();
201#ifdef ___USING_GEANT4___
202        else if(g=="G4TransportManager") tm = new G4TransportManager();
203#endif
204        else
205            throw invalid_argument("invalid DetectorTransportManager: "+g);
206
207        return tm;
208}
Note: See TracBrowser for help on using the repository browser.