DD4hep  01.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
convertToGear.cc
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : F.Gaede
11 //
12 //==========================================================================
13 #include "DD4hep/Detector.h"
14 #include "DD4hep/DD4hepUnits.h"
15 #include "DD4hep/Fields.h"
16 
17 #include "TGeoManager.h"
18 
19 //---- GEAR ----
20 #include "gear/GEAR.h"
21 #include "gearxml/GearXML.h"
22 
23 #include "gearimpl/Util.h"
24 #include "gearimpl/ConstantBField.h"
25 #include "gearimpl/GearMgrImpl.h"
26 
27 #include "geartgeo/TGeoGearPointProperties.h"
28 #include "geartgeo/TGeoGearDistanceProperties.h"
29 
30 #include "DDRec/DDGear.h"
31 
32 using namespace std ;
33 using namespace dd4hep ;
34 using namespace dd4hep::detail;
35 using namespace dd4hep::rec ;
36 
37 //=============================================================================
38 
39 int main(int argc, char** argv ){
40 
41  if( argc < 3 ) {
42  std::cout << " usage: convertToGear plugin compact.xml [gear_file.xml]" << std::endl
43  << " plugin: name of a plugin with a signature \"long int (Detector*, int, char**)\" \n "
44  << " e.g. GearForILD (same as 'default'), GearForCLIC, ..." << std::endl ;
45 
46  exit(1) ;
47  }
48 
49  std::string pluginName = argv[1] ;
50 
51  std::string inFile = argv[2] ;
52 
53  std::string outFile = ( argc>3 ? argv[3] : "" ) ;
54 
55  Detector& description = Detector::getInstance();
56 
57  description.fromCompact( inFile );
58 
59  gear::GearMgr* gearMgr = ( pluginName == "default" ) ? createGearMgr( description ) : createGearMgr( description , pluginName ) ;
60 
61  //----------------------------------------------------------------------------------
62 
63  // std::cout << " ***************************** GEAR parameters **************************************** " << std::endl ;
64  // std::cout << *gearMgr ;
65  // std::cout << " ************************* End of GEAR parameters ************************************* " << std::endl ;
66 
67  //----------------------------------------------------------------------------------
68 
69 
70  if( outFile.empty() ){
71 
72  outFile = "gear_" + gearMgr->getDetectorName() + ".xml" ;
73  }
74 
75  gear::GearXML::createXMLFile ( gearMgr, outFile ) ;
76 
77 
78  std::cout << " ************************************************************** " << std::endl ;
79  std::cout << " created gear file : " << outFile << std::endl ;
80  std::cout << " ************************************************************** " << std::endl ;
81 
82  return 0;
83 }
84 
85 //=============================================================================
T empty(T...args)
T endl(T...args)
STL class.
T exit(T...args)
gear::GearMgr * createGearMgr(Detector &description, const std::string &pluginName="GearForILD")
Factory method that creates a GearMgr object pobulated with the GearParametersImpl objects from all (...
Definition: DDGear.cpp:39
int main(int argc, char **argv)