Back to home page

sPhenix code displayed by LXR

 
 

    


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

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 #ifndef INITIALFROMFILE_H
0017 #define INITIALFROMFILE_H
0018 
0019 #include <iostream>
0020 #include <string>
0021 #include <sstream>
0022 #include <cmath>
0023 #include "hdf5.h"
0024 #include "Hydroinfo_h5.h"
0025 #include "JetScapeModuleBase.h"
0026 #include "InitialState.h"
0027 #include "JetScapeLogger.h"
0028 
0029 using namespace Jetscape;
0030 
0031 class InitialFromFile : public Jetscape::InitialState {
0032   // this is wrapper class to read external files that
0033   // stores initial number of binary collisions and corresponding
0034   // configurations
0035 public:
0036   InitialFromFile();
0037   ~InitialFromFile();
0038 
0039   /** Reads the input parameters from the XML file under the tag  <IS>. Calls InitTask(); This explicit call of InitTask() can be used for actual initialization of modules such as @a Trento if attached as a @a polymorphic class. It also initializes the tasks within the current module.
0040       @sa Read about @a polymorphism in C++.
0041    */
0042   //void Init();
0043 
0044   /** Default Exec() function. It can be overridden by other tasks.
0045    */
0046   void Exec();
0047 
0048   /** Default Clear() function. It can be overridden by other tasks.
0049    */
0050   void Clear();
0051 
0052   void InitTask();
0053 
0054   /** Default Write() function. It can be overridden by other tasks.
0055       @param w A pointer to the JetScapeWriter class.
0056    */
0057   virtual void Write(weak_ptr<JetScapeWriter> w);
0058 
0059   /** Generated number of collision participants.
0060   */
0061   double GetNpart() { return npart; };
0062 
0063   /** Generated number of binary collisions.
0064   */
0065   double GetNcoll() { return ncoll; };
0066 
0067   /** Generated total entropy
0068   */
0069   double GetTotalEntropy() { return totalentropy; };
0070 
0071 private:
0072   // the hdf5 file pointer, e.g. *.hdf5
0073   hid_t H5file_ptr_;
0074 
0075   // the hdf5/group pointer, e.g. /event0
0076   hid_t H5group_ptr_;
0077 
0078   //! Load saved configurations for each event
0079   void ReadConfigs();
0080 
0081   //! Load saved number of binary collisions
0082   void ReadNbcDist();
0083 
0084   //! Load saved initial entropy density distribution
0085   void ReadEntropyDist();
0086 
0087   //! want to use auxiliary hdf5 file readers
0088   HydroinfoH5 *h5_helper_;
0089 
0090   int dim_x_, dim_y_;
0091 
0092   double npart = -1;
0093   double ncoll = -1;
0094   double totalentropy = -1;
0095 
0096   // Allows the registration of the module so that it is available to be used by the Jetscape framework.
0097   static RegisterJetScapeModule<InitialFromFile> reg;
0098 };
0099 
0100 #endif // INITIALFROMFILE_H