Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/gorad/src/GRRunActionMessenger.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 //  Gorad (Geant4 Open-source Radiation Analysis and Design)
 27 //
 28 //  Author : Makoto Asai (SLAC National Accelerator Laboratory)
 29 //
 30 //  Development of Gorad is funded by NASA Johnson Space Center (JSC)
 31 //  under the contract NNJ15HK11B.
 32 //
 33 // ********************************************************************
 34 //
 35 // GRRunActionMessenger.cc
 36 //   A messenger class that defines histograms and n-tuple in GRRunAction.
 37 //
 38 // History
 39 //   September 8th, 2020 : first implementation
 40 //
 41 // ********************************************************************
 42 
 43 #include "GRRunActionMessenger.hh"
 44 
 45 #include "GRRunAction.hh"
 46 #include "G4UIcommand.hh"
 47 #include "G4UIparameter.hh"
 48 #include "G4UIdirectory.hh"
 49 #include "G4UIcmdWithAString.hh"
 50 #include "G4UIcmdWithABool.hh"
 51 #include "G4UIcmdWithAnInteger.hh"
 52 #include "G4UIcmdWithoutParameter.hh"
 53 #include "G4UnitsTable.hh"
 54 
 55 GRRunActionMessenger::GRRunActionMessenger(GRRunAction* dc)
 56 : pRA(dc), currentID(-1)
 57 {
 58   G4UIparameter* para = nullptr;
 59 
 60   anaDir = new G4UIdirectory("/gorad/analysis/");
 61   anaDir->SetGuidance("GORAD analysis commands");
 62 
 63   verboseCmd = new G4UIcmdWithAnInteger("/gorad/analysis/verbose",this);
 64   verboseCmd->SetGuidance("Set verbose level");
 65   verboseCmd->SetParameterName("level",true);
 66   verboseCmd->SetDefaultValue(0);
 67   verboseCmd->SetRange("level>=0");
 68   verboseCmd->AvailableForStates(G4State_Idle);
 69 
 70   fileCmd = new G4UIcmdWithAString("/gorad/analysis/file",this);
 71   fileCmd->SetGuidance("Define the output file name.");
 72   fileCmd->SetParameterName("file",false);
 73   fileCmd->AvailableForStates(G4State_Idle);
 74 
 75   listCmd = new G4UIcmdWithoutParameter("/gorad/analysis/list",this);
 76   listCmd->SetGuidance("List defined histograms.");
 77   listCmd->AvailableForStates(G4State_Idle);
 78 
 79   openCmd = new G4UIcmdWithAnInteger("/gorad/analysis/open",this);
 80   openCmd->SetGuidance("Open a histogram that has already been created and closed.");
 81   openCmd->SetGuidance("\"create\" command open the new histogram so you don't need to open it.");
 82   openCmd->SetGuidance("A histogram is closed when another histogram is created. This \"open\" command is required only for reopening the closed histogram.");
 83   openCmd->SetParameterName("id",false);
 84   openCmd->AvailableForStates(G4State_Idle);
 85 
 86   plotCmd = new G4UIcmdWithAnInteger("/gorad/analysis/plot",this);
 87   plotCmd->SetGuidance("Create an additional postscript plot for specified histogram/profile.");
 88   plotCmd->SetGuidance("Regardless of this command, histogram is dumped to the output file.");
 89   plotCmd->SetGuidance("If id is not specified, currently open histogram/profile is plotted.");
 90   plotCmd->SetGuidance("If id = -1, all currently defined histograms/profiles are plotted.");
 91   plotCmd->SetParameterName("id",true,true);
 92   plotCmd->AvailableForStates(G4State_Idle);
 93 
 94   carryCmd = new G4UIcmdWithABool("/gorad/analysis/carry",this);
 95   carryCmd->SetGuidance("Carry histograms over more than one runs.");
 96   carryCmd->SetGuidance("Once this is set, histograms won't be output until /gorad/analysis/flush is explicitly issued.");
 97   carryCmd->SetGuidance("This command has to be issued before starting the run to be carried over.");
 98   carryCmd->SetParameterName("carry",true);
 99   carryCmd->SetDefaultValue(true);
100   carryCmd->AvailableForStates(G4State_Idle);
101 
102   flushCmd = new G4UIcmdWithoutParameter("/gorad/analysis/flush",this);
103   flushCmd->SetGuidance("Make output. This command is necessary if /gorad/analysis/carry is set.");
104   flushCmd->AvailableForStates(G4State_Idle);
105 
106   resetCmd = new G4UIcmdWithoutParameter("/gorad/analysis/reset",this);
107   resetCmd->SetGuidance("Reset histograms without making output.");
108   resetCmd->AvailableForStates(G4State_Idle);
109 
110   idOffsetCmd = new G4UIcommand("/gorad/analysis/idOffset",this);
111   idOffsetCmd->SetGuidance("Define offset numbers of the histogram ID.");
112   idOffsetCmd->SetGuidance(" The hostogram ID is set as (scorer_id + <offset>) * <factor> + copy_number - 1");
113   para = new G4UIparameter("offset",'i',true);
114   para->SetParameterRange("offset>=0");
115   para->SetDefaultValue(0);
116   idOffsetCmd->SetParameter(para);
117   para = new G4UIparameter("factor",'i',true);
118   para->SetParameterRange("factor>0");
119   para->SetDefaultValue(1000);
120   idOffsetCmd->SetParameter(para);
121   idOffsetCmd->AvailableForStates(G4State_Idle);
122 
123   oneDDir = new G4UIdirectory("/gorad/analysis/1D/");
124   oneDDir->SetGuidance("1-dimentional histogram");
125 
126   create1DCmd = new G4UIcommand("/gorad/analysis/1D/create",this);
127   create1DCmd->SetGuidance("Create a 1D histogram and fill it with event-by-event score.");
128   create1DCmd->SetGuidance("Scoring mesh (logical volume for real-world volume scoring) and");
129   create1DCmd->SetGuidance("primitive scorers must be defined prior to this command.");
130   para = new G4UIparameter("meshName",'s',false);
131   para->SetGuidance("Scoring mesh name. Logical volume name for real-world volume scoring.");
132   create1DCmd->SetParameter(para);
133   para = new G4UIparameter("primName",'s',false);
134   create1DCmd->SetParameter(para);
135   para = new G4UIparameter("idx",'i',true);
136   para->SetGuidance("Index (i.e. copy number) of the cell to be scored. \"-1\" (defult) to score all cells.");
137   para->SetDefaultValue(-1);
138   para->SetParameterRange("idx>=-1");
139   create1DCmd->SetParameter(para);
140   create1DCmd->AvailableForStates(G4State_Idle);
141 
142   create1DPrimPCmd = new G4UIcommand("/gorad/analysis/1D/primary",this);
143   create1DPrimPCmd->SetGuidance("Create a 1D energy spectrum histogram and fill it with kinetic energy of each primary particle.");
144   create1DPrimPCmd->SetGuidance("Weight of each primary track is taken into account if the flag is set.");
145   para = new G4UIparameter("histName",'s',false);
146   para->SetGuidance("Histogram name");
147   create1DPrimPCmd->SetParameter(para);
148   para = new G4UIparameter("weightFlag",'b',true);
149   para->SetGuidance("Weight of each primary track is taken into account");
150   para->SetDefaultValue(true);
151   create1DPrimPCmd->SetParameter(para);
152   create1DPrimPCmd->AvailableForStates(G4State_Idle);
153 
154   create1DPlotPCmd = new G4UIcommand("/gorad/analysis/1D/spectrum",this);
155   create1DPlotPCmd->SetGuidance("Create a 1D energy spectrum histogram and fill it with each individual track that gets into the volume.");
156   create1DPlotPCmd->SetGuidance("Histogram is created for each physical volume separately.");
157   create1DPlotPCmd->SetGuidance("So, this command should not be used for Box or Cylinder mesh type due to memory consumption concern.");
158   create1DPlotPCmd->SetGuidance("Currently, this is supported only for volume flux scorer.");
159   para = new G4UIparameter("meshName",'s',false);
160   para->SetGuidance("Scoring mesh name. Logical volume name for real-world volume scoring.");
161   create1DPlotPCmd->SetParameter(para);
162   para = new G4UIparameter("primName",'s',false);
163   para->SetGuidance("Scoring primitive name.");
164   create1DPlotPCmd->SetParameter(para);
165   create1DPlotPCmd->AvailableForStates(G4State_Idle);
166 
167   set1DCmd = new G4UIcmdWithoutParameter("/gorad/analysis/1D/set",this);
168   set1DCmd->SetGuidance("This command is obsolete. Use /gorad/analysis/1D/config instead.");
169 
170   config1DCmd = new G4UIcommand("/gorad/analysis/1D/config",this);
171   config1DCmd->SetGuidance("Set binning parameters of the current 1D histogram.");
172   config1DCmd->SetGuidance("<unit> is applied to <minVal> and <maxVal> as well as filled value.");
173   para = new G4UIparameter("nBin",'i',false);
174   para->SetParameterRange("nBin>0");
175   config1DCmd->SetParameter(para);
176   para = new G4UIparameter("minVal",'d',false);
177   config1DCmd->SetParameter(para);
178   para = new G4UIparameter("maxVal",'d',false);
179   config1DCmd->SetParameter(para);
180   para = new G4UIparameter("unit",'s',true);
181   para->SetDefaultValue("none");
182   config1DCmd->SetParameter(para);
183   para = new G4UIparameter("scale",'s',true);
184   para->SetGuidance("Define the binning scale. (default: linear)");
185   para->SetParameterCandidates("linear log");
186   para->SetDefaultValue("linear");
187   config1DCmd->SetParameter(para);
188   para = new G4UIparameter("logVal",'b',true);
189   para->SetDefaultValue(false);
190   config1DCmd->SetParameter(para);
191   config1DCmd->AvailableForStates(G4State_Idle);
192 
193   title1DCmd = new G4UIcommand("/gorad/analysis/1D/title",this);
194   title1DCmd->SetGuidance("Define histogram title");
195   para = new G4UIparameter("title",'s',false);
196   title1DCmd->SetParameter(para);
197   para = new G4UIparameter("x_axis",'s',false);
198   title1DCmd->SetParameter(para);
199   para = new G4UIparameter("y_axis",'s',false);
200   title1DCmd->SetParameter(para);
201   title1DCmd->AvailableForStates(G4State_Idle);
202 
203   set1DYaxisLogCmd = new G4UIcmdWithABool("/gorad/analysis/1D/yaxisLog",this);
204   set1DYaxisLogCmd->SetGuidance("Set y-axis in log scale.");
205   set1DYaxisLogCmd->SetParameterName("flag",true);
206   set1DYaxisLogCmd->SetDefaultValue(true);
207   set1DYaxisLogCmd->AvailableForStates(G4State_Idle);
208 
209   onePDir = new G4UIdirectory("/gorad/analysis/1P/");
210   onePDir->SetGuidance("1-dimentional profile plot");
211 
212   create1PCmd = new G4UIcommand("/gorad/analysis/1P/create",this);
213   create1PCmd->SetGuidance("Create a 1D profile plot and fill it with event-by-event score.");
214   create1PCmd->SetGuidance("Scoring mesh (logical volume for real-world volume scoring) and");
215   create1PCmd->SetGuidance("primitive scorers must be defined prior to this command.");
216   create1PCmd->SetGuidance("Copy number of the scoring cell is used as the x-axis value.");
217   para = new G4UIparameter("meshName",'s',false);
218   para->SetGuidance("Scoring mesh name. Logical volume name for real-world volume scoring.");
219   create1PCmd->SetParameter(para);
220   para = new G4UIparameter("primName",'s',false);
221   create1PCmd->SetParameter(para);
222   para = new G4UIparameter("idx",'i',false);
223   para->SetGuidance("Maximum index (i.e. copy number) of the cell to be scored.");
224   para->SetParameterRange("idx>0");
225   create1PCmd->SetParameter(para);
226   create1PCmd->AvailableForStates(G4State_Idle);
227 
228   set1PCmd = new G4UIcommand("/gorad/analysis/1P/set",this);
229   set1PCmd->SetGuidance("Set binning parameters of the current 1D profile plot.");
230   set1PCmd->SetGuidance("<unit> is applied to <minYVal> and <maxYVal> as well as filled value.");
231   para = new G4UIparameter("minYVal",'d',false);
232   set1PCmd->SetParameter(para);
233   para = new G4UIparameter("maxYVal",'d',false);
234   set1PCmd->SetParameter(para);
235   para = new G4UIparameter("unit",'s',true);
236   para->SetDefaultValue("none");
237   set1PCmd->SetParameter(para);
238   para = new G4UIparameter("func-x",'s',true);
239   para->SetGuidance("The function applied to the filled x-value (default: none).");
240   para->SetParameterCandidates("log log10 exp none");
241   para->SetDefaultValue("none");
242   set1PCmd->SetParameter(para);
243   para = new G4UIparameter("func-y",'s',true);
244   para->SetGuidance("The function applied to the filled y-value (default: none).");
245   para->SetParameterCandidates("log log10 exp none");
246   para->SetDefaultValue("none");
247   set1PCmd->SetParameter(para);
248   para = new G4UIparameter("scale",'s',true);
249   para->SetGuidance("Define the binning scale. (default: linear)");
250   para->SetParameterCandidates("linear log");
251   para->SetDefaultValue("linear");
252   set1PCmd->SetParameter(para);
253   set1PCmd->AvailableForStates(G4State_Idle);
254 
255   title1PCmd = new G4UIcommand("/gorad/analysis/1P/title",this);
256   title1PCmd->SetGuidance("Define histogram title");
257   para = new G4UIparameter("title",'s',false);
258   title1PCmd->SetParameter(para);
259   para = new G4UIparameter("x_axis",'s',false);
260   title1PCmd->SetParameter(para);
261   para = new G4UIparameter("y_axis",'s',false);
262   title1PCmd->SetParameter(para);
263   title1PCmd->AvailableForStates(G4State_Idle);
264 
265   ntupleDir = new G4UIdirectory("/gorad/analysis/ntuple/");
266   onePDir->SetGuidance("Define an ntuple");
267 
268   addColumnCmd = new G4UIcommand("/gorad/analysis/ntuple/addColumn",this);
269   addColumnCmd->SetGuidance("Define a column and fill it with event-by-event score.");
270   addColumnCmd->SetGuidance("Scoring mesh (logical volume for real-world volume scoring) and");
271   addColumnCmd->SetGuidance("primitive scorers must be defined prior to this command.");
272   para = new G4UIparameter("meshName",'s',false);
273   para->SetGuidance("Scoring mesh name. Logical volume name for real-world volume scoring.");
274   addColumnCmd->SetParameter(para);
275   para = new G4UIparameter("primName",'s',false);
276   addColumnCmd->SetParameter(para);
277   para = new G4UIparameter("unit",'s',true);
278   para->SetDefaultValue("none");
279   addColumnCmd->SetParameter(para);
280   para = new G4UIparameter("idx",'i',true);
281   para->SetGuidance("Index (i.e. copy number) of the cell to be scored. \"-1\" (defult) to score all cells.");
282   para->SetDefaultValue(-1);
283   para->SetParameterRange("idx>=-1");
284   addColumnCmd->SetParameter(para);
285   addColumnCmd->AvailableForStates(G4State_Idle);
286 }
287 
288 GRRunActionMessenger::~GRRunActionMessenger()
289 { 
290   delete addColumnCmd;
291   delete ntupleDir;
292 
293   delete create1PCmd;
294   delete set1PCmd;
295   delete title1PCmd;
296   delete onePDir;
297 
298   delete create1DCmd;
299   delete create1DPrimPCmd;
300   delete create1DPlotPCmd;
301   delete set1DCmd;
302   delete config1DCmd;
303   delete title1DCmd;
304   delete set1DYaxisLogCmd;
305   delete oneDDir;
306 
307   delete fileCmd;
308   delete verboseCmd;
309   delete listCmd;
310   delete openCmd;
311   delete plotCmd;
312   delete carryCmd;
313   delete flushCmd;
314   delete resetCmd;
315   delete idOffsetCmd;
316   delete anaDir;
317 }
318 
319 #include "G4Tokenizer.hh"
320 
321 void GRRunActionMessenger::SetNewValue(G4UIcommand* cmd, G4String val)
322 {
323   if(cmd==fileCmd)
324   { pRA->SetFileName(val); }
325   else if(cmd==verboseCmd)
326   { pRA->SetVerbose(verboseCmd->GetNewIntValue(val)); }
327   else if(cmd==listCmd)
328   { pRA->ListHistograms(); }
329   else if(cmd==openCmd)
330   { 
331     auto id = openCmd->GetNewIntValue(val);
332     if(currentID!=id)
333     {
334       if(!CheckOpenID(cmd)) return;
335       auto valid = pRA->Open(id);
336       if(!valid)
337       {
338         G4ExceptionDescription ed;
339         ed << "<" << id << "> is not a valid histogram ID.";
340         cmd->CommandFailed(ed);
341       }
342       else
343       { currentID = id; }
344     }
345   }
346   else if(cmd==plotCmd)
347   { 
348     auto id = plotCmd->GetNewIntValue(val);
349     G4bool valid = true;
350     if(id==-1)
351     { valid = pRA->SetAllPlotting(true); }
352     else
353     { valid = pRA->SetPlotting(id,true); }
354     if(!valid)
355     {
356       G4ExceptionDescription ed;
357       ed << "Histogram/profile id <" << id << "> is not valid.";
358       cmd->CommandFailed(ed);
359     }
360   }
361   else if(cmd==carryCmd)
362   { pRA->SetCarry(carryCmd->GetNewBoolValue(val)); }
363   else if(cmd==flushCmd)
364   { pRA->Flush(); }
365   else if(cmd==resetCmd)
366   { /*pRA->ResetHistograms();*/ }
367   else if(cmd==idOffsetCmd)
368   {
369     G4Tokenizer next(val);
370     G4int offset = StoI(next());
371     G4int factor = StoI(next());
372     pRA->SetOffset(offset,factor);
373   }
374 
375   // 1D histogram commands
376 
377   else if(cmd==create1DCmd)
378   {
379     if(!CheckOpenID(cmd)) return;
380     G4Tokenizer next(val);
381     G4String meshName = next();
382     G4String primName = next();
383     G4int idx = StoI(next());
384     auto id = pRA->Create1D(meshName,primName,idx);
385     if(id<0)
386     {
387       G4ExceptionDescription ed;
388       ed << "1D histogram <" << val << "> cannot be created.";
389       cmd->CommandFailed(ed);
390     }
391     else
392     { currentID = id; }
393   }
394   else if(cmd==create1DPrimPCmd)
395   {
396     if(!CheckOpenID(cmd)) return;
397     G4Tokenizer next(val);
398     G4String meshName = next();
399     G4bool wgt = StoB(next());
400     auto id = pRA->Create1DForPrimary(meshName,wgt);
401     if(id<0)
402     {
403       G4ExceptionDescription ed;
404       ed << "1D histogram <" << val << "> cannot be created.";
405       cmd->CommandFailed(ed);
406     }
407     else
408     { currentID = id; }
409   }
410   else if(cmd==create1DPlotPCmd)
411   {
412     if(!CheckOpenID(cmd)) return;
413     G4Tokenizer next(val);
414     G4String meshName = next();
415     G4String primName = next();
416     G4bool wgt = true;
417     auto id = pRA->Create1DForPlotter(meshName,primName,wgt);
418     if(id<0)
419     {
420       G4ExceptionDescription ed;
421       ed << "1D histogram <" << val << "> cannot be created.";
422       cmd->CommandFailed(ed);
423     }
424     else
425     { currentID = id; }
426   }
427   else if(cmd==set1DCmd)
428   {
429     G4ExceptionDescription ed;
430     ed << "This command is OBSOLETE. Use /gorad/analysis/1D/config command!!";
431     cmd->CommandFailed(ed);
432   }
433   else if(cmd==config1DCmd)
434   {
435     if(!CheckID(cmd)) return;
436     G4Tokenizer next(val);
437     G4int nBin = StoI(next());
438     G4double minVal = StoD(next());
439     G4double maxVal = StoD(next());
440     G4String unit = next();
441     G4String schem = next();
442     G4bool logVal = StoB(next());
443     if(unit!="none" && !(G4UnitDefinition::IsUnitDefined(unit)))
444     { 
445       G4ExceptionDescription ed;
446       ed << "Unknown unit <" << unit << ">. Command failed.";
447       cmd->CommandFailed(ed);
448     }
449     else
450     { pRA->Set1D(currentID,nBin,minVal,maxVal,unit,schem,logVal); }
451   }
452   else if(cmd==title1DCmd)
453   {
454     if(!CheckID(cmd)) return;
455     G4Tokenizer next(val);
456     G4String title = next();
457     G4String x_axis = next();
458     G4String y_axis = next();
459     pRA->Set1DTitle(currentID,title,x_axis,y_axis);
460   }
461   else if(cmd==set1DYaxisLogCmd)
462   {
463     if(!CheckID(cmd)) return;
464     auto succ = pRA->Set1DYAxisLog(currentID,set1DYaxisLogCmd->GetNewBoolValue(val));
465     if(!succ)
466     {
467       G4ExceptionDescription ed;
468       ed << "This command is not available for this histogram.";
469       cmd->CommandFailed(ed);
470     }
471   }
472 
473   // 1D profile commands
474 
475   else if(cmd==create1PCmd)
476   {
477     if(!CheckOpenID(cmd)) return;
478     G4Tokenizer next(val);
479     G4String meshName = next();
480     G4String primName = next();
481     G4int cn = StoI(next());
482     auto id = pRA->Create1P(meshName,primName,cn);
483     if(id<0)
484     {
485       G4ExceptionDescription ed;
486       ed << "1D histogram <" << val << "> cannot be created.";
487       cmd->CommandFailed(ed);
488     }
489     else
490     { currentID = id; }
491   }
492   else if(cmd==set1PCmd)
493   {
494     if(!CheckID(cmd)) return;
495     G4Tokenizer next(val);
496     G4double minYVal = StoD(next());
497     G4double maxYVal = StoD(next());
498     G4String unit = next();
499     G4String funcX = next();
500     G4String funcY = next();
501     G4String schem = next();
502     if(unit!="none" && !(G4UnitDefinition::IsUnitDefined(unit)))
503     { 
504       G4ExceptionDescription ed;
505       ed << "Unknown unit <" << unit << ">. Command failed.";
506       cmd->CommandFailed(ed);
507     }
508     else
509     { pRA->Set1P(currentID,minYVal,maxYVal,unit,funcX,funcY,schem); }
510   }
511   else if(cmd==title1PCmd)
512   {
513     if(!CheckID(cmd)) return;
514     G4Tokenizer next(val);
515     G4String title = next();
516     G4String x_axis = next();
517     G4String y_axis = next();
518     pRA->Set1PTitle(currentID,title,x_axis,y_axis);
519   }
520 
521   // ntuple commands
522 
523   else if(cmd==addColumnCmd)
524   {
525     G4Tokenizer next(val);
526     G4String meshName = next();
527     G4String primName = next();
528     G4String unit = next();
529     G4int idx = StoI(next());
530     if(unit!="none" && !(G4UnitDefinition::IsUnitDefined(unit)))
531     { 
532       G4ExceptionDescription ed;
533       ed << "Unknown unit <" << unit << ">. Command failed.";
534       cmd->CommandFailed(ed);
535     }
536     else
537     {
538       auto id = pRA->NtupleColumn(meshName,primName,unit,idx);
539       if(id<0)
540       {
541         G4ExceptionDescription ed;
542         ed << "Ntuple column <" << val << "> cannot be created.";
543         cmd->CommandFailed(ed);
544       }
545     }
546   }
547 }
548 
549 G4String GRRunActionMessenger::GetCurrentValue(G4UIcommand* cmd)
550 {
551   G4String val("");
552   if(cmd==openCmd)
553   { val = openCmd->ConvertToString(currentID); }
554   if(cmd==fileCmd)
555   { val = pRA->GetFileName(); }
556   else if(cmd==verboseCmd)
557   { val = verboseCmd->ConvertToString(pRA->GetVerbose()); }
558   else if(cmd==plotCmd)
559   { val = plotCmd->ConvertToString(currentID); }
560   else if(cmd==carryCmd)
561   { val = carryCmd->ConvertToString(pRA->GetCarry()); }
562   else if(cmd==idOffsetCmd)
563   {
564     G4int offset = 0;
565     G4int factor = 0;
566     pRA->GetOffset(offset,factor);
567     val = idOffsetCmd->ConvertToString(offset);
568     val += " ";
569     val += idOffsetCmd->ConvertToString(factor);
570   }
571 
572   return val;
573 }
574 
575 
576