88 TClonesArray * particle_list = this->
Hadronize(interaction);
90 if(! particle_list ) {
91 LOG(
"AGCharm2023",
pWARN) <<
"Got an empty particle list. Hadronizer failed!";
92 LOG(
"AGCharm2023",
pWARN) <<
"Quitting the current event generation thread";
97 exception.
SetReason(
"Could not simulate the hadronic system");
104 int mom =
event->FinalStateHadronicSystemPosition();
114 const TLorentzVector * had_syst =
event -> Particle(mom) -> P4() ;
115 TVector3 beta( 0., 0., had_syst -> P()/ had_syst -> Energy() ) ;
118 TVector3 unitvq = had_syst -> Vect().Unit();
121 const TLorentzVector & vtx = *(neutrino->
X4());
124 TIter particle_iter(particle_list);
125 while ((particle = (
GHepParticle *) particle_iter.Next())) {
127 int pdgc = particle -> Pdg() ;
130 particle -> P4() -> Boost( beta ) ;
131 particle -> P4() -> RotateUz( unitvq ) ;
144 particle -> SetStatus( ist ) ;
146 int im = mom + 1 + particle -> FirstMother() ;
147 int ifc = ( particle -> FirstDaughter() == -1) ? -1 : mom + 1 + particle -> FirstDaughter();
148 int ilc = ( particle -> LastDaughter() == -1) ? -1 : mom + 1 + particle -> LastDaughter();
150 particle -> SetFirstMother( im ) ;
152 particle -> SetFirstDaughter( ifc ) ;
153 particle -> SetLastDaughter( ilc ) ;
157 particle -> SetPosition( vtx ) ;
159 event->AddParticle(*particle);
162 particle_list -> Delete() ;
163 delete particle_list ;
173 LOG(
"CharmHad",
pNOTICE) <<
"** Running CHARM hadronizer";
181 const InitialState & init_state = interaction -> InitState();
182 const Kinematics & kinematics = interaction -> Kine();
183 const Target & target = init_state.
Tgt();
185 const TLorentzVector & p4Had = kinematics.
HadSystP4();
188 double W = kinematics.
W(
true);
190 TVector3 beta = -1 * p4Had.BoostVector();
191 TLorentzVector p4H(0,0,0,W);
193 double Eh = p4Had.Energy();
195 LOG(
"CharmHad",
pNOTICE) <<
"Ehad (LAB) = " << Eh <<
", W = " << W;
211 TLorentzVector p4C(0,0,0,0);
214 bool got_charmed_hadron =
false;
221 double mc = pdglib->
Find(
pdg)->Mass();
224 <<
"Trying charm hadron = " <<
pdg <<
"(m = " << mc <<
")";
232 double mc2 = TMath::Power(mc,2);
233 double Ec2 = TMath::Power(Ec,2);
234 double pc2 = Ec2-mc2;
237 <<
"Trying charm hadron z = " << z <<
", E = " << Ec;
244 double plc2 = Ec2 - ptc2 - mc2;
246 <<
"Trying charm hadron pT^2 (tranv to pHad) = " << ptc2;
250 double ptc = TMath::Sqrt(ptc2);
251 double plc = TMath::Sqrt(plc2);
253 double pxc = ptc * TMath::Cos(phi);
254 double pyc = ptc * TMath::Sin(phi);
257 p4C.SetPxPyPzE(pxc,pyc,pzc,Ec);
270 TLorentzVector p4 = p4H - p4C;
273 <<
"Invariant mass of remnant hadronic system= " << wr;
275 LOG(
"CharmHad",
pINFO) <<
"Too small hadronic remnant mass!";
280 got_charmed_hadron =
true;
283 <<
"Generated charm hadron = " <<
pdg <<
"(m = " << mc <<
")";
285 <<
"Generated charm hadron z = " << z <<
", E = " << Ec;
296 bool used_lowW_strategy =
false;
297 int fs_nucleon_pdg = -1;
298 if(ch_pdg==-1 && W < 3.){
300 <<
"Had difficulty generating charm hadronic system near W threshold";
302 <<
"Trying an alternative strategy";
304 double qfsl = interaction->
FSPrimLepton()->Charge() / 3.;
305 double qinit = pdglib->
Find(nuc_pdg)->Charge() / 3.;
306 int qhad = (int) (qinit - qfsl);
315 }
else if(qhad == 1) {
321 }
else if(qhad == 0) {
323 }
else if(qhad == -1) {
327 double mc = pdglib->
Find(chrm_pdg)->Mass();
328 double mn = pdglib->
Find(remn_pdg)->Mass();
332 double mass[2] = {mc, mn};
338 for(
int i=0; i<200; i++) {
340 wmax = TMath::Max(wmax,w);
347 bool accept_decay=
false;
348 unsigned int idecay_try=0;
355 <<
"Couldn't generate an unweighted phase space decay after "
356 << idecay_try <<
" attempts";
361 <<
"Decay weight = " << w <<
" > max decay weight = " << wmax;
363 double gw = wmax * rnd->
RndHadro().Rndm();
364 accept_decay = (gw<=w);
367 used_lowW_strategy =
true;
371 fs_nucleon_pdg = remn_pdg;
385 <<
"Couldn't generate charm hadron for: " << *interaction;
389 TLorentzVector p4R = p4H - p4C;
393 LOG(
"CharmHad",
pNOTICE) <<
"Remnant hadronic system mass = " << WR;
401 TClonesArray * particle_list =
new TClonesArray(
"genie::GHepParticle", 2);
402 particle_list->SetOwner(
true);
406 -1,-1,-1,-1, p4C.Px(),p4C.Py(),p4C.Pz(),p4C.E(), 0,0,0,0);
408 -1,-1,-1,-1, p4R.Px(),p4R.Py(),p4R.Pz(),p4R.E(), 0,0,0,0);
410 return particle_list;
418 if(used_lowW_strategy) {
420 TClonesArray * particle_list =
new TClonesArray(
"genie::GHepParticle", 3);
421 particle_list->SetOwner(
true);
425 -1,-1,-1,-1, p4C.Px(),p4C.Py(),p4C.Pz(),p4C.E(), 0,0,0,0);
427 -1,-1,2,2, p4R.Px(),p4R.Py(),p4R.Pz(),p4R.E(), 0,0,0,0);
429 1,1,-1,-1, p4R.Px(),p4R.Py(),p4R.Pz(),p4R.E(), 0,0,0,0);
431 return particle_list;
444 TClonesArray * particle_list =
new TClonesArray(
"genie::GHepParticle");
445 particle_list->SetOwner(
true);
448 -1,-1,-1,-1, p4C.Px(),p4C.Py(),p4C.Pz(),p4C.E(), 0,0,0,0);
450 -1,-1,2,3, p4R.Px(),p4R.Py(),p4R.Pz(),p4R.E(), 0,0,0,0);
452 unsigned int rpos = 2;
454 bool use_pythia = (WR>1.5);
562 if(qrkSyst1 == 0 && qrkSyst2 == 0) {
564 <<
"Couldn't generate quark systems for PYTHIA in: " << *interaction;
568 bool remnant_hadronized = this->
HadronizeRemnant(qrkSyst1,qrkSyst2,WR,p4R,rpos,particle_list);
570 if(!remnant_hadronized) {
571 LOG(
"CharmHad",
pWARN) <<
"Couldn't hadronize (non-charm) remnants!";
593 double qfsl = interaction->
FSPrimLepton()->Charge() / 3.;
594 double qinit = pdglib->
Find(nuc_pdg)->Charge() / 3.;
595 double qch = pdglib->
Find(ch_pdg)->Charge() / 3.;
596 int Q = (int) (qinit - qfsl - qch);
618 pdglib->
Find(pd[0])->Mass(), pdglib->
Find(pd[1])->Mass()
624 LOG(
"CharmHad",
pERROR) <<
" *** Phase space decay is not permitted";
629 for(
int i=0; i<200; i++) {
631 wmax = TMath::Max(wmax,w);
634 LOG(
"CharmHad",
pERROR) <<
" *** Non-positive maximum weight";
635 LOG(
"CharmHad",
pERROR) <<
" *** Can not generate an unweighted phase space decay";
640 <<
"Max phase space gen. weight @ current hadronic system: " << wmax;
644 bool accept_decay=
false;
645 unsigned int idectry=0;
652 <<
"Couldn't generate an unweighted phase space decay after "
653 << itry <<
" attempts";
659 <<
"Decay weight = " << w <<
" > max decay weight = " << wmax;
661 double gw = wmax * rnd->
RndHadro().Rndm();
662 accept_decay = (gw<=w);
664 <<
"Decay weight = " << w <<
" / R = " << gw <<
" - accepted: " << accept_decay;
666 for(
unsigned int i=0; i<2; i++) {
670 pdgc,
kIStStableFinalState,1,1,-1,-1,p4d->Px(),p4d->Py(),p4d->Pz(),p4d->Energy(),
677 return particle_list;
736 bool hadronize_remnants ;
737 GetParamDef(
"HadronizeRemnants", hadronize_remnants,
true ) ;
743 this->
SubAlg(
"FragmentationFunc"));
747 this ->
GetParam(
"PTFunction", pt_function ) ;
749 fCharmPT2pdf =
new TF1(
"fCharmPT2pdf", pt_function.c_str(),0,0.6);
755 std::vector<double> ec, d0frac, dpfrac, dsfrac ;
758 std::vector<std::string> bits ;
760 bool invalid_configuration = false ;
770 if ( d0frac.size() != ec.size() ) {
771 LOG(
"AGCharm2023",
pFATAL) <<
"E entries don't match D0 fraction entries";
772 LOG(
"AGCharm2023",
pFATAL) <<
"E: " << ec.size() ;
773 LOG(
"AGCharm2023",
pFATAL) <<
"D0: " << d0frac.size() ;
774 invalid_configuration = true ;
781 if ( dpfrac.size() != ec.size() ) {
782 LOG(
"AGCharm2023",
pFATAL) <<
"E entries don't match D+ fraction entries";
783 LOG(
"AGCharm2023",
pFATAL) <<
"E: " << ec.size() ;
784 LOG(
"AGCharm2023",
pFATAL) <<
"D+: " << dpfrac.size() ;
785 invalid_configuration = true ;
792 if ( dsfrac.size() != ec.size() ) {
793 LOG(
"AGCharm2023",
pFATAL) <<
"E entries don't match Ds fraction entries";
794 LOG(
"AGCharm2023",
pFATAL) <<
"E: " << ec.size() ;
795 LOG(
"AGCharm2023",
pFATAL) <<
"Ds: " << dsfrac.size() ;
796 invalid_configuration = true ;
808 if ( invalid_configuration ) {
811 <<
"Invalid configuration: Exiting" ;
STDHEP-like event record entry that can fit a particle or a nucleus.
const TLorentzVector * X4(void) const