Import Geant4 10.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 14:11:04 +02:00
parent c9b32a6c0a
commit d4af681f38
4886 changed files with 420149 additions and 1023309 deletions
@@ -41,6 +41,7 @@ class G4AnalysisManagerState
// Only G4VAnalysisManager can change the state
friend class G4VAnalysisManager;
friend class G4VAnalysisReader;
friend class G4ParameterManager;
public:
G4AnalysisManagerState(const G4String& type, G4bool isMaster);
@@ -54,6 +55,7 @@ class G4AnalysisManagerState
const G4AnalysisVerbose* GetVerboseL2() const;
const G4AnalysisVerbose* GetVerboseL3() const;
const G4AnalysisVerbose* GetVerboseL4() const;
G4int GetCompressionLevel() const;
private:
// disabled constructors, operators
@@ -65,12 +67,14 @@ class G4AnalysisManagerState
// (hidden from all clients except for G4VAnalysisManager friend)
void SetIsActivation(G4bool isActivation);
void SetVerboseLevel(G4int verboseLevel);
void SetCompressionLevel(G4int level);
// data members
G4String fType;
G4bool fIsMaster;
G4bool fIsActivation;
G4int fVerboseLevel;
G4int fCompressionLevel;
G4AnalysisVerbose fVerboseL1;
G4AnalysisVerbose fVerboseL2;
G4AnalysisVerbose fVerboseL3;
@@ -86,6 +90,9 @@ class G4AnalysisManagerState
inline void G4AnalysisManagerState::SetIsActivation(G4bool isActivation)
{ fIsActivation = isActivation; }
inline void G4AnalysisManagerState::SetCompressionLevel(G4int level)
{ fCompressionLevel = level; }
inline G4String G4AnalysisManagerState::GetType() const
{ return fType; }
@@ -110,5 +117,8 @@ inline const G4AnalysisVerbose* G4AnalysisManagerState::GetVerboseL3() const
inline const G4AnalysisVerbose* G4AnalysisManagerState::GetVerboseL4() const
{ return fpVerboseL4; }
inline G4int G4AnalysisManagerState::GetCompressionLevel() const
{ return fCompressionLevel; }
#endif
@@ -38,6 +38,8 @@
#include "G4UImessenger.hh"
#include "globals.hh"
#include <memory>
class G4VAnalysisManager;
class G4HnManager;
class G4FileMessenger;
@@ -46,6 +48,7 @@ class G4H2Messenger;
class G4H3Messenger;
class G4P1Messenger;
class G4P2Messenger;
class G4NtupleMessenger;
class G4HnMessenger;
class G4UIdirectory;
@@ -55,36 +58,39 @@ class G4UIcmdWithAnInteger;
class G4AnalysisMessenger : public G4UImessenger
{
public:
G4AnalysisMessenger(G4VAnalysisManager* manager);
explicit G4AnalysisMessenger(G4VAnalysisManager* manager);
virtual ~G4AnalysisMessenger();
// methods
void SetH1HnManager(G4HnManager* h1HnManager);
void SetH2HnManager(G4HnManager* h2HnManager);
void SetH3HnManager(G4HnManager* h2HnManager);
void SetP1HnManager(G4HnManager* h1HnManager);
void SetP2HnManager(G4HnManager* h2HnManager);
void SetH1HnManager(G4HnManager& h1HnManager);
void SetH2HnManager(G4HnManager& h2HnManager);
void SetH3HnManager(G4HnManager& h2HnManager);
void SetP1HnManager(G4HnManager& h1HnManager);
void SetP2HnManager(G4HnManager& h2HnManager);
// methods
virtual void SetNewValue(G4UIcommand* command, G4String value);
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
private:
// data members
G4VAnalysisManager* fManager; ///< Associated class
G4FileMessenger* fFileMessenger;
G4H1Messenger* fH1Messenger;
G4H2Messenger* fH2Messenger;
G4H3Messenger* fH3Messenger;
G4P1Messenger* fP1Messenger;
G4P2Messenger* fP2Messenger;
G4HnMessenger* fH1HnMessenger;
G4HnMessenger* fH2HnMessenger;
G4HnMessenger* fH3HnMessenger;
G4HnMessenger* fP1HnMessenger;
G4HnMessenger* fP2HnMessenger;
G4VAnalysisManager* fManager; ///< Associated class
std::unique_ptr<G4FileMessenger> fFileMessenger;
std::unique_ptr<G4H1Messenger> fH1Messenger;
std::unique_ptr<G4H2Messenger> fH2Messenger;
std::unique_ptr<G4H3Messenger> fH3Messenger;
std::unique_ptr<G4P1Messenger> fP1Messenger;
std::unique_ptr<G4P2Messenger> fP2Messenger;
std::unique_ptr<G4NtupleMessenger> fNtupleMessenger;
std::unique_ptr<G4HnMessenger> fH1HnMessenger;
std::unique_ptr<G4HnMessenger> fH2HnMessenger;
std::unique_ptr<G4HnMessenger> fH3HnMessenger;
std::unique_ptr<G4HnMessenger> fP1HnMessenger;
std::unique_ptr<G4HnMessenger> fP2HnMessenger;
G4UIdirectory* fAnalysisDir;
G4UIcmdWithABool* fSetActivationCmd;
G4UIcmdWithAnInteger* fVerboseCmd;
std::unique_ptr<G4UIdirectory> fAnalysisDir;
std::unique_ptr<G4UIcmdWithABool> fSetActivationCmd;
std::unique_ptr<G4UIcmdWithAnInteger> fVerboseCmd;
std::unique_ptr<G4UIcmdWithAnInteger> fCompressionCmd;
};
#endif
@@ -0,0 +1,116 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AnalysisMessengerHelper.hh 66310 2012-12-17 11:56:35Z ihrivnac $
// The helper class for histogram and profiles messengers.
// It implements reusable commands in /analysis/[hn|pn] directory.
//
// Author: Ivana Hrivnacova, 05/05/2015 (ivana@ipno.in2p3.fr)
#ifndef G4AnalysisMessengerHelper_h
#define G4AnalysisMessengerHelper_h 1
#include "G4UImessenger.hh"
#include "globals.hh"
#include <memory>
class G4VAnalysisManager;
class G4UIdirectory;
class G4UIcommand;
class G4AnalysisMessengerHelper
{
public:
// types
struct BinData {
BinData() :
fNbins(0),
fVmin(0.),
fVmax(0.),
fSunit(""),
fSfcn(""),
fSbinScheme("") {}
G4int fNbins;
G4double fVmin;
G4double fVmax;
G4String fSunit;
G4String fSfcn;
G4String fSbinScheme;
};
// types
struct ValueData {
ValueData() :
fVmin(0.),
fVmax(0.),
fSunit(""),
fSfcn("") {}
G4double fVmin;
G4double fVmax;
G4String fSunit;
G4String fSfcn;
};
public:
// Make available utility Update method
friend class G4HnMessenger;
public:
explicit G4AnalysisMessengerHelper(const G4String& hnType);
~G4AnalysisMessengerHelper();
// methods to create commands
std::unique_ptr<G4UIdirectory> CreateHnDirectory() const;
std::unique_ptr<G4UIcommand> CreateSetTitleCommand(
G4UImessenger* messenger) const;
std::unique_ptr<G4UIcommand> CreateSetBinsCommand(const G4String& axis,
G4UImessenger* messenger) const;
std::unique_ptr<G4UIcommand> CreateSetValuesCommand(const G4String& axis,
G4UImessenger* messenger) const;
std::unique_ptr<G4UIcommand> CreateSetAxisCommand(const G4String& axis,
G4UImessenger* messenger) const;
// methods to read command paremeters
void GetBinData(BinData& data, std::vector<G4String>& parameters,
G4int& counter) const;
void GetValueData(ValueData& data, std::vector<G4String>& parameters,
G4int& counter) const;
// warnings
void WarnAboutParameters(G4UIcommand* command, G4int nofParameters) const;
void WarnAboutSetCommands() const;
private:
// methods
G4String Update(const G4String& str, const G4String& axis = "") const;
// data members
G4String fHnType;
};
#endif
@@ -33,12 +33,33 @@
#include "globals.hh"
#include <vector>
#include <memory>
namespace G4Analysis {
// Enumeration for definition of available output types
enum class G4AnalysisOutput {
kCsv,
kRoot,
kXml,
kNone
};
namespace G4Analysis
{
// Constant expressions
//
// constexpr G4int kX = 0; // not yet supported on vc12
// constexpr G4int kY = 1; // not yet supported on vc12
// constexpr G4int kZ = 2; // not yet supported on vc12
const G4int kX = 0; // not yet supported on vc12
const G4int kY = 1; // not yet supported on vc12
const G4int kZ = 2; // not yet supported on vc12
// Invalid object Id
//
const G4int kInvalidId = -1;
// constexpr G4int kInvalidId = -1; // not yet supported on vc12
const G4int kInvalidId = -1; // not yet supported on vc12
// Utility functions for checking input parameters
G4bool CheckNbins(G4int nbins);
@@ -58,6 +79,27 @@ void UpdateTitle(G4String& title,
// Tokenizer with taking into account composed strings within ""
void Tokenize(const G4String& line, std::vector<G4String>& tokens);
// make-unique utility, not yet availabla in C++11
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
// get output type from name
G4AnalysisOutput GetOutput(const G4String& outputName);
G4String GetOutputName(G4AnalysisOutput outputType);
/*
// make possible to print enumerators in class enum as integer
template <typename Enumeration>
auto as_integer(Enumeration const value)
-> typename std::underlying_type<Enumeration>::type
{
return static_cast<typename std::underlying_type<Enumeration>::type>(value);
}
*/
}
#endif
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AnalysisVerbose.hh 72292 2013-07-15 12:01:43Z ihrivnac $
// $Id: G4AnalysisVerbose.hh 92688 2015-09-14 07:01:13Z gcosmo $
// Utility class for analysis category messages.
@@ -38,7 +38,7 @@ class G4AnalysisVerbose
{
public:
G4AnalysisVerbose(const G4String& type, G4int verboseLevel);
virtual ~G4AnalysisVerbose();
~G4AnalysisVerbose();
void Message(const G4String& action,
const G4String& object,
@@ -42,7 +42,7 @@ class G4AnalysisManagerState;
class G4BaseAnalysisManager
{
public:
G4BaseAnalysisManager(const G4AnalysisManagerState& state);
explicit G4BaseAnalysisManager(const G4AnalysisManagerState& state);
virtual ~G4BaseAnalysisManager();
// methods
@@ -51,19 +51,24 @@ class G4BaseAnalysisManager
// starting from 0; with the following function it is possible to
// change the first Id to start from other value
G4bool SetFirstId(G4int firstId);
void SetLockFirstId(G4bool lockFirstId);
// Access method
G4int GetFirstId() const;
protected:
// data members
const G4AnalysisManagerState& fState;
G4int fFirstId;
G4bool fLockFirstId;
G4bool fLockFirstId;
};
// inline functions
inline void G4BaseAnalysisManager::SetLockFirstId(G4bool lockFirstId) {
fLockFirstId = lockFirstId;
}
inline G4int G4BaseAnalysisManager::GetFirstId() const {
return fFirstId;
}
@@ -38,7 +38,7 @@
class G4BaseFileManager
{
public:
G4BaseFileManager(const G4AnalysisManagerState& state);
explicit G4BaseFileManager(const G4AnalysisManagerState& state);
virtual ~G4BaseFileManager();
virtual G4bool SetFileName(const G4String& fileName);
@@ -67,6 +67,9 @@ class G4BaseFileManager
// - add _tN suffix if called on thread worker
// - add file extension if not present
G4String GetPlotFileName() const;
// Return the file name for batch plotting output
G4String GetFileType() const;
// Return the manager file type (starts with a lowercase letter)
@@ -37,10 +37,10 @@
// Enumeration for definition available binning schemes
enum G4BinScheme {
kLinearBinScheme,
kLogBinScheme,
kUserBinScheme
enum class G4BinScheme {
kLinear,
kLog,
kUser
};
// Utility function
+2 -5
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Fcn.hh 73423 2013-08-27 10:54:55Z gcosmo $
// $Id: G4Fcn.hh 92688 2015-09-14 07:01:13Z gcosmo $
// Author: Ivana Hrivnacova, 04/07/2012 (ivana@ipno.in2p3.fr)
@@ -33,7 +33,7 @@
#include "globals.hh"
// Generic function which can be applied to histogram/ntuple values
typedef G4double (*G4Fcn) (G4double);
using G4Fcn = G4double (*) (G4double);
// Identity function
inline G4double G4FcnIdentity(G4double value) { return value; }
@@ -43,7 +43,4 @@ namespace G4Analysis {
G4Fcn GetFunction(const G4String& fcnName);
}
#endif
@@ -40,23 +40,25 @@
#include "G4UImessenger.hh"
#include "globals.hh"
#include <memory>
class G4VAnalysisManager;
class G4UIcmdWithAString;
class G4FileMessenger : public G4UImessenger
{
public:
G4FileMessenger(G4VAnalysisManager* manager);
explicit G4FileMessenger(G4VAnalysisManager* manager);
virtual ~G4FileMessenger();
// methods
virtual void SetNewValue(G4UIcommand* command, G4String value);
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
G4VAnalysisManager* fManager; ///< Associated class
G4UIcmdWithAString* fSetFileNameCmd;
G4UIcmdWithAString* fSetHistoDirNameCmd;
G4UIcmdWithAString* fSetNtupleDirNameCmd;
std::unique_ptr<G4UIcmdWithAString> fSetFileNameCmd;
std::unique_ptr<G4UIcmdWithAString> fSetHistoDirNameCmd;
std::unique_ptr<G4UIcmdWithAString> fSetNtupleDirNameCmd;
};
#endif
@@ -40,34 +40,36 @@
#include "G4UImessenger.hh"
#include "globals.hh"
#include <memory>
class G4VAnalysisManager;
class G4AnalysisMessengerHelper;
class G4UIdirectory;
class G4UIcommand;
class G4H1Messenger : public G4UImessenger
{
public:
G4H1Messenger(G4VAnalysisManager* manager);
explicit G4H1Messenger(G4VAnalysisManager* manager);
virtual ~G4H1Messenger();
// methods
virtual void SetNewValue(G4UIcommand* command, G4String value);
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
private:
void CreateH1Cmd();
void SetH1Cmd();
void SetH1TitleCmd();
void SetH1XAxisCmd();
void SetH1YAxisCmd();
G4VAnalysisManager* fManager; ///< Associated class
G4UIdirectory* fH1Dir;
G4UIcommand* fCreateH1Cmd;
G4UIcommand* fSetH1Cmd;
G4UIcommand* fSetH1TitleCmd;
G4UIcommand* fSetH1XAxisCmd;
G4UIcommand* fSetH1YAxisCmd;
std::unique_ptr<G4AnalysisMessengerHelper> fHelper;
std::unique_ptr<G4UIdirectory> fDirectory;
std::unique_ptr<G4UIcommand> fCreateH1Cmd;
std::unique_ptr<G4UIcommand> fSetH1Cmd;
std::unique_ptr<G4UIcommand> fSetH1XCmd;
std::unique_ptr<G4UIcommand> fSetH1TitleCmd;
std::unique_ptr<G4UIcommand> fSetH1XAxisCmd;
std::unique_ptr<G4UIcommand> fSetH1YAxisCmd;
};
#endif
@@ -34,8 +34,11 @@
#define G4H2Messenger_h 1
#include "G4UImessenger.hh"
#include "G4AnalysisMessengerHelper.hh"
#include "globals.hh"
#include <memory>
class G4VAnalysisManager;
class G4UIdirectory;
class G4UIcommand;
@@ -43,29 +46,31 @@ class G4UIcommand;
class G4H2Messenger : public G4UImessenger
{
public:
G4H2Messenger(G4VAnalysisManager* manager);
explicit G4H2Messenger(G4VAnalysisManager* manager);
virtual ~G4H2Messenger();
// methods
virtual void SetNewValue(G4UIcommand* command, G4String value);
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
private:
void CreateH2Cmd();
void SetH2Cmd();
void SetH2TitleCmd();
void SetH2XAxisCmd();
void SetH2YAxisCmd();
void SetH2ZAxisCmd();
G4VAnalysisManager* fManager; ///< Associated class
std::unique_ptr<G4AnalysisMessengerHelper> fHelper;
std::unique_ptr<G4UIdirectory> fDirectory;
G4UIdirectory* fH2Dir;
G4UIcommand* fCreateH2Cmd;
G4UIcommand* fSetH2Cmd;
G4UIcommand* fSetH2TitleCmd;
G4UIcommand* fSetH2XAxisCmd;
G4UIcommand* fSetH2YAxisCmd;
G4UIcommand* fSetH2ZAxisCmd;
std::unique_ptr<G4UIcommand> fCreateH2Cmd;
std::unique_ptr<G4UIcommand> fSetH2Cmd;
std::unique_ptr<G4UIcommand> fSetH2XCmd;
std::unique_ptr<G4UIcommand> fSetH2YCmd;
std::unique_ptr<G4UIcommand> fSetH2TitleCmd;
std::unique_ptr<G4UIcommand> fSetH2XAxisCmd;
std::unique_ptr<G4UIcommand> fSetH2YAxisCmd;
std::unique_ptr<G4UIcommand> fSetH2ZAxisCmd;
G4int fXId;
G4AnalysisMessengerHelper::BinData fXData;
};
#endif
@@ -34,8 +34,11 @@
#define G4H3Messenger_h 1
#include "G4UImessenger.hh"
#include "G4AnalysisMessengerHelper.hh"
#include "globals.hh"
#include <memory>
class G4VAnalysisManager;
class G4UIdirectory;
class G4UIcommand;
@@ -43,29 +46,34 @@ class G4UIcommand;
class G4H3Messenger : public G4UImessenger
{
public:
G4H3Messenger(G4VAnalysisManager* manager);
explicit G4H3Messenger(G4VAnalysisManager* manager);
virtual ~G4H3Messenger();
// methods
virtual void SetNewValue(G4UIcommand* command, G4String value);
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
private:
void CreateH3Cmd();
void SetH3Cmd();
void SetH3TitleCmd();
void SetH3XAxisCmd();
void SetH3YAxisCmd();
void SetH3ZAxisCmd();
G4VAnalysisManager* fManager; ///< Associated class
std::unique_ptr<G4AnalysisMessengerHelper> fHelper;
std::unique_ptr<G4UIdirectory> fDirectory;
G4UIdirectory* fH3Dir;
G4UIcommand* fCreateH3Cmd;
G4UIcommand* fSetH3Cmd;
G4UIcommand* fSetH3TitleCmd;
G4UIcommand* fSetH3XAxisCmd;
G4UIcommand* fSetH3YAxisCmd;
G4UIcommand* fSetH3ZAxisCmd;
std::unique_ptr<G4UIcommand> fCreateH3Cmd;
std::unique_ptr<G4UIcommand> fSetH3Cmd;
std::unique_ptr<G4UIcommand> fSetH3XCmd;
std::unique_ptr<G4UIcommand> fSetH3YCmd;
std::unique_ptr<G4UIcommand> fSetH3ZCmd;
std::unique_ptr<G4UIcommand> fSetH3TitleCmd;
std::unique_ptr<G4UIcommand> fSetH3XAxisCmd;
std::unique_ptr<G4UIcommand> fSetH3YAxisCmd;
std::unique_ptr<G4UIcommand> fSetH3ZAxisCmd;
G4int fXId;
G4int fYId;
G4AnalysisMessengerHelper::BinData fXData;
G4AnalysisMessengerHelper::BinData fYData;
};
#endif
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HnInformation.hh 83599 2014-09-03 09:14:50Z gcosmo $
// $Id: G4HnInformation.hh 92688 2015-09-14 07:01:13Z gcosmo $
// Data class for the added Hn/Pn information (not available in g4tools).
//
@@ -35,11 +35,20 @@
#include "globals.hh"
#include "G4Fcn.hh"
#include "G4BinScheme.hh"
#include "G4AnalysisUtilities.hh"
// The additional Hn information per dimension
struct G4HnDimensionInformation
{
G4HnDimensionInformation()
: fUnitName(),
fFcnName(),
fUnit(),
fFcn(nullptr),
fBinScheme(G4BinScheme::kLinear)
{}
G4HnDimensionInformation(
const G4String& unitName,
const G4String& fcnName,
@@ -85,41 +94,42 @@ struct G4HnDimensionInformation
class G4HnInformation
{
public:
enum {
kX = 0,
kY = 1,
kZ = 2
};
public:
G4HnInformation(const G4String& name, G4int nofDimensions)
: fName(name),
fHnDimensionInformations(),
fActivation(true),
fAscii(false) {fHnDimensionInformations.reserve(nofDimensions); }
fAscii(false),
fPlotting(false) { fHnDimensionInformations.reserve(nofDimensions); }
// Deleted default constructor
G4HnInformation() = delete;
// Set methods
void AddHnDimensionInformation(
const G4HnDimensionInformation& hnDimensionInformation);
void AddDimension(
const G4String& unitName, const G4String& fcnName, G4BinScheme binScheme);
void SetDimension(G4int dimension,
const G4String& unitName, const G4String& fcnName, G4BinScheme binScheme);
void SetActivation(G4bool activation);
void SetAscii(G4bool ascii);
void SetAscii(G4bool ascii);
void SetPlotting(G4bool plotting);
// Get methods
G4String GetName() const;
G4HnDimensionInformation* GetHnDimensionInformation(G4int dimension);
G4bool GetActivation() const;
G4bool GetAscii() const;
G4bool GetAscii() const;
G4bool GetPlotting() const;
private:
// Disabled default constructor
G4HnInformation();
// Data members
G4String fName;
std::vector<G4HnDimensionInformation> fHnDimensionInformations;
G4bool fActivation;
G4bool fAscii;
G4bool fPlotting;
};
// inline functions
@@ -128,12 +138,37 @@ inline void G4HnInformation::AddHnDimensionInformation(
const G4HnDimensionInformation& hnDimensionInformation)
{ fHnDimensionInformations.push_back(hnDimensionInformation); }
inline void G4HnInformation::AddDimension(
const G4String& unitName, const G4String& fcnName, G4BinScheme binScheme)
{
auto unit = G4Analysis::GetUnitValue(unitName);
auto fcn = G4Analysis::GetFunction(fcnName);
fHnDimensionInformations.push_back(
G4HnDimensionInformation(unitName, fcnName, unit, fcn, binScheme));
}
inline void G4HnInformation::SetDimension(G4int dimension,
const G4String& unitName, const G4String& fcnName, G4BinScheme binScheme)
{
auto info = GetHnDimensionInformation(dimension);
auto unit = G4Analysis::GetUnitValue(unitName);
auto fcn = G4Analysis::GetFunction(fcnName);
info->fUnitName = unitName;
info->fFcnName = fcnName;
info->fUnit = unit;
info->fFcn = fcn;
info->fBinScheme = binScheme;
}
inline void G4HnInformation::SetActivation(G4bool activation)
{ fActivation = activation; }
inline void G4HnInformation::SetAscii(G4bool ascii)
{ fAscii = ascii; }
inline void G4HnInformation::SetPlotting(G4bool plotting)
{ fPlotting = plotting; }
inline G4String G4HnInformation::GetName() const
{ return fName; }
@@ -146,4 +181,7 @@ inline G4bool G4HnInformation::GetActivation() const
inline G4bool G4HnInformation::GetAscii() const
{ return fAscii; }
inline G4bool G4HnInformation::GetPlotting() const
{ return fPlotting; }
#endif
@@ -48,32 +48,9 @@ class G4HnManager : public G4BaseAnalysisManager
virtual ~G4HnManager();
// Methods to manipulate additional information
void AddH1Information(const G4String& name,
const G4String& unitName,
const G4String& fcnName,
G4double unit,
G4Fcn fx,
G4BinScheme binScheme);
void AddH2Information(const G4String& name,
const G4String& xunitName,
const G4String& yunitName,
const G4String& xfcnName,
const G4String& yfcnName,
G4double xunit, G4double yunit,
G4Fcn fx, G4Fcn fy,
G4BinScheme xBinScheme, G4BinScheme yBinScheme);
void AddH3Information(const G4String& name,
const G4String& xunitName,
const G4String& yunitName,
const G4String& zunitName,
const G4String& xfcnName,
const G4String& yfcnName,
const G4String& zfcnName,
G4double xunit, G4double yunit, G4double zunit,
G4Fcn fx, G4Fcn fy, G4Fcn fz,
G4BinScheme xBinScheme, G4BinScheme yBinScheme,
G4BinScheme zBinScheme);
G4HnInformation* AddHnInformation(const G4String& name, G4int nofDimensions);
// Access methofd
G4HnInformation* GetHnInformation(G4int id,
G4String functionName = "",
@@ -100,12 +77,20 @@ class G4HnManager : public G4BaseAnalysisManager
// return true otherwise
G4bool IsAscii() const;
// Function implementing public analsi manager interface
// Plotting option
// Return false if there is no object selected for plotting,
// return true otherwise
G4bool IsPlotting() const;
// Function implementing public analysis manager interface
//
void SetActivation(G4bool activation);
void SetActivation(G4int id, G4bool activation);
void SetAscii(G4int id, G4bool ascii);
void SetPlotting(G4bool plotting);
void SetPlotting(G4int id, G4bool plotting);
// Access to Hn additional information
G4String GetName(G4int id) const;
@@ -114,12 +99,14 @@ class G4HnManager : public G4BaseAnalysisManager
G4double GetZUnit(G4int id) const;
G4bool GetActivation(G4int id) const;
G4bool GetAscii(G4int id) const;
G4bool GetPlotting(G4int id) const;
private:
// Data members
G4String fHnType;
G4int fNofActiveObjects;
G4int fNofAsciiObjects;
G4int fNofPlottingObjects;
// Additional histograms/ntuple properties not included in tools
std::vector<G4HnInformation*> fHnVector;
@@ -127,7 +114,7 @@ class G4HnManager : public G4BaseAnalysisManager
inline G4int G4HnManager::GetNofHns() const
{ return fHnVector.size(); }
inline G4String G4HnManager::GetHnType() const
{ return fHnType; }
@@ -36,7 +36,10 @@
#include "G4UImessenger.hh"
#include "globals.hh"
#include <memory>
class G4HnManager;
class G4AnalysisMessengerHelper;
class G4UIcommand;
class G4UIcmdWithABool;
class G4UIcmdWithAnInteger;
@@ -44,24 +47,27 @@ class G4UIcmdWithAnInteger;
class G4HnMessenger : public G4UImessenger
{
public:
G4HnMessenger(G4HnManager* manager);
explicit G4HnMessenger(G4HnManager& manager);
virtual ~G4HnMessenger();
// methods
virtual void SetNewValue(G4UIcommand* command, G4String value);
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
private:
G4String GetCmdDirectoryName() const;
G4String GetHnDescription() const;
void SetHnAsciiCmd();
void SetHnActivationCmd();
void SetHnActivationToAllCmd();
void SetHnPlottingCmd();
void SetHnPlottingToAllCmd();
G4HnManager* fManager; ///< Associated class
G4UIcmdWithAnInteger* fSetHnAsciiCmd;
G4UIcommand* fSetHnActivationCmd;
G4UIcmdWithABool* fSetHnActivationAllCmd;
G4HnManager& fManager; ///< Associated class
std::unique_ptr<G4AnalysisMessengerHelper> fHelper;
std::unique_ptr<G4UIcmdWithAnInteger> fSetHnAsciiCmd;
std::unique_ptr<G4UIcommand> fSetHnActivationCmd;
std::unique_ptr<G4UIcmdWithABool> fSetHnActivationAllCmd;
std::unique_ptr<G4UIcommand> fSetHnPlottingCmd;
std::unique_ptr<G4UIcmdWithABool> fSetHnPlottingAllCmd;
};
#endif
@@ -23,24 +23,43 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VH2Manager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
// $Id: G4NtupleMessenger.hh 66310 2012-12-17 11:56:35Z ihrivnac $
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
// The messenger class for histogram information management.
// It implements commands in /analysis/h1 directory.
//
// Author: Ivana Hrivnacova, 05/05/2015 (ivana@ipno.in2p3.fr)
#include "G4VH2Manager.hh"
#include "G4HnManager.hh"
#ifndef G4NtupleMessenger_h
#define G4NtupleMessenger_h 1
//_____________________________________________________________________________
G4VH2Manager::G4VH2Manager(const G4AnalysisManagerState& state)
: G4BaseAnalysisManager(state),
fHnManager(0)
#include "G4UImessenger.hh"
#include "globals.hh"
#include <memory>
class G4VAnalysisManager;
class G4UIcommand;
class G4UIcmdWithABool;
class G4NtupleMessenger : public G4UImessenger
{
fHnManager = new G4HnManager("H2", state);
}
//_____________________________________________________________________________
G4VH2Manager::~G4VH2Manager()
{
delete fHnManager;
}
public:
explicit G4NtupleMessenger(G4VAnalysisManager* manager);
virtual ~G4NtupleMessenger();
// methods
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
private:
void SetActivationCmd();
void SetActivationToAllCmd();
G4VAnalysisManager* fManager; ///< Associated class
std::unique_ptr<G4UIcommand> fSetActivationCmd;
std::unique_ptr<G4UIcmdWithABool> fSetActivationAllCmd;
};
#endif
@@ -34,8 +34,11 @@
#define G4P1Messenger_h 1
#include "G4UImessenger.hh"
#include "G4AnalysisMessengerHelper.hh"
#include "globals.hh"
#include <memory>
class G4VAnalysisManager;
class G4UIdirectory;
class G4UIcommand;
@@ -43,27 +46,30 @@ class G4UIcommand;
class G4P1Messenger : public G4UImessenger
{
public:
G4P1Messenger(G4VAnalysisManager* manager);
explicit G4P1Messenger(G4VAnalysisManager* manager);
virtual ~G4P1Messenger();
// methods
virtual void SetNewValue(G4UIcommand* command, G4String value);
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
private:
void CreateP1Cmd();
void SetP1Cmd();
void SetP1TitleCmd();
void SetP1XAxisCmd();
void SetP1YAxisCmd();
G4VAnalysisManager* fManager; ///< Associated class
std::unique_ptr<G4AnalysisMessengerHelper> fHelper;
std::unique_ptr<G4UIdirectory> fDirectory;
G4UIdirectory* fP1Dir;
G4UIcommand* fCreateP1Cmd;
G4UIcommand* fSetP1Cmd;
G4UIcommand* fSetP1TitleCmd;
G4UIcommand* fSetP1XAxisCmd;
G4UIcommand* fSetP1YAxisCmd;
std::unique_ptr<G4UIcommand> fCreateP1Cmd;
std::unique_ptr<G4UIcommand> fSetP1Cmd;
std::unique_ptr<G4UIcommand> fSetP1XCmd;
std::unique_ptr<G4UIcommand> fSetP1YCmd;
std::unique_ptr<G4UIcommand> fSetP1TitleCmd;
std::unique_ptr<G4UIcommand> fSetP1XAxisCmd;
std::unique_ptr<G4UIcommand> fSetP1YAxisCmd;
G4int fXId;
G4AnalysisMessengerHelper::BinData fXData;
};
#endif
@@ -34,8 +34,11 @@
#define G4P2Messenger_h 1
#include "G4UImessenger.hh"
#include "G4AnalysisMessengerHelper.hh"
#include "globals.hh"
#include <memory>
class G4VAnalysisManager;
class G4UIdirectory;
class G4UIcommand;
@@ -43,29 +46,34 @@ class G4UIcommand;
class G4P2Messenger : public G4UImessenger
{
public:
G4P2Messenger(G4VAnalysisManager* manager);
explicit G4P2Messenger(G4VAnalysisManager* manager);
virtual ~G4P2Messenger();
// methods
virtual void SetNewValue(G4UIcommand* command, G4String value);
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
private:
void CreateP2Cmd();
void SetP2Cmd();
void SetP2TitleCmd();
void SetP2XAxisCmd();
void SetP2YAxisCmd();
void SetP2ZAxisCmd();
G4VAnalysisManager* fManager; ///< Associated class
std::unique_ptr<G4AnalysisMessengerHelper> fHelper;
std::unique_ptr<G4UIdirectory> fDirectory;
G4UIdirectory* fP2Dir;
G4UIcommand* fCreateP2Cmd;
G4UIcommand* fSetP2Cmd;
G4UIcommand* fSetP2TitleCmd;
G4UIcommand* fSetP2XAxisCmd;
G4UIcommand* fSetP2YAxisCmd;
G4UIcommand* fSetP2ZAxisCmd;
std::unique_ptr<G4UIcommand> fCreateP2Cmd;
std::unique_ptr<G4UIcommand> fSetP2Cmd;
std::unique_ptr<G4UIcommand> fSetP2XCmd;
std::unique_ptr<G4UIcommand> fSetP2YCmd;
std::unique_ptr<G4UIcommand> fSetP2ZCmd;
std::unique_ptr<G4UIcommand> fSetP2TitleCmd;
std::unique_ptr<G4UIcommand> fSetP2XAxisCmd;
std::unique_ptr<G4UIcommand> fSetP2YAxisCmd;
std::unique_ptr<G4UIcommand> fSetP2ZAxisCmd;
G4int fXId;
G4int fYId;
G4AnalysisMessengerHelper::BinData fXData;
G4AnalysisMessengerHelper::BinData fYData;
};
#endif
@@ -0,0 +1,148 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// The manager class for batch plotting.
// Author: Ivana Hrivnacova, 02/06/2015 (ivana@ipno.in2p3.fr)
#ifndef G4PlotManager_h
#define G4PlotManager_h 1
#include "G4AnalysisManagerState.hh"
#include "G4PlotParameters.hh"
#include <tools/viewplot>
#include <vector>
#include <memory>
class G4HnInformation;
class G4PlotManager
{
public:
explicit G4PlotManager(const G4AnalysisManagerState& state);
~G4PlotManager();
// deleted functions
G4PlotManager(const G4PlotManager& rhs) = delete;
G4PlotManager& operator=(const G4PlotManager& rhs) = delete;
public:
// methods
G4bool OpenFile(const G4String& fileName);
template <typename T>
G4bool PlotAndWrite(const std::vector<T*>& htVector,
const std::vector<G4HnInformation*>& hnVector);
G4bool CloseFile();
private:
// methods
G4int GetNofPlotsPerPage() const;
G4bool WritePage();
// static data members
static G4PlotParameters fgPlotParameters;
// data members
const G4AnalysisManagerState& fState;
std::unique_ptr<tools::viewplot> fViewer;
G4String fFileName;
};
// inline functions
//_____________________________________________________________________________
inline G4int G4PlotManager::GetNofPlotsPerPage() const
{ return fgPlotParameters.GetColumns()*fgPlotParameters.GetRows(); }
//_____________________________________________________________________________
template <typename T>
inline G4bool G4PlotManager::PlotAndWrite(const std::vector<T*>& htVector,
const std::vector<G4HnInformation*>& hnVector)
{
if ( ! htVector.size() ) return true;
fViewer->plots().init_sg();
//it will recreate the sg::plotters and then reset the styles on new ones.
fViewer->set_cols_rows(fgPlotParameters.GetColumns(), fgPlotParameters.GetRows());
fViewer->plots().set_current_plotter(0);
G4bool finalResult = true;
G4bool isWriteNeeded = false;
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
G4HnInformation* info = hnVector[i];
G4bool plotting = info->GetPlotting();
G4bool activation = info->GetActivation();
G4String name = info->GetName();
// skip plotting if not selected for plotting or
// if activation is enabled and HT is inactivated
if ( ( ! plotting ) ||
( fState.GetIsActivation() && ( ! activation ) ) ) continue;
T* ht = htVector[i];
// plot this object
fViewer->plot(*ht);
fViewer->set_current_plotter_style(fgPlotParameters.GetStyle());
// set color (only blue for the time being)
tools::sg::plotter& plotter = fViewer->plots().current_plotter();
// set plot properties (use info object to get these)
plotter.bins_style(0).color = tools::colorf::blue();
isWriteNeeded = true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() )
fState.GetVerboseL3()->Message("plotting", "hd|pd", name);
#endif
// write a page if number of plots per page is achieved
if ( G4int(fViewer->plots().current_index()) == (GetNofPlotsPerPage() - 1) ) {
G4bool result = WritePage();
finalResult = result && finalResult;
isWriteNeeded = false;
}
// Prepare for the next plot
fViewer->plots().next();
}
// write a page if loop is finished and there are plots to be written
if ( isWriteNeeded ) {
G4bool result = WritePage();
finalResult = result && finalResult;
}
// add test of result
return finalResult;
}
#endif
@@ -25,22 +25,47 @@
//
// $Id$
// Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
// The messenger class for batch plotting.
// It implements commands in /analysis/plot directory.
//
// Author: Ivana Hrivnacova, 21/10/2015 (ivana@ipno.in2p3.fr)
#include "G4VH3Manager.hh"
#include "G4HnManager.hh"
#ifndef G4PlotMessenger_h
#define G4PlotMessenger_h 1
//_____________________________________________________________________________
G4VH3Manager::G4VH3Manager(const G4AnalysisManagerState& state)
: G4BaseAnalysisManager(state),
fHnManager(0)
#include "G4UImessenger.hh"
#include "globals.hh"
#include <memory>
class G4PlotParameters;
class G4AnalysisMessengerHelper;
class G4UIdirectory;
class G4UIcommand;
class G4UIcmdWithAString;
class G4PlotMessenger : public G4UImessenger
{
fHnManager = new G4HnManager("H3", state);
}
public:
explicit G4PlotMessenger(G4PlotParameters* plotParameters);
virtual ~G4PlotMessenger();
// methods
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
private:
void SetStyleCmd();
void SetLayoutCmd();
void SetDimensionsCmd();
G4PlotParameters* fPlotParameters; ///< Associated class
std::unique_ptr<G4AnalysisMessengerHelper> fHelper;
std::unique_ptr<G4UIdirectory> fDirectory;
//_____________________________________________________________________________
G4VH3Manager::~G4VH3Manager()
{
delete fHnManager;
}
std::unique_ptr<G4UIcommand> fSetLayoutCmd;
std::unique_ptr<G4UIcommand> fSetDimensionsCmd;
std::unique_ptr<G4UIcmdWithAString> fSetStyleCmd;
};
#endif
@@ -0,0 +1,116 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// The data class which defined the configuration parameters for plotting
// which can be modified via UI commands.
//
// Author: Ivana Hrivnacova, 21/10/2015 (ivana@ipno.in2p3.fr)
#ifndef G4PlotParameters_h
#define G4PlotParameters_h 1
#include "globals.hh"
#include "G4PlotMessenger.hh"
#include <memory>
class G4PlotParameters
{
public:
G4PlotParameters();
// setters
void SetLayout(G4int columns, G4int rows);
void SetDimensions(G4int width, G4int height);
void SetStyle(const G4String& style);
// getters
// limits
G4int GetMaxColumns();
G4int GetMaxRows();
G4String GetAvailableStyles();
// data
G4int GetColumns() const;
G4int GetRows() const;
G4int GetWidth() const;
G4int GetHeight() const;
G4float GetScale() const;
G4String GetStyle() const;
private:
// data members
std::unique_ptr<G4PlotMessenger> fMessenger;
// defaults
G4int fDefaultColumns;
G4int fDefaultRows;
G4int fDefaultWidth;
G4int fDefaultHeight;
G4String fDefaultStyle;
G4float fDefaultScale;
// limits
G4int fMaxColumns;
G4int fMaxRows;
G4String fAvailableStyles;
// data
G4int fColumns;
G4int fRows;
G4int fWidth;
G4int fHeight;
G4float fScale;
G4String fStyle;
};
// inline functions
inline G4int G4PlotParameters::GetMaxColumns()
{ return fMaxColumns; }
inline G4int G4PlotParameters::GetMaxRows()
{ return fMaxRows; }
inline G4String G4PlotParameters::GetAvailableStyles()
{ return fAvailableStyles; }
inline G4int G4PlotParameters::GetColumns() const
{ return fColumns; }
inline G4int G4PlotParameters::GetRows() const
{ return fRows; }
inline G4int G4PlotParameters::GetWidth() const
{ return fWidth; }
inline G4int G4PlotParameters::GetHeight() const
{ return fHeight; }
inline G4float G4PlotParameters::GetScale() const
{ return fScale; }
inline G4String G4PlotParameters::GetStyle() const
{ return fStyle; }
#endif
@@ -23,23 +23,69 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: G4THnManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
// Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
// Template base class the histograms/profiles objects managers.
#include "G4VP1Manager.hh"
#include "G4HnManager.hh"
// Author: Ivana Hrivnacova, 23/06/2015 (ivana@ipno.in2p3.fr)
//_____________________________________________________________________________
G4VP1Manager::G4VP1Manager(const G4AnalysisManagerState& state)
: G4BaseAnalysisManager(state),
fHnManager(0)
#ifndef G4THnManager_h
#define G4THnManager_h 1
#include "G4Fcn.hh"
#include "G4BinScheme.hh"
#include "globals.hh"
#include <vector>
#include <map>
#include <memory>
class G4AnalysisManagerState;
class G4HnManager;
template <typename T>
class G4THnManager
{
fHnManager = new G4HnManager("P1", state);
}
public:
G4THnManager(const G4AnalysisManagerState& state,
const G4String& hnType);
virtual ~G4THnManager();
// Reset data
G4bool Reset();
// Return true if the H1 vector is empty
G4bool IsEmpty() const;
protected:
// Method for merge (MT)
void AddTVector(const std::vector<T*>& tVector);
// Iterators
typename std::vector<T*>::iterator BeginT();
typename std::vector<T*>::iterator EndT();
typename std::vector<T*>::const_iterator BeginConstT() const;
typename std::vector<T*>::const_iterator EndConstT() const;
T* GetTInFunction(G4int id,
G4String functionName,
G4bool warn = true,
G4bool onlyIfActive = true) const;
G4int RegisterT(T* t, const G4String& name);
G4int GetTId(const G4String& name, G4bool warn = true) const;
// data members
const G4AnalysisManagerState& fState;
std::vector<T*> fTVector;
std::map<G4String, G4int> fNameIdMap;
std::shared_ptr<G4HnManager> fHnManager;
};
// inline functions
#include "G4THnManager.icc"
#endif
//_____________________________________________________________________________
G4VP1Manager::~G4VP1Manager()
{
delete fHnManager;
}
@@ -0,0 +1,192 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4THnManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
// Author: Ivana Hrivnacova, 23/06/2015 (ivana@ipno.in2p3.fr)
#include "G4AnalysisManagerState.hh"
#include "G4HnManager.hh"
#include "G4AnalysisUtilities.hh"
#include <iostream>
//_____________________________________________________________________________
template <typename T>
G4THnManager<T>::G4THnManager(const G4AnalysisManagerState& state,
const G4String& hnType)
: fState(state),
fTVector(),
fNameIdMap(),
fHnManager(nullptr)
{
fHnManager = std::make_shared<G4HnManager>(hnType, state);
}
//_____________________________________________________________________________
template <typename T>
G4THnManager<T>::~G4THnManager()
{
for ( auto t : fTVector ) {
delete t;
}
}
//
// protected methods
//
//_____________________________________________________________________________
template <typename T>
T* G4THnManager<T>::GetTInFunction(G4int id,
G4String functionName, G4bool warn,
G4bool onlyIfActive) const
{
G4int index = id - fHnManager->GetFirstId();
if ( index < 0 || index >= G4int(fTVector.size()) ) {
if ( warn) {
G4String inFunction = "G4THnManager::";
inFunction += functionName;
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception(inFunction, "Analysis_W011", JustWarning, description);
}
return 0;
}
// Do not return histogram if inactive
if ( fState.GetIsActivation() && onlyIfActive && ( ! fHnManager->GetActivation(id) ) ) {
return 0;
}
return fTVector[index];
}
//_____________________________________________________________________________
template <typename T>
G4int G4THnManager<T>::RegisterT(T* t, const G4String& name)
{
G4int index = fTVector.size();
fTVector.push_back(t);
fHnManager->SetLockFirstId(true);
fNameIdMap[name] = index + fHnManager->GetFirstId();
return index + fHnManager->GetFirstId();
}
//_____________________________________________________________________________
template <typename T>
G4int G4THnManager<T>::GetTId(const G4String& name, G4bool warn) const
{
auto it = fNameIdMap.find(name);
if ( it == fNameIdMap.end() ) {
if ( warn) {
G4String inFunction = "G4THnManager::GetH1Id";
G4ExceptionDescription description;
description << " " << "histogram " << name << " does not exist.";
G4Exception(inFunction, "Analysis_W011", JustWarning, description);
}
return G4Analysis::kInvalidId;
}
return it->second;
}
//_____________________________________________________________________________
template <typename T>
void G4THnManager<T>::AddTVector(const std::vector<T*>& tVector)
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("merge", "all " + fHnManager->GetHnType(), "");
#endif
// std::vector<tools::histo::h1d*>::const_iterator itw = h1Vector.begin();
// std::vector<tools::histo::h1d*>::iterator it;
// for (it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
// (*it)->add(*(*itw++));
// }
auto itw = tVector.begin();
for ( auto t : fTVector ) {
t->add(*(*itw++));
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()->Message("merge", "all " + fHnManager->GetHnType(), "");
#endif
}
//_____________________________________________________________________________
template <typename T>
typename std::vector<T*>::iterator G4THnManager<T>::BeginT()
{
return fTVector.begin();
}
//_____________________________________________________________________________
template <typename T>
typename std::vector<T*>::iterator G4THnManager<T>::EndT()
{
return fTVector.end();
}
//_____________________________________________________________________________
template <typename T>
typename std::vector<T*>::const_iterator G4THnManager<T>::BeginConstT() const
{
return fTVector.begin();
}
//_____________________________________________________________________________
template <typename T>
typename std::vector<T*>::const_iterator G4THnManager<T>::EndConstT() const
{
return fTVector.end();
}
//
// public methods
//
//_____________________________________________________________________________
template <typename T>
G4bool G4THnManager<T>::Reset()
{
// Reset histograms and ntuple
G4bool finalResult = true;
for ( auto t : fTVector ) {
G4bool result = t->reset();
if ( ! result ) finalResult = false;
}
return finalResult;
}
//_____________________________________________________________________________
template <typename T>
G4bool G4THnManager<T>::IsEmpty() const
{
return ! fTVector.size();
}
@@ -25,22 +25,40 @@
//
// $Id$
// Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
// Structure templated containing the information related to an ntuple
// for all output types.
//
// Author: Ivana Hrivnacova, 19/06/2015 (ivana@ipno.in2p3.fr)
#include "G4VP2Manager.hh"
#include "G4HnManager.hh"
#ifndef G4TNtupleDescription_h
#define G4TNtupleDescription_h 1
//_____________________________________________________________________________
G4VP2Manager::G4VP2Manager(const G4AnalysisManagerState& state)
: G4BaseAnalysisManager(state),
fHnManager(0)
#include "globals.hh"
#include "tools/ntuple_booking"
#include <fstream>
template <typename TNTUPLE>
struct G4TNtupleDescription
{
fHnManager = new G4HnManager("P2", state);
}
G4TNtupleDescription()
: fFile(nullptr),
fNtuple(nullptr),
fNtupleBooking(),
fActivation(true),
fIsNtupleOwner(true) {}
//_____________________________________________________________________________
G4VP2Manager::~G4VP2Manager()
{
delete fHnManager;
}
~G4TNtupleDescription()
{ delete fFile;
if ( fIsNtupleOwner ) delete fNtuple;
}
std::ofstream* fFile;
TNTUPLE* fNtuple;
tools::ntuple_booking fNtupleBooking;
G4bool fActivation;
G4bool fIsNtupleOwner;
};
#endif
@@ -0,0 +1,162 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4CsvNtupleManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
// Class template for ntuple managers for all output types.
//
// Author: Ivana Hrivnacova, 19/06/2015 (ivana@ipno.in2p3.fr)
#ifndef G4TNtupleManager_h
#define G4TNtupleManager_h 1
#include "G4VNtupleManager.hh"
#include "G4TNtupleDescription.hh"
#include "globals.hh"
#include <vector>
template <typename TNTUPLE>
class G4TNtupleManager : public G4VNtupleManager {
public:
explicit G4TNtupleManager(const G4AnalysisManagerState& state);
~G4TNtupleManager();
protected:
// Methods to manipulate ntuples
void CreateNtuplesFromBooking();
G4bool IsEmpty() const;
G4bool Reset(G4bool deleteNtuple);
// Methods to create ntuples
//
virtual G4int CreateNtuple(const G4String& name, const G4String& title) final;
// Create columns in the last created ntuple
virtual G4int CreateNtupleIColumn(
const G4String& name, std::vector<int>* vector) final;
virtual G4int CreateNtupleFColumn(
const G4String& name, std::vector<float>* vector) final;
virtual G4int CreateNtupleDColumn(
const G4String& name, std::vector<double>* vector) final;
virtual G4int CreateNtupleSColumn(const G4String& name) final;
virtual void FinishNtuple() final;
// Create columns in the ntuple with given id
virtual G4int CreateNtupleIColumn(G4int ntupleId,
const G4String& name, std::vector<int>* vector) final;
virtual G4int CreateNtupleFColumn(G4int ntupleId,
const G4String& name, std::vector<float>* vector) final;
virtual G4int CreateNtupleDColumn(G4int ntupleId,
const G4String& name, std::vector<double>* vector) final;
virtual G4int CreateNtupleSColumn(G4int ntupleId, const G4String& name) final;
virtual void FinishNtuple(G4int ntupleId) final;
// Methods to fill ntuples
// Methods for ntuple with id = FirstNtupleId
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value) final;
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value) final;
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value) final;
virtual G4bool FillNtupleSColumn(G4int columnId, const G4String& value) final;
virtual G4bool AddNtupleRow() final;
// Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value) final;
virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value) final;
virtual G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value) final;
virtual G4bool FillNtupleSColumn(G4int ntupleId, G4int columnId,
const G4String& value) final;
virtual G4bool AddNtupleRow(G4int ntupleId) final;
// Activation option
//
virtual void SetActivation(G4bool activation) final;
virtual void SetActivation(G4int ntupleId, G4bool activation) final;
virtual G4bool GetActivation(G4int ntupleId) const final;
// Access methods
TNTUPLE* GetNtuple() const;
TNTUPLE* GetNtuple(G4int ntupleId) const;
virtual G4int GetNofNtuples() const final;
// Iterators
typename std::vector<TNTUPLE*>::iterator BeginNtuple();
typename std::vector<TNTUPLE*>::iterator EndNtuple();
typename std::vector<TNTUPLE*>::const_iterator BeginConstNtuple() const;
typename std::vector<TNTUPLE*>::const_iterator EndConstNtuple() const;
// Data members
std::vector<G4TNtupleDescription<TNTUPLE>*> fNtupleDescriptionVector;
std::vector<TNTUPLE*> fNtupleVector;
private:
// methods
// Fuctions which are specific to output type
//
virtual void CreateTNtuple(
G4TNtupleDescription<TNTUPLE>* ntupleDescription,
const G4String& name, const G4String& title) = 0;
virtual void CreateTNtupleFromBooking(
G4TNtupleDescription<TNTUPLE>* ntupleDescription) = 0;
virtual void FinishTNtuple(
G4TNtupleDescription<TNTUPLE>* ntupleDescription) = 0;
// Common implementation
//
G4TNtupleDescription<TNTUPLE>* GetNtupleDescriptionInFunction(G4int id,
G4String function,
G4bool warn = true) const;
TNTUPLE* GetNtupleInFunction(G4int id,
G4String function,
G4bool warn = true) const;
// template functions for creating/filling ntuple columns
template <typename T>
void CreateTColumnInNtuple(
G4TNtupleDescription<TNTUPLE>* ntupleDescription,
const G4String& name, std::vector<T>* vector);
template <typename T>
G4int CreateNtupleTColumn(G4int ntupleId,
const G4String& name, std::vector<T>* vector);
template <typename T>
G4int CreateNtupleTColumn(
const G4String& name, std::vector<T>* vector);
template <typename T>
G4bool FillNtupleTColumn(G4int ntupleId, G4int columnId, const T& value);
template <typename T>
G4bool FillNtupleTColumn(G4int columnId, const T& value);
};
#include "G4TNtupleManager.icc"
#endif
@@ -0,0 +1,628 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
#include "G4AnalysisManagerState.hh"
#include "G4AnalysisUtilities.hh"
//
// private template functions
//
//_____________________________________________________________________________
template <typename TNTUPLE>
G4TNtupleManager<TNTUPLE>::G4TNtupleManager(
const G4AnalysisManagerState& state)
: G4VNtupleManager(state),
fNtupleDescriptionVector(),
fNtupleVector()
{}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4TNtupleManager<TNTUPLE>::~G4TNtupleManager()
{
for ( auto ntupleDescription : fNtupleDescriptionVector ) {
delete ntupleDescription;
}
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4TNtupleDescription<TNTUPLE>*
G4TNtupleManager<TNTUPLE>::GetNtupleDescriptionInFunction(
G4int id, G4String functionName, G4bool warn) const
{
auto index = id - fFirstId;
if ( index < 0 || index >= G4int(fNtupleDescriptionVector.size()) ) {
if ( warn) {
G4String inFunction = "G4TNtupleManager::";
inFunction += functionName;
G4ExceptionDescription description;
description << " " << "ntuple " << id << " does not exist.";
G4Exception(inFunction, "Analysis_W011", JustWarning, description);
}
return nullptr;
}
return fNtupleDescriptionVector[index];
}
//_____________________________________________________________________________
template <typename TNTUPLE>
TNTUPLE*
G4TNtupleManager<TNTUPLE>::GetNtupleInFunction(
G4int id, G4String functionName, G4bool warn) const
{
auto ntupleDescription = GetNtupleDescriptionInFunction(id, functionName);
if ( ! ntupleDescription ) return nullptr;
if ( ! ntupleDescription->fNtuple ) {
if ( warn ) {
G4String inFunction = "G4TNtupleManager::";
inFunction += functionName;
G4ExceptionDescription description;
description << " " << "ntupleId " << id << " does not exist.";
G4Exception(inFunction, "Analysis_W011", JustWarning, description);
}
return nullptr;
}
return ntupleDescription->fNtuple;
}
//_____________________________________________________________________________
template <typename TNTUPLE>
template <typename T>
void G4TNtupleManager<TNTUPLE>::CreateTColumnInNtuple(
G4TNtupleDescription<TNTUPLE>* ntupleDescription,
const G4String& name, std::vector<T>* vector)
{
if ( ntupleDescription->fNtuple ) {
if ( vector == nullptr ) {
ntupleDescription->fNtuple->template create_column<T>(name);
}
else {
ntupleDescription->fNtuple->template create_column<T>(name, *vector);
}
}
}
//_____________________________________________________________________________
template <typename TNTUPLE>
template <typename T>
G4int G4TNtupleManager<TNTUPLE>::CreateNtupleTColumn(
G4int ntupleId, const G4String& name, std::vector<T>* vector)
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << name << " ntupleId " << ntupleId;
fState.GetVerboseL4()->Message("create", "ntuple T column", description);
}
#endif
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "CreateNtupleIColumn");
if ( ! ntupleDescription ) return G4Analysis::kInvalidId;
// Save column info in booking
auto& ntupleBooking = ntupleDescription->fNtupleBooking;
auto index = ntupleBooking.columns().size();
if ( ! vector )
ntupleBooking.template add_column<T>(name);
else
ntupleBooking.template add_column<T>(name, *vector);
// Create column if ntuple already exists
CreateTColumnInNtuple<T>(ntupleDescription, name, vector);
fLockFirstNtupleColumnId = true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4ExceptionDescription description;
description << name << " ntupleId " << ntupleId;
fState.GetVerboseL2()->Message("create", "ntuple T column", description);
}
#endif
return index + fFirstNtupleColumnId;
}
//_____________________________________________________________________________
template <typename TNTUPLE>
template <typename T>
G4int G4TNtupleManager<TNTUPLE>::CreateNtupleTColumn(
const G4String& name, std::vector<T>* vector)
{
auto ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
return CreateNtupleTColumn<T>(ntupleId, name, vector);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
template <typename T>
G4bool G4TNtupleManager<TNTUPLE>::FillNtupleTColumn(
G4int ntupleId, G4int columnId, const T& value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
// get ntuple
auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
if ( ! ntuple ) return false;
// get generic column
auto index = columnId - fFirstNtupleColumnId;
if ( index < 0 || index >= G4int(ntuple->columns().size()) ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< " columnId " << columnId << " does not exist.";
G4Exception("G4TNtupleManager::FillNtupleTColumn()",
"Analysis_W011", JustWarning, description);
return false;
}
auto icolumn = ntuple->columns()[index];
// get column and check its type
auto column = dynamic_cast<typename TNTUPLE::template column<T>* >(icolumn);
if ( ! column ) {
G4ExceptionDescription description;
description << " Column type does not match: "
<< " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
G4Exception("G4TNtupleManager:FillNtupleTColumn",
"Analysis_W011", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
fState.GetVerboseL4()->Message("fill", "ntuple T column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
template <typename TNTUPLE>
template <typename T>
G4bool G4TNtupleManager<TNTUPLE>::FillNtupleTColumn(
G4int columnId, const T& value)
{
return FillNtupleTColumn<T>(fFirstId, columnId, value);
}
//
// protected functions
//
//_____________________________________________________________________________
template <typename TNTUPLE>
void G4TNtupleManager<TNTUPLE>::CreateNtuplesFromBooking()
{
// Create ntuple from ntuple_booking.
for ( auto ntupleDescription : fNtupleDescriptionVector ) {
// Do not create ntuple if it is inactivated
if ( fState.GetIsActivation() && ( ! ntupleDescription->fActivation ) ) continue;
// Do not create ntuple if it already exists
if ( ntupleDescription->fNtuple ) continue;
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()
->Message("create from booking", "ntuple",
ntupleDescription->fNtupleBooking.name());
#endif
// create ntuple
CreateTNtupleFromBooking(ntupleDescription);
// finish created ntuple
FinishTNtuple(ntupleDescription);
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() )
fState.GetVerboseL3()
->Message("create from booking", "ntuple",
ntupleDescription->fNtupleBooking.name());
#endif
}
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool
G4TNtupleManager<TNTUPLE>::IsEmpty() const
{
return ! fNtupleDescriptionVector.size();
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool
G4TNtupleManager<TNTUPLE>::Reset(G4bool deleteNtuple)
{
for ( auto ntupleDescription : fNtupleDescriptionVector ) {
if ( deleteNtuple ) {
delete ntupleDescription->fNtuple;
}
ntupleDescription->fNtuple = 0;
}
fNtupleVector.clear();
return true;
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4int G4TNtupleManager<TNTUPLE>::CreateNtuple(
const G4String& name, const G4String& title)
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("create", "ntuple", name);
#endif
// Create ntuple description
auto index = fNtupleDescriptionVector.size();
auto ntupleDescription = new G4TNtupleDescription<TNTUPLE>();
fNtupleDescriptionVector.push_back(ntupleDescription);
// Save name & title in ntuple booking
ntupleDescription->fNtupleBooking.set_name(name);
ntupleDescription->fNtupleBooking.set_title(title);
// Create ntuple
CreateTNtuple(ntupleDescription, name, title);
fLockFirstId = true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4ExceptionDescription description;
description << name << " ntupleId " << index + fFirstId;
fState.GetVerboseL2()->Message("create", "ntuple", description);
}
#endif
return index + fFirstId;
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4int G4TNtupleManager<TNTUPLE>::CreateNtupleIColumn(
const G4String& name, std::vector<int>* vector)
{
return CreateNtupleTColumn<int>(name, vector);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4int G4TNtupleManager<TNTUPLE>::CreateNtupleFColumn(
const G4String& name, std::vector<float>* vector)
{
return CreateNtupleTColumn<float>(name, vector);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4int G4TNtupleManager<TNTUPLE>::CreateNtupleDColumn(
const G4String& name, std::vector<double>* vector)
{
return CreateNtupleTColumn<double>(name, vector);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4int G4TNtupleManager<TNTUPLE>::CreateNtupleSColumn(
const G4String& name)
{
return CreateNtupleTColumn<std::string>(name, nullptr);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
void G4TNtupleManager<TNTUPLE>::FinishNtuple()
{
auto ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
FinishNtuple(ntupleId);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4int G4TNtupleManager<TNTUPLE>::CreateNtupleIColumn(
G4int ntupleId, const G4String& name, std::vector<int>* vector)
{
return CreateNtupleTColumn<int>(ntupleId, name, vector);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4int G4TNtupleManager<TNTUPLE>::CreateNtupleFColumn(
G4int ntupleId, const G4String& name, std::vector<float>* vector)
{
return CreateNtupleTColumn<float>(ntupleId, name, vector);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4int G4TNtupleManager<TNTUPLE>::CreateNtupleDColumn(
G4int ntupleId, const G4String& name, std::vector<double>* vector)
{
return CreateNtupleTColumn<double>(ntupleId, name, vector);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4int G4TNtupleManager<TNTUPLE>::CreateNtupleSColumn(
G4int ntupleId, const G4String& name)
{
return CreateNtupleTColumn<std::string>(ntupleId, name, nullptr);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
void G4TNtupleManager<TNTUPLE>::FinishNtuple(
G4int ntupleId)
{
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "FinishNtuple");
if ( ! ntupleDescription ) return;
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << ntupleDescription->fNtupleBooking.name() << " ntupleId " << ntupleId;
fState.GetVerboseL4()->Message("finish", "ntuple", description);
}
#endif
// check that ntuple was really created
auto ntuple = GetNtupleInFunction(ntupleId, "FinishNtuple", false);
if ( ! ntuple ) return;
FinishTNtuple(ntupleDescription);
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4ExceptionDescription description;
description << ntupleDescription->fNtupleBooking.name() << " ntupleId " << ntupleId;
fState.GetVerboseL2()->Message("finish", "ntuple", description);
}
#endif
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::FillNtupleIColumn(
G4int columnId, G4int value)
{
return FillNtupleTColumn<int>(columnId, value);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::FillNtupleFColumn(
G4int columnId, G4float value)
{
return FillNtupleTColumn<float>(columnId, value);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::FillNtupleDColumn(
G4int columnId, G4double value)
{
return FillNtupleTColumn<double>(columnId, value);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::FillNtupleSColumn(
G4int columnId, const G4String& value)
{
return FillNtupleTColumn<std::string>(columnId, value);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::AddNtupleRow()
{
return AddNtupleRow(fFirstId);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::FillNtupleIColumn(
G4int ntupleId, G4int columnId, G4int value)
{
return FillNtupleTColumn<int>(ntupleId, columnId, value);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::FillNtupleFColumn(
G4int ntupleId, G4int columnId, G4float value)
{
return FillNtupleTColumn<float>(ntupleId, columnId, value);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::FillNtupleDColumn(
G4int ntupleId, G4int columnId, G4double value)
{
return FillNtupleTColumn<double>(ntupleId, columnId, value);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::FillNtupleSColumn(
G4int ntupleId, G4int columnId, const G4String& value)
{
return FillNtupleTColumn<std::string>(ntupleId, columnId, value);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::AddNtupleRow(
G4int ntupleId)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping AddNtupleRow for " << ntupleId << G4endl;
return false;
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId;
fState.GetVerboseL4()->Message("add", "ntuple row", description);
}
#endif
auto ntuple = GetNtupleInFunction(ntupleId, "AddNtupleRow");
if ( ! ntuple ) return false;
auto result = ntuple->add_row();
if ( ! result ) {
G4ExceptionDescription description;
description << " " << " ntupleId " << ntupleId
<< "adding row has failed.";
G4Exception("G4TNtupleManager::AddTNtupleRow()",
"Analysis_W002", JustWarning, description);
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId;
fState.GetVerboseL4()->Message("add", "ntuple row", description);
}
#endif
return true;
}
//_____________________________________________________________________________
template <typename TNTUPLE>
void G4TNtupleManager<TNTUPLE>::SetActivation(
G4bool activation)
{
for ( auto ntupleDescription : fNtupleDescriptionVector ) {
ntupleDescription->fActivation = activation;
}
}
//_____________________________________________________________________________
template <typename TNTUPLE>
void G4TNtupleManager<TNTUPLE>::SetActivation(
G4int ntupleId, G4bool activation)
{
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "SetActivation");
if ( ! ntupleDescription ) return;
ntupleDescription->fActivation = activation;
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4bool G4TNtupleManager<TNTUPLE>::GetActivation(
G4int ntupleId) const
{
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "GetActivation");
if ( ! ntupleDescription ) return false;
return ntupleDescription->fActivation;
}
//_____________________________________________________________________________
template <typename TNTUPLE>
TNTUPLE*
G4TNtupleManager<TNTUPLE>::GetNtuple() const
{
return GetNtuple(fFirstId);
}
//_____________________________________________________________________________
template <typename TNTUPLE>
TNTUPLE*
G4TNtupleManager<TNTUPLE>::GetNtuple(G4int ntupleId) const
{
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "GetNtuple");
if ( ! ntupleDescription ) return nullptr;
return ntupleDescription->fNtuple;
}
//_____________________________________________________________________________
template <typename TNTUPLE>
typename std::vector<TNTUPLE*>::iterator
G4TNtupleManager<TNTUPLE>::BeginNtuple()
{
return fNtupleVector.begin();
}
//_____________________________________________________________________________
template <typename TNTUPLE>
typename std::vector<TNTUPLE*>::iterator
G4TNtupleManager<TNTUPLE>::EndNtuple()
{
return fNtupleVector.end();
}
//_____________________________________________________________________________
template <typename TNTUPLE>
typename std::vector<TNTUPLE*>::const_iterator
G4TNtupleManager<TNTUPLE>::BeginConstNtuple() const
{
return fNtupleVector.begin();
}
//_____________________________________________________________________________
template <typename TNTUPLE>
typename std::vector<TNTUPLE*>::const_iterator
G4TNtupleManager<TNTUPLE>::EndConstNtuple() const
{
return fNtupleVector.end();
}
//_____________________________________________________________________________
template <typename TNTUPLE>
G4int G4TNtupleManager<TNTUPLE>::GetNofNtuples() const
{
return fNtupleVector.size();
}
@@ -43,6 +43,7 @@
#include <vector>
#include <fstream>
#include <memory>
class G4AnalysisMessenger;
@@ -55,6 +56,12 @@ class G4VP2Manager;
class G4VNtupleManager;
class G4VFileManager;
namespace tools {
namespace histo{
class hmpi;
}
}
class G4VAnalysisManager
{
public:
@@ -65,16 +72,21 @@ class G4VAnalysisManager
G4bool OpenFile(const G4String& fileName = "");
G4bool Write();
G4bool CloseFile();
G4bool Merge(tools::histo::hmpi* hmpi);
G4bool Plot();
G4bool IsOpenFile() const;
// Methods for handling files and directories names
G4bool SetFileName(const G4String& fileName);
G4bool SetHistoDirectoryName(const G4String& dirName);
G4bool SetNtupleDirectoryName(const G4String& dirName);
void SetCompressionLevel(G4int level);
G4String GetFileName() const;
G4String GetHistoDirectoryName() const;
G4String GetNtupleDirectoryName() const;
G4int GetCompressionLevel() const;
// Methods for handling histograms
//
G4int CreateH1(const G4String& name, const G4String& title,
@@ -366,6 +378,12 @@ class G4VAnalysisManager
// return true otherwise
G4bool IsAscii() const;
// Plotting option
// Return false if there is no object selected for plottng,
// return true otherwise
G4bool IsPlotting() const;
// Access methods
G4int GetFirstH1Id() const;
G4int GetFirstH2Id() const;
@@ -387,27 +405,36 @@ class G4VAnalysisManager
G4int GetH2Id(const G4String& name, G4bool warn = true) const;
G4int GetH3Id(const G4String& name, G4bool warn = true) const;
// Methods to manipulate histogram & profiles additional information
// Methods to manipulate histogram, profiles & ntuples additional information
//
void SetH1Activation(G4bool activation);
void SetH1Activation(G4int id, G4bool activation);
void SetH1Ascii(G4int id, G4bool ascii);
void SetH1Plotting(G4int id, G4bool plotting);
//
void SetH2Activation(G4bool activation);
void SetH2Activation(G4int id, G4bool activation);
void SetH2Ascii(G4int id, G4bool ascii);
void SetH2Plotting(G4int id, G4bool plotting);
//
void SetH3Activation(G4bool activation);
void SetH3Activation(G4int id, G4bool activation);
void SetH3Ascii(G4int id, G4bool ascii);
void SetH3Plotting(G4int id, G4bool plotting);
//
void SetP1Activation(G4bool activation);
void SetP1Activation(G4int id, G4bool activation);
void SetP1Ascii(G4int id, G4bool ascii);
void SetP1Plotting(G4int id, G4bool plotting);
//
void SetP2Activation(G4bool activation);
void SetP2Activation(G4int id, G4bool activation);
void SetP2Ascii(G4int id, G4bool ascii);
void SetP2Plotting(G4int id, G4bool plotting);
//
void SetNtupleActivation(G4bool activation);
void SetNtupleActivation(G4int id, G4bool activation);
// Access to histogram & profiles parameters
//
@@ -462,12 +489,14 @@ class G4VAnalysisManager
G4double GetH1Unit(G4int id) const;
G4bool GetH1Activation(G4int id) const;
G4bool GetH1Ascii(G4int id) const;
G4bool GetH1Plotting(G4int id) const;
//
G4String GetH2Name(G4int id) const;
G4double GetH2XUnit(G4int id) const;
G4double GetH2YUnit(G4int id) const;
G4bool GetH2Activation(G4int id) const;
G4bool GetH2Ascii(G4int id) const;
G4bool GetH2Plotting(G4int id) const;
//
G4String GetH3Name(G4int id) const;
G4double GetH3XUnit(G4int id) const;
@@ -475,12 +504,14 @@ class G4VAnalysisManager
G4double GetH3ZUnit(G4int id) const;
G4bool GetH3Activation(G4int id) const;
G4bool GetH3Ascii(G4int id) const;
G4bool GetH3Plotting(G4int id) const;
//
G4String GetP1Name(G4int id) const;
G4double GetP1XUnit(G4int id) const;
G4double GetP1YUnit(G4int id) const;
G4bool GetP1Activation(G4int id) const;
G4bool GetP1Ascii(G4int id) const;
G4bool GetP1Plotting(G4int id) const;
//
G4String GetP2Name(G4int id) const;
G4double GetP2XUnit(G4int id) const;
@@ -488,6 +519,9 @@ class G4VAnalysisManager
G4double GetP2ZUnit(G4int id) const;
G4bool GetP2Activation(G4int id) const;
G4bool GetP2Ascii(G4int id) const;
G4bool GetP2Plotting(G4int id) const;
//
G4bool GetNtupleActivation(G4int id) const;
// Setters for histogram & profiles attributes for plotting
//
@@ -554,6 +588,9 @@ class G4VAnalysisManager
virtual G4bool OpenFileImpl(const G4String& fileName) = 0;
virtual G4bool WriteImpl() = 0;
virtual G4bool CloseFileImpl() = 0;
virtual G4bool PlotImpl() = 0;
virtual G4bool MergeImpl(tools::histo::hmpi* hmpi) = 0;
virtual G4bool IsOpenFileImpl() const = 0;
// methods
void SetH1Manager(G4VH1Manager* h1Manager);
@@ -561,30 +598,30 @@ class G4VAnalysisManager
void SetH3Manager(G4VH3Manager* h3Manager);
void SetP1Manager(G4VP1Manager* p1Manager);
void SetP2Manager(G4VP2Manager* p2Manager);
void SetNtupleManager(G4VNtupleManager* ntupleManager);
void SetFileManager(G4VFileManager* fileManager);
void SetNtupleManager(G4VNtupleManager* ntupleManager);
void SetFileManager(std::shared_ptr<G4VFileManager> fileManager);
// Methods to manipulate additional information
G4bool WriteAscii(const G4String& fileName);
// data members
G4AnalysisManagerState fState;
std::shared_ptr<G4VFileManager> fVFileManager;
private:
// data members
G4AnalysisMessenger* fMessenger;
G4HnManager* fH1HnManager;
G4HnManager* fH2HnManager;
G4HnManager* fH3HnManager;
G4HnManager* fP1HnManager;
G4HnManager* fP2HnManager;
G4VH1Manager* fVH1Manager;
G4VH2Manager* fVH2Manager;
G4VH3Manager* fVH3Manager;
G4VP1Manager* fVP1Manager;
G4VP2Manager* fVP2Manager;
G4VNtupleManager* fVNtupleManager;
G4VFileManager* fVFileManager;
std::unique_ptr<G4AnalysisMessenger> fMessenger;
std::shared_ptr<G4HnManager> fH1HnManager;
std::shared_ptr<G4HnManager> fH2HnManager;
std::shared_ptr<G4HnManager> fH3HnManager;
std::shared_ptr<G4HnManager> fP1HnManager;
std::shared_ptr<G4HnManager> fP2HnManager;
std::unique_ptr<G4VH1Manager> fVH1Manager;
std::unique_ptr<G4VH2Manager> fVH2Manager;
std::unique_ptr<G4VH3Manager> fVH3Manager;
std::unique_ptr<G4VP1Manager> fVP1Manager;
std::unique_ptr<G4VP2Manager> fVP2Manager;
std::unique_ptr<G4VNtupleManager> fVNtupleManager;
};
// inline functions
@@ -114,14 +114,14 @@ G4bool G4VAnalysisManager::AddNtupleRow()
//_____________________________________________________________________________
inline
G4bool G4VAnalysisManager::FillNtupleIColumn(G4int ntupleId, G4int columnId,
G4int value)
G4int value)
{
return fVNtupleManager->FillNtupleIColumn(ntupleId, columnId, value);
}
//_____________________________________________________________________________
inline
G4bool G4VAnalysisManager::FillNtupleFColumn(G4int ntupleId, G4int columnId,
G4float value)
G4float value)
{
return fVNtupleManager->FillNtupleFColumn(ntupleId, columnId, value);
}
@@ -129,7 +129,7 @@ G4bool G4VAnalysisManager::FillNtupleFColumn(G4int ntupleId, G4int columnId,
//_____________________________________________________________________________
inline
G4bool G4VAnalysisManager::FillNtupleDColumn(G4int ntupleId, G4int columnId,
G4double value)
G4double value)
{
return fVNtupleManager->FillNtupleDColumn(ntupleId, columnId, value);
}
@@ -137,7 +137,7 @@ G4bool G4VAnalysisManager::FillNtupleDColumn(G4int ntupleId, G4int columnId,
//_____________________________________________________________________________
inline
G4bool G4VAnalysisManager::FillNtupleSColumn(G4int ntupleId, G4int columnId,
const G4String& value)
const G4String& value)
{
return fVNtupleManager->FillNtupleSColumn(ntupleId, columnId, value);
}
@@ -507,6 +507,13 @@ G4bool G4VAnalysisManager::GetH1Ascii(G4int id) const
return fH1HnManager->GetAscii(id);
}
//_____________________________________________________________________________
inline
G4bool G4VAnalysisManager::GetH1Plotting(G4int id) const
{
return fH1HnManager->GetPlotting(id);
}
//_____________________________________________________________________________
inline
G4String G4VAnalysisManager::GetH2Name(G4int id) const
@@ -542,6 +549,12 @@ G4bool G4VAnalysisManager::GetH2Ascii(G4int id) const
return fH2HnManager->GetAscii(id);
}
//_____________________________________________________________________________
inline
G4bool G4VAnalysisManager::GetH2Plotting(G4int id) const
{
return fH2HnManager->GetPlotting(id);
}
//_____________________________________________________________________________
inline
@@ -583,8 +596,14 @@ inline
G4bool G4VAnalysisManager::GetH3Ascii(G4int id) const
{
return fH3HnManager->GetAscii(id);
}
}
//_____________________________________________________________________________
inline
G4bool G4VAnalysisManager::GetH3Plotting(G4int id) const
{
return fH3HnManager->GetPlotting(id);
}
//_____________________________________________________________________________
inline
@@ -621,6 +640,12 @@ G4bool G4VAnalysisManager::GetP1Ascii(G4int id) const
return fP1HnManager->GetAscii(id);
}
//_____________________________________________________________________________
inline
G4bool G4VAnalysisManager::GetP1Plotting(G4int id) const
{
return fP1HnManager->GetPlotting(id);
}
//_____________________________________________________________________________
inline
@@ -664,6 +689,19 @@ G4bool G4VAnalysisManager::GetP2Ascii(G4int id) const
return fP2HnManager->GetAscii(id);
}
//_____________________________________________________________________________
inline
G4bool G4VAnalysisManager::GetP2Plotting(G4int id) const
{
return fP2HnManager->GetPlotting(id);
}
//_____________________________________________________________________________
inline
G4bool G4VAnalysisManager::GetNtupleActivation(G4int id) const
{
return fVNtupleManager->GetActivation(id);
}
//_____________________________________________________________________________
inline
@@ -42,8 +42,7 @@
#include "globals.hh"
#include <vector>
#include <fstream>
#include <memory>
class G4HnManager;
class G4BaseFileManager;
@@ -226,24 +225,18 @@ class G4VAnalysisReader
protected:
// virtual methods
virtual G4int ReadH1Impl(const G4String& /*h1Name*/,
const G4String& /*fileName*/,
G4bool /*isUserFileName*/) { return false; }
virtual G4int ReadH2Impl(const G4String& /*h2Name*/,
const G4String& /*fileName*/,
G4bool /*isUserFileName*/) { return false; }
virtual G4int ReadH3Impl(const G4String& /*h2Name*/,
const G4String& /*fileName*/,
G4bool /*isUserFileName*/) { return false; }
virtual G4int ReadP1Impl(const G4String& /*h1Name*/,
const G4String& /*fileName*/,
G4bool /*isUserFileName*/) { return false; }
virtual G4int ReadP2Impl(const G4String& /*h2Name*/,
const G4String& /*fileName*/,
G4bool /*isUserFileName*/) { return false; }
virtual G4int ReadNtupleImpl(const G4String& /*ntupleName*/,
const G4String& /*fileName*/,
G4bool /*isUserFileName*/) { return false; }
virtual G4int ReadH1Impl(const G4String& h1Name, const G4String& fileName,
G4bool isUserFileName) = 0;
virtual G4int ReadH2Impl(const G4String& h2Name, const G4String& fileName,
G4bool isUserFileName) = 0;
virtual G4int ReadH3Impl(const G4String& h3Name, const G4String& fileName,
G4bool isUserFileName) = 0;
virtual G4int ReadP1Impl(const G4String& p1Name, const G4String& fileName,
G4bool isUserFileName) = 0;
virtual G4int ReadP2Impl(const G4String& p2Name, const G4String& fileName,
G4bool isUserFileName) = 0;
virtual G4int ReadNtupleImpl(const G4String& ntupleName, const G4String& fileName,
G4bool isUserFileName) = 0;
// methods
void SetH1Manager(G4VH1Manager* h1Manager);
@@ -259,13 +252,13 @@ class G4VAnalysisReader
private:
// data members
G4VH1Manager* fVH1Manager;
G4VH2Manager* fVH2Manager;
G4VH3Manager* fVH3Manager;
G4VP1Manager* fVP1Manager;
G4VP2Manager* fVP2Manager;
G4VRNtupleManager* fVNtupleManager;
G4BaseFileManager* fFileManager;
std::unique_ptr<G4VH1Manager> fVH1Manager;
std::unique_ptr<G4VH2Manager> fVH2Manager;
std::unique_ptr<G4VH3Manager> fVH3Manager;
std::unique_ptr<G4VP1Manager> fVP1Manager;
std::unique_ptr<G4VP2Manager> fVP2Manager;
std::unique_ptr<G4VRNtupleManager> fVNtupleManager;
std::unique_ptr<G4BaseFileManager> fFileManager;
};
// inline functions
@@ -38,7 +38,7 @@
class G4VFileManager : public G4BaseFileManager
{
public:
G4VFileManager(const G4AnalysisManagerState& state);
explicit G4VFileManager(const G4AnalysisManagerState& state);
virtual ~G4VFileManager();
// Methods to manipulate files
@@ -48,39 +48,36 @@ class G4VFileManager : public G4BaseFileManager
// Methods for handling files and directories names
//
virtual G4bool SetFileName(const G4String& fileName) final;
void LockHistoDirectoryName();
void LockProfileDirectoryName();
void LockNtupleDirectoryName();
virtual G4bool SetFileName(const G4String& fileName);
G4bool SetHistoDirectoryName(const G4String& dirName);
G4bool SetProfileDirectoryName(const G4String& dirName);
G4bool SetNtupleDirectoryName(const G4String& dirName);
G4bool IsOpenFile() const;
G4String GetHistoDirectoryName() const;
G4String GetProfileDirectoryName() const;
G4String GetNtupleDirectoryName() const;
protected:
// data members
G4bool fIsOpenFile;
G4String fHistoDirectoryName;
G4String fProfileDirectoryName;
G4String fNtupleDirectoryName;
G4bool fLockFileName;
G4bool fLockHistoDirectoryName;
G4bool fLockProfileDirectoryName;
G4bool fLockNtupleDirectoryName;
};
// inline functions
inline G4bool G4VFileManager::IsOpenFile() const
{ return fIsOpenFile; }
inline void G4VFileManager::LockHistoDirectoryName()
{ fLockHistoDirectoryName = true; }
inline void G4VFileManager::LockProfileDirectoryName()
{ fLockProfileDirectoryName = true; }
inline void G4VFileManager::LockNtupleDirectoryName()
{ fLockNtupleDirectoryName = true; }
@@ -89,10 +86,6 @@ inline G4String G4VFileManager::GetHistoDirectoryName() const {
return fHistoDirectoryName;
}
inline G4String G4VFileManager::GetProfileDirectoryName() const {
return fProfileDirectoryName;
}
inline G4String G4VFileManager::GetNtupleDirectoryName() const {
return fNtupleDirectoryName;
}
@@ -32,24 +32,28 @@
#ifndef G4VH1Manager_h
#define G4VH1Manager_h 1
#include "G4BaseAnalysisManager.hh"
#include "globals.hh"
#include <vector>
#include <memory>
class G4HnManager;
class G4AnalysisManagerState;
class G4VH1Manager : public G4BaseAnalysisManager
class G4VH1Manager
{
// Disable using the object managers outside
friend class G4VAnalysisManager;
friend class G4VAnalysisReader;
public:
G4VH1Manager() {}
virtual ~G4VH1Manager() {}
// deleted copy constructor & assignment operator
G4VH1Manager(const G4VH1Manager& rhs) = delete;
G4VH1Manager& operator=(const G4VH1Manager& rhs) = delete;
protected:
G4VH1Manager(const G4AnalysisManagerState& state);
virtual ~G4VH1Manager();
// Methods for handling histograms
virtual G4int CreateH1(const G4String& name, const G4String& title,
G4int nbins, G4double xmin, G4double xmax,
@@ -97,15 +101,9 @@ class G4VH1Manager : public G4BaseAnalysisManager
// Methods to manipulate histograms
virtual G4bool WriteOnAscii(std::ofstream& output) = 0;
// data members
G4HnManager* fHnManager;
private:
// Not implemented copy constructor
G4VH1Manager(const G4VH1Manager& rhs);
// Not implemented assignment operator
G4VH1Manager& operator=(const G4VH1Manager& rhs);
// Access to Hn manager
virtual std::shared_ptr<G4HnManager> GetHnManager() = 0;
};
#endif
@@ -32,22 +32,28 @@
#ifndef G4VH2Manager_h
#define G4VH2Manager_h 1
#include "G4BaseAnalysisManager.hh"
#include "globals.hh"
class G4HnManager;
class G4AnalysisManagerState;
#include <vector>
#include <memory>
class G4VH2Manager : public G4BaseAnalysisManager
class G4HnManager;
class G4VH2Manager
{
// Disable using the object managers outside G4VAnalysisManager
friend class G4VAnalysisManager;
friend class G4VAnalysisReader;
protected:
G4VH2Manager(const G4AnalysisManagerState& state);
virtual ~G4VH2Manager();
public:
G4VH2Manager() {}
virtual ~G4VH2Manager() {}
// deleted copy constructor & assignment operator
G4VH2Manager(const G4VH2Manager& rhs) = delete;
G4VH2Manager& operator=(const G4VH2Manager& rhs) =delete;
protected:
// Methods for handling histograms
virtual G4int CreateH2(const G4String& name, const G4String& title,
G4int nxbins, G4double xmin, G4double xmax,
@@ -118,15 +124,9 @@ class G4VH2Manager : public G4BaseAnalysisManager
// Methods to manipulate histograms
virtual G4bool WriteOnAscii(std::ofstream& output) = 0;
// data members
G4HnManager* fHnManager;
private:
// Not implemented copy constructor
G4VH2Manager(const G4VH2Manager& rhs);
// Not implemented assignment operator
G4VH2Manager& operator=(const G4VH2Manager& rhs);
// Access to Hn manager
virtual std::shared_ptr<G4HnManager> GetHnManager() = 0;
};
#endif
@@ -32,22 +32,28 @@
#ifndef G4VH3Manager_h
#define G4VH3Manager_h 1
#include "G4BaseAnalysisManager.hh"
#include "globals.hh"
class G4HnManager;
class G4AnalysisManagerState;
#include <vector>
#include <memory>
class G4VH3Manager : public G4BaseAnalysisManager
class G4HnManager;
class G4VH3Manager
{
// Disable using the object managers outside G4VAnalysisManager
friend class G4VAnalysisManager;
friend class G4VAnalysisReader;
protected:
G4VH3Manager(const G4AnalysisManagerState& state);
virtual ~G4VH3Manager();
public:
G4VH3Manager() {}
virtual ~G4VH3Manager() {}
// deleted copy constructor & assignment operator
G4VH3Manager(const G4VH3Manager& rhs) = delete;
G4VH3Manager& operator=(const G4VH3Manager& rhs) = delete;
protected:
// Methods for handling histograms
virtual G4int CreateH3(const G4String& name, const G4String& title,
G4int nxbins, G4double xmin, G4double xmax,
@@ -137,15 +143,9 @@ class G4VH3Manager : public G4BaseAnalysisManager
// Methods to manipulate histograms
virtual G4bool WriteOnAscii(std::ofstream& output) = 0;
// data members
G4HnManager* fHnManager;
private:
// Not implemented copy constructor
G4VH3Manager(const G4VH3Manager& rhs);
// Not implemented assignment operator
G4VH3Manager& operator=(const G4VH3Manager& rhs);
// Access to Hn manager
virtual std::shared_ptr<G4HnManager> GetHnManager() = 0;
};
#endif
@@ -44,9 +44,17 @@ class G4VNtupleManager : public G4BaseAnalysisManager
// its messenger
friend class G4VAnalysisManager;
protected:
G4VNtupleManager(const G4AnalysisManagerState& state);
public:
explicit G4VNtupleManager(const G4AnalysisManagerState& state);
virtual ~G4VNtupleManager();
// deleted copy constructor & assignment operator
G4VNtupleManager(const G4VNtupleManager& rhs) = delete;
G4VNtupleManager& operator=(const G4VNtupleManager& rhs) =delete;
protected:
//G4VNtupleManager(const G4AnalysisManagerState& state);
//virtual ~G4VNtupleManager();
// Methods for handling ntuples
virtual G4int CreateNtuple(const G4String& name, const G4String& title) = 0;
@@ -90,6 +98,11 @@ class G4VNtupleManager : public G4BaseAnalysisManager
const G4String& value) = 0;
virtual G4bool AddNtupleRow(G4int ntupleId) = 0;
// Activation option
virtual void SetActivation(G4bool activation) = 0;
virtual void SetActivation(G4int id, G4bool activation) = 0;
virtual G4bool GetActivation(G4int id) const = 0;
// Access methods
virtual G4int GetNofNtuples() const = 0;
@@ -32,24 +32,28 @@
#ifndef G4VP1Manager_h
#define G4VP1Manager_h 1
#include "G4BaseAnalysisManager.hh"
#include "globals.hh"
#include <vector>
#include <memory>
class G4HnManager;
class G4AnalysisManagerState;
class G4VP1Manager : public G4BaseAnalysisManager
class G4VP1Manager
{
// Disable using the object managers outside
friend class G4VAnalysisManager;
friend class G4VAnalysisReader;
public:
G4VP1Manager() {}
virtual ~G4VP1Manager() {}
// deleted copy constructor & assignment operator
G4VP1Manager(const G4VP1Manager& rhs) = delete;
G4VP1Manager& operator=(const G4VP1Manager& rhs) = delete;
protected:
G4VP1Manager(const G4AnalysisManagerState& state);
virtual ~G4VP1Manager();
// Methods for handling profiles
virtual G4int CreateP1(const G4String& name, const G4String& title,
G4int nbins, G4double xmin, G4double xmax,
@@ -112,15 +116,9 @@ class G4VP1Manager : public G4BaseAnalysisManager
// Methods to manipulate profiles
// virtual G4bool WriteOnAscii(std::ofstream& output) = 0;
// data members
G4HnManager* fHnManager;
private:
// Not implemented copy constructor
G4VP1Manager(const G4VP1Manager& rhs);
// Not implemented assignment operator
G4VP1Manager& operator=(const G4VP1Manager& rhs);
// Access to Hn manager
virtual std::shared_ptr<G4HnManager> GetHnManager() = 0;
};
#endif
@@ -32,22 +32,28 @@
#ifndef G4VP2Manager_h
#define G4VP2Manager_h 1
#include "G4BaseAnalysisManager.hh"
#include "globals.hh"
class G4HnManager;
class G4AnalysisManagerState;
#include <vector>
#include <memory>
class G4VP2Manager : public G4BaseAnalysisManager
class G4HnManager;
class G4VP2Manager
{
// Disable using the object managers outside G4VAnalysisManager
friend class G4VAnalysisManager;
friend class G4VAnalysisReader;
protected:
G4VP2Manager(const G4AnalysisManagerState& state);
virtual ~G4VP2Manager();
public:
G4VP2Manager() {}
virtual ~G4VP2Manager() {}
// deleted copy constructor & assignment operator
G4VP2Manager(const G4VP2Manager& rhs) = delete;
G4VP2Manager& operator=(const G4VP2Manager& rhs) = delete;
protected:
// Methods for handling histograms
virtual G4int CreateP2(const G4String& name, const G4String& title,
G4int nxbins, G4double xmin, G4double xmax,
@@ -133,15 +139,9 @@ class G4VP2Manager : public G4BaseAnalysisManager
// Methods to manipulate histograms
virtual G4bool WriteOnAscii(std::ofstream& output) = 0;
// data members
G4HnManager* fHnManager;
private:
// Not implemented copy constructor
G4VP2Manager(const G4VP2Manager& rhs);
// Not implemented assignment operator
G4VP2Manager& operator=(const G4VP2Manager& rhs);
// Access to Hn manager
virtual std::shared_ptr<G4HnManager> GetHnManager() = 0;
};
#endif
@@ -44,11 +44,16 @@ class G4VRNtupleManager : public G4BaseAnalysisManager
// its messenger
friend class G4VAnalysisReader;
protected:
G4VRNtupleManager(const G4AnalysisManagerState& state)
public:
explicit G4VRNtupleManager(const G4AnalysisManagerState& state)
: G4BaseAnalysisManager(state) {}
virtual ~G4VRNtupleManager(){}
// deleted copy constructor & assignment operator
G4VRNtupleManager(const G4VRNtupleManager& rhs) = delete;
G4VRNtupleManager& operator=(const G4VRNtupleManager& rhs) = delete;
protected:
// Methods to read ntuple from a file
// Methods for ntuple with id = FirstNtupleId
virtual G4bool SetNtupleIColumn(const G4String& columnName,
@@ -57,8 +62,8 @@ class G4VRNtupleManager : public G4BaseAnalysisManager
G4float& value)= 0;
virtual G4bool SetNtupleDColumn(const G4String& columnName,
G4double& value)= 0;
virtual G4bool SetNtupleSColumn(const G4String& /*columnName*/,
G4String& /*value*/) { return false; }
virtual G4bool SetNtupleSColumn(const G4String& columnName,
G4String& value) = 0;
// Bind the ntuple columns of vector type
virtual G4bool SetNtupleIColumn(const G4String& columnName,
std::vector<G4int>& vector) = 0;
@@ -73,8 +78,8 @@ class G4VRNtupleManager : public G4BaseAnalysisManager
const G4String& columnName, G4float& value)= 0;
virtual G4bool SetNtupleDColumn(G4int ntupleId,
const G4String& columnName, G4double& value)= 0;
virtual G4bool SetNtupleSColumn(G4int /*ntupleId*/,
const G4String& /*columnName*/, G4String& /*value*/) { return false; }
virtual G4bool SetNtupleSColumn(G4int ntupleId,
const G4String& columnName, G4String& value)= 0;
// Bind the ntuple columns of vector type
virtual G4bool SetNtupleIColumn(G4int ntupleId, const G4String& columnName,
std::vector<G4int>& vector) = 0;
+18 -6
View File
@@ -11,12 +11,13 @@
#
# Generated on : 15/07/2013
#
# $Id: sources.cmake 83748 2014-09-12 12:13:37Z gcosmo $
# $Id: sources.cmake 93451 2015-10-22 14:53:57Z gcosmo $
#
#------------------------------------------------------------------------------
# List external includes needed.
include_directories(${CLHEP_INCLUDE_DIRS})
include_directories(${FREETYPE_INCLUDE_DIRS})
# List internal includes needed.
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
@@ -37,15 +38,25 @@ GEANT4_DEFINE_MODULE(NAME G4analysismng
G4BaseFileManager.hh
G4BinScheme.hh
G4Fcn.hh
G4AnalysisMessengerHelper.hh
G4FileMessenger.hh
G4H1Messenger.hh
G4H2Messenger.hh
G4H3Messenger.hh
G4P1Messenger.hh
G4P2Messenger.hh
G4NtupleMessenger.hh
G4HnInformation.hh
G4HnManager.hh
G4HnMessenger.hh
G4PlotManager.hh
G4PlotMessenger.hh
G4PlotParameters.hh
G4THnManager.hh
G4THnManager.icc
G4TNtupleDescription.hh
G4TNtupleManager.hh
G4TNtupleManager.icc
G4VAnalysisManager.hh
G4VAnalysisManager.icc
G4VAnalysisReader.hh
@@ -68,23 +79,23 @@ GEANT4_DEFINE_MODULE(NAME G4analysismng
G4AnalysisUtilities.cc
G4BinScheme.cc
G4Fcn.cc
G4AnalysisMessengerHelper.cc
G4FileMessenger.cc
G4H1Messenger.cc
G4H2Messenger.cc
G4H3Messenger.cc
G4P1Messenger.cc
G4P2Messenger.cc
G4NtupleMessenger.cc
G4HnManager.cc
G4HnMessenger.cc
G4PlotManager.cc
G4PlotMessenger.cc
G4PlotParameters.cc
G4VAnalysisManager.cc
G4VAnalysisReader.cc
G4VFileManager.cc
G4VH1Manager.cc
G4VH2Manager.cc
G4VH3Manager.cc
G4VNtupleManager.cc
G4VP1Manager.cc
G4VP2Manager.cc
GRANULAR_DEPENDENCIES
G4globman
G4intercoms
@@ -92,6 +103,7 @@ GEANT4_DEFINE_MODULE(NAME G4analysismng
G4global
G4intercoms
LINK_LIBRARIES
${FREETYPE_LIBRARIES}
)
# List any source specific properties here
@@ -39,6 +39,7 @@ G4AnalysisManagerState::G4AnalysisManagerState(
fIsMaster(isMaster),
fIsActivation(false),
fVerboseLevel(0),
fCompressionLevel(1),
fVerboseL1(type,1),
fVerboseL2(type,2),
fVerboseL3(type,3),
@@ -35,34 +35,40 @@
#include "G4H3Messenger.hh"
#include "G4P1Messenger.hh"
#include "G4P2Messenger.hh"
#include "G4NtupleMessenger.hh"
#include "G4HnMessenger.hh"
#include "G4AnalysisUtilities.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithAnInteger.hh"
using namespace G4Analysis;
//_____________________________________________________________________________
G4AnalysisMessenger::G4AnalysisMessenger(G4VAnalysisManager* manager)
: G4UImessenger(),
fManager(manager),
fFileMessenger(0),
fH1Messenger(0),
fH2Messenger(0),
fH3Messenger(0),
fP1Messenger(0),
fP2Messenger(0),
fH1HnMessenger(0),
fH2HnMessenger(0),
fH3HnMessenger(0),
fP1HnMessenger(0),
fP2HnMessenger(0),
fAnalysisDir(0),
fSetActivationCmd(0),
fVerboseCmd(0)
fFileMessenger(nullptr),
fH1Messenger(nullptr),
fH2Messenger(nullptr),
fH3Messenger(nullptr),
fP1Messenger(nullptr),
fP2Messenger(nullptr),
fNtupleMessenger(nullptr),
fH1HnMessenger(nullptr),
fH2HnMessenger(nullptr),
fH3HnMessenger(nullptr),
fP1HnMessenger(nullptr),
fP2HnMessenger(nullptr),
fAnalysisDir(nullptr),
fSetActivationCmd(nullptr),
fVerboseCmd(nullptr),
fCompressionCmd(nullptr)
{
fAnalysisDir = new G4UIdirectory("/analysis/");
fAnalysisDir = G4Analysis::make_unique<G4UIdirectory>("/analysis/");
fAnalysisDir->SetGuidance("analysis control");
fSetActivationCmd = new G4UIcmdWithABool("/analysis/setActivation",this);
fSetActivationCmd = G4Analysis::make_unique<G4UIcmdWithABool>("/analysis/setActivation",this);
G4String guidance = "Set activation. \n";
guidance += "When this option is enabled, only the histograms marked as activated\n";
guidance += "are returned, filled or saved on file.\n";
@@ -70,79 +76,73 @@ G4AnalysisMessenger::G4AnalysisMessenger(G4VAnalysisManager* manager)
fSetActivationCmd->SetGuidance(guidance);
fSetActivationCmd->SetParameterName("Activation",false);
fVerboseCmd = new G4UIcmdWithAnInteger("/analysis/verbose",this);
fVerboseCmd = G4Analysis::make_unique<G4UIcmdWithAnInteger>("/analysis/verbose",this);
fVerboseCmd->SetGuidance("Set verbose level");
fVerboseCmd->SetParameterName("VerboseLevel",false);
fVerboseCmd->SetRange("VerboseLevel>=0 && VerboseLevel<=4");
fFileMessenger = new G4FileMessenger(manager);
fH1Messenger = new G4H1Messenger(manager);
fH2Messenger = new G4H2Messenger(manager);
fH3Messenger = new G4H3Messenger(manager);
fP1Messenger = new G4P1Messenger(manager);
fP2Messenger = new G4P2Messenger(manager);
fCompressionCmd = G4Analysis::make_unique<G4UIcmdWithAnInteger>("/analysis/compression",this);
fCompressionCmd->SetGuidance("Set compression level");
fCompressionCmd->SetParameterName("CompressionLevel",false);
fCompressionCmd->SetRange("CompressionLevel>=0 && CompressionLevel<=4");
fFileMessenger = G4Analysis::make_unique<G4FileMessenger>(manager);
fH1Messenger = G4Analysis::make_unique<G4H1Messenger>(manager);
fH2Messenger = G4Analysis::make_unique<G4H2Messenger>(manager);
fH3Messenger = G4Analysis::make_unique<G4H3Messenger>(manager);
fP1Messenger = G4Analysis::make_unique<G4P1Messenger>(manager);
fP2Messenger = G4Analysis::make_unique<G4P2Messenger>(manager);
fNtupleMessenger = G4Analysis::make_unique<G4NtupleMessenger>(manager);
}
//_____________________________________________________________________________
G4AnalysisMessenger::~G4AnalysisMessenger()
{
delete fSetActivationCmd;
delete fVerboseCmd;
delete fAnalysisDir;
delete fFileMessenger;
delete fH1Messenger;
delete fH2Messenger;
delete fH3Messenger;
delete fP1Messenger;
delete fP2Messenger;
delete fH1HnMessenger;
delete fH2HnMessenger;
delete fH3HnMessenger;
delete fP1HnMessenger;
delete fP2HnMessenger;
}
{}
//
// public functions
//
//_____________________________________________________________________________
void G4AnalysisMessenger::SetH1HnManager(G4HnManager* h1HnManager)
void G4AnalysisMessenger::SetH1HnManager(G4HnManager& h1HnManager)
{
fH1HnMessenger = new G4HnMessenger(h1HnManager);
fH1HnMessenger = G4Analysis::make_unique<G4HnMessenger>(h1HnManager);
}
//_____________________________________________________________________________
void G4AnalysisMessenger::SetH2HnManager(G4HnManager* h2HnManager)
void G4AnalysisMessenger::SetH2HnManager(G4HnManager& h2HnManager)
{
fH2HnMessenger = new G4HnMessenger(h2HnManager);
fH2HnMessenger = G4Analysis::make_unique<G4HnMessenger>(h2HnManager);
}
//_____________________________________________________________________________
void G4AnalysisMessenger::SetH3HnManager(G4HnManager* h2HnManager)
void G4AnalysisMessenger::SetH3HnManager(G4HnManager& h2HnManager)
{
fH2HnMessenger = new G4HnMessenger(h2HnManager);
fH2HnMessenger = G4Analysis::make_unique<G4HnMessenger>(h2HnManager);
}
//_____________________________________________________________________________
void G4AnalysisMessenger::SetP1HnManager(G4HnManager* p1HnManager)
void G4AnalysisMessenger::SetP1HnManager(G4HnManager& p1HnManager)
{
fP1HnMessenger = new G4HnMessenger(p1HnManager);
fP1HnMessenger = G4Analysis::make_unique<G4HnMessenger>(p1HnManager);
}
//_____________________________________________________________________________
void G4AnalysisMessenger::SetP2HnManager(G4HnManager* p2HnManager)
void G4AnalysisMessenger::SetP2HnManager(G4HnManager& p2HnManager)
{
fP2HnMessenger = new G4HnMessenger(p2HnManager);
fP2HnMessenger = G4Analysis::make_unique<G4HnMessenger>(p2HnManager);
}
//_____________________________________________________________________________
void G4AnalysisMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
if ( command == fSetActivationCmd ) {
if ( command == fSetActivationCmd.get() ) {
fManager->SetActivation(fSetActivationCmd->GetNewBoolValue(newValues));
}
else if ( command == fVerboseCmd ) {
else if ( command == fVerboseCmd.get() ) {
fManager->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValues));
}
else if ( command == fCompressionCmd.get() ) {
fManager->SetCompressionLevel(fCompressionCmd->GetNewIntValue(newValues));
}
}
@@ -0,0 +1,331 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// Author: Ivana Hrivnacova, 05/05/2015 (ivana@ipno.in2p3.fr)
//
// This messenger class is a generalization of the HistoMessenger class,
// originally developed for the extended/electromagnetic examples
// by Michel Maire (michel.maire@lapp.in2p3.fr)
#include "G4AnalysisMessengerHelper.hh"
#include "G4VAnalysisManager.hh"
#include "G4AnalysisUtilities.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4Tokenizer.hh"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace G4Analysis;
namespace {
//_____________________________________________________________________________
G4String ObjectType(const G4String& hnType)
{
G4String first = hnType.substr(0,1);
if (first == "h") {
return "Histogram";
} else if (first == "p") {
return "Profile";
} else {
// other possibilitied not handled
return "";
}
}
//_____________________________________________________________________________
void Replace(std::string& str, const std::string& from, const std::string& to) {
// Replace all occurences of from string
if (from.empty()) return;
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
str.replace(start_pos, from.length(), to);
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
}
}
}
//_____________________________________________________________________________
G4AnalysisMessengerHelper::G4AnalysisMessengerHelper(const G4String& hnType)
: fHnType(hnType)
{}
//_____________________________________________________________________________
G4AnalysisMessengerHelper::~G4AnalysisMessengerHelper()
{}
//
// private functions
//
//_____________________________________________________________________________
G4String G4AnalysisMessengerHelper::Update(const G4String& str, const G4String& axis) const
{
G4String newStr(str);
// Hn, Pn
G4String upperHnType(str);
upperHnType.toUpper();
Replace(newStr, "UHNTYPE_", upperHnType);
// hn, pn
Replace(newStr, "HNTYPE_", fHnType);
// n = 1,2,3
G4String second = fHnType.substr(1,1);
Replace(newStr, "NDIM_", second);
// histogram, profile
G4String lowerObjectType(ObjectType(fHnType));
lowerObjectType.toLower();
Replace(newStr, "LOBJECT", lowerObjectType);
// Histogram, Profile
Replace(newStr, "OBJECT", ObjectType(fHnType));
// X, Y, Z
G4String upperAxis(axis);
upperAxis.toUpper();
Replace(newStr, "UAXIS", upperAxis);
// x, y, z
Replace(newStr, "AXIS", axis);
// return result
return newStr;
}
//
// public functions
//
//_____________________________________________________________________________
std::unique_ptr<G4UIdirectory>
G4AnalysisMessengerHelper::CreateHnDirectory() const
{
std::unique_ptr<G4UIdirectory> directory(new G4UIdirectory(Update("/analysis/HNTYPE_/")));
directory->SetGuidance(Update("NDIM_D LOBJECT control"));
return directory;
}
//_____________________________________________________________________________
std::unique_ptr<G4UIcommand>
G4AnalysisMessengerHelper::CreateSetTitleCommand(G4UImessenger* messenger) const
{
auto parId = new G4UIparameter("id", 'i', false);
parId->SetGuidance(Update("OBJECT id"));
parId->SetParameterRange("id>=0");
auto parTitle = new G4UIparameter("title", 's', true);
parTitle->SetGuidance(Update("OBJECT title"));
parTitle->SetDefaultValue("none");
std::unique_ptr<G4UIcommand> command(
new G4UIcommand(Update("/analysis/HNTYPE_/setTitle"), messenger));
command->SetGuidance(Update("Set title for the NDIM_D LOBJECT of given id"));
command->SetParameter(parId);
command->SetParameter(parTitle);
command->AvailableForStates(G4State_PreInit, G4State_Idle);
return command;
}
//_____________________________________________________________________________
std::unique_ptr<G4UIcommand>
G4AnalysisMessengerHelper::CreateSetBinsCommand(const G4String& axis,
G4UImessenger* messenger) const
{
auto parId = new G4UIparameter("id", 'i', false);
parId->SetGuidance(Update( "OBJECT id"));
parId->SetParameterRange("id>=0");
auto parNbins = new G4UIparameter("nbins", 'i', false);
parNbins->SetGuidance("Number of bins");
auto parValMin = new G4UIparameter("valMin", 'd', false);
parValMin->SetGuidance("Minimum value, expressed in unit");
auto parValMax = new G4UIparameter("valMax", 'd', false);
parValMax->SetGuidance("Maximum value, expressed in unit");
auto parValUnit = new G4UIparameter("valUnit", 's', true);
parValUnit->SetGuidance("The unit applied to filled values and valMin, valMax");
parValUnit->SetDefaultValue("none");
auto parValFcn = new G4UIparameter("valFcn", 's', true);
parValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnGuidance = "The function applied to filled values (log, log10, exp, none).\n";
fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
fcnGuidance += "but none value should be used instead.";
parValFcn->SetGuidance(fcnGuidance);
parValFcn->SetDefaultValue("none");
auto parValBinScheme = new G4UIparameter("valBinScheme", 's', true);
parValBinScheme->SetParameterCandidates("linear log");
G4String binSchemeGuidance = "The binning scheme (linear, log).\n";
binSchemeGuidance
+= "Note that the unit and fcn parameters cannot be omitted in this case,\n";
binSchemeGuidance += "but none value should be used instead.";
parValBinScheme->SetGuidance(binSchemeGuidance);
parValBinScheme->SetDefaultValue("linear");
std::unique_ptr<G4UIcommand> command(
new G4UIcommand(Update("/analysis/HNTYPE_/setUAXIS", axis), messenger));
command->SetGuidance(Update("Set parameters for the NDIM_D LOBJECT of given id:"));
command->SetGuidance(
Update(" nAXISbins; AXISvalMin; AXISvalMax; AXISunit; AXISfunction; AXISbinScheme", axis));
command->SetParameter(parId);
command->SetParameter(parNbins);
command->SetParameter(parValMin);
command->SetParameter(parValMax);
command->SetParameter(parValUnit);
command->SetParameter(parValFcn);
command->SetParameter(parValBinScheme);
command->AvailableForStates(G4State_PreInit, G4State_Idle);
return command;
}
//_____________________________________________________________________________
std::unique_ptr<G4UIcommand>
G4AnalysisMessengerHelper::CreateSetValuesCommand(const G4String& axis,
G4UImessenger* messenger) const
{
auto parId = new G4UIparameter("id", 'i', false);
parId->SetGuidance(Update("OBJECT id"));
parId->SetParameterRange("id>=0");
auto parValMin = new G4UIparameter("valMin", 'd', false);
parValMin->SetGuidance(Update("Minimum AXIS-value expressed in unit", axis));
auto parValMax = new G4UIparameter("valMax", 'd', false);
parValMax->SetGuidance(Update("Maximum AXIS-value expressed in unit", axis));
auto parValUnit = new G4UIparameter("valUnit", 's', true);
parValUnit->SetGuidance("The unit applied to filled values and valMin, valMax");
parValUnit->SetDefaultValue("none");
auto parValFcn = new G4UIparameter("valFcn", 's', true);
parValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnGuidance = "The function applied to filled values (log, log10, exp, none).\n";
fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
fcnGuidance += "but none value should be used instead.";
parValFcn->SetGuidance(fcnGuidance);
parValFcn->SetDefaultValue("none");
std::unique_ptr<G4UIcommand> command(
new G4UIcommand(Update("/analysis/HNTYPE_/setUAXIS", axis), messenger));
command->SetGuidance(Update("Set parameters for the NDIM_D LOBJECT of #id:"));
command->SetGuidance(
Update(" AXISvalMin; AXISvalMax; AXISunit; AXISfunction", axis));
command->AvailableForStates(G4State_PreInit, G4State_Idle);
return command;
}
//_____________________________________________________________________________
std::unique_ptr<G4UIcommand>
G4AnalysisMessengerHelper::CreateSetAxisCommand(const G4String& axis,
G4UImessenger* messenger) const
{
auto parId = new G4UIparameter("id", 'i', false);
parId->SetGuidance(Update("OBJECT id"));
parId->SetParameterRange("id>=0");
auto parAxis = new G4UIparameter("axis", 's', true);
parAxis->SetGuidance(Update("Histogram AXIS-axis title", axis));
parAxis->SetDefaultValue("none");
std::unique_ptr<G4UIcommand> command(
new G4UIcommand(Update("/analysis/HNTYPE_/setUAXISaxis", axis), messenger));
command->SetGuidance(Update("Set AXIS-axis title for the NDIM_D LOBJECT of given id", axis));
command->SetParameter(parId);
command->SetParameter(parAxis);
command->AvailableForStates(G4State_PreInit, G4State_Idle);
return command;
}
//_____________________________________________________________________________
void G4AnalysisMessengerHelper::GetBinData(BinData& data,
std::vector<G4String>& parameters,
G4int& counter) const
{
data.fNbins = G4UIcommand::ConvertToInt(parameters[counter++]);
data.fVmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
data.fVmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
data.fSunit = parameters[counter++];
data.fSfcn = parameters[counter++];
data.fSbinScheme = parameters[counter++];
}
//_____________________________________________________________________________
void G4AnalysisMessengerHelper::GetValueData(ValueData& data,
std::vector<G4String>& parameters,
G4int& counter) const
{
data.fVmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
data.fVmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
data.fSunit = parameters[counter++];
data.fSfcn = parameters[counter++];
}
//_____________________________________________________________________________
void G4AnalysisMessengerHelper::WarnAboutParameters(G4UIcommand* command,
G4int nofParameters) const
{
G4ExceptionDescription description;
description
<< "Got wrong number of \"" << command->GetCommandName()
<< "\" parameters: " << nofParameters
<< " instead of " << command->GetParameterEntries()
<< " expected" << G4endl;
G4String methodName(Update("G4UHNTYPE_Messenger::SetNewValue"));
G4Exception(methodName,
"Analysis_W013", JustWarning, description);
}
//_____________________________________________________________________________
void G4AnalysisMessengerHelper::WarnAboutSetCommands() const
{
G4ExceptionDescription description;
description
<< "Command setX, setY, setZ must be called sucessively in this order. " << G4endl
<< "Command was ignored." << G4endl;
G4String methodName(Update("G4UHNTYPE_Messenger::SetNewValue"));
G4Exception(methodName,
"Analysis_W013", JustWarning, description);
}
@@ -38,7 +38,7 @@ namespace {
G4bool GetToken(const G4String& line, G4String& token,
std::string::size_type begIdx, std::string::size_type& endIdx)
{
while ( line[begIdx] == ' ') ++begIdx;
while ( line[begIdx] == ' ') ++begIdx; // Loop checking, 23.06.2015, I. Hrivnacova
if ( line[begIdx] == '"' ) {
endIdx = line.find('"', begIdx+1);
if ( endIdx == std::string::npos ) endIdx = line.length();
@@ -78,7 +78,7 @@ G4bool CheckNbins(G4int nbins)
G4bool CheckMinMax(G4double xmin, G4double xmax,
const G4String& fcnName, const G4String& binSchemeName)
{
G4bool result = true;
auto result = true;
if ( xmax <= xmin ) {
G4ExceptionDescription description;
@@ -101,7 +101,7 @@ G4bool CheckMinMax(G4double xmin, G4double xmax,
result = false;
}
if ( ( GetBinScheme(binSchemeName) == kLogBinScheme ||
if ( ( GetBinScheme(binSchemeName) == G4BinScheme::kLog ||
fcnName == "log" || fcnName == "log10" ) && ( xmin == 0 ) ) {
G4ExceptionDescription description;
description
@@ -185,7 +185,50 @@ void Tokenize(const G4String& line, std::vector<G4String>& tokens)
}
begIdx = endIdx + 1;
}
while ( endIdx != line.length() );
while ( endIdx < line.length() ); // Loop checking, 23.06.2015, I. Hrivnacova
}
//_____________________________________________________________________________
G4AnalysisOutput GetOutput(const G4String& outputName) {
if ( outputName == "csv" ) { return G4AnalysisOutput::kCsv; }
else if ( outputName == "root" ) { return G4AnalysisOutput::kRoot; }
else if ( outputName == "xml" ) { return G4AnalysisOutput::kXml; }
else if ( outputName == "none" ) { return G4AnalysisOutput::kNone; }
else {
G4ExceptionDescription description;
description
<< " \"" << outputName << "\" output type is not supported." << G4endl
<< " " << "Root type will be used.";
G4Exception("G4Analysis::GetOutputType",
"Analysis_W013", JustWarning, description);
return G4AnalysisOutput::kNone;
}
}
//_____________________________________________________________________________
G4String GetOutputName(G4AnalysisOutput output) {
switch ( output ) {
case G4AnalysisOutput::kCsv:
return "csv";
break;
case G4AnalysisOutput::kRoot:
return "root";
break;
case G4AnalysisOutput::kXml:
return "xml";
break;
case G4AnalysisOutput::kNone:
return "none";
break;
}
// should never reach this line
G4ExceptionDescription description;
description
<< " \"" << static_cast<int>(output) << "\" is not handled." << G4endl
<< " " << "none type will be used.";
G4Exception("G4Analysis::GetOutputName",
"Analysis_W013", JustWarning, description);
return "none";
}
}
@@ -38,13 +38,11 @@ G4BaseAnalysisManager::G4BaseAnalysisManager(
: fState(state),
fFirstId(0),
fLockFirstId(false)
{
}
{}
//_____________________________________________________________________________
G4BaseAnalysisManager::~G4BaseAnalysisManager()
{
}
{}
//
// public methods
@@ -96,7 +96,7 @@ G4String G4BaseFileManager::GetNtupleFileName(const G4String& ntupleName) const
G4String name(fFileName);
// Take out file extension
G4String extension = TakeOffExtension(name);
auto extension = TakeOffExtension(name);
// Add ntupleName
name.append("_nt_");
@@ -123,7 +123,7 @@ G4String G4BaseFileManager::GetHnFileName(const G4String& hnType,
G4String name(fFileName);
// Take out file extension
G4String extension = TakeOffExtension(name);
auto extension = TakeOffExtension(name);
// Add _hnType_hnName
name.append("_");
@@ -137,6 +137,20 @@ G4String G4BaseFileManager::GetHnFileName(const G4String& hnType,
return name;
}
//_____________________________________________________________________________
G4String G4BaseFileManager::GetPlotFileName() const
{
G4String name(fFileName);
// Take out file extension
auto extension = TakeOffExtension(name);
// Add .ps extension
name.append(".ps");
return name;
}
//_____________________________________________________________________________
G4String G4BaseFileManager::GetFileType() const
{
+19 -19
View File
@@ -35,15 +35,15 @@ namespace G4Analysis
//_____________________________________________________________________________
G4BinScheme GetBinScheme(const G4String& binSchemeName)
{
G4BinScheme binScheme = kLinearBinScheme;
G4BinScheme binScheme = G4BinScheme::kLinear;
if ( binSchemeName != "linear" ) {
if ( binSchemeName == "log" )
binScheme = kLogBinScheme;
binScheme = G4BinScheme::kLog;
else {
// There is no name associated with kUserBinScheme
// There is no name associated with G4BinScheme::kUser
G4ExceptionDescription description;
description
<< " \"" << binScheme << "\" binning scheme is not supported." << G4endl
<< " \"" << binSchemeName << "\" binning scheme is not supported." << G4endl
<< " " << "Linear binning will be applied.";
G4Exception("G4Analysis::GetBinScheme",
"Analysis_W013", JustWarning, description);
@@ -60,29 +60,29 @@ void ComputeEdges(G4int nbins, G4double xmin, G4double xmax,
// Compute edges from parameters
// Apply units
G4double xumin = xmin/unit;
G4double xumax = xmax/unit;
auto xumin = xmin/unit;
auto xumax = xmax/unit;
if ( binScheme == kLinearBinScheme ) {
G4double dx = (fcn(xumax) - fcn(xumin) ) / nbins;
G4double binValue = fcn(xumin);
while ( G4int(edges.size()) <= nbins ) {
if ( binScheme == G4BinScheme::kLinear ) {
auto dx = (fcn(xumax) - fcn(xumin) ) / nbins;
auto binValue = fcn(xumin);
while ( G4int(edges.size()) <= nbins ) { // Loop checking, 23.06.2015, I. Hrivnacova
edges.push_back(binValue);
binValue += dx;
}
}
else if ( binScheme == kLogBinScheme ) {
else if ( binScheme == G4BinScheme::kLog ) {
// do not apply fcn
G4double dlog
auto dlog
= (std::log10(xumax) - std::log10(xumin))/ nbins;
G4double dx = std::pow(10, dlog);
G4double binValue = xumin;
while ( G4int(edges.size()) <= nbins ) {
auto dx = std::pow(10, dlog);
auto binValue = xumin;
while ( G4int(edges.size()) <= nbins ) { // Loop checking, 23.06.2015, I. Hrivnacova
edges.push_back(binValue);
binValue *= dx;
}
}
else if ( binScheme == kUserBinScheme ) {
else if ( binScheme == G4BinScheme::kUser ) {
// This should never happen, but let's make sure about it
// by issuing a warning
G4ExceptionDescription description;
@@ -100,9 +100,9 @@ void ComputeEdges(const std::vector<G4double>& edges,
std::vector<G4double>& newBins)
{
// Apply function to defined edges
std::vector<G4double>::const_iterator it;
for (it = edges.begin(); it != edges.end(); it++ ) {
newBins.push_back(fcn((*it)/unit));
for (auto element : edges) {
newBins.push_back(fcn(element/unit));
}
}
@@ -29,29 +29,32 @@
#include "G4FileMessenger.hh"
#include "G4VAnalysisManager.hh"
#include "G4AnalysisUtilities.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
using namespace G4Analysis;
//_____________________________________________________________________________
G4FileMessenger::G4FileMessenger(G4VAnalysisManager* manager)
: G4UImessenger(),
fManager(manager),
fSetFileNameCmd(0),
fSetHistoDirNameCmd(0),
fSetNtupleDirNameCmd(0)
fSetFileNameCmd(nullptr),
fSetHistoDirNameCmd(nullptr),
fSetNtupleDirNameCmd(nullptr)
{
fSetFileNameCmd = new G4UIcmdWithAString("/analysis/setFileName",this);
fSetFileNameCmd = G4Analysis::make_unique<G4UIcmdWithAString>("/analysis/setFileName",this);
fSetFileNameCmd->SetGuidance("Set name for the histograms & ntuple file");
fSetFileNameCmd->SetParameterName("Filename", false);
fSetFileNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSetHistoDirNameCmd = new G4UIcmdWithAString("/analysis/setHistoDirName",this);
fSetHistoDirNameCmd = G4Analysis::make_unique<G4UIcmdWithAString>("/analysis/setHistoDirName",this);
fSetHistoDirNameCmd->SetGuidance("Set name for the histograms directory");
fSetHistoDirNameCmd->SetParameterName("HistoDirName", false);
fSetHistoDirNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSetNtupleDirNameCmd = new G4UIcmdWithAString("/analysis/setNtupleDirName",this);
fSetNtupleDirNameCmd = G4Analysis::make_unique<G4UIcmdWithAString>("/analysis/setNtupleDirName",this);
fSetNtupleDirNameCmd->SetGuidance("Set name for the ntuple directory");
fSetNtupleDirNameCmd->SetParameterName("NtupleDirName", false);
fSetNtupleDirNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
@@ -59,11 +62,7 @@ G4FileMessenger::G4FileMessenger(G4VAnalysisManager* manager)
//_____________________________________________________________________________
G4FileMessenger::~G4FileMessenger()
{
delete fSetFileNameCmd;
delete fSetHistoDirNameCmd;
delete fSetNtupleDirNameCmd;
}
{}
//
// public functions
@@ -71,14 +70,14 @@ G4FileMessenger::~G4FileMessenger()
//_____________________________________________________________________________
void G4FileMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
if ( command == fSetFileNameCmd ) {
if ( command == fSetFileNameCmd.get() ) {
G4cout << "Set file name: " << newValues << G4endl;
fManager->SetFileName(newValues);
}
else if ( command == fSetHistoDirNameCmd ) {
else if ( command == fSetHistoDirNameCmd.get() ) {
fManager->SetHistoDirectoryName(newValues);
}
else if ( command == fSetNtupleDirNameCmd ) {
else if ( command == fSetNtupleDirNameCmd.get() ) {
fManager->SetNtupleDirectoryName(newValues);
}
}
+79 -143
View File
@@ -34,6 +34,7 @@
#include "G4H1Messenger.hh"
#include "G4VAnalysisManager.hh"
#include "G4AnalysisUtilities.hh"
#include "G4AnalysisMessengerHelper.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
@@ -45,53 +46,36 @@
using namespace G4Analysis;
namespace {
void Exception(G4UIcommand* command, G4int nofParameters)
{
G4ExceptionDescription description;
description
<< "Got wrong number of \"" << command->GetCommandName()
<< "\" parameters: " << nofParameters
<< " instead of " << command->GetParameterEntries()
<< " expected" << G4endl;
G4Exception("G4H1Messenger::SetNewValue",
"Analysis_W013", JustWarning, description);
}
}
//_____________________________________________________________________________
G4H1Messenger::G4H1Messenger(G4VAnalysisManager* manager)
: G4UImessenger(),
fManager(manager),
fH1Dir(0),
fCreateH1Cmd(0),
fSetH1Cmd(0),
fSetH1TitleCmd(0),
fSetH1XAxisCmd(0),
fSetH1YAxisCmd(0)
fHelper(nullptr),
fDirectory(nullptr),
fCreateH1Cmd(nullptr),
fSetH1Cmd(nullptr),
fSetH1TitleCmd(nullptr),
fSetH1XAxisCmd(nullptr),
fSetH1YAxisCmd(nullptr)
{
fH1Dir = new G4UIdirectory("/analysis/h1/");
fH1Dir->SetGuidance("1D histograms control");
fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("h1");
fDirectory = fHelper->CreateHnDirectory();
CreateH1Cmd();
SetH1Cmd();
SetH1TitleCmd();
SetH1XAxisCmd();
SetH1YAxisCmd();
fSetH1XCmd = fHelper->CreateSetBinsCommand("x", this);
fSetH1TitleCmd = fHelper->CreateSetTitleCommand(this);
fSetH1XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
fSetH1YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
}
//_____________________________________________________________________________
G4H1Messenger::~G4H1Messenger()
{
delete fCreateH1Cmd;
delete fSetH1Cmd;
delete fSetH1TitleCmd;
delete fSetH1XAxisCmd;
delete fSetH1YAxisCmd;
delete fH1Dir;
}
{}
//
// private functions
@@ -100,32 +84,32 @@ G4H1Messenger::~G4H1Messenger()
//_____________________________________________________________________________
void G4H1Messenger::CreateH1Cmd()
{
G4UIparameter* h1Name = new G4UIparameter("name", 's', false);
auto h1Name = new G4UIparameter("name", 's', false);
h1Name->SetGuidance("Histogram name (label)");
G4UIparameter* h1Title = new G4UIparameter("title", 's', false);
auto h1Title = new G4UIparameter("title", 's', false);
h1Title->SetGuidance("Histogram title");
G4UIparameter* h1Nbins0 = new G4UIparameter("nbins0", 'i', true);
auto h1Nbins0 = new G4UIparameter("nbins0", 'i', true);
h1Nbins0->SetGuidance("Number of bins (default = 100)");
h1Nbins0->SetGuidance("Can be reset with /analysis/h1/set command");
h1Nbins0->SetDefaultValue(100);
G4UIparameter* h1ValMin0 = new G4UIparameter("valMin0", 'd', true);
auto h1ValMin0 = new G4UIparameter("valMin0", 'd', true);
h1ValMin0->SetGuidance("Minimum value, expressed in unit (default = 0.)");
h1ValMin0->SetGuidance("Can be reset with /analysis/h1/set command");
h1ValMin0->SetDefaultValue(0.);
G4UIparameter* h1ValMax0 = new G4UIparameter("valMax0", 'd', true);
auto h1ValMax0 = new G4UIparameter("valMax0", 'd', true);
h1ValMax0->SetGuidance("Maximum value, expressed in unit (default = 1.)");
h1ValMax0->SetGuidance("Can be reset with /analysis/h1/set command");
h1ValMax0->SetDefaultValue(1.);
G4UIparameter* h1ValUnit0 = new G4UIparameter("valUnit0", 's', true);
auto h1ValUnit0 = new G4UIparameter("valUnit0", 's', true);
h1ValUnit0->SetGuidance("The unit applied to filled values and valMin0, valMax0");
h1ValUnit0->SetDefaultValue("none");
G4UIparameter* h1ValFcn0 = new G4UIparameter("valFcn0", 's', true);
auto h1ValFcn0 = new G4UIparameter("valFcn0", 's', true);
G4String fcnGuidance = "The function applied to filled values (log, log10, exp).\n";
fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
fcnGuidance += "but none value should be used instead.";
@@ -133,7 +117,7 @@ void G4H1Messenger::CreateH1Cmd()
h1ValFcn0->SetParameterCandidates("log log10 exp none");
h1ValFcn0->SetDefaultValue("none");
G4UIparameter* h1ValBinScheme0 = new G4UIparameter("valBinScheme0", 's', true);
auto h1ValBinScheme0 = new G4UIparameter("valBinScheme0", 's', true);
G4String binSchemeGuidance = "The binning scheme (linear, log).\n";
h1ValBinScheme0->SetParameterCandidates("linear log");
binSchemeGuidance
@@ -142,7 +126,7 @@ void G4H1Messenger::CreateH1Cmd()
h1ValBinScheme0->SetGuidance(binSchemeGuidance);
h1ValBinScheme0->SetDefaultValue("linear");
fCreateH1Cmd = new G4UIcommand("/analysis/h1/create", this);
fCreateH1Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/h1/create", this);
fCreateH1Cmd->SetGuidance("Create 1D histogram");
fCreateH1Cmd->SetParameter(h1Name);
fCreateH1Cmd->SetParameter(h1Title);
@@ -159,24 +143,24 @@ void G4H1Messenger::CreateH1Cmd()
//_____________________________________________________________________________
void G4H1Messenger::SetH1Cmd()
{
G4UIparameter* h1Id = new G4UIparameter("id", 'i', false);
auto h1Id = new G4UIparameter("id", 'i', false);
h1Id->SetGuidance("Histogram id");
h1Id->SetParameterRange("id>=0");
G4UIparameter* h1Nbins = new G4UIparameter("nbins", 'i', false);
auto h1Nbins = new G4UIparameter("nbins", 'i', false);
h1Nbins->SetGuidance("Number of bins");
G4UIparameter* h1ValMin = new G4UIparameter("valMin", 'd', false);
auto h1ValMin = new G4UIparameter("valMin", 'd', false);
h1ValMin->SetGuidance("Minimum value, expressed in unit");
G4UIparameter* h1ValMax = new G4UIparameter("valMax", 'd', false);
auto h1ValMax = new G4UIparameter("valMax", 'd', false);
h1ValMax->SetGuidance("Maximum value, expressed in unit");
G4UIparameter* h1ValUnit = new G4UIparameter("valUnit", 's', true);
auto h1ValUnit = new G4UIparameter("valUnit", 's', true);
h1ValUnit->SetGuidance("The unit applied to filled values and valMin, valMax");
h1ValUnit->SetDefaultValue("none");
G4UIparameter* h1ValFcn = new G4UIparameter("valFcn", 's', true);
auto h1ValFcn = new G4UIparameter("valFcn", 's', true);
h1ValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnGuidance = "The function applied to filled values (log, log10, exp, none).\n";
fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
@@ -184,7 +168,7 @@ void G4H1Messenger::SetH1Cmd()
h1ValFcn->SetGuidance(fcnGuidance);
h1ValFcn->SetDefaultValue("none");
G4UIparameter* h1ValBinScheme = new G4UIparameter("valBinScheme", 's', true);
auto h1ValBinScheme = new G4UIparameter("valBinScheme", 's', true);
h1ValBinScheme->SetParameterCandidates("linear log");
G4String binSchemeGuidance = "The binning scheme (linear, log).\n";
binSchemeGuidance
@@ -193,8 +177,8 @@ void G4H1Messenger::SetH1Cmd()
h1ValBinScheme->SetGuidance(binSchemeGuidance);
h1ValBinScheme->SetDefaultValue("linear");
fSetH1Cmd = new G4UIcommand("/analysis/h1/set", this);
fSetH1Cmd->SetGuidance("Set parameters for the 1D histogram of #Id :");
fSetH1Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/h1/set", this);
fSetH1Cmd->SetGuidance("Set parameters for the 1D histogram of given id:");
fSetH1Cmd->SetGuidance(" nbins; valMin; valMax; unit; function; binScheme");
fSetH1Cmd->SetParameter(h1Id);
fSetH1Cmd->SetParameter(h1Nbins);
@@ -206,60 +190,6 @@ void G4H1Messenger::SetH1Cmd()
fSetH1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H1Messenger::SetH1TitleCmd()
{
G4UIparameter* h1Id = new G4UIparameter("idTitle", 'i', false);
h1Id->SetGuidance("Histogram id");
h1Id->SetParameterRange("idTitle>=0");
G4UIparameter* h1Title = new G4UIparameter("h1Title", 's', true);
h1Title->SetGuidance("Histogram title");
h1Title->SetDefaultValue("none");
fSetH1TitleCmd = new G4UIcommand("/analysis/h1/setTitle", this);
fSetH1TitleCmd->SetGuidance("Set title for the 1D histogram of #Id");
fSetH1TitleCmd->SetParameter(h1Id);
fSetH1TitleCmd->SetParameter(h1Title);
fSetH1TitleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H1Messenger::SetH1XAxisCmd()
{
G4UIparameter* h1Id = new G4UIparameter("idXaxis", 'i', false);
h1Id->SetGuidance("Histogram id");
h1Id->SetParameterRange("idXaxis>=0");
G4UIparameter* h1XAxis = new G4UIparameter("h1Xaxis", 's', true);
h1XAxis->SetGuidance("Histogram x-axis title");
h1XAxis->SetDefaultValue("none");
fSetH1XAxisCmd = new G4UIcommand("/analysis/h1/setXaxis", this);
fSetH1XAxisCmd->SetGuidance("Set x-axis title for the 1D histogram of #Id");
fSetH1XAxisCmd->SetParameter(h1Id);
fSetH1XAxisCmd->SetParameter(h1XAxis);
fSetH1XAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H1Messenger::SetH1YAxisCmd()
{
G4UIparameter* h1Id = new G4UIparameter("idYaxis", 'i', false);
h1Id->SetGuidance("Histogram id");
h1Id->SetParameterRange("idYaxis>=0");
G4UIparameter* h1YAxis = new G4UIparameter("h1Yaxis", 's', true);
h1YAxis->SetGuidance("Histogram y-axis title");
h1YAxis->SetDefaultValue("none");
fSetH1YAxisCmd = new G4UIcommand("/analysis/h1/setYaxis", this);
fSetH1YAxisCmd->SetGuidance("Set y-axis title for the 1D histogram of #Id");
fSetH1YAxisCmd->SetParameter(h1Id);
fSetH1YAxisCmd->SetParameter(h1YAxis);
fSetH1YAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//
// public functions
//
@@ -273,51 +203,57 @@ void G4H1Messenger::SetNewValue(G4UIcommand* command, G4String newValues)
// check consistency
if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
// Should never happen but let's check anyway for consistency
Exception(command, parameters.size());
fHelper->WarnAboutParameters(command, parameters.size());
return;
}
if ( command == fCreateH1Cmd ) {
G4int counter = 0;
G4String name = parameters[counter++];
G4String title = parameters[counter++];
G4int nbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double vmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double vmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String sunit = parameters[counter++];
G4String sfcn = parameters[counter++];
G4String sbinScheme = parameters[counter++];
G4double unit = GetUnitValue(sunit);
fManager->CreateH1(name, title, nbins, vmin*unit, vmax*unit, sunit, sfcn, sbinScheme);
if ( command == fCreateH1Cmd.get() ) {
auto counter = 0;
auto name = parameters[counter++];
auto title = parameters[counter++];
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto unit = GetUnitValue(xdata.fSunit);
fManager->CreateH1(name, title,
xdata.fNbins, xdata.fVmin*unit, xdata.fVmax*unit,
xdata.fSunit, xdata.fSfcn, xdata.fSbinScheme);
}
else if ( command == fSetH1Cmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4int nbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double vmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double vmax = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4String sunit = parameters[counter++];
G4String sfcn = parameters[counter++];
G4String sbinScheme = parameters[counter++];
G4double unit = GetUnitValue(sunit);
fManager->SetH1(id, nbins, vmin*unit, vmax*unit, sunit, sfcn, sbinScheme);
else if ( command == fSetH1Cmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto unit = GetUnitValue(xdata.fSunit);
fManager->SetH1(id,
xdata.fNbins, xdata.fVmin*unit, xdata.fVmax*unit,
xdata.fSunit, xdata.fSfcn, xdata.fSbinScheme);
}
else if ( command == fSetH1TitleCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String title = parameters[counter++];
else if ( command == fSetH1XCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto unit = GetUnitValue(xdata.fSunit);
fManager->SetH1(id,
xdata.fNbins, xdata.fVmin*unit, xdata.fVmax*unit,
xdata.fSunit, xdata.fSfcn, xdata.fSbinScheme);
}
else if ( command == fSetH1TitleCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto title = parameters[counter++];
fManager->SetH1Title(id, title);
}
else if ( command == fSetH1XAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String xaxis = parameters[counter++];
else if ( command == fSetH1XAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto xaxis = parameters[counter++];
fManager->SetH1XAxisTitle(id, xaxis);
}
else if ( command == fSetH1YAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String yaxis = parameters[counter++];
else if ( command == fSetH1YAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto yaxis = parameters[counter++];
fManager->SetH1YAxisTitle(id, yaxis);
}
}
+124 -197
View File
@@ -39,57 +39,41 @@
using namespace G4Analysis;
namespace {
void Exception(G4UIcommand* command, G4int nofParameters)
{
G4ExceptionDescription description;
description
<< "Got wrong number of \"" << command->GetCommandName()
<< "\" parameters: " << nofParameters
<< " instead of " << command->GetParameterEntries()
<< " expected" << G4endl;
G4Exception("G4H2Messenger::SetNewValue",
"Analysis_W013", JustWarning, description);
}
}
//_____________________________________________________________________________
G4H2Messenger::G4H2Messenger(G4VAnalysisManager* manager)
: G4UImessenger(),
fManager(manager),
fH2Dir(0),
fCreateH2Cmd(0),
fSetH2Cmd(0),
fSetH2TitleCmd(0),
fSetH2XAxisCmd(0),
fSetH2YAxisCmd(0)
fHelper(nullptr),
fDirectory(nullptr),
fCreateH2Cmd(nullptr),
fSetH2Cmd(nullptr),
fSetH2XCmd(nullptr),
fSetH2YCmd(nullptr),
fSetH2TitleCmd(nullptr),
fSetH2XAxisCmd(nullptr),
fSetH2YAxisCmd(nullptr),
fXId(-1),
fXData()
{
fH2Dir = new G4UIdirectory("/analysis/h2/");
fH2Dir->SetGuidance("2D histograms control");
fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("h2");
fDirectory = fHelper->CreateHnDirectory();
CreateH2Cmd();
SetH2Cmd();
fSetH2XCmd = fHelper->CreateSetBinsCommand("x", this);
fSetH2YCmd = fHelper->CreateSetBinsCommand("y", this);
SetH2TitleCmd();
SetH2XAxisCmd();
SetH2YAxisCmd();
SetH2ZAxisCmd();
fSetH2TitleCmd = fHelper->CreateSetTitleCommand(this);
fSetH2XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
fSetH2YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
fSetH2ZAxisCmd = fHelper->CreateSetAxisCommand("z", this);
}
//_____________________________________________________________________________
G4H2Messenger::~G4H2Messenger()
{
delete fCreateH2Cmd;
delete fSetH2Cmd;
delete fSetH2TitleCmd;
delete fSetH2XAxisCmd;
delete fSetH2YAxisCmd;
delete fSetH2ZAxisCmd;
delete fH2Dir;
}
{}
//
// private functions
@@ -98,75 +82,75 @@ G4H2Messenger::~G4H2Messenger()
//_____________________________________________________________________________
void G4H2Messenger::CreateH2Cmd()
{
G4UIparameter* h2Name = new G4UIparameter("name", 's', false);
auto h2Name = new G4UIparameter("name", 's', false);
h2Name->SetGuidance("Histogram name (label)");
G4UIparameter* h2Title = new G4UIparameter("title", 's', false);
auto h2Title = new G4UIparameter("title", 's', false);
h2Title->SetGuidance("Histogram title");
G4UIparameter* h2xNbins0 = new G4UIparameter("xnbins0", 'i', true);
auto h2xNbins0 = new G4UIparameter("xnbins0", 'i', true);
h2xNbins0->SetGuidance("Number of x-bins (default = 100)");
h2xNbins0->SetGuidance("Can be reset with /analysis/h2/set command");
h2xNbins0->SetDefaultValue(100);
G4UIparameter* h2xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
auto h2xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
h2xValMin0->SetGuidance("Minimum x-value, expressed in unit (default = 0.)");
h2xValMin0->SetGuidance("Can be reset with /analysis/h2/set command");
h2xValMin0->SetDefaultValue(0.);
G4UIparameter* h2xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
auto h2xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
h2xValMax0->SetGuidance("Maximum x-value, expressed in unit (default = 1.)");
h2xValMax0->SetGuidance("Can be reset with /analysis/h2/set command");
h2xValMax0->SetDefaultValue(1.);
G4UIparameter* h2xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
auto h2xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
h2xValUnit0->SetGuidance("The unit applied to filled x-values and xvalMin0, xvalMax0");
h2xValUnit0->SetDefaultValue("none");
G4UIparameter* h2xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
auto h2xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).";
h2xValFcn0->SetGuidance(fcnxGuidance);
h2xValFcn0->SetParameterCandidates("log log10 exp none");
h2xValFcn0->SetDefaultValue("none");
G4UIparameter* h2xValBinScheme0 = new G4UIparameter("xvalBinScheme0", 's', true);
auto h2xValBinScheme0 = new G4UIparameter("xvalBinScheme0", 's', true);
G4String xbinSchemeGuidance = "The binning scheme (linear, log).";
h2xValBinScheme0->SetParameterCandidates("linear log");
h2xValBinScheme0->SetGuidance(xbinSchemeGuidance);
h2xValBinScheme0->SetDefaultValue("linear");
G4UIparameter* h2yNbins0 = new G4UIparameter("ynbins0", 'i', true);
auto h2yNbins0 = new G4UIparameter("ynbins0", 'i', true);
h2yNbins0->SetGuidance("Number of y-bins (default = 100)");
h2yNbins0->SetGuidance("Can be reset with /analysis/h2/set command");
h2yNbins0->SetDefaultValue(100);
G4UIparameter* h2yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
auto h2yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
h2yValMin0->SetGuidance("Minimum y-value, expressed in unit (default = 0.)");
h2yValMin0->SetGuidance("Can be reset with /analysis/h2/set command");
h2yValMin0->SetDefaultValue(0.);
G4UIparameter* h2yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
auto h2yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
h2yValMax0->SetGuidance("Maximum y-value, expressed in unit (default = 1.)");
h2yValMax0->SetGuidance("Can be reset with /analysis/h2/set command");
h2yValMax0->SetDefaultValue(1.);
G4UIparameter* h2yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
auto h2yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
h2yValUnit0->SetGuidance("The unit applied to filled y-values and yvalMin0, yvalMax0");
h2yValUnit0->SetDefaultValue("none");
G4UIparameter* h2yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
auto h2yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).";
h2yValFcn0->SetGuidance(fcnyGuidance);
h2yValFcn0->SetParameterCandidates("log log10 exp none");
h2yValFcn0->SetDefaultValue("none");
G4UIparameter* h2yValBinScheme0 = new G4UIparameter("yvalBinScheme0", 's', true);
auto h2yValBinScheme0 = new G4UIparameter("yvalBinScheme0", 's', true);
G4String ybinSchemeGuidance = "The binning scheme (linear, log).";
h2yValBinScheme0->SetParameterCandidates("linear log");
h2yValBinScheme0->SetGuidance(ybinSchemeGuidance);
h2yValBinScheme0->SetDefaultValue("linear");
fCreateH2Cmd = new G4UIcommand("/analysis/h2/create", this);
fCreateH2Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/h2/create", this);
fCreateH2Cmd->SetGuidance("Create 2D histogram");
fCreateH2Cmd->SetParameter(h2Name);
fCreateH2Cmd->SetParameter(h2Title);
@@ -189,62 +173,62 @@ void G4H2Messenger::CreateH2Cmd()
//_____________________________________________________________________________
void G4H2Messenger::SetH2Cmd()
{
G4UIparameter* h2Id = new G4UIparameter("id", 'i', false);
auto h2Id = new G4UIparameter("id", 'i', false);
h2Id->SetGuidance("Histogram id");
h2Id->SetParameterRange("id>=0");
G4UIparameter* h2xNbins = new G4UIparameter("xnbins", 'i', false);
auto h2xNbins = new G4UIparameter("xnbins", 'i', false);
h2xNbins->SetGuidance("Number of x-bins");
G4UIparameter* h2xValMin = new G4UIparameter("xvalMin", 'd', false);
auto h2xValMin = new G4UIparameter("xvalMin", 'd', false);
h2xValMin->SetGuidance("Minimum x-value, expressed in unit");
G4UIparameter* h2xValMax = new G4UIparameter("xvalMax", 'd', false);
auto h2xValMax = new G4UIparameter("xvalMax", 'd', false);
h2xValMax->SetGuidance("Maximum x-value, expressed in unit");
G4UIparameter* h2xValUnit = new G4UIparameter("xvalUnit", 's', false);
auto h2xValUnit = new G4UIparameter("xvalUnit", 's', false);
h2xValUnit->SetGuidance("The unit applied to filled x-values and xvalMin, xvalMax");
h2xValUnit->SetDefaultValue("none");
G4UIparameter* h2xValFcn = new G4UIparameter("xvalFcn", 's', false);
auto h2xValFcn = new G4UIparameter("xvalFcn", 's', false);
h2xValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).";
h2xValFcn->SetGuidance(fcnxGuidance);
h2xValFcn->SetDefaultValue("none");
G4UIparameter* h2xValBinScheme = new G4UIparameter("xvalBinScheme", 's', true);
auto h2xValBinScheme = new G4UIparameter("xvalBinScheme", 's', true);
G4String xbinSchemeGuidance = "The binning scheme (linear, log).";
h2xValBinScheme->SetParameterCandidates("linear log");
h2xValBinScheme->SetGuidance(xbinSchemeGuidance);
h2xValBinScheme->SetDefaultValue("linear");
G4UIparameter* h2yNbins = new G4UIparameter("nybins", 'i', false);
auto h2yNbins = new G4UIparameter("nybins", 'i', false);
h2yNbins->SetGuidance("Number of y-bins");
G4UIparameter* h2yValMin = new G4UIparameter("yvalMin", 'd', false);
auto h2yValMin = new G4UIparameter("yvalMin", 'd', false);
h2yValMin->SetGuidance("Minimum y-value, expressed in unit");
G4UIparameter* h2yValMax = new G4UIparameter("yvalMax", 'd', false);
auto h2yValMax = new G4UIparameter("yvalMax", 'd', false);
h2yValMax->SetGuidance("Maximum y-value, expressed in unit");
G4UIparameter* h2yValUnit = new G4UIparameter("yvalUnit", 's', true);
auto h2yValUnit = new G4UIparameter("yvalUnit", 's', true);
h2yValUnit->SetGuidance("The unit applied to filled y-values and yvalMin, yvalMax");
h2yValUnit->SetDefaultValue("none");
G4UIparameter* h2yValFcn = new G4UIparameter("yvalFcn", 's', false);
auto h2yValFcn = new G4UIparameter("yvalFcn", 's', false);
h2yValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).";
h2yValFcn->SetGuidance(fcnyGuidance);
h2yValFcn->SetDefaultValue("none");
G4UIparameter* h2yValBinScheme = new G4UIparameter("yvalBinScheme", 's', true);
auto h2yValBinScheme = new G4UIparameter("yvalBinScheme", 's', true);
G4String ybinSchemeGuidance = "The binning scheme (linear, log).";
h2yValBinScheme->SetParameterCandidates("linear log");
h2yValBinScheme->SetGuidance(ybinSchemeGuidance);
h2yValBinScheme->SetDefaultValue("linear");
fSetH2Cmd = new G4UIcommand("/analysis/h2/set", this);
fSetH2Cmd->SetGuidance("Set parameters for the 2D histogram of #Id :");
fSetH2Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/h2/set", this);
fSetH2Cmd->SetGuidance("Set parameters for the 2D histogram of given id:");
fSetH2Cmd->SetGuidance(" nxbins; xvalMin; xvalMax; xunit; xfunction; xbinScheme");
fSetH2Cmd->SetGuidance(" nybins; yvalMin; yvalMax; yunit; yfunction; ybinScheme");
fSetH2Cmd->SetParameter(h2Id);
@@ -263,77 +247,6 @@ void G4H2Messenger::SetH2Cmd()
fSetH2Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H2Messenger::SetH2TitleCmd()
{
G4UIparameter* h2Id = new G4UIparameter("idTitle", 'i', false);
h2Id->SetGuidance("Histogram id");
h2Id->SetParameterRange("idTitle>=0");
G4UIparameter* h2Title = new G4UIparameter("h2Title", 's', true);
h2Title->SetGuidance("Histogram title");
h2Title->SetDefaultValue("none");
fSetH2TitleCmd = new G4UIcommand("/analysis/h2/setTitle", this);
fSetH2TitleCmd->SetGuidance("Set title for the 2D histogram of #Id");
fSetH2TitleCmd->SetParameter(h2Id);
fSetH2TitleCmd->SetParameter(h2Title);
fSetH2TitleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H2Messenger::SetH2XAxisCmd()
{
G4UIparameter* h2Id = new G4UIparameter("idXaxis", 'i', false);
h2Id->SetGuidance("Histogram id");
h2Id->SetParameterRange("idXaxis>=0");
G4UIparameter* h2XAxis = new G4UIparameter("h2Xaxis", 's', true);
h2XAxis->SetGuidance("Histogram x-axis title");
h2XAxis->SetDefaultValue("none");
fSetH2XAxisCmd = new G4UIcommand("/analysis/h2/setXaxis", this);
fSetH2XAxisCmd->SetGuidance("Set x-axis title for the 2D histogram of #Id");
fSetH2XAxisCmd->SetParameter(h2Id);
fSetH2XAxisCmd->SetParameter(h2XAxis);
fSetH2XAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H2Messenger::SetH2YAxisCmd()
{
G4UIparameter* h2Id = new G4UIparameter("idYaxis", 'i', false);
h2Id->SetGuidance("Histogram id");
h2Id->SetParameterRange("idYaxis>=0");
G4UIparameter* h2YAxis = new G4UIparameter("h2Yaxis", 's', true);
h2YAxis->SetGuidance("Histogram y-axis title");
h2YAxis->SetDefaultValue("none");
fSetH2YAxisCmd = new G4UIcommand("/analysis/h2/setYaxis", this);
fSetH2YAxisCmd->SetGuidance("Set y-axis title for the 2D histogram of #Id");
fSetH2YAxisCmd->SetParameter(h2Id);
fSetH2YAxisCmd->SetParameter(h2YAxis);
fSetH2YAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H2Messenger::SetH2ZAxisCmd()
{
G4UIparameter* h2Id = new G4UIparameter("idYaxis", 'i', false);
h2Id->SetGuidance("Histogram id");
h2Id->SetParameterRange("idYaxis>=0");
G4UIparameter* h2YAxis = new G4UIparameter("h2Yaxis", 's', true);
h2YAxis->SetGuidance("Histogram y-axis title");
h2YAxis->SetDefaultValue("none");
fSetH2ZAxisCmd = new G4UIcommand("/analysis/h2/setYaxis", this);
fSetH2ZAxisCmd->SetGuidance("Set y-axis title for the 2D histogram of #Id");
fSetH2ZAxisCmd->SetParameter(h2Id);
fSetH2ZAxisCmd->SetParameter(h2YAxis);
fSetH2ZAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//
// public functions
@@ -348,77 +261,91 @@ void G4H2Messenger::SetNewValue(G4UIcommand* command, G4String newValues)
// check consistency
if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
// Should never happen but let's check anyway for consistency
Exception(command, parameters.size());
fHelper->WarnAboutParameters(command, parameters.size());
return;
}
if ( command == fCreateH2Cmd ) {
G4int counter = 0;
G4String name = parameters[counter++];
G4String title = parameters[counter++];
G4int xnbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double xvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double xvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String xsunit = parameters[counter++];
G4String xsfcn = parameters[counter++];
G4String xsbinScheme = parameters[counter++];
G4double xunit = GetUnitValue(xsunit);
G4int ynbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double yvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double yvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String ysunit = parameters[counter++];
G4String ysfcn = parameters[counter++];
G4String ysbinScheme = parameters[counter++];
G4double yunit = GetUnitValue(ysunit);
if ( command == fCreateH2Cmd.get() ) {
auto counter = 0;
auto name = parameters[counter++];
auto title = parameters[counter++];
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto xunit = GetUnitValue(xdata.fSunit);
G4AnalysisMessengerHelper::BinData ydata;
fHelper->GetBinData(ydata, parameters, counter);
auto yunit = GetUnitValue(ydata.fSunit);
fManager->CreateH2(name, title,
xnbins, xvmin*xunit, xvmax*xunit,
ynbins, yvmin*yunit, yvmax*yunit,
xsunit, ysunit, xsfcn, ysfcn, xsbinScheme, ysbinScheme);
xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
xdata.fSunit, ydata.fSunit,
xdata.fSfcn, ydata.fSfcn,
xdata.fSbinScheme, ydata.fSbinScheme);
}
else if ( command == fSetH2Cmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4int xnbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double xvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double xvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String xsunit = parameters[counter++];
G4String xsfcn = parameters[counter++];
G4String xsbinScheme = parameters[counter++];
G4double xunit = GetUnitValue(xsunit);
G4int ynbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double yvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double yvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String ysunit = parameters[counter++];
G4String ysfcn = parameters[counter++];
G4String ysbinScheme = parameters[counter++];
G4double yunit = GetUnitValue(ysunit);
else if ( command == fSetH2Cmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto xunit = GetUnitValue(xdata.fSunit);
G4AnalysisMessengerHelper::BinData ydata;
fHelper->GetBinData(ydata, parameters, counter);
auto yunit = GetUnitValue(ydata.fSunit);
fManager->SetH2(id,
xnbins, xvmin*xunit, xvmax*xunit,
ynbins, yvmin*yunit, yvmax*yunit,
xsunit, ysunit, xsfcn, ysfcn, xsbinScheme, ysbinScheme);
xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
xdata.fSunit, ydata.fSunit,
xdata.fSfcn, ydata.fSfcn,
xdata.fSbinScheme, ydata.fSbinScheme);
}
else if ( command == fSetH2TitleCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String title = parameters[counter++];
else if ( command == fSetH2XCmd.get() ) {
// Only save values
auto counter = 0;
fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
fHelper->GetBinData(fXData, parameters, counter);
}
else if ( command == fSetH2YCmd.get() ) {
// Check if setX command was called
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
if ( fXId == -1 || fXId != id ) {
fHelper->WarnAboutSetCommands();
return;
}
auto xunit = GetUnitValue(fXData.fSunit);
G4AnalysisMessengerHelper::BinData ydata;
fHelper->GetBinData(ydata, parameters, counter);
auto yunit = GetUnitValue(ydata.fSunit);
fManager->SetH2(id,
fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
fXData.fSunit, ydata.fSunit,
fXData.fSfcn, ydata.fSfcn,
fXData.fSbinScheme, ydata.fSbinScheme);
fXId = -1;
}
else if ( command == fSetH2TitleCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto title = parameters[counter++];
fManager->SetH2Title(id, title);
}
else if ( command == fSetH2XAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String xaxis = parameters[counter++];
else if ( command == fSetH2XAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto xaxis = parameters[counter++];
fManager->SetH2XAxisTitle(id, xaxis);
}
else if ( command == fSetH2YAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String yaxis = parameters[counter++];
else if ( command == fSetH2YAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto yaxis = parameters[counter++];
fManager->SetH2YAxisTitle(id, yaxis);
}
else if ( command == fSetH2ZAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String zaxis = parameters[counter++];
else if ( command == fSetH2ZAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto zaxis = parameters[counter++];
fManager->SetH2ZAxisTitle(id, zaxis);
}
}
+158 -227
View File
@@ -39,57 +39,45 @@
using namespace G4Analysis;
namespace {
void Exception(G4UIcommand* command, G4int nofParameters)
{
G4ExceptionDescription description;
description
<< "Got wrong number of \"" << command->GetCommandName()
<< "\" parameters: " << nofParameters
<< " instead of " << command->GetParameterEntries()
<< " expected" << G4endl;
G4Exception("G4H3Messenger::SetNewValue",
"Analysis_W013", JustWarning, description);
}
}
//_____________________________________________________________________________
G4H3Messenger::G4H3Messenger(G4VAnalysisManager* manager)
: G4UImessenger(),
fManager(manager),
fH3Dir(0),
fCreateH3Cmd(0),
fSetH3Cmd(0),
fSetH3TitleCmd(0),
fSetH3XAxisCmd(0),
fSetH3YAxisCmd(0)
fHelper(nullptr),
fDirectory(nullptr),
fCreateH3Cmd(nullptr),
fSetH3Cmd(nullptr),
fSetH3XCmd(nullptr),
fSetH3YCmd(nullptr),
fSetH3ZCmd(nullptr),
fSetH3TitleCmd(nullptr),
fSetH3XAxisCmd(nullptr),
fSetH3YAxisCmd(nullptr),
fSetH3ZAxisCmd(nullptr),
fXId(-1),
fYId(-1),
fXData(),
fYData()
{
fH3Dir = new G4UIdirectory("/analysis/h3/");
fH3Dir->SetGuidance("3D histograms control");
fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("h3");
fDirectory = fHelper->CreateHnDirectory();
CreateH3Cmd();
SetH3Cmd();
fSetH3XCmd = fHelper->CreateSetBinsCommand("x", this);
fSetH3YCmd = fHelper->CreateSetBinsCommand("y", this);
SetH3TitleCmd();
SetH3XAxisCmd();
SetH3YAxisCmd();
SetH3ZAxisCmd();
fSetH3TitleCmd = fHelper->CreateSetTitleCommand(this);
fSetH3XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
fSetH3YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
fSetH3ZAxisCmd = fHelper->CreateSetAxisCommand("z", this);
}
//_____________________________________________________________________________
G4H3Messenger::~G4H3Messenger()
{
delete fCreateH3Cmd;
delete fSetH3Cmd;
delete fSetH3TitleCmd;
delete fSetH3XAxisCmd;
delete fSetH3YAxisCmd;
delete fSetH3ZAxisCmd;
delete fH3Dir;
}
{}
//
// private functions
@@ -98,106 +86,106 @@ G4H3Messenger::~G4H3Messenger()
//_____________________________________________________________________________
void G4H3Messenger::CreateH3Cmd()
{
G4UIparameter* h3Name = new G4UIparameter("name", 's', false);
auto h3Name = new G4UIparameter("name", 's', false);
h3Name->SetGuidance("Histogram name (label)");
G4UIparameter* h3Title = new G4UIparameter("title", 's', false);
auto h3Title = new G4UIparameter("title", 's', false);
h3Title->SetGuidance("Histogram title");
G4UIparameter* h3xNbins0 = new G4UIparameter("xnbins0", 'i', true);
auto h3xNbins0 = new G4UIparameter("xnbins0", 'i', true);
h3xNbins0->SetGuidance("Number of x-bins (default = 100)");
h3xNbins0->SetGuidance("Can be reset with /analysis/h3/set command");
h3xNbins0->SetDefaultValue(100);
G4UIparameter* h3xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
auto h3xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
h3xValMin0->SetGuidance("Minimum x-value, expressed in unit (default = 0.)");
h3xValMin0->SetGuidance("Can be reset with /analysis/h3/set command");
h3xValMin0->SetDefaultValue(0.);
G4UIparameter* h3xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
auto h3xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
h3xValMax0->SetGuidance("Maximum x-value, expressed in unit (default = 1.)");
h3xValMax0->SetGuidance("Can be reset with /analysis/h3/set command");
h3xValMax0->SetDefaultValue(1.);
G4UIparameter* h3xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
auto h3xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
h3xValUnit0->SetGuidance("The unit applied to filled x-values and xvalMin0, xvalMax0");
h3xValUnit0->SetDefaultValue("none");
G4UIparameter* h3xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
auto h3xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).";
h3xValFcn0->SetGuidance(fcnxGuidance);
h3xValFcn0->SetParameterCandidates("log log10 exp none");
h3xValFcn0->SetDefaultValue("none");
G4UIparameter* h3xValBinScheme0 = new G4UIparameter("xvalBinScheme0", 's', true);
auto h3xValBinScheme0 = new G4UIparameter("xvalBinScheme0", 's', true);
G4String xbinSchemeGuidance = "The binning scheme (linear, log).";
h3xValBinScheme0->SetParameterCandidates("linear log");
h3xValBinScheme0->SetGuidance(xbinSchemeGuidance);
h3xValBinScheme0->SetDefaultValue("linear");
G4UIparameter* h3yNbins0 = new G4UIparameter("ynbins0", 'i', true);
auto h3yNbins0 = new G4UIparameter("ynbins0", 'i', true);
h3yNbins0->SetGuidance("Number of y-bins (default = 100)");
h3yNbins0->SetGuidance("Can be reset with /analysis/h3/set command");
h3yNbins0->SetDefaultValue(100);
G4UIparameter* h3yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
auto h3yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
h3yValMin0->SetGuidance("Minimum y-value, expressed in unit (default = 0.)");
h3yValMin0->SetGuidance("Can be reset with /analysis/h3/set command");
h3yValMin0->SetDefaultValue(0.);
G4UIparameter* h3yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
auto h3yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
h3yValMax0->SetGuidance("Maximum y-value, expressed in unit (default = 1.)");
h3yValMax0->SetGuidance("Can be reset with /analysis/h3/set command");
h3yValMax0->SetDefaultValue(1.);
G4UIparameter* h3yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
auto h3yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
h3yValUnit0->SetGuidance("The unit applied to filled y-values and yvalMin0, yvalMax0");
h3yValUnit0->SetDefaultValue("none");
G4UIparameter* h3yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
auto h3yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).";
h3yValFcn0->SetGuidance(fcnyGuidance);
h3yValFcn0->SetParameterCandidates("log log10 exp none");
h3yValFcn0->SetDefaultValue("none");
G4UIparameter* h3yValBinScheme0 = new G4UIparameter("yvalBinScheme0", 's', true);
auto h3yValBinScheme0 = new G4UIparameter("yvalBinScheme0", 's', true);
G4String ybinSchemeGuidance = "The binning scheme (linear, log).";
h3yValBinScheme0->SetParameterCandidates("linear log");
h3yValBinScheme0->SetGuidance(ybinSchemeGuidance);
h3yValBinScheme0->SetDefaultValue("linear");
G4UIparameter* h3zNbins0 = new G4UIparameter("znbins0", 'i', true);
auto h3zNbins0 = new G4UIparameter("znbins0", 'i', true);
h3zNbins0->SetGuidance("Number of z-bins (default = 100)");
h3zNbins0->SetGuidance("Can be reset with /analysis/h3/set command");
h3zNbins0->SetDefaultValue(100);
G4UIparameter* h3zValMin0 = new G4UIparameter("zvalMin0", 'd', true);
auto h3zValMin0 = new G4UIparameter("zvalMin0", 'd', true);
h3zValMin0->SetGuidance("Minimum z-value, expressed in unit (default = 0.)");
h3zValMin0->SetGuidance("Can be reset with /analysis/h3/set command");
h3zValMin0->SetDefaultValue(0.);
G4UIparameter* h3zValMax0 = new G4UIparameter("zvalMax0", 'd', true);
auto h3zValMax0 = new G4UIparameter("zvalMax0", 'd', true);
h3zValMax0->SetGuidance("Maximum z-value, expressed in unit (default = 1.)");
h3zValMax0->SetGuidance("Can be reset with /analysis/h3/set command");
h3zValMax0->SetDefaultValue(1.);
G4UIparameter* h3zValUnit0 = new G4UIparameter("zvalUnit0", 's', true);
auto h3zValUnit0 = new G4UIparameter("zvalUnit0", 's', true);
h3zValUnit0->SetGuidance("The unit applied to filled z-values and zvalMin0, zvalMax0");
h3zValUnit0->SetDefaultValue("none");
G4UIparameter* h3zValFcn0 = new G4UIparameter("zvalFcn0", 's', true);
auto h3zValFcn0 = new G4UIparameter("zvalFcn0", 's', true);
G4String fcnzGuidance = "The function applied to filled z-values (log, log10, exp, none).";
h3zValFcn0->SetGuidance(fcnzGuidance);
h3zValFcn0->SetParameterCandidates("log log10 exp none");
h3zValFcn0->SetDefaultValue("none");
G4UIparameter* h3zValBinScheme0 = new G4UIparameter("zvalBinScheme0", 's', true);
auto h3zValBinScheme0 = new G4UIparameter("zvalBinScheme0", 's', true);
G4String zbinSchemeGuidance = "The binning scheme (linear, log).";
h3zValBinScheme0->SetParameterCandidates("linear log");
h3zValBinScheme0->SetGuidance(zbinSchemeGuidance);
h3zValBinScheme0->SetDefaultValue("linear");
fCreateH3Cmd = new G4UIcommand("/analysis/h3/create", this);
fCreateH3Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/h3/create", this);
fCreateH3Cmd->SetGuidance("Create 3D histogram");
fCreateH3Cmd->SetParameter(h3Name);
fCreateH3Cmd->SetParameter(h3Title);
@@ -226,87 +214,87 @@ void G4H3Messenger::CreateH3Cmd()
//_____________________________________________________________________________
void G4H3Messenger::SetH3Cmd()
{
G4UIparameter* h3Id = new G4UIparameter("id", 'i', false);
auto h3Id = new G4UIparameter("id", 'i', false);
h3Id->SetGuidance("Histogram id");
h3Id->SetParameterRange("id>=0");
G4UIparameter* h3xNbins = new G4UIparameter("xnbins", 'i', false);
auto h3xNbins = new G4UIparameter("xnbins", 'i', false);
h3xNbins->SetGuidance("Number of x-bins");
G4UIparameter* h3xValMin = new G4UIparameter("xvalMin", 'd', false);
auto h3xValMin = new G4UIparameter("xvalMin", 'd', false);
h3xValMin->SetGuidance("Minimum x-value, expressed in unit");
G4UIparameter* h3xValMax = new G4UIparameter("xvalMax", 'd', false);
auto h3xValMax = new G4UIparameter("xvalMax", 'd', false);
h3xValMax->SetGuidance("Maximum x-value, expressed in unit");
G4UIparameter* h3xValUnit = new G4UIparameter("xvalUnit", 's', false);
auto h3xValUnit = new G4UIparameter("xvalUnit", 's', false);
h3xValUnit->SetGuidance("The unit applied to filled x-values and xvalMin0, xvalMax0");
h3xValUnit->SetDefaultValue("none");
G4UIparameter* h3xValFcn = new G4UIparameter("xvalFcn", 's', false);
auto h3xValFcn = new G4UIparameter("xvalFcn", 's', false);
h3xValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).";
h3xValFcn->SetGuidance(fcnxGuidance);
h3xValFcn->SetDefaultValue("none");
G4UIparameter* h3xValBinScheme = new G4UIparameter("xvalBinScheme", 's', true);
auto h3xValBinScheme = new G4UIparameter("xvalBinScheme", 's', true);
G4String xbinSchemeGuidance = "The binning scheme (linear, log).";
h3xValBinScheme->SetParameterCandidates("linear log");
h3xValBinScheme->SetGuidance(xbinSchemeGuidance);
h3xValBinScheme->SetDefaultValue("linear");
G4UIparameter* h3yNbins = new G4UIparameter("nybins", 'i', false);
auto h3yNbins = new G4UIparameter("nybins", 'i', false);
h3yNbins->SetGuidance("Number of y-bins");
G4UIparameter* h3yValMin = new G4UIparameter("yvalMin", 'd', false);
auto h3yValMin = new G4UIparameter("yvalMin", 'd', false);
h3yValMin->SetGuidance("Minimum y-value, expressed in unit");
G4UIparameter* h3yValMax = new G4UIparameter("yvalMax", 'd', false);
auto h3yValMax = new G4UIparameter("yvalMax", 'd', false);
h3yValMax->SetGuidance("Maximum y-value, expressed in unit");
G4UIparameter* h3yValUnit = new G4UIparameter("yvalUnit", 's', true);
auto h3yValUnit = new G4UIparameter("yvalUnit", 's', true);
h3yValUnit->SetGuidance("The unit applied to filled y-values and yvalMin0, yvalMax0");
h3yValUnit->SetDefaultValue("none");
G4UIparameter* h3yValFcn = new G4UIparameter("yvalFcn", 's', false);
auto h3yValFcn = new G4UIparameter("yvalFcn", 's', false);
h3yValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).";
h3yValFcn->SetGuidance(fcnyGuidance);
h3yValFcn->SetDefaultValue("none");
G4UIparameter* h3yValBinScheme = new G4UIparameter("yvalBinScheme", 's', true);
auto h3yValBinScheme = new G4UIparameter("yvalBinScheme", 's', true);
G4String ybinSchemeGuidance = "The binning scheme (linear, log).";
h3yValBinScheme->SetParameterCandidates("linear log");
h3yValBinScheme->SetGuidance(ybinSchemeGuidance);
h3yValBinScheme->SetDefaultValue("linear");
G4UIparameter* h3zNbins = new G4UIparameter("nzbins", 'i', false);
auto h3zNbins = new G4UIparameter("nzbins", 'i', false);
h3zNbins->SetGuidance("Number of z-bins");
G4UIparameter* h3zValMin = new G4UIparameter("zvalMin", 'd', false);
auto h3zValMin = new G4UIparameter("zvalMin", 'd', false);
h3zValMin->SetGuidance("Minimum z-value, expressed in unit");
G4UIparameter* h3zValMax = new G4UIparameter("zvalMax", 'd', false);
auto h3zValMax = new G4UIparameter("zvalMax", 'd', false);
h3zValMax->SetGuidance("Maximum z-value, expressed in unit");
G4UIparameter* h3zValUnit = new G4UIparameter("zvalUnit", 's', true);
auto h3zValUnit = new G4UIparameter("zvalUnit", 's', true);
h3zValUnit->SetGuidance("The unit applied to filled z-values and zvalMin0, zvalMax0");
h3zValUnit->SetDefaultValue("none");
G4UIparameter* h3zValFcn = new G4UIparameter("zvalFcn", 's', false);
auto h3zValFcn = new G4UIparameter("zvalFcn", 's', false);
h3zValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnzGuidance = "The function applied to filled z-values (log, log10, exp, none).";
h3zValFcn->SetGuidance(fcnzGuidance);
h3zValFcn->SetDefaultValue("none");
G4UIparameter* h3zValBinScheme = new G4UIparameter("zvalBinScheme", 's', true);
auto h3zValBinScheme = new G4UIparameter("zvalBinScheme", 's', true);
G4String zbinSchemeGuidance = "The binning scheme (linear, log).";
h3zValBinScheme->SetParameterCandidates("linear log");
h3zValBinScheme->SetGuidance(zbinSchemeGuidance);
h3zValBinScheme->SetDefaultValue("linear");
fSetH3Cmd = new G4UIcommand("/analysis/h3/set", this);
fSetH3Cmd->SetGuidance("Set parameters for the 3D histogram of #Id :");
fSetH3Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/h3/set", this);
fSetH3Cmd->SetGuidance("Set parameters for the 3D histogram of given id:");
fSetH3Cmd->SetGuidance(" nxbins; xvalMin; xvalMax; xunit; xfunction; xbinScheme");
fSetH3Cmd->SetGuidance(" nybins; yvalMin; yvalMax; yunit; yfunction; ybinScheme");
fSetH3Cmd->SetGuidance(" nzbins; zvalMin; zvalMax; zunit; zfunction; zbinScheme");
@@ -332,77 +320,6 @@ void G4H3Messenger::SetH3Cmd()
fSetH3Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H3Messenger::SetH3TitleCmd()
{
G4UIparameter* h3Id = new G4UIparameter("idTitle", 'i', false);
h3Id->SetGuidance("Histogram id");
h3Id->SetParameterRange("idTitle>=0");
G4UIparameter* h3Title = new G4UIparameter("h3Title", 's', true);
h3Title->SetGuidance("Histogram title");
h3Title->SetDefaultValue("none");
fSetH3TitleCmd = new G4UIcommand("/analysis/h3/setTitle", this);
fSetH3TitleCmd->SetGuidance("Set title for the 3D histogram of #Id");
fSetH3TitleCmd->SetParameter(h3Id);
fSetH3TitleCmd->SetParameter(h3Title);
fSetH3TitleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H3Messenger::SetH3XAxisCmd()
{
G4UIparameter* h3Id = new G4UIparameter("idXaxis", 'i', false);
h3Id->SetGuidance("Histogram id");
h3Id->SetParameterRange("idXaxis>=0");
G4UIparameter* h3XAxis = new G4UIparameter("h3Xaxis", 's', true);
h3XAxis->SetGuidance("Histogram x-axis title");
h3XAxis->SetDefaultValue("none");
fSetH3XAxisCmd = new G4UIcommand("/analysis/h3/setXaxis", this);
fSetH3XAxisCmd->SetGuidance("Set x-axis title for the 3D histogram of #Id");
fSetH3XAxisCmd->SetParameter(h3Id);
fSetH3XAxisCmd->SetParameter(h3XAxis);
fSetH3XAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H3Messenger::SetH3YAxisCmd()
{
G4UIparameter* h3Id = new G4UIparameter("idYaxis", 'i', false);
h3Id->SetGuidance("Histogram id");
h3Id->SetParameterRange("idYaxis>=0");
G4UIparameter* h3YAxis = new G4UIparameter("h3Yaxis", 's', true);
h3YAxis->SetGuidance("Histogram y-axis title");
h3YAxis->SetDefaultValue("none");
fSetH3YAxisCmd = new G4UIcommand("/analysis/h3/setYaxis", this);
fSetH3YAxisCmd->SetGuidance("Set y-axis title for the 3D histogram of #Id");
fSetH3YAxisCmd->SetParameter(h3Id);
fSetH3YAxisCmd->SetParameter(h3YAxis);
fSetH3YAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4H3Messenger::SetH3ZAxisCmd()
{
G4UIparameter* h3Id = new G4UIparameter("idYaxis", 'i', false);
h3Id->SetGuidance("Histogram id");
h3Id->SetParameterRange("idYaxis>=0");
G4UIparameter* h3YAxis = new G4UIparameter("h3Yaxis", 's', true);
h3YAxis->SetGuidance("Histogram y-axis title");
h3YAxis->SetDefaultValue("none");
fSetH3ZAxisCmd = new G4UIcommand("/analysis/h3/setZaxis", this);
fSetH3ZAxisCmd->SetGuidance("Set y-axis title for the 3D histogram of #Id");
fSetH3ZAxisCmd->SetParameter(h3Id);
fSetH3ZAxisCmd->SetParameter(h3YAxis);
fSetH3ZAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//
// public functions
@@ -417,95 +334,109 @@ void G4H3Messenger::SetNewValue(G4UIcommand* command, G4String newValues)
// check consistency
if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
// Should never happen but let's check anyway for consistency
Exception(command, parameters.size());
fHelper->WarnAboutParameters(command, parameters.size());
return;
}
if ( command == fCreateH3Cmd ) {
G4int counter = 0;
G4String name = parameters[counter++];
G4String title = parameters[counter++];
G4int xnbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double xvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double xvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String xsunit = parameters[counter++];
G4String xsfcn = parameters[counter++];
G4String xsbinScheme = parameters[counter++];
G4double xunit = GetUnitValue(xsunit);
G4int ynbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double yvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double yvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String ysunit = parameters[counter++];
G4String ysfcn = parameters[counter++];
G4String ysbinScheme = parameters[counter++];
G4double yunit = GetUnitValue(ysunit);
G4int znbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double zvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double zvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String zsunit = parameters[counter++];
G4String zsfcn = parameters[counter++];
G4String zsbinScheme = parameters[counter++];
G4double zunit = GetUnitValue(zsunit);
if ( command == fCreateH3Cmd.get() ) {
auto counter = 0;
auto name = parameters[counter++];
auto title = parameters[counter++];
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto xunit = GetUnitValue(xdata.fSunit);
G4AnalysisMessengerHelper::BinData ydata;
fHelper->GetBinData(ydata, parameters, counter);
auto yunit = GetUnitValue(ydata.fSunit);
G4AnalysisMessengerHelper::BinData zdata;
fHelper->GetBinData(zdata, parameters, counter);
auto zunit = GetUnitValue(zdata.fSunit);
fManager->CreateH3(name, title,
xnbins, xvmin*xunit, xvmax*xunit,
ynbins, yvmin*yunit, yvmax*yunit,
znbins, zvmin*zunit, zvmax*zunit,
xsunit, ysunit, zsunit, xsfcn, ysfcn, zsfcn,
xsbinScheme, ysbinScheme, zsbinScheme);
xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
zdata.fNbins, zdata.fVmin*zunit, zdata.fVmax*zunit,
xdata.fSunit, ydata.fSunit, zdata.fSunit,
xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
xdata.fSbinScheme, ydata.fSbinScheme, zdata.fSbinScheme);
}
else if ( command == fSetH3Cmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4int xnbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double xvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double xvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String xsunit = parameters[counter++];
G4String xsfcn = parameters[counter++];
G4String xsbinScheme = parameters[counter++];
G4double xunit = GetUnitValue(xsunit);
G4int ynbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double yvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double yvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String ysunit = parameters[counter++];
G4String ysfcn = parameters[counter++];
G4String ysbinScheme = parameters[counter++];
G4double yunit = GetUnitValue(ysunit);
G4int znbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double zvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double zvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String zsunit = parameters[counter++];
G4String zsfcn = parameters[counter++];
G4String zsbinScheme = parameters[counter++];
G4double zunit = GetUnitValue(zsunit);
else if ( command == fSetH3Cmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto xunit = GetUnitValue(xdata.fSunit);
G4AnalysisMessengerHelper::BinData ydata;
fHelper->GetBinData(ydata, parameters, counter);
auto yunit = GetUnitValue(ydata.fSunit);
G4AnalysisMessengerHelper::BinData zdata;
fHelper->GetBinData(zdata, parameters, counter);
auto zunit = GetUnitValue(zdata.fSunit);
fManager->SetH3(id,
xnbins, xvmin*xunit, xvmax*xunit,
ynbins, yvmin*yunit, yvmax*yunit,
znbins, zvmin*zunit, zvmax*zunit,
xsunit, ysunit, zsunit, xsfcn, ysfcn, zsfcn,
xsbinScheme, ysbinScheme, zsbinScheme);
xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
zdata.fNbins, zdata.fVmin*zunit, zdata.fVmax*zunit,
xdata.fSunit, ydata.fSunit, zdata.fSunit,
xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
xdata.fSbinScheme, ydata.fSbinScheme, zdata.fSbinScheme);
}
else if ( command == fSetH3TitleCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String title = parameters[counter++];
else if ( command == fSetH3XCmd.get() ) {
// Only save values
auto counter = 0;
fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
fHelper->GetBinData(fXData, parameters, counter);
}
else if ( command == fSetH3YCmd.get() ) {
// Only save values
auto counter = 0;
fYId = G4UIcommand::ConvertToInt(parameters[counter++]);
fHelper->GetBinData(fYData, parameters, counter);
}
else if ( command == fSetH3ZCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
// Check if setX and setY command was called
if ( fXId == -1 || fXId != id ||
fYId == -1 || fYId != id ) {
fHelper->WarnAboutSetCommands();
return;
}
auto xunit = GetUnitValue(fXData.fSunit);
auto yunit = GetUnitValue(fYData.fSunit);
G4AnalysisMessengerHelper::BinData zdata;
fHelper->GetBinData(zdata, parameters, counter);
auto zunit = GetUnitValue(zdata.fSunit);
fManager->SetH3(id,
fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
fYData.fNbins, fYData.fVmin*yunit, fYData.fVmax*yunit,
zdata.fNbins, zdata.fVmin*zunit, zdata.fVmax*zunit,
fXData.fSunit, fYData.fSunit, zdata.fSunit,
fXData.fSfcn, fYData.fSfcn, zdata.fSfcn,
fXData.fSbinScheme, fYData.fSbinScheme, zdata.fSbinScheme);
fXId = -1;
fYId = -1;
}
else if ( command == fSetH3TitleCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto title = parameters[counter++];
fManager->SetH3Title(id, title);
}
else if ( command == fSetH3XAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String xaxis = parameters[counter++];
else if ( command == fSetH3XAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto xaxis = parameters[counter++];
fManager->SetH3XAxisTitle(id, xaxis);
}
else if ( command == fSetH3YAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String yaxis = parameters[counter++];
else if ( command == fSetH3YAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto yaxis = parameters[counter++];
fManager->SetH3YAxisTitle(id, yaxis);
}
else if ( command == fSetH3ZAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String zaxis = parameters[counter++];
else if ( command == fSetH3ZAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto zaxis = parameters[counter++];
fManager->SetH3ZAxisTitle(id, zaxis);
}
}
+77 -78
View File
@@ -28,6 +28,9 @@
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
#include "G4HnManager.hh"
#include "G4AnalysisUtilities.hh"
using namespace G4Analysis;
//_____________________________________________________________________________
G4HnManager::G4HnManager(const G4String& hnType,
@@ -36,6 +39,7 @@ G4HnManager::G4HnManager(const G4String& hnType,
fHnType(hnType),
fNofActiveObjects(0),
fNofAsciiObjects(0),
fNofPlottingObjects(0),
fHnVector()
{
}
@@ -43,10 +47,9 @@ G4HnManager::G4HnManager(const G4String& hnType,
//_____________________________________________________________________________
G4HnManager::~G4HnManager()
{
std::vector<G4HnInformation*>::iterator it;
for (it = fHnVector.begin(); it != fHnVector.end(); it++ ) {
delete (*it);
}
for ( auto hnInformation : fHnVector ) {
delete hnInformation;
}
}
//
@@ -54,69 +57,13 @@ G4HnManager::~G4HnManager()
//
//_____________________________________________________________________________
void G4HnManager::AddH1Information(const G4String& name,
const G4String& unitName,
const G4String& fcnName,
G4double unit, G4Fcn fcn,
G4BinScheme binScheme)
G4HnInformation* G4HnManager::AddHnInformation(const G4String& name, G4int nofDimensions)
{
G4HnInformation* hnInformation = new G4HnInformation(name, 1);
hnInformation
->AddHnDimensionInformation(
G4HnDimensionInformation(unitName, fcnName, unit, fcn, binScheme));
auto hnInformation = new G4HnInformation(name, nofDimensions);
fHnVector.push_back(hnInformation);
++fNofActiveObjects;
}
//_____________________________________________________________________________
void G4HnManager::AddH2Information(const G4String& name,
const G4String& xunitName,
const G4String& yunitName,
const G4String& xfcnName,
const G4String& yfcnName,
G4double xunit, G4double yunit,
G4Fcn xfcn, G4Fcn yfcn,
G4BinScheme xbinScheme, G4BinScheme ybinScheme)
{
G4HnInformation* hnInformation = new G4HnInformation(name, 2);
hnInformation
->AddHnDimensionInformation(
G4HnDimensionInformation(xunitName, xfcnName, xunit, xfcn, xbinScheme));
hnInformation
->AddHnDimensionInformation(
G4HnDimensionInformation(yunitName, yfcnName, yunit, yfcn, ybinScheme));
fHnVector.push_back(hnInformation);
++fNofActiveObjects;
}
//_____________________________________________________________________________
void G4HnManager::AddH3Information(const G4String& name,
const G4String& xunitName,
const G4String& yunitName,
const G4String& zunitName,
const G4String& xfcnName,
const G4String& yfcnName,
const G4String& zfcnName,
G4double xunit, G4double yunit, G4double zunit,
G4Fcn xfcn, G4Fcn yfcn, G4Fcn zfcn,
G4BinScheme xbinScheme, G4BinScheme ybinScheme,
G4BinScheme zbinScheme)
{
G4HnInformation* hnInformation = new G4HnInformation(name, 3);
hnInformation
->AddHnDimensionInformation(
G4HnDimensionInformation(xunitName, xfcnName, xunit, xfcn, xbinScheme));
hnInformation
->AddHnDimensionInformation(
G4HnDimensionInformation(yunitName, yfcnName, yunit, yfcn, ybinScheme));
hnInformation
->AddHnDimensionInformation(
G4HnDimensionInformation(zunitName, zfcnName, zunit, zfcn, zbinScheme));
fHnVector.push_back(hnInformation);
++fNofActiveObjects;
return hnInformation;
}
//_____________________________________________________________________________
@@ -146,7 +93,7 @@ G4HnDimensionInformation* G4HnManager::GetHnDimensionInformation(G4int id,
G4int dimension,
G4String functionName, G4bool warn) const
{
G4HnInformation* hnInformation = GetHnInformation(id, functionName, warn);
auto hnInformation = GetHnInformation(id, functionName, warn);
if ( ! hnInformation ) return 0;
return hnInformation->GetHnDimensionInformation(dimension);
@@ -164,12 +111,18 @@ G4bool G4HnManager::IsAscii() const
return ( fNofAsciiObjects > 0 );
}
//_____________________________________________________________________________
G4bool G4HnManager::IsPlotting() const
{
return ( fNofPlottingObjects > 0 );
}
//_____________________________________________________________________________
void G4HnManager::SetActivation(G4int id, G4bool activation)
{
// Set activation to a given object
G4HnInformation* info = GetHnInformation(id, "SetActivation");
auto info = GetHnInformation(id, "SetActivation");
if ( ! info ) return;
@@ -189,9 +142,11 @@ void G4HnManager::SetActivation(G4bool activation)
{
// Set activation to all objects of the given type
std::vector<G4HnInformation*>::iterator it;
for ( it = fHnVector.begin(); it != fHnVector.end(); it++ ) {
G4HnInformation* info = *it;
//std::vector<G4HnInformation*>::iterator it;
//for ( it = fHnVector.begin(); it != fHnVector.end(); it++ ) {
// G4HnInformation* info = *it;
for ( auto info : fHnVector ) {
// Do nothing if activation does not change
if ( info->GetActivation() == activation ) continue;
@@ -208,7 +163,7 @@ void G4HnManager::SetActivation(G4bool activation)
//_____________________________________________________________________________
void G4HnManager::SetAscii(G4int id, G4bool ascii)
{
G4HnInformation* info = GetHnInformation(id, "SetAscii");
auto info = GetHnInformation(id, "SetAscii");
if ( ! info ) return;
@@ -223,10 +178,47 @@ void G4HnManager::SetAscii(G4int id, G4bool ascii)
fNofAsciiObjects--;
}
//_____________________________________________________________________________
void G4HnManager::SetPlotting(G4int id, G4bool plotting)
{
auto info = GetHnInformation(id, "SetPlotting");
if ( ! info ) return;
// Do nothing if ascii does not change
if ( info->GetPlotting() == plotting ) return;
// Change Plotting and account it in fNofPlottingObjects
info->SetPlotting(plotting);
if ( plotting )
fNofPlottingObjects++;
else
fNofPlottingObjects--;
}
//_____________________________________________________________________________
void G4HnManager::SetPlotting(G4bool plotting)
{
// Set plotting to all objects of the given type
for ( auto info : fHnVector ) {
// Do nothing if plotting does not change
if ( info->GetPlotting() == plotting ) continue;
// Change plotting and account it in fNofActiveObjects
info->SetPlotting(plotting);
if ( plotting )
fNofPlottingObjects++;
else
fNofPlottingObjects--;
}
}
//_____________________________________________________________________________
G4String G4HnManager::GetName(G4int id) const
{
G4HnInformation* info = GetHnInformation(id, "GetName");
auto info = GetHnInformation(id, "GetName");
if ( ! info ) return "";
@@ -236,8 +228,7 @@ G4String G4HnManager::GetName(G4int id) const
//_____________________________________________________________________________
G4double G4HnManager::GetXUnit(G4int id) const
{
G4HnDimensionInformation* info
= GetHnDimensionInformation(id, G4HnInformation::kX, "GetXUnit");
auto info = GetHnDimensionInformation(id, kX, "GetXUnit");
if ( ! info ) return 1.0;
@@ -247,8 +238,7 @@ G4double G4HnManager::GetXUnit(G4int id) const
//_____________________________________________________________________________
G4double G4HnManager::GetYUnit(G4int id) const
{
G4HnDimensionInformation* info
= GetHnDimensionInformation(id, G4HnInformation::kY, "GetYUnit");
auto info = GetHnDimensionInformation(id, kY, "GetYUnit");
if ( ! info ) return 1.0;
@@ -258,8 +248,7 @@ G4double G4HnManager::GetYUnit(G4int id) const
//_____________________________________________________________________________
G4double G4HnManager::GetZUnit(G4int id) const
{
G4HnDimensionInformation* info
= GetHnDimensionInformation(id, G4HnInformation::kZ, "GetZUnit");
auto info = GetHnDimensionInformation(id, kZ, "GetZUnit");
if ( ! info ) return 1.0;
@@ -269,7 +258,7 @@ G4double G4HnManager::GetZUnit(G4int id) const
//_____________________________________________________________________________
G4bool G4HnManager::GetActivation(G4int id) const
{
G4HnInformation* info = GetHnInformation(id, "GetActivation");
auto info = GetHnInformation(id, "GetActivation");
if ( ! info ) return true;
@@ -279,9 +268,19 @@ G4bool G4HnManager::GetActivation(G4int id) const
//_____________________________________________________________________________
G4bool G4HnManager::GetAscii(G4int id) const
{
G4HnInformation* info = GetHnInformation(id, "GetAscii");
auto info = GetHnInformation(id, "GetAscii");
if ( ! info ) return false;
return info->GetAscii();
}
//_____________________________________________________________________________
G4bool G4HnManager::GetPlotting(G4int id) const
{
auto info = GetHnInformation(id, "GetPlotting");
if ( ! info ) return false;
return info->GetPlotting();
}
+99 -93
View File
@@ -30,113 +30,74 @@
#include "G4HnMessenger.hh"
#include "G4HnManager.hh"
#include "G4AnalysisUtilities.hh"
#include "G4AnalysisMessengerHelper.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithABool.hh"
using namespace G4Analysis;
#include <iostream>
namespace {
void Exception(G4UIcommand* command, G4int nofParameters)
{
G4ExceptionDescription description;
description
<< "Got wrong number of \"" << command->GetCommandName()
<< "\" parameters: " << nofParameters
<< " instead of " << command->GetParameterEntries()
<< " expected" << G4endl;
G4Exception("G4HnMessenger::SetNewValue",
"Analysis_W013", JustWarning, description);
}
}
//_____________________________________________________________________________
G4HnMessenger::G4HnMessenger(G4HnManager* manager)
G4HnMessenger::G4HnMessenger(G4HnManager& manager)
: G4UImessenger(),
fManager(manager),
fSetHnAsciiCmd(0),
fSetHnActivationCmd(0),
fSetHnActivationAllCmd(0)
{
fHelper(nullptr),
fSetHnAsciiCmd(nullptr),
fSetHnActivationCmd(nullptr),
fSetHnActivationAllCmd(nullptr),
fSetHnPlottingCmd(nullptr),
fSetHnPlottingAllCmd(nullptr)
{
G4String hnType = fManager.GetHnType();
hnType.toLower();
fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>(hnType);
SetHnAsciiCmd();
SetHnActivationCmd();
SetHnActivationToAllCmd();
SetHnPlottingCmd();
SetHnPlottingToAllCmd();
}
//_____________________________________________________________________________
G4HnMessenger::~G4HnMessenger()
{
delete fSetHnAsciiCmd;
delete fSetHnActivationCmd;
delete fSetHnActivationAllCmd;
}
{}
//
// private functions
//
//_____________________________________________________________________________
G4String G4HnMessenger::GetCmdDirectoryName() const
{
G4String hnType = fManager->GetHnType();
hnType.toLower();
G4String name("/analysis/");
name.append(hnType);
name.append("/");
return name;
}
//_____________________________________________________________________________
G4String G4HnMessenger::GetHnDescription() const
{
G4String hnDescription = fManager->GetHnType();
hnDescription.erase(0);
hnDescription.append("D");
return hnDescription;
}
//_____________________________________________________________________________
void G4HnMessenger::SetHnAsciiCmd()
{
G4String name = GetCmdDirectoryName();
name.append("setAscii");
fSetHnAsciiCmd = new G4UIcmdWithAnInteger(name, this);
fSetHnAsciiCmd
= G4Analysis::make_unique<G4UIcmdWithAnInteger>(fHelper->Update("/analysis/HNTYPE_/setAscii"), this);
fSetHnAsciiCmd->SetGuidance(
fHelper->Update("Print NDIM_D LOBJECT of given id on ascii file."));
G4String guidance("Print ");
guidance.append(GetHnDescription());
guidance.append(" histogram of #Id on ascii file.");
fSetHnAsciiCmd->SetGuidance(guidance);
fSetHnAsciiCmd->SetParameterName("Id",false);
fSetHnAsciiCmd->SetRange("Id>=0");
fSetHnAsciiCmd->SetParameterName("id",false);
fSetHnAsciiCmd->SetRange("id>=0");
fSetHnAsciiCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4HnMessenger::SetHnActivationCmd()
{
G4UIparameter* hnId = new G4UIparameter("idActivation", 'i', false);
hnId->SetGuidance("Histogram id");
hnId->SetParameterRange("idActivation>=0");
auto hnId = new G4UIparameter("id", 'i', false);
hnId->SetGuidance(fHelper->Update("OBJECT id"));
hnId->SetParameterRange("id>=0");
G4UIparameter* hnActivation = new G4UIparameter("hnActivation", 's', true);
hnActivation->SetGuidance("Histogram activation");
auto hnActivation = new G4UIparameter("hnActivation", 's', true);
hnActivation->SetGuidance(fHelper->Update("OBJECT activation"));
hnActivation->SetDefaultValue("none");
G4String name = GetCmdDirectoryName();
name.append("setActivation");
fSetHnActivationCmd = new G4UIcommand(name, this);
G4String guidance("Set activation for the ");
guidance.append(GetHnDescription());
guidance.append(" histogram of #Id");
fSetHnActivationCmd->SetGuidance(guidance);
fSetHnActivationCmd
= G4Analysis::make_unique<G4UIcommand>(fHelper->Update("/analysis/HNTYPE_/setActivation"), this);
fSetHnActivationCmd->SetGuidance(
fHelper->Update("Set activation for the NDIM_D LOBJECT of given id"));
fSetHnActivationCmd->SetParameter(hnId);
fSetHnActivationCmd->SetParameter(hnActivation);
fSetHnActivationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
@@ -145,18 +106,43 @@ void G4HnMessenger::SetHnActivationCmd()
//_____________________________________________________________________________
void G4HnMessenger::SetHnActivationToAllCmd()
{
G4String name = GetCmdDirectoryName();
name.append("setActivationToAll");
fSetHnActivationAllCmd = new G4UIcmdWithABool(name, this);
G4String guidance("Set activation to all ");
guidance.append(GetHnDescription());
guidance.append(" histograms.");
fSetHnActivationAllCmd->SetGuidance(guidance);
fSetHnActivationAllCmd
= G4Analysis::make_unique<G4UIcmdWithABool>(fHelper->Update("/analysis/HNTYPE_/setActivationToAll"), this);
fSetHnActivationAllCmd->SetGuidance(
fHelper->Update("Set activation to all NDIM_D LOBJECTs"));
fSetHnActivationAllCmd->SetParameterName("Activation",false);
}
//_____________________________________________________________________________
void G4HnMessenger::SetHnPlottingCmd()
{
auto hnId = new G4UIparameter("id", 'i', false);
hnId->SetGuidance(fHelper->Update("OBJECT id"));
hnId->SetParameterRange("id>=0");
auto hnPlotting = new G4UIparameter("hnPlotting", 's', true);
hnPlotting->SetGuidance(fHelper->Update("(In)Activate OBJECT plotting"));
hnPlotting->SetDefaultValue("none");
fSetHnPlottingCmd
= G4Analysis::make_unique<G4UIcommand>(fHelper->Update("/analysis/HNTYPE_/setPlotting"), this);
fSetHnPlottingCmd->SetGuidance(
fHelper->Update("(In)Activate batch plotting of the NDIM_D LOBJECT of given id"));
fSetHnPlottingCmd->SetParameter(hnId);
fSetHnPlottingCmd->SetParameter(hnPlotting);
fSetHnPlottingCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4HnMessenger::SetHnPlottingToAllCmd()
{
fSetHnPlottingAllCmd
= G4Analysis::make_unique<G4UIcmdWithABool>(fHelper->Update("/analysis/HNTYPE_/setPlottingToAll"), this);
fSetHnPlottingAllCmd->SetGuidance(
fHelper->Update("(In)Activate batch plotting of all NDIM_D LOBJECTs"));
fSetHnPlottingAllCmd->SetParameterName("Plotting",false);
}
//
// public methods
//
@@ -164,28 +150,48 @@ void G4HnMessenger::SetHnActivationToAllCmd()
//_____________________________________________________________________________
void G4HnMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
if ( command == fSetHnAsciiCmd ) {
G4int id = fSetHnAsciiCmd->GetNewIntValue(newValues);
fManager->SetAscii(id, true);
if ( command == fSetHnAsciiCmd.get() ) {
auto id = fSetHnAsciiCmd->GetNewIntValue(newValues);
fManager.SetAscii(id, true);
}
else if ( command == fSetHnActivationCmd ) {
else if ( command == fSetHnActivationCmd.get() ) {
// tokenize parameters in a vector
std::vector<G4String> parameters;
G4Analysis::Tokenize(newValues, parameters);
// check consistency
if ( G4int(parameters.size()) == command->GetParameterEntries() ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4bool activation = G4UIcommand::ConvertToBool(parameters[counter++]);
fManager->SetActivation(id, activation);
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto activation = G4UIcommand::ConvertToBool(parameters[counter++]);
fManager.SetActivation(id, activation);
}
else {
// Should never happen but let's check anyway for consistency
Exception(command, parameters.size());
fHelper->WarnAboutParameters(command, parameters.size());
}
}
else if ( command == fSetHnActivationAllCmd ) {
G4bool activation = fSetHnActivationAllCmd->GetNewBoolValue(newValues);
fManager->SetActivation(activation);
else if ( command == fSetHnActivationAllCmd.get() ) {
auto activation = fSetHnActivationAllCmd->GetNewBoolValue(newValues);
fManager.SetActivation(activation);
}
else if ( command == fSetHnPlottingCmd.get() ) {
// tokenize parameters in a vector
std::vector<G4String> parameters;
G4Analysis::Tokenize(newValues, parameters);
// check consistency
if ( G4int(parameters.size()) == command->GetParameterEntries() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto activation = G4UIcommand::ConvertToBool(parameters[counter++]);
fManager.SetPlotting(id, activation);
}
else {
// Should never happen but let's check anyway for consistency
fHelper->WarnAboutParameters(command, parameters.size());
}
}
else if ( command == fSetHnPlottingAllCmd.get() ) {
auto activation = fSetHnPlottingAllCmd->GetNewBoolValue(newValues);
fManager.SetPlotting(activation);
}
}
@@ -0,0 +1,127 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// Author: Ivana Hrivnacova, 05/05/2015 (ivana@ipno.in2p3.fr)
#include "G4NtupleMessenger.hh"
#include "G4VAnalysisManager.hh"
#include "G4AnalysisUtilities.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UIcmdWithABool.hh"
#include <iostream>
using namespace G4Analysis;
//_____________________________________________________________________________
G4NtupleMessenger::G4NtupleMessenger(G4VAnalysisManager* manager)
: G4UImessenger(),
fManager(manager),
fSetActivationCmd(nullptr),
fSetActivationAllCmd(nullptr)
{
SetActivationCmd();
SetActivationToAllCmd();
}
//_____________________________________________________________________________
G4NtupleMessenger::~G4NtupleMessenger()
{
}
//
// public functions
//
//_____________________________________________________________________________
void G4NtupleMessenger::SetActivationCmd()
{
auto ntupleId = new G4UIparameter("NtupleId", 'i', false);
ntupleId->SetGuidance("Ntuple id");
ntupleId->SetParameterRange("NtupleId>=0");
auto ntupleActivation = new G4UIparameter("NtupleActivation", 's', true);
ntupleActivation->SetGuidance("Ntuple activation");
ntupleActivation->SetDefaultValue("none");
fSetActivationCmd = G4Analysis::make_unique<G4UIcommand>("/analysis/ntuple/setActivation", this);
G4String guidance("Set activation for the ntuple of given id");
fSetActivationCmd->SetGuidance(guidance);
fSetActivationCmd->SetParameter(ntupleId);
fSetActivationCmd->SetParameter(ntupleActivation);
fSetActivationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4NtupleMessenger::SetActivationToAllCmd()
{
fSetActivationAllCmd
= G4Analysis::make_unique<G4UIcmdWithABool>("/analysis/ntuple/setActivationToAll", this);
G4String guidance("Set activation to all ntuples");
fSetActivationAllCmd->SetGuidance(guidance);
fSetActivationAllCmd->SetParameterName("AllNtupleActivation",false);
}
//
// public methods
//
//_____________________________________________________________________________
void G4NtupleMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
if ( command == fSetActivationCmd.get() ) {
// tokenize parameters in a vector
std::vector<G4String> parameters;
G4Analysis::Tokenize(newValues, parameters);
// check consistency
if ( G4int(parameters.size()) == command->GetParameterEntries() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto activation = G4UIcommand::ConvertToBool(parameters[counter++]);
fManager->SetNtupleActivation(id, activation);
}
else {
// Should never happen but let's check anyway for consistency
G4ExceptionDescription description;
description
<< "Got wrong number of \"" << command->GetCommandName()
<< "\" parameters: " << parameters.size()
<< " instead of " << command->GetParameterEntries()
<< " expected" << G4endl;
G4Exception("G4NtupleMessenger::SetNewValue",
"Analysis_W013", JustWarning, description);
}
}
else if ( command == fSetActivationAllCmd.get() ) {
auto activation = fSetActivationAllCmd->GetNewBoolValue(newValues);
fManager->SetNtupleActivation(activation);
}
}
+113 -167
View File
@@ -39,55 +39,37 @@
using namespace G4Analysis;
namespace {
void Exception(G4UIcommand* command, G4int nofParameters)
{
G4ExceptionDescription description;
description
<< "Got wrong number of \"" << command->GetCommandName()
<< "\" parameters: " << nofParameters
<< " instead of " << command->GetParameterEntries()
<< " expected" << G4endl;
G4Exception("G4P1Messenger::SetNewValue",
"Analysis_W013", JustWarning, description);
}
}
//_____________________________________________________________________________
G4P1Messenger::G4P1Messenger(G4VAnalysisManager* manager)
: G4UImessenger(),
fManager(manager),
fP1Dir(0),
fCreateP1Cmd(0),
fSetP1Cmd(0),
fSetP1TitleCmd(0),
fSetP1XAxisCmd(0),
fSetP1YAxisCmd(0)
fHelper(nullptr),
fDirectory(nullptr),
fCreateP1Cmd(nullptr),
fSetP1Cmd(nullptr),
fSetP1TitleCmd(nullptr),
fSetP1XAxisCmd(nullptr),
fSetP1YAxisCmd(nullptr),
fXData()
{
fP1Dir = new G4UIdirectory("/analysis/p1/");
fP1Dir->SetGuidance("1D profiles control");
fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("p1");
fDirectory = fHelper->CreateHnDirectory();
CreateP1Cmd();
SetP1Cmd();
SetP1TitleCmd();
SetP1XAxisCmd();
SetP1YAxisCmd();
fSetP1XCmd = fHelper->CreateSetBinsCommand("x", this);
fSetP1YCmd = fHelper->CreateSetValuesCommand("y", this);
fSetP1TitleCmd = fHelper->CreateSetTitleCommand(this);
fSetP1XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
fSetP1YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
}
//_____________________________________________________________________________
G4P1Messenger::~G4P1Messenger()
{
delete fCreateP1Cmd;
delete fSetP1Cmd;
delete fSetP1TitleCmd;
delete fSetP1XAxisCmd;
delete fSetP1YAxisCmd;
delete fP1Dir;
}
{}
//
// private functions
@@ -96,32 +78,32 @@ G4P1Messenger::~G4P1Messenger()
//_____________________________________________________________________________
void G4P1Messenger::CreateP1Cmd()
{
G4UIparameter* p1Name = new G4UIparameter("name", 's', false);
auto p1Name = new G4UIparameter("name", 's', false);
p1Name->SetGuidance("Profile name (label)");
G4UIparameter* p1Title = new G4UIparameter("title", 's', false);
auto p1Title = new G4UIparameter("title", 's', false);
p1Title->SetGuidance("Profile title");
G4UIparameter* p1xNbins0 = new G4UIparameter("xnbins0", 'i', true);
auto p1xNbins0 = new G4UIparameter("xnbins0", 'i', true);
p1xNbins0->SetGuidance("Number of x-bins (default = 100)");
p1xNbins0->SetGuidance("Can be reset with /analysis/p1/set command");
p1xNbins0->SetDefaultValue(100);
G4UIparameter* p1xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
auto p1xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
p1xValMin0->SetGuidance("Minimum x-value, expressed in unit (default = 0.)");
p1xValMin0->SetGuidance("Can be reset with /analysis/p1/set command");
p1xValMin0->SetDefaultValue(0.);
G4UIparameter* p1xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
auto p1xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
p1xValMax0->SetGuidance("Maximum x-value, expressed in unit (default = 1.)");
p1xValMax0->SetGuidance("Can be reset with /analysis/p1/set command");
p1xValMax0->SetDefaultValue(1.);
G4UIparameter* p1xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
auto p1xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
p1xValUnit0->SetGuidance("The unit applied to filled x-values and xvalMin0, xvalMax0");
p1xValUnit0->SetDefaultValue("none");
G4UIparameter* p1xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
auto p1xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).\n";
fcnxGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
fcnxGuidance += "but none value should be used insted.";
@@ -129,7 +111,7 @@ void G4P1Messenger::CreateP1Cmd()
p1xValFcn0->SetParameterCandidates("log log10 exp none");
p1xValFcn0->SetDefaultValue("none");
G4UIparameter* p1xValBinScheme0 = new G4UIparameter("xvalBinScheme0", 's', true);
auto p1xValBinScheme0 = new G4UIparameter("xvalBinScheme0", 's', true);
G4String binSchemeGuidance = "The binning scheme (linear, log).\n";
p1xValBinScheme0->SetParameterCandidates("linear log");
binSchemeGuidance
@@ -138,21 +120,21 @@ void G4P1Messenger::CreateP1Cmd()
p1xValBinScheme0->SetGuidance(binSchemeGuidance);
p1xValBinScheme0->SetDefaultValue("linear");
G4UIparameter* p1yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
auto p1yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
p1yValMin0->SetGuidance("Minimum y-value, expressed in unit (default = 0.)");
p1yValMin0->SetGuidance("Can be reset with /analysis/p1/set command");
p1yValMin0->SetDefaultValue(0.);
G4UIparameter* p1yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
auto p1yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
p1yValMax0->SetGuidance("Maximum y-value, expressed in unit (default = 1.)");
p1yValMax0->SetGuidance("Can be reset with /analysis/p1/set command");
p1yValMax0->SetDefaultValue(1.);
G4UIparameter* p1yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
auto p1yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
p1yValUnit0->SetGuidance("The unit applied to filled y-values and yvalMin0, yvalMax0");
p1yValUnit0->SetDefaultValue("none");
G4UIparameter* p1yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
auto p1yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).\n";
fcnyGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
fcnyGuidance += "but none value should be used insted.";
@@ -160,7 +142,7 @@ void G4P1Messenger::CreateP1Cmd()
p1yValFcn0->SetParameterCandidates("log log10 exp none");
p1yValFcn0->SetDefaultValue("none");
fCreateP1Cmd = new G4UIcommand("/analysis/p1/create", this);
fCreateP1Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/p1/create", this);
fCreateP1Cmd->SetGuidance("Create 1D profile");
fCreateP1Cmd->SetParameter(p1Name);
fCreateP1Cmd->SetParameter(p1Title);
@@ -181,24 +163,24 @@ void G4P1Messenger::CreateP1Cmd()
//_____________________________________________________________________________
void G4P1Messenger::SetP1Cmd()
{
G4UIparameter* p1Id = new G4UIparameter("id", 'i', false);
auto p1Id = new G4UIparameter("id", 'i', false);
p1Id->SetGuidance("Profile id");
p1Id->SetParameterRange("id>=0");
G4UIparameter* p1xNbins = new G4UIparameter("xnbins", 'i', false);
auto p1xNbins = new G4UIparameter("xnbins", 'i', false);
p1xNbins->SetGuidance("Number of x-bins");
G4UIparameter* p1xValMin = new G4UIparameter("xvalMin", 'd', false);
auto p1xValMin = new G4UIparameter("xvalMin", 'd', false);
p1xValMin->SetGuidance("Minimum x-value, expressed in unit");
G4UIparameter* p1xValMax = new G4UIparameter("xvalMax", 'd', false);
auto p1xValMax = new G4UIparameter("xvalMax", 'd', false);
p1xValMax->SetGuidance("Maximum x-value, expressed in unit");
G4UIparameter* p1xValUnit = new G4UIparameter("xvalUnit", 's', false);
auto p1xValUnit = new G4UIparameter("xvalUnit", 's', false);
p1xValUnit->SetGuidance("The unit applied to filled x-values and xvalMin0, xvalMax0");
p1xValUnit->SetDefaultValue("none");
G4UIparameter* p1xValFcn = new G4UIparameter("xvalFcn", 's', false);
auto p1xValFcn = new G4UIparameter("xvalFcn", 's', false);
p1xValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).\n";
fcnxGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
@@ -206,7 +188,7 @@ void G4P1Messenger::SetP1Cmd()
p1xValFcn->SetGuidance(fcnxGuidance);
p1xValFcn->SetDefaultValue("none");
G4UIparameter* p1xValBinScheme = new G4UIparameter("xvalBinScheme", 's', true);
auto p1xValBinScheme = new G4UIparameter("xvalBinScheme", 's', true);
G4String binSchemeGuidance = "The binning scheme (linear, log).\n";
p1xValBinScheme->SetParameterCandidates("linear log");
binSchemeGuidance
@@ -215,17 +197,17 @@ void G4P1Messenger::SetP1Cmd()
p1xValBinScheme->SetGuidance(binSchemeGuidance);
p1xValBinScheme->SetDefaultValue("linear");
G4UIparameter* p1yValMin = new G4UIparameter("yvalMin", 'd', false);
auto p1yValMin = new G4UIparameter("yvalMin", 'd', false);
p1yValMin->SetGuidance("Minimum y-value, expressed in unit");
G4UIparameter* p1yValMax = new G4UIparameter("yvalMax", 'd', false);
auto p1yValMax = new G4UIparameter("yvalMax", 'd', false);
p1yValMax->SetGuidance("Maximum y-value, expressed in unit");
G4UIparameter* p1yValUnit = new G4UIparameter("yvalUnit", 's', true);
auto p1yValUnit = new G4UIparameter("yvalUnit", 's', true);
p1yValUnit->SetGuidance("The unit applied to filled y-values and yvalMin0, yvalMax0");
p1yValUnit->SetDefaultValue("none");
G4UIparameter* p1yValFcn = new G4UIparameter("yvalFcn", 's', false);
auto p1yValFcn = new G4UIparameter("yvalFcn", 's', false);
p1yValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).\n";
fcnyGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
@@ -233,8 +215,8 @@ void G4P1Messenger::SetP1Cmd()
p1yValFcn->SetGuidance(fcnyGuidance);
p1yValFcn->SetDefaultValue("none");
fSetP1Cmd = new G4UIcommand("/analysis/p1/set", this);
fSetP1Cmd->SetGuidance("Set parameters for the 1D profile of #Id :");
fSetP1Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/p1/set", this);
fSetP1Cmd->SetGuidance("Set parameters for the 1D profile of given id:");
fSetP1Cmd->SetGuidance(" nbins; xvalMin; xvalMax; xunit; xfunction; xbinScheme");
fSetP1Cmd->SetGuidance(" yvalMin; yvalMax; yunit; yfunction");
fSetP1Cmd->SetParameter(p1Id);
@@ -251,60 +233,6 @@ void G4P1Messenger::SetP1Cmd()
fSetP1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4P1Messenger::SetP1TitleCmd()
{
G4UIparameter* p1Id = new G4UIparameter("idTitle", 'i', false);
p1Id->SetGuidance("Profile id");
p1Id->SetParameterRange("idTitle>=0");
G4UIparameter* p1Title = new G4UIparameter("p1Title", 's', true);
p1Title->SetGuidance("Profile title");
p1Title->SetDefaultValue("none");
fSetP1TitleCmd = new G4UIcommand("/analysis/p1/setTitle", this);
fSetP1TitleCmd->SetGuidance("Set title for the 1D profile of #Id");
fSetP1TitleCmd->SetParameter(p1Id);
fSetP1TitleCmd->SetParameter(p1Title);
fSetP1TitleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4P1Messenger::SetP1XAxisCmd()
{
G4UIparameter* p1Id = new G4UIparameter("idXaxis", 'i', false);
p1Id->SetGuidance("Profile id");
p1Id->SetParameterRange("idXaxis>=0");
G4UIparameter* p1XAxis = new G4UIparameter("p1Xaxis", 's', true);
p1XAxis->SetGuidance("Profile x-axis title");
p1XAxis->SetDefaultValue("none");
fSetP1XAxisCmd = new G4UIcommand("/analysis/p1/setXaxis", this);
fSetP1XAxisCmd->SetGuidance("Set x-axis title for the 1D profile of #Id");
fSetP1XAxisCmd->SetParameter(p1Id);
fSetP1XAxisCmd->SetParameter(p1XAxis);
fSetP1XAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4P1Messenger::SetP1YAxisCmd()
{
G4UIparameter* p1Id = new G4UIparameter("idYaxis", 'i', false);
p1Id->SetGuidance("Profile id");
p1Id->SetParameterRange("idYaxis>=0");
G4UIparameter* p1YAxis = new G4UIparameter("p1Yaxis", 's', true);
p1YAxis->SetGuidance("Profile y-axis title");
p1YAxis->SetDefaultValue("none");
fSetP1YAxisCmd = new G4UIcommand("/analysis/p1/setYaxis", this);
fSetP1YAxisCmd->SetGuidance("Set y-axis title for the 1D profile of #Id");
fSetP1YAxisCmd->SetParameter(p1Id);
fSetP1YAxisCmd->SetParameter(p1YAxis);
fSetP1YAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//
// public functions
//
@@ -318,67 +246,85 @@ void G4P1Messenger::SetNewValue(G4UIcommand* command, G4String newValues)
// check consistency
if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
// Should never happen but let's check anyway for consistency
Exception(command, parameters.size());
fHelper->WarnAboutParameters(command, parameters.size());
return;
}
if ( command == fCreateP1Cmd ) {
G4int counter = 0;
G4String name = parameters[counter++];
G4String title = parameters[counter++];
G4int xnbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double xvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double xvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String xsunit = parameters[counter++];
G4String xsfcn = parameters[counter++];
G4String xsbinScheme = parameters[counter++];
G4double xunit = GetUnitValue(xsunit);
G4double yvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double yvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String ysunit = parameters[counter++];
G4String ysfcn = parameters[counter++];
G4double yunit = GetUnitValue(ysunit);
if ( command == fCreateP1Cmd.get() ) {
auto counter = 0;
auto name = parameters[counter++];
auto title = parameters[counter++];
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto xunit = GetUnitValue(xdata.fSunit);
G4AnalysisMessengerHelper::ValueData ydata;
fHelper->GetValueData(ydata, parameters, counter);
auto yunit = GetUnitValue(ydata.fSunit);
fManager->CreateP1(name, title,
xnbins, xvmin*xunit, xvmax*xunit,
yvmin*yunit, yvmax*yunit,
xsunit, ysunit, xsfcn, ysfcn, xsbinScheme);
xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
ydata.fVmin*yunit, ydata.fVmax*yunit,
xdata.fSunit, ydata.fSunit,
xdata.fSfcn, ydata.fSfcn,
xdata.fSbinScheme);
}
else if ( command == fSetP1Cmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4int xnbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double xvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double xvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String xsunit = parameters[counter++];
G4String xsfcn = parameters[counter++];
G4String xsbinScheme = parameters[counter++];
G4double xunit = GetUnitValue(xsunit);
G4double yvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double yvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String ysunit = parameters[counter++];
G4String ysfcn = parameters[counter++];
G4double yunit = GetUnitValue(ysunit);
else if ( command == fSetP1Cmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto xunit = GetUnitValue(xdata.fSunit);
G4AnalysisMessengerHelper::ValueData ydata;
fHelper->GetValueData(ydata, parameters, counter);
auto yunit = GetUnitValue(ydata.fSunit);
fManager->SetP1(id,
xnbins, xvmin*xunit, xvmax*xunit,
yvmin*yunit, yvmax*yunit,
xsunit, ysunit, xsfcn, ysfcn, xsbinScheme);
xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
ydata.fVmin*yunit, ydata.fVmax*yunit,
xdata.fSunit, ydata.fSunit,
xdata.fSfcn, ydata.fSfcn,
xdata.fSbinScheme);
}
else if ( command == fSetP1TitleCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String title = parameters[counter++];
else if ( command == fSetP1XCmd.get() ) {
// Only save values
auto counter = 0;
fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
fHelper->GetBinData(fXData, parameters, counter);
}
else if ( command == fSetP1YCmd.get() ) {
// Check if setX command was called
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
if ( fXId == -1 || fXId != id ) {
// add exception
return;
}
auto xunit = GetUnitValue(fXData.fSunit);
G4AnalysisMessengerHelper::ValueData ydata;
fHelper->GetValueData(ydata, parameters, counter);
auto yunit = GetUnitValue(ydata.fSunit);
fManager->SetP1(id,
fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
ydata.fVmin*yunit, ydata.fVmax*yunit,
fXData.fSunit, ydata.fSunit,
fXData.fSfcn, ydata.fSfcn,
fXData.fSbinScheme);
fXId = -1;
}
else if ( command == fSetP1TitleCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto title = parameters[counter++];
fManager->SetP1Title(id, title);
}
else if ( command == fSetP1XAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String xaxis = parameters[counter++];
else if ( command == fSetP1XAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto xaxis = parameters[counter++];
fManager->SetP1XAxisTitle(id, xaxis);
}
else if ( command == fSetP1YAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String yaxis = parameters[counter++];
else if ( command == fSetP1YAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto yaxis = parameters[counter++];
fManager->SetP1YAxisTitle(id, yaxis);
}
}
+151 -219
View File
@@ -39,57 +39,41 @@
using namespace G4Analysis;
namespace {
void Exception(G4UIcommand* command, G4int nofParameters)
{
G4ExceptionDescription description;
description
<< "Got wrong number of \"" << command->GetCommandName()
<< "\" parameters: " << nofParameters
<< " instead of " << command->GetParameterEntries()
<< " expected" << G4endl;
G4Exception("G4P2Messenger::SetNewValue",
"Analysis_W013", JustWarning, description);
}
}
//_____________________________________________________________________________
G4P2Messenger::G4P2Messenger(G4VAnalysisManager* manager)
: G4UImessenger(),
fManager(manager),
fP2Dir(0),
fCreateP2Cmd(0),
fSetP2Cmd(0),
fSetP2TitleCmd(0),
fSetP2XAxisCmd(0),
fSetP2YAxisCmd(0)
fHelper(nullptr),
fDirectory(nullptr),
fCreateP2Cmd(nullptr),
fSetP2Cmd(nullptr),
fSetP2XCmd(nullptr),
fSetP2YCmd(nullptr),
fSetP2ZCmd(nullptr),
fSetP2TitleCmd(nullptr),
fSetP2XAxisCmd(nullptr),
fSetP2YAxisCmd(nullptr)
{
fP2Dir = new G4UIdirectory("/analysis/p2/");
fP2Dir->SetGuidance("2D profiles control");
fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("p2");
fDirectory = fHelper->CreateHnDirectory();
CreateP2Cmd();
SetP2Cmd();
SetP2TitleCmd();
SetP2XAxisCmd();
SetP2YAxisCmd();
SetP2ZAxisCmd();
fSetP2XCmd = fHelper->CreateSetBinsCommand("x", this);
fSetP2YCmd = fHelper->CreateSetBinsCommand("y", this);
fSetP2YCmd = fHelper->CreateSetValuesCommand("z", this);
fSetP2TitleCmd = fHelper->CreateSetTitleCommand(this);
fSetP2XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
fSetP2YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
fSetP2ZAxisCmd = fHelper->CreateSetAxisCommand("z", this);
}
//_____________________________________________________________________________
G4P2Messenger::~G4P2Messenger()
{
delete fCreateP2Cmd;
delete fSetP2Cmd;
delete fSetP2TitleCmd;
delete fSetP2XAxisCmd;
delete fSetP2YAxisCmd;
delete fSetP2ZAxisCmd;
delete fP2Dir;
}
{}
//
// private functions
@@ -98,94 +82,94 @@ G4P2Messenger::~G4P2Messenger()
//_____________________________________________________________________________
void G4P2Messenger::CreateP2Cmd()
{
G4UIparameter* p2Name = new G4UIparameter("name", 's', false);
auto p2Name = new G4UIparameter("name", 's', false);
p2Name->SetGuidance("Profile name (label)");
G4UIparameter* p2Title = new G4UIparameter("title", 's', false);
auto p2Title = new G4UIparameter("title", 's', false);
p2Title->SetGuidance("Profile title");
G4UIparameter* p2xNbins0 = new G4UIparameter("xnbins0", 'i', true);
auto p2xNbins0 = new G4UIparameter("xnbins0", 'i', true);
p2xNbins0->SetGuidance("Number of x-bins (default = 100)");
p2xNbins0->SetGuidance("Can be reset with /analysis/p2/set command");
p2xNbins0->SetDefaultValue(100);
G4UIparameter* p2xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
auto p2xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
p2xValMin0->SetGuidance("Minimum x-value, expressed in unit (default = 0.)");
p2xValMin0->SetGuidance("Can be reset with /analysis/p2/set command");
p2xValMin0->SetDefaultValue(0.);
G4UIparameter* p2xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
auto p2xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
p2xValMax0->SetGuidance("Maximum x-value, expressed in unit (default = 1.)");
p2xValMax0->SetGuidance("Can be reset with /analysis/p2/set command");
p2xValMax0->SetDefaultValue(1.);
G4UIparameter* p2xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
auto p2xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
p2xValUnit0->SetGuidance("The unit applied to filled x-values and xvalMin0, xvalMax0");
p2xValUnit0->SetDefaultValue("none");
G4UIparameter* p2xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
auto p2xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).";
p2xValFcn0->SetGuidance(fcnxGuidance);
p2xValFcn0->SetParameterCandidates("log log10 exp none");
p2xValFcn0->SetDefaultValue("none");
G4UIparameter* p2xValBinScheme0 = new G4UIparameter("xvalBinScheme0", 's', true);
auto p2xValBinScheme0 = new G4UIparameter("xvalBinScheme0", 's', true);
G4String binSchemeGuidance = "The binning scheme (linear, log).";
p2xValBinScheme0->SetParameterCandidates("linear log");
p2xValBinScheme0->SetGuidance(binSchemeGuidance);
p2xValBinScheme0->SetDefaultValue("linear");
G4UIparameter* p2yNbins0 = new G4UIparameter("ynbins0", 'i', true);
auto p2yNbins0 = new G4UIparameter("ynbins0", 'i', true);
p2yNbins0->SetGuidance("Number of y-bins (default = 100)");
p2yNbins0->SetGuidance("Can be reset with /analysis/p2/set command");
p2yNbins0->SetDefaultValue(100);
G4UIparameter* p2yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
auto p2yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
p2yValMin0->SetGuidance("Minimum y-value, expressed in unit (default = 0.)");
p2yValMin0->SetGuidance("Can be reset with /analysis/p2/set command");
p2yValMin0->SetDefaultValue(0.);
G4UIparameter* p2yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
auto p2yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
p2yValMax0->SetGuidance("Maximum y-value, expressed in unit (default = 1.)");
p2yValMax0->SetGuidance("Can be reset with /analysis/p2/set command");
p2yValMax0->SetDefaultValue(1.);
G4UIparameter* p2yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
auto p2yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
p2yValUnit0->SetGuidance("The unit applied to filled y-values and yvalMin0, yvalMax0");
p2yValUnit0->SetDefaultValue("none");
G4UIparameter* p2yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
auto p2yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).";
p2yValFcn0->SetGuidance(fcnyGuidance);
p2yValFcn0->SetParameterCandidates("log log10 exp none");
p2yValFcn0->SetDefaultValue("none");
G4UIparameter* p2yValBinScheme0 = new G4UIparameter("yvalBinScheme0", 's', true);
auto p2yValBinScheme0 = new G4UIparameter("yvalBinScheme0", 's', true);
p2yValBinScheme0->SetParameterCandidates("linear log");
p2yValBinScheme0->SetGuidance(binSchemeGuidance);
p2yValBinScheme0->SetDefaultValue("linear");
G4UIparameter* p2zValMin0 = new G4UIparameter("zvalMin0", 'd', true);
auto p2zValMin0 = new G4UIparameter("zvalMin0", 'd', true);
p2zValMin0->SetGuidance("Minimum z-value, expressed in unit (default = 0.)");
p2zValMin0->SetGuidance("Can be reset with /analysis/p2/set command");
p2zValMin0->SetDefaultValue(0.);
G4UIparameter* p2zValMax0 = new G4UIparameter("zvalMax0", 'd', true);
auto p2zValMax0 = new G4UIparameter("zvalMax0", 'd', true);
p2zValMax0->SetGuidance("Maximum z-value, expressed in unit (default = 1.)");
p2zValMax0->SetGuidance("Can be reset with /analysis/p2/set command");
p2zValMax0->SetDefaultValue(1.);
G4UIparameter* p2zValUnit0 = new G4UIparameter("zvalUnit0", 's', true);
auto p2zValUnit0 = new G4UIparameter("zvalUnit0", 's', true);
p2zValUnit0->SetGuidance("The unit applied to filled z-values and zvalMin0, zvalMax0");
p2zValUnit0->SetDefaultValue("none");
G4UIparameter* p2zValFcn0 = new G4UIparameter("zvalFcn0", 's', true);
auto p2zValFcn0 = new G4UIparameter("zvalFcn0", 's', true);
G4String fcnzGuidance = "The function applied to filled z-values (log, log10, exp, none).";
p2zValFcn0->SetGuidance(fcnzGuidance);
p2zValFcn0->SetParameterCandidates("log log10 exp none");
p2zValFcn0->SetDefaultValue("none");
fCreateP2Cmd = new G4UIcommand("/analysis/p2/create", this);
fCreateP2Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/p2/create", this);
fCreateP2Cmd->SetGuidance("Create 2D profile");
fCreateP2Cmd->SetParameter(p2Name);
fCreateP2Cmd->SetParameter(p2Title);
@@ -212,77 +196,77 @@ void G4P2Messenger::CreateP2Cmd()
//_____________________________________________________________________________
void G4P2Messenger::SetP2Cmd()
{
G4UIparameter* p2Id = new G4UIparameter("id", 'i', false);
auto p2Id = new G4UIparameter("id", 'i', false);
p2Id->SetGuidance("Profile id");
p2Id->SetParameterRange("id>=0");
G4UIparameter* p2xNbins = new G4UIparameter("xnbins", 'i', false);
auto p2xNbins = new G4UIparameter("xnbins", 'i', false);
p2xNbins->SetGuidance("Number of x-bins");
G4UIparameter* p2xValMin = new G4UIparameter("xvalMin", 'd', false);
auto p2xValMin = new G4UIparameter("xvalMin", 'd', false);
p2xValMin->SetGuidance("Minimum x-value, expressed in unit");
G4UIparameter* p2xValMax = new G4UIparameter("xvalMax", 'd', false);
auto p2xValMax = new G4UIparameter("xvalMax", 'd', false);
p2xValMax->SetGuidance("Maximum x-value, expressed in unit");
G4UIparameter* p2xValUnit = new G4UIparameter("xvalUnit", 's', false);
auto p2xValUnit = new G4UIparameter("xvalUnit", 's', false);
p2xValUnit->SetGuidance("The unit applied to filled x-values and xvalMin0, xvalMax0");
p2xValUnit->SetDefaultValue("none");
G4UIparameter* p2xValFcn = new G4UIparameter("xvalFcn", 's', false);
auto p2xValFcn = new G4UIparameter("xvalFcn", 's', false);
p2xValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).";
p2xValFcn->SetGuidance(fcnxGuidance);
p2xValFcn->SetDefaultValue("none");
G4UIparameter* p2xValBinScheme = new G4UIparameter("xvalBinScheme", 's', true);
auto p2xValBinScheme = new G4UIparameter("xvalBinScheme", 's', true);
G4String binSchemeGuidance = "The binning scheme (linear, log).";
p2xValBinScheme->SetParameterCandidates("linear log");
p2xValBinScheme->SetGuidance(binSchemeGuidance);
p2xValBinScheme->SetDefaultValue("linear");
G4UIparameter* p2yNbins = new G4UIparameter("nybins", 'i', false);
auto p2yNbins = new G4UIparameter("nybins", 'i', false);
p2yNbins->SetGuidance("Number of y-bins");
G4UIparameter* p2yValMin = new G4UIparameter("yvalMin", 'd', false);
auto p2yValMin = new G4UIparameter("yvalMin", 'd', false);
p2yValMin->SetGuidance("Minimum y-value, expressed in unit");
G4UIparameter* p2yValMax = new G4UIparameter("yvalMax", 'd', false);
auto p2yValMax = new G4UIparameter("yvalMax", 'd', false);
p2yValMax->SetGuidance("Maximum y-value, expressed in unit");
G4UIparameter* p2yValUnit = new G4UIparameter("yvalUnit", 's', true);
auto p2yValUnit = new G4UIparameter("yvalUnit", 's', true);
p2yValUnit->SetGuidance("The unit applied to filled y-values and yvalMin0, yvalMax0");
p2yValUnit->SetDefaultValue("none");
G4UIparameter* p2yValFcn = new G4UIparameter("yvalFcn", 's', false);
auto p2yValFcn = new G4UIparameter("yvalFcn", 's', false);
p2yValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).";
p2yValFcn->SetGuidance(fcnyGuidance);
p2yValFcn->SetDefaultValue("none");
G4UIparameter* p2yValBinScheme = new G4UIparameter("yvalBinScheme", 's', true);
auto p2yValBinScheme = new G4UIparameter("yvalBinScheme", 's', true);
p2yValBinScheme->SetParameterCandidates("linear log");
p2yValBinScheme->SetGuidance(binSchemeGuidance);
p2yValBinScheme->SetDefaultValue("linear");
G4UIparameter* p2zValMin = new G4UIparameter("zvalMin", 'd', false);
auto p2zValMin = new G4UIparameter("zvalMin", 'd', false);
p2zValMin->SetGuidance("Minimum z-value, expressed in unit");
G4UIparameter* p2zValMax = new G4UIparameter("zvalMax", 'd', false);
auto p2zValMax = new G4UIparameter("zvalMax", 'd', false);
p2zValMax->SetGuidance("Maximum z-value, expressed in unit");
G4UIparameter* p2zValUnit = new G4UIparameter("zvalUnit", 's', true);
auto p2zValUnit = new G4UIparameter("zvalUnit", 's', true);
p2zValUnit->SetGuidance("The unit applied to filled z-values and zvalMin0, zvalMax0");
p2zValUnit->SetDefaultValue("none");
G4UIparameter* p2zValFcn = new G4UIparameter("zvalFcn", 's', false);
auto p2zValFcn = new G4UIparameter("zvalFcn", 's', false);
p2zValFcn->SetParameterCandidates("log log10 exp none");
G4String fcnzGuidance = "The function applied to filled z-values (log, log10, exp, none).";
p2zValFcn->SetGuidance(fcnzGuidance);
p2zValFcn->SetDefaultValue("none");
fSetP2Cmd = new G4UIcommand("/analysis/p2/set", this);
fSetP2Cmd->SetGuidance("Set parameters for the 2D profile of #Id :");
fSetP2Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/p2/set", this);
fSetP2Cmd->SetGuidance("Set parameters for the 2D profile of given id:");
fSetP2Cmd->SetGuidance(" nxbins; xvalMin; xvalMax; xunit; xbinScheme");
fSetP2Cmd->SetGuidance(" nybins; yvalMin; yvalMax; yunit; ybinScheme");
fSetP2Cmd->SetGuidance(" zvalMin; zvalMax; zunit; zfunction");
@@ -306,76 +290,6 @@ void G4P2Messenger::SetP2Cmd()
fSetP2Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4P2Messenger::SetP2TitleCmd()
{
G4UIparameter* p2Id = new G4UIparameter("idTitle", 'i', false);
p2Id->SetGuidance("Profile id");
p2Id->SetParameterRange("idTitle>=0");
G4UIparameter* p2Title = new G4UIparameter("p2Title", 's', true);
p2Title->SetGuidance("Profile title");
p2Title->SetDefaultValue("none");
fSetP2TitleCmd = new G4UIcommand("/analysis/p2/setTitle", this);
fSetP2TitleCmd->SetGuidance("Set title for the 2D profile of #Id");
fSetP2TitleCmd->SetParameter(p2Id);
fSetP2TitleCmd->SetParameter(p2Title);
fSetP2TitleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4P2Messenger::SetP2XAxisCmd()
{
G4UIparameter* p2Id = new G4UIparameter("idXaxis", 'i', false);
p2Id->SetGuidance("Profile id");
p2Id->SetParameterRange("idXaxis>=0");
G4UIparameter* p2XAxis = new G4UIparameter("p2Xaxis", 's', true);
p2XAxis->SetGuidance("Profile x-axis title");
p2XAxis->SetDefaultValue("none");
fSetP2XAxisCmd = new G4UIcommand("/analysis/p2/setXaxis", this);
fSetP2XAxisCmd->SetGuidance("Set x-axis title for the 2D profile of #Id");
fSetP2XAxisCmd->SetParameter(p2Id);
fSetP2XAxisCmd->SetParameter(p2XAxis);
fSetP2XAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4P2Messenger::SetP2YAxisCmd()
{
G4UIparameter* p2Id = new G4UIparameter("idYaxis", 'i', false);
p2Id->SetGuidance("Profile id");
p2Id->SetParameterRange("idYaxis>=0");
G4UIparameter* p2YAxis = new G4UIparameter("p2Yaxis", 's', true);
p2YAxis->SetGuidance("Profile y-axis title");
p2YAxis->SetDefaultValue("none");
fSetP2YAxisCmd = new G4UIcommand("/analysis/p2/setYaxis", this);
fSetP2YAxisCmd->SetGuidance("Set y-axis title for the 2D profile of #Id");
fSetP2YAxisCmd->SetParameter(p2Id);
fSetP2YAxisCmd->SetParameter(p2YAxis);
fSetP2YAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4P2Messenger::SetP2ZAxisCmd()
{
G4UIparameter* p2Id = new G4UIparameter("idZaxis", 'i', false);
p2Id->SetGuidance("Profile id");
p2Id->SetParameterRange("idZaxis>=0");
G4UIparameter* p2ZAxis = new G4UIparameter("p2Zaxis", 's', true);
p2ZAxis->SetGuidance("Profile z-axis title");
p2ZAxis->SetDefaultValue("none");
fSetP2ZAxisCmd = new G4UIcommand("/analysis/p2/setZaxis", this);
fSetP2ZAxisCmd->SetParameter(p2Id);
fSetP2ZAxisCmd->SetParameter(p2ZAxis);
fSetP2ZAxisCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//
// public functions
@@ -390,91 +304,109 @@ void G4P2Messenger::SetNewValue(G4UIcommand* command, G4String newValues)
// check consistency
if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
// Should never happen but let's check anyway for consistency
Exception(command, parameters.size());
fHelper->WarnAboutParameters(command, parameters.size());
return;
}
if ( command == fCreateP2Cmd ) {
G4int counter = 0;
G4String name = parameters[counter++];
G4String title = parameters[counter++];
G4int xnbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double xvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double xvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String xsunit = parameters[counter++];
G4String xsfcn = parameters[counter++];
G4String xsbinScheme = parameters[counter++];
G4double xunit = GetUnitValue(xsunit);
G4int ynbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double yvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double yvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String ysunit = parameters[counter++];
G4String ysfcn = parameters[counter++];
G4String ysbinScheme = parameters[counter++];
G4double yunit = GetUnitValue(ysunit);
G4double zvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double zvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String zsunit = parameters[counter++];
G4String zsfcn = parameters[counter++];
G4double zunit = GetUnitValue(zsunit);
if ( command == fCreateP2Cmd.get() ) {
auto counter = 0;
auto name = parameters[counter++];
auto title = parameters[counter++];
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto xunit = GetUnitValue(xdata.fSunit);
G4AnalysisMessengerHelper::BinData ydata;
fHelper->GetBinData(ydata, parameters, counter);
auto yunit = GetUnitValue(ydata.fSunit);
G4AnalysisMessengerHelper::ValueData zdata;
fHelper->GetValueData(zdata, parameters, counter);
auto zunit = GetUnitValue(zdata.fSunit);
fManager->CreateP2(name, title,
xnbins, xvmin*xunit, xvmax*xunit,
ynbins, yvmin*yunit, yvmax*yunit,
zvmin*zunit, zvmax*zunit,
xsunit, ysunit, zsunit, xsfcn, ysfcn, zsfcn,
xsbinScheme, ysbinScheme);
xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
zdata.fVmin*zunit, zdata.fVmax*zunit,
xdata.fSunit, ydata.fSunit, zdata.fSunit,
xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
xdata.fSbinScheme, ydata.fSbinScheme);
}
else if ( command == fSetP2Cmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4int xnbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double xvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double xvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String xsunit = parameters[counter++];
G4String xsfcn = parameters[counter++];
G4String xsbinScheme = parameters[counter++];
G4double xunit = GetUnitValue(xsunit);
G4int ynbins = G4UIcommand::ConvertToInt(parameters[counter++]);
G4double yvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double yvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String ysunit = parameters[counter++];
G4String ysfcn = parameters[counter++];
G4String ysbinScheme = parameters[counter++];
G4double yunit = GetUnitValue(ysunit);
G4double zvmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
G4double zvmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
G4String zsunit = parameters[counter++];
G4String zsfcn = parameters[counter++];
G4double zunit = GetUnitValue(zsunit);
else if ( command == fSetP2Cmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4AnalysisMessengerHelper::BinData xdata;
fHelper->GetBinData(xdata, parameters, counter);
auto xunit = GetUnitValue(xdata.fSunit);
G4AnalysisMessengerHelper::BinData ydata;
fHelper->GetBinData(ydata, parameters, counter);
auto yunit = GetUnitValue(ydata.fSunit);
G4AnalysisMessengerHelper::ValueData zdata;
fHelper->GetValueData(zdata, parameters, counter);
auto zunit = GetUnitValue(zdata.fSunit);
fManager->SetP2(id,
xnbins, xvmin*xunit, xvmax*xunit,
ynbins, yvmin*yunit, yvmax*yunit,
zvmin*zunit, zvmax*zunit,
xsunit, ysunit, zsunit, xsfcn, ysfcn, zsfcn,
xsbinScheme, ysbinScheme);
xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
zdata.fVmin*zunit, zdata.fVmax*zunit,
xdata.fSunit, ydata.fSunit, zdata.fSunit,
xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
xdata.fSbinScheme, ydata.fSbinScheme);
}
else if ( command == fSetP2TitleCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String title = parameters[counter++];
else if ( command == fSetP2XCmd.get() ) {
// Only save values
auto counter = 0;
fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
fHelper->GetBinData(fXData, parameters, counter);
}
else if ( command == fSetP2YCmd.get() ) {
// Only save values
auto counter = 0;
fYId = G4UIcommand::ConvertToInt(parameters[counter++]);
fHelper->GetBinData(fYData, parameters, counter);
}
else if ( command == fSetP2ZCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
// Check if setX and setY command was called
if ( fXId == -1 || fXId != id ||
fYId == -1 || fYId != id ) {
fHelper->WarnAboutSetCommands();
return;
}
auto xunit = GetUnitValue(fXData.fSunit);
auto yunit = GetUnitValue(fYData.fSunit);
G4AnalysisMessengerHelper::ValueData zdata;
fHelper->GetValueData(zdata, parameters, counter);
auto zunit = GetUnitValue(zdata.fSunit);
fManager->SetP2(id,
fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
fYData.fNbins, fYData.fVmin*yunit, fYData.fVmax*yunit,
zdata.fVmin*zunit, zdata.fVmax*zunit,
fXData.fSunit, fYData.fSunit, zdata.fSunit,
fXData.fSfcn, fYData.fSfcn, zdata.fSfcn,
fXData.fSbinScheme, fYData.fSbinScheme);
fXId = -1;
fYId = -1;
}
else if ( command == fSetP2TitleCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto title = parameters[counter++];
fManager->SetP2Title(id, title);
}
else if ( command == fSetP2XAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String xaxis = parameters[counter++];
else if ( command == fSetP2XAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto xaxis = parameters[counter++];
fManager->SetP2XAxisTitle(id, xaxis);
}
else if ( command == fSetP2YAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String yaxis = parameters[counter++];
else if ( command == fSetP2YAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto yaxis = parameters[counter++];
fManager->SetP2YAxisTitle(id, yaxis);
}
else if ( command == fSetP2ZAxisCmd ) {
G4int counter = 0;
G4int id = G4UIcommand::ConvertToInt(parameters[counter++]);
G4String zaxis = parameters[counter++];
else if ( command == fSetP2ZAxisCmd.get() ) {
auto counter = 0;
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
auto zaxis = parameters[counter++];
fManager->SetP2ZAxisTitle(id, zaxis);
}
}
@@ -0,0 +1,292 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4PlotManager.cc 85314 2014-10-27 14:33:08Z ihrivnac $
// Author: Ivana Hrivnacova, 02/06/2015 (ivana@ipno.in2p3.fr)
#include "G4HnInformation.hh"
#include "G4PlotManager.hh"
#include "G4ios.hh"
#if defined(TOOLS_USE_FREETYPE)
#include <tools/sg/text_freetype>
#include <tools/xml/xml_style>
#include <tools/xml/wrap_viewplot_style>
//inlib/xml/viewplot.style file embeded in an inline function.
namespace {
// from g4tools/test/viewplot.cpp
//_____________________________________________________________________________
void HD_style(tools::sg::plots& a_plots,float a_line_width) {
std::vector<tools::sg::plotter*> plotters;
a_plots.plotters(plotters);
tools_vforcit(tools::sg::plotter*,plotters,it) {
tools::sg::plotter* _plotter = *it;
_plotter->bins_style(0).line_width = a_line_width;
_plotter->inner_frame_style().line_width = a_line_width;
_plotter->grid_style().line_width = a_line_width;
_plotter->x_axis().line_style().width = a_line_width;
_plotter->x_axis().ticks_style().width = a_line_width;
_plotter->y_axis().line_style().width = a_line_width;
_plotter->y_axis().ticks_style().width = a_line_width;
_plotter->z_axis().line_style().width = a_line_width;
_plotter->z_axis().ticks_style().width = a_line_width;
// needed if font is hershey :
_plotter->title_style().line_width = a_line_width;
_plotter->infos_style().line_width = a_line_width;
_plotter->title_box_style().line_width = a_line_width;
_plotter->x_axis().labels_style().line_width = a_line_width;
_plotter->x_axis().mag_style().line_width = a_line_width;
_plotter->x_axis().title_style().line_width = a_line_width;
_plotter->y_axis().labels_style().line_width = a_line_width;
_plotter->y_axis().mag_style().line_width = a_line_width;
_plotter->y_axis().title_style().line_width = a_line_width;
_plotter->z_axis().labels_style().line_width = a_line_width;
_plotter->z_axis().mag_style().line_width = a_line_width;
_plotter->z_axis().title_style().line_width = a_line_width;
}
}
// from g4tools/test/viewplot.cpp
//_____________________________________________________________________________
void regions_style(tools::sg::plots& a_plots,float a_plotter_scale = 1) {
// Rescale some plotter parameters (for example margins) according to the number of regions.
// We assume that these parameters had been set previously according to one plot per page.
// Then this function must be applied after all the styles had been applied (because
// a plotting style may set these parameters).
float ww_wc = a_plots.width;
float wh_wc = a_plots.height;
float rw_wc = ww_wc/a_plots.cols;
float rh_wc = wh_wc/a_plots.rows;
float cooking = 1.2f; //if increased the data area is diminished.
float wfac = (rw_wc/ww_wc)*cooking;
float hfac = (rh_wc/wh_wc)*cooking;
float label_cooking = 1.6f; //if increased the labels are bigger.
if((a_plots.cols.value()>=4)&&(a_plots.cols.value()>a_plots.rows.value())) label_cooking = 0.9f;
float title_cooking = 1.1f; //extra title cooking.
a_plots.plotter_scale = a_plotter_scale;
std::vector<tools::sg::plotter*> plotters;
a_plots.plotters(plotters);
tools_vforcit(tools::sg::plotter*,plotters,it) {
tools::sg::plotter* _plotter = *it;
_plotter->left_margin = _plotter->left_margin * wfac;
_plotter->right_margin = _plotter->right_margin * wfac;
_plotter->bottom_margin = _plotter->bottom_margin * hfac;
_plotter->top_margin = _plotter->top_margin * hfac;
_plotter->x_axis().tick_length = _plotter->x_axis().tick_length * wfac;
_plotter->y_axis().tick_length = _plotter->y_axis().tick_length * hfac;
_plotter->title_to_axis = _plotter->title_to_axis * hfac;
_plotter->title_height = _plotter->title_height * hfac * title_cooking;
_plotter->x_axis().label_height = _plotter->x_axis().label_height * hfac * label_cooking;
_plotter->y_axis().label_height = _plotter->y_axis().label_height * hfac * label_cooking;
}
}
// from g4tools/test/viewplot.cpp
//_____________________________________________________________________________
bool load_embeded_styles(tools::xml::styles& a_styles) {
std::string ss;
unsigned int linen;
const char** lines = viewplot_style(linen);
for(unsigned int index=0;index<linen;index++) {
std::string s = lines[index];
tools::replace(s,"@@double_quote@@","\"");
tools::replace(s,"@@back_slash@@","\\");
ss += s + "\n";
}
return tools::xml::load_style_string(a_styles,ss);
}
}
#endif
//
// static data
//
//_____________________________________________________________________________
G4PlotParameters G4PlotManager::fgPlotParameters;
//
// ctors, dtor
//
//_____________________________________________________________________________
G4PlotManager::G4PlotManager(const G4AnalysisManagerState& state)
: fState(state),
fViewer(nullptr),
fFileName()
{
#if defined(TOOLS_USE_FREETYPE)
//////////////////////////////////////////////////////////////////////////////
/// plotting, high resolution with freetype fonts and by using styles : //////
//////////////////////////////////////////////////////////////////////////////
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
G4cout << "... using high resolution with Freetype fonts" << G4endl;
#endif
//Have vertical A4 :
// unsigned int ww = 2000; //to have better antialising on freetype fonts.
// float A4 = 29.7f/21.0f;
// unsigned int wh = (unsigned int)(float(ww)*A4*0.80);
static tools::sg::text_freetype ttf;
fViewer.reset(new tools::viewplot(G4cout, ttf,
fgPlotParameters.GetColumns(),
fgPlotParameters.GetRows(),
fgPlotParameters.GetWidth(),
fgPlotParameters.GetHeight()));
fViewer->plots().view_border = false;
load_embeded_styles(fViewer->styles());
fViewer->styles().add_colormap("default",tools::sg::style_default_colormap());
fViewer->styles().add_colormap("ROOT",tools::sg::style_ROOT_colormap());
#else
// cretae a viewer with default parameters
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
G4cout << "... using low resolution with Hershey fonts" << G4endl;
#endif
fViewer.reset(new tools::viewplot(G4cout,
fgPlotParameters.GetColumns(),
fgPlotParameters.GetRows(),
fgPlotParameters.GetWidth(),
fgPlotParameters.GetHeight()));
fViewer->plots().view_border = false;
#endif
}
//_____________________________________________________________________________
G4PlotManager::~G4PlotManager()
{}
//
// private methods
//
//_____________________________________________________________________________
G4bool G4PlotManager::WritePage()
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("write a page in", "plot file", fFileName);
#endif
#if defined(TOOLS_USE_FREETYPE)
HD_style(fViewer->plots(), 5);
regions_style(fViewer->plots(), fgPlotParameters.GetScale());
#endif
G4bool result = fViewer->write_page();
if ( ! result ) {
G4ExceptionDescription description;
description << " " << "Cannot write a page in the plot file " << fFileName;
G4Exception("G4PlotManager::WritePage()",
"Analysis_W022", JustWarning, description);
}
// clear viewers plots
fViewer->plots().init_sg();
//it will recreate the sg::plotters and then reset the styles on new ones.
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() )
fState.GetVerboseL3()->Message("write a page in", "plot file", fFileName);
#endif
return result;
}
//
// public methods
//
//_____________________________________________________________________________
G4bool G4PlotManager::OpenFile(const G4String& fileName)
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("open", "plot file", fileName);
#endif
// Keep filename for logging
fFileName = fileName;
G4bool result = fViewer->open_file(fileName);
if ( ! result ) {
G4ExceptionDescription description;
description << " " << "Cannot open plot file " << fileName;
G4Exception("G4PlotManager::OpenFile()",
"Analysis_W001", JustWarning, description);
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()->Message("open", "plot file", fileName);
#endif
return result;
}
//_____________________________________________________________________________
G4bool G4PlotManager::CloseFile()
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("close", "plot file", fFileName);
#endif
G4bool result = fViewer->close_file();
if ( ! result ) {
G4ExceptionDescription description;
description << " " << "Cannot close the plot file.";
G4Exception("G4PlotManager::CloseFile()",
"Analysis_W021", JustWarning, description);
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()->Message("close", "plot file", fFileName);
#endif
return result;
}
@@ -0,0 +1,183 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// Author: Ivana Hrivnacova, 21/10/2015 (ivana@ipno.in2p3.fr)
#include "G4PlotMessenger.hh"
#include "G4PlotParameters.hh"
#include "G4AnalysisUtilities.hh"
#include "G4AnalysisMessengerHelper.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UIcmdWithAString.hh"
//#include "G4Tokenizer.hh"
#include <iostream>
#include <sstream>
#include <vector>
using namespace G4Analysis;
//_____________________________________________________________________________
G4PlotMessenger::G4PlotMessenger(G4PlotParameters* plotParameters)
: G4UImessenger(),
fPlotParameters(plotParameters),
fHelper(nullptr),
fDirectory(nullptr),
fSetLayoutCmd(nullptr),
fSetDimensionsCmd(nullptr),
fSetStyleCmd(nullptr)
{
fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("plot");
fDirectory = fHelper->CreateHnDirectory();
SetStyleCmd();
SetLayoutCmd();
SetDimensionsCmd();
}
//_____________________________________________________________________________
G4PlotMessenger::~G4PlotMessenger()
{}
//
// private functions
//
//_____________________________________________________________________________
void G4PlotMessenger::SetStyleCmd()
{
fSetStyleCmd = G4Analysis::make_unique<G4UIcmdWithAString>("/analysis/plot/setStyle",this);
#if defined(TOOLS_USE_FREETYPE)
fSetStyleCmd->SetGuidance("Set plotting style from: ");
fSetStyleCmd->SetGuidance(" ROOT_default: ROOT style with high resolution fonts");
fSetStyleCmd->SetGuidance(" hippodraw: hippodraw style with high resolution fonts");
fSetStyleCmd->SetGuidance(" inlib_default: PAW style with low resolution fonts");
fSetStyleCmd->SetParameterName("Style", false);
#else
fSetStyleCmd->SetGuidance("Only one plotting style is available in low resolution: ");
fSetStyleCmd->SetGuidance(" inlib_default: PAW style with low resolution fonts");
fSetStyleCmd->SetParameterName("Style", false);
fSetStyleCmd->SetCandidates("inlib_default");
#endif
fSetStyleCmd->SetCandidates(fPlotParameters->GetAvailableStyles());
fSetStyleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4PlotMessenger::SetLayoutCmd()
{
auto columns = new G4UIparameter("columns", 'i', false);
columns->SetGuidance("The number of columns in the page layout.");
G4String range = "columns>=1 && columns<=";
std::ostringstream osMaxColumns;
osMaxColumns << fPlotParameters->GetMaxColumns();
range.append(osMaxColumns.str());
columns->SetParameterRange(range);
auto rows = new G4UIparameter("rows", 'i', false);
rows->SetGuidance("The number of rows in the page layout.");
range = "rows>=1 && rows<=";
std::ostringstream osMaxRows;
osMaxRows << fPlotParameters->GetMaxRows();
range.append(osMaxRows.str());
rows->SetParameterRange(range);
fSetLayoutCmd = G4Analysis::make_unique<G4UIcommand>("/analysis/plot/setLayout", this);
// Guidance text:
// Set page layout (number of columns and rows per page).
// Suported layouts:
// columns = 1 .. maxValueAllowed
// rows = 1 .. maxValueAllowed, and >= columns
fSetLayoutCmd->SetGuidance("Set page layout (number of columns and rows per page).");
fSetLayoutCmd->SetGuidance(" Suported layouts: ");
G4String guidance = " columns = 1 .. ";
guidance.append(osMaxColumns.str());
fSetLayoutCmd->SetGuidance(guidance);
guidance = " rows = 1 .. ";
guidance.append(osMaxRows.str());
guidance.append(" and >= columns");
fSetLayoutCmd->SetGuidance(guidance);
fSetLayoutCmd->SetParameter(columns);
fSetLayoutCmd->SetParameter(rows);
fSetLayoutCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//_____________________________________________________________________________
void G4PlotMessenger::SetDimensionsCmd()
{
auto width = new G4UIparameter("width", 'i', false);
width->SetGuidance("The page width.");
auto height = new G4UIparameter("height", 'i', false);
height->SetGuidance("The page height.");
fSetDimensionsCmd = G4Analysis::make_unique<G4UIcommand>("/analysis/plot/setDimensions", this);
fSetDimensionsCmd->SetGuidance("Set the plotter window size (width and height) in pixels.");
fSetDimensionsCmd->SetParameter(width);
fSetDimensionsCmd->SetParameter(height);
fSetDimensionsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//
// public functions
//
//_____________________________________________________________________________
void G4PlotMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
// tokenize parameters in a vector
std::vector<G4String> parameters;
G4Analysis::Tokenize(newValues, parameters);
// check consistency
if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
// Should never happen but let's check anyway for consistency
fHelper->WarnAboutParameters(command, parameters.size());
return;
}
if ( command == fSetLayoutCmd.get() ) {
auto counter = 0;
auto columns = G4UIcommand::ConvertToInt(parameters[counter++]);
auto rows = G4UIcommand::ConvertToInt(parameters[counter++]);
fPlotParameters->SetLayout(columns, rows);
}
else if ( command == fSetDimensionsCmd.get() ) {
auto counter = 0;
auto width = G4UIcommand::ConvertToInt(parameters[counter++]);
auto height = G4UIcommand::ConvertToInt(parameters[counter++]);
fPlotParameters->SetDimensions(width, height);
}
#if defined(TOOLS_USE_FREETYPE)
else if ( command == fSetStyleCmd.get() ) {
fPlotParameters->SetStyle(newValues);
}
#endif
}
@@ -0,0 +1,122 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// Author: Ivana Hrivnacova, 21/10/2015 (ivana@ipno.in2p3.fr)
#include "G4PlotParameters.hh"
#include "G4PlotMessenger.hh"
#include "G4AnalysisUtilities.hh"
#include "globals.hh"
//_____________________________________________________________________________
G4PlotParameters::G4PlotParameters()
: fMessenger(nullptr),
fDefaultColumns(1),
fDefaultRows (2),
#if defined(TOOLS_USE_FREETYPE)
//Have vertical A4 :
fDefaultWidth(2000),
fDefaultHeight((G4int)(29.7f/21.0f*fDefaultWidth)),
fDefaultStyle("ROOT_default"),
fDefaultScale(0.9f),
fMaxColumns(3),
fMaxRows (5),
fAvailableStyles("ROOT_default hippodrow inlib_default"),
#else
fDefaultWidth (700),
fDefaultHeight((G4int)(29.7f/21.0f*fDefaultWidth)),
fDefaultStyle("inlib_default"),
fDefaultScale(0.9f),
fMaxColumns(2),
fMaxRows (3),
fAvailableStyles("inlib_default"),
#endif
fColumns(fDefaultColumns),
fRows(fDefaultRows),
fWidth(fDefaultWidth),
fHeight(fDefaultHeight),
fScale(fDefaultScale),
fStyle(fDefaultStyle)
{
fMessenger = G4Analysis::make_unique<G4PlotMessenger>(this);
}
//
// private methods
//
//_____________________________________________________________________________
void G4PlotParameters::SetLayout(G4int columns, G4int rows)
{
if ( columns > rows ||
columns < 1 || columns > fMaxColumns ||
rows < 1 || rows > fMaxRows ) {
G4ExceptionDescription description;
description
<< "Layout: " << columns << " x " << rows << " was ignored." << G4endl
<< "Suported layouts: " << G4endl
<< " columns <= rows" << G4endl
<< " columns = 1 .. " << fMaxColumns << G4endl
<< " rows = 1 .. " << fMaxRows << G4endl;
G4Exception("G4PlotParameters::SetLayout",
"Analysis_W013", JustWarning, description);
return;
}
fColumns = columns;
fRows = rows;
}
//_____________________________________________________________________________
void G4PlotParameters::SetDimensions(G4int width, G4int height)
{
fWidth = width;
fHeight = height;
}
//_____________________________________________________________________________
void G4PlotParameters::SetStyle(const G4String& style)
{
// Set style and update scale according to the style selected
if ( fAvailableStyles.find(style) == std::string::npos ) {
G4ExceptionDescription description;
description
<< "Style: " << style << " was ignored." << G4endl
<< "Supported styles: " << fAvailableStyles << G4endl;
G4Exception("G4PlotParameters::SetLayout",
"Analysis_W013", JustWarning, description);
return;
}
fStyle = style;
if ( fStyle == "ROOT_default" ) {
fScale = fDefaultScale;
} else {
fScale = 1.f;
}
}
@@ -46,88 +46,79 @@ using namespace G4Analysis;
//_____________________________________________________________________________
G4VAnalysisManager::G4VAnalysisManager(const G4String& type, G4bool isMaster)
: fState(type, isMaster),
fMessenger(0),
fH1HnManager(0),
fH2HnManager(0),
fH3HnManager(0),
fP1HnManager(0),
fP2HnManager(0),
fVH1Manager(0),
fVH2Manager(0),
fVH3Manager(0),
fVP1Manager(0),
fVP2Manager(0),
fVNtupleManager(0),
fVFileManager(0)
fVFileManager(nullptr),
fMessenger(G4Analysis::make_unique<G4AnalysisMessenger>(this)),
fH1HnManager(nullptr),
fH2HnManager(nullptr),
fH3HnManager(nullptr),
fP1HnManager(nullptr),
fP2HnManager(nullptr),
fVH1Manager(nullptr),
fVH2Manager(nullptr),
fVH3Manager(nullptr),
fVP1Manager(nullptr),
fVP2Manager(nullptr),
fVNtupleManager(nullptr)
{
fMessenger = new G4AnalysisMessenger(this);
//fMessenger = G4Analysis::make_unique<G4AnalysisMessenger>(this);
}
//_____________________________________________________________________________
G4VAnalysisManager::~G4VAnalysisManager()
{
delete fMessenger;
delete fVH1Manager;
delete fVH2Manager;
delete fVH3Manager;
delete fVP1Manager;
delete fVP2Manager;
delete fVNtupleManager;
delete fVFileManager;
}
{}
//
// protected methods
//
//_____________________________________________________________________________
void G4VAnalysisManager::SetH1Manager(G4VH1Manager* h1Manager)
{
fVH1Manager = h1Manager;
fH1HnManager = h1Manager->fHnManager;
fMessenger->SetH1HnManager(fH1HnManager);
fVH1Manager.reset(h1Manager);
fH1HnManager = h1Manager->GetHnManager();
fMessenger->SetH1HnManager(*fH1HnManager);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetH2Manager(G4VH2Manager* h2Manager)
{
fVH2Manager = h2Manager;
fH2HnManager = h2Manager->fHnManager;
fMessenger->SetH2HnManager(fH2HnManager);
fVH2Manager.reset(h2Manager);
fH2HnManager = h2Manager->GetHnManager();
fMessenger->SetH2HnManager(*fH2HnManager);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetH3Manager(G4VH3Manager* h3Manager)
{
fVH3Manager = h3Manager;
fH3HnManager = h3Manager->fHnManager;
fMessenger->SetH3HnManager(fH3HnManager);
fVH3Manager.reset(h3Manager);
fH3HnManager = h3Manager->GetHnManager();
fMessenger->SetH3HnManager(*fH3HnManager);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetP1Manager(G4VP1Manager* p1Manager)
{
fVP1Manager = p1Manager;
fP1HnManager = p1Manager->fHnManager;
fMessenger->SetP1HnManager(fP1HnManager);
fVP1Manager.reset(p1Manager);
fP1HnManager = p1Manager->GetHnManager();
fMessenger->SetP1HnManager(*fP1HnManager);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetP2Manager(G4VP2Manager* p2Manager)
{
fVP2Manager = p2Manager;
fP2HnManager = p2Manager->fHnManager;
fMessenger->SetP2HnManager(fP2HnManager);
fVP2Manager.reset(p2Manager);
fP2HnManager = p2Manager->GetHnManager();
fMessenger->SetP2HnManager(*fP2HnManager);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetNtupleManager(G4VNtupleManager* ntupleManager)
{
fVNtupleManager = ntupleManager;
fVNtupleManager.reset(ntupleManager);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetFileManager(G4VFileManager* fileManager)
void G4VAnalysisManager::SetFileManager(std::shared_ptr<G4VFileManager> fileManager)
{
fVFileManager = fileManager;
}
@@ -209,7 +200,17 @@ G4bool G4VAnalysisManager::OpenFile(const G4String& fileName)
//_____________________________________________________________________________
G4bool G4VAnalysisManager::Write()
{
return WriteImpl();
G4bool finalResult = true;
G4bool result = WriteImpl();
finalResult = finalResult && result;
if ( IsPlotting() ) {
result = PlotImpl();
finalResult = finalResult && result;
}
return finalResult;
}
//_____________________________________________________________________________
@@ -218,6 +219,24 @@ G4bool G4VAnalysisManager::CloseFile()
return CloseFileImpl();
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::Merge(tools::histo::hmpi* hmpi)
{
return MergeImpl(hmpi);
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::Plot()
{
return PlotImpl();
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::IsOpenFile() const
{
return IsOpenFileImpl();
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::SetFileName(const G4String& fileName)
{
@@ -236,6 +255,12 @@ G4bool G4VAnalysisManager::SetNtupleDirectoryName(const G4String& dirName)
return fVFileManager->SetNtupleDirectoryName(dirName);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetCompressionLevel(G4int level)
{
fState.SetCompressionLevel(level);
}
//_____________________________________________________________________________
G4String G4VAnalysisManager::GetFileName() const
{
@@ -254,6 +279,12 @@ G4String G4VAnalysisManager::GetNtupleDirectoryName() const
return fVFileManager->GetNtupleDirectoryName();
}
//_____________________________________________________________________________
G4int G4VAnalysisManager::GetCompressionLevel() const
{
return fState.GetCompressionLevel();
}
//_____________________________________________________________________________
G4int G4VAnalysisManager::CreateH1(const G4String& name, const G4String& title,
G4int nbins, G4double xmin, G4double xmax,
@@ -829,40 +860,19 @@ G4bool G4VAnalysisManager::SetFirstHistoId(G4int firstId)
//_____________________________________________________________________________
G4bool G4VAnalysisManager::SetFirstH1Id(G4int firstId)
{
G4bool finalResult = true;
G4bool result = fVH1Manager->SetFirstId(firstId);
finalResult = finalResult && result;
result = fH1HnManager->SetFirstId(firstId);
finalResult = finalResult && result;
return finalResult;
return fH1HnManager->SetFirstId(firstId);
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::SetFirstH2Id(G4int firstId)
{
G4bool finalResult = true;
G4bool result = fVH2Manager->SetFirstId(firstId);
finalResult = finalResult && result;
result = fH2HnManager->SetFirstId(firstId);
finalResult = finalResult && result;
return finalResult;
return fH2HnManager->SetFirstId(firstId);
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::SetFirstH3Id(G4int firstId)
{
G4bool finalResult = true;
G4bool result = fVH3Manager->SetFirstId(firstId);
finalResult = finalResult && result;
result = fH3HnManager->SetFirstId(firstId);
finalResult = finalResult && result;
return finalResult;
return fH3HnManager->SetFirstId(firstId);
}
//_____________________________________________________________________________
@@ -882,27 +892,13 @@ G4bool G4VAnalysisManager::SetFirstProfileId(G4int firstId)
//_____________________________________________________________________________
G4bool G4VAnalysisManager::SetFirstP1Id(G4int firstId)
{
G4bool finalResult = true;
G4bool result = fVP1Manager->SetFirstId(firstId);
finalResult = finalResult && result;
result = fP1HnManager->SetFirstId(firstId);
finalResult = finalResult && result;
return finalResult;
return fP1HnManager->SetFirstId(firstId);
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::SetFirstP2Id(G4int firstId)
{
G4bool finalResult = true;
G4bool result = fVP2Manager->SetFirstId(firstId);
finalResult = finalResult && result;
result = fP2HnManager->SetFirstId(firstId);
finalResult = finalResult && result;
return finalResult;
return fP2HnManager->SetFirstId(firstId);
}
//_____________________________________________________________________________
@@ -934,16 +930,35 @@ G4bool G4VAnalysisManager::IsActive() const
// an activated object.
return fState.GetIsActivation() &&
( fH1HnManager->IsActive() || fH2HnManager->IsActive() );
( fH1HnManager->IsActive() ||
fH2HnManager->IsActive() ||
fH3HnManager->IsActive() ||
fP1HnManager->IsActive() ||
fP2HnManager->IsActive() );
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::IsAscii() const
{
// Return true any of managers has an object with activated ASCII option.
return ( fH1HnManager->IsAscii() || fH2HnManager->IsAscii() );
return ( fH1HnManager->IsAscii() ||
fH2HnManager->IsAscii() ||
fH3HnManager->IsAscii() ||
fP1HnManager->IsAscii() ||
fP2HnManager->IsAscii() );
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::IsPlotting() const
{
// Return true any of managers has an object with activated plotting option.
return ( fH1HnManager->IsPlotting() ||
fH2HnManager->IsPlotting() ||
fH3HnManager->IsPlotting() ||
fP1HnManager->IsPlotting() ||
fP2HnManager->IsPlotting() );
}
//_____________________________________________________________________________
@@ -951,7 +966,7 @@ G4int G4VAnalysisManager::GetFirstH1Id() const
{
// Return first H1 id
return fVH1Manager->GetFirstId();
return fH1HnManager->GetFirstId();
}
//_____________________________________________________________________________
@@ -959,7 +974,7 @@ G4int G4VAnalysisManager::GetFirstH2Id() const
{
// Return first H2 id
return fVH2Manager->GetFirstId();
return fH2HnManager->GetFirstId();
}
//_____________________________________________________________________________
@@ -967,7 +982,7 @@ G4int G4VAnalysisManager::GetFirstH3Id() const
{
// Return first H3 id
return fVH3Manager->GetFirstId();
return fH3HnManager->GetFirstId();
}
//_____________________________________________________________________________
@@ -975,7 +990,7 @@ G4int G4VAnalysisManager::GetFirstP1Id() const
{
// Return first P1 id
return fVP1Manager->GetFirstId();
return fP1HnManager->GetFirstId();
}
//_____________________________________________________________________________
@@ -983,7 +998,7 @@ G4int G4VAnalysisManager::GetFirstP2Id() const
{
// Return first P2 id
return fVP2Manager->GetFirstId();
return fP2HnManager->GetFirstId();
}
//_____________________________________________________________________________
@@ -1062,6 +1077,12 @@ void G4VAnalysisManager::SetH1Ascii(G4int id, G4bool ascii)
fH1HnManager->SetAscii(id, ascii);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetH1Plotting(G4int id, G4bool plotting)
{
fH1HnManager->SetPlotting(id, plotting);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetH2Activation(G4int id, G4bool activation)
{
@@ -1082,6 +1103,12 @@ void G4VAnalysisManager::SetH2Activation(G4bool activation)
void G4VAnalysisManager::SetH2Ascii(G4int id, G4bool ascii)
{
fH2HnManager->SetAscii(id, ascii);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetH2Plotting(G4int id, G4bool plotting)
{
fH2HnManager->SetPlotting(id, plotting);
}
//_____________________________________________________________________________
@@ -1104,7 +1131,13 @@ void G4VAnalysisManager::SetH3Activation(G4bool activation)
void G4VAnalysisManager::SetH3Ascii(G4int id, G4bool ascii)
{
fH3HnManager->SetAscii(id, ascii);
}
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetH3Plotting(G4int id, G4bool plotting)
{
fH3HnManager->SetPlotting(id, plotting);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetP1Activation(G4int id, G4bool activation)
@@ -1126,7 +1159,13 @@ void G4VAnalysisManager::SetP1Activation(G4bool activation)
void G4VAnalysisManager::SetP1Ascii(G4int id, G4bool ascii)
{
fP1HnManager->SetAscii(id, ascii);
}
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetP1Plotting(G4int id, G4bool plotting)
{
fP1HnManager->SetPlotting(id, plotting);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetP2Activation(G4int id, G4bool activation)
@@ -1148,6 +1187,28 @@ void G4VAnalysisManager::SetP2Activation(G4bool activation)
void G4VAnalysisManager::SetP2Ascii(G4int id, G4bool ascii)
{
fP2HnManager->SetAscii(id, ascii);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetP2Plotting(G4int id, G4bool plotting)
{
fP2HnManager->SetPlotting(id, plotting);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetNtupleActivation(G4int id, G4bool activation)
{
// Set activation to a given P2 object
fVNtupleManager->SetActivation(id, activation);
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetNtupleActivation(G4bool activation)
{
// Set activation to all P2 objects
fVNtupleManager->SetActivation(activation);
}
// Access methods in .icc
@@ -45,26 +45,18 @@ using namespace G4Analysis;
//_____________________________________________________________________________
G4VAnalysisReader::G4VAnalysisReader(const G4String& type, G4bool isMaster)
: fState(type, isMaster),
fVH1Manager(0),
fVH2Manager(0),
fVH3Manager(0),
fVP1Manager(0),
fVP2Manager(0),
fVNtupleManager(0),
fFileManager(0)
fVH1Manager(nullptr),
fVH2Manager(nullptr),
fVH3Manager(nullptr),
fVP1Manager(nullptr),
fVP2Manager(nullptr),
fVNtupleManager(nullptr),
fFileManager(nullptr)
{}
//_____________________________________________________________________________
G4VAnalysisReader::~G4VAnalysisReader()
{
delete fVH1Manager;
delete fVH2Manager;
delete fVH3Manager;
delete fVP1Manager;
delete fVP2Manager;
delete fVNtupleManager;
delete fFileManager;
}
{}
//
// protected methods
@@ -73,43 +65,43 @@ G4VAnalysisReader::~G4VAnalysisReader()
//_____________________________________________________________________________
void G4VAnalysisReader::SetH1Manager(G4VH1Manager* h1Manager)
{
fVH1Manager = h1Manager;
fVH1Manager.reset(h1Manager);
}
//_____________________________________________________________________________
void G4VAnalysisReader::SetH2Manager(G4VH2Manager* h2Manager)
{
fVH2Manager = h2Manager;
fVH2Manager.reset(h2Manager);
}
//_____________________________________________________________________________
void G4VAnalysisReader::SetH3Manager(G4VH3Manager* h3Manager)
{
fVH3Manager = h3Manager;
fVH3Manager.reset(h3Manager);
}
//_____________________________________________________________________________
void G4VAnalysisReader::SetP1Manager(G4VP1Manager* p1Manager)
{
fVP1Manager = p1Manager;
fVP1Manager.reset(p1Manager);
}
//_____________________________________________________________________________
void G4VAnalysisReader::SetP2Manager(G4VP2Manager* p2Manager)
{
fVP2Manager = p2Manager;
fVP2Manager.reset(p2Manager);
}
//_____________________________________________________________________________
void G4VAnalysisReader::SetNtupleManager(G4VRNtupleManager* ntupleManager)
{
fVNtupleManager = ntupleManager;
fVNtupleManager.reset(ntupleManager);
}
//_____________________________________________________________________________
void G4VAnalysisReader::SetFileManager(G4BaseFileManager* fileManager)
{
fFileManager = fileManager;
fFileManager.reset(fileManager);
}
//
@@ -248,40 +240,19 @@ G4bool G4VAnalysisReader::SetFirstHistoId(G4int firstId)
//_____________________________________________________________________________
G4bool G4VAnalysisReader::SetFirstH1Id(G4int firstId)
{
G4bool finalResult = true;
G4bool result = fVH1Manager->SetFirstId(firstId);
finalResult = finalResult && result;
result = fVH1Manager->fHnManager->SetFirstId(firstId);
finalResult = finalResult && result;
return finalResult;
return fVH1Manager->GetHnManager()->SetFirstId(firstId);
}
//_____________________________________________________________________________
G4bool G4VAnalysisReader::SetFirstH2Id(G4int firstId)
{
G4bool finalResult = true;
G4bool result = fVH2Manager->SetFirstId(firstId);
finalResult = finalResult && result;
result = fVH2Manager->fHnManager->SetFirstId(firstId);
finalResult = finalResult && result;
return finalResult;
return fVH2Manager->GetHnManager()->SetFirstId(firstId);
}
//_____________________________________________________________________________
G4bool G4VAnalysisReader::SetFirstH3Id(G4int firstId)
{
G4bool finalResult = true;
G4bool result = fVH3Manager->SetFirstId(firstId);
finalResult = finalResult && result;
result = fVH3Manager->fHnManager->SetFirstId(firstId);
finalResult = finalResult && result;
return finalResult;
return fVH3Manager->GetHnManager()->SetFirstId(firstId);
}
//_____________________________________________________________________________
@@ -301,27 +272,13 @@ G4bool G4VAnalysisReader::SetFirstProfileId(G4int firstId)
//_____________________________________________________________________________
G4bool G4VAnalysisReader::SetFirstP1Id(G4int firstId)
{
G4bool finalResult = true;
G4bool result = fVP1Manager->SetFirstId(firstId);
finalResult = finalResult && result;
result = fVP1Manager->fHnManager->SetFirstId(firstId);
finalResult = finalResult && result;
return finalResult;
return fVP1Manager->GetHnManager()->SetFirstId(firstId);
}
//_____________________________________________________________________________
G4bool G4VAnalysisReader::SetFirstP2Id(G4int firstId)
{
G4bool finalResult = true;
G4bool result = fVP2Manager->SetFirstId(firstId);
finalResult = finalResult && result;
result = fVP2Manager->fHnManager->SetFirstId(firstId);
finalResult = finalResult && result;
return finalResult;
return fVP2Manager->GetHnManager()->SetFirstId(firstId);
}
//_____________________________________________________________________________
@@ -471,31 +428,31 @@ G4bool G4VAnalysisReader::GetNtupleRow(G4int ntupleId)
//_____________________________________________________________________________
G4int G4VAnalysisReader::GetNofH1s() const
{
return fVH1Manager->fHnManager->GetNofHns();
return fVH1Manager->GetHnManager()->GetNofHns();
}
//_____________________________________________________________________________
G4int G4VAnalysisReader::GetNofH2s() const
{
return fVH2Manager->fHnManager->GetNofHns();
return fVH2Manager->GetHnManager()->GetNofHns();
}
//_____________________________________________________________________________
G4int G4VAnalysisReader::GetNofH3s() const
{
return fVH3Manager->fHnManager->GetNofHns();
return fVH3Manager->GetHnManager()->GetNofHns();
}
//_____________________________________________________________________________
G4int G4VAnalysisReader::GetNofP1s() const
{
return fVP1Manager->fHnManager->GetNofHns();
return fVP1Manager->GetHnManager()->GetNofHns();
}
//_____________________________________________________________________________
G4int G4VAnalysisReader::GetNofP2s() const
{
return fVP2Manager->fHnManager->GetNofHns();
return fVP2Manager->GetHnManager()->GetNofHns();
}
//_____________________________________________________________________________
@@ -35,20 +35,17 @@
//_____________________________________________________________________________
G4VFileManager::G4VFileManager(const G4AnalysisManagerState& state)
: G4BaseFileManager(state),
fIsOpenFile(false),
fHistoDirectoryName(""),
fProfileDirectoryName(""),
fNtupleDirectoryName(""),
fLockFileName(false),
fLockHistoDirectoryName(false),
fLockProfileDirectoryName(false),
fLockNtupleDirectoryName(false)
{
}
{}
//_____________________________________________________________________________
G4VFileManager::~G4VFileManager()
{
}
{}
//
// public methods
@@ -85,22 +82,6 @@ G4bool G4VFileManager::SetHistoDirectoryName(const G4String& dirName)
return true;
}
//_____________________________________________________________________________
G4bool G4VFileManager::SetProfileDirectoryName(const G4String& dirName)
{
if ( fLockProfileDirectoryName ) {
G4ExceptionDescription description;
description
<< "Cannot set Profile directory name as its value was already used.";
G4Exception("G4VFileManager::SetProfileDirectoryName()",
"Analysis_W012", JustWarning, description);
return false;
}
fProfileDirectoryName = dirName;
return true;
}
//_____________________________________________________________________________
G4bool G4VFileManager::SetNtupleDirectoryName(const G4String& dirName)
{
@@ -1,45 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VH1Manager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
#include "G4VH1Manager.hh"
#include "G4HnManager.hh"
//_____________________________________________________________________________
G4VH1Manager::G4VH1Manager(const G4AnalysisManagerState& state)
: G4BaseAnalysisManager(state),
fHnManager(0)
{
fHnManager = new G4HnManager("H1", state);
}
//_____________________________________________________________________________
G4VH1Manager::~G4VH1Manager()
{
delete fHnManager;
}