DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
convertToGear.cc
Go to the documentation of this file.
1 #include "DD4hep/LCDD.h"
2 #include "DD4hep/DD4hepUnits.h"
3 #include "DD4hep/Fields.h"
4 
5 #include "TGeoManager.h"
6 
7 //---- GEAR ----
8 #include "gear/GEAR.h"
9 #include "gearxml/GearXML.h"
10 
11 #include "gearimpl/Util.h"
12 #include "gearimpl/ConstantBField.h"
13 #include "gearimpl/GearMgrImpl.h"
14 
15 #include "geartgeo/TGeoGearPointProperties.h"
16 #include "geartgeo/TGeoGearDistanceProperties.h"
17 
18 #include "DDRec/DDGear.h"
19 
20 using namespace std ;
21 using namespace DD4hep ;
22 using namespace DD4hep::Geometry;
23 using namespace dd4hep ;
24 
25 //=============================================================================
26 
27 int main(int argc, char** argv ){
28 
29  if( argc < 3 ) {
30  std::cout << " usage: convertToGear plugin compact.xml [gear_file.xml]" << std::endl
31  << " plugin: name of a plugin with a signature \"long int (LCDD*, int, char**)\" \n "
32  << " e.g. GearForILD (same as 'default'), GearForCLIC, ..." << std::endl ;
33 
34  exit(1) ;
35  }
36 
37  std::string pluginName = argv[1] ;
38 
39  std::string inFile = argv[2] ;
40 
41  std::string outFile = ( argc>3 ? argv[3] : "" ) ;
42 
43  LCDD& lcdd = LCDD::getInstance();
44 
45  lcdd.fromCompact( inFile );
46 
47  gear::GearMgr* gearMgr = ( pluginName == "default" ) ? createGearMgr( lcdd ) : createGearMgr( lcdd , pluginName ) ;
48 
49  //----------------------------------------------------------------------------------
50 
51  // std::cout << " ***************************** GEAR parameters **************************************** " << std::endl ;
52  // std::cout << *gearMgr ;
53  // std::cout << " ************************* End of GEAR parameters ************************************* " << std::endl ;
54 
55  //----------------------------------------------------------------------------------
56 
57 
58  if( outFile.empty() ){
59 
60  outFile = "gear_" + gearMgr->getDetectorName() + ".xml" ;
61  }
62 
63  gear::GearXML::createXMLFile ( gearMgr, outFile ) ;
64 
65 
66  std::cout << " ************************************************************** " << std::endl ;
67  std::cout << " created gear file : " << outFile << std::endl ;
68  std::cout << " ************************************************************** " << std::endl ;
69 
70  return 0;
71 }
72 
73 //=============================================================================
int main(int argc, char **argv)
virtual void fromCompact(const std::string &fname, LCDDBuildType type=BUILD_DEFAULT)=0
Deprecated call (use fromXML): Read compact geometry description or alignment file.
The main interface to the DD4hep detector description package.
Definition: LCDD.h:82
gear::GearMgr * createGearMgr(Geometry::LCDD &lcdd, const std::string &pluginName)
Definition: DDGear.cpp:28