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

Holds the history of the GHEP event record as it being modified by the processing steps of an event generation thread. The event record history can be used to step back in the generation sequence if a processing step is to be re-run (this the GENIE event generation framework equivalent of an 'Undo') More...

#include <GHepRecordHistory.h>

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

Public Member Functions

 GHepRecordHistory ()
 
 GHepRecordHistory (const GHepRecordHistory &history)
 
 ~GHepRecordHistory ()
 
void AddSnapshot (int step, GHepRecord *r)
 
void PurgeHistory (void)
 
void PurgeRecentHistory (int start_step)
 
void ReadFlags (void)
 
void Copy (const GHepRecordHistory &history)
 
void Print (ostream &stream) const
 

Private Attributes

bool fEnabledFull
 keep the full GHEP record history More...
 
bool fEnabledBootstrapStep
 keep only the record that bootsrapped the generation cycle More...
 

Friends

ostream & operator<< (ostream &stream, const GHepRecordHistory &history)
 

Detailed Description

Holds the history of the GHEP event record as it being modified by the processing steps of an event generation thread. The event record history can be used to step back in the generation sequence if a processing step is to be re-run (this the GENIE event generation framework equivalent of an 'Undo')

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

Definition at line 40 of file GHepRecordHistory.h.

Constructor & Destructor Documentation

GHepRecordHistory::GHepRecordHistory ( )

Definition at line 32 of file GHepRecordHistory.cxx.

References ReadFlags().

32  :
33 map<int, GHepRecord*>()
34 {
35  this->ReadFlags();
36 }
GHepRecordHistory::GHepRecordHistory ( const GHepRecordHistory history)

Definition at line 38 of file GHepRecordHistory.cxx.

References Copy(), and ReadFlags().

38  :
39 map<int, GHepRecord*>()
40 {
41  this->Copy(history);
42  this->ReadFlags();
43 }
void Copy(const GHepRecordHistory &history)
GHepRecordHistory::~GHepRecordHistory ( )

Definition at line 45 of file GHepRecordHistory.cxx.

References PurgeHistory().

46 {
47  this->PurgeHistory();
48 }

Member Function Documentation

void GHepRecordHistory::AddSnapshot ( int  step,
GHepRecord r 
)

Definition at line 50 of file GHepRecordHistory.cxx.

References fEnabledBootstrapStep, fEnabledFull, LOG, pNOTICE, and pWARN.

Referenced by Copy(), and genie::EventGenerator::ProcessEventRecord().

51 {
52 // Adds a GHepRecord 'snapshot' at the history buffer
53 
54  bool go_on = (fEnabledFull || (fEnabledBootstrapStep && step==-1));
55  if(!go_on) return;
56 
57  if(!record) {
58  LOG("GHEP", pWARN)
59  << "Input GHEP record snapshot is null. Is not added at history record";
60  return;
61  }
62 
63  if( this->count(step) == 0 ) {
64 
65  LOG("GHEP", pNOTICE)
66  << "Adding GHEP snapshot for processing step: " << step;
67 
68  GHepRecord * snapshot = new GHepRecord(*record);
69  this->insert( map<int, GHepRecord*>::value_type(step,snapshot));
70 
71  } else {
72  // If you have already stepped back and reprocessing, then you should
73  // have purged the 'recent' history (corresponing to 'after the return
74  // processing step')
75  LOG("GHEP", pWARN)
76  << "GHEP snapshot for processing step: " << step << " already exists!";
77  }
78 }
bool fEnabledBootstrapStep
keep only the record that bootsrapped the generation cycle
#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
bool fEnabledFull
keep the full GHEP record history
#define pNOTICE
Definition: Messenger.h:61
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:45
void GHepRecordHistory::Copy ( const GHepRecordHistory history)

Definition at line 137 of file GHepRecordHistory.cxx.

References AddSnapshot(), and PurgeHistory().

Referenced by GHepRecordHistory().

138 {
139  this->PurgeHistory();
140 
141  GHepRecordHistory::const_iterator history_iter;
142  for(history_iter = history.begin();
143  history_iter != history.end(); ++history_iter) {
144 
145  unsigned int step = history_iter->first;
146  GHepRecord * record = history_iter->second;
147 
148  this->AddSnapshot(step, record);
149  }
150 }
void AddSnapshot(int step, GHepRecord *r)
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:45
void GHepRecordHistory::Print ( ostream &  stream) const

Definition at line 152 of file GHepRecordHistory.cxx.

Referenced by genie::operator<<().

153 {
154  stream << "\n ****** Printing GHEP record history"
155  << " [depth: " << this->size() << "]" << endl;
156 
157  GHepRecordHistory::const_iterator history_iter;
158  for(history_iter = this->begin();
159  history_iter != this->end(); ++history_iter) {
160 
161  unsigned int step = history_iter->first;
162  GHepRecord * record = history_iter->second;
163 
164  stream << "\n[After processing step = " << step << "] :";
165 
166  if(!record) {
167  stream
168  << "** ERR: No history record available for this processing step!";
169  } else {
170  stream << *record;
171  }
172  }
173 }
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:45
void GHepRecordHistory::PurgeHistory ( void  )

Definition at line 80 of file GHepRecordHistory.cxx.

References clear, LOG, pINFO, and pNOTICE.

Referenced by Copy(), genie::EventGenerator::ProcessEventRecord(), PurgeRecentHistory(), and ~GHepRecordHistory().

81 {
82  LOG("GHEP", pNOTICE) << "Purging GHEP history buffer";
83 
84  GHepRecordHistory::iterator history_iter;
85  for(history_iter = this->begin();
86  history_iter != this->end(); ++history_iter) {
87 
88  int step = history_iter->first;
89  LOG("GHEP", pINFO)
90  << "Deleting GHEP snapshot for processing step: " << step;
91 
92  GHepRecord * record = history_iter->second;
93  if(record) {
94  delete record;
95  record = 0;
96  }
97  }
98  this->clear();
99 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
vector< vector< double > > clear
#define pNOTICE
Definition: Messenger.h:61
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:45
void GHepRecordHistory::PurgeRecentHistory ( int  start_step)

Definition at line 101 of file GHepRecordHistory.cxx.

References LOG, pINFO, pNOTICE, PurgeHistory(), and pWARN.

Referenced by genie::EventGenerator::ProcessEventRecord().

102 {
103 // Snapshots are added to the history record *after* each processing step
104 // (marked 0,1,2,...). A special snapshot corresponding to the event record
105 // before any processing step is added with key = -1.
106 // Therefore GHepRecordHistory keys should be: -1,0,1,2,3,...
107 
108  LOG("GHEP", pNOTICE)
109  << "Purging recent GHEP history buffer (processing step >= "
110  << start_step << ")";
111 
112  if(start_step < -1) {
113  LOG("GHEP", pWARN)
114  << "Invalid starting step: " << start_step << " - Ignoring";
115  return;
116  }
117 
118  if(start_step == -1) {
119  // delete everything
120  this->PurgeHistory();
121  return;
122  }
123 
124  GHepRecordHistory::iterator history_iter;
125  for(history_iter = this->begin();
126  history_iter != this->end(); ++history_iter) {
127 
128  if(history_iter->first >= start_step) {
129  int step = history_iter->first;
130  LOG("GHEP", pINFO)
131  << "Deleting GHEP snapshot for processing step: " << step;
132  this->erase(history_iter);
133  }
134  }
135 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
#define pWARN
Definition: Messenger.h:60
#define pNOTICE
Definition: Messenger.h:61
void GHepRecordHistory::ReadFlags ( void  )

Definition at line 175 of file GHepRecordHistory.cxx.

References genie::utils::print::BoolAsYNString(), fEnabledBootstrapStep, fEnabledFull, LOG, and pINFO.

Referenced by GHepRecordHistory().

176 {
177  if (gSystem->Getenv("GHEPHISTENABLE")) {
178 
179  string envvar = string(gSystem->Getenv("GHEPHISTENABLE"));
180 
181  fEnabledFull = (envvar=="FULL") ? true:false;
182  fEnabledBootstrapStep = (envvar=="BOOTSTRAP") ? true:false;
183 
184  } else {
185  // set defaults
186  fEnabledFull = false;
187  fEnabledBootstrapStep = true;
188  }
189 
190  LOG("GHEP", pINFO) << "GHEP History Flags: ";
191  LOG("GHEP", pINFO) << " - Keep Full History: "
193  LOG("GHEP", pINFO) << " - Keep Bootstrap Record Only: "
195 }
bool fEnabledBootstrapStep
keep only the record that bootsrapped the generation cycle
string BoolAsYNString(bool b)
Definition: PrintUtils.cxx:108
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
bool fEnabledFull
keep the full GHEP record history

Friends And Related Function Documentation

ostream& operator<< ( ostream &  stream,
const GHepRecordHistory history 
)
friend

Definition at line 25 of file GHepRecordHistory.cxx.

26  {
27  history.Print(stream);
28  return stream;
29  }
void Print(ostream &stream) const

Member Data Documentation

bool genie::GHepRecordHistory::fEnabledBootstrapStep
private

keep only the record that bootsrapped the generation cycle

Definition at line 61 of file GHepRecordHistory.h.

Referenced by AddSnapshot(), and ReadFlags().

bool genie::GHepRecordHistory::fEnabledFull
private

keep the full GHEP record history

Definition at line 60 of file GHepRecordHistory.h.

Referenced by AddSnapshot(), and ReadFlags().


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