9 #include "Pythia8/ShowerMEs.h"
21 void ShowerMEs::initPtrVincia(Info* infoPtrIn,
22 SusyLesHouches* slhaPtrIn, VinciaCommon* vinComPtrIn) {
24 coupSMPtr = infoPtr->coupSMPtr;
25 particleDataPtr = infoPtr->particleDataPtr;
26 settingsPtr = infoPtr->settingsPtr;
27 rndmPtr = infoPtr->rndmPtr;
29 vinComPtr = vinComPtrIn;
37 bool ShowerMEs::selectHelicitiesVincia(vector<Particle>& state,
int nIn) {
40 double me2sum = me2Vincia(state, nIn);
41 if (verbose >= superdebug)
42 cout <<
" ShowerMEs::selectHelicities(): "
43 << scientific << me2sum << endl;
46 if (me2sum <= 0.)
return false;
49 int nHelConf = me2hel.size();
50 if (nHelConf <= 0)
return false;
53 double ranHelConf = 0.0;
54 vector<int> hSelected;
55 if (nHelConf >= 2) ranHelConf = rndmPtr->flat() * me2sum;
56 for (map< vector<int>,
double>::iterator it=me2hel.begin();
57 it != me2hel.end(); ++it) {
59 ranHelConf -= it->second;
60 if (ranHelConf <= 0.0) {
61 hSelected = it->first;
65 if (ranHelConf > 0.)
return false;
68 for (
int i = 0; i < (int)state.size(); ++i) state[i].pol(hSelected[i]);
69 if (verbose >= superdebug)
70 cout <<
" ShowerMEs::selectHelicities(): selected " <<
71 makeLabelVincia(hSelected, nIn,
false) << endl;
80 string ShowerMEs::makeLabelVincia(vector<int>&
id,
int nIn,
bool useNames)
83 for (
int i = 0; i < (int)
id.size(); ++i) {
85 if (useNames &&
id[i] != 0) idName = particleDataPtr->name(
id[i]);
86 else idName = num2str(
id[i]);
87 if (i == nIn-1) idName +=
" ->";
98 void ShowerMEs::fillIds(
const Event& event, vector<int>& in, vector<int>& out)
100 in.push_back(event[3].
id());
101 in.push_back(event[4].
id());
102 for (
int i = 4; i <
event.size(); ++i) {
103 if ( event[i].isFinal() ) out.push_back(event[i].id());
111 void ShowerMEs::fillMoms(
const Event& event, vector<Vec4>& p)
const {
112 p.push_back(event[3].p());
113 p.push_back(event[4].p());
114 for (
int i = 4; i <
event.size(); ++i) {
115 if ( event[i].isFinal() ) p.push_back(event[i].p());
123 void ShowerMEs::fillCols(
const Event& event, vector<int>& colors)
const {
124 colors.push_back(event[3].col()); colors.push_back(event[3].acol());
125 colors.push_back(event[4].col()); colors.push_back(event[4].acol());
126 for (
int i = 4; i <
event.size(); ++i) {
127 if ( event[i].isFinal() ) {
128 colors.push_back(event[i].col());
129 colors.push_back(event[i].acol());
139 vector<vector<double> > ShowerMEs::fillMoms(
const Event& event)
const {
142 vector< vector<double> > ret;
143 for (
int i = 0; i < int(p.size()); i++ ) {
144 vector<double> p_tmp(4, 0.);
145 p_tmp[0] = isnan(p[i].e()) ? 0.0 : p[i].e() ;
146 p_tmp[1] = isnan(p[i].px()) ? 0.0 : p[i].px();
147 p_tmp[2] = isnan(p[i].py()) ? 0.0 : p[i].py();
148 p_tmp[3] = isnan(p[i].pz()) ? 0.0 : p[i].pz();
149 ret.push_back(p_tmp);
163 void ShowerMEsPlugin::initPtrVincia(Info* infoPtrIn,
164 SusyLesHouches* slhaPtrIn, VinciaCommon* vinComPtrIn) {
166 coupSMPtr = infoPtr->coupSMPtr;
167 particleDataPtr = infoPtr->particleDataPtr;
168 settingsPtr = infoPtr->settingsPtr;
169 rndmPtr = infoPtr->rndmPtr;
171 vinComPtr = vinComPtrIn;
173 if (mesPtr !=
nullptr)
174 mesPtr->initPtrVincia(infoPtrIn, slhaPtrIn, vinComPtrIn);
181 bool ShowerMEsPlugin::initVincia() {
184 if (name.size() == 0)
return false;
185 if (libPtr ==
nullptr) {
186 if (infoPtr !=
nullptr) libPtr = infoPtr->plugin(name);
187 else libPtr = make_shared<Plugin>(name);
188 if (!libPtr->isLoaded())
return false;
191 NewShowerMEs* newShowerMEs = (NewShowerMEs*)libPtr->symbol(
"newShowerMEs");
192 if (!newShowerMEs)
return false;
193 mesPtr = newShowerMEs();
194 mesPtr->initPtrVincia(infoPtr, slhaPtr, vinComPtr);
198 if (mesPtr !=
nullptr)
return mesPtr->initVincia();
207 bool ShowerMEsPlugin::initDire(Info* infoPtrIn,
string card) {
211 if (name.size() == 0)
return false;
212 if (libPtr ==
nullptr) {
213 if (infoPtr !=
nullptr) libPtr = infoPtr->plugin(name);
214 else libPtr = make_shared<Plugin>(name);
215 if (!libPtr->isLoaded())
return false;
218 NewShowerMEs* newShowerMEs = (NewShowerMEs*)libPtr->symbol(
"newShowerMEs");
219 if (!newShowerMEs)
return false;
220 mesPtr = newShowerMEs();
224 if (mesPtr !=
nullptr)
return mesPtr->initDire(infoPtr, card);
233 ShowerMEsPlugin::~ShowerMEsPlugin() {
236 if (mesPtr ==
nullptr || libPtr ==
nullptr || !libPtr->isLoaded())
return;
237 DeleteShowerMEs* deleteShowerMEs =
238 (DeleteShowerMEs*)libPtr->symbol(
"deleteShowerMEs");
239 if (deleteShowerMEs) deleteShowerMEs(mesPtr);