38 using namespace Jetscape;
52 std::uniform_real_distribution<double> uniran(0.0,1.0);
57 SetId(
"HybridHadronization");
67 return R2chg*(2./3.)*(qm1+qm2)*(qm1+qm2)/(std::abs(qq1)*qm2*qm2 + std::abs(qq2)*qm1*qm1) * (std::abs(qq1) + std::abs(qq2));
72 return R2chg*(2./3.)*(qm1+qm2+qm3)/(std::abs(qq1)*qm2*(qm2+qm3)/(qm1+qm2)+std::abs(qq2)*qm1*(qm1+qm3)/(qm1+qm2)+std::abs(qq3)*(qm1*qm2)/qm3) * (std::abs(qq1) + std::abs(qq2) + std::abs(qq3));
76 return SigBR2*((qm1*qm2)/(qm1+qm2))/(qm3*(qm1+qm2)/(qm1+qm2+qm3));
83 if ( !hadronization ) {
84 JSWARN <<
"Couldn't find tag Jet Hadronization";
85 throw std::runtime_error (
"Couldn't find tag Jet Hadronization");
90 JSDEBUG << s <<
" to be initialized ...";
91 JSINFO<<
"Initialize Hybrid Hadronization ...";
93 JSDEBUG<<
"Initialize HybridHadronization";
98 goldstonereco =
false;
113 reco_hadrons_pythia = 0;
116 double xml_doublein = -1.;
int xml_intin = -1;
unsigned int xml_uintin = std::numeric_limits<unsigned int>::max();
118 xml_doublein = GetXMLElementDouble({
"JetHadronization",
"eCMforHadronization"});
119 if(xml_doublein >= 0.){p_fake = xml_doublein / 6.;} xml_doublein = -1.;
121 xml_doublein = GetXMLElementDouble({
"JetHadronization",
"thermreco_distmax"});
122 if(xml_doublein >= 0.){dist2cut = xml_doublein*xml_doublein;} xml_doublein = -1.;
124 xml_doublein = GetXMLElementDouble({
"JetHadronization",
"shower_recofactor"});
125 if(xml_doublein >= 0.){sh_recofactor = xml_doublein;} xml_doublein = -1.;
127 xml_doublein = GetXMLElementDouble({
"JetHadronization",
"thermal_recofactor"});
128 if(xml_doublein >= 0.){th_recofactor = xml_doublein;} xml_doublein = -1.;
130 xml_intin = GetXMLElementInt({
"JetHadronization",
"reco_Mlevelmax"});
131 if(xml_intin >= 0){maxM_level = xml_intin;} xml_intin = -1;
133 xml_intin = GetXMLElementInt({
"JetHadronization",
"reco_Blevelmax"});
134 if(xml_intin >= -1){maxB_level = xml_intin;} xml_intin = -1;
136 xml_intin = GetXMLElementInt({
"JetHadronization",
"reco_goldstone"});
137 if(xml_intin >= 0){goldstonereco = xml_intin;} xml_intin = -1;
140 xml_intin = GetXMLElementInt({
"JetHadronization",
"recobias_t"});
141 if(xml_intin == 1){torder_reco =
true;} xml_intin = -1;
143 xml_doublein = GetXMLElementDouble({
"JetHadronization",
"hydro_Tc"});
144 if(xml_doublein >= 0){hydro_Tc = xml_doublein;} xml_doublein = -1;
146 xml_doublein = GetXMLElementDouble({
"JetHadronization",
"had_postprop"});
147 if(xml_doublein >= 0){had_prop = xml_doublein;} xml_doublein = -1;
149 xml_doublein = GetXMLElementDouble({
"JetHadronization",
"part_prop"});
150 if(xml_doublein >= 0){part_prop = xml_doublein;} xml_doublein = -1;
152 xml_intin = GetXMLElementInt({
"JetHadronization",
"reco_hadrons_in_pythia"});
153 if(xml_intin == 0 || xml_intin == 1){reco_hadrons_pythia = xml_intin;} xml_intin = -1;
155 xml_intin = GetXMLElementInt({
"Afterburner",
"include_fragmentation_hadrons"});
156 if(xml_intin == 1){afterburner_frag_hadrons =
true;} xml_intin = -1;
160 JSWARN <<
"Requested maximum energy level for mesons too large. Set it to 4.";
167 if ( RandomXmlDescription ){
170 if(xml_uintin < std::numeric_limits<unsigned int>::max()){rand_seed = xml_uintin;} xml_uintin = std::numeric_limits<unsigned int>::max();
172 JSWARN <<
"No <Random> element found in xml, seeding to 0";
174 VERBOSE(7) <<
"Seeding PYTHIA(hadronization) to "<< rand_seed;
177 if(rand_seed != 0){eng.seed(rand_seed);}
180 std::random_device
rd;
181 std::array<int,std::mt19937_64::state_size> seedarray; std::generate_n(seedarray.data(), seedarray.size(),
std::ref(rd));
199 xml_intin = GetXMLElementInt({
"Hard",
"PythiaGun",
"FSR_on"});
200 if(xml_intin && (sh_recofactor > 0.0000000001)){
JSWARN <<
"Recombination with a PYTHIA FSR shower is not fully implemented.";}
204 double Qm_ud = xmq;
double Qm_s = xms;
double Qm_c = xmc;
double Qm_b = xmb;
205 double chg_u = 2./3.;
double chg_d = -1./3.;
209 double R2chg_Pi = 0.42 ;
210 double R2chg_Phi = 0.21 ;
211 double R2chg_K = 0.34 ;
212 double R2chg_Jpi = 0.04 ;
213 double R2chg_Ds = 0.09 ;
214 double R2chg_D = 0.165;
215 double R2chg_Ups = 0.032;
216 double R2chg_Bc = 0.036;
217 double R2chg_B = 0.273;
219 double R2chg_Nuc = 0.69 ;
220 double R2chg_Omg = 0.355;
221 double R2chg_Xi = 0.52 ;
222 double R2chg_Sig = 0.61 ;
223 double R2chg_Occc = 0.179;
224 double R2chg_Occ = 0.043;
225 double R2chg_Xicc = 0.049;
226 double R2chg_Oc = 0.1 ;
227 double R2chg_Xic = 0.24 ;
228 double R2chg_Sigc = 0.27 ;
229 double R2chg_Obbb = 0.001;
230 double R2chg_Obbc = 0.001;
231 double R2chg_Obb = 0.001;
232 double R2chg_Xibb = 0.001;
233 double R2chg_Obcc = 0.001;
234 double R2chg_Obc = 0.001;
235 double R2chg_Xibc = 0.001;
236 double R2chg_Ob = 0.6 ;
237 double R2chg_Xib = 0.63 ;
238 double R2chg_Sigb = 0.66 ;
241 SigPi2 = SigM2_calc(R2chg_Pi, Qm_ud, Qm_ud, chg_d, chg_u);
242 SigPhi2 = SigM2_calc(R2chg_Phi, Qm_s, Qm_s, chg_d, -chg_d);
243 SigK2 = SigM2_calc(R2chg_K, Qm_s, Qm_ud, chg_d, chg_u);
244 SigJpi2 = SigM2_calc(R2chg_Jpi, Qm_c, Qm_c, chg_u, -chg_u);
245 SigDs2 = SigM2_calc(R2chg_Ds, Qm_c, Qm_s, chg_u, chg_d);
246 SigD2 = SigM2_calc(R2chg_D, Qm_c, Qm_ud, chg_u, chg_d);
247 SigUps2 = SigM2_calc(R2chg_Ups, Qm_b, Qm_b, chg_d, -chg_d);
248 SigBc2 = SigM2_calc(R2chg_Bc, Qm_b, Qm_c, chg_d, chg_u);
249 SigB2 = SigM2_calc(R2chg_B, Qm_b, Qm_ud, chg_d, chg_u);
253 SigNucR2 = SigBR2_calc(R2chg_Nuc, Qm_ud, Qm_ud, Qm_ud, chg_d, chg_u, chg_u);
254 SigNucL2 = SigBL2_calc(SigNucR2, Qm_ud, Qm_ud, Qm_ud);
255 SigOmgR2 = SigBR2_calc(R2chg_Omg, Qm_s, Qm_s, Qm_s, chg_d, chg_d, chg_d);
256 SigOmgL2 = SigBL2_calc(SigOmgR2, Qm_s, Qm_s, Qm_s );
257 SigXiR2 = SigBR2_calc(R2chg_Xi, Qm_s, Qm_s, Qm_ud, chg_d, chg_d, chg_d);
258 SigXiL2 = SigBL2_calc(SigXiR2, Qm_s, Qm_s, Qm_ud);
259 SigSigR2 = SigBR2_calc(R2chg_Sig, Qm_s, Qm_ud, Qm_ud, chg_d, chg_u, chg_u);
260 SigSigL2 = SigBL2_calc(SigSigR2, Qm_s, Qm_ud, Qm_ud);
263 SigOcccR2 = SigBR2_calc(R2chg_Occc, Qm_c, Qm_c, Qm_c, chg_d, chg_d, chg_d);
264 SigOcccL2 = SigBL2_calc(SigOcccR2, Qm_c, Qm_c, Qm_c );
265 SigOccR2 = SigBR2_calc(R2chg_Occ, Qm_c, Qm_c, Qm_s, chg_u, chg_u, chg_d);
266 SigOccL2 = SigBL2_calc(SigOccR2, Qm_c, Qm_c, Qm_s );
267 SigXiccR2 = SigBR2_calc(R2chg_Xicc, Qm_c, Qm_c, Qm_ud, chg_u, chg_u, chg_d);
268 SigXiccL2 = SigBL2_calc(SigXiccR2, Qm_c, Qm_c, Qm_ud);
269 SigOcR2 = SigBR2_calc(R2chg_Oc, Qm_c, Qm_s, Qm_s, chg_d, chg_d, chg_d);
270 SigOcL2 = SigBL2_calc(SigOcR2, Qm_c, Qm_s, Qm_s );
271 SigXicR2 = SigBR2_calc(R2chg_Xic, Qm_c, Qm_s, Qm_ud, chg_u, chg_d, chg_u);
272 SigXicL2 = SigBL2_calc(SigXicR2, Qm_c, Qm_s, Qm_ud);
273 SigSigcR2 = SigBR2_calc(R2chg_Sigc, Qm_c, Qm_ud, Qm_ud, chg_u, chg_d, chg_u);
274 SigSigcL2 = SigBL2_calc(SigSigcR2, Qm_c, Qm_ud, Qm_ud);
277 SigObbbR2 = SigBR2_calc(R2chg_Obbb, Qm_b, Qm_b, Qm_b, chg_d, chg_d, chg_d);
278 SigObbbL2 = SigBL2_calc(SigObbbR2, Qm_b, Qm_b, Qm_b );
279 SigObbcR2 = SigBR2_calc(R2chg_Obbc, Qm_b, Qm_b, Qm_c, chg_d, chg_d, chg_d);
280 SigObbcL2 = SigBL2_calc(SigObbcR2, Qm_b, Qm_b, Qm_c );
281 SigObbR2 = SigBR2_calc(R2chg_Obb, Qm_b, Qm_b, Qm_s, chg_d, chg_d, chg_d);
282 SigObbL2 = SigBL2_calc(SigObbR2, Qm_b, Qm_b, Qm_s );
283 SigXibbR2 = SigBR2_calc(R2chg_Xibb, Qm_b, Qm_b, Qm_ud, chg_d, chg_d, chg_d);
284 SigXibbL2 = SigBL2_calc(SigXibbR2, Qm_b, Qm_b, Qm_ud);
285 SigObccR2 = SigBR2_calc(R2chg_Obcc, Qm_b, Qm_c, Qm_c, chg_d, chg_u, chg_u);
286 SigObccL2 = SigBL2_calc(SigObccR2, Qm_b, Qm_c, Qm_c );
287 SigObcR2 = SigBR2_calc(R2chg_Obc, Qm_b, Qm_c, Qm_s, chg_d, chg_d, chg_d);
288 SigObcL2 = SigBL2_calc(SigObcR2, Qm_b, Qm_c, Qm_s );
289 SigXibcR2 = SigBR2_calc(R2chg_Xibc, Qm_b, Qm_c, Qm_ud, chg_d, chg_u, chg_u);
290 SigXibcL2 = SigBL2_calc(SigXibcR2, Qm_b, Qm_c, Qm_ud);
291 SigObR2 = SigBR2_calc(R2chg_Ob, Qm_b, Qm_s, Qm_s, chg_d, chg_d, chg_d);
292 SigObL2 = SigBL2_calc(SigObR2, Qm_b, Qm_s, Qm_s );
293 SigXibR2 = SigBR2_calc(R2chg_Xib, Qm_b, Qm_s, Qm_ud, chg_d, chg_d, chg_d);
294 SigXibL2 = SigBL2_calc(SigXibR2, Qm_b, Qm_s, Qm_ud);
295 SigSigbR2 = SigBR2_calc(R2chg_Sigb, Qm_b, Qm_ud, Qm_ud, chg_d, chg_u, chg_u);
296 SigSigbL2 = SigBL2_calc(SigSigbR2, Qm_b, Qm_ud, Qm_ud);
299 pythia.readString(
"Next:numberShowInfo = 0");
300 pythia.readString(
"Next:numberShowProcess = 0");
301 pythia.readString(
"Next:numberShowEvent = 0");
302 pythia.readString(
"Init:showProcesses = off");
303 pythia.readString(
"Init:showChangedSettings = off");
304 pythia.readString(
"Init:showMultipartonInteractions = off");
305 pythia.readString(
"Init:showChangedParticleData = off");
308 pythia.readString(
"ProcessLevel:all = off");
312 pythia_decays = GetXMLElementText({
"JetHadronization",
"pythia_decays"});
313 double tau0Max = 10.0;
314 double tau0Max_xml = GetXMLElementDouble({
"JetHadronization",
"tau0Max"});
315 if(tau0Max_xml >= 0){tau0Max = tau0Max_xml;}
316 else{
JSWARN <<
"tau0Max should be larger than 0. Set it to 10.";}
317 if(pythia_decays ==
"on"){
318 JSINFO <<
"Pythia decays are turned on for tau0Max < " << tau0Max;
319 pythia.readString(
"HadronLevel:Decay = on");
320 pythia.readString(
"ParticleDecays:limitTau0 = on");
321 pythia.readString(
"ParticleDecays:tau0Max = " +
std::to_string(tau0Max));
323 JSINFO <<
"Pythia decays are turned off";
324 pythia.readString(
"HadronLevel:Decay = off");
330 GetXMLElementText({
"JetHadronization",
"weak_decays"});
331 if (weak_decays ==
"off") {
332 JSINFO <<
"Hadron decays are turned off.";
333 JSWARN <<
"This parameter will be depracted at some point. Use 'pythia_decays' instead.\nOverwriting 'pythia_decays'.";
334 pythia.readString(
"HadronLevel:Decay = off");
335 }
else if(weak_decays ==
"on") {
336 JSINFO <<
"Hadron decays inside a range of 10 mm/c are turned on.";
337 JSWARN <<
"This parameter will be depracted at some point. Use 'pythia_decays' and 'tau0Max' for more control on decays.\nOverwriting 'pythia_decays' and fix 'tau0Max' to 10.";
338 pythia.readString(
"HadronLevel:Decay = on");
339 pythia.readString(
"ParticleDecays:limitTau0 = on");
340 pythia.readString(
"ParticleDecays:tau0Max = 10.0");
344 pythia.readString(
"Random:setSeed = on");
349 pythia.readString(
"Check:event = off");
350 pythia.readString(
"Check:history = off");
362 pythia.readString(
"StringFragmentation:TraceColours = on");
365 pythia.readString(
"ColourReconnection:reconnect = off");
376 std::stringstream
lines;
377 lines << GetXMLElementText({
"JetHadronization",
"LinesToRead"},
false);
378 while (std::getline(lines, s,
'\n')) {
379 if (s.find_first_not_of(
" \t\v\f\r") == s.npos)
381 JSINFO <<
"Also reading in: " <<
s;
382 pythia.readString(s);
386 xml_intin = GetXMLElementInt({
"JetHadronization",
"additional_pythia_particles"});
387 if(xml_intin == 0 || xml_intin == 1){additional_pythia_particles = xml_intin;} xml_intin = -1;
389 if(additional_pythia_particles == 1) {
391 GetXMLElementText({
"JetHadronization",
"additional_pythia_particles_path"});
392 pythia.particleData.readXML(additional_pythia_particle_file,
false);
399 inbrick =
false; brickL = -1.;
400 inhydro =
false; nreusehydro = 1;
402 xml_intin = GetXMLElementInt({
"Eloss",
"Matter",
"brick_med"});
403 if(xml_intin == 1){inbrick =
true;} xml_intin = -1;
404 xml_doublein = GetXMLElementDouble({
"Eloss",
"Matter",
"brick_length"});
405 if(inbrick && (xml_doublein >= 0.)){brickL = xml_doublein;} xml_doublein = -1.;
406 xml_intin = GetXMLElementInt({
"nReuseHydro"});
407 if(xml_intin > 0){nreusehydro = xml_intin;} xml_intin = -1;
408 xml_doublein = GetXMLElementDouble({
"Eloss",
"deltaT"});
409 if(xml_doublein >= 0.){delta_t = xml_doublein;} xml_doublein = -1.;
415 if (elementName ==
"Hydro") {
425 if (elementName ==
"Hydro") {
428 while (childElement) {
430 if (childElementName ==
"Brick") {
442 xml_doublein = GetXMLElementDouble({
"JetHadronization",
"eta_max_boost_inv"});
443 if(inhydro && (xml_doublein >= 0.)){eta_max_boost_inv = xml_doublein;} xml_doublein = -1.;
451 f->WriteComment(
"Hadronization Module : "+GetId());
457 double energy_hadrons = 0.;
460 pythia.event.reset(); HH_shower.clear();
464 std::unique_ptr<FluidCellInfo> check_fluid_info_ptr;
466 bool boost_invariant =
true;
467 bool Cartesian_hydro =
false;
474 Cartesian_hydro =
false;
478 if(brickL < 0.){brickL = 0.; inbrick =
false;}
484 convert_color_tags_to_int_type(
shower);
486 double total_shower_energy = 0.;
487 double total_shower_energy_neg = 0.;
489 for(
unsigned int ishower=0; ishower <
shower.size(); ++ishower){
490 for(
unsigned int ipart=0; ipart <
shower.at(ishower).size(); ++ipart){
493 sh_parton.
px(
shower.at(ishower).at(ipart)->px()); sh_parton.
py(
shower.at(ishower).at(ipart)->py());
494 sh_parton.
pz(
shower.at(ishower).at(ipart)->pz()); sh_parton.
e(
shower.at(ishower).at(ipart)->e());
495 sh_parton.
x(
shower.at(ishower).at(ipart)->x_in().x() ); sh_parton.
y(
shower.at(ishower).at(ipart)->x_in().y() );
496 sh_parton.
z(
shower.at(ishower).at(ipart)->x_in().z() ); sh_parton.
x_t(
shower.at(ishower).at(ipart)->x_in().t() );
497 sh_parton.
mass( sh_parton.
e()*sh_parton.
e() - sh_parton.
px()*sh_parton.
px() - sh_parton.
py()*sh_parton.
py() - sh_parton.
pz()*sh_parton.
pz() );
498 sh_parton.
mass( (sh_parton.
mass() >= 0.) ? sqrt(sh_parton.
mass()) : sqrt(-sh_parton.
mass()) );
499 sh_parton.
col(
shower.at(ishower).at(ipart)->color() ); sh_parton.
acol(
shower.at(ishower).at(ipart)->anti_color() );
501 if(
shower.at(ishower).at(ipart)->pstat()>-1){
502 HH_shower.add(sh_parton);
503 total_shower_energy += HH_shower[HH_shower.num()-1].e();
505 neg_ptns.
add(sh_parton);
506 total_shower_energy_neg += neg_ptns[neg_ptns.
num()-1].e();
509 JSDEBUG<<
"Shower#"<<ishower+1 <<
". Number of partons to hadronize: " << HH_shower.num();
510 JSDEBUG<<
"Shower#"<<ishower+1 <<
". Number of (neg) partons to hadronize: " << neg_ptns.
num();
515 bool runsampler = (((inhydro || inbrick) && HH_thermal.num()==0) || (GetCurrentEvent()%nreusehydro==0)) ?
true :
false;
517 if(runsampler && inbrick){
525 JSINFO <<
"A " << brickL <<
" fm brick was sampled, generating " << brick.
nTot() <<
" partons (" << brick.
th_nL() <<
" light, " << brick.
th_nS() <<
" strange).";
527 for(
int ith=0; ith<brick.
nTot(); ++ith){
530 thparton.
col(0); thparton.
acol(0);
532 thparton.
x( brick.
th_x(ith) ); thparton.
y( brick.
th_y(ith) ); thparton.
z( brick.
th_z(ith) ); thparton.
x_t(brick.
th_t(ith));
533 thparton.
mass( thparton.
e()*thparton.
e() - thparton.
px()*thparton.
px() - thparton.
py()*thparton.
py() - thparton.
pz()*thparton.
pz() );
534 thparton.
mass( (thparton.
mass() >= 0.) ? sqrt(thparton.
mass()) : sqrt(-thparton.
mass()) );
536 HH_thermal.add(thparton);
539 for(
int i=0;
i<HH_thermal.num();++
i){
540 HH_thermal[
i].sibling(
i); HH_thermal[
i].string_id(-
i);
541 HH_thermal[
i].is_used(
true); HH_thermal[
i].sibling( findthermalsibling(
i, HH_thermal) ); HH_thermal[
i].is_used(
false);
543 }
else if(runsampler && inhydro){
545 std::vector<SurfaceCellInfo> surface_cells;
546 GetHydroHyperSurface(hydro_Tc, surface_cells);
557 std::vector<std::vector<double>>
surface;
558 for(
int icel=0; icel<surface_cells.size(); ++icel){
559 std::vector<double> cell;
560 cell.push_back(surface_cells[icel].
tau); cell.push_back(surface_cells[icel].
x); cell.push_back(surface_cells[icel].
y); cell.push_back(surface_cells[icel].
eta);
561 cell.push_back(surface_cells[icel].d3sigma_mu[0]); cell.push_back(surface_cells[icel].d3sigma_mu[1]);
562 cell.push_back(surface_cells[icel].d3sigma_mu[2]); cell.push_back(surface_cells[icel].d3sigma_mu[3]);
563 cell.push_back(surface_cells[icel].temperature);
564 cell.push_back(surface_cells[icel].
vx); cell.push_back(surface_cells[icel].
vy); cell.push_back(surface_cells[icel].
vz);
565 surface.push_back(cell);
576 JSINFO <<
"Hydro was sampled, generating " << part_samp.
nTot() <<
" partons (" << part_samp.
th_nL() <<
" light, " << part_samp.
th_nS() <<
" strange).";
578 for(
int ith=0; ith<part_samp.
nTot(); ++ith){
581 thparton.
px(part_samp.
th_px(ith)); thparton.
py(part_samp.
th_py(ith)); thparton.
pz(part_samp.
th_pz(ith)); thparton.
e( part_samp.
th_e(ith));
582 thparton.
x( part_samp.
th_x(ith) ); thparton.
y( part_samp.
th_y(ith) ); thparton.
z( part_samp.
th_z(ith) ); thparton.
x_t(part_samp.
th_t(ith));
583 thparton.
mass( thparton.
e()*thparton.
e() - thparton.
px()*thparton.
px() - thparton.
py()*thparton.
py() - thparton.
pz()*thparton.
pz() );
584 thparton.
mass( (thparton.
mass() >= 0.) ? sqrt(thparton.
mass()) : sqrt(-thparton.
mass()) );
586 HH_thermal.add(thparton);
589 for(
int i=0;
i<HH_thermal.num();++
i){
590 HH_thermal[
i].sibling(
i); HH_thermal[
i].string_id(-
i);
591 HH_thermal[
i].is_used(
true); HH_thermal[
i].sibling( findthermalsibling(
i, HH_thermal) ); HH_thermal[
i].is_used(
false);
595 if(!inbrick && !inhydro){
596 for(
int i_sh=0; i_sh<HH_shower.num(); ++i_sh){
597 double max_t_dif = part_prop;
598 double vel[3]; vel[0]=HH_shower[i_sh].px()/HH_shower[i_sh].e(); vel[1]=HH_shower[i_sh].py()/HH_shower[i_sh].e(); vel[2]=HH_shower[i_sh].pz()/HH_shower[i_sh].e();
599 HH_shower[i_sh].x(HH_shower[i_sh].
x() + vel[0]*max_t_dif); HH_shower[i_sh].y(HH_shower[i_sh].
y() + vel[1]*max_t_dif); HH_shower[i_sh].z(HH_shower[i_sh].
z() + vel[2]*max_t_dif);
600 HH_shower[i_sh].x_t(HH_shower[i_sh].x_t() + max_t_dif);
602 for(
int i_sh=0; i_sh<neg_ptns.
num(); ++i_sh){
603 double max_t_dif = part_prop;
604 double vel[3]; vel[0]=neg_ptns[i_sh].px()/neg_ptns[i_sh].e(); vel[1]=neg_ptns[i_sh].py()/neg_ptns[i_sh].e(); vel[2]=neg_ptns[i_sh].pz()/neg_ptns[i_sh].e();
605 neg_ptns[i_sh].x(neg_ptns[i_sh].
x() + vel[0]*max_t_dif); neg_ptns[i_sh].y(neg_ptns[i_sh].
y() + vel[1]*max_t_dif); neg_ptns[i_sh].z(neg_ptns[i_sh].
z() + vel[2]*max_t_dif);
606 neg_ptns[i_sh].x_t(neg_ptns[i_sh].x_t() + max_t_dif);
612 for(
int i_sh=0; i_sh<HH_shower.num(); ++i_sh){
613 double vel[3]; vel[0]=HH_shower[i_sh].px()/HH_shower[i_sh].e(); vel[1]=HH_shower[i_sh].py()/HH_shower[i_sh].e(); vel[2]=HH_shower[i_sh].pz()/HH_shower[i_sh].e();
615 if(inbrick && HH_shower[i_sh].x_t() < brickL){
616 t_dif = brickL - HH_shower[i_sh].x_t();
620 while(temp > hydro_Tc){
621 double tnow = HH_shower[i_sh].x_t() + delta_t*
double(i);
622 double xnow = HH_shower[i_sh].x() + vel[0]*delta_t*
double(i);
623 double ynow = HH_shower[i_sh].y() + vel[1]*delta_t*
double(i);
624 double znow = HH_shower[i_sh].z() + vel[2]*delta_t*
double(i);
625 GetHydroCellSignal(tnow, xnow, ynow, znow, check_fluid_info_ptr);
627 if(temp <= hydro_Tc){
628 t_dif = delta_t*
double(i);
633 double max_t_dif = std::max(t_dif,part_prop);
634 HH_shower[i_sh].x(HH_shower[i_sh].
x() + vel[0]*max_t_dif); HH_shower[i_sh].y(HH_shower[i_sh].
y() + vel[1]*max_t_dif); HH_shower[i_sh].z(HH_shower[i_sh].
z() + vel[2]*max_t_dif);
635 HH_shower[i_sh].x_t(HH_shower[i_sh].x_t() + max_t_dif);
639 for(
int i_sh=0; i_sh<neg_ptns.
num(); ++i_sh){
640 double vel[3]; vel[0]=neg_ptns[i_sh].px()/neg_ptns[i_sh].e(); vel[1]=neg_ptns[i_sh].py()/neg_ptns[i_sh].e(); vel[2]=neg_ptns[i_sh].pz()/neg_ptns[i_sh].e();
642 if(inbrick && neg_ptns[i_sh].x_t() < brickL){
643 t_dif = brickL - neg_ptns[i_sh].x_t();
647 while(temp > hydro_Tc){
648 double tnow = neg_ptns[i_sh].x_t() + delta_t*
double(i);
649 double xnow = neg_ptns[i_sh].x() + vel[0]*delta_t*
double(i);
650 double ynow = neg_ptns[i_sh].y() + vel[1]*delta_t*
double(i);
651 double znow = neg_ptns[i_sh].z() + vel[2]*delta_t*
double(i);
652 GetHydroCellSignal(tnow, xnow, ynow, znow, check_fluid_info_ptr);
654 if(temp <= hydro_Tc){
655 t_dif = delta_t*
double(i);
660 double max_t_dif = std::max(t_dif,part_prop);
661 neg_ptns[i_sh].x(neg_ptns[i_sh].
x() + vel[0]*max_t_dif); neg_ptns[i_sh].y(neg_ptns[i_sh].
y() + vel[1]*max_t_dif); neg_ptns[i_sh].z(neg_ptns[i_sh].
z() + vel[2]*max_t_dif);
662 neg_ptns[i_sh].x_t(neg_ptns[i_sh].x_t() + max_t_dif);
674 for(
int pos_ptn = 1; pos_ptn>=0; --pos_ptn){
675 double tmp_threco = th_recofactor;
676 double tmp_maxB_level = maxB_level;
677 int tmp_reco_hadrons_pythia = reco_hadrons_pythia;
679 pythia.event.reset(); HH_shower.
clear(); HH_shower = neg_ptns;
684 if(afterburner_frag_hadrons){
685 reco_hadrons_pythia = 1;
686 pythia.readString(
"HadronLevel:Decay = on");
691 for(
int i=0;
i<HH_thermal.num(); ++
i){
692 if(HH_thermal[
i].is_used()) {
693 HH_thermal[
i].is_used(
false);
694 HH_shower.
add(HH_thermal[
i]);
699 for(
int i=0;
i<HH_recomb_extrapartons.num(); ++
i){
700 HH_shower.add(HH_recomb_extrapartons[
i]);
703 if(HH_shower.num() != 0){
708 if(HH_shower.num() == 0){
712 int attempt_num = 0;
bool run_successfully =
false;
713 while((attempt_num < attempts_max) && (!run_successfully)){
714 HH_showerptns = HH_shower;
716 HH_hadrons.clear(); HH_remnants.clear(); HH_pyremn.clear(); HH_pythia_hadrons.clear(); HH_recomb_extrapartons.clear();
719 for(
int i=0;
i<HH_thermal.num(); ++
i){
720 HH_thermal[
i].is_used(
false); HH_thermal[
i].is_decayedglu(
false); HH_thermal[
i].is_remnant(
false); HH_thermal[
i].used_reco(
false); HH_thermal[
i].used_str(
false); HH_thermal[
i].is_thermal(
true);
721 HH_thermal[
i].orig(1); HH_thermal[
i].par(-1); HH_thermal[
i].status(0); HH_thermal[
i].col(0); HH_thermal[
i].acol(0); HH_thermal[
i].is_fakeparton(
false);
722 HH_thermal[
i].PY_par1(-1); HH_thermal[
i].PY_par2(-1); HH_thermal[
i].PY_dau1(-1); HH_thermal[
i].PY_dau2(-1); HH_thermal[
i].PY_stat(23);
723 HH_thermal[
i].string_id(-
i); HH_thermal[
i].is_strendpt(
false); HH_thermal[
i].pos_str(1); HH_thermal[
i].endpt_id(0);
726 HH_thermal[
i].is_used(
true);
733 while(i_show<HH_showerptns.num()){
734 if(HH_showerptns[i_show].
id() == 21){++i_show;
continue;}
735 else if(std::abs(HH_showerptns[i_show].
id()) <= 6){++i_show;
continue;}
736 else if((std::abs(HH_showerptns[i_show].
id()) >= 1103) && (std::abs(HH_showerptns[i_show].
id()) <= 5503) && ((HH_showerptns[i_show].
id()/10)%10 == 0)){++i_show;
continue;}
737 else if(pythia.particleData.colType(HH_showerptns[i_show].id()) == 2){
738 HH_showerptns[i_show].PY_origid(HH_showerptns[i_show].
id()); HH_showerptns[i_show].id(21); ++i_show;
continue;
740 else if(std::abs(pythia.particleData.colType(HH_showerptns[i_show].id())) == 1){
741 HH_showerptns[i_show].PY_origid( HH_showerptns[i_show].
id() );
742 HH_showerptns[i_show].id( 1*(2*std::signbit(-pythia.particleData.colType(HH_showerptns[i_show].id()))-1) ); ++i_show;
continue;
744 else if(HH_showerptns[i_show].
id() == 90){HH_showerptns.remove(i_show);
continue;}
746 HHhadron had; had.
id( HH_showerptns[i_show].
id() ); had.
orig( HH_showerptns[i_show].orig() ); had.
mass( HH_showerptns[i_show].
mass() );
747 had.
pos(HH_showerptns[i_show].
pos()); had.
P(HH_showerptns[i_show].
P());
748 HH_hadrons.add(had); HH_showerptns.remove(i_show);
755 num_strings = HH_showerptns[HH_showerptns.num()-1].string_id();
758 double sh_recofactor_store = sh_recofactor;
759 if(attempt_num == attempts_max -1) {
762 JSWARN <<
"Hadronization failed, try without recombination one more time";
764 JSWARN <<
"Hadronization of negative partons failed, try without recombination one more time";
770 sh_recofactor = sh_recofactor_store;
775 if(HH_remnants.num()){
776 bool cut = (attempt_num > -1) ?
true :
false;
777 stringprep(HH_remnants, HH_pyremn, cut);
781 for(
int i=0;
i<HH_hadrons.num(); ++
i){
782 HH_hadrons[
i].is_final(
true);
787 for(
int ipart = 0; ipart < HH_pyremn.num(); ipart++) {
788 if(HH_pyremn[ipart].is_fakeparton()) {
789 if(HH_pyremn[ipart].
id() == 21 && HH_pyremn[ipart].mass() > (2.*pythia.particleData.m0(211) + 0.01)) {
790 HH_pyremn[ipart].mass(2.*pythia.particleData.m0(211) + 0.01);
792 HH_pyremn[ipart].e(HH_pyremn[ipart].
mass());
793 HH_pyremn[ipart].px(0.);
794 HH_pyremn[ipart].py(0.);
795 HH_pyremn[ipart].pz(0.);
801 run_successfully = invoke_py();
805 if(run_successfully){
809 if(reco_hadrons_pythia) {
814 for(
int iHad = 0; iHad < HH_pythia_hadrons.num(); iHad++) {
815 HH_hadrons.add(HH_pythia_hadrons[iHad]);
818 bring_hadrons_to_mass_shell(HH_hadrons);
821 for(
int iHad=0; iHad<HH_hadrons.num(); ++iHad){
822 if(std::abs(had_prop) > 0.0001 && HH_hadrons[iHad].id() != 22){
823 double vel[3]; vel[0]=HH_hadrons[iHad].px()/HH_hadrons[iHad].e(); vel[1]=HH_hadrons[iHad].py()/HH_hadrons[iHad].e(); vel[2]=HH_hadrons[iHad].pz()/HH_hadrons[iHad].e();
824 double t_prop = had_prop/sqrt(1. - vel[0]*vel[0] - vel[1]*vel[1] - vel[2]*vel[2]);
825 HH_hadrons[iHad].x(HH_hadrons[iHad].
x() + vel[0]*t_prop); HH_hadrons[iHad].y(HH_hadrons[iHad].
y() + vel[1]*t_prop); HH_hadrons[iHad].z(HH_hadrons[iHad].
z() + vel[2]*t_prop);
826 HH_hadrons[iHad].x_t(HH_hadrons[iHad].x_t() + had_prop);
831 double energy_check = 0.;
832 for(
int iHad = 0; iHad < HH_hadrons.num(); iHad++){
833 energy_check += HH_hadrons[iHad].e();
835 if(pos_ptn == 1 && (energy_check < 0.99*total_shower_energy)){
836 run_successfully =
false;
842 if(!run_successfully){
845 JSWARN <<
"This event could not be hadronized.";
847 JSWARN <<
"The negative partons of this event could not be hadronized.";
854 if(HH_hadrons.num() > 0){
855 scale_kinematics_negative_hadrons(HH_hadrons, total_shower_energy-total_shower_energy_neg, energy_hadrons);
859 for(
unsigned int iHad=0; iHad<HH_hadrons.num(); ++iHad){
860 if(HH_hadrons[iHad].is_final()){
863 int stat = (HH_hadrons[iHad].is_recohad()) ? 810 : 820;
864 stat += (HH_hadrons[iHad].is_shth()) ? 2 : 1;
865 stat *= (pos_ptn == 0) ? -1 : 1 ;
866 int lab = (pos_ptn == 0) ? -1 : 1 ;
867 int idH = HH_hadrons[iHad].id();
double mH = HH_hadrons[iHad].mass();
869 hOut.push_back(std::make_shared<Hadron> (
Hadron (lab,idH,stat,p,x,mH)));
872 energy_hadrons += HH_hadrons[iHad].e();
876 th_recofactor = tmp_threco;
877 maxB_level = tmp_maxB_level;
878 reco_hadrons_pythia = tmp_reco_hadrons_pythia;
879 if(pythia_decays ==
"off"){pythia.readString(
"HadronLevel:Decay = off"); pythia.init();}
886 double negative_hadrons_energy_initial = 0;
887 for(
int i = 0;
i < HH_hadrons.
num();
i++){
888 negative_hadrons_energy_initial += HH_hadrons[
i].e();
891 double e_scaling_factor = (positive_hadrons_energy - shower_energy) / negative_hadrons_energy_initial;
892 if(e_scaling_factor < 0.){
893 JSDEBUG <<
"e_scaling_factor negative, hadron energy below parton energy: " << positive_hadrons_energy - shower_energy <<
"GeV";
897 for(
int i = 0;
i < HH_hadrons.
num();
i++){
898 double new_energy = HH_hadrons[
i].e() * e_scaling_factor;
899 if(new_energy > HH_hadrons[
i].
mass()){
900 HH_hadrons[
i].e(new_energy);
901 double new_abs_momentum = std::sqrt(new_energy*new_energy - HH_hadrons[
i].
mass()*HH_hadrons[
i].
mass());
902 double p_scaling_factor = new_abs_momentum / std::sqrt(HH_hadrons[
i].px()*HH_hadrons[
i].px()+HH_hadrons[
i].py()*HH_hadrons[
i].py()+HH_hadrons[
i].pz()*HH_hadrons[
i].pz());
903 HH_hadrons[
i].px(HH_hadrons[
i].px() * p_scaling_factor);
904 HH_hadrons[
i].py(HH_hadrons[
i].py() * p_scaling_factor);
905 HH_hadrons[
i].pz(HH_hadrons[
i].pz() * p_scaling_factor);
907 HH_hadrons[
i].e(HH_hadrons[
i].
mass());
908 HH_hadrons[
i].px(0.0);
909 HH_hadrons[
i].py(0.0);
910 HH_hadrons[
i].pz(0.0);
917 std::vector<unsigned int> used_tags;
919 int max_allowed_tag = std::numeric_limits<int>::max() - 1e6;
920 for(
unsigned int ishower = 0; ishower <
shower.size(); ishower++) {
921 for(
unsigned int ipart = 0; ipart <
shower.at(ishower).size(); ipart++) {
922 used_tags.push_back(
shower.at(ishower).at(ipart)->color());
923 used_tags.push_back(
shower.at(ishower).at(ipart)->anti_color());
927 std::sort(used_tags.begin(), used_tags.end());
928 used_tags.resize(
std::distance(used_tags.begin(), std::unique(used_tags.begin(), used_tags.end())));
931 std::vector<unsigned int> needed_tags_values;
932 int number_needed_tags = 0;
933 for (
unsigned int tag : used_tags) {
934 if (tag > max_allowed_tag) {
935 needed_tags_values.push_back(tag);
936 number_needed_tags++;
941 int lower_limit_tag = 100;
942 std::vector<int> new_tags;
943 while (new_tags.size() < number_needed_tags) {
944 if (std::find(used_tags.begin(), used_tags.end(), lower_limit_tag) == used_tags.end()) {
945 new_tags.push_back(lower_limit_tag);
951 for(
int tag = 0; tag < number_needed_tags; tag++) {
952 for(
unsigned int ishower = 0; ishower <
shower.size(); ishower++) {
953 for(
unsigned int ipart = 0; ipart <
shower.at(ishower).size(); ipart++) {
954 unsigned int current_tag = needed_tags_values.at(tag);
955 if (
shower.at(ishower).at(ipart)->color() == current_tag) {
956 shower.at(ishower).at(ipart)->set_color(new_tags.at(tag));
958 if (
shower.at(ishower).at(ipart)->anti_color() == current_tag) {
959 shower.at(ishower).at(ipart)->set_anti_color(new_tags.at(tag));
973 for(
int i=0;
i<HH_showerptns.num(); ++
i){
974 if(HH_showerptns[
i].string_id() != 0){
continue;}
976 std::vector<int> colors;
977 if(HH_showerptns[
i].
col() > 0){colors.push_back(HH_showerptns[
i].
col()) ;}
978 if(HH_showerptns[
i].acol() > 0){colors.push_back(HH_showerptns[
i].acol());}
979 HH_showerptns[
i].string_id(nstr); ++nstr;
980 bool newcolor =
true;
984 int j=0;
while(j<HH_showerptns.num()){
985 if(HH_showerptns[j].string_id() != 0){++
j;
continue;}
986 for(
int k=0;
k<colors.size();++
k){
987 if( colors[
k]==HH_showerptns[j].
col() && (HH_showerptns[
j].acol()>0)){
988 colors.push_back(HH_showerptns[j].acol()); newcolor=
true; HH_showerptns[
j].string_id(HH_showerptns[
i].string_id()); j=-1;
break;
990 else if(colors[
k]==HH_showerptns[j].acol() && (HH_showerptns[j].
col() >0)){
991 colors.push_back(HH_showerptns[j].
col()) ; newcolor=
true; HH_showerptns[
j].string_id(HH_showerptns[
i].string_id()); j=-1;
break;
993 else if(colors[
k]==HH_showerptns[j].
col() || colors[
k]==HH_showerptns[j].acol()){HH_showerptns[
j].string_id(HH_showerptns[
i].string_id());
break;}
1015 for(
int i=1;
i<nstr;++
i){
1017 std::vector<bool> is_used; std::vector<int> ptns_new;
1018 std::vector<int> ptns_strnow;
1019 for(
int j=0;
j<HH_showerptns.num(); ++
j){
if(HH_showerptns[
j].string_id()==
i){ptns_strnow.push_back(
j); is_used.push_back(
false);}}
1023 std::vector<int> stack;
1024 bool readcolor=
true;
int firstcol = 0;
1025 for(
int j=0;
j<ptns_strnow.size();++
j){
1026 if(!(HH_showerptns[ptns_strnow[
j]].
id() == 21)){
1027 if((HH_showerptns[ptns_strnow[
j]].
id() > 0 && HH_showerptns[ptns_strnow[
j]].
id() <= 6) || (HH_showerptns[ptns_strnow[
j]].id() < -6)){
1028 stack.push_back(ptns_strnow[
j]); is_used[
j]=
true; firstcol=HH_showerptns[stack[0]].acol();
break;
1030 else{stack.push_back(ptns_strnow[
j]); is_used[
j]=
true; firstcol=HH_showerptns[stack[0]].col(); readcolor=
false;
break;}
1033 else if(
j==ptns_strnow.size()-1){stack.push_back(ptns_strnow[0]); is_used[0]=
true; firstcol=HH_showerptns[stack[0]].acol();}
1035 ptns_new.push_back(stack[0]);
1037 while(stack.size()>0){
1040 if( readcolor && (HH_showerptns[stack.back()].col() == firstcol)){stack.pop_back();
continue;}
1041 else if(!readcolor && (HH_showerptns[stack.back()].acol() == firstcol)){stack.pop_back();
continue;}
1046 for(
int j=0;
j<ptns_strnow.size();++
j){
1047 if( readcolor && !is_used[
j] && (HH_showerptns[stack.back()].col() == HH_showerptns[ptns_strnow[
j]].acol())){
1048 stack[stack.size()-1] = ptns_strnow[
j]; is_used[
j]=
true; ptns_new.push_back(stack.back());
1051 else if(!readcolor && !is_used[
j] && (HH_showerptns[stack.back()].acol() == HH_showerptns[ptns_strnow[
j]].col() )){
1052 stack[stack.size()-1] = ptns_strnow[
j]; is_used[
j]=
true; ptns_new.push_back(stack.back());
1104 if(!found){stack.pop_back();}
1109 for(
int j=0;
j<ptns_new.size();++
j){
1110 HH_showerptns[ptns_new[
j]].pos_str(
j);
1111 HH_showerptns[ptns_new[
j]].endpt_id( (HH_showerptns[ptns_new[
j]].
id() == 21) ? 0 : ++endpt );
1112 HH_showerptns[ptns_new[
j]].is_strendpt( (HH_showerptns[ptns_new[
j]].
id() == 21) ?
false :
true );
1119 int numendpoint = 0;
int num_str0 = -1;
1120 for(
int i=0;
i<HH_showerptns.num();++
i){
1121 if(HH_showerptns[
i].string_id() != 0){
continue;}
1123 bool is_endpoint =
false;
1124 if(HH_showerptns[
i].
id() != 21){iendpoint = ++numendpoint; is_endpoint =
true;}
1125 HH_showerptns[
i].string_id(0);
1126 HH_showerptns[
i].pos_str(++num_str0);
1127 HH_showerptns[
i].endpt_id(iendpoint);
1128 HH_showerptns[
i].is_strendpt(is_endpoint);
1134 std::stable_sort(&HH_showerptns[0], (&HH_showerptns[HH_showerptns.num()-1])+1, [](
const HHparton& parton1,
const HHparton& parton2){
return (parton1.
string_id() < parton2.
string_id());});
1136 for(
int i=0;
i<HH_showerptns.num(); ++
i){
1137 int start, prev_pos, cur_pos, lastfix;
1138 lastfix = 0;
if(
i == HH_showerptns.num()-1){lastfix = 1;}
1139 cur_pos = HH_showerptns[
i].string_id();
1140 if(
i==0){prev_pos = HH_showerptns[0].string_id(); start = 0;}
1141 if(cur_pos != prev_pos ||
i == HH_showerptns.num()-1){
1142 std::stable_sort(&HH_showerptns[start],&HH_showerptns[
i]+lastfix, [](
const HHparton& parton1,
const HHparton& parton2){
return (parton1.
pos_str() < parton2.
pos_str());});
1143 start =
i; prev_pos = HH_showerptns[
i].pos_str();
1161 HH_remnants.
clear();
1164 std::vector<int> list_strs;
1166 list_strs.push_back(HH_showerptns[0].string_id());
1168 for(
int i=0;
i<HH_showerptns.num();++
i){
1169 bool str_match =
false;
1170 for(
int j=0;
j<list_strs.size();++
j){
1171 if(HH_showerptns[
i].string_id() == list_strs[
j]){str_match =
true;}
1173 if(!str_match){list_strs.push_back(HH_showerptns[
i].string_id());}
1181 std::vector<int*> ColInfo3;
1182 for(
int i=0;
i<HH_showerptns.num();
i++) {
1183 int colinfo3[2] = {HH_showerptns[
i].col() , HH_showerptns[
i].acol()};
1184 ColInfo3.push_back(colinfo3);
1192 for(
int i = 0;
i < HH_showerptns.num();
i++){
1193 for(
int j =
i+1;
j < HH_showerptns.num();
j++){
1194 if(HH_showerptns[
i].
col() != 0 && HH_showerptns[
i].col() == HH_showerptns[
j].col()){
1195 for(
int k = 0;
k < HH_showerptns.num();
k++){
1196 if(HH_showerptns[
i].
col() == HH_showerptns[
k].acol()){
1200 Info.push_back(temptag);
1202 HH_showerptns[
i].col(temptag);
1203 HH_showerptns[
k].acol(temptag);
1212 for(
int i = 0;
i < HH_showerptns.num();
i++){
1213 for(
int j =
i+1;
j < HH_showerptns.num();
j++){
1214 if(HH_showerptns[
i].acol() != 0 && HH_showerptns[
i].acol() == HH_showerptns[
j].acol()){
1215 for(
int k = 0;
k < HH_showerptns.num();
k++){
1216 if(HH_showerptns[
i].acol() == HH_showerptns[
k].col()){
1220 Info.push_back(temptag);
1222 HH_showerptns[
i].acol(temptag);
1223 HH_showerptns[
k].col(temptag);
1234 std::vector<int*> ColInfo2;
1235 for(
int i=0;
i<HH_showerptns.num();
i++) {
1236 int colinfo2[2] = {HH_showerptns[
i].col() , HH_showerptns[
i].acol()};
1237 ColInfo2.push_back(colinfo2);
1242 set_initial_parton_masses(HH_showerptns);
1245 for(
int i_pt=0; i_pt<HH_showerptns.num(); ++i_pt){
1247 if((std::abs(HH_showerptns[i_pt].
id()) <= 5 ) && (HH_showerptns[i_pt].PY_origid() == 0)){
1248 showerquarks.
add(HH_showerptns.partons[i_pt]);
1249 showerquarks[showerquarks.
num()-1].par(i_pt);
1252 else if((HH_showerptns[i_pt].
id() == 21) && (HH_showerptns[i_pt].PY_origid() == 0)){
1255 HH_showerptns[i_pt].is_decayedglu(
true); HH_showerptns[i_pt].status(-99);
1260 double temp_glumass = HH_showerptns[i_pt].mass();
1261 if(HH_showerptns[i_pt].
mass()<2.*xmq+0.001){HH_showerptns[i_pt].mass(2.*xmq+0.001);}
1265 gluon_decay(HH_showerptns[i_pt], qpair);
1268 HH_showerptns[i_pt].mass(temp_glumass);
1271 qpair[0].par(i_pt); qpair[1].par(i_pt);
1272 qpair[0].is_shower(
true); qpair[1].is_shower(
true);
1273 qpair[0].orig( HH_showerptns[i_pt].orig() ); qpair[1].orig( HH_showerptns[i_pt].orig() );
1274 qpair[0].string_id ( HH_showerptns[i_pt].string_id()); qpair[1].string_id ( HH_showerptns[i_pt].string_id());
1275 qpair[0].pos_str ( HH_showerptns[i_pt].pos_str()); qpair[1].pos_str ( HH_showerptns[i_pt].pos_str());
1278 showerquarks.
add(qpair);
1281 showerquarks[showerquarks.
num()-1].sibling( showerquarks.
num()-2 );
1282 showerquarks[showerquarks.
num()-2].sibling( showerquarks.
num()-1 );
1313 int perm1[showerquarks.
num()], perm2[showerquarks.
num()+HH_thermal.num()];
1318 std::vector<std::pair<double,int>> tosort1, tosort2;
1319 for (
int i=0;
i<showerquarks.
num();++
i){
1320 tosort1.push_back(std::make_pair(showerquarks[
i].x_t(),
i));
1321 tosort2.push_back(std::make_pair(showerquarks[
i].x_t(),
i+1));
1323 for (
int i=0;
i<HH_thermal.num();++
i){
1324 tosort2.push_back({HH_thermal[
i].x_t(),-
i-1});
1332 for(
int i=0;
i<tosort1.size();++
i){
1333 perm1[
i]=tosort1[
i].second;
1335 for(
int i=0;
i<tosort2.size();++
i){
1336 perm2[
i]=tosort2[
i].second;
1340 for(
int i=0;
i<showerquarks.
num();++
i){
1343 for(
int i=0;
i<HH_thermal.num();++
i){
1344 perm2[
i]=(
i-HH_thermal.num());
1346 for(
int i=HH_thermal.num();
i<showerquarks.
num()+HH_thermal.num();++
i){
1347 perm2[
i]=(
i-HH_thermal.num()+1);
1355 for(
int i=0;
i<showerquarks.
num()-1;++
i){
1356 int ranelement =
i+floor((showerquarks.
num()-
i)*
ran());
1357 int temp = perm1[
i];
1358 perm1[
i] = perm1[ranelement];
1359 perm1[ranelement] = temp;
1361 for(
int i=0;
i<showerquarks.
num()+HH_thermal.num()-1;++
i){
1362 int ranelement =
i+floor((showerquarks.
num()+HH_thermal.num()-
i)*
ran());
1363 int temp = perm2[
i];
1364 perm2[
i] = perm2[ranelement];
1365 perm2[ranelement] = temp;
1370 std::vector<int*> ColInfo;
1371 for(
int i=0;
i<HH_showerptns.num();
i++) {
1372 int colinfo[2] = {HH_showerptns[
i].col() , HH_showerptns[
i].acol()};
1373 ColInfo.push_back(colinfo);
1379 std::vector<vector<int>> IndiceForCol1;
1380 std::vector<int> IndiceForCol2;
1381 std::vector<int> IndiceForColFin;
1383 for(
int iIndice=0; iIndice < HH_showerptns.num(); iIndice++) {
1384 IndiceForCol2.push_back(iIndice);
1385 IndiceForCol2.push_back(1);
1386 IndiceForCol2.push_back(HH_showerptns[iIndice].
col());
1387 IndiceForCol1.push_back(IndiceForCol2);
1388 IndiceForCol2.clear();
1390 IndiceForCol2.push_back(iIndice);
1391 IndiceForCol2.push_back(-1);
1392 IndiceForCol2.push_back(HH_showerptns[iIndice].acol());
1393 IndiceForCol1.push_back(IndiceForCol2);
1394 IndiceForCol2.clear();
1404 vector<int> tempcol;
1406 for(
int icol = 0; icol < IndiceForCol1.size(); icol++){
1407 tempcol.push_back(IndiceForCol1.at(icol).at(2));
1409 if(tempcol.at(0) != 0){
1410 IndiceForColFin.push_back(tempcol.at(0));
1412 if(tempcol.at(1) != 0){
1413 IndiceForColFin.push_back(tempcol.at(1));
1416 for(
int iclear1 = 0; iclear1 < tempcol.size(); iclear1++){
1417 bool foundsame =
false;
1418 for(
int iclear2 = 0; iclear2 < IndiceForColFin.size(); iclear2++){
1419 if(tempcol.at(iclear1) == IndiceForColFin.at(iclear2) || tempcol.at(iclear1) == 0){
1424 IndiceForColFin.push_back(tempcol.at(iclear1));
1430 for(
int i = 0;
i < IndiceForColFin.size();
i++){
1431 if(IndiceForColFin[
i] == 0){
1432 std::vector<int>::iterator i1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), 0 );
1435 IndiceForColFin.erase(i1);
1452 maxtag = *max_element(IndiceForColFin.begin() , IndiceForColFin.end());
1458 std::vector<vector<double>> MesonrecoMatrix1;
1459 std::vector<double> MesonrecoMatrix2;
1462 for(
int irow=0; irow < IndiceForColFin.size(); irow++){
1463 for(
int icol=0; icol < IndiceForColFin.size(); icol++){
1466 int tag1 = IndiceForColFin.at(irow);
1467 int tag2 = IndiceForColFin.at(icol);
1468 std::vector<int>::iterator it1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), tag1);
1469 std::vector<int>::iterator it2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), tag2);
1475 distance = abs(pos1 - pos2);
1480 MesonrecoMatrix2.push_back(Mesonfactor);
1483 Mesonfactor = 0.111;
1485 MesonrecoMatrix2.push_back(Mesonfactor);
1488 MesonrecoMatrix1.push_back(MesonrecoMatrix2);
1489 MesonrecoMatrix2.clear();
1493 for(
int icheck1 = 0; icheck1 < HH_showerptns.num(); icheck1++ ){
1494 if(HH_showerptns[icheck1].
col() != 0 && HH_showerptns[icheck1].acol() != 0 ){
1495 int tag1 = HH_showerptns[icheck1].col();
1496 int tag2 = HH_showerptns[icheck1].acol();
1497 std::vector<int>::iterator it1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), tag1);
1498 std::vector<int>::iterator it2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), tag2);
1501 MesonrecoMatrix1.at(pos1).at(pos2) = 0;
1502 MesonrecoMatrix1.at(pos2).at(pos1) = 0;
1517 std::vector<vector<vector<double>>> BaryonrecoMatrix1;
1518 std::vector<vector<double>> BaryonrecoMatrix2;
1519 std::vector<double> BaryonrecoMatrix3;
1521 for(
int irow=0; irow < IndiceForColFin.size(); irow++){
1522 for(
int icol=0; icol < IndiceForColFin.size(); icol++){
1523 double Baryonfactor;
1524 BaryonrecoMatrix3.push_back(1./27.);
1525 BaryonrecoMatrix3.push_back(0.);
1527 BaryonrecoMatrix2.push_back(BaryonrecoMatrix3);
1528 BaryonrecoMatrix3.clear();
1530 BaryonrecoMatrix1.push_back(BaryonrecoMatrix2);
1531 BaryonrecoMatrix2.clear();
1554 for(
int q1=0;q1<showerquarks.
num();++q1){
1558 if(sh_recofactor < 0.0000000001){
continue;}
1561 bool madehadron =
false;
1564 element[0] = perm1[q1];
1567 if(showerquarks[element[0]].
status() != 0 || showerquarks[element[0]].is_used()){
continue;}
1568 else if(std::abs(showerquarks[element[0]].
id()) > 5){
JSWARN <<
"SOMETHING OTHER THAN u,d,s,c,b WAS considered for recombination, THIS SHOULD NOT HAPPEN!";
continue;}
1573 considering.
add(showerquarks[element[0]]);
1574 showerquarks[element[0]].status(-991);
1576 for(
int q2=0;q2<showerquarks.
num()+HH_thermal.num();++q2){
1580 double recofactor2 = 1./9.;
1584 if(perm2[q2]>0){ element[1] = perm2[q2] - 1;}
1585 else{ element[1] = perm2[q2] + 1;}
1594 if(showerquarks[element[1]].
status() != 0 || showerquarks[element[1]].is_used()){
continue;}
1596 else if(element[0]==element[1]){
continue;}
1598 else if((showerquarks[element[0]].par() != -1) && (showerquarks[element[0]].par() == showerquarks[element[1]].par())){
continue;}
1602 else if(std::abs(showerquarks[element[1]].
id()) > 5){
JSWARN <<
"SOMETHING OTHER THAN u,d,s,c,b WAS considered for recombination, THIS SHOULD NOT HAPPEN!";
continue;}
1604 considering.
add(showerquarks[element[1]]);
1605 showerquarks[element[1]].status(-992);
1607 else if(perm2[q2]<0){
1609 if(HH_thermal[-element[1]].
status() != 0 || HH_thermal[-element[1]].is_used()){
continue;}
1611 else if(std::abs(HH_thermal[-element[1]].
id()) > 5){
JSWARN <<
"SOMETHING OTHER THAN u,d,s,c,b WAS considered for recombination, THIS SHOULD NOT HAPPEN!";
continue;}
1613 else if(th_recofactor < 0.001){
continue;}
1616 FourVector pos_ptn1 = considering[0].pos();
FourVector pos_ptn2 = HH_thermal[-element[1]].pos();
1617 double dt = pos_ptn1.
t() - pos_ptn2.
t();
1619 double dt_E = dt/HH_thermal[-element[1]].e();
1620 pos_ptn2.
Set(pos_ptn2.
x()+HH_thermal[-element[1]].px()*dt_E,pos_ptn2.
y()+HH_thermal[-element[1]].py()*dt_E,pos_ptn2.
z()+HH_thermal[-element[1]].pz()*dt_E,0.);
1623 double dt_E = -dt/considering[0].e();
1624 pos_ptn1.
Set(pos_ptn1.
x()+considering[0].px()*dt_E,pos_ptn1.
y()+considering[0].py()*dt_E,pos_ptn1.
z()+considering[0].pz()*dt_E, 0.);
1626 if(dif2(pos_ptn1,pos_ptn2) > dist2cut){
continue;}
1628 considering.
add(HH_thermal[-element[1]]);
1629 HH_thermal[-element[1]].status(-992);
1631 else{
JSWARN <<
"SOMETHING WENT HORRIBLY WRONG - DO NOT KNOW WHERE CURRENT QUARK CAME FROM?!";}
1636 if((considering[0].
id()*considering[1].
id() > 0) && (q2 < showerquarks.
num()+HH_thermal.num()-1) && (maxB_level > -1)){
1637 for(
int q3=q2+1;q3<showerquarks.
num()+HH_thermal.num();++q3){
1639 double recofactor3 = 2./27.;
1643 while(considering.
num() > 2){considering.
partons.pop_back();}
1647 if(perm2[q3]>0){ element[2] = perm2[q3] - 1;}
1648 else{ element[2] = perm2[q3] + 1;}
1660 if(showerquarks[element[2]].
id()*considering[0].
id() < 0){
continue;}
1662 if(showerquarks[element[2]].
status() != 0 || showerquarks[element[2]].is_used()){
continue;}
1664 else if(element[0]==element[2] || element[1] == element[2]){
continue;}
1666 else if((showerquarks[element[0]].par() != -1) && (showerquarks[element[0]].par() == showerquarks[element[2]].par())){
continue;}
1668 else if((perm2[q2] > 0) && (showerquarks[element[1]].par() != -1) && (showerquarks[element[1]].par() == showerquarks[element[2]].par())){
continue;}
1673 else if(std::abs(showerquarks[element[2]].
id()) > 5){
JSWARN <<
"SOMETHING OTHER THAN u,d,s,c,b WAS considered for recombination, THIS SHOULD NOT HAPPEN!";
continue;}
1675 considering.
add(showerquarks[element[2]]);
1676 showerquarks[element[2]].status(-993);
1682 bool element1 =
false;
1683 bool element2 =
false;
1684 bool element3 =
false;
1685 int juncnum1 = 999999999;
1686 int juncnum2 = 999999999;
1687 int juncnum3 = 999999999;
1689 int standard = IndiceForColFin.size();
1690 int tagformatrix = 999999999;
1691 int loc1 = standard;
1692 std::vector<int>::iterator I1;
1693 std::vector<int>::iterator I2;
1694 int loc2 = standard;
1696 if(considering[0].
id()*considering[1].
id()*considering[2].
id() > 0){
1699 for(
int ijunc=0; ijunc < Tempjunctions.size(); ijunc++){
1700 if((considering[0].
col() == Tempjunctions.at(ijunc).at(1).at(1)) ||
1701 (considering[0].
col() == Tempjunctions.at(ijunc).at(2).at(1)) ||
1702 (considering[0].
col() == Tempjunctions.at(ijunc).at(3).at(1)) ) {
1706 if((considering[1].
col() == Tempjunctions.at(ijunc).at(1).at(1)) ||
1707 (considering[1].
col() == Tempjunctions.at(ijunc).at(2).at(1)) ||
1708 (considering[1].
col() == Tempjunctions.at(ijunc).at(3).at(1)) ) {
1712 if((considering[2].
col() == Tempjunctions.at(ijunc).at(1).at(1)) ||
1713 (considering[2].
col() == Tempjunctions.at(ijunc).at(2).at(1)) ||
1714 (considering[2].
col() == Tempjunctions.at(ijunc).at(3).at(1)) ) {
1719 if((juncnum1 == juncnum2) && (juncnum1 != juncnum3) && juncnum1 != 999999999 && considering[2].
col() != 0){
1720 tagformatrix = Tempjunctions.at(juncnum1).at(3).at(1);
1721 I2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), considering[2].col());
1726 if((juncnum2 == juncnum3) && (juncnum2 != juncnum1) && juncnum2 != 999999999 && considering[0].
col() != 0){
1727 tagformatrix = Tempjunctions.at(juncnum2).at(1).at(1);
1728 I2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), considering[0].col());
1733 if((juncnum1 == juncnum3) && (juncnum1 != juncnum2) && juncnum3 != 999999999 && considering[1].
col() != 0){
1734 tagformatrix = Tempjunctions.at(juncnum3).at(2).at(1);
1735 I2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), considering[1].col());
1741 I1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), tagformatrix);
1748 if (tagformatrix < 999999999 && loc1 < standard && loc2 < standard) {
1749 if(MesonrecoMatrix1.at(loc1).at(loc2) == 1) {
1752 recofactor3 = 1./9.;
1754 }
else{recofactor3 = 1./27.;}
1756 if((juncnum1 == juncnum2) && (juncnum2 == juncnum3) && (tagformatrix != 999999999)){
1760 else if(considering[0].
id()*considering[1].id()*considering[2].id() < 0){
1762 for(
int ijunc=0; ijunc < Tempjunctions.size(); ijunc++){
1763 if((considering[0].acol() == Tempjunctions.at(ijunc).at(1).at(1)) ||
1764 (considering[0].acol() == Tempjunctions.at(ijunc).at(2).at(1)) ||
1765 (considering[0].acol() == Tempjunctions.at(ijunc).at(3).at(1)) ) {
1769 if((considering[1].acol() == Tempjunctions.at(ijunc).at(1).at(1)) ||
1770 (considering[1].acol() == Tempjunctions.at(ijunc).at(2).at(1)) ||
1771 (considering[1].acol() == Tempjunctions.at(ijunc).at(3).at(1)) ) {
1775 if((considering[2].acol() == Tempjunctions.at(ijunc).at(1).at(1)) ||
1776 (considering[2].acol() == Tempjunctions.at(ijunc).at(2).at(1)) ||
1777 (considering[2].acol() == Tempjunctions.at(ijunc).at(3).at(1)) ) {
1782 if((juncnum1 == juncnum2) && (juncnum1 != juncnum3) && juncnum1 != 999999999){
1783 tagformatrix = Tempjunctions.at(juncnum1).at(3).at(1);
1784 I2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), considering[2].acol());
1789 if((juncnum2 == juncnum3) && (juncnum2 != juncnum1) && juncnum2 != 999999999){
1790 tagformatrix = Tempjunctions.at(juncnum2).at(1).at(1);
1791 I2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), considering[0].acol());
1796 if((juncnum1 == juncnum3) && (juncnum1 != juncnum2) && juncnum3 != 999999999){
1797 tagformatrix = Tempjunctions.at(juncnum3).at(2).at(1);
1798 I2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), considering[1].acol());
1804 I1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), tagformatrix);
1811 if (tagformatrix < 999999999 && loc1 < standard && loc2 < standard) {
1812 if(MesonrecoMatrix1.at(loc1).at(loc2) == 1) {
1815 recofactor3 = 1./9.;
1818 else{recofactor3 = 1./27.;}
1820 if((juncnum1 == juncnum2) && (juncnum2 == juncnum3) && (tagformatrix != 999999999)){
1825 }
else if(perm2[q3]<0){
1827 if(HH_thermal[-element[2]].
id()*considering[0].id() < 0){
continue;}
1829 if(HH_thermal[-element[2]].
status() != 0 || HH_thermal[-element[2]].is_used()){
continue;}
1831 else if((perm2[q2] < 0) && (HH_thermal[-element[1]].par() != -1) && (HH_thermal[-element[1]].par() == HH_thermal[-element[2]].par())){
continue;}
1833 else if(std::abs(HH_thermal[-element[2]].
id()) > 5){
JSWARN <<
"SOMETHING OTHER THAN u,d,s,c,b WAS considered for recombination, THIS SHOULD NOT HAPPEN!";
continue;}
1835 else if(th_recofactor < 0.001){
continue;}
1839 if((pos_ptn1.
t() > pos_ptn2.
t()) && (pos_ptn1.
t() > pos_ptn3.
t())){
1840 double dt_E2 = (pos_ptn1.
t() - pos_ptn2.
t())/considering[1].
e();
double dt_E3 = (pos_ptn1.
t() - pos_ptn3.
t())/HH_thermal[-element[2]].
e();
1841 pos_ptn2.
Set(pos_ptn2.
x()+considering[1].px()*dt_E2,pos_ptn2.
y()+considering[1].py()*dt_E2,pos_ptn2.
z()+considering[1].pz()*dt_E2,0.);
1842 pos_ptn3.
Set(pos_ptn3.
x()+HH_thermal[-element[2]].px()*dt_E3,pos_ptn3.
y()+HH_thermal[-element[2]].py()*dt_E3,pos_ptn3.
z()+HH_thermal[-element[2]].pz()*dt_E3,0.);
1844 else if((pos_ptn2.
t() > pos_ptn1.
t()) && (pos_ptn2.
t() > pos_ptn3.
t())){
1845 double dt_E1 = (pos_ptn2.
t() - pos_ptn1.
t())/considering[0].
e();
double dt_E3 = (pos_ptn2.
t() - pos_ptn3.
t())/HH_thermal[-element[2]].
e();
1846 pos_ptn1.
Set(pos_ptn1.
x()+considering[0].px()*dt_E1,pos_ptn1.
y()+considering[0].py()*dt_E1,pos_ptn1.
z()+considering[0].pz()*dt_E1,0.);
1847 pos_ptn3.
Set(pos_ptn3.
x()+HH_thermal[-element[2]].px()*dt_E3,pos_ptn3.
y()+HH_thermal[-element[2]].py()*dt_E3,pos_ptn3.
z()+HH_thermal[-element[2]].pz()*dt_E3,0.);
1850 double dt_E1 = (pos_ptn3.
t() - pos_ptn1.
t())/considering[0].
e();
double dt_E2 = (pos_ptn3.
t() - pos_ptn2.
t())/considering[1].
e();
1851 pos_ptn1.
Set(pos_ptn1.
x()+considering[0].px()*dt_E1,pos_ptn1.
y()+considering[0].py()*dt_E1,pos_ptn1.
z()+considering[0].pz()*dt_E1,0.);
1852 pos_ptn2.
Set(pos_ptn2.
x()+considering[1].px()*dt_E2,pos_ptn2.
y()+considering[1].py()*dt_E2,pos_ptn2.
z()+considering[1].pz()*dt_E2,0.);
1854 if((dif2(pos_ptn3,pos_ptn1) > dist2cut) || (dif2(pos_ptn3,pos_ptn2) > dist2cut) || (dif2(pos_ptn1,pos_ptn2) > dist2cut)){
continue;}
1856 considering.
add(HH_thermal[-element[2]]);
1857 HH_thermal[-element[2]].status(-993);
1858 }
else{
JSWARN <<
"SOMETHING WENT HORRIBLY WRONG - DO NOT KNOW WHERE CURRENT QUARK CAME FROM?!";}
1863 Pbaryon.
Set(considering[0].px()+considering[1].px()+considering[2].px(),considering[0].py()+considering[1].py()+considering[2].py(),considering[0].pz()+considering[1].pz()+considering[2].pz(),0.);
1867 betaB.
Set(Pbaryon.
x()/(considering[0].e()+considering[1].e()+considering[2].e()),Pbaryon.
y()/(considering[0].e()+considering[1].e()+considering[2].e()),Pbaryon.
z()/(considering[0].e()+considering[1].e()+considering[2].e()),0.);
1868 betaB.
Set(betaB.
x(),betaB.
y(),betaB.
z(),1./(sqrt(1. - (betaB.
x()*betaB.
x() + betaB.
y()*betaB.
y() + betaB.
z()*betaB.
z()))));
1872 pos_BCM[0] = considering[0].boost_pos(betaB); pos_BCM[1] = considering[1].boost_pos(betaB); pos_BCM[2] = considering[2].boost_pos(betaB);
1873 p_BCM[0] = considering[0].boost_P(betaB); p_BCM[1] = considering[1].boost_P(betaB); p_BCM[2] = considering[2].boost_P(betaB);
1877 v_BCM[0].
Set(p_BCM[0].
x()/p_BCM[0].
t(),p_BCM[0].
y()/p_BCM[0].
t(),p_BCM[0].
z()/p_BCM[0].
t(),0.);
1878 v_BCM[1].
Set(p_BCM[1].
x()/p_BCM[1].
t(),p_BCM[1].
y()/p_BCM[1].
t(),p_BCM[1].
z()/p_BCM[1].
t(),0.);
1879 v_BCM[2].
Set(p_BCM[2].
x()/p_BCM[2].
t(),p_BCM[2].
y()/p_BCM[2].
t(),p_BCM[2].
z()/p_BCM[2].
t(),0.);
1882 double curtime = std::max(std::max(pos_BCM[0].
t(), pos_BCM[1].
t()), pos_BCM[2].
t());
1884 cur_pos[0].
Set(pos_BCM[0].
x()+v_BCM[0].
x()*(curtime-pos_BCM[0].
t()),pos_BCM[0].
y()+v_BCM[0].
y()*(curtime-pos_BCM[0].
t()),pos_BCM[0].
z()+v_BCM[0].
z()*(curtime-pos_BCM[0].
t()),curtime);
1885 cur_pos[1].
Set(pos_BCM[1].
x()+v_BCM[1].
x()*(curtime-pos_BCM[1].
t()),pos_BCM[1].
y()+v_BCM[1].
y()*(curtime-pos_BCM[1].
t()),pos_BCM[1].
z()+v_BCM[1].
z()*(curtime-pos_BCM[1].
t()),curtime);
1886 cur_pos[2].
Set(pos_BCM[2].
x()+v_BCM[2].
x()*(curtime-pos_BCM[2].
t()),pos_BCM[2].
y()+v_BCM[2].
y()*(curtime-pos_BCM[2].
t()),pos_BCM[2].
z()+v_BCM[2].
z()*(curtime-pos_BCM[2].
t()),curtime);
1891 (cur_pos[0].
x()*considering[0].
mass()+cur_pos[1].
x()*considering[1].
mass()+cur_pos[2].
x()*considering[2].
mass())/(considering[0].
mass()+considering[1].
mass()+considering[2].
mass()),
1892 (cur_pos[0].
y()*considering[0].
mass()+cur_pos[1].
y()*considering[1].
mass()+cur_pos[2].
y()*considering[2].
mass())/(considering[0].
mass()+considering[1].
mass()+considering[2].
mass()),
1893 (cur_pos[0].
z()*considering[0].
mass()+cur_pos[1].
z()*considering[1].
mass()+cur_pos[2].
z()*considering[2].
mass())/(considering[0].
mass()+considering[1].
mass()+considering[2].
mass()),
1898 betaB.
Set(-betaB.
x(),-betaB.
y(),-betaB.
z(),betaB.
t());
1903 k_rel_square[0].
Set(
1904 (considering[1].
mass()*p_BCM[0].
x()-considering[0].
mass()*p_BCM[1].
x())/(considering[0].
mass()+considering[1].
mass()),
1905 (considering[1].
mass()*p_BCM[0].
y()-considering[0].
mass()*p_BCM[1].
y())/(considering[0].
mass()+considering[1].
mass()),
1906 (considering[1].
mass()*p_BCM[0].
z()-considering[0].
mass()*p_BCM[1].
z())/(considering[0].
mass()+considering[1].
mass()),
1908 k_rel_square[1].
Set(
1909 (considering[2].
mass()*(p_BCM[0].
x()+p_BCM[1].
x())-(considering[0].
mass()+considering[1].
mass())*p_BCM[2].
x())/(considering[0].
mass()+considering[1].
mass()+considering[2].
mass()),
1910 (considering[2].
mass()*(p_BCM[0].
y()+p_BCM[1].
y())-(considering[0].
mass()+considering[1].
mass())*p_BCM[2].
y())/(considering[0].
mass()+considering[1].
mass()+considering[2].
mass()),
1911 (considering[2].
mass()*(p_BCM[0].
z()+p_BCM[1].
z())-(considering[0].
mass()+considering[1].
mass())*p_BCM[2].
z())/(considering[0].
mass()+considering[1].
mass()+considering[2].
mass()),
1916 pos_rel_square[0].
Set((cur_pos[0].
x()-cur_pos[1].
x()),(cur_pos[0].
y()-cur_pos[1].
y()),(cur_pos[0].
z()-cur_pos[1].
z()),0.);
1917 pos_rel_square[1].
Set(
1918 ((cur_pos[0].
x()*considering[0].
mass()+cur_pos[1].
x()*considering[1].
mass())/(considering[0].
mass()+considering[1].
mass())-cur_pos[2].
x()),
1919 ((cur_pos[0].
y()*considering[0].
mass()+cur_pos[1].
y()*considering[1].
mass())/(considering[0].
mass()+considering[1].
mass())-cur_pos[2].
y()),
1920 ((cur_pos[0].
z()*considering[0].
mass()+cur_pos[1].
z()*considering[1].
mass())/(considering[0].
mass()+considering[1].
mass())-cur_pos[2].
z()),
1924 double SigRB2 = SigNucR2;
double SigLB2 = SigNucL2;
1925 int sortid[3] = {std::abs(considering[0].
id()),std::abs(considering[1].
id()),std::abs(considering[2].
id())};
1929 if( sortid[0] == 3){
1930 if( sortid[1] == 3){
1931 if( sortid[2] == 3){SigRB2 = SigOmgR2; SigLB2 = SigOmgL2;}
1932 else{ SigRB2 = SigXiR2; SigLB2 = SigXiL2;}
1934 else{ SigRB2 = SigSigR2; SigLB2 = SigSigL2;}
1936 else if(sortid[0] == 4){
1937 if( sortid[1] == 4){
1938 if( sortid[2] == 4){SigRB2 = SigOcccR2; SigLB2 = SigOcccL2;}
1939 else if(sortid[2] == 3){SigRB2 = SigOccR2; SigLB2 = SigOccL2;}
1940 else{ SigRB2 = SigXiccR2; SigLB2 = SigXiccL2;}
1942 else if(sortid[1] == 3){
1943 if( sortid[2] == 3){SigRB2 = SigOcR2; SigLB2 = SigOcL2;}
1944 else{ SigRB2 = SigXicR2; SigLB2 = SigXicL2;}
1946 else{ SigRB2 = SigSigcR2; SigLB2 = SigSigcL2;}
1948 else if(sortid[0] == 5){
1949 if( sortid[1] == 5){
1950 if( sortid[2] == 5){SigRB2 = SigObbbR2; SigLB2 = SigObbbL2; recofactor3=0.;}
1951 else if(sortid[2] == 4){SigRB2 = SigObbcR2; SigLB2 = SigObbcL2; recofactor3=0.;}
1952 else if(sortid[2] == 3){SigRB2 = SigObbR2; SigLB2 = SigObbL2; recofactor3=0.;}
1953 else{ SigRB2 = SigXibbR2; SigLB2 = SigXibbL2; recofactor3=0.;}
1955 else if(sortid[1] == 4){
1956 if( sortid[2] == 4){SigRB2 = SigObccR2; SigLB2 = SigObccL2; recofactor3=0.;}
1957 else if(sortid[2] == 3){SigRB2 = SigObcR2; SigLB2 = SigObcL2; recofactor3=0.;}
1958 else{ SigRB2 = SigXibcR2; SigLB2 = SigXibcL2; recofactor3=0.;}
1960 else if(sortid[1] == 3){
1961 if( sortid[2] == 3){SigRB2 = SigObR2; SigLB2 = SigObL2;}
1962 else{ SigRB2 = SigXibR2; SigLB2 = SigXibL2;}
1964 else{ SigRB2 = SigSigbR2; SigLB2 = SigSigbL2;}
1969 double urho[3], ulamb[3];
1970 urho[0] = 0.5*(pos_rel_square[0].
x()*pos_rel_square[0].
x()/SigRB2 + k_rel_square[0].
x()*k_rel_square[0].
x()*SigRB2/hbarc2);
1971 urho[1] = 0.5*(pos_rel_square[0].
y()*pos_rel_square[0].
y()/SigRB2 + k_rel_square[0].
y()*k_rel_square[0].
y()*SigRB2/hbarc2);
1972 urho[2] = 0.5*(pos_rel_square[0].
z()*pos_rel_square[0].
z()/SigRB2 + k_rel_square[0].
z()*k_rel_square[0].
z()*SigRB2/hbarc2);
1973 ulamb[0] = 0.5*(pos_rel_square[1].
x()*pos_rel_square[1].
x()/SigLB2 + k_rel_square[1].
x()*k_rel_square[1].
x()*SigLB2/hbarc2);
1974 ulamb[1] = 0.5*(pos_rel_square[1].
y()*pos_rel_square[1].
y()/SigLB2 + k_rel_square[1].
y()*k_rel_square[1].
y()*SigLB2/hbarc2);
1975 ulamb[2] = 0.5*(pos_rel_square[1].
z()*pos_rel_square[1].
z()/SigLB2 + k_rel_square[1].
z()*k_rel_square[1].
z()*SigLB2/hbarc2);
1979 wig0[0][0] = std::exp(-urho[0]); wig0[0][1] = std::exp(-urho[1]); wig0[0][2] = std::exp(-urho[2]);
1980 wig0[1][0] = std::exp(-ulamb[0]); wig0[1][1] = std::exp(-ulamb[1]); wig0[1][2] = std::exp(-ulamb[2]);
1983 WigB[0] = wig0[0][0]*wig0[0][1]*wig0[0][2]*wig0[1][0]*wig0[1][1]*wig0[1][2];
1989 for(
int i=0;
i<2;++
i){
for(
int j=0;
j<2;++
j){wigE[
i][
j]=0.;}}
1991 wigE[0][0] = wig0[0][0];
1992 for(
int iRx=0; iRx<=maxB_level; ++iRx){
1993 wigE[0][1] = wig0[0][1];
1994 for(
int iRy=0; iRy<=maxB_level-iRx; ++iRy){
1995 wigE[0][2] = wig0[0][2];
1996 for(
int iRz=0; iRz<=maxB_level-iRx-iRy; ++iRz){
1997 wigE[1][0] = wig0[1][0];
1998 for(
int iLx=0; iLx<=maxB_level-iRx-iRy-iRz; ++iLx){
1999 wigE[1][1] = wig0[1][1];
2000 for(
int iLy=0; iLy<=maxB_level-iRx-iRy-iRz-iLx; ++iLy){
2001 wigE[1][2] = wig0[1][2];
2002 for(
int iLz=0; iLz<=maxB_level-iRx-iRy-iRz-iLx-iLy; ++iLz){
2003 WigB[1] += wigE[0][0]*wigE[0][1]*wigE[0][2]*wigE[1][0]*wigE[1][1]*wigE[1][2];
2004 wigE[1][2] *= ulamb[2]/((
double(iLz))+1.);
2006 wigE[1][1] *= ulamb[1]/((
double(iLy))+1.);
2008 wigE[1][0] *= ulamb[0]/((
double(iLx))+1.);
2010 wigE[0][2] *= urho[2]/((
double(iRz))+1.);
2012 wigE[0][1] *= urho[1]/((
double(iRy))+1.);
2014 wigE[0][0] *= urho[0]/((
double(iRx))+1.);
2017 if(maxB_level == -1) {
2023 double rndbaryon =
ran();
2024 double mult = (considering[1].is_thermal() || considering[2].is_thermal()) ? th_recofactor : sh_recofactor;
2025 if(WigB[1]*recofactor3*mult >= rndbaryon){
2026 int junction_with_thermal_parton = 0;
2032 if(considering[0].
id() * considering[1].id() * considering[2].id() > 0){
2034 if(considering[0].
col() > 0 && considering[1].col() > 0 && considering[2].col() > 0) {
2035 IdColInfo1.push_back(-1);
2036 IdColInfo1.push_back(junction_with_thermal_parton);
2037 IdColInfo2.push_back(-1);
2038 IdColInfo2.push_back(considering[0].
col());
2039 IdColInfo3.push_back(-1);
2040 IdColInfo3.push_back(considering[1].
col());
2041 IdColInfo4.push_back(-1);
2042 IdColInfo4.push_back(considering[2].
col());
2044 JunctionInfo.push_back(IdColInfo1);
2045 JunctionInfo.push_back(IdColInfo2);
2046 JunctionInfo.push_back(IdColInfo3);
2047 JunctionInfo.push_back(IdColInfo4);
2049 Tempjunctions.push_back(JunctionInfo);
2055 JunctionInfo.clear();
2058 int coltag1 = considering[0].col();
2059 int coltag2 = considering[1].col();
2060 int coltag3 = considering[2].col();
2061 if(coltag1 > 0 && coltag2 > 0 && coltag3 > 0 && coltag1 <= limit && coltag2 <= limit && coltag3 <= limit ){
2062 double tag1 = (
double)coltag1;
2063 double tag2 = (
double)coltag2;
2064 double tag3 = (
double)coltag3;
2065 std::vector<int>::iterator I1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), coltag1);
2066 std::vector<int>::iterator I2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), coltag2);
2067 std::vector<int>::iterator I3 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), coltag3);
2072 BaryonrecoMatrix1.at(loc1).at(loc2).at(1) = tag3;
2073 BaryonrecoMatrix1.at(loc2).at(loc1).at(1) = tag3;
2074 BaryonrecoMatrix1.at(loc2).at(loc3).at(1) = tag1;
2075 BaryonrecoMatrix1.at(loc3).at(loc2).at(1) = tag1;
2076 BaryonrecoMatrix1.at(loc1).at(loc3).at(1) = tag2;
2077 BaryonrecoMatrix1.at(loc3).at(loc1).at(1) = tag2;
2080 MesonrecoMatrix1.at(loc1).at(loc2) = 0;
2081 MesonrecoMatrix1.at(loc2).at(loc1) = 0;
2082 MesonrecoMatrix1.at(loc2).at(loc3) = 0;
2083 MesonrecoMatrix1.at(loc3).at(loc2) = 0;
2084 MesonrecoMatrix1.at(loc1).at(loc3) = 0;
2085 MesonrecoMatrix1.at(loc3).at(loc1) = 0;
2106 if(considering[0].
col() > 0 && considering[1].
col() == 0 && considering[2].
col() > 0){
2107 IdColInfo1.push_back(-1);
2110 int loc = findcloserepl(considering[1], perm2[q2],
true,
true, showerquarks, HH_thermal);
2111 if(loc == 999999999){
2113 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2114 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2115 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2116 fakep.
e(fakep.
mass());
2118 Extraparton.
add(fakep);
2119 junction_with_thermal_parton = 1;
2122 else if (loc > 0){showerquarks[loc - 1].acol(maxtag); }
2123 else if(loc < 0){HH_thermal[-loc - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2125 IdColInfo1.push_back(junction_with_thermal_parton);
2128 IdColInfo2.push_back(-1);
2129 IdColInfo2.push_back(considering[0].
col());
2130 IdColInfo3.push_back(-1);
2131 IdColInfo3.push_back(maxtag);
2132 IdColInfo4.push_back(-1);
2133 IdColInfo4.push_back(considering[2].
col());
2135 JunctionInfo.push_back(IdColInfo1);
2136 JunctionInfo.push_back(IdColInfo2);
2137 JunctionInfo.push_back(IdColInfo3);
2138 JunctionInfo.push_back(IdColInfo4);
2140 Tempjunctions.push_back(JunctionInfo);
2146 JunctionInfo.clear();
2148 if(considering[0].
col() == 0 && considering[1].
col() > 0 && considering[2].
col() > 0){
2149 IdColInfo1.push_back(-1);
2152 int loc = findcloserepl(considering[0], element[0] + 1,
true,
true, showerquarks, HH_thermal);
2153 if(loc == 999999999){
2155 HHparton fakep = considering[0]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2156 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2157 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2158 fakep.
e(fakep.
mass());
2160 Extraparton.
add(fakep);
2161 junction_with_thermal_parton = 1;
2164 else if (loc > 0){showerquarks[loc - 1].acol(maxtag); }
2165 else if(loc < 0){HH_thermal[-loc - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2167 IdColInfo1.push_back(junction_with_thermal_parton);
2169 IdColInfo2.push_back(-1);
2170 IdColInfo2.push_back(maxtag);
2171 IdColInfo3.push_back(-1);
2172 IdColInfo3.push_back(considering[1].
col());
2173 IdColInfo4.push_back(-1);
2174 IdColInfo4.push_back(considering[2].
col());
2176 JunctionInfo.push_back(IdColInfo1);
2177 JunctionInfo.push_back(IdColInfo2);
2178 JunctionInfo.push_back(IdColInfo3);
2179 JunctionInfo.push_back(IdColInfo4);
2181 Tempjunctions.push_back(JunctionInfo);
2187 JunctionInfo.clear();
2189 if(considering[0].
col() > 0 && considering[1].
col() > 0 && considering[2].
col() == 0){
2190 IdColInfo1.push_back(-1);
2193 int loc = findcloserepl(considering[2], perm2[q3],
true,
true, showerquarks, HH_thermal);
2194 if(loc == 999999999){
2196 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2197 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2198 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2199 fakep.
e(fakep.
mass());
2201 Extraparton.
add(fakep);
2202 junction_with_thermal_parton = 1;
2205 else if (loc > 0){showerquarks[loc - 1].acol(maxtag); }
2206 else if(loc < 0){HH_thermal[-loc - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2208 IdColInfo1.push_back(junction_with_thermal_parton);
2210 IdColInfo2.push_back(-1);
2211 IdColInfo2.push_back(considering[0].
col());
2212 IdColInfo3.push_back(-1);
2213 IdColInfo3.push_back(considering[1].
col());
2214 IdColInfo4.push_back(-1);
2215 IdColInfo4.push_back(maxtag);
2217 JunctionInfo.push_back(IdColInfo1);
2218 JunctionInfo.push_back(IdColInfo2);
2219 JunctionInfo.push_back(IdColInfo3);
2220 JunctionInfo.push_back(IdColInfo4);
2222 Tempjunctions.push_back(JunctionInfo);
2228 JunctionInfo.clear();
2230 if(considering[0].
col() > 0 && considering[1].
col() == 0 && considering[2].
col() == 0){
2231 IdColInfo1.push_back(-1);
2232 IdColInfo2.push_back(-1);
2233 IdColInfo2.push_back(considering[0].
col());
2236 int loc1 = findcloserepl(considering[1], perm2[q2],
true,
true, showerquarks, HH_thermal);
2237 if(loc1 == 999999999){
2239 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2240 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2241 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2242 fakep.
e(fakep.
mass());
2244 Extraparton.
add(fakep);
2245 junction_with_thermal_parton = 1;
2248 else if (loc1 > 0){showerquarks[loc1 - 1].acol(maxtag); }
2249 else if(loc1 < 0){HH_thermal[-loc1 - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2250 IdColInfo3.push_back(-1);
2251 IdColInfo3.push_back(maxtag);
2254 int loc2 = findcloserepl(considering[2], perm2[q3],
true,
true, showerquarks, HH_thermal);
2255 if(loc2 == 999999999){
2257 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2258 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2259 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2260 fakep.
e(fakep.
mass());
2262 Extraparton.
add(fakep);
2263 junction_with_thermal_parton = 1;
2266 else if (loc2 > 0){showerquarks[loc2 - 1].acol(maxtag); }
2267 else if(loc2 < 0){HH_thermal[-loc2 - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2269 IdColInfo1.push_back(junction_with_thermal_parton);
2271 IdColInfo4.push_back(-1);
2272 IdColInfo4.push_back(maxtag);
2275 JunctionInfo.push_back(IdColInfo1);
2276 JunctionInfo.push_back(IdColInfo2);
2277 JunctionInfo.push_back(IdColInfo3);
2278 JunctionInfo.push_back(IdColInfo4);
2280 Tempjunctions.push_back(JunctionInfo);
2286 JunctionInfo.clear();
2288 if(considering[0].
col() == 0 && considering[1].
col() == 0 && considering[2].
col() > 0){
2289 IdColInfo1.push_back(-1);
2292 int loc1 = findcloserepl(considering[0], element[0] + 1,
true,
true, showerquarks, HH_thermal);
2293 if(loc1 == 999999999){
2295 HHparton fakep = considering[0]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2296 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2297 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2298 fakep.
e(fakep.
mass());
2300 Extraparton.
add(fakep);
2301 junction_with_thermal_parton = 1;
2304 else if (loc1 > 0){showerquarks[loc1 - 1].acol(maxtag); }
2305 else if(loc1 < 0){HH_thermal[-loc1 - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2306 IdColInfo3.push_back(-1);
2307 IdColInfo3.push_back(maxtag);
2310 int loc2 = findcloserepl(considering[1], perm2[q2],
true,
true, showerquarks, HH_thermal);
2311 if(loc2 == 999999999){
2313 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2314 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2315 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2316 fakep.
e(fakep.
mass());
2318 Extraparton.
add(fakep);
2319 junction_with_thermal_parton = 1;
2322 else if (loc2 > 0){showerquarks[loc2 - 1].acol(maxtag); }
2323 else if(loc2 < 0){HH_thermal[-loc2 - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2325 IdColInfo1.push_back(junction_with_thermal_parton);
2327 IdColInfo4.push_back(-1);
2328 IdColInfo4.push_back(maxtag);
2331 IdColInfo2.push_back(-1);
2332 IdColInfo2.push_back(considering[2].
col());
2334 JunctionInfo.push_back(IdColInfo1);
2335 JunctionInfo.push_back(IdColInfo2);
2336 JunctionInfo.push_back(IdColInfo3);
2337 JunctionInfo.push_back(IdColInfo4);
2339 Tempjunctions.push_back(JunctionInfo);
2345 JunctionInfo.clear();
2347 if(considering[0].
col() == 0 && considering[1].
col() > 0 && considering[2].
col() == 0){
2348 IdColInfo1.push_back(-1);
2351 int loc1 = findcloserepl(considering[0], element[0] + 1,
true,
true, showerquarks, HH_thermal);
2352 if(loc1 == 999999999){
2354 HHparton fakep = considering[0]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2355 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2356 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2357 fakep.
e(fakep.
mass());
2359 Extraparton.
add(fakep);
2360 junction_with_thermal_parton = 1;
2363 else if (loc1 > 0){showerquarks[loc1 - 1].acol(maxtag); }
2364 else if(loc1 < 0){HH_thermal[-loc1 - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2365 IdColInfo2.push_back(-1);
2366 IdColInfo2.push_back(maxtag);
2368 IdColInfo3.push_back(-1);
2369 IdColInfo3.push_back(considering[1].
col());
2372 int loc2 = findcloserepl(considering[2], perm2[q3],
true,
true, showerquarks, HH_thermal);
2373 if(loc2 == 999999999){
2375 HHparton fakep = considering[2]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2376 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2377 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2378 fakep.
e(fakep.
mass());
2380 Extraparton.
add(fakep);
2381 junction_with_thermal_parton = 1;
2384 else if (loc2 > 0){showerquarks[loc2 - 1].acol(maxtag); }
2385 else if(loc2 < 0){HH_thermal[-loc2 - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2387 IdColInfo1.push_back(junction_with_thermal_parton);
2389 IdColInfo4.push_back(-1);
2390 IdColInfo4.push_back(maxtag);
2392 JunctionInfo.push_back(IdColInfo1);
2393 JunctionInfo.push_back(IdColInfo2);
2394 JunctionInfo.push_back(IdColInfo3);
2395 JunctionInfo.push_back(IdColInfo4);
2397 Tempjunctions.push_back(JunctionInfo);
2403 JunctionInfo.clear();
2405 if(considering[0].
col() == 0 && considering[1].
col() == 0 && considering[2].
col() == 0){
2406 IdColInfo1.push_back(-1);
2409 int loc1 = findcloserepl(considering[0], element[0] + 1,
true,
true, showerquarks, HH_thermal);
2410 if(loc1 == 999999999){
2412 HHparton fakep = considering[0]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2413 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2414 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2415 fakep.
e(fakep.
mass());
2417 Extraparton.
add(fakep);
2418 junction_with_thermal_parton = 1;
2421 else if (loc1 > 0){showerquarks[loc1 - 1].acol(maxtag); }
2422 else if(loc1 < 0){HH_thermal[-loc1 - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2423 IdColInfo2.push_back(-1);
2424 IdColInfo2.push_back(maxtag);
2427 int loc2 = findcloserepl(considering[1], perm2[q2],
true,
true, showerquarks, HH_thermal);
2428 if(loc2 == 999999999){
2430 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2431 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2432 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2433 fakep.
e(fakep.
mass());
2435 Extraparton.
add(fakep);
2436 junction_with_thermal_parton = 1;
2439 else if (loc2 > 0){showerquarks[loc2 - 1].acol(maxtag); }
2440 else if(loc2 < 0){HH_thermal[-loc2 - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2441 IdColInfo3.push_back(-1);
2442 IdColInfo3.push_back(maxtag);
2445 int loc3 = findcloserepl(considering[2], perm2[q3],
true,
true, showerquarks, HH_thermal);
2446 if(loc3 == 999999999){
2448 HHparton fakep = considering[2]; fakep.
id(-fakep.
id()); fakep.
acol(maxtag);
2449 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2450 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2451 fakep.
e(fakep.
mass());
2453 Extraparton.
add(fakep);
2454 junction_with_thermal_parton = 1;
2457 else if (loc3 > 0){showerquarks[loc3 - 1].acol(maxtag); }
2458 else if(loc3 < 0){HH_thermal[-loc3 - 1].acol(maxtag); junction_with_thermal_parton = 1;}
2460 IdColInfo1.push_back(junction_with_thermal_parton);
2462 IdColInfo4.push_back(-1);
2463 IdColInfo4.push_back(maxtag);
2466 JunctionInfo.push_back(IdColInfo1);
2467 JunctionInfo.push_back(IdColInfo2);
2468 JunctionInfo.push_back(IdColInfo3);
2469 JunctionInfo.push_back(IdColInfo4);
2470 Tempjunctions.push_back(JunctionInfo);
2475 JunctionInfo.clear();
2478 else if(considering[0].
id() * considering[1].
id() * considering[2].
id() < 0){
2482 if(considering[0].acol() > 0 && considering[1].acol() > 0 && considering[2].acol() > 0){
2483 IdColInfo1.push_back(1);
2484 IdColInfo1.push_back(junction_with_thermal_parton);
2485 IdColInfo2.push_back(1);
2486 IdColInfo2.push_back(considering[0].acol());
2487 IdColInfo3.push_back(1);
2488 IdColInfo3.push_back(considering[1].acol());
2489 IdColInfo4.push_back(1);
2490 IdColInfo4.push_back(considering[2].acol());
2492 JunctionInfo.push_back(IdColInfo1);
2493 JunctionInfo.push_back(IdColInfo2);
2494 JunctionInfo.push_back(IdColInfo3);
2495 JunctionInfo.push_back(IdColInfo4);
2497 Tempjunctions.push_back(JunctionInfo);
2503 JunctionInfo.clear();
2506 int coltag1 = considering[0].acol();
2507 int coltag2 = considering[1].acol();
2508 int coltag3 = considering[2].acol();
2509 if(coltag1 > 0 && coltag2 > 0 && coltag3 > 0 && coltag1 <= limit && coltag2 <= limit && coltag3 <= limit ){
2510 double tag1 = (
double)coltag1;
2511 double tag2 = (
double)coltag2;
2512 double tag3 = (
double)coltag3;
2513 std::vector<int>::iterator I1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), coltag1);
2514 std::vector<int>::iterator I2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), coltag2);
2515 std::vector<int>::iterator I3 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), coltag3);
2520 BaryonrecoMatrix1.at(loc1).at(loc2).at(1) = tag3;
2521 BaryonrecoMatrix1.at(loc2).at(loc1).at(1) = tag3;
2522 BaryonrecoMatrix1.at(loc2).at(loc3).at(1) = tag1;
2523 BaryonrecoMatrix1.at(loc3).at(loc2).at(1) = tag1;
2524 BaryonrecoMatrix1.at(loc1).at(loc3).at(1) = tag2;
2525 BaryonrecoMatrix1.at(loc3).at(loc1).at(1) = tag2;
2528 MesonrecoMatrix1.at(loc1).at(loc2) = 0;
2529 MesonrecoMatrix1.at(loc2).at(loc1) = 0;
2530 MesonrecoMatrix1.at(loc2).at(loc3) = 0;
2531 MesonrecoMatrix1.at(loc3).at(loc2) = 0;
2532 MesonrecoMatrix1.at(loc1).at(loc3) = 0;
2533 MesonrecoMatrix1.at(loc3).at(loc1) = 0;
2536 if(considering[0].acol() > 0 && considering[1].acol() == 0 && considering[2].acol() > 0){
2537 IdColInfo1.push_back(1);
2540 int loc = findcloserepl(considering[1], perm2[q2],
true,
true, showerquarks, HH_thermal);
2541 if(loc == 999999999){
2543 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2544 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2545 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2546 fakep.
e(fakep.
mass());
2548 Extraparton.
add(fakep);
2549 junction_with_thermal_parton = 1;
2552 else if (loc > 0){showerquarks[loc - 1].col(maxtag); }
2553 else if(loc < 0){HH_thermal[-loc - 1].col(maxtag); junction_with_thermal_parton = 1;}
2555 IdColInfo1.push_back(junction_with_thermal_parton);
2557 IdColInfo2.push_back(1);
2558 IdColInfo2.push_back(considering[0].acol());
2559 IdColInfo3.push_back(1);
2560 IdColInfo3.push_back(maxtag);
2561 IdColInfo4.push_back(1);
2562 IdColInfo4.push_back(considering[2].acol());
2564 JunctionInfo.push_back(IdColInfo1);
2565 JunctionInfo.push_back(IdColInfo2);
2566 JunctionInfo.push_back(IdColInfo3);
2567 JunctionInfo.push_back(IdColInfo4);
2569 Tempjunctions.push_back(JunctionInfo);
2575 JunctionInfo.clear();
2577 if(considering[0].acol() == 0 && considering[1].acol() > 0 && considering[2].acol() > 0){
2578 IdColInfo1.push_back(1);
2581 int loc = findcloserepl(considering[0], element[0] + 1,
true,
true, showerquarks, HH_thermal);
2582 if(loc == 999999999){
2584 HHparton fakep = considering[0]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2585 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2586 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2587 fakep.
e(fakep.
mass());
2589 Extraparton.
add(fakep);
2590 junction_with_thermal_parton = 1;
2593 else if (loc > 0){showerquarks[loc - 1].col(maxtag); }
2594 else if(loc < 0){HH_thermal[-loc - 1].col(maxtag); junction_with_thermal_parton = 1;}
2596 IdColInfo1.push_back(junction_with_thermal_parton);
2598 IdColInfo2.push_back(1);
2599 IdColInfo2.push_back(maxtag);
2600 IdColInfo3.push_back(1);
2601 IdColInfo3.push_back(considering[1].acol());
2602 IdColInfo4.push_back(1);
2603 IdColInfo4.push_back(considering[2].acol());
2605 JunctionInfo.push_back(IdColInfo1);
2606 JunctionInfo.push_back(IdColInfo2);
2607 JunctionInfo.push_back(IdColInfo3);
2608 JunctionInfo.push_back(IdColInfo4);
2610 Tempjunctions.push_back(JunctionInfo);
2616 JunctionInfo.clear();
2618 if(considering[0].acol() > 0 && considering[1].acol() > 0 && considering[2].acol() == 0){
2619 IdColInfo1.push_back(1);
2622 int loc = findcloserepl(considering[2], perm2[q3],
true,
true, showerquarks, HH_thermal);
2623 if(loc == 999999999){
2625 HHparton fakep = considering[2]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2626 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2627 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2628 fakep.
e(fakep.
mass());
2630 Extraparton.
add(fakep);
2631 junction_with_thermal_parton = 1;
2634 else if (loc > 0){showerquarks[loc - 1].col(maxtag); }
2635 else if(loc < 0){HH_thermal[-loc - 1].col(maxtag); junction_with_thermal_parton = 1;}
2637 IdColInfo1.push_back(junction_with_thermal_parton);
2639 IdColInfo2.push_back(1);
2640 IdColInfo2.push_back(considering[0].acol());
2641 IdColInfo3.push_back(1);
2642 IdColInfo3.push_back(considering[1].acol());
2643 IdColInfo4.push_back(1);
2644 IdColInfo4.push_back(maxtag);
2646 JunctionInfo.push_back(IdColInfo1);
2647 JunctionInfo.push_back(IdColInfo2);
2648 JunctionInfo.push_back(IdColInfo3);
2649 JunctionInfo.push_back(IdColInfo4);
2651 Tempjunctions.push_back(JunctionInfo);
2657 JunctionInfo.clear();
2659 if(considering[0].acol() > 0 && considering[1].acol() == 0 && considering[2].acol() == 0){
2660 IdColInfo1.push_back(1);
2661 IdColInfo2.push_back(1);
2662 IdColInfo2.push_back(considering[0].acol());
2665 int loc1 = findcloserepl(considering[1], perm2[q2],
true,
true, showerquarks, HH_thermal);
2666 if(loc1 == 999999999){
2668 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2669 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2670 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2671 fakep.
e(fakep.
mass());
2673 Extraparton.
add(fakep);
2674 junction_with_thermal_parton = 1;
2677 else if (loc1 > 0){showerquarks[loc1 - 1].col(maxtag); }
2678 else if(loc1 < 0){HH_thermal[-loc1 - 1].col(maxtag); junction_with_thermal_parton = 1;}
2679 IdColInfo3.push_back(1);
2680 IdColInfo3.push_back(maxtag);
2683 int loc2 = findcloserepl(considering[2], perm2[q3],
true,
true, showerquarks, HH_thermal);
2684 if(loc2 == 999999999){
2686 HHparton fakep = considering[2]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2687 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2688 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2689 fakep.
e(fakep.
mass());
2691 Extraparton.
add(fakep);
2692 junction_with_thermal_parton = 1;
2695 else if (loc2 > 0){showerquarks[loc2 - 1].col(maxtag); }
2696 else if(loc2 < 0){HH_thermal[-loc2 - 1].col(maxtag); junction_with_thermal_parton = 1;}
2698 IdColInfo1.push_back(junction_with_thermal_parton);
2700 IdColInfo4.push_back(1);
2701 IdColInfo4.push_back(maxtag);
2704 JunctionInfo.push_back(IdColInfo1);
2705 JunctionInfo.push_back(IdColInfo2);
2706 JunctionInfo.push_back(IdColInfo3);
2707 JunctionInfo.push_back(IdColInfo4);
2709 Tempjunctions.push_back(JunctionInfo);
2715 JunctionInfo.clear();
2717 if(considering[0].acol() == 0 && considering[1].acol() == 0 && considering[2].acol() > 0){
2718 IdColInfo1.push_back(1);
2721 int loc1 = findcloserepl(considering[0], element[0] + 1,
true,
true, showerquarks, HH_thermal);
2722 if(loc1 == 999999999){
2724 HHparton fakep = considering[0]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2725 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2726 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2727 fakep.
e(fakep.
mass());
2729 Extraparton.
add(fakep);
2730 junction_with_thermal_parton = 1;
2733 else if (loc1 > 0){showerquarks[loc1 - 1].col(maxtag); }
2734 else if(loc1 < 0){HH_thermal[-loc1 - 1].col(maxtag); junction_with_thermal_parton = 1;}
2735 IdColInfo2.push_back(1);
2736 IdColInfo2.push_back(maxtag);
2739 int loc2 = findcloserepl(considering[1], perm2[q2],
true,
true, showerquarks, HH_thermal);
2740 if(loc2 == 999999999){
2742 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2743 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2744 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2745 fakep.
e(fakep.
mass());
2747 Extraparton.
add(fakep);
2748 junction_with_thermal_parton = 1;
2751 else if (loc2 > 0){showerquarks[loc2 - 1].col(maxtag); }
2752 else if(loc2 < 0){HH_thermal[-loc2 - 1].col(maxtag); junction_with_thermal_parton = 1;}
2754 IdColInfo1.push_back(junction_with_thermal_parton);
2756 IdColInfo3.push_back(1);
2757 IdColInfo3.push_back(maxtag);
2759 IdColInfo4.push_back(1);
2760 IdColInfo4.push_back(considering[2].acol());
2762 JunctionInfo.push_back(IdColInfo1);
2763 JunctionInfo.push_back(IdColInfo2);
2764 JunctionInfo.push_back(IdColInfo3);
2765 JunctionInfo.push_back(IdColInfo4);
2767 Tempjunctions.push_back(JunctionInfo);
2773 JunctionInfo.clear();
2775 if(considering[0].acol() == 0 && considering[1].acol() > 0 && considering[2].acol() == 0){
2776 IdColInfo1.push_back(1);
2779 int loc1 = findcloserepl(considering[0], element[0] + 1,
true,
true, showerquarks, HH_thermal);
2780 if(loc1 == 999999999){
2782 HHparton fakep = considering[0]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2783 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2784 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2785 fakep.
e(fakep.
mass());
2787 Extraparton.
add(fakep);
2788 junction_with_thermal_parton = 1;
2791 else if (loc1 > 0){showerquarks[loc1 - 1].col(maxtag); }
2792 else if(loc1 < 0){HH_thermal[-loc1 - 1].col(maxtag); junction_with_thermal_parton = 1;}
2793 IdColInfo2.push_back(1);
2794 IdColInfo2.push_back(maxtag);
2796 IdColInfo3.push_back(1);
2797 IdColInfo3.push_back(considering[1].acol());
2800 int loc2 = findcloserepl(considering[2], perm2[q3],
true,
true, showerquarks, HH_thermal);
2801 if(loc2 == 999999999){
2803 HHparton fakep = considering[2]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2804 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2805 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2806 fakep.
e(fakep.
mass());
2808 Extraparton.
add(fakep);
2809 junction_with_thermal_parton = 1;
2812 else if (loc2 > 0){showerquarks[loc2 - 1].col(maxtag); }
2813 else if(loc2 < 0){HH_thermal[-loc2 - 1].col(maxtag); junction_with_thermal_parton = 1;}
2815 IdColInfo1.push_back(junction_with_thermal_parton);
2817 IdColInfo4.push_back(1);
2818 IdColInfo4.push_back(maxtag);
2820 JunctionInfo.push_back(IdColInfo1);
2821 JunctionInfo.push_back(IdColInfo2);
2822 JunctionInfo.push_back(IdColInfo3);
2823 JunctionInfo.push_back(IdColInfo4);
2825 Tempjunctions.push_back(JunctionInfo);
2831 JunctionInfo.clear();
2833 if(considering[0].acol() == 0 && considering[1].acol() == 0 && considering[2].acol() == 0){
2834 IdColInfo1.push_back(1);
2837 int loc1 = findcloserepl(considering[0], element[0] + 1,
true,
true, showerquarks, HH_thermal);
2838 if(loc1 == 999999999){
2840 HHparton fakep = considering[0]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2841 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2842 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2843 fakep.
e(fakep.
mass());
2845 Extraparton.
add(fakep);
2846 junction_with_thermal_parton = 1;
2849 else if (loc1 > 0){showerquarks[loc1 - 1].col(maxtag); }
2850 else if(loc1 < 0){HH_thermal[-loc1 - 1].col(maxtag); junction_with_thermal_parton = 1;}
2851 IdColInfo2.push_back(1);
2852 IdColInfo2.push_back(maxtag);
2855 int loc2 = findcloserepl(considering[1], perm2[q2],
true,
true, showerquarks, HH_thermal);
2856 if(loc2 == 999999999){
2858 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2859 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2860 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2861 fakep.
e(fakep.
mass());
2863 Extraparton.
add(fakep);
2864 junction_with_thermal_parton = 1;
2867 else if (loc2 > 0){showerquarks[loc2 - 1].col(maxtag); }
2868 else if(loc2 < 0){HH_thermal[-loc2 - 1].col(maxtag); junction_with_thermal_parton = 1;}
2869 IdColInfo3.push_back(1);
2870 IdColInfo3.push_back(maxtag);
2873 int loc3 = findcloserepl(considering[2], perm2[q3],
true,
true, showerquarks, HH_thermal);
2874 if(loc3 == 999999999){
2876 HHparton fakep = considering[2]; fakep.
id(-fakep.
id()); fakep.
col(maxtag);
2877 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
2878 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
2879 fakep.
e(fakep.
mass());
2881 Extraparton.
add(fakep);
2882 junction_with_thermal_parton = 1;
2885 else if (loc3 > 0){showerquarks[loc3 - 1].col(maxtag); }
2886 else if(loc3 < 0){HH_thermal[-loc3 - 1].col(maxtag); junction_with_thermal_parton = 1;}
2888 IdColInfo1.push_back(junction_with_thermal_parton);
2890 IdColInfo4.push_back(1);
2891 IdColInfo4.push_back(maxtag);
2893 JunctionInfo.push_back(IdColInfo1);
2894 JunctionInfo.push_back(IdColInfo2);
2895 JunctionInfo.push_back(IdColInfo3);
2896 JunctionInfo.push_back(IdColInfo4);
2897 Tempjunctions.push_back(JunctionInfo);
2902 JunctionInfo.clear();
2919 formedhadron.
is_recohad(
true); formedhadron.
mass( p_BCM[0].
t() + p_BCM[1].
t() + p_BCM[2].
t() );
2920 formedhadron.
add_par(showerquarks[element[0]].par());
2921 if(perm2[q2]>0){formedhadron.
add_par(showerquarks[element[1]].par());}
else{formedhadron.
add_par(element[1]);}
2922 if(perm2[q3]>0){formedhadron.
add_par(showerquarks[element[2]].par());}
else{formedhadron.
add_par(element[2]);}
2925 if(WigB[0]*recofactor3*mult < rndbaryon){formedhadron.
is_excited(
true);}
2928 if( perm2[q2]>0 && perm2[q3]>0){ formedhadron.
is_shsh(
true);}
2929 else if(perm2[q2]>0 && perm2[q3]<0){ formedhadron.
is_shth(
true);
if(element[2] == 0){formedhadron.
parents[2] = -99999;}}
2930 else if(perm2[q2]<0 && perm2[q3]>0){ formedhadron.
is_shth(
true);
if(element[1] == 0){formedhadron.
parents[1] = -99999;}}
2931 else if(perm2[q2]<0 && perm2[q3]<0){ formedhadron.
is_shth(
true);
if(element[1] == 0){formedhadron.
parents[1] = -99999;}
2932 if(element[2] == 0){formedhadron.
parents[2] = -99999;}
2936 Pbaryon.
Set(Pbaryon.
x(),Pbaryon.
y(),Pbaryon.
z(),sqrt(Pbaryon.
x()*Pbaryon.
x() + Pbaryon.
y()*Pbaryon.
y() + Pbaryon.
z()*Pbaryon.
z() + formedhadron.
mass()*formedhadron.
mass()));
2937 formedhadron.
pos(pos_lab); formedhadron.
P(Pbaryon);
2941 formedhadron.
add_col((considering[0].
col()>0)?considering[0].
col():considering[0].acol());
2942 formedhadron.
add_col((considering[1].
col()>0)?considering[1].
col():considering[1].acol());
2943 formedhadron.
add_col((considering[2].
col()>0)?considering[2].
col():considering[2].acol());
2947 set_baryon_id(considering, formedhadron);
2950 HH_hadrons.add(formedhadron);
2953 showerquarks[element[0]].status(1); showerquarks[element[0]].is_used(
true);
2954 if(perm2[q2]>0){showerquarks[element[1]].status(1); showerquarks[element[1]].is_used(
true);}
2955 else{ HH_thermal[-element[1]].status(1); HH_thermal[-element[1]].is_used(
true);}
2956 if(perm2[q3]>0){showerquarks[element[2]].status(1); showerquarks[element[2]].is_used(
true);}
2957 else{ HH_thermal[-element[2]].status(1); HH_thermal[-element[2]].is_used(
true);}
2959 madehadron =
true; considering.
clear();
2964 if(perm2[q3]>0){showerquarks[element[2]].status(0);}
2965 else{ HH_thermal[-element[2]].status(0);}
2968 considering.
partons.pop_back();
2971 }
else if(considering[0].
id()*considering[1].
id() < 0){
2973 if(considering[0].
id() > 0 && considering[1].
id() < 0){
2974 int tag0 = considering[0].col();
2975 int tag1 = considering[1].acol();
2976 if(tag0 > 0 && tag1 > 0 && tag0 <= limit && tag1 <= limit ){
2977 std::vector<int>::iterator L1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), tag0);
2978 std::vector<int>::iterator L2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), tag1);
2979 int indexMatrix1 =
std::distance(IndiceForColFin.begin(), L1);
2980 int indexMatrix2 =
std::distance(IndiceForColFin.begin(), L2);
2982 recofactor2 = (MesonrecoMatrix1.at(indexMatrix1).at(indexMatrix2));
2985 else{recofactor2 = 1./9.;}
2987 else if(considering[1].
id() > 0 && considering[0].id() < 0){
2988 int tag0 = considering[1].col();
2989 int tag1 = considering[0].acol();
2990 if(tag0 > 0 && tag1 > 0 && tag0 <= limit && tag1 <= limit){
2991 std::vector<int>::iterator L1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), tag0);
2992 std::vector<int>::iterator L2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), tag1);
2993 int indexMatrix1 =
std::distance(IndiceForColFin.begin(), L1);
2994 int indexMatrix2 =
std::distance(IndiceForColFin.begin(), L2);
2996 recofactor2 = (MesonrecoMatrix1.at(indexMatrix1).at(indexMatrix2));
2998 else{recofactor2 = 1./9.;}
3004 Pmeson.
Set(considering[0].px()+considering[1].px(),considering[0].py()+considering[1].py(),considering[0].pz()+considering[1].pz(),0.);
3008 betaM.
Set(Pmeson.
x()/(considering[0].e()+considering[1].e()),Pmeson.
y()/(considering[0].e()+considering[1].e()),Pmeson.
z()/(considering[0].e()+considering[1].e()),0.);
3009 betaM.
Set(betaM.
x(),betaM.
y(),betaM.
z(),1./(sqrt(1.-(betaM.
x()*betaM.
x() + betaM.
y()*betaM.
y() + betaM.
z()*betaM.
z()))));
3013 pos_MCM[0] = considering[0].boost_pos(betaM); pos_MCM[1] = considering[1].boost_pos(betaM);
3014 p_MCM[0] = considering[0].boost_P(betaM); p_MCM[1] = considering[1].boost_P(betaM);
3018 v_MCM[0].
Set(p_MCM[0].
x()/p_MCM[0].
t(),p_MCM[0].
y()/p_MCM[0].
t(),p_MCM[0].
z()/p_MCM[0].
t(),0.);
3019 v_MCM[1].
Set(p_MCM[1].
x()/p_MCM[1].
t(),p_MCM[1].
y()/p_MCM[1].
t(),p_MCM[1].
z()/p_MCM[1].
t(),0.);
3023 double curtime = (pos_MCM[0].
t() > pos_MCM[1].
t()) ? pos_MCM[0].
t() : pos_MCM[1].
t();
3025 cur_pos[0].
Set(pos_MCM[0].
x()+v_MCM[0].
x()*(curtime-pos_MCM[0].
t()),pos_MCM[0].
y()+v_MCM[0].
y()*(curtime-pos_MCM[0].
t()),pos_MCM[0].
z()+v_MCM[0].
z()*(curtime-pos_MCM[0].
t()),curtime);
3026 cur_pos[1].
Set(pos_MCM[1].
x()+v_MCM[1].
x()*(curtime-pos_MCM[1].
t()),pos_MCM[1].
y()+v_MCM[1].
y()*(curtime-pos_MCM[1].
t()),pos_MCM[1].
z()+v_MCM[1].
z()*(curtime-pos_MCM[1].
t()),curtime);
3031 (cur_pos[0].
x()*considering[0].
mass()+cur_pos[1].
x()*considering[1].
mass())/(considering[0].
mass()+considering[1].
mass()),
3032 (cur_pos[0].
y()*considering[0].
mass()+cur_pos[1].
y()*considering[1].
mass())/(considering[0].
mass()+considering[1].
mass()),
3033 (cur_pos[0].
z()*considering[0].
mass()+cur_pos[1].
z()*considering[1].
mass())/(considering[0].
mass()+considering[1].
mass()),
3037 betaM.
Set(-betaM.
x(),-betaM.
y(),-betaM.
z(),betaM.
t());
3042 double sum_mass_square = (considering[0].mass()+considering[1].mass())*(considering[0].
mass()+considering[1].mass());
3043 k_rel_square.
Set(std::pow(considering[1].
mass()*p_MCM[0].
x()-considering[0].
mass()*p_MCM[1].
x(),2.)/sum_mass_square,std::pow(considering[1].
mass()*p_MCM[0].
y()-considering[0].
mass()*p_MCM[1].
y(),2.)/sum_mass_square,std::pow(considering[1].
mass()*p_MCM[0].
z()-considering[0].
mass()*p_MCM[1].
z(),2.)/sum_mass_square,0.);
3044 k_rel_square.
Set(k_rel_square.
x(),k_rel_square.
y(),k_rel_square.
z(),k_rel_square.
x()+k_rel_square.
y()+k_rel_square.
z());
3048 pos_rel_square.
Set((cur_pos[0].
x()-cur_pos[1].
x())*(cur_pos[0].
x()-cur_pos[1].
x()),(cur_pos[0].
y()-cur_pos[1].
y())*(cur_pos[0].
y()-cur_pos[1].
y()),(cur_pos[0].
z()-cur_pos[1].
z())*(cur_pos[0].
z()-cur_pos[1].
z()),0.);
3049 pos_rel_square.
Set(pos_rel_square.
x(),pos_rel_square.
y(),pos_rel_square.
z(),pos_rel_square.
x()+pos_rel_square.
y()+pos_rel_square.
z());
3052 double SigM2 = SigPi2;
3053 int sortid[2] = {0,0};
3054 if(std::abs(considering[0].
id()) >= std::abs(considering[1].
id())){sortid[0] = std::abs(considering[0].
id()); sortid[1] = std::abs(considering[1].
id());}
3055 else{sortid[0] = std::abs(considering[1].
id()); sortid[1] = std::abs(considering[0].
id());}
3057 if( sortid[0] == 3){
3058 if( sortid[1] == 3){SigM2 = SigPhi2;}
3059 else{ SigM2 = SigK2;}
3061 else if(sortid[0] == 4){
3062 if( sortid[1] == 4){SigM2 = SigJpi2;}
3063 else if(sortid[1] == 3){SigM2 = SigDs2;}
3064 else{ SigM2 = SigD2;}
3066 else if(sortid[0] == 5){
3067 if( sortid[1] == 5){SigM2 = SigUps2;}
3068 else if(sortid[1] == 4){SigM2 = SigBc2;}
3069 else if(sortid[1] == 3){SigM2 = SigB2;}
3070 else{ SigM2 = SigB2;}
3075 u[1] = 0.5*(pos_rel_square.
x()/SigM2 + k_rel_square.
x()*SigM2/hbarc2);
3076 u[2] = 0.5*(pos_rel_square.
y()/SigM2 + k_rel_square.
y()*SigM2/hbarc2);
3077 u[3] = 0.5*(pos_rel_square.
z()/SigM2 + k_rel_square.
z()*SigM2/hbarc2);
3078 u[0] = u[1] + u[2] + u[3];
3081 double WigM = std::exp(-u[0]);
3084 double rdotr = pos_rel_square.
t();
3085 double pdotp = k_rel_square.
t();
3086 double pdotr = std::sqrt(pos_rel_square.
x())*std::sqrt(k_rel_square.
x()) + std::sqrt(pos_rel_square.
y())*std::sqrt(k_rel_square.
y()) + std::sqrt(pos_rel_square.
z())*std::sqrt(k_rel_square.
z());
3088 double s = 1/hbarc2*(pdotp*rdotr - pdotr*pdotr);
3091 double rndmeson =
ran();
3094 int angular_qnum = -1;
3095 int radial_qnum = -1;
3096 double mult1 = considering[1].is_thermal() ? th_recofactor : sh_recofactor;
3097 double total_prob = WigM*recofactor2*mult1;
3099 if(total_prob >= rndmeson)
3106 total_prob += WigM*u[0];
3107 if(total_prob >= rndmeson && maxM_level>0)
3114 total_prob += (1./2.)*WigM*((2./3.)*std::pow(u[0],2) + (1./3.)*
s);
3115 if(total_prob >= rndmeson && maxM_level>1)
3122 total_prob += (1./2.)*WigM*((1./3.)*std::pow(u[0],2) - (1./3.)*
s);
3123 if(total_prob >= rndmeson && maxM_level>1 )
3130 total_prob += (1./6.)*WigM*((2./5.)*std::pow(u[0],3) + (3./5.)*u[0]*
s);
3131 if(total_prob >= rndmeson && maxM_level>2)
3138 total_prob += (1./6.)*WigM*((3./5.)*std::pow(u[0],3) - (3./5.)*u[0]*
s);
3139 if(total_prob >= rndmeson && maxM_level>2)
3146 total_prob += (1./120.)*WigM*std::pow((std::pow(u[0],2)-s),2);
3147 if(total_prob >= rndmeson && maxM_level>3)
3154 total_prob += (1./24.)*WigM*((4./7.)*std::pow(u[0],4)-(2./7.)*std::pow(u[0],2)*s-(2./7.)*std::pow(s,2));
3155 if(total_prob >= rndmeson && maxM_level>3)
3162 total_prob += (1./24.)*WigM*((8./35.)*std::pow(u[0],4)+(24./35.)*std::pow(u[0],2)*s+(3./35.)*std::pow(s,2));
3163 if(total_prob >= rndmeson && maxM_level>3)
3178 if(angular_qnum >= 0) {
3182 if(considering[0].
id() > 0 && considering[1].id() < 0){
3189 if(considering[0].
col() != 0 && considering[1].acol() != 0){
3190 for(
int ijunc=0; ijunc<Tempjunctions.size(); ijunc++){
3191 if(Tempjunctions.at(ijunc).at(1).at(1) == considering[1].acol()){
3192 Tempjunctions.at(ijunc).at(1).pop_back();
3193 Tempjunctions.at(ijunc).at(1).push_back(considering[0].
col());
3195 if(Tempjunctions.at(ijunc).at(2).at(1) == considering[1].acol()){
3196 Tempjunctions.at(ijunc).at(2).pop_back();
3197 Tempjunctions.at(ijunc).at(2).push_back(considering[0].
col());
3199 if(Tempjunctions.at(ijunc).at(3).at(1) == considering[1].acol()){
3200 Tempjunctions.at(ijunc).at(3).pop_back();
3201 Tempjunctions.at(ijunc).at(3).push_back(considering[0].
col());
3207 int coltag1 = considering[0].col();
3208 int coltag2 = considering[1].acol();
3209 if(coltag1 > 0 && coltag2 > 0 && coltag1 <= limit && coltag2 <= limit){
3210 std::vector<int>::iterator I1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), coltag1);
3211 std::vector<int>::iterator I2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), coltag2);
3216 MesonrecoMatrix1.at(loc1).at(loc2) = 1;
3217 MesonrecoMatrix1.at(loc2).at(loc1) = 1;
3219 for(
int iM=0;iM<MesonrecoMatrix1[0].size();++iM){
3220 if(MesonrecoMatrix1[loc1][iM]==1){MesonrecoMatrix1[loc2][iM]=1;}
3221 if(MesonrecoMatrix1[loc2][iM]==1){MesonrecoMatrix1[loc1][iM]=1;}
3222 if(MesonrecoMatrix1[iM][loc1]==1){MesonrecoMatrix1[iM][loc2]=1;}
3223 if(MesonrecoMatrix1[iM][loc2]==1){MesonrecoMatrix1[iM][loc1]=1;}
3224 if(MesonrecoMatrix1[loc1][iM]==0){MesonrecoMatrix1[loc2][iM]=0;}
3225 if(MesonrecoMatrix1[loc2][iM]==0){MesonrecoMatrix1[loc1][iM]=0;}
3226 if(MesonrecoMatrix1[iM][loc1]==0){MesonrecoMatrix1[iM][loc2]=0;}
3227 if(MesonrecoMatrix1[iM][loc2]==0){MesonrecoMatrix1[iM][loc1]=0;}
3242 if(considering[0].
col() > 0 && considering[1].acol() > 0){
3244 HH_showerptns[showerquarks[element[1]].par()].acol(considering[0].
col());
3246 for(
int ishq=0;ishq<showerquarks.
num();++ishq){
3247 if(!showerquarks[ishq].is_used() && showerquarks[ishq].col()==considering[1].acol()){
3248 showerquarks[ishq].col(considering[0].
col());
3251 for(
int ishq=0;ishq<HH_showerptns.num();++ishq){
3252 if(HH_showerptns[ishq].
col()==considering[1].acol()){
3253 HH_showerptns[ishq].col(considering[0].
col());
3257 HH_thermal[-element[1]].acol(considering[0].
col());
3259 }
else if(considering[0].
col() > 0){
3260 int loc = findcloserepl(considering[1] , perm2[q2],
true,
true, showerquarks, HH_thermal);
3261 if(loc == 999999999){
3263 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
col(considering[0].
col());
3264 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
3265 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
3266 fakep.
e(fakep.
mass());
3268 Extraparton.
add(fakep);
3271 HH_thermal[-loc-1].col(considering[0].
col());
3273 showerquarks[loc-1].col(considering[0].
col());
3275 }
else if(considering[1].acol() > 0){
3276 int loc = findcloserepl(considering[0] , perm1[q1]+1,
true,
true, showerquarks, HH_thermal);
3277 if(loc == 999999999){
3279 HHparton fakep = considering[0]; fakep.
id(-fakep.
id()); fakep.
acol(considering[1].acol());
3280 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
3281 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
3282 fakep.
e(fakep.
mass());
3284 Extraparton.
add(fakep);
3287 HH_thermal[-loc-1].acol(considering[1].acol());
3289 showerquarks[loc-1].acol(considering[1].acol());
3292 }
else if(considering[0].
id() < 0 && considering[1].
id() > 0){
3299 if(considering[0].acol() != 0 && considering[1].
col() != 0){
3300 for(
int ijunc=0; ijunc<Tempjunctions.size(); ijunc++){
3301 if(Tempjunctions.at(ijunc).at(1).at(1) == considering[1].col()){
3302 Tempjunctions.at(ijunc).at(1).pop_back();
3303 Tempjunctions.at(ijunc).at(1).push_back(considering[0].acol());
3305 if(Tempjunctions.at(ijunc).at(2).at(1) == considering[1].col()){
3306 Tempjunctions.at(ijunc).at(2).pop_back();
3307 Tempjunctions.at(ijunc).at(2).push_back(considering[0].acol());
3309 if(Tempjunctions.at(ijunc).at(3).at(1) == considering[1].col()){
3310 Tempjunctions.at(ijunc).at(3).pop_back();
3311 Tempjunctions.at(ijunc).at(3).push_back(considering[0].acol());
3317 int coltag1 = considering[0].acol();
3318 int coltag2 = considering[1].col();
3319 if(coltag1 > 0 && coltag2 > 0 && coltag1 <= limit && coltag2 <= limit){
3320 std::vector<int>::iterator I1 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), coltag1);
3321 std::vector<int>::iterator I2 = std::find(IndiceForColFin.begin(), IndiceForColFin.end(), coltag2);
3325 MesonrecoMatrix1.at(loc1).at(loc2) = 1;
3326 MesonrecoMatrix1.at(loc2).at(loc1) = 1;
3328 for(
int iM=0;iM<MesonrecoMatrix1[0].size();++iM){
3329 if(MesonrecoMatrix1[loc1][iM]==1){MesonrecoMatrix1[loc2][iM]=1;}
3330 if(MesonrecoMatrix1[loc2][iM]==1){MesonrecoMatrix1[loc1][iM]=1;}
3331 if(MesonrecoMatrix1[iM][loc1]==1){MesonrecoMatrix1[iM][loc2]=1;}
3332 if(MesonrecoMatrix1[iM][loc2]==1){MesonrecoMatrix1[iM][loc1]=1;}
3333 if(MesonrecoMatrix1[loc1][iM]==0){MesonrecoMatrix1[loc2][iM]=0;}
3334 if(MesonrecoMatrix1[loc2][iM]==0){MesonrecoMatrix1[loc1][iM]=0;}
3335 if(MesonrecoMatrix1[iM][loc1]==0){MesonrecoMatrix1[iM][loc2]=0;}
3336 if(MesonrecoMatrix1[iM][loc2]==0){MesonrecoMatrix1[iM][loc1]=0;}
3347 if(considering[0].acol() > 0 && considering[1].col() > 0){
3349 HH_showerptns[showerquarks[element[1]].par()].col(considering[0].acol());
3351 for(
int ishq=0;ishq<showerquarks.
num();++ishq){
3352 if(!showerquarks[ishq].is_used() && showerquarks[ishq].acol()==considering[1].col()){
3353 showerquarks[ishq].acol(considering[0].acol());
3356 for(
int ishq=0;ishq<HH_showerptns.num();++ishq){
3357 if(HH_showerptns[ishq].acol()==considering[1].col()){
3358 HH_showerptns[ishq].acol(considering[0].acol());
3362 HH_thermal[-element[1]].col(considering[0].acol());
3364 }
else if(considering[0].acol() > 0){
3365 int loc = findcloserepl(considering[1], perm2[q2],
true,
true, showerquarks, HH_thermal );
3366 if(loc == 999999999){
3368 HHparton fakep = considering[1]; fakep.
id(-fakep.
id()); fakep.
acol(considering[0].acol());
3369 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
3370 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
3371 fakep.
e(fakep.
mass());
3373 Extraparton.
add(fakep);
3376 showerquarks[loc-1].acol(considering[0].acol());
3378 HH_thermal[-loc-1].acol(considering[0].acol());
3381 else if(considering[1].
col() > 0){
3382 int loc = findcloserepl(considering[0], perm1[q1]+1,
true,
true, showerquarks, HH_thermal );
3383 if(loc == 999999999){
3385 HHparton fakep = considering[0]; fakep.
id(-fakep.
id()); fakep.
col(considering[1].
col());
3386 fakep.
mass(pythia.particleData.m0(std::abs(fakep.
id())));
3387 fakep.
px(0.); fakep.
py(0.); fakep.
pz(0.);
3388 fakep.
e(fakep.
mass());
3390 Extraparton.
add(fakep);
3393 showerquarks[loc-1].col(considering[1].
col());
3395 HH_thermal[-loc-1].col(considering[1].
col());
3404 formedhadron.
is_recohad(
true); formedhadron.
mass( p_MCM[0].
t() + p_MCM[1].
t() );
3406 formedhadron.
add_par(showerquarks[element[0]].par());
3407 if(perm2[q2]>0){formedhadron.
add_par(showerquarks[element[1]].par());}
else{formedhadron.
add_par(element[1]);}
3410 if(angular_qnum + radial_qnum > 0){formedhadron.
is_excited(
true);}
3413 if( perm2[q2]>0){ formedhadron.
is_shsh(
true);}
3414 else if(perm2[q2]<0){ formedhadron.
is_shth(
true);
if(element[1] == 0){formedhadron.
parents[1] = -99999;}}
3417 Pmeson.
Set(Pmeson.
x(),Pmeson.
y(),Pmeson.
z(),sqrt(Pmeson.
x()*Pmeson.
x() + Pmeson.
y()*Pmeson.
y() + Pmeson.
z()*Pmeson.
z() + formedhadron.
mass()*formedhadron.
mass()));
3418 formedhadron.
pos(pos_lab); formedhadron.
P(Pmeson);
3422 if(considering[0].
id()>0){formedhadron.
add_col(considering[0].
col()); formedhadron.
add_col(considering[1].acol());}
3423 else{formedhadron.
add_col(considering[1].
col()); formedhadron.
add_col(considering[0].acol());}
3426 set_meson_id(considering, formedhadron, angular_qnum, radial_qnum);
3429 HH_hadrons.add(formedhadron);
3432 showerquarks[element[0]].status(1); showerquarks[element[0]].is_used(
true);
3433 if(perm2[q2]>0){showerquarks[element[1]].status(1); showerquarks[element[1]].is_used(
true);}
3434 else{ HH_thermal[-element[1]].status(1); HH_thermal[-element[1]].is_used(
true);}
3437 madehadron =
true; considering.
clear();
3443 if(madehadron){
break;}
3446 if(perm2[q2]>0){showerquarks[element[1]].status(0);}
3447 else{ HH_thermal[-element[1]].status(0);}
3450 considering.
partons.pop_back();
3453 if(madehadron){
continue;}
3458 showerquarks[element[0]].status(0); considering.
partons.pop_back();
3475 for(
int i=0;
i<showerquarks.
num(); ++
i){
3477 if((std::abs(HH_showerptns[showerquarks[
i].par()].
id()) <= 5) && (showerquarks[
i].is_used())){
3478 HH_showerptns[showerquarks[
i].par()].is_used(
true);
3479 HH_showerptns[showerquarks[
i].par()].status(1);
3480 HH_showerptns[showerquarks[
i].par()].used_reco(
true);
3483 else if(std::abs(HH_showerptns[showerquarks[
i].par()].
id()) == 21 && showerquarks[
i].is_used()){
3485 if(HH_showerptns[showerquarks[
i].par()].
status() == -99){
3486 HH_showerptns[showerquarks[
i].par()].status(-1);
3487 HH_showerptns[showerquarks[
i].par()].is_used(
true);
3488 HH_showerptns[showerquarks[
i].par()].used_reco(
true);
3491 else if(HH_showerptns[showerquarks[
i].par()].
status() == -1){
3492 HH_showerptns[showerquarks[
i].par()].status(1);
3495 else{
JSWARN <<
"SOMETHING HAS GONE VERY WRONG WITH REFORMING GLUON IN POS: " << showerquarks[
i].par();
int val; showerquarks[
i].par(0);}
3499 for(
int i=0;
i<HH_showerptns.num(); ++
i){
3500 if(HH_showerptns[
i].
status() == -99){
3501 HH_showerptns[
i].is_decayedglu(
false);
3502 HH_showerptns[
i].status(0);
3507 for(
int i=0;
i<HH_showerptns.num(); ++
i){
3508 if(!HH_showerptns[
i].is_used()){
3509 for(
int j=0;
j<showerquarks.
num(); ++
j){
3510 if(showerquarks[
j].par() ==
i && !showerquarks[
j].is_used()){
3511 HH_showerptns[
i].string_id( showerquarks[
j].string_id());
3512 HH_showerptns[
i].is_strendpt( showerquarks[
j].is_strendpt());
3513 HH_showerptns[
i].pos_str( showerquarks[
j].pos_str());
3514 HH_showerptns[
i].endpt_id( showerquarks[
j].endpt_id());
3526 for(
int i = 0;
i < HH_showerptns.num();
i++){
3527 if(HH_showerptns[
i].is_used()){
continue;}
3528 if(HH_showerptns[
i].
id() == 21 && HH_showerptns[
i].col() == 0 && HH_showerptns[
i].acol() == 0){
3529 int sel_out[2] = { 0 , 0 };
3530 findcloserepl_glu(HH_showerptns[
i], i+1,
true,
true, HH_showerptns, HH_thermal, sel_out);
3531 if(sel_out[0] == 999999999 || sel_out[1] == 999999999){
3532 HHparton fakeg = HH_showerptns[
i]; fakeg.
id(21); fakeg.
acol(++maxtag); fakeg.
col(++maxtag);
3534 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
3535 fakeg.
px(fake_pT * cos(fake_phi)); fakeg.
py(fake_pT * sin(fake_phi));
3537 fakeg.
e(std::sqrt(fakeg.
px()*fakeg.
px() + fakeg.
py()*fakeg.
py() + fakeg.
pz()*fakeg.
pz() + fakeg.
mass()*fakeg.
mass()));
3540 Extraparton.
add(fakeg); HH_showerptns[
i].col(fakeg.
acol()); HH_showerptns[
i].acol(fakeg.
col());
3541 }
else if(sel_out[0] > 0){
3542 HH_showerptns[sel_out[0]-1].col(++maxtag);
3543 HH_showerptns[
i].acol(maxtag);
3544 }
else if(sel_out[0] < 0){
3545 HH_thermal[-sel_out[0]-1].col(++maxtag);
3546 HH_showerptns[
i].acol(maxtag);
3549 if(sel_out[1] > 0 && sel_out[1] != 999999999 && sel_out[0] != 999999999){
3550 HH_showerptns[sel_out[1]-1].acol(++maxtag);
3551 HH_showerptns[
i].col(maxtag);
3552 }
else if(sel_out[1] < 0 && sel_out[1] != 999999999 && sel_out[0] != 999999999){
3553 HH_thermal[-sel_out[1]-1].acol(++maxtag);
3554 HH_showerptns[
i].col(maxtag);
3556 }
else if(HH_showerptns[
i].
id() == 21 && (HH_showerptns[
i].
col() == 0 || HH_showerptns[
i].acol() == 0)){
3557 if(HH_showerptns[
i].
col() == 0){
3558 HH_showerptns[
i].id(1);
3559 int loc = findcloserepl(HH_showerptns[
i], i+1,
true,
true, HH_showerptns, HH_thermal );
3560 HH_showerptns[
i].id(21);
3561 if(loc == 999999999){
3562 double fid = (
ran() > 0.5) ? -1 : -2;
3563 HHparton fakep = HH_showerptns[
i]; fakep.
id(fid); fakep.
acol(++maxtag);
3564 double dir = (
ran() < 0.5) ? 1. : -1.;
double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
3565 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
3566 if (number_p_fake == 0 || number_p_fake == 2){
3568 }
else if (number_p_fake == 1 || number_p_fake == 3) {
3570 }
else {fakep.
pz(0.);}
3572 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
3575 Extraparton.
add(fakep);
3577 else if (loc > 0){HH_showerptns[loc - 1].acol(++maxtag); }
3578 else if(loc < 0){HH_thermal[-loc - 1].acol(++maxtag); }
3580 HH_showerptns[
i].col(maxtag);
3581 }
else if(HH_showerptns[
i].acol() == 0){
3582 HH_showerptns[
i].id(-1);
3583 int loc = findcloserepl(HH_showerptns[
i], i+1,
true,
true, HH_showerptns, HH_thermal );
3584 HH_showerptns[
i].id(21);
3585 if(loc == 999999999){
3586 double fid = (
ran() > 0.5) ? 1 : 2;
3587 HHparton fakep = HH_showerptns[
i]; fakep.
id(fid); fakep.
col(++maxtag);
3588 double dir = (
ran() < 0.5) ? 1. : -1.;
double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
3589 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
3590 if (number_p_fake == 0 || number_p_fake == 2){
3592 }
else if (number_p_fake == 1 || number_p_fake == 3) {
3594 }
else {fakep.
pz(0.);}
3596 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
3599 Extraparton.
add(fakep);
3601 else if (loc > 0){HH_showerptns[loc - 1].col(++maxtag); }
3602 else if(loc < 0){HH_thermal[-loc - 1].col(++maxtag); }
3604 HH_showerptns[
i].acol(maxtag);
3606 }
else if(HH_showerptns[
i].
id() > 0 && HH_showerptns[
i].
col() == 0){
3607 int loc = findcloserepl(HH_showerptns[
i], i+1,
true,
true, HH_showerptns, HH_thermal );
3608 if(loc == 999999999){
3609 double fid = (
ran() > 0.5) ? -1 : -2;
3610 HHparton fakep = HH_showerptns[
i]; fakep.
id(fid); fakep.
acol(++maxtag);
3611 double dir = (
ran() < 0.5) ? 1. : -1.;
double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
3612 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
3613 if (number_p_fake == 0 || number_p_fake == 2){
3615 }
else if (number_p_fake == 1 || number_p_fake == 3) {
3617 }
else {fakep.
pz(0.);}
3619 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
3622 Extraparton.
add(fakep);
3624 else if (loc > 0){HH_showerptns[loc - 1].acol(++maxtag); }
3625 else if(loc < 0){HH_thermal[-loc - 1].acol(++maxtag); }
3627 HH_showerptns[
i].col(maxtag);
3628 }
else if(HH_showerptns[
i].
id() < 0 && HH_showerptns[
i].acol() == 0){
3629 int loc = findcloserepl(HH_showerptns[
i], i+1,
true,
true, HH_showerptns, HH_thermal );
3630 if(loc == 999999999){
3631 double fid = (
ran() > 0.5) ? 1 : 2;
3632 HHparton fakep = HH_showerptns[
i]; fakep.
id(fid); fakep.
col(++maxtag);
3633 double dir = (
ran() < 0.5) ? 1. : -1.;
double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
3634 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
3635 if (number_p_fake == 0 || number_p_fake == 2){
3637 }
else if (number_p_fake == 1 || number_p_fake == 3) {
3639 }
else {fakep.
pz(0.);}
3641 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
3644 Extraparton.
add(fakep);
3646 else if (loc > 0){HH_showerptns[loc - 1].col(++maxtag); }
3647 else if(loc < 0){HH_thermal[-loc - 1].col(++maxtag); }
3649 HH_showerptns[
i].acol(maxtag);
3653 for(
int i=0;
i < HH_showerptns.num(); ++
i){
3655 if(HH_showerptns[
i].
status() == 0){
3656 HH_remnants.add(HH_showerptns[
i]);
3657 HH_remnants[HH_remnants.num() - 1].par(i);
3658 HH_showerptns[
i].is_remnant(
true);
3661 else if(HH_showerptns[
i].
status() == -1){
3663 for(
int j=0;
j<showerquarks.
num(); ++
j){
if(showerquarks[
j].par() ==
i && !showerquarks[
j].is_used()){
3664 if(showerquarks[
j].
col() == 0 && showerquarks[
j].id() > 0){
3665 int loc = findcloserepl(showerquarks[
j], j+1,
true,
true, HH_showerptns, HH_thermal );
3666 if(loc == 999999999){
3667 double fid = (
ran() > 0.5) ? -1 : -2;
3668 HHparton fakep = showerquarks[
j]; fakep.
id(fid); fakep.
acol(++maxtag);
3669 double dir = (
ran() < 0.5) ? 1. : -1.;
double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
3670 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
3671 if (number_p_fake == 0 || number_p_fake == 2){
3673 }
else if (number_p_fake == 1 || number_p_fake == 3) {
3675 }
else {fakep.
pz(0.);}
3677 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
3680 Extraparton.
add(fakep);
3682 else if (loc > 0){HH_showerptns[loc - 1].acol(++maxtag); }
3683 else if(loc < 0){HH_thermal[-loc - 1].acol(++maxtag); }
3685 showerquarks[
j].col(maxtag);
3686 }
else if(showerquarks[
j].acol() == 0 && showerquarks[
j].
id() < 0){
3687 int loc = findcloserepl(showerquarks[
j], j+1,
true,
true, HH_showerptns, HH_thermal );
3688 if(loc == 999999999){
3689 double fid = (
ran() > 0.5) ? 1 : 2;
3690 HHparton fakep = showerquarks[
j]; fakep.
id(fid); fakep.
col(++maxtag);
3691 double dir = (
ran() < 0.5) ? 1. : -1.;
double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
3692 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
3693 if (number_p_fake == 0 || number_p_fake == 2){
3695 }
else if (number_p_fake == 1 || number_p_fake == 3) {
3697 }
else {fakep.
pz(0.);}
3699 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
3702 Extraparton.
add(fakep);
3704 else if (loc > 0){HH_showerptns[loc - 1].col(++maxtag); }
3705 else if(loc < 0){HH_thermal[-loc - 1].col(++maxtag); }
3707 showerquarks[
j].acol(maxtag);
3710 HH_remnants.
add(showerquarks[
j]);
break;
3712 HH_showerptns[
i].is_remnant(
true);
3717 for(
int i=0;
i < HH_thermal.num(); ++
i){
3719 if(HH_thermal[
i].is_used()){
3720 HH_thermal[
i].status(1);
3721 HH_thermal[
i].used_reco(
true);
3724 if(HH_thermal[
i].
col() > 0 || HH_thermal[
i].acol() > 0){
3726 HH_remnants.add(HH_thermal[
i]);
3727 HH_remnants[HH_remnants.num() - 1].par(-i-1);
3728 HH_thermal[
i].is_remnant(
true);
3729 HH_thermal[
i].is_used(
true);
3733 for(
int i = 0;
i < Extraparton.
num(); ++
i ){
3734 HH_remnants.add(Extraparton[
i]);
3735 Extraparton[
i].is_used(
true);
3737 if(Extraparton[i].
id() == 21){
3739 fakep1.
id(1); fakep1.
acol(0);
3740 fakep1.
px(fakep1.
px()/2.); fakep1.
py(fakep1.
py()/2.); fakep1.
pz(fakep1.
pz()/2.); fakep1.
mass(xmq);
3741 fakep1.
e(std::sqrt(fakep1.
px()*fakep1.
px()+fakep1.
py()*fakep1.
py()+fakep1.
pz()*fakep1.
pz()+fakep1.
mass()*fakep1.
mass()));
3744 fakep2.
id(-1); fakep2.
col(0);
3745 fakep2.
px(fakep2.
px()/2.); fakep2.
py(fakep2.
py()/2.); fakep2.
pz(fakep2.
pz()/2.); fakep2.
mass(xmq);
3746 fakep2.
e(std::sqrt(fakep2.
px()*fakep2.
px()+fakep2.
py()*fakep2.
py()+fakep2.
pz()*fakep2.
pz()+fakep2.
mass()*fakep2.
mass()));
3748 HH_recomb_extrapartons.add(fakep1);
3749 HH_recomb_extrapartons.add(fakep2);
3751 HH_recomb_extrapartons.add(Extraparton[i]);
3767 int id[3] = {qrks[0].id(), qrks[1].id(), qrks[2].id()};
3768 std::sort(
id,
id + 3, [](
int a,
int b) {
return std::abs(a) > std::abs(b); });
3794 if(
id[0]==
id[1] &&
id[0]==
id[2]){had.
id( 1000*std::abs(
id[0]) + 100*std::abs(
id[1]) + 10*std::abs(
id[2])+4 );}
3795 else if(
id[0]==
id[1] ||
id[0]==
id[2] ||
id[1]==
id[2]){
3796 if(
ran()>0.333){had.
id( 1000*std::abs(
id[0]) + 100*std::abs(
id[1]) + 10*std::abs(
id[2])+4 );}
3797 else{ had.
id( 1000*std::abs(
id[0]) + 100*std::abs(
id[1]) + 10*std::abs(
id[2])+2 );}
3801 if( prb>0.333){had.
id( 1000*std::abs(
id[0]) + 100*std::abs(
id[1]) + 10*std::abs(
id[2])+4 );}
3802 else if(prb>0.166){had.
id( 1000*std::abs(
id[0]) + 100*std::abs(
id[1]) + 10*std::abs(
id[2])+2 );}
3803 else{ had.
id( 1000*std::abs(
id[0]) + 10*std::abs(
id[1]) + 100*std::abs(
id[2])+2 );}
3814 had.
id(had.
id() * (
id[0] < 0 ? -1 : 1));
3822 int id[2] = {qrks[0].id(), qrks[1].id()};
3823 if(std::abs(qrks[1].
id()) > std::abs(qrks[0].
id())){
3840 int spin_qnum = (
ran() > 0.25) ? 1 : 0;
3843 int j_qnum = spin_qnum;
3844 if(l > 0 && spin_qnum == 1){
3845 double random =
ran();
3847 if((2.*l-1.)/(3.*(2.*l+1.)) >= random){j_qnum = l - 1;}
3848 else if(1./3. + (2.*l-1.)/(3.*(2.*l+1.)) >= random){j_qnum = l;}
3849 else{j_qnum = l + 1;}
3851 else if (spin_qnum == 0){j_qnum = l;}
3857 if(
id[0] == -
id[1]){
3859 if(std::abs(
id[0])==5){baseid = 550;}
3860 if(std::abs(
id[0])==4){baseid = 440;}
3861 if(std::abs(
id[0])==3){baseid = 330;}
3862 if((std::abs(
id[0])==1) || (std::abs(
id[0]) == 2)){
3863 if(
ran()>0.5){baseid = 220;}
else{baseid = 110;}
3867 if(std::abs(
id[0])==5){baseid = 550; }
3868 if(std::abs(
id[0])==4){baseid = 440; }
3869 if(std::abs(
id[0])==3){
if(
ran()>0.666){baseid = 330;}
else{baseid = 220;}}
3870 if(std::abs(
id[0])<3){
3872 if(prb>0.5){baseid = 110;}
3873 else if(prb>0.333){baseid = 220;}
3880 baseid = 100*std::abs(
id[0])+10*std::abs(
id[1]);
3881 if(
id[0]%2 == 0){basesign = 2*std::signbit(-
id[0])-1;}
3882 else{ basesign = 2*std::signbit(
id[0])-1;}
3886 if(j_qnum < 5){baseid += 2*j_qnum + 1;}
3890 if(l > 0 && spin_qnum == 0){baseid += 10000;}
3891 else if(l > 0 && spin_qnum == 1 && l == j_qnum){baseid += 20000;}
3892 else if(l > 1 && spin_qnum == 1 && l == j_qnum + 1){baseid += 30000;}
3893 else if(l == 1 && spin_qnum == 1 && l == j_qnum + 1){baseid += 10000;}
3896 if(k < 10){baseid += k*100000;}
3897 else{baseid += 900000;}
3901 if(baseid == 211){baseid = 213;}
3902 if(baseid == 311){baseid = 313;}
3903 if(baseid == 321){baseid = 323;}
3904 if(baseid == 111){baseid = 113;}
3918 double qmass, glu_e;
3923 glu_e = sqrt(glu.
mass()*glu.
mass() + glu.
px()*glu.
px() + glu.
py()*glu.
py() + glu.
pz()*glu.
pz());
3927 if(glu.
mass() > 2.*xms){
3929 double ratio = 0.5*sqrt((glu.
mass()*glu.
mass()-4.*xms*xms)/(glu.
mass()*glu.
mass()-4.*xmq*xmq))*((glu.
mass()*glu.
mass()+2.*xms*xms)/(glu.
mass()*glu.
mass()+2.*xmq*xmq));
3930 double prob =
ran();
3931 if(prob <= ratio/(1.+ratio)){qmass = xms; q1.
id(3); q2.
id(-3); q1.
mass(xms); q2.
mass(xms);}
3932 else if((prob > ratio/(1.+ratio)) && (prob <= (0.5+ratio)/(1.+ratio))){qmass = xmq; q1.
id(1); q2.
id(-1); q1.
mass(xmq); q2.
mass(xmq);}
3933 else{ qmass = xmq; q1.
id(2); q2.
id(-2); q1.
mass(xmq); q2.
mass(xmq);}
3935 double prob =
ran();
3936 if(prob <= 0.5){qmass = xmq; q1.
id(1); q2.
id(-1); q1.
mass(xmq); q2.
mass(xmq);}
3937 else{ qmass = xmq; q1.
id(2); q2.
id(-2); q1.
mass(xmq); q2.
mass(xmq);}
3942 Betag.
Set(-glu.
px()/glu_e,-glu.
py()/glu_e,-glu.
pz()/glu_e,0.);
3943 double sum2 = Betag.
x()*Betag.
x() + Betag.
y()*Betag.
y() + Betag.
z()*Betag.
z();
3944 if(sum2 < 1.){Betag.
Set(Betag.
x(),Betag.
y(),Betag.
z(),1./sqrt(1.-sum2));}
3948 double pq = (glu.
mass() > 2.*qmass) ? sqrt(glu.
mass()*glu.
mass()/4. - qmass*qmass) : 0.;
3950 Pq_CM.
Set(pq*sin(theta)*cos(phi),pq*sin(theta)*sin(phi),pq*cos(theta),sqrt(qmass*qmass+pq*pq));
3951 Pq1 = HHboost(Betag,Pq_CM);
3952 Pq_CM.
Set(-Pq_CM.
x(),-Pq_CM.
y(),-Pq_CM.
z(),Pq_CM.
t());
3953 Pq2 = HHboost(Betag,Pq_CM);
3954 q1.
P(Pq1); q2.
P(Pq2);
3960 position1.
Set(glu.
x()+(Pq1.
x() / qmass)*part_prop,glu.
y()+(Pq1.
y() / qmass)*part_prop,glu.
z()+(Pq1.
z() / qmass)*part_prop,glu.
x_t()+part_prop);
3961 position2.
Set(glu.
x()+(Pq2.
x() / qmass)*part_prop,glu.
y()+(Pq2.
y() / qmass)*part_prop,glu.
z()+(Pq2.
z() / qmass)*part_prop,glu.
x_t()+part_prop);
3962 q1.
pos(position1); q2.
pos(position2);
3964 qrks.
add(q1); qrks.
add(q2);
3969 if(!therm[therm[ithm].sibling()].is_used() && (therm[therm[ithm].sibling()].string_id() < 0) && (ithm != therm[ithm].sibling())){
return therm[ithm].sibling();}
3970 int qrk_close = -1;
double dist2min = 999999999999.;
3971 for(
int i=0;
i<therm.
num();++
i){
3972 if((therm[ithm].
id() * therm[
i].
id() > 0) || therm[
i].is_used()){
continue;}
3973 double distnow = therm[ithm].posDif2(therm[
i]) + (therm[ithm].x_t()-therm[
i].x_t())*(therm[ithm].x_t()-therm[
i].x_t());
3974 if(distnow < dist2min){qrk_close =
i; dist2min = distnow;}
3976 if(qrk_close == -1){qrk_close = ithm;}
3983 if(iptn == 0 || ptn.
id() == 21){
throw std::runtime_error (
"Parton index is incorrect (should not be 0 or gluon)");}
3986 if((iptn<0) && thm && !lbt && !therm[ptn.
sibling()].is_used() &&
3987 (((therm[ptn.
sibling()].id() > 0) && (therm[ptn.
sibling()].col() != 0)) || ((therm[ptn.
sibling()].id() < 0) && (therm[ptn.
sibling()].acol() != 0))) &&
3991 int qrk_close = 999999999;
double dist2min = 999999999999.;
3993 if(thm){
for(
int i=0;
i<therm.
num();++
i){
3995 if(((therm[
i].
id() > 0) && (therm[
i].
col() != 0)) || ((therm[
i].id() < 0) && (therm[
i].acol() != 0))){
continue;}
3997 if((ptn.
id() * therm[
i].id() > 0) || therm[
i].is_used() || ((iptn<0) && (-
i == iptn+1))){
continue;}
3998 double distnow = ptn.
posDif2(therm[
i]) + (ptn.
x_t()-therm[
i].x_t())*(ptn.
x_t()-therm[
i].x_t());
3999 if(distnow < dist2min){qrk_close = -i-1; dist2min = distnow;}
4002 if(lbt){
for(
int i=0;
i<sh_lbt.
num();++
i){
4004 if(sh_lbt[
i].
id() == 21){
continue;}
4006 if(((sh_lbt[
i].
id() > 0) && (sh_lbt[
i].
col() != 0)) || ((sh_lbt[
i].id() < 0) && (sh_lbt[
i].acol() != 0))){
continue;}
4008 if((ptn.
id() * sh_lbt[
i].id() > 0) || sh_lbt[
i].is_used() || ((iptn>0) && (
i == iptn-1))){
continue;}
4009 double distnow = ptn.
posDif2(sh_lbt[
i]) + (ptn.
x_t()-sh_lbt[
i].x_t())*(ptn.
x_t()-sh_lbt[
i].x_t());
4010 if(distnow < dist2min){qrk_close = i+1; dist2min = distnow;}
4022 if(iptn == 0 || ptn.
id() != 21){
throw std::runtime_error (
"Parton index is incorrect (should not be 0, or anything other than gluon)");}
4023 if(ptn.
is_thermal()){
throw std::runtime_error (
"Parton is thermal (should not be so)");}
4026 int qrk_close = 999999999;
double dist2min = 999999999999.;
4028 if(thm){
for(
int i=0;
i<therm.
num();++
i){
4030 if(((therm[
i].
id() > 0) && (therm[
i].
col() != 0)) || (therm[
i].id() < 0)){
continue;}
4032 if(therm[
i].is_used() || ((iptn<0) && (-
i == iptn+1))){
continue;}
4033 double distnow = ptn.
posDif2(therm[
i]) + (ptn.
x_t()-therm[
i].x_t())*(ptn.
x_t()-therm[
i].x_t());
4034 if(distnow < dist2min){qrk_close = -i-1; dist2min = distnow;}
4037 if(lbt){
for(
int i=0;
i<sh_lbt.
num();++
i){
4039 if(sh_lbt[
i].
id() == 21){
continue;}
4041 if(((sh_lbt[
i].
id() > 0) && (sh_lbt[
i].
col() != 0)) || (sh_lbt[
i].id() < 0)){
continue;}
4043 if(sh_lbt[
i].is_used() || ((iptn>0) && (
i == iptn-1))){
continue;}
4044 double distnow = ptn.
posDif2(sh_lbt[
i]) + (ptn.
x_t()-sh_lbt[
i].x_t())*(ptn.
x_t()-sh_lbt[
i].x_t());
4045 if(distnow < dist2min){qrk_close = i+1; dist2min = distnow;}
4050 sel_out[0]=qrk_close;
4052 qrk_close = 999999999; dist2min = 999999999999.;
4054 if(thm){
for(
int i=0;
i<therm.
num();++
i){
4056 if((therm[
i].
id() > 0) || ((therm[
i].id() < 0) && (therm[
i].acol() != 0))){
continue;}
4058 if(therm[
i].is_used() || ((iptn<0) && (-
i == iptn+1))){
continue;}
4059 double distnow = ptn.
posDif2(therm[
i]) + (ptn.
x_t()-therm[
i].x_t())*(ptn.
x_t()-therm[
i].x_t());
4060 if(distnow < dist2min){qrk_close = -i-1; dist2min = distnow;}
4063 if(lbt){
for(
int i=0;
i<sh_lbt.
num();++
i){
4065 if(sh_lbt[
i].
id() == 21){
continue;}
4067 if((sh_lbt[
i].
id() > 0) || ((sh_lbt[
i].id() < 0) && (sh_lbt[
i].acol() != 0))){
continue;}
4069 if(sh_lbt[
i].is_used() || ((iptn>0) && (
i == iptn-1))){
continue;}
4070 double distnow = ptn.
posDif2(sh_lbt[
i]) + (ptn.
x_t()-sh_lbt[
i].x_t())*(ptn.
x_t()-sh_lbt[
i].x_t());
4071 if(distnow < dist2min){qrk_close = i+1; dist2min = distnow;}
4076 sel_out[1]=qrk_close;
4090 vector<vector<vector<HHparton>>> JuncStructure;
4091 vector<vector<HHparton>> JuncLegs;
4092 vector<HHparton> Leg1;
4093 vector<HHparton> Leg2;
4094 vector<HHparton> Leg3;
4095 vector<int> Legconsidering;
4096 vector<vector<vector<int>>> IMStructure1;
4097 vector<vector<int>> IMStructure2;
4099 vector<int> IMStructure3;
4100 vector<vector<HHparton>> Recombearly1;
4101 vector<HHparton> Recombearly2;
4102 vector<vector<vector<HHparton>>> Dijunction1;
4103 vector<vector<HHparton>> Dijunction2;
4105 vector<vector<int>> DijunctionInfo1;
4106 vector<int> DijunctionInfo2;
4110 vector<vector<vector<HHparton>>> Singlejunction1;
4111 vector<vector<HHparton>> Singlejunction2;
4112 vector<vector<HHparton>> Tailoredstring1;
4113 vector<HHparton> Tailoredstring2;
4114 vector<int> realjuncindice;
4116 vector<HHparton> finalstring;
4126 for(
int irem=0; irem < SP_remnants.
num(); ++irem) {
4127 if(SP_remnants[irem].
col() > maxtag) {
4128 maxtag = SP_remnants[irem].col();
4130 if(SP_remnants[irem].acol() > maxtag) {
4131 maxtag = SP_remnants[irem].acol();
4134 for(
int ijunc=0; ijunc < Tempjunctions.size(); ++ijunc) {
4135 if(Tempjunctions.at(ijunc).at(1).at(1) > maxtag) {
4136 maxtag = Tempjunctions.at(ijunc).at(1).at(1);
4138 if(Tempjunctions.at(ijunc).at(2).at(1) > maxtag) {
4139 maxtag = Tempjunctions.at(ijunc).at(2).at(1);
4141 if(Tempjunctions.at(ijunc).at(3).at(1) > maxtag) {
4142 maxtag = Tempjunctions.at(ijunc).at(3).at(1);
4149 for(
int ijunc=0; ijunc < Tempjunctions.size(); ++ijunc) {
4150 int i1 = 0;
int i2 = 0;
int i3 = 0;
4153 for(
int irem=0; irem < SP_remnants.
num(); ++irem) {
4154 if(Tempjunctions.at(ijunc).at(0).at(0) == -1) {
4155 if(SP_remnants[irem].acol() == Tempjunctions.at(ijunc).at(1).at(1) && Tempjunctions.at(ijunc).at(1).at(1) != 0) {i1 = irem+1;}
4156 if(SP_remnants[irem].acol() == Tempjunctions.at(ijunc).at(2).at(1) && Tempjunctions.at(ijunc).at(2).at(1) != 0) {i2 = irem+1;}
4157 if(SP_remnants[irem].acol() == Tempjunctions.at(ijunc).at(3).at(1) && Tempjunctions.at(ijunc).at(3).at(1) != 0) {i3 = irem+1;}
4158 }
else if(Tempjunctions.at(ijunc).at(0).at(0) == 1) {
4159 if(SP_remnants[irem].
col() == Tempjunctions.at(ijunc).at(1).at(1) && Tempjunctions.at(ijunc).at(1).at(1) != 0) {i1 = irem+1;}
4160 if(SP_remnants[irem].
col() == Tempjunctions.at(ijunc).at(2).at(1) && Tempjunctions.at(ijunc).at(2).at(1) != 0) {i2 = irem+1;}
4161 if(SP_remnants[irem].
col() == Tempjunctions.at(ijunc).at(3).at(1) && Tempjunctions.at(ijunc).at(3).at(1) != 0) {i3 = irem+1;}
4166 for(
int ijunc2=ijunc+1; ijunc2 < Tempjunctions.size(); ++ijunc2) {
4167 if((Tempjunctions.at(ijunc).at(0).at(0) == -1 && Tempjunctions.at(ijunc2).at(0).at(0) == 1) || (Tempjunctions.at(ijunc).at(0).at(0) == 1 && Tempjunctions.at(ijunc2).at(0).at(0) == -1)) {
4168 for(
int ileg=1; ileg <= 3; ++ileg) {
4169 if(Tempjunctions.at(ijunc2).at(ileg).at(1) == Tempjunctions.at(ijunc).at(1).at(1) && Tempjunctions.at(ijunc).at(1).at(1) != 0) {i1 = -ijunc2*10-ileg;}
4170 if(Tempjunctions.at(ijunc2).at(ileg).at(1) == Tempjunctions.at(ijunc).at(2).at(1) && Tempjunctions.at(ijunc).at(2).at(1) != 0) {i2 = -ijunc2*10-ileg;}
4171 if(Tempjunctions.at(ijunc2).at(ileg).at(1) == Tempjunctions.at(ijunc).at(3).at(1) && Tempjunctions.at(ijunc).at(3).at(1) != 0) {i3 = -ijunc2*10-ileg;}
4174 bool warning =
false;
4175 for (
int ileg=1; ileg <= 3; ++ileg) {
4176 for (
int jleg=1; jleg <= 3; ++jleg) {
4177 if (Tempjunctions.at(ijunc).at(ileg).at(1) == Tempjunctions.at(ijunc2).at(jleg).at(1)) {
4183 JSWARN <<
"There is a junction pair which is not junction-antijunction, but junction-junction or antijunction-antijunction. This should not happen!";
4191 tempparton1 = SP_remnants[i2-1];
4192 if(std::abs(tempparton1.
id()) < 6){
4193 tempparton1.
id(-tempparton1.
id());
4196 tempparton1 = SP_remnants[i3-1];
4197 if(std::abs(tempparton1.
id()) < 6){
4198 tempparton1.
id(-tempparton1.
id());
4201 tempparton1 = SP_remnants[0];
4202 if(Tempjunctions.at(ijunc).at(0).at(0) == -1 && std::abs(tempparton1.
id()) < 6 && tempparton1.
id() < 0){
4203 tempparton1.
id(-tempparton1.
id());
4204 }
else if(Tempjunctions.at(ijunc).at(0).at(0) == 1 && std::abs(tempparton1.
id()) < 6 && tempparton1.
id() > 0){
4205 tempparton1.
id(-tempparton1.
id());
4211 tempparton2 = SP_remnants[i1-1];
4212 if(std::abs(tempparton2.
id()) < 6){
4213 tempparton2.
id(-tempparton2.
id());
4216 tempparton2 = SP_remnants[i3-1];
4217 if(std::abs(tempparton2.
id()) < 6){
4218 tempparton2.
id(-tempparton2.
id());
4221 tempparton2 = SP_remnants[0];
4222 if(Tempjunctions.at(ijunc).at(0).at(0) == -1 && std::abs(tempparton2.
id()) < 6 && tempparton2.
id() < 0){
4223 tempparton2.
id(-tempparton2.
id());
4224 }
else if(Tempjunctions.at(ijunc).at(0).at(0) == 1 && std::abs(tempparton2.
id()) < 6 && tempparton2.
id() > 0){
4225 tempparton2.
id(-tempparton2.
id());
4231 tempparton3 = SP_remnants[i1-1];
4232 if(std::abs(tempparton3.
id()) < 6){
4233 tempparton3.
id(-tempparton3.
id());
4236 tempparton3 = SP_remnants[i2-1];
4237 if(std::abs(tempparton3.
id()) < 6){
4238 tempparton3.
id(-tempparton3.
id());
4241 tempparton3 = SP_remnants[0];
4242 if(Tempjunctions.at(ijunc).at(0).at(0) == -1 && std::abs(tempparton3.
id()) < 6 && tempparton3.
id() < 0){
4243 tempparton3.
id(-tempparton3.
id());
4244 }
else if(Tempjunctions.at(ijunc).at(0).at(0) == 1 && std::abs(tempparton3.
id()) < 6 && tempparton3.
id() > 0){
4245 tempparton3.
id(-tempparton3.
id());
4250 if(i1 == 0 || i2 == 0 || i3 == 0){
4251 Tempjunctions.at(ijunc).at(0).at(1) = 1;
4255 if(i1 == 0 && Tempjunctions.at(ijunc).at(0).at(0) == -1) {
4257 if(tempparton1.
id() == 21) {
4259 loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);
4261 }
else{loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);}
4262 if(loc == 999999999 || loc > 0) {
4263 int fid = ((
ran() > 0.33333333) ? ((
ran() > 0.5) ? -1 : -2) : -3);
4265 if(Tempjunctions.at(ijunc).at(1).at(1) != 0) {
4269 Tempjunctions.at(ijunc).at(1).at(1) = maxtag;
4271 if(std::abs(fakep.
id()) < 3) {
4273 }
else {fakep.
mass(xms);}
4274 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4275 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
4276 if (number_p_fake == 0 || number_p_fake == 2){
4278 }
else if (number_p_fake == 1 || number_p_fake == 3) {
4280 }
else {fakep.
pz(0.);}
4282 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4285 SP_remnants.
add(fakep);
4287 if(Tempjunctions.at(ijunc).at(1).at(1) != 0) {
4288 HH_thermal[-loc-1].acol(Tempjunctions.at(ijunc).at(1).at(1));
4290 HH_thermal[-loc-1].acol(++maxtag);
4291 Tempjunctions.at(ijunc).at(1).at(1) = maxtag;
4293 HH_thermal[-loc-1].col(0);
4294 HH_thermal[-loc-1].is_used(
true);
4295 HH_thermal[-loc-1].is_remnant(
true);
4296 SP_remnants.
add(HH_thermal[-loc-1]);
4297 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
4301 if(i2 == 0 && Tempjunctions.at(ijunc).at(0).at(0) == -1 ) {
4303 if(tempparton2.
id() == 21) {
4305 loc = findcloserepl(tempparton2,1,
false,
true, HH_showerptns, HH_thermal);
4307 }
else{loc = findcloserepl(tempparton2,1,
false,
true, HH_showerptns, HH_thermal);}
4308 if(loc == 999999999 || loc > 0) {
4309 int fid = ((
ran() > 0.33333333) ? ((
ran() > 0.5) ? -1 : -2) : -3);
4311 if(Tempjunctions.at(ijunc).at(2).at(1) != 0) {
4315 Tempjunctions.at(ijunc).at(2).at(1) = maxtag;
4317 if(std::abs(fakep.
id()) < 3) {
4319 }
else {fakep.
mass(xms);}
4320 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4321 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
4322 if (number_p_fake == 0 || number_p_fake == 2){
4324 }
else if (number_p_fake == 1 || number_p_fake == 3) {
4326 }
else {fakep.
pz(0.);}
4328 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4331 SP_remnants.
add(fakep);
4333 if(Tempjunctions.at(ijunc).at(2).at(1) != 0) {
4334 HH_thermal[-loc-1].acol(Tempjunctions.at(ijunc).at(2).at(1));
4336 HH_thermal[-loc-1].acol(++maxtag);
4337 Tempjunctions.at(ijunc).at(2).at(1) = maxtag;
4339 HH_thermal[-loc-1].col(0);
4340 HH_thermal[-loc-1].is_used(
true);
4341 HH_thermal[-loc-1].is_remnant(
true);
4342 SP_remnants.
add(HH_thermal[-loc-1]);
4343 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
4347 if(i3 == 0 && Tempjunctions.at(ijunc).at(0).at(0) == -1) {
4349 if(tempparton3.
id() == 21) {
4351 loc = findcloserepl(tempparton3,1,
false,
true, HH_showerptns, HH_thermal);
4353 }
else{loc = findcloserepl(tempparton3,1,
false,
true, HH_showerptns, HH_thermal);}
4354 if(loc == 999999999 || loc > 0) {
4355 int fid = ((
ran() > 0.33333333) ? ((
ran() > 0.5) ? -1 : -2) : -3);
4357 if(Tempjunctions.at(ijunc).at(3).at(1) != 0) {
4361 Tempjunctions.at(ijunc).at(3).at(1) = maxtag;
4363 if(std::abs(fakep.
id()) < 3) {
4365 }
else {fakep.
mass(xms);}
4366 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4367 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
4368 if (number_p_fake == 0 || number_p_fake == 2){
4370 }
else if (number_p_fake == 1 || number_p_fake == 3) {
4372 }
else {fakep.
pz(0.);}
4374 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4377 SP_remnants.
add(fakep);
4379 if(Tempjunctions.at(ijunc).at(3).at(1) != 0) {
4380 HH_thermal[-loc-1].acol(Tempjunctions.at(ijunc).at(3).at(1));
4382 HH_thermal[-loc-1].acol(++maxtag);
4383 Tempjunctions.at(ijunc).at(3).at(1) = maxtag;
4385 HH_thermal[-loc-1].col(0);
4386 HH_thermal[-loc-1].is_used(
true);
4387 HH_thermal[-loc-1].is_remnant(
true);
4388 SP_remnants.
add(HH_thermal[-loc-1]);
4389 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
4393 if(i1 == 0 && Tempjunctions.at(ijunc).at(0).at(0) == 1) {
4395 if(tempparton1.
id() == 21) {
4397 loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);
4399 }
else{loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);}
4400 if(loc == 999999999 || loc > 0) {
4401 int fid = ((
ran() > 0.33333333) ? ((
ran() > 0.5) ? 1 : 2) : 3);
4404 if(Tempjunctions.at(ijunc).at(1).at(1) != 0) {
4405 fakep.
set_color(Tempjunctions.at(ijunc).at(1).at(1));
4408 Tempjunctions.at(ijunc).at(1).at(1) = maxtag;
4410 if(std::abs(fakep.
id()) < 3) {
4412 }
else {fakep.
mass(xms);}
4413 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4414 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
4415 if (number_p_fake == 0 || number_p_fake == 2){
4417 }
else if (number_p_fake == 1 || number_p_fake == 3) {
4419 }
else {fakep.
pz(0.);}
4421 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4424 SP_remnants.
add(fakep);
4426 if(Tempjunctions.at(ijunc).at(1).at(1) != 0) {
4427 HH_thermal[-loc-1].col(Tempjunctions.at(ijunc).at(1).at(1));
4429 HH_thermal[-loc-1].col(++maxtag);
4430 Tempjunctions.at(ijunc).at(1).at(1) = maxtag;
4432 HH_thermal[-loc-1].acol(0);
4433 HH_thermal[-loc-1].is_used(
true);
4434 HH_thermal[-loc-1].is_remnant(
true);
4435 SP_remnants.
add(HH_thermal[-loc-1]);
4436 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
4440 if(i2 == 0 && Tempjunctions.at(ijunc).at(0).at(0) == 1) {
4442 if(tempparton2.
id() == 21) {
4444 loc = findcloserepl(tempparton2,1,
false,
true, HH_showerptns, HH_thermal);
4446 }
else{loc = findcloserepl(tempparton2,1,
false,
true, HH_showerptns, HH_thermal);}
4447 if(loc == 999999999 || loc > 0) {
4448 int fid = ((
ran() > 0.33333333) ? ((
ran() > 0.5) ? 1 : 2) : 3);
4451 if(Tempjunctions.at(ijunc).at(2).at(1) != 0) {
4452 fakep.
set_color(Tempjunctions.at(ijunc).at(2).at(1));
4455 Tempjunctions.at(ijunc).at(2).at(1) = maxtag;
4457 if(std::abs(fakep.
id()) < 3) {
4459 }
else {fakep.
mass(xms);}
4460 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4461 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
4462 if (number_p_fake == 0 || number_p_fake == 2){
4464 }
else if (number_p_fake == 1 || number_p_fake == 3) {
4466 }
else {fakep.
pz(0.);}
4468 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4471 SP_remnants.
add(fakep);
4473 if(Tempjunctions.at(ijunc).at(2).at(1) != 0) {
4474 HH_thermal[-loc-1].col(Tempjunctions.at(ijunc).at(2).at(1));
4476 HH_thermal[-loc-1].col(++maxtag);
4477 Tempjunctions.at(ijunc).at(2).at(1) = maxtag;
4479 HH_thermal[-loc-1].acol(0);
4480 HH_thermal[-loc-1].is_used(
true);
4481 HH_thermal[-loc-1].is_remnant(
true);
4482 SP_remnants.
add(HH_thermal[-loc-1]);
4483 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
4487 if(i3 == 0 && Tempjunctions.at(ijunc).at(0).at(0) == 1) {
4489 if(tempparton3.
id() == 21) {
4491 loc = findcloserepl(tempparton3,1,
false,
true, HH_showerptns, HH_thermal);
4493 }
else{loc = findcloserepl(tempparton3,1,
false,
true, HH_showerptns, HH_thermal);}
4494 if(loc == 999999999 || loc > 0) {
4495 int fid = ((
ran() > 0.33333333) ? ((
ran() > 0.5) ? 1 : 2) : 3);
4498 if(Tempjunctions.at(ijunc).at(3).at(1) != 0) {
4499 fakep.
set_color(Tempjunctions.at(ijunc).at(3).at(1));
4502 Tempjunctions.at(ijunc).at(3).at(1) = maxtag;
4504 if(std::abs(fakep.
id()) < 3) {
4506 }
else {fakep.
mass(xms);}
4507 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4508 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
4509 if (number_p_fake == 0 || number_p_fake == 2){
4511 }
else if (number_p_fake == 1 || number_p_fake == 3) {
4513 }
else {fakep.
pz(0.);}
4515 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4518 SP_remnants.
add(fakep);
4520 if(Tempjunctions.at(ijunc).at(3).at(1) != 0) {
4521 HH_thermal[-loc-1].col(Tempjunctions.at(ijunc).at(3).at(1));
4523 HH_thermal[-loc-1].col(++maxtag);
4524 Tempjunctions.at(ijunc).at(3).at(1) = maxtag;
4526 HH_thermal[-loc-1].acol(0);
4527 HH_thermal[-loc-1].is_used(
true);
4528 HH_thermal[-loc-1].is_remnant(
true);
4529 SP_remnants.
add(HH_thermal[-loc-1]);
4530 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
4535 if(i1 < 0 && Tempjunctions.at(ijunc).at(0).at(0) == -1 ) {
4536 int jleg = ((-i1) % 10);
4537 int jjunc = ((-i1)-jleg)/10;
4542 Tempjunctions.at(jjunc).at(jleg).at(1) = maxtag;
4543 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4544 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi)); fakep.
pz(0.);
4545 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4548 SP_remnants.
add(fakep);
4551 if(i2 < 0 && Tempjunctions.at(ijunc).at(0).at(0) == -1 ) {
4552 int jleg = ((-i2) % 10);
4553 int jjunc = ((-i2)-jleg)/10;
4558 Tempjunctions.at(jjunc).at(jleg).at(1) = maxtag;
4559 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4560 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi)); fakep.
pz(0.);
4561 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4564 SP_remnants.
add(fakep);
4567 if(i3 < 0 && Tempjunctions.at(ijunc).at(0).at(0) == -1 ) {
4568 int jleg = ((-i3) % 10);
4569 int jjunc = ((-i3)-jleg)/10;
4574 Tempjunctions.at(jjunc).at(jleg).at(1) = maxtag;
4575 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4576 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi)); fakep.
pz(0.);
4577 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4580 SP_remnants.
add(fakep);
4583 if(i1 < 0 && Tempjunctions.at(ijunc).at(0).at(0) == 1 ) {
4584 int jleg = ((-i1) % 10);
4585 int jjunc = ((-i1)-jleg)/10;
4588 fakep.
set_color(Tempjunctions.at(ijunc).at(1).at(1));
4590 Tempjunctions.at(jjunc).at(jleg).at(1) = maxtag;
4591 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4592 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi)); fakep.
pz(0.);
4593 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4596 SP_remnants.
add(fakep);
4599 if(i2 < 0 && Tempjunctions.at(ijunc).at(0).at(0) == 1 ) {
4600 int jleg = ((-i2) % 10);
4601 int jjunc = ((-i2)-jleg)/10;
4604 fakep.
set_color(Tempjunctions.at(ijunc).at(2).at(1));
4606 Tempjunctions.at(jjunc).at(jleg).at(1) = maxtag;
4607 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4608 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi)); fakep.
pz(0.);
4609 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4612 SP_remnants.
add(fakep);
4615 if(i3 < 0 && Tempjunctions.at(ijunc).at(0).at(0) == 1 ) {
4616 int jleg = ((-i3) % 10);
4617 int jjunc = ((-i3)-jleg)/10;
4620 fakep.
set_color(Tempjunctions.at(ijunc).at(3).at(1));
4622 Tempjunctions.at(jjunc).at(jleg).at(1) = maxtag;
4623 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4624 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi)); fakep.
pz(0.);
4625 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4628 SP_remnants.
add(fakep);
4633 for(
int ptn1 = 0; ptn1 < SP_remnants.
num(); ptn1++) {
4634 bool colors_match =
false;
4635 bool anti_colors_match =
false;
4636 int ptn1_col = SP_remnants[ptn1].col();
4637 int ptn1_acol = SP_remnants[ptn1].acol();
4638 for(
int ptn2 = 0; ptn2 < SP_remnants.
num(); ptn2++) {
4639 int ptn2_acol = SP_remnants[ptn2].acol();
4640 int ptn2_col = SP_remnants[ptn2].col();
4641 if(ptn1_col == ptn2_acol) {colors_match =
true;}
4642 if(ptn1_acol == ptn2_col) {anti_colors_match =
true;}
4644 if(!colors_match || !anti_colors_match) {
4645 for(
int ijunc = 0; ijunc < Tempjunctions.size(); ijunc++) {
4646 if(Tempjunctions.at(ijunc).at(0).at(0) == 1 && (ptn1_col == Tempjunctions.at(ijunc).at(1).at(1) || ptn1_col == Tempjunctions.at(ijunc).at(2).at(1) || ptn1_col == Tempjunctions.at(ijunc).at(3).at(1))) {
4647 colors_match =
true;
4649 if(Tempjunctions.at(ijunc).at(0).at(0) == -1 && (ptn1_acol == Tempjunctions.at(ijunc).at(1).at(1) || ptn1_acol == Tempjunctions.at(ijunc).at(2).at(1) || ptn1_acol == Tempjunctions.at(ijunc).at(3).at(1))) {
4650 anti_colors_match =
true;
4654 if(!colors_match && SP_remnants[ptn1].
id() > 0) {
4656 if(SP_remnants[ptn1].
id() == 21){
4657 SP_remnants[ptn1].id(1);
4658 loc = findcloserepl(SP_remnants[ptn1], ptn1+1,
false,
true, HH_showerptns, HH_thermal);
4659 SP_remnants[ptn1].id(21);
4660 }
else{loc = findcloserepl(SP_remnants[ptn1], ptn1+1,
false,
true, HH_showerptns, HH_thermal);}
4662 if(loc == 999999999 || loc > 0){
4663 int fid = (
ran() > 0.33333333) ? ((
ran() > 0.5) ? -1 : -2) : -3;
4665 if(std::abs(fakep.
id()) < 3) {
4667 }
else {fakep.
mass(xms);}
4668 double dir = (
ran() < 0.5) ? 1. : -1.;
double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4669 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
4670 if (number_p_fake == 0 || number_p_fake == 2){
4672 }
else if (number_p_fake == 1 || number_p_fake == 3) {
4674 }
else {fakep.
pz(0.);}
4676 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4679 SP_remnants.
add(fakep);
4681 HH_thermal[-loc-1].acol(ptn1_col);
4682 HH_thermal[-loc-1].col(0);
4683 HH_thermal[-loc-1].is_used(
true);
4684 HH_thermal[-loc-1].is_remnant(
true);
4685 SP_remnants.
add(HH_thermal[-loc-1]);
4686 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
4689 if(!anti_colors_match && (SP_remnants[ptn1].
id() < 0 || SP_remnants[ptn1].
id() == 21)) {
4691 if(SP_remnants[ptn1].
id() == 21){
4692 SP_remnants[ptn1].id(-1);
4693 loc = findcloserepl(SP_remnants[ptn1], ptn1+1,
false,
true, HH_showerptns, HH_thermal);
4694 SP_remnants[ptn1].id(21);
4695 }
else{loc = findcloserepl(SP_remnants[ptn1], ptn1+1,
false,
true, HH_showerptns, HH_thermal);}
4697 if(loc == 999999999 || loc > 0){
4698 int fid = (
ran() > 0.33333333) ? ((
ran() > 0.5) ? 1 : 2) : 3;
4700 if(std::abs(fakep.
id()) < 3) {
4702 }
else {fakep.
mass(xms);}
4703 double dir = (
ran() < 0.5) ? 1. : -1.;
double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
4704 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
4705 if (number_p_fake == 0 || number_p_fake == 2){
4707 }
else if (number_p_fake == 1 || number_p_fake == 3) {
4709 }
else {fakep.
pz(0.);}
4711 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
4714 SP_remnants.
add(fakep);
4716 HH_thermal[-loc-1].col(ptn1_acol);
4717 HH_thermal[-loc-1].acol(0);
4718 HH_thermal[-loc-1].is_used(
true);
4719 HH_thermal[-loc-1].is_remnant(
true);
4720 SP_remnants.
add(HH_thermal[-loc-1]);
4721 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
4726 set_initial_parton_masses(SP_remnants);
4728 for(
int ijunc=0; ijunc < Tempjunctions.size(); ++ijunc) {
4738 vector<int> correction;
4739 if(Tempjunctions.at(ijunc).at(0).at(0) == -1) {
4740 for(
int irem=0; irem < SP_remnants.
num(); ++irem) {
4742 if(SP_remnants[irem].acol() == Tempjunctions.at(ijunc).at(1).at(1)){
4743 Leg1.push_back(SP_remnants[irem]);
4744 correction.push_back(irem);
4745 SP_remnants[irem].used_junction(
true);
4747 Legconsidering.push_back(irem);
4749 if(SP_remnants[irem].acol() == Tempjunctions.at(ijunc).at(2).at(1)){
4750 Leg2.push_back(SP_remnants[irem]);
4751 correction.push_back(irem);
4752 SP_remnants[irem].used_junction(
true);
4754 Legconsidering.push_back(irem);
4756 if(SP_remnants[irem].acol() == Tempjunctions.at(ijunc).at(3).at(1)){
4757 Leg3.push_back(SP_remnants[irem]);
4758 correction.push_back(irem);
4759 SP_remnants[irem].used_junction(
true);
4761 Legconsidering.push_back(irem);
4763 if(Legconsidering.size() !=3 ){
4764 for(
int icor = 0; icor < correction.size(); icor++){
4765 SP_remnants[correction.at(icor)].used_junction(
false);
4772 }
else if(Tempjunctions.at(ijunc).at(0).at(0) == 1) {
4773 for(
int irem=0; irem < SP_remnants.
num(); ++irem) {
4775 if(SP_remnants[irem].
col() == Tempjunctions.at(ijunc).at(1).at(1)){
4776 Leg1.push_back(SP_remnants[irem]);
4777 correction.push_back(irem);
4778 SP_remnants[irem].used_junction(
true);
4779 Legconsidering.push_back(irem);
4782 if(SP_remnants[irem].
col() == Tempjunctions.at(ijunc).at(2).at(1)){
4783 Leg2.push_back(SP_remnants[irem]);
4784 correction.push_back(irem);
4785 SP_remnants[irem].used_junction(
true);
4787 Legconsidering.push_back(irem);
4789 if(SP_remnants[irem].
col() == Tempjunctions.at(ijunc).at(3).at(1)){
4790 Leg3.push_back(SP_remnants[irem]);
4791 correction.push_back(irem);
4792 SP_remnants[irem].used_junction(
true);
4794 Legconsidering.push_back(irem);
4796 if(Legconsidering.size() !=3 ){
4797 for(
int icor = 0; icor < correction.size(); icor++){
4798 SP_remnants[correction.at(icor)].used_junction(
false);
4807 if(Legconsidering.size() == 3) {
4808 realjuncindice.push_back(ijunc);
4810 if(Tempjunctions.at(ijunc).at(0).at(0) == -1 && Leg1.at(0).col() != 0 && Leg1.at(0).acol() != 0){
4811 for(
int iloop=0; iloop < SP_remnants.
num(); iloop++){
4812 for(
int icf = 0; icf < SP_remnants.
num(); ++icf) {
4813 if( (Leg1.back().col() != 0) && (Leg1.back().col() == SP_remnants[icf].acol()) ){
4815 Leg1.push_back(SP_remnants[icf]);
4816 SP_remnants[icf].used_junction(
true);
4818 if( Leg1.back().col() == 0 || Leg1.back().acol() == 0 ){
break; }
4821 }
else if(Tempjunctions.at(ijunc).at(0).at(0) == 1 && Leg1.at(0).col() != 0 && Leg1.at(0).acol() != 0){
4822 for(
int iloop=0; iloop < SP_remnants.
num(); iloop++){
4823 for(
int icf = 0; icf < SP_remnants.
num(); ++icf) {
4824 if( (Leg1.back().acol() != 0) && (Leg1.back().acol() == SP_remnants[icf].col()) ){
4826 Leg1.push_back(SP_remnants[icf]);
4827 SP_remnants[icf].used_junction(
true);
4829 if(Leg1.back().col() == 0 || Leg1.back().acol() == 0){
break;}
4834 if(Tempjunctions.at(ijunc).at(0).at(0) == -1 && Leg2.at(0).col() != 0 && Leg2.at(0).acol() != 0){
4835 for(
int iloop=0; iloop < SP_remnants.
num(); iloop++){
4836 for(
int icf = 0; icf < SP_remnants.
num(); ++icf) {
4837 if( ( Leg2.back().col() != 0 ) && (Leg2.back().col() == SP_remnants[icf].acol()) ){
4839 Leg2.push_back(SP_remnants[icf]);
4840 SP_remnants[icf].used_junction(
true);
4842 if( Leg2.back().col() == 0 || Leg2.back().acol() == 0){
break;}
4845 }
else if(Tempjunctions.at(ijunc).at(0).at(0) == 1 && Leg2.at(0).col() != 0 && Leg2.at(0).acol() != 0){
4846 for(
int iloop=0; iloop < SP_remnants.
num(); iloop++){
4847 for(
int icf = 0; icf < SP_remnants.
num(); ++icf) {
4848 if( (Leg2.back().acol() != 0) && (Leg2.back().acol() == SP_remnants[icf].col()) ){
4850 Leg2.push_back(SP_remnants[icf]);
4851 SP_remnants[icf].used_junction(
true);
4853 if( Leg2.back().col() == 0 || Leg2.back().acol() == 0){
break;}
4858 if(Tempjunctions.at(ijunc).at(0).at(0) == -1 && Leg3.at(0).col() != 0 && Leg3.at(0).acol() != 0){
4859 for(
int iloop=0; iloop < SP_remnants.
num(); iloop++){
4860 for(
int icf = 0; icf < SP_remnants.
num(); ++icf) {
4861 if( (Leg3.back().col() != 0) && (Leg3.back().col() == SP_remnants[icf].acol()) ){
4863 Leg3.push_back(SP_remnants[icf]);
4864 SP_remnants[icf].used_junction(
true);
4866 if( Leg3.back().col() == 0 || Leg3.back().acol() == 0){
break;}
4869 }
else if(Tempjunctions.at(ijunc).at(0).at(0) == 1 && Leg3.at(0).col() != 0 && Leg3.at(0).acol() != 0){
4870 for(
int iloop=0; iloop < SP_remnants.
num(); iloop++){
4871 for(
int icf = 0; icf < SP_remnants.
num(); ++icf) {
4874 if( (Leg3.back().acol() != 0) && (Leg3.back().acol() == SP_remnants[icf].col()) ){
4876 Leg3.push_back(SP_remnants[icf]);
4877 SP_remnants[icf].used_junction(
true);
4879 if( Leg3.back().col() == 0 || Leg3.back().acol() == 0 ){
break;}
4883 JuncLegs.push_back(Leg1);
4884 JuncLegs.push_back(Leg2);
4885 JuncLegs.push_back(Leg3);
4886 JuncStructure.push_back(JuncLegs);
4892 Legconsidering.clear();
4919 for(
int irep1 = 0; irep1 < JuncStructure.size(); irep1++){
4920 IMStructure3.push_back(realjuncindice.at(irep1));
4921 IMStructure3.push_back(Tempjunctions.at(realjuncindice.at(irep1)).
at(0).at(0));
4922 IMStructure3.push_back(irep1);
4923 IMStructure3.push_back(0);
4924 IMStructure2.push_back(IMStructure3);
4925 IMStructure3.clear();
4926 for(
int irep2 = 0; irep2 < 3; irep2++){
4927 for(
int irep3 = 0; irep3 < JuncStructure.size(); irep3++){
4928 for(
int irep4 = 0; irep4 < 3; irep4++){
4929 if( (irep1 != irep3) && (JuncStructure.at(irep1).at(irep2).at(0).col() == JuncStructure.at(irep3).at(irep4).back().col()) &&
4930 (JuncStructure.at(irep1).at(irep2).at(0).acol() == JuncStructure.at(irep3).at(irep4).back().acol())){
4931 IMStructure3.push_back(irep1);
4932 IMStructure3.push_back(irep2);
4933 IMStructure3.push_back(irep3);
4934 IMStructure3.push_back(irep4);
4935 IMStructure2.push_back(IMStructure3);
4936 IMStructure3.clear();
4941 IMStructure1.push_back(IMStructure2);
4942 IMStructure2.clear();
4961 std::vector<int> thermal_parton_junction;
4964 for(
int iloop1 = 0; iloop1 < IMStructure1.size(); iloop1++){
4966 if(IMStructure1.at(iloop1).size() == 4){
4967 for(
int iloop2 = 1; iloop2 < IMStructure1.at(iloop1).size(); iloop2++){
4968 for(
int iloop3 = 0; iloop3 < IMStructure1.size(); iloop3++){
4969 for(
int iloop4 = 1; iloop4 < IMStructure1.at(iloop3).size(); iloop4++){
4970 if( (IMStructure1.at(iloop1).at(iloop2).at(2) == IMStructure1.at(iloop3).at(iloop4).at(0)) &&
4971 (IMStructure1.at(iloop1).at(iloop2).at(3) == IMStructure1.at(iloop3).at(iloop4).at(1)) ){
4972 vector<int> testing;
4973 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(2));
4974 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(3));
4975 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(0));
4976 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(1));
4977 std::vector<vector<int>>::iterator
it = std::find(IMStructure1.at(iloop3).begin(), IMStructure1.at(iloop3).end(), testing);
4978 IMStructure1.at(iloop3).erase(it);
4981 if((JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(0)).
at(IMStructure1.at(iloop1).at(iloop2).at(1)).
at(0).col() != 0) &&
4982 (JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(0)).
at(IMStructure1.at(iloop1).at(iloop2).at(1)).
at(0).acol() != 0) &&
4983 (JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).back().col() != 0) &&
4984 (JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).back().acol() != 0)) {
4986 gluon_decay(JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(0)).
at(IMStructure1.at(iloop1).at(iloop2).at(1)).
at(0), tempqpair );
4989 if(IMStructure1.at(iloop1).at(0).at(1) == -1){
4990 Recombearly2.push_back(tempqpair[1]);
4993 JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).pop_back();
4994 JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).push_back(tempqpair[0]);
4998 if(IMStructure1.at(iloop1).at(0).at(1) == 1){
4999 Recombearly2.push_back(tempqpair[0]);
5002 JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).pop_back();
5003 JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).push_back(tempqpair[1]);
5012 thermal_parton_junction.push_back(Tempjunctions.at(IMStructure1.at(iloop1).at(0).at(2)).
at(0).at(1));
5013 IMStructure1.erase(IMStructure1.begin()+iloop1);
5015 Recombearly1.push_back(Recombearly2);
5016 Recombearly2.clear();
5021 for(
int iloop1 = 0; iloop1 < IMStructure1.size(); iloop1++){
5022 if(IMStructure1.at(iloop1).size() == 3){
5026 for(
int itail = 1; itail < IMStructure1.at(iloop1).size(); itail++){
5027 SI = SI + IMStructure1.at(iloop1).at(itail).at(1);
5030 vector<int> indicevec;
5031 indicevec.push_back(2);
5032 indicevec.push_back(1);
5033 indicevec.push_back(0);
5034 leftleg = indicevec[SI-1];
5041 int jidentity = IMStructure1.at(iloop1).at(0).at(1);
5043 int juncnum = IMStructure1.at(iloop1).at(0).at(0);
5044 vector<HHparton> tempstring = JuncStructure.at(juncnum).at(leftleg);
5045 if(jidentity == 1 && tempstring.at(0).col() != 0 && tempstring.at(0).acol() != 0){
5047 gluon_decay( tempstring.at(0), tempqpair);
5048 tempstring.erase(tempstring.begin());
5049 tempstring.insert(tempstring.begin() , tempqpair[1] );
5050 Tailoredstring1.push_back(tempstring);
5051 Recombearly2.push_back(tempqpair[0]);
5052 }
else if(jidentity == -1 && tempstring.at(0).col() != 0 && tempstring.at(0).acol() != 0){
5054 gluon_decay( tempstring.at(0), tempqpair);
5055 tempstring.erase(tempstring.begin());
5056 tempstring.insert(tempstring.begin() , tempqpair[0] );
5057 Tailoredstring1.push_back(tempstring);
5058 Recombearly2.push_back(tempqpair[1]);
5060 Recombearly2.push_back(tempstring.at(0));
5064 for(
int iloop2 = 1; iloop2 < IMStructure1.at(iloop1).size(); iloop2++){
5065 for(
int iloop3 = 0; iloop3 < IMStructure1.size(); iloop3++){
5066 for(
int iloop4 = 1; iloop4 < IMStructure1.at(iloop3).size(); iloop4++){
5067 if( (IMStructure1.at(iloop1).at(iloop2).at(2) == IMStructure1.at(iloop3).at(iloop4).at(0)) &&
5068 (IMStructure1.at(iloop1).at(iloop2).at(3) == IMStructure1.at(iloop3).at(iloop4).at(1)) ){
5069 vector<int> testing;
5070 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(2));
5071 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(3));
5072 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(0));
5073 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(1));
5074 std::vector<vector<int>>::iterator
it = std::find(IMStructure1.at(iloop3).begin(), IMStructure1.at(iloop3).end(), testing);
5075 IMStructure1.at(iloop3).erase(it);
5078 if((JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(0)).
at(IMStructure1.at(iloop1).at(iloop2).at(1)).
at(0).col() != 0) &&
5079 (JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(0)).
at(IMStructure1.at(iloop1).at(iloop2).at(1)).
at(0).acol() != 0) &&
5080 (JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).back().col() != 0) &&
5081 (JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).back().acol() != 0)) {
5083 gluon_decay(JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(0)).
at(IMStructure1.at(iloop1).at(iloop2).at(1)).
at(0), tempqpair );
5086 if(IMStructure1.at(iloop1).at(0).at(1) == -1){
5087 Recombearly2.push_back(tempqpair[1]);
5090 JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).pop_back();
5091 JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).push_back(tempqpair[0]);
5095 if(IMStructure1.at(iloop1).at(0).at(1) == 1){
5096 Recombearly2.push_back(tempqpair[0]);
5099 JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).pop_back();
5100 JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(IMStructure1.at(iloop1).at(iloop2).at(3)).push_back(tempqpair[1]);
5108 thermal_parton_junction.push_back(Tempjunctions.at(IMStructure1.at(iloop1).at(0).at(2)).
at(0).at(1));
5109 IMStructure1.erase(IMStructure1.begin()+iloop1);
5111 Recombearly1.push_back(Recombearly2);
5112 Recombearly2.clear();
5140 for(
int iloop1 = 0; iloop1 < IMStructure1.size(); iloop1++){
5141 if(IMStructure1.at(iloop1).size() == 2 && IMStructure1.at(iloop1).at(0).at(3) == 0){
5142 for(
int iloop2 = 1; iloop2< IMStructure1.at(iloop1).size(); iloop2++){
5143 for(
int iloop3 = 0; iloop3 < IMStructure1.size(); iloop3++){
5144 for(
int iloop4 = 1; iloop4 < IMStructure1.at(iloop3).size(); iloop4++){
5145 if( (IMStructure1.at(iloop1).at(iloop2).at(2) == IMStructure1.at(iloop3).at(iloop4).at(0)) &&
5146 (IMStructure1.at(iloop1).at(iloop2).at(3) == IMStructure1.at(iloop3).at(iloop4).at(1)) ){
5147 if(IMStructure1.at(iloop1).at(0).at(3) == 0) {
5148 for(
int idijunc1 = 0; idijunc1 < 3; idijunc1++){
5149 Dijunction2.push_back(JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(0)).
at(idijunc1));
5151 for(
int idijunc2 = 0; idijunc2 < 3; idijunc2++){
5152 if( idijunc2 != IMStructure1.at(iloop1).at(iloop2).at(3)){
5153 Dijunction2.push_back(JuncStructure.at(IMStructure1.at(iloop1).at(iloop2).at(2)).
at(idijunc2));
5157 Dijunction1.push_back(Dijunction2);
5158 Dijunction2.clear();
5159 IMStructure1.at(iloop1).at(0).pop_back();
5160 IMStructure1.at(iloop1).at(0).push_back(1);
5161 IMStructure1.at(iloop3).at(0).pop_back();
5162 IMStructure1.at(iloop3).at(0).push_back(1);
5164 vector<int> testing;
5165 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(2));
5166 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(3));
5167 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(0));
5168 testing.push_back(IMStructure1.at(iloop1).at(iloop2).at(1));
5169 std::vector<vector<int>>::iterator
it = std::find(IMStructure1.at(iloop3).begin(), IMStructure1.at(iloop3).end(), testing);
5170 IMStructure1.at(iloop3).erase(it);
5194 for(
int irepair = 0; irepair < IMStructure1.size(); irepair++) {
5195 if(IMStructure1.at(irepair).size() == 1 && IMStructure1.at(irepair).at(0).at(3) == 0 ){
5196 Singlejunction2.push_back(JuncStructure.at(IMStructure1.at(irepair).at(0).at(2)).
at(0));
5197 Singlejunction2.push_back(JuncStructure.at(IMStructure1.at(irepair).at(0).at(2)).
at(1));
5198 Singlejunction2.push_back(JuncStructure.at(IMStructure1.at(irepair).at(0).at(2)).
at(2));
5199 Singlejunction1.push_back(Singlejunction2);
5200 Singlejunction2.clear();
5223 for(
int idj1 = 0; idj1 < Dijunction1.size(); idj1++){
5224 for(
int idj2 = 0; idj2 < Dijunction1.at(idj1).size(); idj2++){
5228 for(
int itpj1 = 0; itpj1 < IMStructure1.size(); itpj1++){
5229 for(
int itpj2 = 1; itpj2 < Tempjunctions.at(itpj1).size(); itpj2++){
5230 if(Dijunction1.at(idj1).at(idj2).at(0).col() == Tempjunctions.at(IMStructure1.at(itpj1).at(0).at(0)).
at(itpj2).at(1) ||
5231 Dijunction1.at(idj1).at(idj2).back().col() == Tempjunctions.at(IMStructure1.at(itpj1).at(0).at(0)).
at(itpj2).at(1) ){
5234 if(Dijunction1.at(idj1).at(idj2).at(0).acol() == Tempjunctions.at(IMStructure1.at(itpj1).at(0).at(0)).
at(itpj2).at(1) ||
5235 Dijunction1.at(idj1).at(idj2).back().acol() == Tempjunctions.at(IMStructure1.at(itpj1).at(0).at(0)).
at(itpj2).at(1) ){
5240 if(J ==
true && antiJ ==
false){
5241 DijunctionInfo2.push_back(1);
5243 if(J ==
false && antiJ ==
true){
5244 DijunctionInfo2.push_back(-1);
5246 if(J ==
true && antiJ ==
true){
5250 DijunctionInfo2.push_back(0);
5256 DijunctionInfo1.push_back(DijunctionInfo2);
5257 DijunctionInfo2.clear();
5264 for(
int ileg1 = 0 ; ileg1 < Dijunction1.size(); ileg1++){
5265 for(
int ileg2 = 0; ileg2 < Dijunction1.at(ileg1).size(); ileg2++){
5266 bool needflip =
false;
5267 if((DijunctionInfo1.at(ileg1).at(ileg2) == 0 && Dijunction1.at(ileg1).at(ileg2).size() != 1) &&
5268 (Dijunction1.at(ileg1).at(ileg2).at(0).col() == Dijunction1.at(ileg1).at(ileg2).at(1).acol()) ){
5272 std::reverse(Dijunction1.at(ileg1).at(ileg2).begin() , Dijunction1.at(ileg1).at(ileg2).end() );
5319 for(
int is1 = 0; is1 < Singlejunction1.size(); is1++){
5320 HHparton p1 = Singlejunction1.at(is1).at(0).back();
5321 HHparton p2 = Singlejunction1.at(is1).at(1).back();
5322 HHparton p3 = Singlejunction1.at(is1).at(2).back();
5325 bool ajunction =
false;
5327 if( p1.
id() < 0 || p2.
id() < 0 || p3.
id() < 0){
5331 for(
int is2 = 0; is2 < Singlejunction1.at(is1).size(); is2++){
5332 HHparton endpoint = Singlejunction1.at(is1).at(is2).back();
5334 if(endpoint.
col() != 0 && endpoint.
acol() != 0 && ajunction){
5337 if(tempparton1.
id() == 21) {
5339 loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);
5341 }
else{loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);}
5342 if(loc == 999999999 || loc > 0) {
5343 int fid = ((
ran() > 0.33333333) ? ((
ran() > 0.5) ? -1 : -2) : -3);
5346 if(std::abs(fakep.
id()) < 3) {
5348 }
else {fakep.
mass(xms);}
5349 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
5350 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
5351 if (number_p_fake == 0 || number_p_fake == 2){
5353 }
else if (number_p_fake == 1 || number_p_fake == 3) {
5355 }
else {fakep.
pz(0.);}
5357 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
5360 SP_remnants.
add(fakep);
5361 Singlejunction1.at(is1).at(is2).push_back(fakep);
5363 HH_thermal[-loc-1].acol(endpoint.
col());
5364 HH_thermal[-loc-1].col(0);
5365 HH_thermal[-loc-1].is_used(
true);
5366 HH_thermal[-loc-1].is_remnant(
true); SP_remnants.
add(HH_thermal[-loc-1]);
5367 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
5368 Singlejunction1.at(is1).at(is2).push_back(HH_thermal[-loc-1]);
5373 for(
int is3 = 0; is3 < Singlejunction1.at(is1).size(); is3++){
5374 HHparton endpoint = Singlejunction1.at(is1).at(is3).back();
5376 if(endpoint.
col() != 0 && endpoint.
acol() != 0 && !ajunction){
5379 if(tempparton1.
id() == 21) {
5381 loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);
5383 }
else{loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);}
5384 if(loc == 999999999 || loc > 0) {
5385 int fid = ((
ran() > 0.33333333) ? ((
ran() > 0.5) ? 1 : 2) : 3);
5388 if(std::abs(fakep.
id()) < 3) {
5390 }
else {fakep.
mass(xms);}
5391 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
5392 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
5393 if (number_p_fake == 0 || number_p_fake == 2){
5395 }
else if (number_p_fake == 1 || number_p_fake == 3) {
5397 }
else {fakep.
pz(0.);}
5399 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
5402 SP_remnants.
add(fakep);
5403 Singlejunction1.at(is1).at(is3).push_back(fakep);
5405 HH_thermal[-loc-1].col(endpoint.
acol());
5406 HH_thermal[-loc-1].acol(0);
5407 HH_thermal[-loc-1].is_used(
true);
5408 HH_thermal[-loc-1].is_remnant(
true); SP_remnants.
add(HH_thermal[-loc-1]);
5409 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
5410 Singlejunction1.at(is1).at(is3).push_back(HH_thermal[-loc-1]);
5418 for(
int idj1 = 0; idj1 < Dijunction1.size(); idj1++){
5419 for(
int idj2 = 0; idj2 < Dijunction1.at(idj1).size(); idj2++){
5420 HHparton endpoint = Dijunction1.at(idj1).at(idj2).back();
5422 if(DijunctionInfo1.at(idj1).at(idj2) == -1 && endpoint.
col() != 0 && endpoint.
acol() != 0){
5425 if(tempparton1.
id() == 21) {
5427 loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);
5429 }
else{loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);}
5430 if(loc == 999999999 || loc > 0) {
5431 int fid = ((
ran() > 0.33333333) ? ((
ran() > 0.5) ? -1 : -2) : -3);
5434 if(std::abs(fakep.
id()) < 3) {
5436 }
else {fakep.
mass(xms);}
5437 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
5438 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
5439 if (number_p_fake == 0 || number_p_fake == 2){
5441 }
else if (number_p_fake == 1 || number_p_fake == 3) {
5443 }
else {fakep.
pz(0.);}
5445 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
5448 SP_remnants.
add(fakep);
5449 Dijunction1.at(idj1).at(idj2).push_back(fakep);
5451 HH_thermal[-loc-1].acol(endpoint.
col());
5452 HH_thermal[-loc-1].col(0);
5453 HH_thermal[-loc-1].is_used(
true);
5454 HH_thermal[-loc-1].is_remnant(
true); SP_remnants.
add(HH_thermal[-loc-1]);
5455 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
5456 Dijunction1.at(idj1).at(idj2).push_back(HH_thermal[-loc-1]);
5461 for(
int idj3 = 0; idj3 < Dijunction1.at(idj1).size(); idj3++){
5462 HHparton endpoint = Dijunction1.at(idj1).at(idj3).back();
5464 if(DijunctionInfo1.at(idj1).at(idj3) == 1 && endpoint.
col() != 0 && endpoint.
acol() != 0){
5467 if(tempparton1.
id() == 21) {
5469 loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);
5471 }
else{loc = findcloserepl(tempparton1,1,
false,
true, HH_showerptns, HH_thermal);}
5472 if(loc == 999999999 || loc > 0) {
5473 int fid = ((
ran() > 0.33333333) ? ((
ran() > 0.5) ? 1 : 2) : 3);
5476 if(std::abs(fakep.
id()) < 3) {
5478 }
else {fakep.
mass(xms);}
5479 double fake_pT = (p_fake >= 1.) ? 0.282842712474619 : 0.;
double fake_phi = 2. * 3.14159265358979 *
ran();
5480 fakep.
px(fake_pT * cos(fake_phi)); fakep.
py(fake_pT * sin(fake_phi));
5481 if (number_p_fake == 0 || number_p_fake == 2){
5483 }
else if (number_p_fake == 1 || number_p_fake == 3) {
5485 }
else {fakep.
pz(0.);}
5487 fakep.
e(std::sqrt(fakep.
px()*fakep.
px() + fakep.
py()*fakep.
py() + fakep.
pz()*fakep.
pz() + fakep.
mass()*fakep.
mass()));
5490 SP_remnants.
add(fakep);
5491 Dijunction1.at(idj1).at(idj3).push_back(fakep);
5493 HH_thermal[-loc-1].col(endpoint.
acol());
5494 HH_thermal[-loc-1].acol(0);
5495 HH_thermal[-loc-1].is_used(
true);
5496 HH_thermal[-loc-1].is_remnant(
true); SP_remnants.
add(HH_thermal[-loc-1]);
5497 SP_remnants[SP_remnants.
num()-1].par(-loc-1);
5498 Dijunction1.at(idj1).at(idj3).push_back(HH_thermal[-loc-1]);
5506 for(
int irb1 = 0; irb1 < Recombearly1.size(); irb1++){
5507 for(
int irb2 = 0; irb2 < Recombearly1.at(irb1).size(); irb2++){
5508 for(
int irb3 = irb2+1; irb3 < Recombearly1.at(irb1).size(); irb3++){
5509 if( (Recombearly1.at(irb1).at(irb2).col() == Recombearly1.at(irb1).at(irb3).col()) &&
5510 Recombearly1.at(irb1).at(irb2).acol() == Recombearly1.at(irb1).at(irb3).acol()){
5511 Recombearly1.at(irb1).erase(Recombearly1.at(irb1).begin()+irb3);
5530 for(
int irb = 0; irb < Recombearly1.size(); irb++){
5535 Recombearly1.at(irb)[0].px()+Recombearly1.at(irb)[1].px()+Recombearly1.at(irb)[2].px(),
5536 Recombearly1.at(irb)[0].py()+Recombearly1.at(irb)[1].py()+Recombearly1.at(irb)[2].py(),
5537 Recombearly1.at(irb)[0].pz()+Recombearly1.at(irb)[1].pz()+Recombearly1.at(irb)[2].pz(),
5543 Pbaryon.
x()/(Recombearly1.at(irb)[0].e()+Recombearly1.at(irb)[1].e()+Recombearly1.at(irb)[2].e()),
5544 Pbaryon.
y()/(Recombearly1.at(irb)[0].e()+Recombearly1.at(irb)[1].e()+Recombearly1.at(irb)[2].e()),
5545 Pbaryon.
z()/(Recombearly1.at(irb)[0].e()+Recombearly1.at(irb)[1].e()+Recombearly1.at(irb)[2].e()),
5551 1./(sqrt(1. - (betaB.
x()*betaB.
x() + betaB.
y()*betaB.
y() + betaB.
z()*betaB.
z()))));
5555 pos_BCM[0] = Recombearly1.at(irb)[0].boost_pos(betaB);
5556 pos_BCM[1] = Recombearly1.at(irb)[1].boost_pos(betaB);
5557 pos_BCM[2] = Recombearly1.at(irb)[2].boost_pos(betaB);
5558 p_BCM[0] = Recombearly1.at(irb)[0].boost_P(betaB);
5559 p_BCM[1] = Recombearly1.at(irb)[1].boost_P(betaB);
5560 p_BCM[2] = Recombearly1.at(irb)[2].boost_P(betaB);
5564 v_BCM[0].
Set(p_BCM[0].
x()/p_BCM[0].
t(),p_BCM[0].
y()/p_BCM[0].
t(),p_BCM[0].
z()/p_BCM[0].
t(),0.);
5565 v_BCM[1].
Set(p_BCM[1].
x()/p_BCM[1].
t(),p_BCM[1].
y()/p_BCM[1].
t(),p_BCM[1].
z()/p_BCM[1].
t(),0.);
5566 v_BCM[2].
Set(p_BCM[2].
x()/p_BCM[2].
t(),p_BCM[2].
y()/p_BCM[2].
t(),p_BCM[2].
z()/p_BCM[2].
t(),0.);
5569 double curtime = std::max(std::max(pos_BCM[0].
t(), pos_BCM[1].
t()), pos_BCM[2].
t());
5572 pos_BCM[0].
x()+v_BCM[0].
x()*(curtime-pos_BCM[0].
t()),
5573 pos_BCM[0].
y()+v_BCM[0].
y()*(curtime-pos_BCM[0].
t()),
5574 pos_BCM[0].
z()+v_BCM[0].
z()*(curtime-pos_BCM[0].
t()),
5577 pos_BCM[1].
x()+v_BCM[1].
x()*(curtime-pos_BCM[1].
t()),
5578 pos_BCM[1].
y()+v_BCM[1].
y()*(curtime-pos_BCM[1].
t()),
5579 pos_BCM[1].
z()+v_BCM[1].
z()*(curtime-pos_BCM[1].
t()),
5582 pos_BCM[2].
x()+v_BCM[2].
x()*(curtime-pos_BCM[2].
t()),
5583 pos_BCM[2].
y()+v_BCM[2].
y()*(curtime-pos_BCM[2].
t()),
5584 pos_BCM[2].
z()+v_BCM[2].
z()*(curtime-pos_BCM[2].
t()),
5590 (cur_pos[0].
x()*Recombearly1.at(irb)[0].mass()+cur_pos[1].
x()*Recombearly1.at(irb)[1].mass()+cur_pos[2].
x()*Recombearly1.at(irb)[2].mass())/(Recombearly1.at(irb)[0].mass()+Recombearly1.at(irb)[1].mass()+Recombearly1.at(irb)[2].mass()),
5591 (cur_pos[0].
y()*Recombearly1.at(irb)[0].mass()+cur_pos[1].
y()*Recombearly1.at(irb)[1].mass()+cur_pos[2].
y()*Recombearly1.at(irb)[2].mass())/(Recombearly1.at(irb)[0].mass()+Recombearly1.at(irb)[1].mass()+Recombearly1.at(irb)[2].mass()),
5592 (cur_pos[0].
z()*Recombearly1.at(irb)[0].mass()+cur_pos[1].
z()*Recombearly1.at(irb)[1].mass()+cur_pos[2].
z()*Recombearly1.at(irb)[2].mass())/(Recombearly1.at(irb)[0].mass()+Recombearly1.at(irb)[1].mass()+Recombearly1.at(irb)[2].mass()),
5596 betaB.
Set(-betaB.
x(),-betaB.
y(),-betaB.
z(),betaB.
t());
5601 pos_rel_square[0].
Set(
5602 (cur_pos[0].
x()-cur_pos[1].
x())/sqrt(2.),
5603 (cur_pos[0].
y()-cur_pos[1].
y())/sqrt(2.),
5604 (cur_pos[0].
z()-cur_pos[1].
z())/sqrt(2.),
5606 pos_rel_square[1].
Set(
5607 ((cur_pos[0].
x()*Recombearly1.at(irb)[0].mass()+cur_pos[1].
x()*Recombearly1.at(irb)[1].mass())/(Recombearly1.at(irb)[0].mass()+Recombearly1.at(irb)[1].mass())-cur_pos[2].
x())*sqrt(2./3.),
5608 ((cur_pos[0].
y()*Recombearly1.at(irb)[0].mass()+cur_pos[1].
y()*Recombearly1.at(irb)[1].mass())/(Recombearly1.at(irb)[0].mass()+Recombearly1.at(irb)[1].mass())-cur_pos[2].
y())*sqrt(2./3.),
5609 ((cur_pos[0].
z()*Recombearly1.at(irb)[0].mass()+cur_pos[1].
z()*Recombearly1.at(irb)[1].mass())/(Recombearly1.at(irb)[0].mass()+Recombearly1.at(irb)[1].mass())-cur_pos[2].
z())*sqrt(2./3.),
5617 formedhadron.
mass( p_BCM[0].
t() + p_BCM[1].
t() + p_BCM[2].
t() );
5624 sqrt(Pbaryon.
x()*Pbaryon.
x() + Pbaryon.
y()*Pbaryon.
y() + Pbaryon.
z()*Pbaryon.
z() + formedhadron.
mass()*formedhadron.
mass()));
5625 formedhadron.
pos(pos_lab);
5626 formedhadron.
P(Pbaryon);
5632 tempobject.
add(Recombearly1.at(irb)[0]);
5633 tempobject.
add(Recombearly1.at(irb)[1]);
5634 tempobject.
add(Recombearly1.at(irb)[2]);
5636 set_baryon_id(tempobject, formedhadron);
5638 formedhadron.
is_shth(thermal_parton_junction[irb]);
5641 HH_hadrons.add(formedhadron);
5646 std::vector<int> checking;
5647 bool indicecheck =
false;
5648 for (
int irem = 0; irem < SP_remnants.
num(); irem++){
5649 for(
int ijs1 = 0; ijs1 < JuncStructure.size(); ijs1++){
5650 for(
int ijs2 = 0; ijs2 < JuncStructure.at(ijs1).size(); ijs2++){
5651 for(
int ijs3 = 0; ijs3 < JuncStructure.at(ijs1).at(ijs2).size(); ijs3++){
5652 if( (SP_remnants[irem].
col() == JuncStructure.at(ijs1).at(ijs2).at(ijs3).col()) &&
5653 (SP_remnants[irem].acol() == JuncStructure.at(ijs1).at(ijs2).at(ijs3).acol()) ){
5654 SP_remnants[irem].used_junction(
true);
5655 checking.push_back(irem);
5661 for (
int irem = 0; irem < SP_remnants.
num(); irem++){
5662 for(
int icheck = 0; icheck < checking.size(); icheck++){
5663 if(irem == checking.at(icheck)){ indicecheck =
true; }
5665 if(indicecheck =
false){
5666 SP_remnants[irem].used_junction(
false);
5679 for(
int ileft = 0; ileft < SP_remnants.
num(); ileft++){
5680 if(SP_remnants[ileft].used_junction() ==
false){
5681 finalstring.push_back(SP_remnants[ileft]);
5686 for(
int itail1 = 0; itail1 < Tailoredstring1.size(); itail1++ ){
5687 for(
int itail2 = 0; itail2 < Tailoredstring1.at(itail1).size(); itail2++){
5688 finalstring.push_back(Tailoredstring1.at(itail1).at(itail2));
5706 vector<vector<HHparton>> Transitdijunction1;
5707 vector<HHparton> Transitdijunction2;
5708 vector<vector<vector<HHparton>>> Tempsorting1;
5709 vector<vector<HHparton>> Tempsorting2;
5710 vector<vector<HHparton>> Transitsinglejunction1;
5711 vector<HHparton> Transitsinglejunction2;
5712 vector<HHparton> WaitingLineforPY;
5716 for(
int dijuncfin1 = 0; dijuncfin1 < Dijunction1.size(); dijuncfin1++){
5717 for(
int dijuncfin2= 0; dijuncfin2 < 5; dijuncfin2++){
5718 if(DijunctionInfo1.at(dijuncfin1).at(dijuncfin2) == 0){
5721 fakeq.
id(1); fakeq.
set_color(Dijunction1.at(dijuncfin1).at(dijuncfin2).at(0).col());
5723 fakeq.
px(0.); fakeq.
py(0.); fakeq.
pz(0.);
5724 int endpoint = Dijunction1.at(dijuncfin1).at(dijuncfin2).size() - 1;
5725 fakeqbar.
id(-1); fakeqbar.
set_anti_color(Dijunction1.at(dijuncfin1).at(dijuncfin2).at(endpoint).acol());
5726 fakeqbar.
PY_stat(-21); fakeqbar.
mass(xmq); fakeqbar.
e(xmq); fakeqbar.
orig(-1);
5727 fakeqbar.
px(0.); fakeqbar.
py(0.); fakeqbar.
pz(0.);
5728 std::vector<HHparton>::iterator it2 = Dijunction1.at(dijuncfin1).at(dijuncfin2).begin();
5729 Dijunction1.at(dijuncfin1).at(dijuncfin2).insert(it2, fakeqbar);
5730 std::vector<HHparton>::iterator it1 = Dijunction1.at(dijuncfin1).at(dijuncfin2).begin();
5731 Dijunction1.at(dijuncfin1).at(dijuncfin2).insert(it1, fakeq);
5734 for(
int isort1 = 0; isort1 < 5; isort1++){
5735 if(DijunctionInfo1.at(dijuncfin1).at(isort1) == 1){
5736 Tempsorting2.push_back(Dijunction1.at(dijuncfin1).at(isort1));
5739 for(
int isort1 = 0; isort1 < 5; isort1++){
5740 if(DijunctionInfo1.at(dijuncfin1).at(isort1) == 0){
5741 Tempsorting2.push_back(Dijunction1.at(dijuncfin1).at(isort1));
5744 for(
int isort1 = 0; isort1 < 5; isort1++){
5745 if(DijunctionInfo1.at(dijuncfin1).at(isort1) == -1){
5746 Tempsorting2.push_back(Dijunction1.at(dijuncfin1).at(isort1));
5749 Tempsorting1.push_back(Tempsorting2);
5750 Tempsorting2.clear();
5781 for(
int itag1 = 0; itag1 < Tempsorting1.size(); itag1++){
5786 FakeBaryonElements.
add(Tempsorting1.at(itag1).at(0).back());
5787 FakeBaryonElements.
add(Tempsorting1.at(itag1).at(1).back());
5788 FakeBaryonElements.
add(Tempsorting1.at(itag1).at(2).at(0));
5791 for(
int iswap = 0; iswap < 3; iswap++){
5792 if(abs(FakeBaryonElements[2].
id()) > abs(FakeBaryonElements[1].
id())){
std::swap(FakeBaryonElements[2], FakeBaryonElements[1]) ; }
5793 if(abs(FakeBaryonElements[1].
id()) > abs(FakeBaryonElements[0].
id())){
std::swap(FakeBaryonElements[1], FakeBaryonElements[0]) ; }
5794 if(abs(FakeBaryonElements[2].
id()) > abs(FakeBaryonElements[0].
id())){
std::swap(FakeBaryonElements[2], FakeBaryonElements[0]) ; }
5797 FakeAntibaryonElements.
add(Tempsorting1.at(itag1).at(2).at(1));
5798 FakeAntibaryonElements.
add(Tempsorting1.at(itag1).at(3).back());
5799 FakeAntibaryonElements.
add(Tempsorting1.at(itag1).at(4).back());
5801 for(
int iswap = 0; iswap < 3; iswap++){
5802 if(abs(FakeAntibaryonElements[2].
id()) > abs(FakeAntibaryonElements[1].
id())){
std::swap(FakeAntibaryonElements[2], FakeAntibaryonElements[1]) ; }
5803 if(abs(FakeAntibaryonElements[1].
id()) > abs(FakeAntibaryonElements[0].
id())){
std::swap(FakeAntibaryonElements[1], FakeAntibaryonElements[0]) ; }
5804 if(abs(FakeAntibaryonElements[2].
id()) > abs(FakeAntibaryonElements[0].
id())){
std::swap(FakeAntibaryonElements[2], FakeAntibaryonElements[0]) ; }
5808 set_baryon_id(FakeBaryonElements, store_id_hadron1);
5810 set_baryon_id(FakeAntibaryonElements, store_id_hadron2);
5812 FakeBaryonElements.
clear();
5813 FakeAntibaryonElements.
clear();
5817 fakeB.
id(store_id_hadron1.
id());
5825 fakeBbar.
id(store_id_hadron2.
id());
5827 fakeBbar.
mass(3*xmq);
5833 fakeB.
PY_tag1(Tempsorting1.at(itag1).at(0).back().col());
5834 fakeB.
PY_tag2(Tempsorting1.at(itag1).at(1).back().col());
5835 fakeB.
PY_tag3(Tempsorting1.at(itag1).at(2).at(0).col());
5837 fakeBbar.
PY_tag1(Tempsorting1.at(itag1).at(2).at(1).acol());
5838 fakeBbar.
PY_tag2(Tempsorting1.at(itag1).at(3).back().acol());
5839 fakeBbar.
PY_tag3(Tempsorting1.at(itag1).at(4).back().acol());
5842 Transitdijunction2.push_back(fakeB);
5843 Transitdijunction2.push_back(fakeBbar);
5844 Transitdijunction1.push_back(Transitdijunction2);
5845 Transitdijunction2.clear();
5850 for(
int iMD1 = 0; iMD1 < Tempsorting1.size(); iMD1++){
5852 vector<HHparton> Leg1 = Tempsorting1.at(iMD1).at(0);
5853 vector<HHparton> Leg2 = Tempsorting1.at(iMD1).at(1);
5854 vector<HHparton> Leg3 = Tempsorting1.at(iMD1).at(2);
5855 vector<HHparton> Leg4 = Tempsorting1.at(iMD1).at(3);
5856 vector<HHparton> Leg5 = Tempsorting1.at(iMD1).at(4);
5858 for(
int ileg1 = 0; ileg1 < Leg1.size(); ileg1++){
5859 Leg1.at(ileg1).PY_par1(0);
5860 Leg1.at(ileg1).PY_par2(0);
5861 Transitdijunction1.at(iMD1).push_back(Leg1.at(ileg1));
5863 for(
int ileg2 = 0; ileg2 < Leg2.size(); ileg2++){
5864 Leg2.at(ileg2).PY_par1(0);
5865 Leg2.at(ileg2).PY_par2(0);
5866 Transitdijunction1.at(iMD1).push_back(Leg2.at(ileg2));
5869 Intag = 2 + Leg1.size() + Leg2.size();
5871 Leg3.at(0).PY_par1(0);
5872 Leg3.at(0).PY_par2(0);
5873 Leg3.at(0).PY_dau1(Intag + Leg4.size() + Leg5.size() + 2);
5874 Leg3.at(0).PY_dau2(Intag + Leg4.size() + Leg5.size() + Leg3.size()- 1);
5875 Leg3.at(1).PY_par1(1);
5876 Leg3.at(1).PY_par2(1);
5877 Leg3.at(1).PY_dau1(Intag + Leg4.size() + Leg5.size() + 2);
5878 Leg3.at(1).PY_dau2(Intag + Leg4.size() + Leg5.size() + Leg3.size()- 1);
5880 Transitdijunction1.at(iMD1).push_back(Leg3.at(0));
5881 Transitdijunction1.at(iMD1).push_back(Leg3.at(1));
5883 Transitdijunction1.at(iMD1).at(0).PY_dau1(2);
5884 Transitdijunction1.at(iMD1).at(0).PY_dau2(Intag);
5885 Transitdijunction1.at(iMD1).at(1).PY_dau1(Intag + 1);
5886 Transitdijunction1.at(iMD1).at(1).PY_dau2(Intag + 1 + Leg4.size() + Leg5.size() );
5888 for(
int ileg4 = 0 ; ileg4 < Leg4.size(); ileg4++){
5889 Leg4.at(ileg4).PY_par1(1);
5890 Leg4.at(ileg4).PY_par2(1);
5891 Transitdijunction1.at(iMD1).push_back(Leg4.at(ileg4));
5893 for(
int ileg5 = 0 ; ileg5 < Leg5.size(); ileg5++){
5894 Leg5.at(ileg5).PY_par1(1);
5895 Leg5.at(ileg5).PY_par2(1);
5896 Transitdijunction1.at(iMD1).push_back(Leg5.at(ileg5));
5898 for(
int ileg3 = 2; ileg3 < Leg3.size(); ileg3++){
5899 Leg3.at(ileg3).PY_par1(Intag);
5900 Leg3.at(ileg3).PY_par2(Intag + 1);
5901 Transitdijunction1.at(iMD1).push_back(Leg3.at(ileg3));
5916 for(
int iSJ = 0; iSJ < Singlejunction1.size(); iSJ++){
5920 HHparton q1 = Singlejunction1.at(iSJ).at(0).back();
5921 HHparton q2 = Singlejunction1.at(iSJ).at(1).back();
5922 HHparton q3 = Singlejunction1.at(iSJ).at(2).back();
5928 FakeBaryonElements.
add(q1fin);
5929 FakeBaryonElements.
add(q2fin);
5930 FakeBaryonElements.
add(q3fin);
5933 for(
int iswap = 0; iswap < 3; iswap++){
5934 if(abs(FakeBaryonElements[2].
id()) > abs(FakeBaryonElements[1].
id())){
std::swap(FakeBaryonElements[2], FakeBaryonElements[1]) ; }
5935 if(abs(FakeBaryonElements[1].
id()) > abs(FakeBaryonElements[0].
id())){
std::swap(FakeBaryonElements[1], FakeBaryonElements[0]) ; }
5936 if(abs(FakeBaryonElements[2].
id()) > abs(FakeBaryonElements[0].
id())){
std::swap(FakeBaryonElements[2], FakeBaryonElements[0]) ; }
5940 set_baryon_id(FakeBaryonElements, store_id_hadron1);
5942 int m_id = store_id_hadron1.
id();
5943 if((q1.
id() < 0 && m_id > 0) || (q1.
id() > 0 && m_id < 0)){
5948 fakeB.
id(m_id); fakeB.
PY_stat(-11); fakeB.
mass(3*xmq); fakeB.
e(3*xmq);
5949 fakeB.
px(0.); fakeB.
py(0.); fakeB.
pz(0.);
5952 Transitsinglejunction2.push_back(fakeB);
5953 Transitsinglejunction1.push_back(Transitsinglejunction2);
5954 Transitsinglejunction2.clear();
5957 for(
int iSJ = 0; iSJ < Singlejunction1.size(); iSJ++){
5958 vector<HHparton> Leg1 = Singlejunction1.at(iSJ).at(0);
5959 vector<HHparton> Leg2 = Singlejunction1.at(iSJ).at(1);
5960 vector<HHparton> Leg3 = Singlejunction1.at(iSJ).at(2);
5962 for(
int ileg1 = 0; ileg1 < Leg1.size(); ileg1++ ){
5963 Leg1.at(ileg1).PY_par1(0);
5964 Leg1.at(ileg1).PY_par2(0);
5965 Transitsinglejunction1.at(iSJ).push_back(Leg1.at(ileg1));
5967 for(
int ileg2 = 0; ileg2 < Leg2.size(); ileg2++ ){
5968 Leg2.at(ileg2).PY_par1(0);
5969 Leg2.at(ileg2).PY_par2(0);
5970 Transitsinglejunction1.at(iSJ).push_back(Leg2.at(ileg2));
5972 for(
int ileg3 = 0; ileg3 < Leg3.size(); ileg3++ ){
5973 Leg3.at(ileg3).PY_par1(0);
5974 Leg3.at(ileg3).PY_par2(0);
5975 Transitsinglejunction1.at(iSJ).push_back(Leg3.at(ileg3));
5977 Transitsinglejunction1.at(iSJ).at(0).PY_dau1(1);
5978 Transitsinglejunction1.at(iSJ).at(0).PY_dau2(Leg1.size() + Leg2.size() + Leg3.size());
6004 for(
int itd1 = 0; itd1 < Transitdijunction1.size(); itd1++){
6013 bool EP_conserved =
false;
6014 while(!EP_conserved){
6015 EP_conserved =
true;
6016 for(
int i=0;
i<Transitdijunction1.at(itd1).size(); ++
i){
6017 if(Transitdijunction1[itd1][
i].PY_stat() >= 0 && std::abs(Transitdijunction1[itd1][
i].
id()) < 1000){
6022 int jmax = (Transitdijunction1[itd1][
i].PY_dau2() > Transitdijunction1[itd1][
i].PY_dau1()) ? Transitdijunction1[itd1][
i].PY_dau2() : Transitdijunction1[itd1][
i].PY_dau1();
6024 for(
int j=Transitdijunction1[itd1][
i].PY_dau1();
j<jmax+1; ++
j){
6025 double n =
double(
j-Transitdijunction1[itd1][
i].PY_dau1())+1.;
6030 P_new.
x()+Transitdijunction1[itd1][
j].px(),
6031 P_new.
y()+Transitdijunction1[itd1][
j].py(),
6032 P_new.
z()+Transitdijunction1[itd1][
j].pz(),
6033 P_new.
t()+Transitdijunction1[itd1][
j].e());
6035 pos_new.
x()+(Transitdijunction1[itd1][
j].x()-pos_new.
x())/n,
6036 pos_new.
y()+(Transitdijunction1[itd1][
j].y()-pos_new.
y())/n,
6037 pos_new.
z()+(Transitdijunction1[itd1][
j].z()-pos_new.
z())/n,
6038 pos_new.
t()+(Transitdijunction1[itd1][
j].x_t()-pos_new.
t())/n);
6042 if((dif2(P_new,Transitdijunction1[itd1][
i].
P())+(P_new.
t()-Transitdijunction1[itd1][
i].e())*(P_new.
t()-Transitdijunction1[itd1][
i].e()) > 0.00000001) ||
6043 (dif2(pos_new,Transitdijunction1[itd1][
i].
pos())+(pos_new.
t()-Transitdijunction1[itd1][
i].x_t())*(pos_new.
t()-Transitdijunction1[itd1][
i].x_t()) > 0.00000001)){
6044 Transitdijunction1[itd1][
i].P(P_new);
6045 Transitdijunction1[itd1][
i].pos(pos_new);
6046 Transitdijunction1[itd1][
i].mass(
6047 Transitdijunction1[itd1][
i].
e()*Transitdijunction1[itd1][
i].
e()
6048 - Transitdijunction1[itd1][
i].px()*Transitdijunction1[itd1][
i].px()
6049 - Transitdijunction1[itd1][
i].py()*Transitdijunction1[itd1][
i].py()
6050 - Transitdijunction1[itd1][
i].pz()*Transitdijunction1[itd1][
i].pz());
6051 Transitdijunction1[itd1][
i].mass( (Transitdijunction1[itd1][
i].
mass() >= 0.) ? sqrt(Transitdijunction1[itd1][
i].
mass()) : -sqrt(-Transitdijunction1[itd1][
i].
mass()) );
6052 EP_conserved =
false;
6056 for(
int i=0;
i<Transitdijunction1.at(itd1).size(); ++
i){
6057 if((Transitdijunction1[itd1][
i].PY_stat() == -21)){
6058 Transitdijunction1[itd1][
i].px(Transitdijunction1[itd1][
i].px()/2.);
6059 Transitdijunction1[itd1][
i].py(Transitdijunction1[itd1][
i].py()/2.);
6060 Transitdijunction1[itd1][
i].pz(Transitdijunction1[itd1][
i].pz()/2.);
6061 Transitdijunction1[itd1][
i].e( Transitdijunction1[itd1][
i].
e() /2.);
6062 Transitdijunction1[itd1][
i].mass(Transitdijunction1[itd1][
i].
mass()/2.);
6077 for(
int its1 = 0; its1 < Transitsinglejunction1.size(); its1++){
6078 bool EP_conserved =
false;
6079 while(!EP_conserved){
6080 EP_conserved =
true;
6081 for(
int i=0;
i<Transitsinglejunction1.at(its1).size(); ++
i){
6082 if(Transitsinglejunction1[its1][
i].PY_stat() >= 0 && std::abs(Transitsinglejunction1[its1][
i].
id()) < 1000){
continue;}
6084 int jmax = (Transitsinglejunction1[its1][
i].PY_dau2() > Transitsinglejunction1[its1][
i].PY_dau1()) ? Transitsinglejunction1[its1][
i].PY_dau2() : Transitsinglejunction1[its1][
i].PY_dau1();
6085 for(
int j=Transitsinglejunction1[its1][
i].PY_dau1();
j<jmax+1; ++
j){
6086 double n =
double(
j-Transitsinglejunction1[its1][
i].PY_dau1())+1.;
6087 P_new.
Set(P_new.
x()+Transitsinglejunction1[its1][
j].px(),P_new.
y()+Transitsinglejunction1[its1][
j].py(),P_new.
z()+Transitsinglejunction1[its1][
j].pz(),P_new.
t()+Transitsinglejunction1[its1][
j].e());
6088 pos_new.
Set(pos_new.
x()+(Transitsinglejunction1[its1][
j].x()-pos_new.
x())/n,pos_new.
y()+(Transitsinglejunction1[its1][
j].y()-pos_new.
y())/n,pos_new.
z()+(Transitsinglejunction1[its1][
j].z()-pos_new.
z())/n,pos_new.
t()+(Transitsinglejunction1[its1][
j].x_t()-pos_new.
t())/n);
6090 if((dif2(P_new,Transitsinglejunction1[its1][
i].
P())+(P_new.
t()-Transitsinglejunction1[its1][
i].e())*(P_new.
t()-Transitsinglejunction1[its1][
i].e()) > 0.00000001) ||
6091 (dif2(pos_new,Transitsinglejunction1[its1][
i].
pos())+(pos_new.
t()-Transitsinglejunction1[its1][
i].x_t())*(pos_new.
t()-Transitsinglejunction1[its1][
i].x_t()) > 0.00000001)){
6092 Transitsinglejunction1[its1][
i].P(P_new); Transitsinglejunction1[its1][
i].pos(pos_new);
6093 Transitsinglejunction1[its1][
i].mass( Transitsinglejunction1[its1][
i].
e()*Transitsinglejunction1[its1][
i].
e()
6094 - Transitsinglejunction1[its1][
i].px()*Transitsinglejunction1[its1][
i].px() - Transitsinglejunction1[its1][
i].py()*Transitsinglejunction1[its1][
i].py() - Transitsinglejunction1[its1][
i].pz()*Transitsinglejunction1[its1][
i].pz() );
6095 Transitsinglejunction1[its1][
i].mass( (Transitsinglejunction1[its1][
i].
mass() >= 0.) ? sqrt(Transitsinglejunction1[its1][
i].
mass()) : -sqrt(-Transitsinglejunction1[its1][
i].
mass()) );
6096 EP_conserved =
false;
6100 for(
int i=0;
i<Transitsinglejunction1.at(its1).size(); ++
i){
6101 if((Transitsinglejunction1[its1][
i].PY_stat() == -21)){
6102 Transitsinglejunction1[its1][
i].px(Transitsinglejunction1[its1][
i].px()/2.);
6103 Transitsinglejunction1[its1][
i].py(Transitsinglejunction1[its1][
i].py()/2.);
6104 Transitsinglejunction1[its1][
i].pz(Transitsinglejunction1[its1][
i].pz()/2.);
6105 Transitsinglejunction1[its1][
i].e( Transitsinglejunction1[its1][
i].
e() /2.);
6106 Transitsinglejunction1[its1][
i].mass(Transitsinglejunction1[its1][
i].
mass()/2.);
6113 for(
int itagdij1 = 0; itagdij1 < Transitdijunction1.size(); itagdij1++ ){
6114 double baryon_mass_scaling = 1.25;
6115 double mass_baryons = Transitdijunction1.at(itagdij1).at(0).mass() + Transitdijunction1.at(itagdij1).at(1).mass();
6116 double m1 = pythia.particleData.m0(std::abs(Transitdijunction1.at(itagdij1).at(0).id()));
6117 double m2 = pythia.particleData.m0(std::abs(Transitdijunction1.at(itagdij1).at(1).id()));
6118 if(mass_baryons < baryon_mass_scaling*(m1+m2)){
6120 double new_gluon_mass = 2.*xmq;
6121 for(
int itagdij2 = 0; itagdij2 < Transitdijunction1.at(itagdij1).size(); itagdij2++){
6122 HHparton p = Transitdijunction1.at(itagdij1).at(itagdij2);
6124 new_gluon_mass = p.
mass()+baryon_mass_scaling*(m1+
m2)-mass_baryons;
6125 p.
mass(new_gluon_mass);
6126 double energy_new = std::sqrt(p.
px()*p.
px() + p.
py()*p.
py() + p.
pz()*p.
pz() + p.
mass()*p.
mass());
6128 Transitdijunction1.at(itagdij1).at(itagdij2).mass(p.
mass());
6129 Transitdijunction1.at(itagdij1).at(itagdij2).e(p.
e());
6133 for(
int itagdij2 = 0; itagdij2 < Transitdijunction1.at(itagdij1).size(); itagdij2++){
6134 HHparton p = Transitdijunction1.at(itagdij1).at(itagdij2);
6135 if(p.
PY_stat() == -21 && std::abs(p.
id()) < 6){
6136 p.
mass(new_gluon_mass/2.);
6137 double energy_new = std::sqrt(p.
px()*p.
px() + p.
py()*p.
py() + p.
pz()*p.
pz() + p.
mass()*p.
mass());
6140 if(p.
PY_stat() == -11 && std::abs(p.
id()) > 1000){
6141 p.
mass(p.
mass()+(baryon_mass_scaling*(m1+
m2)-mass_baryons)/2.);
6142 double energy_new = std::sqrt(p.
px()*p.
px() + p.
py()*p.
py() + p.
pz()*p.
pz() + p.
mass()*p.
mass());
6149 for(
int itagdij1 = 0; itagdij1 < Transitdijunction1.size(); itagdij1++ ){
6150 for(
int itagdij2 = 0; itagdij2 < Transitdijunction1.at(itagdij1).size(); itagdij2++){
6151 WaitingLineforPY.push_back(Transitdijunction1.at(itagdij1).at(itagdij2));
6169 for(
int itagsj1 = 0; itagsj1 < Transitsinglejunction1.size(); itagsj1++ ){
6170 double baryon_mass_scaling = 1.15;
6171 double mass_baryon = Transitsinglejunction1.at(itagsj1).at(0).mass();
6172 double m1 = pythia.particleData.m0(std::abs(Transitsinglejunction1.at(itagsj1).at(0).id()));
6174 if(mass_baryon < baryon_mass_scaling*m1){
6175 double baryon_mass_correction = baryon_mass_scaling*m1-mass_baryon;
6176 for(
int itagsj2 = 0; itagsj2 < Transitsinglejunction1.at(itagsj1).size(); itagsj2++){
6177 if(std::abs(Transitsinglejunction1.at(itagsj1).at(itagsj2).id()) < 6){
6178 HHparton p = Transitsinglejunction1.at(itagsj1).at(itagsj2);
6179 p.
mass(p.
mass()+baryon_mass_correction/3.);
6180 double energy_new = std::sqrt(p.
px()*p.
px() + p.
py()*p.
py() + p.
pz()*p.
pz() + p.
mass()*p.
mass());
6182 Transitsinglejunction1.at(itagsj1).at(itagsj2).mass(p.
mass());
6183 Transitsinglejunction1.at(itagsj1).at(itagsj2).e(p.
e());
6187 HHparton p = Transitsinglejunction1.at(itagsj1).at(0);
6188 p.
mass(baryon_mass_scaling*m1);
6189 double energy_new = std::sqrt(p.
px()*p.
px() + p.
py()*p.
py() + p.
pz()*p.
pz() + p.
mass()*p.
mass());
6191 Transitsinglejunction1.at(itagsj1).at(0).mass(p.
mass());
6192 Transitsinglejunction1.at(itagsj1).at(0).e(p.
e());
6197 for(
int itagsj1 = 0; itagsj1 < Transitsinglejunction1.size(); itagsj1++ ){
6198 for(
int itagsj2 = 0; itagsj2 < Transitsinglejunction1.at(itagsj1).size(); itagsj2++){
6199 WaitingLineforPY.push_back(Transitsinglejunction1.at(itagsj1).at(itagsj2));
6207 for(
int ifins = 0; ifins < finalstring.size(); ifins++){
6208 WaitingLineforPY.push_back(finalstring.at(ifins));
6219 for(
int ifin = 0; ifin < WaitingLineforPY.size(); ifin++){
6220 SP_prepremn.
add(WaitingLineforPY[ifin]);
6223 Tempjunctions.clear();
6224 JuncStructure.clear();
6225 realjuncindice.clear();
6226 IMStructure1.clear();
6227 Dijunction1.clear();
6228 DijunctionInfo1.clear();
6229 Recombearly1.clear();
6230 Tailoredstring1.clear();
6231 finalstring.clear();
6232 Transitdijunction1.clear();
6233 Transitsinglejunction1.clear();
6234 WaitingLineforPY.clear();
6235 Tempsorting1.clear();
6241 Event&
event = pythia.event;
6244 if(HH_pyremn.num() + HH_hadrons.num() == 0){
return true;}
6248 for(
int i=0;
i<HH_pyremn.num(); ++
i){
6249 HH_pyremn[
i].PY_par1(HH_pyremn[
i].PY_par1()+1); HH_pyremn[
i].PY_par2(HH_pyremn[
i].PY_par2()+1);
6250 HH_pyremn[
i].PY_dau1(HH_pyremn[
i].PY_dau1()+1); HH_pyremn[
i].PY_dau2(HH_pyremn[
i].PY_dau2()+1);
6251 if(HH_pyremn[
i].PY_origid() != 0) {HH_pyremn[
i].id( HH_pyremn[
i].PY_origid());}
6254 bool need_hadronization =
true;
bool success =
true;
6256 while(need_hadronization){
6262 HH_pythia_hadrons.clear();
6268 std::vector<int> eve_to_had; eve_to_had.push_back(0);
6278 for(
int i=0;
i<HH_pyremn.num(); ++
i){
6281 if(abs(HH_pyremn[
i].
id()) > 1112 && HH_pyremn[
i].PY_tag1() !=0 && HH_pyremn[
i].PY_tag2() !=0 && HH_pyremn[
i].PY_tag3() !=0) {
6285 if((dijuncflag == 1 && abs(HH_pyremn[
i].
id())<100 && HH_pyremn[
i].PY_par1() == 0 && HH_pyremn[
i].PY_par2() == 0)
6286 || (dijuncflag == 2 && abs(HH_pyremn[
i-1].
id()) < 100)) {
6287 size_input =
event.size()-1;
6290 case1 &= pythia.next();
6292 set_spacetime_for_pythia_hadrons(
event,size_input,eve_to_had,attempt,case1,
false,
false);
6295 if(dijuncflag == 1){dijuncflag=0;}
6296 if(dijuncflag == 2){dijuncflag=1;}
6299 if(dijuncflag == 2) {
6300 if(abs(HH_pyremn[
i-1].
id())>1112){dijuncflag=3;}
6301 else{dijuncflag = 1;}
6305 if(dijuncflag == 4 || (HH_pyremn[
i].PY_par1() == 0 && HH_pyremn[
i].PY_par2() == 0 && HH_pyremn[
i].PY_dau1() == 0 && HH_pyremn[
i].PY_dau2() == 0 && dijuncflag == 3)) {
6307 size_input =
event.size()-1;
6310 case2 &= pythia.next();
6312 set_spacetime_for_pythia_hadrons(
event,size_input,eve_to_had,attempt,case2,
false,
false);
6315 if(dijuncflag == 4){dijuncflag=1;}
else{dijuncflag=0;}
6319 event.append(HH_pyremn[
i].
id(),HH_pyremn[
i].PY_stat(),HH_pyremn[
i].PY_par1(),HH_pyremn[
i].PY_par2(),HH_pyremn[
i].PY_dau1(),HH_pyremn[
i].PY_dau2(),
6320 HH_pyremn[
i].
col(),HH_pyremn[
i].acol(),HH_pyremn[
i].px(),HH_pyremn[
i].py(),HH_pyremn[
i].pz(),HH_pyremn[
i].
e(),HH_pyremn[
i].
mass());
6323 event[
event.size()-1].vProd(HH_pyremn[
i].
x(), HH_pyremn[
i].
y(), HH_pyremn[
i].
z(), HH_pyremn[
i].x_t());
6325 if(std::abs(
event[
event.size()-1].id()) > 1112){
6326 event.appendJunction(((
event[
event.size()-1].id()>0) ? 1 : 2), HH_pyremn[
i].PY_tag1(), HH_pyremn[
i].PY_tag2(), HH_pyremn[
i].PY_tag3());
6328 eve_to_had.push_back(-
i-1);
6331 size_input =
event.size()-1;
6336 case3 &= pythia.next();
6338 set_spacetime_for_pythia_hadrons(
event,size_input,eve_to_had,attempt,case3,
false,
false);
6345 if(reco_hadrons_pythia){
6347 for(
int i=0;
i<HH_hadrons.num(); ++
i){
6348 if(HH_hadrons[
i].is_final() && HH_hadrons[
i].is_recohad() && HH_hadrons[
i].is_shsh()){
6350 double massnow = HH_hadrons[
i].e()*HH_hadrons[
i].e() -
6351 (HH_hadrons[
i].px()*HH_hadrons[
i].px() + HH_hadrons[
i].py()*HH_hadrons[
i].py() + HH_hadrons[
i].pz()*HH_hadrons[
i].pz());
6352 massnow = (massnow >= 0.) ? sqrt(massnow) : -sqrt(-massnow);
6353 event.append(HH_hadrons[
i].
id(),81,0,0,HH_hadrons[
i].px(),HH_hadrons[
i].py(),HH_hadrons[
i].pz(),HH_hadrons[
i].
e(),massnow);
6354 event[
event.size()-1].vProd(HH_hadrons[
i].
x(), HH_hadrons[
i].
y(), HH_hadrons[
i].
z(), HH_hadrons[
i].x_t());
6355 eve_to_had.push_back(
i+1);
6358 case4 &= pythia.next();
6359 set_spacetime_for_pythia_hadrons(
event,size_input,eve_to_had,attempt,case4,
true,
true);
6363 for(
int i=0;
i<HH_hadrons.num(); ++
i){
6364 if(HH_hadrons[
i].is_final() && HH_hadrons[
i].is_recohad() && HH_hadrons[
i].is_shth()){
6366 double massnow = HH_hadrons[
i].e()*HH_hadrons[
i].e() -
6367 (HH_hadrons[
i].px()*HH_hadrons[
i].px() + HH_hadrons[
i].py()*HH_hadrons[
i].py() + HH_hadrons[
i].pz()*HH_hadrons[
i].pz());
6368 massnow = (massnow >= 0.) ? sqrt(massnow) : -sqrt(-massnow);
6369 event.append(HH_hadrons[
i].
id(),81,0,0,HH_hadrons[
i].px(),HH_hadrons[
i].py(),HH_hadrons[
i].pz(),HH_hadrons[
i].
e(),massnow);
6370 event[
event.size()-1].vProd(HH_hadrons[
i].
x(), HH_hadrons[
i].
y(), HH_hadrons[
i].
z(), HH_hadrons[
i].x_t());
6371 eve_to_had.push_back(
i+1);
6374 case5 &= pythia.next();
6375 set_spacetime_for_pythia_hadrons(
event,size_input,eve_to_had,attempt,case5,
true,
false);
6379 for(
int i=0;
i<HH_hadrons.num(); ++
i){
6380 if(HH_hadrons[
i].is_final() && !HH_hadrons[
i].is_recohad()){
6382 double massnow = HH_hadrons[
i].e()*HH_hadrons[
i].e() -
6383 (HH_hadrons[
i].px()*HH_hadrons[
i].px() + HH_hadrons[
i].py()*HH_hadrons[
i].py() + HH_hadrons[
i].pz()*HH_hadrons[
i].pz());
6384 massnow = (massnow >= 0.) ? sqrt(massnow) : -sqrt(-massnow);
6385 event.append(HH_hadrons[
i].
id(),81,0,0,HH_hadrons[
i].px(),HH_hadrons[
i].py(),HH_hadrons[
i].pz(),HH_hadrons[
i].
e(),massnow);
6386 event[
event.size()-1].vProd(HH_hadrons[
i].
x(), HH_hadrons[
i].
y(), HH_hadrons[
i].
z(), HH_hadrons[
i].x_t());
6387 eve_to_had.push_back(
i+1);
6390 case6 &= pythia.next();
6391 set_spacetime_for_pythia_hadrons(
event,size_input,eve_to_had,attempt,case6,
false,
false);
6396 if(!case1 || !case2 || !case3 || !case4 || !case5 || !case6){
6397 if(attempt > 4){need_hadronization =
false; success =
false;
break;}
6402 need_hadronization =
false;
6409 if(!find_positions) {
6413 vector<HHhadron> final_hadrons_from_pythia;
6415 vector<int> Case1_hadron_idx;
6416 vector<int> Case1_parton1_idx;
6417 vector<int> Case1_parton2_idx;
6419 vector<int> Case2_hadron_idx;
6420 vector<int> Case2_parton1_idx;
6421 vector<int> Case2_parton2_idx;
6422 vector<int> Case2_parton3_idx;
6423 vector<double> Case2_junction_center;
6427 vector<int> Case3_hadron_idx;
6428 vector<int> Case3_parton1_idx;
6429 vector<int> Case3_parton2_idx;
6430 vector<double> Case3_partons_center;
6432 bool compute_more_precise_positions =
true;
6433 bool warn_could_not_find_positions =
false;
6435 for(
int hadron_idx = 1; hadron_idx <
event.size(); hadron_idx++) {
6436 if(event[hadron_idx].isFinal()) {
6440 hadron_out.
id(event[hadron_idx].
id());
6441 hadron_out.
mass(event[hadron_idx].
m());
6442 hadron_out.
px(event[hadron_idx].px());
6443 hadron_out.
py(event[hadron_idx].py());
6444 hadron_out.
pz(event[hadron_idx].pz());
6445 hadron_out.
e(event[hadron_idx].
e());
6449 std::vector<int> mothers;
6451 std::vector<int> stack;
6453 if((event[hadron_idx].mother1() < event[hadron_idx].mother2()) && (event[hadron_idx].mother1() > 0)
6454 && (std::abs(event[hadron_idx].
status()) >= 81) && (std::abs(event[hadron_idx].
status()) <= 86)){
6455 for(
int hadron_parent = event[hadron_idx].mother1(); hadron_parent <=
event[hadron_idx].mother2(); ++hadron_parent) {
6456 stack.push_back(hadron_parent);
6458 }
else if((event[hadron_idx].mother2() > 0) && (event[hadron_idx].mother1() != event[hadron_idx].mother2())) {
6459 stack.push_back(event[hadron_idx].mother1());
6460 stack.push_back(event[hadron_idx].mother2());
6461 }
else if(event[hadron_idx].mother1() > 0) {
6462 stack.push_back(event[hadron_idx].mother1());
6463 }
else{mothers.push_back(hadron_idx);}
6467 while(stack.size() > 0){
6468 int current = stack.back();
6470 if((event[current].mother1() < event[current].mother2()) && (event[current].mother1() > 0) &&
6471 (std::abs(event[current].
status()) >= 81) && (std::abs(event[current].
status()) <= 86)) {
6472 for(
int hadron_parent = event[current].mother1(); hadron_parent <=
event[current].mother2(); ++hadron_parent) {
6473 stack.push_back(hadron_parent);
6475 }
else if((event[current].mother2() > 0) && (event[current].mother1() != event[current].mother2())) {
6476 stack.push_back(event[current].mother1());
6477 stack.push_back(event[current].mother2());
6478 }
else if(event[current].mother1() > 0) {
6479 stack.push_back(event[current].mother1());
6481 if((current > 0) && (current <= size_input)) {mothers.push_back(current);}
6485 if(mothers.size() == 0) {mothers.push_back(hadron_idx);}
6488 std::sort(mothers.begin(), mothers.end());
6489 mothers.erase(std::unique(mothers.begin(), mothers.end()), mothers.end());
6492 if(mothers[0] <= HH_pyremn.num()){
6499 bool is_therm(
false);
6500 for(
int hadron_parent = 0; hadron_parent < mothers.size(); ++hadron_parent) {
6501 if(mothers[hadron_parent] <= HH_pyremn.num()) {
6502 if(HH_pyremn[mothers[hadron_parent]-1].orig() != -1) {
6503 hadron_out.
add_par(mothers[hadron_parent]-1);
6504 if(HH_pyremn[mothers[hadron_parent]-1].is_thermal()) {is_therm =
true;}
6506 }
else if(mothers[hadron_parent] < size_input){
6507 hadron_out.
parh(eve_to_had[mothers[hadron_parent]]-1);
6508 if(HH_hadrons[hadron_out.
parh()].is_shth()) {is_therm =
true;}
6517 if(is_recohadron && recohadron_shsh){
6521 }
else if(is_recohadron && !recohadron_shsh){
6527 int hadron_col =
event[hadron_idx].col();
6528 int hadron_acol =
event[hadron_idx].acol();
6529 bool info_found =
false;
bool col_known =
false;
bool acol_known =
false;
6532 if(hadron_col != hadron_acol) {
6533 for(
int irem = 0; irem < HH_pyremn.num(); ++irem) {
6534 if(((HH_pyremn[irem].
col() == hadron_col) && (HH_pyremn[irem].acol() == hadron_acol))
6535 || ((HH_pyremn[irem].col() == hadron_acol) && (HH_pyremn[irem].acol() == hadron_col))) {
6536 if(HH_pyremn[irem].PY_stat()<=0) {
continue;}
6537 hadron_out.
x(HH_pyremn[irem].
x());
6538 hadron_out.
y(HH_pyremn[irem].
y());
6539 hadron_out.
z(HH_pyremn[irem].
z());
6540 hadron_out.
x_t(HH_pyremn[irem].x_t());
6551 int ptn1 = -1;
int ptn2 = -1;
6552 for(
int irem = 0; irem < HH_pyremn.num(); ++irem) {
6553 if((HH_pyremn[irem].
col() == hadron_col) && (HH_pyremn[irem].PY_stat() > 0)) {ptn1 = irem;}
6554 if((HH_pyremn[irem].acol() == hadron_acol) && (HH_pyremn[irem].PY_stat() > 0)) {ptn2 = irem;}
6555 if((ptn1 >= 0) && (ptn2 >= 0)){
break;}
6560 if((ptn1 >= 0) && (ptn2 >= 0)){
6562 double pos_x, pos_y, pos_z, pos_t; pos_x = 0.; pos_y = 0.; pos_z = 0.; pos_t = 0.;
6563 pos_x += HH_pyremn[ptn1].x(); pos_y += HH_pyremn[ptn1].y(); pos_z += HH_pyremn[ptn1].z(); pos_t += HH_pyremn[ptn1].x_t();
6564 pos_x += HH_pyremn[ptn2].x(); pos_y += HH_pyremn[ptn2].y(); pos_z += HH_pyremn[ptn2].z(); pos_t += HH_pyremn[ptn2].x_t();
6565 pos_x /= 2.; pos_y /= 2.; pos_z /= 2.; pos_t /= 2.;
6566 hadron_out.
x(pos_x); hadron_out.
y(pos_y); hadron_out.
z(pos_z); hadron_out.
x_t(pos_t);
6568 Case1_hadron_idx.push_back(hadron_idx);
6569 Case1_parton1_idx.push_back(ptn1);
6570 Case1_parton2_idx.push_back(ptn2);
6573 }
else if((hadron_col == hadron_acol) && (hadron_col != 0)) {
6575 int ptn1 = 0;
int ptn2 = 0;
int ptn3 = 0;
6576 bool col_found =
false;
bool acol_found =
false;
bool ptn3_found =
false;
6577 while(ptn1 < HH_pyremn.num()) {
if((HH_pyremn[ptn1].
col() == hadron_col) && (HH_pyremn[ptn1].PY_stat() > 0)) {col_found =
true;
break;} ++ptn1;}
6578 while(ptn2 < HH_pyremn.num()) {
if((HH_pyremn[ptn2].acol() == hadron_acol)&& (HH_pyremn[ptn2].PY_stat() > 0)) {acol_found=
true;
break;} ++ptn2;}
6580 col_known = col_found; acol_known = acol_found;
6589 int coll[2] = {0,0};
6590 for(
int iJ = 0; iJ < pythia.event.sizeJunction(); ++iJ) {
6591 for(
int iC = 0; iC < 3; ++iC) {
6592 if(pythia.event.colJunction(iJ,iC) == hadron_col) {
6593 if(iC == 0) {coll[0] = pythia.event.colJunction(iJ,1); coll[1] = pythia.event.colJunction(iJ,2);}
6594 else if(iC == 1) {coll[0] = pythia.event.colJunction(iJ,0); coll[1] = pythia.event.colJunction(iJ,2);}
6595 else{coll[0] = pythia.event.colJunction(iJ,0); coll[1] = pythia.event.colJunction(iJ,1);}
6596 col_found=
true;
break;
6599 if(col_found) {
break;}
6603 for(
int irem = 0; irem < HH_pyremn.num(); ++irem) {
6604 if(std::abs(HH_pyremn[irem].
id()) > 1112) {
6605 if( HH_pyremn[irem].PY_tag1() == hadron_col) {coll[0] = HH_pyremn[irem].PY_tag2(); coll[1] = HH_pyremn[irem].PY_tag3(); col_found =
true;
break;}
6606 else if(HH_pyremn[irem].PY_tag2() == hadron_col) {coll[0] = HH_pyremn[irem].PY_tag1(); coll[1] = HH_pyremn[irem].PY_tag3(); col_found =
true;
break;}
6607 else if(HH_pyremn[irem].PY_tag3() == hadron_col) {coll[0] = HH_pyremn[irem].PY_tag1(); coll[1] = HH_pyremn[irem].PY_tag2(); col_found =
true;
break;}
6613 bool found_tags[2] = {0,0}; ptn1 = 0;
6614 while(ptn1<HH_pyremn.num()) {
if((HH_pyremn[ptn1].acol() == coll[0]) && (HH_pyremn[ptn1].PY_stat() > 0)) {found_tags[0] =
true;
break;} ++ptn1;}
6615 while(ptn3<HH_pyremn.num()) {
if((HH_pyremn[ptn3].acol() == coll[1]) && (HH_pyremn[ptn2].PY_stat() > 0)) {found_tags[1] =
true;
break;} ++ptn3;}
6616 if(found_tags[0] && found_tags[1]) {ptn3_found =
true;}
6621 if(ptn3_found) {
JSWARN <<
"A hadron was found with more than 3 partonic parents for space-time info!";}
6623 int coll[2] = {0,0};
6624 for(
int iJ = 0; iJ < pythia.event.sizeJunction(); ++iJ) {
6625 for(
int iC = 0; iC < 3; ++iC) {
6626 if(pythia.event.colJunction(iJ,iC) == hadron_acol) {
6627 if(iC == 0) {coll[0] = pythia.event.colJunction(iJ,1); coll[1] = pythia.event.colJunction(iJ,2);}
6628 else if(iC == 1) {coll[0] = pythia.event.colJunction(iJ,0); coll[1] = pythia.event.colJunction(iJ,2);}
6629 else{coll[0] = pythia.event.colJunction(iJ,0); coll[1] = pythia.event.colJunction(iJ,1);}
6630 acol_found =
true;
break;
6633 if(acol_found) {
break;}
6637 for(
int irem = 0; irem < HH_pyremn.num(); ++irem) {
6638 if(std::abs(HH_pyremn[irem].
id()) > 1112) {
6639 if( HH_pyremn[irem].PY_tag1() == hadron_col) {coll[0] = HH_pyremn[irem].PY_tag2(); coll[1] = HH_pyremn[irem].PY_tag3(); acol_found =
true;
break;}
6640 else if(HH_pyremn[irem].PY_tag2() == hadron_col) {coll[0] = HH_pyremn[irem].PY_tag1(); coll[1] = HH_pyremn[irem].PY_tag3(); acol_found =
true;
break;}
6641 else if(HH_pyremn[irem].PY_tag3() == hadron_col) {coll[0] = HH_pyremn[irem].PY_tag1(); coll[1] = HH_pyremn[irem].PY_tag2(); acol_found =
true;
break;}
6647 bool found_tags[2] = {0,0}; ptn2 = 0;
6648 while(ptn2<HH_pyremn.num()){
if((HH_pyremn[ptn2].
col()==coll[0]) && (HH_pyremn[ptn1].PY_stat()>0)){found_tags[0]=
true;
break;} ++ptn2;}
6649 while(ptn3<HH_pyremn.num()){
if((HH_pyremn[ptn3].
col()==coll[1]) && (HH_pyremn[ptn2].PY_stat()>0)){found_tags[1]=
true;
break;} ++ptn3;}
6650 if(found_tags[0] && found_tags[1]){ptn3_found=
true;}
6654 col_known = col_found; acol_known = acol_found;
6656 if(col_found && acol_found) {info_found =
true;}
6659 double pos_x, pos_y, pos_z, pos_t; pos_x=0.; pos_y=0.; pos_z=0.; pos_t=0.;
6660 pos_x += HH_pyremn[ptn1].x(); pos_y += HH_pyremn[ptn1].y(); pos_z += HH_pyremn[ptn1].z(); pos_t += HH_pyremn[ptn1].x_t();
6661 pos_x += HH_pyremn[ptn2].x(); pos_y += HH_pyremn[ptn2].y(); pos_z += HH_pyremn[ptn2].z(); pos_t += HH_pyremn[ptn2].x_t();
6662 Case2_hadron_idx.push_back(hadron_idx);
6663 Case2_parton1_idx.push_back(ptn1);
6664 Case2_parton2_idx.push_back(ptn2);
6666 pos_x += HH_pyremn[ptn3].x(); pos_y += HH_pyremn[ptn3].y(); pos_z += HH_pyremn[ptn3].z(); pos_t += HH_pyremn[ptn3].x_t();
6667 pos_x /= 3.; pos_y /= 3.; pos_z /= 3.; pos_t /= 3.;
6668 Case2_parton3_idx.push_back(ptn3);
6669 Case2_junction_center = {pos_t,pos_x,pos_y,pos_z};
6671 pos_x /= 2.; pos_y /= 2.; pos_z /= 2.; pos_t /= 2.;
6672 Case2_parton3_idx.push_back(-1);
6674 hadron_out.
x(pos_x); hadron_out.
y(pos_y); hadron_out.
z(pos_z); hadron_out.
x_t(pos_t);
6675 }
else if((hadron_col == hadron_acol) && (hadron_col == 0)) {
6676 double avg_x, avg_y, avg_z, avg_t; avg_x=0.; avg_y=0.; avg_z=0.; avg_t=0.;
6678 bool found_first_q_or_qbar =
false;
bool found_second_q_or_qbar =
false;
6679 for(
int imot = 0; imot < mothers.size(); ++imot) {
6680 if(mothers[imot] <= HH_pyremn.num()) {
6682 avg_x += HH_pyremn[mothers[imot]-1].x(); avg_y += HH_pyremn[mothers[imot]-1].y(); avg_z += HH_pyremn[mothers[imot]-1].z(); avg_t += HH_pyremn[mothers[imot]-1].x_t();
6684 if(std::abs(HH_pyremn[mothers[imot]-1].
id()) < 7 && !found_first_q_or_qbar) {
6685 Case3_parton1_idx.push_back(mothers[imot]-1);
6686 found_first_q_or_qbar =
true;
6687 }
else if(std::abs(HH_pyremn[mothers[imot]-1].
id()) < 7 && !found_second_q_or_qbar && found_first_q_or_qbar) {
6688 Case3_parton2_idx.push_back(mothers[imot]-1);
6689 found_second_q_or_qbar =
true;
6693 if(found_first_q_or_qbar && found_second_q_or_qbar) {
6694 Case3_hadron_idx.push_back(hadron_idx);
6696 if(found_first_q_or_qbar && !found_second_q_or_qbar) {
6697 Case3_parton1_idx.pop_back();
6701 Case3_partons_center = {avg_t,avg_x,avg_y,avg_z};
6703 hadron_out.
x(avg_x); hadron_out.
y(avg_y); hadron_out.
z(avg_z); hadron_out.
x_t(avg_t);
6706 compute_more_precise_positions =
false;
6707 warn_could_not_find_positions =
true;
6708 hadron_out.
x(0.); hadron_out.
y(0.); hadron_out.
z(0.); hadron_out.
x_t(0.);
6714 final_hadrons_from_pythia.push_back(hadron_out);
6719 if(warn_could_not_find_positions && GetXMLElementInt({
"Afterburner",
"include_fragmentation_hadrons"}) == 1) {
6720 VERBOSE(2) <<
"Could not find the spacetime information for hadron in pythia event (string fragmentation attempt ="
6721 << pythia_attempt <<
"), set it to (0,0,0,0)";
6725 if(compute_more_precise_positions) {
6728 vector<int> Case1_unique_parton1_idx = Case1_parton1_idx;
6729 std::sort(Case1_unique_parton1_idx.begin(), Case1_unique_parton1_idx.end());
6730 Case1_unique_parton1_idx.erase(std::unique(Case1_unique_parton1_idx.begin(), Case1_unique_parton1_idx.end()), Case1_unique_parton1_idx.end());
6732 for(
int string_seg = 0; string_seg < Case1_unique_parton1_idx.size(); string_seg++) {
6733 int segment_parton1_idx = Case1_unique_parton1_idx.at(string_seg);
6736 vector<int> segment_hadron_idx;
6737 for(
int iHad = 0; iHad < Case1_hadron_idx.size(); iHad++) {
6738 if(Case1_parton1_idx.at(iHad) == segment_parton1_idx) {
6739 segment_hadron_idx.push_back(iHad);
6744 int number_hadrons_segment = segment_hadron_idx.size();
6745 if(number_hadrons_segment > 1) {
6746 for(
int iHad = 0; iHad < number_hadrons_segment; iHad++) {
6747 int parton1_index = Case1_parton1_idx.at(segment_hadron_idx.at(iHad));
6748 int parton2_index = Case1_parton2_idx.at(segment_hadron_idx.at(iHad));
6749 int current_hadron_idx = segment_hadron_idx.at(iHad);
6752 double pos_x_ptn1 = HH_pyremn[parton1_index].x();
6753 double pos_y_ptn1 = HH_pyremn[parton1_index].y();
6754 double pos_z_ptn1 = HH_pyremn[parton1_index].z();
6755 double pos_t_ptn1 = HH_pyremn[parton1_index].x_t();
6756 double pos_x_ptn2 = HH_pyremn[parton2_index].x();
6757 double pos_y_ptn2 = HH_pyremn[parton2_index].y();
6758 double pos_z_ptn2 = HH_pyremn[parton2_index].z();
6759 double pos_t_ptn2 = HH_pyremn[parton2_index].x_t();
6761 double delta_x = (pos_x_ptn2 - pos_x_ptn1) / (number_hadrons_segment+1);
6762 double delta_y = (pos_y_ptn2 - pos_y_ptn1) / (number_hadrons_segment+1);
6763 double delta_z = (pos_z_ptn2 - pos_z_ptn1) / (number_hadrons_segment+1);
6764 double delta_t = (pos_t_ptn2 - pos_t_ptn1) / (number_hadrons_segment+1);
6766 double had_x = pos_x_ptn1 + (iHad+1) * delta_x;
6767 double had_y = pos_y_ptn1 + (iHad+1) * delta_y;
6768 double had_z = pos_z_ptn1 + (iHad+1) * delta_z;
6769 double had_t = pos_t_ptn1 + (iHad+1) * delta_t;
6772 final_hadrons_from_pythia.at(current_hadron_idx).x(had_x);
6773 final_hadrons_from_pythia.at(current_hadron_idx).y(had_y);
6774 final_hadrons_from_pythia.at(current_hadron_idx).z(had_z);
6775 final_hadrons_from_pythia.at(current_hadron_idx).x_t(had_t);
6782 vector<int> Case2_unique_parton1_idx = Case2_parton1_idx;
6783 std::sort(Case2_unique_parton1_idx.begin(), Case2_unique_parton1_idx.end());
6784 Case2_unique_parton1_idx.erase(std::unique(Case2_unique_parton1_idx.begin(), Case2_unique_parton1_idx.end()), Case2_unique_parton1_idx.end());
6787 for(
int string_seg = 0; string_seg < Case2_unique_parton1_idx.size(); string_seg++) {
6788 int segment_parton1_idx = Case2_unique_parton1_idx.at(string_seg);
6791 vector<int> segment_hadron_idx;
6792 for(
int iHad = 0; iHad < Case2_hadron_idx.size(); iHad++) {
6793 if(Case2_parton1_idx.at(iHad) == segment_parton1_idx) {
6794 segment_hadron_idx.push_back(iHad);
6799 int number_hadrons_segment = segment_hadron_idx.size();
6800 if(number_hadrons_segment > 1) {
6801 for(
int iHad = 0; iHad < number_hadrons_segment; iHad++) {
6802 int parton1_index = Case2_parton1_idx.at(segment_hadron_idx.at(iHad));
6803 int parton2_index = Case2_parton2_idx.at(segment_hadron_idx.at(iHad));
6804 int parton3_index = Case2_parton3_idx.at(segment_hadron_idx.at(iHad));
6805 int current_hadron_idx = segment_hadron_idx.at(iHad);
6807 if((parton3_index == -1) && (Case2_junction_center.size() == 0)) {
6809 double pos_x_ptn1 = HH_pyremn[parton1_index].x();
6810 double pos_y_ptn1 = HH_pyremn[parton1_index].y();
6811 double pos_z_ptn1 = HH_pyremn[parton1_index].z();
6812 double pos_t_ptn1 = HH_pyremn[parton1_index].x_t();
6813 double pos_x_ptn2 = HH_pyremn[parton2_index].x();
6814 double pos_y_ptn2 = HH_pyremn[parton2_index].y();
6815 double pos_z_ptn2 = HH_pyremn[parton2_index].z();
6816 double pos_t_ptn2 = HH_pyremn[parton2_index].x_t();
6818 double delta_x = (pos_x_ptn2 - pos_x_ptn1) / (number_hadrons_segment+1);
6819 double delta_y = (pos_y_ptn2 - pos_y_ptn1) / (number_hadrons_segment+1);
6820 double delta_z = (pos_z_ptn2 - pos_z_ptn1) / (number_hadrons_segment+1);
6821 double delta_t = (pos_t_ptn2 - pos_t_ptn1) / (number_hadrons_segment+1);
6823 double had_x = pos_x_ptn1 + (iHad+1) * delta_x;
6824 double had_y = pos_y_ptn1 + (iHad+1) * delta_y;
6825 double had_z = pos_z_ptn1 + (iHad+1) * delta_z;
6826 double had_t = pos_t_ptn1 + (iHad+1) * delta_t;
6829 final_hadrons_from_pythia.at(current_hadron_idx).x(had_x);
6830 final_hadrons_from_pythia.at(current_hadron_idx).y(had_y);
6831 final_hadrons_from_pythia.at(current_hadron_idx).z(had_z);
6832 final_hadrons_from_pythia.at(current_hadron_idx).x_t(had_t);
6833 }
else if(parton3_index > -1 && Case2_junction_center.size() != 0) {
6835 vector<double> leg1_vec = {HH_pyremn[parton1_index].x_t()-Case2_junction_center[0],
6836 HH_pyremn[parton1_index].x()-Case2_junction_center[1],
6837 HH_pyremn[parton1_index].y()-Case2_junction_center[2],
6838 HH_pyremn[parton1_index].z()-Case2_junction_center[3]};
6839 vector<double> leg2_vec = {HH_pyremn[parton2_index].x_t()-Case2_junction_center[0],
6840 HH_pyremn[parton2_index].x()-Case2_junction_center[1],
6841 HH_pyremn[parton2_index].y()-Case2_junction_center[2],
6842 HH_pyremn[parton2_index].z()-Case2_junction_center[3]};
6843 vector<double> leg3_vec = {HH_pyremn[parton3_index].x_t()-Case2_junction_center[0],
6844 HH_pyremn[parton3_index].x()-Case2_junction_center[1],
6845 HH_pyremn[parton3_index].y()-Case2_junction_center[2],
6846 HH_pyremn[parton3_index].z()-Case2_junction_center[3]};
6847 double abs_leg1 = std::sqrt(leg1_vec[0]*leg1_vec[0] + leg1_vec[1]*leg1_vec[1] + leg1_vec[2]*leg1_vec[2] + leg1_vec[3]*leg1_vec[3]);
6848 double abs_leg2 = std::sqrt(leg2_vec[0]*leg2_vec[0] + leg2_vec[1]*leg2_vec[1] + leg2_vec[2]*leg2_vec[2] + leg2_vec[3]*leg2_vec[3]);
6849 double abs_leg3 = std::sqrt(leg3_vec[0]*leg3_vec[0] + leg3_vec[1]*leg3_vec[1] + leg3_vec[2]*leg3_vec[2] + leg3_vec[3]*leg3_vec[3]);
6850 if(abs_leg1 <= 1
e-6 || abs_leg2 <= 1
e-6 || abs_leg3 <= 1
e-6) {
continue;}
6851 double L = abs_leg1 + abs_leg2 + abs_leg3;
6852 double delta_l = L / (number_hadrons_segment + 1);
6854 double had_t, had_x, had_y, had_z;
6855 if(distance <= abs_leg1) {
6856 had_t = leg1_vec[0] * (distance / abs_leg1);
6857 had_x = leg1_vec[1] * (distance / abs_leg1);
6858 had_y = leg1_vec[2] * (distance / abs_leg1);
6859 had_z = leg1_vec[3] * (distance / abs_leg1);
6860 }
else if((abs_leg1 < distance) && (distance <= abs_leg1+abs_leg2)) {
6861 had_t = leg2_vec[0] * ((distance - abs_leg1) / abs_leg2);
6862 had_x = leg2_vec[1] * ((distance - abs_leg1) / abs_leg2);
6863 had_y = leg2_vec[2] * ((distance - abs_leg1) / abs_leg2);
6864 had_z = leg2_vec[3] * ((distance - abs_leg1) / abs_leg2);
6866 had_t = leg3_vec[0] * ((distance - abs_leg1 - abs_leg2) / abs_leg3);
6867 had_x = leg3_vec[1] * ((distance - abs_leg1 - abs_leg2) / abs_leg3);
6868 had_y = leg3_vec[2] * ((distance - abs_leg1 - abs_leg2) / abs_leg3);
6869 had_z = leg3_vec[3] * ((distance - abs_leg1 - abs_leg2) / abs_leg3);
6872 final_hadrons_from_pythia.at(current_hadron_idx).x(had_x);
6873 final_hadrons_from_pythia.at(current_hadron_idx).y(had_y);
6874 final_hadrons_from_pythia.at(current_hadron_idx).z(had_z);
6875 final_hadrons_from_pythia.at(current_hadron_idx).x_t(had_t);
6883 vector<int> Case3_unique_parton1_idx = Case3_parton1_idx;
6884 std::sort(Case3_unique_parton1_idx.begin(), Case3_unique_parton1_idx.end());
6885 Case3_unique_parton1_idx.erase(std::unique(Case3_unique_parton1_idx.begin(), Case3_unique_parton1_idx.end()), Case3_unique_parton1_idx.end());
6887 for(
int string_seg = 0; string_seg < Case3_unique_parton1_idx.size(); string_seg++) {
6888 int segment_parton1_idx = Case3_unique_parton1_idx.at(string_seg);
6891 vector<int> segment_hadron_idx;
6892 for(
int iHad = 0; iHad < Case3_hadron_idx.size(); iHad++) {
6893 if(Case3_parton1_idx.at(iHad) == segment_parton1_idx) {
6894 segment_hadron_idx.push_back(iHad);
6899 int number_hadrons_segment = segment_hadron_idx.size();
6900 if(number_hadrons_segment > 1) {
6901 for(
int iHad = 0; iHad < number_hadrons_segment; iHad++) {
6902 int parton1_index = Case3_parton1_idx.at(segment_hadron_idx.at(iHad));
6903 int parton2_index = Case3_parton2_idx.at(segment_hadron_idx.at(iHad));
6904 int current_hadron_idx = segment_hadron_idx.at(iHad);
6906 vector<double> seg1_vec = {HH_pyremn[parton1_index].x_t()-Case3_partons_center[0],
6907 HH_pyremn[parton1_index].x()-Case3_partons_center[1],
6908 HH_pyremn[parton1_index].y()-Case3_partons_center[2],
6909 HH_pyremn[parton1_index].z()-Case3_partons_center[3]};
6910 vector<double> seg2_vec = {HH_pyremn[parton2_index].x_t()-Case3_partons_center[0],
6911 HH_pyremn[parton2_index].x()-Case3_partons_center[1],
6912 HH_pyremn[parton2_index].y()-Case3_partons_center[2],
6913 HH_pyremn[parton2_index].z()-Case3_partons_center[3]};
6914 double abs_seg1 = std::sqrt(seg1_vec[0]*seg1_vec[0] + seg1_vec[1]*seg1_vec[1] + seg1_vec[2]*seg1_vec[2] + seg1_vec[3]*seg1_vec[3]);
6915 double abs_seg2 = std::sqrt(seg2_vec[0]*seg2_vec[0] + seg2_vec[1]*seg2_vec[1] + seg2_vec[2]*seg2_vec[2] + seg2_vec[3]*seg2_vec[3]);
6916 if(abs_seg1 <= 1
e-6 || abs_seg2 <= 1
e-6) {
continue;}
6917 double L = abs_seg1 + abs_seg2;
6918 double delta_l = L / (number_hadrons_segment + 1);
6920 double had_t, had_x, had_y, had_z;
6921 if(distance <= abs_seg1) {
6922 had_t = seg1_vec[0] * (distance / abs_seg1);
6923 had_x = seg1_vec[1] * (distance / abs_seg1);
6924 had_y = seg1_vec[2] * (distance / abs_seg1);
6925 had_z = seg1_vec[3] * (distance / abs_seg1);
6927 had_t = seg2_vec[0] * ((distance - abs_seg1) / abs_seg2);
6928 had_x = seg2_vec[1] * ((distance - abs_seg1) / abs_seg2);
6929 had_y = seg2_vec[2] * ((distance - abs_seg1) / abs_seg2);
6930 had_z = seg2_vec[3] * ((distance - abs_seg1) / abs_seg2);
6933 final_hadrons_from_pythia.at(current_hadron_idx).x(had_x);
6934 final_hadrons_from_pythia.at(current_hadron_idx).y(had_y);
6935 final_hadrons_from_pythia.at(current_hadron_idx).z(had_z);
6936 final_hadrons_from_pythia.at(current_hadron_idx).x_t(had_t);
6946 for(
int hadron_idx = 0; hadron_idx < final_hadrons_from_pythia.size(); hadron_idx++) {
6947 HH_pythia_hadrons.add(final_hadrons_from_pythia[hadron_idx]);
6961 for(
int iHad=0; iHad<HH_hadrons.
num(); ++iHad){
6963 if(!HH_hadrons[iHad].is_final()){
continue;}
6966 double hadmass = HH_hadrons[iHad].mass();
6967 double m1 = pythia.particleData.m0(HH_hadrons[iHad].
id());
6969 if(!(std::abs(hadmass - m1)/m1 > osf)){
continue;}
6975 if(HH_hadrons[iHad].cols.size() > 0){
6977 for(
int jHad = 0; jHad < HH_hadrons.
num(); ++jHad){
6978 if(!HH_hadrons[jHad].is_final()){
continue;}
6979 if(iHad == jHad){
continue;}
6980 double m2 = pythia.particleData.m0(HH_hadrons[jHad].
id());
6981 double pair_mass = std::sqrt((HH_hadrons[iHad].
e() + HH_hadrons[jHad].
e())*(HH_hadrons[iHad].
e() + HH_hadrons[jHad].
e())
6982 - (HH_hadrons[iHad].px() + HH_hadrons[jHad].px())*(HH_hadrons[iHad].px() + HH_hadrons[jHad].px())
6983 - (HH_hadrons[iHad].py() + HH_hadrons[jHad].py())*(HH_hadrons[iHad].py() + HH_hadrons[jHad].py())
6984 - (HH_hadrons[iHad].pz() + HH_hadrons[jHad].pz())*(HH_hadrons[iHad].pz() + HH_hadrons[jHad].pz()));
6987 double momentum_diff = (HH_hadrons[iHad].px()-HH_hadrons[jHad].px())*(HH_hadrons[iHad].px()-HH_hadrons[jHad].px())
6988 + (HH_hadrons[iHad].py()-HH_hadrons[jHad].py())*(HH_hadrons[iHad].py()-HH_hadrons[jHad].py())
6989 + (HH_hadrons[iHad].pz()-HH_hadrons[jHad].pz())*(HH_hadrons[iHad].pz()-HH_hadrons[jHad].pz());
6990 if(HH_hadrons[jHad].cols.size() > 0){
6992 for(
int icol = 0; icol < HH_hadrons[iHad].cols.size(); ++icol){
6993 for(
int jcol = 0; jcol < HH_hadrons[jHad].cols.size(); ++jcol){
6994 if(!(HH_hadrons[iHad].
col(icol) == HH_hadrons[jHad].
col(jcol)) || momentum_diff < 1
e-6 || (pair_mass < m1+
m2)){
continue;}
6996 partner = jHad;
break;
6998 if(partner > -1){
break;}
7001 if(partner > -1){
break;}
7009 int iprev = iHad-1;
int inext = iHad+1;
7011 double m2 = pythia.particleData.m0(HH_hadrons[iprev].
id());
7012 double pair_mass = std::sqrt((HH_hadrons[iHad].
e() + HH_hadrons[iprev].
e())*(HH_hadrons[iHad].
e() + HH_hadrons[iprev].
e())
7013 - (HH_hadrons[iHad].px() + HH_hadrons[iprev].px())*(HH_hadrons[iHad].px() + HH_hadrons[iprev].px())
7014 - (HH_hadrons[iHad].py() + HH_hadrons[iprev].py())*(HH_hadrons[iHad].py() + HH_hadrons[iprev].py())
7015 - (HH_hadrons[iHad].pz() + HH_hadrons[iprev].pz())*(HH_hadrons[iHad].pz() + HH_hadrons[iprev].pz()));
7016 double momentum_diff = (HH_hadrons[iHad].px()-HH_hadrons[iprev].px())*(HH_hadrons[iHad].px()-HH_hadrons[iprev].px())
7017 + (HH_hadrons[iHad].py()-HH_hadrons[iprev].py())*(HH_hadrons[iHad].py()-HH_hadrons[iprev].py())
7018 + (HH_hadrons[iHad].pz()-HH_hadrons[iprev].pz())*(HH_hadrons[iHad].pz()-HH_hadrons[iprev].pz());
7019 if(HH_hadrons[iprev].is_final() && momentum_diff >= 1
e-6 && pair_mass >= m1+
m2){
break;}
7022 while(inext < HH_hadrons.
num()){
7023 double m2 = pythia.particleData.m0(HH_hadrons[inext].
id());
7024 double pair_mass = std::sqrt((HH_hadrons[iHad].
e() + HH_hadrons[inext].
e())*(HH_hadrons[iHad].
e() + HH_hadrons[inext].
e())
7025 - (HH_hadrons[iHad].px() + HH_hadrons[inext].px())*(HH_hadrons[iHad].px() + HH_hadrons[inext].px())
7026 - (HH_hadrons[iHad].py() + HH_hadrons[inext].py())*(HH_hadrons[iHad].py() + HH_hadrons[inext].py())
7027 - (HH_hadrons[iHad].pz() + HH_hadrons[inext].pz())*(HH_hadrons[iHad].pz() + HH_hadrons[inext].pz()));
7028 double momentum_diff = (HH_hadrons[iHad].px()-HH_hadrons[inext].px())*(HH_hadrons[iHad].px()-HH_hadrons[inext].px())
7029 + (HH_hadrons[iHad].py()-HH_hadrons[inext].py())*(HH_hadrons[iHad].py()-HH_hadrons[inext].py())
7030 + (HH_hadrons[iHad].pz()-HH_hadrons[inext].pz())*(HH_hadrons[iHad].pz()-HH_hadrons[inext].pz());
7031 if(HH_hadrons[inext].is_final() && momentum_diff >= 1
e-6 && pair_mass >= m1+
m2){
break;}
7038 if(iprev < 0){partner = inext;}
7039 else if(inext >= HH_hadrons.
num()){partner = iprev;}
7040 else{partner = (inext - iHad <= iHad - iprev) ? inext : iprev;}
7042 if((partner >= HH_hadrons.
num()) || (partner < 0)) {partner = -1;}
7047 double minimum = 1e6;
7048 int partner_temporary = -1;
7049 for(
int jHad = 0; jHad < HH_hadrons.
num(); ++jHad){
7050 if(!HH_hadrons[jHad].is_final()){
continue;}
7051 if(iHad == jHad){
continue;}
7052 double m2 = pythia.particleData.m0(HH_hadrons[jHad].
id());
7053 double pair_mass = std::sqrt((HH_hadrons[iHad].
e() + HH_hadrons[jHad].
e())*(HH_hadrons[iHad].
e() + HH_hadrons[jHad].
e())
7054 - (HH_hadrons[iHad].px() + HH_hadrons[jHad].px())*(HH_hadrons[iHad].px() + HH_hadrons[jHad].px())
7055 - (HH_hadrons[iHad].py() + HH_hadrons[jHad].py())*(HH_hadrons[iHad].py() + HH_hadrons[jHad].py())
7056 - (HH_hadrons[iHad].pz() + HH_hadrons[jHad].pz())*(HH_hadrons[iHad].pz() + HH_hadrons[jHad].pz()));
7057 if(std::abs(pair_mass-m1-m2) < minimum){
7058 minimum = std::abs(pair_mass-m1-m2);
7059 partner_temporary = jHad;
7062 if(partner_temporary != -1){
7063 partner = partner_temporary;
7070 if(partner == -1){
continue;}
7077 Psys.
Set(HH_hadrons[iHad].px()+HH_hadrons[partner].px(),HH_hadrons[iHad].py()+HH_hadrons[partner].py(),HH_hadrons[iHad].pz()+HH_hadrons[partner].pz(),HH_hadrons[iHad].
e()+HH_hadrons[partner].
e());
7081 beta.
Set(Psys.
x()/Psys.
t(),Psys.
y()/Psys.
t(),Psys.
z()/Psys.
t(),0.);
7082 beta.
Set(beta.
x(),beta.
y(),beta.
z(),1./(sqrt(1.-(beta.
x()*beta.
x() + beta.
y()*beta.
y() + beta.
z()*beta.
z()))));
7085 FourVector p_CM[2]; p_CM[0] = HH_hadrons[iHad].boost_P(beta); p_CM[1] = HH_hadrons[partner].boost_P(beta);
7088 double m2 = pythia.particleData.m0(HH_hadrons[partner].
id());
7089 double Etot = p_CM[0].
t() + p_CM[1].
t();
7090 if(Etot < m1 + m2 + 0.00001){Etot = m1 + m2 + 0.00001; }
7091 double E1 = Etot/2. + ((m1*m1)-(m2*m2))/(2.*Etot);
7092 double E2 = Etot/2. - ((m1*m1)-(m2*m2))/(2.*Etot);
7093 double pmag = sqrt(p_CM[0].
x()*p_CM[0].
x() + p_CM[0].
y()*p_CM[0].
y() + p_CM[0].
z()*p_CM[0].
z());
7094 double fac = sqrt(Etot*Etot/4. + ((m1*m1)-(m2*m2))*((m1*m1)-(m2*m2))/(4.*Etot*Etot) - ((m1*m1)+(m2*m2))/2.)/pmag;
7097 p_CM[0].
Set(fac*p_CM[0].
x(), fac*p_CM[0].
y(), fac*p_CM[0].
z(), E1);
7098 p_CM[1].
Set(fac*p_CM[1].
x(), fac*p_CM[1].
y(), fac*p_CM[1].
z(), E2);
7101 beta.
Set(-beta.
x(), -beta.
y(), -beta.
z(), 0.);
7102 beta.
Set(beta.
x(),beta.
y(),beta.
z(),1./(sqrt(1.-(beta.
x()*beta.
x() + beta.
y()*beta.
y() + beta.
z()*beta.
z()))));
7103 FourVector p_fin[2]; p_fin[0] = HHboost(beta, p_CM[0]); p_fin[1] = HHboost(beta, p_CM[1]);
7104 HH_hadrons[iHad].P(p_fin[0]); HH_hadrons[partner].P(p_fin[1]);
7105 HH_hadrons[iHad].mass(m1);
7106 HH_hadrons[partner].mass(m2);
7127 if(HH_partons.
num() == 1) {
7129 if(std::abs(parton.
id()) < 6 && parton.
mass() < pythia.particleData.m0(std::abs(parton.
id()))) {
7130 parton.
mass(pythia.particleData.m0(std::abs(parton.
id())));
7131 parton.
e(std::sqrt(parton.
px()*parton.
px() + parton.
py()*parton.
py() + parton.
pz()*parton.
pz() + parton.
mass()*parton.
mass()));
7133 }
else if(parton.
id() == 21 && parton.
mass() < 2.*xmq + 0.001) {
7134 parton.
mass(2.*xmq + 0.001);
7135 parton.
e(std::sqrt(parton.
px()*parton.
px() + parton.
py()*parton.
py() + parton.
pz()*parton.
pz() + parton.
mass()*parton.
mass()));
7143 for(
int iPart=0; iPart<HH_partons.
num(); ++iPart){
7145 if ((HH_partons[iPart].
id() != 21) && (std::abs(HH_partons[iPart].
id()) > 5)){
continue;}
7148 double partmass = HH_partons[iPart].mass();
7150 if(HH_partons[iPart].
id() == 21){
7151 m1 = 2.*xmq + 0.001;
7152 }
else if(std::abs(HH_partons[iPart].
id()) < 3) {
7154 }
else if(std::abs(HH_partons[iPart].
id()) == 3) {
7156 }
else if(std::abs(HH_partons[iPart].
id()) == 4) {
7158 }
else if(std::abs(HH_partons[iPart].
id()) == 5) {
7163 if((std::abs(partmass - m1)/m1 < osf) && (std::abs(HH_partons[iPart].
id()) < 6)){
continue;}
7165 if((HH_partons[iPart].
id() == 21) && (partmass > m1)){
continue;}
7171 for(
int jPart=0; jPart<HH_partons.
num(); ++jPart){
7172 if(iPart == jPart || (std::abs(HH_partons[iPart].
id()) > 5 && std::abs(HH_partons[iPart].
id()) < 7)){
continue;}
7174 if ((HH_partons[jPart].
id() == 21) && (HH_partons[jPart].mass() < 2.*xmq + 0.001)){
7175 m2 = 2.*xmq + 0.001;
7176 }
else if ((HH_partons[jPart].
id() == 21) && (HH_partons[jPart].
mass() >= 2.*xmq + 0.001)){
7177 m2 = HH_partons[jPart].mass();
7178 }
else if(std::abs(HH_partons[jPart].
id()) < 3) {
7180 }
else if(std::abs(HH_partons[jPart].
id()) == 3) {
7182 }
else if(std::abs(HH_partons[jPart].
id()) == 4) {
7184 }
else if(std::abs(HH_partons[jPart].
id()) == 5) {
7187 double pair_mass = std::sqrt((HH_partons[iPart].
e() + HH_partons[jPart].
e())*(HH_partons[iPart].
e() + HH_partons[jPart].
e())
7188 - (HH_partons[iPart].px() + HH_partons[jPart].px())*(HH_partons[iPart].px() + HH_partons[jPart].px())
7189 - (HH_partons[iPart].py() + HH_partons[jPart].py())*(HH_partons[iPart].py() + HH_partons[jPart].py())
7190 - (HH_partons[iPart].pz() + HH_partons[jPart].pz())*(HH_partons[iPart].pz() + HH_partons[jPart].pz()));
7193 double momentum_diff = (HH_partons[iPart].px()-HH_partons[jPart].px())*(HH_partons[iPart].px()-HH_partons[jPart].px())
7194 + (HH_partons[iPart].py()-HH_partons[jPart].py())*(HH_partons[iPart].py()-HH_partons[jPart].py())
7195 + (HH_partons[iPart].pz()-HH_partons[jPart].pz())*(HH_partons[iPart].pz()-HH_partons[jPart].pz());
7196 if(((HH_partons[iPart].
col() == HH_partons[jPart].acol()) || (HH_partons[iPart].acol() == HH_partons[jPart].
col())) && (momentum_diff > 1
e-6) && (pair_mass >= m1+m2)){
7197 if((HH_partons[jPart].
id() == 21) && (HH_partons[jPart].
mass() < 2.*xmq + 0.001)) {
7200 }
else if ((std::abs(HH_partons[jPart].
id()) < 3) && (std::abs(HH_partons[jPart].
mass() - xmq)/xmq > osf)) {
7203 }
else if ((std::abs(HH_partons[jPart].
id()) == 3) && (std::abs(HH_partons[jPart].
mass() - xms)/xms > osf)) {
7206 }
else if ((std::abs(HH_partons[jPart].
id()) == 4) && (std::abs(HH_partons[jPart].
mass() - xmc)/xmc > osf)) {
7209 }
else if ((std::abs(HH_partons[jPart].
id()) == 5) && (std::abs(HH_partons[jPart].
mass() - xmb)/xmb > osf)) {
7217 int iPartnerCandidate = -1;
7218 double energy_loss_tracking = 1e6;
7224 int iprev = iPart-1;
int inext = iPart+1;
7227 if ((HH_partons[iprev].
id() == 21) && (HH_partons[iprev].
mass() < 2.*xmq + 0.001)){
7228 m2 = 2.*xmq + 0.001;
7229 }
else if ((HH_partons[iprev].
id() == 21) && (HH_partons[iprev].
mass() >= 2.*xmq + 0.001)){
7230 m2 = HH_partons[iprev].mass();
7231 }
else if(std::abs(HH_partons[iprev].
id()) < 3) {
7233 }
else if(std::abs(HH_partons[iprev].
id()) == 3) {
7235 }
else if(std::abs(HH_partons[iprev].
id()) == 4) {
7237 }
else if(std::abs(HH_partons[iprev].
id()) == 5) {
7240 double pair_mass = std::sqrt((HH_partons[iPart].
e() + HH_partons[iprev].
e())*(HH_partons[iPart].
e() + HH_partons[iprev].
e())
7241 - (HH_partons[iPart].px() + HH_partons[iprev].px())*(HH_partons[iPart].px() + HH_partons[iprev].px())
7242 - (HH_partons[iPart].py() + HH_partons[iprev].py())*(HH_partons[iPart].py() + HH_partons[iprev].py())
7243 - (HH_partons[iPart].pz() + HH_partons[iprev].pz())*(HH_partons[iPart].pz() + HH_partons[iprev].pz()));
7244 double momentum_diff = (HH_partons[iPart].px()-HH_partons[iprev].px())*(HH_partons[iPart].px()-HH_partons[iprev].px())
7245 + (HH_partons[iPart].py()-HH_partons[iprev].py())*(HH_partons[iPart].py()-HH_partons[iprev].py())
7246 + (HH_partons[iPart].pz()-HH_partons[iprev].pz())*(HH_partons[iPart].pz()-HH_partons[iprev].pz());
7247 if((momentum_diff > 1
e-6) && (pair_mass >= m1+
m2) && (std::abs(HH_partons[iprev].
id()) < 6 || HH_partons[iprev].id() == 21)){
7248 if(energy_loss_tracking > std::abs(pair_mass - m1 - m2)) {
7249 energy_loss_tracking = std::abs(pair_mass - m1 - m2);
7250 iPartnerCandidate = iprev;
7256 while(inext < HH_partons.
num()){
7258 if ((HH_partons[inext].
id() == 21) && (HH_partons[inext].mass() < 2.*xmq + 0.001)){
7259 m2 = 2.*xmq + 0.001;
7260 }
else if ((HH_partons[inext].
id() == 21) && (HH_partons[inext].
mass() >= 2.*xmq + 0.001)){
7261 m2 = HH_partons[inext].mass();
7262 }
else if(std::abs(HH_partons[inext].
id()) < 3) {
7264 }
else if(std::abs(HH_partons[inext].
id()) == 3) {
7266 }
else if(std::abs(HH_partons[inext].
id()) == 4) {
7268 }
else if(std::abs(HH_partons[inext].
id()) == 5) {
7271 double pair_mass = std::sqrt((HH_partons[iPart].
e() + HH_partons[inext].
e())*(HH_partons[iPart].
e() + HH_partons[inext].
e())
7272 - (HH_partons[iPart].px() + HH_partons[inext].px())*(HH_partons[iPart].px() + HH_partons[inext].px())
7273 - (HH_partons[iPart].py() + HH_partons[inext].py())*(HH_partons[iPart].py() + HH_partons[inext].py())
7274 - (HH_partons[iPart].pz() + HH_partons[inext].pz())*(HH_partons[iPart].pz() + HH_partons[inext].pz()));
7275 double momentum_diff = (HH_partons[iPart].px()-HH_partons[inext].px())*(HH_partons[iPart].px()-HH_partons[inext].px())
7276 + (HH_partons[iPart].py()-HH_partons[inext].py())*(HH_partons[iPart].py()-HH_partons[inext].py())
7277 + (HH_partons[iPart].pz()-HH_partons[inext].pz())*(HH_partons[iPart].pz()-HH_partons[inext].pz());
7278 if((momentum_diff > 1
e-6) && (pair_mass >= m1+
m2) && (std::abs(HH_partons[inext].
id()) < 6 || HH_partons[inext].id() == 21)){
7279 if(energy_loss_tracking > std::abs(pair_mass - m1 - m2)) {
7280 energy_loss_tracking = std::abs(pair_mass - m1 - m2);
7281 iPartnerCandidate = inext;
7291 if(iprev < 0){partner = inext;}
7292 else if(inext >= HH_partons.
num()){partner = iprev;}
7293 else{partner = (inext - iPart <= iPart - iprev) ? inext : iprev;}
7295 if((iPartnerCandidate >= HH_partons.
num()) || (iPartnerCandidate < 0)){iPartnerCandidate = -1;}
7296 if((partner >= HH_partons.
num()) || (partner < 0)) {partner = -1;}
7302 if(partner == -1 && iPartnerCandidate >= 0){
7303 partner = iPartnerCandidate;
7304 }
else if(partner == -1 && iPartnerCandidate == -1) {
7306 if(std::abs(parton.
id()) < 6 && parton.
mass() < pythia.particleData.m0(std::abs(parton.
id()))) {
7307 parton.
mass(pythia.particleData.m0(std::abs(parton.
id())));
7308 parton.
e(std::sqrt(parton.
px()*parton.
px() + parton.
py()*parton.
py() + parton.
pz()*parton.
pz() + parton.
mass()*parton.
mass()));
7309 HH_partons[iPart] =
parton;
7310 }
else if(parton.
id() == 21 && parton.
mass() < 2.*xmq + 0.001) {
7311 parton.
mass(2.*xmq + 0.001);
7312 parton.
e(std::sqrt(parton.
px()*parton.
px() + parton.
py()*parton.
py() + parton.
pz()*parton.
pz() + parton.
mass()*parton.
mass()));
7313 HH_partons[iPart] =
parton;
7323 Psys.
Set(HH_partons[iPart].px()+HH_partons[partner].px(),HH_partons[iPart].py()+HH_partons[partner].py(),HH_partons[iPart].pz()+HH_partons[partner].pz(),HH_partons[iPart].
e()+HH_partons[partner].
e());
7327 beta.
Set(Psys.
x()/Psys.
t(),Psys.
y()/Psys.
t(),Psys.
z()/Psys.
t(),0.);
7328 beta.
Set(beta.
x(),beta.
y(),beta.
z(),1./(sqrt(1.-(beta.
x()*beta.
x() + beta.
y()*beta.
y() + beta.
z()*beta.
z()))));
7331 FourVector p_CM[2]; p_CM[0] = HH_partons[iPart].boost_P(beta); p_CM[1] = HH_partons[partner].boost_P(beta);
7335 if ((HH_partons[partner].
id() == 21) && (HH_partons[partner].
mass() < 2.*xmq + 0.001)){
7336 m2 = 2.*xmq + 0.001;
7337 }
else if ((HH_partons[partner].
id() == 21) && (HH_partons[partner].
mass() >= 2.*xmq + 0.001)){
7338 m2 = HH_partons[partner].mass();
7339 }
else if(std::abs(HH_partons[partner].
id()) < 3) {
7341 }
else if(std::abs(HH_partons[partner].
id()) == 3) {
7343 }
else if(std::abs(HH_partons[partner].
id()) == 4) {
7345 }
else if(std::abs(HH_partons[partner].
id()) == 5) {
7348 double Etot = p_CM[0].
t() + p_CM[1].
t();
7349 if(Etot < m1 + m2 + 0.00001){Etot = m1 + m2 + 0.00001; }
7350 double E1 = Etot/2. + ((m1*m1)-(m2*m2))/(2.*Etot);
7351 double E2 = Etot/2. - ((m1*m1)-(m2*m2))/(2.*Etot);
7352 double pmag = sqrt(p_CM[0].
x()*p_CM[0].
x() + p_CM[0].
y()*p_CM[0].
y() + p_CM[0].
z()*p_CM[0].
z());
7353 double fac = sqrt(Etot*Etot/4. + ((m1*m1)-(m2*m2))*((m1*m1)-(m2*m2))/(4.*Etot*Etot) - ((m1*m1)+(m2*m2))/2.)/pmag;
7357 p_CM[0].
Set(fac*p_CM[0].
x(), fac*p_CM[0].
y(), fac*p_CM[0].
z(), E1);
7358 p_CM[1].
Set(fac*p_CM[1].
x(), fac*p_CM[1].
y(), fac*p_CM[1].
z(), E2);
7361 beta.
Set(-beta.
x(), -beta.
y(), -beta.
z(), 0.);
7362 beta.
Set(beta.
x(),beta.
y(),beta.
z(),1./(sqrt(1.-(beta.
x()*beta.
x() + beta.
y()*beta.
y() + beta.
z()*beta.
z()))));
7363 FourVector p_fin[2]; p_fin[0] = HHboost(beta, p_CM[0]); p_fin[1] = HHboost(beta, p_CM[1]);
7364 HH_partons[iPart].P(p_fin[0]); HH_partons[partner].P(p_fin[1]);
7365 HH_partons[iPart].mass(m1);
7366 HH_partons[partner].mass(m2);