Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AnalysisMessenger.cc
Go to the documentation of this file.
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// $Id$
27
28// Author: Ivana Hrivnacova, 04/07/2012 ([email protected])
29//
30// This messenger class is a generalization of the HistoMessenger class,
31// originally developed for the extended/electromagnetic examples
32// by Michel Maire ([email protected])
33
35#include "G4VAnalysisManager.hh"
36#include "G4HnInformation.hh"
37
38#include "G4UIdirectory.hh"
39#include "G4UIcommand.hh"
40#include "G4UIparameter.hh"
41#include "G4UIcmdWithAString.hh"
43#include "G4UIcmdWithABool.hh"
44
45#include <iostream>
46
47//_____________________________________________________________________________
49 : G4UImessenger(),
50 fManager(manager),
51 fAnalysisDir(0),
52 fSetFileNameCmd(0),
53 fSetHistoDirNameCmd(0),
54 fSetNtupleDirNameCmd(0),
55 fSetActivationCmd(0),
56 fVerboseCmd(0),
57 fH1Dir(0),
58 fCreateH1Cmd(0),
59 fSetH1Cmd(0),
60 fSetH1AsciiCmd(0),
61 fSetH1TitleCmd(0),
62 fSetH1XAxisCmd(0),
63 fSetH1YAxisCmd(0),
64 fSetH1ActivationCmd(0),
65 fSetH1ActivationAllCmd(0),
66 fH2Dir(0),
67 fCreateH2Cmd(0),
68 fSetH2Cmd(0),
69 fSetH2AsciiCmd(0),
70 fSetH2TitleCmd(0),
71 fSetH2XAxisCmd(0),
72 fSetH2YAxisCmd(0),
73 fSetH2ActivationCmd(0),
74 fSetH2ActivationAllCmd(0)
75{
76 fAnalysisDir = new G4UIdirectory("/analysis/");
77 fAnalysisDir->SetGuidance("analysis control");
78
79 fSetFileNameCmd = new G4UIcmdWithAString("/analysis/setFileName",this);
80 fSetFileNameCmd->SetGuidance("Set name for the histograms & ntuple file");
81 fSetFileNameCmd->SetParameterName("Filename", false);
83
84 fSetHistoDirNameCmd = new G4UIcmdWithAString("/analysis/setHistoDirName",this);
85 fSetHistoDirNameCmd->SetGuidance("Set name for the histograms directory");
86 fSetHistoDirNameCmd->SetParameterName("HistoDirName", false);
87 fSetHistoDirNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
88
89 fSetNtupleDirNameCmd = new G4UIcmdWithAString("/analysis/setNtupleDirName",this);
90 fSetNtupleDirNameCmd->SetGuidance("Set name for the ntuple directory");
91 fSetNtupleDirNameCmd->SetParameterName("NtupleDirName", false);
92 fSetNtupleDirNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
93
94 fSetActivationCmd = new G4UIcmdWithABool("/analysis/setActivation",this);
95 G4String guidance = "Set activation. \n";
96 guidance += "When this option is enabled, only the histograms marked as activated\n";
97 guidance += "are returned, filled or saved on file.\n";
98 guidance += "No warning is issued when Get or Fill is called on inactive histogram.";
99 fSetActivationCmd->SetGuidance(guidance);
100 fSetActivationCmd->SetParameterName("Activation",false);
101
102 fVerboseCmd = new G4UIcmdWithAnInteger("/analysis/verbose",this);
103 fVerboseCmd->SetGuidance("Set verbose level");
104 fVerboseCmd->SetParameterName("VerboseLevel",false);
105 fVerboseCmd->SetRange("VerboseLevel>=0 && VerboseLevel<=4");
106
107 fH1Dir = new G4UIdirectory("/analysis/h1/");
108 fH1Dir->SetGuidance("1D histograms control");
109
110 CreateH1Cmd();
111 SetH1Cmd();
112
113 fSetH1AsciiCmd = new G4UIcmdWithAnInteger("/analysis/h1/setAscii",this);
114 fSetH1AsciiCmd->SetGuidance("Print 1D histogram of #Id on ascii file.");
115 fSetH1AsciiCmd->SetParameterName("Id",false);
116 fSetH1AsciiCmd->SetRange("Id>=0");
118
119 SetH1TitleCmd();
120 SetH1XAxisCmd();
121 SetH1YAxisCmd();
122 SetH1ActivationCmd();
123
124 fSetH1ActivationAllCmd = new G4UIcmdWithABool("/analysis/h1/setActivationToAll",this);
125 fSetH1ActivationAllCmd->SetGuidance("Set activation to all 1D histograms.");
126 fSetH1ActivationAllCmd->SetParameterName("Activation",false);
127
128 fH2Dir = new G4UIdirectory("/analysis/h2/");
129 fH2Dir->SetGuidance("2D histograms control");
130
131 CreateH2Cmd();
132 SetH2Cmd();
133
134 fSetH2AsciiCmd = new G4UIcmdWithAnInteger("/analysis/h2/setAscii",this);
135 fSetH2AsciiCmd->SetGuidance("Print 2D histogram of #Id on ascii file.");
136 fSetH2AsciiCmd->SetParameterName("Id",false);
137 fSetH2AsciiCmd->SetRange("Id>=0");
139
140 SetH2TitleCmd();
141 SetH2XAxisCmd();
142 SetH2YAxisCmd();
143 SetH2ZAxisCmd();
144 SetH2ActivationCmd();
145
146 fSetH2ActivationAllCmd = new G4UIcmdWithABool("/analysis/h2/setActivationToAll",this);
147 fSetH2ActivationAllCmd->SetGuidance("Set activation to all 2D histograms.");
148 fSetH2ActivationAllCmd->SetParameterName("Activation",false);
149
150}
151
152//_____________________________________________________________________________
154{
155 delete fSetFileNameCmd;
156 delete fSetHistoDirNameCmd;
157 delete fSetNtupleDirNameCmd;
158 delete fSetActivationCmd;
159 delete fVerboseCmd;
160 delete fCreateH1Cmd;
161 delete fSetH1Cmd;
162 delete fSetH1AsciiCmd;
163 delete fSetH1TitleCmd;
164 delete fSetH1XAxisCmd;
165 delete fSetH1YAxisCmd;
166 delete fSetH1ActivationCmd;
167 delete fSetH1ActivationAllCmd;
168 delete fH1Dir;
169 delete fCreateH2Cmd;
170 delete fSetH2Cmd;
171 delete fSetH2AsciiCmd;
172 delete fSetH2TitleCmd;
173 delete fSetH2XAxisCmd;
174 delete fSetH2YAxisCmd;
175 delete fSetH2ZAxisCmd;
176 delete fSetH2ActivationCmd;
177 delete fSetH2ActivationAllCmd;
178 delete fH2Dir;
179 delete fAnalysisDir;
180}
181
182//
183// private functions
184//
185
186//_____________________________________________________________________________
187void G4AnalysisMessenger::CreateH1Cmd()
188{
189 G4UIparameter* h1Name = new G4UIparameter("name", 's', false);
190 h1Name->SetGuidance("Histogram name (label)");
191
192 G4UIparameter* h1Title = new G4UIparameter("title", 's', false);
193 h1Title->SetGuidance("Histogram title");
194
195 G4UIparameter* h1Nbins0 = new G4UIparameter("nbins0", 'i', true);
196 h1Nbins0->SetGuidance("Number of bins (default = 100)");
197 h1Nbins0->SetGuidance("Can be reset with /analysis/h1/set command");
198 h1Nbins0->SetDefaultValue(100);
199
200 G4UIparameter* h1ValMin0 = new G4UIparameter("valMin0", 'd', true);
201 h1ValMin0->SetGuidance("Minimum value, expressed in unit (default = 0.)");
202 h1ValMin0->SetGuidance("Can be reset with /analysis/h1/set command");
203 h1ValMin0->SetDefaultValue(0.);
204
205 G4UIparameter* h1ValMax0 = new G4UIparameter("valMax0", 'd', true);
206 h1ValMax0->SetGuidance("Maximum value, expressed in unit (default = 1.)");
207 h1ValMax0->SetGuidance("Can be reset with /analysis/h1/set command");
208 h1ValMax0->SetDefaultValue(1.);
209
210 G4UIparameter* h1ValUnit0 = new G4UIparameter("valUnit0", 's', true);
211 h1ValUnit0->SetGuidance("The unit of valMin0 and valMax0");
212 h1ValUnit0->SetDefaultValue("none");
213
214 G4UIparameter* h1ValFcn0 = new G4UIparameter("valFcn0", 's', true);
215 G4String fcnGuidance = "The function applied to filled values (log, log10, exp).\n";
216 fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
217 fcnGuidance += "but none value should be used insted.";
218 h1ValFcn0->SetGuidance(fcnGuidance);
219 h1ValFcn0->SetParameterCandidates("log log10 exp none");
220 h1ValFcn0->SetDefaultValue("none");
221
222 fCreateH1Cmd = new G4UIcommand("/analysis/h1/create", this);
223 fCreateH1Cmd->SetGuidance("Create 1D histogram");
224 fCreateH1Cmd->SetParameter(h1Name);
225 fCreateH1Cmd->SetParameter(h1Title);
226 fCreateH1Cmd->SetParameter(h1Nbins0);
227 fCreateH1Cmd->SetParameter(h1ValMin0);
228 fCreateH1Cmd->SetParameter(h1ValMax0);
229 fCreateH1Cmd->SetParameter(h1ValUnit0);
230 fCreateH1Cmd->SetParameter(h1ValFcn0);
232}
233
234
235//_____________________________________________________________________________
236void G4AnalysisMessenger::SetH1Cmd()
237{
238 G4UIparameter* h1Id = new G4UIparameter("id", 'i', false);
239 h1Id->SetGuidance("Histogram id");
240 h1Id->SetParameterRange("id>=0");
241
242 G4UIparameter* h1Nbins = new G4UIparameter("nbins", 'i', false);
243 h1Nbins->SetGuidance("Number of bins");
244
245 G4UIparameter* h1ValMin = new G4UIparameter("valMin", 'd', false);
246 h1ValMin->SetGuidance("Minimum value, expressed in unit");
247
248 G4UIparameter* h1ValMax = new G4UIparameter("valMax", 'd', false);
249 h1ValMax->SetGuidance("Maximum value, expressed in unit");
250
251 G4UIparameter* h1ValUnit = new G4UIparameter("valUnit", 's', true);
252 h1ValUnit->SetGuidance("The unit of valMin and valMax");
253 h1ValUnit->SetDefaultValue("none");
254
255 G4UIparameter* h1ValFcn = new G4UIparameter("valFcn", 's', true);
256 h1ValFcn->SetParameterCandidates("log log10 exp none");
257 G4String fcnGuidance = "The function applied to filled values (log, log10, exp, none).\n";
258 fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
259 fcnGuidance += "but none value should be used insted.";
260 h1ValFcn->SetGuidance(fcnGuidance);
261 h1ValFcn->SetDefaultValue("none");
262
263 fSetH1Cmd = new G4UIcommand("/analysis/h1/set", this);
264 fSetH1Cmd->SetGuidance("Set parameters for the 1D histogram of #Id :");
265 fSetH1Cmd->SetGuidance(" nbins; valMin; valMax; unit (of vmin and vmax)");
266 fSetH1Cmd->SetParameter(h1Id);
267 fSetH1Cmd->SetParameter(h1Nbins);
268 fSetH1Cmd->SetParameter(h1ValMin);
269 fSetH1Cmd->SetParameter(h1ValMax);
270 fSetH1Cmd->SetParameter(h1ValUnit);
271 fSetH1Cmd->SetParameter(h1ValFcn);
273}
274
275//_____________________________________________________________________________
276void G4AnalysisMessenger::SetH1TitleCmd()
277{
278 G4UIparameter* h1Id = new G4UIparameter("idTitle", 'i', false);
279 h1Id->SetGuidance("Histogram id");
280 h1Id->SetParameterRange("idTitle>=0");
281
282 G4UIparameter* h1Title = new G4UIparameter("h1Title", 's', true);
283 h1Title->SetGuidance("Histogram title");
284 h1Title->SetDefaultValue("none");
285
286 fSetH1TitleCmd = new G4UIcommand("/analysis/h1/setTitle", this);
287 fSetH1TitleCmd->SetGuidance("Set title for the 1D histogram of #Id");
288 fSetH1TitleCmd->SetParameter(h1Id);
289 fSetH1TitleCmd->SetParameter(h1Title);
291}
292
293//_____________________________________________________________________________
294void G4AnalysisMessenger::SetH1XAxisCmd()
295{
296 G4UIparameter* h1Id = new G4UIparameter("idXaxis", 'i', false);
297 h1Id->SetGuidance("Histogram id");
298 h1Id->SetParameterRange("idXaxis>=0");
299
300 G4UIparameter* h1XAxis = new G4UIparameter("h1Xaxis", 's', true);
301 h1XAxis->SetGuidance("Histogram x-axis title");
302 h1XAxis->SetDefaultValue("none");
303
304 fSetH1XAxisCmd = new G4UIcommand("/analysis/h1/setXaxis", this);
305 fSetH1XAxisCmd->SetGuidance("Set x-axis title for the 1D histogram of #Id");
306 fSetH1XAxisCmd->SetParameter(h1Id);
307 fSetH1XAxisCmd->SetParameter(h1XAxis);
309}
310
311//_____________________________________________________________________________
312void G4AnalysisMessenger::SetH1YAxisCmd()
313{
314 G4UIparameter* h1Id = new G4UIparameter("idYaxis", 'i', false);
315 h1Id->SetGuidance("Histogram id");
316 h1Id->SetParameterRange("idYaxis>=0");
317
318 G4UIparameter* h1YAxis = new G4UIparameter("h1Yaxis", 's', true);
319 h1YAxis->SetGuidance("Histogram y-axis title");
320 h1YAxis->SetDefaultValue("none");
321
322 fSetH1YAxisCmd = new G4UIcommand("/analysis/h1/setYaxis", this);
323 fSetH1YAxisCmd->SetGuidance("Set y-axis title for the 1D histogram of #Id");
324 fSetH1YAxisCmd->SetParameter(h1Id);
325 fSetH1YAxisCmd->SetParameter(h1YAxis);
327}
328
329//_____________________________________________________________________________
330void G4AnalysisMessenger::SetH1ActivationCmd()
331{
332 G4UIparameter* h1Id = new G4UIparameter("idActivation", 'i', false);
333 h1Id->SetGuidance("Histogram id");
334 h1Id->SetParameterRange("idActivation>=0");
335
336 G4UIparameter* h1Activation = new G4UIparameter("h1Activation", 's', true);
337 h1Activation->SetGuidance("Histogram activation");
338 h1Activation->SetDefaultValue("none");
339
340 fSetH1ActivationCmd = new G4UIcommand("/analysis/h1/setActivation", this);
341 fSetH1ActivationCmd->SetGuidance("Set activation for the 1D histogram of #Id");
342 fSetH1ActivationCmd->SetParameter(h1Id);
343 fSetH1ActivationCmd->SetParameter(h1Activation);
344 fSetH1ActivationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
345}
346
347//_____________________________________________________________________________
348void G4AnalysisMessenger::CreateH2Cmd()
349{
350 G4UIparameter* h2Name = new G4UIparameter("name", 's', false);
351 h2Name->SetGuidance("Histogram name (label)");
352
353 G4UIparameter* h2Title = new G4UIparameter("title", 's', false);
354 h2Title->SetGuidance("Histogram title");
355
356 G4UIparameter* h2xNbins0 = new G4UIparameter("xnbins0", 'i', true);
357 h2xNbins0->SetGuidance("Number of x-bins (default = 100)");
358 h2xNbins0->SetGuidance("Can be reset with /analysis/h2/set command");
359 h2xNbins0->SetDefaultValue(100);
360
361 G4UIparameter* h2xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
362 h2xValMin0->SetGuidance("Minimum x-value, expressed in unit (default = 0.)");
363 h2xValMin0->SetGuidance("Can be reset with /analysis/h2/set command");
364 h2xValMin0->SetDefaultValue(0.);
365
366 G4UIparameter* h2xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
367 h2xValMax0->SetGuidance("Maximum x-value, expressed in unit (default = 1.)");
368 h2xValMax0->SetGuidance("Can be reset with /analysis/h2/set command");
369 h2xValMax0->SetDefaultValue(1.);
370
371 G4UIparameter* h2xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
372 h2xValUnit0->SetGuidance("The unit of xvalMin0 and xvalMax0");
373 h2xValUnit0->SetDefaultValue("none");
374
375 G4UIparameter* h2xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
376 G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).\n";
377 fcnxGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
378 fcnxGuidance += "but none value should be used insted.";
379 h2xValFcn0->SetGuidance(fcnxGuidance);
380 h2xValFcn0->SetParameterCandidates("log log10 exp none");
381 h2xValFcn0->SetDefaultValue("none");
382
383 G4UIparameter* h2yNbins0 = new G4UIparameter("ynbins0", 'i', true);
384 h2yNbins0->SetGuidance("Number of y-bins (default = 100)");
385 h2yNbins0->SetGuidance("Can be reset with /analysis/h2/set command");
386 h2yNbins0->SetDefaultValue(100);
387
388 G4UIparameter* h2yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
389 h2yValMin0->SetGuidance("Minimum y-value, expressed in unit (default = 0.)");
390 h2yValMin0->SetGuidance("Can be reset with /analysis/h2/set command");
391 h2yValMin0->SetDefaultValue(0.);
392
393 G4UIparameter* h2yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
394 h2yValMax0->SetGuidance("Maximum y-value, expressed in unit (default = 1.)");
395 h2yValMax0->SetGuidance("Can be reset with /analysis/h2/set command");
396 h2yValMax0->SetDefaultValue(1.);
397
398 G4UIparameter* h2yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
399 h2yValUnit0->SetGuidance("The unit of xvalMin0 and yvalMax0");
400 h2yValUnit0->SetDefaultValue("none");
401
402 G4UIparameter* h2yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
403 G4String fcnyGuidance = "The function applied to filled x-values (log, log10, exp, none).\n";
404 fcnyGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
405 fcnyGuidance += "but none value should be used insted.";
406 h2yValFcn0->SetGuidance(fcnyGuidance);
407 h2yValFcn0->SetParameterCandidates("log log10 exp none");
408 h2yValFcn0->SetDefaultValue("none");
409
410 fCreateH2Cmd = new G4UIcommand("/analysis/h2/create", this);
411 fCreateH2Cmd->SetGuidance("Create 2D histogram");
412 fCreateH2Cmd->SetParameter(h2Name);
413 fCreateH2Cmd->SetParameter(h2Title);
414 fCreateH2Cmd->SetParameter(h2xNbins0);
415 fCreateH2Cmd->SetParameter(h2xValMin0);
416 fCreateH2Cmd->SetParameter(h2xValMax0);
417 fCreateH2Cmd->SetParameter(h2xValUnit0);
418 fCreateH2Cmd->SetParameter(h2xValFcn0);
419 fCreateH2Cmd->SetParameter(h2yNbins0);
420 fCreateH2Cmd->SetParameter(h2yValMin0);
421 fCreateH2Cmd->SetParameter(h2yValMax0);
422 fCreateH2Cmd->SetParameter(h2yValUnit0);
423 fCreateH2Cmd->SetParameter(h2yValFcn0);
425}
426
427
428//_____________________________________________________________________________
429void G4AnalysisMessenger::SetH2Cmd()
430{
431 G4UIparameter* h2Id = new G4UIparameter("id", 'i', false);
432 h2Id->SetGuidance("Histogram id");
433 h2Id->SetParameterRange("id>=0");
434
435 G4UIparameter* h2xNbins = new G4UIparameter("xnbins", 'i', false);
436 h2xNbins->SetGuidance("Number of x-bins");
437
438 G4UIparameter* h2xValMin = new G4UIparameter("xvalMin", 'd', false);
439 h2xValMin->SetGuidance("Minimum x-value, expressed in unit");
440
441 G4UIparameter* h2xValMax = new G4UIparameter("xvalMax", 'd', false);
442 h2xValMax->SetGuidance("Maximum x-value, expressed in unit");
443
444 G4UIparameter* h2xValFcn = new G4UIparameter("xvalFcn", 's', false);
445 h2xValFcn->SetParameterCandidates("log log10 exp none");
446 G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).\n";
447 fcnxGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
448 fcnxGuidance += "but none value should be used insted.";
449 h2xValFcn->SetGuidance(fcnxGuidance);
450 h2xValFcn->SetDefaultValue("none");
451
452 G4UIparameter* h2yValUnit = new G4UIparameter("yvalUnit", 's', false);
453 h2yValUnit->SetGuidance("The unit of yvalMin and yvalMax");
454 h2yValUnit->SetDefaultValue("none");
455
456 G4UIparameter* h2yNbins = new G4UIparameter("nybins", 'i', false);
457 h2yNbins->SetGuidance("Number of y-bins");
458
459 G4UIparameter* h2yValMin = new G4UIparameter("yvalMin", 'd', false);
460 h2yValMin->SetGuidance("Minimum y-value, expressed in unit");
461
462 G4UIparameter* h2yValMax = new G4UIparameter("yvalMax", 'd', false);
463 h2yValMax->SetGuidance("Maximum y-value, expressed in unit");
464
465 G4UIparameter* h2xValUnit = new G4UIparameter("xvalUnit", 's', true);
466 h2xValUnit->SetGuidance("The unit of xvalMin and xvalMax");
467 h2xValUnit->SetDefaultValue("none");
468
469 G4UIparameter* h2yValFcn = new G4UIparameter("yvalFcn", 's', false);
470 h2yValFcn->SetParameterCandidates("log log10 exp none");
471 G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).\n";
472 fcnyGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
473 fcnyGuidance += "but none value should be used insted.";
474 h2yValFcn->SetGuidance(fcnyGuidance);
475 h2yValFcn->SetDefaultValue("none");
476
477 fSetH2Cmd = new G4UIcommand("/analysis/h2/set", this);
478 fSetH2Cmd->SetGuidance("Set parameters for the 2D histogram of #Id :");
479 fSetH2Cmd->SetGuidance(" nbins; valMin; valMax; unit (of vmin and vmax)");
480 fSetH2Cmd->SetParameter(h2Id);
481 fSetH2Cmd->SetParameter(h2xNbins);
482 fSetH2Cmd->SetParameter(h2xValMin);
483 fSetH2Cmd->SetParameter(h2xValMax);
484 fSetH2Cmd->SetParameter(h2xValUnit);
485 fSetH2Cmd->SetParameter(h2xValFcn);
486 fSetH2Cmd->SetParameter(h2yNbins);
487 fSetH2Cmd->SetParameter(h2yValMin);
488 fSetH2Cmd->SetParameter(h2yValMax);
489 fSetH2Cmd->SetParameter(h2yValUnit);
490 fSetH2Cmd->SetParameter(h2yValFcn);
492}
493
494//_____________________________________________________________________________
495void G4AnalysisMessenger::SetH2TitleCmd()
496{
497 G4UIparameter* h2Id = new G4UIparameter("idTitle", 'i', false);
498 h2Id->SetGuidance("Histogram id");
499 h2Id->SetParameterRange("idTitle>=0");
500
501 G4UIparameter* h2Title = new G4UIparameter("h2Title", 's', true);
502 h2Title->SetGuidance("Histogram title");
503 h2Title->SetDefaultValue("none");
504
505 fSetH2TitleCmd = new G4UIcommand("/analysis/h2/setTitle", this);
506 fSetH2TitleCmd->SetGuidance("Set title for the 2D histogram of #Id");
507 fSetH2TitleCmd->SetParameter(h2Id);
508 fSetH2TitleCmd->SetParameter(h2Title);
510}
511
512//_____________________________________________________________________________
513void G4AnalysisMessenger::SetH2XAxisCmd()
514{
515 G4UIparameter* h2Id = new G4UIparameter("idXaxis", 'i', false);
516 h2Id->SetGuidance("Histogram id");
517 h2Id->SetParameterRange("idXaxis>=0");
518
519 G4UIparameter* h2XAxis = new G4UIparameter("h2Xaxis", 's', true);
520 h2XAxis->SetGuidance("Histogram x-axis title");
521 h2XAxis->SetDefaultValue("none");
522
523 fSetH2XAxisCmd = new G4UIcommand("/analysis/h2/setXaxis", this);
524 fSetH2XAxisCmd->SetGuidance("Set x-axis title for the 2D histogram of #Id");
525 fSetH2XAxisCmd->SetParameter(h2Id);
526 fSetH2XAxisCmd->SetParameter(h2XAxis);
528}
529
530//_____________________________________________________________________________
531void G4AnalysisMessenger::SetH2YAxisCmd()
532{
533 G4UIparameter* h2Id = new G4UIparameter("idYaxis", 'i', false);
534 h2Id->SetGuidance("Histogram id");
535 h2Id->SetParameterRange("idYaxis>=0");
536
537 G4UIparameter* h2YAxis = new G4UIparameter("h2Yaxis", 's', true);
538 h2YAxis->SetGuidance("Histogram y-axis title");
539 h2YAxis->SetDefaultValue("none");
540
541 fSetH2YAxisCmd = new G4UIcommand("/analysis/h2/setYaxis", this);
542 fSetH2YAxisCmd->SetGuidance("Set y-axis title for the 2D histogram of #Id");
543 fSetH2YAxisCmd->SetParameter(h2Id);
544 fSetH2YAxisCmd->SetParameter(h2YAxis);
546}
547
548//_____________________________________________________________________________
549void G4AnalysisMessenger::SetH2ZAxisCmd()
550{
551 G4UIparameter* h2Id = new G4UIparameter("idYaxis", 'i', false);
552 h2Id->SetGuidance("Histogram id");
553 h2Id->SetParameterRange("idYaxis>=0");
554
555 G4UIparameter* h2YAxis = new G4UIparameter("h2Yaxis", 's', true);
556 h2YAxis->SetGuidance("Histogram y-axis title");
557 h2YAxis->SetDefaultValue("none");
558
559 fSetH2ZAxisCmd = new G4UIcommand("/analysis/h2/setYaxis", this);
560 fSetH2ZAxisCmd->SetGuidance("Set y-axis title for the 2D histogram of #Id");
561 fSetH2ZAxisCmd->SetParameter(h2Id);
562 fSetH2ZAxisCmd->SetParameter(h2YAxis);
564}
565
566//_____________________________________________________________________________
567void G4AnalysisMessenger::SetH2ActivationCmd()
568{
569 G4UIparameter* h2Id = new G4UIparameter("idActivation", 'i', false);
570 h2Id->SetGuidance("Histogram id");
571 h2Id->SetParameterRange("idActivation>=0");
572
573 G4UIparameter* h2Activation = new G4UIparameter("h2Activation", 's', true);
574 h2Activation->SetGuidance("Histogram activation");
575 h2Activation->SetDefaultValue("none");
576
577 fSetH2ActivationCmd = new G4UIcommand("/analysis/h2/setActivation", this);
578 fSetH2ActivationCmd->SetGuidance("Set activation for the 2D histogram of #Id");
579 fSetH2ActivationCmd->SetParameter(h2Id);
580 fSetH2ActivationCmd->SetParameter(h2Activation);
581 fSetH2ActivationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
582}
583
584//_____________________________________________________________________________
586{
587 if ( command == fSetFileNameCmd ) {
588 G4cout << "Set file name: " << newValues << G4endl;
589 fManager->SetFileName(newValues);
590 }
591 else if ( command == fSetHistoDirNameCmd ) {
592 fManager->SetHistoDirectoryName(newValues);
593 }
594 else if ( command == fSetNtupleDirNameCmd ) {
595 fManager->SetNtupleDirectoryName(newValues);
596 }
597 else if ( command == fSetActivationCmd ) {
598 fManager->SetActivation(fSetActivationCmd->GetNewBoolValue(newValues));
599 }
600 else if ( command == fVerboseCmd ) {
601 fManager->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValues));
602 }
603 else if ( command == fCreateH1Cmd ) {
604 G4String name, title;
605 G4int nbins;
606 G4double vmin,vmax;
607 G4String sunit;
608 G4String sfcn;
609 std::istringstream is(newValues.data());
610 is >> name >> title >> nbins >> vmin >> vmax >> sunit >> sfcn;
611 fManager->CreateH1(name, title, nbins, vmin, vmax, sunit, sfcn);
612 }
613 else if ( command == fSetH1Cmd ) {
614 G4int id;
615 G4int nbins;
616 G4double vmin, vmax;
617 G4String sunit;
618 G4String sfcn;
619 std::istringstream is(newValues.data());
620 is >> id >> nbins >> vmin >> vmax >> sunit >> sfcn;
621 fManager->SetH1(id, nbins, vmin, vmax, sunit, sfcn);
622 }
623 else if ( command == fSetH1AsciiCmd ) {
624 G4int id = fSetH1AsciiCmd->GetNewIntValue(newValues);
625 fManager->SetAscii(G4VAnalysisManager::kH1, id, true);
626 }
627 else if ( command == fSetH1TitleCmd ) {
628 G4int id;
629 G4String title;
630 std::istringstream is(newValues.data());
631 is >> id;
632 getline(is, title);
633 fManager->SetH1Title(id, title);
634 }
635 else if ( command == fSetH1XAxisCmd ) {
636 G4int id;
637 G4String xaxis;
638 std::istringstream is(newValues.data());
639 is >> id;
640 getline(is, xaxis);
641 fManager->SetH1XAxisTitle(id, xaxis);
642 }
643 else if ( command == fSetH1YAxisCmd ) {
644 G4int id;
645 G4String yaxis;
646 std::istringstream is(newValues.data());
647 is >> id;
648 getline(is, yaxis);
649 fManager->SetH1YAxisTitle(id, yaxis);
650 }
651 else if ( command == fSetH1ActivationCmd ) {
652 G4int id;
653 G4String sactivation;
654 std::istringstream is(newValues.data());
655 is >> id >> sactivation;
656 G4bool activation = G4UIcommand::ConvertToBool(sactivation);
657 fManager->SetActivation(G4VAnalysisManager::kH1, id, activation);
658 }
659 else if ( command == fSetH1ActivationAllCmd ) {
660 G4bool activation = fSetH1ActivationAllCmd->GetNewBoolValue(newValues);
661 fManager->SetActivation(G4VAnalysisManager::kH1, activation);
662 }
663 else if ( command == fCreateH2Cmd ) {
664 G4String name, title;
665 G4int xnbins, ynbins;
666 G4double xvmin, xvmax, yvmin, yvmax;
667 G4String xsunit,xsfcn, ysunit, ysfcn;
668 std::istringstream is(newValues.data());
669 is >> name >> title
670 >> xnbins >> xvmin >> xvmax >> xsunit >> xsfcn
671 >> ynbins >> yvmin >> yvmax >> ysunit >> ysfcn;
672 fManager->CreateH2(name, title,
673 xnbins, xvmin, xvmax, ynbins, yvmin, yvmax,
674 ysunit, ysfcn, ysunit, ysfcn);
675 }
676 else if ( command == fSetH2Cmd ) {
677 G4int id;
678 G4int xnbins, ynbins;
679 G4double xvmin, xvmax, yvmin, yvmax;
680 G4String xsunit,xsfcn, ysunit, ysfcn;
681 std::istringstream is(newValues.data());
682 is >> id
683 >> xnbins >> xvmin >> xvmax >> xsunit >> xsfcn
684 >> ynbins >> yvmin >> yvmax >> ysunit >> ysfcn;
685 fManager->SetH2(id,
686 xnbins, xvmin, xvmax, ynbins, yvmin, yvmax,
687 ysunit, ysfcn, ysunit, ysfcn);
688 }
689 else if ( command == fSetH2AsciiCmd ) {
690 G4int id = fSetH2AsciiCmd->GetNewIntValue(newValues);
691 fManager->SetAscii(G4VAnalysisManager::kH2, id, true);
692 }
693 else if ( command == fSetH2TitleCmd ) {
694 G4int id;
695 G4String title;
696 std::istringstream is(newValues.data());
697 is >> id;
698 getline(is, title);
699 fManager->SetH2Title(id, title);
700 }
701 else if ( command == fSetH2XAxisCmd ) {
702 G4int id;
703 G4String xaxis;
704 std::istringstream is(newValues.data());
705 is >> id;
706 getline(is, xaxis);
707 fManager->SetH2XAxisTitle(id, xaxis);
708 }
709 else if ( command == fSetH2YAxisCmd ) {
710 G4int id;
711 G4String yaxis;
712 std::istringstream is(newValues.data());
713 is >> id;
714 getline(is, yaxis);
715 fManager->SetH2YAxisTitle(id, yaxis);
716 }
717 else if ( command == fSetH2ZAxisCmd ) {
718 G4int id;
719 G4String zaxis;
720 std::istringstream is(newValues.data());
721 is >> id;
722 getline(is, zaxis);
723 fManager->SetH2ZAxisTitle(id, zaxis);
724 }
725 else if ( command == fSetH2ActivationCmd ) {
726 G4int id;
727 G4String sactivation;
728 std::istringstream is(newValues.data());
729 is >> id >> sactivation;
730 G4bool activation = G4UIcommand::ConvertToBool(sactivation);
731 fManager->SetActivation(G4VAnalysisManager::kH2, id, activation);
732 }
733 else if ( command == fSetH2ActivationAllCmd ) {
734 G4bool activation = fSetH2ActivationAllCmd->GetNewBoolValue(newValues);
735 fManager->SetActivation(G4VAnalysisManager::kH2, activation);
736 }
737}
@ G4State_Idle
@ G4State_PreInit
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4AnalysisMessenger(G4VAnalysisManager *manager)
virtual void SetNewValue(G4UIcommand *command, G4String value)
const char * data() const
static G4bool GetNewBoolValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:147
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:403
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:219
void SetDefaultValue(const char *theDefaultValue)
void SetGuidance(const char *theGuidance)
void SetParameterRange(const char *theRange)
void SetParameterCandidates(const char *theString)
void SetAscii(ObjectType type, G4int id, G4bool ascii)
void SetActivation(G4bool activation)
virtual G4bool SetH2ZAxisTitle(G4int id, const G4String &title)=0
virtual G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none")=0
virtual G4bool SetH1(G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none")=0
virtual G4bool SetH2Title(G4int id, const G4String &title)=0
virtual G4bool SetH1Title(G4int id, const G4String &title)=0
virtual G4bool SetH1YAxisTitle(G4int id, const G4String &title)=0
virtual G4bool SetHistoDirectoryName(const G4String &dirName)
virtual G4bool SetH1XAxisTitle(G4int id, const G4String &title)=0
virtual void SetVerboseLevel(G4int verboseLevel)
virtual G4bool SetFileName(const G4String &fileName)
virtual G4bool SetH2YAxisTitle(G4int id, const G4String &title)=0
virtual G4bool SetNtupleDirectoryName(const G4String &dirName)
virtual G4bool SetH2(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none")=0
virtual G4bool SetH2XAxisTitle(G4int id, const G4String &title)=0
virtual G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none")=0