GENIEGenerator
Loading...
Searching...
No Matches
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:
[legend]
Collaboration diagram for genie::GHepRecordHistory:
[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
bool fEnabledBootstrapStep
 keep only the record that bootsrapped the generation cycle

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 \at cern.ch> University of Liverpool
Created:\n September 23, 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 40 of file GHepRecordHistory.h.

Constructor & Destructor Documentation

◆ GHepRecordHistory() [1/2]

GHepRecordHistory::GHepRecordHistory ( )

Definition at line 32 of file GHepRecordHistory.cxx.

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

References ReadFlags().

Referenced by Copy(), GHepRecordHistory(), and operator<<.

◆ GHepRecordHistory() [2/2]

GHepRecordHistory::GHepRecordHistory ( const GHepRecordHistory & history)

Definition at line 38 of file GHepRecordHistory.cxx.

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

References Copy(), GHepRecordHistory(), and ReadFlags().

◆ ~GHepRecordHistory()

GHepRecordHistory::~GHepRecordHistory ( )

Definition at line 45 of file GHepRecordHistory.cxx.

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

References PurgeHistory().

Member Function Documentation

◆ AddSnapshot()

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

Definition at line 50 of file GHepRecordHistory.cxx.

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}
#define pNOTICE
Definition Messenger.h:61
#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
bool fEnabledBootstrapStep
keep only the record that bootsrapped the generation cycle

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

Referenced by Copy().

◆ Copy()

void GHepRecordHistory::Copy ( const GHepRecordHistory & history)

Definition at line 137 of file GHepRecordHistory.cxx.

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)

References AddSnapshot(), GHepRecordHistory(), and PurgeHistory().

Referenced by GHepRecordHistory().

◆ Print()

void GHepRecordHistory::Print ( ostream & stream) const

Definition at line 152 of file GHepRecordHistory.cxx.

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}

Referenced by operator<<.

◆ PurgeHistory()

void GHepRecordHistory::PurgeHistory ( void )

Definition at line 80 of file GHepRecordHistory.cxx.

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}
vector< vector< double > > clear
#define pINFO
Definition Messenger.h:62

References clear, LOG, pINFO, and pNOTICE.

Referenced by Copy(), PurgeRecentHistory(), and ~GHepRecordHistory().

◆ PurgeRecentHistory()

void GHepRecordHistory::PurgeRecentHistory ( int start_step)

Definition at line 101 of file GHepRecordHistory.cxx.

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}

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

◆ ReadFlags()

void GHepRecordHistory::ReadFlags ( void )

Definition at line 175 of file GHepRecordHistory.cxx.

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;
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}
string BoolAsYNString(bool b)

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

Referenced by GHepRecordHistory(), and GHepRecordHistory().

◆ operator<<

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

References GHepRecordHistory(), and Print().

Member Data Documentation

◆ fEnabledBootstrapStep

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().

◆ fEnabledFull

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: