GENIEGenerator
Loading...
Searching...
No Matches
gtestInteraction.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*!
3
4\program gtestInteraction
5
6\brief Program used for testing / debugging the Interaction and its aggregate
7 objects (InitialState, ProcessInfo, Kinematics, XclsTag)
8
9\author Costas Andreopoulos <C.V.Andreopoulos@@rl.ac.uk>
10 University of Liverpool
11
12\created May 4, 2004
13
14\cpright Copyright (c) 2003-2025, The GENIE Collaboration
15 For the full text of the license visit http://copyright.genie-mc.org
16
17*/
18//____________________________________________________________________________
19
24
25using namespace genie;
26using namespace genie::constants;
27
28int main(int /*argc*/, char ** /*argv*/)
29{
30 //-- build an initial state
31 Target Fe(26,56);
32 int numu(kPdgNuMu);
33 TLorentzVector pnu(0,0,8,8);
34 InitialState init_state(Fe, numu);
35
36 init_state.SetProbeP4(pnu);
37
38 //-- build process info
40
41 //-- create an interaction & print it
42 Interaction interaction(init_state, proc);
43
44 LOG("test", pINFO) << "Printing an interaction object";
45 LOG("test", pINFO) << interaction;
46
47 //-- set struck nucleon & quark info in the initial state's Target
48 // note: using methods ending in Ptr -> they return a 'writable'
49 // object that can be modified
50
51 TLorentzVector pnucl(0,0,0,kNucleonMass);
52
53 interaction.InitStatePtr()->TgtPtr()->SetHitNucP4(pnucl);
54 interaction.InitStatePtr()->TgtPtr()->SetHitNucPdg(kPdgProton);
55 interaction.InitStatePtr()->TgtPtr()->SetHitQrkPdg(kPdgUQuark);
56
57 //-- get a 'read-only' InitialState and print it (check that struck nucleon
58 // and quark were set)
59 // note: using the methods not ending in Ptr to get a 'read-only' object
60
61 const InitialState & cinit = interaction.InitState();
62
63 LOG("test", pINFO) << "Printing initial state after setting struck nucl/qrk";
64 LOG("test", pINFO) << "\n" << cinit;
65
66 //-- take just the Target from the initial state and print it
67
68 LOG("test", pINFO) << "Printing target after setting struck nucl/qrk";
69 const Target & ctgt = interaction.InitState().Tgt();
70 LOG("test", pINFO) << "\n" <<ctgt;
71
72 //-- change the struck nucleon
73 //-- instead of using the long syntax above, get a writable Target object first
74
75 Target * wtgt = interaction.InitStatePtr()->TgtPtr();
77
78 LOG("test", pINFO) << "Printing target after changing struck nucl";
79 LOG("test", pINFO) << "\n" << *wtgt;
80
81 //-- take the Kinematics object and set some
82
83 Kinematics * wkine = interaction.KinePtr();
84
85 wkine->Setx(0.1781);
86 wkine->Sety(0.6892);
87 wkine->SetQ2(3.2218);
88
89 LOG("test", pINFO) << "Printing kinematics after setting x,y,Q2";
90 LOG("test", pINFO) << "\n" <<*wkine;
91
92 //-- modify some & add a new
93 wkine->Setx(0.2);
94 wkine->Sety(0.2);
95 wkine->SetW(1.9219);
96
97 LOG("test", pINFO) << "Printing kinematics after modifying x,y and adding W";
98 LOG("test", pINFO) << "\n" << *wkine;
99
100 //-- now set "selected" kinematics
101 wkine->Setx(0.25, true);
102 wkine->Sety(0.21, true);
103 wkine->SetW(2.89, true);
104
105 LOG("test", pINFO) << "Printing kinematics after setting 'selected'";
106 LOG("test", pINFO) << "\n" << *wkine;
107
108 //-- now delete 'running' kinematics
109 wkine->ClearRunningValues();
110
111 LOG("test", pINFO) << "Printing kinematics after deleting 'running'";
112 LOG("test", pINFO) << "\n" << *wkine;
113
114 //-- copy the 'selected' kinematics to the 'running' ones
115 wkine->UseSelectedKinematics();
116
117 LOG("test", pINFO) << "Printing kinematics after copying 'selected'";
118 LOG("test", pINFO) << "\n" << *wkine;
119
120 //-- see that the interaction was updated
121
122 LOG("test", pINFO) << "Printing the interaction object after all changes";
123 LOG("test", pINFO) << interaction;
124}
125
#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.
int main()
Initial State information.
const Target & Tgt(void) const
void SetProbeP4(const TLorentzVector &P4)
Target * TgtPtr(void) const
Summary information for an interaction.
Definition Interaction.h:56
InitialState * InitStatePtr(void) const
Definition Interaction.h:74
const InitialState & InitState(void) const
Definition Interaction.h:69
Kinematics * KinePtr(void) const
Definition Interaction.h:76
Generated/set kinematical variables for an event.
Definition Kinematics.h:39
void Setx(double x, bool selected=false)
void SetQ2(double Q2, bool selected=false)
void ClearRunningValues(void)
void Sety(double y, bool selected=false)
void SetW(double W, bool selected=false)
void UseSelectedKinematics(void)
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
Definition ProcessInfo.h:46
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition Target.h:40
void SetHitNucP4(const TLorentzVector &p4)
Definition Target.cxx:189
void SetHitQrkPdg(int pdgc)
Definition Target.cxx:184
void SetHitNucPdg(int pdgc)
Definition Target.cxx:171
Basic constants.
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
const int kPdgUQuark
Definition PDGCodes.h:42
const int kPdgProton
Definition PDGCodes.h:81
@ kScDeepInelastic
const int kPdgNuMu
Definition PDGCodes.h:30