Back to home page

sPhenix code displayed by LXR

 
 

    


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

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 "HardProcess.h"
0017 #include "JetScapeLogger.h"
0018 #include "JetScapeXML.h"
0019 #include "JetScapeSignalManager.h"
0020 #include <string>
0021 
0022 #include <iostream>
0023 
0024 using namespace std;
0025 
0026 #define MAGENTA "\033[35m"
0027 
0028 namespace Jetscape {
0029 
0030 HardProcess::HardProcess() {
0031   VERBOSE(8);
0032   SetId("HardProcess");
0033 }
0034 
0035 HardProcess::~HardProcess() {
0036   VERBOSE(8);
0037   hp_list.clear();
0038   hd_list.clear();
0039   disconnect_all();
0040 }
0041 
0042 void HardProcess::Init() {
0043   JetScapeModuleBase::Init();
0044 
0045   JSINFO << "Initialize HardProcess : " << GetId() << " ...";
0046 
0047   VERBOSE(8);
0048 
0049   ini = JetScapeSignalManager::Instance()->GetInitialStatePointer().lock();
0050   if (!ini) {
0051 
0052     // If not vacuum case, give warning to add initial state module
0053     bool in_vac = GetXMLElementInt({"Eloss", "Matter", "in_vac"});
0054     if (!in_vac) {
0055       JSWARN << "No initial state module! Please check whether you intend to "
0056                 "add an initial state module.";
0057     }
0058   }
0059     string status = GetXMLElementText({"PartonPrinter","Status"});
0060     if (status!="off")
0061     {
0062         printer = GetXMLElementText({"PartonPrinter","FileName"});
0063         JSINFO << BOLDYELLOW << "Extra parton info goes to " << printer ;
0064     }
0065   InitTask();
0066 
0067   JetScapeTask::InitTasks();
0068 }
0069 
0070 void HardProcess::Exec() {
0071   JSINFO << "Run Hard Process : " << GetId() << " ...";
0072   VERBOSE(8) << "Current Event #" << GetCurrentEvent();
0073 
0074   JetScapeTask::ExecuteTasks();
0075 }
0076 
0077 void HardProcess::Clear() {
0078   JSDEBUG << "Clear Hard Process : " << GetId() << " ...";
0079 
0080   hp_list.clear();
0081   hd_list.clear();
0082   VERBOSE(8) << hp_list.size();
0083 }
0084 
0085 void HardProcess::WriteTask(weak_ptr<JetScapeWriter> w) {
0086   VERBOSE(8);
0087 
0088   auto f = w.lock();
0089   if (f) {
0090     VERBOSE(8) << f->GetOutputFileName();
0091 
0092     // Weight, xsec, etc
0093 
0094     // // Can explicitly write our own header information, though the writer should handle this.
0095     // std::ostringstream oss;
0096     // oss.str(""); oss << GetId() << " sigmaGen  = " << GetSigmaGen();
0097     // f->WriteComment ( oss.str() );
0098     // oss.str(""); oss << GetId() << " sigmaErr  = " << GetSigmaErr();
0099     // f->WriteComment ( oss.str() );
0100     // oss.str(""); oss << GetId() << " weight  = " << GetEventWeight();
0101     // f->WriteComment ( oss.str() );
0102 
0103     // Hard partons
0104     f->WriteComment("HardProcess Parton List: " + GetId());
0105     for (auto hp : hp_list)
0106       f->Write(hp);
0107   }
0108 }
0109 
0110 void HardProcess::CollectHeader(weak_ptr<JetScapeWriter> w) {
0111   auto f = w.lock();
0112   if (f) {
0113     auto &header = f->GetHeader();
0114     header.SetSigmaGen(GetSigmaGen());
0115     header.SetSigmaErr(GetSigmaErr());
0116     header.SetPtHat(GetPtHat());
0117     header.SetEventWeight(GetEventWeight());
0118   }
0119 }
0120 
0121 } // end namespace Jetscape