Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:19:18

0001 /*******************************************************************************
0002  * Copyright (c) The JETSCAPE Collaboration, 2018
0003  *
0004  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
0005  * 
0006  * For the list of contributors see AUTHORS.
0007  *
0008  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
0009  *
0010  * or via email to bugs.jetscape@gmail.com
0011  *
0012  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
0013  * See COPYING for details.
0014  ******************************************************************************/
0015 
0016 #include "JetScapeModuleBase.h"
0017 #include "JetScapeXML.h"
0018 #include "JetScapeTaskSupport.h"
0019 #include "JetScapeLogger.h"
0020 
0021 #include <iostream>
0022 
0023 namespace Jetscape {
0024 
0025 // Create an instance of the static map to register modules
0026 JetScapeModuleFactory::map_type *JetScapeModuleFactory::moduleMap =
0027     new JetScapeModuleFactory::map_type;
0028 
0029 int JetScapeModuleBase::current_event = 0;
0030 
0031 // ---------------------------------------------------------------------------
0032 /** Default constructor to create a JetScapeModuleBase. It sets the XML file name to a default string value.                                 
0033    */
0034 JetScapeModuleBase::JetScapeModuleBase()
0035     : JetScapeTask(), xml_main_file_name(""), xml_user_file_name(""),
0036       mt19937_generator_(nullptr) {}
0037 
0038 // ---------------------------------------------------------------------------
0039 /** This is a destructor for the JetScapeModuleBase.                       
0040    */
0041 JetScapeModuleBase::~JetScapeModuleBase() { disconnect_all(); }
0042 
0043 // ---------------------------------------------------------------------------
0044 /** A virtual function for a default initialization of a JetScapeModuleBase. It also checks whether a XML file is loaded or not.
0045    */
0046 void JetScapeModuleBase::Init() {
0047   if (!JetScapeXML::Instance()->GetXMLRootMain()) {
0048     JSWARN << "Not a valid JetScape Main XML file or no XML file loaded!";
0049     exit(-1);
0050   }
0051   if (!JetScapeXML::Instance()->GetXMLRootUser()) {
0052     JSWARN << "Not a valid JetScape XML file or no XML file loaded!";
0053     exit(-1);
0054   }
0055 }
0056 
0057 // ---------------------------------------------------------------------------
0058 /** This function returns a random number based on Mersenne-Twister algorithm.
0059    */
0060 shared_ptr<std::mt19937> JetScapeModuleBase::GetMt19937Generator() {
0061   // Instantiate if it isn't there yet
0062   if (!mt19937_generator_) {
0063     mt19937_generator_ =
0064         JetScapeTaskSupport::Instance()->GetMt19937Generator(GetMyTaskNumber());
0065   }
0066   return mt19937_generator_;
0067 }
0068 
0069 } // end namespace Jetscape