Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4PlotManager Class Reference

#include <G4PlotManager.hh>

Public Member Functions

 G4PlotManager (const G4AnalysisManagerState &state)
 
 ~G4PlotManager ()
 
 G4PlotManager (const G4PlotManager &rhs)=delete
 
G4PlotManageroperator= (const G4PlotManager &rhs)=delete
 
G4bool OpenFile (const G4String &fileName)
 
template<typename T >
G4bool PlotAndWrite (const std::vector< T * > &htVector, const std::vector< G4HnInformation * > &hnVector)
 
G4bool CloseFile ()
 

Detailed Description

Definition at line 45 of file G4PlotManager.hh.

Constructor & Destructor Documentation

G4PlotManager::G4PlotManager ( const G4AnalysisManagerState state)
explicit

Definition at line 156 of file G4PlotManager.cc.

157  : fState(state),
158  fViewer(nullptr),
159  fFileName()
160 {
161 #if defined(TOOLS_USE_FREETYPE)
162 #ifdef G4VERBOSE
166  if ( fState.GetVerboseL1() )
167  G4cout << "... using high resolution with Freetype fonts" << G4endl;
168 #endif
169  //Have vertical A4 :
170  // unsigned int ww = 2000; //to have better antialising on freetype fonts.
171  // float A4 = 29.7f/21.0f;
172  // unsigned int wh = (unsigned int)(float(ww)*A4*0.80);
173  static tools::sg::text_freetype ttf;
174  fViewer.reset(new tools::viewplot(G4cout, ttf,
175  fgPlotParameters.GetColumns(),
176  fgPlotParameters.GetRows(),
177  fgPlotParameters.GetWidth(),
178  fgPlotParameters.GetHeight()));
179  fViewer->plots().view_border = false;
180  load_embeded_styles(fViewer->styles());
181  fViewer->styles().add_colormap("default",tools::sg::style_default_colormap());
182  fViewer->styles().add_colormap("ROOT",tools::sg::style_ROOT_colormap());
183 #else
184  // cretae a viewer with default parameters
185 #ifdef G4VERBOSE
186  if ( fState.GetVerboseL1() )
187  G4cout << "... using low resolution with Hershey fonts" << G4endl;
188 #endif
189  fViewer.reset(new tools::viewplot(G4cout,
190  fgPlotParameters.GetColumns(),
191  fgPlotParameters.GetRows(),
192  fgPlotParameters.GetWidth(),
193  fgPlotParameters.GetHeight()));
194  fViewer->plots().view_border = false;
195 #endif
196 }
G4int GetWidth() const
G4int GetRows() const
G4GLOB_DLL std::ostream G4cout
G4int GetColumns() const
#define G4endl
Definition: G4ios.hh:61
const G4AnalysisVerbose * GetVerboseL1() const
G4int GetHeight() const

Here is the call graph for this function:

G4PlotManager::~G4PlotManager ( )

Definition at line 199 of file G4PlotManager.cc.

200 {}
G4PlotManager::G4PlotManager ( const G4PlotManager rhs)
delete

Member Function Documentation

G4bool G4PlotManager::CloseFile ( )

Definition at line 271 of file G4PlotManager.cc.

272 {
273 #ifdef G4VERBOSE
274  if ( fState.GetVerboseL4() )
275  fState.GetVerboseL4()->Message("close", "plot file", fFileName);
276 #endif
277 
278  G4bool result = fViewer->close_file();
279  if ( ! result ) {
280  G4ExceptionDescription description;
281  description << " " << "Cannot close the plot file.";
282  G4Exception("G4PlotManager::CloseFile()",
283  "Analysis_W021", JustWarning, description);
284  }
285 
286 #ifdef G4VERBOSE
287  if ( fState.GetVerboseL1() )
288  fState.GetVerboseL1()->Message("close", "plot file", fFileName);
289 #endif
290 
291  return result;
292 }
G4double G4ParticleHPJENDLHEData::G4double result
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const G4AnalysisVerbose * GetVerboseL4() const
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4AnalysisVerbose * GetVerboseL1() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4PlotManager::OpenFile ( const G4String fileName)

Definition at line 244 of file G4PlotManager.cc.

245 {
246 #ifdef G4VERBOSE
247  if ( fState.GetVerboseL4() )
248  fState.GetVerboseL4()->Message("open", "plot file", fileName);
249 #endif
250 
251  // Keep filename for logging
252  fFileName = fileName;
253 
254  G4bool result = fViewer->open_file(fileName);
255  if ( ! result ) {
256  G4ExceptionDescription description;
257  description << " " << "Cannot open plot file " << fileName;
258  G4Exception("G4PlotManager::OpenFile()",
259  "Analysis_W001", JustWarning, description);
260  }
261 
262 #ifdef G4VERBOSE
263  if ( fState.GetVerboseL1() )
264  fState.GetVerboseL1()->Message("open", "plot file", fileName);
265 #endif
266 
267  return result;
268 }
G4double G4ParticleHPJENDLHEData::G4double result
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const G4AnalysisVerbose * GetVerboseL4() const
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4AnalysisVerbose * GetVerboseL1() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4PlotManager& G4PlotManager::operator= ( const G4PlotManager rhs)
delete
template<typename T >
G4bool G4PlotManager::PlotAndWrite ( const std::vector< T * > &  htVector,
const std::vector< G4HnInformation * > &  hnVector 
)
inline

Definition at line 86 of file G4PlotManager.hh.

88 {
89  if ( ! htVector.size() ) return true;
90 
91  fViewer->plots().init_sg();
92  //it will recreate the sg::plotters and then reset the styles on new ones.
93  fViewer->set_cols_rows(fgPlotParameters.GetColumns(), fgPlotParameters.GetRows());
94  fViewer->plots().set_current_plotter(0);
95 
96  G4bool finalResult = true;
97  G4bool isWriteNeeded = false;
98 
99  for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
100  G4HnInformation* info = hnVector[i];
101  G4bool plotting = info->GetPlotting();
102  G4bool activation = info->GetActivation();
103  G4String name = info->GetName();
104  // skip plotting if not selected for plotting or
105  // if activation is enabled and HT is inactivated
106  if ( ( ! plotting ) ||
107  ( fState.GetIsActivation() && ( ! activation ) ) ) continue;
108 
109  T* ht = htVector[i];
110 
111  // plot this object
112  fViewer->plot(*ht);
113  fViewer->set_current_plotter_style(fgPlotParameters.GetStyle());
114 
115  // set color (only blue for the time being)
116  tools::sg::plotter& plotter = fViewer->plots().current_plotter();
117  // set plot properties (use info object to get these)
118  plotter.bins_style(0).color = tools::colorf_blue();
119 
120  isWriteNeeded = true;
121 
122 #ifdef G4VERBOSE
123  if ( fState.GetVerboseL3() )
124  fState.GetVerboseL3()->Message("plotting", "hd|pd", name);
125 #endif
126 
127  // write a page if number of plots per page is achieved
128  if ( G4int(fViewer->plots().current_index()) == (GetNofPlotsPerPage() - 1) ) {
129  G4bool result = WritePage();
130  finalResult = result && finalResult;
131  isWriteNeeded = false;
132  }
133 
134  // Prepare for the next plot
135  fViewer->plots().next();
136  }
137 
138  // write a page if loop is finished and there are plots to be written
139  if ( isWriteNeeded ) {
140  G4bool result = WritePage();
141  finalResult = result && finalResult;
142  }
143 
144  // add test of result
145  return finalResult;
146 }
G4double G4ParticleHPJENDLHEData::G4double result
const XML_Char XML_Encoding * info
Definition: expat.h:530
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const XML_Char * name
Definition: expat.h:151
G4bool GetActivation() const
G4bool GetPlotting() const
G4int GetRows() const
int G4int
Definition: G4Types.hh:78
G4String GetStyle() const
const G4AnalysisVerbose * GetVerboseL3() const
bool G4bool
Definition: G4Types.hh:79
G4int GetColumns() const
G4String GetName() const

Here is the call graph for this function:

Here is the caller graph for this function:


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