void Lund_Interface::FillOutgoingParticlesInBlob(Blob *blob) { Flavour flav; Vec4D momentum; Particle * particle; int n_q(0), n_g(0); Particle_Vector partons; for (int j=hepevt.jdahep[0][0]-1;j<hepevt.jdahep[0][1];j++) { int idhep = hepevt.idhep[j]; flav=IdhepToSherpa(idhep); momentum=Vec4D(hepevt.phep[j][3],hepevt.phep[j][0], hepevt.phep[j][1],hepevt.phep[j][2]); // don't fill blob position vector here, because decay is in CMS until boosting back particle = new Particle(-1,flav,momentum); particle->SetNumber(0); particle->SetStatus(part_status::active); particle->SetInfo('D'); particle->SetFinalMass(hepevt.phep[j][4]); blob->AddToOutParticles(particle); if(abs(idhep)>0 && abs(idhep)<7) { n_q++; partons.push_back(particle); } else if(abs(idhep)==21) { n_g++; partons.push_back(particle); } } size_t n=partons.size(); if(n>0) blob->SetStatus(blob_status::needs_showers); if(n_q==2 && n_g==0 && n==2) { if(partons[0]->Flav().IsAnti()) { partons[0]->SetFlow(2,-1); partons[1]->SetFlow(1,partons[0]->GetFlow(2)); } else { partons[0]->SetFlow(1,-1); partons[1]->SetFlow(2,partons[0]->GetFlow(1)); } } else if(n_q==0 && n_g==2 && n==2) { partons[0]->SetFlow(2,-1); partons[0]->SetFlow(1,-1); partons[1]->SetFlow(2,partons[0]->GetFlow(1)); partons[1]->SetFlow(1,partons[0]->GetFlow(2)); } else if(n_q==0 && n_g==3 && n==3) { partons[0]->SetFlow(2,-1); partons[0]->SetFlow(1,-1); partons[1]->SetFlow(2,partons[0]->GetFlow(1)); partons[1]->SetFlow(1,-1); partons[2]->SetFlow(2,partons[1]->GetFlow(1)); partons[2]->SetFlow(1,partons[0]->GetFlow(2)); } else if(n>0) { msg_Error()<<METHOD<<" wasn't able to set the color flow for"<<endl<<*blob<<endl; } }
void Lund_Interface::FillFragmentationBlob(Blob *blob) { Particle *particle; Flavour flav; Vec4D momentum, position; for (int i=0;i<hepevt.nhep;++i) { if ((hepevt.isthep[i]!=2)&&(hepevt.isthep[i]!=1)&&(hepevt.isthep[i]!=149)) continue; if (hepevt.idhep[i]==93) flav=Flavour(kf_cluster); else flav=IdhepToSherpa(hepevt.idhep[i]); if (flav==Flavour(kf_string) || flav==Flavour(kf_cluster)) { for (int j=hepevt.jdahep[i][0]-1;j<hepevt.jdahep[i][1];j++) { flav=IdhepToSherpa(hepevt.idhep[j]); momentum=Vec4D(hepevt.phep[j][3],hepevt.phep[j][0], hepevt.phep[j][1],hepevt.phep[j][2]); position=Vec4D(hepevt.vhep[j][3],hepevt.vhep[j][0], hepevt.vhep[j][1],hepevt.vhep[j][2]); particle = new Particle(-1,flav,momentum); particle->SetNumber(0); particle->SetStatus(part_status::active); particle->SetInfo('P'); particle->SetFinalMass(hepevt.phep[j][4]); blob->SetPosition(position); blob->AddToOutParticles(particle); } } } blob->SetStatus(blob_status::needs_hadrondecays); }
Return_Value::code Lund_Interface::PerformDecay(Blob * blob) { if (blob->NInP()!=1 || blob->InParticle(0)->Status()!=part_status::active) { msg_Error()<<METHOD<<" returns Error."<<endl; msg_Error()<<" blob->Status()="<<blob->Status()<<endl; msg_Error()<<" blob->NInP()="<<blob->NInP()<<endl; msg_Error()<<" part->Status()="<<blob->InParticle(0)->Status()<<endl; return Return_Value::Error; } Particle * part = blob->InParticle(0); Flavour fl = part->Flav(); int kc = pycomp(SherpaToIdhep(fl))-1; double peak = pydat2.pmas[1-1][kc]; double w_cut = pydat2.pmas[3-1][kc]; if( part->FinalMass()+Accu() < peak-w_cut || part->FinalMass()-Accu() > peak+w_cut) { return Return_Value::Retry_Method; } int nhep(0); int idhep = SherpaToIdhep(fl); hepevt.idhep[nhep] = idhep; for (short int j=1;j<4;++j) hepevt.phep[nhep][j-1]=part->Momentum()[j]; hepevt.phep[nhep][3] = part->Momentum()[0]; hepevt.phep[nhep][4] = part->FinalMass(); for (short int j=0;j<4;++j) hepevt.vhep[nhep][j]=0.0; hepevt.isthep[nhep]=1; hepevt.jmohep[nhep][0]=0; hepevt.jmohep[nhep][1]=0; hepevt.jdahep[nhep][0]=0; hepevt.jdahep[nhep][1]=0; nhep++; hepevt.nevhep=0; hepevt.nhep=nhep; pyhepc(2); pydat1.mstu[70-1]=1; pydat1.mstu[71-1]=hepevt.nhep; int ip(1); pydecy(ip); if (pydat1.mstu[24-1]!=0) { msg_Tracking()<<"ERROR in "<<METHOD<<" : "<<std::endl <<" PYDECY call results in error code : "<<pydat1.mstu[24-1]<<std::endl <<" for decay of "<<fl<<" ("<<(long int) fl<<" -> "<<idhep<<")"<<std::endl; if (pydat1.mstu[23-1]<int(rpa->gen.NumberOfGeneratedEvents()/100) || rpa->gen.NumberOfGeneratedEvents()<200) { msg_Tracking()<<" Up to now: "<<pydat1.mstu[23-1]<<" errors, try new event."<<std::endl; return Return_Value::Retry_Method; } msg_Tracking()<<" Up to now: "<<pydat1.mstu[23-1]<<" errors, abort the run."<<std::endl; } part->SetStatus(part_status::decayed); pyhepc(1); FillOutgoingParticlesInBlob(blob); return Return_Value::Success; }
bool Simple_String::CreateMomenta() { m_filledblob=false; if (p_remnants[0]==NULL || p_remnants[1]==NULL) { msg_Error()<<"Simple_String::CreateMomenta(): " <<"No remnant found."<<std::endl; return false; } m_reggeons[0]->Fit(m_start[0]*m_start[0],m_start[2]); m_start[1]=sqrt(m_reggeons[0]->GetT(0.0,m_start[0]*m_start[0],ran->Get())); const unsigned int flow=Flow::Counter(); for (short unsigned int i=0;i<2;++i) { PDF::Hadron_Remnant *hadron= dynamic_cast<PDF::Hadron_Remnant*>(p_remnants[i]); if (hadron==NULL) { msg_Error()<<"Simple_String::CreateMomenta(): " <<"Incoming particle is no hadron."<<std::endl; return false; } const std::vector<Flavour> &constit= hadron->GetConstituents(kf_none); double pz=0.0, phi=ran->Get()*2.0*M_PI; for (size_t j=0;j<constit.size();++j) { if (constit[j].IsQuark() && constit[j].IsAnti()==i) { Particle *particle = new Particle(0,constit[j]); do { double E=hadron->GetBeam()->Energy()* hadron->GetXPDF(constit[j],m_start[0]*m_start[0]); pz=sqrt(E*E-sqr(constit[j].Mass())-m_start[1]*m_start[1]); if (i==1) pz*=-1.0; particle->SetMomentum(Vec4D(E,(i==0?1.0:-1.0)*m_start[1]*cos(phi), (i==0?1.0:-1.0)*m_start[1]*sin(phi),pz)); } while (!(dabs(pz)>0.0)); particle->SetFlow(1+constit[j].IsAnti(),flow); particle->SetFlow(2-constit[j].IsAnti(),0); particle->SetStatus(part_status::active); m_inparticles.push_back(particle); m_outparticles.push_back(particle); break; } } } m_filledblob=true; return true; }
bool Hadron_Remnant::DecomposeHadron() { bool success=true; double Eb(p_beam->Energy()); for (Particle_List::iterator pit=m_extracted.begin(); pit!=m_extracted.end();++pit) { if ((*pit)->Momentum()[0]>Eb || (*pit)->Momentum()[0]<0.0) { msg_Error()<<"Hadron_Remnant::DecomposeHadron(): " <<"Constituent energy out of range. \n E_" <<(*pit)->Flav()<<" = "<<(*pit)->Momentum()[0] <<"."<<std::endl; success=false; } for (size_t j=0;j<m_constit.size();++j) { if ((*pit)->Flav()==m_constit[j]) { //std::cout<<METHOD<<" "<<success<<":"<<(*pit)->Flav() // <<" ("<<ValenceQuark(*pit)<<")"<<std::endl; if (success && ValenceQuark(*pit)) { p_start = new Color_Dipole(*pit,&m_companions); p_start->Begin(ANTI((*pit)->Flav().IsAnti()))-> SetFlav(Opposite((*pit)->Flav())); return success; } } } } Flavour flav = m_constit[(size_t)(ran->Get()*3.)]; Particle * part = new Particle(-1,flav); part->SetStatus(part_status::active); part->SetFinalMass(flav.Mass()); part->SetFlow(COLOR((qri::type)(flav.IsAnti())),Flow::Counter()); //std::cout<<METHOD<<":"<<flav<<std::endl // <<" "<<(*part)<<std::endl; p_start = new Color_Dipole(part,&m_companions); p_start->Begin(ANTI(flav.IsAnti()))->SetFlav(Opposite(flav)); m_companions.push_back(part); return success; }
size_t Colour_Generator:: SelectColourReplacement(Particle * part1,Particle * part2) { bool dir(ran->Get()>=0.5),found(false); size_t beam,index,col,col1,idcol; for (size_t i=0;i<2;i++) { beam = dir?i:1-i; for (index = 1;index<3;index++) { col = (beam==1?part2:part1)->GetFlow(index); for (set<int>::iterator cit=m_col[beam][2-index].begin(); cit!=m_col[beam][2-index].end();cit++) { if (col==(*cit)) { col1 = (beam==1?part1:part2)->GetFlow(3-index); if (col1!=0) { found = false; for (int i=0;i<m_hadrons[1-beam]->GetParticles().size();i++){ if (m_hadrons[1-beam]->GetParticles()[i]->GetFlow(index)==col && m_hadrons[1-beam]->GetParticles()[i]->GetFlow(3-index)!=col1){ found = true; idcol = m_hadrons[1-beam]->GetParticles()[i]->GetFlow(3-index); break; } } break; } } } if (found) break; } if (found) break; } if (!found) return 0; p_compensator = new Blob(p_ladder->Position()*rpa->hBar()*rpa->c()); p_compensator->SetId(); p_compensator->SetType(btp::Soft_Collision); p_compensator->SetTypeSpec("ColourCompensation"); p_compensator->SetStatus(blob_status::inactive); p_compensator->AddToInParticles((beam==1?part2:part1)); (beam==1?part2:part1)->SetStatus(part_status::decayed); Particle * gluon = new Particle(-1,Flavour(kf_gluon),Vec4D(0.,0.,0.,0.),'R'); gluon->SetNumber(); gluon->SetFlow(index,col1); gluon->SetFlow(3-index,col); if (col1==0 || col1==0) msg_Error()<<"Error with colours here (4).\n"; gluon->SetStatus(part_status::decayed); p_compensator->AddToInParticles(gluon); p_blob->AddToOutParticles(gluon); Particle * part= new Particle(*((beam==1?part2:part1))); part->SetNumber(); part->SetFlow(index,col1); if ((part->Flav().IsGluon() && col1==0) || (part->Flav().IsQuark() && part->Flav().IsAnti() && index==2 && col1==0) || (part->Flav().IsQuark() && !part->Flav().IsAnti() && index==1 && col1==0)) msg_Error()<<"Error with colours here (5).\n"; (beam==1?p_ladder->GetIn2():p_ladder->GetIn1())->m_flow.SetCode(index,col1); (beam==1?p_ladder->GetIn2():p_ladder->GetIn1())->p_part = part; for (int i=0;i<p_blob->NInP();i++) { part = p_blob->InParticle(i); if (part->GetFlow(index)==col && part->GetFlow(3-index)==idcol && part->Beam()==(1-beam)){ part->SetFlow(index,col1); break; } if ((part->Flav().IsGluon() && col1==0) || (part->Flav().IsQuark() && part->Flav().IsAnti() && index==2 && col1==0) || (part->Flav().IsQuark() && !part->Flav().IsAnti() && index==1 && col1==0)) msg_Error()<<"Error with colours here (6).\n"; } m_col[beam][2-index].erase(col); m_col[beam][2-index].insert(col1); return (beam==1?3-index:index); }