diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index f6cd2087f..371828a6a 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -18,10 +18,10 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : _description = "Cartesian segmentation in the local XY-plane"; // register all necessary parameters - registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit); - registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); - registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); - registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit); + registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); + registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); } @@ -35,10 +35,10 @@ CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) : _description = "Cartesian segmentation in the local XY-plane"; // register all necessary parameters - registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit); - registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); - registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); - registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit); + registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); + registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); } @@ -57,14 +57,16 @@ Vector3D CartesianGridXY::position(const CellID& cID) const { } /// determine the cell ID based on the position - CellID CartesianGridXY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - CellID cID = vID ; +CellID CartesianGridXY::cellID(const Vector3D& localPosition, + const Vector3D& /* globalPosition */, + const VolumeID& vID) const { + CellID cID = vID; _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) ); _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) ); - return cID ; + return cID; } -std::vector CartesianGridXY::cellDimensions(const CellID&) const { + std::vector CartesianGridXY::cellDimensions(const CellID& /* cellID */) const { #if __cplusplus >= 201103L return {_gridSizeX, _gridSizeY}; #else diff --git a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp index 69cf77236..504794d7e 100644 --- a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp +++ b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp @@ -11,8 +11,9 @@ namespace dd4hep { namespace DDSegmentation { /// default constructor using an encoding string -CartesianGridXYStaggered::CartesianGridXYStaggered(const std::string& cellEncoding) : - CartesianGrid(cellEncoding) { +CartesianGridXYStaggered::CartesianGridXYStaggered(const std::string& cellEncoding) + : CartesianGrid(cellEncoding) +{ // define type and description _type = "CartesianGridXYStaggered"; _description = "Cartesian segmentation in the local XY-plane, with options for staggering"; @@ -22,14 +23,14 @@ CartesianGridXYStaggered::CartesianGridXYStaggered(const std::string& cellEncodi registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); - registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, - SegmentationParameter::NoUnit, true); - registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, - SegmentationParameter::NoUnit, true); + registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", + _staggerX, 0, SegmentationParameter::NoUnit, true); + registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", + _staggerY, 0, SegmentationParameter::NoUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", - SegmentationParameter::NoUnit, true); + registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", + _staggerKeyword, (std::string)"layer", SegmentationParameter::NoUnit, true); } /// Default constructor used by derived classes passing an existing decoder @@ -45,14 +46,14 @@ CartesianGridXYStaggered::CartesianGridXYStaggered(const BitFieldCoder* decode) registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); - registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, - SegmentationParameter::NoUnit, true); - registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, - SegmentationParameter::NoUnit, true); + registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", + _staggerX, 0, SegmentationParameter::NoUnit, true); + registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", + _staggerY, 0, SegmentationParameter::NoUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", - SegmentationParameter::NoUnit, true); + registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", + _staggerKeyword, (std::string)"layer", SegmentationParameter::NoUnit, true); } /// destructor @@ -73,10 +74,12 @@ Vector3D CartesianGridXYStaggered::position(const CellID& cID) const { } return cellPosition; } - + /// determine the cell ID based on the position - CellID CartesianGridXYStaggered::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - CellID cID = vID ; +CellID CartesianGridXYStaggered::cellID(const Vector3D& localPosition, + const Vector3D& /* globalPosition */, + const VolumeID& vID) const { + CellID cID = vID ; if (_staggerX || _staggerY){ int layer= _decoder->get(cID,_staggerKeyword); _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); @@ -88,11 +91,9 @@ Vector3D CartesianGridXYStaggered::position(const CellID& cID) const { return cID ; } - -std::vector CartesianGridXYStaggered::cellDimensions(const CellID& cellID) const { +std::vector CartesianGridXYStaggered::cellDimensions(const CellID& /* cellID */) const { return {_gridSizeX, _gridSizeY}; } - } /* namespace DDSegmentation */ } /* namespace dd4hep */ diff --git a/UtilityApps/src/run_plugin.h b/UtilityApps/src/run_plugin.h index a0c2cf274..cd94a56f0 100644 --- a/UtilityApps/src/run_plugin.h +++ b/UtilityApps/src/run_plugin.h @@ -299,16 +299,15 @@ namespace dd4hep { return 0; } - void usage_plugin_runner() { - std::cout << - "geoPluginRun -opt [-opt] \n" + void usage_plugin_runner(const char* runner="geoPluginRun", bool exit_program=true) { + std::cout << runner << " -opt [-opt] \n" " -input [OPTIONAL] Specify geometry input file. \n" " -plugin [args] [-end-plugin] \n" " [REQUIRED] Plugin to be executed and applied. \n" " -plugin [args] -end-plugin \n" " [OPTIONAL] Next plugin with arguments. \n"; print_default_args() << std::endl; - ::exit(EINVAL); + if ( exit_program ) ::exit(EINVAL); } //______________________________________________________________________________ diff --git a/UtilityApps/src/teve_display.cpp b/UtilityApps/src/teve_display.cpp index 8030b5307..8e70d5025 100644 --- a/UtilityApps/src/teve_display.cpp +++ b/UtilityApps/src/teve_display.cpp @@ -64,24 +64,30 @@ void make_gui(); TEveStraightLineSet* getSurfaces(int col=kRed, const SurfaceType& type=SurfaceType(), TString name="Surfaces" ) ; TEveStraightLineSet* getSurfaceVectors(bool addO=true, bool addU= true, bool addV=true, bool addN=true,TString name="SurfaceVectors",int color=kGreen) ; +//===================================================================================== +static void print_teve_help() { + std::cout << + "Usage: teveDisplay -arg [-arg] \n\n" + " Invoke TEve display using the factory mechanism. \n\n" + " -input [OPTIONAL] Specify geometry input file. \n"; + print_default_args() << std::endl << + " -level Visualization level [TGeoManager::SetVisLevel] Default: 4 \n" + " -visopt Visualization option [TGeoManager::SetVisOption] Default: 0 \n" + " -help Print this help output" << std::endl << std::flush; + ::exit(EINVAL); +} + //===================================================================================== static long teve_display(Detector& description, int argc, char** argv) { int level = 4, visopt = 0, help = 0; - for( int i=0; i Visualization level [TGeoManager::SetVisLevel] Default: 4 \n" - " -visopt Visualization option [TGeoManager::SetVisOption] Default: 0 \n" - " -help Print this help output" << std::endl << std::flush; - ::exit(EINVAL); + print_teve_help(); } TGeoManager* mgr = &description.manager(); @@ -149,20 +155,27 @@ static long teve_display(Detector& description, int argc, char** argv) { } DECLARE_APPLY(DD4hepTEveDisplay,teve_display) - //===================================================================================================================== - int main(int argc,char** argv) { std::vector av; std::string level, visopt, opt; - bool help = false; - for( int i=0; i 2 ) av.emplace_back(argv[i]); + } + if ( !help && argc == 2 ) { // Single argument given --> geometry file + av.emplace_back("-input"); + av.emplace_back(argv[1]); } av.emplace_back("-interactive"); av.emplace_back("-plugin"); @@ -171,22 +184,22 @@ int main(int argc,char** argv) { if ( !opt.empty() ) av.emplace_back("-opt"), av.emplace_back(opt.c_str()); if ( !level.empty() ) av.emplace_back("-level"), av.emplace_back(level.c_str()); if ( !visopt.empty() ) av.emplace_back("-visopt"), av.emplace_back(visopt.c_str()); + if ( help ) { + print_teve_help(); + } return dd4hep::execute::main_plugins("DD4hepTEveDisplay", av.size(), (char**)&av[0]); } //===================================================================================================================== -TEveStraightLineSet* getSurfaceVectors(bool addO, bool addU, bool addV, bool addN, TString name,int color) { +TEveStraightLineSet* getSurfaceVectors(bool addO, bool addU, bool addV, bool addN, TString name,int color) { TEveStraightLineSet* ls = new TEveStraightLineSet(name); Detector& description = Detector::getInstance(); - DetElement world = description.world() ; + DetElement world = description.world(); // create a list of all surfaces in the detector: - SurfaceHelper surfMan( world ) ; - + SurfaceHelper surfMan( world ); const SurfaceList& sL = surfMan.surfaceList() ; - for( SurfaceList::const_iterator it = sL.begin() ; it != sL.end() ; ++it ){ - ISurface* surf = *it ; const Vector3D& u = surf->u() ; const Vector3D& v = surf->v() ;