Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:42

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 /* 
0014  Plugin invocation:
0015  ==================
0016  This plugin behaves like a main program.
0017  Invoke the plugin with something like this:
0018 
0019  geoPluginRun -destroy -plugin DD4hep_TestConstantsMultiplier -opt [-opt]
0020 
0021 */
0022 // Framework include files
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 /// Plugin function: Test in memory XML parsing of a simple sub detector
0033 /**
0034  *  Factory: DD4hep_XML-In-Memory
0035  *
0036  *  Though there is a file name given, it is read FIRST and then parsed.
0037  *  Similar to a in memory XML string.
0038  *
0039  *  \author  M.Frank
0040  *  \version 1.0
0041  *  \date    20/01/2018
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     /// Help printout describing the basic command line interface
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)