InitialStateAppender.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13  @ Dec 14, 2009 - CA
14  Include the struck e- for Glashow resonance reactions.
15  @ Feb 12, 2013 - CA (code from Rosen Matev)
16  Handle the IMD annihilation channel.
17 
18 */
19 //____________________________________________________________________________
20 
21 #include <TLorentzVector.h>
22 
32 
33 using namespace genie;
34 
35 //___________________________________________________________________________
37 EventRecordVisitorI("genie::InitialStateAppender")
38 {
39 
40 }
41 //___________________________________________________________________________
43 EventRecordVisitorI("genie::InitialStateAppender", config)
44 {
45 
46 }
47 //___________________________________________________________________________
49 {
50 
51 }
52 //___________________________________________________________________________
54 {
55 // Adds the initial state particles at the event record (the order is
56 // significant)
57 
58  LOG("ISApp", pINFO) << "Adding the initial state to the event record";
59 
60  //-- add the incoming neutrino to the event record
61  this->AddNeutrino(evrec);
62 
63  //-- add the nuclear target at the event record (if any)
64  this->AddNucleus(evrec);
65 
66  //-- add the struck nucleon to the event record (if any)
67  // It is added with status-code = 0 (init state) if the target was a
68  // free nucleon, or with a status-code = 11 (nucleon target) if the
69  // target was a nucleus.
70  // If the interaction was ve- elastic, inverse muon decay or Glashow
71  // resonance then it will add the target e- instead.
72  this->AddStruckParticle(evrec);
73 }
74 //___________________________________________________________________________
76 {
77  Interaction * interaction = evrec->Summary();
78  const InitialState & init_state = interaction->InitState();
79 
80  TLorentzVector * p4 = init_state.GetProbeP4(kRfLab);
81  const TLorentzVector v4(0.,0.,0.,0.);
82 
83  int pdgc = init_state.ProbePdg();
84 
85  LOG("ISApp", pINFO) << "Adding neutrino [pdgc = " << pdgc << "]";
86 
87  evrec->AddParticle(pdgc,kIStInitialState, -1,-1,-1,-1, *p4, v4);
88 
89  delete p4;
90 }
91 //___________________________________________________________________________
93 {
94  Interaction * interaction = evrec->Summary();
95  const InitialState & init_state = interaction->InitState();
96 
97  bool is_nucleus = init_state.Tgt().IsNucleus();
98  if(!is_nucleus) {
99  LOG("ISApp", pINFO)
100  << "Not an interaction with a nuclear target - no nucleus to add";
101  return;
102  }
103  int A = init_state.Tgt().A();
104  int Z = init_state.Tgt().Z();
105  int pdgc = pdg::IonPdgCode(A, Z);
106  double M = PDGLibrary::Instance()->Find(pdgc)->Mass();
107 
108  LOG("ISApp", pINFO)
109  << "Adding nucleus [A = " << A << ", Z = " << Z
110  << ", pdg = " << pdgc << "]";
111 
112  evrec->AddParticle(pdgc,kIStInitialState,-1,-1,-1,-1, 0,0,0,M, 0,0,0,0);
113 }
114 //___________________________________________________________________________
116 {
117  Interaction * interaction = evrec->Summary();
118  const InitialState & init_state = interaction->InitState();
119  const ProcessInfo & proc_info = interaction->ProcInfo();
120 
121  bool hit_e = proc_info.IsInverseMuDecay() ||
122  proc_info.IsIMDAnnihilation() ||
123  proc_info.IsNuElectronElastic() ||
124  proc_info.IsGlashowResonance();
125 
126  if(hit_e) {
127  int pdgc = kPdgElectron;
128  double mass = PDGLibrary::Instance()->Find(pdgc)->Mass();
129  const TLorentzVector p4(0,0,0, mass);
130  const TLorentzVector v4(0.,0.,0.,0.);
131 
132  LOG("ISApp", pINFO) << "Adding struck electron";
133  evrec->AddParticle(pdgc, kIStInitialState, 1, -1, -1, -1, p4, v4);
134  return;
135  }
136 
137  int pdgc = init_state.Tgt().HitNucPdg();
138 
139  if(pdgc != 0) {
140 
141  bool is_nucleus = init_state.Tgt().IsNucleus();
142 
143  GHepStatus_t ist = (is_nucleus) ? kIStNucleonTarget : kIStInitialState;
144  int imom1 = (is_nucleus) ? 1 : -1;
145  int imom2 = -1;
146 
147  const TLorentzVector p4(init_state.Tgt().HitNucP4());
148  const TLorentzVector v4(0.,0.,0.,0.);
149 
150  LOG("ISApp", pINFO)<< "Adding struck nucleon [pdgc = " << pdgc << "]";
151 
152  evrec->AddParticle(pdgc, ist, imom1, imom2, -1, -1, p4, v4);
153 
154  }//if struck nucleon was set
155 }
156 //___________________________________________________________________________
void AddNeutrino(GHepRecord *event_rec) const
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
void ProcessEventRecord(GHepRecord *event_rec) const
virtual Interaction * Summary(void) const
Definition: GHepRecord.cxx:135
int HitNucPdg(void) const
Definition: Target.cxx:321
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the &#39;Visito...
int A(void) const
Definition: Target.h:71
bool IsInverseMuDecay(void) const
enum genie::EGHepStatus GHepStatus_t
bool IsNucleus(void) const
Definition: Target.cxx:289
Definition: config.py:1
bool IsIMDAnnihilation(void) const
const int kPdgElectron
Definition: PDGCodes.h:35
void AddNucleus(GHepRecord *event_rec) const
Float_t Z
Definition: plot.C:38
Summary information for an interaction.
Definition: Interaction.h:56
const TLorentzVector & HitNucP4(void) const
Definition: Target.h:92
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
void AddStruckParticle(GHepRecord *event_rec) const
bool IsNuElectronElastic(void) const
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
Definition: ProcessInfo.h:44
int ProbePdg(void) const
Definition: InitialState.h:65
int Z(void) const
Definition: Target.h:69
#define pINFO
Definition: Messenger.h:63
static const double A
Definition: Units.h:82
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:43
TParticlePDG * Find(int pdgc)
Definition: PDGLibrary.cxx:61
int IonPdgCode(int A, int Z)
Definition: PDGUtils.cxx:69
virtual void AddParticle(const GHepParticle &p)
Definition: GHepRecord.cxx:535
const InitialState & InitState(void) const
Definition: Interaction.h:69
const ProcessInfo & ProcInfo(void) const
Definition: Interaction.h:70
const Target & Tgt(void) const
Definition: InitialState.h:67
bool IsGlashowResonance(void) const
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:46
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
TLorentzVector * GetProbeP4(RefFrame_t rf=kRfHitNucRest) const
Initial State information.
Definition: InitialState.h:49