File indexing completed on 2025-01-18 09:14:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include "DD4hep/Printout.h"
0024 #include "DD4hep/Factories.h"
0025 #include "DD4hep/Detector.h"
0026 #include "DD4hep/detail/ObjectsInterna.h"
0027 #include <fstream>
0028 #include <cerrno>
0029
0030 using namespace dd4hep;
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 static int multiply_constants (Detector& detector, int argc, char** argv) {
0044 bool help = false;
0045 std::string name = "TestConstantsMultiplier";
0046 for(int i=0; i<argc && argv[i]; ++i) {
0047 if ( 0 == ::strncmp("-name",argv[i],4) )
0048 name = argv[++i];
0049 else if ( 0 == ::strncmp("-help",argv[i],4) )
0050 help = true;
0051 else
0052 help = true;
0053 }
0054 if ( help ) {
0055
0056 std::cout <<
0057 "Usage: -plugin <name> -arg [-arg] \n"
0058 " name: factory name DD4hep_TestConstantsMultiplier \n"
0059 "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush;
0060 ::exit(EINVAL);
0061 }
0062 int num_test = 0;
0063 const auto& constants = detector.constants();
0064 for(const auto& e : constants) {
0065 Constant c = e.second;
0066 if ( c.dataType() == "number" ) {
0067 try {
0068 double res = _multiply(c.name(),1.0);
0069 printout(INFO,name,"+++ Constant: %-16s = %-16s [%s] -> %-16s = %9.3g",
0070 c.name(), c->GetTitle(), c.dataType().c_str(), c.name(), res);
0071 ++num_test;
0072 }
0073 catch(...) {
0074 }
0075 }
0076 }
0077 printout(ALWAYS,name,"+++ Tested %d numeric constants for expression evaluation.",num_test);
0078 return 1;
0079 }
0080 DECLARE_APPLY(DD4hep_TestConstantsMultiplier,multiply_constants)
0081
0082 static int print_line(Detector& , int, char** ) {
0083 printout(ALWAYS,"Line","+++ ------------------------------------------------------------------");
0084 return 1;
0085 }
0086 DECLARE_APPLY(DD4hep_TestPrintLine,print_line)