GENIEGenerator
Loading...
Searching...
No Matches
InitialStateAppender.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <c.andreopoulos \at cern.ch>
7 University of Liverpool
8*/
9//____________________________________________________________________________
10
11#include <TLorentzVector.h>
12
22
23using namespace genie;
24
25//___________________________________________________________________________
27EventRecordVisitorI("genie::InitialStateAppender")
28{
29
30}
31//___________________________________________________________________________
33EventRecordVisitorI("genie::InitialStateAppender", config)
34{
35
36}
37//___________________________________________________________________________
42//___________________________________________________________________________
44{
45// Adds the initial state particles at the event record (the order is
46// significant)
47
48 LOG("ISApp", pINFO) << "Adding the initial state to the event record";
49
50 //-- add the incoming neutrino to the event record
51 this->AddNeutrino(evrec);
52
53 //-- add the nuclear target at the event record (if any)
54 this->AddNucleus(evrec);
55
56 //-- add the struck nucleon to the event record (if any)
57 // It is added with status-code = 0 (init state) if the target was a
58 // free nucleon, or with a status-code = 11 (nucleon target) if the
59 // target was a nucleus.
60 // If the interaction was ve- elastic, inverse muon decay or Glashow
61 // resonance then it will add the target e- instead.
62 this->AddStruckParticle(evrec);
63 LOG("ISApp", pINFO) << *evrec;
64}
65//___________________________________________________________________________
67{
68 Interaction * interaction = evrec->Summary();
69 const InitialState & init_state = interaction->InitState();
70
71 TLorentzVector * p4 = init_state.GetProbeP4(kRfLab);
72 const TLorentzVector v4(0.,0.,0.,0.);
73
74 int pdgc = init_state.ProbePdg();
75
76 LOG("ISApp", pINFO) << "Adding neutrino [pdgc = " << pdgc << "]";
77
78 evrec->AddParticle(pdgc,kIStInitialState, -1,-1,-1,-1, *p4, v4);
79
80 delete p4;
81}
82//___________________________________________________________________________
84{
85 Interaction * interaction = evrec->Summary();
86 const InitialState & init_state = interaction->InitState();
87 const ProcessInfo & proc_info = interaction->ProcInfo();
88
89 bool is_nucleus = init_state.Tgt().IsNucleus() || proc_info.IsNorm();
90 if(!is_nucleus && !proc_info.IsGlashowResonance() && !proc_info.IsPhotonCoherent()) {
91 LOG("ISApp", pINFO)
92 << "Not an interaction with a nuclear target - no nucleus to add";
93 return;
94 }
95 int A = init_state.Tgt().A();
96 int Z = init_state.Tgt().Z();
97 int pdgc = pdg::IonPdgCode(A, Z);
98 double M = PDGLibrary::Instance()->Find(pdgc)->Mass();
99
100 LOG("ISApp", pINFO)
101 << "Adding nucleus [A = " << A << ", Z = " << Z
102 << ", pdg = " << pdgc << "]";
103
104 evrec->AddParticle(pdgc,kIStInitialState,-1,-1,-1,-1, 0,0,0,M, 0,0,0,0);
105}
106//___________________________________________________________________________
108{
109 Interaction * interaction = evrec->Summary();
110 const InitialState & init_state = interaction->InitState();
111 const ProcessInfo & proc_info = interaction->ProcInfo();
112
113 // EDIT: Add the dark matter scattering off electron here
114 bool hit_e = proc_info.IsInverseMuDecay() ||
115 proc_info.IsIMDAnnihilation() ||
116 proc_info.IsNuElectronElastic() ||
117 proc_info.IsDarkMatterElectronElastic() ||
118 proc_info.IsGlashowResonance();
119
120 if(hit_e) {
121 int pdgc = kPdgElectron;
122 double mass = PDGLibrary::Instance()->Find(pdgc)->Mass();
123 const TLorentzVector p4(0,0,0, mass);
124 const TLorentzVector v4(0.,0.,0.,0.);
125
126 LOG("ISApp", pINFO) << "Adding struck electron";
127 evrec->AddParticle(pdgc, kIStInitialState, 1, -1, -1, -1, p4, v4);
128 return;
129 }
130
131 int pdgc = init_state.Tgt().HitNucPdg();
132
133 if(pdgc != 0) {
134
135 bool is_nucleus = init_state.Tgt().IsNucleus();
136
137 GHepStatus_t ist = (is_nucleus) ? kIStNucleonTarget : kIStInitialState;
138 int imom1 = (is_nucleus) ? 1 : -1;
139 int imom2 = -1;
140
141 const TLorentzVector p4(init_state.Tgt().HitNucP4());
142 const TLorentzVector v4(0.,0.,0.,0.);
143
144 LOG("ISApp", pINFO)<< "Adding struck nucleon [pdgc = " << pdgc << "]";
145
146 evrec->AddParticle(pdgc, ist, imom1, imom2, -1, -1, p4, v4);
147
148 }//if struck nucleon was set
149}
150//___________________________________________________________________________
#define pINFO
Definition Messenger.h:62
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils.
GENIE's GHEP MC event record.
Definition GHepRecord.h:45
virtual Interaction * Summary(void) const
virtual void AddParticle(const GHepParticle &p)
void AddNucleus(GHepRecord *event_rec) const
void ProcessEventRecord(GHepRecord *event_rec) const
void AddNeutrino(GHepRecord *event_rec) const
void AddStruckParticle(GHepRecord *event_rec) const
Initial State information.
TLorentzVector * GetProbeP4(RefFrame_t rf=kRfHitNucRest) const
const Target & Tgt(void) const
int ProbePdg(void) const
Summary information for an interaction.
Definition Interaction.h:56
const ProcessInfo & ProcInfo(void) const
Definition Interaction.h:70
const InitialState & InitState(void) const
Definition Interaction.h:69
static PDGLibrary * Instance(void)
TParticlePDG * Find(int pdgc, bool must_exist=true)
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
Definition ProcessInfo.h:46
bool IsNuElectronElastic(void) const
bool IsNorm(void) const
bool IsInverseMuDecay(void) const
bool IsPhotonCoherent(void) const
bool IsDarkMatterElectronElastic(void) const
bool IsIMDAnnihilation(void) const
bool IsGlashowResonance(void) const
int HitNucPdg(void) const
Definition Target.cxx:304
const TLorentzVector & HitNucP4(void) const
Definition Target.h:91
int Z(void) const
Definition Target.h:68
int A(void) const
Definition Target.h:70
bool IsNucleus(void) const
Definition Target.cxx:272
int IonPdgCode(int A, int Z)
Definition PDGUtils.cxx:71
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
@ kIStInitialState
Definition GHepStatus.h:29
@ kIStNucleonTarget
Definition GHepStatus.h:34
enum genie::EGHepStatus GHepStatus_t
@ kRfLab
Definition RefFrame.h:26
const int kPdgElectron
Definition PDGCodes.h:35