Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:55

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file electromagnetic/TestEm17/src/HistoMessenger.cc
0027 /// \brief Implementation of the HistoMessenger class
0028 //
0029 //
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 #include "HistoMessenger.hh"
0035 
0036 #include "HistoManager.hh"
0037 
0038 #include "G4UIcmdWithAString.hh"
0039 #include "G4UIcmdWithAnInteger.hh"
0040 #include "G4UIcommand.hh"
0041 #include "G4UIdirectory.hh"
0042 #include "G4UIparameter.hh"
0043 
0044 #include <sstream>
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 HistoMessenger::HistoMessenger(HistoManager* manager)
0049   : G4UImessenger(),
0050     fHistoManager(manager),
0051     fHistoDir(0),
0052     fFileNameCmd(0),
0053     fHistoCmd(0),
0054     fPrtHistoCmd(0)
0055 {
0056   fHistoDir = new G4UIdirectory("/testem/histo/");
0057   fHistoDir->SetGuidance("histograms control");
0058 
0059   fFileNameCmd = new G4UIcmdWithAString("/testem/histo/setFileName", this);
0060   fFileNameCmd->SetGuidance("set name for the histograms file");
0061 
0062   fHistoCmd = new G4UIcommand("/testem/histo/setHisto", this);
0063   fHistoCmd->SetGuidance("Set bining of the histo number ih :");
0064   fHistoCmd->SetGuidance("  nbBins; valMin; valMax; unit (of vmin and vmax)");
0065   //
0066   G4UIparameter* ih = new G4UIparameter("ih", 'i', false);
0067   ih->SetGuidance("histo number : from 1 to kMaxHisto");
0068   ih->SetParameterRange("ih>0");
0069   fHistoCmd->SetParameter(ih);
0070   //
0071   G4UIparameter* nbBins = new G4UIparameter("nbBins", 'i', false);
0072   nbBins->SetGuidance("number of bins");
0073   nbBins->SetParameterRange("nbBins>0");
0074   fHistoCmd->SetParameter(nbBins);
0075   //
0076   G4UIparameter* valMin = new G4UIparameter("valMin", 'd', false);
0077   valMin->SetGuidance("valMin, expressed in unit");
0078   fHistoCmd->SetParameter(valMin);
0079   //
0080   G4UIparameter* valMax = new G4UIparameter("valMax", 'd', false);
0081   valMax->SetGuidance("valMax, expressed in unit");
0082   fHistoCmd->SetParameter(valMax);
0083   //
0084   G4UIparameter* unit = new G4UIparameter("unit", 's', true);
0085   unit->SetGuidance("if omitted, vmin and vmax are assumed dimensionless");
0086   unit->SetDefaultValue("none");
0087   fHistoCmd->SetParameter(unit);
0088 
0089   fPrtHistoCmd = new G4UIcmdWithAnInteger("/testem/histo/printHisto", this);
0090   fPrtHistoCmd->SetGuidance("print histo #id on ascii file");
0091   fPrtHistoCmd->SetParameterName("id", false);
0092   fPrtHistoCmd->SetRange("id>0");
0093 }
0094 
0095 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0096 
0097 HistoMessenger::~HistoMessenger()
0098 {
0099   delete fPrtHistoCmd;
0100   delete fHistoCmd;
0101   delete fFileNameCmd;
0102   delete fHistoDir;
0103 }
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0106 
0107 void HistoMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
0108 {
0109   if (command == fFileNameCmd) fHistoManager->SetFileName(newValues);
0110 
0111   if (command == fHistoCmd) {
0112     G4int ih, nbBins;
0113     G4double vmin, vmax;
0114     G4String unit;
0115     const char* t = newValues;
0116     std::istringstream is(t);
0117     is >> ih >> nbBins >> vmin >> vmax >> unit;
0118     fHistoManager->SetHisto(ih, nbBins, vmin, vmax, unit);
0119   }
0120 
0121   if (command == fPrtHistoCmd) fHistoManager->PrintHisto(fPrtHistoCmd->GetNewIntValue(newValues));
0122 }
0123 
0124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......