GENIEGenerator
Loading...
Searching...
No Matches
XSecAlgorithmMap.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <c.andreopoulos \at cern.ch>
7 University of Liverpool
8*/
9//____________________________________________________________________________
10
19
20using std::endl;
21using namespace genie;
22
23//____________________________________________________________________________
24namespace genie {
25 ostream & operator << (ostream & stream, const XSecAlgorithmMap & intl)
26 {
27 intl.Print(stream);
28 return stream;
29 }
30}
31//___________________________________________________________________________
33map<string, const XSecAlgorithmI *> ()
34{
35 this->Init();
36}
37//___________________________________________________________________________
39map<string, const XSecAlgorithmI *> ()
40{
41 this->Copy(xsmap);
42}
43//___________________________________________________________________________
48//___________________________________________________________________________
50{
51 this->CleanUp();
52 this->Init();
53}
54//___________________________________________________________________________
62//___________________________________________________________________________
64{
65 delete fInitState;
66 delete fInteractionList;
67
68 this->clear();
69}
70//___________________________________________________________________________
72{
74
75 fInitState -> Copy (*xsmap.fInitState);
77
78 this->clear();
79
80 XSecAlgorithmMap::const_iterator iter;
81
82 for(iter = xsmap.begin(); iter != xsmap.end(); ++iter) {
83 string code = iter->first;
84 const XSecAlgorithmI * alg = iter->second;
85
86 this->insert(map<string, const XSecAlgorithmI *>::value_type(code,alg));
87 }
88}
89//___________________________________________________________________________
94//___________________________________________________________________________
96{
97 LOG("XSecAlgMap", pNOTICE)
98 << "Building 'interaction' -> 'xsec algorithm' associations";
99 LOG("XSecAlgMap", pNOTICE)
100 << "Using all simulated interactions for init-state: "
101 << init_state.AsString();
103 LOG("XSecAlgMap", pWARN)
104 << "No EventGeneratorList was loaded. Will not build XSecAlgorithmMap";
105 return;
106 }
107
108 fInitState->Copy(init_state);
109
110 EventGeneratorList::const_iterator evgliter; // event generator list iter
111 InteractionList::iterator intliter; // interaction list iter
112
113 // loop over all EventGenerator objects used in the current job
114 for(evgliter = fEventGeneratorList->begin();
115 evgliter != fEventGeneratorList->end(); ++evgliter) {
116 // current EventGenerator
117 const EventGeneratorI * evgen = *evgliter;
118 assert(evgen);
119
120 // ask the event generator to produce a list of all interaction it can
121 // generate for the input initial state
122 LOG("XSecAlgMap", pNOTICE)
123 << "Querying [" << evgen->Id().Key() << "] for its InteractionList";
124
125 const InteractionListGeneratorI * ilstgen = evgen->IntListGenerator();
126 InteractionList * ilst = ilstgen->CreateInteractionList(init_state);
127
128 // no point to go on if the list is NULL - continue to next iteration
129 if(!ilst) continue;
130
131 // append the new InteractionList to the local copy
132 fInteractionList->Append(*ilst);
133
134 // cross section algorithm used by this EventGenerator
135 const XSecAlgorithmI * xsec_alg = evgen->CrossSectionAlg();
136
137 // loop over all interaction that can be genererated by the current
138 // EventGenerator and link all of them to the current XSecAlgorithmI
139 for(intliter = ilst->begin(); intliter != ilst->end(); ++intliter)
140 {
141 // current interaction
142 Interaction * interaction = *intliter;
143 string code = interaction->AsString();
144
145 // link with the xsec algorithm
146 SLOG("XSecAlgMap", pINFO)
147 << "\nLinking: " << code
148 << "\n --> with xsec algorithm: " << xsec_alg->Id().Key();
149 this->insert(
150 map<string, const XSecAlgorithmI *>::value_type(code,xsec_alg));
151
152 } // loop over interactions
153 delete ilst;
154 ilst = 0;
155 } // loop over event generators
156}
157//___________________________________________________________________________
159 const Interaction * interaction) const
160{
161 if(!interaction) {
162 LOG("XSecAlgMap", pWARN) << "Null interaction!!";
163 return 0;
164 }
165
166 string code = interaction->AsString();
167
168 XSecAlgorithmMap::const_iterator xsec_alg_iter = this->find(code);
169 if(xsec_alg_iter == this->end()) {
170 LOG("XSecAlgMap", pWARN)
171 << "No XSecAlgorithmI was found for interaction: \n" << code;
172 return 0;
173 }
174
175 const XSecAlgorithmI * xsec_alg = xsec_alg_iter->second;
176 return xsec_alg;
177}
178//___________________________________________________________________________
183//___________________________________________________________________________
184void XSecAlgorithmMap::Print(ostream & stream) const
185{
186 XSecAlgorithmMap::const_iterator iter;
187
188 stream<< "Printing 'interaction' -> 'xsec algorithm' associations" << endl;
189
190 for(iter = this->begin(); iter != this->end(); ++iter) {
191 string code = iter->first;
192 const XSecAlgorithmI * alg = iter->second;
193 if(alg) {
194 stream << code << " -> " << alg->Id().Key() << endl;
195 } else {
196 stream << code << " -> **** NULL XSEC ALGORITHM ****" << endl;
197 }
198 }
199}
200//___________________________________________________________________________
202{
203 this->Copy(xs);
204 return (*this);
205}
206//___________________________________________________________________________
vector< vector< double > > clear
#define pNOTICE
Definition Messenger.h:61
#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
#define pWARN
Definition Messenger.h:60
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition Messenger.h:84
string Key(void) const
Definition AlgId.h:46
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition Algorithm.h:98
Defines the EventGeneratorI interface.
virtual const InteractionListGeneratorI * IntListGenerator(void) const =0
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
A vector of EventGeneratorI objects.
Initial State information.
string AsString(void) const
Defines the InteractionListGeneratorI interface. Concrete implementations of this interface generate ...
virtual InteractionList * CreateInteractionList(const InitialState &init) const =0
A vector of Interaction objects.
Summary information for an interaction.
Definition Interaction.h:56
string AsString(void) const
Cross Section Calculation Interface.
InteractionList * fInteractionList
void BuildMap(const InitialState &init_state)
const InteractionList & GetInteractionList(void) const
const XSecAlgorithmI * FindXSecAlgorithm(const Interaction *in) const
void Copy(const XSecAlgorithmMap &xsmap)
void UseGeneratorList(const EventGeneratorList *list)
void Print(ostream &stream) const
XSecAlgorithmMap & operator=(const XSecAlgorithmMap &xsmap)
const EventGeneratorList * fEventGeneratorList
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)