source: trunk/examples/extended/radioactivedecay/exrdm/src/exrdmHistoMessenger.cc @ 1279

Last change on this file since 1279 was 1230, checked in by garnier, 14 years ago

update to geant4.9.3

File size: 4.6 KB
Line 
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//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
27
28#include "exrdmHistoMessenger.hh"
29
30#include <sstream>
31
32#include "exrdmHisto.hh"
33#include "G4UIdirectory.hh"
34#include "G4UIcommand.hh"
35#include "G4UIparameter.hh"
36#include "G4UIcmdWithAString.hh"
37
38//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39
40exrdmHistoMessenger::exrdmHistoMessenger(exrdmHisto* manager)
41:histo (manager)
42{
43  histoDir = new G4UIdirectory("/histo/");
44  histoDir->SetGuidance("histograms control");
45
46  factoryCmd = new G4UIcmdWithAString("/histo/fileName",this);
47  factoryCmd->SetGuidance("set name for the histograms file");
48  factoryCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
49
50  fileCmd = new G4UIcmdWithAString("/histo/fileType",this);
51  fileCmd->SetGuidance("set type (aida, hbook or root) for the histograms file");
52  fileCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
53
54  histoCmd = new G4UIcommand("/histo/setHisto",this);
55  histoCmd->SetGuidance("Set bining of the histo number ih :");
56  histoCmd->SetGuidance("  nbBins; valMin; valMax; unit (of vmin and vmax)");
57  histoCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
58
59  //
60  G4UIparameter* ih = new G4UIparameter("ih",'i',false);
61  ih->SetGuidance("histo number : from 0 to MaxexrdmHisto");
62  ih->SetParameterRange("ih>=0");
63  histoCmd->SetParameter(ih);
64  //
65  G4UIparameter* nbBins = new G4UIparameter("nbBins",'i',false);
66  nbBins->SetGuidance("number of bins");
67  nbBins->SetParameterRange("nbBins>0");
68  histoCmd->SetParameter(nbBins);
69  //
70  G4UIparameter* valMin = new G4UIparameter("valMin",'d',false);
71  valMin->SetGuidance("valMin, expressed in unit");
72  histoCmd->SetParameter(valMin);
73  //
74  G4UIparameter* valMax = new G4UIparameter("valMax",'d',false);
75  valMax->SetGuidance("valMax, expressed in unit");
76  histoCmd->SetParameter(valMax);
77  //
78  G4UIparameter* unit = new G4UIparameter("unit",'s',true);
79  unit->SetGuidance("if omitted, vmin and vmax are assumed dimensionless");
80  unit->SetDefaultValue("none");
81  histoCmd->SetParameter(unit);
82
83}
84
85//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86
87exrdmHistoMessenger::~exrdmHistoMessenger()
88{
89  delete fileCmd;
90  delete histoCmd;
91  delete factoryCmd;
92  delete histoDir;
93}
94
95//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96
97void exrdmHistoMessenger::SetNewValue(G4UIcommand* command,G4String newValues)
98{
99  if (command == factoryCmd)
100    histo->setFileName(newValues);
101
102  if (command == fileCmd)
103    histo->setFileType(newValues);
104   
105  if (command == histoCmd)
106   { G4int ih,nbBins; G4double vmin,vmax; char unts[30];
107     const char* t = newValues;
108     std::istringstream is(t);
109     is >> ih >> nbBins >> vmin >> vmax >> unts;
110     G4String unit = unts;
111     G4double vUnit = 1. ;
112     if (unit != "none") vUnit = G4UIcommand::ValueOf(unit);
113     histo->setHisto1D(ih,nbBins,vmin,vmax,vUnit);
114   }
115}
116
117//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.