MarlinTrk  02.08
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Factory.cc
Go to the documentation of this file.
1 #include "MarlinTrk/Factory.h"
2 
5 
6 #include "streamlog/streamlog.h"
7 
8 #include <sstream>
9 
10 namespace MarlinTrk{
11 
12 
13 
15  const gear::GearMgr*,
16  const std::string& /*options*/ ){
17 
18 
19  // check if we have already instantiated a tracking system of the requested type:
20 
21  TrkSystemMap::iterator tsI = instance()->_map.find( systemType ) ;
22 
23  if( tsI != instance()->_map.end() ) {
24 
25  streamlog_out( DEBUG4 ) << " Factory::createMarlinTrkSystem(): return already created IMarlinTrkSystem "
26  << " of type: " << systemType << std::endl ;
27 
28  return tsI->second ;
29  }
30 
31 
32  //--------------------------
33 
34  IMarlinTrkSystem* trkSystem = 0 ;
35 
36  streamlog_out( MESSAGE ) << " Factory::createMarlinTrkSystem: creating IMarlinTrkSystem of type \""
37  << systemType << "\"" << std::endl ;
38 
39 
40  if( systemType == std::string( "DDKalTest" ) ) {
41 
42  trkSystem = new MarlinDDKalTest ;
43  }
44  else if( systemType == std::string( "AidaTT" ) ) {
45 
46  trkSystem = new MarlinAidaTT ;
47  }
48 
49  if( ! trkSystem ) {
50 
51  std::stringstream log ;
52  log << " Factory::createMarlinTrkSystem - cannot create IMarlinTrkSystem for type : " << systemType ;
53  throw Exception( log.str() ) ;
54  }
55 
56  instance()->_map.insert( std::make_pair( systemType, trkSystem ) ) ;
57 
58  instance()->_currentTrkSystem = trkSystem ;
59 
60  return instance()->_currentTrkSystem ;
61  }
62 
63  //-------------------------------------------------------------------------------------------------------------------
64 
66 
67  TrkSystemMap::iterator tsI = instance()->_map.find( systemType ) ;
68 
69  if( tsI == instance()->_map.end() ) {
70 
71  std::stringstream log ;
72  log << " Factory::getMarlinTrkSystem called without a preceeding call to createMarlinTrkSystem() for type : "
73  << systemType << std::endl ;
74 
75  throw Exception( log.str() ) ;
76  }
77 
78  streamlog_out( DEBUG4 ) << " Factory::getMarlinTrkSystem(): return IMarlinTrkSystem "
79  << " of type: " << systemType << std::endl ;
80 
81  instance()->_currentTrkSystem = tsI->second ;
82 
83  return instance()->_currentTrkSystem ;
84  }
85 
86  //-------------------------------------------------------------------------------------------------------------------
88 
90 
91  if( current == 0 ){
92 
93  std::stringstream log ;
94  log << " Factory::getCurrentMarlinTrkSystem called without a preceeding call to createMarlinTrkSystem() ot getMarlinTrkSystem() " ;
95 
96  throw Exception( log.str() ) ;
97  }
98 
99  streamlog_out( DEBUG4 ) << " Factory::getCurrentMarlinTrkSystem() called - return allready initialized IMarlinTrkSystem " << std::endl ;
100 
101  return current ;
102  }
103  //-------------------------------------------------------------------------------------------------------------------
104 
106  static Factory _me ;
107  return &_me ;
108  }
109  //-------------------------------------------------------------------------------------------------------------------
110 
111 
112 
113 
114 
115 
116 
117 
118 }
Interface to KaltTest Kalman fitter - instantiates and holds the detector geometry.
Definition: MarlinAidaTT.h:43
Factory methods for creating the MarlinTrkSystem of a certain type: DDKalTest, aidaTT,... Currently implemented: DDKalTest, aidaTT.
Definition: Factory.h:28
TrkSystemMap _map
Definition: Factory.h:86
T endl(T...args)
T end(T...args)
STL class.
T str(T...args)
T make_pair(T...args)
T insert(T...args)
static IMarlinTrkSystem * getCurrentMarlinTrkSystem()
Return the current MarlinTrkSystem, i.e.
Definition: Factory.cc:87
T find(T...args)
IMarlinTrkSystem * _currentTrkSystem
Definition: Factory.h:84
Interface to KaltTest Kalman fitter - instantiates and holds the detector geometry.
Base class for tracking system implementations in MarlinTrk.
static IMarlinTrkSystem * getMarlinTrkSystem(const std::string &systemType)
Return the MarlinTrkSystem of the given type - only valid after a preceeding call to createMarlinTrkS...
Definition: Factory.cc:65
Exception thrown in IMarlinTrk namespace (implemetations of IMarlinTrkSystem and IMarlinTrack).
static IMarlinTrkSystem * createMarlinTrkSystem(const std::string &systemType, const gear::GearMgr *gearMgr, const std::string &options)
Create the MarlinTrkSystem instance of the specified type: DDKalTest, aidaTT,... Returns 0 if type ...
Definition: Factory.cc:14
static Factory * instance()
Definition: Factory.cc:105