Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JetEnergyLossModule.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JetEnergyLossModule.h
1 /*******************************************************************************
2  * Copyright (c) The JETSCAPE Collaboration, 2018
3  *
4  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
5  *
6  * For the list of contributors see AUTHORS.
7  *
8  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
9  *
10  * or via email to bugs.jetscape@gmail.com
11  *
12  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
13  * See COPYING for details.
14  ******************************************************************************/
15 
16 // Use CRTP for cloning of derived class in base class
17 
18 #ifndef JETENERGYLOSSMODULE_H
19 #define JETENERGYLOSSMODULE_H
20 
21 #include "JetEnergyLoss.h"
22 
23 using std::abs;
24 using std::uniform_real_distribution;
25 
26 namespace Jetscape {
27 
28 template <typename Derived> class JetEnergyLossModule : public JetEnergyLoss {
29 
30 public:
32 
34  virtual shared_ptr<JetEnergyLoss> Clone() const override {
35  JSDEBUG << "Cloning task with id=" << GetId()
36  << " and TaskNumber= " << GetMyTaskNumber();
37  // DEBUG/TODO: KK: Joern's plan was to not have to call Init again, but I'm not sure that can work/is desirable.
38  auto ret = make_shared<Derived>(static_cast<const Derived &>(*this));
39  //ret->Init();
40  return ret;
41  }
42 
44  void SetActive(bool m_active_exec) {
45  throw std::runtime_error("SetActive not supported for energy loss modules. "
46  "Please remove the module from the manager.");
47  };
48 
49 protected:
56  if (p.GetControlled()) {
57  JSWARN << " Parton was controlled by " << p.GetController() << ". Now "
58  << GetId() << " is trying to take responsibility as well.";
59  throw std::runtime_error(
60  "Two Eloss modules were fighting for one parton!");
61  };
62  // cout << " &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Was controlled by " << p.GetController() << endl;
63  bool wascontrolled = p.SetController(GetId());
64  // cout << " &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Now controlled by " << p.GetController() << endl;
65  return wascontrolled;
66  };
67 };
68 
69 } // end namespace Jetscape
70 
71 #endif