GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
genie::InteractionGeneratorMap Class Reference

An Interaction -> EventGeneratorI associative container. The container is being built for the loaded EventGeneratorList and for the input InitialState object and is being used to locate the generator that can generate aany given interaction. More...

#include <InteractionGeneratorMap.h>

Inheritance diagram for genie::InteractionGeneratorMap:
Inheritance graph
[legend]
Collaboration diagram for genie::InteractionGeneratorMap:
Collaboration graph
[legend]

Public Member Functions

 InteractionGeneratorMap ()
 
 InteractionGeneratorMap (const InteractionGeneratorMap &igmap)
 
 ~InteractionGeneratorMap ()
 
void UseGeneratorList (const EventGeneratorList *list)
 
void BuildMap (const InitialState &init_state)
 
const EventGeneratorIFindGenerator (const Interaction *in) const
 
const InteractionListGetInteractionList (void) const
 
void Reset (void)
 
void Copy (const InteractionGeneratorMap &xsmap)
 
void Print (ostream &stream) const
 
InteractionGeneratorMapoperator= (const InteractionGeneratorMap &xsmap)
 

Private Member Functions

void Init (void)
 
void CleanUp (void)
 

Private Attributes

const EventGeneratorListfEventGeneratorList
 
InitialStatefInitState
 
InteractionListfInteractionList
 

Friends

ostream & operator<< (ostream &stream, const InteractionGeneratorMap &xsmap)
 

Detailed Description

An Interaction -> EventGeneratorI associative container. The container is being built for the loaded EventGeneratorList and for the input InitialState object and is being used to locate the generator that can generate aany given interaction.

Author
Costas Andreopoulos <c.andreopoulos cern.ch> University of Liverpool
Created:
January 23, 2006
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 44 of file InteractionGeneratorMap.h.

Constructor & Destructor Documentation

InteractionGeneratorMap::InteractionGeneratorMap ( )

Definition at line 37 of file InteractionGeneratorMap.cxx.

References Init().

37  :
38 map<string, const EventGeneratorI *> ()
39 {
40  this->Init();
41 }
InteractionGeneratorMap::InteractionGeneratorMap ( const InteractionGeneratorMap igmap)

Definition at line 43 of file InteractionGeneratorMap.cxx.

References Copy().

44  :
45 map<string, const EventGeneratorI *> ()
46 {
47  this->Copy(igmap);
48 }
void Copy(const InteractionGeneratorMap &xsmap)
InteractionGeneratorMap::~InteractionGeneratorMap ( )

Definition at line 50 of file InteractionGeneratorMap.cxx.

References CleanUp().

51 {
52  this->CleanUp();
53 }

Member Function Documentation

void InteractionGeneratorMap::BuildMap ( const InitialState init_state)

Definition at line 101 of file InteractionGeneratorMap.cxx.

References genie::InteractionList::Append(), genie::InitialState::AsString(), genie::Interaction::AsString(), genie::InitialState::Copy(), genie::InteractionListGeneratorI::CreateInteractionList(), fEventGeneratorList, fInitState, fInteractionList, genie::Algorithm::Id(), genie::EventGeneratorI::IntListGenerator(), genie::AlgId::Key(), LOG, pDEBUG, pNOTICE, pWARN, and SLOG.

102 {
103  SLOG("IntGenMap", pDEBUG)
104  << "Building 'interaction' -> 'generator' associations";
105  SLOG("IntGenMap", pNOTICE)
106  << "Using all simulated interactions for init-state: "
107  << init_state.AsString();
108  if(!fEventGeneratorList) {
109  LOG("IntGenMap", pWARN) << "No EventGeneratorList was loaded!!";
110  return;
111  }
112 
113  fInitState->Copy(init_state);
114 
115  EventGeneratorList::const_iterator evgliter; // event generator list iter
116  InteractionList::iterator intliter; // interaction list iter
117 
118  // loop over all EventGenerator objects used in the current job
119  for(evgliter = fEventGeneratorList->begin();
120  evgliter != fEventGeneratorList->end(); ++evgliter) {
121  // current EventGenerator
122  const EventGeneratorI * evgen = *evgliter;
123  assert(evgen);
124 
125  // ask the event generator to produce a list of all interaction it can
126  // generate for the input initial state
127  SLOG("IntGenMap", pNOTICE)
128  << "Querying [" << evgen->Id().Key() << "] for its InteractionList";
129 
130  const InteractionListGeneratorI * ilstgen = evgen->IntListGenerator();
131  InteractionList * ilst = ilstgen->CreateInteractionList(init_state);
132 
133  // no point to go on if the list is NULL - continue to next iteration
134  if(!ilst) continue;
135 
136  // append the new InteractionList to the local copy
137  fInteractionList->Append(*ilst);
138 
139  // loop over all interaction that can be genererated by the current
140  // EventGenerator and link all of them to iy
141  for(intliter = ilst->begin(); intliter != ilst->end(); ++intliter)
142  {
143  // current interaction
144  Interaction * interaction = *intliter;
145  string code = interaction->AsString();
146 
147  SLOG("IntGenMap", pDEBUG)
148  << "\nLinking: " << code << " --> to: " << evgen->Id().Key();
149  this->insert(
150  map<string, const EventGeneratorI *>::value_type(code,evgen));
151  } // loop over interactions
152  delete ilst;
153  ilst = 0;
154  } // loop over event generators
155 }
const EventGeneratorList * fEventGeneratorList
Defines the InteractionListGeneratorI interface. Concrete implementations of this interface generate ...
Defines the EventGeneratorI interface.
virtual InteractionList * CreateInteractionList(const InitialState &init) const =0
string AsString(void) const
Summary information for an interaction.
Definition: Interaction.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void Copy(const InitialState &init_state)
string AsString(void) const
#define pWARN
Definition: Messenger.h:60
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
void Append(const InteractionList &intl)
A vector of Interaction objects.
virtual const InteractionListGeneratorI * IntListGenerator(void) const =0
#define pNOTICE
Definition: Messenger.h:61
#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
#define pDEBUG
Definition: Messenger.h:63
void InteractionGeneratorMap::CleanUp ( void  )
private

Definition at line 69 of file InteractionGeneratorMap.cxx.

References clear, fInitState, and fInteractionList.

Referenced by Reset(), and ~InteractionGeneratorMap().

70 {
71  delete fInitState;
72  delete fInteractionList;
73 
74  this->clear();
75 }
vector< vector< double > > clear
void InteractionGeneratorMap::Copy ( const InteractionGeneratorMap xsmap)

Definition at line 77 of file InteractionGeneratorMap.cxx.

References clear, fEventGeneratorList, fInitState, and fInteractionList.

Referenced by InteractionGeneratorMap(), and operator=().

78 {
80 
81  fInitState -> Copy (*xsmap.fInitState);
83 
84  this->clear();
85 
86  InteractionGeneratorMap::const_iterator iter;
87 
88  for(iter = xsmap.begin(); iter != xsmap.end(); ++iter) {
89  string code = iter->first;
90  const EventGeneratorI * evg = iter->second;
91 
92  this->insert(map<string, const EventGeneratorI *>::value_type(code,evg));
93  }
94 }
const EventGeneratorList * fEventGeneratorList
Defines the EventGeneratorI interface.
void Copy(const InteractionGeneratorMap &xsmap)
vector< vector< double > > clear
const EventGeneratorI * InteractionGeneratorMap::FindGenerator ( const Interaction in) const

Definition at line 157 of file InteractionGeneratorMap.cxx.

References genie::Interaction::AsString(), LOG, and pWARN.

Referenced by genie::PhysInteractionSelector::SelectInteraction().

159 {
160  if(!interaction) {
161  LOG("IntGenMap", pWARN) << "Null interaction!!";
162  return 0;
163  }
164  string code = interaction->AsString();
165  InteractionGeneratorMap::const_iterator evgiter = this->find(code);
166  if(evgiter == this->end()) {
167  LOG("IntGenMap", pWARN)
168  << "No EventGeneratorI was found for interaction: \n" << code;
169  return 0;
170  }
171  const EventGeneratorI * evg = evgiter->second;
172  return evg;
173 }
Defines the EventGeneratorI interface.
#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
const InteractionList & InteractionGeneratorMap::GetInteractionList ( void  ) const
void InteractionGeneratorMap::Init ( void  )
private

Definition at line 61 of file InteractionGeneratorMap.cxx.

References fEventGeneratorList, fInitState, and fInteractionList.

Referenced by InteractionGeneratorMap(), and Reset().

62 {
64 
67 }
const EventGeneratorList * fEventGeneratorList
A vector of Interaction objects.
Initial State information.
Definition: InitialState.h:48
InteractionGeneratorMap & InteractionGeneratorMap::operator= ( const InteractionGeneratorMap xsmap)

Definition at line 203 of file InteractionGeneratorMap.cxx.

References Copy().

205 {
206  this->Copy(igmap);
207  return (*this);
208 }
void Copy(const InteractionGeneratorMap &xsmap)
void InteractionGeneratorMap::Print ( ostream &  stream) const

Definition at line 180 of file InteractionGeneratorMap.cxx.

References genie::Algorithm::Id(), and genie::AlgId::Key().

Referenced by genie::operator<<().

181 {
182  stream << endl;
183 
184  InteractionGeneratorMap::const_iterator iter;
185 
186  unsigned int maxlen = 0;
187  for(iter = this->begin(); iter != this->end(); ++iter) {
188  string icode = iter->first;
189  unsigned int isz = (unsigned int) icode.size();
190  maxlen=TMath::Max(maxlen,isz);
191  }
192 
193  for(iter = this->begin(); iter != this->end(); ++iter) {
194  const EventGeneratorI * evg = iter->second;
195  string intstr = iter->first;
196  string evgstr = (evg) ? evg->Id().Key() : "** NULL EVENT GENERATOR **";
197 
198  stream << setfill(' ') << setw(maxlen)
199  << intstr << " --> " << evgstr << endl;
200  }
201 }
Defines the EventGeneratorI interface.
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
string Key(void) const
Definition: AlgId.h:46
void InteractionGeneratorMap::Reset ( void  )

Definition at line 55 of file InteractionGeneratorMap.cxx.

References CleanUp(), and Init().

56 {
57  this->CleanUp();
58  this->Init();
59 }
void InteractionGeneratorMap::UseGeneratorList ( const EventGeneratorList list)

Definition at line 96 of file InteractionGeneratorMap.cxx.

References fEventGeneratorList.

Referenced by genie::GEVGDriver::BuildInteractionGeneratorMap().

97 {
99 }
const EventGeneratorList * fEventGeneratorList

Friends And Related Function Documentation

ostream& operator<< ( ostream &  stream,
const InteractionGeneratorMap xsmap 
)
friend

Definition at line 30 of file InteractionGeneratorMap.cxx.

31  {
32  intl.Print(stream);
33  return stream;
34  }

Member Data Documentation

const EventGeneratorList* genie::InteractionGeneratorMap::fEventGeneratorList
private

Definition at line 69 of file InteractionGeneratorMap.h.

Referenced by BuildMap(), Copy(), Init(), and UseGeneratorList().

InitialState* genie::InteractionGeneratorMap::fInitState
private

Definition at line 71 of file InteractionGeneratorMap.h.

Referenced by BuildMap(), CleanUp(), Copy(), and Init().

InteractionList* genie::InteractionGeneratorMap::fInteractionList
private

Definition at line 72 of file InteractionGeneratorMap.h.

Referenced by BuildMap(), CleanUp(), Copy(), GetInteractionList(), and Init().


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