diff --git a/doc/cmake.cmds b/doc/cmake.cmds index a9eca22d4e2bb29600bb5e79108165ac1cde3e48..c80469a5ce9aace4b96730872f32176135af4946 100644 --- a/doc/cmake.cmds +++ b/doc/cmake.cmds @@ -1,10 +1,13 @@ # +# ++++ Build DD4hep (simplest) +# +cmake -DCMAKE_BUILD_TYPE=Debug -DDD4HEP_WITH_GEANT4=OFF -DDD4HEP_USE_PYROOT=OFF ../DD4hep +# # ++++ Build DD4hep with XERCES # cmake -DCMAKE_BUILD_TYPE=Debug \ --DDD4HEP_WITH_GEANT4=OFF \ +-DDD4HEP_WITH_GEANT4=OFF -DDD4HEP_USE_PYROOT=OFF \ -DDD4HEP_USE_XERCESC=ON -DXERCESC_ROOT_DIR=${XERCESCSYS} \ --DDD4HEP_USE_PYROOT=OFF \ ../DD4hep # # @@ -16,9 +19,17 @@ cmake -DCMAKE_BUILD_TYPE=Debug \ -DDD4HEP_USE_PYROOT=OFF \ ../DD4hep # +# +# ++++ Build DD4hep with GEANT4 (no Xerces) +# +cmake -DCMAKE_BUILD_TYPE=Debug \ +-DDD4HEP_WITH_GEANT4=ON -DGeant4_ROOT_DIR=${G4SYS} \ +-DCLHEP_ROOT_DIR=${CLHEPSYS} -DDD4HEP_USE_PYROOT=OFF \ +../DD4hep +# # ++++ Build Geant 4 # -cmake -DCMAKE_INSTALL_PREFIX=`pwd`/../geant4 \ +cmake -DCMAKE_INSTALL_PREFIX=`pwd`/../g4.9.5 \ -DCMAKE_BUILD_TYPE=Debug \ -DBUILD_SHARED_LIBS=ON \ -DGEANT4_INSTALL_DATA=ON \ diff --git a/doc/gdml_root.C b/doc/gdml_root.C index f1c0754ff50346d47e405cf490724eb6499b028f..3b4b63e2fa712acfb709f6bfb994015d88fdec33 100644 --- a/doc/gdml_root.C +++ b/doc/gdml_root.C @@ -1,10 +1,31 @@ +// $Id:$ +//==================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------- +// +// Standalone ROOT script to load geometries from DD4hep: +// +// Full GDML cycle can be tested (deplace <detector> with some meaningful identifier): +// a) Extract gdml information +// $ > geoConverter -compact2gdml -input file:<compact-input-xml-file> -output <detector>.gdml +// b) Extract visualisation hints to csv file +// $ > geoConverter -compact2vis -input file:<compact-input-xml-file> -output <detector>.vis.csv -ascii +// c) Load GDML into ROOT (as AClick, but can also be interpreted): +// $ > root.exe ../doc/gdml_root.C+\(\"<detector>\"\) +// The macro expects *at least* the <detector>.gdml file. If no visualisation +// information is found, the resulting graphics however is not very nice! +// +// +// Author : M.Frank +// +//==================================================================== +// C/C++ include files #include <fstream> -#include <cstring> #include <cerrno> #include <string> #include <sstream> -#include <map> +// ROOT include files #include <TGeoManager.h> #include <TColor.h> #include <TObjArray.h> @@ -14,23 +35,19 @@ using namespace std; TGeoVolume* gdml_root(const char* sys_name) { - bool debug_processing = false; + bool debug_processing = false; TGeoManager* geo = new TGeoManager(); - string system = sys_name; - string gdml_file = system+".gdml"; - string vis_file = system+".vis.csv"; - map<string,TGeoVolume*> vol_map; - ifstream in(vis_file.c_str()); - TGDMLParse parse; + string system = sys_name; + string gdml_file = system+".gdml"; + string vis_file = system+".vis.csv"; + ifstream in(vis_file.c_str()); + TGDMLParse parse; cout << "++ Processing gdml file:" << gdml_file << endl; TGeoVolume* top_vol = parse.GDMLReadFile(gdml_file.c_str()); TObjArray* vols = gGeoManager->GetListOfVolumes(); - for(int i=0;i<vols->GetEntries();++i) { - TGeoVolume* v=(TGeoVolume*)vols->At(i); - vol_map.insert(make_pair(v->GetName(),v)); - } + int num_volumes = vols->GetEntries(); if ( !in.good() ) cout << "++ Failed to open visualization file:" << vis_file @@ -40,12 +57,11 @@ TGeoVolume* gdml_root(const char* sys_name) { while(in.good() ) { stringstream debug; - char text[1024], *line; - const char* vol_name=""; - float red = 0, blue = 0, green = 0; - bool visible = false, show_daughters = false; - string line_style="solid", drawing_style="solid"; - map<string,TGeoVolume*>::iterator vit; + char text[1024], *line; + const char* vol_name=""; + float red = 0, blue = 0, green = 0; + bool visible = false, show_daughters = false; + string line_style="solid", drawing_style="solid"; in.getline(text,sizeof(text),'\n'); line = strtok(text,";"); @@ -94,36 +110,46 @@ TGeoVolume* gdml_root(const char* sys_name) { } if ( debug_processing ) cout << debug.str() << endl; debug.str(""); - if ( vol_name && ::strlen(vol_name) && (vit=vol_map.find(vol_name)) != vol_map.end() ) { - TGeoVolume* volume = (*vit).second; - int color = TColor::GetColor(red,green,blue); - Color_t bright = TColor::GetColorBright(color); - Color_t dark = TColor::GetColorDark(color); - debug << "+ \tr:" << red << " g:" << green << " b:" << blue << " col:" << color - << " line_style:" << line_style << " drawing_style:" << drawing_style - << " visible:" << visible << " show_daughters:" << show_daughters; - volume->SetLineColor(dark); - if ( drawing_style == "solid" ) { - volume->SetFillColor(bright); - volume->SetFillStyle(1001); // Root: solid + TGeoVolume* volume = 0; + + if ( vol_name && ::strlen(vol_name) ) { + for(int i=0;i<num_volumes;++i) { + TGeoVolume* v=(TGeoVolume*)vols->At(i); + if ( 0 == ::strcmp(vol_name,v->GetName()) ) { + volume = v; + break; + } + } + if ( volume ) { + int color = TColor::GetColor(red,green,blue); + Color_t bright = TColor::GetColorBright(color); + Color_t dark = TColor::GetColorDark(color); + debug << "+ \tr:" << red << " g:" << green << " b:" << blue << " col:" << color + << " line_style:" << line_style << " drawing_style:" << drawing_style + << " visible:" << visible << " show_daughters:" << show_daughters; + volume->SetLineColor(dark); + if ( drawing_style == "solid" ) { + volume->SetFillColor(bright); + volume->SetFillStyle(1001); // Root: solid + } + else { + //volume->SetFillColor(bright); + volume->SetFillColor(0); + volume->SetFillStyle(0); // Root: hollow + } + if ( line_style == "unbroken" ) + volume->SetFillStyle(1); + else + volume->SetFillStyle(2); + + volume->SetLineWidth(10); + volume->SetVisibility(visible ? kTRUE : kFALSE); + volume->SetAttBit(TGeoAtt::kVisContainers,kTRUE); + volume->SetVisDaughters(show_daughters ? kTRUE : kFALSE); } else { - //volume->SetFillColor(bright); - volume->SetFillColor(0); - volume->SetFillStyle(0); // Root: hollow + cout << endl << "++ Failed to find volume with name:" << vol_name; } - if ( line_style == "unbroken" ) - volume->SetFillStyle(1); - else - volume->SetFillStyle(2); - - volume->SetLineWidth(10); - volume->SetVisibility(visible ? kTRUE : kFALSE); - volume->SetAttBit(TGeoAtt::kVisContainers,kTRUE); - volume->SetVisDaughters(show_daughters ? kTRUE : kFALSE); - } - else { - cout << endl << "++ Failed to find volume with name:" << vol_name; } if ( debug_processing ) cout << debug.str() << endl; }