GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NucBindEnergyAggregator.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2024, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6 
7  Costas Andreopoulos <c.andreopoulos \at cern.ch>
8  University of Liverpool - November 19, 2004
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13 
14 */
15 //____________________________________________________________________________
16 
17 #include <TLorentzVector.h>
18 
31 
32 using namespace genie;
33 using namespace genie::constants;
34 
35 //___________________________________________________________________________
37 EventRecordVisitorI("genie::NucBindEnergyAggregator")
38 {
39 
40 }
41 //___________________________________________________________________________
43 EventRecordVisitorI("genie::NucBindEnergyAggregator", config)
44 {
45 
46 }
47 //___________________________________________________________________________
49 {
50 
51 }
52 //___________________________________________________________________________
54 {
55  // Return if the neutrino was not scatterred off a nuclear target
56  GHepParticle * nucltgt = evrec->TargetNucleus();
57  if (!nucltgt) {
58  LOG("Nuclear", pINFO)
59  << "No nuclear target found - Not subtracting any binding energy";
60  return;
61  }
62 
63  // Loop over particles, find final state nucleons for which a removal
64  // energy has been set and subtract it from their energy
65  TIter stdhep_iter(evrec);
66  GHepParticle * p = 0;
67 
68  while( (p = (GHepParticle * ) stdhep_iter.Next()) ) {
69 
70  bool is_nucleon = pdg::IsNeutronOrProton(p->Pdg());
71  bool in_fin_state = (p->Status() == kIStStableFinalState);
72  bool had_bind_e = (p->RemovalEnergy() > 0.);
73 
74  bool handle = is_nucleon && in_fin_state && had_bind_e;
75  if(!handle) continue;
76 
77  //-- ask for the binding energy set by the nuclear model
78  double bindE = p->RemovalEnergy();
79  LOG("Nuclear", pINFO) << "Binding energy = " << bindE;
80 
81  //-- subtract this energy from the final state nucleon
82  LOG("Nuclear", pINFO)
83  << "Subtracting the binding energy from the escaped nucleon";
84 
85  double M = p->Mass();
86  double En = p->Energy();
87  double KE = En-M;
88 
89  LOG("Nuclear", pINFO) << "Kinetic energy before subtraction = " << KE;
90  KE -= bindE;
91 
92  LOG("Nuclear", pINFO) << "Kinetic energy after subtraction = " << KE;
93 
94  En = KE+M;
95 
96  if(En>M || !fAllowRecombination) {
97  double pmag_old = p->P4()->P();
98  double pmag_new = TMath::Sqrt(utils::math::NonNegative(En*En-M*M));
99  double scale = pmag_new / pmag_old;
100  LOG("Nuclear", pINFO)
101  << "|pnew| = " << pmag_new << ", |pold| = " << pmag_old
102  << ", scale = " << scale;
103 
104  double pxn = scale * p->Px();
105  double pyn = scale * p->Py();
106  double pzn = scale * p->Pz();
107 
108  double pxb = (1-scale) * p->Px();
109  double pyb = (1-scale) * p->Py();
110  double pzb = (1-scale) * p->Pz();
111 
112  p->SetEnergy ( En );
113  p->SetPx ( pxn );
114  p->SetPy ( pyn );
115  p->SetPz ( pzn );
116  p->SetRemovalEnergy(0);
117 
118  //-- and add a GHEP entry to record this in the event record and
119  // conserve energy/momentum
120  LOG("Nuclear", pINFO)
121  << "Adding a [BindingE] to account for nuclear binding energy";
122 
124  -1,-1,-1,-1, pxb,pyb,pzb,bindE, 0,0,0,0);
125  } else {
126  LOG("Nuclear", pNOTICE)
127  << "Nucleon is above the Fermi sea but can't escape the nucleus";
128  LOG("Nuclear", pNOTICE)
129  << "Recombining remnant nucleus + f/s nucleon";
130 
131 
132  // find the remnant nucleus if corresponding cascade modules provide it
133  int rnucpos = evrec->RemnantNucleusPosition();
134 
135  if (rnucpos != -1)
136  {
137  GHepParticle * rnucl = evrec->Particle(rnucpos);
138 
139  // mark both the remnant nucleus and the final state nucleon as
140  // intermediate states
141  rnucl -> SetStatus(kIStIntermediateState);
142  p -> SetStatus(kIStIntermediateState);
143 
144  // figure out the recombined nucleus PDG code
145  int Z = rnucl->Z();
146  int A = rnucl->A();
147  if(pdg::IsProton(p->Pdg())) Z++;
148  A++;
149  int ipdgc = pdg::IonPdgCode(A,Z);
150 
151  // add-up their 4-momenta
152  double pxnuc = rnucl->Px() + p->Px();
153  double pynuc = rnucl->Py() + p->Py();
154  double pznuc = rnucl->Pz() + p->Pz();
155  double Enuc = rnucl->E() + p->E();
156 
157  evrec->AddParticle(ipdgc, kIStStableFinalState,
158  rnucpos,-1,-1,-1, pxnuc,pynuc,pznuc,Enuc, 0,0,0,0);
159  }
160  else
161  {
162  // Find hadronic blob which is provided by Intranuke models
164  // If there is no hadronic blob do nothing
165  if (hblob == nullptr) return;
166  p -> SetStatus(kIStIntermediateState);
167 
168  // add-up their 4-momenta
169  double pxhblob = hblob->Px() + p->Px();
170  double pyhblob = hblob->Py() + p->Py();
171  double pzhblob = hblob->Pz() + p->Pz();
172  double Ehblob = hblob->E() + p->E();
173  hblob->SetMomentum(pxhblob, pyhblob, pzhblob, Ehblob);
174  }
175  }
176  }
177 }
178 //___________________________________________________________________________
179 /*
180 GHepParticle * NucBindEnergyAggregator::FindMotherNucleus(
181  int ipos, GHepRecord * evrec) const
182 {
183  GHepParticle * p = evrec->Particle(ipos);
184 
185  //-- get its mothet
186  int mother_pos = p->FirstMother();
187 
188  //-- if mother is set
189  if(mother_pos != -1) {
190  GHepParticle * mother = evrec->Particle(mother_pos);
191 
192  //-- check its status
193  if( mother->Status() == kIStNucleonTarget ) {
194 
195  //-- get the mother's mother
196  int grandmother_pos = mother->FirstMother();
197 
198  //-- if grandmother is set get its PDG code a check if it is an ion
199  if(grandmother_pos != -1) {
200  GHepParticle * grandmother =
201  evrec->Particle(grandmother_pos);
202 
203  int grandmother_pdgc = grandmother->Pdg();
204  if( pdg::IsIon(grandmother_pdgc) ) return grandmother;
205 
206  } // gmpos != -1
207  } // mother-status
208  } //mpos != -1
209 
210  return 0;
211 } */
212 //___________________________________________________________________________
214 {
215  Algorithm::Configure(config);
216  this->LoadConfig();
217 }
218 //____________________________________________________________________________
220 {
221  Algorithm::Configure(config);
222  this->LoadConfig();
223 }
224 //____________________________________________________________________________
226 {
227  GetParamDef("AllowNuclRecombination",fAllowRecombination, true ) ;
228 
229 }
230 //____________________________________________________________________________
231 
int Z(void) const
virtual GHepParticle * Particle(int position) const
Definition: GHepRecord.cxx:104
double E(void) const
Get energy.
Definition: GHepParticle.h:91
void SetPz(double pz)
virtual GHepParticle * FindParticle(int pdg, GHepStatus_t ist, int start) const
Definition: GHepRecord.cxx:118
const TLorentzVector * P4(void) const
Definition: GHepParticle.h:78
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the &#39;Visito...
const int kPdgHadronicBlob
Definition: PDGCodes.h:211
virtual int RemnantNucleusPosition(void) const
Definition: GHepRecord.cxx:397
const int kPdgBindino
Definition: PDGCodes.h:212
void SetMomentum(const TLorentzVector &p4)
double RemovalEnergy(void) const
Get removal energy.
Definition: GHepParticle.h:100
double Mass(void) const
Mass that corresponds to the PDG code.
double Pz(void) const
Get Pz.
Definition: GHepParticle.h:90
GHepStatus_t Status(void) const
Definition: GHepParticle.h:64
void SetPx(double px)
double Energy(void) const
Get energy.
Definition: GHepParticle.h:92
double Px(void) const
Get Px.
Definition: GHepParticle.h:88
int Pdg(void) const
Definition: GHepParticle.h:63
bool IsProton(int pdgc)
Definition: PDGUtils.cxx:336
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static constexpr double A
Definition: Units.h:74
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void Configure(const Registry &config)
virtual GHepParticle * TargetNucleus(void) const
Definition: GHepRecord.cxx:293
#define pINFO
Definition: Messenger.h:62
void SetRemovalEnergy(double Erm)
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
bool IsNeutronOrProton(int pdgc)
Definition: PDGUtils.cxx:351
int IonPdgCode(int A, int Z)
Definition: PDGUtils.cxx:71
virtual void AddParticle(const GHepParticle &p)
Definition: GHepRecord.cxx:499
double NonNegative(double x)
Definition: MathUtils.cxx:273
int A(void) const
#define pNOTICE
Definition: Messenger.h:61
bool GetParamDef(const RgKey &name, T &p, const T &def) const
void SetEnergy(double E)
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:45
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
void SetPy(double py)
void ProcessEventRecord(GHepRecord *event_rec) const
double Py(void) const
Get Py.
Definition: GHepParticle.h:89