Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HardProcess.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HardProcess.cc
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 #include "HardProcess.h"
17 #include "JetScapeLogger.h"
18 #include "JetScapeXML.h"
19 #include "JetScapeSignalManager.h"
20 #include <string>
21 
22 #include <iostream>
23 
24 using namespace std;
25 
26 #define MAGENTA "\033[35m"
27 
28 namespace Jetscape {
29 
30 HardProcess::HardProcess() {
31  VERBOSE(8);
32  SetId("HardProcess");
33 }
34 
35 HardProcess::~HardProcess() {
36  VERBOSE(8);
37  hp_list.clear();
38  hd_list.clear();
39  disconnect_all();
40 }
41 
44 
45  JSINFO << "Initialize HardProcess : " << GetId() << " ...";
46 
47  VERBOSE(8);
48 
49  ini = JetScapeSignalManager::Instance()->GetInitialStatePointer().lock();
50  if (!ini) {
51 
52  // If not vacuum case, give warning to add initial state module
53  bool in_vac = GetXMLElementInt({"Eloss", "Matter", "in_vac"});
54  if (!in_vac) {
55  JSWARN << "No initial state module! Please check whether you intend to "
56  "add an initial state module.";
57  }
58  }
59  string status = GetXMLElementText({"PartonPrinter","Status"});
60  if (status!="off")
61  {
62  printer = GetXMLElementText({"PartonPrinter","FileName"});
63  JSINFO << BOLDYELLOW << "Extra parton info goes to " << printer ;
64  }
65  InitTask();
66 
67  JetScapeTask::InitTasks();
68 }
69 
70 void HardProcess::Exec() {
71  JSINFO << "Run Hard Process : " << GetId() << " ...";
72  VERBOSE(8) << "Current Event #" << GetCurrentEvent();
73 
74  JetScapeTask::ExecuteTasks();
75 }
76 
78  JSDEBUG << "Clear Hard Process : " << GetId() << " ...";
79 
80  hp_list.clear();
81  hd_list.clear();
82  VERBOSE(8) << hp_list.size();
83 }
84 
85 void HardProcess::WriteTask(weak_ptr<JetScapeWriter> w) {
86  VERBOSE(8);
87 
88  auto f = w.lock();
89  if (f) {
90  VERBOSE(8) << f->GetOutputFileName();
91 
92  // Weight, xsec, etc
93 
94  // // Can explicitly write our own header information, though the writer should handle this.
95  // std::ostringstream oss;
96  // oss.str(""); oss << GetId() << " sigmaGen = " << GetSigmaGen();
97  // f->WriteComment ( oss.str() );
98  // oss.str(""); oss << GetId() << " sigmaErr = " << GetSigmaErr();
99  // f->WriteComment ( oss.str() );
100  // oss.str(""); oss << GetId() << " weight = " << GetEventWeight();
101  // f->WriteComment ( oss.str() );
102 
103  // Hard partons
104  f->WriteComment("HardProcess Parton List: " + GetId());
105  for (auto hp : hp_list)
106  f->Write(hp);
107  }
108 }
109 
110 void HardProcess::CollectHeader(weak_ptr<JetScapeWriter> w) {
111  auto f = w.lock();
112  if (f) {
113  auto &header = f->GetHeader();
114  header.SetSigmaGen(GetSigmaGen());
115  header.SetSigmaErr(GetSigmaErr());
116  header.SetPtHat(GetPtHat());
117  header.SetEventWeight(GetEventWeight());
118  }
119 }
120 
121 } // end namespace Jetscape