InitialStateAppender.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7  University of Liverpool & STFC Rutherford Appleton Laboratory
8 */
9 //____________________________________________________________________________
10 
11 #include <TLorentzVector.h>
12 
22 
23 using namespace genie;
24 
25 //___________________________________________________________________________
27 EventRecordVisitorI("genie::InitialStateAppender")
28 {
29 
30 }
31 //___________________________________________________________________________
33 EventRecordVisitorI("genie::InitialStateAppender", config)
34 {
35 
36 }
37 //___________________________________________________________________________
39 {
40 
41 }
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();
90  if(!is_nucleus && !proc_info.IsGlashowResonance()) {
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 //___________________________________________________________________________
void AddNeutrino(GHepRecord *event_rec) const
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
void ProcessEventRecord(GHepRecord *event_rec) const
bool IsDarkMatterElectronElastic(void) const
virtual Interaction * Summary(void) const
Definition: GHepRecord.cxx:91
int HitNucPdg(void) const
Definition: Target.cxx:304
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the &#39;Visito...
int A(void) const
Definition: Target.h:70
bool IsInverseMuDecay(void) const
bool IsNucleus(void) const
Definition: Target.cxx:272
bool IsIMDAnnihilation(void) const
const int kPdgElectron
Definition: PDGCodes.h:35
void AddNucleus(GHepRecord *event_rec) const
Summary information for an interaction.
Definition: Interaction.h:56
const TLorentzVector & HitNucP4(void) const
Definition: Target.h:91
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void AddStruckParticle(GHepRecord *event_rec) const
bool IsNuElectronElastic(void) const
static Config * config
Definition: config.cpp:1054
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
Definition: ProcessInfo.h:46
int ProbePdg(void) const
Definition: InitialState.h:64
int Z(void) const
Definition: Target.h:68
#define pINFO
Definition: Messenger.h:62
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:57
int IonPdgCode(int A, int Z)
Definition: PDGUtils.cxx:68
#define A
Definition: memgrp.cpp:38
virtual void AddParticle(const GHepParticle &p)
Definition: GHepRecord.cxx:491
const InitialState & InitState(void) const
Definition: Interaction.h:69
const ProcessInfo & ProcInfo(void) const
Definition: Interaction.h:70
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:75
const Target & Tgt(void) const
Definition: InitialState.h:66
bool IsGlashowResonance(void) const
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...
TLorentzVector * GetProbeP4(RefFrame_t rf=kRfHitNucRest) const
enum genie::EGHepStatus GHepStatus_t
Initial State information.
Definition: InitialState.h:48