GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
gtestInteraction.cxx File Reference
#include "Framework/Conventions/Constants.h"
#include "Framework/Interaction/Interaction.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/ParticleData/PDGCodes.h"
Include dependency graph for gtestInteraction.cxx:

Go to the source code of this file.

Functions

int main (int, char **)
 

Function Documentation

int main ( int  ,
char **   
)

Definition at line 28 of file gtestInteraction.cxx.

References genie::Kinematics::ClearRunningValues(), genie::Interaction::InitState(), genie::Interaction::InitStatePtr(), genie::Interaction::KinePtr(), genie::kIntWeakCC, genie::constants::kNucleonMass, genie::kPdgNuMu, genie::kPdgProton, genie::kPdgUQuark, genie::kScDeepInelastic, LOG, pINFO, genie::Target::SetHitNucP4(), genie::Target::SetHitNucPdg(), genie::Target::SetHitQrkPdg(), genie::InitialState::SetProbeP4(), genie::Kinematics::SetQ2(), genie::Kinematics::SetW(), genie::Kinematics::Setx(), genie::Kinematics::Sety(), genie::InitialState::Tgt(), genie::InitialState::TgtPtr(), and genie::Kinematics::UseSelectedKinematics().

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();
76  wtgt->SetHitNucPdg(kPdgProton);
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 }
static const double kNucleonMass
void SetQ2(double Q2, bool selected=false)
Definition: Kinematics.cxx:255
const int kPdgUQuark
Definition: PDGCodes.h:42
const int kPdgNuMu
Definition: PDGCodes.h:30
Generated/set kinematical variables for an event.
Definition: Kinematics.h:39
Summary information for an interaction.
Definition: Interaction.h:56
void UseSelectedKinematics(void)
Definition: Kinematics.cxx:359
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
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
#define pINFO
Definition: Messenger.h:62
void Setx(double x, bool selected=false)
Definition: Kinematics.cxx:231
void SetW(double W, bool selected=false)
Definition: Kinematics.cxx:279
void SetHitNucPdg(int pdgc)
Definition: Target.cxx:171
void Sety(double y, bool selected=false)
Definition: Kinematics.cxx:243
const int kPdgProton
Definition: PDGCodes.h:81
void ClearRunningValues(void)
Definition: Kinematics.cxx:347
Initial State information.
Definition: InitialState.h:48