GENIEGenerator
Loading...
Searching...
No Matches
genie::PhysInteractionSelector Class Reference

Selects interactions to be generated. More...

#include <PhysInteractionSelector.h>

Inheritance diagram for genie::PhysInteractionSelector:
[legend]
Collaboration diagram for genie::PhysInteractionSelector:
[legend]

Public Member Functions

 PhysInteractionSelector ()
 PhysInteractionSelector (string config)
 ~PhysInteractionSelector ()
EventRecordSelectInteraction (const InteractionGeneratorMap *igmp, const TLorentzVector &p4) const
 implement the InteractionSelectorI interface
void Configure (const Registry &config)
void Configure (string param_set)
Public Member Functions inherited from genie::InteractionSelectorI
virtual ~InteractionSelectorI ()
Public Member Functions inherited from genie::Algorithm
virtual ~Algorithm ()
virtual void FindConfig (void)
virtual const RegistryGetConfig (void) const
RegistryGetOwnedConfig (void)
virtual const AlgIdId (void) const
 Get algorithm ID.
virtual AlgStatus_t GetStatus (void) const
 Get algorithm status.
virtual bool AllowReconfig (void) const
virtual AlgCmp_t Compare (const Algorithm *alg) const
 Compare with input algorithm.
virtual void SetId (const AlgId &id)
 Set algorithm ID.
virtual void SetId (string name, string config)
const AlgorithmSubAlg (const RgKey &registry_key) const
void AdoptConfig (void)
void AdoptSubstructure (void)
virtual void Print (ostream &stream) const
 Print algorithm info.

Private Member Functions

void LoadConfigData (void)

Private Attributes

bool fUseSplines

Additional Inherited Members

Static Public Member Functions inherited from genie::Algorithm
static string BuildParamVectKey (const std::string &comm_name, unsigned int i)
static string BuildParamVectSizeKey (const std::string &comm_name)
static string BuildParamMatKey (const std::string &comm_name, unsigned int i, unsigned int j)
static string BuildParamMatRowSizeKey (const std::string &comm_name)
static string BuildParamMatColSizeKey (const std::string &comm_name)
Protected Member Functions inherited from genie::InteractionSelectorI
 InteractionSelectorI ()
 InteractionSelectorI (string name)
 InteractionSelectorI (string name, string config)
Protected Member Functions inherited from genie::Algorithm
 Algorithm ()
 Algorithm (string name)
 Algorithm (string name, string config)
void Initialize (void)
void DeleteConfig (void)
void DeleteSubstructure (void)
RegistryExtractLocalConfig (const Registry &in) const
RegistryExtractLowerConfig (const Registry &in, const string &alg_key) const
 Split an incoming configuration Registry into a block valid for the sub-algo identified by alg_key.
template<class T>
bool GetParam (const RgKey &name, T &p, bool is_top_call=true) const
template<class T>
bool GetParamDef (const RgKey &name, T &p, const T &def) const
template<class T>
int GetParamVect (const std::string &comm_name, std::vector< T > &v, bool is_top_call=true) const
 Handle to load vectors of parameters.
int GetParamVectKeys (const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
template<class T>
int GetParamMat (const std::string &comm_name, TMatrixT< T > &mat, bool is_top_call=true) const
 Handle to load matrix of parameters.
template<class T>
int GetParamMatSym (const std::string &comm_name, TMatrixTSym< T > &mat, bool is_top_call=true) const
int GetParamMatKeys (const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
int AddTopRegistry (Registry *rp, bool owns=true)
 add registry with top priority, also update ownership
int AddLowRegistry (Registry *rp, bool owns=true)
 add registry with lowest priority, also update ownership
int MergeTopRegistry (const Registry &r)
int AddTopRegisties (const vector< Registry * > &rs, bool owns=false)
 Add registries with top priority, also udated Ownerships.
Protected Attributes inherited from genie::Algorithm
bool fAllowReconfig
bool fOwnsSubstruc
 true if it owns its substructure (sub-algs,...)
AlgId fID
 algorithm name and configuration set
vector< Registry * > fConfVect
vector< bool > fOwnerships
 ownership for every registry in fConfVect
AlgStatus_t fStatus
 algorithm execution status
AlgMapfOwnedSubAlgMp
 local pool for owned sub-algs (taken out of the factory pool)

Detailed Description

Selects interactions to be generated.

    Is a concrete implementation of the InteractionSelectorI interface.
Author
Costas Andreopoulos <c.andreopoulos \at cern.ch> University of Liverpool
Created:\n January 25, 2005
License:\n Copyright (c) 2003-2025, The GENIE Collaboration
For the full text of the license visit http://copyright.genie-mc.org

Definition at line 27 of file PhysInteractionSelector.h.

Constructor & Destructor Documentation

◆ PhysInteractionSelector() [1/2]

PhysInteractionSelector::PhysInteractionSelector ( )

Definition at line 42 of file PhysInteractionSelector.cxx.

42 :
43InteractionSelectorI("genie::PhysInteractionSelector")
44{
45
46}

References genie::InteractionSelectorI::InteractionSelectorI().

◆ PhysInteractionSelector() [2/2]

PhysInteractionSelector::PhysInteractionSelector ( string config)

Definition at line 48 of file PhysInteractionSelector.cxx.

48 :
49InteractionSelectorI("genie::PhysInteractionSelector", config)
50{
51
52}

References genie::InteractionSelectorI::InteractionSelectorI().

◆ ~PhysInteractionSelector()

PhysInteractionSelector::~PhysInteractionSelector ( )

Definition at line 54 of file PhysInteractionSelector.cxx.

55{
56
57}

Member Function Documentation

◆ Configure() [1/2]

void PhysInteractionSelector::Configure ( const Registry & config)
virtual

override the Algorithm::Configure methods to load configuration data to private data members

Reimplemented from genie::Algorithm.

Definition at line 205 of file PhysInteractionSelector.cxx.

206{
207 Algorithm::Configure(config);
208 this->LoadConfigData();
209}
virtual void Configure(const Registry &config)
Definition Algorithm.cxx:62

References genie::Algorithm::Configure(), and LoadConfigData().

◆ Configure() [2/2]

void PhysInteractionSelector::Configure ( string config)
virtual

Configure the algorithm from the AlgoConfigPool based on param_set string given in input An algorithm contains a vector of registries coming from different xml configuration files, which are loaded according a very precise prioriy This methods will load a number registries in order of priority: 1) "Tunable" parameter set from CommonParametes. This is loaded with the highest prioriry and it is designed to be used for tuning procedure Usage not expected from the user. 2) For every string defined in "CommonParame" the corresponding parameter set will be loaded from CommonParameter.xml 3) parameter set specified by the config string and defined in the xml file of the algorithm 4) if config is not "Default" also the Default parameter set from the same xml file will be loaded Effectively this avoids the repetion of a parameter when it is not changed in the requested configuration

Reimplemented from genie::Algorithm.

Definition at line 211 of file PhysInteractionSelector.cxx.

212{
213 Algorithm::Configure(param_set);
214 this->LoadConfigData();
215}

References genie::Algorithm::Configure(), and LoadConfigData().

◆ LoadConfigData()

void PhysInteractionSelector::LoadConfigData ( void )
private

Definition at line 217 of file PhysInteractionSelector.cxx.

218{
219 //check whether the user prefers the cross sections to be calculated or
220 //evaluated from a spline object constructed at the job initialization
221 fUseSplines = false ;
222 GetParam( "UseStoredXSecs", fUseSplines ) ;
223
224}
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const

References fUseSplines, and genie::Algorithm::GetParam().

Referenced by Configure(), and Configure().

◆ SelectInteraction()

EventRecord * PhysInteractionSelector::SelectInteraction ( const InteractionGeneratorMap * igmp,
const TLorentzVector & p4 ) const
virtual

implement the InteractionSelectorI interface

Implements genie::InteractionSelectorI.

Definition at line 59 of file PhysInteractionSelector.cxx.

61{
62 if(!igmap) {
63 LOG("IntSel", pERROR)
64 << "\n*** NULL InteractionGeneratorMap! Can't select interaction";
65 return 0;
66 }
67 if(igmap->size() <= 0) {
68 LOG("IntSel", pERROR)
69 << "\n*** Empty InteractionGeneratorMap! Can't select interaction";
70 return 0;
71 }
72
73 // Get the list of spline objects
74 // Should have been constructed at the job initialization
75 XSecSplineList * xssl = 0;
77
78 const InteractionList & ilst = igmap->GetInteractionList();
79 vector<double> xseclist(ilst.size());
80
81 string istate = ilst[0]->InitState().AsString();
82 ostringstream msg;
83 msg << "Selecting an interaction for the given initial state = "
84 << istate << " at E = " << p4.E() << " GeV";
85
86 LOG("IntSel", pNOTICE)
87 << utils::print::PrintFramedMesg(msg.str(), 0, '=');
88 LOG("IntSel", pNOTICE)
89 << "Computing xsecs for all relevant modeled interactions:";
90
91 unsigned int i=0;
92 InteractionList::const_iterator intliter = ilst.begin();
93
94 ostringstream xsec_table_printout;
95
96 xsec_table_printout
97 << " |" << setfill('-') << setw(112) << "|" << endl
98 << " | " << setfill(' ') << setw(80) << "interaction"
99 << " | cross-section (1E-38*cm^2) |" << endl
100 << " |" << setfill('-') << setw(112) << "|" << endl;
101
102 for( ; intliter != ilst.end(); ++intliter) {
103
104 Interaction * interaction = new Interaction(**intliter);
105 interaction->InitStatePtr()->SetProbeP4(p4);
106
107 SLOG("IntSel", pDEBUG)
108 << "Computing xsec for: \n " << interaction->AsString();
109
110 // get the cross section for this interaction
111 const XSecAlgorithmI * xsec_alg =
112 igmap->FindGenerator(interaction)->CrossSectionAlg();
113 assert(xsec_alg);
114
115 double xsec = 0; // cross section for this interaction
116
117 bool spline_computed = xssl->SplineExists(xsec_alg, interaction);
118 bool eval = fUseSplines && spline_computed;
119 if (eval) {
120 const InitialState & init = interaction->InitState();
121 const ProcessInfo & proc = interaction->ProcInfo();
122 double E = init.ProbeE(kRfLab);
123 if(TMath::IsNaN(E)) {
124 BLOG("IntSel", pFATAL) << *interaction;
125 BLOG("IntSel", pFATAL) << "E = " << E;
126 abort();
127 }
128 const Spline * spl = xssl->GetSpline(xsec_alg,interaction);
129 if(spl->ClosestKnotValueIsZero(E,"-")) xsec = 0;
130 else xsec = spl->Evaluate(E);
131 } else {
132 xsec = xsec_alg->Integral(interaction);
133 }
134 TMath::Max(0., xsec);
135/*
136 LOG("IntSel", pNOTICE)
137 << interaction->AsString()
138 << " --> xsec " << (eval ? "[**interp**]" : "[**calc**]")
139 << " = " << xsec/genie::units::cm2 << " cm^2";
140*/
141 xsec_table_printout
142 << " | " << setfill(' ') << setw(80) << interaction->AsString()
143 << " | " << setfill(' ') << setw(26) << xsec/(1E-38*genie::units::cm2)
144 << " | " << endl;
145
146 xseclist[i++] = xsec;
147 delete interaction;
148
149 } // loop over interaction that can be generated
150
151 xsec_table_printout
152 << " |" << setfill('-') << setw(112) << "|" << endl;
153
154 LOG("IntSel", pNOTICE)
155 << "\n" << xsec_table_printout.str();
156
157 // select an interaction
158
159 LOG("IntSel", pINFO)
160 << "Selecting an entry from the Interaction List";
161 double xsec_sum = 0;
162 for(unsigned int iint = 0; iint < xseclist.size(); iint++) {
163 xsec_sum += xseclist[iint];
164 xseclist[iint] = xsec_sum;
165
166 SLOG("IntSel", pINFO)
167 << "Sum{xsec}(0->" << iint << ") = " << xsec_sum;
168 }
169 RandomGen * rnd = RandomGen::Instance();
170 double R = xsec_sum * rnd->RndISel().Rndm();
171
172 LOG("IntSel", pINFO)
173 << "Generating Rndm (0. -> max = " << xsec_sum << ") = " << R;
174
175 for(unsigned int iint = 0; iint < xseclist.size(); iint++) {
176
177 SLOG("IntSel", pDEBUG)
178 << "Sum{xsec}(0->" << iint <<") = " << xseclist[iint];
179
180 if( R < xseclist[iint] ) {
181 Interaction * selected_interaction = new Interaction (*ilst[iint]);
182 selected_interaction->InitStatePtr()->SetProbeP4(p4);
183
184 // set the cross section for the selected interaction (just extract it
185 // from the array of summed xsecs rather than recomputing it)
186 double xsec_pedestal = (iint > 0) ? xseclist[iint-1] : 0.;
187 double xsec = xseclist[iint] - xsec_pedestal;
188 assert(xsec>0);
189
190 LOG("IntSel", pNOTICE)
191 << "Selected interaction: " << selected_interaction->AsString();
192
193 // bootstrap the event record
194 EventRecord * evrec = new EventRecord;
195 evrec->AttachSummary(selected_interaction);
196 evrec->SetXSec(xsec);
197
198 return evrec;
199 }
200 }
201 LOG("IntSel", pERROR) << "Could not select interaction";
202 return 0;
203}
#define pNOTICE
Definition Messenger.h:61
#define pINFO
Definition Messenger.h:62
#define pERROR
Definition Messenger.h:59
#define pFATAL
Definition Messenger.h:56
#define pDEBUG
Definition Messenger.h:63
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
#define BLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending no additional information.
Definition Messenger.h:212
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition Messenger.h:84
virtual void AttachSummary(Interaction *interaction)
virtual void SetXSec(double xsec)
Definition GHepRecord.h:132
void SetProbeP4(const TLorentzVector &P4)
double ProbeE(RefFrame_t rf) const
string AsString(void) const
InitialState * InitStatePtr(void) const
Definition Interaction.h:74
const ProcessInfo & ProcInfo(void) const
Definition Interaction.h:70
const InitialState & InitState(void) const
Definition Interaction.h:69
static RandomGen * Instance()
Access instance.
Definition RandomGen.cxx:74
TRandom3 & RndISel(void) const
rnd number generator used by interaction selectors
Definition RandomGen.h:65
double Evaluate(double x) const
Definition Spline.cxx:363
bool ClosestKnotValueIsZero(double x, Option_t *opt="-+") const
Definition Spline.cxx:561
virtual double Integral(const Interaction *i) const =0
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
const Spline * GetSpline(const XSecAlgorithmI *alg, const Interaction *i) const
static XSecSplineList * Instance()
static constexpr double cm2
Definition Units.h:69
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f=' *')
@ kRfLab
Definition RefFrame.h:26

References genie::Interaction::AsString(), genie::GHepRecord::AttachSummary(), BLOG, genie::Spline::ClosestKnotValueIsZero(), genie::units::cm2, genie::EventGeneratorI::CrossSectionAlg(), genie::Spline::Evaluate(), genie::InteractionGeneratorMap::FindGenerator(), fUseSplines, genie::InteractionGeneratorMap::GetInteractionList(), genie::XSecSplineList::GetSpline(), genie::Interaction::InitState(), genie::Interaction::InitStatePtr(), genie::RandomGen::Instance(), genie::XSecSplineList::Instance(), genie::XSecAlgorithmI::Integral(), genie::kRfLab, LOG, pDEBUG, pERROR, pFATAL, pINFO, pNOTICE, genie::utils::print::PrintFramedMesg(), genie::InitialState::ProbeE(), genie::Interaction::ProcInfo(), genie::RandomGen::RndISel(), genie::InitialState::SetProbeP4(), genie::GHepRecord::SetXSec(), SLOG, and genie::XSecSplineList::SplineExists().

Member Data Documentation

◆ fUseSplines

bool genie::PhysInteractionSelector::fUseSplines
private

Definition at line 46 of file PhysInteractionSelector.h.

Referenced by LoadConfigData(), and SelectInteraction().


The documentation for this class was generated from the following files: