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 // Use CRTP for cloning of derived class in base class
0017 
0018 #ifndef JETENERGYLOSSMODULE_H
0019 #define JETENERGYLOSSMODULE_H
0020 
0021 #include "JetEnergyLoss.h"
0022 
0023 using std::abs;
0024 using std::uniform_real_distribution;
0025 
0026 namespace Jetscape {
0027 
0028 template <typename Derived> class JetEnergyLossModule : public JetEnergyLoss {
0029 
0030 public:
0031   using JetEnergyLoss::JetEnergyLoss;
0032 
0033   //! Deep copy constructor. The goal is to not have to initialize Modules multiple times
0034   virtual shared_ptr<JetEnergyLoss> Clone() const override {
0035     JSDEBUG << "Cloning task with id=" << GetId()
0036             << " and TaskNumber= " << GetMyTaskNumber();
0037     // DEBUG/TODO: KK: Joern's plan was to not have to call Init again, but I'm not sure that can work/is desirable.
0038     auto ret = make_shared<Derived>(static_cast<const Derived &>(*this));
0039     //ret->Init();
0040     return ret;
0041   }
0042 
0043   //! Override deactivation
0044   void SetActive(bool m_active_exec) {
0045     throw std::runtime_error("SetActive not supported for energy loss modules. "
0046                              "Please remove the module from the manager.");
0047   };
0048 
0049 protected:
0050   /** Only one Eloss module at a time should be manipulating a parton
0051    * In the current setup, that's all but impossible to impose and relies
0052    * on cooperation between modules. 
0053    * This is a crude way (relying on self-reporting) to check that this is always the case.
0054    */
0055   bool TakeResponsibilityFor(Parton &p) {
0056     if (p.GetControlled()) {
0057       JSWARN << " Parton was controlled by " << p.GetController() << ". Now "
0058              << GetId() << " is trying to take responsibility as well.";
0059       throw std::runtime_error(
0060           "Two Eloss modules were fighting for one parton!");
0061     };
0062     // cout << " &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Was controlled by " << p.GetController() << endl;
0063     bool wascontrolled = p.SetController(GetId());
0064     // cout << " &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Now controlled by " << p.GetController() << endl;
0065     return wascontrolled;
0066   };
0067 };
0068 
0069 } // end namespace Jetscape
0070 
0071 #endif