Commit in slic on MAIN | |||
slic.cc | +2 | -5 | 1.21 -> 1.22 |
include/CommandLineOption.hh | +90 | -103 | 1.1 -> 1.2 |
/CommandLineProcessor.hh | +152 | -161 | 1.8 -> 1.9 |
/CommandQueue.hh | +77 | -84 | 1.2 -> 1.3 |
/EventAction.hh | +27 | -29 | 1.10 -> 1.11 |
/EventDebugger.hh | +40 | -42 | 1.5 -> 1.6 |
/EventDebuggerMessenger.hh | +25 | -27 | 1.4 -> 1.5 |
/EventMessenger.hh | +20 | -22 | 1.6 -> 1.7 |
/EventSource.hh | +29 | -30 | 1.9 -> 1.10 |
/EventSourceManager.hh | +107 | -111 | 1.13 -> 1.14 |
/EventSourceWithInputFile.hh | +43 | -50 | 1.9 -> 1.10 |
/FieldManager.hh | +9 | -11 | 1.2 -> 1.3 |
/FieldMessenger.hh | +29 | -31 | 1.5 -> 1.6 |
/FileUtil.hh | +18 | -20 | 1.10 -> 1.11 |
/G4MagIntegratorStepperFactory.hh | +24 | -26 | 1.5 -> 1.6 |
/GPSEventSource.hh | +19 | -21 | 1.8 -> 1.9 |
/GeneratorMessenger.hh | +34 | -36 | 1.10 -> 1.11 |
/HepPDTManager.hh | +86 | -103 | 1.1 -> 1.2 |
/HitsCollectionUtil.hh | +16 | -18 | 1.8 -> 1.9 |
/LCDD.hh | +21 | -26 | 1.1 -> 1.2 |
/LCExtendedDecay.hh | +12 | -14 | 1.2 -> 1.3 |
/LCExtendedParticles.hh | +18 | -20 | 1.4 -> 1.5 |
/LCOpticalPhysics.hh | +23 | -32 | 1.2 -> 1.3 |
/LCSUSYDecay.hh | +12 | -14 | 1.1 -> 1.2 |
/LCSUSYPhysics.hh | +18 | -20 | 1.3 -> 1.4 |
/LcioEventSource.hh | +28 | -30 | 1.8 -> 1.9 |
/LcioFileNamer.hh | +27 | -28 | 1.9 -> 1.10 |
/LcioHitsCollectionBuilder.hh | +93 | -102 | 1.6 -> 1.7 |
/LcioManager.hh | +133 | -142 | 1.58 -> 1.59 |
/LcioMcpFactory.hh | +53 | -55 | 1.9 -> 1.10 |
/LcioMcpFilter.hh | +24 | -26 | 1.7 -> 1.8 |
/LcioMcpManager.hh | +94 | -98 | 1.55 -> 1.56 |
/LcioMcpMaps.hh | +56 | -58 | 1.6 -> 1.7 |
/LcioMcpMessenger.hh | +25 | -27 | 1.10 -> 1.11 |
/LcioMcpPrinter.hh | +74 | -76 | 1.18 -> 1.19 |
/LcioMcpStatusSetter.hh | +27 | -28 | 1.5 -> 1.6 |
/LcioMcpUtil.hh | +21 | -22 | 1.5 -> 1.6 |
/LcioMessenger.hh | +37 | -39 | 1.21 -> 1.22 |
/LcioPrimaryGenerator.hh | +27 | -29 | 1.16 -> 1.17 |
/LogManager.hh | +161 | -178 | 1.14 -> 1.15 |
/LogMessenger.hh | +22 | -24 | 1.10 -> 1.11 |
/LogStream.hh | +352 | -391 | 1.5 -> 1.6 |
/Module.hh | +101 | -101 | 1.11 -> 1.12 |
/ModuleRegistry.hh | +32 | -36 | 1.6 -> 1.7 |
/ParticleGunEventSource.hh | +20 | -22 | 1.7 -> 1.8 |
/PhysicsListBuilder.hh | +55 | -62 | 1.1 -> 1.2 |
/PhysicsListFactory.hh | +54 | -56 | 1.15 -> 1.16 |
/PhysicsListManager.hh | +52 | -60 | 1.21 -> 1.22 |
/PhysicsMessenger.hh | +29 | -31 | 1.12 -> 1.13 |
/PrimaryGeneratorAction.hh | +32 | -34 | 1.23 -> 1.24 |
/RunAction.hh | +24 | -26 | 1.12 -> 1.13 |
/RunManager.hh | +44 | -46 | 1.14 -> 1.15 |
/Singleton.hh | +23 | -26 | 1.3 -> 1.4 |
/SlicApplication.hh | +183 | -171 | 1.39 -> 1.40 |
/SlicApplicationMessenger.hh | +22 | -24 | 1.1 -> 1.2 |
/SlicMain.hh | +10 | -12 | 1.1 -> 1.2 |
/StdHepEventSource.hh | +26 | -28 | 1.9 -> 1.10 |
/StdHepLoader.hh | +46 | -49 | 1.16 -> 1.17 |
/StdHepToLcioConvertor.hh | +117 | -122 | 1.21 -> 1.22 |
/SteppingAction.hh | +12 | -14 | 1.13 -> 1.14 |
/TimeUtil.hh | +27 | -28 | 1.10 -> 1.11 |
/TrackingAction.hh | +18 | -20 | 1.8 -> 1.9 |
/Trajectory.hh | +185 | -212 | 1.17 -> 1.18 |
/TrajectoryManager.hh | +216 | -236 | 1.32 -> 1.33 |
/VRML2Writer.hh | +23 | -25 | 1.3 -> 1.4 |
/VRML2WriterMessenger.hh | +14 | -16 | 1.1 -> 1.2 |
src/CommandLineProcessor.cc | +421 | -541 | 1.13 -> 1.14 |
/CommandQueue.cc | +26 | -36 | 1.3 -> 1.4 |
/EventAction.cc | +73 | -82 | 1.30 -> 1.31 |
/EventDebugger.cc | +89 | -110 | 1.6 -> 1.7 |
/EventDebuggerMessenger.cc | +55 | -65 | 1.4 -> 1.5 |
/EventMessenger.cc | +29 | -34 | 1.4 -> 1.5 |
/EventSource.cc | +33 | -41 | 1.7 -> 1.8 |
/EventSourceManager.cc | +320 | -410 | 1.23 -> 1.24 |
/EventSourceWithInputFile.cc | +92 | -100 | 1.9 -> 1.10 |
/FieldManager.cc | +8 | -11 | 1.5 -> 1.6 |
/FieldMessenger.cc | +57 | -64 | 1.8 -> 1.9 |
/FileUtil.cc | +70 | -81 | 1.13 -> 1.14 |
/G4MagIntegratorStepperFactory.cc | +58 | -74 | 1.7 -> 1.8 |
/GPSEventSource.cc | +48 | -55 | 1.8 -> 1.9 |
/GeneratorMessenger.cc | +125 | -135 | 1.17 -> 1.18 |
/HitsCollectionUtil.cc | +55 | -65 | 1.4 -> 1.5 |
/LCExtendedParticles.cc | +67 | -80 | 1.7 -> 1.8 |
/LCOpticalPhysics.cc | +56 | -70 | 1.6 -> 1.7 |
/LCSUSYPhysics.cc | +60 | -71 | 1.6 -> 1.7 |
/LcioEventSource.cc | +84 | -101 | 1.8 -> 1.9 |
/LcioFileNamer.cc | +124 | -150 | 1.21 -> 1.22 |
/LcioHitsCollectionBuilder.cc | +351 | -424 | 1.24 -> 1.25 |
/LcioManager.cc | +404 | -420 | 1.89 -> 1.90 |
/LcioMcpFactory.cc | +475 | -531 | 1.22 -> 1.23 |
/LcioMcpFilter.cc | +143 | -149 | 1.5 -> 1.6 |
/LcioMcpManager.cc | +218 | -247 | 1.72 -> 1.73 |
/LcioMcpMaps.cc | +173 | -220 | 1.6 -> 1.7 |
/LcioMcpMessenger.cc | +68 | -71 | 1.12 -> 1.13 |
/LcioMcpPrinter.cc | +275 | -312 | 1.19 -> 1.20 |
/LcioMcpStatusSetter.cc | +89 | -102 | 1.5 -> 1.6 |
/LcioMcpUtil.cc | +27 | -32 | 1.2 -> 1.3 |
/LcioMessenger.cc | +139 | -142 | 1.36 -> 1.37 |
/LcioPrimaryGenerator.cc | +151 | -163 | 1.39 -> 1.40 |
/LogMessenger.cc | +35 | -37 | 1.11 -> 1.12 |
/Module.cc | +23 | -28 | 1.7 -> 1.8 |
/ModuleRegistry.cc | +57 | -69 | 1.6 -> 1.7 |
/ParticleGunEventSource.cc | +31 | -37 | 1.5 -> 1.6 |
/PhysicsListFactory.cc | +59 | -73 | 1.30 -> 1.31 |
/PhysicsListManager.cc | +104 | -133 | 1.27 -> 1.28 |
/PhysicsMessenger.cc | +82 | -91 | 1.25 -> 1.26 |
/PrimaryGeneratorAction.cc | +160 | -166 | 1.35 -> 1.36 |
/RunAction.cc | +50 | -57 | 1.21 -> 1.22 |
/RunManager.cc | +107 | -87 | 1.19 -> 1.20 |
/SlicApplication.cc | +195 | -239 | 1.56 -> 1.57 |
/SlicApplicationMessenger.cc | +39 | -46 | 1.1 -> 1.2 |
/SlicMain.cc | +48 | -49 | 1.5 -> 1.6 |
/StdHepEventSource.cc | +79 | -91 | 1.8 -> 1.9 |
/StdHepLoader.cc | +66 | -75 | 1.21 -> 1.22 |
/StdHepToLcioConvertor.cc | +327 | -383 | 1.42 -> 1.43 |
/SteppingAction.cc | +10 | -12 | 1.12 -> 1.13 |
/TimeUtil.cc | +24 | -28 | 1.9 -> 1.10 |
/TrackingAction.cc | +20 | -24 | 1.13 -> 1.14 |
/Trajectory.cc | +115 | -141 | 1.15 -> 1.16 |
/TrajectoryManager.cc | +569 | -618 | 1.51 -> 1.52 |
/VRML2Writer.cc | +190 | -212 | 1.6 -> 1.7 |
/VRML2WriterMessenger.cc | +26 | -28 | 1.1 -> 1.2 |
+10449 | -11779 |
improved error handling; source formatting of all files according to slightly modified K&R style
diff -u -r1.21 -r1.22 --- slic.cc 8 Jun 2010 00:45:11 -0000 1.21 +++ slic.cc 27 Nov 2012 19:32:17 -0000 1.22 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/slic.cc,v 1.21 2010/06/08 00:45:11 jeremy Exp $
+// $Header: /cvs/lcd/slic/slic.cc,v 1.22 2012/11/27 19:32:17 jeremy Exp $
/** @mainpage
@@ -13,12 +13,9 @@
// slic #include "SlicMain.hh"
-#include <iostream> -
using namespace slic;
-int main(int argc, char** argv) -{
+int main(int argc, char** argv) {
return (new SlicMain())->main(argc, argv); }
diff -u -r1.1 -r1.2 --- CommandLineOption.hh 30 Nov 2006 02:32:23 -0000 1.1 +++ CommandLineOption.hh 27 Nov 2012 19:32:17 -0000 1.2 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/CommandLineOption.hh,v 1.1 2006/11/30 02:32:23 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/CommandLineOption.hh,v 1.2 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_COMMANDLINEOPTION_HH #define SLIC_COMMANDLINEOPTION_HH
@@ -8,109 +8,96 @@
#include <vector> #include <string>
-namespace slic -{
+namespace slic {
- /** - * @author Jeremy McCormick <[log in to unmask]> - * - * @class CommandLineOption - * - * @brief Command-line option with a single letter, full name and description - * plus an associated Geant4 command (which is optional). - * - */ - class CommandLineOption - { - - public: - - /** - * The fully qualified constructor for CommandLineOption. - * (There are no setters for this class.) - */ - CommandLineOption(const std::string& shortname, - const std::string& longname, - const std::string& description, - unsigned int min_args=0, - unsigned int max_args=0, - const std::string& g4cmdstr="") - : m_shortname(shortname), - m_longname(longname), - m_description(description), - m_g4cmdstr(g4cmdstr), - m_minArgs(min_args), - m_maxArgs(max_args) - {;} - - virtual ~CommandLineOption() - {;} - - public: - - /** - * Get the short name associated with this option. - * This must be a single letter, such as 'm'. - */ - const std::string& getShortName() const - { - return m_shortname; - } - - /** - * Get the long name associated with this option. - * This must be one or more words separated by dashes, - * such as "lcio-path". - */ - const std::string& getLongName() const - { - return m_longname; - } - - /** - * Get a brief description of this option. - */ - const std::string& getDescription() const - { - return m_description; - } - - /** - * Get the Geant4 command associated with this option. - * This may be a null string if there is no associated - * Geant4 command, though currently all of SLIC's options - * have a corresponding Geant4 macro command. - */ - const std::string& getG4CommandString() const - { - return m_g4cmdstr; - } - - /** - * Get the minimum number of arguments to this option. - */ - unsigned int getMinArgs() const - { - return m_minArgs; - } - - /** - * Get the maximum number of arguments to this option. - */ - unsigned int getMaxArgs() const - { - return m_maxArgs; - } - - private: - - std::string m_shortname; - std::string m_longname; - std::string m_description; - std::string m_g4cmdstr; - int m_minArgs; - int m_maxArgs; - };
+/** + * @author Jeremy McCormick <[log in to unmask]> + * + * @class CommandLineOption + * + * @brief Command-line option with a single letter, full name and description + * plus an associated Geant4 command (which is optional). + * + */ +class CommandLineOption { + +public: + + /** + * The fully qualified constructor for CommandLineOption. + * (There are no setters for this class.) + */ + CommandLineOption(const std::string& shortname, const std::string& longname, + const std::string& description, unsigned int min_args = 0, unsigned int max_args = 0, + const std::string& g4cmdstr = "") : + m_shortname(shortname), m_longname(longname), m_description(description), m_g4cmdstr(g4cmdstr), m_minArgs( + min_args), m_maxArgs(max_args) { + ; + } + + virtual ~CommandLineOption() { + ; + } + +public: + + /** + * Get the short name associated with this option. + * This must be a single letter, such as 'm'. + */ + const std::string& getShortName() const { + return m_shortname; + } + + /** + * Get the long name associated with this option. + * This must be one or more words separated by dashes, + * such as "lcio-path". + */ + const std::string& getLongName() const { + return m_longname; + } + + /** + * Get a brief description of this option. + */ + const std::string& getDescription() const { + return m_description; + } + + /** + * Get the Geant4 command associated with this option. + * This may be a null string if there is no associated + * Geant4 command, though currently all of SLIC's options + * have a corresponding Geant4 macro command. + */ + const std::string& getG4CommandString() const { + return m_g4cmdstr; + } + + /** + * Get the minimum number of arguments to this option. + */ + unsigned int getMinArgs() const { + return m_minArgs; + } + + /** + * Get the maximum number of arguments to this option. + */ + unsigned int getMaxArgs() const { + return m_maxArgs; + } + +private: + + std::string m_shortname; + std::string m_longname; + std::string m_description; + std::string m_g4cmdstr; + int m_minArgs; + int m_maxArgs; +};
} #endif
diff -u -r1.8 -r1.9 --- CommandLineProcessor.hh 27 Jul 2009 22:20:41 -0000 1.8 +++ CommandLineProcessor.hh 27 Nov 2012 19:32:17 -0000 1.9 @@ -15,167 +15,158 @@
#include "PackageInfo.hh" #include "Singleton.hh"
-namespace slic -{ - /** - * @author Jeremy McCormick - * - * @brief Command line processor for SLIC using getopt. - * - * @note All options are mapped in a straightforward fashion - * to Geant4 macro commands that may be defined - * within LCDD, SLIC, or Geant4 itself. The result - * of processing the command line using this class is - * to fill the CommandQueue, which is then retrieved - * and executed by G4Application. - */ - class CommandLineProcessor : public Module, public Singleton<CommandLineProcessor> - { - - public: - - /** - * OptionsPair is a short option name and its associated arguments. - */ - typedef std::pair<std::string, std::string> OptionsPair; - - /** - * CommandLineArguments is the list of options and arguments from the command line. - */ - typedef std::vector<CommandLineProcessor::OptionsPair> CommandLineArguments; - - /** - * OptionsList is a list of CommandLineOption classes describing valid command line switches. - */ - typedef std::vector<CommandLineOption*> OptionsList; - - public: - virtual ~CommandLineProcessor(); - CommandLineProcessor(); - - public: - - /** - * This is the primary function to process the raw arguments. - * Options that will cause an abort, e.g. '-h', '-v', and '-n', - * are handled explicitly so that the correct flag is set. - * Other arguments are handled generically and put into the - * CommandLineArguments vector, which associates a short - * option name with its arguments (if any). Options that can - * occur more than once, such as the '-m' command, get one entry - * per occurrence in the CommandLineArguments. getopt will - * check that the option is valid and that enough arguments - * were received, before the command is put into CommandLineArguments. - * After calling process(), the getCommandQueue() function can - * be used to retrieve the list of Geant4 macro commands that - * resulted from processing the raw command line arguments. - */ - void process(int argc, char** argv); - - /** - * Print out the options table. - */ - void printOptions(); - - /** - * Print the version information. - */ - void printVersion() - { - log() << LOG::okay - << PackageInfo::getFullApplicationString() - << LOG::done; - log() << LOG::okay - << "Geant4 " - << Geant4VersionInfo::getFullVersion() - << LOG::done; - } - - /** - * Get the queue of Geant4 macro commands created from - * the command line arguments. - */ - CommandQueue* getCommandQueue() - { - return &m_g4q; - } - - /** - * Print the usage statement. - */ - void printUsage(); - - private: - - /** - * Process all the command line arguments in correct - * order to create the queue of Geant4 commands. - */ - void processOptions(); - - /** - * Abort the application before Geant4 starts, - * e.g. if usage or version are selected. - * This is not called if the command line arguments - * are invalid, as getopt will handle this and - * call exit() itself. - */ - inline void abort(); - - /** - * Process a command line switch by adding - * the corresponding Geant4 macro command to - * the CommandQueue. - */ - inline void processOption(const std::string&); - - /** - * Add a command line option describing a - * command line switch, its full name, - * description, geant4 command, etc. - */ - inline void addOption(CommandLineOption*); - - /** - * Find an option specification by its single letter designation (with no '-'). - */ - inline CommandLineOption* getCommandLineOption(const std::string& opt); - - /** - * Automatically create the getopt options string from OptionsList - * and set the m_getoptOptions variable to this value. - */ - inline void createOptionsString(); - - /** - * Register the list of valid command line options. - */ - inline void registerOptions(); - - /** - * Returns true if the option was found in the command line arguments. - */ - inline bool hasOption(const std::string& opt); - - private: - - // A vector of options with their arguments. - CommandLineArguments m_commandline; - - // A list of Geant4 macro commands filled by processing the command line arguments. - CommandQueue m_g4q; - - // The list of valid options and their associated meta-data. - OptionsList m_cmds; - - // Flags to be set by the process function. - int m_help_flag; - int m_interactive_flag; - int m_version_flag; - - // The getopt options string, which is created automatically. - std::string m_getoptOptions; - };
+namespace slic { +/** + * @author Jeremy McCormick + * + * @brief Command line processor for SLIC using getopt. + * + * @note All options are mapped in a straightforward fashion + * to Geant4 macro commands that may be defined + * within LCDD, SLIC, or Geant4 itself. The result + * of processing the command line using this class is + * to fill the CommandQueue, which is then retrieved + * and executed by G4Application. + */ +class CommandLineProcessor: public Module, public Singleton<CommandLineProcessor> { + +public: + + /** + * OptionsPair is a short option name and its associated arguments. + */ + typedef std::pair<std::string, std::string> OptionsPair; + + /** + * CommandLineArguments is the list of options and arguments from the command line. + */ + typedef std::vector<CommandLineProcessor::OptionsPair> CommandLineArguments; + + /** + * OptionsList is a list of CommandLineOption classes describing valid command line switches. + */ + typedef std::vector<CommandLineOption*> OptionsList; + +public: + virtual ~CommandLineProcessor(); + CommandLineProcessor(); + +public: + + /** + * This is the primary function to process the raw arguments. + * Options that will cause an abort, e.g. '-h', '-v', and '-n', + * are handled explicitly so that the correct flag is set. + * Other arguments are handled generically and put into the + * CommandLineArguments vector, which associates a short + * option name with its arguments (if any). Options that can + * occur more than once, such as the '-m' command, get one entry + * per occurrence in the CommandLineArguments. getopt will + * check that the option is valid and that enough arguments + * were received, before the command is put into CommandLineArguments. + * After calling process(), the getCommandQueue() function can + * be used to retrieve the list of Geant4 macro commands that + * resulted from processing the raw command line arguments. + */ + void process(int argc, char** argv); + + /** + * Print out the options table. + */ + void printOptions(); + + /** + * Print the version information. + */ + void printVersion() { + log() << LOG::okay << PackageInfo::getFullApplicationString() << LOG::done; + log() << LOG::okay << "Geant4 " << Geant4VersionInfo::getFullVersion() << LOG::done; + } + + /** + * Get the queue of Geant4 macro commands created from + * the command line arguments. + */ + CommandQueue* getCommandQueue() { + return &m_g4q; + } + + /** + * Print the usage statement. + */ + void printUsage(); + +private: + + /** + * Process all the command line arguments in correct + * order to create the queue of Geant4 commands. + */ + void processOptions(); + + /** + * Abort the application before Geant4 starts, + * e.g. if usage or version are selected. + * This is not called if the command line arguments + * are invalid, as getopt will handle this and + * call exit() itself. + */ + inline void abort(); + + /** + * Process a command line switch by adding + * the corresponding Geant4 macro command to + * the CommandQueue. + */ + inline void processOption(const std::string&); + + /** + * Add a command line option describing a + * command line switch, its full name, + * description, geant4 command, etc. + */ + inline void addOption(CommandLineOption*); + + /** + * Find an option specification by its single letter designation (with no '-'). + */ + inline CommandLineOption* getCommandLineOption(const std::string& opt); + + /** + * Automatically create the getopt options string from OptionsList + * and set the m_getoptOptions variable to this value. + */ + inline void createOptionsString(); + + /** + * Register the list of valid command line options. + */ + inline void registerOptions(); + + /** + * Returns true if the option was found in the command line arguments. + */ + inline bool hasOption(const std::string& opt); + +private: + + // A vector of options with their arguments. + CommandLineArguments m_commandline; + + // A list of Geant4 macro commands filled by processing the command line arguments. + CommandQueue m_g4q; + + // The list of valid options and their associated meta-data. + OptionsList m_cmds; + + // Flags to be set by the process function. + int m_help_flag; + int m_interactive_flag; + int m_version_flag; + + // The getopt options string, which is created automatically. + std::string m_getoptOptions; +};
} #endif
diff -u -r1.2 -r1.3 --- CommandQueue.hh 27 Apr 2007 01:54:32 -0000 1.2 +++ CommandQueue.hh 27 Nov 2012 19:32:17 -0000 1.3 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/CommandQueue.hh,v 1.2 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/CommandQueue.hh,v 1.3 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_COMMANDQUEUE_HH #define SLIC_COMMANDQUEUE_HH
@@ -9,89 +9,82 @@
#include <vector> #include <string>
-namespace slic -{ - /** - * @class CommandQueue - * @brief A queue of G4 commands to be executed in order. - * @note Created by CommandLineProcessor from the command line arguments. - */ - class CommandQueue : public Module - { - public: - - typedef std::vector<std::string> CmdVecType; - typedef std::string CmdType; - typedef size_t SizeType; - - public: - - CommandQueue() - : Module( "CommandQueue" ) - {} - - virtual ~CommandQueue() - {} - - /** - * Add a command to the queue. - */ - void add(const CmdType& g4cmd) - { - m_commands.push_back( g4cmd ); - } - - /** - * Add a command using char* type. - */ - void add(const char* g4cmd) - { - std::string cmdStr = g4cmd; - add(std::string(cmdStr)); - } - - /** - * Get the begin iterator of the queue. - */ - CmdVecType::iterator cmdsBegin() - { - return m_commands.begin(); - } - - /** - * Get the end iterator of the queue. - */ - CmdVecType::iterator cmdsEnd() - { - return m_commands.end(); - } - - /** - * Print the queue to the log. - */ - void printOut(); - - /** - * Execute the commands in the queue sequentially. - */ - void execute(); - - /** - * Clear all the commands in the queue. - */ - void clear() - { - m_commands.clear(); - } - - /** - * Find the first command that matches a string. - */ - CmdVecType::iterator find(const std::string& str); - - private: - CmdVecType m_commands; - };
+namespace slic { +/** + * @class CommandQueue + * @brief A queue of G4 commands to be executed in order. + * @note Created by CommandLineProcessor from the command line arguments. + */ +class CommandQueue: public Module { +public: + + typedef std::vector<std::string> CmdVecType; + typedef std::string CmdType; + typedef size_t SizeType; + +public: + + CommandQueue() : + Module("CommandQueue") { + } + + virtual ~CommandQueue() { + } + + /** + * Add a command to the queue. + */ + void add(const CmdType& g4cmd) { + m_commands.push_back(g4cmd); + } + + /** + * Add a command using char* type. + */ + void add(const char* g4cmd) { + std::string cmdStr = g4cmd; + add(std::string(cmdStr)); + } + + /** + * Get the begin iterator of the queue. + */ + CmdVecType::iterator cmdsBegin() { + return m_commands.begin(); + } + + /** + * Get the end iterator of the queue. + */ + CmdVecType::iterator cmdsEnd() { + return m_commands.end(); + } + + /** + * Print the queue to the log. + */ + void printOut(); + + /** + * Execute the commands in the queue sequentially. + */ + void execute(); + + /** + * Clear all the commands in the queue. + */ + void clear() { + m_commands.clear(); + } + + /** + * Find the first command that matches a string. + */ + CmdVecType::iterator find(const std::string& str); + +private: + CmdVecType m_commands; +};
} #endif
diff -u -r1.10 -r1.11 --- EventAction.hh 27 Apr 2007 01:54:32 -0000 1.10 +++ EventAction.hh 27 Nov 2012 19:32:17 -0000 1.11 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/EventAction.hh,v 1.10 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/EventAction.hh,v 1.11 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_EVENTACTION_HH #define SLIC_EVENTACTION_HH 1
@@ -16,44 +16,42 @@
class G4UImessenger;
-namespace slic -{
+namespace slic {
- /** - * @class EventAction. - * @brief Implementation of G4UserEventAction. - * @note Calls actions of TrajectoryManager and LcioManager. - */ - class EventAction : public G4UserEventAction, public Module - { - public: - EventAction(); - ~EventAction();
+/** + * @class EventAction. + * @brief Implementation of G4UserEventAction. + * @note Calls actions of TrajectoryManager and LcioManager. + */ +class EventAction: public G4UserEventAction, public Module { +public: + EventAction(); + ~EventAction();
- public:
+public:
- // virtuals from G4 - virtual void BeginOfEventAction (const G4Event *anEvent); - virtual void EndOfEventAction (const G4Event *anEvent);
+ // virtuals from G4 + virtual void BeginOfEventAction(const G4Event *anEvent); + virtual void EndOfEventAction(const G4Event *anEvent);
- static EventAction* getEventAction();
+ static EventAction* getEventAction();
- // event timing - void enableEventTimer(bool et = true); - void startEventTimer(); - void stopEventTimer();
+ // event timing + void enableEventTimer(bool et = true); + void startEventTimer(); + void stopEventTimer();
- private:
+private:
- void printEndEventMessage(const G4Event *anEvent);
+ void printEndEventMessage(const G4Event *anEvent);
- private:
+private:
- bool m_enableEventTimer; - mutable G4Timer m_eventTimer;
+ bool m_enableEventTimer; + mutable G4Timer m_eventTimer;
- G4UImessenger* m_messenger; - };
+ G4UImessenger* m_messenger; +};
} #endif
diff -u -r1.5 -r1.6 --- EventDebugger.hh 5 Sep 2006 23:21:42 -0000 1.5 +++ EventDebugger.hh 27 Nov 2012 19:32:17 -0000 1.6 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/EventDebugger.hh,v 1.5 2006/09/05 23:21:42 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/EventDebugger.hh,v 1.6 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_EVENTDEBUGGER_HH #define SLIC_EVENTDEBUGGER_HH 1
@@ -17,64 +17,62 @@
class G4Run; class G4Event;
-namespace slic -{ - class EventDebuggerMessenger;
+namespace slic { +class EventDebuggerMessenger;
- /** - * @class EventDebugger - * @brief Manages debugging of individual G4Events. - */ - class EventDebugger : public Module, public Singleton<EventDebugger> - { - public:
+/** + * @class EventDebugger + * @brief Manages debugging of individual G4Events. + */ +class EventDebugger: public Module, public Singleton<EventDebugger> { +public:
- typedef std::vector<G4int> DebugEventList;
+ typedef std::vector<G4int> DebugEventList;
- public: - virtual ~EventDebugger(); - //static EventDebugger* instance();
+public: + virtual ~EventDebugger(); + //static EventDebugger* instance();
- //protected: - EventDebugger();
+ //protected: + EventDebugger();
- public:
+public:
- void enableDebug(bool e = true);
+ void enableDebug(bool e = true);
- void addDebugEvent(G4int eventNum); - void clearDebugEvents(); - bool haveDebugEvent(G4int) const;
+ void addDebugEvent(G4int eventNum); + void clearDebugEvents(); + bool haveDebugEvent(G4int) const;
- void setDebugMacro(std::string); - void setCleanupMacro(std::string);
+ void setDebugMacro(std::string); + void setCleanupMacro(std::string);
- void beginRun(const G4Run*); - void beginEvent(const G4Event*); - void endEvent(const G4Event*);
+ void beginRun(const G4Run*); + void beginEvent(const G4Event*); + void endEvent(const G4Event*);
- private:
+private:
- void sortDebugEvents();
+ void sortDebugEvents();
- void execDebugMacro(); - void execCleanupMacro();
+ void execDebugMacro(); + void execCleanupMacro();
- private:
+private:
- //static EventDebugger* m_instance;
+ //static EventDebugger* m_instance;
- EventDebuggerMessenger* m_messenger;
+ EventDebuggerMessenger* m_messenger;
- std::string m_debugMacro; - std::string m_cleanupMacro;
+ std::string m_debugMacro; + std::string m_cleanupMacro;
- DebugEventList m_events; - bool m_debugging; - bool m_haveDebugMacro; - bool m_haveCleanupMacro; - bool m_forceDebugMode; - };
+ DebugEventList m_events; + bool m_debugging; + bool m_haveDebugMacro; + bool m_haveCleanupMacro; + bool m_forceDebugMode; +};
} #endif
diff -u -r1.4 -r1.5 --- EventDebuggerMessenger.hh 5 Sep 2006 23:21:42 -0000 1.4 +++ EventDebuggerMessenger.hh 27 Nov 2012 19:32:17 -0000 1.5 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/EventDebuggerMessenger.hh,v 1.4 2006/09/05 23:21:42 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/EventDebuggerMessenger.hh,v 1.5 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_EVENTDEBUGGERMESSENGER_HH #define SLIC_EVENTDEBUGGERMESSENGER_HH 1
@@ -11,32 +11,30 @@
class G4UIcmdWithAString; class G4UIcmdWithABool;
-namespace slic -{ - /** - * @class EventDebuggerMessenger - * @brief G4UImessenger for the EventDebugger - */ - class EventDebuggerMessenger : public G4UImessenger - { - public: - EventDebuggerMessenger(); - virtual ~EventDebuggerMessenger(); - - public: - virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); - - private: - void defineCommands(); - - private: - G4UIdirectory* m_debugDir; - G4UIcmdWithAString* m_debugMacroCmd; - G4UIcmdWithAString* m_cleanupMacroCmd; - G4UIcommand* m_clearDebugEventsCmd; - G4UIcmdWithABool* m_enableDebugCmd; - G4UIcommand* m_addDebugEventsCmd; - };
+namespace slic { +/** + * @class EventDebuggerMessenger + * @brief G4UImessenger for the EventDebugger + */ +class EventDebuggerMessenger: public G4UImessenger { +public: + EventDebuggerMessenger(); + virtual ~EventDebuggerMessenger(); + +public: + virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); + +private: + void defineCommands(); + +private: + G4UIdirectory* m_debugDir; + G4UIcmdWithAString* m_debugMacroCmd; + G4UIcmdWithAString* m_cleanupMacroCmd; + G4UIcommand* m_clearDebugEventsCmd; + G4UIcmdWithABool* m_enableDebugCmd; + G4UIcommand* m_addDebugEventsCmd; +};
} #endif
diff -u -r1.6 -r1.7 --- EventMessenger.hh 5 Sep 2006 23:21:42 -0000 1.6 +++ EventMessenger.hh 27 Nov 2012 19:32:17 -0000 1.7 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/EventMessenger.hh,v 1.6 2006/09/05 23:21:42 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/EventMessenger.hh,v 1.7 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_EVENTMESSENGER_HH #define SLIC_EVENTMESSENGER_HH 1
@@ -8,27 +8,25 @@
class G4UIcmdWithABool;
-namespace slic -{ - /** - * @class EventMessenger - * @brief Messenger for event-related commands. - */ - class EventMessenger : public G4UImessenger - { - public: - EventMessenger(); - virtual ~EventMessenger(); - - public: - virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); - - private: - void defineCommands(); - - private: - G4UIcmdWithABool* m_eventTimerCmd; - };
+namespace slic { +/** + * @class EventMessenger + * @brief Messenger for event-related commands. + */ +class EventMessenger: public G4UImessenger { +public: + EventMessenger(); + virtual ~EventMessenger(); + +public: + virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); + +private: + void defineCommands(); + +private: + G4UIcmdWithABool* m_eventTimerCmd; +};
} #endif
diff -u -r1.9 -r1.10 --- EventSource.hh 27 Apr 2007 01:54:32 -0000 1.9 +++ EventSource.hh 27 Nov 2012 19:32:17 -0000 1.10 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/EventSource.hh,v 1.9 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/EventSource.hh,v 1.10 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_EVENTSOURCE_HH #define SLIC_EVENTSOURCE_HH 1
@@ -12,38 +12,37 @@
class G4Event; class G4Run;
-namespace slic -{ - /** - * @class EventSource - * @brief The base class for a physics event source such as a StdHep file source. - */ - class EventSource : public Module - { - - public: - - virtual ~EventSource(); - - protected: - EventSource( const std::string& name ); - - public: - - virtual void generate( G4Event* evt ) = 0; - virtual void dumpCurrentEvent() = 0; - virtual void reset(); - virtual unsigned int skipEvents( unsigned int ); - virtual void beginEvent( const G4Event* ); - virtual void endEvent( const G4Event* ); - virtual void beginRun( const G4Run* ); - virtual void endRun( const G4Run* );
+namespace slic { +/** + * @class EventSource + * @brief The base class for a physics event source such as a StdHep file source. + */ +class EventSource: public Module {
- private:
+public:
- std::string m_name;
+ virtual ~EventSource();
- };
+protected: + EventSource(const std::string& name); + +public: + + virtual void generate(G4Event* evt) = 0; + virtual void dumpCurrentEvent() = 0; + virtual void reset(); + virtual unsigned int skipEvents(unsigned int); + virtual void beginEvent(const G4Event*); + virtual void endEvent(const G4Event*); + virtual void beginRun(const G4Run*); + virtual void endRun(const G4Run*); + +private: + + std::string m_name; + int nEventsGenerated; + +};
} #endif
diff -u -r1.13 -r1.14 --- EventSourceManager.hh 4 Jul 2012 01:01:47 -0000 1.13 +++ EventSourceManager.hh 27 Nov 2012 19:32:17 -0000 1.14 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/EventSourceManager.hh,v 1.13 2012/07/04 01:01:47 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/EventSourceManager.hh,v 1.14 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_EVENTSOURCEMANAGER_HH #define SLIC_EVENTSOURCEMANAGER_HH 1
@@ -18,116 +18,112 @@
#include "G4ParticleGun.hh" #include "G4UnitsTable.hh"
-namespace slic -{ - /** - * @class EventSourceManager - * @brief This singleton is responsible for managing physics event sources. - */ - class EventSourceManager : public Module, public Singleton<EventSourceManager> - { - public: - enum ESourceType { - eUnknown = 0, - eStdHep = 1, - eLCIO, - eGPS, - eParticleGun - }; - public: - virtual ~EventSourceManager(); - EventSourceManager(); - - public: - void setSourceType(ESourceType est); - void setSourceType(const std::string& s); - ESourceType getCurrentSourceType(); - ESourceType getSourceTypeFromFileExtension(const std::string& s); - const std::string& getCurrentSourceName(); - const std::string& getSourceNameFromType( ESourceType egt ) const; - ESourceType getSourceTypeFromName( const std::string& s ) const; - const std::string& getFilename(); - void setFilename(const std::string& f); - void setupEventSource(); - void resetCurrentEventSource(); - void setSkipEvents(unsigned int s); - unsigned int getSkipEvents(); - void dumpCurrentEvent(); - void printNumEventsGenerated(); - int getNumEventsGenerated(); - void incrNumEventsGenerated(); - void generate(G4Event* evt); - void setEventSource(EventSource* es); - void deleteCurrentEventSource(); - EventSource* createEventSource(ESourceType st); - EventSource* getCurrentSource(); - void setupEventSource(ESourceType st); - void setupEventSource(const std::string& s); - void beginEvent(const G4Event*); - void endEvent(const G4Event*); - void beginRun(const G4Run*); - void endRun(const G4Run*); - bool isEOF(); - bool isNewSource(); - bool isNewSource(ESourceType est); - bool isNewFilename(); - bool isFileSource(); - EventSourceWithInputFile* getFileSource(); - G4GeneralParticleSource* getGPS(); - G4ParticleGun* getParticleGun(); - double getLorentzTransformationAngle() { return m_lorentzTransformationAngle; } - void setLorentzTransformationAngle( const G4double lorentzTransformationAngle ); - void setZSmearing(const G4double zSmearingParam) { - m_zSmearingParam = zSmearingParam; - G4cout << "Set m_zSmearingParam = " << m_zSmearingParam << G4endl; - } - G4double getZSmearing() { - return m_zSmearingParam; - } - public: - virtual void GeneratePrimaryVertex(G4Event* evt); - - private: - - // generator messenger - GeneratorMessenger* m_messenger; - - // current event source - EventSource* m_currentEventSource; - - // ParticleGun source. Always enabled. - EventSource* m_particleGunSource; - - // filename - std::string m_filename; - bool m_fileIsSet; - bool m_newFilename; - - // num events generated on current generator - int m_ngen; - - // num events to skip - unsigned int m_nskip; - - // need to setup a new source new run? - bool m_newSource; - - // gen strings - static std::string m_stdhepStr; - static std::string m_lcioStr; - static std::string m_gpsStr; - static std::string m_gunStr; - static std::string m_unknownStr; - - // source type - ESourceType m_sourceType; - - // Lorentz transformation angle which will be applied to event. - G4double m_lorentzTransformationAngle; - - // Parameter which will be used to smear vertex Z position. - G4double m_zSmearingParam; - };
+namespace slic { +/** + * @class EventSourceManager + * @brief This singleton is responsible for managing physics event sources. + */ +class EventSourceManager: public Module, public Singleton<EventSourceManager> { +public: + enum ESourceType { + eUnknown = 0, eStdHep = 1, eLCIO, eGPS, eParticleGun + }; +public: + virtual ~EventSourceManager(); + EventSourceManager(); + +public: + void setSourceType(ESourceType est); + void setSourceType(const std::string& s); + ESourceType getCurrentSourceType(); + ESourceType getSourceTypeFromFileExtension(const std::string& s); + const std::string& getCurrentSourceName(); + const std::string& getSourceNameFromType(ESourceType egt) const; + ESourceType getSourceTypeFromName(const std::string& s) const; + const std::string& getFilename(); + void setFilename(const std::string& f); + void setupEventSource(); + void resetCurrentEventSource(); + void setSkipEvents(unsigned int s); + unsigned int getSkipEvents(); + void dumpCurrentEvent(); + void printNumEventsGenerated(); + int getNumEventsGenerated(); + void incrNumEventsGenerated(); + void generate(G4Event* evt); + void setEventSource(EventSource* es); + void deleteCurrentEventSource(); + EventSource* createEventSource(ESourceType st); + EventSource* getCurrentSource(); + void setupEventSource(ESourceType st); + void setupEventSource(const std::string& s); + void beginEvent(const G4Event*); + void endEvent(const G4Event*); + void beginRun(const G4Run*); + void endRun(const G4Run*); + bool isEOF(); + bool isNewSource(); + bool isNewSource(ESourceType est); + bool isNewFilename(); + bool isFileSource(); + EventSourceWithInputFile* getFileSource(); + G4GeneralParticleSource* getGPS(); + G4ParticleGun* getParticleGun(); + double getLorentzTransformationAngle() { + return m_lorentzTransformationAngle; + } + void setLorentzTransformationAngle(const G4double lorentzTransformationAngle); + void setZSmearing(const G4double zSmearingParam) { + m_zSmearingParam = zSmearingParam; + G4cout << "Set m_zSmearingParam = " << m_zSmearingParam << G4endl; + } + G4double getZSmearing() { + return m_zSmearingParam; + } +public: + virtual void GeneratePrimaryVertex(G4Event* evt); + +private: + + // generator messenger + GeneratorMessenger* m_messenger; + + // current event source + EventSource* m_currentEventSource; + + // ParticleGun source. Always enabled. + EventSource* m_particleGunSource; + + // filename + std::string m_filename; + bool m_fileIsSet; + bool m_newFilename; + + // num events generated on current generator + int m_ngen; + + // num events to skip + unsigned int m_nskip; + + // need to setup a new source new run? + bool m_newSource; + + // gen strings + static std::string m_stdhepStr; + static std::string m_lcioStr; + static std::string m_gpsStr; + static std::string m_gunStr; + static std::string m_unknownStr; + + // source type + ESourceType m_sourceType; + + // Lorentz transformation angle which will be applied to event. + G4double m_lorentzTransformationAngle; + + // Parameter which will be used to smear vertex Z position. + G4double m_zSmearingParam; +};
} #endif
diff -u -r1.9 -r1.10 --- EventSourceWithInputFile.hh 27 Apr 2007 01:54:32 -0000 1.9 +++ EventSourceWithInputFile.hh 27 Nov 2012 19:32:17 -0000 1.10 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/EventSourceWithInputFile.hh,v 1.9 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/EventSourceWithInputFile.hh,v 1.10 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_EVENTSOURCEWITHINPUTFILE_HH #define SLIC_EVENTSOURCEWITHINPUTFILE_HH 1
@@ -8,73 +8,66 @@
#include "FileUtil.hh" #include "Module.hh"
-namespace slic -{ - /** - * @class EventSourceWithInputFile - * @brief A physics event source with an associated input file, such as StdHep or LCIO. - */ - class EventSourceWithInputFile : public EventSource - {
+namespace slic { +/** + * @class EventSourceWithInputFile + * @brief A physics event source with an associated input file, such as StdHep or LCIO. + */ +class EventSourceWithInputFile: public EventSource {
- protected:
+protected:
- EventSourceWithInputFile( const std::string& name, - const std::string& filename = "" ) - : EventSource( name ), - m_filename(filename), - m_eof(false), - m_fileIsOpen(false), - m_fileIsNew(false), - m_fileIsSet(false) - {}
+ EventSourceWithInputFile(const std::string& name, const std::string& filename = "") : + EventSource(name), m_filename(filename), m_eof(false), m_fileIsOpen(false), m_fileIsNew(false), m_fileIsSet( + false) { + }
- public: - virtual ~EventSourceWithInputFile() - {}
+public: + virtual ~EventSourceWithInputFile() { + }
- public:
+public:
- void setFilename(const std::string& s);
+ void setFilename(const std::string& s);
- const std::string& getFilename();
+ const std::string& getFilename();
- // reset current source - virtual void reset();
+ // reset current source + virtual void reset();
- // skip n events - virtual unsigned int skipEvents(unsigned int nevents);
+ // skip n events + virtual unsigned int skipEvents(unsigned int nevents);
- // current status = EOF? - virtual bool isEOF();
+ // current status = EOF? + virtual bool isEOF();
- virtual void beginEvent(const G4Event*);
+ virtual void beginEvent(const G4Event*);
- virtual void beginRun(const G4Run*);
+ virtual void beginRun(const G4Run*);
- // Next 4 to be implemented by subclasses...
+ // Next 4 to be implemented by subclasses...
- // open the current file - virtual void open() = 0;
+ // open the current file + virtual void open() = 0;
- // close the current file - virtual void close() = 0;
+ // close the current file + virtual void close() = 0;
- // read the next event - virtual void readNextEvent() = 0; - virtual void dumpCurrentEvent() = 0;
+ // read the next event + virtual void readNextEvent() = 0; + virtual void dumpCurrentEvent() = 0;
- protected:
+protected:
- // name of input file - std::string m_filename;
+ // name of input file + std::string m_filename;
- // state vars - bool m_eof; - bool m_fileIsOpen; - bool m_fileIsNew; - bool m_fileIsSet; - };
+ // state vars + bool m_eof; + bool m_fileIsOpen; + bool m_fileIsNew; + bool m_fileIsSet; +};
} #endif
diff -u -r1.2 -r1.3 --- FieldManager.hh 14 Nov 2006 01:14:37 -0000 1.2 +++ FieldManager.hh 27 Nov 2012 19:32:17 -0000 1.3 @@ -1,4 +1,4 @@
-// $Id: FieldManager.hh,v 1.2 2006/11/14 01:14:37 jeremy Exp $
+// $Id: FieldManager.hh,v 1.3 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_FIELDMANAGER_HH #define SLIC_FIELDMANAGER_HH 1
@@ -7,20 +7,18 @@
#include "FieldMessenger.hh" #include "Singleton.hh"
-namespace slic -{ - class FieldManager : public Module, public Singleton<FieldManager> - {
+namespace slic { +class FieldManager: public Module, public Singleton<FieldManager> {
- public: - FieldManager();
+public: + FieldManager();
- virtual ~FieldManager();
+ virtual ~FieldManager();
- private:
+private:
- FieldMessenger* m_messenger; - };
+ FieldMessenger* m_messenger; +};
} #endif
diff -u -r1.5 -r1.6 --- FieldMessenger.hh 27 Apr 2007 01:54:32 -0000 1.5 +++ FieldMessenger.hh 27 Nov 2012 19:32:17 -0000 1.6 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/FieldMessenger.hh,v 1.5 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/FieldMessenger.hh,v 1.6 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_FIELDMESSENGER_HH #define SLIC_FIELDMESSENGER_HH 1
@@ -10,36 +10,34 @@
class G4UIcommand; class G4UIdirectory;
-namespace slic -{ - class FieldManager; - - /** - * @class FieldMessenger - * @brief G4UImessenger to G4FieldManager (and related). - */ - class FieldMessenger : public G4UImessenger - { - public: - FieldMessenger( FieldManager* mgr); - virtual ~FieldMessenger(); - - public: - virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); - - private: - void defineCommands(); - - private: - - FieldManager* m_mgr; - - G4UIdirectory* m_fieldDir; - - G4UIcommand* m_selectStepperCmd; - G4UIcmdWithADoubleAndUnit* m_setDeltaOneStepCmd; - G4UIcmdWithADoubleAndUnit* m_setDeltaIntersectionCmd; - };
+namespace slic { +class FieldManager; + +/** + * @class FieldMessenger + * @brief G4UImessenger to G4FieldManager (and related). + */ +class FieldMessenger: public G4UImessenger { +public: + FieldMessenger(FieldManager* mgr); + virtual ~FieldMessenger(); + +public: + virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); + +private: + void defineCommands(); + +private: + + FieldManager* m_mgr; + + G4UIdirectory* m_fieldDir; + + G4UIcommand* m_selectStepperCmd; + G4UIcmdWithADoubleAndUnit* m_setDeltaOneStepCmd; + G4UIcmdWithADoubleAndUnit* m_setDeltaIntersectionCmd; +};
} #endif
diff -u -r1.10 -r1.11 --- FileUtil.hh 5 Sep 2006 23:21:42 -0000 1.10 +++ FileUtil.hh 27 Nov 2012 19:32:17 -0000 1.11 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/FileUtil.hh,v 1.10 2006/09/05 23:21:42 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/FileUtil.hh,v 1.11 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_FILEUTIL_HH #define SLIC_FILEUTIL_HH 1
@@ -6,26 +6,24 @@
// std #include <string>
-namespace slic -{
+namespace slic {
- /** - @class FileUtil - @brief Utilities for file manipulation using std. - */ - class FileUtil - { - public: - static int removeFile(const char* filename); - static int removeFile(const std::string& filename); - - static bool fileExists(const char* filename); - static bool fileExists(const std::string& filename); - - static std::string basename(std::string fn); - static std::string extension(std::string fn); - static std::string removeExtension(std::string ext); - };
+/** + @class FileUtil + @brief Utilities for file manipulation using std. + */ +class FileUtil { +public: + static int removeFile(const char* filename); + static int removeFile(const std::string& filename); + + static bool fileExists(const char* filename); + static bool fileExists(const std::string& filename); + + static std::string basename(std::string fn); + static std::string extension(std::string fn); + static std::string removeExtension(std::string ext); +};
} #endif
diff -u -r1.5 -r1.6 --- G4MagIntegratorStepperFactory.hh 27 Apr 2007 01:54:32 -0000 1.5 +++ G4MagIntegratorStepperFactory.hh 27 Nov 2012 19:32:17 -0000 1.6 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/G4MagIntegratorStepperFactory.hh,v 1.5 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/G4MagIntegratorStepperFactory.hh,v 1.6 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_G4MAGINTEGRATORSTEPPERFACTORY_HH #define SLIC_G4MAGINTEGRATORSTEPPERFACTORY_HH 1
@@ -15,31 +15,29 @@
class G4FieldManager; class G4MagneticField;
-namespace slic -{ - /** - * @class G4MagIntegratorStepperFactory - * @brief Instantiates and sets the G4MagIntegratorStepper based on name. - */ - class G4MagIntegratorStepperFactory : public Singleton<G4MagIntegratorStepperFactory>, public Module - { - public: - - virtual ~G4MagIntegratorStepperFactory(); - - G4MagIntegratorStepperFactory(); - - public: - void setupG4MagIntegratorStepper(std::string name); - - private: - G4MagIntegratorStepper* createG4MagIntegratorStepper(std::string name); - - private: - G4Mag_EqRhs* m_fieldEquations; - G4FieldManager* m_fieldMgr; - G4MagneticField* m_field; - };
+namespace slic { +/** + * @class G4MagIntegratorStepperFactory + * @brief Instantiates and sets the G4MagIntegratorStepper based on name. + */ +class G4MagIntegratorStepperFactory: public Singleton<G4MagIntegratorStepperFactory>, public Module { +public: + + virtual ~G4MagIntegratorStepperFactory(); + + G4MagIntegratorStepperFactory(); + +public: + void setupG4MagIntegratorStepper(std::string name); + +private: + G4MagIntegratorStepper* createG4MagIntegratorStepper(std::string name); + +private: + G4Mag_EqRhs* m_fieldEquations; + G4FieldManager* m_fieldMgr; + G4MagneticField* m_field; +};
} #endif
diff -u -r1.8 -r1.9 --- GPSEventSource.hh 27 Apr 2007 01:54:32 -0000 1.8 +++ GPSEventSource.hh 27 Nov 2012 19:32:17 -0000 1.9 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/GPSEventSource.hh,v 1.8 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/GPSEventSource.hh,v 1.9 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_GPSEVENTSOURCE_HH #define SLIC_GPSEVENTSOURCE_HH 1
@@ -9,33 +9,31 @@
// geant4 #include "G4GeneralParticleSource.hh"
-namespace slic -{ - /** - * @class GPSEventSource - * @brief Wrapper for Geant4's general particle source. - */ - class GPSEventSource : public EventSource - { - public: - GPSEventSource(); - virtual ~GPSEventSource();
+namespace slic { +/** + * @class GPSEventSource + * @brief Wrapper for Geant4's general particle source. + */ +class GPSEventSource: public EventSource { +public: + GPSEventSource(); + virtual ~GPSEventSource();
- public: - virtual void generate(G4Event* evt);
+public: + virtual void generate(G4Event* evt);
- virtual void dumpCurrentEvent();
+ virtual void dumpCurrentEvent();
- /** Set default GPS event in ctor. */ - void setupGeneratorDefaults();
+ /** Set default GPS event in ctor. */ + void setupGeneratorDefaults();
- G4GeneralParticleSource* getGPS();
+ G4GeneralParticleSource* getGPS();
- private:
+private:
- G4GeneralParticleSource* m_generator;
+ G4GeneralParticleSource* m_generator;
- };
+};
} #endif
diff -u -r1.10 -r1.11 --- GeneratorMessenger.hh 4 Jul 2012 01:01:47 -0000 1.10 +++ GeneratorMessenger.hh 27 Nov 2012 19:32:17 -0000 1.11 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/GeneratorMessenger.hh,v 1.10 2012/07/04 01:01:47 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/GeneratorMessenger.hh,v 1.11 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_GENERATORMESSENGER_HH #define SLIC_GENERATORMESSENGER_HH 1
@@ -12,41 +12,39 @@
class G4UIcmdWithADouble; class G4UIcmdWithADoubleAndUnit;
-namespace slic -{ - /** - * @class GeneratorMessenger - * @brief Geant4 commands related to event generation. - */ - class GeneratorMessenger : public G4UImessenger - { - - public: - - GeneratorMessenger(); - virtual ~GeneratorMessenger(); - - public: - - virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); - - private: - - void defineCommands(); - - private: - - G4UIdirectory* m_generatorDir; - G4UIcommand* m_randomSeedCmd; - G4UIcommand* m_selectCmd; - G4UIcommand* m_resetCmd; - G4UIcmdWithAnInteger* m_skipEventsCmd; - G4UIcommand* m_filenameCmd; - G4UIcommand* m_dumpCurrentEventCmd; - G4UIcommand* m_printNumEventsGeneratedCmd; - G4UIcmdWithADoubleAndUnit* m_setLorentzTransformationAngleCmd; - G4UIcmdWithADouble* m_setZSmearingParameterCmd; - };
+namespace slic { +/** + * @class GeneratorMessenger + * @brief Geant4 commands related to event generation. + */ +class GeneratorMessenger: public G4UImessenger { + +public: + + GeneratorMessenger(); + virtual ~GeneratorMessenger(); + +public: + + virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); + +private: + + void defineCommands(); + +private: + + G4UIdirectory* m_generatorDir; + G4UIcommand* m_randomSeedCmd; + G4UIcommand* m_selectCmd; + G4UIcommand* m_resetCmd; + G4UIcmdWithAnInteger* m_skipEventsCmd; + G4UIcommand* m_filenameCmd; + G4UIcommand* m_dumpCurrentEventCmd; + G4UIcommand* m_printNumEventsGeneratedCmd; + G4UIcmdWithADoubleAndUnit* m_setLorentzTransformationAngleCmd; + G4UIcmdWithADouble* m_setZSmearingParameterCmd; +};
} #endif
diff -u -r1.1 -r1.2 --- HepPDTManager.hh 11 Apr 2008 03:20:19 -0000 1.1 +++ HepPDTManager.hh 27 Nov 2012 19:32:17 -0000 1.2 @@ -14,115 +14,98 @@
using HepPDT::TableBuilder;
-namespace slic -{ - class HepPDTManager : public Module, public Singleton<HepPDTManager> - { - public: - - HepPDTManager() - : Module("HepPDTManager"), - m_datacol( 0 ), - m_fileSet( false ) - { - //loadParticleData(); - log().setOutputLevel( LOG::debug ); - } - - ~HepPDTManager() - { - delete m_datacol; - } - - public: - - HepPDT::ParticleDataTable* getParticleDataTable() - { - if ( m_datacol == 0 ) { - loadParticleData(); - } - return m_datacol; - } - - void setParticleDataFile( std::string pdfile ) - { - m_pdfile = pdfile; - m_fileSet = true; - } - - private: - - void loadParticleData() - { - // See if we can get the data file from the environment if it wasn't setup via CL or G4 macro. - if ( !m_fileSet ) - { - char *heppdt = getenv( "HEPPDT_BASE" ); - if ( heppdt ) - { - m_pdfile = std::string( heppdt ) + std::string( "/data/particle.tbl" ); - } - else - { - log() << LOG::error << "Could not find particle.tbl!" << LOG::done; - return; - } - } - - std::ifstream pdfile( m_pdfile.c_str() ); - if( !pdfile ) {
+namespace slic { +class HepPDTManager: public Module, public Singleton<HepPDTManager> { +public: + + HepPDTManager() : + Module("HepPDTManager"), m_datacol(0), m_fileSet(false) { + //loadParticleData(); + log().setOutputLevel(LOG::debug); + } + + ~HepPDTManager() { + delete m_datacol; + } + +public: + + HepPDT::ParticleDataTable* getParticleDataTable() { + if (m_datacol == 0) { + loadParticleData(); + } + return m_datacol; + } + + void setParticleDataFile(std::string pdfile) { + m_pdfile = pdfile; + m_fileSet = true; + } + +private: + + void loadParticleData() { + // See if we can get the data file from the environment if it wasn't setup via CL or G4 macro. + if (!m_fileSet) { + char *heppdt = getenv("HEPPDT_BASE"); + if (heppdt) { + m_pdfile = std::string(heppdt) + std::string("/data/particle.tbl"); + } else { + log() << LOG::error << "Could not find particle.tbl!" << LOG::done; + return; + } + } + + std::ifstream pdfile(m_pdfile.c_str()); + if (!pdfile) {
#ifdef SLIC_LOG
- log() << LOG::error << "error reading file " << m_pdfile << LOG::done;
+ log() << LOG::error << "error reading file " << m_pdfile << LOG::done;
#endif
- return; - }
+ return; + }
- m_datacol = new HepPDT::ParticleDataTable( "Particle Data Table" ); - HepPDT::TableBuilder *tb = new HepPDT::TableBuilder( (*m_datacol) ); - if( !addParticleTable( pdfile, (*tb) ) ) - {
+ m_datacol = new HepPDT::ParticleDataTable("Particle Data Table"); + HepPDT::TableBuilder *tb = new HepPDT::TableBuilder((*m_datacol)); + if (!addParticleTable(pdfile, (*tb))) {
#ifdef SLIC_LOG
- log() << LOG::error << "error reading lines from " << m_pdfile << LOG::done;
+ log() << LOG::error << "error reading lines from " << m_pdfile << LOG::done;
#endif
- } - - delete tb; tb = 0; - pdfile.close();
+ }
- // DEBUG - //printParticleData(); - } - - void printParticleData() - { - log() << LOG::always << "-- HepPDT Particle Data Table --" << LOG::endl; - log() << "ParticleDataTable has " << m_datacol->size() << " particles" << LOG::endl; - - for ( HepPDT::ParticleDataTable::const_iterator it = m_datacol->begin(); - it != m_datacol->end(); - it++ ) - { - HepPDT::ParticleID id = it->first; - HepPDT::ParticleData pdata = it->second; - - log() << LOG::always << id.pid() << " " << id.PDTname(); - - if ( id.isSUSY() ) - { - log() << " <-- SUSY particle"; - } - - log() << LOG::endl; - } - - log() << LOG::done; - } - - private: - HepPDT::ParticleDataTable* m_datacol; - std::string m_pdfile; - bool m_fileSet; - };
+ delete tb; + tb = 0; + pdfile.close(); + + // DEBUG + //printParticleData(); + } + + void printParticleData() { + log() << LOG::always << "-- HepPDT Particle Data Table --" << LOG::endl; + log() << "ParticleDataTable has " << m_datacol->size() << " particles" << LOG::endl; + + for (HepPDT::ParticleDataTable::const_iterator it = m_datacol->begin(); it != m_datacol->end(); + it++) { + HepPDT::ParticleID id = it->first; + HepPDT::ParticleData pdata = it->second; + + log() << LOG::always << id.pid() << " " << id.PDTname(); + + if (id.isSUSY()) { + log() << " <-- SUSY particle"; + } + + log() << LOG::endl; + } + + log() << LOG::done; + } + +private: + HepPDT::ParticleDataTable* m_datacol; + std::string m_pdfile; + bool m_fileSet; +};
} #endif
diff -u -r1.8 -r1.9 --- HitsCollectionUtil.hh 12 Dec 2007 03:19:13 -0000 1.8 +++ HitsCollectionUtil.hh 27 Nov 2012 19:32:17 -0000 1.9 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/HitsCollectionUtil.hh,v 1.8 2007/12/12 03:19:13 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/HitsCollectionUtil.hh,v 1.9 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_HITSCOLLECTIONUTIL_HH #define SLIC_HITSCOLLECTIONUTIL_HH 1
@@ -9,23 +9,21 @@
class G4SensitiveDetector;
-namespace slic -{ - /** - * @class HitsCollectionUtil - * @brief Static utility methods for Hits Collections. - */ - class HitsCollectionUtil - { - private: - HitsCollectionUtil(); - - public: - - static std::vector<G4SensitiveDetector*> getSensitiveDetectors(); - static std::vector<int> getHCIDs(); - static std::vector<std::string> getHCNames(); - };
+namespace slic { +/** + * @class HitsCollectionUtil + * @brief Static utility methods for Hits Collections. + */ +class HitsCollectionUtil { +private: + HitsCollectionUtil(); + +public: + + static std::vector<G4SensitiveDetector*> getSensitiveDetectors(); + static std::vector<int> getHCIDs(); + static std::vector<std::string> getHCNames(); +};
} #endif
diff -u -r1.1 -r1.2 --- LCDD.hh 27 Apr 2007 01:54:32 -0000 1.1 +++ LCDD.hh 27 Nov 2012 19:32:17 -0000 1.2 @@ -1,4 +1,4 @@
-// $Id: LCDD.hh,v 1.1 2007/04/27 01:54:32 jeremy Exp $
+// $Id: LCDD.hh,v 1.2 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_LCDD_HH #define SLIC_LCDD_HH 1
@@ -6,31 +6,26 @@
#include "LCDDDetectorConstruction.hh"
-namespace slic -{ - /** - * The LCDDDetectorConstruction wrapped via a Module. - */ - class LCDD : public Module - { - - public: - - LCDD() - : Module("LCDD"), - m_det(0) - { - m_det = new LCDDDetectorConstruction(); - } - - LCDDDetectorConstruction* getDetectorConstruction() - { - return m_det; - } - - private: - LCDDDetectorConstruction* m_det; - };
+namespace slic { +/** + * The LCDDDetectorConstruction wrapped via a Module. + */ +class LCDD: public Module { + +public: + + LCDD() : + Module("LCDD"), m_det(0) { + m_det = new LCDDDetectorConstruction(); + } + + LCDDDetectorConstruction* getDetectorConstruction() { + return m_det; + } + +private: + LCDDDetectorConstruction* m_det; +};
} #endif
diff -u -r1.2 -r1.3 --- LCExtendedDecay.hh 6 Aug 2009 20:03:25 -0000 1.2 +++ LCExtendedDecay.hh 27 Nov 2012 19:32:17 -0000 1.3 @@ -3,20 +3,18 @@
#include "G4UnknownDecay.hh"
-namespace slic -{ - class LCExtendedDecay : public G4UnknownDecay - { - public: - LCExtendedDecay() - : G4UnknownDecay( "LCExtendedDecay" ) - {;} - - G4bool IsApplicable( const G4ParticleDefinition &pdef ) - { - return ( pdef.GetParticleType() == "extended" ); - } - };
+namespace slic { +class LCExtendedDecay: public G4UnknownDecay { +public: + LCExtendedDecay() : + G4UnknownDecay("LCExtendedDecay") { + ; + } + + G4bool IsApplicable(const G4ParticleDefinition &pdef) { + return (pdef.GetParticleType() == "extended"); + } +};
} #endif
diff -u -r1.4 -r1.5 --- LCExtendedParticles.hh 16 Dec 2009 00:11:47 -0000 1.4 +++ LCExtendedParticles.hh 27 Nov 2012 19:32:17 -0000 1.5 @@ -10,26 +10,24 @@
#include "G4hIonisation.hh" #include "G4hMultipleScattering.hh"
-namespace slic -{ - class LCExtendedParticles : public G4VPhysicsConstructor - { - public: - - LCExtendedParticles( const G4String& name = "LCExtendedParticles" ); - - virtual ~LCExtendedParticles(); - - void ConstructParticle(); - - void ConstructProcess(); - - private: - - G4Decay m_decay; - G4hIonisation m_ionise; - G4hMultipleScattering m_scatter; - };
+namespace slic { +class LCExtendedParticles: public G4VPhysicsConstructor { +public: + + LCExtendedParticles(const G4String& name = "LCExtendedParticles"); + + virtual ~LCExtendedParticles(); + + void ConstructParticle(); + + void ConstructProcess(); + +private: + + G4Decay m_decay; + G4hIonisation m_ionise; + G4hMultipleScattering m_scatter; +};
} #endif
diff -u -r1.2 -r1.3 --- LCOpticalPhysics.hh 17 Dec 2007 21:11:59 -0000 1.2 +++ LCOpticalPhysics.hh 27 Nov 2012 19:32:17 -0000 1.3 @@ -19,40 +19,31 @@
#include "G4OpBoundaryProcess.hh" #include "G4ProcessManager.hh"
-class LCOpticalPhysics : public G4VPhysicsConstructor -{ - public: - - LCOpticalPhysics(const G4String& name = "optical"); - - virtual ~LCOpticalPhysics(); - - // This method will be invoked in the Construct() method. - // each particle type will be instantiated - virtual void ConstructParticle(); - - // This method will be invoked in the Construct() method. - // each physics process will be instantiated and - // registered to the process manager of each particle type - virtual void ConstructProcess(); - //these methods Construct physics processes and register them - void ConstructOp(); - - protected: - G4Cerenkov* theCerenkovProcess; - G4Scintillation* theScintillationProcess; - G4OpAbsorption* theAbsorptionProcess; - G4OpRayleigh* theRayleighScatteringProcess; - G4OpBoundaryProcess* theBoundaryProcess; -}; - - -#endif - - -
+class LCOpticalPhysics: public G4VPhysicsConstructor { +public:
+ LCOpticalPhysics(const G4String& name = "optical");
+ virtual ~LCOpticalPhysics();
+ // This method will be invoked in the Construct() method. + // each particle type will be instantiated + virtual void ConstructParticle(); + + // This method will be invoked in the Construct() method. + // each physics process will be instantiated and + // registered to the process manager of each particle type + virtual void ConstructProcess(); + //these methods Construct physics processes and register them + void ConstructOp(); + +protected: + G4Cerenkov* theCerenkovProcess; + G4Scintillation* theScintillationProcess; + G4OpAbsorption* theAbsorptionProcess; + G4OpRayleigh* theRayleighScatteringProcess; + G4OpBoundaryProcess* theBoundaryProcess; +};
+#endif
diff -u -r1.1 -r1.2 --- LCSUSYDecay.hh 11 Apr 2008 03:20:19 -0000 1.1 +++ LCSUSYDecay.hh 27 Nov 2012 19:32:17 -0000 1.2 @@ -3,20 +3,18 @@
#include "G4UnknownDecay.hh"
-namespace slic -{ - class LCSUSYDecay : public G4UnknownDecay - { - public: - LCSUSYDecay() - : G4UnknownDecay( "LCSUSYDecay" ) - {;} - - G4bool IsApplicable(const G4ParticleDefinition &pdef) - { - return ( pdef.GetParticleType() == "susy" ); - } - };
+namespace slic { +class LCSUSYDecay: public G4UnknownDecay { +public: + LCSUSYDecay() : + G4UnknownDecay("LCSUSYDecay") { + ; + } + + G4bool IsApplicable(const G4ParticleDefinition &pdef) { + return (pdef.GetParticleType() == "susy"); + } +};
} #endif
diff -u -r1.3 -r1.4 --- LCSUSYPhysics.hh 16 Dec 2009 00:11:47 -0000 1.3 +++ LCSUSYPhysics.hh 27 Nov 2012 19:32:17 -0000 1.4 @@ -11,26 +11,24 @@
#include "G4hIonisation.hh" #include "G4hMultipleScattering.hh"
-namespace slic -{ - class LCSUSYPhysics : public G4VPhysicsConstructor - { - public: - - LCSUSYPhysics( const G4String& name = "LCSUSYPhysics" ); - - virtual ~LCSUSYPhysics(); - - void ConstructParticle(); - - void ConstructProcess(); - - private: - - G4hMultipleScattering m_scatter; - LCSUSYDecay m_decay; - G4hIonisation m_ionise; - };
+namespace slic { +class LCSUSYPhysics: public G4VPhysicsConstructor { +public: + + LCSUSYPhysics(const G4String& name = "LCSUSYPhysics"); + + virtual ~LCSUSYPhysics(); + + void ConstructParticle(); + + void ConstructProcess(); + +private: + + G4hMultipleScattering m_scatter; + LCSUSYDecay m_decay; + G4hIonisation m_ionise; +};
} #endif
diff -u -r1.8 -r1.9 --- LcioEventSource.hh 27 Apr 2007 01:54:32 -0000 1.8 +++ LcioEventSource.hh 27 Nov 2012 19:32:17 -0000 1.9 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioEventSource.hh,v 1.8 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioEventSource.hh,v 1.9 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_LCIOEVENTSOURCE_HH #define SLIC_LCIOEVENTSOURCE_HH 1
@@ -16,47 +16,45 @@
#include "IOIMPL/LCFactory.h" #include "IO/LCReader.h"
-namespace slic -{ - /** - * @class LcioEventSource - * @brief Event generation from the MCParticle collection of an LCIO file. - */ - class LcioEventSource : public EventSourceWithInputFile - { - public: - LcioEventSource(const std::string& fname = "");
+namespace slic { +/** + * @class LcioEventSource + * @brief Event generation from the MCParticle collection of an LCIO file. + */ +class LcioEventSource: public EventSourceWithInputFile { +public: + LcioEventSource(const std::string& fname = "");
- virtual ~LcioEventSource();
+ virtual ~LcioEventSource();
- public:
+public:
- // open the current file - virtual void open();
+ // open the current file + virtual void open();
- // close the current file - virtual void close();
+ // close the current file + virtual void close();
- // read the next event - virtual void readNextEvent();
+ // read the next event + virtual void readNextEvent();
- virtual void dumpCurrentEvent();
+ virtual void dumpCurrentEvent();
- void generate(G4Event* anEvent);
+ void generate(G4Event* anEvent);
- virtual void beginRun(const G4Run* aRun);
+ virtual void beginRun(const G4Run* aRun);
- virtual void beginEvent(const G4Event* anEvent);
+ virtual void beginEvent(const G4Event* anEvent);
- //virtual void endEvent(const G4Event*);
+ //virtual void endEvent(const G4Event*);
- EVENT::LCCollection* getCurrentMcpLCCollection();
+ EVENT::LCCollection* getCurrentMcpLCCollection();
- private: - LcioMcpFilter* m_filter; - IO::LCReader* m_reader; - EVENT::LCEvent* m_event; - };
+private: + LcioMcpFilter* m_filter; + IO::LCReader* m_reader; + EVENT::LCEvent* m_event; +};
} #endif
diff -u -r1.9 -r1.10 --- LcioFileNamer.hh 24 Sep 2007 21:00:02 -0000 1.9 +++ LcioFileNamer.hh 27 Nov 2012 19:32:17 -0000 1.10 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioFileNamer.hh,v 1.9 2007/09/24 21:00:02 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioFileNamer.hh,v 1.10 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_LCIOFILENAMER_HH #define SLIC_LCIOFILENAMER_HH 1
@@ -13,44 +13,43 @@
#include <string> #include <vector>
-namespace slic -{
+namespace slic {
- /** - * @class LcioFileNamer - * @brief Automatically name LCIO output files according to input settings. - */ - class LcioFileNamer : public Module - { - public: - LcioFileNamer(); - virtual ~LcioFileNamer() {}
+/** + * @class LcioFileNamer + * @brief Automatically name LCIO output files according to input settings. + */ +class LcioFileNamer: public Module { +public: + LcioFileNamer(); + virtual ~LcioFileNamer() { + }
- public:
+public:
- std::string makeFileName(std::vector<std::string>);
+ std::string makeFileName(std::vector<std::string>);
- private: - std::string getFieldValue(std::string);
+private: + std::string getFieldValue(std::string);
- std::string makeDefaultFileName();
+ std::string makeDefaultFileName();
- static std::string makeEventName();
+ static std::string makeEventName();
- static std::string makeFileBasedName(); - static std::string makeGPSName(); - static std::string makeGunName();
+ static std::string makeFileBasedName(); + static std::string makeGPSName(); + static std::string makeGunName();
- static std::string makeRunNumberString(); - static std::string makeEventNumberString();
+ static std::string makeRunNumberString(); + static std::string makeEventNumberString();
- static std::string getGeant4VersionString();
+ static std::string getGeant4VersionString();
- private:
+private:
- static std::string m_sep; - std::vector<std::string> m_defaultFields; - };
+ static std::string m_sep; + std::vector<std::string> m_defaultFields; +};
} #endif
diff -u -r1.6 -r1.7 --- LcioHitsCollectionBuilder.hh 14 Oct 2009 20:55:10 -0000 1.6 +++ LcioHitsCollectionBuilder.hh 27 Nov 2012 19:32:17 -0000 1.7 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioHitsCollectionBuilder.hh,v 1.6 2009/10/14 20:55:10 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioHitsCollectionBuilder.hh,v 1.7 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_LCIOHITSCOLLECTIONBUILDER_HH #define SLIC_LCIOHITSCOLLECTIONBUILDER_HH
@@ -22,109 +22,100 @@
// geant4 #include "G4Event.hh"
-namespace slic -{
+namespace slic {
- class LcioMcpManager;
+class LcioMcpManager;
- /** - @class LcioHitsCollectionBuilder - @brief Builds Lcio hits collections from G4/SLIC event data. - @note Makes use of LcioMcpManager for Mcp hit contributions. - */ - class LcioHitsCollectionBuilder : public Module - { - public: - LcioHitsCollectionBuilder(); - virtual ~LcioHitsCollectionBuilder(); - - public: - - // interface function to create an Lcio event from a G4 event - EVENT::LCEvent* createHCsFromG4Event(const G4Event* g4evt, EVENT::LCEvent* lcevt); - - // flags for hits - void setLongFlag(bool s = true); - void setPDGFlag(bool s = true); - - void setStoreMomentum( bool s = true ) - { - m_storeMomentum = s; - } - - bool getStoreMomentum() - { - return m_storeMomentum; - } - - private: - // create the hit collections in Lcio Event from the current G4Event - void createHitCollections(); - - // create the LCCollectionVec - IMPL::LCCollectionVec* createCollectionVec(G4VHitsCollection* g4HC, - G4SensitiveDetector::EType SDtype); - - // create a tracker coll - IMPL::LCCollectionVec* createTrackerCollectionVec(G4VHitsCollection* g4HC); - - // create a calorimeter coll - IMPL::LCCollectionVec* createCalorimeterCollectionVec(G4VHitsCollection* g4HC); - - // save cal hits - void saveHits(G4CalorimeterHitsCollection* calHits, - IMPL::LCCollectionVec* lcioColl); - - // save trk hits - void saveHits(G4TrackerHitsCollection* trkHits, - IMPL::LCCollectionVec* lcioColl); - - // create cal hit from G4 cal hit - IMPL::SimCalorimeterHitImpl* createHit(G4CalorimeterHit* calHit); - - // create trk hit from G4 trk hit - IMPL::SimTrackerHitImpl* createHit(G4TrackerHit* trkHit); - - // copy MCParticle hit contributions from G4 cal hit to the LCIO cal hit - void addMcpContribs( G4CalorimeterHit*, IMPL::SimCalorimeterHitImpl* ); - - // setup default flag settings; called in ctor - void setCalFlagDefaults(); - - // combine Mcp hit contribs using track ID - void combineMcpHitContribs(const McpHitContribList& long_contrib, - McpHitContribList& combined_contrib); - - // find single contrib by track ID in the combined list - McpHitContrib* findMcpHitContribByTrackID(int trk_id, - McpHitContribList& contribs); - - // set endcap bit in trk or cal flag depending on SD type - void setEndcapFlag(G4SensitiveDetector* g4sd); - - /** - * True if the LCEvent contains a collection with given name; False if not. - */ - static bool containsCollection(EVENT::LCEvent*, const std::string&); - - private: - - // current Lcio event - EVENT::LCEvent* m_currentLCEvent; - - // current G4 event - const G4Event* m_currentG4Event; - - // default flags - IMPL::LCFlagImpl m_trkCollFlag; - IMPL::LCFlagImpl m_calCollFlag; - - // store momentum - bool m_storeMomentum; - - // ptr to Lcio Mcp manager for lkp of Mcp data - LcioMcpManager* m_mcpManager; - };
+/** + @class LcioHitsCollectionBuilder + @brief Builds Lcio hits collections from G4/SLIC event data. + @note Makes use of LcioMcpManager for Mcp hit contributions. + */ +class LcioHitsCollectionBuilder: public Module { +public: + LcioHitsCollectionBuilder(); + virtual ~LcioHitsCollectionBuilder(); + +public: + + // interface function to create an Lcio event from a G4 event + EVENT::LCEvent* createHCsFromG4Event(const G4Event* g4evt, EVENT::LCEvent* lcevt); + + // flags for hits + void setLongFlag(bool s = true); + void setPDGFlag(bool s = true); + + void setStoreMomentum(bool s = true) { + m_storeMomentum = s; + } + + bool getStoreMomentum() { + return m_storeMomentum; + } + +private: + // create the hit collections in Lcio Event from the current G4Event + void createHitCollections(); + + // create the LCCollectionVec + IMPL::LCCollectionVec* createCollectionVec(G4VHitsCollection* g4HC, G4SensitiveDetector::EType SDtype); + + // create a tracker coll + IMPL::LCCollectionVec* createTrackerCollectionVec(G4VHitsCollection* g4HC); + + // create a calorimeter coll + IMPL::LCCollectionVec* createCalorimeterCollectionVec(G4VHitsCollection* g4HC); + + // save cal hits + void saveHits(G4CalorimeterHitsCollection* calHits, IMPL::LCCollectionVec* lcioColl); + + // save trk hits + void saveHits(G4TrackerHitsCollection* trkHits, IMPL::LCCollectionVec* lcioColl); + + // create cal hit from G4 cal hit + IMPL::SimCalorimeterHitImpl* createHit(G4CalorimeterHit* calHit); + + // create trk hit from G4 trk hit + IMPL::SimTrackerHitImpl* createHit(G4TrackerHit* trkHit); + + // copy MCParticle hit contributions from G4 cal hit to the LCIO cal hit + void addMcpContribs(G4CalorimeterHit*, IMPL::SimCalorimeterHitImpl*); + + // setup default flag settings; called in ctor + void setCalFlagDefaults(); + + // combine Mcp hit contribs using track ID + void combineMcpHitContribs(const McpHitContribList& long_contrib, McpHitContribList& combined_contrib); + + // find single contrib by track ID in the combined list + McpHitContrib* findMcpHitContribByTrackID(int trk_id, McpHitContribList& contribs); + + // set endcap bit in trk or cal flag depending on SD type + void setEndcapFlag(G4SensitiveDetector* g4sd); + + /** + * True if the LCEvent contains a collection with given name; False if not. + */ + static bool containsCollection(EVENT::LCEvent*, const std::string&); + +private: + + // current Lcio event + EVENT::LCEvent* m_currentLCEvent; + + // current G4 event + const G4Event* m_currentG4Event; + + // default flags + IMPL::LCFlagImpl m_trkCollFlag; + IMPL::LCFlagImpl m_calCollFlag; + + // store momentum + bool m_storeMomentum; + + // ptr to Lcio Mcp manager for lkp of Mcp data + LcioMcpManager* m_mcpManager; +};
} #endif
diff -u -r1.58 -r1.59 --- LcioManager.hh 2 Aug 2012 23:05:38 -0000 1.58 +++ LcioManager.hh 27 Nov 2012 19:32:17 -0000 1.59 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioManager.hh,v 1.58 2012/08/02 23:05:38 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioManager.hh,v 1.59 2012/11/27 19:32:17 jeremy Exp $
#ifndef SLIC_LCIOMANAGER_HH #define SLIC_LCIOMANAGER_HH 1
@@ -38,203 +38,194 @@
class G4VHitsCollection; class G4TrajectoryContainer;
-namespace slic -{
+namespace slic {
- class LcioMessenger;
+class LcioMessenger;
- /** - * @class LcioManager - * @brief Singleton manager class of Lcio file operations. - * @note This class is the top-level instantiator of other - * Lcio singleton managers and helper classes. - */ - class LcioManager : public Module, public Singleton<LcioManager> - {
+/** + * @class LcioManager + * @brief Singleton manager class of Lcio file operations. + * @note This class is the top-level instantiator of other + * Lcio singleton managers and helper classes. + */ +class LcioManager: public Module, public Singleton<LcioManager> {
- public:
+public:
- enum EFileExistsAction { - eInvalid = -1, - eFail = 0, - eDelete = 1, - eAppend = 2 - };
+ enum EFileExistsAction { + eInvalid = -1, eFail = 0, eDelete = 1, eAppend = 2 + };
- typedef unsigned int RunNumberType;
+ typedef unsigned int RunNumberType;
- public: - virtual ~LcioManager();
+public: + virtual ~LcioManager();
- //static LcioManager* instance();
+ //static LcioManager* instance();
- LcioManager();
+ LcioManager();
- public:
+public:
- // open file from mvar vals - void openLcioFile();
+ // open file from mvar vals + void openLcioFile();
- // path and filename - void setPath(const std::string& path); - void setFilename(const std::string& filename); - void setAutonameFields(const std::vector<std::string>& fields);
+ // path and filename + void setPath(const std::string& path); + void setFilename(const std::string& filename); + void setAutonameFields(const std::vector<std::string>& fields);
- const std::string& getPath() const; - const std::string& getFilename() const;
+ const std::string& getPath() const; + const std::string& getFilename() const;
- // get path + filename; arg == true to include ".slcio" extension - std::string getFullOutputPath(bool withExtension = false);
+ // get path + filename; arg == true to include ".slcio" extension + std::string getFullOutputPath(bool withExtension = false);
- // convert to file exists setting from a string - static EFileExistsAction getFileExistsActionFromString( const std::string& fea);
+ // convert to file exists setting from a string + static EFileExistsAction getFileExistsActionFromString(const std::string& fea);
- void setRunNumber(RunNumberType rnt);
+ void setRunNumber(RunNumberType rnt);
- // run actions - void beginRun( const G4Run* ); - void endRun( const G4Run* );
+ // run actions + void beginRun(const G4Run*); + void endRun(const G4Run*);
- // create the LCEvent - IMPL::LCEventImpl* createLCEvent(const G4Event* anEvent); - IMPL::LCEventImpl* createLCEvent();
+ // create the LCEvent + IMPL::LCEventImpl* createLCEvent(const G4Event* anEvent); + IMPL::LCEventImpl* createLCEvent();
- // create Mcp coll - void createFinalMcpCollection();
+ // create Mcp coll + void createFinalMcpCollection();
- void addCollection( EVENT::LCEvent*, EVENT::LCCollection*, const std::string& );
+ void addCollection(EVENT::LCEvent*, EVENT::LCCollection*, const std::string&);
- void addCollection( EVENT::LCCollection*, const std::string& ); - - void addInitialMCParticleCollection();
+ void addCollection(EVENT::LCCollection*, const std::string&);
- // formerly writeEvent() - void endEvent(const G4Event* anEvent);
+ void addInitialMCParticleCollection();
- // set the current LCEvent - void setCurrentLCEvent(IMPL::LCEventImpl* anLCEvent) { m_currentLCEvent = anLCEvent; } - IMPL::LCEventImpl* getCurrentLCEvent() { return m_currentLCEvent; }
+ // formerly writeEvent() + void endEvent(const G4Event* anEvent);
- void setStoreMomentum(bool s = true) - { - m_HCBuilder->setStoreMomentum(s); - }
+ // set the current LCEvent + void setCurrentLCEvent(IMPL::LCEventImpl* anLCEvent) { + m_currentLCEvent = anLCEvent; + } + IMPL::LCEventImpl* getCurrentLCEvent() { + return m_currentLCEvent; + }
- void setFileExistsAction(EFileExistsAction fea) - { - if ( fea == eInvalid ) {
+ void setStoreMomentum(bool s = true) { + m_HCBuilder->setStoreMomentum(s); + } + + void setFileExistsAction(EFileExistsAction fea) { + if (fea == eInvalid) {
#ifdef SLIC_LOG
- log() << LOG::error << "Invalid setting for FileExistsAction." << LOG::done;
+ log() << LOG::error << "Invalid setting for FileExistsAction." << LOG::done;
#endif
- return; - }
+ return; + } + + m_fileExistsAction = fea; + }
- m_fileExistsAction = fea; - } - - EFileExistsAction getFileExistsAction() - { - return m_fileExistsAction; - }
+ EFileExistsAction getFileExistsAction() { + return m_fileExistsAction; + }
- inline LcioPrimaryGenerator* getGenerator() - { - return m_eventGenerator; - }
+ inline LcioPrimaryGenerator* getGenerator() { + return m_eventGenerator; + }
- inline LcioMcpManager* getMcpManager() - { - return m_mcpManager; - }
+ inline LcioMcpManager* getMcpManager() { + return m_mcpManager; + }
- inline LcioHitsCollectionBuilder* getHCBuilder() - { - return m_HCBuilder; - }
+ inline LcioHitsCollectionBuilder* getHCBuilder() { + return m_HCBuilder; + }
- inline LcioFileNamer* getFileNamer() - { - return m_namer; - }
+ inline LcioFileNamer* getFileNamer() { + return m_namer; + }
- void enableDumpEvent(bool p = true) - { - m_enableDumpEvent = p; - }
+ void enableDumpEvent(bool p = true) { + m_enableDumpEvent = p; + }
- private:
+private:
- void makeAutoname();
+ void makeAutoname();
- // add HCs using builder and current ptrs - void createHitsCollections();
+ // add HCs using builder and current ptrs + void createHitsCollections();
- // LCWriter - void createWriter(); - void deleteWriter();
+ // LCWriter + void createWriter(); + void deleteWriter();
- // run header - void createRunHeader(const G4Run*); - void deleteRunHeader();
+ // run header + void createRunHeader(const G4Run*); + void deleteRunHeader();
- // set detector tag in LCIO output header - void setDetectorName();
+ // set detector tag in LCIO output header + void setDetectorName();
- // set timestamp - void setEventTimeStamp();
+ // set timestamp + void setEventTimeStamp();
- // add actives detectors from LCDD parser into the LCIO header - void addActiveSubdetectors();
+ // add actives detectors from LCDD parser into the LCIO header + void addActiveSubdetectors();
- // reset cached instance vars - void reset();
+ // reset cached instance vars + void reset();
- private:
+private:
- // final Mcp collection with all info from McpInitial, Trajectories, Primaries - IMPL::LCCollectionVec* m_McpFinalColl;
+ // final Mcp collection with all info from McpInitial, Trajectories, Primaries + IMPL::LCCollectionVec* m_McpFinalColl;
- // writer - IO::LCWriter* m_writer;
+ // writer + IO::LCWriter* m_writer;
- // run header - IMPL::LCRunHeaderImpl* m_runHdr;
+ // run header + IMPL::LCRunHeaderImpl* m_runHdr;
- // file info - std::string m_filename; - std::string m_path;
+ // file info + std::string m_filename; + std::string m_path;
- // Mcp manager - LcioMcpManager* m_mcpManager;
+ // Mcp manager + LcioMcpManager* m_mcpManager;
- // event generator from MCP Coll - LcioPrimaryGenerator* m_eventGenerator;
+ // event generator from MCP Coll + LcioPrimaryGenerator* m_eventGenerator;
- // creation of HCs - LcioHitsCollectionBuilder* m_HCBuilder;
+ // creation of HCs + LcioHitsCollectionBuilder* m_HCBuilder;
- // current LCEvent - IMPL::LCEventImpl* m_currentLCEvent;
+ // current LCEvent + IMPL::LCEventImpl* m_currentLCEvent;
- // messenger - LcioMessenger* m_messenger;
+ // messenger + LcioMessenger* m_messenger;
- // action when file exists - EFileExistsAction m_fileExistsAction;
+ // action when file exists + EFileExistsAction m_fileExistsAction;
- // starting run number - RunNumberType m_runNumber;
+ // starting run number + RunNumberType m_runNumber;
- LcioFileNamer* m_namer;
+ LcioFileNamer* m_namer;
- static std::string m_defaultFileName; - std::vector<std::string> m_currentAutonameFields;
+ static std::string m_defaultFileName; + std::vector<std::string> m_currentAutonameFields;
- bool m_enableDumpEvent; - bool m_writerIsOpen; - bool m_usingAutoname; - //bool m_abortCurrentRun; - };
+ bool m_enableDumpEvent; + bool m_writerIsOpen; + bool m_usingAutoname; + //bool m_abortCurrentRun; +};
} #endif
diff -u -r1.9 -r1.10 --- LcioMcpFactory.hh 1 Sep 2011 21:20:27 -0000 1.9 +++ LcioMcpFactory.hh 27 Nov 2012 19:32:18 -0000 1.10 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpFactory.hh,v 1.9 2011/09/01 21:20:27 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpFactory.hh,v 1.10 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_LCIOMCPFACTORY_HH #define SLIC_LCIOMCPFACTORY_HH 1
@@ -16,84 +16,82 @@
class G4TrajectoryContainer; class G4Event;
-namespace slic -{ - class LcioMcpManager; - class Trajectory;
+namespace slic { +class LcioMcpManager; +class Trajectory;
- /** - * @class LcioMcpFactory - * @brief Creates LCIO MCParticles from saved Geant4/SLIC runtime information. - */ - class LcioMcpFactory : public Module - {
+/** + * @class LcioMcpFactory + * @brief Creates LCIO MCParticles from saved Geant4/SLIC runtime information. + */ +class LcioMcpFactory: public Module {
- public: - LcioMcpFactory(LcioMcpManager*); - virtual ~LcioMcpFactory();
+public: + LcioMcpFactory(LcioMcpManager*); + virtual ~LcioMcpFactory();
- public:
+public:
- // create new, blank Mcp coll - EVENT::LCCollection* createEmptyMcpCollection(const std::string& collName, bool errorOnExist = true);
+ // create new, blank Mcp coll + EVENT::LCCollection* createEmptyMcpCollection(const std::string& collName, bool errorOnExist = true);
- // chooses to create from initial or traj cont - void createFinalMcpCollection(const G4Event* event);
+ // chooses to create from initial or traj cont + void createFinalMcpCollection(const G4Event* event);
- private:
+private:
- // use StdHep-generated mcpVec to create final mcpVec for an event - void createFinalMcpCollectionFromInitial(EVENT::LCCollection* mcpVecInitial);
+ // use StdHep-generated mcpVec to create final mcpVec for an event + void createFinalMcpCollectionFromInitial(EVENT::LCCollection* mcpVecInitial);
- // These two functions create the Mcp coll from trajectories only in case of G4 GPS or gun - void createFinalMcpCollectionFromTrajectoryContainer(G4TrajectoryContainer* trjCont);
+ // These two functions create the Mcp coll from trajectories only in case of G4 GPS or gun + void createFinalMcpCollectionFromTrajectoryContainer(G4TrajectoryContainer* trjCont);
- /* Create Mcp daughters of a trajectory with the given track ID. */ - void addMcpDaughtersFromTrajectoryContainer(IMPL::MCParticleImpl* parMcp, int parTrkID);
+ /* Create Mcp daughters of a trajectory with the given track ID. */ + void addMcpDaughtersFromTrajectoryContainer(IMPL::MCParticleImpl* parMcp, int parTrkID);
- // create an Mcp from a trajectory only - IMPL::MCParticleImpl* createMcpFromTrajectory( Trajectory* );
+ // create an Mcp from a trajectory only + IMPL::MCParticleImpl* createMcpFromTrajectory(Trajectory*);
- // create Mcps recursively given an initial Mcp - IMPL::MCParticleImpl* createMcpFromInitialRecurse(EVENT::MCParticle* mcp);
+ // create Mcps recursively given an initial Mcp + IMPL::MCParticleImpl* createMcpFromInitialRecurse(EVENT::MCParticle* mcp);
- // create an Mcp from another, associated initial Mcp only - IMPL::MCParticleImpl* createMcpFromInitialOnly(EVENT::MCParticle* mcpInit);
+ // create an Mcp from another, associated initial Mcp only + IMPL::MCParticleImpl* createMcpFromInitialOnly(EVENT::MCParticle* mcpInit);
- // create an Mcp from a G4PrimaryParticle - IMPL::MCParticleImpl* createMcpFromPrimary(G4PrimaryParticle*, EVENT::MCParticle* );
+ // create an Mcp from a G4PrimaryParticle + IMPL::MCParticleImpl* createMcpFromPrimary(G4PrimaryParticle*, EVENT::MCParticle*);
- // create an Mcp from primary and input Mcp - IMPL::MCParticleImpl* createMcpFromInitialAndPrimary(G4PrimaryParticle* primary, EVENT::MCParticle* mcpInit);
+ // create an Mcp from primary and input Mcp + IMPL::MCParticleImpl* createMcpFromInitialAndPrimary(G4PrimaryParticle* primary, + EVENT::MCParticle* mcpInit);
- // create an Mcp from a trajectory and an input Mcp - IMPL::MCParticleImpl* createMcpFromInitialAndTrajectory( Trajectory*, EVENT::MCParticle* mcpInit );
+ // create an Mcp from a trajectory and an input Mcp + IMPL::MCParticleImpl* createMcpFromInitialAndTrajectory(Trajectory*, EVENT::MCParticle* mcpInit);
- // create an Mcp from a G4PrimaryParticle, shallow copy only - IMPL::MCParticleImpl* createMcpFromPrimaryShallowCopy(G4PrimaryParticle*);
+ // create an Mcp from a G4PrimaryParticle, shallow copy only + IMPL::MCParticleImpl* createMcpFromPrimaryShallowCopy(G4PrimaryParticle*);
- // create new Mcp and shallow copy from input Mcp - IMPL::MCParticleImpl* createMcpShallowCopy(EVENT::MCParticle* mcp);
+ // create new Mcp and shallow copy from input Mcp + IMPL::MCParticleImpl* createMcpShallowCopy(EVENT::MCParticle* mcp);
- // create and add MCP daughters based on G4PrimaryParticle and associated MCP from StdHep - void createDaughtersFromPrimary(G4PrimaryParticle* primary, - EVENT::MCParticle* mcpInit, - IMPL::MCParticleImpl* mcpPar);
+ // create and add MCP daughters based on G4PrimaryParticle and associated MCP from StdHep + void createDaughtersFromPrimary(G4PrimaryParticle* primary, EVENT::MCParticle* mcpInit, + IMPL::MCParticleImpl* mcpPar);
- // add daughters to a MCP based on associated intial MCP from StdHep - void addMcpDaughtersFromInitial( IMPL::MCParticleImpl* mcpNew, EVENT::MCParticle* mcpInit );
+ // add daughters to a MCP based on associated intial MCP from StdHep + void addMcpDaughtersFromInitial(IMPL::MCParticleImpl* mcpNew, EVENT::MCParticle* mcpInit);
- void fillMcpEndPointEnergy(IMPL::LCCollectionVec* mcpColl);
+ void fillMcpEndPointEnergy(IMPL::LCCollectionVec* mcpColl);
#if LCIO_VERSION_GE(1, 60)
- void copySpinAndColorFlow(EVENT::MCParticle* mcp1, EVENT::MCParticle* mcp2);
+ void copySpinAndColorFlow(EVENT::MCParticle* mcp1, EVENT::MCParticle* mcp2);
#endif
- private: - LcioMcpManager* m_manager; - IMPL::LCCollectionVec* m_finalColl; - G4TrajectoryContainer* m_currentTrajectoryContainer; - };
+private: + LcioMcpManager* m_manager; + IMPL::LCCollectionVec* m_finalColl; + G4TrajectoryContainer* m_currentTrajectoryContainer; +};
} #endif
diff -u -r1.7 -r1.8 --- LcioMcpFilter.hh 27 Apr 2007 01:54:32 -0000 1.7 +++ LcioMcpFilter.hh 27 Nov 2012 19:32:18 -0000 1.8 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpFilter.hh,v 1.7 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpFilter.hh,v 1.8 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_LCIOMCPFILTER_HH #define SLIC_LCIOMCPFILTER_HH 1
@@ -12,31 +12,29 @@
#include "EVENT/MCParticle.h" #include "IMPL/MCParticleImpl.h"
-namespace slic -{ - /** - * @class LcioMcpFilter - * @brief Filters simulation particles from an MCParticle collection. - */ - class LcioMcpFilter : public Module - { - - public: - - LcioMcpFilter(); - virtual ~LcioMcpFilter(); - - public: - - EVENT::LCCollection* filterSimParticles(EVENT::LCCollection* mcpColl); - IMPL::MCParticleImpl* makeMcp(EVENT::MCParticle* mcp, EVENT::LCCollection* mcpColl); - void addSimDaughters(EVENT::MCParticle* mcp, EVENT::MCParticle* parMcp, EVENT::LCCollection* mcpColl); - - bool wasAdded(EVENT::MCParticle* mcp); - - private: - std::vector<EVENT::MCParticle*> m_mcpList; - };
+namespace slic { +/** + * @class LcioMcpFilter + * @brief Filters simulation particles from an MCParticle collection. + */ +class LcioMcpFilter: public Module { + +public: + + LcioMcpFilter(); + virtual ~LcioMcpFilter(); + +public: + + EVENT::LCCollection* filterSimParticles(EVENT::LCCollection* mcpColl); + IMPL::MCParticleImpl* makeMcp(EVENT::MCParticle* mcp, EVENT::LCCollection* mcpColl); + void addSimDaughters(EVENT::MCParticle* mcp, EVENT::MCParticle* parMcp, EVENT::LCCollection* mcpColl); + + bool wasAdded(EVENT::MCParticle* mcp); + +private: + std::vector<EVENT::MCParticle*> m_mcpList; +};
} #endif
diff -u -r1.55 -r1.56 --- LcioMcpManager.hh 4 Jul 2012 01:01:47 -0000 1.55 +++ LcioMcpManager.hh 27 Nov 2012 19:32:18 -0000 1.56 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpManager.hh,v 1.55 2012/07/04 01:01:47 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpManager.hh,v 1.56 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_LCIOMCPMANAGER_HH #define SLIC_LCIOMCPMANAGER_HH 1
@@ -27,137 +27,133 @@
class G4Event; class G4TrajectoryContainer;
-namespace slic -{
+namespace slic {
- class LcioMcpMessenger; - class LcioMcpFactory; - class LcioMcpPrinter; - class Trajectory;
+class LcioMcpMessenger; +class LcioMcpFactory; +class LcioMcpPrinter; +class Trajectory;
- /** - * @class LcioMcpManager - * @brief This singleton manages creation of the LCIO MCParticle output collection from transient - * G4Event and slic data. - */ - class LcioMcpManager : public Module, public Singleton<LcioMcpManager> - {
+/** + * @class LcioMcpManager + * @brief This singleton manages creation of the LCIO MCParticle output collection from transient + * G4Event and slic data. + */ +class LcioMcpManager: public Module, public Singleton<LcioMcpManager> {
- public: - // Mcp collections - typedef std::map<std::string, EVENT::LCCollection*> McpCollectionMap;
+public: + // Mcp collections + typedef std::map<std::string, EVENT::LCCollection*> McpCollectionMap;
- public: - virtual ~LcioMcpManager(); - LcioMcpManager();
+public: + virtual ~LcioMcpManager(); + LcioMcpManager();
- public:
+public:
- // action at end of event - void endEvent(const G4Event* anEvent);
+ // action at end of event + void endEvent(const G4Event* anEvent);
- /* - * Create an empty MCParticle collection indexed by collName. - * SIDE EFFECT: Automatically registers collection into the map. - */ - EVENT::LCCollection* createMcpCollection(const std::string& collName);
+ /* + * Create an empty MCParticle collection indexed by collName. + * SIDE EFFECT: Automatically registers collection into the map. + */ + EVENT::LCCollection* createMcpCollection(const std::string& collName);
- /** - * Get the MCP collection generated from StdHep. - * Creates empty collection if doesn't exist. - */ - EVENT::LCCollection* getInitialMcpCollection();
+ /** + * Get the MCP collection generated from StdHep. + * Creates empty collection if doesn't exist. + */ + EVENT::LCCollection* getInitialMcpCollection();
- /** - * Get the MCP collection generated at EndOfEvent. - * Creates empty collection if doesn't exist. - */ - EVENT::LCCollection* getFinalMcpCollection();
+ /** + * Get the MCP collection generated at EndOfEvent. + * Creates empty collection if doesn't exist. + */ + EVENT::LCCollection* getFinalMcpCollection();
- void setMinimumTrackingDistance(double minDist); - double getMinimumTrackingDistance();
+ void setMinimumTrackingDistance(double minDist); + double getMinimumTrackingDistance();
- // reset the manager at the end of event - void reset();
+ // reset the manager at the end of event + void reset();
- // set initial mcp coll externally - void setInitialMcpCollection(EVENT::LCCollection* mcpColl);
+ // set initial mcp coll externally + void setInitialMcpCollection(EVENT::LCCollection* mcpColl);
- /* Register an LCCollection object containing MCParticles, by name. */ - void registerMcpCollection(const std::string& collName, EVENT::LCCollection*);
+ /* Register an LCCollection object containing MCParticles, by name. */ + void registerMcpCollection(const std::string& collName, EVENT::LCCollection*);
- /* Find the first MCParticle coll in the LCevent. */ - EVENT::LCCollection* findMcpCollection(EVENT::LCEvent* event);
+ /* Find the first MCParticle coll in the LCevent. */ + EVENT::LCCollection* findMcpCollection(EVENT::LCEvent* event);
- /* Find a registered MCParticle coll. */ - EVENT::LCCollection* findMcpCollection(const std::string& collName); - - /* Print utility functions, using the LcioMcpPrinter. */ - void printMcpCollection(const std::string& collName); - void printMcpCollection(const std::string& collName, EVENT::LCCollection* coll);
+ /* Find a registered MCParticle coll. */ + EVENT::LCCollection* findMcpCollection(const std::string& collName);
- /* Get the MCParticle data maps. */ - LcioMcpMaps* getMaps();
+ /* Print utility functions, using the LcioMcpPrinter. */ + void printMcpCollection(const std::string& collName); + void printMcpCollection(const std::string& collName, EVENT::LCCollection* coll);
- void enablePrintFinal(bool p = true); - void enablePrintInitial(bool p = true);
+ /* Get the MCParticle data maps. */ + LcioMcpMaps* getMaps();
- void beginEvent(const G4Event* anEvent);
+ void enablePrintFinal(bool p = true); + void enablePrintInitial(bool p = true);
- double getNoChargeFlag() const;
+ void beginEvent(const G4Event* anEvent);
- inline void setWriteInitialMCParticleCollection(bool b) - { - m_writeInitialMCParticleCollection=b; - } - - inline bool writeInitialMCParticleCollection() - { - return m_writeInitialMCParticleCollection; - }
+ double getNoChargeFlag() const;
- int getMCParticleIndex( EVENT::LCCollection*, EVENT::MCParticle*);
+ inline void setWriteInitialMCParticleCollection(bool b) { + m_writeInitialMCParticleCollection = b; + }
- // delete the initial collection - void deleteInitialMcpCollection();
+ inline bool writeInitialMCParticleCollection() { + return m_writeInitialMCParticleCollection; + }
- private:
+ int getMCParticleIndex(EVENT::LCCollection*, EVENT::MCParticle*);
- // clear the maps - void clearMaps();
+ // delete the initial collection + void deleteInitialMcpCollection();
- private:
+private:
- // current LCEvent - IMPL::LCEventImpl* m_currentLCEvent;
+ // clear the maps + void clearMaps();
- // printer for MCP debugging - LcioMcpPrinter* m_printer;
+private:
- // user settings - double m_vertexIsNotEndpointOfParentTolerance; - double m_minimumTrackingDistance;
+ // current LCEvent + IMPL::LCEventImpl* m_currentLCEvent;
- // G4 messenger for Mcp handling - LcioMcpMessenger* m_messenger;
+ // printer for MCP debugging + LcioMcpPrinter* m_printer;
- // map of Mcp colls being tracked by the manager - McpCollectionMap m_mcpColls;
+ // user settings + double m_vertexIsNotEndpointOfParentTolerance; + double m_minimumTrackingDistance;
- /* Factory for creating MCParticles from Geant4 runtime data. */ - LcioMcpFactory* m_factory;
+ // G4 messenger for Mcp handling + LcioMcpMessenger* m_messenger;
- /* Collection of maps with MCParticle information. */ - LcioMcpMaps* m_maps;
+ // map of Mcp colls being tracked by the manager + McpCollectionMap m_mcpColls;
- bool m_enablePrintFinal; - bool m_enablePrintInitial; - bool m_writeInitialMCParticleCollection;
+ /* Factory for creating MCParticles from Geant4 runtime data. */ + LcioMcpFactory* m_factory;
- public: - static const double m_NAN; - static const double DEFAULT_MIN_TRACKING_DISTANCE; - };
+ /* Collection of maps with MCParticle information. */ + LcioMcpMaps* m_maps; + + bool m_enablePrintFinal; + bool m_enablePrintInitial; + bool m_writeInitialMCParticleCollection; + +public: + static const double m_NAN; + static const double DEFAULT_MIN_TRACKING_DISTANCE; +};
} #endif
diff -u -r1.6 -r1.7 --- LcioMcpMaps.hh 27 Apr 2007 01:54:32 -0000 1.6 +++ LcioMcpMaps.hh 27 Nov 2012 19:32:18 -0000 1.7 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpMaps.hh,v 1.6 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpMaps.hh,v 1.7 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_LCIOMCPMAPS_HH #define SLIC_LCIOMCPMAPS_HH 1
@@ -19,87 +19,85 @@
// geant4 class G4PrimaryParticle;
-namespace slic -{
+namespace slic {
- // slic - class LcioMcpManager; - class Trajectory;
+// slic +class LcioMcpManager; +class Trajectory;
- /** - * @class LcioMcpMaps - * @brief Data maps that relate MCParticles to various other runtime objects. - */ - class LcioMcpMaps : public Module - {
+/** + * @class LcioMcpMaps + * @brief Data maps that relate MCParticles to various other runtime objects. + */ +class LcioMcpMaps: public Module {
- public: - LcioMcpMaps(LcioMcpManager*); - virtual ~LcioMcpMaps();
+public: + LcioMcpMaps(LcioMcpManager*); + virtual ~LcioMcpMaps();
- public:
+public:
- // track to Mcp - typedef std::map<G4int, IMPL::MCParticleImpl*> TrackToMcpMap;
+ // track to Mcp + typedef std::map<G4int, IMPL::MCParticleImpl*> TrackToMcpMap;
- // Mcp to primary particle - typedef std::map<EVENT::MCParticle*, G4PrimaryParticle*> McpToPrimaryMap;
+ // Mcp to primary particle + typedef std::map<EVENT::MCParticle*, G4PrimaryParticle*> McpToPrimaryMap;
- // initial Mcp from StdHep to final Mcp - typedef std::map<EVENT::MCParticle*, IMPL::MCParticleImpl*> InitMcpToMcpMap;
+ // initial Mcp from StdHep to final Mcp + typedef std::map<EVENT::MCParticle*, IMPL::MCParticleImpl*> InitMcpToMcpMap;
- public:
+public:
- // connect an initial Mcp to a primary - void addMcpToPrimaryLink(EVENT::MCParticle* mcp, G4PrimaryParticle* primary);
+ // connect an initial Mcp to a primary + void addMcpToPrimaryLink(EVENT::MCParticle* mcp, G4PrimaryParticle* primary);
- // connect track to MCParticle via track ID - void addTrackIDToMcpLink(G4int trkID, IMPL::MCParticleImpl* mcp);
+ // connect track to MCParticle via track ID + void addTrackIDToMcpLink(G4int trkID, IMPL::MCParticleImpl* mcp);
- // connect initial Mcp to final Mcp - void addInitialMcpToFinalMcpLink( EVENT::MCParticle* mcpInit, IMPL::MCParticleImpl* mcpFinal);
+ // connect initial Mcp to final Mcp + void addInitialMcpToFinalMcpLink(EVENT::MCParticle* mcpInit, IMPL::MCParticleImpl* mcpFinal);
- // find an MCParticle from the trackID - IMPL::MCParticleImpl* findMcpFromTrackID( G4int trkID ) const;
+ // find an MCParticle from the trackID + IMPL::MCParticleImpl* findMcpFromTrackID(G4int trkID) const;
- /* Find the trackID for the final MCParticle. */ - G4int findTrackIDFromFinalMcp( EVENT::MCParticle* ) const;
+ /* Find the trackID for the final MCParticle. */ + G4int findTrackIDFromFinalMcp(EVENT::MCParticle*) const;
- // find matching primary particle given an MCP ptr - G4PrimaryParticle* findPrimaryFromMcp(EVENT::MCParticle* mcp) const;
+ // find matching primary particle given an MCP ptr + G4PrimaryParticle* findPrimaryFromMcp(EVENT::MCParticle* mcp) const;
- // loop over input collection to find matching Mcp primary for this trajectory - EVENT::MCParticle* findPrimaryInitialMcpFromTrajectory(Trajectory* trj) const;
+ // loop over input collection to find matching Mcp primary for this trajectory + EVENT::MCParticle* findPrimaryInitialMcpFromTrajectory(Trajectory* trj) const;
- // find a dau Mcp given a G4PrimaryParticle dau - EVENT::MCParticle* findDaughterMcpFromPrimary(EVENT::MCParticle* mcpInit, - G4PrimaryParticle* primary) const;
+ // find a dau Mcp given a G4PrimaryParticle dau + EVENT::MCParticle* findDaughterMcpFromPrimary(EVENT::MCParticle* mcpInit, + G4PrimaryParticle* primary) const;
- // given an input particle from stdhep, find the proper output particle - IMPL::MCParticleImpl* findFinalParticleFromInitial( EVENT::MCParticle* mcpInit) const;
+ // given an input particle from stdhep, find the proper output particle + IMPL::MCParticleImpl* findFinalParticleFromInitial(EVENT::MCParticle* mcpInit) const;
- // print maps - void printMaps(); - void printTrackToMcpMap(); - void printMcpToPrimaryMap(); - void printInitMcpToMcpMap();
+ // print maps + void printMaps(); + void printTrackToMcpMap(); + void printMcpToPrimaryMap(); + void printInitMcpToMcpMap();
- void clear();
+ void clear();
- private:
+private:
- // trackID -> MCP - TrackToMcpMap m_trackToMcp;
+ // trackID -> MCP + TrackToMcpMap m_trackToMcp;
- // MCP -> G4PrimaryParticle - McpToPrimaryMap m_McpToPrimary;
+ // MCP -> G4PrimaryParticle + McpToPrimaryMap m_McpToPrimary;
- // initial Mcp -> final Mcp - InitMcpToMcpMap m_initMcpToMcp;
+ // initial Mcp -> final Mcp + InitMcpToMcpMap m_initMcpToMcp;
- // back pointer to LcioMcpManager - LcioMcpManager* m_manager; - };
+ // back pointer to LcioMcpManager + LcioMcpManager* m_manager; +};
} #endif
diff -u -r1.10 -r1.11 --- LcioMcpMessenger.hh 27 Apr 2007 01:54:32 -0000 1.10 +++ LcioMcpMessenger.hh 27 Nov 2012 19:32:18 -0000 1.11 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpMessenger.hh,v 1.10 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpMessenger.hh,v 1.11 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_LCIOMCPMESSENGER_HH #define SLIC_LCIOMCPMESSENGER_HH 1
@@ -10,33 +10,31 @@
#include "G4UIdirectory.hh" #include "G4UImessenger.hh"
-namespace slic -{
+namespace slic {
- /** - @class LcioMcpMessenger - @brief G4UImessenger to LcioMcpManager. - */ - class LcioMcpMessenger : public G4UImessenger - { - public: - LcioMcpMessenger(); - virtual ~LcioMcpMessenger(); - - public: - virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); - - private: - void defineCommands(); - - private: - G4UIdirectory* m_mcpDir; - - G4UIcmdWithADoubleAndUnit* m_minTrackingDistanceCmd; - G4UIcmdWithABool* m_printFinalCollection; - G4UIcmdWithABool* m_printInitialCollection; - G4UIcmdWithABool* m_writeInitialCollection; - };
+/** + @class LcioMcpMessenger + @brief G4UImessenger to LcioMcpManager. + */ +class LcioMcpMessenger: public G4UImessenger { +public: + LcioMcpMessenger(); + virtual ~LcioMcpMessenger(); + +public: + virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); + +private: + void defineCommands(); + +private: + G4UIdirectory* m_mcpDir; + + G4UIcmdWithADoubleAndUnit* m_minTrackingDistanceCmd; + G4UIcmdWithABool* m_printFinalCollection; + G4UIcmdWithABool* m_printInitialCollection; + G4UIcmdWithABool* m_writeInitialCollection; +};
} #endif
diff -u -r1.18 -r1.19 --- LcioMcpPrinter.hh 27 Apr 2007 01:54:32 -0000 1.18 +++ LcioMcpPrinter.hh 27 Nov 2012 19:32:18 -0000 1.19 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpPrinter.hh,v 1.18 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpPrinter.hh,v 1.19 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_LCIOMCPPRINTER_HH #define SLIC_LCIOMCPPRINTER_HH 1
@@ -13,82 +13,80 @@
// std #include <map>
-namespace slic -{
+namespace slic {
- /** - @class LcioMcpPrinter - @brief Mcp printer, mostly for debugging output of MCParticle collection. - */ - class LcioMcpPrinter : public Module - { - public: - - typedef std::vector<int> IdxVec; - - public: - - LcioMcpPrinter(); - virtual ~LcioMcpPrinter(); - - public: - - void printMcpCollection(const std::string& collName, EVENT::LCCollection* coll); - - protected: - - /* Print from member vars */ - void printMcpCollection(); - - /* Print a single MCParticle line */ - void printMcp(EVENT::MCParticle* mcp); - - // str conv - static std::string makeDoubleArray3String(const double*); - static std::string makeFloatArray3String(const float*); - static std::string makeSimStatusCodesString(EVENT::MCParticle* mcp); - static std::string makeIdxVecString(const IdxVec&); - - IdxVec findDaughterIndices(EVENT::MCParticle* mcp); - IdxVec findParentIndices(EVENT::MCParticle* mcp); - - // index of a particle (-1 for not found) - int findMcpIndex(EVENT::MCParticle* mcp); - - // formatting chunks - inline void sep(); - inline void line(); - inline void head(); - inline void foot(); - - // column labels - void colLabels(); - - // flag labels - void flagLabels(); - - public: - - static const int idx_width; - static const int ptr_width; - static const int pdg_width; - static const int par_width; - static const int dau_width; - static const int mom_width; - static const int vtx_width; - static const int end_width; - static const int time_width; - static const int mass_width; - static const int chrg_width; - static const int e_width; - static const int stat_width; - static const int flags_width; - - private: - - EVENT::LCCollection* m_coll; - std::string m_collName; - };
+/** + @class LcioMcpPrinter + @brief Mcp printer, mostly for debugging output of MCParticle collection. + */ +class LcioMcpPrinter: public Module { +public: + + typedef std::vector<int> IdxVec; + +public: + + LcioMcpPrinter(); + virtual ~LcioMcpPrinter(); + +public: + + void printMcpCollection(const std::string& collName, EVENT::LCCollection* coll); + +protected: + + /* Print from member vars */ + void printMcpCollection(); + + /* Print a single MCParticle line */ + void printMcp(EVENT::MCParticle* mcp); + + // str conv + static std::string makeDoubleArray3String(const double*); + static std::string makeFloatArray3String(const float*); + static std::string makeSimStatusCodesString(EVENT::MCParticle* mcp); + static std::string makeIdxVecString(const IdxVec&); + + IdxVec findDaughterIndices(EVENT::MCParticle* mcp); + IdxVec findParentIndices(EVENT::MCParticle* mcp); + + // index of a particle (-1 for not found) + int findMcpIndex(EVENT::MCParticle* mcp); + + // formatting chunks + inline void sep(); + inline void line(); + inline void head(); + inline void foot(); + + // column labels + void colLabels(); + + // flag labels + void flagLabels(); + +public: + + static const int idx_width; + static const int ptr_width; + static const int pdg_width; + static const int par_width; + static const int dau_width; + static const int mom_width; + static const int vtx_width; + static const int end_width; + static const int time_width; + static const int mass_width; + static const int chrg_width; + static const int e_width; + static const int stat_width; + static const int flags_width; + +private: + + EVENT::LCCollection* m_coll; + std::string m_collName; +};
} #endif
diff -u -r1.5 -r1.6 --- LcioMcpStatusSetter.hh 10 Sep 2008 00:04:58 -0000 1.5 +++ LcioMcpStatusSetter.hh 27 Nov 2012 19:32:18 -0000 1.6 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpStatusSetter.hh,v 1.5 2008/09/10 00:04:58 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpStatusSetter.hh,v 1.6 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_LCIOMCPSTATUSSETTER_HH #define SLIC_LCIOMCPSTATUSSETTER_HH 1
@@ -7,33 +7,32 @@
#include "EVENT/MCParticle.h" #include "IMPL/MCParticleImpl.h"
-namespace slic -{ - class Trajectory; - - /** - * @class LcioMcpStatusSetter - * @brief Static utility functions for setting the status of MCParticles - * from associated Trajectory, initial MCParticle, and TrackInformation - * objects. - */ - class LcioMcpStatusSetter - { - private: - LcioMcpStatusSetter() {} - - public: - // set Mcp status codes from trajectory - static IMPL::MCParticleImpl* setMcpStatusCodesFromTrajectory( Trajectory*, IMPL::MCParticleImpl* ); - static void setGeneratorStatus(EVENT::MCParticle* mcpInit, IMPL::MCParticleImpl* mcp); - - private: - // check and set MCP flags - static void setVertexIsNotEndpointOfParentFlag( Trajectory*, IMPL::MCParticleImpl* ); - static void setFinalStatusFlags( Trajectory*, IMPL::MCParticleImpl* ); - static void setCreatedInSimulationFlag( Trajectory*, IMPL::MCParticleImpl* ); - static void setBackscatterFlag( Trajectory*, IMPL::MCParticleImpl* ); - };
+namespace slic { +class Trajectory; + +/** + * @class LcioMcpStatusSetter + * @brief Static utility functions for setting the status of MCParticles + * from associated Trajectory, initial MCParticle, and TrackInformation + * objects. + */ +class LcioMcpStatusSetter { +private: + LcioMcpStatusSetter() { + } + +public: + // set Mcp status codes from trajectory + static IMPL::MCParticleImpl* setMcpStatusCodesFromTrajectory(Trajectory*, IMPL::MCParticleImpl*); + static void setGeneratorStatus(EVENT::MCParticle* mcpInit, IMPL::MCParticleImpl* mcp); + +private: + // check and set MCP flags + static void setVertexIsNotEndpointOfParentFlag(Trajectory*, IMPL::MCParticleImpl*); + static void setFinalStatusFlags(Trajectory*, IMPL::MCParticleImpl*); + static void setCreatedInSimulationFlag(Trajectory*, IMPL::MCParticleImpl*); + static void setBackscatterFlag(Trajectory*, IMPL::MCParticleImpl*); +};
} #endif
diff -u -r1.5 -r1.6 --- LcioMcpUtil.hh 5 Sep 2006 23:21:46 -0000 1.5 +++ LcioMcpUtil.hh 27 Nov 2012 19:32:18 -0000 1.6 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpUtil.hh,v 1.5 2006/09/05 23:21:46 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpUtil.hh,v 1.6 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_LCIOMCPUTIL_HH #define SLIC_LCIOMCPUTIL_HH
@@ -9,27 +9,26 @@
// g4 #include "globals.hh"
-namespace slic -{ - /** - * @class LcioMcpUtil - * @brief Static MCParticle utility functions. - */ - class LcioMcpUtil - { - - private: - LcioMcpUtil() {} - - public: - - // distance computation based on Mcp 3vect positions - static G4double computeMcpDistance(IMPL::MCParticleImpl*, IMPL::MCParticleImpl*); - static G4double computeDistance(const double *v1, const double *v2); - - // Mcp with no parents - static bool isPrimary(IMPL::MCParticleImpl* mcp); - };
+namespace slic { +/** + * @class LcioMcpUtil + * @brief Static MCParticle utility functions. + */ +class LcioMcpUtil { + +private: + LcioMcpUtil() { + } + +public: + + // distance computation based on Mcp 3vect positions + static G4double computeMcpDistance(IMPL::MCParticleImpl*, IMPL::MCParticleImpl*); + static G4double computeDistance(const double *v1, const double *v2); + + // Mcp with no parents + static bool isPrimary(IMPL::MCParticleImpl* mcp); +};
} #endif
diff -u -r1.21 -r1.22 --- LcioMessenger.hh 5 Sep 2006 23:21:46 -0000 1.21 +++ LcioMessenger.hh 27 Nov 2012 19:32:18 -0000 1.22 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMessenger.hh,v 1.21 2006/09/05 23:21:46 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMessenger.hh,v 1.22 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_LCIOMESSENGER_HH #define SLIC_LCIOMESSENGER_HH 1
@@ -11,44 +11,42 @@
class G4UIcmdWithAnInteger; class G4UIdirectory;
-namespace slic -{ - class LcioManager; - - /** - * @class LcioMessenger - * @brief G4UIcommand class for Lcio commands. - */ - class LcioMessenger : public G4UImessenger - { - public: - LcioMessenger(LcioManager* mgr); - virtual ~LcioMessenger(); - - public: - - virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); - - private: - - void defineCommands(); - - private: - - LcioManager* m_mgr; - - G4UIdirectory* m_lcioDir; - G4UIcommand* m_pathCmd; - G4UIcommand* m_filenameCmd; - G4UIcommand* m_verboseCmd; - G4UIcommand* m_setLongFlagCmd; - G4UIcommand* m_setPDGFlagCmd; - G4UIcommand* m_fileExistsActionCmd; - G4UIcommand* m_mcpFilenameCmd; - G4UIcmdWithAnInteger* m_setRunNumberCmd; - G4UIcommand* m_autonameCmd; - G4UIcmdWithABool* m_dumpEventCmd; - };
+namespace slic { +class LcioManager; + +/** + * @class LcioMessenger + * @brief G4UIcommand class for Lcio commands. + */ +class LcioMessenger: public G4UImessenger { +public: + LcioMessenger(LcioManager* mgr); + virtual ~LcioMessenger(); + +public: + + virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); + +private: + + void defineCommands(); + +private: + + LcioManager* m_mgr; + + G4UIdirectory* m_lcioDir; + G4UIcommand* m_pathCmd; + G4UIcommand* m_filenameCmd; + G4UIcommand* m_verboseCmd; + G4UIcommand* m_setLongFlagCmd; + G4UIcommand* m_setPDGFlagCmd; + G4UIcommand* m_fileExistsActionCmd; + G4UIcommand* m_mcpFilenameCmd; + G4UIcmdWithAnInteger* m_setRunNumberCmd; + G4UIcommand* m_autonameCmd; + G4UIcmdWithABool* m_dumpEventCmd; +};
} #endif
diff -u -r1.16 -r1.17 --- LcioPrimaryGenerator.hh 17 Feb 2011 18:26:45 -0000 1.16 +++ LcioPrimaryGenerator.hh 27 Nov 2012 19:32:18 -0000 1.17 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioPrimaryGenerator.hh,v 1.16 2011/02/17 18:26:45 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioPrimaryGenerator.hh,v 1.17 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_LCIOPRIMARYGENERATOR_HH #define SLIC_LCIOPRIMARYGENERATOR_HH
@@ -15,36 +15,34 @@
#include "G4PrimaryVertex.hh" #include "G4Event.hh"
-namespace slic -{
+namespace slic {
- class LcioManager; - class LcioMcpManager;
+class LcioManager; +class LcioMcpManager;
- /** - @class LcioPrimaryGenerator - @brief Generates G4PrimaryParticles from an Lcio MCParticle tree. - */ - class LcioPrimaryGenerator : public Module - { - - public: - typedef std::map<EVENT::MCParticle*, G4PrimaryParticle*> McpToPrimaryMap; - - public: - LcioPrimaryGenerator(LcioManager*); - virtual ~LcioPrimaryGenerator(); - - public: - void generatePrimaryVertexFromMcpCollection( EVENT::LCCollection* mcpVec, G4Event* anEvent ); - - G4PrimaryParticle* createPrimaryParticleFromMcp(IMPL::MCParticleImpl* mcp); - G4PrimaryVertex* createPrimaryVertexFromMcp(IMPL::MCParticleImpl* mcp); - - private: - LcioManager* m_mgr; - LcioMcpManager* m_mcpManager; - };
+/** + @class LcioPrimaryGenerator + @brief Generates G4PrimaryParticles from an Lcio MCParticle tree. + */ +class LcioPrimaryGenerator: public Module { + +public: + typedef std::map<EVENT::MCParticle*, G4PrimaryParticle*> McpToPrimaryMap; + +public: + LcioPrimaryGenerator(LcioManager*); + virtual ~LcioPrimaryGenerator(); + +public: + void generatePrimaryVertexFromMcpCollection(EVENT::LCCollection* mcpVec, G4Event* anEvent); + + G4PrimaryParticle* createPrimaryParticleFromMcp(IMPL::MCParticleImpl* mcp); + G4PrimaryVertex* createPrimaryVertexFromMcp(IMPL::MCParticleImpl* mcp); + +private: + LcioManager* m_mgr; + LcioMcpManager* m_mcpManager; +};
} #endif
diff -u -r1.14 -r1.15 --- LogManager.hh 11 Apr 2008 03:20:19 -0000 1.14 +++ LogManager.hh 27 Nov 2012 19:32:18 -0000 1.15 @@ -14,185 +14,168 @@
#include <vector> #include <map>
-namespace slic -{ - /** - * Manages LogStreams and their associated LogMessenger objects. - * This class "owns" both LogStream and LogMessenger objects, so - * neither of these classes should be deleted outside of this class. - * - * LogManager and LogStream are both friends of each other. - */ - class LogManager : public Singleton<LogManager> - { - - private: - - // LogStream vector. - typedef std::vector<LogStream*> LogList; - - // LogStream vector iterator. - typedef LogList::iterator LogListIterator; - - // LogMessenger vector. - typedef std::vector<LogMessenger*> LogMessengerList; - - // LogMessenger vector iterator. - typedef LogMessengerList::iterator LogMessengerListIterator; - - // Name to LogStream map. - typedef std::map<std::string, LogStream*> LogNameMap; - - // LogMessenger to LogStream map. - typedef std::map<LogStream*, LogMessenger*> LogMessengerMap; - - public: - - LogManager() - { - m_logDir = new G4UIdirectory( "/log/" ); - m_logDir->SetGuidance( "Commands for changing log output settings. [SLIC]" ); - } - - virtual ~LogManager() - { - delete m_logDir; - } - - public: - - /** - * Create a LogStream. - */ - LogStream* createLog( std::string name = "NONE", - LOG::ELevel level = LOG::okay, - ostream* os = &std::cout) - { - LogStream *l = new LogStream( name, level, os ); - m_logs.push_back( l ); - m_logNameMap[ name ] = l; - return l; - } - - /** - * Create a LogStream and associated LogMessenger. - */ - - LogStream* createLogWithMessenger( std::string name = "NONE", - LOG::ELevel level = LOG::okay, - ostream* os = &std::cout) - { - LogStream *l = createLog( name, level, os ); - createLogMessenger( l ); - return l; - } - - /** - * Remove a LogStream and also its LogMessenger, if it exists. - */ - void removeLog( LogStream *log ) - { - if ( log == 0 ) return; - LogListIterator it = findLog( log ); - if ( it != m_logs.end() ) - { - LogStream *l = (*it); - - // Delete the LogStream's messenger, if it exists. - LogMessenger *lm = findLogMessenger( l ); - if ( lm != 0 ) - { - removeLogMessenger( lm ); - } - - // Delete the LogStream object. - delete (*it); - - // Remove the LogStream entry. - m_logs.erase( it ); - } - } - - private: - - /** - * Create a LogMessenger attached to the given LogStream. - */ - LogMessenger* createLogMessenger( LogStream *l ) - { - // Check for and return an existing LogMessenger. - LogMessenger *check = findLogMessenger( l ); - if ( check != 0 ) - { - return check; - } - - // Make a new LogMessenger. - LogMessenger *lm = new LogMessenger( l ); - m_messengers.push_back( lm ); - m_logMessengerMap[ l ] = lm; - return lm; - } - - /** - * Remove a LogMessenger. - */ - void removeLogMessenger( LogMessenger *lm ) - { - if ( lm == 0 ) return; - LogMessengerListIterator it = findLogMessenger( lm ); - if ( it != m_messengers.end() ) - { - delete (*it); - m_messengers.erase( it ); - } - } - - /** - * Find a LogStream pointer by name. - */ - LogStream* findLog( const std::string &name ) - { - return m_logNameMap[ name ]; - } - - /** - * Get position of LogStream by its pointer. - */ - LogListIterator findLog( LogStream *log ) - { - if ( log == 0 ) return m_logs.end(); - return find( m_logs.begin(), m_logs.end(), log ); - } - - /** - * Find position of LogMessenger by its pointer. - */ - LogMessengerListIterator findLogMessenger( LogMessenger *lm ) - { - if ( lm == 0 ) return m_messengers.end(); - return find( m_messengers.begin(), m_messengers.end(), lm ); - } - - /** - * Find a LogMessenger by its associated LogStream. - */ - LogMessenger* findLogMessenger( LogStream *s ) - { - return m_logMessengerMap[ s ]; - } - - friend class LogStream; - - private: - LogList m_logs; - LogMessengerList m_messengers; - LogNameMap m_logNameMap; - LogMessengerMap m_logMessengerMap;
+namespace slic { +/** + * Manages LogStreams and their associated LogMessenger objects. + * This class "owns" both LogStream and LogMessenger objects, so + * neither of these classes should be deleted outside of this class. + * + * LogManager and LogStream are both friends of each other. + */ +class LogManager: public Singleton<LogManager> { + +private: + + // LogStream vector. + typedef std::vector<LogStream*> LogList; + + // LogStream vector iterator. + typedef LogList::iterator LogListIterator; + + // LogMessenger vector. + typedef std::vector<LogMessenger*> LogMessengerList; + + // LogMessenger vector iterator. + typedef LogMessengerList::iterator LogMessengerListIterator; + + // Name to LogStream map. + typedef std::map<std::string, LogStream*> LogNameMap; + + // LogMessenger to LogStream map. + typedef std::map<LogStream*, LogMessenger*> LogMessengerMap; + +public: + + LogManager() { + m_logDir = new G4UIdirectory("/log/"); + m_logDir->SetGuidance("Commands for changing log output settings. [SLIC]"); + } + + virtual ~LogManager() { + delete m_logDir; + } + +public: + + /** + * Create a LogStream. + */ + LogStream* createLog(std::string name = "NONE", LOG::ELevel level = LOG::okay, ostream* os = &std::cout) { + LogStream *l = new LogStream(name, level, os); + m_logs.push_back(l); + m_logNameMap[name] = l; + return l; + } + + /** + * Create a LogStream and associated LogMessenger. + */ + + LogStream* createLogWithMessenger(std::string name = "NONE", LOG::ELevel level = LOG::okay, ostream* os = + &std::cout) { + LogStream *l = createLog(name, level, os); + createLogMessenger(l); + return l; + } + + /** + * Remove a LogStream and also its LogMessenger, if it exists. + */ + void removeLog(LogStream *log) { + if (log == 0) + return; + LogListIterator it = findLog(log); + if (it != m_logs.end()) { + LogStream *l = (*it); + + // Delete the LogStream's messenger, if it exists. + LogMessenger *lm = findLogMessenger(l); + if (lm != 0) { + removeLogMessenger(lm); + } + + // Delete the LogStream object. + delete (*it); + + // Remove the LogStream entry. + m_logs.erase(it); + } + } + +private: + + /** + * Create a LogMessenger attached to the given LogStream. + */ + LogMessenger* createLogMessenger(LogStream *l) { + // Check for and return an existing LogMessenger. + LogMessenger *check = findLogMessenger(l); + if (check != 0) { + return check; + } + + // Make a new LogMessenger. + LogMessenger *lm = new LogMessenger(l); + m_messengers.push_back(lm); + m_logMessengerMap[l] = lm; + return lm; + } + + /** + * Remove a LogMessenger. + */ + void removeLogMessenger(LogMessenger *lm) { + if (lm == 0) + return; + LogMessengerListIterator it = findLogMessenger(lm); + if (it != m_messengers.end()) { + delete (*it); + m_messengers.erase(it); + } + } + + /** + * Find a LogStream pointer by name. + */ + LogStream* findLog(const std::string &name) { + return m_logNameMap[name]; + } + + /** + * Get position of LogStream by its pointer. + */ + LogListIterator findLog(LogStream *log) { + if (log == 0) + return m_logs.end(); + return find(m_logs.begin(), m_logs.end(), log); + } + + /** + * Find position of LogMessenger by its pointer. + */ + LogMessengerListIterator findLogMessenger(LogMessenger *lm) { + if (lm == 0) + return m_messengers.end(); + return find(m_messengers.begin(), m_messengers.end(), lm); + } + + /** + * Find a LogMessenger by its associated LogStream. + */ + LogMessenger* findLogMessenger(LogStream *s) { + return m_logMessengerMap[s]; + } + + friend class LogStream; + +private: + LogList m_logs; + LogMessengerList m_messengers; + LogNameMap m_logNameMap; + LogMessengerMap m_logMessengerMap;
- G4UIdirectory *m_logDir; - };
+ G4UIdirectory *m_logDir; +};
}
-
#endif
diff -u -r1.10 -r1.11 --- LogMessenger.hh 23 May 2007 21:06:50 -0000 1.10 +++ LogMessenger.hh 27 Nov 2012 19:32:18 -0000 1.11 @@ -1,4 +1,4 @@
-// $Id: LogMessenger.hh,v 1.10 2007/05/23 21:06:50 jeremy Exp $
+// $Id: LogMessenger.hh,v 1.11 2012/11/27 19:32:18 jeremy Exp $
#ifndef LOG_MESSENGER_HH #define LOG_MESSENGER_HH 1
@@ -9,29 +9,27 @@
class G4UIcmdWithAnInteger; class G4UIcmdWithAString;
-namespace slic -{ - class LogStream; - - class LogMessenger : public G4UImessenger - { - public: - LogMessenger(LogStream* logstream); - virtual ~LogMessenger(); - - public: - void SetNewValue(G4UIcommand* cmd, G4String newVals); - - private: - void defineCommands(); - - private: - LogStream* m_logStream; - - G4UIcmdWithAnInteger* m_setLevelCmd; - G4UIcmdWithAString* m_fileCmd; - G4UIdirectory* m_loggerDir; - };
+namespace slic { +class LogStream; + +class LogMessenger: public G4UImessenger { +public: + LogMessenger(LogStream* logstream); + virtual ~LogMessenger(); + +public: + void SetNewValue(G4UIcommand* cmd, G4String newVals); + +private: + void defineCommands(); + +private: + LogStream* m_logStream; + + G4UIcmdWithAnInteger* m_setLevelCmd; + G4UIcmdWithAString* m_fileCmd; + G4UIdirectory* m_loggerDir; +};
} #endif
diff -u -r1.5 -r1.6 --- LogStream.hh 11 Apr 2008 03:20:19 -0000 1.5 +++ LogStream.hh 27 Nov 2012 19:32:18 -0000 1.6 @@ -17,400 +17,361 @@
using std::ios; using std::ios_base;
-namespace LOG -{ - enum EManip { - done, - head, - endl - }; - - enum ELevel { - none=0, - always, - fatal, - error, - warning, - okay, - verbose, - debug, - nlevels - };
+namespace LOG { +enum EManip { + done, head, time, level, name, sep, endl +}; + +enum ELevel { + none = 0, always, fatal, error, warning, okay, verbose, debug, nlevels +};
}
-static std::string levelNames[ LOG::nlevels ] = -{ "NONE", "ALWAYS", "FATAL", "ERROR", "WARNING", "OKAY", "VERBOSE", "DEBUG" };
+static std::string levelNames[LOG::nlevels] = { "NONE", "ALWAYS", "FATAL", "ERROR", "WARNING", "OKAY", + "VERBOSE", "DEBUG" };
-namespace slic -{ - /** - * LogStream provides methods for logging messages at a certain level. The - * LogStream has a default level, and if a message's log level is greater - * than the current log level, it is discarded. - * - * The stream operators are overloaded so that the LogStream can be used - * similarly to std::cout. - * - * The manipulator LOG::done should be used to terminate a log message. - * - * Some of the code, particularly the handling of ios manipulators, - * is based on Gaudi's - * <a href="http://isscvs.cern.ch/cgi-bin/cvsweb.cgi/GaudiKernel/GaudiKernel/MsgStream.h?rev=1.41;content-type=text%2Fplain;cvsroot=Gaudi">MsgStream</a> - * class. - */ - class LogStream - { - - protected: - - LogStream( std::string name, - LOG::ELevel level, - ostream* os = &std::cout ) - : m_name( name ), - m_outputLevel( level ), - m_os( os ), - m_active( true ), - m_fos( 0 ) - {;} - - LogStream( ) - : m_name( "NONE" ), - m_outputLevel( LOG::okay ), - m_os ( &std::cout ), - m_active( true ), - m_fos( 0 ) - {;} - - virtual ~LogStream() - {} - - // Give LogManager full access to protected constructors. - friend class LogManager; - - public: - - const std::string& getName() const - { - return m_name; - } - - bool isActive() const - { - return m_active; - } - - LOG::ELevel getOutputLevel() const - { - return m_outputLevel; - } - - ostream& getOutputStream() const - { - return *m_os; - } - - void setOutputLevel( const LOG::ELevel& outputLevel ) - { - m_outputLevel = outputLevel; - } - - /** - * Stream the level of this message. - */ - LogStream& operator << ( const LOG::ELevel& x ) - { - // Subsequent messages will be placed onto the LogStream - // if the argument is less than or equal to the current - // output level. - if ( x <= getOutputLevel() ) { - // Set active state. - m_active = true; - } - else { - // Set inactive state. - m_active = false; - } - return *this; - } - - LogStream& operator << ( const LOG::EManip& x ) - { - if ( isActive() ) { - if ( x == LOG::done ) { - getOutputStream() << std::endl; - } - else if ( x == LOG::head ) { - getOutputStream() << - "[ " << TimeUtil::getAscTime() << " ] :: " << - levelNames[ getOutputLevel() ] << " :: " << - getName() << " :: "; - } - else if ( x == LOG::endl ) { - getOutputStream() << std::endl; - } - } - return *this; - } - - LogStream& operator << ( const std::_Setiosflags &manip ) - { - if ( isActive() ) { - getOutputStream() << manip; - } - return *this; - } - - LogStream& operator << (const std::_Resetiosflags &manip) - { - if ( isActive() ) { - getOutputStream() << manip; - } - return *this; - } - - LogStream& operator << (const std::_Setbase &manip) - { - if ( isActive() ) { - getOutputStream() << manip; - } - return *this; - } - - LogStream& operator << (const std::_Setprecision &manip) - { - if ( isActive() ) { - getOutputStream() << manip; - } - return *this; - } - - LogStream& operator << (const std::_Setw &manip) - { - if ( isActive() ) { - getOutputStream() << manip; - } - return *this; - } - - // Accept ios class modifiers. - LogStream& operator << ( ios& (*manip)(std::ios&) ) - { - if ( isActive() ) { - getOutputStream() << manip; - } - return *this; - } - - // Accept ios base class modifiers - LogStream& operator << ( std::ios_base& (*manip)(std::ios_base&) ) - { - if ( isActive() ) { - getOutputStream() << manip; - } - return *this; - } - - // Templated stream operator. - template <typename T> - LogStream& operator<< ( const T& arg ) - { - if ( isActive() ) { - getOutputStream() << arg; - } - return *this; - } - - // Specialization stream operator for vector<T>. - template <typename T> - LogStream& operator << ( const std::vector<T>& v ) { - if( isActive() ) { - for ( typename std::vector<T>::const_iterator i = v.begin(); - i != v.end(); ++i ) { getOutputStream() << *i << " "; } - } - return *this; - } - - // std::ios emulation - int width() const - { - return isActive() ? getOutputStream().width() : 0; - } - - int width( int v ) - { - return isActive() ? getOutputStream().width(v) : 0; - } - - - long flags() const - { - return isActive() ? getOutputStream().flags() : 0; - } - - long flags( std::ios_base::fmtflags v ) - { - return isActive() ? getOutputStream().flags(v) : 0; - } - - long setf( std::ios_base::fmtflags v ) - { - return isActive() ? getOutputStream().setf(v) : 0; - } - - char fill() const - { - return isActive() ? getOutputStream().fill() : -1; - } - - char fill(char v) - { - return isActive() ? getOutputStream().fill(v) : -1; - } - - int precision() const - { - return isActive() ? getOutputStream().precision(): 0; - } - - int precision(int v) - { - return isActive() ? getOutputStream().precision(v): 0; - } - - int rdstate() const - { - return isActive() ? getOutputStream().rdstate () : std::ios_base::failbit; - } - - int good() const - { - return isActive() ? getOutputStream().good () : 0; - } - - int eof() const - { - return isActive() ? getOutputStream().eof () : 0; - } - - int bad() const - { - return isActive() ? getOutputStream().bad() : 0; - } - - long setf( std::ios_base::fmtflags _f, std::ios_base::fmtflags _m ) - { - return isActive() ? getOutputStream().setf(_f, _m) : 0; - } - - void unsetf( std::ios_base::fmtflags _l ) - { - if ( isActive() ) { - getOutputStream().unsetf(_l); - } - } - - void clear( std::ios_base::iostate _i = std::ios_base::failbit ) - { - if ( isActive() ) { - getOutputStream().clear(_i); - } - } - - // Redirect to a file. - void setOutputFile(const std::string& file) - { - ofstream* m_fos = new ofstream(); - m_fos->open( file.c_str(), ios::app | ios::out ); - m_os = m_fos; - } - - LogStream& debug() - { - return *this << LOG::debug; - } - - LogStream& verbose() - { - return *this << LOG::verbose; - } - - LogStream& okay() - { - return *this << LOG::okay; - } - - LogStream& warning() - { - return *this << LOG::warning; - } - - LogStream& error() - { - return *this << LOG::error; - } - - LogStream& fatal() - { - return *this << LOG::fatal; - } - - LogStream& always() - { - return *this << LOG::always; - } - - void log( const std::string& mesg, const LOG::ELevel& level ) - { - (*this) << level << mesg << LOG::done; - } - - void log( const std::string& mesg ) - { - log( mesg, getOutputLevel() ); - } - - void debug( const std::string& mesg ) - { - log( mesg, LOG::debug ); - } - - void verbose( const std::string& mesg ) - { - log( mesg, LOG::verbose ); - } - - void okay( const std::string& mesg ) - { - log( mesg, LOG::okay ); - } - - void warning( const std::string& mesg ) - { - log( mesg, LOG::warning ); - } - - void error( const std::string& mesg ) - { - log( mesg, LOG::error ); - } - - void fatal( const std::string& mesg ) - { - log( mesg, LOG::fatal ); - } - - void always( const std::string& mesg ) - { - log( mesg, LOG::always ); - } - - private: - std::string m_name; - LOG::ELevel m_outputLevel; - ostream* m_os; - bool m_active; - std::ofstream* m_fos; - };
+namespace slic { + +/** + * LogStream provides methods for logging messages at a certain level. The + * LogStream has a default level, and if a message's log level is greater + * than the current log level, it is discarded. + * + * The stream operators are overloaded so that the LogStream can be used + * similarly to std::cout. + * + * The manipulator LOG::done should be used to terminate a log message. + * + * Some of the code, particularly the handling of ios manipulators, + * is based on Gaudi's + * <a href="http://isscvs.cern.ch/cgi-bin/cvsweb.cgi/GaudiKernel/GaudiKernel/MsgStream.h?rev=1.41;content-type=text%2Fplain;cvsroot=Gaudi">MsgStream</a> + * class. + */ +class LogStream { + +protected: + + LogStream(std::string name, LOG::ELevel level, ostream* os = &std::cout) : + m_name(name), m_outputLevel(level), m_currentMessageLevel(LOG::okay), m_os(os), m_active(true), m_fos( + 0) { + ; + } + + LogStream() : + m_name("NONE"), m_outputLevel(LOG::okay), m_currentMessageLevel(LOG::okay), m_os(&std::cout), m_active( + true), m_fos(0) { + ; + } + + virtual ~LogStream() { + } + + // Give LogManager full access to protected constructors. + friend class LogManager; + +public: + + const std::string& getName() const { + return m_name; + } + + bool isActive() const { + return m_active; + } + + LOG::ELevel getOutputLevel() const { + return m_outputLevel; + } + + ostream& getOutputStream() const { + return *m_os; + } + + void setOutputLevel(const LOG::ELevel& outputLevel) { + m_outputLevel = outputLevel; + } + + LOG::ELevel getCurrentLevel() const { + return m_currentMessageLevel; + } + + void setCurrentLevel(LOG::ELevel level) { + m_currentMessageLevel = level; + } + + /** + * Set the log level via streamer. Subsequent messages will be placed onto the LogStream if + * the argument is less than or equal to the current output level. Otherwise they will be + * discarded. + */ + LogStream& operator <<(const LOG::ELevel& x) { + setCurrentLevel(x); + if (getCurrentLevel() <= getOutputLevel()) { + // Set active state. + setActive(true); + } else { + // Set inactive state. + setActive(false); + } + return *this; + } + + LogStream& operator <<(const LOG::EManip& x) { + if (isActive()) { + // End of message. + if (x == LOG::done) { + getOutputStream() << std::endl; + // Print full header info. + } else if (x == LOG::head) { + getOutputStream() << TimeUtil::getAscTime() << " :: " << levelNames[m_currentMessageLevel] + << " :: " << getName() << " :: "; + // Print current time. + } else if (x == LOG::time) { + getOutputStream() << TimeUtil::getAscTime(); + // Print current message level. + } else if (x == LOG::level) { + getOutputStream() << levelNames[m_currentMessageLevel]; + // Print logger name. + } else if (x == LOG::name) { + getOutputStream() << getName(); + } else if (x == LOG::sep) { + getOutputStream() << " :: "; + // Print end of line terminator. + } else if (x == LOG::endl) { + getOutputStream() << std::endl; + } + } + return *this; + } + + // Redirect to a file. + void setOutputFile(const std::string& file) { + ofstream* m_fos = new ofstream(); + m_fos->open(file.c_str(), ios::app | ios::out); + m_os = m_fos; + } + + LogStream& debug() { + return *this << LOG::debug; + } + + LogStream& verbose() { + return *this << LOG::verbose; + } + + LogStream& okay() { + return *this << LOG::okay; + } + + LogStream& warning() { + return *this << LOG::warning; + } + + LogStream& error() { + return *this << LOG::error; + } + + LogStream& fatal() { + return *this << LOG::fatal; + } + + LogStream& always() { + return *this << LOG::always; + } + + void log(const std::string& mesg, const LOG::ELevel& level) { + (*this) << level << mesg << LOG::done; + } + + void log(const std::string& mesg) { + log(mesg, getOutputLevel()); + } + + void debug(const std::string& mesg) { + log(mesg, LOG::debug); + } + + void verbose(const std::string& mesg) { + log(mesg, LOG::verbose); + } + + void okay(const std::string& mesg) { + log(mesg, LOG::okay); + } + + void warning(const std::string& mesg) { + log(mesg, LOG::warning); + } + + void error(const std::string& mesg) { + log(mesg, LOG::error); + } + + void fatal(const std::string& mesg) { + log(mesg, LOG::fatal); + } + + void always(const std::string& mesg) { + log(mesg, LOG::always); + } + + LogStream& operator <<(const std::_Setiosflags &manip) { + if (isActive()) { + getOutputStream() << manip; + } + return *this; + } + + LogStream& operator <<(const std::_Resetiosflags &manip) { + if (isActive()) { + getOutputStream() << manip; + } + return *this; + } + + LogStream& operator <<(const std::_Setbase &manip) { + if (isActive()) { + getOutputStream() << manip; + } + return *this; + } + + LogStream& operator <<(const std::_Setprecision &manip) { + if (isActive()) { + getOutputStream() << manip; + } + return *this; + } + + LogStream& operator <<(const std::_Setw &manip) { + if (isActive()) { + getOutputStream() << manip; + } + return *this; + } + + // Accept ios class modifiers. + LogStream& operator <<(ios& (*manip)(std::ios&)) { + if (isActive()) { + getOutputStream() << manip; + } + return *this; + } + + // Accept ios base class modifiers + LogStream& operator <<(std::ios_base& (*manip)(std::ios_base&)) { + if (isActive()) { + getOutputStream() << manip; + } + return *this; + } + + // Templated stream operator. + template<typename T> + LogStream& operator<<(const T& arg) { + if (isActive()) { + getOutputStream() << arg; + } + return *this; + } + + // Specialization stream operator for vector<T>. + template<typename T> + LogStream& operator <<(const std::vector<T>& v) { + if (isActive()) { + for (typename std::vector<T>::const_iterator i = v.begin(); i != v.end(); ++i) { + getOutputStream() << *i << " "; + } + } + return *this; + } + + // + // Following are a bunch of methods for std::ios emulation. + // + + int width() const { + return isActive() ? getOutputStream().width() : 0; + } + + int width(int v) { + return isActive() ? getOutputStream().width(v) : 0; + } + + long flags() const { + return isActive() ? getOutputStream().flags() : 0; + } + + long flags(std::ios_base::fmtflags v) { + return isActive() ? getOutputStream().flags(v) : 0; + } + + long setf(std::ios_base::fmtflags v) { + return isActive() ? getOutputStream().setf(v) : 0; + } + + char fill() const { + return isActive() ? getOutputStream().fill() : -1; + } + + char fill(char v) { + return isActive() ? getOutputStream().fill(v) : -1; + } + + int precision() const { + return isActive() ? getOutputStream().precision() : 0; + } + + int precision(int v) { + return isActive() ? getOutputStream().precision(v) : 0; + } + + int rdstate() const { + return isActive() ? getOutputStream().rdstate() : std::ios_base::failbit; + } + + int good() const { + return isActive() ? getOutputStream().good() : 0; + } + + int eof() const { + return isActive() ? getOutputStream().eof() : 0; + } + + int bad() const { + return isActive() ? getOutputStream().bad() : 0; + } + + long setf(std::ios_base::fmtflags _f, std::ios_base::fmtflags _m) { + return isActive() ? getOutputStream().setf(_f, _m) : 0; + } + + void unsetf(std::ios_base::fmtflags _l) { + if (isActive()) { + getOutputStream().unsetf(_l); + } + } + + void clear(std::ios_base::iostate _i = std::ios_base::failbit) { + if (isActive()) { + getOutputStream().clear(_i); + } + } + +private: + + void setActive(bool active) { + m_active = active; + } + +private: + std::string m_name; + LOG::ELevel m_outputLevel; + LOG::ELevel m_currentMessageLevel; + ostream* m_os; + bool m_active; + std::ofstream* m_fos; +};
} #endif
diff -u -r1.11 -r1.12 --- Module.hh 31 Jan 2012 18:52:30 -0000 1.11 +++ Module.hh 27 Nov 2012 19:32:18 -0000 1.12 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/Module.hh,v 1.11 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/Module.hh,v 1.12 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_MODULE_HH #define SLIC_MODULE_HH 1
@@ -17,106 +17,106 @@
class G4Step; class G4Track;
-namespace slic -{ - /** - * @class Module - * @brief Base class for slic code modules that provides common functionality, - * such as logging to an output stream. - */ - class Module - { - public: - enum ModuleStatus { - eOkay = 0, - eNotInitialized = 1, - eBadState = 2, - eFatalError = 3 - }; - - protected: - - /** - * Only concrete Module subclasses can access the constructor. - */ - Module( const std::string& name, - bool deleteOnExit = true, - bool autoRegister = true); - - public: - virtual ~Module(); - - public: - - const std::string& getName() const - { - return m_name; - } - - ModuleStatus getStatus() const - { - return m_status; - } - - virtual void initialize() - {;} - - virtual void reset() - {;} - - virtual void cleanup() - {;} - - bool deleteOnExit() - { - return m_deleteOnExit; - } - - LogStream& log() - { - return *m_log; - } - - virtual void beginEvent( const G4Event* ) - {;} - - virtual void endEvent( const G4Event* ) - {;} - - virtual void beginRun( const G4Run* ) - {;} - - virtual void endRun( const G4Run* ) - {;} - - virtual void preTracking( const G4Track* ) - {;} - - virtual void postTracking( const G4Track* ) - {;} - - virtual void stepping( const G4Step* ) - {;} - - G4ClassificationOfNewTrack stackingClassifyNewTrack( const G4Track* ) - { - G4Exception("", "", FatalException, "This method should be overridden."); - // Arbitrary return value. Will never reach here. - return fWaiting; - } - - void stackingNewStage() - {;} - - void stackingPrepareNewEvent() - {;} - - public: - ModuleStatus m_status; - std::string m_name; - LogStream* m_log; - bool m_deleteOnExit; - };
+namespace slic { +/** + * @class Module + * @brief Base class for slic code modules that provides common functionality, + * such as logging to an output stream. + */ +class Module { +public: + enum ModuleStatus { + eOkay = 0, eNotInitialized = 1, eBadState = 2, eFatalError = 3 + }; + +protected: + + /** + * Only concrete Module subclasses can access the constructor. + */ + Module(const std::string& name, bool deleteOnExit = true, bool autoRegister = true); + +public: + virtual ~Module(); + +public: + + const std::string& getName() const { + return m_name; + } + + ModuleStatus getStatus() const { + return m_status; + } + + virtual void initialize() { + ; + } + + virtual void reset() { + ; + } + + virtual void cleanup() { + ; + } + + bool deleteOnExit() { + return m_deleteOnExit; + } + + LogStream& log() { + return *m_log; + } + + virtual void beginEvent(const G4Event*) { + ; + } + + virtual void endEvent(const G4Event*) { + ; + } + + virtual void beginRun(const G4Run*) { + ; + } + + virtual void endRun(const G4Run*) { + ; + } + + virtual void preTracking(const G4Track*) { + ; + } + + virtual void postTracking(const G4Track*) { + ; + } + + virtual void stepping(const G4Step*) { + ; + } + + G4ClassificationOfNewTrack stackingClassifyNewTrack(const G4Track*) { + G4Exception("", "", FatalException, "This method should be overridden."); + // Arbitrary return value. Will never reach here. + return fWaiting; + } + + void stackingNewStage() { + ; + } + + void stackingPrepareNewEvent() { + ; + } + +public: + ModuleStatus m_status; + std::string m_name; + LogStream* m_log; + bool m_deleteOnExit; +};
} #endif
diff -u -r1.6 -r1.7 --- ModuleRegistry.hh 27 Apr 2007 01:54:32 -0000 1.6 +++ ModuleRegistry.hh 27 Nov 2012 19:32:18 -0000 1.7 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/ModuleRegistry.hh,v 1.6 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/ModuleRegistry.hh,v 1.7 2012/11/27 19:32:18 jeremy Exp $
// std #include <map>
@@ -8,39 +8,35 @@
#include "Module.hh" #include "Singleton.hh"
-namespace slic -{ - /** - * @class ModuleRegistry - * @brief A central store for classes inheriting from Module. - */ - class ModuleRegistry : - public Singleton<ModuleRegistry>, - public Module - { - public: - typedef std::map<std::string, Module*> ModuleMap; - - public: - virtual ~ModuleRegistry(); - ModuleRegistry(); - - public: - - void registerModule(Module*); - Module* findModule(const std::string&); - - void deregisterModule(Module* module); - void deregisterModule(const std::string& name); - - /** - * Print the list of registered modules to the log. - */ - void print(); - - void deleteModules(); - - private: - ModuleMap m_modules; - };
+namespace slic { +/** + * @class ModuleRegistry + * @brief A central store for classes inheriting from Module. + */ +class ModuleRegistry: public Singleton<ModuleRegistry>, public Module { +public: + typedef std::map<std::string, Module*> ModuleMap; + +public: + virtual ~ModuleRegistry(); + ModuleRegistry(); + +public: + + void registerModule(Module*); + Module* findModule(const std::string&); + + void deregisterModule(Module* module); + void deregisterModule(const std::string& name); + + /** + * Print the list of registered modules to the log. + */ + void print(); + + void deleteModules(); + +private: + ModuleMap m_modules; +};
}
diff -u -r1.7 -r1.8 --- ParticleGunEventSource.hh 27 Apr 2007 01:54:32 -0000 1.7 +++ ParticleGunEventSource.hh 27 Nov 2012 19:32:18 -0000 1.8 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/ParticleGunEventSource.hh,v 1.7 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/ParticleGunEventSource.hh,v 1.8 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_PARTICLEGUNEVENTSOURCE_HH #define SLIC_PARTICLEGUNEVENTSOURCE_HH 1
@@ -9,27 +9,25 @@
// geant4 #include "G4ParticleGun.hh"
-namespace slic -{ - /** - * @class ParticleGunEventSource - * @brief Wrapper for the Geant4 particle gun. - */ - class ParticleGunEventSource : public EventSource - { - public: - ParticleGunEventSource(); - virtual ~ParticleGunEventSource(); - - public: - virtual void generate(G4Event* evt); - void dumpCurrentEvent(); - - G4ParticleGun* getParticleGun(); - - private: - G4ParticleGun* m_generator; - };
+namespace slic { +/** + * @class ParticleGunEventSource + * @brief Wrapper for the Geant4 particle gun. + */ +class ParticleGunEventSource: public EventSource { +public: + ParticleGunEventSource(); + virtual ~ParticleGunEventSource(); + +public: + virtual void generate(G4Event* evt); + void dumpCurrentEvent(); + + G4ParticleGun* getParticleGun(); + +private: + G4ParticleGun* m_generator; +};
} #endif
diff -u -r1.1 -r1.2 --- PhysicsListBuilder.hh 18 Dec 2006 23:04:28 -0000 1.1 +++ PhysicsListBuilder.hh 27 Nov 2012 19:32:18 -0000 1.2 @@ -3,69 +3,62 @@
#include "G4VUserPhysicsList.hh"
-namespace slic -{
+namespace slic {
- /** - * Abstract class for building a single physics list such as LHEP or LCPhys. - */ - class VPhysicsListBuilder - { - - public: - VPhysicsListBuilder( const G4String& name, - const G4String& description) - : m_name( name ), - m_description( description ) - {} - - virtual ~VPhysicsListBuilder() - {;} - - public: - - const G4String& getName() - { - return m_name; - } - - const G4String& getDescription() - { - return m_description; - } - - virtual G4VUserPhysicsList* create() const = 0; - - private: - - G4String m_name; - G4String m_description; - - }; - - /** - * Templated VPhysicsListBuilder for returning a concrete - * physics list object, such as LHEP or LCPhys. - */ - template < class T > - class TPhysicsListBuilder : public VPhysicsListBuilder - { - public: - TPhysicsListBuilder( const G4String& name, - const G4String& description ) - : VPhysicsListBuilder( name, description ) - {} - - virtual ~TPhysicsListBuilder() - {;} - - public: - - virtual G4VUserPhysicsList* create() const - { - return new T(); - } - };
+/** + * Abstract class for building a single physics list such as LHEP or LCPhys. + */ +class VPhysicsListBuilder { + +public: + VPhysicsListBuilder(const G4String& name, const G4String& description) : + m_name(name), m_description(description) { + } + + virtual ~VPhysicsListBuilder() { + ; + } + +public: + + const G4String& getName() { + return m_name; + } + + const G4String& getDescription() { + return m_description; + } + + virtual G4VUserPhysicsList* create() const = 0; + +private: + + G4String m_name; + G4String m_description; + +}; + +/** + * Templated VPhysicsListBuilder for returning a concrete + * physics list object, such as LHEP or LCPhys. + */ +template<class T> +class TPhysicsListBuilder: public VPhysicsListBuilder { +public: + TPhysicsListBuilder(const G4String& name, const G4String& description) : + VPhysicsListBuilder(name, description) { + } + + virtual ~TPhysicsListBuilder() { + ; + } + +public: + + virtual G4VUserPhysicsList* create() const { + return new T(); + } +};
} // namespace slic #endif
diff -u -r1.15 -r1.16 --- PhysicsListFactory.hh 3 Jan 2011 18:22:53 -0000 1.15 +++ PhysicsListFactory.hh 27 Nov 2012 19:32:18 -0000 1.16 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/PhysicsListFactory.hh,v 1.15 2011/01/03 18:22:53 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/PhysicsListFactory.hh,v 1.16 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_PHYSICSLISTFACTORY_HH #define SLIC_PHYSICSLISTFACTORY_HH 1
@@ -12,65 +12,63 @@
// geant4 #include "G4VUserPhysicsList.hh"
-namespace slic -{
+namespace slic {
- class VPhysicsListBuilder;
+class VPhysicsListBuilder;
- /** - * @class PhysicsListFactory - * - * Factory to instantiate a Geant4 physics list from the name. - * - * Each available list has a header in - * - * $G4INSTALL/source/physics_lists/lists/include - * - * This version of slic uses the Physics Lists defined in the Geant4 9.4 release. - */ - class PhysicsListFactory : public Singleton<PhysicsListFactory>, public Module - { - - public: - PhysicsListFactory(); - - virtual ~PhysicsListFactory(); - - public: - - /** - * Map of list names to builders. - */ - typedef std::map<G4String, VPhysicsListBuilder*> BuilderMap; - - public: - - /** - * Initialize a TPhysicsListBuilder for each supported physics list. - */ - void initializeBuilders(); - - /** - * Add a builder that can instantiate a physics list. - * @param The VPhysicsListBuilder to add to the PhysicsListFactory . - */ - void addBuilder( VPhysicsListBuilder* ); - - /** - * @param name The name of the physics list to instantiate. - * @return A G4VUserPhysicsList with a concrete type of @param name, such as LHEP. - */ - G4VUserPhysicsList* create( const std::string& name ); - - /** - * Print the available lists with their descriptions to the log. - */ - void printAvailableLists();
+/** + * @class PhysicsListFactory + * + * Factory to instantiate a Geant4 physics list from the name. + * + * Each available list has a header in + * + * $G4INSTALL/source/physics_lists/lists/include + * + * This version of slic uses the Physics Lists defined in the Geant4 9.4 release. + */ +class PhysicsListFactory: public Singleton<PhysicsListFactory>, public Module { + +public: + PhysicsListFactory(); + + virtual ~PhysicsListFactory(); + +public: + + /** + * Map of list names to builders. + */ + typedef std::map<G4String, VPhysicsListBuilder*> BuilderMap; + +public: + + /** + * Initialize a TPhysicsListBuilder for each supported physics list. + */ + void initializeBuilders(); + + /** + * Add a builder that can instantiate a physics list. + * @param The VPhysicsListBuilder to add to the PhysicsListFactory . + */ + void addBuilder(VPhysicsListBuilder*); + + /** + * @param name The name of the physics list to instantiate. + * @return A G4VUserPhysicsList with a concrete type of @param name, such as LHEP. + */ + G4VUserPhysicsList* create(const std::string& name); + + /** + * Print the available lists with their descriptions to the log. + */ + void printAvailableLists();
- private:
+private:
- BuilderMap m_builders; - };
+ BuilderMap m_builders; +};
} #endif
diff -u -r1.21 -r1.22 --- PhysicsListManager.hh 8 Jan 2010 23:58:12 -0000 1.21 +++ PhysicsListManager.hh 27 Nov 2012 19:32:18 -0000 1.22 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/PhysicsListManager.hh,v 1.21 2010/01/08 23:58:12 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/PhysicsListManager.hh,v 1.22 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_PHYSICSLISTMANAGER_HH #define SLIC_PHYSICSLISTMANAGER_HH 1
@@ -21,90 +21,82 @@
class G4PhysListFactory;
-namespace slic -{
+namespace slic {
- /** - * @class PhysicsListManager - * @brief Provides management of user physics lists. - * @note Current, primary function is selection of a list and . - * setting the default, which is LCPhys. - */
+/** + * @class PhysicsListManager + * @brief Provides management of user physics lists. + * @note Current, primary function is selection of a list and . + * setting the default, which is LCPhys. + */
- class PhysicsListManager : public Module, public Singleton<PhysicsListManager> - {
+class PhysicsListManager: public Module, public Singleton<PhysicsListManager> {
- public:
+public:
- PhysicsListManager();
+ PhysicsListManager();
- virtual ~PhysicsListManager();
+ virtual ~PhysicsListManager();
- public:
+public:
- void initializePhysicsList();
+ void initializePhysicsList();
- void setCurrentListName( const std::string& n );
+ void setCurrentListName(const std::string& n);
- inline const std::string& getCurrentListName() - { - return m_currentListName; - }
+ inline const std::string& getCurrentListName() { + return m_currentListName; + }
- inline bool isInitialized() - { - return m_isInitialized; - }
+ inline bool isInitialized() { + return m_isInitialized; + }
- inline void enableLimits(bool l) - { - m_enableLimits = l; - }
+ inline void enableLimits(bool l) { + m_enableLimits = l; + }
- inline bool enableLimits() - { - return m_enableLimits; - }
+ inline bool enableLimits() { + return m_enableLimits; + }
- inline bool enableOptical() - { - return m_enableOptical; - }
+ inline bool enableOptical() { + return m_enableOptical; + }
- inline void enableOptical(bool b) - { - m_enableOptical = b; - }
+ inline void enableOptical(bool b) { + m_enableOptical = b; + }
- // Needs to be public for the RunManager to call it. - void setupUserLimitsProcesses();
+ // Needs to be public for the RunManager to call it. + void setupUserLimitsProcesses();
- void printAvailablePhysicsLists();
+ void printAvailablePhysicsLists();
- private:
+private:
- void setupOpticalProcesses();
+ void setupOpticalProcesses();
- void setupSUSY();
+ void setupSUSY();
- void setupExtended();
+ void setupExtended();
- private:
+private:
- G4VUserPhysicsList* m_currentList; - bool m_isInitialized; - bool m_isFromDefault; - bool m_enableLimits; - bool m_setupLimits; - bool m_enableOptical;
+ G4VUserPhysicsList* m_currentList; + bool m_isInitialized; + bool m_isFromDefault; + bool m_enableLimits; + bool m_setupLimits; + bool m_enableOptical;
- PhysicsMessenger* m_messenger;
+ PhysicsMessenger* m_messenger;
- std::string m_currentListName; - static const std::string m_defaultListName;
+ std::string m_currentListName; + static const std::string m_defaultListName;
- G4PhysListFactory *m_factory; - };
+ G4PhysListFactory *m_factory; +};
} #endif
diff -u -r1.12 -r1.13 --- PhysicsMessenger.hh 11 Apr 2008 03:20:19 -0000 1.12 +++ PhysicsMessenger.hh 27 Nov 2012 19:32:18 -0000 1.13 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/PhysicsMessenger.hh,v 1.12 2008/04/11 03:20:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/PhysicsMessenger.hh,v 1.13 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_PHYSICSMESSENGER_HH #define SLIC_PHYSICSMESSENGER_HH 1
@@ -10,37 +10,35 @@
class G4UIcmdWithoutParameter; class G4UIdirectory;
-namespace slic -{
+namespace slic {
- /** - @class PhysicsMessenger - @brief G4UImessenger for selection of physics list at runtime. - Also handles data for the HepPDT interface. - */ - class PhysicsMessenger : public G4UImessenger - { - public: - PhysicsMessenger(); - virtual ~PhysicsMessenger(); - - public: - - virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); - - private: - void defineCommands(); - - private: - - G4UIdirectory* m_physicsListDir; - - G4UIcommand* m_selectCmd; - G4UIcmdWithoutParameter* m_printListsCmd; - G4UIcmdWithoutParameter* m_printCurrentCmd; - G4UIcmdWithABool* m_enableOpticalCmd; - G4UIcommand* m_pdgCmd; - };
+/** + @class PhysicsMessenger + @brief G4UImessenger for selection of physics list at runtime. + Also handles data for the HepPDT interface. + */ +class PhysicsMessenger: public G4UImessenger { +public: + PhysicsMessenger(); + virtual ~PhysicsMessenger(); + +public: + + virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); + +private: + void defineCommands(); + +private: + + G4UIdirectory* m_physicsListDir; + + G4UIcommand* m_selectCmd; + G4UIcmdWithoutParameter* m_printListsCmd; + G4UIcmdWithoutParameter* m_printCurrentCmd; + G4UIcmdWithABool* m_enableOpticalCmd; + G4UIcommand* m_pdgCmd; +};
} #endif
diff -u -r1.23 -r1.24 --- PrimaryGeneratorAction.hh 4 Jul 2012 01:01:47 -0000 1.23 +++ PrimaryGeneratorAction.hh 27 Nov 2012 19:32:18 -0000 1.24 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/PrimaryGeneratorAction.hh,v 1.23 2012/07/04 01:01:47 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/PrimaryGeneratorAction.hh,v 1.24 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_PRIMARYGENERATORACTION_HH #define SLIC_PRIMARYGENERATORACTION_HH 1
@@ -12,42 +12,40 @@
#include "G4ParticleGun.hh" #include "G4RunManager.hh"
-namespace slic -{
+namespace slic {
- /** - @class PrimaryGeneratorAction - @brief Implementation of G4VUserPrimaryGeneratorAction. - @note Delegates all control to EventSourceManager. - */ - class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction, public Module - { - - public: - PrimaryGeneratorAction(); - virtual ~PrimaryGeneratorAction(); - - public: - virtual void GeneratePrimaries(G4Event *anEvent); - - /** - * Apply Lorentz transformation to event. The lorentz transformation - * is retrieved from the singleton EventSourceManager. - * @param[in] anEvent The current Geant4 event. - */ - void applyLorentzTransformation(G4Event *anEvent); - - /** - * Apply Z smearing to event. The Z spread parameter is retrieved - * from the singleton EventSourceManager. - * @param[in] anEvent The current Geant4 event. - */ - void zsmear(G4Event* anEvent);
+/** + @class PrimaryGeneratorAction + @brief Implementation of G4VUserPrimaryGeneratorAction. + @note Delegates all control to EventSourceManager. + */ +class PrimaryGeneratorAction: public G4VUserPrimaryGeneratorAction, public Module { + +public: + PrimaryGeneratorAction(); + virtual ~PrimaryGeneratorAction(); + +public: + virtual void GeneratePrimaries(G4Event *anEvent); + + /** + * Apply Lorentz transformation to event. The lorentz transformation + * is retrieved from the singleton EventSourceManager. + * @param[in] anEvent The current Geant4 event. + */ + void applyLorentzTransformation(G4Event *anEvent); + + /** + * Apply Z smearing to event. The Z spread parameter is retrieved + * from the singleton EventSourceManager. + * @param[in] anEvent The current Geant4 event. + */ + void zsmear(G4Event* anEvent);
- private:
+private:
- void printBeginEventMessage(G4Event* anEvent); - };
+ void printBeginEventMessage(G4Event* anEvent); +};
} #endif
diff -u -r1.12 -r1.13 --- RunAction.hh 27 Apr 2007 01:54:32 -0000 1.12 +++ RunAction.hh 27 Nov 2012 19:32:18 -0000 1.13 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/RunAction.hh,v 1.12 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/RunAction.hh,v 1.13 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_RUNACTION_HH #define SLIC_RUNACTION_HH 1
@@ -10,35 +10,33 @@
#include "G4UserRunAction.hh" #include "G4Timer.hh"
-namespace slic -{
+namespace slic {
- /** - * @class RunAction - * @brief Implementation of G4UserRunAction. - */ - - class RunAction : public G4UserRunAction, public Module - { - public: - RunAction(); - ~RunAction(); - - public: - virtual void BeginOfRunAction (const G4Run *aRun); - virtual void EndOfRunAction (const G4Run *aRun); - - private: - void startRunTimer(); - void stopRunTimer();
+/** + * @class RunAction + * @brief Implementation of G4UserRunAction. + */
- void printBeginOfRunMessage( const G4Run *aRun ); - void printEndOfRunMessage( const G4Run *aRun );
+class RunAction: public G4UserRunAction, public Module { +public: + RunAction(); + ~RunAction();
- private:
+public: + virtual void BeginOfRunAction(const G4Run *aRun); + virtual void EndOfRunAction(const G4Run *aRun);
- G4Timer m_runTimer; - };
+private: + void startRunTimer(); + void stopRunTimer(); + + void printBeginOfRunMessage(const G4Run *aRun); + void printEndOfRunMessage(const G4Run *aRun); + +private: + + G4Timer m_runTimer; +};
} #endif
diff -u -r1.14 -r1.15 --- RunManager.hh 2 Aug 2012 23:05:38 -0000 1.14 +++ RunManager.hh 27 Nov 2012 19:32:18 -0000 1.15 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/RunManager.hh,v 1.14 2012/08/02 23:05:38 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/RunManager.hh,v 1.15 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_RUNMANAGER_HH #define SLIC_RUNMANAGER_HH 1
@@ -7,51 +7,49 @@
#include "Module.hh"
-namespace slic -{ - /** - * @class RunManager - * @brief Extension of G4RunManager. - * @note Current, primary function is to initialize the default - * physics list setup using PhysicsListManager. - */ - class RunManager : public G4RunManager, public Module - { - public: - RunManager(); - virtual ~RunManager(); - - public: - - static RunManager* instance() - { - return dynamic_cast<RunManager*>(G4RunManager::GetRunManager()); - } - - void abortRun() { - //std::cout << "RunManager.abortRun - run will be aborted!!!" << std::endl; - m_abortRun = true; - } - - void Initialize(); - int getNumberOfEventsToRun(); - bool isRunAborted(); - - protected: - - void BeamOn(G4int n_event, const char* macroFile=0, G4int n_select=-1); - void InitializePhysics(); - void InitializeGeometry(); - - private: - void initializeUserActions(); - - private: - - bool m_userActionsInitialized; - int m_numberOfEventsToRun; - bool m_abortRun; - };
+namespace slic { +/** + * @class RunManager + * @brief Extension of G4RunManager. + * @note Current, primary function is to initialize the default + * physics list setup using PhysicsListManager. + */ +class RunManager: public G4RunManager, public Module { +public: + RunManager(); + virtual ~RunManager(); + +public: + + static RunManager* instance() { + return dynamic_cast<RunManager*>(G4RunManager::GetRunManager()); + } + + void abortRun() { + //std::cout << "RunManager.abortRun - run will be aborted!!!" << std::endl; + m_abortRun = true; + } + + void Initialize(); + int getNumberOfEventsToRun(); + bool isRunAborted(); + +protected: + + void BeamOn(G4int n_event, const char* macroFile = 0, G4int n_select = -1); + void DoEventLoop(G4int, const char*, G4int); + void InitializePhysics(); + void InitializeGeometry(); + +private: + void initializeUserActions(); + +private: + + bool m_userActionsInitialized; + int m_numberOfEventsToRun; + bool m_abortRun; +};
} #endif
diff -u -r1.3 -r1.4 --- Singleton.hh 27 Apr 2007 01:54:32 -0000 1.3 +++ Singleton.hh 27 Nov 2012 19:32:18 -0000 1.4 @@ -1,48 +1,45 @@
-// $Id: Singleton.hh,v 1.3 2007/04/27 01:54:32 jeremy Exp $
+// $Id: Singleton.hh,v 1.4 2012/11/27 19:32:18 jeremy Exp $
#ifndef LCDD_SINGLETON_HH #define LCDD_SINGLETON_HH 1 template<class T>
-class Singleton -{
+class Singleton {
public:
- static T* instance(); - void release(); - - Singleton(); - ~Singleton(); -
+ static T* instance(); + void release(); + + Singleton(); + ~Singleton(); +
private:
- static T* m_singleton;
+ static T* m_singleton;
}; template<class T> T* Singleton<T>::m_singleton = 0; template<class T>
-Singleton<T>::Singleton() -{}
+Singleton<T>::Singleton() { +}
template<class T>
-Singleton<T>::~Singleton() -{}
+Singleton<T>::~Singleton() { +}
template<class T>
-T* Singleton<T>::instance() -{ - if (m_singleton == 0) { - m_singleton = new T; - } - return m_singleton;
+T* Singleton<T>::instance() { + if (m_singleton == 0) { + m_singleton = new T; + } + return m_singleton;
} template<class T>
-void Singleton<T>::release () -{ - if (m_singleton == 0) - return; - delete m_singleton; - m_singleton = 0;
+void Singleton<T>::release() { + if (m_singleton == 0) + return; + delete m_singleton; + m_singleton = 0;
} #endif
diff -u -r1.39 -r1.40 --- SlicApplication.hh 26 Sep 2011 20:47:18 -0000 1.39 +++ SlicApplication.hh 27 Nov 2012 19:32:18 -0000 1.40 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/SlicApplication.hh,v 1.39 2011/09/26 20:47:18 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/SlicApplication.hh,v 1.40 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_SLICAPPLICATION_HH #define SLIC_SLICAPPLICATION_HH 1
@@ -18,189 +18,201 @@
class G4RunManager; class G4UIExecutive;
-namespace slic -{ - // slic - class FieldMessenger; - class SlicApplicationMessenger; - class RunManager; - - /** - * @class SlicApplication - * @brief Singleton class for a Geant4 application. - * @note Instantiates manager and messenger classes, including - * user actions, G4RunManager, GeneratorManager, and PhysicsListManager. - */ - class SlicApplication : public Singleton<SlicApplication>, public Module - { - - public: - - /** - * Indicates the run mode: batch or interactive. - */ - enum ERunMode { eBatch=1, eInteractive=2 }; - - public: - - /** - * The constructor. - */ - SlicApplication(); - - /** - * The destructor. - */ - virtual ~SlicApplication(); - - public: - - /** - * Return SLIC's RunManager instance. - */ - RunManager* getRunManager(); - - /** - * Initialize the application. - */ - void initialize(); - - /** - * Run the application. - */ - void run(); - - /** - * Print the usage by calling the CommandLineProcessor. - */ - void printUsage(); - - /** - * Print the version string. - */ - void printVersion(); - - /** - * Print SLIC's splash screen. - */ - void printSplashScreen(); - - /** - * Print the start time. - */ - void printStartTime(); - - /** - * Print the end time. - */ - void printEndTime(); - - /** - * Get the return code. - */ - int getReturnCode() const; - - /** - * Get the run mode, interactive or batch. - */ - ERunMode getMode() const; - - /** - * Set abort state. - */ - void setAborting(bool a = true); - - /** - * Check abort state. - */ - bool isAborting() const; - - /** - * Set the run mode. - */ - void setMode(ERunMode rmode); - - /** - * Get the name of the binary as it was invoked. - */ - const std::string& getBinaryName() const; - - /** - * Get the base name of the binary (file name only). - */ - const std::string& getBinaryBasename() const; - - /** - * Setup SLIC from command line arguments using the CommandLineProcessor. - */ - void initialize(int, char**); - - /** - * Set the return code. - */ - void setReturnCode(int rc); - - /** - * Get the Geant4 version string. - */ - std::string getGeant4VersionString(); - - private: - - /** - * Set the binary base name from the full name. - */ - void setBinaryBasename(); - - /** - * Register the Geant4 user action classes with the G4RunManager. - */ - void initializeUserActions(); - - /** - * Register the LCDDDetectorConstruction. - */ - void initializeLCDD(); - - /** - * Initialize the Geant4 visualization subsystem. - */
+namespace slic { +// slic +class FieldMessenger; +class SlicApplicationMessenger; +class RunManager; + +/** + * @class SlicApplication + * @brief Singleton class for a Geant4 application. + * @note Instantiates manager and messenger classes, including + * user actions, G4RunManager, GeneratorManager, and PhysicsListManager. + */ +class SlicApplication: public Singleton<SlicApplication>, public Module { + +public: + + /** + * Indicates the run mode: batch or interactive. + */ + enum ERunMode { + eBatch = 1, eInteractive = 2 + }; + + /** + * Error codes. + */ + enum ErrorCode { + UNKNOWN_ERROR = 1, + UNKNOWN_EXCEPTION = 2, + STD_EXCEPTION = 3, + OUTPUT_FILE_EXISTS = 4, + FAILED_DELETE = 5, + EVENT_UNDERFLOW = 6 + }; + +public: + + /** + * The constructor. + */ + SlicApplication(); + + /** + * The destructor. + */ + virtual ~SlicApplication(); + +public: + + /** + * Return SLIC's RunManager instance. + */ + RunManager* getRunManager(); + + /** + * Initialize the application. + */ + void initialize(); + + /** + * Run the application. + */ + void run(); + + /** + * Print the usage by calling the CommandLineProcessor. + */ + void printUsage(); + + /** + * Print the version string. + */ + void printVersion(); + + /** + * Print SLIC's splash screen. + */ + void printSplashScreen(); + + /** + * Print the start time. + */ + void printStartTime(); + + /** + * Print the end time. + */ + void printEndTime(); + + /** + * Get the return code. + */ + int getReturnCode() const; + + /** + * Get the run mode, interactive or batch. + */ + ERunMode getMode() const; + + /** + * Set abort state. + */ + void setAborting(bool a = true); + + /** + * Check abort state. + */ + bool isAborting() const; + + /** + * Set the run mode. + */ + void setMode(ERunMode rmode); + + /** + * Get the name of the binary as it was invoked. + */ + const std::string& getBinaryName() const; + + /** + * Get the base name of the binary (file name only). + */ + const std::string& getBinaryBasename() const; + + /** + * Setup SLIC from command line arguments using the CommandLineProcessor. + */ + void initialize(int, char**); + + /** + * Set the return code. + */ + void setReturnCode(int rc); + + /** + * Get the Geant4 version string. + */ + std::string getGeant4VersionString(); + +private: + + /** + * Set the binary base name from the full name. + */ + void setBinaryBasename(); + + /** + * Register the Geant4 user action classes with the G4RunManager. + */ + void initializeUserActions(); + + /** + * Register the LCDDDetectorConstruction. + */ + void initializeLCDD(); + + /** + * Initialize the Geant4 visualization subsystem. + */
#ifdef G4VIS_USE
- void initializeVis();
+ void initializeVis();
#endif
- protected:
+protected:
- // G4 UI manager. - G4UIExecutive* m_ui;
+ // G4 UI manager. + G4UIExecutive* m_ui;
- // app messenger - SlicApplicationMessenger* m_appMessenger;
+ // app messenger + SlicApplicationMessenger* m_appMessenger;
- // field messenger - FieldMessenger* m_fieldMessenger;
+ // field messenger + FieldMessenger* m_fieldMessenger;
- RunManager* m_runManager;
+ RunManager* m_runManager;
- // application run mode: batch or interactive - ERunMode m_mode;
+ // application run mode: batch or interactive + ERunMode m_mode;
- // return code - int m_returnCode;
+ // return code + int m_returnCode;
- // hack to make aborting G4 work (doesn't seem to function properly) - bool m_setRunAbort;
+ // hack to make aborting G4 work (doesn't seem to function properly) + bool m_setRunAbort;
- // Has the initialize() function been called? - bool m_isInitialized;
+ // Has the initialize() function been called? + bool m_isInitialized;
- // What was the name of the SLIC binary from CL? (used by LcioFileNamer) - std::string m_binaryname; - std::string m_binarybasename;
+ // What was the name of the SLIC binary from CL? (used by LcioFileNamer) + std::string m_binaryname; + std::string m_binarybasename;
- // Version string of Geant4. - std::string* m_geant4VersionString; - };
+ // Version string of Geant4. + std::string* m_geant4VersionString; +};
} #endif
diff -u -r1.1 -r1.2 --- SlicApplicationMessenger.hh 27 Apr 2007 01:54:32 -0000 1.1 +++ SlicApplicationMessenger.hh 27 Nov 2012 19:32:18 -0000 1.2 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/SlicApplicationMessenger.hh,v 1.1 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/SlicApplicationMessenger.hh,v 1.2 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_SLICAPPLICATIONMESSENGER_HH #define SLIC_SLICAPPLICATIONMESSENGER_HH 1
@@ -8,37 +8,35 @@
#include "G4UIdirectory.hh" #include "G4UIcommand.hh"
-namespace slic -{
+namespace slic {
- class SlicApplication;
+class SlicApplication;
- /** - @class SlicApplicationMessenger - @brief G4UImessenger to the generic G4 application. - */ - class SlicApplicationMessenger : public G4UImessenger - { - public: - SlicApplicationMessenger(SlicApplication*); - virtual ~SlicApplicationMessenger();
+/** + @class SlicApplicationMessenger + @brief G4UImessenger to the generic G4 application. + */ +class SlicApplicationMessenger: public G4UImessenger { +public: + SlicApplicationMessenger(SlicApplication*); + virtual ~SlicApplicationMessenger();
- public: - virtual void SetNewValue(G4UIcommand* cmd, G4String newVals);
+public: + virtual void SetNewValue(G4UIcommand* cmd, G4String newVals);
- private: - void defineCommands();
+private: + void defineCommands();
- private:
+private:
- SlicApplication* m_app;
+ SlicApplication* m_app;
- G4UIdirectory* m_slicDir;
+ G4UIdirectory* m_slicDir;
- G4UIcommand* m_interactive; - G4UIcommand* m_slicUsage; - G4UIcommand* m_slicVersion; - };
+ G4UIcommand* m_interactive; + G4UIcommand* m_slicUsage; + G4UIcommand* m_slicVersion; +};
} #endif
diff -u -r1.1 -r1.2 --- SlicMain.hh 27 Apr 2007 01:54:32 -0000 1.1 +++ SlicMain.hh 27 Nov 2012 19:32:18 -0000 1.2 @@ -1,20 +1,18 @@
-// $Id: SlicMain.hh,v 1.1 2007/04/27 01:54:32 jeremy Exp $
+// $Id: SlicMain.hh,v 1.2 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_SLICMAIN_HH #define SLIC_SLICMAIN_HH 1 #include "Module.hh"
-namespace slic -{ - class SlicMain : public Module - { - public: - SlicMain(); - virtual ~SlicMain(); - - public: - int main(int argc, char** argv); - };
+namespace slic { +class SlicMain: public Module { +public: + SlicMain(); + virtual ~SlicMain(); + +public: + int main(int argc, char** argv); +};
} #endif
diff -u -r1.9 -r1.10 --- StdHepEventSource.hh 29 Aug 2008 00:42:49 -0000 1.9 +++ StdHepEventSource.hh 27 Nov 2012 19:32:18 -0000 1.10 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/StdHepEventSource.hh,v 1.9 2008/08/29 00:42:49 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/StdHepEventSource.hh,v 1.10 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_STDHEPEVENTSOURCE_HH #define SLIC_STDHEPEVENTSOURCE_HH 1
@@ -8,43 +8,41 @@
#include "StdHepToLcioConvertor.hh" #include "EventSourceWithInputFile.hh"
-namespace slic -{ - /** - * @class StdHepEventSource - * @brief Top-level controller of StdHep input. - * @note Uses Willy Langeveld's lStdHep and lXDR classes for input processing. - */ - class StdHepEventSource : public EventSourceWithInputFile - { - public: - StdHepEventSource(const std::string& fname);
+namespace slic { +/** + * @class StdHepEventSource + * @brief Top-level controller of StdHep input. + * @note Uses Willy Langeveld's lStdHep and lXDR classes for input processing. + */ +class StdHepEventSource: public EventSourceWithInputFile { +public: + StdHepEventSource(const std::string& fname);
- public:
+public:
- virtual void generate(G4Event* anEvent);
+ virtual void generate(G4Event* anEvent);
- // open the current file - virtual void open();
+ // open the current file + virtual void open();
- // close the current file - virtual void close();
+ // close the current file + virtual void close();
- // read the next event - virtual void readNextEvent();
+ // read the next event + virtual void readNextEvent();
- virtual void dumpCurrentEvent();
+ virtual void dumpCurrentEvent();
- virtual void beginRun(const G4Run* aRun);
+ virtual void beginRun(const G4Run* aRun);
- virtual void beginEvent(const G4Event* anEvent);
+ virtual void beginEvent(const G4Event* anEvent);
- lStdHep* getStdHepReader();
+ lStdHep* getStdHepReader();
- private: - StdHepLoader* m_loader; - StdHepToLcioConvertor* m_convertor; - };
+private: + StdHepLoader* m_loader; + StdHepToLcioConvertor* m_convertor; +};
} #endif
diff -u -r1.16 -r1.17 --- StdHepLoader.hh 31 May 2011 16:41:06 -0000 1.16 +++ StdHepLoader.hh 27 Nov 2012 19:32:18 -0000 1.17 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/StdHepLoader.hh,v 1.16 2011/05/31 16:41:06 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/StdHepLoader.hh,v 1.17 2012/11/27 19:32:18 jeremy Exp $
#ifndef slic_StdhepLoader_hh #define slic_StdhepLoader_hh 1
@@ -19,54 +19,51 @@
using UTIL::lStdHep;
-namespace slic -{ - enum EErrorCode { eEOF = 106 }; - - /** - @class StdHepLoader - @brief Simple wrapper to lStdHep interface. - */ - class StdHepLoader : public Module - { - - public: - virtual ~StdHepLoader(); - StdHepLoader(); - - public: - - const std::string& getFilename() const - { - return m_filename; - } - - lStdHep* getStdHepReader() - { - return m_reader; - } - - bool isEndOfInput() - { - return m_isEndOfInput; - } - - public: - - void openStdHepFile(const std::string&); - void openStdHepFile(const char*); - - void closeStdHepFile(); - - void readNextEvent(); - void dumpCurrentEvent(); - - private: - - std::string m_filename; - lStdHep* m_reader; - bool m_isEndOfInput; - };
+namespace slic { +enum EErrorCode { + eEOF = 106 +}; + +/** + @class StdHepLoader + @brief Simple wrapper to lStdHep interface. + */ +class StdHepLoader: public Module { + +public: + virtual ~StdHepLoader(); + StdHepLoader(); + +public: + + const std::string& getFilename() const { + return m_filename; + } + + lStdHep* getStdHepReader() { + return m_reader; + } + + bool isEndOfInput() { + return m_isEndOfInput; + } + +public: + + void openStdHepFile(const std::string&); + void openStdHepFile(const char*); + + void closeStdHepFile(); + + void readNextEvent(); + void dumpCurrentEvent(); + +private: + + std::string m_filename; + lStdHep* m_reader; + bool m_isEndOfInput; +};
} #endif
diff -u -r1.21 -r1.22 --- StdHepToLcioConvertor.hh 31 May 2011 16:41:06 -0000 1.21 +++ StdHepToLcioConvertor.hh 27 Nov 2012 19:32:18 -0000 1.22 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/StdHepToLcioConvertor.hh,v 1.21 2011/05/31 16:41:06 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/StdHepToLcioConvertor.hh,v 1.22 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_STDHEPTOLCIOCONVERTOR_HH #define SLIC_STDHEPTOLCIOCONVERTOR_HH 1
@@ -17,128 +17,123 @@
using UTIL::lStdHep;
-namespace slic -{
+namespace slic {
- /** - * @class StdHepToLcioConvertor - * @brief Converts an input StdHep event to an LCIO MCParticle collection. - */ - - /** - @verbatim - - The index "pointers" daughter1, daughter2, mother1 and mother2 are handled as follows, - where idx1 is daughter1/mother1, and idx2 is daughter2/mother2. - - idx1 cmp idx2 action - _______________________ - - -1 -1 do nothing - # -1 use idx1 - -1 # use idx2 - # == # use idx1 - # < # range = idx1 to idx2 - # > # use idx1 and idx2 as discrete indices - - @endverbatim - */ - class StdHepToLcioConvertor : public Module - { - - public: - StdHepToLcioConvertor(lStdHep* rdr); - StdHepToLcioConvertor(); - virtual ~StdHepToLcioConvertor(); - - public: - - /** - * Set the lStdHep reader to be used by the convertor. - */ - void setStdHepReader(lStdHep* rdr) - { - assert( rdr ); - m_reader = rdr; - } - - /** - * Create the next MCP collection using current event - * NOTE: This function depends upon an external read operation for the next event. - */ - void fillCurrentMcpCollectionFromStdHep(); - - /** - * Reset the current MCParticle collection. - */ - void setCurrentMcpCollection(EVENT::LCCollection* mcpColl); - - /** - * Get the current MCParticle collection. - */ - EVENT::LCCollection* getCurrentMcpCollection(); - - /** - * Create a single MCParticle from a StdHep track. - * NOTE: Does not setup mother or daughter links. - */ - IMPL::MCParticleImpl* createMcpFromStdHep( int ihep ); - - /** - * Setup the parent pointers of this track. - */ - void setupParents( int ihep, IMPL::MCParticleImpl* ); - - /** - * Setup the input MCParticle as a parent of this track. - */ - void addMcpParent( int parIdx, IMPL::MCParticleImpl* parMcp ); - - /** - * Setup the daughter pointers of this track. - */ - void setupDaughters( int ihep, IMPL::MCParticleImpl* ); - - /** - * Setup the input MCParticle as a parent of this track. - */ - void addMcpDaughter( int dauIdx, IMPL::MCParticleImpl* parMcp ); - - /** - * Check if an MCParticle has another particle as its parent. - */ - bool hasParent( IMPL::MCParticleImpl* dauMcp, IMPL::MCParticleImpl* parMcp); - - /** - * Given two ihep indices, return a vector of all the included indices (discrete, range, etc.). - */ - std::vector<int> makeIndexVec( int idx1, int idx2, std::vector<int>& vec ); - - /** - * Perform various sanity checks on the track's mother and daughter index values. - */ - void checkParentage( int ihep ); - - - /* Print utilities. */ - void printIndex( int ihep ); - void printMothers( int ihep ); - void printDaughters( int ihep ); - void printTrack( int ihep ); - - bool isValidDaughterIndex(int ihep) - { - return (ihep > -1 && ihep < m_reader->nTracks()); - } - - private: - - /* Pointer to the current MCParticle collection that is being filled. */ - EVENT::LCCollection* m_currentMcpColl; - - /* Pointer to the lStdHep reader being used as a data source. */ - lStdHep* m_reader; - };
+/** + * @class StdHepToLcioConvertor + * @brief Converts an input StdHep event to an LCIO MCParticle collection. + */ + +/** + @verbatim + + The index "pointers" daughter1, daughter2, mother1 and mother2 are handled as follows, + where idx1 is daughter1/mother1, and idx2 is daughter2/mother2. + + idx1 cmp idx2 action + _______________________ + + -1 -1 do nothing + # -1 use idx1 + -1 # use idx2 + # == # use idx1 + # < # range = idx1 to idx2 + # > # use idx1 and idx2 as discrete indices + + @endverbatim + */ +class StdHepToLcioConvertor: public Module { + +public: + StdHepToLcioConvertor(lStdHep* rdr); + StdHepToLcioConvertor(); + virtual ~StdHepToLcioConvertor(); + +public: + + /** + * Set the lStdHep reader to be used by the convertor. + */ + void setStdHepReader(lStdHep* rdr) { + assert(rdr); + m_reader = rdr; + } + + /** + * Create the next MCP collection using current event + * NOTE: This function depends upon an external read operation for the next event. + */ + void fillCurrentMcpCollectionFromStdHep(); + + /** + * Reset the current MCParticle collection. + */ + void setCurrentMcpCollection(EVENT::LCCollection* mcpColl); + + /** + * Get the current MCParticle collection. + */ + EVENT::LCCollection* getCurrentMcpCollection(); + + /** + * Create a single MCParticle from a StdHep track. + * NOTE: Does not setup mother or daughter links. + */ + IMPL::MCParticleImpl* createMcpFromStdHep(int ihep); + + /** + * Setup the parent pointers of this track. + */ + void setupParents(int ihep, IMPL::MCParticleImpl*); + + /** + * Setup the input MCParticle as a parent of this track. + */ + void addMcpParent(int parIdx, IMPL::MCParticleImpl* parMcp); + + /** + * Setup the daughter pointers of this track. + */ + void setupDaughters(int ihep, IMPL::MCParticleImpl*); + + /** + * Setup the input MCParticle as a parent of this track. + */ + void addMcpDaughter(int dauIdx, IMPL::MCParticleImpl* parMcp); + + /** + * Check if an MCParticle has another particle as its parent. + */ + bool hasParent(IMPL::MCParticleImpl* dauMcp, IMPL::MCParticleImpl* parMcp); + + /** + * Given two ihep indices, return a vector of all the included indices (discrete, range, etc.). + */ + std::vector<int> makeIndexVec(int idx1, int idx2, std::vector<int>& vec); + + /** + * Perform various sanity checks on the track's mother and daughter index values. + */ + void checkParentage(int ihep); + + /* Print utilities. */ + void printIndex(int ihep); + void printMothers(int ihep); + void printDaughters(int ihep); + void printTrack(int ihep); + + bool isValidDaughterIndex(int ihep) { + return (ihep > -1 && ihep < m_reader->nTracks()); + } + +private: + + /* Pointer to the current MCParticle collection that is being filled. */ + EVENT::LCCollection* m_currentMcpColl; + + /* Pointer to the lStdHep reader being used as a data source. */ + lStdHep* m_reader; +};
} #endif
diff -u -r1.13 -r1.14 --- SteppingAction.hh 5 Sep 2006 23:21:49 -0000 1.13 +++ SteppingAction.hh 27 Nov 2012 19:32:18 -0000 1.14 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/SteppingAction.hh,v 1.13 2006/09/05 23:21:49 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/SteppingAction.hh,v 1.14 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_STEPPINGACTION_HH #define SLIC_STEPPINGACTION_HH 1
@@ -11,20 +11,18 @@
class G4UserRegionInformation;
-namespace slic -{
+namespace slic {
- /** - @class SteppingAction - @brief Implementation of G4UserSteppingAction. - */ - class SteppingAction : public G4UserSteppingAction - { - public: - SteppingAction(); - virtual ~SteppingAction(); - virtual void UserSteppingAction(const G4Step*); - };
+/** + @class SteppingAction + @brief Implementation of G4UserSteppingAction. + */ +class SteppingAction: public G4UserSteppingAction { +public: + SteppingAction(); + virtual ~SteppingAction(); + virtual void UserSteppingAction(const G4Step*); +};
} #endif
diff -u -r1.10 -r1.11 --- TimeUtil.hh 27 Apr 2007 01:54:33 -0000 1.10 +++ TimeUtil.hh 27 Nov 2012 19:32:18 -0000 1.11 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/TimeUtil.hh,v 1.10 2007/04/27 01:54:33 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/TimeUtil.hh,v 1.11 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_TIMEUTIL_HH #define SLIC_TIMEUTIL_HH 1
@@ -7,37 +7,36 @@
#include <string> /**
- @class TimeUtil - @brief Time utilities. -*/ -class TimeUtil -{ - - public: - - typedef long long long64; -
+ @class TimeUtil + @brief Time utilities. + */ +class TimeUtil { + +public: + + typedef long long long64; +
public:
- virtual ~TimeUtil(); -
+ virtual ~TimeUtil(); +
private:
- TimeUtil(); -
+ TimeUtil(); +
public:
- - /* @return date formatted as "YYYY-MM-DD" */ - static std::string getDate(); - - /* @return full time string as ASCII formatted string */ - static std::string getAscTime(); - - /* @return time since the epoch with second resolution, converted to NS */ - static TimeUtil::long64 getTimeNS(); -
+ + /* @return date formatted as "YYYY-MM-DD" */ + static std::string getDate(); + + /* @return full time string as ASCII formatted string */ + static std::string getAscTime(); + + /* @return time since the epoch with second resolution, converted to NS */ + static TimeUtil::long64 getTimeNS(); +
private:
- - /* @return timeinfo processed with localtime() */ - static tm* get_tm_local();
+ + /* @return timeinfo processed with localtime() */ + static tm* get_tm_local();
}; #endif
diff -u -r1.8 -r1.9 --- TrackingAction.hh 5 Sep 2006 23:21:49 -0000 1.8 +++ TrackingAction.hh 27 Nov 2012 19:32:18 -0000 1.9 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/TrackingAction.hh,v 1.8 2006/09/05 23:21:49 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/TrackingAction.hh,v 1.9 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_TRACKINGACTION_HH #define SLIC_TRACKINGACTION_HH 1
@@ -6,29 +6,27 @@
#include "G4UserTrackingAction.hh" #include "G4TrackingManager.hh"
-namespace slic -{
+namespace slic {
- class TrajectoryManager;
+class TrajectoryManager;
- /** - @class TrackingAction - @brief Implementation of G4UserTrackingAction. - */ - class TrackingAction : public G4UserTrackingAction - { - public: - TrackingAction(); - ~TrackingAction(); - - public: - void PreUserTrackingAction(const G4Track* aTrack); - void PostUserTrackingAction(const G4Track* aTrack);
+/** + @class TrackingAction + @brief Implementation of G4UserTrackingAction. + */ +class TrackingAction: public G4UserTrackingAction { +public: + TrackingAction(); + ~TrackingAction(); + +public: + void PreUserTrackingAction(const G4Track* aTrack); + void PostUserTrackingAction(const G4Track* aTrack);
- private:
+private:
- TrajectoryManager* m_trjMgr; - };
+ TrajectoryManager* m_trjMgr; +};
} #endif
diff -u -r1.17 -r1.18 --- Trajectory.hh 5 Sep 2006 23:21:49 -0000 1.17 +++ Trajectory.hh 27 Nov 2012 19:32:18 -0000 1.18 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/Trajectory.hh,v 1.17 2006/09/05 23:21:49 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/Trajectory.hh,v 1.18 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_TRAJECTORY_HH #define SLIC_TRAJECTORY_HH 1
@@ -10,219 +10,192 @@
#include "G4VTrajectoryPoint.hh" #include "globals.hh"
-namespace slic -{
+namespace slic {
- typedef std::vector<G4VTrajectoryPoint*> TrajectoryPointContainer;
+typedef std::vector<G4VTrajectoryPoint*> TrajectoryPointContainer;
- /** - @class Trajectory - @brief Implementation of G4VTrajectory. - */ - class Trajectory : public G4VTrajectory - { - public: - - enum EFinalStatus { - eUnset = 0, - eDecayedInTracker = 1, - eLeftDetector = 2, - eStopped = 3, - eDecayedInCalorimeter = 4 - }; - - public: - - // no arg ctor - Trajectory(); - - // create from track - Trajectory(const G4Track *aTrack); - - // copy ctor from trajectory - Trajectory(Trajectory &); - - virtual ~Trajectory(); - - public: - - virtual void DrawTrajectory(G4int i_mode) const - { - G4VTrajectory::DrawTrajectory( i_mode ); - } - - // static string of final status - static const std::string& getFinalStatusString(EFinalStatus fs); - - // non-static version - const std::string& getFinalStatusString() const - { - return Trajectory::getFinalStatusString( m_finalStatus ); - } - - // new op - inline void* operator new(size_t); - - // del op - inline void operator delete(void*); - - inline int operator == (const Trajectory& right) const - { - return (this==&right); - } - - inline G4int GetTrackID() const - { - return m_trackID; - } - - inline G4int GetParentID() const - { - return m_parentID; - } - - inline G4String GetParticleName() const - { - return m_particleName; - } - - inline G4double GetCharge() const - { - return m_PDGCharge; - } - - inline G4int GetPDGEncoding() const - { - return m_PDGEncoding; - } - - inline G4ThreeVector GetInitialMomentum() const - { - return m_initialMomentum; - } - - inline const G4ParticleDefinition* GetParticleDefinition() - { - return m_particleDefinition; - } - - inline G4double GetGlobalTime() - { - return m_globalTime; - } - - // has endpoint daughters - inline G4bool getHasEndpointDaughters() const - { - return m_hasEndpointDaughters; - } - - inline void setHasEndpointDaughters(G4bool d) - { - m_hasEndpointDaughters = d; - } - - // backscatter - inline G4bool getBackscatter() const - { - return m_backscatter; - } - - inline void setBackscatter(G4bool b) - { - m_backscatter = b; - } - - // vertexIsNotEndpointOfParent - inline G4bool getVertexIsNotEndpointOfParent() const - { - return m_vertexIsNotEndpointOfParent; - } - - inline void setVertexIsNotEndpointOfParent(G4bool = true) - { - m_vertexIsNotEndpointOfParent = true; - } - - // final status - inline void setFinalStatus(EFinalStatus fstatus) - { - m_finalStatus = fstatus; - } - - inline EFinalStatus getFinalStatus() const - { - return m_finalStatus; - } - - // createdInSimulation - inline void setCreatedInSimulation(G4bool c) - { - m_createdInSimulation = c; - } - - inline G4bool getCreatedInSimulation() const - { - return m_createdInSimulation; - } - - // set additional info from track - void setupManuallyFromTrack(const G4Track* aTrack); - - inline void setEndpointEnergy(G4double e) - { - m_endpointEnergy = e; - } - - G4double getEndPointEnergy() - { - return m_endpointEnergy; - } - - public: - virtual void AppendStep(const G4Step *aStep); - virtual void MergeTrajectory(G4VTrajectory *secondTrajectory); - - virtual G4int GetPointEntries() const { return m_posRecord->size(); } - virtual G4VTrajectoryPoint* GetPoint(G4int i) const {return (*m_posRecord)[i]; } - - private: - - // track info - G4ParticleDefinition* m_particleDefinition; - G4String m_particleName; - G4double m_PDGCharge; - G4int m_PDGEncoding; - G4int m_trackID; - G4int m_parentID; - TrajectoryPointContainer* m_posRecord; - G4ThreeVector m_initialMomentum; - G4double m_globalTime; - G4double m_endpointEnergy; - - // non-exclusive sim statuses - G4bool m_createdInSimulation; - G4bool m_hasEndpointDaughters; - G4bool m_backscatter; - G4bool m_vertexIsNotEndpointOfParent; - - // mutually exclusive final states: see enums - EFinalStatus m_finalStatus; - }; - - extern G4Allocator<Trajectory> TrajectoryAllocator; - - inline void* Trajectory::operator new(size_t) - { - void *aTrajectory; - aTrajectory = (void*) TrajectoryAllocator.MallocSingle(); - return aTrajectory; - } - - inline void Trajectory::operator delete(void* aTrajectory) - { - TrajectoryAllocator.FreeSingle( ( Trajectory* ) aTrajectory ); - }
+/** + @class Trajectory + @brief Implementation of G4VTrajectory. + */ +class Trajectory: public G4VTrajectory { +public: + + enum EFinalStatus { + eUnset = 0, eDecayedInTracker = 1, eLeftDetector = 2, eStopped = 3, eDecayedInCalorimeter = 4 + }; + +public: + + // no arg ctor + Trajectory(); + + // create from track + Trajectory(const G4Track *aTrack); + + // copy ctor from trajectory + Trajectory(Trajectory &); + + virtual ~Trajectory(); + +public: + + virtual void DrawTrajectory(G4int i_mode) const { + G4VTrajectory::DrawTrajectory(i_mode); + } + + // static string of final status + static const std::string& getFinalStatusString(EFinalStatus fs); + + // non-static version + const std::string& getFinalStatusString() const { + return Trajectory::getFinalStatusString(m_finalStatus); + } + + // new op + inline void* operator new(size_t); + + // del op + inline void operator delete(void*); + + inline int operator ==(const Trajectory& right) const { + return (this == &right); + } + + inline G4int GetTrackID() const { + return m_trackID; + } + + inline G4int GetParentID() const { + return m_parentID; + } + + inline G4String GetParticleName() const { + return m_particleName; + } + + inline G4double GetCharge() const { + return m_PDGCharge; + } + + inline G4int GetPDGEncoding() const { + return m_PDGEncoding; + } + + inline G4ThreeVector GetInitialMomentum() const { + return m_initialMomentum; + } + + inline const G4ParticleDefinition* GetParticleDefinition() { + return m_particleDefinition; + } + + inline G4double GetGlobalTime() { + return m_globalTime; + } + + // has endpoint daughters + inline G4bool getHasEndpointDaughters() const { + return m_hasEndpointDaughters; + } + + inline void setHasEndpointDaughters(G4bool d) { + m_hasEndpointDaughters = d; + } + + // backscatter + inline G4bool getBackscatter() const { + return m_backscatter; + } + + inline void setBackscatter(G4bool b) { + m_backscatter = b; + } + + // vertexIsNotEndpointOfParent + inline G4bool getVertexIsNotEndpointOfParent() const { + return m_vertexIsNotEndpointOfParent; + } + + inline void setVertexIsNotEndpointOfParent(G4bool = true) { + m_vertexIsNotEndpointOfParent = true; + } + + // final status + inline void setFinalStatus(EFinalStatus fstatus) { + m_finalStatus = fstatus; + } + + inline EFinalStatus getFinalStatus() const { + return m_finalStatus; + } + + // createdInSimulation + inline void setCreatedInSimulation(G4bool c) { + m_createdInSimulation = c; + } + + inline G4bool getCreatedInSimulation() const { + return m_createdInSimulation; + } + + // set additional info from track + void setupManuallyFromTrack(const G4Track* aTrack); + + inline void setEndpointEnergy(G4double e) { + m_endpointEnergy = e; + } + + G4double getEndPointEnergy() { + return m_endpointEnergy; + } + +public: + virtual void AppendStep(const G4Step *aStep); + virtual void MergeTrajectory(G4VTrajectory *secondTrajectory); + + virtual G4int GetPointEntries() const { + return m_posRecord->size(); + } + virtual G4VTrajectoryPoint* GetPoint(G4int i) const { + return (*m_posRecord)[i]; + } + +private: + + // track info + G4ParticleDefinition* m_particleDefinition; + G4String m_particleName; + G4double m_PDGCharge; + G4int m_PDGEncoding; + G4int m_trackID; + G4int m_parentID; + TrajectoryPointContainer* m_posRecord; + G4ThreeVector m_initialMomentum; + G4double m_globalTime; + G4double m_endpointEnergy; + + // non-exclusive sim statuses + G4bool m_createdInSimulation; + G4bool m_hasEndpointDaughters; + G4bool m_backscatter; + G4bool m_vertexIsNotEndpointOfParent; + + // mutually exclusive final states: see enums + EFinalStatus m_finalStatus; +}; + +extern G4Allocator<Trajectory> TrajectoryAllocator; + +inline void* Trajectory::operator new(size_t) { + void *aTrajectory; + aTrajectory = (void*) TrajectoryAllocator.MallocSingle(); + return aTrajectory; +} + +inline void Trajectory::operator delete(void* aTrajectory) { + TrajectoryAllocator.FreeSingle((Trajectory*) aTrajectory); +}
} #endif
diff -u -r1.32 -r1.33 --- TrajectoryManager.hh 31 Jan 2012 18:52:30 -0000 1.32 +++ TrajectoryManager.hh 27 Nov 2012 19:32:18 -0000 1.33 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/TrajectoryManager.hh,v 1.32 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/TrajectoryManager.hh,v 1.33 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_TRAJECTORYMANAGER_HH #define SLIC_TRAJECTORYMANAGER_HH 1
@@ -21,242 +21,222 @@
class G4Event;
-namespace slic -{
+namespace slic {
- /** - * @class TrajectoryManager - * - * @brief Provides runtime management of trajectories and track information, - * mainly to provide enough data for correct settings of MCParticle - * data in LcioMcpManager. - * - * @todo Add current track ID and G4Track instance variables to simplify - * internal handling and function signatures. - */ - - class TrajectoryManager : public Module, public Singleton<TrajectoryManager> - { - public: - typedef std::map<G4int, Trajectory*> TrackIDToTrajectoryMap; - - public: - virtual ~TrajectoryManager(); - TrajectoryManager(); - - public: - - // beginEvent action - void beginEvent(const G4Event*) - { - clearTrackIDToTrajectoryMap(); - } - - // preTracking action - void preTracking(const G4Track*); - - // postTracking action - void postTracking(const G4Track*); - - // stepping action - void stepping( const G4Step*); - - // find trajectory by track ID - Trajectory* findTrajectory(G4int trkID); - - // find trajectory by const track - Trajectory* findTrajectory(const G4Track* aTrack ) - { - return findTrajectory( aTrack->GetTrackID() ); - } - - // find trajectory by track - Trajectory* findTrajectory(G4Track* aTrack ) - { - return findTrajectory( ( const_cast<const G4Track*> ( aTrack ) )->GetTrackID() ); - } - - void printTrackIDToTrajectoryMap() - { - log() << LOG::debug << "TrackIDToTrajectoryMap" << LOG::done; - log() << LOG::debug << "trackID | trjPtr" << LOG::done; - for ( TrackIDToTrajectoryMap::iterator iter = m_trackIDToTrajectory.begin(); - iter != m_trackIDToTrajectory.end(); - iter++) { - log() << LOG::debug << iter->first << " " << iter->second << LOG::done; - } - } - - // set the TrackingManager - inline void setTrackingManager(const G4TrackingManager* trkMgr) - { - m_trackingManager = const_cast<G4TrackingManager*>(trkMgr); - } - - private: - - // handle a primary track - void handlePrimaryTrack(const G4Track* aTrack); - - // setup primary track info - void setPrimaryTrackInformation(const G4Track* aTrack); - - // handle a secondary track - void handleSecondaryTrack(const G4Track* aTrack); - - // setup trajectory for a secondary track in handleSecondaryTrack() - Trajectory* createSecondaryTrajectory(const G4Track* aTrack); - - // setup track info for secondary in tracking region - void setupSecondaryTrackInformation(const G4Track* aTrack); - - // setup secondary track info - void copySecondaryTrackInformationFromParent(const G4Track* aTrack); - - // check if this track requires manual trajectory setup - bool needsManualTrajectorySetup(const G4Track* aTrack); - - // set final status of track in postTracking - void setTrajectoryFinalStatus(const G4Track* aTrack); - - // count num secondaries at track's end - G4int getNumberOfSecondariesAtEnd(const G4Track* aTrack); - - // does this track represent a primary particle, i.e. is parent trkID = 0? - inline bool isPrimaryTrack(const G4Track* aTrack) const - { - return ( aTrack->GetParentID() == 0 ); - } - - /** - * Return true if energy is less than region's threshold to create a trajectory or if the - * flag has been set on the track info; False if not. - */ - inline bool isBelowThreshold(const G4Track* aTrack) const - { - return ( (aTrack->GetKineticEnergy() - < G4UserRegionInformation::getRegionInformation( aTrack )->getThreshold() ) || - ( TrackInformation::getTrackInformation(aTrack)->getBelowThreshold() == true ) ); - } - - /* - Check if original tracking status is not in a tracking region, - which works ok because this function is only relavent when track - is currently in the tracking region. - */ - inline bool isBackscatter(const G4Track* aTrack) const - { - return - TrackInformation::getTrackInformation( aTrack )->getOriginalTrackingStatus() != - TrackInformation::eInTrackingRegion; - } - - // is track status = alive? - bool isAlive(const G4Step* aStep) - { - return aStep->GetTrack()->GetTrackStatus() == fAlive; - } - - // get trajectory from tracking manager - Trajectory* getCurrentTrajectory() - { - return static_cast<Trajectory*> ( m_trackingManager->GimmeTrajectory() ); - } - - void fillTrackIDToTrajectoryMap( const G4Event*, bool clearIt = true ); - void addTrackIDToTrajectoryLink( Trajectory* ); - - void clearTrackIDToTrajectoryMap() - { - m_trackIDToTrajectory.clear(); - } - - // debug printers - void printStatusFlags(const G4Track* trk); - void printStatusFlags(TrackInformation* trkInfo); - void printTrack(const G4Track* trk, bool isSecondary = false); - void printTrajectory(const Trajectory* trj); - void printSecondaries(); - - void setTrackingFlagFromRegionInformation(TrackInformation* trk_info, G4UserRegionInformation* reg_info); - - void printPhysVolDbg(G4StepPoint* stepPnt); - - // use parent's endpoint and the seco track position to determine vertexIsNotEndpointOfParent flag - bool vertexIsNotEndpointOfParent(const G4ThreeVector& parEndpoint, G4Track* secoTrack) - { - assert( secoTrack ); - - bool r = false; - - if (!parEndpoint.isNear( secoTrack->GetPosition() ) ) { - r = true; - } - - return r; - } - - // get trajectory point 3vect - static G4ThreeVector getTrajectoryPointPosition(Trajectory* trj, G4int pos_idx = 0) - { - // check null trajectory - if (!trj ) { - G4Exception("TrajectoryManager::getTrajectoryPointPosition()", "", FatalException, "Trajectory is null."); - } - - // get number of trajectories - G4int numPnts = trj->GetPointEntries(); - - // check idx argument against number of trajectories - if ( ( pos_idx > ( numPnts - 1 ) ) || pos_idx < 0 ) { - G4Exception("TrajectoryManager::getTrajectoryPointPosition()", "", FatalException, "The trajectory position index is invalid."); - } - - // return point at idx - return trj->GetPoint(pos_idx)->GetPosition(); - } - - // get a trajectory's vertex point - static G4ThreeVector getTrajectoryVertex(Trajectory* trj) - { - return getTrajectoryPointPosition( trj, 0 ); - } - - // get a trajectory's endpoint - static G4ThreeVector getTrajectoryEndpoint(Trajectory* trj) - { - return getTrajectoryPointPosition( trj, trj->GetPointEntries() - 1 ); - } - - // create a trajectory from track's data - Trajectory* createTrajectoryFromTrack(const G4Track* aTrack ); - - /** - * @return Pointer to the current trajectory being processed. - */ - inline Trajectory* getCurrentTrajectory() const - { - return m_currentTrajectory; - } - - inline const G4Track* getCurrentTrack() const - { - return m_currentTrack; - } - - inline G4int getCurrentTrackID() const - { - return m_currentTrackID; - } - - private: - - G4TrackingManager* m_trackingManager; - TrackIDToTrajectoryMap m_trackIDToTrajectory; - Trajectory* m_currentTrajectory; - const G4Track* m_currentTrack; - G4int m_currentTrackID; - };
+/** + * @class TrajectoryManager + * + * @brief Provides runtime management of trajectories and track information, + * mainly to provide enough data for correct settings of MCParticle + * data in LcioMcpManager. + * + * @todo Add current track ID and G4Track instance variables to simplify + * internal handling and function signatures. + */ + +class TrajectoryManager: public Module, public Singleton<TrajectoryManager> { +public: + typedef std::map<G4int, Trajectory*> TrackIDToTrajectoryMap; + +public: + virtual ~TrajectoryManager(); + TrajectoryManager(); + +public: + + // beginEvent action + void beginEvent(const G4Event*) { + clearTrackIDToTrajectoryMap(); + } + + // preTracking action + void preTracking(const G4Track*); + + // postTracking action + void postTracking(const G4Track*); + + // stepping action + void stepping(const G4Step*); + + // find trajectory by track ID + Trajectory* findTrajectory(G4int trkID); + + // find trajectory by const track + Trajectory* findTrajectory(const G4Track* aTrack) { + return findTrajectory(aTrack->GetTrackID()); + } + + // find trajectory by track + Trajectory* findTrajectory(G4Track* aTrack) { + return findTrajectory((const_cast<const G4Track*>(aTrack))->GetTrackID()); + } + + void printTrackIDToTrajectoryMap() { + log() << LOG::debug << "TrackIDToTrajectoryMap" << LOG::done; + log() << LOG::debug << "trackID | trjPtr" << LOG::done; + for (TrackIDToTrajectoryMap::iterator iter = m_trackIDToTrajectory.begin(); + iter != m_trackIDToTrajectory.end(); iter++) { + log() << LOG::debug << iter->first << " " << iter->second << LOG::done; + } + } + + // set the TrackingManager + inline void setTrackingManager(const G4TrackingManager* trkMgr) { + m_trackingManager = const_cast<G4TrackingManager*>(trkMgr); + } + +private: + + // handle a primary track + void handlePrimaryTrack(const G4Track* aTrack); + + // setup primary track info + void setPrimaryTrackInformation(const G4Track* aTrack); + + // handle a secondary track + void handleSecondaryTrack(const G4Track* aTrack); + + // setup trajectory for a secondary track in handleSecondaryTrack() + Trajectory* createSecondaryTrajectory(const G4Track* aTrack); + + // setup track info for secondary in tracking region + void setupSecondaryTrackInformation(const G4Track* aTrack); + + // setup secondary track info + void copySecondaryTrackInformationFromParent(const G4Track* aTrack); + + // check if this track requires manual trajectory setup + bool needsManualTrajectorySetup(const G4Track* aTrack); + + // set final status of track in postTracking + void setTrajectoryFinalStatus(const G4Track* aTrack); + + // count num secondaries at track's end + G4int getNumberOfSecondariesAtEnd(const G4Track* aTrack); + + // does this track represent a primary particle, i.e. is parent trkID = 0? + inline bool isPrimaryTrack(const G4Track* aTrack) const { + return (aTrack->GetParentID() == 0); + } + + /** + * Return true if energy is less than region's threshold to create a trajectory or if the + * flag has been set on the track info; False if not. + */ + inline bool isBelowThreshold(const G4Track* aTrack) const { + return ((aTrack->GetKineticEnergy() + < G4UserRegionInformation::getRegionInformation(aTrack)->getThreshold()) + || (TrackInformation::getTrackInformation(aTrack)->getBelowThreshold() == true)); + } + + /* + Check if original tracking status is not in a tracking region, + which works ok because this function is only relavent when track + is currently in the tracking region. + */ + inline bool isBackscatter(const G4Track* aTrack) const { + return TrackInformation::getTrackInformation(aTrack)->getOriginalTrackingStatus() + != TrackInformation::eInTrackingRegion; + } + + // is track status = alive? + bool isAlive(const G4Step* aStep) { + return aStep->GetTrack()->GetTrackStatus() == fAlive; + } + + // get trajectory from tracking manager + Trajectory* getCurrentTrajectory() { + return static_cast<Trajectory*>(m_trackingManager->GimmeTrajectory()); + } + + void fillTrackIDToTrajectoryMap(const G4Event*, bool clearIt = true); + void addTrackIDToTrajectoryLink(Trajectory*); + + void clearTrackIDToTrajectoryMap() { + m_trackIDToTrajectory.clear(); + } + + // debug printers + void printStatusFlags(const G4Track* trk); + void printStatusFlags(TrackInformation* trkInfo); + void printTrack(const G4Track* trk, bool isSecondary = false); + void printTrajectory(const Trajectory* trj); + void printSecondaries(); + + void setTrackingFlagFromRegionInformation(TrackInformation* trk_info, G4UserRegionInformation* reg_info); + + void printPhysVolDbg(G4StepPoint* stepPnt); + + // use parent's endpoint and the seco track position to determine vertexIsNotEndpointOfParent flag + bool vertexIsNotEndpointOfParent(const G4ThreeVector& parEndpoint, G4Track* secoTrack) { + assert( secoTrack); + + bool r = false; + + if (!parEndpoint.isNear(secoTrack->GetPosition())) { + r = true; + } + + return r; + } + + // get trajectory point 3vect + static G4ThreeVector getTrajectoryPointPosition(Trajectory* trj, G4int pos_idx = 0) { + // check null trajectory + if (!trj) { + G4Exception("TrajectoryManager::getTrajectoryPointPosition()", "", FatalException, + "Trajectory is null."); + } + + // get number of trajectories + G4int numPnts = trj->GetPointEntries(); + + // check idx argument against number of trajectories + if ((pos_idx > (numPnts - 1)) || pos_idx < 0) { + G4Exception("TrajectoryManager::getTrajectoryPointPosition()", "", FatalException, + "The trajectory position index is invalid."); + } + + // return point at idx + return trj->GetPoint(pos_idx)->GetPosition(); + } + + // get a trajectory's vertex point + static G4ThreeVector getTrajectoryVertex(Trajectory* trj) { + return getTrajectoryPointPosition(trj, 0); + } + + // get a trajectory's endpoint + static G4ThreeVector getTrajectoryEndpoint(Trajectory* trj) { + return getTrajectoryPointPosition(trj, trj->GetPointEntries() - 1); + } + + // create a trajectory from track's data + Trajectory* createTrajectoryFromTrack(const G4Track* aTrack); + + /** + * @return Pointer to the current trajectory being processed. + */ + inline Trajectory* getCurrentTrajectory() const { + return m_currentTrajectory; + } + + inline const G4Track* getCurrentTrack() const { + return m_currentTrack; + } + + inline G4int getCurrentTrackID() const { + return m_currentTrackID; + } + +private: + + G4TrackingManager* m_trackingManager; + TrackIDToTrajectoryMap m_trackIDToTrajectory; + Trajectory* m_currentTrajectory; + const G4Track* m_currentTrack; + G4int m_currentTrackID; +};
} #endif
diff -u -r1.3 -r1.4 --- VRML2Writer.hh 9 Jul 2009 22:11:51 -0000 1.3 +++ VRML2Writer.hh 27 Nov 2012 19:32:18 -0000 1.4 @@ -13,35 +13,33 @@
class G4VSolid; class G4Polyhedron;
-namespace slic -{ - /** - * A simple standalone VRML2 writer that dumps the detector geometry in hierarchical format. - */ - class VRML2Writer - { - public: - VRML2Writer(const std::string& filename); - ~VRML2Writer(); - void write();
+namespace slic { +/** + * A simple standalone VRML2 writer that dumps the detector geometry in hierarchical format. + */ +class VRML2Writer { +public: + VRML2Writer(const std::string& filename); + ~VRML2Writer(); + void write();
- private:
+private:
- void processTopVolume(G4VPhysicalVolume*); - void processPhysicalVolume(G4VPhysicalVolume*); - void processVisualization(G4VPhysicalVolume*); - void processSolid(G4VSolid*); - void processBox(G4Box*); - void processPolyhedron(G4Polyhedron*); - void writeLine(const std::string&); - void indent(); - void unindent();
+ void processTopVolume(G4VPhysicalVolume*); + void processPhysicalVolume(G4VPhysicalVolume*); + void processVisualization(G4VPhysicalVolume*); + void processSolid(G4VSolid*); + void processBox(G4Box*); + void processPolyhedron(G4Polyhedron*); + void writeLine(const std::string&); + void indent(); + void unindent();
- private:
+private:
- std::ofstream _out; - int _indentLevel; - };
+ std::ofstream _out; + int _indentLevel; +};
} #endif
diff -u -r1.1 -r1.2 --- VRML2WriterMessenger.hh 7 Jul 2009 21:39:19 -0000 1.1 +++ VRML2WriterMessenger.hh 27 Nov 2012 19:32:18 -0000 1.2 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/VRML2WriterMessenger.hh,v 1.1 2009/07/07 21:39:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/VRML2WriterMessenger.hh,v 1.2 2012/11/27 19:32:18 jeremy Exp $
#ifndef SLIC_VRML2WRITERMESSENGER_HH #define SLIC_VRML2WRITERMESSENGER_HH 1
@@ -9,21 +9,19 @@
class G4UIdirectory; class G4UIcmdWithAString;
-namespace slic -{ - class VRML2WriterMessenger : public G4UImessenger - { - public: - VRML2WriterMessenger(); - virtual ~VRML2WriterMessenger(); - - public: - virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); - - private: - G4UIdirectory* m_vrmlDir; - G4UIcmdWithAString* m_writeVrmlCmd; - };
+namespace slic { +class VRML2WriterMessenger: public G4UImessenger { +public: + VRML2WriterMessenger(); + virtual ~VRML2WriterMessenger(); + +public: + virtual void SetNewValue(G4UIcommand* cmd, G4String newVals); + +private: + G4UIdirectory* m_vrmlDir; + G4UIcmdWithAString* m_writeVrmlCmd; +};
} #endif
diff -u -r1.13 -r1.14 --- CommandLineProcessor.cc 8 Jan 2010 23:18:56 -0000 1.13 +++ CommandLineProcessor.cc 27 Nov 2012 19:32:19 -0000 1.14 @@ -1,4 +1,4 @@
-// $Id: CommandLineProcessor.cc,v 1.13 2010/01/08 23:18:56 jeremy Exp $
+// $Id: CommandLineProcessor.cc,v 1.14 2012/11/27 19:32:19 jeremy Exp $
#include "CommandLineProcessor.hh"
@@ -17,547 +17,427 @@
using std::stringstream; using std::left;
-namespace slic -{ - CommandLineProcessor::CommandLineProcessor() - : Module("CommandLineProcessor"), - m_help_flag(0), - m_interactive_flag(0), - m_version_flag(0) - { - registerOptions(); - createOptionsString(); - } - - CommandLineProcessor::~CommandLineProcessor() - {} - - void CommandLineProcessor::process(int argc, char** argv) - { - // Description of SLIC's options in getopt's format. - static struct option long_options[] = { - {"help", no_argument, 0, 'h'}, - {"help", no_argument, 0, '?'}, - {"version", no_argument, 0, 'v'}, - {"interactive", no_argument, 0, 'n'}, - {"macro", required_argument, 0, 'm'}, - {"event-file", required_argument, 0, 'i'}, - {"lcdd-url", required_argument, 0, 'g'}, - {"lcio-file", required_argument, 0, 'o'}, - {"lcio-path", required_argument, 0, 'p'}, - {"autoname", optional_argument, 0, 'O'}, - {"lcio-delete", no_argument, 0, 'x'}, - {"run-events", required_argument, 0, 'r'}, - {"skip-events", required_argument, 0, 's'}, - {"physics-list", required_argument, 0, 'l'}, - {"log-file", required_argument, 0, 'L'}, - {"seed", required_argument, 0, 'd'}, - {"dump-gdml", required_argument, 0, 'G'}, - {"optical", no_argument, 0, 'c'}, - {"pdg-file", required_argument, 0, 'P'}, - {0, 0, 0, 0} - }; - - const char* optstr = m_getoptOptions.c_str(); - - while (1) - { - int option_index = 0; - int c; - - // Call getopt for next option. - c = getopt_long (argc, - argv, - optstr, - long_options, - &option_index);
+namespace slic { +CommandLineProcessor::CommandLineProcessor() : + Module("CommandLineProcessor"), m_help_flag(0), m_interactive_flag(0), m_version_flag(0) { + registerOptions(); + createOptionsString(); +} + +CommandLineProcessor::~CommandLineProcessor() { +} + +void CommandLineProcessor::process(int argc, char** argv) { + // Description of SLIC's options in getopt's format. + static struct option long_options[] = { { "help", no_argument, 0, 'h' }, { "help", no_argument, 0, '?' }, + { "version", no_argument, 0, 'v' }, { "interactive", no_argument, 0, 'n' }, { "macro", + required_argument, 0, 'm' }, { "event-file", required_argument, 0, 'i' }, { "lcdd-url", + required_argument, 0, 'g' }, { "lcio-file", required_argument, 0, 'o' }, { "lcio-path", + required_argument, 0, 'p' }, { "autoname", optional_argument, 0, 'O' }, { "lcio-delete", + no_argument, 0, 'x' }, { "run-events", required_argument, 0, 'r' }, { "skip-events", + required_argument, 0, 's' }, { "physics-list", required_argument, 0, 'l' }, { "log-file", + required_argument, 0, 'L' }, { "seed", required_argument, 0, 'd' }, { "dump-gdml", + required_argument, 0, 'G' }, { "optical", no_argument, 0, 'c' }, { "pdg-file", + required_argument, 0, 'P' }, { 0, 0, 0, 0 } }; + + const char* optstr = m_getoptOptions.c_str(); + + while (1) { + int option_index = 0; + int c; + + // Call getopt for next option. + c = getopt_long(argc, argv, optstr, long_options, &option_index);
#ifdef SLIC_LOG
- log() << LOG::verbose << "Handling option <" << c << ">." << LOG::done;
+ log() << LOG::verbose << "Handling option <" << c << ">." << LOG::done;
#endif
- - // Done. - if ( c == -1 ) - break; - - // Handle options. - switch (c) { - - case 'h': - m_help_flag=1; - break; - - case '?': - m_help_flag=1; - break; - - case 'n': - m_interactive_flag=1; - break; - - case 'v': - m_version_flag=1; - break; - - default: - - stringstream ostr; - char cc = (char)c; - ostr << cc; - string theopt = ostr.str(); - - if ( optarg ) { - m_commandline.push_back( OptionsPair( theopt, optarg ) ); - } - else { - m_commandline.push_back( OptionsPair( theopt, "" ) ); - } - - break; - } - } - - // - // The processing flow... - // - // 1) If version flag is set, print version and exit. - // - // 2) If usage flag is set or no arguments were received, - // print the usage and exit. - // - // 3) If a single non-option command was received, treat - // it as a macro to execute. - // - // 4) If no options were received or the number of options - // is less than the number of arguments, print usage - // and exit (syntax incorrect). - // - // 5) Finally, process the options in order if the syntax - // appears to be okay. - // - - // Print the version information and abort. - if ( m_version_flag ) { - printVersion(); - abort(); - } - // Print the usage and abort if the help flag is set - // or no arguments were received. - else if ( m_help_flag || argc == 1 ) { - printUsage(); - abort(); - } - // Single macro to execute, if got 1 argument that is a non-option. - else if ( argc == 2 && optind < argc ) { - stringstream str; - str << "/control/execute "; - str << argv[1]; - m_g4q.add( str.str() ); - } - // Probably extra arguments or no options. - else if ( optind == 1 || optind < argc ) { - printUsage(); - abort(); - } - // Default is process all the options and build the CommandQueue. - else { - processOptions(); - } - } - - void CommandLineProcessor::printUsage() - { - printVersion(); - - log() << LOG::okay << LOG::done; - log() << LOG::okay << "**************" << LOG::done; - log() << LOG::okay << "* SLIC Usage *" << LOG::done; - log() << LOG::okay << "**************" << LOG::done; - - log() << LOG::okay << LOG::done; - log() << LOG::okay << "Command line usage: " << LOG::done; - log() << LOG::okay << LOG::done; - log() << LOG::okay << "slic [single_macro_path]" << LOG::done; - log() << LOG::okay << "slic [options]" << LOG::done; - - log() << LOG::okay << LOG::done; - - log() << LOG::okay << "Interactive usage: " << LOG::done; - log() << LOG::okay << LOG::done; - log() << LOG::okay << "slic -n" << LOG::done; - - log() << LOG::okay << LOG::done; - - printOptions(); - - log() << LOG::okay << LOG::done; - } - - void CommandLineProcessor::abort() - { - exit(0); - } - - void CommandLineProcessor::registerOptions() - { - // Print application usage. - addOption(new CommandLineOption("h", - "help", - "Print SLIC usage.", - 0, - 0, - "/slic/usage")); - - // Usage is also activated with the '?' switch. - addOption(new CommandLineOption("?", - "help", - "Print SLIC usage.", - 0, - 0, - "/slic/usage")); - - // Run in interactive mode. - addOption(new CommandLineOption("n", - "interactive", - "Start a Geant4 interactive session.", - 0, - 0, - "/control/interactive")); - - // Print SLIC version info. - addOption(new CommandLineOption("v", - "version", - "Print SLIC version.", - 0, - 0, - "/slic/version")); - - // Execute the commands from a macro file. - addOption(new CommandLineOption("m", - "macro", - "Execute Geant4 commands from a file.", - 1, - 1, - "/control/execute")); - - // Set the URL of the input LCDD file. - addOption(new CommandLineOption("g", - "lcdd-url", - "Set LCDD geometry file URL.", - 1, - 1, - "/lcdd/url")); - - // Set the path to a generator file, e.g. StdHep or LCIO. - addOption(new CommandLineOption("i", - "event-file", - "Set event input file full path.", - 1, - 1, - "/generator/filename")); - - // Set the name of the LCIO output file. - addOption(new CommandLineOption("o", - "lcio-file", - "Set name of LCIO output file.", - 1, - 1, - "/lcio/filename")); - - // Set the path of output files. - addOption(new CommandLineOption("p", - "lcio-path", - "Set directory for LCIO output.", - 1, - 1, - "/lcio/path")); - - // Automatically name the LCIO output file. - addOption(new CommandLineOption("O", - "autoname", - "Automatically name the LCIO output file.", - 0, - 1, - "/lcio/autoname")); - - // Overwrite an existing LCIO output file. - addOption(new CommandLineOption("x", - "lcio-delete", - "Delete an existing LCIO file.", - 0, - 0, - "/lcio/fileExists delete")); - - // Number of events to run. - addOption(new CommandLineOption("r", - "run-events", - "Run # of events.", - 1, - 1, - "/run/beamOn")); - - // Set number of events to skip from a file-based event source (e.g. StdHep). - addOption(new CommandLineOption("s", - "skip-events", - "Set number of events to skip.", - 1, - 1, - "/generator/skipEvents")); - - // Set the physics list. - addOption(new CommandLineOption("l", - "physics-list", - "Set Geant4 physics list.", - 1, - 1, - "/physics/select")); - - // Set the name of the log file. - addOption(new CommandLineOption("L", - "log-file", - "Set logfile name.", - 0, - 0, - "/log/filename")); - - // Set the random seed. - addOption(new CommandLineOption("d", - "seed", - "Set the random seed. (No argument seeds with time.)", - 0, - 1, - "/random/seed")); - - // Dump the loaded Geant4 geometry to a GDML file. - addOption(new CommandLineOption("G", - "dump-gdml", - "Dump geometry to GDML file.", - 1, - 1, - "/lcdd/dumpGDML")); - - // Enable optical physics processes. - addOption(new CommandLineOption("c", - "optical", - "Enable optical physics processes.", - 0, - 0, - "/physics/enableOptical")); - - // Set location of particle.tbl. - addOption(new CommandLineOption("P", - "pdg-file", - "Set location of particle.tbl file.", - 1, - 1, - "/physics/setPDGFile")); - } - - void CommandLineProcessor::processOption(const string& opt) - { - // Loop over all input arguments to look for this option. - for ( CommandLineArguments::iterator it = m_commandline.begin(); - it != m_commandline.end(); - it++ ) { - - // Look for a matching switch in the arguments. - if ( it->first == opt ) { - - // Get the associated specification for this option. - CommandLineOption* cmdlineopt = getCommandLineOption(opt); - - // We must have a valid option! - assert(cmdlineopt != 0); - - // Get the associated Geant4 command string. - string cmdstr = cmdlineopt->getG4CommandString(); - - // Add arguments to the command string, if some were passed. - if ( it->second != "" ) { - cmdstr += " "; - cmdstr += it->second; - } - - // Add the command string to the CommandQueue. - m_g4q.add(cmdstr); - } - } - } - - void CommandLineProcessor::addOption(CommandLineOption* opt) - { - m_cmds.push_back(opt); - } - - void CommandLineProcessor::processOptions() - { - // Logger. - processOption("L"); - - // Geometry file. - processOption("g"); - - // Optical processes. - processOption("c"); - - // SUSY data. - processOption("P"); - - // Physics list. - processOption("l"); - - // Add initialization after geometry and physics, - // but only if there was a geometry file argument. - // Otherwise, initialize is not called, and the - // user is given the PreInit prompt. - if ( hasOption("g") ) { - m_g4q.add("/run/initialize"); - } - - // Dump gdml. - processOption("G"); - - // Random seed. - processOption("d"); - - // Event file. - processOption("i"); - - // Output path. - processOption("p"); - - // Delete existing LCIO file. - processOption("x"); - - // Set LCIO file name. - processOption("o"); - - // Autoname the LCIO file. - processOption("O"); - - // Events to skip. - processOption("s"); - - // Geant4 macro to run. - processOption("m"); - - // Events to run. - processOption("r"); - - // Interactive mode, if selected. - if (m_interactive_flag) { - m_g4q.add("/control/interactive"); - } - } - - void CommandLineProcessor::printOptions() - { - log() << LOG::okay << "************************" << LOG::done; - log() << LOG::okay << "* Command Line Options *" << LOG::done; - log() << LOG::okay << "************************" << LOG::done; - log() << LOG::okay << LOG::done; - - static const int opt_width = 8; - static const int descr_width = 15; - static const int name_width = 16; - static const int cmd_width = 24; - static const int sep_width = 60; - - log().getOutputStream().width(opt_width); - log().getOutputStream() << left; - - log().getOutputStream() << left; - log() << LOG::okay << "Option"; - - log().getOutputStream().width(name_width); - log().getOutputStream() << left; - log() << LOG::okay << "Full Name"; - - log().getOutputStream().width(cmd_width); - log().getOutputStream() << left; - log() << LOG::okay << "Macro Command"; - - log().getOutputStream().width(descr_width); - log().getOutputStream() << left; - log() << LOG::okay << "Description"; - - log().getOutputStream().fill('-'); - log().getOutputStream().width(sep_width); - - log() << LOG::okay << LOG::done; - log() << LOG::okay << '-' << LOG::done; - - log().getOutputStream().fill(' '); - - for ( OptionsList::const_iterator iter = m_cmds.begin(); - iter != m_cmds.end(); - iter++ ) { - CommandLineOption* cl_opt = (*iter); - - std::string opt_str = "-" + cl_opt->getShortName(); - log().getOutputStream().width(opt_width); - log().getOutputStream() << left; - log() << LOG::okay << opt_str; - - std::string name_str = "--" + cl_opt->getLongName(); - log().getOutputStream().width(name_width); - log().getOutputStream() << left; - log() << LOG::okay << name_str; - - log().getOutputStream().width(cmd_width); - log().getOutputStream() << left; - log() << LOG::okay << cl_opt->getG4CommandString(); - - log().getOutputStream().width(descr_width); - log().getOutputStream() << left; - log() << LOG::okay << cl_opt->getDescription(); - - log() << LOG::okay << LOG::done; - } - } - - CommandLineOption* CommandLineProcessor::getCommandLineOption(const std::string& opt) - { - CommandLineOption* clo = 0; - for ( OptionsList::const_iterator iter = m_cmds.begin(); - iter != m_cmds.end(); - iter++ ) { - if ( (*iter)->getShortName() == opt ) { - clo = (*iter); - break; - } - } - return clo; - } - - bool CommandLineProcessor::hasOption(const std::string& opt) - { - bool hasoption = false; - for ( CommandLineArguments::iterator it = m_commandline.begin(); - it != m_commandline.end(); - it++ ) { - if ( (*it).first == opt ) { - hasoption=true; - break; - } - } - return hasoption; - } - - void CommandLineProcessor::createOptionsString() - { - m_getoptOptions=""; - for ( OptionsList::iterator it = m_cmds.begin(); - it != m_cmds.end(); - it++ ) { - CommandLineOption* opt = *it; - m_getoptOptions += opt->getShortName(); - if ( opt->getMinArgs() ) { - m_getoptOptions += ":"; - } - else if ( opt->getMaxArgs() ) { - m_getoptOptions += "::"; - } - } - }
+ + // Done. + if (c == -1) + break; + + // Handle options. + switch (c) { + + case 'h': + m_help_flag = 1; + break; + + case '?': + m_help_flag = 1; + break; + + case 'n': + m_interactive_flag = 1; + break; + + case 'v': + m_version_flag = 1; + break; + + default: + + stringstream ostr; + char cc = (char) c; + ostr << cc; + string theopt = ostr.str(); + + if (optarg) { + m_commandline.push_back(OptionsPair(theopt, optarg)); + } else { + m_commandline.push_back(OptionsPair(theopt, "")); + } + + break; + } + } + + // + // The processing flow... + // + // 1) If version flag is set, print version and exit. + // + // 2) If usage flag is set or no arguments were received, + // print the usage and exit. + // + // 3) If a single non-option command was received, treat + // it as a macro to execute. + // + // 4) If no options were received or the number of options + // is less than the number of arguments, print usage + // and exit (syntax incorrect). + // + // 5) Finally, process the options in order if the syntax + // appears to be okay. + // + + // Print the version information and abort. + if (m_version_flag) { + printVersion(); + abort(); + } + // Print the usage and abort if the help flag is set + // or no arguments were received. + else if (m_help_flag || argc == 1) { + printUsage(); + abort(); + } + // Single macro to execute, if got 1 argument that is a non-option. + else if (argc == 2 && optind < argc) { + stringstream str; + str << "/control/execute "; + str << argv[1]; + m_g4q.add(str.str()); + } + // Probably extra arguments or no options. + else if (optind == 1 || optind < argc) { + printUsage(); + abort(); + } + // Default is process all the options and build the CommandQueue. + else { + processOptions(); + } +} + +void CommandLineProcessor::printUsage() { + printVersion(); + + log() << LOG::okay << LOG::done; + log() << LOG::okay << "**************" << LOG::done; + log() << LOG::okay << "* SLIC Usage *" << LOG::done; + log() << LOG::okay << "**************" << LOG::done; + + log() << LOG::okay << LOG::done; + log() << LOG::okay << "Command line usage: " << LOG::done; + log() << LOG::okay << LOG::done; + log() << LOG::okay << "slic [single_macro_path]" << LOG::done; + log() << LOG::okay << "slic [options]" << LOG::done; + + log() << LOG::okay << LOG::done; + + log() << LOG::okay << "Interactive usage: " << LOG::done; + log() << LOG::okay << LOG::done; + log() << LOG::okay << "slic -n" << LOG::done; + + log() << LOG::okay << LOG::done; + + printOptions(); + + log() << LOG::okay << LOG::done; +} + +void CommandLineProcessor::abort() { + exit(0); +} + +void CommandLineProcessor::registerOptions() { + // Print application usage. + addOption(new CommandLineOption("h", "help", "Print SLIC usage.", 0, 0, "/slic/usage")); + + // Usage is also activated with the '?' switch. + addOption(new CommandLineOption("?", "help", "Print SLIC usage.", 0, 0, "/slic/usage")); + + // Run in interactive mode. + addOption( + new CommandLineOption("n", "interactive", "Start a Geant4 interactive session.", 0, 0, + "/control/interactive")); + + // Print SLIC version info. + addOption(new CommandLineOption("v", "version", "Print SLIC version.", 0, 0, "/slic/version")); + + // Execute the commands from a macro file. + addOption( + new CommandLineOption("m", "macro", "Execute Geant4 commands from a file.", 1, 1, + "/control/execute")); + + // Set the URL of the input LCDD file. + addOption(new CommandLineOption("g", "lcdd-url", "Set LCDD geometry file URL.", 1, 1, "/lcdd/url")); + + // Set the path to a generator file, e.g. StdHep or LCIO. + addOption( + new CommandLineOption("i", "event-file", "Set event input file full path.", 1, 1, + "/generator/filename")); + + // Set the name of the LCIO output file. + addOption( + new CommandLineOption("o", "lcio-file", "Set name of LCIO output file.", 1, 1, "/lcio/filename")); + + // Set the path of output files. + addOption(new CommandLineOption("p", "lcio-path", "Set directory for LCIO output.", 1, 1, "/lcio/path")); + + // Automatically name the LCIO output file. + addOption( + new CommandLineOption("O", "autoname", "Automatically name the LCIO output file.", 0, 1, + "/lcio/autoname")); + + // Overwrite an existing LCIO output file. + addOption( + new CommandLineOption("x", "lcio-delete", "Delete an existing LCIO file.", 0, 0, + "/lcio/fileExists delete")); + + // Number of events to run. + addOption(new CommandLineOption("r", "run-events", "Run # of events.", 1, 1, "/run/beamOn")); + + // Set number of events to skip from a file-based event source (e.g. StdHep). + addOption( + new CommandLineOption("s", "skip-events", "Set number of events to skip.", 1, 1, + "/generator/skipEvents")); + + // Set the physics list. + addOption( + new CommandLineOption("l", "physics-list", "Set Geant4 physics list.", 1, 1, "/physics/select")); + + // Set the name of the log file. + addOption(new CommandLineOption("L", "log-file", "Set logfile name.", 0, 0, "/log/filename")); + + // Set the random seed. + addOption( + new CommandLineOption("d", "seed", "Set the random seed. (No argument seeds with time.)", 0, 1, + "/random/seed")); + + // Dump the loaded Geant4 geometry to a GDML file. + addOption(new CommandLineOption("G", "dump-gdml", "Dump geometry to GDML file.", 1, 1, "/lcdd/dumpGDML")); + + // Enable optical physics processes. + addOption( + new CommandLineOption("c", "optical", "Enable optical physics processes.", 0, 0, + "/physics/enableOptical")); + + // Set location of particle.tbl. + addOption( + new CommandLineOption("P", "pdg-file", "Set location of particle.tbl file.", 1, 1, + "/physics/setPDGFile")); +} + +void CommandLineProcessor::processOption(const string& opt) { + // Loop over all input arguments to look for this option. + for (CommandLineArguments::iterator it = m_commandline.begin(); it != m_commandline.end(); it++) { + + // Look for a matching switch in the arguments. + if (it->first == opt) { + + // Get the associated specification for this option. + CommandLineOption* cmdlineopt = getCommandLineOption(opt); + + // We must have a valid option! + assert(cmdlineopt != 0); + + // Get the associated Geant4 command string. + string cmdstr = cmdlineopt->getG4CommandString(); + + // Add arguments to the command string, if some were passed. + if (it->second != "") { + cmdstr += " "; + cmdstr += it->second; + } + + // Add the command string to the CommandQueue. + m_g4q.add(cmdstr); + } + } +} + +void CommandLineProcessor::addOption(CommandLineOption* opt) { + m_cmds.push_back(opt); +} + +void CommandLineProcessor::processOptions() { + // Logger. + processOption("L"); + + // Geometry file. + processOption("g"); + + // Optical processes. + processOption("c"); + + // SUSY data. + processOption("P"); + + // Physics list. + processOption("l"); + + // Add initialization after geometry and physics, + // but only if there was a geometry file argument. + // Otherwise, initialize is not called, and the + // user is given the PreInit prompt. + if (hasOption("g")) { + m_g4q.add("/run/initialize"); + } + + // Dump gdml. + processOption("G"); + + // Random seed. + processOption("d"); + + // Event file. + processOption("i"); + + // Output path. + processOption("p"); + + // Delete existing LCIO file. + processOption("x"); + + // Set LCIO file name. + processOption("o"); + + // Autoname the LCIO file. + processOption("O"); + + // Events to skip. + processOption("s"); + + // Geant4 macro to run. + processOption("m"); + + // Events to run. + processOption("r"); + + // Interactive mode, if selected. + if (m_interactive_flag) { + m_g4q.add("/control/interactive"); + } +} + +void CommandLineProcessor::printOptions() { + log() << LOG::okay << "************************" << LOG::done; + log() << LOG::okay << "* Command Line Options *" << LOG::done; + log() << LOG::okay << "************************" << LOG::done; + log() << LOG::okay << LOG::done; + + static const int opt_width = 8; + static const int descr_width = 15; + static const int name_width = 16; + static const int cmd_width = 24; + static const int sep_width = 60; + + log().getOutputStream().width(opt_width); + log().getOutputStream() << left; + + log().getOutputStream() << left; + log() << LOG::okay << "Option"; + + log().getOutputStream().width(name_width); + log().getOutputStream() << left; + log() << LOG::okay << "Full Name"; + + log().getOutputStream().width(cmd_width); + log().getOutputStream() << left; + log() << LOG::okay << "Macro Command"; + + log().getOutputStream().width(descr_width); + log().getOutputStream() << left; + log() << LOG::okay << "Description"; + + log().getOutputStream().fill('-'); + log().getOutputStream().width(sep_width); + + log() << LOG::okay << LOG::done; + log() << LOG::okay << '-' << LOG::done; + + log().getOutputStream().fill(' '); + + for (OptionsList::const_iterator iter = m_cmds.begin(); iter != m_cmds.end(); iter++) { + CommandLineOption* cl_opt = (*iter); + + std::string opt_str = "-" + cl_opt->getShortName(); + log().getOutputStream().width(opt_width); + log().getOutputStream() << left; + log() << LOG::okay << opt_str; + + std::string name_str = "--" + cl_opt->getLongName(); + log().getOutputStream().width(name_width); + log().getOutputStream() << left; + log() << LOG::okay << name_str; + + log().getOutputStream().width(cmd_width); + log().getOutputStream() << left; + log() << LOG::okay << cl_opt->getG4CommandString(); + + log().getOutputStream().width(descr_width); + log().getOutputStream() << left; + log() << LOG::okay << cl_opt->getDescription(); + + log() << LOG::okay << LOG::done; + } +} + +CommandLineOption* CommandLineProcessor::getCommandLineOption(const std::string& opt) { + CommandLineOption* clo = 0; + for (OptionsList::const_iterator iter = m_cmds.begin(); iter != m_cmds.end(); iter++) { + if ((*iter)->getShortName() == opt) { + clo = (*iter); + break; + } + } + return clo; +} + +bool CommandLineProcessor::hasOption(const std::string& opt) { + bool hasoption = false; + for (CommandLineArguments::iterator it = m_commandline.begin(); it != m_commandline.end(); it++) { + if ((*it).first == opt) { + hasoption = true; + break; + } + } + return hasoption; +} + +void CommandLineProcessor::createOptionsString() { + m_getoptOptions = ""; + for (OptionsList::iterator it = m_cmds.begin(); it != m_cmds.end(); it++) { + CommandLineOption* opt = *it; + m_getoptOptions += opt->getShortName(); + if (opt->getMinArgs()) { + m_getoptOptions += ":"; + } else if (opt->getMaxArgs()) { + m_getoptOptions += "::"; + } + } +}
} // namespace slic
diff -u -r1.3 -r1.4 --- CommandQueue.cc 8 Jan 2010 23:18:56 -0000 1.3 +++ CommandQueue.cc 27 Nov 2012 19:32:19 -0000 1.4 @@ -1,45 +1,35 @@
-// $Header: /cvs/lcd/slic/src/CommandQueue.cc,v 1.3 2010/01/08 23:18:56 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/CommandQueue.cc,v 1.4 2012/11/27 19:32:19 jeremy Exp $
#include "CommandQueue.hh" // geant4 #include "G4UImanager.hh"
-namespace slic -{ - void CommandQueue::printOut() - { - log() << LOG::always << "************************" << LOG::done; - log() << LOG::always << "* Geant4 Command Queue *" << LOG::done; - log() << LOG::always << "************************" << LOG::done; - for ( CmdVecType::iterator iter = cmdsBegin(); - iter != cmdsEnd(); - iter++ ) { - log() << LOG::always << *iter << LOG::done; - } - log() << LOG::always << LOG::done; - }
+namespace slic { +void CommandQueue::printOut() { + log() << LOG::always << "************************" << LOG::done; + log() << LOG::always << "* Geant4 Command Queue *" << LOG::done; + log() << LOG::always << "************************" << LOG::done; + for (CmdVecType::iterator iter = cmdsBegin(); iter != cmdsEnd(); iter++) { + log() << LOG::always << *iter << LOG::done; + } + log() << LOG::always << LOG::done; +}
- void CommandQueue::execute() - { - for ( CmdVecType::iterator iter = cmdsBegin(); - iter != cmdsEnd(); - iter++ ) { - std::string cmd = *iter; - G4UImanager::GetUIpointer()->ApplyCommand( cmd ); - } - }
+void CommandQueue::execute() { + for (CmdVecType::iterator iter = cmdsBegin(); iter != cmdsEnd(); iter++) { + std::string cmd = *iter; + G4UImanager::GetUIpointer()->ApplyCommand(cmd); + } +}
- CommandQueue::CmdVecType::iterator CommandQueue::find(const std::string& str) - { - CmdVecType::iterator iter = m_commands.begin(); - for ( ; - iter != m_commands.end(); - iter++ ) { - if ( (*iter).find(str) != std::string::npos ) { - break; - } - } - return iter; - }
+CommandQueue::CmdVecType::iterator CommandQueue::find(const std::string& str) { + CmdVecType::iterator iter = m_commands.begin(); + for (; iter != m_commands.end(); iter++) { + if ((*iter).find(str) != std::string::npos) { + break; + } + } + return iter; +}
}
diff -u -r1.30 -r1.31 --- EventAction.cc 13 Jul 2012 20:09:02 -0000 1.30 +++ EventAction.cc 27 Nov 2012 19:32:19 -0000 1.31 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/EventAction.cc,v 1.30 2012/07/13 20:09:02 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventAction.cc,v 1.31 2012/11/27 19:32:19 jeremy Exp $
#include "EventAction.hh"
@@ -18,95 +18,86 @@
#include "G4SDManager.hh" #include "G4Event.hh"
-namespace slic -{
+namespace slic {
- EventAction::EventAction() - : G4UserEventAction(), - Module("EventAction", false), - m_enableEventTimer(false) - { - m_messenger = new EventMessenger(); - } - - EventAction::~EventAction() - {} - - void EventAction::BeginOfEventAction (const G4Event *anEvent) - { - // check aborted - if (!anEvent->IsAborted() ) { - - // debugger - //EventDebugger::instance()->beginEvent( anEvent ); - - // trj mgr - TrajectoryManager::instance()->beginEvent( anEvent ); - - /* MCP begin event */ - LcioMcpManager::instance()->beginEvent(anEvent); - }
+EventAction::EventAction() : + G4UserEventAction(), Module("EventAction", false), m_enableEventTimer(false) { + m_messenger = new EventMessenger(); +} + +EventAction::~EventAction() { +} + +void EventAction::BeginOfEventAction(const G4Event *anEvent) { + // check aborted + if (!anEvent->IsAborted()) { + + // debugger + //EventDebugger::instance()->beginEvent( anEvent ); + + // trj mgr + TrajectoryManager::instance()->beginEvent(anEvent); + + /* MCP begin event */ + LcioMcpManager::instance()->beginEvent(anEvent); + }
#ifdef SLIC_LOG
- else { - log().warning("aborted EventAction::BeginOfEventAction"); - }
+ else { + log().warning("aborted EventAction::BeginOfEventAction"); + }
#endif
- }
+}
- void EventAction::EndOfEventAction (const G4Event *anEvent) - { - // check aborted - if (!SlicApplication::instance()->isAborting()) { - // LcioManager's action - LcioManager::instance()->endEvent(anEvent); - } - - // event source (generator) action - EventSourceManager::instance()->endEvent(anEvent); - - // event timer - stopEventTimer(); - - // debugger - //EventDebugger::instance()->endEvent(anEvent); - - // end event mesg - printEndEventMessage(anEvent); - } - - void EventAction::printEndEventMessage(const G4Event *anEvent) - { - log() << LOG::okay << ">>>> EndEvent <" + StringUtil::toString( anEvent->GetEventID() ) + ">" << LOG::endl << LOG::done; - } - - EventAction* EventAction::getEventAction() - { - const EventAction* ea = static_cast<const EventAction*> ( G4RunManager::GetRunManager()->GetUserEventAction() ); - return const_cast<EventAction*> ( ea ); - } - - void EventAction::stopEventTimer() - { - if ( m_enableEventTimer ) { - m_eventTimer.Stop();
+void EventAction::EndOfEventAction(const G4Event *anEvent) { + // check aborted + if (!SlicApplication::instance()->isAborting()) { + // LcioManager's action + LcioManager::instance()->endEvent(anEvent); + } + + // event source (generator) action + EventSourceManager::instance()->endEvent(anEvent); + + // event timer + stopEventTimer(); + + // debugger + //EventDebugger::instance()->endEvent(anEvent); + + // end event mesg + printEndEventMessage(anEvent); +} + +void EventAction::printEndEventMessage(const G4Event *anEvent) { + log() << LOG::okay << ">>>> EndEvent <" + StringUtil::toString(anEvent->GetEventID()) + ">" << LOG::endl + << LOG::done; +} + +EventAction* EventAction::getEventAction() { + const EventAction* ea = + static_cast<const EventAction*>(G4RunManager::GetRunManager()->GetUserEventAction()); + return const_cast<EventAction*>(ea); +} + +void EventAction::stopEventTimer() { + if (m_enableEventTimer) { + m_eventTimer.Stop();
#ifdef SLIC_LOG
- log() << LOG::okay << "Event Timer: " << m_eventTimer << LOG::done;
+ log() << LOG::okay << "Event Timer: " << m_eventTimer << LOG::done;
#endif
- } - }
+ } +}
- void EventAction::startEventTimer() - { - if ( m_enableEventTimer ) { - m_eventTimer.Start();
+void EventAction::startEventTimer() { + if (m_enableEventTimer) { + m_eventTimer.Start();
#ifdef SLIC_LOG
- log() << LOG::verbose << "Started Event Timer." << LOG::done;
+ log() << LOG::verbose << "Started Event Timer." << LOG::done;
#endif
- } - }
+ } +}
- void EventAction::enableEventTimer(bool et) - { - m_enableEventTimer = et; - }
+void EventAction::enableEventTimer(bool et) { + m_enableEventTimer = et; +}
}
diff -u -r1.6 -r1.7 --- EventDebugger.cc 27 Apr 2007 01:54:34 -0000 1.6 +++ EventDebugger.cc 27 Nov 2012 19:32:19 -0000 1.7 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/EventDebugger.cc,v 1.6 2007/04/27 01:54:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventDebugger.cc,v 1.7 2012/11/27 19:32:19 jeremy Exp $
#include "EventDebugger.hh" // slic
@@ -9,126 +9,105 @@
#include "G4Event.hh" #include "G4UImanager.hh"
-namespace slic -{ - EventDebugger::EventDebugger() - : Module("EventDebugger"), - m_debugging(false), - m_haveDebugMacro(false), - m_haveCleanupMacro(false), - m_forceDebugMode(false) - { - m_messenger = new EventDebuggerMessenger(); - } - - EventDebugger::~EventDebugger() - { - delete m_messenger; - } - - void EventDebugger::enableDebug(bool e) - { - m_forceDebugMode = e; - } - - void EventDebugger::addDebugEvent(G4int eventNum) - { - if ( !haveDebugEvent(eventNum) ) { - m_events.push_back(eventNum);
+namespace slic { +EventDebugger::EventDebugger() : + Module("EventDebugger"), m_debugging(false), m_haveDebugMacro(false), m_haveCleanupMacro(false), m_forceDebugMode( + false) { + m_messenger = new EventDebuggerMessenger(); +} + +EventDebugger::~EventDebugger() { + delete m_messenger; +} + +void EventDebugger::enableDebug(bool e) { + m_forceDebugMode = e; +} + +void EventDebugger::addDebugEvent(G4int eventNum) { + if (!haveDebugEvent(eventNum)) { + m_events.push_back(eventNum);
#ifdef SLIC_LOG
- log() << LOG::okay << "EventDebugger - Added debug event <" << eventNum << ">" << LOG::done;
+ log() << LOG::okay << "EventDebugger - Added debug event <" << eventNum << ">" << LOG::done;
#endif
- }
+ }
#ifdef SLIC_LOG
- else { - log() << LOG::warning << "EventDebugger - Ignoring dup event #" << eventNum << LOG::done; - }
+ else { + log() << LOG::warning << "EventDebugger - Ignoring dup event #" << eventNum << LOG::done; + }
#endif
- }
+}
- void EventDebugger::setDebugMacro(std::string mac) - { - m_haveDebugMacro = true; - m_debugMacro = mac; - } - - void EventDebugger::setCleanupMacro(std::string mac) - { - m_haveCleanupMacro = true; - m_cleanupMacro = mac; - } - - void EventDebugger::clearDebugEvents() - { - m_events.clear(); - } - - void EventDebugger::sortDebugEvents() - { - std::sort(m_events.begin(), m_events.end() ); - } - - bool EventDebugger::haveDebugEvent(G4int evtNum) const - { - for ( DebugEventList::const_iterator it = m_events.begin(); - it != m_events.end(); - it++ ) { - if ( (*it) == evtNum ) { - return true; - } - } - return false; - } - - void EventDebugger::beginRun(const G4Run*) - { - sortDebugEvents(); - } - - void EventDebugger::beginEvent(const G4Event* evt) - { - if ( m_forceDebugMode || - haveDebugEvent( evt->GetEventID() ) ) { - m_debugging = true; - execDebugMacro(); - } - } - - void EventDebugger::endEvent(const G4Event*) - { - if ( m_debugging ) { - execCleanupMacro(); - m_debugging = false; - } - } - - void EventDebugger::execDebugMacro() - { - if ( m_haveDebugMacro ) { - G4UImanager::GetUIpointer()->ApplyCommand( "/control/execute " + m_debugMacro );
+void EventDebugger::setDebugMacro(std::string mac) { + m_haveDebugMacro = true; + m_debugMacro = mac; +} + +void EventDebugger::setCleanupMacro(std::string mac) { + m_haveCleanupMacro = true; + m_cleanupMacro = mac; +} + +void EventDebugger::clearDebugEvents() { + m_events.clear(); +} + +void EventDebugger::sortDebugEvents() { + std::sort(m_events.begin(), m_events.end()); +} + +bool EventDebugger::haveDebugEvent(G4int evtNum) const { + for (DebugEventList::const_iterator it = m_events.begin(); it != m_events.end(); it++) { + if ((*it) == evtNum) { + return true; + } + } + return false; +} + +void EventDebugger::beginRun(const G4Run*) { + sortDebugEvents(); +} + +void EventDebugger::beginEvent(const G4Event* evt) { + if (m_forceDebugMode || haveDebugEvent(evt->GetEventID())) { + m_debugging = true; + execDebugMacro(); + } +} + +void EventDebugger::endEvent(const G4Event*) { + if (m_debugging) { + execCleanupMacro(); + m_debugging = false; + } +} + +void EventDebugger::execDebugMacro() { + if (m_haveDebugMacro) { + G4UImanager::GetUIpointer()->ApplyCommand("/control/execute " + m_debugMacro);
#ifdef SLIC_LOG
- if ( !m_haveCleanupMacro ) { - log() << "WARNING: Executed debugging macro, but cleanup macro was not set." << LOG::done; - }
+ if ( !m_haveCleanupMacro ) { + log() << "WARNING: Executed debugging macro, but cleanup macro was not set." << LOG::done; + }
#endif
- }
+ }
#ifdef SLIC_LOG
- else { - log() << LOG::error << "ERROR: debug macro not set" << LOG::done; - }
+ else { + log() << LOG::error << "ERROR: debug macro not set" << LOG::done; + }
#endif
- }
+}
- void EventDebugger::execCleanupMacro() - { - if ( m_haveCleanupMacro ) { - G4UImanager::GetUIpointer()->ApplyCommand( "/control/execute " + m_cleanupMacro ); - }
+void EventDebugger::execCleanupMacro() { + if (m_haveCleanupMacro) { + G4UImanager::GetUIpointer()->ApplyCommand("/control/execute " + m_cleanupMacro); + }
#ifdef SLIC_LOG
- else { - log() << LOG::error << "ERROR: cleanup macro not set" << LOG::done; - }
+ else { + log() << LOG::error << "ERROR: cleanup macro not set" << LOG::done; + }
#endif
- }
+}
} // namespace slic
diff -u -r1.4 -r1.5 --- EventDebuggerMessenger.cc 9 Dec 2005 01:58:34 -0000 1.4 +++ EventDebuggerMessenger.cc 27 Nov 2012 19:32:19 -0000 1.5 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/EventDebuggerMessenger.cc,v 1.4 2005/12/09 01:58:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventDebuggerMessenger.cc,v 1.5 2012/11/27 19:32:19 jeremy Exp $
#include "EventDebuggerMessenger.hh" // slic
@@ -11,68 +11,58 @@
#include "G4UIcmdWithAString.hh" #include "G4UIcmdWithABool.hh"
-namespace slic -{ - EventDebuggerMessenger::EventDebuggerMessenger() - { - defineCommands(); - } - - EventDebuggerMessenger::~EventDebuggerMessenger() - {} - - void EventDebuggerMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) - { - EventDebugger* debugger = EventDebugger::instance(); - if ( cmd == m_debugMacroCmd ) { - debugger->setDebugMacro( newVals ); - } - else if ( cmd == m_cleanupMacroCmd ) { - debugger->setCleanupMacro( newVals ); - } - else if ( cmd == m_addDebugEventsCmd ) { - - std::vector<std::string> strList; - const std::string str = std::string(newVals); - const std::string delim = " "; - - StringUtil::split( str, delim, strList ); - - EventDebugger::DebugEventList dbgList; - for ( std::vector<std::string>::iterator it = strList.begin(); - it != strList.end(); - it++ ) { - debugger->addDebugEvent(StringUtil::toInt(*it)); - } - } - else if ( cmd == m_clearDebugEventsCmd ) { - debugger->clearDebugEvents(); - } - else if ( cmd == m_enableDebugCmd ) { - debugger->enableDebug( m_enableDebugCmd->GetNewBoolValue( newVals.c_str() ) ); - } - } - - void EventDebuggerMessenger::defineCommands() - { - m_debugDir = new G4UIdirectory( "/debug/" ); - m_debugDir->SetGuidance( "Debugging commands. [SLIC]" ); - - m_debugMacroCmd = new G4UIcmdWithAString( "/debug/debugMacro", this ); - m_debugMacroCmd->SetGuidance( "Set macro for debugging." ); - - m_cleanupMacroCmd = new G4UIcmdWithAString( "/debug/cleanupMacro", this ); - m_cleanupMacroCmd->SetGuidance( "Set macro to cleanup debug state." ); - - m_addDebugEventsCmd = new G4UIcmdWithAString( "/debug/addEvents", this ); - m_addDebugEventsCmd->SetGuidance( "Add event IDs to debug, separated by spaces." ); - - m_clearDebugEventsCmd = new G4UIcommand( "/debug/clearEvents", this ); - m_clearDebugEventsCmd->SetGuidance( "Clear the list of events to debug." ); - - m_enableDebugCmd = new G4UIcmdWithABool( "/debug/enableDebug", this ); - m_enableDebugCmd->SetGuidance( "Enable event debugging for all subsequent events." ); - m_enableDebugCmd->SetParameterName("enable", true); - m_enableDebugCmd->SetDefaultValue(true); - }
+namespace slic { +EventDebuggerMessenger::EventDebuggerMessenger() { + defineCommands(); +} + +EventDebuggerMessenger::~EventDebuggerMessenger() { +} + +void EventDebuggerMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) { + EventDebugger* debugger = EventDebugger::instance(); + if (cmd == m_debugMacroCmd) { + debugger->setDebugMacro(newVals); + } else if (cmd == m_cleanupMacroCmd) { + debugger->setCleanupMacro(newVals); + } else if (cmd == m_addDebugEventsCmd) { + + std::vector<std::string> strList; + const std::string str = std::string(newVals); + const std::string delim = " "; + + StringUtil::split(str, delim, strList); + + EventDebugger::DebugEventList dbgList; + for (std::vector<std::string>::iterator it = strList.begin(); it != strList.end(); it++) { + debugger->addDebugEvent(StringUtil::toInt(*it)); + } + } else if (cmd == m_clearDebugEventsCmd) { + debugger->clearDebugEvents(); + } else if (cmd == m_enableDebugCmd) { + debugger->enableDebug(m_enableDebugCmd->GetNewBoolValue(newVals.c_str())); + } +} + +void EventDebuggerMessenger::defineCommands() { + m_debugDir = new G4UIdirectory("/debug/"); + m_debugDir->SetGuidance("Debugging commands. [SLIC]"); + + m_debugMacroCmd = new G4UIcmdWithAString("/debug/debugMacro", this); + m_debugMacroCmd->SetGuidance("Set macro for debugging."); + + m_cleanupMacroCmd = new G4UIcmdWithAString("/debug/cleanupMacro", this); + m_cleanupMacroCmd->SetGuidance("Set macro to cleanup debug state."); + + m_addDebugEventsCmd = new G4UIcmdWithAString("/debug/addEvents", this); + m_addDebugEventsCmd->SetGuidance("Add event IDs to debug, separated by spaces."); + + m_clearDebugEventsCmd = new G4UIcommand("/debug/clearEvents", this); + m_clearDebugEventsCmd->SetGuidance("Clear the list of events to debug."); + + m_enableDebugCmd = new G4UIcmdWithABool("/debug/enableDebug", this); + m_enableDebugCmd->SetGuidance("Enable event debugging for all subsequent events."); + m_enableDebugCmd->SetParameterName("enable", true); + m_enableDebugCmd->SetDefaultValue(true); +}
} // namespace slic
diff -u -r1.4 -r1.5 --- EventMessenger.cc 31 Jan 2012 18:52:30 -0000 1.4 +++ EventMessenger.cc 27 Nov 2012 19:32:19 -0000 1.5 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/EventMessenger.cc,v 1.4 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventMessenger.cc,v 1.5 2012/11/27 19:32:19 jeremy Exp $
#include "EventMessenger.hh" // slic
@@ -7,37 +7,32 @@
// geant4 #include "G4UIcmdWithABool.hh"
-namespace slic -{ - EventMessenger::EventMessenger() - { - defineCommands(); - } - - EventMessenger::~EventMessenger() - {} - - void EventMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) - { - if ( cmd == m_eventTimerCmd ) { - bool et = true; - - if ( newVals != G4String("") ) { - et = G4UIcmdWithABool::GetNewBoolValue( newVals ); - } - - EventAction::getEventAction()->enableEventTimer( et ); - } - else { - G4Exception("", "", JustWarning, "Unknown command for this messenger."); - } - } - - void EventMessenger::defineCommands() - { - m_eventTimerCmd = new G4UIcmdWithABool( "/event/enableEventTimer", this ); - m_eventTimerCmd->SetGuidance( "Enable timing of individual events." ); - m_eventTimerCmd->SetParameterName( "enable", 'b', true ); - m_eventTimerCmd->SetDefaultValue( true ); - }
+namespace slic { +EventMessenger::EventMessenger() { + defineCommands(); +} + +EventMessenger::~EventMessenger() { +} + +void EventMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) { + if (cmd == m_eventTimerCmd) { + bool et = true; + + if (newVals != G4String("")) { + et = G4UIcmdWithABool::GetNewBoolValue(newVals); + } + + EventAction::getEventAction()->enableEventTimer(et); + } else { + G4Exception("", "", JustWarning, "Unknown command for this messenger."); + } +} + +void EventMessenger::defineCommands() { + m_eventTimerCmd = new G4UIcmdWithABool("/event/enableEventTimer", this); + m_eventTimerCmd->SetGuidance("Enable timing of individual events."); + m_eventTimerCmd->SetParameterName("enable", 'b', true); + m_eventTimerCmd->SetDefaultValue(true); +}
}
diff -u -r1.7 -r1.8 --- EventSource.cc 27 Apr 2007 01:54:34 -0000 1.7 +++ EventSource.cc 27 Nov 2012 19:32:19 -0000 1.8 @@ -1,49 +1,41 @@
-// $Header: /cvs/lcd/slic/src/EventSource.cc,v 1.7 2007/04/27 01:54:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventSource.cc,v 1.8 2012/11/27 19:32:19 jeremy Exp $
#include "EventSource.hh" // geant4 #include "G4Run.hh" #include "G4Event.hh"
-namespace slic -{
+namespace slic {
- EventSource::~EventSource() - {} - - EventSource::EventSource(const std::string& name) - : Module( name ), - m_name( name ) - {} - - void EventSource::reset() - { - // no-op -- implement if generator can be reset to event 0 or new file/source - } - - unsigned int EventSource::skipEvents(unsigned int) - { - // no-op -- implement if generator can "skip" an event - return 0; - } - - void EventSource::beginEvent(const G4Event*) - { - // no-op -- implement if generator has an action at beginning of event - } - - void EventSource::endEvent(const G4Event*) - { - // no-op -- implement if generator has an action at end of event - } - - void EventSource::beginRun(const G4Run*) - { - // no-op -- implement if generator has an action at beginning of run - } - - void EventSource::endRun(const G4Run*) - { - // no-op -- implement if generator has an action at end of run - }
+EventSource::~EventSource() { +} + +EventSource::EventSource(const std::string& name) : + Module(name), m_name(name) { +} + +void EventSource::reset() { + // no-op -- implement if generator can be reset to event 0 or new file/source +} + +unsigned int EventSource::skipEvents(unsigned int) { + // no-op -- implement if generator can "skip" an event + return 0; +} + +void EventSource::beginEvent(const G4Event*) { + // no-op -- implement if generator has an action at beginning of event +} + +void EventSource::endEvent(const G4Event*) { + // no-op -- implement if generator has an action at end of event +} + +void EventSource::beginRun(const G4Run*) { + // no-op -- implement if generator has an action at beginning of run +} + +void EventSource::endRun(const G4Run*) { + // no-op -- implement if generator has an action at end of run +}
}
diff -u -r1.23 -r1.24 --- EventSourceManager.cc 4 Jul 2012 01:01:48 -0000 1.23 +++ EventSourceManager.cc 27 Nov 2012 19:32:19 -0000 1.24 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.23 2012/07/04 01:01:48 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.24 2012/11/27 19:32:19 jeremy Exp $
#include "EventSourceManager.hh" // slic
@@ -12,424 +12,334 @@
// lcdd #include "StringUtil.hh"
-namespace slic -{ - std::string EventSourceManager::m_stdhepStr = std::string("stdhep"); - std::string EventSourceManager::m_lcioStr = std::string("lcio"); - std::string EventSourceManager::m_gpsStr = std::string("gps"); - std::string EventSourceManager::m_gunStr = std::string("gun"); - std::string EventSourceManager::m_unknownStr = std::string("unknown"); - - EventSourceManager::EventSourceManager() - : Module("EventSourceManager"), - m_currentEventSource(0), - m_filename(""), - m_fileIsSet(false), - m_newFilename(false), - m_ngen(0), - m_nskip(0), - m_newSource(true), - m_sourceType(eGPS), - m_lorentzTransformationAngle(0.), - m_zSmearingParam(0.) - { - // messenger with generator command macro bindings - m_messenger = new GeneratorMessenger(); - - // Always create a ParticleGun generator. - m_particleGunSource = new ParticleGunEventSource(); - } - - EventSourceManager::~EventSourceManager() - {} - - const std::string& EventSourceManager::getFilename() - { - return m_filename; - } - - void EventSourceManager::setFilename(const std::string& f) - { - m_filename = f; - m_fileIsSet = true; - m_newFilename = true; - - /* Get a file extension from the input file. */ - std::string fext = FileUtil::extension(m_filename); - - /* For known file extensions, get a source type. */ - ESourceType est = getSourceTypeFromFileExtension(fext); - - /* Setup a (possibly) new source. */ - setupEventSource( est ); - } - - EventSourceManager::ESourceType EventSourceManager::getSourceTypeFromFileExtension(const std::string& fext) - { - ESourceType est = eUnknown; - - /* LCIO file extension */ - if ( fext == "slcio" ) - { - est = eLCIO; - } - /* StdHep files, which may have .xdr file ext */ - else if ( fext == "stdhep" || fext == "xdr" ) - { - est = eStdHep; - } - else - { - log() << LOG::error << "WARNING: File <" << m_filename << "> does not have a known file extension." << LOG::done; - } - return est; - } - - void EventSourceManager::resetCurrentEventSource() - { - m_currentEventSource->reset(); - m_ngen = 0; - } - - void EventSourceManager::setSkipEvents(unsigned int s) - { - m_nskip = s; - } - - unsigned int EventSourceManager::getSkipEvents() - { - return m_nskip; - } - - void EventSourceManager::setSourceType(const std::string& s) - { - setSourceType( getSourceTypeFromName( s ) ); - } - - void EventSourceManager::setSourceType(ESourceType egt) - { - m_sourceType = egt; - m_newSource = true; - } - - const std::string& EventSourceManager::getSourceNameFromType( ESourceType egt ) const - { - if ( egt == eStdHep ) - { - return m_stdhepStr; - } - else if ( egt == eLCIO ) - { - return m_lcioStr; - } - else if ( egt == eGPS ) - { - return m_gpsStr; - } - else if ( egt == eParticleGun ) - { - return m_gunStr; - } - - return m_unknownStr; - } - - EventSourceManager::ESourceType EventSourceManager::getSourceTypeFromName( const std::string& s ) const - { - std::string sl = StringUtil::toLower(s); - - ESourceType egt = eUnknown; - - if ( sl == m_stdhepStr ) - { - egt = eStdHep; - } - else if ( sl == m_gpsStr ) - { - egt = eGPS; - } - else if ( sl == m_gunStr ) - { - egt = eParticleGun; - } - else if ( sl == m_lcioStr ) - { - egt = eLCIO; - } - - return egt; - } - - EventSourceManager::ESourceType EventSourceManager::getCurrentSourceType() - { - return m_sourceType; - } - - const std::string& EventSourceManager::getCurrentSourceName() - { - return getSourceNameFromType( m_sourceType ); - } - - void EventSourceManager::dumpCurrentEvent() - { - m_currentEventSource->dumpCurrentEvent(); - } - - void EventSourceManager::printNumEventsGenerated() - { - log() << LOG::okay << "Num events generated <" << m_ngen << ">." << LOG::done; - } - - int EventSourceManager::getNumEventsGenerated() - { - return m_ngen; - } - - void EventSourceManager::incrNumEventsGenerated() - { - m_ngen += 1; - } - - void EventSourceManager::generate(G4Event* evt) - { - if ( !isEOF() ) - { - m_currentEventSource->generate(evt); - } - else - { - log() << LOG::error << "No more input events from file <" << m_filename << ">." << LOG::done; - } - } - - void EventSourceManager::setEventSource(EventSource* es) - { - deleteCurrentEventSource(); - m_currentEventSource = es; - } - - void EventSourceManager::deleteCurrentEventSource() - { - if ( m_currentEventSource ) - { - delete m_currentEventSource; - m_currentEventSource = 0; - } - } - - EventSource* EventSourceManager::createEventSource(ESourceType st) - { - EventSource* src = 0; - if ( st == eLCIO ) - { - src = new LcioEventSource( getFilename() ); - } - else if ( st == eStdHep ) - { - src = new StdHepEventSource( getFilename() ); - } - else if ( st == eGPS ) - { - src = new GPSEventSource(); - } - else if ( st == eParticleGun ) - { - return m_particleGunSource; - } - else if ( st == eUnknown ) - { - log() << LOG::error << "The event source type <" << getSourceNameFromType(st) << " is flagged as unknown!" << LOG::done; - } - else - { - log() << LOG::error << "Invalid ESourceType." << LOG::done; - } - - return src; - } - - void EventSourceManager::setupEventSource(ESourceType st) - { - // Is it a known source type? - if ( st != eUnknown ) - { - // It is a new type of source? - if ( isNewSource(st) ) - { - // Set new source type. - m_sourceType = st;
+namespace slic { +std::string EventSourceManager::m_stdhepStr = std::string("stdhep"); +std::string EventSourceManager::m_lcioStr = std::string("lcio"); +std::string EventSourceManager::m_gpsStr = std::string("gps"); +std::string EventSourceManager::m_gunStr = std::string("gun"); +std::string EventSourceManager::m_unknownStr = std::string("unknown"); + +EventSourceManager::EventSourceManager() : + Module("EventSourceManager"), m_currentEventSource(0), m_filename(""), m_fileIsSet(false), m_newFilename( + false), m_ngen(0), m_nskip(0), m_newSource(true), m_sourceType(eGPS), m_lorentzTransformationAngle( + 0.), m_zSmearingParam(0.) {
- // Delete current source. - deleteCurrentEventSource();
+ // messenger with generator command macro bindings + m_messenger = new GeneratorMessenger();
- // Create new source. - m_currentEventSource = createEventSource( m_sourceType );
+ // Always create a ParticleGun generator. + m_particleGunSource = new ParticleGunEventSource(); + + log().setOutputLevel(LOG::always); +} + +EventSourceManager::~EventSourceManager() { +} + +const std::string& EventSourceManager::getFilename() { + return m_filename; +} + +void EventSourceManager::setFilename(const std::string& f) { + m_filename = f; + m_fileIsSet = true; + m_newFilename = true; + + /* Get a file extension from the input file. */ + std::string fext = FileUtil::extension(m_filename); + + /* For known file extensions, get a source type. */ + ESourceType est = getSourceTypeFromFileExtension(fext); + + /* Setup a (possibly) new source. */ + setupEventSource(est); +} + +EventSourceManager::ESourceType EventSourceManager::getSourceTypeFromFileExtension(const std::string& fext) { + ESourceType est = eUnknown; + + /* LCIO file extension */ + if (fext == "slcio") { + est = eLCIO; + } + /* StdHep files, which may have .xdr file ext */ + else if (fext == "stdhep" || fext == "xdr") { + est = eStdHep; + } else { + log() << LOG::error << "WARNING: File <" << m_filename << "> does not have a known file extension." + << LOG::done; + } + return est; +} + +void EventSourceManager::resetCurrentEventSource() { + m_currentEventSource->reset(); + m_ngen = 0; +} + +void EventSourceManager::setSkipEvents(unsigned int s) { + m_nskip = s; +} + +unsigned int EventSourceManager::getSkipEvents() { + return m_nskip; +} + +void EventSourceManager::setSourceType(const std::string& s) { + setSourceType(getSourceTypeFromName(s)); +} + +void EventSourceManager::setSourceType(ESourceType egt) { + m_sourceType = egt; + m_newSource = true; +} + +const std::string& EventSourceManager::getSourceNameFromType(ESourceType egt) const { + if (egt == eStdHep) { + return m_stdhepStr; + } else if (egt == eLCIO) { + return m_lcioStr; + } else if (egt == eGPS) { + return m_gpsStr; + } else if (egt == eParticleGun) { + return m_gunStr; + } + + return m_unknownStr; +} + +EventSourceManager::ESourceType EventSourceManager::getSourceTypeFromName(const std::string& s) const { + std::string sl = StringUtil::toLower(s); + + ESourceType egt = eUnknown; + + if (sl == m_stdhepStr) { + egt = eStdHep; + } else if (sl == m_gpsStr) { + egt = eGPS; + } else if (sl == m_gunStr) { + egt = eParticleGun; + } else if (sl == m_lcioStr) { + egt = eLCIO; + } + + return egt; +} + +EventSourceManager::ESourceType EventSourceManager::getCurrentSourceType() { + return m_sourceType; +} + +const std::string& EventSourceManager::getCurrentSourceName() { + return getSourceNameFromType(m_sourceType); +} + +void EventSourceManager::dumpCurrentEvent() { + m_currentEventSource->dumpCurrentEvent(); +} + +void EventSourceManager::printNumEventsGenerated() { + log() << LOG::okay << LOG::head << "Generated " << m_ngen << " events." << LOG::done; +} + +int EventSourceManager::getNumEventsGenerated() { + return m_ngen; +} + +void EventSourceManager::incrNumEventsGenerated() { + m_ngen += 1; +} + +void EventSourceManager::generate(G4Event* evt) { + if (!isEOF()) { + m_currentEventSource->generate(evt); + } else { + log() << LOG::error << "No more input events from file <" << m_filename << ">." << LOG::done; + } + incrNumEventsGenerated(); +} + +void EventSourceManager::setEventSource(EventSource* es) { + deleteCurrentEventSource(); + m_currentEventSource = es; +} + +void EventSourceManager::deleteCurrentEventSource() { + if (m_currentEventSource) { + delete m_currentEventSource; + m_currentEventSource = 0; + } +} + +EventSource* EventSourceManager::createEventSource(ESourceType st) { + EventSource* src = 0; + if (st == eLCIO) { + src = new LcioEventSource(getFilename()); + } else if (st == eStdHep) { + src = new StdHepEventSource(getFilename()); + } else if (st == eGPS) { + src = new GPSEventSource(); + } else if (st == eParticleGun) { + return m_particleGunSource; + } else if (st == eUnknown) { + log() << LOG::error << "The event source type <" << getSourceNameFromType(st) + << " is flagged as unknown!" << LOG::done; + } else { + log() << LOG::error << "Invalid ESourceType." << LOG::done; + } + + return src; +} + +void EventSourceManager::setupEventSource(ESourceType st) { + // Is it a known source type? + if (st != eUnknown) { + // It is a new type of source? + if (isNewSource(st)) { + // Set new source type. + m_sourceType = st; + + // Delete current source. + deleteCurrentEventSource(); + + // Create new source. + m_currentEventSource = createEventSource(m_sourceType);
#ifdef SLIC_LOG
- log().okay("Created event generator <" + getCurrentSourceName() + ">");
+ log().okay("Created event generator <" + getCurrentSourceName() + ">");
#endif
- } - else - { - log().warning("Type of new event source is same as old; keeping old source."); - } - } - else - { - G4Exception("", "", JustWarning, "Event Source type is unknown."); - } - } - - void EventSourceManager::setupEventSource(const std::string& s) - { - ESourceType st = getSourceTypeFromName( s ); - if ( st != eUnknown ) - { - setupEventSource( st ); - } - else - { - log().error("The name <" + s + "> is not a valid event source. New source was NOT created."); - } - } - - - EventSource* EventSourceManager::getCurrentSource() - { - return m_currentEventSource; - } - - void EventSourceManager::beginEvent(const G4Event* anEvent) - { - // Start the event timer, as generation occurs before EventAction::BeginOfEventAction(). - EventAction::getEventAction()->startEventTimer(); - - // Begin event action of current source. - m_currentEventSource->beginEvent(anEvent); - } - - void EventSourceManager::endEvent(const G4Event* anEvent) - { - m_currentEventSource->endEvent(anEvent); - } - - void EventSourceManager::beginRun(const G4Run* aRun) - { - // Setup a new event source if neccessary. - setupEventSource(); - - // Call the beginRun() function of the current event source. - m_currentEventSource->beginRun(aRun); - - // Filename is now old so source won't reset. - m_newFilename = false; - } - - void EventSourceManager::setupEventSource() - { - if ( m_newSource ) - { - m_currentEventSource = createEventSource( m_sourceType ); - m_newSource = false; - } - } - - void EventSourceManager::endRun(const G4Run* aRun) - { - m_currentEventSource->endRun(aRun); - } - - bool EventSourceManager::isFileSource() - { - return ( m_sourceType == eStdHep || m_sourceType == eLCIO ); - } - - bool EventSourceManager::isEOF() - { - bool eof = false; - if ( isFileSource() ) - { - EventSourceWithInputFile* src = dynamic_cast<EventSourceWithInputFile*> ( m_currentEventSource ); - - if ( src ) - { - eof = src->isEOF(); - } - else - { - G4Exception("", "", JustWarning, "Cast to EventSourceWithInputFile failed."); - } - } - return eof; - } - - bool EventSourceManager::isNewSource() - { - return m_newSource; - } - - bool EventSourceManager::isNewSource(ESourceType est) - { - return ( est != eUnknown && est != m_sourceType ); - } - - bool EventSourceManager::isNewFilename() - { - return m_newFilename; - } - - EventSourceWithInputFile* EventSourceManager::getFileSource() - { - EventSourceWithInputFile* esif = 0; - if ( isFileSource() ) - { - esif = dynamic_cast<EventSourceWithInputFile*> ( m_currentEventSource ) ; - } - return esif; - } - - G4GeneralParticleSource* EventSourceManager::getGPS() - { - GPSEventSource* src = dynamic_cast<GPSEventSource*> ( m_currentEventSource ); - - G4GeneralParticleSource* gps = 0; - if ( src ) - { - gps = src->getGPS(); - } - - return gps; - } - - G4ParticleGun* EventSourceManager::getParticleGun() - { - ParticleGunEventSource* src = dynamic_cast<ParticleGunEventSource*> ( m_currentEventSource ); - - G4ParticleGun* gun = 0; - if ( src ) - { - gun = src->getParticleGun(); - } - - return gun; - } - - void EventSourceManager::GeneratePrimaryVertex(G4Event* evt) - { - generate(evt); - }
+ } else { + log().warning("Type of new event source is same as old; keeping old source."); + } + } else { + G4Exception("", "", JustWarning, "Event Source type is unknown."); + } +} + +void EventSourceManager::setupEventSource(const std::string& s) { + ESourceType st = getSourceTypeFromName(s); + if (st != eUnknown) { + setupEventSource(st); + } else { + log().error("The name <" + s + "> is not a valid event source. New source was NOT created."); + } +} + +EventSource* EventSourceManager::getCurrentSource() { + return m_currentEventSource; +} + +void EventSourceManager::beginEvent(const G4Event* anEvent) { + // Start the event timer, as generation occurs before EventAction::BeginOfEventAction(). + EventAction::getEventAction()->startEventTimer();
- void EventSourceManager::setLorentzTransformationAngle( const G4double lorentzTransformationAngle ) - {
+ // Begin event action of current source. + m_currentEventSource->beginEvent(anEvent); +} + +void EventSourceManager::endEvent(const G4Event* anEvent) { + m_currentEventSource->endEvent(anEvent); +} + +void EventSourceManager::beginRun(const G4Run* aRun) { + // Setup a new event source if neccessary. + setupEventSource(); + + // Call the beginRun() function of the current event source. + m_currentEventSource->beginRun(aRun); + + // Filename is now old so source won't reset. + m_newFilename = false; + + // Reset event counter. + m_ngen = 0; +} + +void EventSourceManager::setupEventSource() { + if (m_newSource) { + m_currentEventSource = createEventSource(m_sourceType); + m_newSource = false; + } +} + +void EventSourceManager::endRun(const G4Run* aRun) { + m_currentEventSource->endRun(aRun); +}
- m_lorentzTransformationAngle = lorentzTransformationAngle;
+bool EventSourceManager::isFileSource() { + return (m_sourceType == eStdHep || m_sourceType == eLCIO); +} + +bool EventSourceManager::isEOF() { + bool eof = false; + if (isFileSource()) { + EventSourceWithInputFile* src = dynamic_cast<EventSourceWithInputFile*>(m_currentEventSource); + + if (src) { + eof = src->isEOF(); + } else { + G4Exception("", "", JustWarning, "Cast to EventSourceWithInputFile failed."); + } + } + return eof; +} + +bool EventSourceManager::isNewSource() { + return m_newSource; +} + +bool EventSourceManager::isNewSource(ESourceType est) { + return (est != eUnknown && est != m_sourceType); +} + +bool EventSourceManager::isNewFilename() { + return m_newFilename; +} + +EventSourceWithInputFile* EventSourceManager::getFileSource() { + EventSourceWithInputFile* esif = 0; + if (isFileSource()) { + esif = dynamic_cast<EventSourceWithInputFile*>(m_currentEventSource); + } + return esif; +} + +G4GeneralParticleSource* EventSourceManager::getGPS() { + GPSEventSource* src = dynamic_cast<GPSEventSource*>(m_currentEventSource); + + G4GeneralParticleSource* gps = 0; + if (src) { + gps = src->getGPS(); + } + + return gps; +} + +G4ParticleGun* EventSourceManager::getParticleGun() { + ParticleGunEventSource* src = dynamic_cast<ParticleGunEventSource*>(m_currentEventSource); + + G4ParticleGun* gun = 0; + if (src) { + gun = src->getParticleGun(); + } + + return gun; +} + +void EventSourceManager::GeneratePrimaryVertex(G4Event* evt) { + generate(evt); +} + +void EventSourceManager::setLorentzTransformationAngle(const G4double lorentzTransformationAngle) { + + m_lorentzTransformationAngle = lorentzTransformationAngle;
#ifdef SLIC_LOG
- log() << LOG::always - << "Set Lorentz transformation angle to " - << G4BestUnit(m_lorentzTransformationAngle, "Angle") - << LOG::done;
+ log() << LOG::always + << "Set Lorentz transformation angle to " + << G4BestUnit(m_lorentzTransformationAngle, "Angle") + << LOG::done;
#endif
- }
+}
}
diff -u -r1.9 -r1.10 --- EventSourceWithInputFile.cc 31 Jan 2012 18:52:30 -0000 1.9 +++ EventSourceWithInputFile.cc 27 Nov 2012 19:32:19 -0000 1.10 @@ -1,122 +1,114 @@
-// $Header: /cvs/lcd/slic/src/EventSourceWithInputFile.cc,v 1.9 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventSourceWithInputFile.cc,v 1.10 2012/11/27 19:32:19 jeremy Exp $
#include "EventSourceWithInputFile.hh" // slic #include "EventSourceManager.hh"
-namespace slic -{ - void EventSourceWithInputFile::setFilename(const std::string& s) - { - if ( s != std::string("") ) { - - if ( FileUtil::fileExists( s ) ) { - m_filename = s; - - m_fileIsSet = true; - m_fileIsNew = true; - }
+namespace slic { +void EventSourceWithInputFile::setFilename(const std::string& s) { + if (s != std::string("")) { + + if (FileUtil::fileExists(s)) { + m_filename = s; + + m_fileIsSet = true; + m_fileIsNew = true; + }
#ifdef SLIC_LOG
- else { - log() << LOG::error << "Ignoring nonexistant input file <" << s << ">." << LOG::done; - }
+ else { + log() << LOG::error << "Ignoring nonexistant input file <" << s << ">." << LOG::done; + }
#endif
- }
+ }
#ifdef SLIC_LOG
- else { - log() << LOG::error << "Ignoring blank filename." << LOG::done; - }
+ else { + log() << LOG::error << "Ignoring blank filename." << LOG::done; + }
#endif
- }
+} + +const std::string& EventSourceWithInputFile::getFilename() { + return m_filename; +} + +void EventSourceWithInputFile::reset() { + // close if open + if (m_fileIsOpen) { + close(); + } + + // (re)open + open(); + + // should not be EOF now (maybe on next read) + m_eof = false; +}
- const std::string& EventSourceWithInputFile::getFilename() - { - return m_filename; - } - - void EventSourceWithInputFile::reset() - { - // close if open - if ( m_fileIsOpen ) { - close(); - } - - // (re)open - open(); - - // should not be EOF now (maybe on next read) - m_eof = false; - } - - unsigned int EventSourceWithInputFile::skipEvents(unsigned int nevents) - { - unsigned int i; - for (i=0; i<nevents; i++) { - - if ( isEOF() ) { - break; - } - - readNextEvent(); - } - return i; - } - - bool EventSourceWithInputFile::isEOF() - { - return m_eof; - } - - void EventSourceWithInputFile::beginEvent(const G4Event*) - { - readNextEvent(); - } - - void EventSourceWithInputFile::beginRun(const G4Run*) - { - // attempt to setup filename from mgr if got a new filename - if ( EventSourceManager::instance()->isNewFilename() ) { - setFilename( EventSourceManager::instance()->getFilename() ); - } - - // check if filename is setup correctly - if ( !m_fileIsSet ) { - G4Exception("", "", FatalException, "Generator filename was not set."); - } - - // reset if new file - if ( m_fileIsNew ) { - - // close and open (possibly with new file) - reset(); - - /* Set state variables. */ - m_fileIsNew = false; - m_fileIsOpen = true; - }
+unsigned int EventSourceWithInputFile::skipEvents(unsigned int nevents) { + unsigned int i; + for (i = 0; i < nevents; i++) { + + if (isEOF()) { + break; + } + + readNextEvent(); + } + return i; +} + +bool EventSourceWithInputFile::isEOF() { + return m_eof; +}
- // get num events to skip from mgr - int nskip = EventSourceManager::instance()->getSkipEvents();
+void EventSourceWithInputFile::beginEvent(const G4Event*) { + readNextEvent(); +}
- if ( nskip ) {
+void EventSourceWithInputFile::beginRun(const G4Run*) { + // attempt to setup filename from mgr if got a new filename + if (EventSourceManager::instance()->isNewFilename()) { + setFilename(EventSourceManager::instance()->getFilename()); + } + + // check if filename is setup correctly + if (!m_fileIsSet) { + G4Exception("", "", FatalException, "Generator filename was not set."); + } + + // reset if new file + if (m_fileIsNew) { + + // close and open (possibly with new file) + reset(); + + /* Set state variables. */ + m_fileIsNew = false; + m_fileIsOpen = true; + } + + // get num events to skip from mgr + int nskip = EventSourceManager::instance()->getSkipEvents(); + + if (nskip) {
#ifdef SLIC_LOG
- log() << LOG::okay << "Skipping <" << nskip << "> events ..." << LOG::done;
+ log() << LOG::okay << "Skipping <" << nskip << "> events ..." << LOG::done;
#endif
- // skip events according to current mgr val - int actualskipped = skipEvents(nskip);
+ // skip events according to current mgr val + int actualskipped = skipEvents(nskip);
#ifdef SLIC_LOG
- log() << LOG::okay << "Skipped <" << actualskipped << "> events." << LOG::done;
+ log() << LOG::okay << "Skipped <" << actualskipped << "> events." << LOG::done;
- if (actualskipped < nskip) { - log() << LOG::warning << "Ran out of records to skip on event file!" << LOG::done; - }
+ if (actualskipped < nskip) { + log() << LOG::warning << "Ran out of records to skip on event file!" << LOG::done; + }
#endif
- // reset skip events - EventSourceManager::instance()->setSkipEvents(0); - } - }
+ // reset skip events + EventSourceManager::instance()->setSkipEvents(0); + } +}
}
diff -u -r1.5 -r1.6 --- FieldManager.cc 27 Apr 2007 01:54:34 -0000 1.5 +++ FieldManager.cc 27 Nov 2012 19:32:19 -0000 1.6 @@ -1,15 +1,12 @@
#include "FieldManager.hh"
-namespace slic -{ - FieldManager::FieldManager() - : Module("FieldManager") - { - m_messenger = new FieldMessenger( this ); - }
+namespace slic { +FieldManager::FieldManager() : + Module("FieldManager") { + m_messenger = new FieldMessenger(this); +}
- FieldManager::~FieldManager() - { - delete m_messenger; - }
+FieldManager::~FieldManager() { + delete m_messenger; +}
}
diff -u -r1.8 -r1.9 --- FieldMessenger.cc 31 Jan 2012 18:52:30 -0000 1.8 +++ FieldMessenger.cc 27 Nov 2012 19:32:19 -0000 1.9 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/FieldMessenger.cc,v 1.8 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/FieldMessenger.cc,v 1.9 2012/11/27 19:32:19 jeremy Exp $
#include "FieldMessenger.hh" // slic
@@ -13,71 +13,64 @@
#include "G4TransportationManager.hh" #include "G4ApplicationState.hh"
-namespace slic -{
+namespace slic {
- FieldMessenger::FieldMessenger( FieldManager* mgr ) - : m_mgr( mgr ) - { - defineCommands(); - } - - FieldMessenger::~FieldMessenger() - { - delete m_fieldDir; - delete m_selectStepperCmd; - delete m_setDeltaOneStepCmd; - delete m_setDeltaIntersectionCmd; - } - - void FieldMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) - { - G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
+FieldMessenger::FieldMessenger(FieldManager* mgr) : + m_mgr(mgr) { + defineCommands(); +} + +FieldMessenger::~FieldMessenger() { + delete m_fieldDir; + delete m_selectStepperCmd; + delete m_setDeltaOneStepCmd; + delete m_setDeltaIntersectionCmd; +}
- if (cmd==m_selectStepperCmd) { - G4MagIntegratorStepperFactory::instance()->setupG4MagIntegratorStepper(newVals);
+void FieldMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) { + G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager(); + + if (cmd == m_selectStepperCmd) { + G4MagIntegratorStepperFactory::instance()->setupG4MagIntegratorStepper(newVals);
#ifdef SLIC_LOG
- m_mgr->log() << LOG::okay << "mag field integrator <" << newVals << ">" << LOG::done;
+ m_mgr->log() << LOG::okay << "mag field integrator <" << newVals << ">" << LOG::done;
#endif
- } - else if (cmd==m_setDeltaOneStepCmd) { - double deltaOneStep = m_setDeltaOneStepCmd->GetNewDoubleValue(newVals); - fieldMgr->SetDeltaOneStep(deltaOneStep); - m_mgr->log() << LOG::okay << "delta one step <" << deltaOneStep << ">" << LOG::done; - } - else if (cmd==m_setDeltaIntersectionCmd) { - double deltaIntersection = m_setDeltaIntersectionCmd->GetNewDoubleValue(newVals); - fieldMgr->SetDeltaIntersection(deltaIntersection); - m_mgr->log() << LOG::okay << "delta intersection <" << deltaIntersection << ">" << LOG::done; - } - else { - G4Exception("", "", JustWarning, "Unknown command."); - } - } - - void FieldMessenger::defineCommands() - { - G4UIparameter *p; - - m_fieldDir = new G4UIdirectory("/field/"); - m_fieldDir->SetGuidance("Magnetic field customization commands. [SLIC]"); - - m_selectStepperCmd = new G4UIcommand("/field/selectStepper", this); - - m_selectStepperCmd->SetGuidance("Select the G4MagIntegratorStepper:\nG4ClassicalRK4 G4ExplicitEuler G4HelixExplicitEuler G4HelixHeum G4HelixImplicitEuler G4HelixSimpleRunge G4ImplicitEuler G4CashKarpRKF45 G4SimpleHeum G4SimpleRunge"); - - p = new G4UIparameter("stepper", 's', false ); - m_selectStepperCmd->SetParameter(p); - m_selectStepperCmd->AvailableForStates(G4State_Init, G4State_Idle); - - m_setDeltaOneStepCmd = new G4UIcmdWithADoubleAndUnit("/field/setDeltaOneStep", this); - m_setDeltaOneStepCmd->SetGuidance("Set the delta of one step."); - m_setDeltaOneStepCmd->SetDefaultUnit("mm"); - m_setDeltaOneStepCmd->AvailableForStates(G4State_Init, G4State_Idle); - - m_setDeltaIntersectionCmd = new G4UIcmdWithADoubleAndUnit("/field/setDeltaIntersection", this); - m_setDeltaIntersectionCmd->SetGuidance("Set the delta of intersection."); - m_setDeltaIntersectionCmd->SetDefaultUnit("mm"); - m_setDeltaIntersectionCmd->AvailableForStates(G4State_Init, G4State_Idle); - }
+ } else if (cmd == m_setDeltaOneStepCmd) { + double deltaOneStep = m_setDeltaOneStepCmd->GetNewDoubleValue(newVals); + fieldMgr->SetDeltaOneStep(deltaOneStep); + m_mgr->log() << LOG::okay << "delta one step <" << deltaOneStep << ">" << LOG::done; + } else if (cmd == m_setDeltaIntersectionCmd) { + double deltaIntersection = m_setDeltaIntersectionCmd->GetNewDoubleValue(newVals); + fieldMgr->SetDeltaIntersection(deltaIntersection); + m_mgr->log() << LOG::okay << "delta intersection <" << deltaIntersection << ">" << LOG::done; + } else { + G4Exception("", "", JustWarning, "Unknown command."); + } +} + +void FieldMessenger::defineCommands() { + G4UIparameter *p; + + m_fieldDir = new G4UIdirectory("/field/"); + m_fieldDir->SetGuidance("Magnetic field customization commands. [SLIC]"); + + m_selectStepperCmd = new G4UIcommand("/field/selectStepper", this); + + m_selectStepperCmd->SetGuidance( + "Select the G4MagIntegratorStepper:\nG4ClassicalRK4 G4ExplicitEuler G4HelixExplicitEuler G4HelixHeum G4HelixImplicitEuler G4HelixSimpleRunge G4ImplicitEuler G4CashKarpRKF45 G4SimpleHeum G4SimpleRunge"); + + p = new G4UIparameter("stepper", 's', false); + m_selectStepperCmd->SetParameter(p); + m_selectStepperCmd->AvailableForStates(G4State_Init, G4State_Idle); + + m_setDeltaOneStepCmd = new G4UIcmdWithADoubleAndUnit("/field/setDeltaOneStep", this); + m_setDeltaOneStepCmd->SetGuidance("Set the delta of one step."); + m_setDeltaOneStepCmd->SetDefaultUnit("mm"); + m_setDeltaOneStepCmd->AvailableForStates(G4State_Init, G4State_Idle); + + m_setDeltaIntersectionCmd = new G4UIcmdWithADoubleAndUnit("/field/setDeltaIntersection", this); + m_setDeltaIntersectionCmd->SetGuidance("Set the delta of intersection."); + m_setDeltaIntersectionCmd->SetDefaultUnit("mm"); + m_setDeltaIntersectionCmd->AvailableForStates(G4State_Init, G4State_Idle); +}
}
diff -u -r1.13 -r1.14 --- FileUtil.cc 19 Oct 2005 22:51:15 -0000 1.13 +++ FileUtil.cc 27 Nov 2012 19:32:19 -0000 1.14 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/FileUtil.cc,v 1.13 2005/10/19 22:51:15 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/FileUtil.cc,v 1.14 2012/11/27 19:32:19 jeremy Exp $
#include "FileUtil.hh" // std
@@ -9,91 +9,80 @@
using std::ifstream; using std::ios;
-namespace slic -{
+namespace slic {
- int FileUtil::removeFile(const char* filename) - { - int ret = remove( filename ); - return ret; - } - - int FileUtil::removeFile(const std::string& filename) - { - return FileUtil::removeFile( filename.c_str() ); - } - - bool FileUtil::fileExists(const char* filename) - { - bool exists=true; - - ifstream fin; - fin.open(filename, ios::in); - - // either doesn't exist or can't read - if( fin.fail() ) { - exists=false; - } - fin.close(); - return exists; - } - - bool FileUtil::fileExists(const std::string& filename) - { - return FileUtil::fileExists( filename.c_str() ); - } - - std::string FileUtil::basename(std::string fn) - { - static std::string delim = "/";
+int FileUtil::removeFile(const char* filename) { + int ret = remove(filename); + return ret; +} + +int FileUtil::removeFile(const std::string& filename) { + return FileUtil::removeFile(filename.c_str()); +} + +bool FileUtil::fileExists(const char* filename) { + bool exists = true; + + ifstream fin; + fin.open(filename, ios::in); + + // either doesn't exist or can't read + if (fin.fail()) { + exists = false; + } + fin.close(); + return exists; +} + +bool FileUtil::fileExists(const std::string& filename) { + return FileUtil::fileExists(filename.c_str()); +} + +std::string FileUtil::basename(std::string fn) { + static std::string delim = "/";
- std::string filename = fn;
+ std::string filename = fn;
- // find Unix/Cygwin delim - int basename_pos = filename.rfind(delim);
+ // find Unix/Cygwin delim + int basename_pos = filename.rfind(delim);
- // may be dealing with a Windows-style path
+ // may be dealing with a Windows-style path
#if defined(__WIN32__) || defined(__CYGWIN__) || defined(__CYGWIN32__)
- if ( basename_pos == -1 ) { - basename_pos = filename.rfind("\\"); - }
+ if ( basename_pos == -1 ) { + basename_pos = filename.rfind("\\"); + }
#endif
- // found a dir delimiter so erase up to it - if ( basename_pos != -1 ) { - filename.erase(filename.begin(), - filename.begin() + basename_pos + 1); - } - - return filename; - } - - std::string FileUtil::extension(std::string fn) - { - std::string::size_type idx = fn.find_last_of("."); - - std::string ext; - if ( idx != std::string::npos ) { - ext = fn.substr(idx + 1, fn.size() - idx); - } - else { - ext = ""; - } - - return ext; - } - - std::string FileUtil::removeExtension(std::string fn) - { - std::string::size_type idx = fn.find_last_of("."); - - std::string fname; - if ( idx != std::string::npos ) { - fname = fn.substr(0, idx); - } - else { - fname = fn; - } - return fname; - }
+ // found a dir delimiter so erase up to it + if (basename_pos != -1) { + filename.erase(filename.begin(), filename.begin() + basename_pos + 1); + } + + return filename; +} + +std::string FileUtil::extension(std::string fn) { + std::string::size_type idx = fn.find_last_of("."); + + std::string ext; + if (idx != std::string::npos) { + ext = fn.substr(idx + 1, fn.size() - idx); + } else { + ext = ""; + } + + return ext; +} + +std::string FileUtil::removeExtension(std::string fn) { + std::string::size_type idx = fn.find_last_of("."); + + std::string fname; + if (idx != std::string::npos) { + fname = fn.substr(0, idx); + } else { + fname = fn; + } + return fname; +}
}
diff -u -r1.7 -r1.8 --- G4MagIntegratorStepperFactory.cc 31 Jan 2012 18:52:30 -0000 1.7 +++ G4MagIntegratorStepperFactory.cc 27 Nov 2012 19:32:19 -0000 1.8 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/G4MagIntegratorStepperFactory.cc,v 1.7 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/G4MagIntegratorStepperFactory.cc,v 1.8 2012/11/27 19:32:19 jeremy Exp $
#include "G4MagIntegratorStepperFactory.hh" // G4
@@ -22,78 +22,62 @@
using std::string;
-namespace slic -{ - G4MagIntegratorStepperFactory::G4MagIntegratorStepperFactory() - : Module( "G4MagIntegratorStepperFactory" ) - { - m_fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager(); - m_field = static_cast<G4MagneticField*>(const_cast<G4Field*>(m_fieldMgr->GetDetectorField())); - if ( m_field == 0 ) { - log() << LOG::error << "Command refused. Detector has no G4MagneticField." << LOG::done; - } - else { - m_fieldEquations = new G4Mag_UsualEqRhs(m_field); - } - } - - G4MagIntegratorStepperFactory::~G4MagIntegratorStepperFactory() - { - delete m_fieldEquations; - } - - void G4MagIntegratorStepperFactory::setupG4MagIntegratorStepper(std::string name) - { - G4MagIntegratorStepper* stepper = createG4MagIntegratorStepper(name); - - if ( stepper != 0 ) { - - G4ChordFinder* oldChordFinder = m_fieldMgr->GetChordFinder(); - if (oldChordFinder != 0) { - delete oldChordFinder; - } - - /* Create new chord finder with default step minimum. */ - m_fieldMgr->SetChordFinder(new G4ChordFinder(m_field, 1E-2*mm, stepper)); - } - } - - G4MagIntegratorStepper* G4MagIntegratorStepperFactory::createG4MagIntegratorStepper(string name) - { - if (name=="G4ClassicalRK4") { - return new G4ClassicalRK4(m_fieldEquations); - } - else if (name=="G4ExplicitEuler") { - return new G4ExplicitEuler(m_fieldEquations); - } - else if (name=="G4HelixExplicitEuler") { - return new G4HelixExplicitEuler(m_fieldEquations); - } - else if (name=="G4HelixHeum") { - return new G4HelixHeum(m_fieldEquations); - } - else if (name=="G4HelixImplicitEuler") { - return new G4HelixImplicitEuler(m_fieldEquations); - } - else if (name=="G4HelixSimpleRunge") { - return new G4HelixSimpleRunge(m_fieldEquations); - } - else if (name=="G4ImplicitEuler") { - return new G4ImplicitEuler(m_fieldEquations); - } - else if (name=="G4CashKarpRKF45") { - return new G4CashKarpRKF45(m_fieldEquations); - } - else if (name=="G4SimpleHeum") { - return new G4SimpleHeum(m_fieldEquations); - } - else if (name=="G4SimpleRunge") { - return new G4SimpleRunge(m_fieldEquations); - } - else { - log() << LOG::error << "Unknown G4MagIntegratorStepper <" + name << ">" << LOG::done; - }
+namespace slic { +G4MagIntegratorStepperFactory::G4MagIntegratorStepperFactory() : + Module("G4MagIntegratorStepperFactory") { + m_fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager(); + m_field = static_cast<G4MagneticField*>(const_cast<G4Field*>(m_fieldMgr->GetDetectorField())); + if (m_field == 0) { + log() << LOG::error << "Command refused. Detector has no G4MagneticField." << LOG::done; + } else { + m_fieldEquations = new G4Mag_UsualEqRhs(m_field); + } +} + +G4MagIntegratorStepperFactory::~G4MagIntegratorStepperFactory() { + delete m_fieldEquations; +} + +void G4MagIntegratorStepperFactory::setupG4MagIntegratorStepper(std::string name) { + G4MagIntegratorStepper* stepper = createG4MagIntegratorStepper(name); + + if (stepper != 0) {
- return 0; - }
+ G4ChordFinder* oldChordFinder = m_fieldMgr->GetChordFinder(); + if (oldChordFinder != 0) { + delete oldChordFinder; + } + + /* Create new chord finder with default step minimum. */ + m_fieldMgr->SetChordFinder(new G4ChordFinder(m_field, 1E-2 * mm, stepper)); + } +} + +G4MagIntegratorStepper* G4MagIntegratorStepperFactory::createG4MagIntegratorStepper(string name) { + if (name == "G4ClassicalRK4") { + return new G4ClassicalRK4(m_fieldEquations); + } else if (name == "G4ExplicitEuler") { + return new G4ExplicitEuler(m_fieldEquations); + } else if (name == "G4HelixExplicitEuler") { + return new G4HelixExplicitEuler(m_fieldEquations); + } else if (name == "G4HelixHeum") { + return new G4HelixHeum(m_fieldEquations); + } else if (name == "G4HelixImplicitEuler") { + return new G4HelixImplicitEuler(m_fieldEquations); + } else if (name == "G4HelixSimpleRunge") { + return new G4HelixSimpleRunge(m_fieldEquations); + } else if (name == "G4ImplicitEuler") { + return new G4ImplicitEuler(m_fieldEquations); + } else if (name == "G4CashKarpRKF45") { + return new G4CashKarpRKF45(m_fieldEquations); + } else if (name == "G4SimpleHeum") { + return new G4SimpleHeum(m_fieldEquations); + } else if (name == "G4SimpleRunge") { + return new G4SimpleRunge(m_fieldEquations); + } else { + log() << LOG::error << "Unknown G4MagIntegratorStepper <" + name << ">" << LOG::done; + } + + return 0; +}
}
diff -u -r1.8 -r1.9 --- GPSEventSource.cc 27 Apr 2007 01:54:34 -0000 1.8 +++ GPSEventSource.cc 27 Nov 2012 19:32:19 -0000 1.9 @@ -1,61 +1,54 @@
-// $Header: /cvs/lcd/slic/src/GPSEventSource.cc,v 1.8 2007/04/27 01:54:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/GPSEventSource.cc,v 1.9 2012/11/27 19:32:19 jeremy Exp $
#include "GPSEventSource.hh" // geant4 #include "G4MuonMinus.hh"
-namespace slic -{ - GPSEventSource::GPSEventSource() - : EventSource( "GPSEventSource" ) - { - m_generator = new G4GeneralParticleSource(); - - setupGeneratorDefaults(); - } - - GPSEventSource::~GPSEventSource() - { - delete m_generator; - } - - void GPSEventSource::setupGeneratorDefaults() - { - m_generator->GetCurrentSource()->SetParticleDefinition( G4MuonMinus::MuonMinusDefinition() ); - - m_generator->GetCurrentSource()->GetEneDist()->SetEnergyDisType("Mono"); - m_generator->GetCurrentSource()->GetEneDist()->SetMonoEnergy(5 * GeV); - - m_generator->GetCurrentSource()->GetPosDist()->SetPosDisType("Point"); - m_generator->GetCurrentSource()->GetPosDist()->SetCentreCoords(G4ThreeVector(0, 0, 0)); - - m_generator->GetCurrentSource()->GetAngDist()->SetAngDistType("planar"); - m_generator->GetCurrentSource()->GetAngDist()->SetParticleMomentumDirection(G4ThreeVector(0, 1, 0)); - } - - void GPSEventSource::generate(G4Event* evt) - { - m_generator->GeneratePrimaryVertex(evt); - } - - /** This is mostly wrong until after the first event generation. */ - void GPSEventSource::dumpCurrentEvent() - { - log() << LOG::okay << "Dumping GPS Event info..." << LOG::done; - - G4ParticleDefinition* pdef = m_generator->GetParticleDefinition(); - - log() << LOG::okay << "particle: " << pdef->GetParticleName() << LOG::done; - log() << LOG::okay << "time: " << m_generator->GetParticleTime () << LOG::done; - log() << LOG::okay << "nparts: " << m_generator->GetNumberOfParticles() << LOG::done; - log() << LOG::okay << "pos: " << m_generator->GetParticlePosition () << LOG::done; - log() << LOG::okay << "mom: " << m_generator->GetParticleMomentumDirection() << LOG::done; - log() << LOG::okay << "E: " << m_generator->GetParticleEnergy() << LOG::done; - log() << LOG::okay << LOG::done; - } - - G4GeneralParticleSource* GPSEventSource::getGPS() - { - return m_generator; - }
+namespace slic { +GPSEventSource::GPSEventSource() : + EventSource("GPSEventSource") { + m_generator = new G4GeneralParticleSource(); + + setupGeneratorDefaults(); +} + +GPSEventSource::~GPSEventSource() { + delete m_generator; +} + +void GPSEventSource::setupGeneratorDefaults() { + m_generator->GetCurrentSource()->SetParticleDefinition(G4MuonMinus::MuonMinusDefinition()); + + m_generator->GetCurrentSource()->GetEneDist()->SetEnergyDisType("Mono"); + m_generator->GetCurrentSource()->GetEneDist()->SetMonoEnergy(5 * GeV); + + m_generator->GetCurrentSource()->GetPosDist()->SetPosDisType("Point"); + m_generator->GetCurrentSource()->GetPosDist()->SetCentreCoords(G4ThreeVector(0, 0, 0)); + + m_generator->GetCurrentSource()->GetAngDist()->SetAngDistType("planar"); + m_generator->GetCurrentSource()->GetAngDist()->SetParticleMomentumDirection(G4ThreeVector(0, 1, 0)); +} + +void GPSEventSource::generate(G4Event* evt) { + m_generator->GeneratePrimaryVertex(evt); +} + +/** This is mostly wrong until after the first event generation. */ +void GPSEventSource::dumpCurrentEvent() { + log() << LOG::okay << "Dumping GPS Event info..." << LOG::done; + + G4ParticleDefinition* pdef = m_generator->GetParticleDefinition(); + + log() << LOG::okay << "particle: " << pdef->GetParticleName() << LOG::done; + log() << LOG::okay << "time: " << m_generator->GetParticleTime() << LOG::done; + log() << LOG::okay << "nparts: " << m_generator->GetNumberOfParticles() << LOG::done; + log() << LOG::okay << "pos: " << m_generator->GetParticlePosition() << LOG::done; + log() << LOG::okay << "mom: " << m_generator->GetParticleMomentumDirection() << LOG::done; + log() << LOG::okay << "E: " << m_generator->GetParticleEnergy() << LOG::done; + log() << LOG::okay << LOG::done; +} + +G4GeneralParticleSource* GPSEventSource::getGPS() { + return m_generator; +}
} // namespace slic
diff -u -r1.17 -r1.18 --- GeneratorMessenger.cc 4 Jul 2012 01:01:48 -0000 1.17 +++ GeneratorMessenger.cc 27 Nov 2012 19:32:19 -0000 1.18 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/GeneratorMessenger.cc,v 1.17 2012/07/04 01:01:48 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/GeneratorMessenger.cc,v 1.18 2012/11/27 19:32:19 jeremy Exp $
#include "GeneratorMessenger.hh" // slic
@@ -20,141 +20,131 @@
#include <ctime>
-namespace CLHEP {}
+namespace CLHEP { +}
using namespace CLHEP;
-namespace slic -{
+namespace slic { + +GeneratorMessenger::GeneratorMessenger() { + defineCommands(); +} + +GeneratorMessenger::~GeneratorMessenger() { +} + +void GeneratorMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) { + std::istringstream is((const char*) newVals);
- GeneratorMessenger::GeneratorMessenger() - { - defineCommands(); - } - - GeneratorMessenger::~GeneratorMessenger() - {} - - void GeneratorMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) - { - std::istringstream is ( ( const char* ) newVals ); - - std::string s; - is >> s; - - EventSourceManager* mgr = EventSourceManager::instance(); - - // select - if ( cmd == m_selectCmd ) - { - mgr->setupEventSource( s ); - } - // reset - else if ( cmd == m_resetCmd ) - { - mgr->resetCurrentEventSource(); - } - // skipEvents - else if ( cmd == m_skipEventsCmd ) - { - mgr->setSkipEvents( StringUtil::toInt( s ) ); - } - // filename - else if ( cmd == m_filenameCmd ) - { - mgr->setFilename( s ); - } - // dumpCurrentEvent - else if ( cmd == m_dumpCurrentEventCmd ) - { - mgr->dumpCurrentEvent(); - } - // printNumEventsGenerated - else if ( cmd == m_printNumEventsGeneratedCmd ) - { - mgr->printNumEventsGenerated(); - } - // set random seed - else if ( cmd == m_randomSeedCmd ) - { - G4int seed = 0; - - // seed from user arg - if ( s != std::string("") ) { - seed = StringUtil::toInt( s ); - } - // seed from time - // @todo Get MS instead of just seconds, which is not very good quality for a seed. - else { - seed = ((unsigned)time(NULL)); - } - - // seed it - HepRandom::setTheSeed( seed ); - - mgr->log() << LOG::okay << "set random seed: " << seed << LOG::done; - } - // Lorentz transformation angle - else if ( cmd == m_setLorentzTransformationAngleCmd ) - { - EventSourceManager::instance()->setLorentzTransformationAngle(G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(newVals)); - } - else if (cmd == m_setZSmearingParameterCmd) { - EventSourceManager::instance()->setZSmearing(G4UIcmdWithADouble::GetNewDoubleValue(newVals)); - } - else { - G4Exception("", "", JustWarning, "Unknown command."); - } - } - - void GeneratorMessenger::defineCommands() - { - G4UIparameter *p; - - // generator dir - m_generatorDir = new G4UIdirectory( "/generator/" ); - m_generatorDir->SetGuidance( "Event generation commands." ); - - // select - m_selectCmd = new G4UIcommand( "/generator/select", this ); - m_selectCmd->SetGuidance( "Set Generator to use: lcio, stdhep, gps or gun." ); - p = new G4UIparameter( "generator", 's', false ); - m_selectCmd->SetParameter(p); - - // reset - m_resetCmd = new G4UIcommand( "/generator/reset", this); - m_resetCmd->SetGuidance( "Reset the generator using the current info." ); - - // skipEvents - m_skipEventsCmd = new G4UIcmdWithAnInteger( "/generator/skipEvents", this); - m_skipEventsCmd->SetGuidance( "Skip n events of current generator." ); - m_skipEventsCmd->SetParameterName( "NumEvents", false); - - // filename - m_filenameCmd = new G4UIcommand( "/generator/filename", this); - m_filenameCmd->SetGuidance( "Set generator input filename."); - p = new G4UIparameter( "filename", 's', false); - m_filenameCmd->SetParameter(p); - - // dumpCurrentEvent - m_dumpCurrentEventCmd = new G4UIcommand( "/generator/dumpEvent", this); - m_dumpCurrentEventCmd->SetGuidance( "Dump information about the current generator event." ); - - // printNumEventsGenerated - m_printNumEventsGeneratedCmd = new G4UIcommand( "/generator/printNumEventsGenerated", this); - m_printNumEventsGeneratedCmd->SetGuidance( "Print out number of events generated with current generator."); - - // random seed cmd - m_randomSeedCmd = new G4UIcommand( "/random/seed", this ); - m_randomSeedCmd->SetGuidance( "Set random seed; no argument seeds with current time." ); - p = new G4UIparameter( "seedValue", 'i', true ); - m_randomSeedCmd->SetParameter( p ); - - // Lorentz transformation - m_setLorentzTransformationAngleCmd = new G4UIcmdWithADoubleAndUnit("/generator/setLorentzTransformationAngle",this); - m_setLorentzTransformationAngleCmd->SetGuidance( "Set the Lorentz transformation angle to boost generated events." ); - - // Z smearing parameter. - m_setZSmearingParameterCmd = new G4UIcmdWithADouble("/generator/setZSmearingParameter", this); - m_setZSmearingParameterCmd->SetGuidance("Set the parameter for smearing vertex Z positions."); - }
+ std::string s; + is >> s; + + EventSourceManager* mgr = EventSourceManager::instance(); + + // select + if (cmd == m_selectCmd) { + mgr->setupEventSource(s); + } + // reset + else if (cmd == m_resetCmd) { + mgr->resetCurrentEventSource(); + } + // skipEvents + else if (cmd == m_skipEventsCmd) { + mgr->setSkipEvents(StringUtil::toInt(s)); + } + // filename + else if (cmd == m_filenameCmd) { + mgr->setFilename(s); + } + // dumpCurrentEvent + else if (cmd == m_dumpCurrentEventCmd) { + mgr->dumpCurrentEvent(); + } + // printNumEventsGenerated + else if (cmd == m_printNumEventsGeneratedCmd) { + mgr->printNumEventsGenerated(); + } + // set random seed + else if (cmd == m_randomSeedCmd) { + G4int seed = 0; + + // seed from user arg + if (s != std::string("")) { + seed = StringUtil::toInt(s); + } + // seed from time + // @todo Get MS instead of just seconds, which is not very good quality for a seed. + else { + seed = ((unsigned) time(NULL)); + } + + // seed it + HepRandom::setTheSeed(seed); + + mgr->log() << LOG::okay << "set random seed: " << seed << LOG::done; + } + // Lorentz transformation angle + else if (cmd == m_setLorentzTransformationAngleCmd) { + EventSourceManager::instance()->setLorentzTransformationAngle( + G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(newVals)); + } else if (cmd == m_setZSmearingParameterCmd) { + EventSourceManager::instance()->setZSmearing(G4UIcmdWithADouble::GetNewDoubleValue(newVals)); + } else { + G4Exception("", "", JustWarning, "Unknown command."); + } +} + +void GeneratorMessenger::defineCommands() { + G4UIparameter *p; + + // generator dir + m_generatorDir = new G4UIdirectory("/generator/"); + m_generatorDir->SetGuidance("Event generation commands."); + + // select + m_selectCmd = new G4UIcommand("/generator/select", this); + m_selectCmd->SetGuidance("Set Generator to use: lcio, stdhep, gps or gun."); + p = new G4UIparameter("generator", 's', false); + m_selectCmd->SetParameter(p); + + // reset + m_resetCmd = new G4UIcommand("/generator/reset", this); + m_resetCmd->SetGuidance("Reset the generator using the current info."); + + // skipEvents + m_skipEventsCmd = new G4UIcmdWithAnInteger("/generator/skipEvents", this); + m_skipEventsCmd->SetGuidance("Skip n events of current generator."); + m_skipEventsCmd->SetParameterName("NumEvents", false); + + // filename + m_filenameCmd = new G4UIcommand("/generator/filename", this); + m_filenameCmd->SetGuidance("Set generator input filename."); + p = new G4UIparameter("filename", 's', false); + m_filenameCmd->SetParameter(p); + + // dumpCurrentEvent + m_dumpCurrentEventCmd = new G4UIcommand("/generator/dumpEvent", this); + m_dumpCurrentEventCmd->SetGuidance("Dump information about the current generator event."); + + // printNumEventsGenerated + m_printNumEventsGeneratedCmd = new G4UIcommand("/generator/printNumEventsGenerated", this); + m_printNumEventsGeneratedCmd->SetGuidance("Print out number of events generated with current generator."); + + // random seed cmd + m_randomSeedCmd = new G4UIcommand("/random/seed", this); + m_randomSeedCmd->SetGuidance("Set random seed; no argument seeds with current time."); + p = new G4UIparameter("seedValue", 'i', true); + m_randomSeedCmd->SetParameter(p); + + // Lorentz transformation + m_setLorentzTransformationAngleCmd = new G4UIcmdWithADoubleAndUnit( + "/generator/setLorentzTransformationAngle", this); + m_setLorentzTransformationAngleCmd->SetGuidance( + "Set the Lorentz transformation angle to boost generated events."); + + // Z smearing parameter. + m_setZSmearingParameterCmd = new G4UIcmdWithADouble("/generator/setZSmearingParameter", this); + m_setZSmearingParameterCmd->SetGuidance("Set the parameter for smearing vertex Z positions."); +}
}
diff -u -r1.4 -r1.5 --- HitsCollectionUtil.cc 12 Dec 2007 03:19:13 -0000 1.4 +++ HitsCollectionUtil.cc 27 Nov 2012 19:32:19 -0000 1.5 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/HitsCollectionUtil.cc,v 1.4 2007/12/12 03:19:13 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/HitsCollectionUtil.cc,v 1.5 2012/11/27 19:32:19 jeremy Exp $
#include "HitsCollectionUtil.hh" // lcdd
@@ -15,69 +15,59 @@
#include <vector> #include <algorithm>
-namespace slic -{ - std::vector<G4SensitiveDetector*> HitsCollectionUtil::getSensitiveDetectors() - { - G4SDManager* SDmgr = G4SDManager::GetSDMpointer(); - G4HCtable* HCtbl = SDmgr->GetHCtable(); - G4int num_entries = HCtbl->entries(); - - std::vector<G4SensitiveDetector*> sds; - - for (G4int i = 0;i < num_entries;i++) { - // get the name of this SD - G4String sdname = HCtbl->GetSDname( i ); - // retrieve corresponding Sensitive Detector from Geant4 store and cast to LCDD type - G4SensitiveDetector* sd = - static_cast<G4SensitiveDetector*> ( G4SDManager::GetSDMpointer()->FindSensitiveDetector( sdname ) ); - // Add, checking for dups. - if (sd && std::find(sds.begin(), sds.end(), sd) == sds.end()) sds.push_back(sd); - } - return sds; - } - - std::vector<int> HitsCollectionUtil::getHCIDs() - { - std::vector<int> hcids; - const std::vector<G4SensitiveDetector*>& sds = getSensitiveDetectors(); - for ( std::vector<G4SensitiveDetector*>::const_iterator it = sds.begin(); - it != sds.end(); - it++ ) - { - G4SensitiveDetector* sd = (*it); - for( int i = 0; i < sd->getNumberOfHitsCollections(); i++) - { - hcids.push_back( sd->getHCID(i) ); - } - } - return hcids; - } - - std::vector<std::string> HitsCollectionUtil::getHCNames() - { - std::vector<int> hcids = getHCIDs(); - - const G4Event* currEvent = - G4EventManager::GetEventManager()->GetConstCurrentEvent(); - - G4HCofThisEvent* hce = currEvent->GetHCofThisEvent(); - - std::vector<std::string> hcnames; - - if ( currEvent ) { - - G4VHitsCollection* hc = 0; - - for (std::vector<int>::const_iterator iter = hcids.begin(); - iter != hcids.end(); - iter++) { - hc = hce->GetHC( (*iter) ); - hcnames.push_back( hc->GetName() ); - } - } - - return hcnames; - }
+namespace slic { +std::vector<G4SensitiveDetector*> HitsCollectionUtil::getSensitiveDetectors() { + G4SDManager* SDmgr = G4SDManager::GetSDMpointer(); + G4HCtable* HCtbl = SDmgr->GetHCtable(); + G4int num_entries = HCtbl->entries(); + + std::vector<G4SensitiveDetector*> sds; + + for (G4int i = 0; i < num_entries; i++) { + // get the name of this SD + G4String sdname = HCtbl->GetSDname(i); + // retrieve corresponding Sensitive Detector from Geant4 store and cast to LCDD type + G4SensitiveDetector* sd = + static_cast<G4SensitiveDetector*>(G4SDManager::GetSDMpointer()->FindSensitiveDetector(sdname)); + // Add, checking for dups. + if (sd && std::find(sds.begin(), sds.end(), sd) == sds.end()) + sds.push_back(sd); + } + return sds; +} + +std::vector<int> HitsCollectionUtil::getHCIDs() { + std::vector<int> hcids; + const std::vector<G4SensitiveDetector*>& sds = getSensitiveDetectors(); + for (std::vector<G4SensitiveDetector*>::const_iterator it = sds.begin(); it != sds.end(); it++) { + G4SensitiveDetector* sd = (*it); + for (int i = 0; i < sd->getNumberOfHitsCollections(); i++) { + hcids.push_back(sd->getHCID(i)); + } + } + return hcids; +} + +std::vector<std::string> HitsCollectionUtil::getHCNames() { + std::vector<int> hcids = getHCIDs(); + + const G4Event* currEvent = G4EventManager::GetEventManager()->GetConstCurrentEvent(); + + G4HCofThisEvent* hce = currEvent->GetHCofThisEvent(); + + std::vector<std::string> hcnames; + + if (currEvent) { + + G4VHitsCollection* hc = 0; + + for (std::vector<int>::const_iterator iter = hcids.begin(); iter != hcids.end(); iter++) { + hc = hce->GetHC((*iter)); + hcnames.push_back(hc->GetName()); + } + } + + return hcnames; +}
}
diff -u -r1.7 -r1.8 --- LCExtendedParticles.cc 7 Apr 2011 23:32:20 -0000 1.7 +++ LCExtendedParticles.cc 27 Nov 2012 19:32:19 -0000 1.8 @@ -6,85 +6,72 @@
// geant4 #include "G4ProcessManager.hh"
-namespace slic -{
+namespace slic {
- LCExtendedParticles::LCExtendedParticles(const G4String& name) - : G4VPhysicsConstructor(name) - {} - - LCExtendedParticles::~LCExtendedParticles() - {} - - void LCExtendedParticles::ConstructParticle() - { - // Get the particle data table to be imported. - HepPDT::ParticleDataTable* pdtbl = HepPDTManager::instance()->getParticleDataTable(); - - // Loop over all particles. - for ( HepPDT::ParticleDataTable::const_iterator it = pdtbl->begin(); - it != pdtbl->end(); - it++ ) - { - HepPDT::ParticleID id = it->first; - HepPDT::ParticleData pdata = it->second; - - // Check for a built-in definition of this particle. - G4ParticleDefinition* pdef = G4ParticleTable::GetParticleTable()->FindParticle(pdata.pid()); - - // Add particles that Geant4 does not already know about. - if (pdef == 0) - { - G4String name = "extended"; - if ( id.isSUSY() ) - name = "susy"; - - // Create a G4ParticleDefinition for this SUSY particle. - new G4ParticleDefinition( - pdata.PDTname(), // name - pdata.mass().value() * GeV, // mass - pdata.totalWidth().value(), // width - pdata.charge(), // charge - 0, // 2*spin - 0, // parity - 0, // C-conjugation - 0, // 2*isospin - 0, // 2*isospin3 - 0, // G-parity - "extended", // type - 0, // lepton number - 0, // baryon number - pdata.pid(), // PDG encoding - false, // stable - DBL_MIN, // lifetime (can be overridden by predefined decay time) - 0, // decay table - false // short lived - ); - } - } - } - - void LCExtendedParticles::ConstructProcess() - { - theParticleIterator->reset(); - while((*theParticleIterator)()) - { - G4ParticleDefinition* pdef = theParticleIterator->value(); - G4ProcessManager* pmgr = pdef->GetProcessManager(); - if (pdef->GetParticleType() == "extended" || pdef->GetParticleType() == "susy") - { - if (pdef->GetPDGCharge() != 0) - { - pmgr->AddProcess(&m_scatter, -1, 1, 1); // multiple scattering - pmgr->AddProcess(&m_ionise, -1, 2, 2); // ionisation - pmgr->AddProcess(&m_decay, -1, -1, 2); // decay - } - else - { - pmgr->AddProcess(&m_scatter, -1, 1, 1); // multiple scattering - pmgr->AddProcess(&m_decay, -1, -1, 2); // decay - } - } - } - }
+LCExtendedParticles::LCExtendedParticles(const G4String& name) : + G4VPhysicsConstructor(name) { +} + +LCExtendedParticles::~LCExtendedParticles() { +} + +void LCExtendedParticles::ConstructParticle() { + // Get the particle data table to be imported. + HepPDT::ParticleDataTable* pdtbl = HepPDTManager::instance()->getParticleDataTable(); + + // Loop over all particles. + for (HepPDT::ParticleDataTable::const_iterator it = pdtbl->begin(); it != pdtbl->end(); it++) { + HepPDT::ParticleID id = it->first; + HepPDT::ParticleData pdata = it->second; + + // Check for a built-in definition of this particle. + G4ParticleDefinition* pdef = G4ParticleTable::GetParticleTable()->FindParticle(pdata.pid()); + + // Add particles that Geant4 does not already know about. + if (pdef == 0) { + G4String name = "extended"; + if (id.isSUSY()) + name = "susy"; + + // Create a G4ParticleDefinition for this SUSY particle. + new G4ParticleDefinition(pdata.PDTname(), // name + pdata.mass().value() * GeV, // mass + pdata.totalWidth().value(), // width + pdata.charge(), // charge + 0, // 2*spin + 0, // parity + 0, // C-conjugation + 0, // 2*isospin + 0, // 2*isospin3 + 0, // G-parity + "extended", // type + 0, // lepton number + 0, // baryon number + pdata.pid(), // PDG encoding + false, // stable + DBL_MIN, // lifetime (can be overridden by predefined decay time) + 0, // decay table + false // short lived + ); + } + } +} + +void LCExtendedParticles::ConstructProcess() { + theParticleIterator->reset(); + while ((*theParticleIterator)()) { + G4ParticleDefinition* pdef = theParticleIterator->value(); + G4ProcessManager* pmgr = pdef->GetProcessManager(); + if (pdef->GetParticleType() == "extended" || pdef->GetParticleType() == "susy") { + if (pdef->GetPDGCharge() != 0) { + pmgr->AddProcess(&m_scatter, -1, 1, 1); // multiple scattering + pmgr->AddProcess(&m_ionise, -1, 2, 2); // ionisation + pmgr->AddProcess(&m_decay, -1, -1, 2); // decay + } else { + pmgr->AddProcess(&m_scatter, -1, 1, 1); // multiple scattering + pmgr->AddProcess(&m_decay, -1, -1, 2); // decay + } + } + } +}
}
diff -u -r1.6 -r1.7 --- LCOpticalPhysics.cc 19 Feb 2008 00:23:55 -0000 1.6 +++ LCOpticalPhysics.cc 27 Nov 2012 19:32:19 -0000 1.7 @@ -13,88 +13,74 @@
// slic #include "Geant4VersionInfo.hh"
-LCOpticalPhysics::LCOpticalPhysics(const G4String& name) - : G4VPhysicsConstructor(name) -{} - -LCOpticalPhysics::~LCOpticalPhysics() -{} - -void LCOpticalPhysics::ConstructParticle() -{ - // optical photon - G4OpticalPhoton::OpticalPhotonDefinition();
+LCOpticalPhysics::LCOpticalPhysics(const G4String& name) : + G4VPhysicsConstructor(name) {
}
-void LCOpticalPhysics::ConstructProcess() -{ - ConstructOp();
+LCOpticalPhysics::~LCOpticalPhysics() { +}
+void LCOpticalPhysics::ConstructParticle() { + // optical photon + G4OpticalPhoton::OpticalPhotonDefinition();
}
-void LCOpticalPhysics::ConstructOp() -{ - theCerenkovProcess = new G4Cerenkov("Cerenkov"); - theScintillationProcess = new G4Scintillation("Scintillation"); - theAbsorptionProcess = new G4OpAbsorption(); - theRayleighScatteringProcess = new G4OpRayleigh(); - theBoundaryProcess = new G4OpBoundaryProcess();
+void LCOpticalPhysics::ConstructProcess() { + ConstructOp(); + +} + +void LCOpticalPhysics::ConstructOp() { + theCerenkovProcess = new G4Cerenkov("Cerenkov"); + theScintillationProcess = new G4Scintillation("Scintillation"); + theAbsorptionProcess = new G4OpAbsorption(); + theRayleighScatteringProcess = new G4OpRayleigh(); + theBoundaryProcess = new G4OpBoundaryProcess();
// theCerenkovProcess->DumpPhysicsTable(); // theScintillationProcess->DumpPhysicsTable(); // theAbsorptionProcess->DumpPhysicsTable(); // theRayleighScatteringProcess->DumpPhysicsTable();
- -
//#ifdef debug // G4cout << "VERBOSE = " << theCerenkovProcess->GetVerboseLevel() << G4endl; // G4cout << "Inside LCOpticalPhysics::ConstructOp()" << G4endl;
- //#endif - - - theCerenkovProcess->SetMaxNumPhotonsPerStep(300); - - - theScintillationProcess->SetScintillationYieldFactor(1.); - // theScintillationProcess->SetTrackSecondariesFirst(true); - - G4OpticalSurfaceModel themodel = unified; - theBoundaryProcess->SetModel(themodel); - - theParticleIterator->reset(); - - while( (*theParticleIterator)() ) - { - - G4ParticleDefinition* particle = theParticleIterator->value(); - G4ProcessManager* pmanager = particle->GetProcessManager(); - G4String particleName = particle->GetParticleName(); - - if (theCerenkovProcess->IsApplicable(*particle)) - { - if (Geant4VersionInfo::getMajorVersion() >= 9 && Geant4VersionInfo::getMinorVersion() >= 1) - { - // Geant4 9.1 changes Cerenkov to be a post-step process. - pmanager->AddProcess(theCerenkovProcess); - pmanager->SetProcessOrderingToLast(theCerenkovProcess, idxPostStep); - } - else - { - pmanager->AddContinuousProcess(theCerenkovProcess); - } - } - if (theScintillationProcess->IsApplicable(*particle)) - { - pmanager->AddProcess(theScintillationProcess); - pmanager->SetProcessOrderingToLast(theScintillationProcess, idxAtRest); - pmanager->SetProcessOrderingToLast(theScintillationProcess, idxPostStep); - } - if (particleName == "opticalphoton") - { - pmanager->AddDiscreteProcess(theAbsorptionProcess); - pmanager->AddDiscreteProcess(theRayleighScatteringProcess); - pmanager->AddDiscreteProcess(theBoundaryProcess); - } - }
+ //#endif + + theCerenkovProcess->SetMaxNumPhotonsPerStep(300); + + theScintillationProcess->SetScintillationYieldFactor(1.); + // theScintillationProcess->SetTrackSecondariesFirst(true); + + G4OpticalSurfaceModel themodel = unified; + theBoundaryProcess->SetModel(themodel); + + theParticleIterator->reset(); + + while ((*theParticleIterator)()) { + + G4ParticleDefinition* particle = theParticleIterator->value(); + G4ProcessManager* pmanager = particle->GetProcessManager(); + G4String particleName = particle->GetParticleName(); + + if (theCerenkovProcess->IsApplicable(*particle)) { + if (Geant4VersionInfo::getMajorVersion() >= 9 && Geant4VersionInfo::getMinorVersion() >= 1) { + // Geant4 9.1 changes Cerenkov to be a post-step process. + pmanager->AddProcess(theCerenkovProcess); + pmanager->SetProcessOrderingToLast(theCerenkovProcess, idxPostStep); + } else { + pmanager->AddContinuousProcess(theCerenkovProcess); + } + } + if (theScintillationProcess->IsApplicable(*particle)) { + pmanager->AddProcess(theScintillationProcess); + pmanager->SetProcessOrderingToLast(theScintillationProcess, idxAtRest); + pmanager->SetProcessOrderingToLast(theScintillationProcess, idxPostStep); + } + if (particleName == "opticalphoton") { + pmanager->AddDiscreteProcess(theAbsorptionProcess); + pmanager->AddDiscreteProcess(theRayleighScatteringProcess); + pmanager->AddDiscreteProcess(theBoundaryProcess); + } + }
}
diff -u -r1.6 -r1.7 --- LCSUSYPhysics.cc 16 Dec 2009 00:11:47 -0000 1.6 +++ LCSUSYPhysics.cc 27 Nov 2012 19:32:19 -0000 1.7 @@ -9,77 +9,66 @@
#include "G4ParticleDefinition.hh" #include "G4UnknownDecay.hh"
-namespace slic -{ - LCSUSYPhysics::LCSUSYPhysics( const G4String& name ) - : G4VPhysicsConstructor( name ) - {;} - - LCSUSYPhysics::~LCSUSYPhysics() - {;} - - void LCSUSYPhysics::ConstructParticle() - { - // Get the particle data table to be imported. - HepPDT::ParticleDataTable* pdtbl = HepPDTManager::instance()->getParticleDataTable();
+namespace slic { +LCSUSYPhysics::LCSUSYPhysics(const G4String& name) : + G4VPhysicsConstructor(name) { + ; +} + +LCSUSYPhysics::~LCSUSYPhysics() { + ; +} + +void LCSUSYPhysics::ConstructParticle() { + // Get the particle data table to be imported. + HepPDT::ParticleDataTable* pdtbl = HepPDTManager::instance()->getParticleDataTable();
- // Loop over all particles. - for ( HepPDT::ParticleDataTable::const_iterator it = pdtbl->begin(); - it != pdtbl->end(); - it++ ) - { - HepPDT::ParticleID id = it->first; - HepPDT::ParticleData pdata = it->second;
+ // Loop over all particles. + for (HepPDT::ParticleDataTable::const_iterator it = pdtbl->begin(); it != pdtbl->end(); it++) { + HepPDT::ParticleID id = it->first; + HepPDT::ParticleData pdata = it->second;
- // Only adding SUSY particles. - if ( id.isSUSY() ) - { - // Create a G4ParticleDefinition for this SUSY particle. - new G4ParticleDefinition( - pdata.PDTname(), // name - pdata.mass().value() * GeV, // mass - pdata.totalWidth().value(), // width - pdata.charge(), // charge - 0, // 2*spin - 0, // parity - 0, // C-conjugation - 0, // 2*isospin - 0, // 2*isospin3 - 0, // G-parity - "susy", // type - 0, // lepton number - 0, // baryon number - pdata.pid(), // PDG encoding - false, // stable - 1e30, // lifetime (DEBUG) - 0, // decay table - false // short lived - ); - } - } - } - - void LCSUSYPhysics::ConstructProcess() - { - theParticleIterator->reset(); - while( ( *theParticleIterator ) () ) - { - G4ParticleDefinition* pdef = theParticleIterator->value(); - G4ProcessManager* pmgr = pdef->GetProcessManager(); - if ( m_decay.IsApplicable( *pdef ) ) - { - if ( pdef->GetPDGCharge() != 0 ) - { - pmgr->AddProcess( &m_scatter, -1, 1, 1 ); // multiple scattering - pmgr->AddProcess( &m_ionise, -1, 2, 2 ); // ionisation - pmgr->AddProcess( &m_decay, -1, -1, 3 ); // decay - } - else - { - pmgr->AddProcess( &m_scatter, -1, 1, 1 ); // multiple scattering - pmgr->AddProcess( &m_decay, -1, -1, 2 ); // decay - } - } - } - }
+ // Only adding SUSY particles. + if (id.isSUSY()) { + // Create a G4ParticleDefinition for this SUSY particle. + new G4ParticleDefinition(pdata.PDTname(), // name + pdata.mass().value() * GeV, // mass + pdata.totalWidth().value(), // width + pdata.charge(), // charge + 0, // 2*spin + 0, // parity + 0, // C-conjugation + 0, // 2*isospin + 0, // 2*isospin3 + 0, // G-parity + "susy", // type + 0, // lepton number + 0, // baryon number + pdata.pid(), // PDG encoding + false, // stable + 1e30, // lifetime (DEBUG) + 0, // decay table + false // short lived + ); + } + } +} + +void LCSUSYPhysics::ConstructProcess() { + theParticleIterator->reset(); + while ((*theParticleIterator)()) { + G4ParticleDefinition* pdef = theParticleIterator->value(); + G4ProcessManager* pmgr = pdef->GetProcessManager(); + if (m_decay.IsApplicable(*pdef)) { + if (pdef->GetPDGCharge() != 0) { + pmgr->AddProcess(&m_scatter, -1, 1, 1); // multiple scattering + pmgr->AddProcess(&m_ionise, -1, 2, 2); // ionisation + pmgr->AddProcess(&m_decay, -1, -1, 3); // decay + } else { + pmgr->AddProcess(&m_scatter, -1, 1, 1); // multiple scattering + pmgr->AddProcess(&m_decay, -1, -1, 2); // decay + } + } + } +}
}
diff -u -r1.8 -r1.9 --- LcioEventSource.cc 31 Jan 2012 18:52:30 -0000 1.8 +++ LcioEventSource.cc 27 Nov 2012 19:32:19 -0000 1.9 @@ -1,110 +1,93 @@
-// $Header: /cvs/lcd/slic/src/LcioEventSource.cc,v 1.8 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioEventSource.cc,v 1.9 2012/11/27 19:32:19 jeremy Exp $
#include "LcioEventSource.hh" // slic #include "LcioMcpFilter.hh"
-namespace slic -{
+namespace slic {
- LcioEventSource::LcioEventSource(const std::string& fname) - : EventSourceWithInputFile( "LcioEventSource", fname), - m_event(0) - { - m_reader = IOIMPL::LCFactory::getInstance()->createLCReader(); - - m_filter = new LcioMcpFilter(); - } - - LcioEventSource::~LcioEventSource() - { - delete m_reader; - } - - // open the current file - void LcioEventSource::open() - { - try {
+LcioEventSource::LcioEventSource(const std::string& fname) : + EventSourceWithInputFile("LcioEventSource", fname), m_event(0) { + m_reader = IOIMPL::LCFactory::getInstance()->createLCReader(); + + m_filter = new LcioMcpFilter(); +} + +LcioEventSource::~LcioEventSource() { + delete m_reader; +} + +// open the current file +void LcioEventSource::open() { + try {
#ifdef SLIC_LOG
- log() << LOG::verbose << "opening filename <" << m_filename << ">" << LOG::done;
+ log() << LOG::verbose << "opening filename <" << m_filename << ">" << LOG::done;
#endif
- m_reader->open( m_filename ); - m_fileIsOpen = true; - } - catch (IO::IOException& ioe) { - log() << LOG::error << ioe.what() << LOG::done; - G4Exception("", "", FatalException, "Caught exception while reading LCIO input file."); - } - } - - // close the current file - void LcioEventSource::close() - { - try { - m_reader->close(); - m_fileIsOpen = false; - } - catch (...) { - } - } - - // read the next event - void LcioEventSource::readNextEvent() - { - m_event = m_reader->readNextEvent(); - - if ( 0 == m_event ) { - m_eof = true; - } - } - - void LcioEventSource::dumpCurrentEvent() - { - log() << LOG::debug << "LcioEventSource - Initial MCParticle Collection" << LOG::done; - - LcioMcpManager::instance()->printMcpCollection( "initial" ); - } - - void LcioEventSource::generate(G4Event* anEvent) - { - assert( LcioMcpManager::instance()->getInitialMcpCollection() ); - LcioManager::instance() - ->getGenerator() - ->generatePrimaryVertexFromMcpCollection(LcioMcpManager::instance()->getInitialMcpCollection(), - anEvent ); - } - - void LcioEventSource::beginRun(const G4Run* aRun) - { - // do superclass action - EventSourceWithInputFile::beginRun( aRun ); - } - - void LcioEventSource::beginEvent(const G4Event* anEvent) - { - // read an event - EventSourceWithInputFile::beginEvent( anEvent ); - - // set initial collection to filtered coll w/ gen parts only - LcioMcpManager::instance() - ->setInitialMcpCollection( m_filter->filterSimParticles( getCurrentMcpLCCollection() ) ); - } - - EVENT::LCCollection* LcioEventSource::getCurrentMcpLCCollection() - { - EVENT::LCCollection* mcpColl = 0; - - if ( m_event ) { - - mcpColl = LcioMcpManager::instance()->findMcpCollection( m_event ); - - if ( mcpColl == 0 ) { - G4Exception("", "", FatalException, "No Mcp collection found in LCIO input event."); - } - } - else { - log() << LOG::error << "LCEvent is null" << LOG::done; - } - return mcpColl; - }
+ m_reader->open(m_filename); + m_fileIsOpen = true; + } catch (IO::IOException& ioe) { + log() << LOG::error << ioe.what() << LOG::done; + G4Exception("", "", FatalException, "Caught exception while reading LCIO input file."); + } +} + +// close the current file +void LcioEventSource::close() { + try { + m_reader->close(); + m_fileIsOpen = false; + } catch (...) { + } +} + +// read the next event +void LcioEventSource::readNextEvent() { + m_event = m_reader->readNextEvent(); + + if (0 == m_event) { + m_eof = true; + } +} + +void LcioEventSource::dumpCurrentEvent() { + log() << LOG::debug << "LcioEventSource - Initial MCParticle Collection" << LOG::done; + + LcioMcpManager::instance()->printMcpCollection("initial"); +} + +void LcioEventSource::generate(G4Event* anEvent) { + assert( LcioMcpManager::instance()->getInitialMcpCollection()); + LcioManager::instance()->getGenerator()->generatePrimaryVertexFromMcpCollection( + LcioMcpManager::instance()->getInitialMcpCollection(), anEvent); +} + +void LcioEventSource::beginRun(const G4Run* aRun) { + // do superclass action + EventSourceWithInputFile::beginRun(aRun); +} + +void LcioEventSource::beginEvent(const G4Event* anEvent) { + // read an event + EventSourceWithInputFile::beginEvent(anEvent); + + // set initial collection to filtered coll w/ gen parts only + LcioMcpManager::instance()->setInitialMcpCollection( + m_filter->filterSimParticles(getCurrentMcpLCCollection())); +} + +EVENT::LCCollection* LcioEventSource::getCurrentMcpLCCollection() { + EVENT::LCCollection* mcpColl = 0; + + if (m_event) { + + mcpColl = LcioMcpManager::instance()->findMcpCollection(m_event); + + if (mcpColl == 0) { + G4Exception("", "", FatalException, "No Mcp collection found in LCIO input event."); + } + } else { + log() << LOG::error << "LCEvent is null" << LOG::done; + } + return mcpColl; +}
}
diff -u -r1.21 -r1.22 --- LcioFileNamer.cc 10 Oct 2007 21:57:43 -0000 1.21 +++ LcioFileNamer.cc 27 Nov 2012 19:32:19 -0000 1.22 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioFileNamer.cc,v 1.21 2007/10/10 21:57:43 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioFileNamer.cc,v 1.22 2012/11/27 19:32:19 jeremy Exp $
#include "LcioFileNamer.hh" // lcdd
@@ -23,160 +23,134 @@
using namespace std;
-namespace slic -{
+namespace slic {
- std::string LcioFileNamer::m_sep = "_";
+std::string LcioFileNamer::m_sep = "_";
- LcioFileNamer::LcioFileNamer() - : Module("LcioFileNamer") - { - m_defaultFields.push_back("event"); - m_defaultFields.push_back("application"); - m_defaultFields.push_back("geant4"); - m_defaultFields.push_back("physics"); - m_defaultFields.push_back("geometry"); - } - - std::string LcioFileNamer::getFieldValue(std::string field) - { - std::string value; - - if ( field == "application" || field == "app" ) { - value = PackageInfo::getAbbrevString() + "-" + PackageInfo::getVersionString(); - } - else if ( field == "geometry" || field == "geo" ) { - value = LCDDProcessor::instance()->getDetectorName(); - } - else if ( field == "date" ) { - value = TimeUtil::getDate(); - } - else if ( field == "event" || field == "evt" ) { - value = LcioFileNamer::makeEventName(); - } - else if ( field == "eventNumber" || field == "evtNum" ) { - value = LcioFileNamer::makeEventNumberString(); - } - else if ( field == "run" || field == "runNumber" || field == "runNum" ) { - value = LcioFileNamer::makeRunNumberString(); - } - else if ( field == "binary" ) { - value = SlicApplication::instance()->getBinaryBasename(); - } - else if ( field == "physics" ) { - value = PhysicsListManager::instance()->getCurrentListName(); - } - else if ( field == "geant4" ) { - value = SlicApplication::instance()->getGeant4VersionString(); - } - else {
+LcioFileNamer::LcioFileNamer() : + Module("LcioFileNamer") { + m_defaultFields.push_back("event"); + m_defaultFields.push_back("application"); + m_defaultFields.push_back("geant4"); + m_defaultFields.push_back("physics"); + m_defaultFields.push_back("geometry"); +} + +std::string LcioFileNamer::getFieldValue(std::string field) { + std::string value; + + if (field == "application" || field == "app") { + value = PackageInfo::getAbbrevString() + "-" + PackageInfo::getVersionString(); + } else if (field == "geometry" || field == "geo") { + value = LCDDProcessor::instance()->getDetectorName(); + } else if (field == "date") { + value = TimeUtil::getDate(); + } else if (field == "event" || field == "evt") { + value = LcioFileNamer::makeEventName(); + } else if (field == "eventNumber" || field == "evtNum") { + value = LcioFileNamer::makeEventNumberString(); + } else if (field == "run" || field == "runNumber" || field == "runNum") { + value = LcioFileNamer::makeRunNumberString(); + } else if (field == "binary") { + value = SlicApplication::instance()->getBinaryBasename(); + } else if (field == "physics") { + value = PhysicsListManager::instance()->getCurrentListName(); + } else if (field == "geant4") { + value = SlicApplication::instance()->getGeant4VersionString(); + } else {
#ifdef SLIC_LOG
- log() << LOG::error << "Ignoring unknown autoname field <" << field << ">." << LOG::done;
+ log() << LOG::error << "Ignoring unknown autoname field <" << field << ">." << LOG::done;
#endif
- value = ""; - }
+ value = ""; + }
- return value; - }
+ return value; +}
- std::string LcioFileNamer::makeFileName(std::vector<std::string> fieldList) - { - std::string filename = ""; - if ( fieldList.size() != 0 ) { - for(std::vector<std::string>::const_iterator it = fieldList.begin(); - it != fieldList.end(); - it++) { - std::string value = getFieldValue(*it); - if ( value != "" ) { - filename = filename + value + m_sep;
+std::string LcioFileNamer::makeFileName(std::vector<std::string> fieldList) { + std::string filename = ""; + if (fieldList.size() != 0) { + for (std::vector<std::string>::const_iterator it = fieldList.begin(); it != fieldList.end(); it++) { + std::string value = getFieldValue(*it); + if (value != "") { + filename = filename + value + m_sep; + } + } + if (filename != "") { + filename.erase(filename.end() - 1, filename.end()); + } + } else { + filename = makeDefaultFileName();
}
- } - if ( filename != "" ) { - filename.erase(filename.end() - 1, filename.end()); - } - } - else { - filename = makeDefaultFileName(); - } - return filename; - } - - std::string LcioFileNamer::makeDefaultFileName() - { - return makeFileName(m_defaultFields); - } - - std::string LcioFileNamer::makeEventName() - { - std::string evt; - - EventSourceManager::ESourceType est = EventSourceManager::instance()->getCurrentSourceType(); - - if ( EventSourceManager::instance()->isFileSource() ) { - evt = makeFileBasedName(); - } - else if ( est == EventSourceManager::eGPS ) { - evt = makeGPSName(); - } - else if ( est == EventSourceManager::eParticleGun ) { - evt = makeGunName(); - } - else { - evt = "events"; - } - return evt; - } - - std::string LcioFileNamer::makeFileBasedName() - { - std::string fname = EventSourceManager::instance()->getFilename(); - - // basename and remove file extension - fname = FileUtil::removeExtension( FileUtil::basename(fname) ); - - return fname; - } - - std::string LcioFileNamer::makeGPSName() - { - G4GeneralParticleSource* gps = EventSourceManager::instance()->getGPS(); - - // particle name - std::string pname = gps->GetParticleDefinition()->GetParticleName(); - - // energy - double ene = gps->GetCurrentSource()->GetEneDist()->GenerateOne( gps->GetParticleDefinition() ); - std::string eneStr = StringUtil::toString( ene / GeV ) + "GeV"; - - // full string - std::string evtname = pname + m_sep + eneStr; - - return evtname; - } - - std::string LcioFileNamer::makeGunName() - { - G4ParticleGun* gun = EventSourceManager::instance()->getParticleGun(); - - // particle name - std::string pname = gun->GetParticleDefinition()->GetParticleName(); - - // energy - std::string pE = StringUtil::toString( gun->GetParticleEnergy() / GeV ) + "GeV"; - - // full string - std::string evtname = pname + m_sep + pE; - - return evtname; - } - - std::string LcioFileNamer::makeRunNumberString() - { - return StringUtil::toString( G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID() ); - } - - std::string LcioFileNamer::makeEventNumberString() - { - return StringUtil::toString( SlicApplication::instance()->getRunManager()->getNumberOfEventsToRun() ); - }
+ return filename; +} + +std::string LcioFileNamer::makeDefaultFileName() { + return makeFileName(m_defaultFields); +} + +std::string LcioFileNamer::makeEventName() { + std::string evt; + + EventSourceManager::ESourceType est = EventSourceManager::instance()->getCurrentSourceType(); + + if (EventSourceManager::instance()->isFileSource()) { + evt = makeFileBasedName(); + } else if (est == EventSourceManager::eGPS) { + evt = makeGPSName(); + } else if (est == EventSourceManager::eParticleGun) { + evt = makeGunName(); + } else { + evt = "events"; + } + return evt; +} + +std::string LcioFileNamer::makeFileBasedName() { + std::string fname = EventSourceManager::instance()->getFilename(); + + // basename and remove file extension + fname = FileUtil::removeExtension(FileUtil::basename(fname)); + + return fname; +} + +std::string LcioFileNamer::makeGPSName() { + G4GeneralParticleSource* gps = EventSourceManager::instance()->getGPS(); + + // particle name + std::string pname = gps->GetParticleDefinition()->GetParticleName(); + + // energy + double ene = gps->GetCurrentSource()->GetEneDist()->GenerateOne(gps->GetParticleDefinition()); + std::string eneStr = StringUtil::toString(ene / GeV) + "GeV"; + + // full string + std::string evtname = pname + m_sep + eneStr; + + return evtname; +} + +std::string LcioFileNamer::makeGunName() { + G4ParticleGun* gun = EventSourceManager::instance()->getParticleGun(); + + // particle name + std::string pname = gun->GetParticleDefinition()->GetParticleName(); + + // energy + std::string pE = StringUtil::toString(gun->GetParticleEnergy() / GeV) + "GeV"; + + // full string + std::string evtname = pname + m_sep + pE; + + return evtname; +} + +std::string LcioFileNamer::makeRunNumberString() { + return StringUtil::toString(G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID()); +} + +std::string LcioFileNamer::makeEventNumberString() { + return StringUtil::toString(SlicApplication::instance()->getRunManager()->getNumberOfEventsToRun()); +}
}
diff -u -r1.24 -r1.25 --- LcioHitsCollectionBuilder.cc 14 Aug 2012 19:13:34 -0000 1.24 +++ LcioHitsCollectionBuilder.cc 27 Nov 2012 19:32:19 -0000 1.25 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioHitsCollectionBuilder.cc,v 1.24 2012/08/14 19:13:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioHitsCollectionBuilder.cc,v 1.25 2012/11/27 19:32:19 jeremy Exp $
// SLIC #include "LcioHitsCollectionBuilder.hh"
@@ -28,514 +28,441 @@
using IMPL::LCCollectionVec; using EVENT::LCIO;
-namespace CLHEP -{}
+namespace CLHEP { +}
using namespace CLHEP; using std::string;
-namespace slic -{
+namespace slic {
LcioHitsCollectionBuilder::LcioHitsCollectionBuilder() :
- Module("LcioHitsCollectionBuilder"), m_storeMomentum(0) -{ - // set local LcioMcpManager ptr - m_mcpManager = LcioMcpManager::instance();
+ Module("LcioHitsCollectionBuilder"), m_storeMomentum(0) { + // set local LcioMcpManager ptr + m_mcpManager = LcioMcpManager::instance();
- // setup default coll flag for cal hits - setCalFlagDefaults();
+ // setup default coll flag for cal hits + setCalFlagDefaults();
- // Set store momentum bit for TrackerHits - m_trkCollFlag.setBit(LCIO::THBIT_MOMENTUM);
+ // Set store momentum bit for TrackerHits + m_trkCollFlag.setBit(LCIO::THBIT_MOMENTUM);
}
-LcioHitsCollectionBuilder::~LcioHitsCollectionBuilder() -{;}
+LcioHitsCollectionBuilder::~LcioHitsCollectionBuilder() { + ; +}
// create the hit collections
-void LcioHitsCollectionBuilder::createHitCollections() -{ - // fetch HCIDs - std::vector<int> hcids = HitsCollectionUtil::getHCIDs();
+void LcioHitsCollectionBuilder::createHitCollections() { + // fetch HCIDs + std::vector<int> hcids = HitsCollectionUtil::getHCIDs();
- // fetch hit collection of event - G4HCofThisEvent* HCE = m_currentG4Event->GetHCofThisEvent();
+ // fetch hit collection of event + G4HCofThisEvent* HCE = m_currentG4Event->GetHCofThisEvent();
- // HC table - G4HCtable* HCtbl = G4SDManager::GetSDMpointer()->GetHCtable();
+ // HC table + G4HCtable* HCtbl = G4SDManager::GetSDMpointer()->GetHCtable();
- // HCID - G4int hcid;
+ // HCID + G4int hcid;
- LCCollectionVec* collVec = 0;
+ LCCollectionVec* collVec = 0;
- for (std::vector<int>::const_iterator iter = hcids.begin(); iter!=hcids.end(); iter++) - { - hcid = *iter;
+ for (std::vector<int>::const_iterator iter = hcids.begin(); iter != hcids.end(); iter++) { + hcid = *iter;
#ifdef SLIC_LOG
- log().debug(" Creating hits collections for HCID: " + StringUtil::toString( hcid ) );
+ log().debug(" Creating hits collections for HCID: " + StringUtil::toString( hcid ) );
#endif
- // retrieve Sensitive Detector ptr - G4SensitiveDetector - *SD = - static_cast<G4SensitiveDetector*> (G4SDManager::GetSDMpointer()->FindSensitiveDetector( - HCtbl->GetSDname(hcid))); - - // get hits collection - for (int i = 0; i<SD->getNumberOfHitsCollections(); i++) - { - if (SD->getHCID(i)==hcid) - { - G4VHitsCollection* HC = HCE->GetHC(hcid); - - // add a LCCollectionVec if got a HC - if (HC) - { - // set LCIO endcap bit in the flag (i.e. CHBIT_BARREL ) according to SDs setting - setEndcapFlag(SD); - - // create collection vector based on type of SD - collVec = createCollectionVec(HC, SD->getType()); - - // Store the cellID description into the LCIO::cellIDEncoding parameter in the collection. - if (SD->getIdSpec()) - { - std::string id = SD->getIdSpec()->getFieldDescription();
+ // retrieve Sensitive Detector ptr + G4SensitiveDetector *SD = + static_cast<G4SensitiveDetector*>(G4SDManager::GetSDMpointer()->FindSensitiveDetector( + HCtbl->GetSDname(hcid))); + + // get hits collection + for (int i = 0; i < SD->getNumberOfHitsCollections(); i++) { + if (SD->getHCID(i) == hcid) { + G4VHitsCollection* HC = HCE->GetHC(hcid); + + // add a LCCollectionVec if got a HC + if (HC) { + // set LCIO endcap bit in the flag (i.e. CHBIT_BARREL ) according to SDs setting + setEndcapFlag(SD); + + // create collection vector based on type of SD + collVec = createCollectionVec(HC, SD->getType()); + + // Store the cellID description into the LCIO::cellIDEncoding parameter in the collection. + if (SD->getIdSpec()) { + std::string id = SD->getIdSpec()->getFieldDescription();
#if LCIO_VERSION_GE(1, 7)
- collVec->parameters().setValue(LCIO::CellIDEncoding, id);
+ collVec->parameters().setValue(LCIO::CellIDEncoding, id);
#else
- collVec->parameters().setValue("CellIDEncoding", id);
+ collVec->parameters().setValue("CellIDEncoding", id);
#endif
- }
+ }
- // Check for existing collection. - if (containsCollection(m_currentLCEvent, HC->GetName())) - {
+ // Check for existing collection. + if (containsCollection(m_currentLCEvent, HC->GetName())) {
#ifdef SLIC_LOG
- log().debug("Adding hits to existing collection " + HC->GetName() + ".");
+ log().debug("Adding hits to existing collection " + HC->GetName() + ".");
#endif
- // Update existing collection. - // TODO: Check for matching id scheme and flags! - LCCollectionVec * collection = - (LCCollectionVec*)m_currentLCEvent->getCollection(HC->GetName()); - collection->insert(collection->begin(), collVec->begin(), collVec->end()); - } - // No collection found. - else - {
+ // Update existing collection. + // TODO: Check for matching id scheme and flags! + LCCollectionVec * collection = (LCCollectionVec*) m_currentLCEvent->getCollection( + HC->GetName()); + collection->insert(collection->begin(), collVec->begin(), collVec->end()); + } + // No collection found. + else {
#ifdef SLIC_LOG
- log().debug("Creating new hit collection collection " + HC->GetName() + ".");
+ log().debug("Creating new hit collection collection " + HC->GetName() + ".");
#endif
- // Add new collection vector to LCEvent. - m_currentLCEvent->addCollection(collVec, HC->GetName()); - } - } - - else - { - G4Exception("LcioHitsCollectionBuilder::createHitCollections()", "", FatalException, "No collection found for Hits Collection ID"); - } - } - } - }
+ // Add new collection vector to LCEvent. + m_currentLCEvent->addCollection(collVec, HC->GetName()); + } + } + + else { + G4Exception("LcioHitsCollectionBuilder::createHitCollections()", "", FatalException, + "No collection found for Hits Collection ID"); + } + } + } + }
} // create the CollectionVec (decides which overloaded subfunction to call) IMPL::LCCollectionVec* LcioHitsCollectionBuilder::createCollectionVec(G4VHitsCollection* g4HC,
- G4SensitiveDetector::EType SDtype) -{ - // vec to create - LCCollectionVec* collVec = 0; - - // cal hits - if (SDtype==G4SensitiveDetector::eCalorimeter) - { - collVec = createCalorimeterCollectionVec(g4HC); - } - // tracker hits - else if (SDtype==G4SensitiveDetector::eTracker) - { - collVec = createTrackerCollectionVec(g4HC); - } - // unknown type of hit - else - { - G4Exception("", "", FatalException, "Unknown HC type."); - } - - return collVec; -} - -LCCollectionVec* LcioHitsCollectionBuilder::createTrackerCollectionVec(G4VHitsCollection* g4HC) -{ - // create Lcio tracker coll - LCCollectionVec* collVec = new LCCollectionVec(LCIO::SIMTRACKERHIT); - - // cast to G4 trk HC - G4TrackerHitsCollection* trkHits = dynamic_cast<G4TrackerHitsCollection*> (g4HC); - - // call overloaded save function for trk hits - saveHits(trkHits, collVec); - - // set trk flags - collVec->setFlag(m_trkCollFlag.getFlag()); - - return collVec; -} - -LCCollectionVec* LcioHitsCollectionBuilder::createCalorimeterCollectionVec(G4VHitsCollection* g4HC) -{ - // create Lcio cal coll - LCCollectionVec* collVec = new LCCollectionVec(LCIO::SIMCALORIMETERHIT); - - // cast to G4 cal HC - G4CalorimeterHitsCollection* calHits = dynamic_cast<G4CalorimeterHitsCollection*> (g4HC); - - // call overloaded save function for cal hits - saveHits(calHits, collVec); - - // set cal flags - collVec->setFlag(m_calCollFlag.getFlag()); - - return collVec; -} - -void LcioHitsCollectionBuilder::setCalFlagDefaults() -{ - m_calCollFlag.setBit(LCIO::CHBIT_LONG); - m_calCollFlag.setBit(LCIO::CHBIT_ID1); -} - -void LcioHitsCollectionBuilder::setEndcapFlag(G4SensitiveDetector* g4sd) -{ - bool ec_flag = g4sd->getEndcapFlag(); - - // set for cal - if (g4sd->getType()==G4SensitiveDetector::eCalorimeter) - { - if (ec_flag) - { - m_calCollFlag.unsetBit(LCIO::CHBIT_BARREL); - } - else - { - m_calCollFlag.setBit(LCIO::CHBIT_BARREL); - } - } - // set for trk - else if (g4sd->getType()==G4SensitiveDetector::eTracker) - { - if (ec_flag) - { - m_trkCollFlag.unsetBit(LCIO::THBIT_BARREL); - } - else - { - m_trkCollFlag.setBit(LCIO::THBIT_BARREL); - } - }
+ G4SensitiveDetector::EType SDtype) { + // vec to create + LCCollectionVec* collVec = 0; + + // cal hits + if (SDtype == G4SensitiveDetector::eCalorimeter) { + collVec = createCalorimeterCollectionVec(g4HC); + } + // tracker hits + else if (SDtype == G4SensitiveDetector::eTracker) { + collVec = createTrackerCollectionVec(g4HC); + } + // unknown type of hit + else { + G4Exception("", "", FatalException, "Unknown HC type."); + } + + return collVec; +} + +LCCollectionVec* LcioHitsCollectionBuilder::createTrackerCollectionVec(G4VHitsCollection* g4HC) { + // create Lcio tracker coll + LCCollectionVec* collVec = new LCCollectionVec(LCIO::SIMTRACKERHIT); + + // cast to G4 trk HC + G4TrackerHitsCollection* trkHits = dynamic_cast<G4TrackerHitsCollection*>(g4HC); + + // call overloaded save function for trk hits + saveHits(trkHits, collVec); + + // set trk flags + collVec->setFlag(m_trkCollFlag.getFlag()); + + return collVec; +} + +LCCollectionVec* LcioHitsCollectionBuilder::createCalorimeterCollectionVec(G4VHitsCollection* g4HC) { + // create Lcio cal coll + LCCollectionVec* collVec = new LCCollectionVec(LCIO::SIMCALORIMETERHIT); + + // cast to G4 cal HC + G4CalorimeterHitsCollection* calHits = dynamic_cast<G4CalorimeterHitsCollection*>(g4HC); + + // call overloaded save function for cal hits + saveHits(calHits, collVec); + + // set cal flags + collVec->setFlag(m_calCollFlag.getFlag()); + + return collVec; +} + +void LcioHitsCollectionBuilder::setCalFlagDefaults() { + m_calCollFlag.setBit(LCIO::CHBIT_LONG); + m_calCollFlag.setBit(LCIO::CHBIT_ID1); +} + +void LcioHitsCollectionBuilder::setEndcapFlag(G4SensitiveDetector* g4sd) { + bool ec_flag = g4sd->getEndcapFlag(); + + // set for cal + if (g4sd->getType() == G4SensitiveDetector::eCalorimeter) { + if (ec_flag) { + m_calCollFlag.unsetBit(LCIO::CHBIT_BARREL); + } else { + m_calCollFlag.setBit(LCIO::CHBIT_BARREL); + } + } + // set for trk + else if (g4sd->getType() == G4SensitiveDetector::eTracker) { + if (ec_flag) { + m_trkCollFlag.unsetBit(LCIO::THBIT_BARREL); + } else { + m_trkCollFlag.setBit(LCIO::THBIT_BARREL); + } + }
} // save cal hits void LcioHitsCollectionBuilder::saveHits(G4CalorimeterHitsCollection* calHits,
- IMPL::LCCollectionVec* lcioColl) -{ - size_t s = calHits->GetSize(); - for (size_t i = 0; i<s; i++) - { - G4CalorimeterHit* calHit = static_cast<G4CalorimeterHit*> (calHits->GetHit(i)); - lcioColl->push_back(createHit(calHit)); - }
+ IMPL::LCCollectionVec* lcioColl) { + size_t s = calHits->GetSize(); + for (size_t i = 0; i < s; i++) { + G4CalorimeterHit* calHit = static_cast<G4CalorimeterHit*>(calHits->GetHit(i)); + lcioColl->push_back(createHit(calHit)); + }
} // save trk hits
-void LcioHitsCollectionBuilder::saveHits(G4TrackerHitsCollection* trkHits, - IMPL::LCCollectionVec* lcioColl) -{ - size_t s = trkHits->GetSize(); - for (size_t i = 0; i<s; i++) - { - G4TrackerHit* trkHit = static_cast<G4TrackerHit*> (trkHits->GetHit(i)); - lcioColl->push_back(createHit(trkHit)); - }
+void LcioHitsCollectionBuilder::saveHits(G4TrackerHitsCollection* trkHits, IMPL::LCCollectionVec* lcioColl) { + size_t s = trkHits->GetSize(); + for (size_t i = 0; i < s; i++) { + G4TrackerHit* trkHit = static_cast<G4TrackerHit*>(trkHits->GetHit(i)); + lcioColl->push_back(createHit(trkHit)); + }
} // create cal hit from G4
-IMPL::SimCalorimeterHitImpl* LcioHitsCollectionBuilder::createHit(G4CalorimeterHit* calHit) -{ - SimCalorimeterHitImpl* simCalHit = new SimCalorimeterHitImpl(); - - // set cellid from cal hit's id64 - const Id64bit& id64 = calHit->getId64bit(); - simCalHit->setCellID0(id64.getId0()); - simCalHit->setCellID1(id64.getId1()); - - // position - const Hep3Vector hitPos = calHit->getPos(); - float pos[3] = - { hitPos.x(), hitPos.y(), hitPos.z() }; - simCalHit->setPosition(pos);
+IMPL::SimCalorimeterHitImpl* LcioHitsCollectionBuilder::createHit(G4CalorimeterHit* calHit) { + SimCalorimeterHitImpl* simCalHit = new SimCalorimeterHitImpl();
- // copy Mcp contrib info; energy is also incremented by contrib addition - addMcpContribs(calHit, simCalHit);
+ // set cellid from cal hit's id64 + const Id64bit& id64 = calHit->getId64bit(); + simCalHit->setCellID0(id64.getId0()); + simCalHit->setCellID1(id64.getId1()); + + // position + const Hep3Vector hitPos = calHit->getPos(); + float pos[3] = { hitPos.x(), hitPos.y(), hitPos.z() }; + simCalHit->setPosition(pos);
- // compare edep of calHit with simHit when debugging
+ // copy Mcp contrib info; energy is also incremented by contrib addition + addMcpContribs(calHit, simCalHit); + + // compare edep of calHit with simHit when debugging
//#ifdef SLIC_DEBUG
- const McpHitContribList& contribs = calHit->getMcpHitContribList(); - double totE = 0; - for ( McpHitContribList::const_iterator iter = contribs.begin(); - iter != contribs.end(); - iter++ ) - { - totE += (*iter).getEdep(); - } - - // Set energy from total of individual contributions. - //simCalHit->setEnergy(totE/GeV); - - //std::cout << "set totE = " << totE/GeV << std::endl; - // sanity check so that new and old edeps must match - //if (abs( totE/GeV - simCalHit->getEnergy() ) > ( 0.001 * totE ) ) - //{ - // log() << LOG::debug << "g4 hit E: " << totE << LOG::done; - // log() << LOG::debug << "sim hit E: " << simCalHit->getEnergy() << LOG::done; - // G4Exception("", "", JustWarning, "LCIO simCalHit E != G4 CalHit E, within tolerance"); - //}
+ const McpHitContribList& contribs = calHit->getMcpHitContribList(); + double totE = 0; + for (McpHitContribList::const_iterator iter = contribs.begin(); iter != contribs.end(); iter++) { + totE += (*iter).getEdep(); + } + + // Set energy from total of individual contributions. + //simCalHit->setEnergy(totE/GeV); + + //std::cout << "set totE = " << totE/GeV << std::endl; + // sanity check so that new and old edeps must match + //if (abs( totE/GeV - simCalHit->getEnergy() ) > ( 0.001 * totE ) ) + //{ + // log() << LOG::debug << "g4 hit E: " << totE << LOG::done; + // log() << LOG::debug << "sim hit E: " << simCalHit->getEnergy() << LOG::done; + // G4Exception("", "", JustWarning, "LCIO simCalHit E != G4 CalHit E, within tolerance"); + //}
//#endif
- return simCalHit;
+ return simCalHit;
} // create trk hit from G4
-IMPL::SimTrackerHitImpl* LcioHitsCollectionBuilder::createHit(G4TrackerHit* trkHit) -{ - SimTrackerHitImpl* simTrkHit = new SimTrackerHitImpl(); - - // position in mm - const Hep3Vector hitPos = trkHit->getPos(); - double pos[3] = - { hitPos.x(), hitPos.y(), hitPos.z() }; - simTrkHit->setPosition(pos); - - // momentum in GeV - const G4ThreeVector& momentum = trkHit->getMomentum(); - simTrkHit->setMomentum(momentum.x()/GeV, momentum.y()/GeV, momentum.z()/GeV); - - // pathLength = distance between exit and entry points in mm - simTrkHit->setPathLength(trkHit->getLength()); - - // dEdx in GeV (LCIO units) - float edep = trkHit->getEdep(); - simTrkHit->setEDep(edep/GeV); - - // time in NS - float tEdep = trkHit->getTdep(); - simTrkHit->setTime(tEdep);
+IMPL::SimTrackerHitImpl* LcioHitsCollectionBuilder::createHit(G4TrackerHit* trkHit) { + SimTrackerHitImpl* simTrkHit = new SimTrackerHitImpl(); + + // position in mm + const Hep3Vector hitPos = trkHit->getPos(); + double pos[3] = { hitPos.x(), hitPos.y(), hitPos.z() }; + simTrkHit->setPosition(pos); + + // momentum in GeV + const G4ThreeVector& momentum = trkHit->getMomentum(); + simTrkHit->setMomentum(momentum.x() / GeV, momentum.y() / GeV, momentum.z() / GeV); + + // pathLength = distance between exit and entry points in mm + simTrkHit->setPathLength(trkHit->getLength()); + + // dEdx in GeV (LCIO units) + float edep = trkHit->getEdep(); + simTrkHit->setEDep(edep / GeV); + + // time in NS + float tEdep = trkHit->getTdep(); + simTrkHit->setTime(tEdep);
- // Cell ID.
+ // Cell ID.
#if LCIO_VERSION_GE(1, 60)
- // New method for 64-bit IDs. - simTrkHit->setCellID0(trkHit->getId());
+ // New method for 64-bit IDs. + simTrkHit->setCellID0(trkHit->getId());
#else
- // Old method for 32-bit IDs. - simTrkHit->setCellID(trkHit->getId());
+ // Old method for 32-bit IDs. + simTrkHit->setCellID(trkHit->getId());
#endif
- // MCP using McpManager - MCParticleImpl* mcp = m_mcpManager->getMaps()->findMcpFromTrackID(trkHit->getTrackID());
+ // MCP using McpManager + MCParticleImpl* mcp = m_mcpManager->getMaps()->findMcpFromTrackID(trkHit->getTrackID());
- if (!mcp) - { - log().error( - "No MCP found for trackID <"+StringUtil::toString(trkHit->getTrackID()) - +"> for trk hit."); - } - else - { - simTrkHit->setMCParticle(mcp); - }
+ if (!mcp) { + log().error( + "No MCP found for trackID <" + StringUtil::toString(trkHit->getTrackID()) + "> for trk hit."); + } else { + simTrkHit->setMCParticle(mcp); + }
- return simTrkHit;
+ return simTrkHit;
} // add an MCParticle hit contribution from G4 to LCIO void LcioHitsCollectionBuilder::addMcpContribs(G4CalorimeterHit* g4CalHit,
- IMPL::SimCalorimeterHitImpl* simCalHit) -{ - // Create empty hit contrib list. - McpHitContribList contribs; - - // Use aggregation of contribs by track ID if CHBIT_PDG is not set. - if (!m_calCollFlag.bitSet(LCIO::CHBIT_PDG)) - { - // Pass a ref to contrib list, which will get filled. - combineMcpHitContribs(g4CalHit->getMcpHitContribList(), contribs); - } - // Otherwise, use the complete list from the CalHit. - else - { - contribs = g4CalHit->getMcpHitContribList(); - } - - // Add contribs to the LCIO MCParticle. - size_t ncontrib = 0; - for (McpHitContribList::const_iterator iter = contribs.begin(); iter!=contribs.end(); iter++) - { - // This contrib. - const McpHitContrib& contrib = (*iter); - - // Get the MCParticle pointer from the track ID. - MCParticleImpl* contribMcp = m_mcpManager->getMaps()->findMcpFromTrackID(contrib.getTrackID()); - - if (contribMcp != 0) - { - // Add the MCParticle contribution to the hit.
+ IMPL::SimCalorimeterHitImpl* simCalHit) { + // Create empty hit contrib list. + McpHitContribList contribs; + + // Use aggregation of contribs by track ID if CHBIT_PDG is not set. + if (!m_calCollFlag.bitSet(LCIO::CHBIT_PDG)) { + // Pass a ref to contrib list, which will get filled. + combineMcpHitContribs(g4CalHit->getMcpHitContribList(), contribs); + } + // Otherwise, use the complete list from the CalHit. + else { + contribs = g4CalHit->getMcpHitContribList(); + } + + // Add contribs to the LCIO MCParticle. + size_t ncontrib = 0; + for (McpHitContribList::const_iterator iter = contribs.begin(); iter != contribs.end(); iter++) { + // This contrib. + const McpHitContrib& contrib = (*iter); + + // Get the MCParticle pointer from the track ID. + MCParticleImpl* contribMcp = m_mcpManager->getMaps()->findMcpFromTrackID(contrib.getTrackID()); + + if (contribMcp != 0) { + // Add the MCParticle contribution to the hit.
#if LCIO_VERSION_GE(1, 60)
- // Newer LCIO versions have the step position for contributions. - simCalHit->addMCParticleContribution( - contribMcp, - (float)(contrib.getEdep()/GeV), - (float)(contrib.getGlobalTime()), - contrib.getPDGID(), - const_cast<float*>(contrib.getPosition()));
+ // Newer LCIO versions have the step position for contributions. + simCalHit->addMCParticleContribution( + contribMcp, + (float)(contrib.getEdep()/GeV), + (float)(contrib.getGlobalTime()), + contrib.getPDGID(), + const_cast<float*>(contrib.getPosition()));
#else
- // Older LCIO versions do not include the step position. - simCalHit->addMCParticleContribution( - contribMcp, - (float)(contrib.getEdep()/GeV), - (float)contrib.getGlobalTime(), - contrib.getPDGID());
+ // Older LCIO versions do not include the step position. + simCalHit->addMCParticleContribution(contribMcp, (float) (contrib.getEdep() / GeV), + (float) contrib.getGlobalTime(), contrib.getPDGID());
#endif
- ++ncontrib; - } - // Problem! Contributing particle is missing from MCParticle list.
+ ++ncontrib; + } + // Problem! Contributing particle is missing from MCParticle list.
#ifdef SLIC_LOG
- else - { - log() << LOG::always << "ERROR: Could not find MCParticle from track ID <" << contrib.getTrackID() << ">." << LOG::endl; - }
+ else + { + log() << LOG::always << "ERROR: Could not find MCParticle from track ID <" << contrib.getTrackID() << ">." << LOG::endl; + }
#endif
- }
+ }
#ifdef SLIC_LOG
- if ( ncontrib == 0 ) - { - log().error("No hit contribs for sim cal hit."); - }
+ if ( ncontrib == 0 ) + { + log().error("No hit contribs for sim cal hit."); + }
#endif } void LcioHitsCollectionBuilder::combineMcpHitContribs(const McpHitContribList& longContrib,
- McpHitContribList& combinedContrib) -{ - combinedContrib.clear(); - - // iterate over long list (one entry for every hit) - for (McpHitContribList::const_iterator iter = longContrib.begin(); iter!=longContrib.end(); iter++) - { - int trkId = (*iter).getTrackID(); - - //log().debug("Combining hits on trk_id: " + StringUtil::toString( trk_id ) ); - - // old track id in new combined list? - McpHitContrib* trk_contrib = 0; - if ((trk_contrib = findMcpHitContribByTrackID((*iter).getTrackID(), combinedContrib))) - { - // Add to the energy deposition. - trk_contrib->incrEdep((*iter).getEdep()); - - // Set the minimum time. - trk_contrib->setMinTime((*iter).getGlobalTime()); - } - // no existing contrib - else - { - // Create a new contribution. - combinedContrib.push_back(McpHitContrib(trkId, - (*iter).getEdep(), - (*iter).getPDGID(), - (*iter).getGlobalTime())); - } - }
+ McpHitContribList& combinedContrib) { + combinedContrib.clear(); + + // iterate over long list (one entry for every hit) + for (McpHitContribList::const_iterator iter = longContrib.begin(); iter != longContrib.end(); iter++) { + int trkId = (*iter).getTrackID(); + + //log().debug("Combining hits on trk_id: " + StringUtil::toString( trk_id ) ); + + // old track id in new combined list? + McpHitContrib* trk_contrib = 0; + if ((trk_contrib = findMcpHitContribByTrackID((*iter).getTrackID(), combinedContrib))) { + // Add to the energy deposition. + trk_contrib->incrEdep((*iter).getEdep()); + + // Set the minimum time. + trk_contrib->setMinTime((*iter).getGlobalTime()); + } + // no existing contrib + else { + // Create a new contribution. + combinedContrib.push_back( + McpHitContrib(trkId, (*iter).getEdep(), (*iter).getPDGID(), (*iter).getGlobalTime())); + } + }
} McpHitContrib* LcioHitsCollectionBuilder::findMcpHitContribByTrackID(int trk_id,
- McpHitContribList& contribs) -{ - McpHitContrib* c = 0; - for (McpHitContribList::iterator iter = contribs.begin(); iter!=contribs.end(); iter++) - { - if ((*iter).getTrackID()==trk_id) - { - c = &(*iter); - break; - } - } - - return c; -} - -EVENT::LCEvent* LcioHitsCollectionBuilder::createHCsFromG4Event(const G4Event* g4evt, - EVENT::LCEvent* lcevt) -{ - // set instance vars - m_currentG4Event = g4evt; - m_currentLCEvent = lcevt; - - // call real HC creation function - createHitCollections(); - - // return evt pntr, which is same as input - return m_currentLCEvent; -} - -void LcioHitsCollectionBuilder::setLongFlag(bool setting) -{ - if (setting) - { - m_calCollFlag.setBit(LCIO::CHBIT_LONG); - } - else - { - m_calCollFlag.unsetBit(LCIO::CHBIT_LONG); - }
+ McpHitContribList& contribs) { + McpHitContrib* c = 0; + for (McpHitContribList::iterator iter = contribs.begin(); iter != contribs.end(); iter++) { + if ((*iter).getTrackID() == trk_id) { + c = &(*iter); + break; + } + } + + return c; +} + +EVENT::LCEvent* LcioHitsCollectionBuilder::createHCsFromG4Event(const G4Event* g4evt, EVENT::LCEvent* lcevt) { + // set instance vars + m_currentG4Event = g4evt; + m_currentLCEvent = lcevt; + + // call real HC creation function + createHitCollections(); + + // return evt pntr, which is same as input + return m_currentLCEvent; +} + +void LcioHitsCollectionBuilder::setLongFlag(bool setting) { + if (setting) { + m_calCollFlag.setBit(LCIO::CHBIT_LONG); + } else { + m_calCollFlag.unsetBit(LCIO::CHBIT_LONG); + }
#ifdef SLIC_LOG
- log().verbose("Set CHBIT_LONG: " + StringUtil::toString( setting ) );
+ log().verbose("Set CHBIT_LONG: " + StringUtil::toString( setting ) );
#endif }
-void LcioHitsCollectionBuilder::setPDGFlag(bool setting) -{ - if (setting) - { - m_calCollFlag.setBit(LCIO::CHBIT_PDG); - } - else - { - m_calCollFlag.setBit(LCIO::CHBIT_PDG); - }
+void LcioHitsCollectionBuilder::setPDGFlag(bool setting) { + if (setting) { + m_calCollFlag.setBit(LCIO::CHBIT_PDG); + } else { + m_calCollFlag.setBit(LCIO::CHBIT_PDG); + }
#ifdef SLIC_LOG
- log().verbose("Set CHBIT_PDG: " + StringUtil::toString( setting ) );
+ log().verbose("Set CHBIT_PDG: " + StringUtil::toString( setting ) );
#endif }
-bool LcioHitsCollectionBuilder::containsCollection(EVENT::LCEvent* event, - const string& collectionName) -{ - for (std::vector<string>::const_iterator iter = event->getCollectionNames()->begin(); iter - !=event->getCollectionNames()->end(); iter++) - { - const string thisName = *iter; - if (thisName.compare(collectionName)==0) - { - return true; - } - } - return false;
+bool LcioHitsCollectionBuilder::containsCollection(EVENT::LCEvent* event, const string& collectionName) { + for (std::vector<string>::const_iterator iter = event->getCollectionNames()->begin(); + iter != event->getCollectionNames()->end(); iter++) { + const string thisName = *iter; + if (thisName.compare(collectionName) == 0) { + return true; + } + } + return false;
} } // namespace
diff -u -r1.89 -r1.90 --- LcioManager.cc 2 Aug 2012 23:05:38 -0000 1.89 +++ LcioManager.cc 27 Nov 2012 19:32:19 -0000 1.90 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioManager.cc,v 1.89 2012/08/02 23:05:38 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioManager.cc,v 1.90 2012/11/27 19:32:19 jeremy Exp $
#include "LcioManager.hh" // slic
@@ -49,425 +49,409 @@
using std::string;
-namespace slic -{
+namespace slic {
- string LcioManager::m_defaultFileName = "outfile";
+string LcioManager::m_defaultFileName = "outfile";
- LcioManager::LcioManager() - : Module("LcioManager"), - m_McpFinalColl(0), - m_writer(0), - m_runHdr(0), - m_fileExistsAction( LcioManager::eFail ), - m_runNumber(0), - m_enableDumpEvent(false), - m_writerIsOpen(false), - m_usingAutoname(false) { - // Initialize the Geant4 UI messenger for the LCIO. - m_messenger = new LcioMessenger(this); - - // Initialize the LCIO-based event generator. - m_eventGenerator = new LcioPrimaryGenerator(this); - - // Initialize the LCIO MCParticle manager. - m_mcpManager = LcioMcpManager::instance(); - - // Initialize the LCIO HitsCollectionBuilder. - m_HCBuilder = new LcioHitsCollectionBuilder(); - - // Create the LCIO writer. - createWriter(); - - // Create the LCIO file namer. - m_namer = new LcioFileNamer(); - - // Set the default output file name. - m_filename = m_defaultFileName; - } - - LcioManager::~LcioManager() { - deleteWriter(); - - if (m_messenger != 0) { - delete m_messenger; - } - - } - - void LcioManager::openLcioFile() { - - // Get full output path with extension to check its existence. - string fullFilename = getFullOutputPath(true); - - // Default to writing a new file. - int writeMode = LCIO::WRITE_NEW; - - // File exists? - if (FileUtil::fileExists(fullFilename)) { - - // Failure mode is on, so kill the current run. - if (m_fileExistsAction == eFail) { - log().fatal("LCIO file <" + fullFilename + "> already exists and will not be deleted."); - //G4Exception("LcioManager::openLcioFile()", "", RunMustBeAborted, "LCIO output file already exists."); - RunManager::instance()->abortRun(); - //m_abortCurrentRun = true; - } - // Deletion mode is on, so try to remove the current file. - else if (m_fileExistsAction == eDelete) { - if (FileUtil::removeFile( fullFilename) != 0) { - // Fatal error. File could not be removed. - log().fatal("Unable to delete old LCIO file <" + fullFilename + ">"); - //G4Exception("", "", FatalException, "Unable to delete old LCIO file."); - RunManager::instance()->abortRun(); - } - else { - log().okay("Deleted old LCIO file <" + fullFilename + ">"); - } - } - // Append mode is on. - else if ( m_fileExistsAction == eAppend ) { - log().okay("Appending to existing LCIO file <" + fullFilename + ">"); - writeMode = LCIO::WRITE_APPEND; - } - } - // Create a new file if doesn't exist. - else { - log().okay("Creating new Lcio file <" + fullFilename + ">"); - } - - // Open the file using the writer with the full path. - if(m_writer) { - if (!RunManager::instance()->isRunAborted()) { - m_writer->open(getFullOutputPath(false), writeMode); - m_writerIsOpen = true; - } - } - else { - G4Exception("", "", FatalException, "LCWriter is null."); - } - } - - LcioManager::EFileExistsAction LcioManager::getFileExistsActionFromString( const string& feaStr) { - string s = StringUtil::toLower( feaStr ); - EFileExistsAction fea = eInvalid; - if ( s == "fail" ) { - fea = eFail; - } - else if ( s == "overwrite" || s == "delete" ) { - fea = eDelete; - } - else if ( s == "append" ) { - fea = eAppend; - } - - return fea; - } - - void LcioManager::setRunNumber(RunNumberType rnt) { - m_runNumber = rnt; - - log().verbose("Set starting run number <" + StringUtil::toString( (int)m_runNumber ) + ">"); - } - - void LcioManager::createWriter() { - m_writer = IOIMPL::LCFactory::getInstance()->createLCWriter(); - } - - void LcioManager::deleteWriter() { - if ( m_writer != 0 ) { - if ( m_writerIsOpen ) { - try { - m_writer->close(); - m_writerIsOpen = false; - } - catch (...) {} - } - delete m_writer; - m_writer = 0; - } - } - - string LcioManager::getFullOutputPath(bool withExtension) { - string fullPath; - - if (m_path.length() > 0) { - // Append the output directory if one exists. - fullPath = m_path; - } - else - { - // Default to the current directory if none specified. - fullPath = "."; - } - - // Append file name. - fullPath += "/" + m_filename; - - // Append extension. - if (withExtension) { - fullPath += ".slcio"; - } - - return fullPath; - } - - void LcioManager::beginRun(const G4Run* aRun) { - // Reset the abort run flag. - //m_abortCurrentRun = false; - - // Automatically create LCIO output file name if option was selected. - if (m_usingAutoname) { - makeAutoname(); - } - - // Set the G4Run counter. - G4RunManager::GetRunManager()->SetRunIDCounter(m_runNumber); - - // Open the LCIO output file for writing. - openLcioFile(); - - //std::cout << "abortCurrentRun = " << m_abortCurrentRun << std::endl; - - // Run aborted, because LCIO output file already exists. - if (!RunManager::instance()->isRunAborted()) { - - // create new LCRunHeader - createRunHeader(aRun); - - // write the run header - m_writer->writeRunHeader(m_runHdr); - - // Incr run number. - ++m_runNumber; - } - } - - void LcioManager::endRun(const G4Run*) { - - // Delete the LCIO run header object. - deleteRunHeader(); - - // Set append mode for subsequent writes if interactive mode and the run was not aborted. - if (!RunManager::instance()->isRunAborted()) { - // If run was aborted, writer was never opened. - if (m_writer != 0) { - m_writer->close(); - m_writerIsOpen = false; - } - // Close the writer to flush it (could be reopened). - if (SlicApplication::instance()->getMode() == SlicApplication::eInteractive) { - m_fileExistsAction = eAppend; - } - } - } - - void LcioManager::createRunHeader(const G4Run*) { - // create new run header - m_runHdr = new LCRunHeaderImpl(); - - // Write SLIC version into run header. - m_runHdr->parameters().setValue("SLIC_VERSION", PackageInfo::getVersionString()); - - // Write Geant4 version into run header. - m_runHdr->parameters().setValue("GEANT4_VERSION", SlicApplication::instance()->getGeant4VersionString().replace(0,7,"")); - - // set run number - m_runHdr->setRunNumber(m_runNumber); - - // set detector name in LCIO header - setDetectorName(); - - // add active subdet to header - addActiveSubdetectors(); - } - - void LcioManager::setDetectorName() { - string det_tag = LCDDProcessor::instance()->getDetectorName(); - m_runHdr->setDetectorName( det_tag ); - log().okay("Detector name set to <" + det_tag + "> in run header."); - } - - void LcioManager::deleteRunHeader() { - if ( m_runHdr ) { - delete m_runHdr; - m_runHdr = 0; - } - } - - void LcioManager::addActiveSubdetectors() { - LCDDProcessor::SensitiveDetectors::const_iterator iter; - LCDDProcessor* lcddProc = LCDDProcessor::instance(); - - for ( iter = lcddProc->getSensitiveDetectorsBegin(); - iter != lcddProc->getSensitiveDetectorsEnd(); - iter++ ) { - m_runHdr->addActiveSubdetector( (iter->second)->GetName() ); - } - } - - void LcioManager::setPath(const string& path) { - log().okay("Set output directory to <" + path + ">."); - - m_path = path; - } - - void LcioManager::setFilename(const string& filename) { - m_filename = filename; - - /* If the given filename has an extension, then remove it. - The LCIO library will add it automatically. */ - size_t hasExt = filename.find(".slcio"); - if (hasExt != string::npos) - { - m_filename.replace( filename.size() - 6, 6, "" ); - } - - log().okay("Set output file name to <" + m_filename + ">."); - } - - void LcioManager::setAutonameFields(const std::vector<std::string>& fields) { - m_usingAutoname = true; - m_currentAutonameFields.clear(); - for(std::vector<std::string>::const_iterator it = fields.begin(); - it != fields.end(); - it++) { - m_currentAutonameFields.push_back(*it); - } - } - - void LcioManager::makeAutoname() { - std::string autoname = m_namer->makeFileName( m_currentAutonameFields ); - if ( autoname.size() == 0 || autoname == "" ) { - log().warning("Autonaming returned an empty string. Using default file name <" + m_defaultFileName + ">"); - setFilename( m_defaultFileName ); - } - else { - setFilename( autoname ); - log().okay("Autoname set file name to <" + autoname + ">."); - } - } - - const string& LcioManager::getPath() const { - return m_path; - } - - const string& LcioManager::getFilename() const { - return m_filename; - } - - LCEventImpl* LcioManager::createLCEvent(const G4Event* anEvent) { - assert( anEvent ); - - LCEventImpl* lcevt = new LCEventImpl(); - lcevt->setEventNumber(anEvent->GetEventID() ); - lcevt->setRunNumber(m_runHdr->getRunNumber() ); - lcevt->setDetectorName(m_runHdr->getDetectorName() ); - - // Set the event weight and idrup from the StdHep file. - EventSourceManager* genMgr = EventSourceManager::instance(); - if (genMgr->getCurrentSourceType() == EventSourceManager::eStdHep) - { - lStdHep* stdhep = ((StdHepEventSource*)(genMgr->getCurrentSource()))->getStdHepReader(); - if (stdhep->isStdHepEv4()) - { - lcevt->parameters().setValue("_weight",(float)stdhep->eventweight()); - lcevt->parameters().setValue("idrup",(int)stdhep->idrup()); - } - } - else - { - lcevt->parameters().setValue("_weight",(float)1.0); - lcevt->parameters().setValue("idrup",(float)0.0); - } - - // Write Geant4 version into event header. - lcevt->parameters().setValue("GEANT4_VERSION", SlicApplication::instance()->getGeant4VersionString().replace(0,7,"")); - - // Write SLIC version into event header. - lcevt->parameters().setValue("SLIC_VERSION", PackageInfo::getVersionString()); - - setCurrentLCEvent( lcevt ); - return lcevt; - } - - LCEventImpl* LcioManager::createLCEvent() { - return createLCEvent( G4EventManager::GetEventManager() - ->GetNonconstCurrentEvent() ); - } - - void LcioManager::endEvent(const G4Event*) { - if (!RunManager::instance()->isRunAborted()) { - - // create LCEvent - createLCEvent(); - - // create Mcp coll in LcioMcpManager - m_mcpManager->endEvent( G4EventManager::GetEventManager()->GetNonconstCurrentEvent() ); - - // create mcp collection from input event - createFinalMcpCollection(); - - // If selected, add the initial MCParticle collection to the event. - if ( LcioMcpManager::instance()->writeInitialMCParticleCollection() ) { - addInitialMCParticleCollection(); - } - - // create HC in current LCEvent from current G4Event using builder - createHitsCollections(); - - // Dump event stats. - if ( m_enableDumpEvent ) { - LCTOOLS::dumpEventDetailed( m_currentLCEvent ); - //LCTOOLS::printMCParticles( LcioMcpManager::instance()->getFinalMcpCollection() ); - } - - // set timestamp - setEventTimeStamp(); - - // write event - m_writer->writeEvent( m_currentLCEvent ); - - // flush writer - m_writer->flush(); - - // delete event's transient objects, including current LCEvent - reset(); - } - } - - void LcioManager::setEventTimeStamp() { - getCurrentLCEvent()->setTimeStamp( TimeUtil::getTimeNS() ); - } - - void LcioManager::createHitsCollections() { - m_HCBuilder->createHCsFromG4Event( G4EventManager::GetEventManager()->GetNonconstCurrentEvent(), m_currentLCEvent ); - } - - void LcioManager::reset() { - // delete transient event container - delete m_currentLCEvent; - m_currentLCEvent = 0; - - // reset mcp mgr, including clearing maps - m_mcpManager->reset(); - } - - void LcioManager::createFinalMcpCollection() { - // add Mcp coll to current event - getCurrentLCEvent()->addCollection( m_mcpManager->getFinalMcpCollection(), LCIO::MCPARTICLE ); - } - - void LcioManager::addCollection( EVENT::LCEvent* event, EVENT::LCCollection* collection, const std::string& collectionName) { - event->addCollection( collection, collectionName ); - } - - void LcioManager::addCollection( EVENT::LCCollection* collection, const std::string& collectionName ) { - getCurrentLCEvent()->addCollection( collection, collectionName ); - } - - void LcioManager::addInitialMCParticleCollection() { - const std::string& name = std::string(LCIO::MCPARTICLE) + std::string("Initial"); - addCollection( LcioMcpManager::instance()->getInitialMcpCollection(), name ); - }
+LcioManager::LcioManager() : + Module("LcioManager"), m_McpFinalColl(0), m_writer(0), m_runHdr(0), m_fileExistsAction( + LcioManager::eFail), m_runNumber(0), m_enableDumpEvent(false), m_writerIsOpen(false), m_usingAutoname( + false) { + // Initialize the Geant4 UI messenger for the LCIO. + m_messenger = new LcioMessenger(this); + + // Initialize the LCIO-based event generator. + m_eventGenerator = new LcioPrimaryGenerator(this); + + // Initialize the LCIO MCParticle manager. + m_mcpManager = LcioMcpManager::instance(); + + // Initialize the LCIO HitsCollectionBuilder. + m_HCBuilder = new LcioHitsCollectionBuilder(); + + // Create the LCIO writer. + createWriter(); + + // Create the LCIO file namer. + m_namer = new LcioFileNamer(); + + // Set the default output file name. + m_filename = m_defaultFileName; +} + +LcioManager::~LcioManager() { + deleteWriter(); + + if (m_messenger != 0) { + delete m_messenger; + } + +} + +void LcioManager::openLcioFile() { + + // Get full output path with extension to check its existence. + string fullFilename = getFullOutputPath(true); + + // Default to writing a new file. + int writeMode = LCIO::WRITE_NEW; + + // File exists? + if (FileUtil::fileExists(fullFilename)) { + + // Failure mode is on, so kill the current run. + if (m_fileExistsAction == eFail) { + log() << LOG::fatal << LOG::head << "LCIO file already exists: " << fullFilename << LOG::done; + SlicApplication::instance()->setReturnCode(SlicApplication::OUTPUT_FILE_EXISTS); + RunManager::instance()->abortRun(); + } + // Deletion mode is on, so try to remove the current file. + else if (m_fileExistsAction == eDelete) { + if (FileUtil::removeFile(fullFilename) != 0) { + // Fatal error. File could not be removed. + log() << LOG::fatal << LOG::head << "Unable to delete old LCIO file: " << fullFilename + << LOG::done; + SlicApplication::instance()->setReturnCode(SlicApplication::FAILED_DELETE); + RunManager::instance()->abortRun(); + } else { + log().okay("Deleted old LCIO file: " + fullFilename); + } + } + // Append mode is on. + else if (m_fileExistsAction == eAppend) { + log().okay("Appending to existing LCIO file: " + fullFilename); + writeMode = LCIO::WRITE_APPEND; + } + } + // Create a new file if doesn't exist. + else { + log().okay("Creating new LCIO file: " + fullFilename); + } + + // Open the file using the writer with the full path. + if (m_writer) { + if (!RunManager::instance()->isRunAborted()) { + m_writer->open(getFullOutputPath(false), writeMode); + m_writerIsOpen = true; + } + } else { + //G4Exception("", "", FatalException, "LCWriter is null."); + log() << LOG::fatal << LOG::head << "LCWriter is null." << LOG::done; + RunManager::instance()->abortRun(); + } +} + +LcioManager::EFileExistsAction LcioManager::getFileExistsActionFromString(const string& feaStr) { + string s = StringUtil::toLower(feaStr); + EFileExistsAction fea = eInvalid; + if (s == "fail") { + fea = eFail; + } else if (s == "overwrite" || s == "delete") { + fea = eDelete; + } else if (s == "append") { + fea = eAppend; + } + + return fea; +} + +void LcioManager::setRunNumber(RunNumberType rnt) { + m_runNumber = rnt; + + log().verbose("Set starting run number <" + StringUtil::toString((int) m_runNumber) + ">"); +} + +void LcioManager::createWriter() { + m_writer = IOIMPL::LCFactory::getInstance()->createLCWriter(); +} + +void LcioManager::deleteWriter() { + if (m_writer != 0) { + if (m_writerIsOpen) { + try { + m_writer->close(); + m_writerIsOpen = false; + } catch (...) { + } + } + delete m_writer; + m_writer = 0; + } +} + +string LcioManager::getFullOutputPath(bool withExtension) { + string fullPath; + + if (m_path.length() > 0) { + // Append the output directory if one exists. + fullPath = m_path; + } else { + // Default to the current directory if none specified. + fullPath = "."; + } + + // Append file name. + fullPath += "/" + m_filename; + + // Append extension. + if (withExtension) { + fullPath += ".slcio"; + } + + return fullPath; +} + +void LcioManager::beginRun(const G4Run* aRun) { + // Reset the abort run flag. + //m_abortCurrentRun = false; + + // Automatically create LCIO output file name if option was selected. + if (m_usingAutoname) { + makeAutoname(); + } + + // Set the G4Run counter. + G4RunManager::GetRunManager()->SetRunIDCounter(m_runNumber); + + // Open the LCIO output file for writing. + openLcioFile(); + + //std::cout << "abortCurrentRun = " << m_abortCurrentRun << std::endl; + + // Run aborted, because LCIO output file already exists. + if (!RunManager::instance()->isRunAborted()) { + + // create new LCRunHeader + createRunHeader(aRun); + + // write the run header + m_writer->writeRunHeader(m_runHdr); + + // Incr run number. + ++m_runNumber; + } +} + +void LcioManager::endRun(const G4Run*) { + + // Delete the LCIO run header object. + deleteRunHeader(); + + // Set append mode for subsequent writes if interactive mode and the run was not aborted. + if (!RunManager::instance()->isRunAborted()) { + // If run was aborted, writer was never opened. + if (m_writer != 0) { + m_writer->close(); + m_writerIsOpen = false; + } + // Close the writer to flush it (could be reopened). + if (SlicApplication::instance()->getMode() == SlicApplication::eInteractive) { + m_fileExistsAction = eAppend; + } + } +} + +void LcioManager::createRunHeader(const G4Run*) { + // create new run header + m_runHdr = new LCRunHeaderImpl(); + + // Write SLIC version into run header. + m_runHdr->parameters().setValue("SLIC_VERSION", PackageInfo::getVersionString()); + + // Write Geant4 version into run header. + m_runHdr->parameters().setValue("GEANT4_VERSION", + SlicApplication::instance()->getGeant4VersionString().replace(0, 7, "")); + + // set run number + m_runHdr->setRunNumber(m_runNumber); + + // set detector name in LCIO header + setDetectorName(); + + // add active subdet to header + addActiveSubdetectors(); +} + +void LcioManager::setDetectorName() { + string det_tag = LCDDProcessor::instance()->getDetectorName(); + m_runHdr->setDetectorName(det_tag); + log().okay("Detector name set to <" + det_tag + "> in run header."); +} + +void LcioManager::deleteRunHeader() { + if (m_runHdr) { + delete m_runHdr; + m_runHdr = 0; + } +} + +void LcioManager::addActiveSubdetectors() { + LCDDProcessor::SensitiveDetectors::const_iterator iter; + LCDDProcessor* lcddProc = LCDDProcessor::instance(); + + for (iter = lcddProc->getSensitiveDetectorsBegin(); iter != lcddProc->getSensitiveDetectorsEnd(); + iter++) { + m_runHdr->addActiveSubdetector((iter->second)->GetName()); + } +} + +void LcioManager::setPath(const string& path) { + log().okay("Set output directory to <" + path + ">."); + + m_path = path; +} + +void LcioManager::setFilename(const string& filename) { + m_filename = filename; + + /* If the given filename has an extension, then remove it. + The LCIO library will add it automatically. */ + size_t hasExt = filename.find(".slcio"); + if (hasExt != string::npos) { + m_filename.replace(filename.size() - 6, 6, ""); + } + + log().okay("Set output file name to <" + m_filename + ">."); +} + +void LcioManager::setAutonameFields(const std::vector<std::string>& fields) { + m_usingAutoname = true; + m_currentAutonameFields.clear(); + for (std::vector<std::string>::const_iterator it = fields.begin(); it != fields.end(); it++) { + m_currentAutonameFields.push_back(*it); + } +} + +void LcioManager::makeAutoname() { + std::string autoname = m_namer->makeFileName(m_currentAutonameFields); + if (autoname.size() == 0 || autoname == "") { + log().warning( + "Autonaming returned an empty string. Using default file name <" + m_defaultFileName + ">"); + setFilename(m_defaultFileName); + } else { + setFilename(autoname); + log().okay("Autoname set file name to <" + autoname + ">."); + } +} + +const string& LcioManager::getPath() const { + return m_path; +} + +const string& LcioManager::getFilename() const { + return m_filename; +} + +LCEventImpl* LcioManager::createLCEvent(const G4Event* anEvent) { + assert( anEvent); + + LCEventImpl* lcevt = new LCEventImpl(); + lcevt->setEventNumber(anEvent->GetEventID()); + lcevt->setRunNumber(m_runHdr->getRunNumber()); + lcevt->setDetectorName(m_runHdr->getDetectorName()); + + // Set the event weight and idrup from the StdHep file. + EventSourceManager* genMgr = EventSourceManager::instance(); + if (genMgr->getCurrentSourceType() == EventSourceManager::eStdHep) { + lStdHep* stdhep = ((StdHepEventSource*) (genMgr->getCurrentSource()))->getStdHepReader(); + if (stdhep->isStdHepEv4()) { + lcevt->parameters().setValue("_weight", (float) stdhep->eventweight()); + lcevt->parameters().setValue("idrup", (int) stdhep->idrup()); + } + } else { + lcevt->parameters().setValue("_weight", (float) 1.0); + lcevt->parameters().setValue("idrup", (float) 0.0); + } + + // Write Geant4 version into event header. + lcevt->parameters().setValue("GEANT4_VERSION", + SlicApplication::instance()->getGeant4VersionString().replace(0, 7, "")); + + // Write SLIC version into event header. + lcevt->parameters().setValue("SLIC_VERSION", PackageInfo::getVersionString()); + + setCurrentLCEvent(lcevt); + return lcevt; +} + +LCEventImpl* LcioManager::createLCEvent() { + return createLCEvent(G4EventManager::GetEventManager()->GetNonconstCurrentEvent()); +} + +void LcioManager::endEvent(const G4Event*) { + if (!RunManager::instance()->isRunAborted()) { + + // create LCEvent + createLCEvent(); + + // create Mcp coll in LcioMcpManager + m_mcpManager->endEvent(G4EventManager::GetEventManager()->GetNonconstCurrentEvent()); + + // create mcp collection from input event + createFinalMcpCollection(); + + // If selected, add the initial MCParticle collection to the event. + if (LcioMcpManager::instance()->writeInitialMCParticleCollection()) { + addInitialMCParticleCollection(); + } + + // create HC in current LCEvent from current G4Event using builder + createHitsCollections(); + + // Dump event stats. + if (m_enableDumpEvent) { + LCTOOLS::dumpEventDetailed(m_currentLCEvent); + //LCTOOLS::printMCParticles( LcioMcpManager::instance()->getFinalMcpCollection() ); + } + + // set timestamp + setEventTimeStamp(); + + // write event + m_writer->writeEvent(m_currentLCEvent); + + // flush writer + m_writer->flush(); + + // delete event's transient objects, including current LCEvent + reset(); + } +} + +void LcioManager::setEventTimeStamp() { + getCurrentLCEvent()->setTimeStamp(TimeUtil::getTimeNS()); +} + +void LcioManager::createHitsCollections() { + m_HCBuilder->createHCsFromG4Event(G4EventManager::GetEventManager()->GetNonconstCurrentEvent(), + m_currentLCEvent); +} + +void LcioManager::reset() { + // delete transient event container + delete m_currentLCEvent; + m_currentLCEvent = 0; + + // reset mcp mgr, including clearing maps + m_mcpManager->reset(); +} + +void LcioManager::createFinalMcpCollection() { + // add Mcp coll to current event + getCurrentLCEvent()->addCollection(m_mcpManager->getFinalMcpCollection(), LCIO::MCPARTICLE); +} + +void LcioManager::addCollection(EVENT::LCEvent* event, EVENT::LCCollection* collection, + const std::string& collectionName) { + event->addCollection(collection, collectionName); +} + +void LcioManager::addCollection(EVENT::LCCollection* collection, const std::string& collectionName) { + getCurrentLCEvent()->addCollection(collection, collectionName); +} + +void LcioManager::addInitialMCParticleCollection() { + const std::string& name = std::string(LCIO::MCPARTICLE) + std::string("Initial"); + addCollection(LcioMcpManager::instance()->getInitialMcpCollection(), name); +}
}
diff -u -r1.22 -r1.23 --- LcioMcpFactory.cc 31 Jan 2012 18:52:30 -0000 1.22 +++ LcioMcpFactory.cc 27 Nov 2012 19:32:19 -0000 1.23 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpFactory.cc,v 1.22 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpFactory.cc,v 1.23 2012/11/27 19:32:19 jeremy Exp $
#include "LcioMcpFactory.hh" // slic
@@ -26,455 +26,413 @@
using EVENT::LCIO; using EVENT::MCParticle;
-namespace slic -{ - LcioMcpFactory::LcioMcpFactory(LcioMcpManager* manager) - : Module("LcioMcpFactory"), - m_manager(manager), - m_finalColl(0), - m_currentTrajectoryContainer(0) - {} - - LcioMcpFactory::~LcioMcpFactory() - {} - - void LcioMcpFactory::createFinalMcpCollection(const G4Event* event) - { - // new coll for final Mcps - m_finalColl = static_cast<LCCollectionVec*>(m_manager->getFinalMcpCollection()); - - // Set current G4TrajectoryContainer - m_currentTrajectoryContainer = event->GetTrajectoryContainer(); - - // Check if using StdHep or LCIO e.g. a file-based source? - if (EventSourceManager::instance()->isFileSource()) { - // Create from the initial coll of Mcp. - createFinalMcpCollectionFromInitial(m_manager->getInitialMcpCollection()); - } - // G4 source using trajectories only. - else - { - // Create from trajectory container of current G4Event. - createFinalMcpCollectionFromTrajectoryContainer(m_currentTrajectoryContainer); - } - - // Fill supplementary collection with MCParticle endpoint energies. - fillMcpEndPointEnergy(m_finalColl); - } - - IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromTrajectory(Trajectory* trj) - { -#ifdef SLIC_LOG - log() << LOG::debug << "createMcpFromTrajectory() - trackId: " << trj->GetTrackID() << LOG::done; - log() << LOG::debug << "trj PDG: " << trj->GetParticleDefinition()->GetPDGEncoding() << LOG::done; -#endif - - // new Mcp - MCParticleImpl* mcp = new MCParticleImpl(); - - // PDG - mcp->setPDG(trj->GetPDGEncoding()); - - // mom - G4ThreeVector mom = trj->GetInitialMomentum()/GeV; - float fmom[3] = {mom.x(), mom.y(), mom.z()}; - mcp->setMomentum(fmom); - - // Get particle def. - const G4ParticleDefinition* pdef = trj->GetParticleDefinition(); - - // To store mass for new particle. - G4double m = 0; - - /* - * For particles from extended particle table supplied by slic, use the StdHep mass instead. - * Also, use the StdHep mass for PDG codes Geant4 doesn't know that aren't in particle.tbl. - */ - if (pdef == 0 || (pdef->GetParticleType().compare("extended") == 0 || pdef->GetParticleType().compare("susy") == 0)) - { - // Get the primary particle from the LCIO data map. - MCParticle* primaryMcp = LcioMcpManager::instance()->getMaps()->findPrimaryInitialMcpFromTrajectory(trj); - - // Require that this particle have a matching primary MCParticle to get mass. - if (primaryMcp != 0) - { - m = primaryMcp->getMass(); -#ifdef SLIC_LOG - log() << "mass from primary: " << m << LOG::endl; -#endif - } - // Need a primary particle to get mass. - else - { - G4Exception("", "", FatalException, "Could not find required LCIO primary particle."); - } - } - // Use Geant4's mass from the particle definition, which is appropriate for SM particles. - else - { - m = trj->GetParticleDefinition()->GetPDGMass()/GeV; -#ifdef SLIC_LOG - log() << "mass from pdef: " << m << LOG::endl; -#endif - } - - // mass - mcp->setMass(m); - - // charge - mcp->setCharge(trj->GetCharge()); - - // begin and end points - G4int npts = trj->GetPointEntries(); - - // begin pnt - G4VTrajectoryPoint* beginTrjPnt = trj->GetPoint(0); - G4ThreeVector beginPos = beginTrjPnt->GetPosition()/mm; - double fBeginPos[3] = {beginPos.x(), beginPos.y(), beginPos.z()}; - mcp->setVertex(fBeginPos); - - // end pnt - G4VTrajectoryPoint* endTrjPnt = trj->GetPoint(npts - 1); - G4ThreeVector endPos = endTrjPnt->GetPosition()/mm; - double fEndPos[3] = {endPos.x(), endPos.y(), endPos.z()}; - mcp->setEndpoint(fEndPos); - - // time - mcp->setTime(trj->GetGlobalTime()); - - // set status codes from trajectory info (with no dep on any associated Mcps) - LcioMcpStatusSetter::setMcpStatusCodesFromTrajectory(trj, mcp); - - // add to map of trkID -> mcp -#ifdef SLIC_LOG - log() << LOG::debug << "adding trackId <" << trj->GetTrackID() << "> to MCP <" << mcp << "> link." << LOG::done; -#endif - m_manager->getMaps()->addTrackIDToMcpLink(trj->GetTrackID(), mcp); - - return mcp; - } - - // FIXME: This method doesn't seem to work correctly! - void LcioMcpFactory::createFinalMcpCollectionFromTrajectoryContainer(G4TrajectoryContainer* m_currentTrajectoryContainer) - { - if ( m_currentTrajectoryContainer ) - { - // loop over trj cont - int n_trj = m_currentTrajectoryContainer->entries(); - for ( int i = 0; - i < n_trj; - i++ ) - { - Trajectory* trj = static_cast<Trajectory*>((*m_currentTrajectoryContainer)[i]); - - // Only add primary trajectories; daughters are picked up within. - if (trj->GetParentID() == 0) - { -#ifdef SLIC_LOG - log() << LOG::debug << "Making primary MCParticle for trajectory with trackID <" << trj->GetTrackID() << ">." << LOG::done; -#endif - - // Create MCParticle output from trajectory. - MCParticleImpl* mcp = createMcpFromTrajectory(trj); - - // Add to the final MCParticle collection. - m_finalColl->addElement(mcp); - - // Process the daughters. -#ifdef SLIC_LOG - log() << LOG::debug << "Making primary MCParticle for trajectory with trackID <" << trj->GetTrackID() << ">." << LOG::done; -#endif - addMcpDaughtersFromTrajectoryContainer(mcp, trj->GetTrackID()); - } - } - } - else - { - G4Exception("", "", FatalException, "G4TrajectoryContainer is null!"); - } - - // DEBUG - LcioMcpManager::instance()->getMaps()->printTrackToMcpMap(); - - } - - void LcioMcpFactory::addMcpDaughtersFromTrajectoryContainer(MCParticleImpl* parMcp, - int parTrkID) - { -#ifdef SLIC_LOG - log() << LOG::debug << "addMcpDaughtersFromTraj - parTrkId <" << parTrkID << ">." << LOG::done; -#endif - - // loop over trj cont - int n_trj = m_currentTrajectoryContainer->entries(); - for ( int i = 0; - i < n_trj; - i++ ) - { - Trajectory* trj = static_cast<Trajectory*>((*m_currentTrajectoryContainer)[i]); - - if ( trj->GetParentID() == parTrkID ) - { - - // lkp dau Mcp by track ID - MCParticleImpl* dauMcp = m_manager->getMaps()->findMcpFromTrackID(trj->GetTrackID()); - - if (dauMcp == 0) - { - dauMcp = createMcpFromTrajectory(trj); - } - - if (dauMcp == 0) - G4Exception("", "", FatalException, "Failed to create MCParticle."); - - // add this to final coll - m_finalColl->addElement( dauMcp ); - - // Recursively add daughters of this daughter. - addMcpDaughtersFromTrajectoryContainer( dauMcp, trj->GetTrackID() ); - - // Set the parent particle in the daughter. - dauMcp->addParent( parMcp ); - } - } - } - - - void LcioMcpFactory::createFinalMcpCollectionFromInitial(EVENT::LCCollection* mcpVecInitial) - { - // coll must exist - if (mcpVecInitial) - { - // get num Mcp in coll - int numInitMcp = mcpVecInitial->getNumberOfElements(); - - // coll must have members - if (numInitMcp > 0) - { - // loop over input Mcp coll - for (int i=0; i < numInitMcp; i++) - {
+namespace slic { +LcioMcpFactory::LcioMcpFactory(LcioMcpManager* manager) : + Module("LcioMcpFactory"), m_manager(manager), m_finalColl(0), m_currentTrajectoryContainer(0) { +} + +LcioMcpFactory::~LcioMcpFactory() { +} + +void LcioMcpFactory::createFinalMcpCollection(const G4Event* event) { + // new coll for final Mcps + m_finalColl = static_cast<LCCollectionVec*>(m_manager->getFinalMcpCollection()); + + // Set current G4TrajectoryContainer + m_currentTrajectoryContainer = event->GetTrajectoryContainer(); + + // Check if using StdHep or LCIO e.g. a file-based source? + if (EventSourceManager::instance()->isFileSource()) { + // Create from the initial coll of Mcp. + createFinalMcpCollectionFromInitial(m_manager->getInitialMcpCollection()); + } + // G4 source using trajectories only. + else { + // Create from trajectory container of current G4Event. + createFinalMcpCollectionFromTrajectoryContainer(m_currentTrajectoryContainer); + } + + // Fill supplementary collection with MCParticle endpoint energies. + fillMcpEndPointEnergy(m_finalColl); +} + +IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromTrajectory(Trajectory* trj) { +#ifdef SLIC_LOG + log() << LOG::debug << "createMcpFromTrajectory() - trackId: " << trj->GetTrackID() << LOG::done; + log() << LOG::debug << "trj PDG: " << trj->GetParticleDefinition()->GetPDGEncoding() << LOG::done; +#endif + + // new Mcp + MCParticleImpl* mcp = new MCParticleImpl(); + + // PDG + mcp->setPDG(trj->GetPDGEncoding()); + + // mom + G4ThreeVector mom = trj->GetInitialMomentum() / GeV; + float fmom[3] = { mom.x(), mom.y(), mom.z() }; + mcp->setMomentum(fmom); + + // Get particle def. + const G4ParticleDefinition* pdef = trj->GetParticleDefinition(); + + // To store mass for new particle. + G4double m = 0; + + /* + * For particles from extended particle table supplied by slic, use the StdHep mass instead. + * Also, use the StdHep mass for PDG codes Geant4 doesn't know that aren't in particle.tbl. + */ + if (pdef == 0 + || (pdef->GetParticleType().compare("extended") == 0 + || pdef->GetParticleType().compare("susy") == 0)) { + // Get the primary particle from the LCIO data map. + MCParticle* primaryMcp = LcioMcpManager::instance()->getMaps()->findPrimaryInitialMcpFromTrajectory( + trj); + + // Require that this particle have a matching primary MCParticle to get mass. + if (primaryMcp != 0) { + m = primaryMcp->getMass(); +#ifdef SLIC_LOG + log() << "mass from primary: " << m << LOG::endl; +#endif + } + // Need a primary particle to get mass. + else { + G4Exception("", "", FatalException, "Could not find required LCIO primary particle."); + } + } + // Use Geant4's mass from the particle definition, which is appropriate for SM particles. + else { + m = trj->GetParticleDefinition()->GetPDGMass() / GeV; +#ifdef SLIC_LOG + log() << "mass from pdef: " << m << LOG::endl; +#endif + } + + // mass + mcp->setMass(m); + + // charge + mcp->setCharge(trj->GetCharge()); + + // begin and end points + G4int npts = trj->GetPointEntries(); + + // begin pnt + G4VTrajectoryPoint* beginTrjPnt = trj->GetPoint(0); + G4ThreeVector beginPos = beginTrjPnt->GetPosition() / mm; + double fBeginPos[3] = { beginPos.x(), beginPos.y(), beginPos.z() }; + mcp->setVertex(fBeginPos); + + // end pnt + G4VTrajectoryPoint* endTrjPnt = trj->GetPoint(npts - 1); + G4ThreeVector endPos = endTrjPnt->GetPosition() / mm; + double fEndPos[3] = { endPos.x(), endPos.y(), endPos.z() }; + mcp->setEndpoint(fEndPos); + + // time + mcp->setTime(trj->GetGlobalTime()); + + // set status codes from trajectory info (with no dep on any associated Mcps) + LcioMcpStatusSetter::setMcpStatusCodesFromTrajectory(trj, mcp); + + // add to map of trkID -> mcp +#ifdef SLIC_LOG + log() << LOG::debug << "adding trackId <" << trj->GetTrackID() << "> to MCP <" << mcp << "> link." << LOG::done; +#endif + m_manager->getMaps()->addTrackIDToMcpLink(trj->GetTrackID(), mcp); + + return mcp; +} + +// FIXME: This method doesn't seem to work correctly! +void LcioMcpFactory::createFinalMcpCollectionFromTrajectoryContainer( + G4TrajectoryContainer* m_currentTrajectoryContainer) { + if (m_currentTrajectoryContainer) { + // loop over trj cont + int n_trj = m_currentTrajectoryContainer->entries(); + for (int i = 0; i < n_trj; i++) { + Trajectory* trj = static_cast<Trajectory*>((*m_currentTrajectoryContainer)[i]); + + // Only add primary trajectories; daughters are picked up within. + if (trj->GetParentID() == 0) { +#ifdef SLIC_LOG + log() << LOG::debug << "Making primary MCParticle for trajectory with trackID <" << trj->GetTrackID() << ">." << LOG::done; +#endif + + // Create MCParticle output from trajectory. + MCParticleImpl* mcp = createMcpFromTrajectory(trj); + + // Add to the final MCParticle collection. + m_finalColl->addElement(mcp); + + // Process the daughters. +#ifdef SLIC_LOG + log() << LOG::debug << "Making primary MCParticle for trajectory with trackID <" << trj->GetTrackID() << ">." << LOG::done; +#endif + addMcpDaughtersFromTrajectoryContainer(mcp, trj->GetTrackID()); + } + } + } else { + G4Exception("", "", FatalException, "G4TrajectoryContainer is null!"); + }
+ // DEBUG + LcioMcpManager::instance()->getMaps()->printTrackToMcpMap(); + +} + +void LcioMcpFactory::addMcpDaughtersFromTrajectoryContainer(MCParticleImpl* parMcp, int parTrkID) {
#ifdef SLIC_LOG
- log() << LOG::debug << "proc initial MCP: " << i << LOG::done;
+ log() << LOG::debug << "addMcpDaughtersFromTraj - parTrkId <" << parTrkID << ">." << LOG::done; +#endif + + // loop over trj cont + int n_trj = m_currentTrajectoryContainer->entries(); + for (int i = 0; i < n_trj; i++) { + Trajectory* trj = static_cast<Trajectory*>((*m_currentTrajectoryContainer)[i]); + + if (trj->GetParentID() == parTrkID) { + + // lkp dau Mcp by track ID + MCParticleImpl* dauMcp = m_manager->getMaps()->findMcpFromTrackID(trj->GetTrackID()); + + if (dauMcp == 0) { + dauMcp = createMcpFromTrajectory(trj); + } + + if (dauMcp == 0) + G4Exception("", "", FatalException, "Failed to create MCParticle."); + + // add this to final coll + m_finalColl->addElement(dauMcp); + + // Recursively add daughters of this daughter. + addMcpDaughtersFromTrajectoryContainer(dauMcp, trj->GetTrackID()); + + // Set the parent particle in the daughter. + dauMcp->addParent(parMcp); + } + } +} + +void LcioMcpFactory::createFinalMcpCollectionFromInitial(EVENT::LCCollection* mcpVecInitial) { + // coll must exist + if (mcpVecInitial) { + // get num Mcp in coll + int numInitMcp = mcpVecInitial->getNumberOfElements(); + + // coll must have members + if (numInitMcp > 0) { + // loop over input Mcp coll + for (int i = 0; i < numInitMcp; i++) { + +#ifdef SLIC_LOG + log() << LOG::debug << "proc initial MCP: " << i << LOG::done;
#endif
- // get Mcp - MCParticleImpl* mcp = static_cast<MCParticleImpl*>(mcpVecInitial->getElementAt(i));
+ // get Mcp + MCParticleImpl* mcp = static_cast<MCParticleImpl*>(mcpVecInitial->getElementAt(i));
- // create only from Mcp primaries, e.g. no parents - if (LcioMcpUtil::isPrimary(mcp)) - { -#ifdef SLIC_LOG - log() << LOG::debug << "isPrimary" << LOG::done; -#endif - - createMcpFromInitialRecurse(mcp); - } - } - } - else - { - G4Exception("", "", FatalException, "Initial McpVec has no members."); - } - } - else - { - G4Exception("", "", FatalException, "Initial McpVec ptr is null."); - } - }
+ // create only from Mcp primaries, e.g. no parents + if (LcioMcpUtil::isPrimary(mcp)) { +#ifdef SLIC_LOG + log() << LOG::debug << "isPrimary" << LOG::done; +#endif
- IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromInitialRecurse(EVENT::MCParticle* mcpInit) - {
+ createMcpFromInitialRecurse(mcp); + } + } + } else { + G4Exception("", "", FatalException, "Initial McpVec has no members."); + } + } else { + G4Exception("", "", FatalException, "Initial McpVec ptr is null."); + } +} + +IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromInitialRecurse(EVENT::MCParticle* mcpInit) {
#ifdef SLIC_LOG
- log() << LOG::debug << "createMcpFromInitialRecurse: " << m_manager->getMCParticleIndex(m_manager->getInitialMcpCollection(), mcpInit) << LOG::done;
+ log() << LOG::debug << "createMcpFromInitialRecurse: " << m_manager->getMCParticleIndex(m_manager->getInitialMcpCollection(), mcpInit) << LOG::done;
#endif
- MCParticleImpl* mcp = 0;
+ MCParticleImpl* mcp = 0;
- // find associated primary - G4PrimaryParticle* g4primary = m_manager->getMaps()->findPrimaryFromMcp(mcpInit);
+ // find associated primary + G4PrimaryParticle* g4primary = m_manager->getMaps()->findPrimaryFromMcp(mcpInit);
- // no associated primary with this initial mcp? - if (!g4primary) - {
+ // no associated primary with this initial mcp? + if (!g4primary) {
#ifdef SLIC_LOG
- log() << LOG::debug << "initialOnly" << LOG::done;
+ log() << LOG::debug << "initialOnly" << LOG::done;
#endif
- // create from initial Mcp only - mcp = createMcpFromInitialOnly(mcpInit); - } - // create from primary - else - {
+ // create from initial Mcp only + mcp = createMcpFromInitialOnly(mcpInit); + } + // create from primary + else {
#ifdef SLIC_LOG
- log() << LOG::debug << "fromPrimary" << LOG::done;
+ log() << LOG::debug << "fromPrimary" << LOG::done;
#endif
- // create it from primary - mcp = createMcpFromPrimary(g4primary, mcpInit); - }
+ // create it from primary + mcp = createMcpFromPrimary(g4primary, mcpInit); + }
- // return the output MCP - return mcp; - }
+ // return the output MCP + return mcp; +}
- IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromInitialOnly(EVENT::MCParticle* mcpInit) - { - log() << LOG::debug << "createMcpFromInitialOnly: " << m_manager->getMCParticleIndex(m_manager->getInitialMcpCollection(), mcpInit) << LOG::done;
+IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromInitialOnly(EVENT::MCParticle* mcpInit) { + log() << LOG::debug << "createMcpFromInitialOnly: " + << m_manager->getMCParticleIndex(m_manager->getInitialMcpCollection(), mcpInit) << LOG::done;
- // copy shallow the initial - MCParticleImpl* mcp = createMcpShallowCopy(mcpInit);
+ // copy shallow the initial + MCParticleImpl* mcp = createMcpShallowCopy(mcpInit);
- // should add to Mcp map here? - m_manager->getMaps()->addInitialMcpToFinalMcpLink(mcpInit, mcp);
+ // should add to Mcp map here? + m_manager->getMaps()->addInitialMcpToFinalMcpLink(mcpInit, mcp);
- // given initial, create and add daughters - addMcpDaughtersFromInitial(mcp, mcpInit);
+ // given initial, create and add daughters + addMcpDaughtersFromInitial(mcp, mcpInit);
- // add to final coll - m_finalColl->addElement(mcp);
+ // add to final coll + m_finalColl->addElement(mcp);
- return mcp; - }
+ return mcp; +}
- IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromPrimary(G4PrimaryParticle* primary, EVENT::MCParticle* mcpInit) - {
+IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromPrimary(G4PrimaryParticle* primary, + EVENT::MCParticle* mcpInit) {
#ifdef SLIC_LOG
- log() << LOG::done << "createMcpFromPrimary - MCP idx <" << m_manager->getMCParticleIndex(m_manager->getInitialMcpCollection(), mcpInit) << ">" << LOG::done;
+ log() << LOG::done << "createMcpFromPrimary - MCP idx <" << m_manager->getMCParticleIndex(m_manager->getInitialMcpCollection(), mcpInit) << ">" << LOG::done;
#endif
- int trkID = primary->GetTrackID();
+ int trkID = primary->GetTrackID();
#ifdef SLIC_LOG
- if (trkID <= 0) - { - log() << "WARNING: trkID <" << trkID << "> looks bad" << LOG::done; - } - log() << LOG::done << "primary TID <" << trkID << ">" << LOG::done;
+ if (trkID <= 0) + { + log() << "WARNING: trkID <" << trkID << "> looks bad" << LOG::done; + } + log() << LOG::done << "primary TID <" << trkID << ">" << LOG::done;
#endif
- MCParticleImpl* mcp = 0; - Trajectory* trj = TrajectoryManager::instance()->findTrajectory(trkID);
+ MCParticleImpl* mcp = 0; + Trajectory* trj = TrajectoryManager::instance()->findTrajectory(trkID);
- // No trajectory was created. - if (!trj) - {
+ // No trajectory was created. + if (!trj) {
#ifdef SLIC_LOG
- log() << LOG::debug << "initialAndPrimary" << LOG::done;
+ log() << LOG::debug << "initialAndPrimary" << LOG::done;
#endif
- // Recursively create particles from primary and initial MCParticles. - mcp = createMcpFromInitialAndPrimary(primary, mcpInit);
+ // Recursively create particles from primary and initial MCParticles. + mcp = createMcpFromInitialAndPrimary(primary, mcpInit);
- } - // Found a trajectory. - else - {
+ } + // Found a trajectory. + else {
#ifdef SLIC_LOG
- log() << LOG::debug << "initialAndTrajectory" << LOG::done;
+ log() << LOG::debug << "initialAndTrajectory" << LOG::done;
#endif
- // Recursively create MCParticles from a trajectory and the initial MCParticle. - mcp = createMcpFromInitialAndTrajectory(trj, mcpInit);
+ // Recursively create MCParticles from a trajectory and the initial MCParticle. + mcp = createMcpFromInitialAndTrajectory(trj, mcpInit);
- }
+ }
- // Set generator status from initial particle. - mcp->setGeneratorStatus(mcpInit->getGeneratorStatus());
+ // Set generator status from initial particle. + mcp->setGeneratorStatus(mcpInit->getGeneratorStatus());
- // Primary particles do not originate in the simulation. - mcp->setCreatedInSimulation(false); - - // Link the input MCP to an output MCP. - m_manager->getMaps()->addInitialMcpToFinalMcpLink(mcpInit, mcp);
+ // Primary particles do not originate in the simulation. + mcp->setCreatedInSimulation(false);
+ // Link the input MCP to an output MCP. + m_manager->getMaps()->addInitialMcpToFinalMcpLink(mcpInit, mcp);
//#ifdef SLIC_LOG // log() << LOG::debug << "createMcpFromPrimary() - adding trackId <" << trj->GetTrackID() << "> to MCP <" << mcp << "> link." << LOG::done; //#endif
- // Link the track ID to the output particle. - if (trkID > 0) - { - m_manager->getMaps()->addTrackIDToMcpLink(trkID, mcp); - } - else - { -#ifdef SLIC_LOG - log() << LOG::debug << "WARNING: not adding trkID <" << trkID << "> to map!" << LOG::done; -#endif - } - - log() << LOG::done; - - return mcp; - } - - IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromInitialAndPrimary(G4PrimaryParticle* primary, - EVENT::MCParticle* mcpInit) - { - log() << LOG::done << "createMcpFromInitialAndPrimary: " << m_manager->getMCParticleIndex( m_manager->getInitialMcpCollection(), mcpInit) << LOG::done; - - /* - * Create new Mcp from primary particle, - * shallow copy only (no recursion). - */ - MCParticleImpl* mcpNew = createMcpFromPrimaryShallowCopy(primary); - - /* Get vertex from initial particle, because primary does not have it -- was immediately decayed */ - double vtx[3] = {mcpInit->getVertex()[0], mcpInit->getVertex()[1], mcpInit->getVertex()[2]}; - mcpNew->setVertex(vtx); - - /* setup primary's daughters */ - createDaughtersFromPrimary(primary, /* this primary */ - mcpInit, /* associated initial Mcp particle */ - mcpNew /* parent Mcp particle */ - );
+// Link the track ID to the output particle. + if (trkID > 0) { + m_manager->getMaps()->addTrackIDToMcpLink(trkID, mcp); + } else { +#ifdef SLIC_LOG + log() << LOG::debug << "WARNING: not adding trkID <" << trkID << "> to map!" << LOG::done; +#endif + } + + log() << LOG::done; + + return mcp; +} + +IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromInitialAndPrimary(G4PrimaryParticle* primary, + EVENT::MCParticle* mcpInit) { + log() << LOG::done << "createMcpFromInitialAndPrimary: " + << m_manager->getMCParticleIndex(m_manager->getInitialMcpCollection(), mcpInit) << LOG::done; + + /* + * Create new Mcp from primary particle, + * shallow copy only (no recursion). + */ + MCParticleImpl* mcpNew = createMcpFromPrimaryShallowCopy(primary); + + /* Get vertex from initial particle, because primary does not have it -- was immediately decayed */ + double vtx[3] = { mcpInit->getVertex()[0], mcpInit->getVertex()[1], mcpInit->getVertex()[2] }; + mcpNew->setVertex(vtx); + + /* setup primary's daughters */ + createDaughtersFromPrimary(primary, /* this primary */ + mcpInit, /* associated initial Mcp particle */ + mcpNew /* parent Mcp particle */ + );
#ifdef SLIC_DEBUG
- if (mcpNew->getDaughters().size() == 0) - {
+ if (mcpNew->getDaughters().size() == 0) + {
#ifdef SLIC_LOG
- log() << LOG::debug << "No Mcp daughters added." << LOG::done;
+ log() << LOG::debug << "No Mcp daughters added." << LOG::done;
#endif
- }
+ }
#endif
- // Copy spin and color flow information if LCIO version is compatible.
+ // Copy spin and color flow information if LCIO version is compatible.
#if LCIO_VERSION_GE(1, 60)
- copySpinAndColorFlow(mcpInit, mcpNew);
+ copySpinAndColorFlow(mcpInit, mcpNew);
#endif
- // done with particle; add to coll - m_finalColl->addElement(mcpNew);
+ // done with particle; add to coll + m_finalColl->addElement(mcpNew);
- return mcpNew; - }
+ return mcpNew; +}
- IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromInitialAndTrajectory(Trajectory* trj, EVENT::MCParticle* mcpInit) - {
+IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromInitialAndTrajectory(Trajectory* trj, + EVENT::MCParticle* mcpInit) {
#ifdef SLIC_LOG
- log() << LOG::done << "createMcpFromInitialAndTrajectory: " << m_manager->getMCParticleIndex(m_manager->getInitialMcpCollection(), mcpInit) << LOG::done;
+ log() << LOG::done << "createMcpFromInitialAndTrajectory: " << m_manager->getMCParticleIndex(m_manager->getInitialMcpCollection(), mcpInit) << LOG::done;
#endif
- // shallow copy create with basic info and no daughters - IMPL::MCParticleImpl* mcp = createMcpFromTrajectory(trj);
+ // shallow copy create with basic info and no daughters + IMPL::MCParticleImpl* mcp = createMcpFromTrajectory(trj);
- // set generator status and created in sim flag - LcioMcpStatusSetter::setGeneratorStatus(mcpInit, mcp);
+ // set generator status and created in sim flag + LcioMcpStatusSetter::setGeneratorStatus(mcpInit, mcp);
- // loop over all trajectories to find trajectory daughter - int numTrj = m_currentTrajectoryContainer->entries();
+ // loop over all trajectories to find trajectory daughter + int numTrj = m_currentTrajectoryContainer->entries();
#ifdef SLIC_LOG
- log() << LOG::done << "nTrajectoryDau: " << numTrj << LOG::done;
+ log() << LOG::done << "nTrajectoryDau: " << numTrj << LOG::done;
#endif
-
//#ifdef SLIC_LOG // if ( thisTrj->GetParentID() == -1 ) // {
@@ -482,205 +440,191 @@
// } //#endif
- for(int j=0; j<numTrj; j++) - {
+ for (int j = 0; j < numTrj; j++) {
- Trajectory* thisTrj = static_cast<Trajectory*>((*m_currentTrajectoryContainer)[j]);
+ Trajectory* thisTrj = static_cast<Trajectory*>((*m_currentTrajectoryContainer)[j]);
- // found daughter - if (thisTrj->GetParentID() == trj->GetTrackID()) - {
+ // found daughter + if (thisTrj->GetParentID() == trj->GetTrackID()) {
#ifdef SLIC_LOG
- log() << LOG::debug << "Trajectory with trackID <" << trj->GetTrackID() << "> has parent with trackID <" << thisTrj->GetParentID() << ">" << LOG::done;
+ log() << LOG::debug << "Trajectory with trackID <" << trj->GetTrackID() << "> has parent with trackID <" << thisTrj->GetParentID() << ">" << LOG::done;
#endif
- // find matching primary Mcp input particle - MCParticle* mcpPrim = m_manager->getMaps()->findPrimaryInitialMcpFromTrajectory(thisTrj);
+ // find matching primary Mcp input particle + MCParticle* mcpPrim = m_manager->getMaps()->findPrimaryInitialMcpFromTrajectory(thisTrj);
- // create MCP output particle from this input daughter - MCParticleImpl* mcpDauNew = createMcpFromInitialAndTrajectory(thisTrj, mcpPrim);
+ // create MCP output particle from this input daughter + MCParticleImpl* mcpDauNew = createMcpFromInitialAndTrajectory(thisTrj, mcpPrim);
- // set parent link of new daughter - mcpDauNew->addParent(mcp); - } - // DEBUG - //else - //{ - // log() << LOG::done << "BAD NEWS! Could not find Trajectory <" << j << "> with TID <" << trj->GetTrackID() << ">" << LOG::done; - //} - // END DEBUG - }
+ // set parent link of new daughter + mcpDauNew->addParent(mcp); + } + // DEBUG + //else + //{ + // log() << LOG::done << "BAD NEWS! Could not find Trajectory <" << j << "> with TID <" << trj->GetTrackID() << ">" << LOG::done; + //} + // END DEBUG + }
- // add to collection - m_finalColl->addElement(mcp);
+ // add to collection + m_finalColl->addElement(mcp);
- return mcp; - }
+ return mcp; +}
- IMPL::MCParticleImpl* LcioMcpFactory::createMcpShallowCopy(EVENT::MCParticle* mcp) - { - IMPL::MCParticleImpl* mcpNew = new IMPL::MCParticleImpl();
+IMPL::MCParticleImpl* LcioMcpFactory::createMcpShallowCopy(EVENT::MCParticle* mcp) { + IMPL::MCParticleImpl* mcpNew = new IMPL::MCParticleImpl();
- mcpNew->setPDG(mcp->getPDG());
+ mcpNew->setPDG(mcp->getPDG());
- float p[3] = {mcp->getMomentum()[0], mcp->getMomentum()[1], mcp->getMomentum()[2]};
+ float p[3] = { mcp->getMomentum()[0], mcp->getMomentum()[1], mcp->getMomentum()[2] };
- mcpNew->setMomentum(p); - mcpNew->setMass(mcp->getMass());
+ mcpNew->setMomentum(p); + mcpNew->setMass(mcp->getMass());
- double vtx[3] = {mcp->getVertex()[0], mcp->getVertex()[1], mcp->getVertex()[2]}; - mcpNew->setVertex(vtx);
+ double vtx[3] = { mcp->getVertex()[0], mcp->getVertex()[1], mcp->getVertex()[2] }; + mcpNew->setVertex(vtx);
- mcpNew->setGeneratorStatus(mcp->getGeneratorStatus()); - mcpNew->setSimulatorStatus(0); - mcpNew->setCharge(mcp->getCharge()); - mcpNew->setTime(mcp->getTime());
+ mcpNew->setGeneratorStatus(mcp->getGeneratorStatus()); + mcpNew->setSimulatorStatus(0); + mcpNew->setCharge(mcp->getCharge()); + mcpNew->setTime(mcp->getTime());
#if LCIO_VERSION_GE(1, 60)
- copySpinAndColorFlow(mcp, mcpNew);
+ copySpinAndColorFlow(mcp, mcpNew);
#endif
- return mcpNew; - }
+ return mcpNew; +}
- // FIXME: Need to pass along colorflow and spin in this method??? - IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromPrimaryShallowCopy(G4PrimaryParticle* primary) - { - // new MCP - MCParticleImpl* mcp = new MCParticleImpl();
+// FIXME: Need to pass along colorflow and spin in this method??? +IMPL::MCParticleImpl* LcioMcpFactory::createMcpFromPrimaryShallowCopy(G4PrimaryParticle* primary) { + // new MCP + MCParticleImpl* mcp = new MCParticleImpl();
- // PDG - mcp->setPDG( primary->GetPDGcode() );
+ // PDG + mcp->setPDG(primary->GetPDGcode());
- // momentum - G4ThreeVector pVec = primary->GetMomentum() / GeV; - float p[3] = { pVec.x(), pVec.y(), pVec.z() }; - mcp->setMomentum( p );
+ // momentum + G4ThreeVector pVec = primary->GetMomentum() / GeV; + float p[3] = { pVec.x(), pVec.y(), pVec.z() }; + mcp->setMomentum(p);
- // mass - mcp->setMass( primary->GetMass() / GeV );
+ // mass + mcp->setMass(primary->GetMass() / GeV);
#ifdef SLIC_LOG
- log() << "mass from primary: " << mcp->getMass() << LOG::endl;
+ log() << "mass from primary: " << mcp->getMass() << LOG::endl;
#endif
- // FIXME: Wrong if G4PrimaryParticle actually has valid charge. (Can it happen?) - mcp->setCharge(LcioMcpManager::m_NAN);
+ // FIXME: Wrong if G4PrimaryParticle actually has valid charge. (Can it happen?) + mcp->setCharge(LcioMcpManager::m_NAN);
- return mcp; - }
+ return mcp; +}
- // create LCIO MCParticles from daughters, setting proper linkage - void LcioMcpFactory::createDaughtersFromPrimary(G4PrimaryParticle* primary, - EVENT::MCParticle* mcpInit, - IMPL::MCParticleImpl* mcpPar) - {
+// create LCIO MCParticles from daughters, setting proper linkage +void LcioMcpFactory::createDaughtersFromPrimary(G4PrimaryParticle* primary, EVENT::MCParticle* mcpInit, + IMPL::MCParticleImpl* mcpPar) {
#ifdef SLIC_LOG
- log() << LOG::debug << "createDaughtersFromPrimary" << LOG::done; - log() << LOG::debug << "primary: " << primary << LOG::done; - log() << LOG::debug << "trkID: " << primary->GetTrackID() << LOG::done; - log() << LOG::debug << "mcpInit: " << mcpInit << LOG::done; - log() << LOG::debug << "mcpPar: " << mcpPar << LOG::done;
+ log() << LOG::debug << "createDaughtersFromPrimary" << LOG::done; + log() << LOG::debug << "primary: " << primary << LOG::done; + log() << LOG::debug << "trkID: " << primary->GetTrackID() << LOG::done; + log() << LOG::debug << "mcpInit: " << mcpInit << LOG::done; + log() << LOG::debug << "mcpPar: " << mcpPar << LOG::done;
#endif
- // loop over primary daughters - G4PrimaryParticle* primDau = primary->GetDaughter(); - while (primDau) {
+ // loop over primary daughters + G4PrimaryParticle* primDau = primary->GetDaughter(); + while (primDau) { + + // find input Mcp for the primary dau + MCParticle* mcpDau = m_manager->getMaps()->findDaughterMcpFromPrimary(mcpInit, primDau);
- // find input Mcp for the primary dau - MCParticle* mcpDau = m_manager->getMaps()->findDaughterMcpFromPrimary(mcpInit, primDau);
+ // must find it or die + if (0 == mcpDau) { + G4Exception("", "", FatalException, "Mcp daughter was not found."); + }
- // must find it or die - if (0 == mcpDau) - { - G4Exception("", "", FatalException, "Mcp daughter was not found."); - }
+ // create dau Mcp + MCParticleImpl* mcpDauNew = createMcpFromPrimary(primDau, mcpDau);
- // create dau Mcp - MCParticleImpl* mcpDauNew = createMcpFromPrimary(primDau, mcpDau);
+ // make mcpPar the parent + mcpDauNew->addParent(mcpPar);
[truncated at 1000 lines; 145 more skipped]
diff -u -r1.5 -r1.6 --- LcioMcpFilter.cc 26 Sep 2007 18:42:00 -0000 1.5 +++ LcioMcpFilter.cc 27 Nov 2012 19:32:19 -0000 1.6 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpFilter.cc,v 1.5 2007/09/26 18:42:00 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpFilter.cc,v 1.6 2012/11/27 19:32:19 jeremy Exp $
#include "LcioMcpFilter.hh" // slic
@@ -13,167 +13,161 @@
using EVENT::LCIO;
-namespace slic -{
+namespace slic { + +LcioMcpFilter::LcioMcpFilter() : + Module("LcioMcpFilter") { + ; +} + +LcioMcpFilter::~LcioMcpFilter() { + ; +} + +EVENT::LCCollection* LcioMcpFilter::filterSimParticles(EVENT::LCCollection* mcpColl) { + assert(mcpColl); + + // new coll w/ gen parts only + EVENT::LCCollection* genMcpColl = new IMPL::LCCollectionVec(LCIO::MCPARTICLE); + + // iterate over input collection + int mcpSize = mcpColl->getNumberOfElements(); + for (int i = 0; i < mcpSize; i++) {
- LcioMcpFilter::LcioMcpFilter() - : Module( "LcioMcpFilter" ) - {;} - - LcioMcpFilter::~LcioMcpFilter() - {;} - - EVENT::LCCollection* LcioMcpFilter::filterSimParticles(EVENT::LCCollection* mcpColl) - { - assert(mcpColl); - - // new coll w/ gen parts only - EVENT::LCCollection* genMcpColl = new IMPL::LCCollectionVec(LCIO::MCPARTICLE); - - // iterate over input collection - int mcpSize = mcpColl->getNumberOfElements(); - for (int i = 0; i < mcpSize; i++) { -
#ifdef SLIC_DEBUG
- log() << LOG::debug << "handling mcp <" << i << ">" << LOG::done;
+ log() << LOG::debug << "handling mcp <" << i << ">" << LOG::done;
#endif
- // next input Mcp - EVENT::MCParticle* mcp = - static_cast<EVENT::MCParticle*> ( mcpColl->getElementAt(i) );
+ // next input Mcp + EVENT::MCParticle* mcp = static_cast<EVENT::MCParticle*>(mcpColl->getElementAt(i));
- // primary e.g. no parents? - if ( 0 == mcp->getParents().size() ) {
+ // primary e.g. no parents? + if (0 == mcp->getParents().size()) {
#ifdef SLIC_LOG
- log() << LOG::debug << "handling primary Mcp" << LOG::done;
+ log() << LOG::debug << "handling primary Mcp" << LOG::done;
#endif
- // make new Mcp (function checks if gen part) - makeMcp( mcp, genMcpColl );
+ // make new Mcp (function checks if gen part) + makeMcp(mcp, genMcpColl);
- // add to coll - //if ( simMcp ) { - // genMcpColl->addElement( simMcp ); - //} - } - }
+ // add to coll + //if ( simMcp ) { + // genMcpColl->addElement( simMcp ); + //} + } + }
#ifdef SLIC_LOG
- log() << LOG::debug << "input coll size <" << mcpSize << ">" << LOG::done; - log() << LOG::debug << "gen coll size <" << genMcpColl->getNumberOfElements() << ">" << LOG::done; - log() << LOG::debug << "generator mcp coll..." << LOG::done;
+ log() << LOG::debug << "input coll size <" << mcpSize << ">" << LOG::done; + log() << LOG::debug << "gen coll size <" << genMcpColl->getNumberOfElements() << ">" << LOG::done; + log() << LOG::debug << "generator mcp coll..." << LOG::done;
#endif
- //LcioMcpPrinter* prn = new LcioMcpPrinter(); - //prn->printMcpCollection( genMcpColl ); - //delete prn; - - m_mcpList.clear(); - - return genMcpColl; - } - - IMPL::MCParticleImpl* LcioMcpFilter::makeMcp(EVENT::MCParticle* mcp, EVENT::LCCollection* mcpColl) - { - IMPL::MCParticleImpl* mcpGen = 0; - - // has non-0 gen status and was not added? - if ( mcp->getGeneratorStatus() && !wasAdded(mcp) ) { - - //log() << LOG::debug << "gen part" << LOG::done; - - // new Mcp part - mcpGen = new IMPL::MCParticleImpl(); - - // PDG - mcpGen->setPDG( mcp->getPDG() ); - - // gen stat - mcpGen->setGeneratorStatus( mcp->getGeneratorStatus() ); - - // mass - mcpGen->setMass( mcp->getMass() ); - - // sim stat - mcpGen->setSimulatorStatus( mcp->getSimulatorStatus() ); - - // momentum - float p[3] = { mcp->getMomentum()[0], mcp->getMomentum()[1], mcp->getMomentum()[2] }; - mcpGen->setMomentum( p ); - - // vtx - double vtx[3] = { mcp->getVertex()[0], mcp->getVertex()[1], mcp->getVertex()[2] }; - mcpGen->setVertex( vtx ); - - // endp - double endp[3] = { mcp->getEndpoint()[0], mcp->getEndpoint()[1], mcp->getEndpoint()[2] }; - mcpGen->setEndpoint( endp ); - - // time - mcpGen->setTime( mcp->getTime() ); - - // charge - mcpGen->setCharge( mcp->getCharge() ); - - // add it - mcpColl->addElement( mcpGen ); - m_mcpList.push_back( mcp ); - - // add sim daughters - addSimDaughters( mcp, mcpGen, mcpColl ); - } - //else { - // log() << LOG::debug << "skipping sim part and its daughters" << LOG::done; - //} - - return mcpGen; - } - - void LcioMcpFilter::addSimDaughters(EVENT::MCParticle* mcp, - EVENT::MCParticle* parMcp, - EVENT::LCCollection* mcpColl) - { - int nmcp = mcp->getNumberOfDaughters(); - - //log() << LOG::debug << "handling <" << nmcp << "> dau parts" << LOG::done; - - // has at least 1 dau? - if ( nmcp ) { - - // iterate over dau parts - for ( int i = 0; i < nmcp; i++ ) { - EVENT::MCParticle* dauMcp = mcp->getDaughter(i); - - // dau != null? (safety check) - if ( dauMcp ) { - - // make a new dau (could be null ) - IMPL::MCParticleImpl* newDauMcp = makeMcp( dauMcp, mcpColl ); - - // made a new dau? - if ( newDauMcp ) { - //log() << LOG::debug << "add gen dau" << LOG::done; - - // set the dau's par - newDauMcp->addParent( parMcp ); - }
+ //LcioMcpPrinter* prn = new LcioMcpPrinter(); + //prn->printMcpCollection( genMcpColl ); + //delete prn; + + m_mcpList.clear(); + + return genMcpColl; +} + +IMPL::MCParticleImpl* LcioMcpFilter::makeMcp(EVENT::MCParticle* mcp, EVENT::LCCollection* mcpColl) { + IMPL::MCParticleImpl* mcpGen = 0; + + // has non-0 gen status and was not added? + if (mcp->getGeneratorStatus() && !wasAdded(mcp)) { + + //log() << LOG::debug << "gen part" << LOG::done; + + // new Mcp part + mcpGen = new IMPL::MCParticleImpl(); + + // PDG + mcpGen->setPDG(mcp->getPDG()); + + // gen stat + mcpGen->setGeneratorStatus(mcp->getGeneratorStatus()); + + // mass + mcpGen->setMass(mcp->getMass()); + + // sim stat + mcpGen->setSimulatorStatus(mcp->getSimulatorStatus()); + + // momentum + float p[3] = { mcp->getMomentum()[0], mcp->getMomentum()[1], mcp->getMomentum()[2] }; + mcpGen->setMomentum(p); + + // vtx + double vtx[3] = { mcp->getVertex()[0], mcp->getVertex()[1], mcp->getVertex()[2] }; + mcpGen->setVertex(vtx); + + // endp + double endp[3] = { mcp->getEndpoint()[0], mcp->getEndpoint()[1], mcp->getEndpoint()[2] }; + mcpGen->setEndpoint(endp); + + // time + mcpGen->setTime(mcp->getTime()); + + // charge + mcpGen->setCharge(mcp->getCharge()); + + // add it + mcpColl->addElement(mcpGen); + m_mcpList.push_back(mcp); + + // add sim daughters + addSimDaughters(mcp, mcpGen, mcpColl);
}
- } - } - } - - bool LcioMcpFilter::wasAdded(EVENT::MCParticle* mcp) - { - bool f = false; - for ( std::vector<EVENT::MCParticle*>::const_iterator iter = m_mcpList.begin(); - iter != m_mcpList.end(); - iter++ ) { - if ((*iter) == mcp ) { - f = true; - break; - } - } - return f; - }
+ //else { + // log() << LOG::debug << "skipping sim part and its daughters" << LOG::done; + //} + + return mcpGen; +} + +void LcioMcpFilter::addSimDaughters(EVENT::MCParticle* mcp, EVENT::MCParticle* parMcp, + EVENT::LCCollection* mcpColl) { + int nmcp = mcp->getNumberOfDaughters(); + + //log() << LOG::debug << "handling <" << nmcp << "> dau parts" << LOG::done; + + // has at least 1 dau? + if (nmcp) { + + // iterate over dau parts + for (int i = 0; i < nmcp; i++) { + EVENT::MCParticle* dauMcp = mcp->getDaughter(i); + + // dau != null? (safety check) + if (dauMcp) { + + // make a new dau (could be null ) + IMPL::MCParticleImpl* newDauMcp = makeMcp(dauMcp, mcpColl); + + // made a new dau? + if (newDauMcp) { + //log() << LOG::debug << "add gen dau" << LOG::done; + + // set the dau's par + newDauMcp->addParent(parMcp); + } + } + } + } +} + +bool LcioMcpFilter::wasAdded(EVENT::MCParticle* mcp) { + bool f = false; + for (std::vector<EVENT::MCParticle*>::const_iterator iter = m_mcpList.begin(); iter != m_mcpList.end(); + iter++) { + if ((*iter) == mcp) { + f = true; + break; + } + } + return f; +}
}
diff -u -r1.72 -r1.73 --- LcioMcpManager.cc 13 Jul 2012 20:09:02 -0000 1.72 +++ LcioMcpManager.cc 27 Nov 2012 19:32:19 -0000 1.73 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpManager.cc,v 1.72 2012/07/13 20:09:02 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpManager.cc,v 1.73 2012/11/27 19:32:19 jeremy Exp $
#include "LcioMcpManager.hh" // slic
@@ -30,268 +30,239 @@
using EVENT::LCIO; using IMPL::LCCollectionVec;
-namespace slic -{
+namespace slic {
- const double LcioMcpManager::m_NAN = std::sqrt((double)-1.0); - const double LcioMcpManager::DEFAULT_MIN_TRACKING_DISTANCE = 1.0;
+const double LcioMcpManager::m_NAN = std::sqrt((double) -1.0); +const double LcioMcpManager::DEFAULT_MIN_TRACKING_DISTANCE = 1.0;
- LcioMcpManager::~LcioMcpManager() - {}
+LcioMcpManager::~LcioMcpManager() { +}
- LcioMcpManager::LcioMcpManager() - : Module("LcioMcpManager"), - m_minimumTrackingDistance(DEFAULT_MIN_TRACKING_DISTANCE), - m_enablePrintFinal(false), - m_enablePrintInitial(false), - m_writeInitialMCParticleCollection(false) - { - // create new Mcp messenger instance - m_messenger = new LcioMcpMessenger(); - - // setup mcp printer - m_printer = new LcioMcpPrinter(); - - /* Setup the MCParticle factory. */ - m_factory = new LcioMcpFactory(this); - - /* Create the MCParticle data maps object. */ - m_maps = new LcioMcpMaps(this); - - /* Check NAN != NAN */ - assert( m_NAN != m_NAN ); - }
+LcioMcpManager::LcioMcpManager() : + Module("LcioMcpManager"), m_minimumTrackingDistance(DEFAULT_MIN_TRACKING_DISTANCE), m_enablePrintFinal( + false), m_enablePrintInitial(false), m_writeInitialMCParticleCollection(false) { + // create new Mcp messenger instance + m_messenger = new LcioMcpMessenger(); + + // setup mcp printer + m_printer = new LcioMcpPrinter();
- void LcioMcpManager::endEvent(const G4Event* event) - { -#ifdef SLIC_LOG - log() << LOG::debug << "LcioMcpManager::endEvent" << LOG::done; -#endif -/* - // DEBUG - dump traj cont - G4TrajectoryContainer* trajectories = event->GetTrajectoryContainer(); - if ( trajectories ) - { - G4int ntrajectories = trajectories->entries(); - - if (ntrajectories == 0) - log() << LOG::debug << "Trajectories container is empty for this event!" << LOG::done; - - Trajectory* trj = 0; - for ( int i=0; i < ntrajectories; i++ ) - { - trj = static_cast<Trajectory*> ( (*trajectories)[i] ); -#ifdef SLIC_LOG - log() << LOG::debug << "trajectoryIndex: " << i << LOG::done; - log() << LOG::debug << "TID: " << trj->GetTrackID() << LOG::done;
+ /* Setup the MCParticle factory. */ + m_factory = new LcioMcpFactory(this);
- //log() << "Trajectory (Name TID PID time): " << ((int)trj->GetTrackID()) << " " << ((int)trj->GetParentID()) << " " << ((std::string)trj->GetParticleName()) << " " << log::DONE; - log() << LOG::done; -#endif - } - } - else - {
+ /* Create the MCParticle data maps object. */ + m_maps = new LcioMcpMaps(this); + + /* Check NAN != NAN */ + assert( m_NAN != m_NAN); +} + +void LcioMcpManager::endEvent(const G4Event* event) {
#ifdef SLIC_LOG
- log() << LOG::debug << "No trajectories container for this event!" << LOG::done;
+ log() << LOG::debug << "LcioMcpManager::endEvent" << LOG::done;
#endif
- } - // END DEBUG -*/ - - /* - * Create the Mcp collection. Factory will - * retrieve current event from G4EventManager. - */ - m_factory->createFinalMcpCollection(event); - - if ( m_enablePrintFinal ) { - printMcpCollection("final"); - }
+ /* + // DEBUG - dump traj cont + G4TrajectoryContainer* trajectories = event->GetTrajectoryContainer(); + if ( trajectories ) + { + G4int ntrajectories = trajectories->entries(); + + if (ntrajectories == 0) + log() << LOG::debug << "Trajectories container is empty for this event!" << LOG::done; + + Trajectory* trj = 0; + for ( int i=0; i < ntrajectories; i++ ) + { + trj = static_cast<Trajectory*> ( (*trajectories)[i] ); + #ifdef SLIC_LOG + log() << LOG::debug << "trajectoryIndex: " << i << LOG::done; + log() << LOG::debug << "TID: " << trj->GetTrackID() << LOG::done; + + //log() << "Trajectory (Name TID PID time): " << ((int)trj->GetTrackID()) << " " << ((int)trj->GetParentID()) << " " << ((std::string)trj->GetParticleName()) << " " << log::DONE; + log() << LOG::done; + #endif + } + } + else + { + #ifdef SLIC_LOG + log() << LOG::debug << "No trajectories container for this event!" << LOG::done; + #endif + } + // END DEBUG + */ + + /* + * Create the Mcp collection. Factory will + * retrieve current event from G4EventManager. + */ + m_factory->createFinalMcpCollection(event); + + if (m_enablePrintFinal) { + printMcpCollection("final"); + }
#ifdef SLIC_DEBUG
- // print out Mcp processing maps - m_maps->printMaps();
+ // print out Mcp processing maps + m_maps->printMaps();
#endif
- }
+}
- EVENT::LCCollection* LcioMcpManager::findMcpCollection(EVENT::LCEvent* event) - { - const std::vector<std::string>* collNames = event->getCollectionNames(); - - EVENT::LCCollection* mcpColl = 0; - for ( std::vector<std::string>::const_iterator iter = collNames->begin(); - iter != collNames->end(); - iter++ ) { - EVENT::LCCollection* thisColl = event->getCollection( *iter ); - if ( thisColl->getTypeName() == LCIO::MCPARTICLE ) { - mcpColl = thisColl; - break; - } - } - return mcpColl; - } - - EVENT::LCCollection* LcioMcpManager::findMcpCollection(const std::string& collName) - { - return m_mcpColls[collName]; - } - - void LcioMcpManager::setInitialMcpCollection(EVENT::LCCollection* mcpColl) - { - if ( mcpColl ) { - m_mcpColls["initial"] = mcpColl; - } - else { - G4Exception("", "", FatalException, "Initial collection cannot be set to null."); - } - }
+EVENT::LCCollection* LcioMcpManager::findMcpCollection(EVENT::LCEvent* event) { + const std::vector<std::string>* collNames = event->getCollectionNames(); + + EVENT::LCCollection* mcpColl = 0; + for (std::vector<std::string>::const_iterator iter = collNames->begin(); iter != collNames->end(); + iter++) { + EVENT::LCCollection* thisColl = event->getCollection(*iter); + if (thisColl->getTypeName() == LCIO::MCPARTICLE) { + mcpColl = thisColl; + break; + } + } + return mcpColl; +}
- EVENT::LCCollection* LcioMcpManager::createMcpCollection(const std::string& collName) - {
+EVENT::LCCollection* LcioMcpManager::findMcpCollection(const std::string& collName) { + return m_mcpColls[collName]; +} + +void LcioMcpManager::setInitialMcpCollection(EVENT::LCCollection* mcpColl) { + if (mcpColl) { + m_mcpColls["initial"] = mcpColl; + } else { + G4Exception("", "", FatalException, "Initial collection cannot be set to null."); + } +} + +EVENT::LCCollection* LcioMcpManager::createMcpCollection(const std::string& collName) {
#ifdef SLIC_LOG
- log() << LOG::debug << "creating mcp coll <" << collName << ">" << LOG::done;
+ log() << LOG::debug << "creating mcp coll <" << collName << ">" << LOG::done;
#endif
- LCCollection* coll = 0; - if ( findMcpCollection(collName) ) { - G4Exception("", "", FatalException, "Attempting to create duplicate Mcp collection."); - } - else { - coll = new LCCollectionVec(LCIO::MCPARTICLE); - registerMcpCollection( collName, coll ); - } - - return coll; - } - - void LcioMcpManager::registerMcpCollection(const std::string& collName, EVENT::LCCollection* mcpColl) - { - if (mcpColl->getTypeName() != LCIO::MCPARTICLE ) { - G4Exception("", "", FatalException, "The LCCollection does not contain MCParticle objects."); - } - - if ( m_mcpColls[collName] ) { - log() << LOG::warning << "WARNING: Mcp collection " + collName + " is already registered" << LOG::done; - } - else { - m_mcpColls[collName] = mcpColl; - } - } - - void LcioMcpManager::deleteInitialMcpCollection() - { - LCCollection* mcpVec = getInitialMcpCollection(); - - if (0 != mcpVec) { - delete mcpVec; - } - } - - void LcioMcpManager::reset() { - - // Initial MCParticle collection needs deletion if it wasn't added to the event. - if (!writeInitialMCParticleCollection()) { - deleteInitialMcpCollection(); - } - - // Clear the map of MCParticle collections. - m_mcpColls.clear(); - - // Clear the maps of MCParticle runtime data from this event. - m_maps->clear(); - - // NOTE: The final MCParticle collection is deleted by the LCEvent destructor. - } - - // get MCP collection generated at EndOfEvent - EVENT::LCCollection* LcioMcpManager::getFinalMcpCollection() - { - if ( !findMcpCollection("final") ) { - createMcpCollection("final"); - } - - return m_mcpColls["final"]; - } - - EVENT::LCCollection* LcioMcpManager::getInitialMcpCollection() - { - if (!findMcpCollection("initial")) { - createMcpCollection("initial"); - } - - return m_mcpColls["initial"]; - } - - void LcioMcpManager::setMinimumTrackingDistance(double minDist) - { - m_minimumTrackingDistance = minDist; - } - - double LcioMcpManager::getMinimumTrackingDistance() - { - return m_minimumTrackingDistance; - } - - LcioMcpMaps* LcioMcpManager::getMaps() - { - return m_maps; - } - - void LcioMcpManager::enablePrintFinal(bool p) - { - m_enablePrintFinal = p; - } - - void LcioMcpManager::enablePrintInitial(bool p) - { - m_enablePrintInitial = p; - } - - void LcioMcpManager::beginEvent(const G4Event*) - { - if ( m_enablePrintInitial ) { - printMcpCollection("initial"); - } - } - - double LcioMcpManager::getNoChargeFlag() const - { - return m_NAN; - } - - void LcioMcpManager::printMcpCollection(const std::string& collName) - { - LCCollection* coll = findMcpCollection( collName ); - - if ( coll != 0 ) { - printMcpCollection(collName, coll); - }
+ LCCollection* coll = 0; + if (findMcpCollection(collName)) { + G4Exception("", "", FatalException, "Attempting to create duplicate Mcp collection."); + } else { + coll = new LCCollectionVec(LCIO::MCPARTICLE); + registerMcpCollection(collName, coll); + } + + return coll; +} + +void LcioMcpManager::registerMcpCollection(const std::string& collName, EVENT::LCCollection* mcpColl) { + if (mcpColl->getTypeName() != LCIO::MCPARTICLE) { + G4Exception("", "", FatalException, "The LCCollection does not contain MCParticle objects."); + } + + if (m_mcpColls[collName]) { + log() << LOG::warning << "WARNING: Mcp collection " + collName + " is already registered" + << LOG::done; + } else { + m_mcpColls[collName] = mcpColl; + } +} + +void LcioMcpManager::deleteInitialMcpCollection() { + LCCollection* mcpVec = getInitialMcpCollection(); + + if (0 != mcpVec) { + delete mcpVec; + } +} + +void LcioMcpManager::reset() { + + // Initial MCParticle collection needs deletion if it wasn't added to the event. + if (!writeInitialMCParticleCollection()) { + deleteInitialMcpCollection(); + } + + // Clear the map of MCParticle collections. + m_mcpColls.clear(); + + // Clear the maps of MCParticle runtime data from this event. + m_maps->clear(); + + // NOTE: The final MCParticle collection is deleted by the LCEvent destructor. +} + +// get MCP collection generated at EndOfEvent +EVENT::LCCollection* LcioMcpManager::getFinalMcpCollection() { + if (!findMcpCollection("final")) { + createMcpCollection("final"); + } + + return m_mcpColls["final"]; +} + +EVENT::LCCollection* LcioMcpManager::getInitialMcpCollection() { + if (!findMcpCollection("initial")) { + createMcpCollection("initial"); + } + + return m_mcpColls["initial"]; +} + +void LcioMcpManager::setMinimumTrackingDistance(double minDist) { + m_minimumTrackingDistance = minDist; +} + +double LcioMcpManager::getMinimumTrackingDistance() { + return m_minimumTrackingDistance; +} + +LcioMcpMaps* LcioMcpManager::getMaps() { + return m_maps; +} + +void LcioMcpManager::enablePrintFinal(bool p) { + m_enablePrintFinal = p; +} + +void LcioMcpManager::enablePrintInitial(bool p) { + m_enablePrintInitial = p; +} + +void LcioMcpManager::beginEvent(const G4Event*) { + if (m_enablePrintInitial) { + printMcpCollection("initial"); + } +} + +double LcioMcpManager::getNoChargeFlag() const { + return m_NAN; +} + +void LcioMcpManager::printMcpCollection(const std::string& collName) { + LCCollection* coll = findMcpCollection(collName); + + if (coll != 0) { + printMcpCollection(collName, coll); + }
#ifdef SLIC_LOG
- else { - log() << LOG::warning << "LcioMcpManager::printMcpCollection - " + collName + " was not found" << LOG::done; - }
+ else { + log() << LOG::warning << "LcioMcpManager::printMcpCollection - " + collName + " was not found" << LOG::done; + }
#endif
- }
+}
- void LcioMcpManager::printMcpCollection(const std::string& collName, EVENT::LCCollection* coll) - { - m_printer->printMcpCollection(collName, coll); - } - - int LcioMcpManager::getMCParticleIndex( EVENT::LCCollection* collection, EVENT::MCParticle* particle) - { - if (collection->getTypeName() != LCIO::MCPARTICLE) - return -1; - - for (int i=0, n=collection->getNumberOfElements(); i<n; i++) - { - EVENT::MCParticle *nextParticle = (MCParticle*)collection->getElementAt(i); - if (nextParticle == particle) - { - return i; - } - } - return -1; - }
+void LcioMcpManager::printMcpCollection(const std::string& collName, EVENT::LCCollection* coll) { + m_printer->printMcpCollection(collName, coll); +} + +int LcioMcpManager::getMCParticleIndex(EVENT::LCCollection* collection, EVENT::MCParticle* particle) { + if (collection->getTypeName() != LCIO::MCPARTICLE) + return -1; + + for (int i = 0, n = collection->getNumberOfElements(); i < n; i++) { + EVENT::MCParticle *nextParticle = (MCParticle*) collection->getElementAt(i); + if (nextParticle == particle) { + return i; + } + } + return -1; +}
}
diff -u -r1.6 -r1.7 --- LcioMcpMaps.cc 16 Dec 2009 00:16:04 -0000 1.6 +++ LcioMcpMaps.cc 27 Nov 2012 19:32:19 -0000 1.7 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpMaps.cc,v 1.6 2009/12/16 00:16:04 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpMaps.cc,v 1.7 2012/11/27 19:32:19 jeremy Exp $
#include "LcioMcpMaps.hh" // slic
@@ -9,224 +9,177 @@
using EVENT::MCParticle; using IMPL::MCParticleImpl;
-namespace slic -{
+namespace slic {
- LcioMcpMaps::LcioMcpMaps(LcioMcpManager* manager) - : Module( "LcioMcpMaps" ) - { - m_manager = manager; - } - - LcioMcpMaps::~LcioMcpMaps() - {} - - void LcioMcpMaps::addTrackIDToMcpLink(G4int trkID, - MCParticleImpl* mcp) - { - assert( mcp ); - assert(trkID > 0); - - m_trackToMcp[ trkID ] = mcp; - } - - MCParticleImpl* LcioMcpMaps::findMcpFromTrackID( G4int trkID ) const - { - MCParticleImpl* mcp = 0; - for ( TrackToMcpMap::const_iterator iter = m_trackToMcp.begin(); - iter != m_trackToMcp.end(); - iter++ ) - { - if ( iter->first == trkID ) { - mcp = iter->second; - break; - } - } - return mcp; - } - - /* Find the trackID for the final MCParticle. */ - G4int LcioMcpMaps::findTrackIDFromFinalMcp( MCParticle* mcp) const - { - G4int trkID = -1; - for ( TrackToMcpMap::const_iterator iter = m_trackToMcp.begin(); - iter != m_trackToMcp.end(); - iter++ ) - { - if ( iter->second == mcp ) - { - trkID = iter->first; - break; - } - } - return trkID; - } - - MCParticle* LcioMcpMaps::findPrimaryInitialMcpFromTrajectory(Trajectory* trj) const - { - MCParticle* mcpPrim = 0; - - G4int trjTrkID = trj->GetTrackID(); - - /* Get initial collection. */ - EVENT::LCCollection* initMcpColl = m_manager->getInitialMcpCollection(); - - // loop over input collection - int numPrePart = initMcpColl->getNumberOfElements(); - for( int k=0; k < numPrePart; k++ ) - { - - // current MCP - MCParticle* mcpPre = static_cast<MCParticle*> ( initMcpColl->getElementAt( k ) ); - - // do we have matching primary for this Mcp? - G4PrimaryParticle* primaryMatch = findPrimaryFromMcp( mcpPre ); - if ( primaryMatch ) - { - - // found matching primary to this input trajectory - if ( primaryMatch->GetTrackID() == trjTrkID ) - { - mcpPrim = mcpPre; - break; - } - - } - } - - return mcpPrim; - } - - MCParticle* LcioMcpMaps::findDaughterMcpFromPrimary(MCParticle* mcpInit, - G4PrimaryParticle* primDau) const - { - // loop over Mcp input particle's daughters - MCParticle* mcpDau = 0; - int numMcpDau = mcpInit->getDaughters().size(); - for ( int i=0; i < numMcpDau; i++ ) - { - // does ith Mcp dau match this primary? - if ( findPrimaryFromMcp( mcpInit->getDaughters()[i] ) == primDau ) - { - // found it - mcpDau = mcpInit->getDaughters()[i]; - break; - } - } - - // return dau - return mcpDau; - } - - MCParticleImpl* LcioMcpMaps::findFinalParticleFromInitial( MCParticle* mcpInit) const - { - MCParticleImpl* mcpFinal = 0; - for ( InitMcpToMcpMap::const_iterator iter = m_initMcpToMcp.begin(); - iter != m_initMcpToMcp.end(); - iter++ ) - { - if ( iter->first == mcpInit ) - { - mcpFinal = iter->second; - break; - } - } - - return mcpFinal; - } - - G4PrimaryParticle* LcioMcpMaps::findPrimaryFromMcp(MCParticle* mcp) const - { - G4PrimaryParticle *pp = 0; - for ( McpToPrimaryMap::const_iterator iter = m_McpToPrimary.begin(); - iter != m_McpToPrimary.end(); - iter++ ) - { - if ( iter->first == mcp ) - { - pp = iter->second; - break; - } - } - - return pp; - } - - void LcioMcpMaps::addMcpToPrimaryLink(MCParticle* mcp, - G4PrimaryParticle* primary) - { - m_McpToPrimary[ mcp ] = primary; - } - - void LcioMcpMaps::addInitialMcpToFinalMcpLink(MCParticle* mcpInit, - MCParticleImpl* mcpFinal) - { - m_initMcpToMcp[ mcpInit ] = mcpFinal; - } - - void LcioMcpMaps::clear() - { - m_trackToMcp.clear(); - m_McpToPrimary.clear(); - m_initMcpToMcp.clear(); - } - - void LcioMcpMaps::printMaps() - { - log() << LOG::debug << "Printing maps..." << LOG::done; - - printTrackToMcpMap(); - printMcpToPrimaryMap(); - printInitMcpToMcpMap(); - // TrajectoryManager::instance()->printTrackIDToTrajectoryMap(); - } - - void LcioMcpMaps::printTrackToMcpMap() - { - log() << LOG::debug << "Printing track to Mcp map..." << LOG::done; - - log() << LOG::debug << "*** TrackToMcpMap ***" << LOG::done; - log() << LOG::debug << "trkID | McpPtr" << LOG::done; - for ( TrackToMcpMap::iterator iter = m_trackToMcp.begin(); - iter != m_trackToMcp.end(); - iter++ ) - { - log() << LOG::debug << iter->first << " " << iter->second << LOG::done; - } - log() << LOG::debug << LOG::done; - } - - void LcioMcpMaps::printMcpToPrimaryMap() - { - log() << LOG::debug << "Printing Mcp to primary map..." << LOG::done; - - log() << LOG::debug << LOG::done; - log() << LOG::debug << "*** McpToPrimaryMap ***" << LOG::done; - log() << LOG::debug << "McpPtr | PrimaryPtr" << LOG::done; - - for ( McpToPrimaryMap::iterator iter = m_McpToPrimary.begin(); - iter != m_McpToPrimary.end(); - iter++ ) - { - log() << LOG::debug << iter->first << " " << iter->second << LOG::done; - } - log() << LOG::debug << LOG::done; - } - - void LcioMcpMaps::printInitMcpToMcpMap() - { - log() << LOG::debug << "Printing InitMcp to Mcp map..." << LOG::done; - - log() << LOG::debug << LOG::done; - log() << LOG::debug << "*** McpToMcpMap ***" << LOG::done; - log() << LOG::debug << "McpPtrInit | McpPtrFinal" << LOG::done; - - for ( InitMcpToMcpMap::iterator iter = m_initMcpToMcp.begin(); - iter != m_initMcpToMcp.end(); - iter++ ) - { - log() << LOG::debug << iter->first << " " << iter->second << LOG::done; - } - log() << LOG::debug << LOG::done; - }
+LcioMcpMaps::LcioMcpMaps(LcioMcpManager* manager) : + Module("LcioMcpMaps") { + m_manager = manager; +} + +LcioMcpMaps::~LcioMcpMaps() { +} + +void LcioMcpMaps::addTrackIDToMcpLink(G4int trkID, MCParticleImpl* mcp) { + assert( mcp); + assert(trkID > 0); + + m_trackToMcp[trkID] = mcp; +} + +MCParticleImpl* LcioMcpMaps::findMcpFromTrackID(G4int trkID) const { + MCParticleImpl* mcp = 0; + for (TrackToMcpMap::const_iterator iter = m_trackToMcp.begin(); iter != m_trackToMcp.end(); iter++) { + if (iter->first == trkID) { + mcp = iter->second; + break; + } + } + return mcp; +} + +/* Find the trackID for the final MCParticle. */ +G4int LcioMcpMaps::findTrackIDFromFinalMcp(MCParticle* mcp) const { + G4int trkID = -1; + for (TrackToMcpMap::const_iterator iter = m_trackToMcp.begin(); iter != m_trackToMcp.end(); iter++) { + if (iter->second == mcp) { + trkID = iter->first; + break; + } + } + return trkID; +} + +MCParticle* LcioMcpMaps::findPrimaryInitialMcpFromTrajectory(Trajectory* trj) const { + MCParticle* mcpPrim = 0; + + G4int trjTrkID = trj->GetTrackID(); + + /* Get initial collection. */ + EVENT::LCCollection* initMcpColl = m_manager->getInitialMcpCollection(); + + // loop over input collection + int numPrePart = initMcpColl->getNumberOfElements(); + for (int k = 0; k < numPrePart; k++) { + + // current MCP + MCParticle* mcpPre = static_cast<MCParticle*>(initMcpColl->getElementAt(k)); + + // do we have matching primary for this Mcp? + G4PrimaryParticle* primaryMatch = findPrimaryFromMcp(mcpPre); + if (primaryMatch) { + + // found matching primary to this input trajectory + if (primaryMatch->GetTrackID() == trjTrkID) { + mcpPrim = mcpPre; + break; + } + + } + } + + return mcpPrim; +} + +MCParticle* LcioMcpMaps::findDaughterMcpFromPrimary(MCParticle* mcpInit, G4PrimaryParticle* primDau) const { + // loop over Mcp input particle's daughters + MCParticle* mcpDau = 0; + int numMcpDau = mcpInit->getDaughters().size(); + for (int i = 0; i < numMcpDau; i++) { + // does ith Mcp dau match this primary? + if (findPrimaryFromMcp(mcpInit->getDaughters()[i]) == primDau) { + // found it + mcpDau = mcpInit->getDaughters()[i]; + break; + } + } + + // return dau + return mcpDau; +} + +MCParticleImpl* LcioMcpMaps::findFinalParticleFromInitial(MCParticle* mcpInit) const { + MCParticleImpl* mcpFinal = 0; + for (InitMcpToMcpMap::const_iterator iter = m_initMcpToMcp.begin(); iter != m_initMcpToMcp.end(); + iter++) { + if (iter->first == mcpInit) { + mcpFinal = iter->second; + break; + } + } + + return mcpFinal; +} + +G4PrimaryParticle* LcioMcpMaps::findPrimaryFromMcp(MCParticle* mcp) const { + G4PrimaryParticle *pp = 0; + for (McpToPrimaryMap::const_iterator iter = m_McpToPrimary.begin(); iter != m_McpToPrimary.end(); + iter++) { + if (iter->first == mcp) { + pp = iter->second; + break; + } + } + + return pp; +} + +void LcioMcpMaps::addMcpToPrimaryLink(MCParticle* mcp, G4PrimaryParticle* primary) { + m_McpToPrimary[mcp] = primary; +} + +void LcioMcpMaps::addInitialMcpToFinalMcpLink(MCParticle* mcpInit, MCParticleImpl* mcpFinal) { + m_initMcpToMcp[mcpInit] = mcpFinal; +} + +void LcioMcpMaps::clear() { + m_trackToMcp.clear(); + m_McpToPrimary.clear(); + m_initMcpToMcp.clear(); +} + +void LcioMcpMaps::printMaps() { + log() << LOG::debug << "Printing maps..." << LOG::done; + + printTrackToMcpMap(); + printMcpToPrimaryMap(); + printInitMcpToMcpMap(); + // TrajectoryManager::instance()->printTrackIDToTrajectoryMap(); +} + +void LcioMcpMaps::printTrackToMcpMap() { + log() << LOG::debug << "Printing track to Mcp map..." << LOG::done; + + log() << LOG::debug << "*** TrackToMcpMap ***" << LOG::done; + log() << LOG::debug << "trkID | McpPtr" << LOG::done; + for (TrackToMcpMap::iterator iter = m_trackToMcp.begin(); iter != m_trackToMcp.end(); iter++) { + log() << LOG::debug << iter->first << " " << iter->second << LOG::done; + } + log() << LOG::debug << LOG::done; +} + +void LcioMcpMaps::printMcpToPrimaryMap() { + log() << LOG::debug << "Printing Mcp to primary map..." << LOG::done; + + log() << LOG::debug << LOG::done; + log() << LOG::debug << "*** McpToPrimaryMap ***" << LOG::done; + log() << LOG::debug << "McpPtr | PrimaryPtr" << LOG::done; + + for (McpToPrimaryMap::iterator iter = m_McpToPrimary.begin(); iter != m_McpToPrimary.end(); iter++) { + log() << LOG::debug << iter->first << " " << iter->second << LOG::done; + } + log() << LOG::debug << LOG::done; +} + +void LcioMcpMaps::printInitMcpToMcpMap() { + log() << LOG::debug << "Printing InitMcp to Mcp map..." << LOG::done; + + log() << LOG::debug << LOG::done; + log() << LOG::debug << "*** McpToMcpMap ***" << LOG::done; + log() << LOG::debug << "McpPtrInit | McpPtrFinal" << LOG::done; + + for (InitMcpToMcpMap::iterator iter = m_initMcpToMcp.begin(); iter != m_initMcpToMcp.end(); iter++) { + log() << LOG::debug << iter->first << " " << iter->second << LOG::done; + } + log() << LOG::debug << LOG::done; +}
}
diff -u -r1.12 -r1.13 --- LcioMcpMessenger.cc 31 Jan 2012 18:52:30 -0000 1.12 +++ LcioMcpMessenger.cc 27 Nov 2012 19:32:19 -0000 1.13 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpMessenger.cc,v 1.12 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpMessenger.cc,v 1.13 2012/11/27 19:32:19 jeremy Exp $
#include "LcioMcpMessenger.hh" // slic
@@ -10,75 +10,72 @@
// geant4 #include "G4UIparameter.hh"
-namespace slic -{
+namespace slic {
- LcioMcpMessenger::LcioMcpMessenger() - { - defineCommands(); - } - - LcioMcpMessenger::~LcioMcpMessenger() - {} - - void LcioMcpMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) - { - std::istringstream is ( ( const char* ) newVals ); - std::string s; - is >> s; - - LcioMcpManager* mgr = LcioMcpManager::instance(); - - // set minimum tracking distance - if ( cmd == m_minTrackingDistanceCmd ) { - mgr->setMinimumTrackingDistance( m_minTrackingDistanceCmd->GetNewDoubleValue( newVals ) ); - } - else if ( cmd == m_printFinalCollection ) { - mgr->enablePrintFinal( m_printFinalCollection->GetNewBoolValue( newVals.c_str() ) ); - } - else if ( cmd == m_printInitialCollection ) { - mgr->enablePrintInitial( m_printInitialCollection->GetNewBoolValue( newVals.c_str() ) ); - } - // Enable writing of initial MCParticle collection to event. - else if ( cmd == m_writeInitialCollection ) { - mgr->setWriteInitialMCParticleCollection( m_writeInitialCollection->GetNewBoolValue(newVals.c_str() ) ); - } - else { - G4Exception("LcioMessenger::setNewValue()", "", JustWarning, "Unknown command"); - } - - return; - } - - void LcioMcpMessenger::defineCommands() - { - // Mcp dir - m_mcpDir = new G4UIdirectory( "/mcp/" ); - m_mcpDir->SetGuidance( "LCIO Monte Carlo Particle commands. [SLIC]" ); - - // minimumTrackingDistance - m_minTrackingDistanceCmd = new G4UIcmdWithADoubleAndUnit( "/mcp/minimumTrackingDistance", this ); - m_minTrackingDistanceCmd->SetGuidance( "Set the minimum travel distance for an input particle to be tracked in Geant4." ); - m_minTrackingDistanceCmd->SetParameterName("minimumTrackingDistance", false, true); - m_minTrackingDistanceCmd->SetDefaultUnit("mm"); - m_minTrackingDistanceCmd->SetDefaultValue(0.1); - m_minTrackingDistanceCmd->SetRange("minimumTrackingDistance > 0."); - - // Enable printing of MCParticle collections during the event. - m_printInitialCollection = new G4UIcmdWithABool( "/mcp/printInitialCollection", this ); - m_printInitialCollection->SetGuidance( "Enable printing of the initial MCParticle collection during event processing." ); - m_printInitialCollection->SetParameterName("enable", true); - m_printInitialCollection->SetDefaultValue(true); - - // Enable printing of MCParticle collections during the event. - m_printFinalCollection = new G4UIcmdWithABool( "/mcp/printFinalCollection", this ); - m_printFinalCollection->SetGuidance( "Enable printing of the final MCParticle collection during event processing." ); - m_printFinalCollection->SetParameterName("enable", true); - m_printFinalCollection->SetDefaultValue(true); - - m_writeInitialCollection = new G4UIcmdWithABool( "/mcp/writeInitialCollection", this ); - m_writeInitialCollection->SetGuidance( "Write the initial MCParticle collection from StdHep conversion to the LCEvent." ); - m_writeInitialCollection->SetParameterName( "enable", true ); - m_writeInitialCollection->SetDefaultValue(false); - }
+LcioMcpMessenger::LcioMcpMessenger() { + defineCommands(); +} + +LcioMcpMessenger::~LcioMcpMessenger() { +} + +void LcioMcpMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) { + std::istringstream is((const char*) newVals); + std::string s; + is >> s; + + LcioMcpManager* mgr = LcioMcpManager::instance(); + + // set minimum tracking distance + if (cmd == m_minTrackingDistanceCmd) { + mgr->setMinimumTrackingDistance(m_minTrackingDistanceCmd->GetNewDoubleValue(newVals)); + } else if (cmd == m_printFinalCollection) { + mgr->enablePrintFinal(m_printFinalCollection->GetNewBoolValue(newVals.c_str())); + } else if (cmd == m_printInitialCollection) { + mgr->enablePrintInitial(m_printInitialCollection->GetNewBoolValue(newVals.c_str())); + } + // Enable writing of initial MCParticle collection to event. + else if (cmd == m_writeInitialCollection) { + mgr->setWriteInitialMCParticleCollection(m_writeInitialCollection->GetNewBoolValue(newVals.c_str())); + } else { + G4Exception("LcioMessenger::setNewValue()", "", JustWarning, "Unknown command"); + } + + return; +} + +void LcioMcpMessenger::defineCommands() { + // Mcp dir + m_mcpDir = new G4UIdirectory("/mcp/"); + m_mcpDir->SetGuidance("LCIO Monte Carlo Particle commands. [SLIC]"); + + // minimumTrackingDistance + m_minTrackingDistanceCmd = new G4UIcmdWithADoubleAndUnit("/mcp/minimumTrackingDistance", this); + m_minTrackingDistanceCmd->SetGuidance( + "Set the minimum travel distance for an input particle to be tracked in Geant4."); + m_minTrackingDistanceCmd->SetParameterName("minimumTrackingDistance", false, true); + m_minTrackingDistanceCmd->SetDefaultUnit("mm"); + m_minTrackingDistanceCmd->SetDefaultValue(0.1); + m_minTrackingDistanceCmd->SetRange("minimumTrackingDistance > 0."); + + // Enable printing of MCParticle collections during the event. + m_printInitialCollection = new G4UIcmdWithABool("/mcp/printInitialCollection", this); + m_printInitialCollection->SetGuidance( + "Enable printing of the initial MCParticle collection during event processing."); + m_printInitialCollection->SetParameterName("enable", true); + m_printInitialCollection->SetDefaultValue(true); + + // Enable printing of MCParticle collections during the event. + m_printFinalCollection = new G4UIcmdWithABool("/mcp/printFinalCollection", this); + m_printFinalCollection->SetGuidance( + "Enable printing of the final MCParticle collection during event processing."); + m_printFinalCollection->SetParameterName("enable", true); + m_printFinalCollection->SetDefaultValue(true); + + m_writeInitialCollection = new G4UIcmdWithABool("/mcp/writeInitialCollection", this); + m_writeInitialCollection->SetGuidance( + "Write the initial MCParticle collection from StdHep conversion to the LCEvent."); + m_writeInitialCollection->SetParameterName("enable", true); + m_writeInitialCollection->SetDefaultValue(false); +}
}
diff -u -r1.19 -r1.20 --- LcioMcpPrinter.cc 27 Apr 2007 01:54:35 -0000 1.19 +++ LcioMcpPrinter.cc 27 Nov 2012 19:32:19 -0000 1.20 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpPrinter.cc,v 1.19 2007/04/27 01:54:35 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpPrinter.cc,v 1.20 2012/11/27 19:32:19 jeremy Exp $
#include "LcioMcpPrinter.hh" // lcdd
@@ -15,359 +15,322 @@
using namespace std; using std::ios;
-namespace slic -{
+namespace slic {
- const int LcioMcpPrinter::idx_width = 4; - const int LcioMcpPrinter::ptr_width = 10; - const int LcioMcpPrinter::pdg_width = 5; - const int LcioMcpPrinter::par_width = 15; - const int LcioMcpPrinter::dau_width = 15; - const int LcioMcpPrinter::mom_width = 20; - const int LcioMcpPrinter::vtx_width = 20; - const int LcioMcpPrinter::end_width = 20; - const int LcioMcpPrinter::time_width = 6; - const int LcioMcpPrinter::mass_width = 6; - const int LcioMcpPrinter::chrg_width = 4; - const int LcioMcpPrinter::e_width = 6; - const int LcioMcpPrinter::stat_width = 5; - const int LcioMcpPrinter::flags_width = 16; - - LcioMcpPrinter::LcioMcpPrinter() - : Module("LcioMcpPrinter"), - m_coll(0), - m_collName("") - {} - - LcioMcpPrinter::~LcioMcpPrinter() - {} - - void LcioMcpPrinter::printMcpCollection(const std::string& collName, EVENT::LCCollection* coll) - { - m_coll = coll; - m_collName = collName; - printMcpCollection(); - } - - void LcioMcpPrinter::printMcpCollection() - { - head(); - - if ( m_coll != 0 ) { - - // LCCollectionVec* mcpCollVec = static_cast<LCCollectionVec*> ( m_coll ); - - if ( m_coll->getNumberOfElements() > 0 ) { - - log() << LOG::debug << "Collection Name: " << m_collName << LOG::done; - log() << LOG::debug << "# of Particles: " << m_coll->getNumberOfElements() << LOG::done; - - colLabels(); - - LCCollectionVec* vec = static_cast<LCCollectionVec*>(m_coll); - for ( LCCollectionVec::iterator iter = vec->begin(); - iter != vec->end(); - iter++ ) { - printMcp ( static_cast<EVENT::MCParticle*> (*iter) ); - }
+const int LcioMcpPrinter::idx_width = 4; +const int LcioMcpPrinter::ptr_width = 10; +const int LcioMcpPrinter::pdg_width = 5; +const int LcioMcpPrinter::par_width = 15; +const int LcioMcpPrinter::dau_width = 15; +const int LcioMcpPrinter::mom_width = 20; +const int LcioMcpPrinter::vtx_width = 20; +const int LcioMcpPrinter::end_width = 20; +const int LcioMcpPrinter::time_width = 6; +const int LcioMcpPrinter::mass_width = 6; +const int LcioMcpPrinter::chrg_width = 4; +const int LcioMcpPrinter::e_width = 6; +const int LcioMcpPrinter::stat_width = 5; +const int LcioMcpPrinter::flags_width = 16; + +LcioMcpPrinter::LcioMcpPrinter() : + Module("LcioMcpPrinter"), m_coll(0), m_collName("") { +} + +LcioMcpPrinter::~LcioMcpPrinter() { +} + +void LcioMcpPrinter::printMcpCollection(const std::string& collName, EVENT::LCCollection* coll) { + m_coll = coll; + m_collName = collName; + printMcpCollection(); +} + +void LcioMcpPrinter::printMcpCollection() { + head(); + + if (m_coll != 0) { + + // LCCollectionVec* mcpCollVec = static_cast<LCCollectionVec*> ( m_coll ); + + if (m_coll->getNumberOfElements() > 0) { + + log() << LOG::debug << "Collection Name: " << m_collName << LOG::done; + log() << LOG::debug << "# of Particles: " << m_coll->getNumberOfElements() << LOG::done; + + colLabels(); + + LCCollectionVec* vec = static_cast<LCCollectionVec*>(m_coll); + for (LCCollectionVec::iterator iter = vec->begin(); iter != vec->end(); iter++) { + printMcp(static_cast<EVENT::MCParticle*>(*iter)); + }
#ifdef SLIC_LOG
- flagLabels();
+ flagLabels();
#endif
- } - else { - log() << LOG::debug << "COLLECTION IS EMPTY" << LOG::done; - } - } - else { - log() << LOG::debug << "NO CURRENT MCPARTICLE COLLECTION" << LOG::done; - } - - foot(); - }
+ } else { + log() << LOG::debug << "COLLECTION IS EMPTY" << LOG::done; + } + } else { + log() << LOG::debug << "NO CURRENT MCPARTICLE COLLECTION" << LOG::done; + }
- void LcioMcpPrinter::flagLabels() - { - line();
+ foot(); +}
- log() << LOG::debug << "FLAGS: createdInSimulation Backscatter vertexIsNotEndpointOfParent " - << "DecayedInTracker DecayedInCalorimeter LeftDetector Stopped";
+void LcioMcpPrinter::flagLabels() { + line();
- line(); - }
+ log() << LOG::debug << "FLAGS: createdInSimulation Backscatter vertexIsNotEndpointOfParent " + << "DecayedInTracker DecayedInCalorimeter LeftDetector Stopped";
- void LcioMcpPrinter::printMcp(EVENT::MCParticle* mcp) - { - // index - log().getOutputStream().width(idx_width); - log().getOutputStream() << left; - log() << LOG::debug << findMcpIndex( mcp );
+ line(); +}
- sep();
+void LcioMcpPrinter::printMcp(EVENT::MCParticle* mcp) { + // index + log().getOutputStream().width(idx_width); + log().getOutputStream() << left; + log() << LOG::debug << findMcpIndex(mcp);
- // ptr - log().getOutputStream().width(ptr_width); - log().getOutputStream() << left; - log() << LOG::debug << mcp;
+ sep();
- sep();
+ // ptr + log().getOutputStream().width(ptr_width); + log().getOutputStream() << left; + log() << LOG::debug << mcp;
- // PDG - log().getOutputStream().width(pdg_width); - log() << LOG::debug << left << mcp->getPDG();
+ sep();
- sep();
+ // PDG + log().getOutputStream().width(pdg_width); + log() << LOG::debug << left << mcp->getPDG();
- // parents - log().getOutputStream().width(par_width); - log() << LOG::debug << left << makeIdxVecString( findParentIndices( mcp ) );
+ sep();
- sep();
+ // parents + log().getOutputStream().width(par_width); + log() << LOG::debug << left << makeIdxVecString(findParentIndices(mcp));
- // daughters - log().getOutputStream().width(dau_width); - log() << LOG::debug << left << makeIdxVecString( findDaughterIndices( mcp ) );
+ sep();
- sep();
+ // daughters + log().getOutputStream().width(dau_width); + log() << LOG::debug << left << makeIdxVecString(findDaughterIndices(mcp));
- // momentum - log().getOutputStream().width(mom_width); - log() << LOG::debug << left << makeDoubleArray3String( mcp->getMomentum() );
+ sep();
- sep();
+ // momentum + log().getOutputStream().width(mom_width); + log() << LOG::debug << left << makeDoubleArray3String(mcp->getMomentum());
- // vertex - log().getOutputStream().width(vtx_width); - log() << LOG::debug << left << makeDoubleArray3String( mcp->getVertex() );
+ sep();
- sep();
+ // vertex + log().getOutputStream().width(vtx_width); + log() << LOG::debug << left << makeDoubleArray3String(mcp->getVertex());
- // endpoint - log().getOutputStream().width(end_width); - log() << LOG::debug << left << makeDoubleArray3String( mcp->getEndpoint() );
+ sep();
- sep();
+ // endpoint + log().getOutputStream().width(end_width); + log() << LOG::debug << left << makeDoubleArray3String(mcp->getEndpoint());
- // time - log().getOutputStream().width(time_width); - log() << LOG::debug << left << mcp->getTime();
+ sep();
- sep();
+ // time + log().getOutputStream().width(time_width); + log() << LOG::debug << left << mcp->getTime();
- // mass - log().getOutputStream().width(mass_width); - log() << LOG::debug << left << mcp->getMass();
+ sep();
- sep();
+ // mass + log().getOutputStream().width(mass_width); + log() << LOG::debug << left << mcp->getMass();
- // charge - log().getOutputStream().width(chrg_width); - log() << LOG::debug << mcp->getCharge();
+ sep();
- sep();
+ // charge + log().getOutputStream().width(chrg_width); + log() << LOG::debug << mcp->getCharge();
- // energy - log().getOutputStream().width(e_width); - log() << LOG::debug << mcp->getEnergy();
+ sep();
- // gen status - log() << LOG::debug << mcp->getGeneratorStatus();
+ // energy + log().getOutputStream().width(e_width); + log() << LOG::debug << mcp->getEnergy();
+ // gen status + log() << LOG::debug << mcp->getGeneratorStatus();
#ifdef SLIC_LOG
- sep(); - log() << LOG::debug << left << makeSimStatusCodesString( mcp );
+ sep(); + log() << LOG::debug << left << makeSimStatusCodesString( mcp );
#endif
- line(); - line(); - } - - std::string LcioMcpPrinter::makeDoubleArray3String(const double* arr) - { - - return - "(" + StringUtil::toString( arr[0] ) - + ", " + StringUtil::toString( arr[1] ) - + ", " + StringUtil::toString( arr[2] ) - + ")"; - } - - std::string LcioMcpPrinter::makeFloatArray3String(const float* arr) - { - return "(" + StringUtil::toString( arr[0] ) - + ", " + StringUtil::toString( arr[1] ) - + ", " + StringUtil::toString( arr[2] ) + ")"; - } - - std::string LcioMcpPrinter::makeSimStatusCodesString(EVENT::MCParticle* mcp) - { - return StringUtil::toString( mcp->isCreatedInSimulation() ) + " " - + StringUtil::toString( mcp->isBackscatter() ) + " " - + StringUtil::toString( mcp->vertexIsNotEndpointOfParent() ) + " " - + StringUtil::toString( mcp->isDecayedInTracker() ) + " " - + StringUtil::toString( mcp->isDecayedInCalorimeter() ) + " " - + StringUtil::toString( mcp->hasLeftDetector() ) + " " - + StringUtil::toString( mcp->isStopped() ); - } - - std::string LcioMcpPrinter::makeIdxVecString(const IdxVec& idxVec) - { - std::string idx_vec; - idx_vec = "[ "; - - for ( IdxVec::const_iterator iter = idxVec.begin(); - iter != idxVec.end(); - iter++ ) { - int this_idx = (*iter); - idx_vec += StringUtil::toString( this_idx ) + " "; - } - - idx_vec += "]"; - return idx_vec; - } - - LcioMcpPrinter::IdxVec LcioMcpPrinter::findDaughterIndices(EVENT::MCParticle* mcp) - { - IdxVec dauIdxs; - const EVENT::MCParticleVec& dauVec = mcp->getDaughters(); - for ( EVENT::MCParticleVec::const_iterator iter = dauVec.begin(); - iter != dauVec.end(); - iter++ ) { - dauIdxs.push_back( findMcpIndex( ( const_cast<MCParticle*> (*iter) ) ) ); - } - - return dauIdxs; - } - - LcioMcpPrinter::IdxVec LcioMcpPrinter::findParentIndices(EVENT::MCParticle* mcp) - { - IdxVec parIdxs; - const EVENT::MCParticleVec& parVec = mcp->getParents(); - for ( EVENT::MCParticleVec::const_iterator iter = parVec.begin(); - iter != parVec.end(); - iter++ ) { - parIdxs.push_back( findMcpIndex( ( const_cast<MCParticle*> (*iter) ) ) ); - } - - return parIdxs; - } - - int LcioMcpPrinter::findMcpIndex(EVENT::MCParticle* mcp) - { - int idx = 0; - bool fnd = false; - LCCollectionVec* mcpCollVec = static_cast<LCCollectionVec*> ( m_coll ); - for ( LCCollectionVec::iterator iter = mcpCollVec->begin(); - iter != mcpCollVec->end(); - iter++ ) { - // ptr compare - if ( ( static_cast<MCParticle*> (*iter) ) == mcp ) { - fnd = true; - break; - } - idx++; - } - - if ( !fnd ) { - idx = -1; - } - - return idx; - } - - inline void LcioMcpPrinter::sep() - { - log() << LOG::debug << "|"; - } - - inline void LcioMcpPrinter::line() - { - log() << LOG::debug << LOG::done; - } - - inline void LcioMcpPrinter::head() - { - log() << LOG::debug << "---------------------MCParticle Collection---------------------"; - - line(); - } - - inline void LcioMcpPrinter::foot() - { - log() << LOG::debug << "---------------------------------------------------------------"; - - line(); - } - - void LcioMcpPrinter::colLabels() - { - log().getOutputStream().width(idx_width); - log() << LOG::debug << left << "idx"; - - sep(); - - log().getOutputStream().width(ptr_width); - log() << LOG::debug << left << "ptr"; - - sep(); - - log().getOutputStream().width(pdg_width); - log() << LOG::debug << left << "pdg"; - - sep(); - - log().getOutputStream().width(par_width); - log() << LOG::debug << left << "par"; - - sep(); - - log().getOutputStream().width(dau_width); - log() << LOG::debug << left << "dau"; - - sep(); - - log().getOutputStream().width(mom_width); - log() << LOG::debug << left << "mom"; - - sep(); - - log().getOutputStream().width(vtx_width); - log() << LOG::debug << left << "vtx"; - - sep(); - - log().getOutputStream().width(end_width); - log() << LOG::debug << left << "end"; - - sep(); - - log().getOutputStream().width(time_width); - log() << LOG::debug << left << "time"; - - sep(); - - log().getOutputStream().width(mass_width); - log() << LOG::debug << left << "mass"; - - sep(); - - log().getOutputStream().width(chrg_width); - log() << LOG::debug << left << "chg";
+ line(); + line(); +} + +std::string LcioMcpPrinter::makeDoubleArray3String(const double* arr) { + + return "(" + StringUtil::toString(arr[0]) + ", " + StringUtil::toString(arr[1]) + ", " + + StringUtil::toString(arr[2]) + ")"; +} + +std::string LcioMcpPrinter::makeFloatArray3String(const float* arr) { + return "(" + StringUtil::toString(arr[0]) + ", " + StringUtil::toString(arr[1]) + ", " + + StringUtil::toString(arr[2]) + ")"; +} + +std::string LcioMcpPrinter::makeSimStatusCodesString(EVENT::MCParticle* mcp) { + return StringUtil::toString(mcp->isCreatedInSimulation()) + " " + + StringUtil::toString(mcp->isBackscatter()) + " " + + StringUtil::toString(mcp->vertexIsNotEndpointOfParent()) + " " + + StringUtil::toString(mcp->isDecayedInTracker()) + " " + + StringUtil::toString(mcp->isDecayedInCalorimeter()) + " " + + StringUtil::toString(mcp->hasLeftDetector()) + " " + StringUtil::toString(mcp->isStopped()); +} + +std::string LcioMcpPrinter::makeIdxVecString(const IdxVec& idxVec) { + std::string idx_vec; + idx_vec = "[ "; + + for (IdxVec::const_iterator iter = idxVec.begin(); iter != idxVec.end(); iter++) { + int this_idx = (*iter); + idx_vec += StringUtil::toString(this_idx) + " "; + } + + idx_vec += "]"; + return idx_vec; +} + +LcioMcpPrinter::IdxVec LcioMcpPrinter::findDaughterIndices(EVENT::MCParticle* mcp) { + IdxVec dauIdxs; + const EVENT::MCParticleVec& dauVec = mcp->getDaughters(); + for (EVENT::MCParticleVec::const_iterator iter = dauVec.begin(); iter != dauVec.end(); iter++) { + dauIdxs.push_back(findMcpIndex((const_cast<MCParticle*>(*iter)))); + } + + return dauIdxs; +} + +LcioMcpPrinter::IdxVec LcioMcpPrinter::findParentIndices(EVENT::MCParticle* mcp) { + IdxVec parIdxs; + const EVENT::MCParticleVec& parVec = mcp->getParents(); + for (EVENT::MCParticleVec::const_iterator iter = parVec.begin(); iter != parVec.end(); iter++) { + parIdxs.push_back(findMcpIndex((const_cast<MCParticle*>(*iter)))); + } + + return parIdxs; +} + +int LcioMcpPrinter::findMcpIndex(EVENT::MCParticle* mcp) { + int idx = 0; + bool fnd = false; + LCCollectionVec* mcpCollVec = static_cast<LCCollectionVec*>(m_coll); + for (LCCollectionVec::iterator iter = mcpCollVec->begin(); iter != mcpCollVec->end(); iter++) { + // ptr compare + if ((static_cast<MCParticle*>(*iter)) == mcp) { + fnd = true; + break; + } + idx++; + } + + if (!fnd) { + idx = -1; + } + + return idx; +} + +inline void LcioMcpPrinter::sep() { + log() << LOG::debug << "|"; +} + +inline void LcioMcpPrinter::line() { + log() << LOG::debug << LOG::done; +} + +inline void LcioMcpPrinter::head() { + log() << LOG::debug << "---------------------MCParticle Collection---------------------"; + + line(); +} + +inline void LcioMcpPrinter::foot() { + log() << LOG::debug << "---------------------------------------------------------------"; + + line(); +} + +void LcioMcpPrinter::colLabels() { + log().getOutputStream().width(idx_width); + log() << LOG::debug << left << "idx"; + + sep(); + + log().getOutputStream().width(ptr_width); + log() << LOG::debug << left << "ptr";
- sep();
+ sep();
- log().getOutputStream().width(e_width); - log() << LOG::debug << "E";
+ log().getOutputStream().width(pdg_width); + log() << LOG::debug << left << "pdg";
- sep();
+ sep(); + + log().getOutputStream().width(par_width); + log() << LOG::debug << left << "par"; + + sep(); + + log().getOutputStream().width(dau_width); + log() << LOG::debug << left << "dau"; + + sep(); + + log().getOutputStream().width(mom_width); + log() << LOG::debug << left << "mom"; + + sep(); + + log().getOutputStream().width(vtx_width); + log() << LOG::debug << left << "vtx"; + + sep(); + + log().getOutputStream().width(end_width); + log() << LOG::debug << left << "end"; + + sep(); + + log().getOutputStream().width(time_width); + log() << LOG::debug << left << "time"; + + sep(); + + log().getOutputStream().width(mass_width); + log() << LOG::debug << left << "mass"; + + sep(); + + log().getOutputStream().width(chrg_width); + log() << LOG::debug << left << "chg"; + + sep(); + + log().getOutputStream().width(e_width); + log() << LOG::debug << "E"; + + sep();
#ifdef SLIC_LOG
- log().getOutputStream().width(flags_width); - log() << LOG::debug << "flags";
+ log().getOutputStream().width(flags_width); + log() << LOG::debug << "flags";
#endif
- line(); - }
+ line(); +}
}
diff -u -r1.5 -r1.6 --- LcioMcpStatusSetter.cc 10 Sep 2008 00:04:58 -0000 1.5 +++ LcioMcpStatusSetter.cc 27 Nov 2012 19:32:19 -0000 1.6 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpStatusSetter.cc,v 1.5 2008/09/10 00:04:58 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpStatusSetter.cc,v 1.6 2012/11/27 19:32:19 jeremy Exp $
#include "LcioMcpStatusSetter.hh" // slic
@@ -8,105 +8,92 @@
using IMPL::MCParticleImpl; using EVENT::MCParticle;
-namespace slic -{ - IMPL::MCParticleImpl* LcioMcpStatusSetter::setMcpStatusCodesFromTrajectory(Trajectory* trj, - MCParticleImpl* mcp) - { - // set vertexIsNotEndOfParent flag - LcioMcpStatusSetter::setVertexIsNotEndpointOfParentFlag( trj, mcp ); - - // set final status flags - LcioMcpStatusSetter::setFinalStatusFlags( trj, mcp ); - - // set backscatter flag - LcioMcpStatusSetter::setBackscatterFlag( trj, mcp ); - - // For GPS source, set generator status to FS for trajectories without parents, - // i.e. the parent track ID is 0. - if (EventSourceManager::instance()->getCurrentSourceType() == - EventSourceManager::eGPS) { - if (trj->GetParentID() == 0) { - mcp->setGeneratorStatus(1); - } - } - - // return the MCP - return mcp; - } - - void LcioMcpStatusSetter::setBackscatterFlag(Trajectory* trj, - IMPL::MCParticleImpl* mcp) - { - if ( trj->getBackscatter() ) { - mcp->setBackscatter( true ); - } - } - - void LcioMcpStatusSetter::setVertexIsNotEndpointOfParentFlag(Trajectory* trj, - MCParticleImpl* mcp) - { - mcp->setVertexIsNotEndpointOfParent( trj->getVertexIsNotEndpointOfParent() ); - } - - void LcioMcpStatusSetter::setCreatedInSimulationFlag(Trajectory* trj, - IMPL::MCParticleImpl* mcp) - { - if ( trj->getCreatedInSimulation() ) { - mcp->setGeneratorStatus( 0 ); - mcp->setCreatedInSimulation( true ); - } - else { - mcp->setCreatedInSimulation( false ); - } - } - - void LcioMcpStatusSetter::setFinalStatusFlags(Trajectory* trj, - IMPL::MCParticleImpl* mcp) - { - // set final status flags - Trajectory::EFinalStatus trjFinalStatus = trj->getFinalStatus(); - switch ( trjFinalStatus ) { - - case Trajectory::eDecayedInTracker: - mcp->setDecayedInTracker( true ); - break; - - case Trajectory::eLeftDetector: - mcp->setHasLeftDetector( true ); - break; - - case Trajectory::eStopped: - mcp->setStopped( true ); - break; - - case Trajectory::eDecayedInCalorimeter: - mcp->setDecayedInCalorimeter( true ); - break; - - case Trajectory::eUnset: - break; - - default: - break; - } - } - - void LcioMcpStatusSetter::setGeneratorStatus(MCParticle* mcpInit, MCParticleImpl* mcp) - { - // set generator status if initial exists - if ( mcpInit ) { - - // if init particle, this was not created in sim - mcp->setCreatedInSimulation( false ); - - // copy gen status from initial - mcp->setGeneratorStatus( mcpInit->getGeneratorStatus() ); - } - // no initial -> created in sim - else { - mcp->setCreatedInSimulation( true ); - mcp->setGeneratorStatus( 0 ); - } - }
+namespace slic { +IMPL::MCParticleImpl* LcioMcpStatusSetter::setMcpStatusCodesFromTrajectory(Trajectory* trj, + MCParticleImpl* mcp) { + // set vertexIsNotEndOfParent flag + LcioMcpStatusSetter::setVertexIsNotEndpointOfParentFlag(trj, mcp); + + // set final status flags + LcioMcpStatusSetter::setFinalStatusFlags(trj, mcp); + + // set backscatter flag + LcioMcpStatusSetter::setBackscatterFlag(trj, mcp); + + // For GPS source, set generator status to FS for trajectories without parents, + // i.e. the parent track ID is 0. + if (EventSourceManager::instance()->getCurrentSourceType() == EventSourceManager::eGPS) { + if (trj->GetParentID() == 0) { + mcp->setGeneratorStatus(1); + } + } + + // return the MCP + return mcp; +} + +void LcioMcpStatusSetter::setBackscatterFlag(Trajectory* trj, IMPL::MCParticleImpl* mcp) { + if (trj->getBackscatter()) { + mcp->setBackscatter(true); + } +} + +void LcioMcpStatusSetter::setVertexIsNotEndpointOfParentFlag(Trajectory* trj, MCParticleImpl* mcp) { + mcp->setVertexIsNotEndpointOfParent(trj->getVertexIsNotEndpointOfParent()); +} + +void LcioMcpStatusSetter::setCreatedInSimulationFlag(Trajectory* trj, IMPL::MCParticleImpl* mcp) { + if (trj->getCreatedInSimulation()) { + mcp->setGeneratorStatus(0); + mcp->setCreatedInSimulation(true); + } else { + mcp->setCreatedInSimulation(false); + } +} + +void LcioMcpStatusSetter::setFinalStatusFlags(Trajectory* trj, IMPL::MCParticleImpl* mcp) { + // set final status flags + Trajectory::EFinalStatus trjFinalStatus = trj->getFinalStatus(); + switch (trjFinalStatus) { + + case Trajectory::eDecayedInTracker: + mcp->setDecayedInTracker(true); + break; + + case Trajectory::eLeftDetector: + mcp->setHasLeftDetector(true); + break; + + case Trajectory::eStopped: + mcp->setStopped(true); + break; + + case Trajectory::eDecayedInCalorimeter: + mcp->setDecayedInCalorimeter(true); + break; + + case Trajectory::eUnset: + break; + + default: + break; + } +} + +void LcioMcpStatusSetter::setGeneratorStatus(MCParticle* mcpInit, MCParticleImpl* mcp) { + // set generator status if initial exists + if (mcpInit) { + + // if init particle, this was not created in sim + mcp->setCreatedInSimulation(false); + + // copy gen status from initial + mcp->setGeneratorStatus(mcpInit->getGeneratorStatus()); + } + // no initial -> created in sim + else { + mcp->setCreatedInSimulation(true); + mcp->setGeneratorStatus(0); + } +}
}
diff -u -r1.2 -r1.3 --- LcioMcpUtil.cc 19 Oct 2005 22:51:17 -0000 1.2 +++ LcioMcpUtil.cc 27 Nov 2012 19:32:19 -0000 1.3 @@ -1,36 +1,31 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpUtil.cc,v 1.2 2005/10/19 22:51:17 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpUtil.cc,v 1.3 2012/11/27 19:32:19 jeremy Exp $
#include "LcioMcpUtil.hh"
-namespace slic -{ - // Mcp with no parents - bool LcioMcpUtil::isPrimary(IMPL::MCParticleImpl* mcp) - { - return ( mcp->getParents().size() == 0 ); - } - - G4double LcioMcpUtil::computeMcpDistance(IMPL::MCParticleImpl* mcp1, - IMPL::MCParticleImpl* mcp2 ) - { - return computeDistance( mcp1->getVertex(), mcp2->getVertex() ); - } - - G4double LcioMcpUtil::computeDistance(const double *v1, const double *v2) - { - // distance = sqrt ( x^2 + y^2 + z^2 ) - - // x^2 - G4double x = (v1[0] - v2[0]); - G4double x2 = pow( x, 2 ); - - // y^2 - G4double y = (v1[1] - v2[1]); - G4double y2 = pow( y, 2 ); - - // z^2 - G4double z = (v1[2] - v2[2]); - G4double z2 = pow( z, 2 );
+namespace slic { +// Mcp with no parents +bool LcioMcpUtil::isPrimary(IMPL::MCParticleImpl* mcp) { + return (mcp->getParents().size() == 0); +} + +G4double LcioMcpUtil::computeMcpDistance(IMPL::MCParticleImpl* mcp1, IMPL::MCParticleImpl* mcp2) { + return computeDistance(mcp1->getVertex(), mcp2->getVertex()); +}
- return sqrt( x2 + y2 + z2 ); - }
+G4double LcioMcpUtil::computeDistance(const double *v1, const double *v2) { + // distance = sqrt ( x^2 + y^2 + z^2 ) + + // x^2 + G4double x = (v1[0] - v2[0]); + G4double x2 = pow(x, 2); + + // y^2 + G4double y = (v1[1] - v2[1]); + G4double y2 = pow(y, 2); + + // z^2 + G4double z = (v1[2] - v2[2]); + G4double z2 = pow(z, 2); + + return sqrt(x2 + y2 + z2); +}
}
diff -u -r1.36 -r1.37 --- LcioMessenger.cc 31 Jan 2012 18:52:30 -0000 1.36 +++ LcioMessenger.cc 27 Nov 2012 19:32:19 -0000 1.37 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMessenger.cc,v 1.36 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMessenger.cc,v 1.37 2012/11/27 19:32:19 jeremy Exp $
#include "LcioMessenger.hh" // slic
@@ -20,146 +20,143 @@
// std #include <sstream>
-namespace slic -{
+namespace slic {
- LcioMessenger::LcioMessenger(LcioManager* mgr) - : m_mgr(mgr) - { - defineCommands(); - } - - LcioMessenger::~LcioMessenger() - { - delete m_lcioDir; - delete m_pathCmd; - delete m_filenameCmd; - } - - void LcioMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) - { - std::istringstream is ( ( const char* ) newVals ); - - std::string s; - is >> s; - - // set output path - if ( cmd == m_pathCmd ) { - m_mgr->setPath( s ); - } - // set filename - else if ( cmd == m_filenameCmd ) { - m_mgr->setFilename( s ); - } - // fileExistsAction - else if ( cmd == m_fileExistsActionCmd ) { - m_mgr->setFileExistsAction( LcioManager::getFileExistsActionFromString( s ) ); - } - // setRunNumber - else if ( cmd == m_setRunNumberCmd ) { - m_mgr->setRunNumber( StringUtil::toInt( s ) ); - } - // autoname - else if ( cmd == m_autonameCmd ) { - std::vector<std::string> fields; - StringUtil::split(newVals, " ", fields); - m_mgr->setAutonameFields(fields); - } - /* dump event */ - else if ( cmd == m_dumpEventCmd ) { - m_mgr->enableDumpEvent( m_dumpEventCmd->GetNewBoolValue( newVals.c_str() ) ); - } - // flags - else if ( cmd == m_setLongFlagCmd || cmd == m_setPDGFlagCmd ) { - - // no args then true - bool flag_set = true; - - // get arg val if exists - if ( s != std::string("") ) { - flag_set = StringUtil::toBool( s ); - } - - LcioHitsCollectionBuilder* hcb = m_mgr->getHCBuilder(); - - if ( hcb ) { - - // CHBIT_LONG for positions in hits - if ( cmd == m_setLongFlagCmd ) { - hcb->setLongFlag( flag_set ); - } - // CHBIT_PDG for every PDG contribution in hits - else if ( cmd == m_setPDGFlagCmd ) { - hcb->setPDGFlag( flag_set ); - } - } - else { - G4Exception( "", "", FatalException, "LcioHitsCollectionBuilder is null." ); - } - } - // bad command; shouldn't happen - else { - G4Exception( "LcioMessenger::setNewValue()", "", JustWarning, "Unknown command." ); - } - return; - } - - void LcioMessenger::defineCommands() - { - G4UIparameter* p; - - // Lcio dir - m_lcioDir = new G4UIdirectory( "/lcio/" ); - m_lcioDir->SetGuidance( "LCIO output commands. [SLIC]" ); - - // path - m_pathCmd = new G4UIcommand( "/lcio/path", this ); - m_pathCmd->SetGuidance( "Set Lcio output path." ); - p = new G4UIparameter( "path", 's', false ); - m_pathCmd->SetParameter( p ); - - // filename - m_filenameCmd = new G4UIcommand( "/lcio/filename", this ); - m_filenameCmd->SetGuidance( "Set Lcio output filename." ); - p = new G4UIparameter ( "filename", 's', false ); - m_filenameCmd->SetParameter( p ); - - // CHBIT_LONG - m_setLongFlagCmd = new G4UIcommand( "/lcio/longFlag", this ); - m_setLongFlagCmd->SetGuidance( "Set CHBIT_LONG flag for hit positions in output (default = on)." ); - p = new G4UIparameter( "Value", 'b', true ); - m_setLongFlagCmd->SetParameter( p ); - m_setLongFlagCmd->AvailableForStates( G4State_PreInit ); - - // CHBIT_PDG - m_setPDGFlagCmd = new G4UIcommand( "/lcio/PDGFlag", this ); - m_setPDGFlagCmd->SetGuidance( "Set CHBIT_PDG flag for super-long output with all Mcp contribs (default is aggregated)." ); - p = new G4UIparameter( "Value", 'b', true ); - m_setPDGFlagCmd->SetParameter( p ); - m_setLongFlagCmd->AvailableForStates( G4State_PreInit ); - - // fileExistsAction - m_fileExistsActionCmd = new G4UIcommand( "/lcio/fileExists", this ); - m_fileExistsActionCmd->SetGuidance( "Set action when an Lcio output file exists: fail, overwrite/delete or append." ); - p = new G4UIparameter( "mode", 's', false ); - m_fileExistsActionCmd->SetParameter( p ); - - // set the starting run number - m_setRunNumberCmd = new G4UIcmdWithAnInteger( "/lcio/runNumber", this ); - m_setRunNumberCmd->SetGuidance( "Set starting run number for LCIO event." ); - m_setRunNumberCmd->SetParameterName( "RunNumber", false ); - - // enable autonaming - m_autonameCmd = new G4UIcommand( "/lcio/autoname", this ); - m_autonameCmd->SetGuidance( "Set autonaming parameters." ); - m_autonameCmd->SetGuidance("Valid autoname fields: application geometry event eventNumber run binary physics date geant4"); - p = new G4UIparameter("autoname", 's', true ); - m_autonameCmd->SetParameter(p); - - /* dumping of event data */ - m_dumpEventCmd = new G4UIcmdWithABool( "/lcio/dumpEvent", this ); - m_dumpEventCmd->SetGuidance( "Dump information about collections in the event" ); - m_dumpEventCmd->SetParameterName("enable", true); - m_dumpEventCmd->SetDefaultValue(true); - }
+LcioMessenger::LcioMessenger(LcioManager* mgr) : + m_mgr(mgr) { + defineCommands(); +} + +LcioMessenger::~LcioMessenger() { + delete m_lcioDir; + delete m_pathCmd; + delete m_filenameCmd; +} + +void LcioMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) { + std::istringstream is((const char*) newVals); + + std::string s; + is >> s; + + // set output path + if (cmd == m_pathCmd) { + m_mgr->setPath(s); + } + // set filename + else if (cmd == m_filenameCmd) { + m_mgr->setFilename(s); + } + // fileExistsAction + else if (cmd == m_fileExistsActionCmd) { + m_mgr->setFileExistsAction(LcioManager::getFileExistsActionFromString(s)); + } + // setRunNumber + else if (cmd == m_setRunNumberCmd) { + m_mgr->setRunNumber(StringUtil::toInt(s)); + } + // autoname + else if (cmd == m_autonameCmd) { + std::vector<std::string> fields; + StringUtil::split(newVals, " ", fields); + m_mgr->setAutonameFields(fields); + } + /* dump event */ + else if (cmd == m_dumpEventCmd) { + m_mgr->enableDumpEvent(m_dumpEventCmd->GetNewBoolValue(newVals.c_str())); + } + // flags + else if (cmd == m_setLongFlagCmd || cmd == m_setPDGFlagCmd) { + + // no args then true + bool flag_set = true; + + // get arg val if exists + if (s != std::string("")) { + flag_set = StringUtil::toBool(s); + } + + LcioHitsCollectionBuilder* hcb = m_mgr->getHCBuilder(); + + if (hcb) { + + // CHBIT_LONG for positions in hits + if (cmd == m_setLongFlagCmd) { + hcb->setLongFlag(flag_set); + } + // CHBIT_PDG for every PDG contribution in hits + else if (cmd == m_setPDGFlagCmd) { + hcb->setPDGFlag(flag_set); + } + } else { + G4Exception("", "", FatalException, "LcioHitsCollectionBuilder is null."); + } + } + // bad command; shouldn't happen + else { + G4Exception("LcioMessenger::setNewValue()", "", JustWarning, "Unknown command."); + } + return; +} + +void LcioMessenger::defineCommands() { + G4UIparameter* p; + + // Lcio dir + m_lcioDir = new G4UIdirectory("/lcio/"); + m_lcioDir->SetGuidance("LCIO output commands. [SLIC]"); + + // path + m_pathCmd = new G4UIcommand("/lcio/path", this); + m_pathCmd->SetGuidance("Set Lcio output path."); + p = new G4UIparameter("path", 's', false); + m_pathCmd->SetParameter(p); + + // filename + m_filenameCmd = new G4UIcommand("/lcio/filename", this); + m_filenameCmd->SetGuidance("Set Lcio output filename."); + p = new G4UIparameter("filename", 's', false); + m_filenameCmd->SetParameter(p); + + // CHBIT_LONG + m_setLongFlagCmd = new G4UIcommand("/lcio/longFlag", this); + m_setLongFlagCmd->SetGuidance("Set CHBIT_LONG flag for hit positions in output (default = on)."); + p = new G4UIparameter("Value", 'b', true); + m_setLongFlagCmd->SetParameter(p); + m_setLongFlagCmd->AvailableForStates(G4State_PreInit); + + // CHBIT_PDG + m_setPDGFlagCmd = new G4UIcommand("/lcio/PDGFlag", this); + m_setPDGFlagCmd->SetGuidance( + "Set CHBIT_PDG flag for super-long output with all Mcp contribs (default is aggregated)."); + p = new G4UIparameter("Value", 'b', true); + m_setPDGFlagCmd->SetParameter(p); + m_setLongFlagCmd->AvailableForStates(G4State_PreInit); + + // fileExistsAction + m_fileExistsActionCmd = new G4UIcommand("/lcio/fileExists", this); + m_fileExistsActionCmd->SetGuidance( + "Set action when an Lcio output file exists: fail, overwrite/delete or append."); + p = new G4UIparameter("mode", 's', false); + m_fileExistsActionCmd->SetParameter(p); + + // set the starting run number + m_setRunNumberCmd = new G4UIcmdWithAnInteger("/lcio/runNumber", this); + m_setRunNumberCmd->SetGuidance("Set starting run number for LCIO event."); + m_setRunNumberCmd->SetParameterName("RunNumber", false); + + // enable autonaming + m_autonameCmd = new G4UIcommand("/lcio/autoname", this); + m_autonameCmd->SetGuidance("Set autonaming parameters."); + m_autonameCmd->SetGuidance( + "Valid autoname fields: application geometry event eventNumber run binary physics date geant4"); + p = new G4UIparameter("autoname", 's', true); + m_autonameCmd->SetParameter(p); + + /* dumping of event data */ + m_dumpEventCmd = new G4UIcmdWithABool("/lcio/dumpEvent", this); + m_dumpEventCmd->SetGuidance("Dump information about collections in the event"); + m_dumpEventCmd->SetParameterName("enable", true); + m_dumpEventCmd->SetDefaultValue(true); +}
}
diff -u -r1.39 -r1.40 --- LcioPrimaryGenerator.cc 31 Jan 2012 18:52:30 -0000 1.39 +++ LcioPrimaryGenerator.cc 27 Nov 2012 19:32:19 -0000 1.40 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioPrimaryGenerator.cc,v 1.39 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioPrimaryGenerator.cc,v 1.40 2012/11/27 19:32:19 jeremy Exp $
// slic #include "LogStream.hh"
@@ -18,253 +18,241 @@
using EVENT::LCCollection; using EVENT::LCIO;
-namespace slic -{
+namespace slic {
- LcioPrimaryGenerator::LcioPrimaryGenerator(LcioManager* mgr) - : Module( "LcioPrimaryGenerator" ) - { - m_mgr = mgr;
+LcioPrimaryGenerator::LcioPrimaryGenerator(LcioManager* mgr) : + Module("LcioPrimaryGenerator") { + m_mgr = mgr;
- m_mcpManager = LcioMcpManager::instance(); - }
+ m_mcpManager = LcioMcpManager::instance(); +}
- LcioPrimaryGenerator::~LcioPrimaryGenerator() - {}
+LcioPrimaryGenerator::~LcioPrimaryGenerator() { +}
- void LcioPrimaryGenerator::generatePrimaryVertexFromMcpCollection( LCCollection* mcpVec, G4Event* anEvent ) - {
+void LcioPrimaryGenerator::generatePrimaryVertexFromMcpCollection(LCCollection* mcpVec, G4Event* anEvent) {
#ifdef SLIC_LOG
- log() << LOG::debug << "********** Generating Event from LCIO MCParticles **********" << LOG::endl << LOG::done;
+ log() << LOG::debug << "********** Generating Event from LCIO MCParticles **********" << LOG::endl << LOG::done;
#endif
- assert( mcpVec ); - assert( mcpVec->getTypeName() == LCIO::MCPARTICLE );
+ assert( mcpVec); + assert( mcpVec->getTypeName() == LCIO::MCPARTICLE);
- G4int nhep = mcpVec->getNumberOfElements();
+ G4int nhep = mcpVec->getNumberOfElements();
- if ( nhep < 1 ) { - return; - }
+ if (nhep < 1) { + return; + }
//#ifdef SLIC_LOG // log() << LOG::debug << "nInitialMCParticles: " << nhep << LOG::done; //#endif
- for ( int i=0; i < nhep; i++ ) {
+ for (int i = 0; i < nhep; i++) {
- MCParticleImpl* mcp = dynamic_cast<MCParticleImpl*> - (mcpVec->getElementAt( i ) );
+ MCParticleImpl* mcp = dynamic_cast<MCParticleImpl*>(mcpVec->getElementAt(i));
- //assert( mcp ); - if (mcp == 0) - G4Exception( "", "", FatalException, "Could not find MCParticle at indx." );
+ //assert( mcp ); + if (mcp == 0) + G4Exception("", "", FatalException, "Could not find MCParticle at indx.");
- // debug info - G4ParticleTable* tbl = G4ParticleTable::GetParticleTable(); - G4ParticleDefinition* pdef = tbl->FindParticle( mcp->getPDG() );
+ // debug info + G4ParticleTable* tbl = G4ParticleTable::GetParticleTable(); + G4ParticleDefinition* pdef = tbl->FindParticle(mcp->getPDG());
- G4String pname = "unknown"; - if (pdef != 0) - pname = pdef->GetParticleName(); - // end debug info
+ G4String pname = "unknown"; + if (pdef != 0) + pname = pdef->GetParticleName(); + // end debug info
#ifdef SLIC_LOG
- log() << LOG::debug << "generating particle #" << i << ", pdg: " << mcp->getPDG() << ", name: " << pname << LOG::done; - log() << LOG::debug << "vertex: ( " << mcp->getVertex()[0] << ", " << mcp->getVertex()[1] << ", " << mcp->getVertex()[2] << " )" << LOG::done; - if (mcp->getEndpoint() != 0) - log() << LOG::debug << "endp: ( " << mcp->getEndpoint()[0] << ", " << mcp->getEndpoint()[1] << ", " << mcp->getEndpoint()[2] << " )" << LOG::done; - log() << LOG::debug << "time: " << mcp->getTime() << LOG::done;
+ log() << LOG::debug << "generating particle #" << i << ", pdg: " << mcp->getPDG() << ", name: " << pname << LOG::done; + log() << LOG::debug << "vertex: ( " << mcp->getVertex()[0] << ", " << mcp->getVertex()[1] << ", " << mcp->getVertex()[2] << " )" << LOG::done; + if (mcp->getEndpoint() != 0) + log() << LOG::debug << "endp: ( " << mcp->getEndpoint()[0] << ", " << mcp->getEndpoint()[1] << ", " << mcp->getEndpoint()[2] << " )" << LOG::done; + log() << LOG::debug << "time: " << mcp->getTime() << LOG::done;
#endif
- G4int numPar = mcp->getParents().size();
+ G4int numPar = mcp->getParents().size();
#ifdef SLIC_LOG
- log() << LOG::debug << "nparents: " << numPar << LOG::done;
+ log() << LOG::debug << "nparents: " << numPar << LOG::done;
#endif
- /* - * Handle 4 cases, following Ron Cassell's LCSHEPEvtInterface from LCS package: - * case 1: predecay - * case 2: not predecay; "final state" - * case 3: not predecay; "intermediate" or "documentation" TO BE TRACKED - * case 4: not predecay; "intermediate" or "documentation" *NOT* TRACKED - */ - // loop vars - MCParticleImpl* parMcp = 0; - G4PrimaryParticle* g4parent = 0;
+ /* + * Handle 4 cases, following Ron Cassell's LCSHEPEvtInterface from LCS package: + * case 1: predecay + * case 2: not predecay; "final state" + * case 3: not predecay; "intermediate" or "documentation" TO BE TRACKED + * case 4: not predecay; "intermediate" or "documentation" *NOT* TRACKED + */ + // loop vars + MCParticleImpl* parMcp = 0; + G4PrimaryParticle* g4parent = 0;
- G4PrimaryParticle* thePrimary = 0; - G4PrimaryVertex* theVertex = 0;
+ G4PrimaryParticle* thePrimary = 0; + G4PrimaryVertex* theVertex = 0;
- G4bool isPreDecay = false; - G4bool createPrimary = false; - G4bool createVertex = false;
+ G4bool isPreDecay = false; + G4bool createPrimary = false; + G4bool createVertex = false;
- // check if case 1 (PreDecay) - if ( numPar > 0 ) { - parMcp = dynamic_cast<MCParticleImpl*>(mcp->getParents()[0]); - g4parent = m_mcpManager->getMaps()->findPrimaryFromMcp( parMcp );
+ // check if case 1 (PreDecay) + if (numPar > 0) { + parMcp = dynamic_cast<MCParticleImpl*>(mcp->getParents()[0]); + g4parent = m_mcpManager->getMaps()->findPrimaryFromMcp(parMcp);
- // Check if the particle has parents, in which case it needs a predecay. - if ( g4parent != 0 ) {
+ // Check if the particle has parents, in which case it needs a predecay. + if (g4parent != 0) {
- isPreDecay = true;
+ isPreDecay = true;
#ifdef SLIC_LOG
- log() << "PREDECAY" << LOG::done; - log() << LOG::debug << "parent idx: " << LcioMcpManager::instance()->getMCParticleIndex(mcpVec, parMcp) << LOG::done;
+ log() << "PREDECAY" << LOG::done; + log() << LOG::debug << "parent idx: " << LcioMcpManager::instance()->getMCParticleIndex(mcpVec, parMcp) << LOG::done;
#endif
- } - }
+ } + }
- // case 1 - if ( isPreDecay ) { - createPrimary = true; - // no vertex - } - else { - // case 2: final state - if ( mcp->getGeneratorStatus() == 1 ) {
+ // case 1 + if (isPreDecay) { + createPrimary = true; + // no vertex + } else { + // case 2: final state + if (mcp->getGeneratorStatus() == 1) {
#ifdef SLIC_LOG
- log() << LOG::debug << "FINAL STATE" << LOG::done;
+ log() << LOG::debug << "FINAL STATE" << LOG::done;
#endif
- createPrimary = true; - createVertex = true; - } - else { - G4double dist = 0;
+ createPrimary = true; + createVertex = true; + } else { + G4double dist = 0;
- // check case 3, if traveled > minDist - if ( mcp->getDaughters().size() > 0 ) {
+ // check case 3, if traveled > minDist + if (mcp->getDaughters().size() > 0) {
- IMPL::MCParticleImpl* firstDau = dynamic_cast<IMPL::MCParticleImpl*> - ( mcp->getDaughters()[0] );
+ IMPL::MCParticleImpl* firstDau = + dynamic_cast<IMPL::MCParticleImpl*>(mcp->getDaughters()[0]);
- dist = LcioMcpUtil::computeMcpDistance( mcp, firstDau );
+ dist = LcioMcpUtil::computeMcpDistance(mcp, firstDau);
#ifdef SLIC_LOG
- log() << LOG::debug << "mcpDistance=" << dist << LOG::done; - log() << LOG::debug << "minTrackingDist=" << m_mcpManager->getMinimumTrackingDistance() << LOG::done;
+ log() << LOG::debug << "mcpDistance=" << dist << LOG::done; + log() << LOG::debug << "minTrackingDist=" << m_mcpManager->getMinimumTrackingDistance() << LOG::done;
#endif
- // case 3 - if ( dist > m_mcpManager->getMinimumTrackingDistance() ) {
+ // case 3 + if (dist > m_mcpManager->getMinimumTrackingDistance()) {
#ifdef SLIC_LOG
- log() << LOG::debug << "INTERMEDIATE OR DOC TO BE TRACKED" << LOG::done;
+ log() << LOG::debug << "INTERMEDIATE OR DOC TO BE TRACKED" << LOG::done;
#endif
- - createPrimary = true; - createVertex = true; - } - // case 4 = no-op - // *This particle will not be tracked.*
+ + createPrimary = true; + createVertex = true; + } + // case 4 = no-op + // *This particle will not be tracked.*
#ifdef SLIC_LOG
- else { - log() << LOG::debug << "INTERMEDIATE OR DOC THAT WILL NOT BE TRACKED" << LOG::done; - }
+ else { + log() << LOG::debug << "INTERMEDIATE OR DOC THAT WILL NOT BE TRACKED" << LOG::done; + }
#endif
- }
+ } + + } + }
- } - } -
#ifdef SLIC_LOG
- log() << "isPreDecay: " << isPreDecay << LOG::done; - log() << "createPrimary: " << createPrimary << LOG::done; - log() << "createVertex: " << createVertex << LOG::done;
+ log() << "isPreDecay: " << isPreDecay << LOG::done; + log() << "createPrimary: " << createPrimary << LOG::done; + log() << "createVertex: " << createVertex << LOG::done;
#endif
- // create a primary - if ( createPrimary ) {
+ // create a primary + if (createPrimary) {
- thePrimary = createPrimaryParticleFromMcp( mcp );
+ thePrimary = createPrimaryParticleFromMcp(mcp);
- // set daughters for PreDecay - if ( isPreDecay ) {
+ // set daughters for PreDecay + if (isPreDecay) {
- assert( g4parent );
+ assert( g4parent);
- // - // Computation of proper_time from RC - // - - G4ThreeVector parMom = g4parent->GetMomentum();
+ // + // Computation of proper_time from RC + // + + G4ThreeVector parMom = g4parent->GetMomentum();
#ifdef SLIC_LOG
- log() << "parent p: " << parMom << LOG::done;
+ log() << "parent p: " << parMom << LOG::done;
#endif
- G4double E = sqrt(pow(g4parent->GetMass(), 2) + pow( parMom.x(), 2 ) + pow( parMom.y(), 2) + pow( parMom.z(), 2 ) );
+ G4double E = sqrt( + pow(g4parent->GetMass(), 2) + pow(parMom.x(), 2) + pow(parMom.y(), 2) + + pow(parMom.z(), 2));
#ifdef SLIC_LOG
- log() << "particle time: " << mcp->getTime() << LOG::done; - log() << "parent time: " << parMcp->getTime() << LOG::done; - log() << "parent mass: " << g4parent->GetMass() << LOG::done;
+ log() << "particle time: " << mcp->getTime() << LOG::done; + log() << "parent time: " << parMcp->getTime() << LOG::done; + log() << "parent mass: " << g4parent->GetMass() << LOG::done;
#endif
- G4double proper_time = ( ( mcp->getTime() - parMcp->getTime() ) * g4parent->GetMass() ) / E;
+ G4double proper_time = ((mcp->getTime() - parMcp->getTime()) * g4parent->GetMass()) / E;
#ifdef SLIC_LOG
- log() << LOG::debug << "parent E: " << E << LOG::done; - log() << LOG::debug << "proper time: " << proper_time << LOG::done;
+ log() << LOG::debug << "parent E: " << E << LOG::done; + log() << LOG::debug << "proper time: " << proper_time << LOG::done;
#endif
- g4parent->SetDaughter( thePrimary ); - g4parent->SetProperTime( proper_time );
+ g4parent->SetDaughter(thePrimary); + g4parent->SetProperTime(proper_time);
#ifdef SLIC_LOG
- log() << LOG::debug << "mcp decay time: " << mcp->getTime() - parMcp->getTime() << LOG::done;
+ log() << LOG::debug << "mcp decay time: " << mcp->getTime() - parMcp->getTime() << LOG::done;
#endif
- } - }
+ } + }
- // create a vertex, add primary and set in event - if ( createVertex ) { - theVertex = createPrimaryVertexFromMcp( mcp ); - theVertex->SetPrimary( thePrimary ); - anEvent->AddPrimaryVertex( theVertex ); - }
+ // create a vertex, add primary and set in event + if (createVertex) { + theVertex = createPrimaryVertexFromMcp(mcp); + theVertex->SetPrimary(thePrimary); + anEvent->AddPrimaryVertex(theVertex); + }
- // insert mcp, primary pair into LcioManager's map (could be null) - if ( thePrimary ) { - m_mcpManager->getMaps()->addMcpToPrimaryLink(mcp, thePrimary ); - }
+ // insert mcp, primary pair into LcioManager's map (could be null) + if (thePrimary) { + m_mcpManager->getMaps()->addMcpToPrimaryLink(mcp, thePrimary); + }
#ifdef SLIC_LOG
- log() << LOG::debug << LOG::endl;
+ log() << LOG::debug << LOG::endl;
#endif
- } - }
+ } +}
- G4PrimaryParticle* LcioPrimaryGenerator::createPrimaryParticleFromMcp(IMPL::MCParticleImpl* mcp) - { - G4PrimaryParticle* primary = new G4PrimaryParticle(mcp->getPDG(), - mcp->getMomentum()[0] * GeV, - mcp->getMomentum()[1] * GeV, - mcp->getMomentum()[2] * GeV - ); - primary->SetMass( mcp->getMass() * GeV );
+G4PrimaryParticle* LcioPrimaryGenerator::createPrimaryParticleFromMcp(IMPL::MCParticleImpl* mcp) { + G4PrimaryParticle* primary = new G4PrimaryParticle(mcp->getPDG(), mcp->getMomentum()[0] * GeV, + mcp->getMomentum()[1] * GeV, mcp->getMomentum()[2] * GeV); + primary->SetMass(mcp->getMass() * GeV);
- return primary; - }
+ return primary; +}
- G4PrimaryVertex* LcioPrimaryGenerator::createPrimaryVertexFromMcp(IMPL::MCParticleImpl* mcp) - {
+G4PrimaryVertex* LcioPrimaryGenerator::createPrimaryVertexFromMcp(IMPL::MCParticleImpl* mcp) {
#ifdef SLIC_LOG
- log() << "createPrimaryVertexFromMcp" << LOG::done; - log() << "particle time: " << mcp->getTime() << LOG::done;
+ log() << "createPrimaryVertexFromMcp" << LOG::done; + log() << "particle time: " << mcp->getTime() << LOG::done;
#endif
- G4ThreeVector pos = G4ThreeVector( mcp->getVertex()[0], - mcp->getVertex()[1], - mcp->getVertex()[2]);
+ G4ThreeVector pos = G4ThreeVector(mcp->getVertex()[0], mcp->getVertex()[1], mcp->getVertex()[2]);
- return new G4PrimaryVertex(pos, - mcp->getTime() );
+ return new G4PrimaryVertex(pos, mcp->getTime());
- }
+}
}
diff -u -r1.11 -r1.12 --- LogMessenger.cc 9 Apr 2008 22:09:36 -0000 1.11 +++ LogMessenger.cc 27 Nov 2012 19:32:19 -0000 1.12 @@ -1,4 +1,4 @@
-// $Id: LogMessenger.cc,v 1.11 2008/04/09 22:09:36 jeremy Exp $
+// $Id: LogMessenger.cc,v 1.12 2012/11/27 19:32:19 jeremy Exp $
#include "LogMessenger.hh"
@@ -11,40 +11,38 @@
#include "G4UIcmdWithAString.hh" #include "G4UIdirectory.hh"
-namespace slic -{ - LogMessenger::LogMessenger(LogStream* logger) - : m_logStream( logger ) - { - defineCommands(); - } - - LogMessenger::~LogMessenger() - {;} - - void LogMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) - { - if ( cmd == m_setLevelCmd ) { - m_logStream->setOutputLevel( (LOG::ELevel)G4UIcmdWithAnInteger::GetNewIntValue( newVals ) ); - } - else if ( cmd == m_fileCmd ) { - m_logStream->setOutputFile( newVals ); - } - } - - void LogMessenger::defineCommands() - { - m_loggerDir = new G4UIdirectory( std::string( "/log/" + m_logStream->getName() + "/" ).c_str() ); - m_loggerDir->SetGuidance( std::string( "Commands for the logger " + m_logStream->getName() ).c_str() ); - - m_setLevelCmd = new G4UIcmdWithAnInteger( std::string("/log/" + m_logStream->getName() + "/setLogLevel" ).c_str(), this ); - m_setLevelCmd->SetParameterName( "logLevel", false ); - std::string range = "logLevel >= 0 && logLevel < " + StringUtil::toString( LOG::nlevels ); - m_setLevelCmd->SetRange( range.c_str() ); - m_setLevelCmd->SetGuidance("Set the log level."); - - m_fileCmd = new G4UIcmdWithAString( std::string("/log/" + m_logStream->getName() + "/setLogFile" ).c_str(), this ); - m_fileCmd->SetParameterName( "file", false ); - m_fileCmd->SetGuidance("Set the output file for this logger."); - }
+namespace slic { +LogMessenger::LogMessenger(LogStream* logger) : + m_logStream(logger) { + defineCommands(); +} + +LogMessenger::~LogMessenger() { + ; +} + +void LogMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) { + if (cmd == m_setLevelCmd) { + m_logStream->setOutputLevel((LOG::ELevel) G4UIcmdWithAnInteger::GetNewIntValue(newVals)); + } else if (cmd == m_fileCmd) { + m_logStream->setOutputFile(newVals); + } +} + +void LogMessenger::defineCommands() { + m_loggerDir = new G4UIdirectory(std::string("/log/" + m_logStream->getName() + "/").c_str()); + m_loggerDir->SetGuidance(std::string("Commands for the logger " + m_logStream->getName()).c_str()); + + m_setLevelCmd = new G4UIcmdWithAnInteger( + std::string("/log/" + m_logStream->getName() + "/setLogLevel").c_str(), this); + m_setLevelCmd->SetParameterName("logLevel", false); + std::string range = "logLevel >= 0 && logLevel < " + StringUtil::toString(LOG::nlevels); + m_setLevelCmd->SetRange(range.c_str()); + m_setLevelCmd->SetGuidance("Set the log level."); + + m_fileCmd = new G4UIcmdWithAString(std::string("/log/" + m_logStream->getName() + "/setLogFile").c_str(), + this); + m_fileCmd->SetParameterName("file", false); + m_fileCmd->SetGuidance("Set the output file for this logger."); +}
}
diff -u -r1.7 -r1.8 --- Module.cc 11 Apr 2008 03:20:19 -0000 1.7 +++ Module.cc 27 Nov 2012 19:32:19 -0000 1.8 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/Module.cc,v 1.7 2008/04/11 03:20:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/Module.cc,v 1.8 2012/11/27 19:32:19 jeremy Exp $
#include "Module.hh" // lcdd
@@ -7,35 +7,30 @@
// slic #include "ModuleRegistry.hh"
-namespace slic -{ - Module::Module( const std::string& name, - bool deleteOnExit, - bool autoRegister ) - : m_deleteOnExit( deleteOnExit ) - { - m_name = name; - - // If requested, register the module with the ModuleRegistry. - if ( autoRegister ) { - ModuleRegistry::instance()->registerModule( this ); - } - - // Create a logger for this module. - m_log = LogManager::instance()->createLogWithMessenger( m_name, LOG::okay ); - - // Init message.
+namespace slic { +Module::Module(const std::string& name, bool deleteOnExit, bool autoRegister) : + m_deleteOnExit(deleteOnExit) { + m_name = name; + + // If requested, register the module with the ModuleRegistry. + if (autoRegister) { + ModuleRegistry::instance()->registerModule(this); + } + + // Create a logger for this module. + m_log = LogManager::instance()->createLogWithMessenger(m_name, LOG::okay); + + // Init message.
#ifdef SLIC_LOG
- log().verbose( "Initialized module <" + getName() + ">" );
+ log().verbose( "Initialized module <" + getName() + ">" );
#endif
- } - - Module::~Module() - {
+} + +Module::~Module() {
#ifdef SLIC_LOG
- log().verbose( getName() + " is being deleted." );
+ log().verbose( getName() + " is being deleted." );
#endif
- LogManager::instance()->removeLog( m_log ); - ModuleRegistry::instance()->deregisterModule( this ); - }
+ LogManager::instance()->removeLog(m_log); + ModuleRegistry::instance()->deregisterModule(this); +}
}
diff -u -r1.6 -r1.7 --- ModuleRegistry.cc 27 Apr 2007 01:54:35 -0000 1.6 +++ ModuleRegistry.cc 27 Nov 2012 19:32:19 -0000 1.7 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/ModuleRegistry.cc,v 1.6 2007/04/27 01:54:35 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/ModuleRegistry.cc,v 1.7 2012/11/27 19:32:19 jeremy Exp $
#include "ModuleRegistry.hh" // slic
@@ -7,72 +7,60 @@
// geant4 #include "globals.hh"
-namespace slic -{ - ModuleRegistry::ModuleRegistry() - : Module("ModuleRegistry",false,false) - {} - - ModuleRegistry::~ModuleRegistry() - {} - - Module* ModuleRegistry::findModule(const std::string& name) - { - return m_modules[ name ]; - } - - void ModuleRegistry::registerModule(Module* module) - { - if ( module == 0 ) { - log().warning("ModuleRegistry::registerModule - module points to null!"); - return; - } - - if ( m_modules[ module->getName() ] == 0 ) { - m_modules[ module->getName() ] = module; - } - else { - log().warning(module->getName() + " is already registered!"); - } - } - - void ModuleRegistry::deregisterModule(Module* module) - { - deregisterModule(module->getName()); - } - - void ModuleRegistry::deregisterModule(const std::string& name) - { - ModuleMap::iterator it = m_modules.find( name ); - - if ( it != m_modules.end() ) { - m_modules.erase( it ); - } - } - - void ModuleRegistry::print() - { - log() << LOG::always << LOG::endl; - log() << LOG::always << "********************" << LOG::endl; - log() << LOG::always << "* Module Registry *" << LOG::endl; - log() << LOG::always << "********************" << LOG::endl; - for ( ModuleMap::const_iterator it = m_modules.begin(); - it != m_modules.end(); - it++ ) { - log() << LOG::always << it->first << LOG::endl; - } - } - - void ModuleRegistry::deleteModules() - { - for (ModuleMap::iterator it = m_modules.begin(); - it != m_modules.end(); - it++) { - // Delete it as long as Module has not - // been flagged to not delete on exit. - if (it->second->deleteOnExit() ) { - delete it->second; - } - } - }
+namespace slic { +ModuleRegistry::ModuleRegistry() : + Module("ModuleRegistry", false, false) { +} + +ModuleRegistry::~ModuleRegistry() { +} + +Module* ModuleRegistry::findModule(const std::string& name) { + return m_modules[name]; +} + +void ModuleRegistry::registerModule(Module* module) { + if (module == 0) { + log().warning("ModuleRegistry::registerModule - module points to null!"); + return; + } + + if (m_modules[module->getName()] == 0) { + m_modules[module->getName()] = module; + } else { + log().warning(module->getName() + " is already registered!"); + } +} + +void ModuleRegistry::deregisterModule(Module* module) { + deregisterModule(module->getName()); +} + +void ModuleRegistry::deregisterModule(const std::string& name) { + ModuleMap::iterator it = m_modules.find(name); + + if (it != m_modules.end()) { + m_modules.erase(it); + } +} + +void ModuleRegistry::print() { + log() << LOG::always << LOG::endl; + log() << LOG::always << "********************" << LOG::endl; + log() << LOG::always << "* Module Registry *" << LOG::endl; + log() << LOG::always << "********************" << LOG::endl; + for (ModuleMap::const_iterator it = m_modules.begin(); it != m_modules.end(); it++) { + log() << LOG::always << it->first << LOG::endl; + } +} + +void ModuleRegistry::deleteModules() { + for (ModuleMap::iterator it = m_modules.begin(); it != m_modules.end(); it++) { + // Delete it as long as Module has not + // been flagged to not delete on exit. + if (it->second->deleteOnExit()) { + delete it->second; + } + } +}
}
diff -u -r1.5 -r1.6 --- ParticleGunEventSource.cc 8 Jan 2010 23:18:56 -0000 1.5 +++ ParticleGunEventSource.cc 27 Nov 2012 19:32:19 -0000 1.6 @@ -1,44 +1,38 @@
-// $Header: /cvs/lcd/slic/src/ParticleGunEventSource.cc,v 1.5 2010/01/08 23:18:56 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/ParticleGunEventSource.cc,v 1.6 2012/11/27 19:32:19 jeremy Exp $
#include "ParticleGunEventSource.hh" // geant4 #include "G4ParticleGun.hh"
-namespace slic -{
+namespace slic {
- ParticleGunEventSource::ParticleGunEventSource() - : EventSource( "ParticleGunEventSource" ) - { - m_generator = new G4ParticleGun(); - } - - ParticleGunEventSource::~ParticleGunEventSource() - { - delete m_generator; - } - - void ParticleGunEventSource::generate(G4Event* evt) - { - m_generator->GeneratePrimaryVertex(evt); - } - - void ParticleGunEventSource::dumpCurrentEvent() - { - log() << LOG::okay << "Dumping ParticleGun Event info..." << LOG::done; - - G4ParticleDefinition* pdef = m_generator->GetParticleDefinition(); - - log() << LOG::okay << "particle: " << pdef->GetParticleName() << LOG::done; - log() << LOG::okay << "time: " << m_generator->GetParticleTime () << LOG::done; - log() << LOG::okay << "pos: " << m_generator->GetParticlePosition () << LOG::done; - log() << LOG::okay << "mom: " << m_generator->GetParticleMomentumDirection() << LOG::done; - log() << LOG::okay << "E: " << m_generator->GetParticleEnergy() << LOG::done; - log() << LOG::okay << LOG::done; - } - - G4ParticleGun* ParticleGunEventSource::getParticleGun() - { - return m_generator; - }
+ParticleGunEventSource::ParticleGunEventSource() : + EventSource("ParticleGunEventSource") { + m_generator = new G4ParticleGun(); +} + +ParticleGunEventSource::~ParticleGunEventSource() { + delete m_generator; +} + +void ParticleGunEventSource::generate(G4Event* evt) { + m_generator->GeneratePrimaryVertex(evt); +} + +void ParticleGunEventSource::dumpCurrentEvent() { + log() << LOG::okay << "Dumping ParticleGun Event info..." << LOG::done; + + G4ParticleDefinition* pdef = m_generator->GetParticleDefinition(); + + log() << LOG::okay << "particle: " << pdef->GetParticleName() << LOG::done; + log() << LOG::okay << "time: " << m_generator->GetParticleTime() << LOG::done; + log() << LOG::okay << "pos: " << m_generator->GetParticlePosition() << LOG::done; + log() << LOG::okay << "mom: " << m_generator->GetParticleMomentumDirection() << LOG::done; + log() << LOG::okay << "E: " << m_generator->GetParticleEnergy() << LOG::done; + log() << LOG::okay << LOG::done; +} + +G4ParticleGun* ParticleGunEventSource::getParticleGun() { + return m_generator; +}
}
diff -u -r1.30 -r1.31 --- PhysicsListFactory.cc 31 Jan 2012 18:52:30 -0000 1.30 +++ PhysicsListFactory.cc 27 Nov 2012 19:32:19 -0000 1.31 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/PhysicsListFactory.cc,v 1.30 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PhysicsListFactory.cc,v 1.31 2012/11/27 19:32:19 jeremy Exp $
#include "PhysicsListFactory.hh" // Include generated list of Geant4 PhysLists.
@@ -17,80 +17,66 @@
*/ #define BUILDER(list,description) this->addBuilder( new TPhysicsListBuilder<list>( #list, description ) );
-namespace slic -{
+namespace slic {
- PhysicsListFactory::PhysicsListFactory() - : Module("PhysicsListFactory") - { - initializeBuilders(); - } - - PhysicsListFactory::~PhysicsListFactory() - { - for ( BuilderMap::const_iterator it = m_builders.begin(); - it != m_builders.end(); - it++ ) { - delete it->second; - } - m_builders.clear(); - } - - G4VUserPhysicsList* PhysicsListFactory::create( const std::string& name ) - { - log().okay("Creating physics list <" + name + ">."); - - G4VUserPhysicsList* physicslist = 0; - - VPhysicsListBuilder* builder = m_builders[ name ]; - - if ( builder != 0 ) { - physicslist = builder->create(); - } - else { - G4Exception("", "", FatalException, "No builder found for physics list."); - } - - return physicslist; - } - - void PhysicsListFactory::printAvailableLists() - { - log() << LOG::okay << LOG::done; - log() << LOG::okay << "----GEANT4 PHYSICS LISTS----" << LOG::endl << LOG::done; - log() << LOG::okay << "NAME DESCRIPTION" << LOG::done; - log() << LOG::okay << "----------------------------------------------------------------------" << LOG::done; - for ( BuilderMap::const_iterator it = m_builders.begin(); - it != m_builders.end(); - it++ ) - { - log().width(15); - log() << LOG::okay << left << it->first; - log() << LOG::okay << it->second->getDescription() << LOG::done; - } - } - - /** - * Initialize all supported builders. - * Based on lists from Geant4 9.2.p02. - */ - void PhysicsListFactory::initializeBuilders() - {
+PhysicsListFactory::PhysicsListFactory() : + Module("PhysicsListFactory") { + initializeBuilders(); +} + +PhysicsListFactory::~PhysicsListFactory() { + for (BuilderMap::const_iterator it = m_builders.begin(); it != m_builders.end(); it++) { + delete it->second; + } + m_builders.clear(); +} + +G4VUserPhysicsList* PhysicsListFactory::create(const std::string& name) { + log().okay("Creating physics list <" + name + ">."); + + G4VUserPhysicsList* physicslist = 0; + + VPhysicsListBuilder* builder = m_builders[name]; + + if (builder != 0) { + physicslist = builder->create(); + } else { + G4Exception("", "", FatalException, "No builder found for physics list."); + } + + return physicslist; +} + +void PhysicsListFactory::printAvailableLists() { + log() << LOG::okay << LOG::done; + log() << LOG::okay << "----GEANT4 PHYSICS LISTS----" << LOG::endl << LOG::done; + log() << LOG::okay << "NAME DESCRIPTION" << LOG::done; + log() << LOG::okay << "----------------------------------------------------------------------" + << LOG::done; + for (BuilderMap::const_iterator it = m_builders.begin(); it != m_builders.end(); it++) { + log().width(15); + log() << LOG::okay << left << it->first; + log() << LOG::okay << it->second->getDescription() << LOG::done; + } +} + +/** + * Initialize all supported builders. + * Based on lists from Geant4 9.2.p02. + */ +void PhysicsListFactory::initializeBuilders() {
// Include generated PhysList builders. #include "G4PhysicsBuilders.icc"
- }
+}
- void PhysicsListFactory::addBuilder(VPhysicsListBuilder* builder) - { - const G4String& name = builder->getName(); - - if ( m_builders.find( name ) != m_builders.end() ) - { - log() << LOG::warning << "Ignoring duplicate physics list builder for <" << name << "> ." << LOG::done; - } - else - { - m_builders[ name ] = builder; - } - }
+void PhysicsListFactory::addBuilder(VPhysicsListBuilder* builder) { + const G4String& name = builder->getName(); + + if (m_builders.find(name) != m_builders.end()) { + log() << LOG::warning << "Ignoring duplicate physics list builder for <" << name << "> ." + << LOG::done; + } else { + m_builders[name] = builder; + } +}
}
diff -u -r1.27 -r1.28 --- PhysicsListManager.cc 31 Jan 2012 18:52:30 -0000 1.27 +++ PhysicsListManager.cc 27 Nov 2012 19:32:19 -0000 1.28 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/PhysicsListManager.cc,v 1.27 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PhysicsListManager.cc,v 1.28 2012/11/27 19:32:19 jeremy Exp $
#include "PhysicsListManager.hh" // geant4
@@ -12,153 +12,124 @@
#include "LCOpticalPhysics.hh" #include "HepPDTManager.hh" #include "LCExtendedParticles.hh"
- -namespace slic -{ - // QGSP_BERT is the default physics list. - const std::string PhysicsListManager::m_defaultListName = std::string("QGSP_BERT"); - - PhysicsListManager::PhysicsListManager() - : Module("PhysicsListManager"), - m_currentList( 0 ), - m_isInitialized( false ), - m_isFromDefault( false ), - m_enableLimits( false ), - m_setupLimits( false ), - m_enableOptical( false ) - { - // Set the current list to the default. - m_currentListName = m_defaultListName; - - // Create the messenger class for the manager. - m_messenger = new PhysicsMessenger(); - - // Create the list factory. - m_factory = new G4PhysListFactory(); - } - - PhysicsListManager::~PhysicsListManager() - {} - - void PhysicsListManager::setCurrentListName(const std::string& n) - { - m_currentListName = n; - m_isFromDefault = false; - } - - void PhysicsListManager::initializePhysicsList() - { - if ( !m_isInitialized ) - {
+ +namespace slic { +// QGSP_BERT is the default physics list. +const std::string PhysicsListManager::m_defaultListName = std::string("QGSP_BERT"); + +PhysicsListManager::PhysicsListManager() : + Module("PhysicsListManager"), m_currentList(0), m_isInitialized(false), m_isFromDefault(false), m_enableLimits( + false), m_setupLimits(false), m_enableOptical(false) { + // Set the current list to the default. + m_currentListName = m_defaultListName; + + // Create the messenger class for the manager. + m_messenger = new PhysicsMessenger(); + + // Create the list factory. + m_factory = new G4PhysListFactory(); +} + +PhysicsListManager::~PhysicsListManager() { +} + +void PhysicsListManager::setCurrentListName(const std::string& n) { + m_currentListName = n; + m_isFromDefault = false; +} + +void PhysicsListManager::initializePhysicsList() { + if (!m_isInitialized) {
#ifdef SLIC_LOG
- if ( m_isFromDefault ) - { - log() << LOG::okay << "Using default physics list <" << m_defaultListName << ">." << LOG::done; - }
+ if ( m_isFromDefault ) + { + log() << LOG::okay << "Using default physics list <" << m_defaultListName << ">." << LOG::done; + }
#endif
- // Create the physics list from the name argument. - //m_currentList = PhysicsListFactory::instance()->create(m_currentListName); - m_currentList = m_factory->GetReferencePhysList(m_currentListName); - - // Enable optical processes. - if ( enableOptical() ) - { - setupOpticalProcesses(); - } - - // Support for extended set of particles from PDT. - setupExtended(); - - // Register the physics list with the run manager. - G4RunManager::GetRunManager()->SetUserInitialization(m_currentList); - - // Print out particle table. - //G4cout << "Dumping Geant4 particle table ..." << G4endl; - //G4ParticleTable::GetParticleTable()->DumpTable();
+ // Create the physics list from the name argument. + //m_currentList = PhysicsListFactory::instance()->create(m_currentListName); + m_currentList = m_factory->GetReferencePhysList(m_currentListName); + + // Enable optical processes. + if (enableOptical()) { + setupOpticalProcesses(); + } + + // Support for extended set of particles from PDT. + setupExtended(); + + // Register the physics list with the run manager. + G4RunManager::GetRunManager()->SetUserInitialization(m_currentList); + + // Print out particle table. + //G4cout << "Dumping Geant4 particle table ..." << G4endl; + //G4ParticleTable::GetParticleTable()->DumpTable();
- m_isInitialized = true; - }
+ m_isInitialized = true; + }
#ifdef SLIC_LOG
- // Don't allow initialization to be called more than once. - else - { - log().error("Ignoring additional call to PhysicsListManager::initializePhysics() !!!"); - }
+ // Don't allow initialization to be called more than once. + else + { + log().error("Ignoring additional call to PhysicsListManager::initializePhysics() !!!"); + }
#endif
- }
+} + +void PhysicsListManager::setupUserLimitsProcesses() { + G4ParticleTable* ptbl = G4ParticleTable::GetParticleTable(); + + G4ParticleTable::G4PTblDicIterator* piter = ptbl->GetIterator(); + + G4UserSpecialCuts* cuts = new G4UserSpecialCuts("UserSpecialCuts"); + G4StepLimiter* slim = new G4StepLimiter("StepLimiter");
- void PhysicsListManager::setupUserLimitsProcesses() - { - G4ParticleTable* ptbl = G4ParticleTable::GetParticleTable(); - - G4ParticleTable::G4PTblDicIterator* piter = ptbl->GetIterator(); - - G4UserSpecialCuts* cuts = new G4UserSpecialCuts("UserSpecialCuts"); - G4StepLimiter* slim = new G4StepLimiter("StepLimiter"); - - piter->reset(); - while ( (*piter)() ) - { - G4ParticleDefinition* pdef = piter->value(); - G4ProcessManager* pmgr = pdef->GetProcessManager(); - - // Add user limit processes for steps and special cuts. - if ( pmgr ) - { - pmgr->AddProcess( slim, - -1, - -1, - 3); - - pmgr->AddProcess( cuts, - -1, - -1, - 4); - } - else - { - G4Exception("", "", FatalException, "G4ProcessManager is null."); - } - } - }
+ piter->reset(); + while ((*piter)()) { + G4ParticleDefinition* pdef = piter->value(); + G4ProcessManager* pmgr = pdef->GetProcessManager(); + + // Add user limit processes for steps and special cuts. + if (pmgr) { + pmgr->AddProcess(slim, -1, -1, 3); + + pmgr->AddProcess(cuts, -1, -1, 4); + } else { + G4Exception("", "", FatalException, "G4ProcessManager is null."); + } + } +}
- void PhysicsListManager::setupOpticalProcesses() - {
+void PhysicsListManager::setupOpticalProcesses() {
#ifdef SLIC_LOG
- log() << LOG::always << "Enabling optical physics processes for the current physics list." << LOG::done;
+ log() << LOG::always << "Enabling optical physics processes for the current physics list." << LOG::done;
#endif
- G4VModularPhysicsList* l = dynamic_cast<G4VModularPhysicsList*>(m_currentList); - l->RegisterPhysics(new LCOpticalPhysics("optical")); - }
+ G4VModularPhysicsList* l = dynamic_cast<G4VModularPhysicsList*>(m_currentList); + l->RegisterPhysics(new LCOpticalPhysics("optical")); +}
- void PhysicsListManager::setupExtended() - {
+void PhysicsListManager::setupExtended() {
#ifdef SLIC_LOG
- log().always("Enabling extended PDT particles for the current physics list.");
+ log().always("Enabling extended PDT particles for the current physics list.");
#endif
- G4VModularPhysicsList* l = dynamic_cast<G4VModularPhysicsList*>(m_currentList); - if (HepPDTManager::instance()->getParticleDataTable()) - { - l->RegisterPhysics(new LCExtendedParticles()); - }
+ G4VModularPhysicsList* l = dynamic_cast<G4VModularPhysicsList*>(m_currentList); + if (HepPDTManager::instance()->getParticleDataTable()) { + l->RegisterPhysics(new LCExtendedParticles()); + }
#ifdef SLIC_LOG
- else - { - log() << LOG::error << "HepPDTManager could not load particle data, so extended particles will not be enabled!" << LOG::done; - }
+ else + { + log() << LOG::error << "HepPDTManager could not load particle data, so extended particles will not be enabled!" << LOG::done; + }
#endif
- }
+}
- void PhysicsListManager::printAvailablePhysicsLists() - { - const std::vector<G4String>& lists = m_factory->AvailablePhysLists(); - for (std::vector<G4String>::const_iterator it = lists.begin(); - it != lists.end(); - it++) - { - log().always(*it); - } - }
+void PhysicsListManager::printAvailablePhysicsLists() { + const std::vector<G4String>& lists = m_factory->AvailablePhysLists(); + for (std::vector<G4String>::const_iterator it = lists.begin(); it != lists.end(); it++) { + log().always(*it); + } +}
}
diff -u -r1.25 -r1.26 --- PhysicsMessenger.cc 8 Jan 2010 23:58:12 -0000 1.25 +++ PhysicsMessenger.cc 27 Nov 2012 19:32:19 -0000 1.26 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/PhysicsMessenger.cc,v 1.25 2010/01/08 23:58:12 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PhysicsMessenger.cc,v 1.26 2012/11/27 19:32:19 jeremy Exp $
#include "PhysicsMessenger.hh" // slic
@@ -13,95 +13,86 @@
#include "G4UIcmdWithoutParameter.hh" #include "G4UIdirectory.hh"
-namespace slic -{
+namespace slic {
- PhysicsMessenger::PhysicsMessenger() - : m_physicsListDir(0), - m_selectCmd(0) - { - defineCommands(); - } - - PhysicsMessenger::~PhysicsMessenger() - {} - - void PhysicsMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) - { - std::istringstream is ( ( const char* ) newVals ); - - std::string s; - is >> s; - - PhysicsListManager* mgr = PhysicsListManager::instance(); - - // set physics list - if ( cmd == m_selectCmd ) - { - mgr->setCurrentListName( s ); - } - // print available lists - else if ( cmd == m_printListsCmd ) - { - PhysicsListManager::instance()->printAvailablePhysicsLists(); - } - // Print current list and whether initialized. - else if ( cmd == m_printCurrentCmd ) - { - mgr->log() << LOG::okay << "Current physics list <" << mgr->getCurrentListName() << ">." << LOG::done; - mgr->log() << LOG::okay << "Physics has been initialized <" << mgr->isInitialized() << ">." << LOG::done; - } - // Enable optical physics processes. - else if ( cmd == m_enableOpticalCmd ) - { - bool enableOptical=true; - if (newVals != G4String("") ) - enableOptical = G4UIcmdWithABool::GetNewBoolValue(newVals); - PhysicsListManager::instance()->enableOptical(enableOptical); - } - // Set location of particle.tbl for HepPDT. - else if ( cmd == m_pdgCmd ) - { - HepPDTManager::instance()->setParticleDataFile( s ); - } - else { - mgr->log() << LOG::error << "Unknown command for PhysicsMessenger." << LOG::done; - } - } - - void PhysicsMessenger::defineCommands() - { - G4UIparameter* p; - - m_physicsListDir = new G4UIdirectory( "/physics/" ); - m_physicsListDir->SetGuidance( "Physics list commands. [SLIC]" ); - - // select physics list - m_selectCmd = new G4UIcommand("/physics/select", this ); - m_selectCmd->SetGuidance( "Select the Geant4 physics list. This command is only available in the PreInit state." ); - p = new G4UIparameter( "list", 's', false ); - m_selectCmd->SetParameter( p ); - m_selectCmd->AvailableForStates( G4State_PreInit ); - - // print available lists - m_printListsCmd = new G4UIcmdWithoutParameter("/physics/printLists", this ); - m_printListsCmd->SetGuidance( "Print available physics lists." ); - - // print current list - m_printCurrentCmd = new G4UIcmdWithoutParameter( "/physics/printCurrent", this ); - m_printCurrentCmd->SetGuidance( "Print name of currently selected physics list." ); - - // Enable optical physics processes for the current list when it is initialized. - m_enableOpticalCmd = new G4UIcmdWithABool("/physics/enableOptical", this); - m_enableOpticalCmd->SetGuidance("Enable optical physics processes."); - m_enableOpticalCmd->SetParameterName ("enable", 'b', true); - m_enableOpticalCmd->SetDefaultValue(true); - - // Set location of particle.tbl for supplementary particle data. - m_pdgCmd = new G4UIcommand("/physics/setPDGFile", this ); - m_pdgCmd->SetGuidance( "Set location of particle data for HepPDT, probably called particle.tbl." ); - p = new G4UIparameter( "file", 's', false ); - m_pdgCmd->SetParameter( p ); - m_pdgCmd->AvailableForStates( G4State_PreInit ); - }
+PhysicsMessenger::PhysicsMessenger() : + m_physicsListDir(0), m_selectCmd(0) { + defineCommands(); +} + +PhysicsMessenger::~PhysicsMessenger() { +} + +void PhysicsMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) { + std::istringstream is((const char*) newVals); + + std::string s; + is >> s; + + PhysicsListManager* mgr = PhysicsListManager::instance(); + + // set physics list + if (cmd == m_selectCmd) { + mgr->setCurrentListName(s); + } + // print available lists + else if (cmd == m_printListsCmd) { + PhysicsListManager::instance()->printAvailablePhysicsLists(); + } + // Print current list and whether initialized. + else if (cmd == m_printCurrentCmd) { + mgr->log() << LOG::okay << "Current physics list <" << mgr->getCurrentListName() << ">." << LOG::done; + mgr->log() << LOG::okay << "Physics has been initialized <" << mgr->isInitialized() << ">." + << LOG::done; + } + // Enable optical physics processes. + else if (cmd == m_enableOpticalCmd) { + bool enableOptical = true; + if (newVals != G4String("")) + enableOptical = G4UIcmdWithABool::GetNewBoolValue(newVals); + PhysicsListManager::instance()->enableOptical(enableOptical); + } + // Set location of particle.tbl for HepPDT. + else if (cmd == m_pdgCmd) { + HepPDTManager::instance()->setParticleDataFile(s); + } else { + mgr->log() << LOG::error << "Unknown command for PhysicsMessenger." << LOG::done; + } +} + +void PhysicsMessenger::defineCommands() { + G4UIparameter* p; + + m_physicsListDir = new G4UIdirectory("/physics/"); + m_physicsListDir->SetGuidance("Physics list commands. [SLIC]"); + + // select physics list + m_selectCmd = new G4UIcommand("/physics/select", this); + m_selectCmd->SetGuidance( + "Select the Geant4 physics list. This command is only available in the PreInit state."); + p = new G4UIparameter("list", 's', false); + m_selectCmd->SetParameter(p); + m_selectCmd->AvailableForStates(G4State_PreInit); + + // print available lists + m_printListsCmd = new G4UIcmdWithoutParameter("/physics/printLists", this); + m_printListsCmd->SetGuidance("Print available physics lists."); + + // print current list + m_printCurrentCmd = new G4UIcmdWithoutParameter("/physics/printCurrent", this); + m_printCurrentCmd->SetGuidance("Print name of currently selected physics list."); + + // Enable optical physics processes for the current list when it is initialized. + m_enableOpticalCmd = new G4UIcmdWithABool("/physics/enableOptical", this); + m_enableOpticalCmd->SetGuidance("Enable optical physics processes."); + m_enableOpticalCmd->SetParameterName("enable", 'b', true); + m_enableOpticalCmd->SetDefaultValue(true); + + // Set location of particle.tbl for supplementary particle data. + m_pdgCmd = new G4UIcommand("/physics/setPDGFile", this); + m_pdgCmd->SetGuidance("Set location of particle data for HepPDT, probably called particle.tbl."); + p = new G4UIparameter("file", 's', false); + m_pdgCmd->SetParameter(p); + m_pdgCmd->AvailableForStates(G4State_PreInit); +}
}
diff -u -r1.35 -r1.36 --- PrimaryGeneratorAction.cc 2 Aug 2012 23:05:38 -0000 1.35 +++ PrimaryGeneratorAction.cc 27 Nov 2012 19:32:19 -0000 1.36 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/PrimaryGeneratorAction.cc,v 1.35 2012/08/02 23:05:38 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PrimaryGeneratorAction.cc,v 1.36 2012/11/27 19:32:19 jeremy Exp $
#include "PrimaryGeneratorAction.hh"
@@ -21,174 +21,168 @@
#include "G4Types.hh" #include "G4StateManager.hh"
-namespace slic -{ - PrimaryGeneratorAction::PrimaryGeneratorAction() - : Module("PrimaryGeneratorAction", false) - {} - - PrimaryGeneratorAction::~PrimaryGeneratorAction() - {} - - void PrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent) - { - // Check if run needs to be aborted. - if (RunManager::instance()->isRunAborted()) { - G4RunManager::GetRunManager()->AbortRun(); - } - - EventSourceManager* mgr = EventSourceManager::instance(); - - // Beginning of event message that prints the event number. - // This should show up as the first line in the log messages for this event. - printBeginEventMessage(anEvent); - - // State of MCP manager needs to be reset for new event. - // FIXME: This is also called in LcioManager::reset() but not working for some reason! - LcioMcpManager::instance()->reset(); - - // Generator manager begin event hook. - mgr->beginEvent(anEvent); - - // Generate vertices using the manager. - mgr->GeneratePrimaryVertex(anEvent); - - // Apply Lorentz transformation to event, used for non-zero beam crossing angle. - applyLorentzTransformation(anEvent); - - // Apply Z smearing to event vertices. - zsmear(anEvent); - - // If source has no more events then abort the run. - if (mgr->isEOF()) { - SlicApplication::instance()->setAborting(true); - } - } - - void PrimaryGeneratorAction::printBeginEventMessage(G4Event* anEvent) - { - log() << LOG::okay << ">>>> BeginEvent <" << StringUtil::toString( anEvent->GetEventID() ) << ">" << LOG::done; - } - - void PrimaryGeneratorAction::applyLorentzTransformation(G4Event *evt) - { - const G4double alpha = EventSourceManager::instance()->getLorentzTransformationAngle(); - - if (alpha == 0) return; // nothing to do
+namespace slic { +PrimaryGeneratorAction::PrimaryGeneratorAction() : + Module("PrimaryGeneratorAction", false) { +} + +PrimaryGeneratorAction::~PrimaryGeneratorAction() { +} + +void PrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent) { + // Check if run needs to be aborted. + if (RunManager::instance()->isRunAborted()) { + G4RunManager::GetRunManager()->AbortRun(); + } + + EventSourceManager* mgr = EventSourceManager::instance(); + + // Beginning of event message that prints the event number. + // This should show up as the first line in the log messages for this event. + printBeginEventMessage(anEvent); + + // State of MCP manager needs to be reset for new event. + // FIXME: This is also called in LcioManager::reset() but not working for some reason! + LcioMcpManager::instance()->reset(); + + // Generator manager begin event hook. + mgr->beginEvent(anEvent); + + // Generate vertices using the manager. + mgr->GeneratePrimaryVertex(anEvent); + + // Apply Lorentz transformation to event, used for non-zero beam crossing angle. + applyLorentzTransformation(anEvent); + + // Apply Z smearing to event vertices. + zsmear(anEvent); + + // If source has no more events then abort the run. + if (mgr->isEOF()) { + SlicApplication::instance()->setAborting(true); + } +} + +void PrimaryGeneratorAction::printBeginEventMessage(G4Event* anEvent) { + log() << LOG::okay << ">>>> BeginEvent <" << StringUtil::toString(anEvent->GetEventID()) << ">" + << LOG::done; +} + +void PrimaryGeneratorAction::applyLorentzTransformation(G4Event *evt) { + const G4double alpha = EventSourceManager::instance()->getLorentzTransformationAngle(); + + if (alpha == 0) + return; // nothing to do
//#ifdef SLIC_LOG // log() << LOG::always << "applying Lorentz Transformation angle <" << alpha << LOG::done; //#endif
- // parameters of the Lorentz transformation matrix - const G4double gamma = sqrt(1 + sqr(tan(alpha))); - const G4double betagamma = tan(alpha); - - // scan through all vertices and all valid primary particles - for (int iVertex = 0; iVertex < evt->GetNumberOfPrimaryVertex(); iVertex++) - { - G4PrimaryVertex *vertex = evt->GetPrimaryVertex(iVertex); - for (int iParticle = 0; iParticle < vertex->GetNumberOfParticle(); iParticle++) - { - G4PrimaryParticle *particle = vertex->GetPrimary(iParticle); - // does the particle have a valid particle definition attached? - if (particle->GetG4code()) - { - // before the transformation - const G4double px = particle->GetPx(); - const G4double py = particle->GetPy(); - const G4double pz = particle->GetPz(); - - //FG: take generator mass ( not necessarily euqal to PDG mass ) - const G4double m = particle->GetMass() ; - - // after the transformation (boost in x-direction) - const G4double pxPrime = betagamma * sqrt(sqr(px) + sqr(py) + sqr(pz) + sqr(m)) + gamma * px; - - // py and pz remain the same, E changes implicitly with px - particle->SetMomentum(pxPrime, py, pz); - } - } - // the position of the vertex is not transformed here - } - - EVENT::LCCollection* col = LcioMcpManager::instance()->getInitialMcpCollection(); - - if( col !=0 ) - { // if particle gun is used no collection exists ... - - int nMCP = col->getNumberOfElements() ; - - for(int i=0; i < nMCP ; ++i ) - { - - IMPL::MCParticleImpl* mcp = dynamic_cast<IMPL::MCParticleImpl*>( col->getElementAt(i) ) ; - - const double* p = mcp->getMomentum() ; - - // before the transformation - double pPrime[3] ; - - const G4double m = mcp->getMass() ; - - // after the transformation (boost in x-direction) - pPrime[0] = betagamma * sqrt(sqr(p[0] ) + sqr(p[1] ) + sqr( p[2]) + sqr(m) ) + gamma * p[0] ; - - pPrime[1] = p[1] ; - pPrime[2] = p[2] ; - - // py and pz remain the same, E changes implicitly with px - mcp->setMomentum( pPrime ); - } - } - } - - /** - * Apply a Z smear to the position of every G4PrimaryVertex in an event. - */ - void PrimaryGeneratorAction::zsmear(G4Event* anEvent) { - - //G4cout << "zsmear" << G4endl; - - G4double zParam = EventSourceManager::instance()->getZSmearing(); - - //G4cout << "got zParam = " << zParam << G4endl; - - if (zParam == 0) return; - - // Generate smeared Z position. - double zspread = (zParam == 0.0 ? 0.0 : G4RandGauss::shoot(0, zParam/mm)); - - //G4cout << "zspread = " << zspread << G4endl; - - // Apply Z smearing to Geant4 event. - int nVertices = anEvent->GetNumberOfPrimaryVertex(); - //G4cout << "nVertices = " << nVertices << G4endl; - for (int iVertex = 0; iVertex < nVertices; iVertex++) { - G4PrimaryVertex* vertex = anEvent->GetPrimaryVertex(iVertex); - //G4cout << "G4.preZSmear = " << vertex->GetZ0() << G4endl; - vertex->SetPosition(vertex->GetX0(), vertex->GetY0(), vertex->GetZ0() + zspread); - //G4cout << "G4.postZSmear = " << vertex->GetZ0() << G4endl; - } - - // Apply Z smearing to MCParticle collection. - EVENT::LCCollection* mcpColl = LcioMcpManager::instance()->getInitialMcpCollection(); - if (mcpColl != 0) { - int nMCP = mcpColl->getNumberOfElements(); - //G4cout << "nMCP = " << nMCP << G4endl; - for (int i=0; i<nMCP; ++i) { - IMPL::MCParticleImpl* mcp = dynamic_cast<IMPL::MCParticleImpl*>(mcpColl->getElementAt(i)); - if (zParam != 0) { - const double* v = mcp->getVertex(); - double vPrime[3]; - vPrime[0] = v[0]; - vPrime[1] = v[1]; - vPrime[2] = v[2] + zspread; - //G4cout << "MCP.preZSmear = " << mcp->getVertex()[2] << G4endl; - mcp->setVertex(vPrime); - //G4cout << "MCP.postZSmear = " << mcp->getVertex()[2] << G4endl; - } - } - } - }
+ // parameters of the Lorentz transformation matrix + const G4double gamma = sqrt(1 + sqr(tan(alpha))); + const G4double betagamma = tan(alpha); + + // scan through all vertices and all valid primary particles + for (int iVertex = 0; iVertex < evt->GetNumberOfPrimaryVertex(); iVertex++) { + G4PrimaryVertex *vertex = evt->GetPrimaryVertex(iVertex); + for (int iParticle = 0; iParticle < vertex->GetNumberOfParticle(); iParticle++) { + G4PrimaryParticle *particle = vertex->GetPrimary(iParticle); + // does the particle have a valid particle definition attached? + if (particle->GetG4code()) { + // before the transformation + const G4double px = particle->GetPx(); + const G4double py = particle->GetPy(); + const G4double pz = particle->GetPz(); + + //FG: take generator mass ( not necessarily euqal to PDG mass ) + const G4double m = particle->GetMass(); + + // after the transformation (boost in x-direction) + const G4double pxPrime = betagamma * sqrt(sqr(px) + sqr(py) + sqr(pz) + sqr(m)) + gamma * px; + + // py and pz remain the same, E changes implicitly with px + particle->SetMomentum(pxPrime, py, pz); + } + } + // the position of the vertex is not transformed here + } + + EVENT::LCCollection* col = LcioMcpManager::instance()->getInitialMcpCollection(); + + if (col != 0) { // if particle gun is used no collection exists ... + + int nMCP = col->getNumberOfElements(); + + for (int i = 0; i < nMCP; ++i) { + + IMPL::MCParticleImpl* mcp = dynamic_cast<IMPL::MCParticleImpl*>(col->getElementAt(i)); + + const double* p = mcp->getMomentum(); + + // before the transformation + double pPrime[3]; + + const G4double m = mcp->getMass(); + + // after the transformation (boost in x-direction) + pPrime[0] = betagamma * sqrt(sqr(p[0]) + sqr(p[1]) + sqr(p[2]) + sqr(m)) + gamma * p[0]; + + pPrime[1] = p[1]; + pPrime[2] = p[2]; + + // py and pz remain the same, E changes implicitly with px + mcp->setMomentum(pPrime); + } + } +} + +/** + * Apply a Z smear to the position of every G4PrimaryVertex in an event. + */ +void PrimaryGeneratorAction::zsmear(G4Event* anEvent) { + + //G4cout << "zsmear" << G4endl; + + G4double zParam = EventSourceManager::instance()->getZSmearing(); + + //G4cout << "got zParam = " << zParam << G4endl; + + if (zParam == 0) + return; + + // Generate smeared Z position. + double zspread = (zParam == 0.0 ? 0.0 : G4RandGauss::shoot(0, zParam/mm)); + + //G4cout << "zspread = " << zspread << G4endl; + + // Apply Z smearing to Geant4 event. + int nVertices = anEvent->GetNumberOfPrimaryVertex(); + //G4cout << "nVertices = " << nVertices << G4endl; + for (int iVertex = 0; iVertex < nVertices; iVertex++) { + G4PrimaryVertex* vertex = anEvent->GetPrimaryVertex(iVertex); + //G4cout << "G4.preZSmear = " << vertex->GetZ0() << G4endl; + vertex->SetPosition(vertex->GetX0(), vertex->GetY0(), vertex->GetZ0() + zspread); + //G4cout << "G4.postZSmear = " << vertex->GetZ0() << G4endl; + } + + // Apply Z smearing to MCParticle collection. + EVENT::LCCollection* mcpColl = LcioMcpManager::instance()->getInitialMcpCollection(); + if (mcpColl != 0) { + int nMCP = mcpColl->getNumberOfElements(); + //G4cout << "nMCP = " << nMCP << G4endl; + for (int i = 0; i < nMCP; ++i) { + IMPL::MCParticleImpl* mcp = dynamic_cast<IMPL::MCParticleImpl*>(mcpColl->getElementAt(i)); + if (zParam != 0) { + const double* v = mcp->getVertex(); + double vPrime[3]; + vPrime[0] = v[0]; + vPrime[1] = v[1]; + vPrime[2] = v[2] + zspread; + //G4cout << "MCP.preZSmear = " << mcp->getVertex()[2] << G4endl; + mcp->setVertex(vPrime); + //G4cout << "MCP.postZSmear = " << mcp->getVertex()[2] << G4endl; + } + } + } +}
}
diff -u -r1.21 -r1.22 --- RunAction.cc 13 Jul 2012 20:09:02 -0000 1.21 +++ RunAction.cc 27 Nov 2012 19:32:19 -0000 1.22 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/RunAction.cc,v 1.21 2012/07/13 20:09:02 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/RunAction.cc,v 1.22 2012/11/27 19:32:19 jeremy Exp $
// slic #include "LcioManager.hh"
@@ -12,82 +12,75 @@
#include "RunAction.hh" #include "G4Run.hh"
-namespace slic -{
+namespace slic {
- RunAction::RunAction() - : Module("RunAction", false) - {} - - RunAction::~RunAction() - {} - - void RunAction::BeginOfRunAction (const G4Run *aRun) - { - // Start the run clock. - startRunTimer();
+RunAction::RunAction() : + Module("RunAction", false) { +} + +RunAction::~RunAction() { +}
- // Print the run start message.
+void RunAction::BeginOfRunAction(const G4Run *aRun) { + // Start the run clock. + startRunTimer(); + + // Print the run start message.
#ifdef SLIC_LOG
- printBeginOfRunMessage( aRun );
+ printBeginOfRunMessage( aRun );
#endif
- // Execute LcioManager's beginRun action. - LcioManager::instance()->beginRun( aRun );
+ // Execute LcioManager's beginRun action. + LcioManager::instance()->beginRun(aRun);
- // Execute EventSourceManager's beginRun action - EventSourceManager::instance()->beginRun( aRun );
+ // Execute EventSourceManager's beginRun action + EventSourceManager::instance()->beginRun(aRun);
- // Execute GeometryManager's beginRun action. - GeometryManager::instance()->beginRun( aRun );
+ // Execute GeometryManager's beginRun action. + GeometryManager::instance()->beginRun(aRun);
- // Execute EventDebugger's beginRun action. - //EventDebugger::instance()->beginRun( aRun ); - }
+ // Execute EventDebugger's beginRun action. + //EventDebugger::instance()->beginRun( aRun ); +}
- void RunAction::EndOfRunAction (const G4Run *run) - { - // LcioManager's action - LcioManager::instance()->endRun( run );
+void RunAction::EndOfRunAction(const G4Run *run) { + // LcioManager's action + LcioManager::instance()->endRun(run);
- // event source mgr - EventSourceManager::instance()->endRun( run );
+ // event source mgr + EventSourceManager::instance()->endRun(run);
- // stop run clock - stopRunTimer();
+ // stop run clock + stopRunTimer();
- // end message
+ // end message
#ifdef SLIC_LOG
- printEndOfRunMessage( run );
+ printEndOfRunMessage( run );
#endif
- }
+}
- void RunAction::startRunTimer() - { - // start run timer - m_runTimer.Start();
+void RunAction::startRunTimer() { + // start run timer + m_runTimer.Start();
#ifdef SLIC_LOG
- log() << LOG::okay << "Started Run Timer." << LOG::done;
+ log() << LOG::okay << "Started Run Timer." << LOG::done;
#endif
- }
+}
- void RunAction::stopRunTimer() - { - // stop run timer - m_runTimer.Stop();
+void RunAction::stopRunTimer() { + // stop run timer + m_runTimer.Stop();
#ifdef SLIC_LOG
- log() << LOG::okay << "Run Timer: " << m_runTimer << LOG::done;
+ log() << LOG::okay << "Run Timer: " << m_runTimer << LOG::done;
#endif
- }
+}
- void RunAction::printBeginOfRunMessage( const G4Run* aRun ) - { - log() << LOG::okay << ">>>> BeginRun <" << aRun->GetRunID() << ">" << LOG::done; - } - - void RunAction::printEndOfRunMessage( const G4Run* aRun ) - { - log() << LOG::okay << ">>>> EndRun <" << aRun->GetRunID() << ">" << LOG::done; - }
+void RunAction::printBeginOfRunMessage(const G4Run* aRun) { + log() << LOG::okay << ">>>> BeginRun <" << aRun->GetRunID() << ">" << LOG::done; +} + +void RunAction::printEndOfRunMessage(const G4Run* aRun) { + log() << LOG::okay << ">>>> EndRun <" << aRun->GetRunID() << ">" << LOG::done; +}
}
diff -u -r1.19 -r1.20 --- RunManager.cc 2 Aug 2012 23:05:38 -0000 1.19 +++ RunManager.cc 27 Nov 2012 19:32:19 -0000 1.20 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/RunManager.cc,v 1.19 2012/08/02 23:05:38 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/RunManager.cc,v 1.20 2012/11/27 19:32:19 jeremy Exp $
#include "RunManager.hh" // lcdd
@@ -12,6 +12,7 @@
#include "PhysicsListManager.hh" #include "PrimaryGeneratorAction.hh" #include "RunAction.hh"
+#include "SlicApplication.hh"
#include "SteppingAction.hh" #include "TrackingAction.hh"
@@ -19,97 +20,116 @@
#include "G4StateManager.hh" #include "G4UImanager.hh"
-namespace slic -{
+namespace slic {
- RunManager::RunManager() : - Module("RunManager", false), - m_userActionsInitialized(false) { - } - - RunManager::~RunManager() { - } - - void RunManager::initializeUserActions() { - SetUserAction(new PrimaryGeneratorAction); - SetUserAction(new RunAction); - SetUserAction(new EventAction); - SetUserAction(new TrackingAction); - SetUserAction(new SteppingAction); - m_userActionsInitialized = true; - } - - void RunManager::Initialize() { - // This makes sure that physics initialization occurs before other user actions. - G4RunManager::Initialize(); - - // Initialize user actions here to avoid ordering problems. - if (!m_userActionsInitialized) - initializeUserActions();
+RunManager::RunManager() : + Module("RunManager", false), m_userActionsInitialized(false), m_abortRun(false) { +} + +RunManager::~RunManager() { +} + +void RunManager::initializeUserActions() { + SetUserAction(new PrimaryGeneratorAction); + SetUserAction(new RunAction); + SetUserAction(new EventAction); + SetUserAction(new TrackingAction); + SetUserAction(new SteppingAction); + m_userActionsInitialized = true; +} + +void RunManager::Initialize() { + // This makes sure that physics initialization occurs before other user actions. + G4RunManager::Initialize();
- // Initialize the event generation manager. - EventSourceManager::instance();
+ // Initialize user actions here to avoid ordering problems. + if (!m_userActionsInitialized) + initializeUserActions();
- // Setup the default event source. - EventSourceManager::instance()->setupEventSource();
+ // Initialize the event generation manager. + EventSourceManager::instance();
- // Print list of registered modules.
+ // Setup the default event source. + EventSourceManager::instance()->setupEventSource(); + + // Print list of registered modules.
#ifdef SLIC_LOG
- ModuleRegistry::instance()->print();
+ ModuleRegistry::instance()->print();
#endif
- }
+} + +void RunManager::InitializePhysics() { + // Initialize the physics list. + PhysicsListManager::instance()->initializePhysicsList(); + + // Call the G4RunManager's intitialization method. + G4RunManager::InitializePhysics(); + + // Check if the LCDD subsystem got some limits. + LCDDProcessor* lcdd = LCDDProcessor::instance(); + PhysicsListManager* pmgr = PhysicsListManager::instance(); + if (lcdd->getLimitSetsBegin() != lcdd->getLimitSetsEnd()) { + pmgr->enableLimits(true); + } + + // Enable physics limits, if necessary. + if (pmgr->enableLimits()) { + pmgr->setupUserLimitsProcesses(); + } +} + +void RunManager::InitializeGeometry() { + if (!LCDDParser::instance()->isValidSetup()) { + G4Exception("", "", FatalException, "Current LCDD geometry setup is not valid."); + } + + G4RunManager::InitializeGeometry(); +} + +void RunManager::BeamOn(G4int n_event, const char* macroFile, G4int n_select) { + + // Reset abort run flag. + m_abortRun = false; + + // Attempt to initialize Geant4 if not in idle state. + if (G4StateManager::GetStateManager()->GetCurrentState() != G4State_Idle) { + this->Initialize(); + } + + // Run events. + m_numberOfEventsToRun = n_event; + G4RunManager::BeamOn(n_event, macroFile, n_select); + + // Print number of events generated. + EventSourceManager* eventManager = EventSourceManager::instance(); + eventManager->printNumEventsGenerated(); + + // Check if event underflow occurred where number of events provided was less than requested. + int nEventsGenerated = eventManager->getNumEventsGenerated(); + if (nEventsGenerated < m_numberOfEventsToRun) { + log() << LOG::error << LOG::head << "Generated " << nEventsGenerated << " events but " << n_event + << " were requested." << LOG::done; + SlicApplication::instance()->setReturnCode(SlicApplication::EVENT_UNDERFLOW); + } +} + +void RunManager::DoEventLoop(G4int n_event, const char* macroFile, G4int n_select) { + // The event loop is only called if the run is not already aborted, + // e.g. in the setup of some manager or event action class called before here. + if (!m_abortRun) { + log() << LOG::okay << LOG::head << "Generating " << n_event << " events." << LOG::done; + G4RunManager::DoEventLoop(n_event, macroFile, n_select); + } else { + log() << LOG::warning << LOG::head << "Run was aborted before G4 event loop was executed." + << LOG::done; + } +} + +int RunManager::getNumberOfEventsToRun() { + return m_numberOfEventsToRun; +}
- void RunManager::InitializePhysics() { - // Initialize the physics list. - PhysicsListManager::instance()->initializePhysicsList(); - - // Call the G4RunManager's intitialization method. - G4RunManager::InitializePhysics(); - - // Check if the LCDD subsystem got some limits. - LCDDProcessor* lcdd = LCDDProcessor::instance(); - PhysicsListManager* pmgr = PhysicsListManager::instance(); - if ( lcdd->getLimitSetsBegin() != lcdd->getLimitSetsEnd() ) - { - pmgr->enableLimits(true); - } - - // Enable physics limits, if necessary. - if ( pmgr->enableLimits() ) - { - pmgr->setupUserLimitsProcesses(); - } - } - - void RunManager::InitializeGeometry() { - if ( !LCDDParser::instance()->isValidSetup() ) - { - G4Exception("", "", FatalException, "Current LCDD geometry setup is not valid."); - } - - G4RunManager::InitializeGeometry(); - } - - void RunManager::BeamOn(G4int n_event, const char* macroFile, G4int n_select) { - - // Reset abort run flag. - m_abortRun = false; - - // Attempt to initialize Geant4 if not in idle state. - if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_Idle ) { - this->Initialize(); - } - - m_numberOfEventsToRun = n_event; - - G4RunManager::BeamOn(n_event, macroFile, n_select); - } - - int RunManager::getNumberOfEventsToRun() { - return m_numberOfEventsToRun; - } - - bool RunManager::isRunAborted() { - return m_abortRun; - }
+bool RunManager::isRunAborted() { + return m_abortRun;
}
+} // namespace slic
diff -u -r1.56 -r1.57 --- SlicApplication.cc 26 Sep 2011 20:46:49 -0000 1.56 +++ SlicApplication.cc 27 Nov 2012 19:32:19 -0000 1.57 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/SlicApplication.cc,v 1.56 2011/09/26 20:46:49 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/SlicApplication.cc,v 1.57 2012/11/27 19:32:19 jeremy Exp $
#include "SlicApplication.hh"
@@ -24,300 +24,256 @@
// lcdd #include "LCDDDetectorConstruction.hh"
-// Geant4
+// geant4
#include "G4ApplicationState.hh" #include "G4ScoringManager.hh" #include "G4StateManager.hh"
-// Geant4 visualization
+// geant4 visualization
#ifdef G4VIS_USE #include "G4VisExecutive.hh"
+//#include "G4BlineTracer.hh"
#endif
-//#ifndef G4UI_NONE -//#include "G4UImanager.hh" -//#include "G4UIterminal.hh" -//#include "G4UItcsh.hh" -//#include "G4UIcsh.hh"
+// geant4 UI
#include "G4UIExecutive.hh"
-//#ifdef G4UI_USE_XM -//#include "G4UIXm.hh" -//#endif - -//#ifdef G4UI_USE_GAG -//#include "G4UIGAG.hh" -//#endif -//#endif // G4UI_NONE -
#ifdef HAVE_G4VERSION #include "G4Version.hh" #endif #include "PhysicsListManager.hh"
-namespace slic -{
+namespace slic {
- SlicApplication::SlicApplication() - : Module("SlicApplication", false), - m_appMessenger(0), - m_runManager(0), - m_mode(SlicApplication::eBatch), - m_returnCode(0), - m_setRunAbort(false), - m_isInitialized(false), - m_geant4VersionString(0) - {
+SlicApplication::SlicApplication() : + Module("SlicApplication", false), m_appMessenger(0), m_runManager(0), m_mode(SlicApplication::eBatch), m_returnCode( + 0), m_setRunAbort(false), m_isInitialized(false), m_geant4VersionString(0) {
#ifdef SLIC_LOG
- log() << LOG::okay << LOG::head << "SLIC is starting." << LOG::done;
+ log() << LOG::okay << LOG::head << "SLIC is starting." << LOG::done;
#endif
- }
+}
- SlicApplication::~SlicApplication() - { - if (m_appMessenger != 0) - { - delete m_appMessenger; - }
+SlicApplication::~SlicApplication() { + if (m_appMessenger != 0) { + delete m_appMessenger; + }
- // Delete all the modules. Only seems to work without seg fault on Linux. - // https://jira.slac.stanford.edu/browse/SLIC-185
+ // Delete all the modules. Only seems to work without seg fault on Linux. + // https://jira.slac.stanford.edu/browse/SLIC-185
#ifdef linux #ifdef SLIC_LOG
- log().debug("Deleting registered modules ...");
+ log().debug("Deleting registered modules ...");
#endif
- ModuleRegistry::instance()->deleteModules();
+ ModuleRegistry::instance()->deleteModules();
#endif
- // Delete the G4RunManager, which also deletes all the Geant4-related modules.
+ // Delete the G4RunManager, which also deletes all the Geant4-related modules.
#ifdef SLIC_LOG
- log().debug("Deleting G4RunManager ...");
+ log().debug("Deleting G4RunManager ...");
#endif
- delete G4RunManager::GetRunManager();
+ delete G4RunManager::GetRunManager();
#ifdef SLIC_LOG
- log() << LOG::okay << LOG::head << "SLIC is exiting." << LOG::done;
+ log() << LOG::okay << LOG::head << "SLIC is exiting." << LOG::done;
#endif
- }
+}
- void SlicApplication::initialize(int argc, char** argv) - { - // Set the name and basename of slic's binary from the command line arguments. - m_binaryname = std::string(argv[0]); - setBinaryBasename(); - - // Process arguments using the CommandLineProcessor. - CommandLineProcessor* cmd = CommandLineProcessor::instance(); - cmd->process(argc, argv);
+void SlicApplication::initialize(int argc, char** argv) { + // Set the name and basename of slic's binary from the command line arguments. + m_binaryname = std::string(argv[0]); + setBinaryBasename(); + + // Process arguments using the CommandLineProcessor. + CommandLineProcessor* cmd = CommandLineProcessor::instance(); + cmd->process(argc, argv);
#ifdef G4UI_USE
- m_ui = new G4UIExecutive(argc, argv);
+ m_ui = new G4UIExecutive(argc, argv);
#endif
- }
+}
- void SlicApplication::initialize() - { - if (!m_isInitialized) - { - // Print the SLIC splash screen. - printSplashScreen();
+void SlicApplication::initialize() { + if (!m_isInitialized) { + // Print the SLIC splash screen. + printSplashScreen();
- // Initialize the application messenger. - m_appMessenger = new SlicApplicationMessenger(this);
+ // Initialize the application messenger. + m_appMessenger = new SlicApplicationMessenger(this);
- // Create a new RunManager. - m_runManager = new RunManager();
+ // Create a new RunManager. + m_runManager = new RunManager();
- // Activate command-based scorer. - G4ScoringManager::GetScoringManager();
+ // Activate command-based scorer. + G4ScoringManager::GetScoringManager();
- // Initialize the physics list manager. - PhysicsListManager::instance();
+ // Initialize the physics list manager. + PhysicsListManager::instance();
- // Initialize the LcioManager. - LcioManager::instance();
+ // Initialize the LcioManager. + LcioManager::instance();
- // Initialize the magnetic field messenger. - FieldManager::instance(); - - // Setup the LCDD subsystem. - initializeLCDD();
+ // Initialize the magnetic field messenger. + FieldManager::instance();
- // Initialize visualization.
+ // Setup the LCDD subsystem. + initializeLCDD(); + + // Initialize visualization.
#ifdef G4VIS_USE
- initializeVis();
+ initializeVis();
#endif
- HepPDTManager::instance();
+ HepPDTManager::instance();
- // Set state variable. - m_isInitialized = true; - } - else - { - log().warning("Call to SlicApplication::initialize() was ignored. SLIC is already initialized!"); - } - }
+ // Set state variable. + m_isInitialized = true; + } else { + log().warning("Call to SlicApplication::initialize() was ignored. SLIC is already initialized!"); + } +}
#ifdef G4VIS_USE
- void SlicApplication::initializeVis() - { - G4VisExecutive* vis = new G4VisExecutive(); - vis->Initialize(); - - // VRML writer within SLIC. - new VRML2WriterMessenger(); - } -#endif - - void SlicApplication::initializeLCDD() - { - // LCDD geometry subsystem. - m_runManager->SetUserInitialization((new LCDD())->getDetectorConstruction()); - } - - void SlicApplication::setMode(SlicApplication::ERunMode rmode) - { - m_mode = rmode; - } - - const std::string& SlicApplication::getBinaryName() const - { - return m_binaryname; - } - - const std::string& SlicApplication::getBinaryBasename() const - { - return m_binarybasename; - } - - int SlicApplication::getReturnCode() const - { - return m_returnCode; - } - - void SlicApplication::setReturnCode(int rc) - { - m_returnCode = rc; - } - - void SlicApplication::setBinaryBasename() - { - std::string::size_type sidx = m_binaryname.find_last_of('/'); - if (sidx != std::string::npos) - { - m_binarybasename = std::string(m_binaryname, sidx + 1); - } - } - - SlicApplication::ERunMode SlicApplication::getMode() const - { - return m_mode; - } - - void SlicApplication::setAborting(bool a) - { - if (a) - { - // FIXME: Does this actually do anything to current G4Event? - G4RunManager::GetRunManager()->AbortRun(a); - } - - m_setRunAbort = a; - } - - bool SlicApplication::isAborting() const - { - return m_setRunAbort; - } - - RunManager* SlicApplication::getRunManager() - { - return m_runManager; - } - - void SlicApplication::run() - { - // Initialize if not already. - if (!m_isInitialized) - { - initialize(); - }
+void SlicApplication::initializeVis() +{ + G4VisExecutive* vis = new G4VisExecutive(); + vis->Initialize();
- // Retrieve the list of Geant4 commands created by CommandLineProcessor. - CommandQueue* q = CommandLineProcessor::instance()->getCommandQueue();
+ // VRML writer within SLIC. + new VRML2WriterMessenger();
- // Print, execute, and clear the CommandQueue.
+ // B-field visualization. + //new G4BlineTracer(); +} +#endif + +void SlicApplication::initializeLCDD() { + // LCDD geometry subsystem. + m_runManager->SetUserInitialization((new LCDD())->getDetectorConstruction()); +} + +void SlicApplication::setMode(SlicApplication::ERunMode rmode) { + m_mode = rmode; +} + +const std::string& SlicApplication::getBinaryName() const { + return m_binaryname; +} + +const std::string& SlicApplication::getBinaryBasename() const { + return m_binarybasename; +} + +int SlicApplication::getReturnCode() const { + return m_returnCode; +} + +void SlicApplication::setReturnCode(int rc) { + m_returnCode = rc; +} + +void SlicApplication::setBinaryBasename() { + std::string::size_type sidx = m_binaryname.find_last_of('/'); + if (sidx != std::string::npos) { + m_binarybasename = std::string(m_binaryname, sidx + 1); + } +} + +SlicApplication::ERunMode SlicApplication::getMode() const { + return m_mode; +} + +void SlicApplication::setAborting(bool a) { + if (a) { + // FIXME: Does this actually do anything to current G4Event? + G4RunManager::GetRunManager()->AbortRun(a); + } + + m_setRunAbort = a; +} + +bool SlicApplication::isAborting() const { + return m_setRunAbort; +} + +RunManager* SlicApplication::getRunManager() { + return m_runManager; +} + +void SlicApplication::run() { + // Initialize if not already. + if (!m_isInitialized) { + initialize(); + } + + // Retrieve the list of Geant4 commands created by CommandLineProcessor. + CommandQueue* q = CommandLineProcessor::instance()->getCommandQueue(); + + // Print, execute, and clear the CommandQueue.
#ifdef SLIC_LOG
- log().verbose("Printing the Geant4 command queue ..."); - q->printOut();
+ log().verbose("Printing the Geant4 command queue ..."); + q->printOut();
#endif
- q->execute(); - q->clear(); - - // Start the UI session if in interactive mode.
+ q->execute(); + q->clear(); + + // Start the UI session if in interactive mode.
#ifndef G4UI_NONE
- if ( getMode() == eInteractive ) - { - log().verbose("Starting interactive session ..."); - m_ui->SessionStart(); - delete m_ui; - }
+ if (getMode() == eInteractive) { + log().verbose("Starting interactive session ..."); + m_ui->SessionStart(); + delete m_ui; + }
#endif
- }
+}
- void SlicApplication::printVersion() - { - CommandLineProcessor::instance()->printVersion(); - } - - void SlicApplication::printSplashScreen() - { - log() << LOG::done; - log() << LOG::always << "*************************************************************" << LOG::done; - log() << LOG::always << " App : " << PackageInfo::getNameString() << " (" << PackageInfo::getAbbrevString() << ")" << LOG::done; - log() << LOG::always << " Version : " << PackageInfo::getVersionString() << LOG::done; - log() << LOG::always << " Date : " << PackageInfo::getChangeDateString() << LOG::done; - log() << LOG::always << " Authors : " << PackageInfo::getAuthorString() << LOG::done; - log() << LOG::always << " Inst : " << PackageInfo::getInstitutionString() << LOG::done; - log() << LOG::always << " WWW : " << PackageInfo::getWWW() << LOG::done; - log() << LOG::always << " Contact : " << PackageInfo::getEmail() << LOG::done; - log() << LOG::always << "*************************************************************" << LOG::done; - } - - void SlicApplication::printUsage() - { - CommandLineProcessor::instance()->printUsage(); - } - - std::string SlicApplication::getGeant4VersionString() - { - if (m_geant4VersionString == 0) - { - std::string g4ver;
+void SlicApplication::printVersion() { + CommandLineProcessor::instance()->printVersion(); +} + +void SlicApplication::printSplashScreen() { + log() << LOG::done; + log() << LOG::always << "*************************************************************" << LOG::done; + log() << LOG::always << " App : " << PackageInfo::getNameString() << " (" + << PackageInfo::getAbbrevString() << ")" << LOG::done; + log() << LOG::always << " Version : " << PackageInfo::getVersionString() << LOG::done; + log() << LOG::always << " Date : " << PackageInfo::getChangeDateString() << LOG::done; + log() << LOG::always << " Authors : " << PackageInfo::getAuthorString() << LOG::done; + log() << LOG::always << " Inst : " << PackageInfo::getInstitutionString() << LOG::done; + log() << LOG::always << " WWW : " << PackageInfo::getWWW() << LOG::done; + log() << LOG::always << " Contact : " << PackageInfo::getEmail() << LOG::done; + log() << LOG::always << "*************************************************************" << LOG::done; +} + +void SlicApplication::printUsage() { + CommandLineProcessor::instance()->printUsage(); +} + +std::string SlicApplication::getGeant4VersionString() { + if (m_geant4VersionString == 0) { + std::string g4ver;
#ifdef HAVE_G4VERSION
- g4ver = StringUtil::toString(G4VERSION_NUMBER);
+ g4ver = StringUtil::toString(G4VERSION_NUMBER);
#else
- // Massage the string returned by G4RunManager into format - // returned by G4Version in recent Geant4 versions. - g4ver = G4RunManager::GetRunManager()->GetVersionString(); - std::string::size_type start = g4ver.find("geant4-",0) + 7; - std::string::size_type end = g4ver.find(" ",start); - g4ver = g4ver.substr(start, end - start); - std::string g4major = g4ver.substr(1,1); - std::string g4minor = g4ver.substr(4,1); - std::string g4patch = "0"; - if (g4ver.find("patch") != string::npos) { - g4patch = g4ver.substr(13,1); - } - g4ver = g4major + g4minor + g4patch; -#endif - std::stringstream s; - s << "geant4-" << "v" << g4ver[0] << "r" << g4ver[1] << "p" << g4ver[2]; - m_geant4VersionString = new std::string(s.str()); - } - return *m_geant4VersionString; - } -
+ // Massage the string returned by G4RunManager into format + // returned by G4Version in recent Geant4 versions. + g4ver = G4RunManager::GetRunManager()->GetVersionString(); + std::string::size_type start = g4ver.find("geant4-", 0) + 7; + std::string::size_type end = g4ver.find(" ", start); + g4ver = g4ver.substr(start, end - start); + std::string g4major = g4ver.substr(1, 1); + std::string g4minor = g4ver.substr(4, 1); + std::string g4patch = "0"; + if (g4ver.find("patch") != string::npos) { + g4patch = g4ver.substr(13, 1); + } + g4ver = g4major + g4minor + g4patch; +#endif + std::stringstream s; + s << "geant4-" << "v" << g4ver[0] << "r" << g4ver[1] << "p" << g4ver[2]; + m_geant4VersionString = new std::string(s.str()); + } + return *m_geant4VersionString; +} +
} // namespace slic
diff -u -r1.1 -r1.2 --- SlicApplicationMessenger.cc 27 Apr 2007 01:54:35 -0000 1.1 +++ SlicApplicationMessenger.cc 27 Nov 2012 19:32:19 -0000 1.2 @@ -1,54 +1,47 @@
-// $Header: /cvs/lcd/slic/src/SlicApplicationMessenger.cc,v 1.1 2007/04/27 01:54:35 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/SlicApplicationMessenger.cc,v 1.2 2012/11/27 19:32:19 jeremy Exp $
#include "SlicApplicationMessenger.hh" // slic #include "SlicApplication.hh" #include "PackageInfo.hh"
-namespace slic -{
+namespace slic {
- SlicApplicationMessenger::SlicApplicationMessenger(SlicApplication* app) - { - m_app = app; - defineCommands(); - } - - SlicApplicationMessenger::~SlicApplicationMessenger() - {} - - void SlicApplicationMessenger::SetNewValue(G4UIcommand* cmd, G4String) - { - if (cmd == m_interactive) { - m_app->setMode(SlicApplication::eInteractive); - } - else if (cmd == m_slicVersion) { - m_app->printVersion(); - } - else if (cmd == m_slicUsage) { - m_app->printUsage(); - } - else { - m_app->log() << LOG::error << "Unknown command to SlicApplicationMessenger." << LOG::done; - } - } - - void SlicApplicationMessenger::defineCommands() - { - // interactive mode - m_interactive = new G4UIcommand( "/control/interactive", this); - m_interactive->SetGuidance( "Set interactive mode to G4 UI session. [SLIC]" ); - - // SLIC dir - m_slicDir = new G4UIdirectory( "/slic/" ); - m_slicDir->SetGuidance( "SLIC simulator commands. [SLIC]" ); - - // print SLIC usage - m_slicUsage = new G4UIcommand( "/slic/usage", this ); - m_slicUsage->SetGuidance( "Print SLIC usage instructions." ); - - // print SLIC version - m_slicVersion = new G4UIcommand( "/slic/version", this ); - m_slicVersion->SetGuidance( "Print SLIC version information." ); - }
+SlicApplicationMessenger::SlicApplicationMessenger(SlicApplication* app) { + m_app = app; + defineCommands(); +} + +SlicApplicationMessenger::~SlicApplicationMessenger() { +} + +void SlicApplicationMessenger::SetNewValue(G4UIcommand* cmd, G4String) { + if (cmd == m_interactive) { + m_app->setMode(SlicApplication::eInteractive); + } else if (cmd == m_slicVersion) { + m_app->printVersion(); + } else if (cmd == m_slicUsage) { + m_app->printUsage(); + } else { + m_app->log() << LOG::error << "Unknown command to SlicApplicationMessenger." << LOG::done; + } +} + +void SlicApplicationMessenger::defineCommands() { + // interactive mode + m_interactive = new G4UIcommand("/control/interactive", this); + m_interactive->SetGuidance("Set interactive mode to G4 UI session. [SLIC]"); + + // SLIC dir + m_slicDir = new G4UIdirectory("/slic/"); + m_slicDir->SetGuidance("SLIC simulator commands. [SLIC]"); + + // print SLIC usage + m_slicUsage = new G4UIcommand("/slic/usage", this); + m_slicUsage->SetGuidance("Print SLIC usage instructions."); + + // print SLIC version + m_slicVersion = new G4UIcommand("/slic/version", this); + m_slicVersion->SetGuidance("Print SLIC version information."); +}
}
diff -u -r1.5 -r1.6 --- SlicMain.cc 9 Jun 2011 01:51:51 -0000 1.5 +++ SlicMain.cc 27 Nov 2012 19:32:19 -0000 1.6 @@ -1,4 +1,4 @@
-// $Id: SlicMain.cc,v 1.5 2011/06/09 01:51:51 jeremy Exp $
+// $Id: SlicMain.cc,v 1.6 2012/11/27 19:32:19 jeremy Exp $
#include "SlicMain.hh"
@@ -9,59 +9,58 @@
// geant4 #include "G4RunManager.hh"
-namespace slic -{
+namespace slic {
-SlicMain::SlicMain() - : Module("SlicMain") -{;} - -SlicMain::~SlicMain() -{;} - -int SlicMain::main(int argc, char** argv) -{ - // Default return code. - int returnCode = 0; - - SlicApplication* slicApp = 0; - - // Top-level try block.
+SlicMain::SlicMain() : + Module("SlicMain") { + ; +} + +SlicMain::~SlicMain() { + ; +} + +int SlicMain::main(int argc, char** argv) { + // Default return code. + int returnCode = 0; + + // Application instance. + SlicApplication* slicApp = 0; + + // Top-level try block.
#ifdef SLIC_CATCH_STD_EXCEPTIONS
- try - {
+ try {
#endif
- // Create the SLIC application using singleton function. - slicApp = SlicApplication::instance(); - - // Setup the command line arguments. - slicApp->initialize(argc, argv); - - // Run the simulator. - slicApp->run(); - - // Get the application return code. - returnCode = slicApp->getReturnCode();
+ // Create the SLIC application using the singleton function. + slicApp = SlicApplication::instance(); + + // Setup the command line arguments. + slicApp->initialize(argc, argv); + + // Run the simulator. + slicApp->run(); + + // Get the application return code. + returnCode = slicApp->getReturnCode(); + + // Delete the application. + if (slicApp) { + delete slicApp; + }
#ifdef SLIC_CATCH_STD_EXCEPTIONS
- } - // Catch an std::exception. - catch(std::exception& stde) - { - log() << LOG::error << stde.what() << LOG::done; - } - // Catch an unknown exception. - catch(...) - { - log() << LOG::error << "Top-level catch caught unknown exception!" << LOG::done; - }
+ // Catch a generic std::exception. +} catch(std::exception& stde) { + log() << LOG::error << LOG::head << stde.what() << LOG::done; + returnCode = SlicApplication::STD_EXCEPTION; +} +// Catch an unknown exception. +catch(...) { + log() << LOG::error << LOG::head << "Top-level catch block caught an unknown exception!" << LOG::done; + returnCode = SlicApplication::UNKNOWN_EXCEPTION; +}
#endif
- - if (slicApp) - { - delete slicApp; - } - - return returnCode;
+ + return returnCode;
} } // namespace slic
diff -u -r1.8 -r1.9 --- StdHepEventSource.cc 4 Jul 2012 01:01:48 -0000 1.8 +++ StdHepEventSource.cc 27 Nov 2012 19:32:19 -0000 1.9 @@ -1,97 +1,85 @@
-// $Header: /cvs/lcd/slic/src/StdHepEventSource.cc,v 1.8 2012/07/04 01:01:48 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/StdHepEventSource.cc,v 1.9 2012/11/27 19:32:19 jeremy Exp $
#include "StdHepEventSource.hh" // slic #include "LcioManager.hh" #include "LcioMcpManager.hh"
-namespace slic -{ - StdHepEventSource::StdHepEventSource(const std::string& fname) - : EventSourceWithInputFile( "StdHepEventSource", fname ), - m_convertor(0) - { - // create loader with internal reader - m_loader = new StdHepLoader(); - - // create new convertor - m_convertor = new StdHepToLcioConvertor(); - } - - void StdHepEventSource::generate(G4Event* anEvent) - { - LcioManager::instance()->getGenerator()->generatePrimaryVertexFromMcpCollection( - LcioMcpManager::instance()->getInitialMcpCollection(), anEvent); - } - - // open the current file - void StdHepEventSource::open() - { - m_loader->openStdHepFile( m_filename ); - m_fileIsOpen = true; - } - - // close the current file - void StdHepEventSource::close() - { - m_loader->closeStdHepFile(); - m_fileIsOpen = false; - } - - // read the next event - void StdHepEventSource::readNextEvent() - { - m_loader->readNextEvent(); - - if (m_loader->isEndOfInput()) { - m_eof = true; - } - } - - void StdHepEventSource::dumpCurrentEvent() - { - log() << LOG::okay << "Dumping StdHep event info ..." << LOG::done; - - lStdHep* rdr = m_loader->getStdHepReader(); - - if ( rdr ) { - rdr->printEventTable(); - } - else { - log() << LOG::error << "No current StdHep reader." << LOG::done; - } - - log() << LOG::okay << LOG::endl; - } - - void StdHepEventSource::beginRun(const G4Run* aRun) - { - // do superclass setup - EventSourceWithInputFile::beginRun( aRun ); - - // setup convertor - assert( m_loader->getStdHepReader() ); - m_convertor->setStdHepReader( m_loader->getStdHepReader() ); - } - - void StdHepEventSource::beginEvent(const G4Event* anEvent) - { - // read an event - EventSourceWithInputFile::beginEvent(anEvent); - - // not EOF? - if (!isEOF()) { - - // set convertor's coll - m_convertor->setCurrentMcpCollection(LcioMcpManager::instance()->getInitialMcpCollection()); - - // run convertor - m_convertor->fillCurrentMcpCollectionFromStdHep(); - } - } - - lStdHep* StdHepEventSource::getStdHepReader() - { - return m_loader->getStdHepReader(); - } -}
+namespace slic { +StdHepEventSource::StdHepEventSource(const std::string& fname) : + EventSourceWithInputFile("StdHepEventSource", fname), m_convertor(0) { + // create loader with internal reader + m_loader = new StdHepLoader(); + + // create new convertor + m_convertor = new StdHepToLcioConvertor(); +} + +void StdHepEventSource::generate(G4Event* anEvent) { + LcioManager::instance()->getGenerator()->generatePrimaryVertexFromMcpCollection( + LcioMcpManager::instance()->getInitialMcpCollection(), anEvent); +} + +// open the current file +void StdHepEventSource::open() { + m_loader->openStdHepFile(m_filename); + m_fileIsOpen = true; +} + +// close the current file +void StdHepEventSource::close() { + m_loader->closeStdHepFile(); + m_fileIsOpen = false; +} + +// read the next event +void StdHepEventSource::readNextEvent() { + m_loader->readNextEvent(); + + if (m_loader->isEndOfInput()) { + m_eof = true; + } +} + +void StdHepEventSource::dumpCurrentEvent() { + log() << LOG::okay << "Dumping StdHep event info ..." << LOG::done; + + lStdHep* rdr = m_loader->getStdHepReader(); + + if (rdr) { + rdr->printEventTable(); + } else { + log() << LOG::error << "No current StdHep reader." << LOG::done; + } + + log() << LOG::okay << LOG::endl; +} + +void StdHepEventSource::beginRun(const G4Run* aRun) { + // do superclass setup + EventSourceWithInputFile::beginRun(aRun); + + // setup convertor + assert( m_loader->getStdHepReader()); + m_convertor->setStdHepReader(m_loader->getStdHepReader()); +} + +void StdHepEventSource::beginEvent(const G4Event* anEvent) { + // read an event + EventSourceWithInputFile::beginEvent(anEvent); + + // not EOF? + if (!isEOF()) { + + // set convertor's coll + m_convertor->setCurrentMcpCollection(LcioMcpManager::instance()->getInitialMcpCollection()); + + // run convertor + m_convertor->fillCurrentMcpCollectionFromStdHep(); + } +} + +lStdHep* StdHepEventSource::getStdHepReader() { + return m_loader->getStdHepReader(); +} +}
diff -u -r1.21 -r1.22 --- StdHepLoader.cc 31 Jan 2012 18:52:30 -0000 1.21 +++ StdHepLoader.cc 27 Nov 2012 19:32:19 -0000 1.22 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/StdHepLoader.cc,v 1.21 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/StdHepLoader.cc,v 1.22 2012/11/27 19:32:19 jeremy Exp $
#include "StdHepLoader.hh"
@@ -17,80 +17,71 @@
using UTIL::lStdHep;
-namespace slic -{
+namespace slic {
- StdHepLoader::~StdHepLoader() - {;}
+StdHepLoader::~StdHepLoader() { + ; +} + +StdHepLoader::StdHepLoader() : + Module("StdHepLoader"), m_filename(""), m_reader(0), m_isEndOfInput(false) { + ; +} + +void StdHepLoader::openStdHepFile(const std::string& filename) { + openStdHepFile(filename.c_str()); +} + +void StdHepLoader::openStdHepFile(const char* filename) { + // set filename + m_filename = filename; + + // close if currently open + closeStdHepFile(); + + // new lStdHep interface + m_reader = new lStdHep(filename); + + // if error, assume fatal + if (m_reader->getError()) { + G4Exception("StdHepLoader::openStdHepFile()", "", FatalException, "Error opening input file."); + } + + // print open message + log().okay( + "StdHep file <" + std::string(filename) + "> opened with <" + + StringUtil::toString((int) m_reader->numEvents()) + "> events."); +} + +void StdHepLoader::closeStdHepFile() { + if (0 != m_reader) { + delete m_reader; + m_reader = 0; + } +}
- StdHepLoader::StdHepLoader() - : Module("StdHepLoader"), - m_filename(""), - m_reader(0), - m_isEndOfInput(false) - {;} - - void StdHepLoader::openStdHepFile(const std::string& filename) - { - openStdHepFile( filename.c_str() ); - } - - void StdHepLoader::openStdHepFile(const char* filename) - { - // set filename - m_filename = filename; - - // close if currently open - closeStdHepFile(); - - // new lStdHep interface - m_reader = new lStdHep( filename ); - - // if error, assume fatal - if ( m_reader->getError() ) - { - G4Exception( "StdHepLoader::openStdHepFile()", "", FatalException, "Error opening input file." ); - } - - // print open message - log().okay("StdHep file <" + std::string( filename ) + "> opened with <" + StringUtil::toString( (int)m_reader->numEvents() ) + "> events."); - } - - void StdHepLoader::closeStdHepFile() - { - if ( 0 != m_reader ) - { - delete m_reader; - m_reader = 0; - } - } - - void StdHepLoader::readNextEvent() - { - /* Read the next event and check the error code. */ - if ( m_reader->readEvent() != LSH_SUCCESS ) - { - /* The error code was not EOF. Assume this means a fatal error occurred. */ - if ( m_reader->getError() != LSH_ENDOFFILE ) { - log().fatal("StdHep errorcode <" + StringUtil::toString( (int)m_reader->getError() ) + ">."); - G4Exception("", "", FatalException, "lStdHep reported an unrecoverable error."); - } - /* EOF */ - else { - m_isEndOfInput = true; - } - } - } - - void StdHepLoader::dumpCurrentEvent() - { - if ( m_reader ) { - m_reader->printEventHeader(); - m_reader->printEvent(); - m_reader->printEventTable(); - } - else { - log().error("Cannot run StdHepLoader::dumpCurrentEvent. StdHep reader is not initialized."); - } - }
+void StdHepLoader::readNextEvent() { + /* Read the next event and check the error code. */ + if (m_reader->readEvent() != LSH_SUCCESS) { + /* The error code was not EOF. Assume this means a fatal error occurred. */ + if (m_reader->getError() != LSH_ENDOFFILE) { + log().fatal("StdHep errorcode <" + StringUtil::toString((int) m_reader->getError()) + ">."); + G4Exception("", "", FatalException, "lStdHep reported an unrecoverable error."); + } + /* EOF */ + else { + m_isEndOfInput = true; + } + } +} + +void StdHepLoader::dumpCurrentEvent() { + if (m_reader) { + m_reader->printEventHeader(); + m_reader->printEvent(); + m_reader->printEventTable(); + } else { + log().error("Cannot run StdHepLoader::dumpCurrentEvent. StdHep reader is not initialized."); + } +}
}
diff -u -r1.42 -r1.43 --- StdHepToLcioConvertor.cc 4 Jul 2012 01:01:48 -0000 1.42 +++ StdHepToLcioConvertor.cc 27 Nov 2012 19:32:19 -0000 1.43 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/StdHepToLcioConvertor.cc,v 1.42 2012/07/04 01:01:48 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/StdHepToLcioConvertor.cc,v 1.43 2012/11/27 19:32:19 jeremy Exp $
#include "StdHepToLcioConvertor.hh" // slic
@@ -26,571 +26,515 @@
using IMPL::MCParticleImpl; using UTIL::LCTOOLS;
-namespace slic -{ - StdHepToLcioConvertor::StdHepToLcioConvertor(lStdHep* rdr) - : Module("StdHepToLcioConverter"), - m_reader(rdr) - { - assert( rdr ); - }
+namespace slic { +StdHepToLcioConvertor::StdHepToLcioConvertor(lStdHep* rdr) : + Module("StdHepToLcioConverter"), m_reader(rdr) { + assert(rdr); +}
- StdHepToLcioConvertor::StdHepToLcioConvertor() - : Module("StdHepToLcioConverter"), - m_reader(0) - {}
+StdHepToLcioConvertor::StdHepToLcioConvertor() : + Module("StdHepToLcioConverter"), m_reader(0) { +}
- StdHepToLcioConvertor::~StdHepToLcioConvertor() - {}
+StdHepToLcioConvertor::~StdHepToLcioConvertor() { +}
- void StdHepToLcioConvertor::setCurrentMcpCollection(EVENT::LCCollection* mcpColl) - { - m_currentMcpColl = mcpColl; - }
+void StdHepToLcioConvertor::setCurrentMcpCollection(EVENT::LCCollection* mcpColl) { + m_currentMcpColl = mcpColl; +}
- EVENT::LCCollection* StdHepToLcioConvertor::getCurrentMcpCollection() - { - return m_currentMcpColl; - }
+EVENT::LCCollection* StdHepToLcioConvertor::getCurrentMcpCollection() { + return m_currentMcpColl; +}
- void StdHepToLcioConvertor::fillCurrentMcpCollectionFromStdHep() - { - // Reset the MCParticle list. - //m_currentMcpColl->clear(); - //G4cout << "m_currentMcpColl.size =" << m_currentMcpColl->getNumberOfElements() << G4endl;
+void StdHepToLcioConvertor::fillCurrentMcpCollectionFromStdHep() { + // Reset the MCParticle list. + //m_currentMcpColl->clear(); + //G4cout << "m_currentMcpColl.size =" << m_currentMcpColl->getNumberOfElements() << G4endl;
#ifdef SLIC_LOG
- log() << LOG::debug << "********** Creating LCIO MCParticle Collection from StdHep **********" << LOG::done;
+ log() << LOG::debug << "********** Creating LCIO MCParticle Collection from StdHep **********" << LOG::done;
#endif
- //assert( m_reader ); - //assert( m_currentMcpColl );
+ //assert( m_reader ); + //assert( m_currentMcpColl );
#ifdef SLIC_LOG
- log() << LOG::debug << "******** loop 1: create MCParticles ********" << LOG::done;
+ log() << LOG::debug << "******** loop 1: create MCParticles ********" << LOG::done;
#endif
- /* Loop #1 : Create MCParticles with no parentage or daughter links. */ - int ntracks = m_reader->nTracks(); - //G4cout << "StdHep.ntracks = " << ntracks << G4endl; - for ( int ihep = 0; - ihep < ntracks; - ihep++ ) {
+ /* Loop #1 : Create MCParticles with no parentage or daughter links. */ + int ntracks = m_reader->nTracks(); + //G4cout << "StdHep.ntracks = " << ntracks << G4endl; + for (int ihep = 0; ihep < ntracks; ihep++) {
#ifdef SLIC_DEBUG
- printTrack( ihep );
+ printTrack( ihep );
#endif #ifdef SLIC_DEBUG
- checkParentage( ihep );
+ checkParentage( ihep );
#endif
- // create MCP and add to coll - createMcpFromStdHep( ihep );
+ // create MCP and add to coll + createMcpFromStdHep(ihep);
#ifdef SLIC_LOG
- log() << LOG::debug << LOG::endl << "--" << LOG::endl << LOG::done;
+ log() << LOG::debug << LOG::endl << "--" << LOG::endl << LOG::done;
#endif
- }
+ }
#ifdef SLIC_LOG
- log() << LOG::debug << "******** loop 2: parent setup ********" << LOG::done << LOG::done;
+ log() << LOG::debug << "******** loop 2: parent setup ********" << LOG::done << LOG::done;
#endif
- /* Loop #2 : Set the MCParticle parentage. */ - for ( int ihep = 0; - ihep < ntracks; - ihep++ ) {
+ /* Loop #2 : Set the MCParticle parentage. */ + for (int ihep = 0; ihep < ntracks; ihep++) {
#ifdef SLIC_LOG
- printIndex( ihep );
+ printIndex( ihep );
// printMothers( ihep ); #endif
- MCParticleImpl* mcp = - dynamic_cast<MCParticleImpl*> ( m_currentMcpColl->getElementAt(ihep) );
+ MCParticleImpl* mcp = dynamic_cast<MCParticleImpl*>(m_currentMcpColl->getElementAt(ihep));
- if ( mcp ) { - setupParents( ihep, mcp ); - }
+ if (mcp) { + setupParents(ihep, mcp); + }
#ifdef SLIC_LOG
- log() << LOG::debug << LOG::done << "--" << LOG::done << LOG::done;
+ log() << LOG::debug << LOG::done << "--" << LOG::done << LOG::done;
#endif
- }
+ }
#ifdef SLIC_LOG
- log() << LOG::debug << "******** loop 3: daughter setup ********" << LOG::done << LOG::done;
+ log() << LOG::debug << "******** loop 3: daughter setup ********" << LOG::done << LOG::done;
#endif
- /* Loop #3 : Setup the daughters. */ - for ( int ihep = 0; - ihep < ntracks; - ihep++ ) {
+ /* Loop #3 : Setup the daughters. */ + for (int ihep = 0; ihep < ntracks; ihep++) {
#ifdef SLIC_LOG
- printIndex( ihep ); - printDaughters( ihep );
+ printIndex( ihep ); + printDaughters( ihep );
#endif
- MCParticleImpl* mcp = - dynamic_cast<MCParticleImpl*> ( m_currentMcpColl->getElementAt(ihep) );
+ MCParticleImpl* mcp = dynamic_cast<MCParticleImpl*>(m_currentMcpColl->getElementAt(ihep));
- if ( mcp ) { - setupDaughters( ihep, mcp ); - } - else { - log() << LOG::error << "mcp is null; ihep <" << ihep << "> does not appear to be a valid idx!" << LOG::done; - }
+ if (mcp) { + setupDaughters(ihep, mcp); + } else { + log() << LOG::error << "mcp is null; ihep <" << ihep << "> does not appear to be a valid idx!" + << LOG::done; + }
#ifdef SLIC_LOG
- log() << LOG::debug << LOG::done << "--" << LOG::done << LOG::done;
+ log() << LOG::debug << LOG::done << "--" << LOG::done << LOG::done;
#endif
- }
+ }
#ifdef SLIC_LOG
- log() << LOG::debug << LOG::done;
+ log() << LOG::debug << LOG::done;
#endif
- }
+}
- IMPL::MCParticleImpl* StdHepToLcioConvertor::createMcpFromStdHep( int ihep ) - { - // new MCP - MCParticleImpl* mcp = new MCParticleImpl();
+IMPL::MCParticleImpl* StdHepToLcioConvertor::createMcpFromStdHep(int ihep) { + // new MCP + MCParticleImpl* mcp = new MCParticleImpl();
- // PDG - int pdgid = m_reader->pid( ihep ); - mcp->setPDG(pdgid);
+ // PDG + int pdgid = m_reader->pid(ihep); + mcp->setPDG(pdgid);
- G4ParticleDefinition* pdef = G4ParticleTable::GetParticleTable()->FindParticle(pdgid);
+ G4ParticleDefinition* pdef = G4ParticleTable::GetParticleTable()->FindParticle(pdgid);
#ifdef SLIC_LOG
- if ( pdef != 0 ) { - log() << LOG::debug << "found definition for particle <" << pdef->GetParticleName() << "> with pdgid <" << pdgid << ">" << LOG::done; - } - else { - log() << LOG::debug << "no definition found for particle with PDG ID <" << pdgid << ">" << LOG::done; - }
+ if ( pdef != 0 ) { + log() << LOG::debug << "found definition for particle <" << pdef->GetParticleName() << "> with pdgid <" << pdgid << ">" << LOG::done; + } + else { + log() << LOG::debug << "no definition found for particle with PDG ID <" << pdgid << ">" << LOG::done; + }
#endif
- /* - * Geant4 Particle definition exists for this MCParticle, - * so set the charge from it. - */ - if ( pdef != 0 ) { - mcp->setCharge( pdef->GetPDGCharge() ); - } - /* - * No Geant4 particle definition, so flag charge as invalid. - */ - else - { - mcp->setCharge( LcioMcpManager::m_NAN ); - }
+ /* + * Geant4 Particle definition exists for this MCParticle, + * so set the charge from it. + */ + if (pdef != 0) { + mcp->setCharge(pdef->GetPDGCharge()); + } + /* + * No Geant4 particle definition, so flag charge as invalid. + */ + else { + mcp->setCharge(LcioMcpManager::m_NAN); + }
- // momentum vec - float p[3] = { m_reader->Px( ihep ), - m_reader->Py( ihep ), - m_reader->Pz( ihep ) }; - mcp->setMomentum( p );
+ // momentum vec + float p[3] = { m_reader->Px(ihep), m_reader->Py(ihep), m_reader->Pz(ihep) }; + mcp->setMomentum(p);
- // mass - mcp->setMass( m_reader->M( ihep ) );
+ // mass + mcp->setMass(m_reader->M(ihep));
- // vertex - double vtx[3] = { m_reader->X( ihep ), - m_reader->Y( ihep ), - m_reader->Z( ihep ) }; - mcp->setVertex( vtx );
+ // vertex + double vtx[3] = { m_reader->X(ihep), m_reader->Y(ihep), m_reader->Z(ihep) }; + mcp->setVertex(vtx);
- // generator status - mcp->setGeneratorStatus( m_reader->status( ihep ) );
+ // generator status + mcp->setGeneratorStatus(m_reader->status(ihep));
- // sim status = none - mcp->setSimulatorStatus( 0 );
+ // sim status = none + mcp->setSimulatorStatus(0);
- // creation time - mcp->setTime( m_reader->T( ihep ) / c_light );
+ // creation time + mcp->setTime(m_reader->T(ihep) / c_light);
#if LCIO_VERSION_GE(1, 60)
- // Spin and color flow code only applicable to StdHep4 files. - if(m_reader->isStdHepEv4()) - { - // Set particle spin. - float spin[3]; - spin[0] = m_reader->spinX(ihep); - spin[1] = m_reader->spinY(ihep); - spin[2] = m_reader->spinZ(ihep); - mcp->setSpin(spin); - - // Set particle color flow. - int colorFlow[2] = {m_reader->colorflow(ihep, 0), m_reader->colorflow(ihep, 1)}; - mcp->setColorFlow(colorFlow); - } -#endif - - // Add particle to collection. - m_currentMcpColl->addElement( mcp ); - - return mcp; - } - - // util functions - void StdHepToLcioConvertor::setupParents( int ihep, IMPL::MCParticleImpl* mcp ) - {
+ // Spin and color flow code only applicable to StdHep4 files. + if(m_reader->isStdHepEv4()) + { + // Set particle spin. + float spin[3]; + spin[0] = m_reader->spinX(ihep); + spin[1] = m_reader->spinY(ihep); + spin[2] = m_reader->spinZ(ihep); + mcp->setSpin(spin); + + // Set particle color flow. + int colorFlow[2] = {m_reader->colorflow(ihep, 0), m_reader->colorflow(ihep, 1)}; + mcp->setColorFlow(colorFlow); + } +#endif + + // Add particle to collection. + m_currentMcpColl->addElement(mcp); + + return mcp; +} + +// util functions +void StdHepToLcioConvertor::setupParents(int ihep, IMPL::MCParticleImpl* mcp) {
//#ifdef SLIC_LOG // log() << LOG::debug << "setupParents" << LOG::done; //#endif
- // get parent indices - int mom1_idx = m_reader->mother1( ihep ) - 1; - int mom2_idx = m_reader->mother2( ihep ) - 1; - - std::vector<int> parVec; - makeIndexVec( mom1_idx, mom2_idx, parVec ); - - if ( parVec.size() > 0 ) { - for ( std::vector<int>::iterator it = parVec.begin(); - it != parVec.end(); - it++ ) - { - if ( *it != ihep ) - { - addMcpParent( *it, mcp ); - }
+ // get parent indices + int mom1_idx = m_reader->mother1(ihep) - 1; + int mom2_idx = m_reader->mother2(ihep) - 1; + + std::vector<int> parVec; + makeIndexVec(mom1_idx, mom2_idx, parVec); + + if (parVec.size() > 0) { + for (std::vector<int>::iterator it = parVec.begin(); it != parVec.end(); it++) { + if (*it != ihep) { + addMcpParent(*it, mcp); + }
//#ifdef SLIC_LOG // else // { // log() << LOG::debug << "Ignoring parent pointing to self for ihep <" << ihep << ">" << LOG::done; // } //#endif
- } - } - }
+ } + } +}
- void StdHepToLcioConvertor::setupDaughters( int ihep, IMPL::MCParticleImpl* mcp ) - {
+void StdHepToLcioConvertor::setupDaughters(int ihep, IMPL::MCParticleImpl* mcp) {
//#ifdef SLIC_LOG // log() << LOG::debug << "setupDaughters for ihep <" << ihep << "> and MCParticle <" << mcp << ">" << LOG::done; //#endif #ifdef SLIC_LOG
- log() << LOG::debug << "MCParticle idx: " << LcioMcpManager::instance()->getMCParticleIndex(LcioMcpManager::instance()->getInitialMcpCollection(), mcp) << LOG::done;
+ log() << LOG::debug << "MCParticle idx: " << LcioMcpManager::instance()->getMCParticleIndex(LcioMcpManager::instance()->getInitialMcpCollection(), mcp) << LOG::done;
#endif
- // get dau indices - int dau1_idx = m_reader->daughter1( ihep ) % 10000 - 1; - int dau2_idx = m_reader->daughter2( ihep ) % 10000 - 1;
+ // get dau indices + int dau1_idx = m_reader->daughter1(ihep) % 10000 - 1; + int dau2_idx = m_reader->daughter2(ihep) % 10000 - 1;
#ifdef SLIC_LOG
- log() << LOG::debug << "dau1 <" << dau1_idx << ">" << LOG::done; - log() << LOG::debug << "dau2 <" << dau2_idx << ">" << LOG::done;
+ log() << LOG::debug << "dau1 <" << dau1_idx << ">" << LOG::done; + log() << LOG::debug << "dau2 <" << dau2_idx << ">" << LOG::done;
#endif
- // Check for valid daughter indices. Some generators such as Whizard put bad values in these fields. - if (!isValidDaughterIndex(dau1_idx) || !isValidDaughterIndex(dau2_idx)) - {
+ // Check for valid daughter indices. Some generators such as Whizard put bad values in these fields. + if (!isValidDaughterIndex(dau1_idx) || !isValidDaughterIndex(dau2_idx)) {
#ifdef SLIC_LOG
- log() << LOG::debug << "ihep <" << ihep << "> has invalid daughter index range <" << dau1_idx << ", " << dau2_idx << ">." << LOG::done;
+ log() << LOG::debug << "ihep <" << ihep << "> has invalid daughter index range <" << dau1_idx << ", " << dau2_idx << ">." << LOG::done;
#endif
- return; - }
+ return; + }
- std::vector<int> dauVec; - dauVec = makeIndexVec( dau1_idx, dau2_idx, dauVec );
+ std::vector<int> dauVec; + dauVec = makeIndexVec(dau1_idx, dau2_idx, dauVec);
#ifdef SLIC_LOG
- log() << LOG::debug << "printing dau vec ..." << LOG::done; - for (std::vector<int>::const_iterator it = dauVec.begin(); - it != dauVec.end(); - it++) - { - log() << LOG::debug << (*it) << " "; - } - log () << LOG::done;
+ log() << LOG::debug << "printing dau vec ..." << LOG::done; + for (std::vector<int>::const_iterator it = dauVec.begin(); + it != dauVec.end(); + it++) + { + log() << LOG::debug << (*it) << " "; + } + log () << LOG::done;
#endif
- if ( dauVec.size() > 0 ) { - for ( std::vector<int>::iterator it = dauVec.begin(); - it != dauVec.end(); - it++ ) { - if ( *it != ihep ) { - addMcpDaughter( *it, mcp ); - }
+ if (dauVec.size() > 0) { + for (std::vector<int>::iterator it = dauVec.begin(); it != dauVec.end(); it++) { + if (*it != ihep) { + addMcpDaughter(*it, mcp); + }
#ifdef SLIC_LOG
- else - { - log() << LOG::error << "Ignoring daughter pointing to self!" << LOG::done; - }
+ else + { + log() << LOG::error << "Ignoring daughter pointing to self!" << LOG::done; + }
#endif
- } - }
+ } + }
#ifdef SLIC_LOG
- else { - log() << LOG::debug << "particle has no daughters" << LOG::done; - }
+ else { + log() << LOG::debug << "particle has no daughters" << LOG::done; + }
#endif
- }
+}
- bool StdHepToLcioConvertor::hasParent( IMPL::MCParticleImpl* dauMcp, IMPL::MCParticleImpl* parMcp) - { - bool isPar = false; - if ( dauMcp && parMcp ) { - int numParents = dauMcp->getParents().size();
+bool StdHepToLcioConvertor::hasParent(IMPL::MCParticleImpl* dauMcp, IMPL::MCParticleImpl* parMcp) { + bool isPar = false; + if (dauMcp && parMcp) { + int numParents = dauMcp->getParents().size();
- MCParticleImpl* pMomMcp;
+ MCParticleImpl* pMomMcp;
- // find if already lists as parent - for ( int i = 0; - i < numParents; - i++ ) {
+ // find if already lists as parent + for (int i = 0; i < numParents; i++) {
- pMomMcp = static_cast<MCParticleImpl*> - ( dauMcp->getParents()[i] );
+ pMomMcp = static_cast<MCParticleImpl*>(dauMcp->getParents()[i]);
- if ( pMomMcp == parMcp ) { - isPar = true; - break; - } - } - }
+ if (pMomMcp == parMcp) { + isPar = true; + break; + } + } + }
- return isPar; - }
+ return isPar; +}
- void StdHepToLcioConvertor::addMcpDaughter( int dauIdx, IMPL::MCParticleImpl* parMcp ) - { - if ( dauIdx >= 0 ) {
+void StdHepToLcioConvertor::addMcpDaughter(int dauIdx, IMPL::MCParticleImpl* parMcp) { + if (dauIdx >= 0) {
- MCParticleImpl* dauMcp = static_cast<MCParticleImpl*> - ( m_currentMcpColl->getElementAt( dauIdx ) );
+ MCParticleImpl* dauMcp = static_cast<MCParticleImpl*>(m_currentMcpColl->getElementAt(dauIdx));
#ifdef SLIC_LOG
- log() << LOG::debug << "found dau particle <" << dauMcp << ">" << LOG::done;
+ log() << LOG::debug << "found dau particle <" << dauMcp << ">" << LOG::done;
#endif // assert( dauMcp );
- if ( dauMcp ) { - if ( !hasParent( dauMcp, parMcp ) ) { - dauMcp->addParent( parMcp );
+ if (dauMcp) { + if (!hasParent(dauMcp, parMcp)) { + dauMcp->addParent(parMcp);
#ifdef SLIC_LOG
- log() << LOG::debug << "added daughter <" << dauIdx << ">" << LOG::done;
+ log() << LOG::debug << "added daughter <" << dauIdx << ">" << LOG::done;
#endif
- }
+ }
#ifdef SLIC_LOG
- else { - log() << LOG::debug << "daughter <" << dauIdx << "> already has this parent" << LOG::done; - }
+ else { + log() << LOG::debug << "daughter <" << dauIdx << "> already has this parent" << LOG::done; + }
#endif
- }
+ }
#ifdef SLIC_LOG
- else { - log() << LOG::error << "WARNING: dauMcp or parMcp is null!" << LOG::done; - }
+ else { + log() << LOG::error << "WARNING: dauMcp or parMcp is null!" << LOG::done; + }
#endif
- } - }
+ } +}
- void StdHepToLcioConvertor::addMcpParent( int parIdx, IMPL::MCParticleImpl* mcp ) - {
+void StdHepToLcioConvertor::addMcpParent(int parIdx, IMPL::MCParticleImpl* mcp) {
#ifdef SLIC_LOG
- log() << LOG::debug << "addMcpParent" << LOG::done;
+ log() << LOG::debug << "addMcpParent" << LOG::done;
#endif
- if ( parIdx >= 0 ) {
+ if (parIdx >= 0) {
- /* If index is > size of collection, the particle's parent doesn't exist yet. We need to die! */ - if ( parIdx > m_currentMcpColl->getNumberOfElements() ) {
+ /* If index is > size of collection, the particle's parent doesn't exist yet. We need to die! */ + if (parIdx > m_currentMcpColl->getNumberOfElements()) {
#ifdef SLIC_LOG
- log() << LOG::fatal << "StdHepToLcioConverter::addMcpParent - Parent index is out of range <" << parIdx << ">" << LOG::done;
+ log() << LOG::fatal << "StdHepToLcioConverter::addMcpParent - Parent index is out of range <" << parIdx << ">" << LOG::done;
#endif
- G4Exception("", "", FatalException, "StdHep index (ihep) is out of range."); - }
+ G4Exception("", "", FatalException, "StdHep index (ihep) is out of range."); + }
- MCParticleImpl* parMcp = static_cast<MCParticleImpl*> - ( m_currentMcpColl->getElementAt( parIdx ) );
+ MCParticleImpl* parMcp = static_cast<MCParticleImpl*>(m_currentMcpColl->getElementAt(parIdx));
- if ( parMcp ) { - if ( !hasParent(mcp, parMcp) ) { - mcp->addParent( parMcp );
+ if (parMcp) { + if (!hasParent(mcp, parMcp)) { + mcp->addParent(parMcp);
#ifdef SLIC_LOG
- log() << LOG::debug << "added parent <" << parIdx << ">" << LOG::done;
+ log() << LOG::debug << "added parent <" << parIdx << ">" << LOG::done;
#endif
- }
+ }
#ifdef SLIC_LOG
- else { - log() << LOG::debug << "daughter already has parent <" << parIdx << ">" << LOG::done; - }
+ else { + log() << LOG::debug << "daughter already has parent <" << parIdx << ">" << LOG::done; + }
#endif
- } - else { - G4Exception("", "", FatalException, "Failed to get parent particle from MCParticle collection."); - } - }
+ } else { + G4Exception("", "", FatalException, "Failed to get parent particle from MCParticle collection."); + } + }
#ifdef SLIC_LOG
- else { - log() << LOG::debug << "ignoring parIdx = -1 " << LOG::done; - }
+ else { + log() << LOG::debug << "ignoring parIdx = -1 " << LOG::done; + }
#endif
- }
+}
- std::vector<int> StdHepToLcioConvertor::makeIndexVec( int idx1, int idx2, std::vector<int>& vec ) - {
+std::vector<int> StdHepToLcioConvertor::makeIndexVec(int idx1, int idx2, std::vector<int>& vec) {
#ifdef SLIC_LOG
- log() << LOG::debug << "idx1 <" << idx1 << ">" << LOG::done; - log() << LOG::debug << "idx2 <" << idx2 << ">" << LOG::done;
+ log() << LOG::debug << "idx1 <" << idx1 << ">" << LOG::done; + log() << LOG::debug << "idx2 <" << idx2 << ">" << LOG::done;
#endif
- if ( idx1 >= 0 && idx2 >= 0 ) {
+ if (idx1 >= 0 && idx2 >= 0) {
- if ( idx1 < idx2 ) {
+ if (idx1 < idx2) {
#ifdef SLIC_LOG
- log() << LOG::debug << "range: idx1 to idx2" << LOG::done;
+ log() << LOG::debug << "range: idx1 to idx2" << LOG::done;
#endif
- for ( int i = idx1; - i < (idx2 + 1); - i++ ) { - vec.push_back(i); - } - } - else if ( idx1 > idx2 ) {
+ for (int i = idx1; i < (idx2 + 1); i++) { + vec.push_back(i); + } + } else if (idx1 > idx2) {
#ifdef SLIC_LOG
- log() << LOG::debug << "discrete: idx1 and idx2" << LOG::done;
+ log() << LOG::debug << "discrete: idx1 and idx2" << LOG::done;
#endif
- vec.push_back(idx1); - vec.push_back(idx2); - } - // indices are equal - else {
+ vec.push_back(idx1); + vec.push_back(idx2); + } + // indices are equal + else {
#ifdef SLIC_LOG
- log() << LOG::debug << "single: idx1 == idx2" << LOG::done;
+ log() << LOG::debug << "single: idx1 == idx2" << LOG::done;
#endif
- vec.push_back(idx1); - } - } - else if ( idx1 >= 0 ) {
+ vec.push_back(idx1); + } + } else if (idx1 >= 0) {
#ifdef SLIC_LOG
- log() << LOG::debug << "single: idx1 only" << LOG::done;
+ log() << LOG::debug << "single: idx1 only" << LOG::done;
#endif
- vec.push_back(idx1); - } - else if ( idx2 >= 0 ) {
+ vec.push_back(idx1); + } else if (idx2 >= 0) {
#ifdef SLIC_LOG
- log() << LOG::debug << "single: idx2 only" << LOG::done;
+ log() << LOG::debug << "single: idx2 only" << LOG::done;
#endif
- vec.push_back(idx2); - }
+ vec.push_back(idx2); + }
- return vec; - }
+ return vec; +}
- void StdHepToLcioConvertor::printIndex( int ihep ) - { - log() << LOG::debug << "ihep <" << ihep << ">" << LOG::done; - }
+void StdHepToLcioConvertor::printIndex(int ihep) { + log() << LOG::debug << "ihep <" << ihep << ">" << LOG::done; +}
- void StdHepToLcioConvertor::printMothers( int ihep ) - { - log() << LOG::debug << "mom1 <" << m_reader->mother1(ihep) - 1 << ">" << LOG::done; - log() << LOG::debug << "mom2 <" << m_reader->mother2(ihep) - 1 << ">" << LOG::done; - }
+void StdHepToLcioConvertor::printMothers(int ihep) { + log() << LOG::debug << "mom1 <" << m_reader->mother1(ihep) - 1 << ">" << LOG::done; + log() << LOG::debug << "mom2 <" << m_reader->mother2(ihep) - 1 << ">" << LOG::done; +}
- void StdHepToLcioConvertor::printDaughters( int ihep ) - { - log() << LOG::debug << "dau1 <" << m_reader->daughter1(ihep) - 1 << ">" << LOG::done; - log() << LOG::debug << "dau2 <" << m_reader->daughter2(ihep) - 1 << ">" << LOG::done; - }
+void StdHepToLcioConvertor::printDaughters(int ihep) { + log() << LOG::debug << "dau1 <" << m_reader->daughter1(ihep) - 1 << ">" << LOG::done; + log() << LOG::debug << "dau2 <" << m_reader->daughter2(ihep) - 1 << ">" << LOG::done; +}
- void StdHepToLcioConvertor::printTrack( int ihep ) - { - printIndex( ihep );
+void StdHepToLcioConvertor::printTrack(int ihep) { + printIndex(ihep);
- log() << LOG::debug << "pid <" << m_reader->pid( ihep ) << ">" << LOG::done; - log() << LOG::debug << "M = " << m_reader->M( ihep ) << LOG::done; - log() << LOG::debug << "T = " << m_reader->T( ihep ) << LOG::done; - log() << LOG::debug << "status <" << m_reader->status( ihep ) << ">" << LOG::done;
+ log() << LOG::debug << "pid <" << m_reader->pid(ihep) << ">" << LOG::done; + log() << LOG::debug << "M = " << m_reader->M(ihep) << LOG::done; + log() << LOG::debug << "T = " << m_reader->T(ihep) << LOG::done; + log() << LOG::debug << "status <" << m_reader->status(ihep) << ">" << LOG::done;
- printMothers(ihep); - printDaughters(ihep);
+ printMothers(ihep); + printDaughters(ihep);
- log() << LOG::debug << "P = (" - << m_reader->Px( ihep ) << ", " - << m_reader->Py( ihep ) << ", " - << m_reader->Pz( ihep) << ")" - << LOG::done;
+ log() << LOG::debug << "P = (" << m_reader->Px(ihep) << ", " << m_reader->Py(ihep) << ", " + << m_reader->Pz(ihep) << ")" << LOG::done;
- log() << LOG::debug << "Vtx = (" - << m_reader->X( ihep ) << ", " - << m_reader->Y( ihep ) << ", " - << m_reader->Z( ihep ) << ")" - << LOG::done;
+ log() << LOG::debug << "Vtx = (" << m_reader->X(ihep) << ", " << m_reader->Y(ihep) << ", " + << m_reader->Z(ihep) << ")" << LOG::done;
- log() << LOG::debug << LOG::done; - }
+ log() << LOG::debug << LOG::done; +}
- void StdHepToLcioConvertor::checkParentage(int ihep ) - { - int mom1 = m_reader->mother1(ihep) - 1; - int mom2 = m_reader->mother2(ihep) - 1; - int dau1 = m_reader->daughter1(ihep) - 1; - int dau2 = m_reader->daughter2(ihep) -1;
+void StdHepToLcioConvertor::checkParentage(int ihep) { + int mom1 = m_reader->mother1(ihep) - 1; + int mom2 = m_reader->mother2(ihep) - 1; + int dau1 = m_reader->daughter1(ihep) - 1; + int dau2 = m_reader->daughter2(ihep) - 1;
- // dau1 < ihep - if ( dau1 >= 0 && dau1 < ihep ) { - log() << LOG::debug << "WARNING: dau1 < ihep" << LOG::done; - }
+ // dau1 < ihep + if (dau1 >= 0 && dau1 < ihep) { + log() << LOG::debug << "WARNING: dau1 < ihep" << LOG::done; + }
- // dau2 < ihep - if ( dau2 >= 0 && dau2 < ihep ) { - log() << LOG::debug << "WARNING: dau2 < ihep" << LOG::done; - }
+ // dau2 < ihep + if (dau2 >= 0 && dau2 < ihep) { + log() << LOG::debug << "WARNING: dau2 < ihep" << LOG::done; + }
- // mom1 > ihep - if ( mom1 >= 0 && mom1 > ihep ) { - log() << LOG::debug << "WARNING: mom1 > ihep" << LOG::done; - }
+ // mom1 > ihep + if (mom1 >= 0 && mom1 > ihep) { + log() << LOG::debug << "WARNING: mom1 > ihep" << LOG::done; + }
- // mom2 > ihep - if ( mom2 >= 0 && mom2 > ihep ) { - log() << LOG::debug << "WARNING: mom2 > ihep" << LOG::done; - }
+ // mom2 > ihep + if (mom2 >= 0 && mom2 > ihep) { + log() << LOG::debug << "WARNING: mom2 > ihep" << LOG::done; + }
- // first particle in list has parents - if ( ihep == 0 && ( mom1 >= 0 || mom2 >= 0 ) ) { - log() << LOG::debug << "WARNING: ihep == 0 has parents" << LOG::done; - }
+ // first particle in list has parents + if (ihep == 0 && (mom1 >= 0 || mom2 >= 0)) { + log() << LOG::debug << "WARNING: ihep == 0 has parents" << LOG::done; + }
- // particle past first 2 with no mother - if ( ihep > 1 && ( mom1 < 0 && mom2 < 0 ) ) { - log() << LOG::debug << "WARNING: ihep > 1 with no mother" << LOG::done; - }
+ // particle past first 2 with no mother + if (ihep > 1 && (mom1 < 0 && mom2 < 0)) { + log() << LOG::debug << "WARNING: ihep > 1 with no mother" << LOG::done; + }
- // mother points to self - if ( ihep == mom1 || ihep == mom2 ) { - log() << LOG::debug << "WARNING: mom1 or mom2 == ihep" << LOG::done; - }
+ // mother points to self + if (ihep == mom1 || ihep == mom2) { + log() << LOG::debug << "WARNING: mom1 or mom2 == ihep" << LOG::done; + }
- // daughter points to self - if ( ihep == dau1 || ihep == dau2 ) { - log() << LOG::debug << "WARNING: dau1 or dau2 == ihep" << LOG::done; - } - }
+ // daughter points to self + if (ihep == dau1 || ihep == dau2) { + log() << LOG::debug << "WARNING: dau1 or dau2 == ihep" << LOG::done; + } +}
} // namespace slic
diff -u -r1.12 -r1.13 --- SteppingAction.cc 6 Jul 2006 22:07:30 -0000 1.12 +++ SteppingAction.cc 27 Nov 2012 19:32:19 -0000 1.13 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/SteppingAction.cc,v 1.12 2006/07/06 22:07:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/SteppingAction.cc,v 1.13 2012/11/27 19:32:19 jeremy Exp $
#include "SteppingAction.hh" // slic
@@ -10,19 +10,17 @@
#include "G4UserSteppingAction.hh"
-namespace slic -{
+namespace slic {
- SteppingAction::SteppingAction() - {}
+SteppingAction::SteppingAction() { +}
- SteppingAction::~SteppingAction() - {}
+SteppingAction::~SteppingAction() { +}
- void SteppingAction::UserSteppingAction(const G4Step* aStep) - { - // TrajectoryManager's stepping action - TrajectoryManager::instance()->stepping( aStep ); - }
+void SteppingAction::UserSteppingAction(const G4Step* aStep) { + // TrajectoryManager's stepping action + TrajectoryManager::instance()->stepping(aStep); +}
}
diff -u -r1.9 -r1.10 --- TimeUtil.cc 27 Apr 2007 01:54:35 -0000 1.9 +++ TimeUtil.cc 27 Nov 2012 19:32:19 -0000 1.10 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/TimeUtil.cc,v 1.9 2007/04/27 01:54:35 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/TimeUtil.cc,v 1.10 2012/11/27 19:32:19 jeremy Exp $
#include "TimeUtil.hh" // std
@@ -6,37 +6,33 @@
#include <cstdio> #include <iostream>
-std::string TimeUtil::getAscTime() -{ - tm* timeinfo = get_tm_local(); - - std::string s = asctime( timeinfo ); - s.erase( s.end() - 1, s.end() ); - return s;
+std::string TimeUtil::getAscTime() { + tm* timeinfo = get_tm_local(); + + std::string s = asctime(timeinfo); + s.erase(s.end() - 1, s.end()); + return s;
}
-TimeUtil::long64 TimeUtil::getTimeNS() -{ - long64 t_sec = (long64) time(NULL); - long64 t_ns = t_sec * ( (long64) 1e9 ); - return t_ns;
+TimeUtil::long64 TimeUtil::getTimeNS() { + long64 t_sec = (long64) time(NULL); + long64 t_ns = t_sec * ((long64) 1e9); + return t_ns;
}
-std::string TimeUtil::getDate() -{ - tm* timeinfo = get_tm_local(); - char buffer[11]; - strftime(buffer, 11, "%Y-%m-%d", timeinfo); - return std::string(buffer);
+std::string TimeUtil::getDate() { + tm* timeinfo = get_tm_local(); + char buffer[11]; + strftime(buffer, 11, "%Y-%m-%d", timeinfo); + return std::string(buffer);
}
-tm* TimeUtil::get_tm_local() -{ - time_t rawtime; - struct tm* timeinfo; - - time ( &rawtime ); - timeinfo = localtime( &rawtime ); - - return timeinfo;
+tm* TimeUtil::get_tm_local() { + time_t rawtime; + struct tm* timeinfo; + + time(&rawtime); + timeinfo = localtime(&rawtime); + + return timeinfo;
}
diff -u -r1.13 -r1.14 --- TrackingAction.cc 19 Oct 2005 22:51:18 -0000 1.13 +++ TrackingAction.cc 27 Nov 2012 19:32:19 -0000 1.14 @@ -1,32 +1,28 @@
-// $Header: /cvs/lcd/slic/src/TrackingAction.cc,v 1.13 2005/10/19 22:51:18 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/TrackingAction.cc,v 1.14 2012/11/27 19:32:19 jeremy Exp $
#include "TrackingAction.hh" // slic #include "Trajectory.hh" #include "TrajectoryManager.hh"
-namespace slic -{
+namespace slic {
- TrackingAction::TrackingAction() - { - // set TrajectoryManager links - m_trjMgr = TrajectoryManager::instance(); - } - - TrackingAction::~TrackingAction() - {} - - void TrackingAction::PreUserTrackingAction(const G4Track* aTrack) - { - // TrajectoryManager's action; also requires setup of trkMgr - m_trjMgr->setTrackingManager( fpTrackingManager ); // needs to be called every time? - m_trjMgr->preTracking( aTrack ); - } - - void TrackingAction::PostUserTrackingAction(const G4Track* aTrack) - { - // TrajectoryManager's action - m_trjMgr->postTracking( aTrack ); - }
+TrackingAction::TrackingAction() { + // set TrajectoryManager links + m_trjMgr = TrajectoryManager::instance(); +} + +TrackingAction::~TrackingAction() { +} + +void TrackingAction::PreUserTrackingAction(const G4Track* aTrack) { + // TrajectoryManager's action; also requires setup of trkMgr + m_trjMgr->setTrackingManager(fpTrackingManager); // needs to be called every time? + m_trjMgr->preTracking(aTrack); +} + +void TrackingAction::PostUserTrackingAction(const G4Track* aTrack) { + // TrajectoryManager's action + m_trjMgr->postTracking(aTrack); +}
}
diff -u -r1.15 -r1.16 --- Trajectory.cc 4 Apr 2006 22:45:28 -0000 1.15 +++ Trajectory.cc 27 Nov 2012 19:32:19 -0000 1.16 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/Trajectory.cc,v 1.15 2006/04/04 22:45:28 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/Trajectory.cc,v 1.16 2012/11/27 19:32:19 jeremy Exp $
#include "Trajectory.hh" // lcdd
@@ -7,147 +7,121 @@
// geant4 #include "G4TrajectoryPoint.hh"
-namespace slic -{
+namespace slic {
- G4Allocator<Trajectory> TrajectoryAllocator;
+G4Allocator<Trajectory> TrajectoryAllocator;
- Trajectory::Trajectory() - : G4VTrajectory(), - m_particleDefinition(0), - m_particleName(""), - m_PDGCharge(0), - m_PDGEncoding(0), - m_trackID(0), - m_parentID(0), - m_posRecord(0), - m_globalTime(0), - m_endpointEnergy(0), - m_createdInSimulation(false), - m_hasEndpointDaughters(false), - m_backscatter(false), - m_vertexIsNotEndpointOfParent(false) - {} - - Trajectory::Trajectory(const G4Track *aTrack ) - : G4VTrajectory() - { - m_particleDefinition = aTrack->GetDefinition(); - m_particleName = m_particleDefinition->GetParticleName(); - m_PDGCharge = m_particleDefinition->GetPDGCharge(); - m_PDGEncoding = m_particleDefinition->GetPDGEncoding(); - m_trackID = aTrack->GetTrackID(); - m_parentID = aTrack->GetParentID(); - m_posRecord = new TrajectoryPointContainer(); - m_posRecord->push_back(new G4TrajectoryPoint( aTrack->GetPosition() ) ); - m_initialMomentum = aTrack->GetMomentum(); - - // default flags to false - m_createdInSimulation=false; - m_hasEndpointDaughters=false; - m_backscatter=false; - m_vertexIsNotEndpointOfParent=false; - - m_globalTime = aTrack->GetGlobalTime(); - } - - void Trajectory::setupManuallyFromTrack(const G4Track* aTrack) - { - TrackInformation* trkInfo = - static_cast<TrackInformation*> (aTrack->GetUserInformation() ); - - assert( trkInfo ); - - m_parentID = trkInfo->getOriginalTrackID(); - - // position already added in trajectory ctor - m_posRecord->insert(m_posRecord->begin(), - new G4TrajectoryPoint(aTrack->GetVertexPosition() ) ); - - G4double vKE = aTrack->GetVertexKineticEnergy(); - - G4double mass = m_particleDefinition->GetPDGMass(); - G4double magmom = sqrt( vKE * vKE + 2. * vKE*mass ); - m_initialMomentum = magmom * ( aTrack->GetVertexMomentumDirection() ); - - m_globalTime = aTrack->GetGlobalTime(); - } - - Trajectory::Trajectory(Trajectory &right) - : G4VTrajectory() - { - m_particleName = right.m_particleName; - m_particleDefinition = right.m_particleDefinition; - m_PDGCharge = right.m_PDGCharge; - m_PDGEncoding = right.m_PDGEncoding; - m_trackID = right.m_trackID; - m_parentID = right.m_parentID; - m_globalTime = right.m_globalTime; - - m_posRecord = new TrajectoryPointContainer(); - for (unsigned int i = 0; - i < right.m_posRecord->size(); - i++) { - G4TrajectoryPoint *rightPoint = (G4TrajectoryPoint*)((*(right.m_posRecord))[i]); - m_posRecord->push_back(new G4TrajectoryPoint(*rightPoint)); - } - } - - Trajectory::~Trajectory() - { - for (unsigned int i=0; i < m_posRecord->size(); i++) - { - delete (*m_posRecord)[i]; - } - - m_posRecord->clear(); - delete m_posRecord; - } - - void Trajectory::AppendStep(const G4Step *aStep) - { - m_posRecord->push_back(new G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition() )); - } - - void Trajectory::MergeTrajectory(G4VTrajectory *secondTrajectory) - { - if (!secondTrajectory) return; - - Trajectory *seco = (Trajectory*)secondTrajectory; - G4int pent = seco->GetPointEntries(); - for (int i=1; i<pent; i++) { - m_posRecord->push_back((*(seco->m_posRecord))[i]); - } - - delete (*seco->m_posRecord)[0]; - seco->m_posRecord->clear(); - } - - const std::string& Trajectory::getFinalStatusString(EFinalStatus fs) - { - static const std::string str_unset = "Unset"; - static const std::string str_invalid = "Invalid"; - static const std::string str_decayed_trk = "DecayedInTracker"; - static const std::string str_left = "LeftDetector"; - static const std::string str_stopped = "Stopped"; - static const std::string str_decayed_cal = "DecayedInCalorimeter"; - - if ( fs == eDecayedInTracker ) { - return str_decayed_trk; - } - else if ( fs == eLeftDetector ) { - return str_left; - } - else if ( fs == eStopped ) { - return str_stopped; - } - else if ( fs == eDecayedInCalorimeter ) { - return str_decayed_cal; - } - else if ( fs == eUnset ) { - return str_unset; - }
+Trajectory::Trajectory() : + G4VTrajectory(), m_particleDefinition(0), m_particleName(""), m_PDGCharge(0), m_PDGEncoding(0), m_trackID( + 0), m_parentID(0), m_posRecord(0), m_globalTime(0), m_endpointEnergy(0), m_createdInSimulation( + false), m_hasEndpointDaughters(false), m_backscatter(false), m_vertexIsNotEndpointOfParent( + false) { +} + +Trajectory::Trajectory(const G4Track *aTrack) : + G4VTrajectory() { + m_particleDefinition = aTrack->GetDefinition(); + m_particleName = m_particleDefinition->GetParticleName(); + m_PDGCharge = m_particleDefinition->GetPDGCharge(); + m_PDGEncoding = m_particleDefinition->GetPDGEncoding(); + m_trackID = aTrack->GetTrackID(); + m_parentID = aTrack->GetParentID(); + m_posRecord = new TrajectoryPointContainer(); + m_posRecord->push_back(new G4TrajectoryPoint(aTrack->GetPosition())); + m_initialMomentum = aTrack->GetMomentum(); + + // default flags to false + m_createdInSimulation = false; + m_hasEndpointDaughters = false; + m_backscatter = false; + m_vertexIsNotEndpointOfParent = false; + + m_globalTime = aTrack->GetGlobalTime(); +} + +void Trajectory::setupManuallyFromTrack(const G4Track* aTrack) { + TrackInformation* trkInfo = static_cast<TrackInformation*>(aTrack->GetUserInformation()); + + assert( trkInfo); + + m_parentID = trkInfo->getOriginalTrackID(); + + // position already added in trajectory ctor + m_posRecord->insert(m_posRecord->begin(), new G4TrajectoryPoint(aTrack->GetVertexPosition())); + + G4double vKE = aTrack->GetVertexKineticEnergy(); + + G4double mass = m_particleDefinition->GetPDGMass(); + G4double magmom = sqrt(vKE * vKE + 2. * vKE * mass); + m_initialMomentum = magmom * (aTrack->GetVertexMomentumDirection()); + + m_globalTime = aTrack->GetGlobalTime(); +}
- return str_invalid; - }
+Trajectory::Trajectory(Trajectory &right) : + G4VTrajectory() { + m_particleName = right.m_particleName; + m_particleDefinition = right.m_particleDefinition; + m_PDGCharge = right.m_PDGCharge; + m_PDGEncoding = right.m_PDGEncoding; + m_trackID = right.m_trackID; + m_parentID = right.m_parentID; + m_globalTime = right.m_globalTime; + + m_posRecord = new TrajectoryPointContainer(); + for (unsigned int i = 0; i < right.m_posRecord->size(); i++) { + G4TrajectoryPoint *rightPoint = (G4TrajectoryPoint*) ((*(right.m_posRecord))[i]); + m_posRecord->push_back(new G4TrajectoryPoint(*rightPoint)); + } +} + +Trajectory::~Trajectory() { + for (unsigned int i = 0; i < m_posRecord->size(); i++) { + delete (*m_posRecord)[i]; + } + + m_posRecord->clear(); + delete m_posRecord; +} + +void Trajectory::AppendStep(const G4Step *aStep) { + m_posRecord->push_back(new G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition())); +} + +void Trajectory::MergeTrajectory(G4VTrajectory *secondTrajectory) { + if (!secondTrajectory) + return; + + Trajectory *seco = (Trajectory*) secondTrajectory; + G4int pent = seco->GetPointEntries(); + for (int i = 1; i < pent; i++) { + m_posRecord->push_back((*(seco->m_posRecord))[i]); + } + + delete (*seco->m_posRecord)[0]; + seco->m_posRecord->clear(); +} + +const std::string& Trajectory::getFinalStatusString(EFinalStatus fs) { + static const std::string str_unset = "Unset"; + static const std::string str_invalid = "Invalid"; + static const std::string str_decayed_trk = "DecayedInTracker"; + static const std::string str_left = "LeftDetector"; + static const std::string str_stopped = "Stopped"; + static const std::string str_decayed_cal = "DecayedInCalorimeter"; + + if (fs == eDecayedInTracker) { + return str_decayed_trk; + } else if (fs == eLeftDetector) { + return str_left; + } else if (fs == eStopped) { + return str_stopped; + } else if (fs == eDecayedInCalorimeter) { + return str_decayed_cal; + } else if (fs == eUnset) { + return str_unset; + } + + return str_invalid; +}
}
diff -u -r1.51 -r1.52 --- TrajectoryManager.cc 31 Jan 2012 18:52:30 -0000 1.51 +++ TrajectoryManager.cc 27 Nov 2012 19:32:19 -0000 1.52 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/TrajectoryManager.cc,v 1.51 2012/01/31 18:52:30 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/TrajectoryManager.cc,v 1.52 2012/11/27 19:32:19 jeremy Exp $
// slic #include "TrajectoryManager.hh"
@@ -8,626 +8,577 @@
#include "G4TrackVector.hh" #include "G4Event.hh"
-namespace slic -{
+namespace slic {
- TrajectoryManager::~TrajectoryManager() - {}
+TrajectoryManager::~TrajectoryManager() { +} + +TrajectoryManager::TrajectoryManager() : + Module("TrajectoryManager"), m_trackingManager(0), m_currentTrajectory(0), m_currentTrack(0), m_currentTrackID( + -1) { +} + +void TrajectoryManager::preTracking(const G4Track* aTrack) { + m_currentTrack = aTrack; + m_currentTrackID = aTrack->GetTrackID(); + +#ifdef SLIC_LOG + log() << LOG::verbose + << "TrajectoryManager::preTracking()" << LOG::endl + << "trackID <" << aTrack->GetTrackID() << ">" << LOG::endl + << "particle <" << aTrack->GetDefinition()->GetParticleName() << ">" << LOG::endl + << "volume <" << aTrack->GetVolume()->GetName() << ">" + << LOG::done; + printStatusFlags(aTrack); +#endif + + // default trajectory storage to OFF + m_trackingManager->SetStoreTrajectory(false); + + // handle primary or secondary track + if (isPrimaryTrack(aTrack)) { + handlePrimaryTrack(aTrack); + } else { + handleSecondaryTrack(aTrack); + } +} + +void TrajectoryManager::printStatusFlags(const G4Track* trk) { + log() << LOG::debug << "status flags for trackID <" << trk->GetTrackID() << ">" << LOG::done; + printStatusFlags(TrackInformation::getTrackInformation(trk)); +} + +void TrajectoryManager::printStatusFlags(TrackInformation* trkInfo) { + if (trkInfo) { + log() << LOG::verbose << "tracking status <" + << TrackInformation::getTrackingStatusString(trkInfo->getTrackingStatus()) << ">" << LOG::endl + << "orig tracking status <" + << TrackInformation::getTrackingStatusString(trkInfo->getOriginalTrackingStatus()) << ">" + << LOG::endl << "backscatter flag <" << trkInfo->getBackscatter() << ">" << LOG::endl + << "belowThreshold flag <" << trkInfo->getBelowThreshold() << ">" << LOG::endl + << "tracker hit flag <" << trkInfo->hasTrackerHit() << ">" << LOG::endl << "vtxnotendp flag <" + << trkInfo->getVertexIsNotEndpointOfParent() << ">" << LOG::done; + } +#ifdef SLIC_LOG + else { + log() << LOG::debug << "Track info NULL in printStatusFlags()." << LOG::done; + } +#endif +} + +void TrajectoryManager::printTrajectory(const Trajectory* trj) { + log() << LOG::debug << "trajectory info" << LOG::endl << "trackID <" << trj->GetTrackID() << ">" + << LOG::endl << "final status: " << trj->getFinalStatusString() << LOG::endl << "endp dau: " + << trj->getHasEndpointDaughters() << LOG::endl << "backscatter: " << trj->getBackscatter() + << LOG::endl << "vtxnotendp: " << trj->getVertexIsNotEndpointOfParent() << LOG::endl + << "created in sim: " << trj->getCreatedInSimulation() << LOG::endl << "vtx: " + << trj->GetPoint(0)->GetPosition() << LOG::endl << "endp: " + << trj->GetPoint(trj->GetPointEntries() - 1)->GetPosition() << LOG::endl << LOG::done; +} + +void TrajectoryManager::postTracking(const G4Track* aTrack) { +#ifdef SLIC_LOG + log() << LOG::verbose << "TrajectoryManager::postTracking()" << LOG::endl; +#endif + + // check if needs manual setup + if (needsManualTrajectorySetup(aTrack)) { + +#ifdef SLIC_LOG + log() << LOG::verbose << "needs manual trajectory setup" << LOG::done; +#endif + + // setup trajectory in default way + Trajectory* trj = createTrajectoryFromTrack(aTrack); + + // do additional, manual setup using this track + trj->setupManuallyFromTrack(aTrack); + } + + // trk info to secondaries + copySecondaryTrackInformationFromParent(aTrack); + + // set final status codes in current trajectory + setTrajectoryFinalStatus(aTrack); + + // print if store traj on/off +#ifdef SLIC_LOG + log() << LOG::verbose << "store trajectory <" << m_trackingManager->GetStoreTrajectory() << ">" << LOG::done; +#endif + + // print status flags +#ifdef SLIC_LOG + printStatusFlags(aTrack); +#endif + + Trajectory* trj = static_cast<Trajectory*>(m_trackingManager->GimmeTrajectory()); + if (0 != trj) { + trj->setEndpointEnergy(aTrack->GetTotalEnergy()); + } +} + +void TrajectoryManager::handlePrimaryTrack(const G4Track* aTrack) { + // set track info + setPrimaryTrackInformation(aTrack); + + // create the trajectory + createTrajectoryFromTrack(aTrack); +} + +Trajectory* TrajectoryManager::createTrajectoryFromTrack(const G4Track* aTrack) { +#ifdef SLIC_LOG + log() << LOG::verbose << "createTrajectoryFromTrack()" << LOG::done; +#endif + Trajectory* trj = new Trajectory(aTrack); + m_trackingManager->SetStoreTrajectory(true); + m_trackingManager->SetTrajectory(trj); + addTrackIDToTrajectoryLink(trj); + m_currentTrajectory = trj; + return trj; +} + +void TrajectoryManager::setPrimaryTrackInformation(const G4Track* aTrack) { + TrackInformation* trkInfo = new TrackInformation(aTrack); + + // set tracking flag using reg info + setTrackingFlagFromRegionInformation(trkInfo, G4UserRegionInformation::getRegionInformation(aTrack)); + + G4Track* nconstTrack = const_cast<G4Track*>(aTrack); + nconstTrack->SetUserInformation(trkInfo); +} + +void TrajectoryManager::setTrackingFlagFromRegionInformation(TrackInformation* trk_info, + G4UserRegionInformation* reg_info) { + if (reg_info->getStoreSecondaries() == true) { + trk_info->setTrackingStatus(TrackInformation::eInTrackingRegion); + } else { + trk_info->setTrackingStatus(TrackInformation::eInNontrackingRegion); + } +} + +/* + Called in PreTracking to set status flags and + decide whether or not to create a trj for + this secondary particle. + */ +void TrajectoryManager::handleSecondaryTrack(const G4Track* aTrack) { + // get track information + TrackInformation* trkInfo = TrackInformation::getTrackInformation(aTrack); + + // get region information + G4UserRegionInformation* regInfo = G4UserRegionInformation::getRegionInformation(aTrack); + + // must have track and region info to proceed + if (regInfo && trkInfo) { + + // check if in tracking region + if (regInfo->getStoreSecondaries()) { + + // check if backscatter + if (isBackscatter(aTrack)) { + trkInfo->setBackscatter(true); + } + + /* + Check if below threshold and continuous process creation, + i.e. not an endp dau. + */ + else if (isBelowThreshold(aTrack) && trkInfo->getVertexIsNotEndpointOfParent()) { + trkInfo->setBelowThreshold(true); + } + + /* + Process of elimination: above threshold and not backscatter, + so requires a new trajectory and trkInfo. + */ + else { + + // setup secondary track info + setupSecondaryTrackInformation(aTrack); + + // create the secondary trajectory + createSecondaryTrajectory(aTrack); + } + + /* + // DEBUG + if ( trkInfo != TrackInformation::getTrackInformation( aTrack ) ) { + log() << "WARNING: track info was reset" << LOG::endl; + + log() << LOG::endl; + log() << "old flags" << LOG::endl; + printStatusFlags( trkInfo ); + log() << LOG::endl; + + log() << "new flags" << LOG::endl; + printStatusFlags( TrackInformation::getTrackInformation( aTrack ) ); + log() << LOG::endl; + } + */ + + /* + Set flag for in tracking region, re-getting track info, + because may have been recreated above. + */ + TrackInformation::getTrackInformation(aTrack)->setTrackingStatus( + TrackInformation::eInTrackingRegion); + } + // in calorimeter, i.e. non-tracking + else { + + // set non tracking status + trkInfo->setTrackingStatus(TrackInformation::eInNontrackingRegion); + trkInfo->setOriginalTrackingStatus(TrackInformation::eInNontrackingRegion); + } + } + // fatal error: regInfo or trkInfo were null + else { + log() << LOG::fatal << "FATAL ERROR: region info or track info were null in handleSecondaryTrack()." + << LOG::endl << "region info <" << regInfo << ">" << LOG::endl << "track info <" << trkInfo + << ">" << LOG::done; + G4Exception("", "", FatalException, "Track info or region info was null."); + } +} + +void TrajectoryManager::setupSecondaryTrackInformation(const G4Track* aTrack) { + // old track info + TrackInformation* oldTrkInfo = TrackInformation::getTrackInformation(aTrack); + + // create new track info + TrackInformation* newTrkInfo = new TrackInformation(aTrack); + + // copy vtxnotendp flag from old trkInfo + newTrkInfo->setVertexIsNotEndpointOfParent(oldTrkInfo->getVertexIsNotEndpointOfParent()); + + /* + Delete old track info to avoid mem leak. + */ + delete oldTrkInfo; + oldTrkInfo = 0; + + /* + Set original tracking status; it must be tracking, because otherwise + would not be calling this function. (By definition, secondary tracks + do not get trajectories in non-tracking regions.) + */ + newTrkInfo->setOriginalTrackingStatus(TrackInformation::eInTrackingRegion); + + /* + Setup new track info in this track. + */ + G4Track* nconstTrk = const_cast<G4Track*>(aTrack); + nconstTrk->SetUserInformation(newTrkInfo); +} + +Trajectory* TrajectoryManager::createSecondaryTrajectory(const G4Track* aTrack) { + // create the trajectory + Trajectory* trj = createTrajectoryFromTrack(aTrack); + + // set CreatedInSimulation flag + trj->setCreatedInSimulation(true); + + return trj; +} + +// called in PostTracking to pass trk info to the track's secondaries +void TrajectoryManager::copySecondaryTrackInformationFromParent(const G4Track* aTrack) { + // get track info for parent + TrackInformation* parTrkInfo = TrackInformation::getTrackInformation(aTrack); + + // get current trajectory from tracking manager + Trajectory* parTrj = getCurrentTrajectory(); + + // get secondaries container + G4TrackVector* secondaries = m_trackingManager->GimmeSecondaries();
- TrajectoryManager::TrajectoryManager() - : Module("TrajectoryManager"), - m_trackingManager(0), - m_currentTrajectory(0), - m_currentTrack(0), - m_currentTrackID(-1) - {} - - void TrajectoryManager::preTracking(const G4Track* aTrack) - { - m_currentTrack = aTrack; - m_currentTrackID = aTrack->GetTrackID(); - -#ifdef SLIC_LOG - log() << LOG::verbose - << "TrajectoryManager::preTracking()" << LOG::endl - << "trackID <" << aTrack->GetTrackID() << ">" << LOG::endl - << "particle <" << aTrack->GetDefinition()->GetParticleName() << ">" << LOG::endl - << "volume <" << aTrack->GetVolume()->GetName() << ">" - << LOG::done; - printStatusFlags(aTrack); -#endif - - // default trajectory storage to OFF - m_trackingManager->SetStoreTrajectory( false ); - - // handle primary or secondary track - if ( isPrimaryTrack(aTrack) ) { - handlePrimaryTrack( aTrack ); - } - else { - handleSecondaryTrack( aTrack ); - } - } - - void TrajectoryManager::printStatusFlags( const G4Track* trk) - { - log() << LOG::debug << "status flags for trackID <" << trk->GetTrackID() << ">" << LOG::done; - printStatusFlags( TrackInformation::getTrackInformation( trk ) ); - } - - void TrajectoryManager::printStatusFlags(TrackInformation* trkInfo) - { - if ( trkInfo ) { - log() << LOG::verbose - << "tracking status <" << TrackInformation::getTrackingStatusString( trkInfo->getTrackingStatus() ) << ">" << LOG::endl - << "orig tracking status <" << TrackInformation::getTrackingStatusString( trkInfo->getOriginalTrackingStatus() ) << ">" << LOG::endl - << "backscatter flag <" << trkInfo->getBackscatter() << ">" << LOG::endl - << "belowThreshold flag <" << trkInfo->getBelowThreshold() << ">" << LOG::endl - << "tracker hit flag <" << trkInfo->hasTrackerHit() << ">" << LOG::endl - << "vtxnotendp flag <" << trkInfo->getVertexIsNotEndpointOfParent() << ">" - << LOG::done; - } -#ifdef SLIC_LOG - else { - log() << LOG::debug << "Track info NULL in printStatusFlags()." << LOG::done; - } -#endif - } - - void TrajectoryManager::printTrajectory(const Trajectory* trj) - { - log() << LOG::debug - << "trajectory info" << LOG::endl - << "trackID <" << trj->GetTrackID() << ">" << LOG::endl - << "final status: " << trj->getFinalStatusString() << LOG::endl - << "endp dau: " << trj->getHasEndpointDaughters() << LOG::endl - << "backscatter: " << trj->getBackscatter() << LOG::endl - << "vtxnotendp: " << trj->getVertexIsNotEndpointOfParent() << LOG::endl - << "created in sim: " << trj->getCreatedInSimulation() << LOG::endl - << "vtx: " << trj->GetPoint(0)->GetPosition() << LOG::endl - << "endp: " << trj->GetPoint(trj->GetPointEntries() - 1)->GetPosition() << LOG::endl - << LOG::done; - } - - void TrajectoryManager::postTracking(const G4Track* aTrack) - { -#ifdef SLIC_LOG - log() << LOG::verbose << "TrajectoryManager::postTracking()" << LOG::endl; -#endif - - // check if needs manual setup - if ( needsManualTrajectorySetup( aTrack ) ) { - -#ifdef SLIC_LOG - log() << LOG::verbose << "needs manual trajectory setup" << LOG::done; -#endif - - // setup trajectory in default way - Trajectory* trj = createTrajectoryFromTrack( aTrack ); - - // do additional, manual setup using this track - trj->setupManuallyFromTrack( aTrack ); - } - - // trk info to secondaries - copySecondaryTrackInformationFromParent( aTrack ); - - // set final status codes in current trajectory - setTrajectoryFinalStatus( aTrack ); - - // print if store traj on/off -#ifdef SLIC_LOG - log() << LOG::verbose << "store trajectory <" << m_trackingManager->GetStoreTrajectory() << ">" << LOG::done; -#endif - - // print status flags -#ifdef SLIC_LOG - printStatusFlags(aTrack); -#endif - - Trajectory* trj = static_cast<Trajectory*>(m_trackingManager->GimmeTrajectory()); - if ( 0 != trj ) { - trj->setEndpointEnergy( aTrack->GetTotalEnergy() ); - } - } - - void TrajectoryManager::handlePrimaryTrack(const G4Track* aTrack) - { - // set track info - setPrimaryTrackInformation(aTrack); - - // create the trajectory - createTrajectoryFromTrack( aTrack ); - } - - Trajectory* TrajectoryManager::createTrajectoryFromTrack(const G4Track* aTrack ) - { -#ifdef SLIC_LOG - log() << LOG::verbose << "createTrajectoryFromTrack()" << LOG::done; -#endif - Trajectory* trj = new Trajectory( aTrack ); - m_trackingManager->SetStoreTrajectory( true ); - m_trackingManager->SetTrajectory( trj ); - addTrackIDToTrajectoryLink( trj ); - m_currentTrajectory = trj; - return trj; - } - - void TrajectoryManager::setPrimaryTrackInformation(const G4Track* aTrack) - { - TrackInformation* trkInfo = new TrackInformation( aTrack ); - - // set tracking flag using reg info - setTrackingFlagFromRegionInformation( trkInfo, G4UserRegionInformation::getRegionInformation( aTrack ) ); - - G4Track* nconstTrack = const_cast<G4Track*> (aTrack); - nconstTrack->SetUserInformation( trkInfo ); - } - - void TrajectoryManager::setTrackingFlagFromRegionInformation(TrackInformation* trk_info, G4UserRegionInformation* reg_info) - { - if ( reg_info->getStoreSecondaries() == true ) { - trk_info->setTrackingStatus(TrackInformation::eInTrackingRegion); - } - else { - trk_info->setTrackingStatus(TrackInformation::eInNontrackingRegion); - } - } - - /* - Called in PreTracking to set status flags and - decide whether or not to create a trj for - this secondary particle. - */ - void TrajectoryManager::handleSecondaryTrack(const G4Track* aTrack) - { - // get track information - TrackInformation* trkInfo = TrackInformation::getTrackInformation( aTrack ); - - // get region information - G4UserRegionInformation* regInfo = G4UserRegionInformation::getRegionInformation ( aTrack ); - - // must have track and region info to proceed - if ( regInfo && trkInfo ) { - - // check if in tracking region - if ( regInfo->getStoreSecondaries() ) { - - // check if backscatter - if ( isBackscatter( aTrack ) ) { - trkInfo->setBackscatter( true ); - } - - /* - Check if below threshold and continuous process creation, - i.e. not an endp dau. - */ - else if ( isBelowThreshold( aTrack ) && - trkInfo->getVertexIsNotEndpointOfParent() ) { - trkInfo->setBelowThreshold( true ); - } - - /* - Process of elimination: above threshold and not backscatter, - so requires a new trajectory and trkInfo. - */ - else { - - // setup secondary track info - setupSecondaryTrackInformation( aTrack ); - - // create the secondary trajectory - createSecondaryTrajectory( aTrack ); - } - - - /* - // DEBUG - if ( trkInfo != TrackInformation::getTrackInformation( aTrack ) ) { - log() << "WARNING: track info was reset" << LOG::endl; - - log() << LOG::endl; - log() << "old flags" << LOG::endl; - printStatusFlags( trkInfo ); - log() << LOG::endl; - - log() << "new flags" << LOG::endl; - printStatusFlags( TrackInformation::getTrackInformation( aTrack ) ); - log() << LOG::endl; - } - */ - - /* - Set flag for in tracking region, re-getting track info, - because may have been recreated above. - */ - TrackInformation::getTrackInformation( aTrack ) - ->setTrackingStatus( TrackInformation::eInTrackingRegion ); - } - // in calorimeter, i.e. non-tracking - else { - - // set non tracking status - trkInfo->setTrackingStatus( TrackInformation::eInNontrackingRegion ); - trkInfo->setOriginalTrackingStatus( TrackInformation::eInNontrackingRegion ); - } - } - // fatal error: regInfo or trkInfo were null - else { - log() << LOG::fatal << "FATAL ERROR: region info or track info were null in handleSecondaryTrack()." << LOG::endl - << "region info <" << regInfo << ">" << LOG::endl - << "track info <" << trkInfo << ">" << LOG::done; - G4Exception("", "", FatalException, "Track info or region info was null."); - } - } - - void TrajectoryManager::setupSecondaryTrackInformation(const G4Track* aTrack) - { - // old track info - TrackInformation* oldTrkInfo = TrackInformation::getTrackInformation( aTrack ); - - // create new track info - TrackInformation* newTrkInfo = new TrackInformation( aTrack ); - - // copy vtxnotendp flag from old trkInfo - newTrkInfo->setVertexIsNotEndpointOfParent( oldTrkInfo->getVertexIsNotEndpointOfParent() ); - - /* - Delete old track info to avoid mem leak. - */ - delete oldTrkInfo; - oldTrkInfo = 0; - - /* - Set original tracking status; it must be tracking, because otherwise - would not be calling this function. (By definition, secondary tracks - do not get trajectories in non-tracking regions.) - */ - newTrkInfo->setOriginalTrackingStatus( TrackInformation::eInTrackingRegion ); - - /* - Setup new track info in this track. - */ - G4Track* nconstTrk = const_cast<G4Track*> ( aTrack ); - nconstTrk->SetUserInformation( newTrkInfo ); - } - - Trajectory* TrajectoryManager::createSecondaryTrajectory(const G4Track* aTrack) - { - // create the trajectory - Trajectory* trj = createTrajectoryFromTrack( aTrack ); - - // set CreatedInSimulation flag - trj->setCreatedInSimulation( true ); - - return trj; - } - - // called in PostTracking to pass trk info to the track's secondaries - void TrajectoryManager::copySecondaryTrackInformationFromParent(const G4Track* aTrack) - { - // get track info for parent - TrackInformation* parTrkInfo = TrackInformation::getTrackInformation( aTrack ); - - // get current trajectory from tracking manager - Trajectory* parTrj = getCurrentTrajectory(); - - // get secondaries container - G4TrackVector* secondaries = m_trackingManager->GimmeSecondaries(); - - // loop over secondaries to 1) create trk info and 2) set vertexIsNotEndpointOfParent flag - if ( secondaries ) { - size_t nseco = secondaries->size(); - for ( size_t i = 0; i < nseco; i++ ) { - - // set current seco track ptr - G4Track* seco = (*secondaries)[i]; - - // setup new trk info for seco - TrackInformation* secoTrkInfo = new TrackInformation( parTrkInfo ); - seco->SetUserInformation( secoTrkInfo ); - - // set vtxnotendp flag in trk info - if ( parTrj ) { - - // get parent's endpoint - G4ThreeVector parEndpoint = getTrajectoryEndpoint( parTrj ); - - // check if direct parent (flag always on if not) OR endp not near - if ( secoTrkInfo->getOriginalTrackID() != aTrack->GetTrackID() || - vertexIsNotEndpointOfParent( parEndpoint, seco ) ) { - - // set vertexIsNotEndpointOfParent flag in trk info - secoTrkInfo->setVertexIsNotEndpointOfParent( true ); - } - } - // vtxnotendp always set, because parent is not stored - else { - secoTrkInfo->setVertexIsNotEndpointOfParent( true ); - } - } - -#ifdef SLIC_LOG - log() << LOG::verbose << "track info passed to <" << nseco << "> secondaries" << LOG::endl; -#endif - } - } - - bool TrajectoryManager::needsManualTrajectorySetup(const G4Track* aTrack) - { - // store != ON and has a corresponding tracker hit - return ( !m_trackingManager->GetStoreTrajectory() ) && - ( TrackInformation::getTrackInformation( aTrack )->hasTrackerHit() ); - } - - void TrajectoryManager::stepping(const G4Step* aStep) - { - const G4Track* theTrack = aStep->GetTrack(); - - // step has a live track - if ( isAlive( aStep ) ) { - - TrackInformation* trkInfo = TrackInformation::getTrackInformation( theTrack ); - - G4UserRegionInformation* preReg = G4UserRegionInformation::getRegionInformation( aStep->GetPreStepPoint() ); - G4UserRegionInformation* postReg = G4UserRegionInformation::getRegionInformation( aStep->GetPostStepPoint() ); - - // set tracking status based on region info - if ( preReg && postReg ) { - - // tracking to non-tracking - if ( preReg->getStoreSecondaries() && ( !postReg->getStoreSecondaries() ) ) { - trkInfo->setTrackingStatus( TrackInformation::eInNontrackingRegion ); - } - // non-tracking to tracking - else if ( !preReg->getStoreSecondaries() && postReg->getStoreSecondaries() ) { - TrackInformation::ETrackingStatus origStatus = trkInfo->getOriginalTrackingStatus(); - - // if looped like tracking -> nontracking -> tracking without dying - if ( ! ( origStatus == TrackInformation::eInTrackingRegion ) ) { - trkInfo->setBackscatter(true); - } - - // set tracking status to tracking - trkInfo->setTrackingStatus( TrackInformation::eInTrackingRegion ); - } - } - } - } - - void TrajectoryManager::setTrajectoryFinalStatus(const G4Track* aTrack) - { - // get current traj - Trajectory* trj = getCurrentTrajectory(); - - // must have trajectory to set status - if ( trj ) { - - G4StepPoint* postStep = aTrack->GetStep()->GetPostStepPoint(); - - // get track info - TrackInformation* trkInfo = - TrackInformation::getTrackInformation( aTrack ); - - // has endpoint daughters - G4int nSecoAtEnd = getNumberOfSecondariesAtEnd( aTrack ); - if ( nSecoAtEnd > 0 ) { - trj->setHasEndpointDaughters( true ); - } - - // default final status to unset - Trajectory::EFinalStatus finalStatus = Trajectory::eUnset; - - // backscatter from track info - trj->setBackscatter( trkInfo->getBackscatter() ); - - // vertexIsNotEndpointOfParent - if ( trkInfo->getVertexIsNotEndpointOfParent() ) { - trj->setVertexIsNotEndpointOfParent( true ); - } - - // no decay -> no secondaries at end - if ( nSecoAtEnd <= 0 ) { - // left detector - if ( !postStep->GetMaterial() ) { - finalStatus = Trajectory::eLeftDetector; - } - - // stopped - else if ( aTrack->GetKineticEnergy() <= 0. ) { - finalStatus = Trajectory::eStopped; - } - // unflagged loopers killed by G4
+ // loop over secondaries to 1) create trk info and 2) set vertexIsNotEndpointOfParent flag + if (secondaries) { + size_t nseco = secondaries->size(); + for (size_t i = 0; i < nseco; i++) { + + // set current seco track ptr + G4Track* seco = (*secondaries)[i]; + + // setup new trk info for seco + TrackInformation* secoTrkInfo = new TrackInformation(parTrkInfo); + seco->SetUserInformation(secoTrkInfo); + + // set vtxnotendp flag in trk info + if (parTrj) { + + // get parent's endpoint + G4ThreeVector parEndpoint = getTrajectoryEndpoint(parTrj); + + // check if direct parent (flag always on if not) OR endp not near + if (secoTrkInfo->getOriginalTrackID() != aTrack->GetTrackID() + || vertexIsNotEndpointOfParent(parEndpoint, seco)) { + + // set vertexIsNotEndpointOfParent flag in trk info + secoTrkInfo->setVertexIsNotEndpointOfParent(true); + } + } + // vtxnotendp always set, because parent is not stored + else { + secoTrkInfo->setVertexIsNotEndpointOfParent(true); + } + } + +#ifdef SLIC_LOG + log() << LOG::verbose << "track info passed to <" << nseco << "> secondaries" << LOG::endl; +#endif + } +} + +bool TrajectoryManager::needsManualTrajectorySetup(const G4Track* aTrack) { + // store != ON and has a corresponding tracker hit + return (!m_trackingManager->GetStoreTrajectory()) + && (TrackInformation::getTrackInformation(aTrack)->hasTrackerHit()); +} + +void TrajectoryManager::stepping(const G4Step* aStep) { + const G4Track* theTrack = aStep->GetTrack(); + + // step has a live track + if (isAlive(aStep)) { + + TrackInformation* trkInfo = TrackInformation::getTrackInformation(theTrack); + + G4UserRegionInformation* preReg = G4UserRegionInformation::getRegionInformation( + aStep->GetPreStepPoint()); + G4UserRegionInformation* postReg = G4UserRegionInformation::getRegionInformation( + aStep->GetPostStepPoint()); + + // set tracking status based on region info + if (preReg && postReg) { + + // tracking to non-tracking + if (preReg->getStoreSecondaries() && (!postReg->getStoreSecondaries())) { + trkInfo->setTrackingStatus(TrackInformation::eInNontrackingRegion); + } + // non-tracking to tracking + else if (!preReg->getStoreSecondaries() && postReg->getStoreSecondaries()) { + TrackInformation::ETrackingStatus origStatus = trkInfo->getOriginalTrackingStatus(); + + // if looped like tracking -> nontracking -> tracking without dying + if (!(origStatus == TrackInformation::eInTrackingRegion)) { + trkInfo->setBackscatter(true); + } + + // set tracking status to tracking + trkInfo->setTrackingStatus(TrackInformation::eInTrackingRegion); + } + } + } +} + +void TrajectoryManager::setTrajectoryFinalStatus(const G4Track* aTrack) { + // get current traj + Trajectory* trj = getCurrentTrajectory(); + + // must have trajectory to set status + if (trj) { + + G4StepPoint* postStep = aTrack->GetStep()->GetPostStepPoint(); + + // get track info + TrackInformation* trkInfo = TrackInformation::getTrackInformation(aTrack); + + // has endpoint daughters + G4int nSecoAtEnd = getNumberOfSecondariesAtEnd(aTrack); + if (nSecoAtEnd > 0) { + trj->setHasEndpointDaughters(true); + } + + // default final status to unset + Trajectory::EFinalStatus finalStatus = Trajectory::eUnset; + + // backscatter from track info + trj->setBackscatter(trkInfo->getBackscatter()); + + // vertexIsNotEndpointOfParent + if (trkInfo->getVertexIsNotEndpointOfParent()) { + trj->setVertexIsNotEndpointOfParent(true); + } + + // no decay -> no secondaries at end + if (nSecoAtEnd <= 0) { + // left detector + if (!postStep->GetMaterial()) { + finalStatus = Trajectory::eLeftDetector; + } + + // stopped + else if (aTrack->GetKineticEnergy() <= 0.) { + finalStatus = Trajectory::eStopped; + } + // unflagged loopers killed by G4
#ifdef SLIC_DEBUG
- else { - log() << LOG::debug << "Unknown decay case (probably a looper)." << LOG::done; - } -#endif - } - // decayed - else { - - // decayed in tracker - if ( trkInfo->getTrackingStatus() == TrackInformation::eInTrackingRegion ) { - finalStatus = Trajectory::eDecayedInTracker; - } - // process of elimination: decayed in calorimeter - else { - finalStatus = Trajectory::eDecayedInCalorimeter; - } - } - - // set final status in trajectory - trj->setFinalStatus( finalStatus ); - } - } - - void TrajectoryManager::printTrack(const G4Track* trk, bool isSecondary) - { - log() << LOG::endl; - log() << "track ptr <" << trk << ">" << LOG::endl; - log() << "trackID <" << trk->GetTrackID() << ">" << LOG::endl; - log() << "parent trackID <" << trk->GetParentID() << ">" << LOG::endl; - log() << "PDG <" << trk->GetDefinition()->GetPDGEncoding() << ">" << LOG::endl; - log() << "position <" << trk->GetPosition() << ">" << LOG::endl; - - if ( !isSecondary ) { - if ( trk->GetMaterial() ) { - log() << "material <" << trk->GetMaterial()->GetName() << ">" << LOG::endl; - } - else { - log() << "NO material" << LOG::endl; - } - - if ( trk->GetVolume() ) { - log() << "volume <" << trk->GetVolume()->GetName() << ">" << LOG::endl; - } - else { - log() << "NO volume" << LOG::endl; - } - } - - if ( !isSecondary ) { - log() << "numSecoAtEnd <" << getNumberOfSecondariesAtEnd(trk) << ">" << LOG::endl; - } - - log() << "kE <" << trk->GetKineticEnergy() << ">" << LOG::endl; - log() << "mom <" << trk->GetMomentum() << ">" << LOG::endl; - - printStatusFlags(trk); - - log() << LOG::endl; - } - - void TrajectoryManager::printPhysVolDbg(G4StepPoint* stepPnt) - { - if ( stepPnt ) { - G4VPhysicalVolume* pv = stepPnt->GetPhysicalVolume(); - - if ( pv ) { - log() << LOG::debug << "PV name <" << pv->GetName() << ">" << LOG::endl; - } - else { - log() << LOG::debug << "PV is NULL!" << LOG::endl; - } - } - } - - - G4int TrajectoryManager::getNumberOfSecondariesAtEnd(const G4Track* aTrack) - { - G4int numSecoAtEnd = 0; - G4TrackVector* seco = m_trackingManager->GimmeSecondaries(); - G4ThreeVector endPnt = aTrack->GetPosition(); - - if ( seco ) { - size_t numSeco = seco->size(); - -#ifdef SLIC_LOG - log() << LOG::debug << "numSeco <" << numSeco << ">" << LOG::endl; -#endif - - for( size_t i = 0; - i < numSeco; - i++ ) { - // if seco endpoint near track's endpoint - if ( (*seco)[i]->GetPosition().isNear( endPnt ) ) { - ++numSecoAtEnd; - } - } - } - -#ifdef SLIC_LOG - log() << LOG::debug << "found numSecoAtEnd <" << numSecoAtEnd << ">" << LOG::endl; -#endif - - return numSecoAtEnd; - } - - - void TrajectoryManager::fillTrackIDToTrajectoryMap( const G4Event* anEvent, bool clearIt) - { -#ifdef SLIC_LOG - log() << LOG::verbose << "fillTrackIDToTrajectoryMap()" << LOG::endl; -#endif - if ( clearIt ) - { - clearTrackIDToTrajectoryMap(); - } - - G4TrajectoryContainer* trajCont = anEvent->GetTrajectoryContainer(); - - if ( trajCont ) - { - G4int n_traj = trajCont->entries(); - - Trajectory* trj = 0; - for ( int i=0; i < n_traj; i++ ) - { - trj = static_cast<Trajectory*> ( (*trajCont)[i] ); - addTrackIDToTrajectoryLink( trj ); - } - } - else - { - log() << LOG::error << "Cannot fill map without a trajectory container!" << LOG::endl; - } - } - - void TrajectoryManager::addTrackIDToTrajectoryLink( Trajectory* trj) - { - if ( trj ) { - m_trackIDToTrajectory[ trj->GetTrackID() ] = trj; - } - else { - log() << LOG::error << "Trajectory is null!" << LOG::endl; - } - } - - void TrajectoryManager::printSecondaries() - { - log() << LOG::debug - << "secondaries for trackID <" - << m_trackingManager->GetTrack()->GetTrackID() - << ">" - << LOG::done; - - G4TrackVector* secondaries = m_trackingManager->GimmeSecondaries();[truncated at 1000 lines; 204 more skipped]
diff -u -r1.6 -r1.7 --- VRML2Writer.cc 19 Jan 2011 21:29:27 -0000 1.6 +++ VRML2Writer.cc 27 Nov 2012 19:32:19 -0000 1.7 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/VRML2Writer.cc,v 1.6 2011/01/19 21:29:27 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/VRML2Writer.cc,v 1.7 2012/11/27 19:32:19 jeremy Exp $
#include "VRML2Writer.hh" // stl
@@ -20,216 +20,194 @@
#include "math.h"
-namespace slic -{
+namespace slic {
- VRML2Writer::VRML2Writer(const::std::string& filename) - : _indentLevel(0) - { - _out.open(filename.c_str()); - } - - VRML2Writer::~VRML2Writer() - { - if (_out.is_open()) - _out.close(); - } - - void VRML2Writer::write() - { - writeLine("#VRML V2.0 utf8"); - processTopVolume( G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume() ); - } - - void VRML2Writer::processTopVolume(G4VPhysicalVolume* wv) - { - writeLine("Group {"); - indent(); - writeLine("children ["); - indent(); - processPhysicalVolume(wv); - unindent(); - writeLine("]"); - unindent(); - writeLine("}"); // Group - } - - void VRML2Writer::processPhysicalVolume(G4VPhysicalVolume* pv) - { - writeLine("DEF " + pv->GetName() + " Transform {"); - indent(); - writeLine("children ["); - indent(); - - // shape node for each physical volume - const G4VisAttributes* vis = pv->GetLogicalVolume()->GetVisAttributes(); - bool show = true; - if (vis && !vis->IsVisible()) show = false; - if (show) - { - writeLine("DEF " + pv->GetName() + " Shape {"); - indent(); - processVisualization(pv); - processSolid(pv->GetLogicalVolume()->GetSolid()); - unindent(); - writeLine("}"); - } - - G4LogicalVolume* lv = pv->GetLogicalVolume(); - - // Recurse through daughter volumes - bool showDaughters = true; - if (vis && vis->IsDaughtersInvisible()) showDaughters = false; - if (showDaughters) - { - for (int i=0, ndau=lv->GetNoDaughters(); i < ndau; i++) - { - processPhysicalVolume(lv->GetDaughter(i)); - } - } - - unindent(); - writeLine("]"); // children - - // translation - const G4ThreeVector& pos = pv->GetTranslation(); - std::stringstream ss; - ss << "translation " << pos.x() / m << " " << pos.y() / m << " " << pos.z() / m; - writeLine(ss.str()); - - // rotation - const G4RotationMatrix* rot = pv->GetRotation(); - CLHEP::Hep3Vector axis(0,0,0); - double angle = 0; - if (rot != 0) - rot->getAngleAxis(angle, axis); - std::stringstream ss2; - ss2 << "rotation " << axis.x() << " " << axis.y() << " " << axis.z() << " " << -angle; - rot = 0; - writeLine(ss2.str()); - - unindent(); - writeLine("}"); // Transform - } - - void VRML2Writer::processVisualization(G4VPhysicalVolume* pv) - { - const G4VisAttributes* vis = pv->GetLogicalVolume()->GetVisAttributes(); - double r, g, b; - r = g = b = 1.0; - if ( vis != 0 ) - { - const G4Colour& col = vis->GetColour(); - r = col.GetRed(); - g = col.GetGreen(); - b = col.GetBlue(); - } - writeLine("appearance Appearance {"); - indent(); - writeLine("material Material {"); - indent(); - std::stringstream ss; - ss << r << " " << g << " " << b; - writeLine("diffuseColor " + ss.str()); - writeLine("transparency 0.0"); // use viewer like Deep View to get a wireframe or transparent view - unindent(); - writeLine("}"); - unindent(); - writeLine("}"); - } - - void VRML2Writer::processSolid(G4VSolid* solid) - { - if (solid->GetEntityType() == "G4Box") - { - processBox((G4Box*)solid); - } - else - { - processPolyhedron(solid->GetPolyhedron()); - } - } - - void VRML2Writer::processBox(G4Box* box) - { - writeLine("geometry Box {"); - indent(); - std::stringstream ss; - ss << "size " - << box->GetXHalfLength() * 2 / m << " " - << box->GetYHalfLength() * 2 / m << " " - << box->GetZHalfLength() * 2 / m; - writeLine(ss.str()); - unindent(); - writeLine("}"); - } - - // code taken from Geant4.... - // G4MVRL2SceneHandlerFunc.icc - G4VRML2SCENEHANDLER::AddPrimitive(const G4Polyhedron& polyhedron) - void VRML2Writer::processPolyhedron(G4Polyhedron* polyhedron) - { - writeLine("geometry IndexedFaceSet {"); - indent(); - writeLine("coord Coordinate {"); - indent(); - writeLine("point ["); - indent(); - - int i, j; - for (i = 1, j = polyhedron->GetNoVertices(); j; j--, i++) - { - G4Point3D point = polyhedron->GetVertex(i); - std::stringstream ss; - ss << point.x() / m << " " << point.y() / m << " " << point.z() / m; - writeLine(ss.str()); - } - unindent(); - writeLine("]"); // point - unindent(); - writeLine("}"); // coord - - writeLine("coordIndex ["); - indent(); - - // facet loop - int f; - for (f = polyhedron->GetNoFacets(); f; f--) - { - // edge loop - bool notLastEdge; - int index = -1, edgeFlag = 1; - std::stringstream ss; - do { - notLastEdge = polyhedron->GetNextVertexIndex(index, edgeFlag); - ss << index - 1 << ", "; - } while (notLastEdge); - ss << "-1, "; - writeLine(ss.str()); - } - - unindent(); - writeLine("]"); - writeLine("solid FALSE"); - unindent(); - writeLine("}"); // IndexFaceSet - } - - void VRML2Writer::writeLine(const std::string& text) - { - for (int i=0; i<_indentLevel; i++) - { - _out << " "; - } - _out << text << std::endl; - } - - void VRML2Writer::indent() - { - ++_indentLevel; - } - - void VRML2Writer::unindent() - { - --_indentLevel; - }
+VRML2Writer::VRML2Writer(const ::std::string& filename) : + _indentLevel(0) { + _out.open(filename.c_str()); +} + +VRML2Writer::~VRML2Writer() { + if (_out.is_open()) + _out.close(); +} + +void VRML2Writer::write() { + writeLine("#VRML V2.0 utf8"); + processTopVolume( + G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()); +} + +void VRML2Writer::processTopVolume(G4VPhysicalVolume* wv) { + writeLine("Group {"); + indent(); + writeLine("children ["); + indent(); + processPhysicalVolume(wv); + unindent(); + writeLine("]"); + unindent(); + writeLine("}"); // Group +} + +void VRML2Writer::processPhysicalVolume(G4VPhysicalVolume* pv) { + writeLine("DEF " + pv->GetName() + " Transform {"); + indent(); + writeLine("children ["); + indent(); + + // shape node for each physical volume + const G4VisAttributes* vis = pv->GetLogicalVolume()->GetVisAttributes(); + bool show = true; + if (vis && !vis->IsVisible()) + show = false; + if (show) { + writeLine("DEF " + pv->GetName() + " Shape {"); + indent(); + processVisualization(pv); + processSolid(pv->GetLogicalVolume()->GetSolid()); + unindent(); + writeLine("}"); + } + + G4LogicalVolume* lv = pv->GetLogicalVolume(); + + // Recurse through daughter volumes + bool showDaughters = true; + if (vis && vis->IsDaughtersInvisible()) + showDaughters = false; + if (showDaughters) { + for (int i = 0, ndau = lv->GetNoDaughters(); i < ndau; i++) { + processPhysicalVolume(lv->GetDaughter(i)); + } + } + + unindent(); + writeLine("]"); // children + + // translation + const G4ThreeVector& pos = pv->GetTranslation(); + std::stringstream ss; + ss << "translation " << pos.x() / m << " " << pos.y() / m << " " << pos.z() / m; + writeLine(ss.str()); + + // rotation + const G4RotationMatrix* rot = pv->GetRotation(); + CLHEP::Hep3Vector axis(0, 0, 0); + double angle = 0; + if (rot != 0) + rot->getAngleAxis(angle, axis); + std::stringstream ss2; + ss2 << "rotation " << axis.x() << " " << axis.y() << " " << axis.z() << " " << -angle; + rot = 0; + writeLine(ss2.str()); + + unindent(); + writeLine("}"); // Transform +} + +void VRML2Writer::processVisualization(G4VPhysicalVolume* pv) { + const G4VisAttributes* vis = pv->GetLogicalVolume()->GetVisAttributes(); + double r, g, b; + r = g = b = 1.0; + if (vis != 0) { + const G4Colour& col = vis->GetColour(); + r = col.GetRed(); + g = col.GetGreen(); + b = col.GetBlue(); + } + writeLine("appearance Appearance {"); + indent(); + writeLine("material Material {"); + indent(); + std::stringstream ss; + ss << r << " " << g << " " << b; + writeLine("diffuseColor " + ss.str()); + writeLine("transparency 0.0"); // use viewer like Deep View to get a wireframe or transparent view + unindent(); + writeLine("}"); + unindent(); + writeLine("}"); +} + +void VRML2Writer::processSolid(G4VSolid* solid) { + if (solid->GetEntityType() == "G4Box") { + processBox((G4Box*) solid); + } else { + processPolyhedron(solid->GetPolyhedron()); + } +} + +void VRML2Writer::processBox(G4Box* box) { + writeLine("geometry Box {"); + indent(); + std::stringstream ss; + ss << "size " << box->GetXHalfLength() * 2 / m << " " << box->GetYHalfLength() * 2 / m << " " + << box->GetZHalfLength() * 2 / m; + writeLine(ss.str()); + unindent(); + writeLine("}"); +} + +// code taken from Geant4.... +// G4MVRL2SceneHandlerFunc.icc - G4VRML2SCENEHANDLER::AddPrimitive(const G4Polyhedron& polyhedron) +void VRML2Writer::processPolyhedron(G4Polyhedron* polyhedron) { + writeLine("geometry IndexedFaceSet {"); + indent(); + writeLine("coord Coordinate {"); + indent(); + writeLine("point ["); + indent(); + + int i, j; + for (i = 1, j = polyhedron->GetNoVertices(); j; j--, i++) { + G4Point3D point = polyhedron->GetVertex(i); + std::stringstream ss; + ss << point.x() / m << " " << point.y() / m << " " << point.z() / m; + writeLine(ss.str()); + } + unindent(); + writeLine("]"); // point + unindent(); + writeLine("}"); // coord + + writeLine("coordIndex ["); + indent(); + + // facet loop + int f; + for (f = polyhedron->GetNoFacets(); f; f--) { + // edge loop + bool notLastEdge; + int index = -1, edgeFlag = 1; + std::stringstream ss; + do { + notLastEdge = polyhedron->GetNextVertexIndex(index, edgeFlag); + ss << index - 1 << ", "; + } while (notLastEdge); + ss << "-1, "; + writeLine(ss.str()); + } + + unindent(); + writeLine("]"); + writeLine("solid FALSE"); + unindent(); + writeLine("}"); // IndexFaceSet +} + +void VRML2Writer::writeLine(const std::string& text) { + for (int i = 0; i < _indentLevel; i++) { + _out << " "; + } + _out << text << std::endl; +} + +void VRML2Writer::indent() { + ++_indentLevel; +} + +void VRML2Writer::unindent() { + --_indentLevel; +}
}
diff -u -r1.1 -r1.2 --- VRML2WriterMessenger.cc 7 Jul 2009 21:39:19 -0000 1.1 +++ VRML2WriterMessenger.cc 27 Nov 2012 19:32:19 -0000 1.2 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/VRML2WriterMessenger.cc,v 1.1 2009/07/07 21:39:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/VRML2WriterMessenger.cc,v 1.2 2012/11/27 19:32:19 jeremy Exp $
#include "VRML2WriterMessenger.hh"
@@ -10,32 +10,30 @@
#include "G4UIdirectory.hh" #include "G4UIcmdWithAString.hh"
-namespace slic -{
+namespace slic {
- VRML2WriterMessenger::VRML2WriterMessenger() - { - m_vrmlDir = new G4UIdirectory("/vrml/"); - m_vrmlDir->SetGuidance( "Test VRML2Writer. [SLIC]" ); - - m_writeVrmlCmd = new G4UIcmdWithAString( "/vrml/writeVRML", this ); - m_writeVrmlCmd->SetGuidance( "Write VRML of current geometry to a file." ); - - } - - VRML2WriterMessenger::~VRML2WriterMessenger() - {;} - - void VRML2WriterMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) - { - G4String fname; - if (newVals == "") - fname = "geometry.wrl"; - else - fname = newVals; - VRML2Writer* writer = new VRML2Writer(fname); - writer->write(); - delete writer; - writer = 0; - }
+VRML2WriterMessenger::VRML2WriterMessenger() { + m_vrmlDir = new G4UIdirectory("/vrml/"); + m_vrmlDir->SetGuidance("Test VRML2Writer. [SLIC]"); + + m_writeVrmlCmd = new G4UIcmdWithAString("/vrml/writeVRML", this); + m_writeVrmlCmd->SetGuidance("Write VRML of current geometry to a file."); + +} + +VRML2WriterMessenger::~VRML2WriterMessenger() { + ; +} + +void VRML2WriterMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) { + G4String fname; + if (newVals == "") + fname = "geometry.wrl"; + else + fname = newVals; + VRML2Writer* writer = new VRML2Writer(fname); + writer->write(); + delete writer; + writer = 0; +}
}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1