source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/simulation/detector/electronics/src/ElectronicsFactory.cc @ 117

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

ESAF version compilable on mac OS

File size: 7.0 KB
Line 
1// Electronics Factory
2// $Id: ElectronicsFactory.cc 2912 2011-05-20 12:37:28Z biktem $
3// M. Pallavicini - created
4//
5
6#include <iostream>
7#include <string>
8
9#include "ElectronicsFactory.hh"
10#include "EusoElectronics.hh"
11#include "Detector.hh"
12#include "EusoDetector.hh"
13#include "SimpleDetector.hh"
14#include "PhPToRootFileDetector.hh"
15#include "OpticsFactory.hh"
16#include "Photomultiplier.hh"
17#include "R11265U100Photomultiplier.hh"
18#include "R11265U200Photomultiplier.hh"
19#include "R7600M64Photomultiplier.hh"
20#include "R8900M36Photomultiplier.hh"
21#include "R8900M64Photomultiplier.hh"
22#include "FrontEndChip.hh"
23#include "StandardMacroCell.hh"
24#include "PmtGeometry.hh"
25#include "SimpleTelemetry.hh"
26#include "FullAnalogFrontEnd.hh"
27#include "ElementaryCell.hh"
28#include "MacroCellGeometry.hh"
29
30#ifdef ___USING_GEANT4___
31#include "G4Detector.hh"
32#endif
33
34ClassImp(ElectronicsFactory)
35
36ElectronicsFactory* ElectronicsFactory::fMe = 0;
37
38//______________________________________________________________________________
39ElectronicsFactory::ElectronicsFactory() : fEusoElec(0) {
40    // private ctor
41}
42
43//______________________________________________________________________________
44ElectronicsFactory::~ElectronicsFactory() {
45    //
46    // Destructor
47    //
48
49    SafeDelete(fEusoElec);
50}
51
52//______________________________________________________________________________
53ElectronicsFactory* ElectronicsFactory::Get() {
54    // singleton method
55
56    if ( fMe == 0 )
57        fMe = new ElectronicsFactory();
58  return fMe;
59}
60
61//______________________________________________________________________________
62EusoElectronics* ElectronicsFactory::Build() {
63    // build an EusoElectronics object
64
65    DeleteEusoElectronics();
66
67    fEusoElec = new EusoElectronics();
68
69    // build child-parent associations before the electronics
70    Config::Get()->AssociateParent(Conf()->GetStr("ElectronicsFactory.PmtType"),"Photomultiplier");
71
72    // build the system
73    if ( !fEusoElec->Build() ) {
74        FatalError("Cannot build Euso Electronics");
75        return 0;
76    }
77
78    return fEusoElec;
79}
80
81//______________________________________________________________________________
82void ElectronicsFactory::DeleteEusoElectronics() {
83    //
84    // Delete the electonics
85    //
86    FrontEndChip::ResetClass();
87    MacroCell::ResetClass();
88    SafeDelete(fEusoElec);
89}
90
91//______________________________________________________________________________
92// EusoElectronics* ElectronicsFactory::GetEusoElectronics() {
93//     // get euso electronics
94//
95//     return fEusoElec;
96// }
97
98//______________________________________________________________________________
99Detector* ElectronicsFactory::MakeDetector() {
100    // get euso electronics
101
102    Detector* detector(0);
103    string type = Conf()->GetStr("ElectronicsFactory.Detector");
104
105    if ( type == "Euso" )
106        detector = new EusoDetector();
107    else if ( type == "PhPToRootFile" )
108        detector = new PhPToRootFileDetector();
109    else if ( type == "Simple" )
110        detector = new SimpleDetector();
111    else if ( type == "Test" )
112        detector = new TestDetector();
113#ifdef ___USING_GEANT4___
114    else if ( type == "G4Detector" )
115        detector = new G4Detector();
116#endif
117    else
118        FatalError(type + ", unknown Detector");
119
120    return detector;
121}
122
123//______________________________________________________________________________
124FrontEndChip* ElectronicsFactory::MakeFrontEndChip( Int_t size) {
125    // build the selected front end chip object
126
127    string type = Conf()->GetStr("ElectronicsFactory.FrontEndType");
128    if ( type == "Standard" ) {
129        return new FrontEndChip( size );
130    }
131    FatalError("Unknown FrontEndChip type");
132    return 0;
133}
134
135//______________________________________________________________________________
136ElementaryCell* ElectronicsFactory::MakeElementaryCell() {
137    // build the selected elementary cell
138
139    string type = Conf()->GetStr("ElectronicsFactory.ElementaryCellType");
140    if ( type == "Standard" ) {
141        return new ElementaryCell();
142    }
143    FatalError("Unknown ElementaryCell type");
144    return 0;
145}
146
147//______________________________________________________________________________
148AnalogFrontEnd* ElectronicsFactory::MakeAFEE( FrontEndChip* pChip, Int_t size) {
149    // build the specified type of AFEE
150
151    string type = Conf()->GetStr("ElectronicsFactory.AfeeType");
152    if ( type == "Full" ) {
153        return new FullAnalogFrontEnd( pChip, size );
154    }
155    FatalError("Unknown AFEE Type");
156    return 0;
157}
158
159//______________________________________________________________________________
160Photomultiplier* ElectronicsFactory::MakePmt(Int_t id, PmtGeometry *g) {
161    // build the specified type of Photomultiplier object
162
163    string type = Conf()->GetStr("ElectronicsFactory.PmtType");
164    if ( type == "R7600M64Photomultiplier" ) {
165        return new R7600M64Photomultiplier( id , g );
166    }
167    if ( type == "R8900M36Photomultiplier" ) {
168        return new R8900M36Photomultiplier( id , g );
169    }
170    if ( type == "R8900M64Photomultiplier" ) {
171        return new R8900M64Photomultiplier( id , g );
172    }
173    if ( type == "R11265U100Photomultiplier" ) {
174        return new R11265U100Photomultiplier( id , g ); 
175    }
176    if ( type == "R11265U200Photomultiplier" ) {
177        return new R11265U200Photomultiplier( id , g );
178    }
179    FatalError(type + ", unknown Pmt Type");
180    return 0;
181}
182
183//______________________________________________________________________________
184MacroCell* ElectronicsFactory::MakeMacroCell() {
185    // build the specified type of Photomultiplier object
186
187    string type = Conf()->GetStr("ElectronicsFactory.MacroCellType");
188    if ( type == "Standard") {
189        Int_t size = (Int_t)Config::Get()->GetCF("Electronics","MacroCell")->GetNum("MacroCell.fSize");
190        if ( size <= 0 ) {
191            FatalError("Invalid MacroCell size");
192            return 0;
193        }
194        return new StandardMacroCell(size,size);
195    }
196    FatalError( "Unknown MacroCell type" );
197    return 0;
198}
199
200//______________________________________________________________________________
201MacroCellGeometry *ElectronicsFactory::MakeMacroCellGeometry( MacroCell *pCell ) {
202    // build the specified type of macrocell geometry
203
204    string type = Conf()->GetStr("ElectronicsFactory.MacroCellType");
205    if ( type == "Standard") {
206        return new MacroCellGeometry( pCell );
207    }
208    FatalError( "Unknown MacroCellGeometry type" );
209    return 0;
210}
211
212//______________________________________________________________________________
213PmtGeometry* ElectronicsFactory::MakePmtGeometry( const EVector& pos, const EVector& norm, const EVector& dir) {
214    // build PmtGeometry
215
216    PmtGeometry* g = new PmtGeometry( pos , norm, dir);
217    return g;
218}
219
220//______________________________________________________________________________
221Telemetry* ElectronicsFactory::MakeTelemetry() {
222    // build specified Telemetry object
223
224    string type = Conf()->GetStr("ElectronicsFactory.TelemetryType");
225    if ( type == "Standard" ) {
226        return new SimpleTelemetry();
227    }
228    FatalError( "Unknown Telemetry Type" );
229    return 0;
230}
Note: See TracBrowser for help on using the repository browser.