ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HepMCFlowAfterBurner.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HepMCFlowAfterBurner.cc
1 //
2 // Inspired by code from ATLAS. Thanks!
3 //
4 #include "HepMCFlowAfterBurner.h"
5 
6 #include "PHHepMCGenEvent.h"
7 #include "PHHepMCGenEventMap.h"
8 
9 #include <flowafterburner/flowAfterburner.h>
10 
12 #include <fun4all/SubsysReco.h> // for SubsysReco
13 
14 #include <phool/PHRandomSeed.h>
15 #include <phool/getClass.h>
16 #include <phool/phool.h>
17 
20 
21 #include <iostream>
22 #include <iterator> // for operator!=, reverse_ite...
23 #include <set> // for set, _Rb_tree_const_ite...
24 #include <string>
25 #include <utility> // for pair
26 
27 using namespace std;
28 
29 class PHCompositeNode;
30 namespace HepMC { class GenEvent; }
31 
33 
34 set<string> algoset = {"MINBIAS", "MINBIAS_V2_ONLY", "CUSTOM"};
35 
36 // we want to keep the default eta range identical between here and
37 // the flowAfterburner executable. If you change the default eta range here
38 // please apply the same change to generators/flowAfterburner/main.cc
40  : SubsysReco(name)
41  , algorithmName("MINBIAS")
42  , mineta(-4)
43  , maxeta(4)
44  , minpt(0.)
45  , maxpt(100.)
46  , seedset(0)
47  , seed(0)
48  , randomSeed(11793)
49 {
50 }
51 
53 {
54  if (seedset)
55  {
56  randomSeed = seed;
57  }
58  else
59  {
61  }
62 
64 
65  return 0;
66 }
67 
69 {
70  PHHepMCGenEventMap *genevtmap = findNode::getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap");
71  for (PHHepMCGenEventMap::ReverseIter iter = genevtmap->rbegin(); iter != genevtmap->rend(); ++iter)
72  {
73  PHHepMCGenEvent *genevt = iter->second;
74 
75  HepMC::GenEvent *evt = genevt->getEvent();
76  if (!evt)
77  {
78  cout << PHWHERE << " no evt pointer under HEPMC Node found" << endl;
80  }
81  if (Verbosity() > 0)
82  {
83  cout << "calling flowAfterburner with algorithm "
84  << algorithmName << ", mineta " << mineta
85  << ", maxeta: " << maxeta << ", minpt: " << minpt
86  << ", maxpt: " << maxpt << endl;
87  }
89  }
91 }
92 
93 void HepMCFlowAfterBurner::setSeed(const long il)
94 {
95  seedset = 1;
96  seed = il;
97  randomSeed = seed;
98  // just in case we are already running, kill the engine and make
99  // a new one using the selected seed
100  if (engine)
101  {
102  delete engine;
104  }
105  return;
106 }
107 
108 void HepMCFlowAfterBurner::SaveRandomState(const string &savefile)
109 {
110  if (engine)
111  {
112  engine->saveStatus(savefile.c_str());
113  return;
114  }
115  cout << PHWHERE << " Random engine not started yet" << endl;
116 }
117 
118 void HepMCFlowAfterBurner::RestoreRandomState(const string &savefile)
119 {
120  if (engine)
121  {
122  engine->restoreStatus(savefile.c_str());
123  return;
124  }
125  cout << PHWHERE << " Random engine not started yet" << endl;
126 }
127 
128 void HepMCFlowAfterBurner::Print(const string &/*what*/) const
129 {
130  cout << "FlowAfterBurner parameters:" << endl;
131  cout << "algorithm: " << algorithmName << endl;
132  cout << "mineta: " << mineta << ", maxeta: " << maxeta << endl;
133  cout << "minpt: " << minpt << ", maxpt: " << maxpt << endl;
134  cout << "Implemented algorithms: MINBIAS (default), MINBIAS_V2_ONLY, CUSTOM"
135  << endl;
136  return;
137 }
138 
140 {
141  auto it = algoset.find(name);
142  if (it != algoset.end())
143  {
144  algorithmName = *it;
145  }
146  else
147  {
148  cout << "algorithm " << name << " not in list of possible algorithms" << endl;
149  cout << "possible algorithms are" << endl;
150  for (auto &al : algoset)
151  {
152  cout << al << endl;
153  }
154  }
155  return;
156 }