9 #include "Pythia8/DireSplitInfo.h"
17 void DireSplitKinematics::store (
const DireSplitKinematics& k) {
26 m2RadBef = k.m2RadBef;
28 m2RadAft = k.m2RadAft;
29 m2EmtAft = k.m2EmtAft;
30 m2EmtAft2 = k.m2EmtAft2;
35 void DireSplitKinematics::list() {
36 cout <<
"List DireSplitKinematics:"
37 << scientific << setprecision(3) <<
"\n"
38 <<
" m2Dip = " << m2Dip <<
"\n"
39 <<
" pT2 = " << pT2 <<
"\t"
40 <<
" z = " << z <<
"\t"
41 <<
" phi = " << phi <<
"\n"
42 <<
" sai = " << sai <<
"\t"
43 <<
" xa = " << xa <<
"\t"
44 <<
" phi2 = " << phi2 <<
"\n"
45 <<
" m2RadBef = " << m2RadBef <<
" "
46 <<
" m2Rec = " << m2Rec <<
" "
47 <<
" m2RadAft = " << m2RadAft <<
" "
48 <<
" m2EmtAft = " << m2EmtAft <<
" "
49 <<
" m2EmtAft2t = " << m2EmtAft2 <<
"\n";
56 void DireSplitInfo::init(
const Event& state) {
57 if (iRadBef>0) particleSave.push_back(DireSplitParticle(state[iRadBef]));
58 else particleSave.push_back(DireSplitParticle());
59 if (iRecBef>0) particleSave.push_back(DireSplitParticle(state[iRecBef]));
60 else particleSave.push_back(DireSplitParticle());
61 if (iRadAft>0) particleSave.push_back(DireSplitParticle(state[iRadAft]));
62 else particleSave.push_back(DireSplitParticle());
63 if (iRecAft>0) particleSave.push_back(DireSplitParticle(state[iRecAft]));
64 else particleSave.push_back(DireSplitParticle());
65 if (iEmtAft>0) particleSave.push_back(DireSplitParticle(state[iEmtAft]));
66 else particleSave.push_back(DireSplitParticle());
67 if (iEmtAft2>0)particleSave.push_back(DireSplitParticle(state[iEmtAft2]));
68 else particleSave.push_back(DireSplitParticle());
71 void DireSplitInfo::store (
const DireSplitInfo& s) {
74 particleSave.resize(0);
81 iEmtAft2 = s.iEmtAft2;
82 for (
int i=0; i < int(s.particleSave.size()); ++i)
83 particleSave.push_back(s.particleSave[i]);
84 kinSave.store(s.kinSave);
88 systemRec = s.systemRec;
89 splittingSelName = s.splittingSelName;
90 for ( unordered_map<string,double>::const_iterator it = s.extras.begin();
91 it != s.extras.end(); ++it )
92 extras.insert(make_pair(it->first,it->second));
93 useForBranching = s.useForBranching;
94 terminateEvolution = s.terminateEvolution;
95 iSiblings = s.iSiblings;
98 void DireSplitInfo::save () {
99 kinSaveStore = kinSave;
100 particleSaveStore = particleSave;
101 extrasStore = extras;
102 iRadBefStore = iRadBef;
103 iRecBefStore = iRecBef;
104 iRadAftStore = iRadAft;
105 iRecAftStore = iRecAft;
106 iEmtAftStore = iEmtAft;
107 iEmtAft2Store = iEmtAft2;
110 systemStore = system;
111 systemRecStore = systemRec;
112 splittingSelNameStore = splittingSelName;
113 useForBranchingStore = useForBranching;
114 terminateEvolutionStore = terminateEvolution;
115 iSiblingsStore = iSiblings;
118 void DireSplitInfo::restore () {
119 kinSave = kinSaveStore;
120 particleSave = particleSaveStore;
121 extras = extrasStore;
122 iRadBef = iRadBefStore;
123 iRecBef = iRecBefStore;
124 iRadAft = iRadAftStore;
125 iRecAft = iRecAftStore;
126 iEmtAft = iEmtAftStore;
127 iEmtAft2 = iEmtAft2Store;
130 system = systemStore;
131 systemRec = systemRecStore;
132 splittingSelName = splittingSelNameStore;
133 useForBranching = useForBranchingStore;
134 terminateEvolution = terminateEvolutionStore;
135 iSiblings = iSiblingsStore;
138 void DireSplitInfo::storeInfo(
string name,
int typeIn,
int systemIn,
140 int sideIn,
int iPosRadBef,
int iPosRecBef,
141 const Event& state,
int idEmtAft,
142 int idRadAft,
int nEmissions,
double m2Dip,
double pT2,
double pT2Old,
143 double z,
double phi,
double m2Bef,
double m2s,
double m2r,
double m2i,
144 double sa1,
double xa,
double phia1,
double m2j,
double xBef,
double xAft) {
148 storeSystem(systemIn);
149 storeSystemRec(systemRecIn);
151 storeRadRecBefPos(iPosRadBef, iPosRecBef);
152 storeRadBef(state[iPosRadBef]);
153 storeRecBef(state[iPosRecBef]);
156 if (nEmissions == 2) set2to4kin( m2Dip, pT2, z, phi, sa1, xa, phia1,
157 m2Bef, m2s, m2r, m2i, m2j);
158 else set2to3kin( m2Dip, pT2, z, phi, m2Bef, m2s, m2r, m2i);
160 unordered_map<string,double>(create_unordered_map<string,double>
161 (
"iRadBef",iPosRadBef)(
"iRecBef",iPosRecBef)(
"idRadAft",idRadAft)) );
167 void DireSplitInfo::storePosAfter(
int iRadAftIn,
int iRecAftIn,
int iEmtAftIn,
172 iEmtAft2 = iEmtAft2In;
175 void DireSplitInfo::clear() {
176 iRadBef = iRecBef = iRadAft = iRecAft = iEmtAft = iEmtAft2 = side
177 = type = system = systemRec = 0;
178 splittingSelName =
"";
179 useForBranching = terminateEvolution =
false;
180 for (
int i= 0; i < int(particleSave.size()); ++i) particleSave[i].clear();
185 void DireSplitInfo::list() {
186 cout <<
"List DireSplitInfo: "
187 <<
" name = " << splittingSelName <<
"\n"
188 <<
" [ id(radBef)= " << radBef()->id
189 <<
" id(recBef)= " << recBef()->id <<
" ] --> "
190 <<
" { id(radAft)= " << radAft()->id
191 <<
" id(emtAft)= " << emtAft()->id
192 <<
" id(emtAft2)= " << emtAft2()->id
193 <<
" id(recAft)= " << recAft()->id
203 DireSingleColChain::DireSingleColChain(
int iPos,
const Event& state,
204 PartonSystems* partonSysPtr) {
206 int colSign = (iPos > 0) ? 1 : -1;
208 int type = state[iPos].colType();
210 int iSys = partonSysPtr->getSystemOf(iPos,
true);
211 int sizeSystem = partonSysPtr->sizeAll(iSys);
212 if (!state[iPos].isFinal() || colSign < 0) type *= -1;
213 addToChain(iPos, state);
218 if (type < 0) icol = acolEnd();
220 bool foundRad =
false;
221 for (
int i = 0; i < sizeSystem; ++i) {
222 int j = partonSysPtr->getAll(iSys, i);
223 if ( j == iPos || state[j].colType() == 0)
continue;
224 if (!state[j].isFinal()
225 && state[j].mother1() != 1
226 && state[j].mother1() != 2)
continue;
227 int jcol = state[j].col();
228 int jacl = state[j].acol();
229 if ( type < 0) swap(jcol,jacl);
230 if ( !state[j].isFinal()) swap(jcol,jacl);
231 if ( jacl == icol ) {
238 if (foundRad) addToChain( iPos, state);
242 bool foundMotRad =
false;
246 int sizeSys = partonSysPtr->sizeSys();
248 int iParentInOther = 0;
249 int nSys = partonSysPtr->sizeAll(iSys);
250 for (
int iInSys = 0; iInSys < nSys; ++iInSys){
251 int iNow = partonSysPtr->getAll(iSys,iInSys);
252 for (
int iOtherSys = 0; iOtherSys < sizeSys; ++iOtherSys){
253 if (iOtherSys == iSys)
continue;
254 int nOtherSys = partonSysPtr->sizeAll(iOtherSys);
255 for (
int iInOtherSys = 0; iInOtherSys < nOtherSys; ++iInOtherSys){
256 int iOtherNow = partonSysPtr->getAll(iOtherSys,iInOtherSys);
257 if (state[iNow].isAncestor(iOtherNow)) {
258 iParentInOther = iOtherNow;
263 in1 = iParentInOther;
265 int jcol = state[in1].col();
266 int jacl = state[in1].acol();
267 if ( !state[in1].isFinal() || type < 0) swap(jcol,jacl);
268 if ( !state[in1].isFinal() && type < 0) swap(jcol,jacl);
269 if ( jacl == icol ) {
274 if (foundMotRad) { addToChain( iPos, state);
break;}
277 }
while ( abs(state[iPosEnd()].colType()) != 1 && iPosEnd() != iStart );
278 if (iPosEnd() == iStart) chain.pop_back();
282 void DireSingleColChain::addToChain(
const int iPos,
const Event& state){
283 int col = state[iPos].col();
284 int acl = state[iPos].acol();
285 original_chain.push_back( make_pair(iPos, make_pair(col, acl)));
286 if ( !state[iPos].isFinal()) swap(col,acl);
287 chain.push_back( make_pair(iPos, make_pair(col, acl)));
290 bool DireSingleColChain::isInChain(
int iPos) {
291 for (
int i=0; i< size(); ++i)
292 if (chain[i].first == iPos)
return true;
296 int DireSingleColChain::posInChain(
int iPos) {
297 for (
int i=0; i< size(); ++i)
298 if (chain[i].first == iPos)
return i;
302 bool DireSingleColChain::colInChain(
int col) {
303 for (
int i=0; i< size(); ++i)
304 if ( chain[i].second.first == col
305 || chain[i].second.second == col)
return true;
309 DireSingleColChain DireSingleColChain::chainFromCol(
int iPos,
int col,
310 int nSteps,
const Event& state) {
311 DireSingleColChain ret;
313 int iPosInChain = posInChain(iPos);
316 if (state[iPos].
id() == 21) {
318 if (iPosInChain == 0) {
320 ret.addToChain(chain[iPosInChain].first, state);
321 if ( iPosInChain+1 < size() && chain[iPosInChain+1].first > 0
322 && !ret.isInChain(chain[iPosInChain+1].first))
323 ret.addToChain(chain[iPosInChain+1].first, state);
324 if ( iPosInChain+2 < size() && chain[iPosInChain+2].first > 0
325 && !ret.isInChain(chain[iPosInChain+2].first))
326 ret.addToChain(chain[iPosInChain+2].first, state);
328 }
else if (iPosInChain == size()-1) {
330 if ( iPosInChain-2 >= 0
331 && chain[iPosInChain-2].first > 0
332 && !ret.isInChain(chain[iPosInChain-2].first))
333 ret.addToChain(chain[iPosInChain-2].first, state);
334 if ( iPosInChain-1 >= 0 && iPosInChain-1 < size()
335 && chain[iPosInChain-1].first > 0
336 && !ret.isInChain(chain[iPosInChain-1].first))
337 ret.addToChain(chain[iPosInChain-1].first, state);
338 ret.addToChain(chain[iPosInChain].first, state);
342 if ( iPosInChain-1 >= 0 && iPosInChain-1 < size()
343 && chain[iPosInChain-1].first > 0
344 && !ret.isInChain(chain[iPosInChain-1].first))
345 ret.addToChain(chain[iPosInChain-1].first, state);
346 if ( iPosInChain >= 0 && iPosInChain < size()
347 && chain[iPosInChain].first > 0
348 && !ret.isInChain(chain[iPosInChain].first))
349 ret.addToChain(chain[iPosInChain].first, state);
350 if ( iPosInChain+1 < size() && chain[iPosInChain+1].first > 0
351 && !ret.isInChain(chain[iPosInChain+1].first))
352 ret.addToChain(chain[iPosInChain+1].first, state);
358 for (
int i=0; i< size(); ++i) {
359 if ( iSteps == 0 && size() - 1 - i > nSteps
360 && chain[i].second.first != col
361 && chain[i].second.second != col)
continue;
363 if (chain[i].first > 0 && !ret.isInChain(chain[i].first))
364 ret.addToChain(chain[i].first, state);
365 if (iSteps > nSteps)
break;
372 string DireSingleColChain::listPos()
const {
374 for (
int i=0; i< size(); ++i) os <<
" " << chain[i].first;
379 void DireSingleColChain::print()
const {
385 for (i=0; i<length; i++) {
386 cout << setw(i == 0 ? 5 : 10) << chain[i].first;
391 max = (length%2 == 0 ? length : length-1);
393 if (i == 0) cout <<
" ";
394 if (i < max-1) cout << (i%2 == 0 ?
" _____________" :
" ");
401 if (i == 0) cout <<
" ";
403 if (i < max-1) cout << (i%2 == 0 ?
" " :
" ");
408 for (i=0; i<length; i++) {
409 cout << setw(4) << chain[i].second.first;
410 cout << setw(4) << chain[i].second.second;
416 max = (length%2 == 0 ? length-2 : length-1);
418 if (i == 0) cout <<
" ";
420 if (i < max-1) cout << (i%2 == 0 ?
"_____________" :
" ");
425 max = 10*(length-1)-5;
426 if (chain[0].second.second == chain[length-1].second.first
427 && chain[0].second.second != 0) {
429 for (i=0; i<max; i++) cout <<
"_";
436 void DireSingleColChain::list ()
const {
437 if (size() > 0) cout <<
" ";
438 for (
int i=0; i<size(); i++) {
439 cout <<
"[" << chain[i].second.second <<
"]";
440 cout <<
" " << chain[i].first <<
" ";
441 cout <<
"(" << chain[i].second.first <<
")";
442 if (i < size()-1) cout <<
" --- ";
448 string DireSingleColChain::list2 ()
const {
450 if (size() > 0) os <<
" ";
451 for (
int i=0; i<size(); i++) {
452 os <<
"[" << chain[i].second.second <<
"]";
453 os <<
" " << chain[i].first <<
" ";
454 os <<
"(" << chain[i].second.first <<
")";
455 if (i < size()-1) os <<
" --- ";
464 DireSingleColChain DireColChains::chainOf (
int iPos) {
465 for (
int i=0; i< size(); ++i)
466 if ( chains[i].isInChain(iPos) )
return chains[i];
467 return DireSingleColChain();
470 DireSingleColChain DireColChains::chainFromCol (
int iPos,
int col,
int nSteps,
471 const Event& state) {
472 for (
int i=0; i< size(); ++i) {
473 if ( chains[i].colInChain(col) ) {
474 return chains[i].chainFromCol(iPos, col, nSteps, state);}
476 return DireSingleColChain();
479 int DireColChains::check(
int iSys,
const Event& state,
480 PartonSystems* partonSysPtr) {
482 int sizeSystem = partonSysPtr->sizeAll(iSys);
484 for (
int i = 0; i < sizeSystem; ++i) {
485 int j = partonSysPtr->getAll(iSys, i);
486 if (!state[j].isFinal())
continue;
488 if ( state[j].colType() == 0)
continue;
489 if ( chainOf(j).size() < 2)
return j;
492 for (
int i = 0; i < sizeSystem; ++i) {
493 int j = partonSysPtr->getAll(iSys, i);
494 if ( state[j].colType() == 0)
continue;
495 if ( state[j].mother1() != 1 && state[j].mother1() != 2)
continue;
496 if ( nFinal > 0 && chainOf(j).size() < 2)
return j;
504 void DireColChains::list() {
505 cout <<
"\n --------- Begin DIRE Color Chain Listing -----------------"
506 <<
"--------------------------------------------------------------"
507 <<
"----------" << endl << endl;
509 for (
int i=0; i < size(); ++i){
510 cout <<
" Chain " << setw(4) << i <<
"\n" << endl;
513 cout <<
" **********************************************************"
514 <<
"***********************************************************"
515 <<
"**************" << endl;
518 cout <<
" ---------- End DIRE Color Chain Listing -----------------"
519 <<
"--------------------------------------------------------------"
520 <<
"----------" << endl;