Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:47

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // ********************************************************************
0027 //
0028 //  CaTS (Calorimetry and Tracking Simulation)
0029 //
0030 //  Authors : Hans Wenzel
0031 //            Soon Yung Jun
0032 //            (Fermi National Accelerator Laboratory)
0033 //
0034 // History
0035 //   October 18th, 2021 : first implementation
0036 //
0037 // ********************************************************************
0038 //
0039 /// \file ConfigurationManager.cc
0040 /// \brief Implementation of the CaTS::ConfigurationManager class
0041 
0042 // Geant4 headers
0043 #include <G4ios.hh>
0044 #include "G4GenericMessenger.hh"
0045 // project headers
0046 #include "ConfigurationManager.hh"
0047 // c++ headers
0048 #include <ostream>
0049 #include <string>
0050 ConfigurationManager* ConfigurationManager::fginstance = nullptr;
0051 std::once_flag ConfigurationManager::fginitInstanceFlag;
0052 
0053 ConfigurationManager::ConfigurationManager() { DefineCommands(); }
0054 
0055 ConfigurationManager::~ConfigurationManager() { delete fMessenger; }
0056 
0057 void ConfigurationManager::Print()
0058 {
0059   G4cout << "--------------------------------------------------" << G4endl;
0060   G4cout << "CaTS configuration: " << G4endl;
0061   G4cout << "====================" << G4endl;
0062   G4cout << G4endl;
0063   G4cout << "fenable_verbose:   " << fenable_verbose << G4endl;
0064   G4cout << "fdumpgdml:         " << fdumpgdml << G4endl;
0065   G4cout << "fGDMLFileName:     " << fGDMLFileName << G4endl;
0066 #ifdef WITH_ROOT
0067   G4cout << "fdoAnalysis:       " << fdoAnalysis << G4endl;
0068   G4cout << "fHistoFileName:    " << fHistoFileName << G4endl;
0069   G4cout << "fwriteHits:        " << fwriteHits << G4endl;
0070   G4cout << "fname:            " << fname << G4endl;
0071 #endif
0072   G4cout << "fenable_opticks:   " << fenable_opticks << G4endl;
0073   G4cout << "fMaxPhotons:       " << fMaxPhotons << G4endl;
0074   G4cout << "--------------------------------------------------" << G4endl;
0075 }
0076 
0077 void ConfigurationManager::DefineCommands()
0078 {
0079   fMessenger = new G4GenericMessenger(this, "/CaTS/", "Configuring CaTS");
0080   //
0081   // Commands defining RootIO
0082 #ifdef WITH_ROOT
0083   auto& HistoFileNameCmd =
0084     fMessenger->DeclareProperty("HistoFileName", fHistoFileName);
0085   HistoFileNameCmd.SetGuidance("Filename for Analysis Histograms");
0086   HistoFileNameCmd.SetStates(G4State_PreInit, G4State_Init, G4State_Idle);
0087   HistoFileNameCmd.SetDefaultValue("histograms.root");
0088   auto& writeHitsCmd = fMessenger->DeclareProperty("writeHits", fwriteHits);
0089   writeHitsCmd.SetGuidance("Write out Hits collection");
0090   writeHitsCmd.SetStates(G4State_PreInit, G4State_Init, G4State_Idle);
0091   writeHitsCmd.SetDefaultValue("false");
0092   auto& doAnalysisCmd = fMessenger->DeclareProperty("doAnalysis", fdoAnalysis);
0093   doAnalysisCmd.SetGuidance("Do Analysis");
0094   doAnalysisCmd.SetStates(G4State_PreInit, G4State_Init, G4State_Idle);
0095   doAnalysisCmd.SetDefaultValue("false");
0096   auto& fnameCmd = fMessenger->DeclareProperty("fname", fname);
0097   fnameCmd.SetGuidance("set fname");
0098   fnameCmd.SetStates(G4State_PreInit);
0099   fnameCmd.SetDefaultValue("Hits");
0100 #endif
0101   //
0102   // Commands enabling G4Opticks and frequency calling it:
0103   //
0104   auto& enable_opticksCmd =
0105     fMessenger->DeclareProperty("enable_opticks", fenable_opticks);
0106   enable_opticksCmd.SetGuidance(
0107     "use opticks for generating and tracing of optical photons");
0108   enable_opticksCmd.SetDefaultValue("false");
0109   enable_opticksCmd.SetStates(G4State_PreInit, G4State_Init, G4State_Idle);
0110   auto& MaxPhotonsCmd = fMessenger->DeclareProperty("MaxPhotons", fMaxPhotons);
0111   MaxPhotonsCmd.SetGuidance(
0112     "set number of photons to be collecetd befores invoking G4Opticks");
0113   MaxPhotonsCmd.SetDefaultValue("1000000");
0114   MaxPhotonsCmd.SetStates(G4State_PreInit, G4State_Init, G4State_Idle);
0115   //
0116   // general command to control verbosity and writing out geometry to a gdml
0117   // file:
0118   //
0119   fMessenger->DeclareMethod("list", &ConfigurationManager::Print)
0120     .SetGuidance("Print all configuration parameters")
0121     .SetStates(G4State_PreInit, G4State_Init, G4State_Idle);
0122   auto& verboseCmd = fMessenger->DeclareProperty("verbose", fenable_verbose);
0123   verboseCmd.SetGuidance("Set flag for enabling verbose diagnostic printout");
0124   verboseCmd.SetDefaultValue("false");
0125   verboseCmd.SetStates(G4State_PreInit, G4State_Init, G4State_Idle);
0126   auto& GDMLFileNameCmd =
0127     fMessenger->DeclareProperty("GDMLFileName", fGDMLFileName);
0128   GDMLFileNameCmd.SetGuidance(
0129     "Set Filename to dump GDML representation of Geometry");
0130   GDMLFileNameCmd.SetStates(G4State_PreInit, G4State_Init, G4State_Idle);
0131   GDMLFileNameCmd.SetDefaultValue("dump.gdml_G4");
0132   auto& dumpgdmlCmd = fMessenger->DeclareProperty("dumpgdml", fdumpgdml);
0133   dumpgdmlCmd.SetGuidance(
0134     "Set flag for enabling dumping the Geometry to a gdml file");
0135   dumpgdmlCmd.SetStates(G4State_PreInit, G4State_Init, G4State_Idle);
0136   dumpgdmlCmd.SetDefaultValue("false");
0137 }