Import Geant4 11.1.0 source tree
This commit is contained in:
@@ -1,179 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Manager class for tools::histo::h1d.
|
||||
// It implements functions specific to the H1 type
|
||||
// (defined in g4tools).
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4H1ToolsManager_h
|
||||
#define G4H1ToolsManager_h 1
|
||||
|
||||
#include "G4VH1Manager.hh"
|
||||
#include "G4THnManager.hh"
|
||||
#include "G4HnManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace tools {
|
||||
namespace histo {
|
||||
class h1d;
|
||||
}
|
||||
}
|
||||
|
||||
class G4H1ToolsManager : public G4VH1Manager,
|
||||
public G4THnManager<tools::histo::h1d>
|
||||
{
|
||||
public:
|
||||
explicit G4H1ToolsManager(const G4AnalysisManagerState& state);
|
||||
G4H1ToolsManager() = delete;
|
||||
virtual ~G4H1ToolsManager() = default;
|
||||
|
||||
// Method to add histograms read from a file
|
||||
G4int AddH1(const G4String& name, tools::histo::h1d* h1d);
|
||||
// Method for merge (MT)
|
||||
void AddH1Vector(const std::vector<tools::histo::h1d*>& h1Vector);
|
||||
|
||||
// Access methods
|
||||
//
|
||||
tools::histo::h1d* GetH1(G4int id, G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
|
||||
// Iterators
|
||||
std::vector<tools::histo::h1d*>::iterator BeginH1();
|
||||
std::vector<tools::histo::h1d*>::iterator EndH1();
|
||||
std::vector<tools::histo::h1d*>::const_iterator BeginConstH1() const;
|
||||
std::vector<tools::histo::h1d*>::const_iterator EndConstH1() const;
|
||||
|
||||
// Access to histogram vector (needed for Write())
|
||||
const std::vector<tools::histo::h1d*>& GetH1Vector() const;
|
||||
const std::vector<G4HnInformation*>& GetHnVector() const;
|
||||
|
||||
protected:
|
||||
// Virtual functions from base class
|
||||
//
|
||||
|
||||
// Methods to create histograms
|
||||
//
|
||||
virtual G4int CreateH1(const G4String& name, const G4String& title,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
const G4String& unitName = "none",
|
||||
const G4String& fcnName = "none",
|
||||
const G4String& binScheme = "linear") final;
|
||||
virtual G4int CreateH1(const G4String& name, const G4String& title,
|
||||
const std::vector<G4double>& edges,
|
||||
const G4String& unitName = "none",
|
||||
const G4String& fcnName = "none") final;
|
||||
|
||||
virtual G4bool SetH1(G4int id,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
const G4String& unitName = "none",
|
||||
const G4String& fcnName = "none",
|
||||
const G4String& binSchemeName = "linear") final;
|
||||
virtual G4bool SetH1(G4int id,
|
||||
const std::vector<G4double>& edges,
|
||||
const G4String& unitName = "none",
|
||||
const G4String& fcnName = "none") final;
|
||||
virtual G4bool ScaleH1(G4int id, G4double factor) final;
|
||||
|
||||
// Method to fill histograms
|
||||
//
|
||||
virtual G4bool FillH1(G4int id, G4double value, G4double weight = 1.0) final;
|
||||
|
||||
// Access methods
|
||||
//
|
||||
virtual G4int GetH1Id(const G4String& name, G4bool warn = true) const final;
|
||||
|
||||
// Access to H1 parameters
|
||||
virtual G4int GetH1Nbins(G4int id) const final;
|
||||
virtual G4double GetH1Xmin(G4int id) const final;
|
||||
virtual G4double GetH1Xmax(G4int id) const final;
|
||||
virtual G4double GetH1Width(G4int id) const final;
|
||||
|
||||
// Attributes for plotting
|
||||
//
|
||||
|
||||
// Setters
|
||||
virtual G4bool SetH1Title(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetH1XAxisTitle(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetH1YAxisTitle(G4int id, const G4String& title) final;
|
||||
|
||||
// Accessors
|
||||
virtual G4String GetH1Title(G4int id) const final;
|
||||
virtual G4String GetH1XAxisTitle(G4int id) const final;
|
||||
virtual G4String GetH1YAxisTitle(G4int id) const final;
|
||||
|
||||
// Write data on ASCII file
|
||||
virtual G4bool WriteOnAscii(std::ofstream& output) final;
|
||||
|
||||
// Access to Hn manager
|
||||
virtual std::shared_ptr<G4HnManager> GetHnManager() final;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
//
|
||||
void AddH1Information(const G4String& name,
|
||||
const G4String& unitName,
|
||||
const G4String& fcnName,
|
||||
G4BinScheme binScheme) const;
|
||||
|
||||
// Static data members
|
||||
static constexpr std::string_view fkClass { "G4H1ToolsManager" };
|
||||
static constexpr G4int fkDimension = 1;
|
||||
};
|
||||
|
||||
// inline methods
|
||||
|
||||
inline std::vector<tools::histo::h1d*>::iterator G4H1ToolsManager::BeginH1()
|
||||
{ return BeginT(); }
|
||||
|
||||
inline std::vector<tools::histo::h1d*>::iterator G4H1ToolsManager::EndH1()
|
||||
{ return EndT(); }
|
||||
|
||||
inline std::vector<tools::histo::h1d*>::const_iterator
|
||||
G4H1ToolsManager::BeginConstH1() const
|
||||
{ return BeginConstT(); }
|
||||
|
||||
inline std::vector<tools::histo::h1d*>::const_iterator
|
||||
G4H1ToolsManager::EndConstH1() const
|
||||
{ return EndConstT(); }
|
||||
|
||||
inline const std::vector<tools::histo::h1d*>& G4H1ToolsManager::GetH1Vector() const
|
||||
{ return fTVector; }
|
||||
|
||||
inline const std::vector<G4HnInformation*>& G4H1ToolsManager::GetHnVector() const
|
||||
{ return fHnManager->GetHnVector(); }
|
||||
|
||||
inline std::shared_ptr<G4HnManager> G4H1ToolsManager::GetHnManager()
|
||||
{ return std::shared_ptr<G4HnManager>(fHnManager); }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,201 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Manager class for tools::histo::h2d.
|
||||
// It implements functions specific to the H2 type
|
||||
// (defined in g4tools).
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4H2ToolsManager_h
|
||||
#define G4H2ToolsManager_h 1
|
||||
|
||||
#include "G4VH2Manager.hh"
|
||||
#include "G4THnManager.hh"
|
||||
#include "G4HnManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace tools {
|
||||
namespace histo {
|
||||
class h2d;
|
||||
}
|
||||
}
|
||||
|
||||
class G4H2ToolsManager : public G4VH2Manager,
|
||||
public G4THnManager<tools::histo::h2d>
|
||||
{
|
||||
public:
|
||||
explicit G4H2ToolsManager(const G4AnalysisManagerState& state);
|
||||
virtual ~G4H2ToolsManager() = default;
|
||||
|
||||
// Method to add histograms read from a file
|
||||
G4int AddH2(const G4String& name, tools::histo::h2d* h2d);
|
||||
// Method for merge (MT)
|
||||
void AddH2Vector(const std::vector<tools::histo::h2d*>& h2Vector);
|
||||
|
||||
// Access methods
|
||||
//
|
||||
tools::histo::h2d* GetH2(G4int id, G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
// Iterators
|
||||
std::vector<tools::histo::h2d*>::iterator BeginH2();
|
||||
std::vector<tools::histo::h2d*>::iterator EndH2();
|
||||
std::vector<tools::histo::h2d*>::const_iterator BeginConstH2() const;
|
||||
std::vector<tools::histo::h2d*>::const_iterator EndConstH2() const;
|
||||
|
||||
// Access to histogram vector (needed for Write())
|
||||
const std::vector<tools::histo::h2d*>& GetH2Vector() const;
|
||||
const std::vector<G4HnInformation*>& GetHnVector() const;
|
||||
|
||||
protected:
|
||||
// Virtual functions from base class
|
||||
//
|
||||
|
||||
// Methods to create histograms
|
||||
//
|
||||
virtual G4int CreateH2(const G4String& name, const G4String& title,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& xbinScheme = "linear",
|
||||
const G4String& ybinScheme = "linear") final;
|
||||
|
||||
virtual G4int CreateH2(const G4String& name, const G4String& title,
|
||||
const std::vector<G4double>& xedges,
|
||||
const std::vector<G4double>& yedges,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none") final;
|
||||
|
||||
virtual G4bool SetH2(G4int id,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& xbinScheme = "linear",
|
||||
const G4String& ybinScheme = "linear") final;
|
||||
|
||||
virtual G4bool SetH2(G4int id,
|
||||
const std::vector<G4double>& xedges,
|
||||
const std::vector<G4double>& yedges,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none") final;
|
||||
|
||||
virtual G4bool ScaleH2(G4int id, G4double factor) final;
|
||||
|
||||
// Method to fill histograms
|
||||
//
|
||||
virtual G4bool FillH2(G4int id, G4double xvalue, G4double yvalue,
|
||||
G4double weight = 1.0) final;
|
||||
|
||||
|
||||
// Methods to manipulate histograms
|
||||
//
|
||||
|
||||
// Access methods
|
||||
virtual G4int GetH2Id(const G4String& name, G4bool warn = true) const final;
|
||||
|
||||
// Access to H2 parameters
|
||||
virtual G4int GetH2Nxbins(G4int id) const final;
|
||||
virtual G4double GetH2Xmin(G4int id) const final;
|
||||
virtual G4double GetH2Xmax(G4int id) const final;
|
||||
virtual G4double GetH2XWidth(G4int id) const final;
|
||||
virtual G4int GetH2Nybins(G4int id) const final;
|
||||
virtual G4double GetH2Ymin(G4int id) const final;
|
||||
virtual G4double GetH2Ymax(G4int id) const final;
|
||||
virtual G4double GetH2YWidth(G4int id) const final;
|
||||
|
||||
// Setters for attributes for plotting
|
||||
virtual G4bool SetH2Title(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetH2XAxisTitle(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetH2YAxisTitle(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetH2ZAxisTitle(G4int id, const G4String& title) final;
|
||||
|
||||
// Access attributes for plotting
|
||||
virtual G4String GetH2Title(G4int id) const final;
|
||||
virtual G4String GetH2XAxisTitle(G4int id) const final;
|
||||
virtual G4String GetH2YAxisTitle(G4int id) const final;
|
||||
virtual G4String GetH2ZAxisTitle(G4int id) const final;
|
||||
|
||||
// Write data on ASCII file
|
||||
virtual G4bool WriteOnAscii(std::ofstream& output) final;
|
||||
|
||||
// Access to Hn manager
|
||||
virtual std::shared_ptr<G4HnManager> GetHnManager() final;
|
||||
|
||||
private:
|
||||
void AddH2Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
G4BinScheme xbinScheme,
|
||||
G4BinScheme ybinScheme) const;
|
||||
|
||||
// Static data members
|
||||
static constexpr std::string_view fkClass { "G4H2ToolsManager" };
|
||||
static constexpr G4int fkDimension = 2;
|
||||
};
|
||||
// inline methods
|
||||
|
||||
inline std::vector<tools::histo::h2d*>::iterator G4H2ToolsManager::BeginH2()
|
||||
{ return BeginT(); }
|
||||
|
||||
inline std::vector<tools::histo::h2d*>::iterator G4H2ToolsManager::EndH2()
|
||||
{ return EndT(); }
|
||||
|
||||
inline std::vector<tools::histo::h2d*>::const_iterator
|
||||
G4H2ToolsManager::BeginConstH2() const
|
||||
{ return BeginConstT(); }
|
||||
|
||||
inline std::vector<tools::histo::h2d*>::const_iterator
|
||||
G4H2ToolsManager::EndConstH2() const
|
||||
{ return EndConstT(); }
|
||||
|
||||
inline const std::vector<tools::histo::h2d*>& G4H2ToolsManager::GetH2Vector() const
|
||||
{ return fTVector; }
|
||||
|
||||
inline const std::vector<G4HnInformation*>& G4H2ToolsManager::GetHnVector() const
|
||||
{ return fHnManager->GetHnVector(); }
|
||||
|
||||
inline std::shared_ptr<G4HnManager> G4H2ToolsManager::GetHnManager()
|
||||
{ return std::shared_ptr<G4HnManager>(fHnManager); }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,224 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Manager class for tools::histo::h3d.
|
||||
// It implements functions specific to the H3 type
|
||||
// (defined in g4tools).
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4H3ToolsManager_h
|
||||
#define G4H3ToolsManager_h 1
|
||||
|
||||
#include "G4VH3Manager.hh"
|
||||
#include "G4THnManager.hh"
|
||||
#include "G4HnManager.hh"
|
||||
#include "G4BinScheme.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace tools {
|
||||
namespace histo {
|
||||
class h3d;
|
||||
}
|
||||
}
|
||||
|
||||
class G4H3ToolsManager : public G4VH3Manager,
|
||||
public G4THnManager<tools::histo::h3d>
|
||||
{
|
||||
public:
|
||||
explicit G4H3ToolsManager(const G4AnalysisManagerState& state);
|
||||
virtual ~G4H3ToolsManager() = default;
|
||||
|
||||
// Method to add histograms read from a file
|
||||
G4int AddH3(const G4String& name, tools::histo::h3d* h3d);
|
||||
// Method for merge (MT)
|
||||
void AddH3Vector(const std::vector<tools::histo::h3d*>& h3Vector);
|
||||
|
||||
// Access methods
|
||||
//
|
||||
tools::histo::h3d* GetH3(G4int id, G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
// Iterators
|
||||
std::vector<tools::histo::h3d*>::iterator BeginH3();
|
||||
std::vector<tools::histo::h3d*>::iterator EndH3();
|
||||
std::vector<tools::histo::h3d*>::const_iterator BeginConstH3() const;
|
||||
std::vector<tools::histo::h3d*>::const_iterator EndConstH3() const;
|
||||
|
||||
// Access to histogram vector (needed for Write())
|
||||
const std::vector<tools::histo::h3d*>& GetH3Vector() const;
|
||||
const std::vector<G4HnInformation*>& GetHnVector() const;
|
||||
|
||||
protected:
|
||||
// Virtual functions from base class
|
||||
//
|
||||
|
||||
// Methods to create histograms
|
||||
//
|
||||
virtual G4int CreateH3(const G4String& name, const G4String& title,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
G4int nzbins, G4double zmin, G4double zmax,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& zunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& zfcnName = "none",
|
||||
const G4String& xbinScheme = "linear",
|
||||
const G4String& ybinScheme = "linear",
|
||||
const G4String& zbinScheme = "linear") final;
|
||||
|
||||
virtual G4int CreateH3(const G4String& name, const G4String& title,
|
||||
const std::vector<G4double>& xedges,
|
||||
const std::vector<G4double>& yedges,
|
||||
const std::vector<G4double>& zedges,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& zunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& zfcnName = "none") final;
|
||||
|
||||
virtual G4bool SetH3(G4int id,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
G4int nzbins, G4double zmin, G4double zmax,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& zunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& zfcnName = "none",
|
||||
const G4String& xbinScheme = "linear",
|
||||
const G4String& ybinScheme = "linear",
|
||||
const G4String& zbinScheme = "linear") final;
|
||||
|
||||
virtual G4bool SetH3(G4int id,
|
||||
const std::vector<G4double>& xedges,
|
||||
const std::vector<G4double>& yedges,
|
||||
const std::vector<G4double>& zedges,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& zunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& zfcnName = "none") final;
|
||||
|
||||
virtual G4bool ScaleH3(G4int id, G4double factor) final;
|
||||
|
||||
// Method to fill histograms
|
||||
//
|
||||
virtual G4bool FillH3(G4int id,
|
||||
G4double xvalue, G4double yvalue, G4double zvalue,
|
||||
G4double weight = 1.0) final;
|
||||
|
||||
|
||||
// Methods to manipulate histograms
|
||||
//
|
||||
|
||||
// Access methods
|
||||
virtual G4int GetH3Id(const G4String& name, G4bool warn = true) const final;
|
||||
|
||||
// Access to H3 parameters
|
||||
virtual G4int GetH3Nxbins(G4int id) const final;
|
||||
virtual G4double GetH3Xmin(G4int id) const final;
|
||||
virtual G4double GetH3Xmax(G4int id) const final;
|
||||
virtual G4double GetH3XWidth(G4int id) const final;
|
||||
virtual G4int GetH3Nybins(G4int id) const final;
|
||||
virtual G4double GetH3Ymin(G4int id) const final;
|
||||
virtual G4double GetH3Ymax(G4int id) const final;
|
||||
virtual G4double GetH3YWidth(G4int id) const final;
|
||||
virtual G4int GetH3Nzbins(G4int id) const final;
|
||||
virtual G4double GetH3Zmin(G4int id) const final;
|
||||
virtual G4double GetH3Zmax(G4int id) const final;
|
||||
virtual G4double GetH3ZWidth(G4int id) const final;
|
||||
|
||||
// Setters for attributes for plotting
|
||||
virtual G4bool SetH3Title(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetH3XAxisTitle(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetH3YAxisTitle(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetH3ZAxisTitle(G4int id, const G4String& title) final;
|
||||
|
||||
// Access attributes for plotting
|
||||
virtual G4String GetH3Title(G4int id) const final;
|
||||
virtual G4String GetH3XAxisTitle(G4int id) const final;
|
||||
virtual G4String GetH3YAxisTitle(G4int id) const final;
|
||||
virtual G4String GetH3ZAxisTitle(G4int id) const final;
|
||||
|
||||
// Write data on ASCII file
|
||||
virtual G4bool WriteOnAscii(std::ofstream& output) final;
|
||||
|
||||
// Access to Hn manager
|
||||
virtual std::shared_ptr<G4HnManager> GetHnManager() final;
|
||||
|
||||
private:
|
||||
void AddH3Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
G4BinScheme xbinScheme,
|
||||
G4BinScheme ybinScheme,
|
||||
G4BinScheme zbinScheme) const;
|
||||
|
||||
// Static data members
|
||||
static constexpr std::string_view fkClass { "G4H3ToolsManager" };
|
||||
static constexpr G4int fkDimension = 3;
|
||||
};
|
||||
// inline methods
|
||||
|
||||
inline std::vector<tools::histo::h3d*>::iterator G4H3ToolsManager::BeginH3()
|
||||
{ return BeginT(); }
|
||||
|
||||
inline std::vector<tools::histo::h3d*>::iterator G4H3ToolsManager::EndH3()
|
||||
{ return EndT(); }
|
||||
|
||||
inline std::vector<tools::histo::h3d*>::const_iterator
|
||||
G4H3ToolsManager::BeginConstH3() const
|
||||
{ return BeginConstT(); }
|
||||
|
||||
inline std::vector<tools::histo::h3d*>::const_iterator
|
||||
G4H3ToolsManager::EndConstH3() const
|
||||
{ return EndConstT(); }
|
||||
|
||||
inline const std::vector<tools::histo::h3d*>& G4H3ToolsManager::GetH3Vector() const
|
||||
{ return fTVector; }
|
||||
|
||||
inline const std::vector<G4HnInformation*>& G4H3ToolsManager::GetHnVector() const
|
||||
{ return fHnManager->GetHnVector(); }
|
||||
|
||||
inline std::shared_ptr<G4HnManager> G4H3ToolsManager::GetHnManager()
|
||||
{ return std::shared_ptr<G4HnManager>(fHnManager); }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,19 +53,22 @@ class G4MPIToolsManager
|
||||
public:
|
||||
// Methods
|
||||
template <typename HT>
|
||||
G4bool Merge(const std::vector<HT*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector);
|
||||
G4bool Merge(const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector
|
||||
|
||||
);
|
||||
private:
|
||||
// Methods
|
||||
template <typename HT>
|
||||
G4bool Send(G4int nofActiveT,
|
||||
const std::vector<HT*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector);
|
||||
const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector
|
||||
|
||||
);
|
||||
|
||||
template <typename HT>
|
||||
G4bool Receive(G4int nofActiveT,
|
||||
const std::vector<HT*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector);
|
||||
const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector
|
||||
|
||||
);
|
||||
|
||||
// Static data members
|
||||
static constexpr std::string_view fkClass { "G4MPIToolsManager" };
|
||||
|
||||
@@ -33,9 +33,8 @@ using std::to_string;
|
||||
//_____________________________________________________________________________
|
||||
template <typename HT>
|
||||
inline
|
||||
G4bool G4MPIToolsManager::Send(G4int nofActiveT,
|
||||
const std::vector<HT*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector)
|
||||
G4bool G4MPIToolsManager::Send(
|
||||
G4int nofActiveT, const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector)
|
||||
{
|
||||
auto result = true;
|
||||
|
||||
@@ -44,13 +43,11 @@ G4bool G4MPIToolsManager::Send(G4int nofActiveT,
|
||||
fHmpi->beg_send(nofActiveT);
|
||||
|
||||
// pack objects
|
||||
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
|
||||
for (const auto& [ht, info] : hnVector) {
|
||||
// skip sending if activation is enabled and HT is inactivated
|
||||
auto info = hnVector[i];
|
||||
if ( ( fState.GetIsActivation() && ( ! info->GetActivation() ) ) ) continue;
|
||||
// pack histogram for sending
|
||||
// G4cout << "Packed " << i << "th T" << G4endl;
|
||||
auto ht = htVector[i];
|
||||
result &= fHmpi->pack(*ht);
|
||||
}
|
||||
|
||||
@@ -68,9 +65,8 @@ G4bool G4MPIToolsManager::Send(G4int nofActiveT,
|
||||
//_____________________________________________________________________________
|
||||
template <typename HT>
|
||||
inline
|
||||
G4bool G4MPIToolsManager::Receive(G4int nofActiveT,
|
||||
const std::vector<HT*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector)
|
||||
G4bool G4MPIToolsManager::Receive(
|
||||
G4int nofActiveT, const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector)
|
||||
{
|
||||
G4int commSize;
|
||||
G4bool result = fHmpi->comm_size(commSize);
|
||||
@@ -109,12 +105,10 @@ G4bool G4MPIToolsManager::Receive(G4int nofActiveT,
|
||||
|
||||
// merge the objects to destination rank
|
||||
G4int counter = 0;
|
||||
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
|
||||
for (const auto& [ht, info] : hnVector) {
|
||||
// skip sending if activation is enabled and HT is inactivated
|
||||
auto info = hnVector[i];
|
||||
if ( ( fState.GetIsActivation() && ( ! info->GetActivation() ) ) ) continue;
|
||||
// merge histograms
|
||||
auto ht = htVector[i];
|
||||
auto newHt = static_cast<HT*>(hs[counter++].second);
|
||||
ht->add(*newHt);
|
||||
}
|
||||
@@ -126,21 +120,21 @@ G4bool G4MPIToolsManager::Receive(G4int nofActiveT,
|
||||
//_____________________________________________________________________________
|
||||
template <typename HT>
|
||||
inline
|
||||
G4bool G4MPIToolsManager::Merge(const std::vector<HT*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector)
|
||||
G4bool G4MPIToolsManager::Merge(
|
||||
const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector)
|
||||
{
|
||||
if ( ! htVector.size() ) return true;
|
||||
if ( hnVector.empty() ) return true;
|
||||
|
||||
// Get number of objects to be sent
|
||||
G4int nofActiveT = 0;
|
||||
if ( fState.GetIsActivation() ) {
|
||||
// only activated histograms will be treated
|
||||
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
|
||||
auto activation = hnVector[i]->GetActivation();
|
||||
for (const auto& htn : hnVector) {
|
||||
auto activation = htn.second->GetActivation();
|
||||
if ( activation ) ++nofActiveT;
|
||||
}
|
||||
} else {
|
||||
nofActiveT = G4int(htVector.size());
|
||||
nofActiveT = G4int(hnVector.size());
|
||||
}
|
||||
|
||||
if ( ! nofActiveT ) return true;
|
||||
@@ -160,7 +154,7 @@ G4bool G4MPIToolsManager::Merge(const std::vector<HT*>& htVector,
|
||||
"on rank " + to_string(commRank) +
|
||||
" destination rank: " + to_string(fHmpi->rank()));
|
||||
|
||||
result &= Send(nofActiveT, htVector, hnVector);
|
||||
result &= Send(nofActiveT, hnVector);
|
||||
|
||||
fState.Message(G4Analysis::kVL1, "mpi send", "Hn|Pn",
|
||||
"on rank " + to_string(commRank) +
|
||||
@@ -171,7 +165,7 @@ G4bool G4MPIToolsManager::Merge(const std::vector<HT*>& htVector,
|
||||
"on rank " + to_string(commRank) +
|
||||
" destination rank: " + to_string(fHmpi->rank()));
|
||||
|
||||
result &= Receive(nofActiveT, htVector, hnVector);
|
||||
result &= Receive(nofActiveT, hnVector);
|
||||
|
||||
fState.Message(G4Analysis::kVL1, "mpi wait_histos", "Hn|Pn",
|
||||
"on rank " + to_string(commRank) +
|
||||
|
||||
@@ -1,197 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Manager class for tools::histo::P1d.
|
||||
// It implements functions specific to the P1 type
|
||||
// (defined in g4tools).
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4P1ToolsManager_h
|
||||
#define G4P1ToolsManager_h 1
|
||||
|
||||
#include "G4VP1Manager.hh"
|
||||
#include "G4THnManager.hh"
|
||||
#include "G4HnManager.hh"
|
||||
#include "G4BinScheme.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace tools {
|
||||
namespace histo {
|
||||
class p1d;
|
||||
}
|
||||
}
|
||||
|
||||
class G4P1ToolsManager : public G4VP1Manager,
|
||||
public G4THnManager<tools::histo::p1d>
|
||||
{
|
||||
public:
|
||||
explicit G4P1ToolsManager(const G4AnalysisManagerState& state);
|
||||
G4P1ToolsManager() = delete;
|
||||
virtual ~G4P1ToolsManager() = default;
|
||||
|
||||
// Method to add profiles read from a file
|
||||
G4int AddP1(const G4String& name, tools::histo::p1d* p1d);
|
||||
// Method for merge (MT)
|
||||
void AddP1Vector(const std::vector<tools::histo::p1d*>& p1Vector);
|
||||
|
||||
// Access methods
|
||||
//
|
||||
tools::histo::p1d* GetP1(G4int id, G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
|
||||
// Iterators
|
||||
std::vector<tools::histo::p1d*>::iterator BeginP1();
|
||||
std::vector<tools::histo::p1d*>::iterator EndP1();
|
||||
std::vector<tools::histo::p1d*>::const_iterator BeginConstP1() const;
|
||||
std::vector<tools::histo::p1d*>::const_iterator EndConstP1() const;
|
||||
|
||||
// Access to profile vector (needed for Write())
|
||||
const std::vector<tools::histo::p1d*>& GetP1Vector() const;
|
||||
const std::vector<G4HnInformation*>& GetHnVector() const;
|
||||
|
||||
protected:
|
||||
// Virtual functions from base class
|
||||
//
|
||||
|
||||
// Methods to create profiles
|
||||
//
|
||||
virtual G4int CreateP1(const G4String& name, const G4String& title,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
G4double ymin = 0, G4double ymax = 0,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& xbinScheme = "linear") final;
|
||||
virtual G4int CreateP1(const G4String& name, const G4String& title,
|
||||
const std::vector<G4double>& edges,
|
||||
G4double ymin = 0, G4double ymax = 0,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none") final;
|
||||
|
||||
virtual G4bool SetP1(G4int id,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
G4double ymin = 0, G4double ymax = 0,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& xbinScheme = "linear") final;
|
||||
virtual G4bool SetP1(G4int id,
|
||||
const std::vector<G4double>& edges,
|
||||
G4double ymin = 0, G4double ymax = 0,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none") final;
|
||||
virtual G4bool ScaleP1(G4int id, G4double factor) final;
|
||||
|
||||
// Method to fill profiles
|
||||
//
|
||||
virtual G4bool FillP1(G4int id, G4double xvalue, G4double yvalue,
|
||||
G4double weight = 1.0) final;
|
||||
|
||||
// Access methods
|
||||
//
|
||||
virtual G4int GetP1Id(const G4String& name, G4bool warn = true) const final;
|
||||
|
||||
// Access to P1 parameters
|
||||
virtual G4int GetP1Nbins(G4int id) const final;
|
||||
virtual G4double GetP1Xmin(G4int id) const final;
|
||||
virtual G4double GetP1Xmax(G4int id) const final;
|
||||
virtual G4double GetP1XWidth(G4int id) const final;
|
||||
virtual G4double GetP1Ymin(G4int id) const final;
|
||||
virtual G4double GetP1Ymax(G4int id) const final;
|
||||
|
||||
// Attributes for plotting
|
||||
//
|
||||
|
||||
// Setters
|
||||
virtual G4bool SetP1Title(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetP1XAxisTitle(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetP1YAxisTitle(G4int id, const G4String& title) final;
|
||||
|
||||
// Accessors
|
||||
virtual G4String GetP1Title(G4int id) const final;
|
||||
virtual G4String GetP1XAxisTitle(G4int id) const final;
|
||||
virtual G4String GetP1YAxisTitle(G4int id) const final;
|
||||
|
||||
// Write data on ASCII file
|
||||
virtual G4bool WriteOnAscii(std::ofstream& output) final;
|
||||
|
||||
// Access to Hn manager
|
||||
virtual std::shared_ptr<G4HnManager> GetHnManager() final;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
//
|
||||
void AddP1Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
G4BinScheme xbinScheme) const;
|
||||
|
||||
// Static data members
|
||||
static constexpr std::string_view fkClass { "G4P1ToolsManager" };
|
||||
static constexpr G4int fkDimension = 2;
|
||||
};
|
||||
|
||||
// inline methods
|
||||
|
||||
inline std::vector<tools::histo::p1d*>::iterator G4P1ToolsManager::BeginP1()
|
||||
{ return BeginT(); }
|
||||
|
||||
inline std::vector<tools::histo::p1d*>::iterator G4P1ToolsManager::EndP1()
|
||||
{ return EndT(); }
|
||||
|
||||
inline std::vector<tools::histo::p1d*>::const_iterator
|
||||
G4P1ToolsManager::BeginConstP1() const
|
||||
{ return BeginConstT(); }
|
||||
|
||||
inline std::vector<tools::histo::p1d*>::const_iterator
|
||||
G4P1ToolsManager::EndConstP1() const
|
||||
{ return EndConstT(); }
|
||||
|
||||
inline const std::vector<tools::histo::p1d*>& G4P1ToolsManager::GetP1Vector() const
|
||||
{ return fTVector; }
|
||||
|
||||
inline const std::vector<G4HnInformation*>& G4P1ToolsManager::GetHnVector() const
|
||||
{ return fHnManager->GetHnVector(); }
|
||||
|
||||
inline std::shared_ptr<G4HnManager> G4P1ToolsManager::GetHnManager()
|
||||
{ return std::shared_ptr<G4HnManager>(fHnManager); }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,220 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Manager class for tools::histo::p2d.
|
||||
// It implements functions specific to the P2 type
|
||||
// (defined in g4tools).
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4P2ToolsManager_h
|
||||
#define G4P2ToolsManager_h 1
|
||||
|
||||
#include "G4VP2Manager.hh"
|
||||
#include "G4THnManager.hh"
|
||||
#include "G4HnManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace tools {
|
||||
namespace histo {
|
||||
class p2d;
|
||||
}
|
||||
}
|
||||
|
||||
class G4P2ToolsManager : public G4VP2Manager,
|
||||
public G4THnManager<tools::histo::p2d>
|
||||
{
|
||||
public:
|
||||
explicit G4P2ToolsManager(const G4AnalysisManagerState& state);
|
||||
G4P2ToolsManager() = delete;
|
||||
virtual ~G4P2ToolsManager() = default;
|
||||
|
||||
// Method to add histograms read from a file
|
||||
G4int AddP2(const G4String& name, tools::histo::p2d* p2d);
|
||||
// Method for merge (MT)
|
||||
void AddP2Vector(const std::vector<tools::histo::p2d*>& p2Vector);
|
||||
|
||||
// Access methods
|
||||
//
|
||||
tools::histo::p2d* GetP2(G4int id, G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
// Iterators
|
||||
std::vector<tools::histo::p2d*>::iterator BeginP2();
|
||||
std::vector<tools::histo::p2d*>::iterator EndP2();
|
||||
std::vector<tools::histo::p2d*>::const_iterator BeginConstP2() const;
|
||||
std::vector<tools::histo::p2d*>::const_iterator EndConstP2() const;
|
||||
|
||||
// Access to histogram vector (needed for Write())
|
||||
const std::vector<tools::histo::p2d*>& GetP2Vector() const;
|
||||
const std::vector<G4HnInformation*>& GetHnVector() const;
|
||||
|
||||
protected:
|
||||
// Virtual functions from base class
|
||||
//
|
||||
|
||||
// Methods to create histograms
|
||||
//
|
||||
virtual G4int CreateP2(const G4String& name, const G4String& title,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
G4double zmin = 0, G4double zmax = 0,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& zunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& zfcnName = "none",
|
||||
const G4String& xbinScheme = "linear",
|
||||
const G4String& ybinScheme = "linear") final;
|
||||
|
||||
virtual G4int CreateP2(const G4String& name, const G4String& title,
|
||||
const std::vector<G4double>& xedges,
|
||||
const std::vector<G4double>& yedges,
|
||||
G4double zmin = 0, G4double zmax = 0,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& zunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& zfcnName = "none") final;
|
||||
|
||||
virtual G4bool SetP2(G4int id,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
G4double zmin = 0, G4double zmax = 0,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& zunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& zfcnName = "none",
|
||||
const G4String& xbinScheme = "linear",
|
||||
const G4String& ybinScheme = "linear") final;
|
||||
|
||||
virtual G4bool SetP2(G4int id,
|
||||
const std::vector<G4double>& xedges,
|
||||
const std::vector<G4double>& yedges,
|
||||
G4double zmin = 0, G4double zmax = 0,
|
||||
const G4String& xunitName = "none",
|
||||
const G4String& yunitName = "none",
|
||||
const G4String& zunitName = "none",
|
||||
const G4String& xfcnName = "none",
|
||||
const G4String& yfcnName = "none",
|
||||
const G4String& zfcnName = "none") final;
|
||||
|
||||
virtual G4bool ScaleP2(G4int id, G4double factor) final;
|
||||
|
||||
// Method to fill histograms
|
||||
//
|
||||
virtual G4bool FillP2(G4int id,
|
||||
G4double xvalue, G4double yvalue, G4double zvalue,
|
||||
G4double weight = 1.0) final;
|
||||
|
||||
|
||||
// Methods to manipulate histograms
|
||||
//
|
||||
|
||||
// Access methods
|
||||
virtual G4int GetP2Id(const G4String& name, G4bool warn = true) const final;
|
||||
|
||||
// Access to P2 parameters
|
||||
virtual G4int GetP2Nxbins(G4int id) const final;
|
||||
virtual G4double GetP2Xmin(G4int id) const final;
|
||||
virtual G4double GetP2Xmax(G4int id) const final;
|
||||
virtual G4double GetP2XWidth(G4int id) const final;
|
||||
virtual G4int GetP2Nybins(G4int id) const final;
|
||||
virtual G4double GetP2Ymin(G4int id) const final;
|
||||
virtual G4double GetP2Ymax(G4int id) const final;
|
||||
virtual G4double GetP2YWidth(G4int id) const final;
|
||||
virtual G4double GetP2Zmin(G4int id) const final;
|
||||
virtual G4double GetP2Zmax(G4int id) const final;
|
||||
|
||||
// Setters for attributes for plotting
|
||||
virtual G4bool SetP2Title(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetP2XAxisTitle(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetP2YAxisTitle(G4int id, const G4String& title) final;
|
||||
virtual G4bool SetP2ZAxisTitle(G4int id, const G4String& title) final;
|
||||
|
||||
// Access attributes for plotting
|
||||
virtual G4String GetP2Title(G4int id) const final;
|
||||
virtual G4String GetP2XAxisTitle(G4int id) const final;
|
||||
virtual G4String GetP2YAxisTitle(G4int id) const final;
|
||||
virtual G4String GetP2ZAxisTitle(G4int id) const final;
|
||||
|
||||
// Write data on ASCII file
|
||||
virtual G4bool WriteOnAscii(std::ofstream& output) final;
|
||||
|
||||
// Access to Hn manager
|
||||
virtual std::shared_ptr<G4HnManager> GetHnManager() final;
|
||||
|
||||
private:
|
||||
void AddP2Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
G4BinScheme xbinScheme,
|
||||
G4BinScheme ybinScheme) const;
|
||||
|
||||
// Static data members
|
||||
static constexpr std::string_view fkClass { "G4P2ToolsManager" };
|
||||
static constexpr G4int fkDimension = 3;
|
||||
};
|
||||
|
||||
// inline methods
|
||||
|
||||
inline std::vector<tools::histo::p2d*>::iterator G4P2ToolsManager::BeginP2()
|
||||
{ return BeginT(); }
|
||||
|
||||
inline std::vector<tools::histo::p2d*>::iterator G4P2ToolsManager::EndP2()
|
||||
{ return EndT(); }
|
||||
|
||||
inline std::vector<tools::histo::p2d*>::const_iterator
|
||||
G4P2ToolsManager::BeginConstP2() const
|
||||
{ return BeginConstT(); }
|
||||
|
||||
inline std::vector<tools::histo::p2d*>::const_iterator
|
||||
G4P2ToolsManager::EndConstP2() const
|
||||
{ return EndConstT(); }
|
||||
|
||||
inline const std::vector<tools::histo::p2d*>& G4P2ToolsManager::GetP2Vector() const
|
||||
{ return fTVector; }
|
||||
|
||||
inline const std::vector<G4HnInformation*>& G4P2ToolsManager::GetHnVector() const
|
||||
{ return fHnManager->GetHnVector(); }
|
||||
|
||||
inline std::shared_ptr<G4HnManager> G4P2ToolsManager::GetHnManager()
|
||||
{ return std::shared_ptr<G4HnManager>(fHnManager); }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// 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 "G4HnInformation.hh"
|
||||
|
||||
#include "tools/viewplot"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
class G4PlotManager
|
||||
{
|
||||
public:
|
||||
explicit G4PlotManager(const G4AnalysisManagerState& state);
|
||||
~G4PlotManager() = default;
|
||||
|
||||
// deleted functions
|
||||
G4PlotManager() = delete;
|
||||
G4PlotManager(const G4PlotManager& rhs) = delete;
|
||||
G4PlotManager& operator=(const G4PlotManager& rhs) = delete;
|
||||
|
||||
public:
|
||||
// Methods
|
||||
G4bool OpenFile(const G4String& fileName);
|
||||
template <typename HT>
|
||||
G4bool PlotAndWrite(const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector);
|
||||
G4bool CloseFile();
|
||||
|
||||
private:
|
||||
// Methods
|
||||
G4int GetNofPlotsPerPage() const;
|
||||
G4bool WritePage();
|
||||
|
||||
// Static data members
|
||||
static constexpr std::string_view fkClass { "G4PlotManager" };
|
||||
|
||||
// Data members
|
||||
const G4AnalysisManagerState& fState;
|
||||
G4PlotParameters fPlotParameters;
|
||||
std::unique_ptr<tools::viewplot> fViewer;
|
||||
G4String fFileName;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline G4int G4PlotManager::GetNofPlotsPerPage() const
|
||||
{ return fPlotParameters.GetColumns()*fPlotParameters.GetRows(); }
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename HT>
|
||||
inline G4bool G4PlotManager::PlotAndWrite(
|
||||
const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector)
|
||||
{
|
||||
if ( ! hnVector.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(fPlotParameters.GetColumns(), fPlotParameters.GetRows());
|
||||
fViewer->plots().set_current_plotter(0);
|
||||
|
||||
auto result = true;
|
||||
auto isWriteNeeded = false;
|
||||
|
||||
for (const auto& [ht, info] : hnVector) {
|
||||
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;
|
||||
|
||||
// plot this object
|
||||
fViewer->plot(*ht);
|
||||
fViewer->set_current_plotter_style(fPlotParameters.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();
|
||||
|
||||
// get axis titles from base_histo (base of all T)
|
||||
G4String title;
|
||||
if ( ht->annotation(tools::histo::key_axis_x_title(), title) ) {
|
||||
plotter.x_axis().title = title;
|
||||
}
|
||||
if ( ht->annotation(tools::histo::key_axis_y_title(), title) ) {
|
||||
plotter.y_axis().title = title;
|
||||
}
|
||||
if ( ht->annotation(tools::histo::key_axis_z_title(), title) ) {
|
||||
plotter.z_axis().title = title;
|
||||
}
|
||||
|
||||
#ifndef TOOLS_USE_FREETYPE
|
||||
plotter.set_encoding_none();
|
||||
#endif
|
||||
|
||||
// get log axis parameters from G4HnInformation
|
||||
if ( info->GetIsLogAxis(G4Analysis::kX) ) {
|
||||
plotter.x_axis().labels_style().encoding = "PAW";
|
||||
plotter.x_axis_is_log = true;
|
||||
}
|
||||
if ( info->GetIsLogAxis(G4Analysis::kY) ) {
|
||||
plotter.y_axis().labels_style().encoding = "PAW";
|
||||
plotter.y_axis_is_log = true;
|
||||
}
|
||||
if ( info->GetIsLogAxis(G4Analysis::kZ) ) {
|
||||
plotter.z_axis().labels_style().encoding = "PAW";
|
||||
plotter.z_axis_is_log = true;
|
||||
}
|
||||
isWriteNeeded = true;
|
||||
|
||||
fState.Message(G4Analysis::kVL3, "plotting", "hd|pd", name);
|
||||
|
||||
// write a page if number of plots per page is achieved
|
||||
if ( G4int(fViewer->plots().current_index()) == (GetNofPlotsPerPage() - 1) ) {
|
||||
result &= WritePage();
|
||||
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 ) {
|
||||
result &= WritePage();
|
||||
}
|
||||
|
||||
// add test of result
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// The messenger class for batch plotting.
|
||||
// It implements commands in /analysis/plot directory.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 21/10/2015 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4PlotMessenger_h
|
||||
#define G4PlotMessenger_h 1
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
class G4PlotParameters;
|
||||
class G4UIdirectory;
|
||||
class G4UIcommand;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIparameter;
|
||||
|
||||
class G4PlotMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
explicit G4PlotMessenger(G4PlotParameters* plotParameters);
|
||||
G4PlotMessenger() = delete;
|
||||
~G4PlotMessenger() override;
|
||||
|
||||
// Methods
|
||||
void SetNewValue(G4UIcommand* command, G4String value) final;
|
||||
|
||||
private:
|
||||
// Helper functions
|
||||
template <typename CMD>
|
||||
std::unique_ptr<CMD> CreateCommand(G4String name, G4String guidance);
|
||||
void AddIntParameter(
|
||||
G4UIcommand& command, G4String name, G4String guidance, G4String range = "");
|
||||
|
||||
// Functions to create commands
|
||||
void SetStyleCmd();
|
||||
void SetLayoutCmd();
|
||||
void SetDimensionsCmd();
|
||||
|
||||
// constants
|
||||
static constexpr std::string_view fkClass { "G4PlotMessenger" };
|
||||
|
||||
// Data members
|
||||
G4PlotParameters* fPlotParameters { nullptr }; ///< Associated class
|
||||
std::unique_ptr<G4UIdirectory> fDirectory;
|
||||
|
||||
std::unique_ptr<G4UIcommand> fSetLayoutCmd;
|
||||
std::unique_ptr<G4UIcommand> fSetDimensionsCmd;
|
||||
std::unique_ptr<G4UIcmdWithAString> fSetStyleCmd;
|
||||
};
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename CMD>
|
||||
std::unique_ptr<CMD> G4PlotMessenger::CreateCommand(
|
||||
G4String name, G4String guidance)
|
||||
{
|
||||
G4String fullName = "/analysis/plot/" + name;
|
||||
|
||||
auto command = std::make_unique<CMD>(fullName, this);
|
||||
command->SetGuidance(guidance.c_str());
|
||||
command->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// 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>
|
||||
#include <string_view>
|
||||
|
||||
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:
|
||||
// Static data members
|
||||
static constexpr std::string_view fkClass { "G4PlotParameters" };
|
||||
static constexpr G4int fkHRDefaultWidth { 2000 };
|
||||
static constexpr G4int fkLRDefaultWidth { 700 };
|
||||
static constexpr G4int fkDefaultColumns { 1 };
|
||||
static constexpr G4int fkDefaultRows { 2 };
|
||||
static constexpr G4float fkDefaultScale { 0.9f };
|
||||
#if defined(TOOLS_USE_FREETYPE)
|
||||
//Have vertical A4 :
|
||||
static constexpr G4int fkDefaultWidth { fkHRDefaultWidth };
|
||||
static constexpr G4int fkDefaultHeight { static_cast<G4int>(29.7f/21.0f*fkHRDefaultWidth) };
|
||||
// limits
|
||||
static constexpr G4int fkMaxColumns { 3 };
|
||||
static constexpr G4int fkMaxRows { 5 };
|
||||
#else
|
||||
//Have vertical A4 :
|
||||
static constexpr G4int fkDefaultWidth { fkLRDefaultWidth };
|
||||
static constexpr G4int fkDefaultHeight { static_cast<G4int>(29.7f/21.0f*fkLRDefaultWidth) };
|
||||
// limits
|
||||
static constexpr G4int fkMaxColumns { 2 };
|
||||
static constexpr G4int fkMaxRows { 3 };
|
||||
#endif
|
||||
|
||||
// Data members
|
||||
std::unique_ptr<G4PlotMessenger> fMessenger;
|
||||
// defaults
|
||||
G4String fDefaultStyle;
|
||||
G4String fAvailableStyles;
|
||||
// data
|
||||
G4int fColumns { fkDefaultColumns };
|
||||
G4int fRows { fkDefaultRows };
|
||||
G4int fWidth { fkDefaultWidth };
|
||||
G4int fHeight { fkDefaultHeight };
|
||||
G4float fScale { fkDefaultScale };
|
||||
G4String fStyle;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
inline G4int G4PlotParameters::GetMaxColumns()
|
||||
{ return fkMaxColumns; }
|
||||
|
||||
inline G4int G4PlotParameters::GetMaxRows()
|
||||
{ return fkMaxRows; }
|
||||
|
||||
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
|
||||
+27
-32
@@ -24,44 +24,39 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Utility functions using tools::histo::base_histo information.
|
||||
// Common implementation for histograms managers.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 22/06/2015 (ivana@ipno.in2p3.fr)
|
||||
// Author: Ivana Hrivnacova, 10/08/2022 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4BaseHistoUtilities_h
|
||||
#define G4BaseHistoUtilities_h 1
|
||||
#ifndef G4TH1ToolsManager_h
|
||||
#define G4TH1ToolsManager_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4THnToolsManager.hh"
|
||||
|
||||
#include "tools/histo/base_histo"
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
tools::histo::h1d* G4THnToolsManager<1, tools::histo::h1d>::CreateToolsHT(
|
||||
const G4String& title,
|
||||
const std::array<G4HnDimension, 1>& bins,
|
||||
const std::array<G4HnDimensionInformation, 1>& hnInfo);
|
||||
|
||||
namespace G4Analysis
|
||||
{
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
void G4THnToolsManager<1, tools::histo::h1d>::ConfigureToolsHT(
|
||||
tools::histo::h1d* ht,
|
||||
const std::array<G4HnDimension, 1>& bins,
|
||||
const std::array<G4HnDimensionInformation, 1>& hnInfo);
|
||||
|
||||
using G4ToolsBaseHisto
|
||||
= tools::histo::base_histo<double, unsigned int, unsigned int, double, double>;
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
G4bool G4THnToolsManager<1, tools::histo::h1d>::FillHT(
|
||||
tools::histo::h1d* ht, const G4HnInformation& hnInformation,
|
||||
std::array<G4double, 1>& value, G4double weight);
|
||||
|
||||
// Access to data parameters
|
||||
//
|
||||
G4int GetNbins(const G4ToolsBaseHisto& baseHisto, G4int dimension);
|
||||
G4double GetMin(const G4ToolsBaseHisto& baseHisto, G4int dimension);
|
||||
G4double GetMax(const G4ToolsBaseHisto& baseHisto, G4int dimension);
|
||||
G4double GetWidth(const G4ToolsBaseHisto& baseHisto, G4int dimension,
|
||||
const G4String& hnType);
|
||||
|
||||
// Attributes for plotting
|
||||
//
|
||||
|
||||
// Setters
|
||||
G4bool SetTitle(G4ToolsBaseHisto& baseHisto, const G4String& title);
|
||||
G4bool SetAxisTitle(G4ToolsBaseHisto& baseHisto, G4int dimension, const G4String& title);
|
||||
|
||||
// Accessors
|
||||
G4String GetTitle(const G4ToolsBaseHisto& baseHisto);
|
||||
G4String GetAxisTitle(const G4ToolsBaseHisto& baseHisto, G4int dimension,
|
||||
const G4String& hnType);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
G4bool G4THnToolsManager<1, tools::histo::h1d>::WriteOnAscii(
|
||||
std::ofstream& output);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Common implementation for histograms managers.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 10/08/2022 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4TH2ToolsManager_h
|
||||
#define G4TH2ToolsManager_h 1
|
||||
|
||||
#include "G4THnToolsManager.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
tools::histo::h2d* G4THnToolsManager<2, tools::histo::h2d>::CreateToolsHT(
|
||||
const G4String& title,
|
||||
const std::array<G4HnDimension, 2>& bins,
|
||||
const std::array<G4HnDimensionInformation, 2>& hnInfo);
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
void G4THnToolsManager<2, tools::histo::h2d>::ConfigureToolsHT(
|
||||
tools::histo::h2d* ht,
|
||||
const std::array<G4HnDimension, 2>& bins,
|
||||
const std::array<G4HnDimensionInformation, 2>& hnInfo);
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
G4bool G4THnToolsManager<2, tools::histo::h2d>::FillHT(
|
||||
tools::histo::h2d* ht, const G4HnInformation& hnInformation,
|
||||
std::array<G4double, 2>& value, G4double weight);
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
G4bool G4THnToolsManager<2, tools::histo::h2d>::WriteOnAscii(
|
||||
std::ofstream& output);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Common implementation for histograms managers.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 10/08/2022 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4TH3ToolsManager_h
|
||||
#define G4TH3ToolsManager_h 1
|
||||
|
||||
#include "G4THnToolsManager.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
tools::histo::h3d* G4THnToolsManager<3, tools::histo::h3d>::CreateToolsHT(
|
||||
const G4String& title,
|
||||
const std::array<G4HnDimension, 3>& bins,
|
||||
const std::array<G4HnDimensionInformation, 3>& hnInfo);
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
void G4THnToolsManager<3, tools::histo::h3d>::ConfigureToolsHT(
|
||||
tools::histo::h3d* ht,
|
||||
const std::array<G4HnDimension, 3>& bins,
|
||||
const std::array<G4HnDimensionInformation, 3>& hnInfo);
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
G4bool G4THnToolsManager<3, tools::histo::h3d>::FillHT(
|
||||
tools::histo::h3d* ht, const G4HnInformation& hnInformation,
|
||||
std::array<G4double, 3>& value, G4double weight);
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
G4bool G4THnToolsManager<3, tools::histo::h3d>::WriteOnAscii(
|
||||
std::ofstream& output);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Common implementation for histograms managers.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 10/08/2022 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4TH2ToolsManager_h
|
||||
#define G4TH2ToolsManager_h 1
|
||||
|
||||
#include "G4THnToolsManager.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
tools::histo::p1d* G4THnToolsManager<2, tools::histo::p1d>::CreateToolsHT(
|
||||
const G4String& title,
|
||||
const std::array<G4HnDimension, 2>& bins,
|
||||
const std::array<G4HnDimensionInformation, 2>& hnInfo);
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
void G4THnToolsManager<2, tools::histo::p1d>::ConfigureToolsHT(
|
||||
tools::histo::p1d* ht,
|
||||
const std::array<G4HnDimension, 2>& bins,
|
||||
const std::array<G4HnDimensionInformation, 2>& hnInfo);
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
G4bool G4THnToolsManager<2, tools::histo::p1d>::FillHT(
|
||||
tools::histo::p1d* ht, const G4HnInformation& hnInformation,
|
||||
std::array<G4double, 2>& value, G4double weight);
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
G4bool G4THnToolsManager<2, tools::histo::p1d>::WriteOnAscii(
|
||||
std::ofstream& output);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Common implementation for histograms managers.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 10/08/2022 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4TH2ToolsManager_h
|
||||
#define G4TH2ToolsManager_h 1
|
||||
|
||||
#include "G4THnToolsManager.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
tools::histo::p2d* G4THnToolsManager<3, tools::histo::p2d>::CreateToolsHT(
|
||||
const G4String& title,
|
||||
const std::array<G4HnDimension, 3>& bins,
|
||||
const std::array<G4HnDimensionInformation, 3>& hnInfo,
|
||||
std::string_view className);
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
void G4THnToolsManager<3, tools::histo::p2d>::ConfigureToolsHT(
|
||||
tools::histo::p2d* ht,
|
||||
const std::array<G4HnDimension, 3>& bins,
|
||||
const std::array<G4HnDimensionInformation, 3>& hnInfo,
|
||||
std::string_view className);
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
G4bool G4THnToolsManager<3, tools::histo::p2d>::FillHT(
|
||||
tools::histo::p2d* ht, const G4HnInformation& hnInformation,
|
||||
std::array<G4double, 3>& value, G4double weight);
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
G4bool G4THnToolsManager<3, tools::histo::p2d>::WriteOnAscii(
|
||||
std::ofstream& output);
|
||||
|
||||
#endif
|
||||
@@ -32,9 +32,15 @@
|
||||
#define G4ToolsAnalysisManager_h 1
|
||||
|
||||
#include "G4VAnalysisManager.hh"
|
||||
#include "G4ToolsAnalysisMessenger.hh"
|
||||
#include "G4TH1ToolsManager.hh"
|
||||
#include "G4TH2ToolsManager.hh"
|
||||
#include "G4TH3ToolsManager.hh"
|
||||
#include "G4TP1ToolsManager.hh"
|
||||
#include "G4TP2ToolsManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "G4THnToolsManager.hh" // make forward declaration if possible
|
||||
|
||||
#include "tools/histo/h1d"
|
||||
#include "tools/histo/h2d"
|
||||
#include "tools/histo/h3d"
|
||||
@@ -43,11 +49,7 @@
|
||||
|
||||
#include <string_view>
|
||||
|
||||
class G4H1ToolsManager;
|
||||
class G4H2ToolsManager;
|
||||
class G4H3ToolsManager;
|
||||
class G4P1ToolsManager;
|
||||
class G4P2ToolsManager;
|
||||
class G4PlotManager;
|
||||
|
||||
namespace tools {
|
||||
namespace histo {
|
||||
@@ -60,9 +62,9 @@ class G4ToolsAnalysisManager : public G4VAnalysisManager
|
||||
friend class G4ToolsAnalysisMessenger;
|
||||
|
||||
public:
|
||||
virtual ~G4ToolsAnalysisManager();
|
||||
~G4ToolsAnalysisManager() override;
|
||||
|
||||
// Static methods
|
||||
// Static methods
|
||||
static G4ToolsAnalysisManager* Instance();
|
||||
static G4bool IsInstance();
|
||||
|
||||
@@ -108,14 +110,16 @@ class G4ToolsAnalysisManager : public G4VAnalysisManager
|
||||
explicit G4ToolsAnalysisManager(const G4String& type);
|
||||
|
||||
// Virtual methods from base class
|
||||
virtual G4bool PlotImpl() final;
|
||||
virtual G4bool MergeImpl(tools::histo::hmpi* hmpi) final;
|
||||
virtual G4bool WriteImpl() override;
|
||||
virtual G4bool ResetImpl() override;
|
||||
virtual void ClearImpl() override;
|
||||
G4bool OpenFileImpl(const G4String& fileName) override;
|
||||
G4bool WriteImpl() override;
|
||||
G4bool CloseFileImpl(G4bool reset) override;
|
||||
G4bool ResetImpl() override;
|
||||
void ClearImpl() override;
|
||||
G4bool PlotImpl() final;
|
||||
G4bool MergeImpl(tools::histo::hmpi* hmpi) final;
|
||||
G4bool IsOpenFileImpl() const final;
|
||||
|
||||
// Methods
|
||||
G4bool Merge();
|
||||
G4bool IsEmpty();
|
||||
|
||||
// Static data members
|
||||
@@ -124,22 +128,25 @@ class G4ToolsAnalysisManager : public G4VAnalysisManager
|
||||
static constexpr std::string_view fkClass { "G4ToolsAnalysisManager" };
|
||||
|
||||
// Data members
|
||||
G4H1ToolsManager* fH1Manager { nullptr };
|
||||
G4H2ToolsManager* fH2Manager { nullptr };
|
||||
G4H3ToolsManager* fH3Manager { nullptr };
|
||||
G4P1ToolsManager* fP1Manager { nullptr };
|
||||
G4P2ToolsManager* fP2Manager { nullptr };
|
||||
G4THnToolsManager<kDim1, tools::histo::h1d>* fH1Manager { nullptr };
|
||||
G4THnToolsManager<kDim2, tools::histo::h2d>* fH2Manager { nullptr };
|
||||
G4THnToolsManager<kDim3, tools::histo::h3d>* fH3Manager { nullptr };
|
||||
G4THnToolsManager<kDim2, tools::histo::p1d>* fP1Manager { nullptr };
|
||||
G4THnToolsManager<kDim3, tools::histo::p2d>* fP2Manager { nullptr };
|
||||
|
||||
private:
|
||||
// // Static data members
|
||||
// Static G4ThreadLocal G4ToolsAnalysisManager* fgToolsInstance;
|
||||
// Methods
|
||||
template <typename HT>
|
||||
G4bool WriteT(const std::vector<HT*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector);
|
||||
G4bool WriteT(const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector);
|
||||
|
||||
G4bool WriteHns();
|
||||
G4bool ResetHns();
|
||||
G4bool MergeHns();
|
||||
|
||||
// Data members
|
||||
std::unique_ptr<G4ToolsAnalysisMessenger> fMessenger;
|
||||
std::shared_ptr<G4PlotManager> fPlotManager { nullptr };
|
||||
};
|
||||
|
||||
#include "G4ToolsAnalysisManager.icc"
|
||||
|
||||
@@ -25,29 +25,22 @@
|
||||
//
|
||||
|
||||
#include "G4HnInformation.hh"
|
||||
#include "G4H1ToolsManager.hh"
|
||||
#include "G4H2ToolsManager.hh"
|
||||
#include "G4H3ToolsManager.hh"
|
||||
#include "G4P1ToolsManager.hh"
|
||||
#include "G4P2ToolsManager.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename HT>
|
||||
inline
|
||||
G4bool G4ToolsAnalysisManager::WriteT(const std::vector<HT*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector)
|
||||
G4bool G4ToolsAnalysisManager::WriteT(
|
||||
const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector)
|
||||
{
|
||||
auto result = true;
|
||||
|
||||
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
|
||||
auto info = hnVector[i];
|
||||
for ( auto& [ht, info] : hnVector) {
|
||||
auto activation = info->GetActivation();
|
||||
|
||||
// skip writing if activation is enabled and H1 is inactivated
|
||||
if ( fState.GetIsActivation() && ( ! activation ) ) continue;
|
||||
|
||||
auto name = info->GetName();
|
||||
auto ht = htVector[i];
|
||||
|
||||
auto fileName = info->GetFileName();
|
||||
auto fileManager = GetFileManager(fileName);
|
||||
|
||||
@@ -67,10 +60,15 @@ G4bool G4ToolsAnalysisManager::WriteT(const std::vector<HT*>& htVector,
|
||||
fileName = fileManager->GetFullFileName();
|
||||
}
|
||||
|
||||
// update name with a cycle number
|
||||
if (! fileManager->HasCycles() && fState.GetCycle() > 0) {
|
||||
name += "_v" + std::to_string(fState.GetCycle());
|
||||
}
|
||||
|
||||
Message(G4Analysis::kVL4, "write", G4Analysis::GetHnType<HT>(),
|
||||
name + fileKind + fileName);
|
||||
|
||||
if ( ! fileManager->GetHnFileManager<HT>()->Write(ht, name, fileName) ) {
|
||||
if ( ! fileManager->template GetHnFileManager<HT>()->Write(ht, name, fileName) ) {
|
||||
G4Analysis::Warn(
|
||||
"Writing " + G4Analysis::GetHnType<HT>() + " " + name +
|
||||
" to file " + fileName + " failed.",
|
||||
@@ -78,8 +76,10 @@ G4bool G4ToolsAnalysisManager::WriteT(const std::vector<HT*>& htVector,
|
||||
result = false;
|
||||
}
|
||||
|
||||
// notify that file has a written object
|
||||
fileManager->SetIsEmpty(fileName, false);
|
||||
if (result) {
|
||||
// notify that file has a written object
|
||||
fileManager->SetIsEmpty(fileName, false);
|
||||
}
|
||||
|
||||
Message(G4Analysis::kVL3, "write", G4Analysis::GetHnType<HT>(),
|
||||
name + " in the " + fileKind + " file " + fileName);
|
||||
@@ -88,12 +88,19 @@ G4bool G4ToolsAnalysisManager::WriteT(const std::vector<HT*>& htVector,
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
G4bool G4ToolsAnalysisManager::IsOpenFileImpl() const
|
||||
{
|
||||
return fVFileManager->IsOpenFile();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::h1d* G4ToolsAnalysisManager::GetH1(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return fH1Manager->GetH1(id, warn, onlyIfActive);
|
||||
return fH1Manager->GetT(id, warn, onlyIfActive);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -101,7 +108,7 @@ inline
|
||||
tools::histo::h2d* G4ToolsAnalysisManager::GetH2(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return fH2Manager->GetH2(id, warn, onlyIfActive);
|
||||
return fH2Manager->GetT(id, warn, onlyIfActive);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -109,7 +116,7 @@ inline
|
||||
tools::histo::h3d* G4ToolsAnalysisManager::GetH3(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return fH3Manager->GetH3(id, warn, onlyIfActive);
|
||||
return fH3Manager->GetT(id, warn, onlyIfActive);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -117,7 +124,7 @@ inline
|
||||
tools::histo::p1d* G4ToolsAnalysisManager::GetP1(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return fP1Manager->GetP1(id, warn, onlyIfActive);
|
||||
return fP1Manager->GetT(id, warn, onlyIfActive);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -125,21 +132,21 @@ inline
|
||||
tools::histo::p2d* G4ToolsAnalysisManager::GetP2(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return fP2Manager->GetP2(id, warn, onlyIfActive);
|
||||
return fP2Manager->GetT(id, warn, onlyIfActive);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::BeginH1()
|
||||
{
|
||||
return fH1Manager->BeginH1();
|
||||
return fH1Manager->BeginT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::EndH1()
|
||||
{
|
||||
return fH1Manager->EndH1();
|
||||
return fH1Manager->EndT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -147,7 +154,7 @@ inline
|
||||
std::vector<tools::histo::h1d*>::const_iterator
|
||||
G4ToolsAnalysisManager::BeginConstH1() const
|
||||
{
|
||||
return fH1Manager->BeginConstH1();
|
||||
return fH1Manager->BeginConstT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -155,21 +162,21 @@ inline
|
||||
std::vector<tools::histo::h1d*>::const_iterator
|
||||
G4ToolsAnalysisManager::EndConstH1() const
|
||||
{
|
||||
return fH1Manager->EndConstH1();
|
||||
return fH1Manager->EndConstT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::BeginH2()
|
||||
{
|
||||
return fH2Manager->BeginH2();
|
||||
return fH2Manager->BeginT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::EndH2()
|
||||
{
|
||||
return fH2Manager->EndH2();
|
||||
return fH2Manager->EndT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -177,7 +184,7 @@ inline
|
||||
std::vector<tools::histo::h2d*>::const_iterator
|
||||
G4ToolsAnalysisManager::BeginConstH2() const
|
||||
{
|
||||
return fH2Manager->BeginConstH2();
|
||||
return fH2Manager->BeginConstT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -185,21 +192,21 @@ inline
|
||||
std::vector<tools::histo::h2d*>::const_iterator
|
||||
G4ToolsAnalysisManager::EndConstH2() const
|
||||
{
|
||||
return fH2Manager->EndConstH2();
|
||||
return fH2Manager->EndConstT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::BeginH3()
|
||||
{
|
||||
return fH3Manager->BeginH3();
|
||||
return fH3Manager->BeginT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::EndH3()
|
||||
{
|
||||
return fH3Manager->EndH3();
|
||||
return fH3Manager->EndT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -207,7 +214,7 @@ inline
|
||||
std::vector<tools::histo::h3d*>::const_iterator
|
||||
G4ToolsAnalysisManager::BeginConstH3() const
|
||||
{
|
||||
return fH3Manager->BeginConstH3();
|
||||
return fH3Manager->BeginConstT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -215,21 +222,21 @@ inline
|
||||
std::vector<tools::histo::h3d*>::const_iterator
|
||||
G4ToolsAnalysisManager::EndConstH3() const
|
||||
{
|
||||
return fH3Manager->EndConstH3();
|
||||
return fH3Manager->EndConstT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::BeginP1()
|
||||
{
|
||||
return fP1Manager->BeginP1();
|
||||
return fP1Manager->BeginT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::EndP1()
|
||||
{
|
||||
return fP1Manager->EndP1();
|
||||
return fP1Manager->EndT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -237,7 +244,7 @@ inline
|
||||
std::vector<tools::histo::p1d*>::const_iterator
|
||||
G4ToolsAnalysisManager::BeginConstP1() const
|
||||
{
|
||||
return fP1Manager->BeginConstP1();
|
||||
return fP1Manager->BeginConstT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -245,21 +252,21 @@ inline
|
||||
std::vector<tools::histo::p1d*>::const_iterator
|
||||
G4ToolsAnalysisManager::EndConstP1() const
|
||||
{
|
||||
return fP1Manager->EndConstP1();
|
||||
return fP1Manager->EndConstT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::BeginP2()
|
||||
{
|
||||
return fP2Manager->BeginP2();
|
||||
return fP2Manager->BeginT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::EndP2()
|
||||
{
|
||||
return fP2Manager->EndP2();
|
||||
return fP2Manager->EndT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -267,7 +274,7 @@ inline
|
||||
std::vector<tools::histo::p2d*>::const_iterator
|
||||
G4ToolsAnalysisManager::BeginConstP2() const
|
||||
{
|
||||
return fP2Manager->BeginConstP2();
|
||||
return fP2Manager->BeginConstT();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -275,6 +282,5 @@ inline
|
||||
std::vector<tools::histo::p2d*>::const_iterator
|
||||
G4ToolsAnalysisManager::EndConstP2() const
|
||||
{
|
||||
return fP2Manager->EndConstP2();
|
||||
return fP2Manager->EndConstT();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,118 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// The messenger class for tools objects getters.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 29/10/2021 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4ToolsAnalysisMessenger_h
|
||||
#define G4ToolsAnalysisMessenger_h 1
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
#include "G4THnManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class G4ToolsAnalysisManager;
|
||||
class G4UIcommand;
|
||||
|
||||
class G4ToolsAnalysisMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
explicit G4ToolsAnalysisMessenger(G4ToolsAnalysisManager* manager);
|
||||
virtual ~G4ToolsAnalysisMessenger();
|
||||
|
||||
// Methods
|
||||
G4String GetCurrentValue (G4UIcommand* command);
|
||||
virtual void SetNewValue(G4UIcommand* command, G4String value) final;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
template <typename HT>
|
||||
G4String GetHnAddress(G4int id, G4THnManager<HT>* htManager) const;
|
||||
template <typename HT>
|
||||
G4String GetHnVectorAddress(G4THnManager<HT>* htManager) const;
|
||||
|
||||
// Data members
|
||||
G4ToolsAnalysisManager* fManager; ///< Associated class
|
||||
|
||||
// analysis/hn|pn/get command
|
||||
std::unique_ptr<G4UIcommand> fGetH1Cmd;
|
||||
std::unique_ptr<G4UIcommand> fGetH2Cmd;
|
||||
std::unique_ptr<G4UIcommand> fGetH3Cmd;
|
||||
std::unique_ptr<G4UIcommand> fGetP1Cmd;
|
||||
std::unique_ptr<G4UIcommand> fGetP2Cmd;
|
||||
G4String fH1Value;
|
||||
G4String fH2Value;
|
||||
G4String fH3Value;
|
||||
G4String fP1Value;
|
||||
G4String fP2Value;
|
||||
|
||||
// analysis/hn|pn/getVector command
|
||||
std::unique_ptr<G4UIcommand> fGetH1VectorCmd;
|
||||
std::unique_ptr<G4UIcommand> fGetH2VectorCmd;
|
||||
std::unique_ptr<G4UIcommand> fGetH3VectorCmd;
|
||||
std::unique_ptr<G4UIcommand> fGetP1VectorCmd;
|
||||
std::unique_ptr<G4UIcommand> fGetP2VectorCmd;
|
||||
G4String fH1VectorValue;
|
||||
G4String fH2VectorValue;
|
||||
G4String fH3VectorValue;
|
||||
G4String fP1VectorValue;
|
||||
G4String fP2VectorValue;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
template <typename HT>
|
||||
inline
|
||||
G4String G4ToolsAnalysisMessenger::GetHnAddress(
|
||||
G4int id, G4THnManager<HT>* htManager) const
|
||||
{
|
||||
auto ht = htManager->GetT(id);
|
||||
if ( ht != nullptr ) {
|
||||
std::ostringstream os;
|
||||
os << static_cast<void*>(ht);
|
||||
return os.str();
|
||||
}
|
||||
return G4String();
|
||||
}
|
||||
|
||||
template <typename HT>
|
||||
inline
|
||||
G4String G4ToolsAnalysisMessenger::GetHnVectorAddress(
|
||||
G4THnManager<HT>* htManager) const
|
||||
{
|
||||
auto htVector = htManager->GetTVector();
|
||||
if ( htVector != nullptr ) {
|
||||
std::ostringstream os;
|
||||
os << static_cast<void*>(htVector);
|
||||
return os.str();
|
||||
}
|
||||
return G4String();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -35,16 +35,14 @@
|
||||
#include "G4THnManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "G4THnToolsManager.hh" // TO DO: make forward declaration if possible
|
||||
|
||||
#include "tools/histo/h1d"
|
||||
#include "tools/histo/h2d"
|
||||
#include "tools/histo/h3d"
|
||||
#include "tools/histo/p1d"
|
||||
#include "tools/histo/p2d"
|
||||
|
||||
class G4H1ToolsManager;
|
||||
class G4H2ToolsManager;
|
||||
class G4H3ToolsManager;
|
||||
class G4P1ToolsManager;
|
||||
class G4P2ToolsManager;
|
||||
|
||||
namespace tools {
|
||||
@@ -56,7 +54,7 @@ class hmpi;
|
||||
class G4ToolsAnalysisReader : public G4VAnalysisReader
|
||||
{
|
||||
public:
|
||||
virtual ~G4ToolsAnalysisReader() = default;
|
||||
~G4ToolsAnalysisReader() override = default;
|
||||
|
||||
// Access methods
|
||||
tools::histo::h1d* GetH1(G4int id, G4bool warn = true) const;
|
||||
@@ -69,16 +67,16 @@ class G4ToolsAnalysisReader : public G4VAnalysisReader
|
||||
explicit G4ToolsAnalysisReader(const G4String& type);
|
||||
|
||||
// Virtual methods from base class
|
||||
virtual G4int ReadH1Impl(const G4String& h1Name, const G4String& fileName,
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
virtual G4int ReadH2Impl(const G4String& h2Name, const G4String& fileName,
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
virtual G4int ReadH3Impl(const G4String& h3Name, const G4String& fileName,
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
virtual G4int ReadP1Impl(const G4String& p1Name, const G4String& fileName,
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
virtual G4int ReadP2Impl(const G4String& p2Name, const G4String& fileName,
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
G4int ReadH1Impl(const G4String& h1Name, const G4String& fileName, const G4String& dirName,
|
||||
G4bool isUserFileName) final;
|
||||
G4int ReadH2Impl(const G4String& h2Name, const G4String& fileName, const G4String& dirName,
|
||||
G4bool isUserFileName) final;
|
||||
G4int ReadH3Impl(const G4String& h3Name, const G4String& fileName, const G4String& dirName,
|
||||
G4bool isUserFileName) final;
|
||||
G4int ReadP1Impl(const G4String& p1Name, const G4String& fileName, const G4String& dirName,
|
||||
G4bool isUserFileName) final;
|
||||
G4int ReadP2Impl(const G4String& p2Name, const G4String& fileName, const G4String& dirName,
|
||||
G4bool isUserFileName) final;
|
||||
|
||||
// Fuction specific to output type
|
||||
template <typename HT>
|
||||
@@ -93,14 +91,13 @@ class G4ToolsAnalysisReader : public G4VAnalysisReader
|
||||
static constexpr std::string_view fkClass { "G4ToolsAnalysisReader" };
|
||||
|
||||
// Data members
|
||||
G4H1ToolsManager* fH1Manager { nullptr };
|
||||
G4H2ToolsManager* fH2Manager { nullptr };
|
||||
G4H3ToolsManager* fH3Manager { nullptr };
|
||||
G4P1ToolsManager* fP1Manager { nullptr };
|
||||
G4P2ToolsManager* fP2Manager { nullptr };
|
||||
G4THnToolsManager<1, tools::histo::h1d>* fH1Manager { nullptr };
|
||||
G4THnToolsManager<2, tools::histo::h2d>* fH2Manager { nullptr };
|
||||
G4THnToolsManager<3, tools::histo::h3d>* fH3Manager { nullptr };
|
||||
G4THnToolsManager<2, tools::histo::p1d>* fP1Manager { nullptr };
|
||||
G4THnToolsManager<3, tools::histo::p2d>* fP2Manager { nullptr };
|
||||
};
|
||||
|
||||
#include "G4ToolsAnalysisReader.icc"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -24,11 +24,6 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
#include "G4H1ToolsManager.hh"
|
||||
#include "G4H2ToolsManager.hh"
|
||||
#include "G4H3ToolsManager.hh"
|
||||
#include "G4P1ToolsManager.hh"
|
||||
#include "G4P2ToolsManager.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -53,7 +48,7 @@ G4int G4ToolsAnalysisReader::ReadTImpl(
|
||||
return G4Analysis::kInvalidId;
|
||||
}
|
||||
|
||||
auto id = htManager->RegisterT(static_cast<HT*>(ht), htName);
|
||||
auto id = htManager->RegisterT(htName, static_cast<HT*>(ht));
|
||||
|
||||
Message(G4Analysis::kVL2, "read", G4Analysis::GetHnType<HT>(), htName,
|
||||
id > G4Analysis::kInvalidId);
|
||||
@@ -66,33 +61,33 @@ G4int G4ToolsAnalysisReader::ReadTImpl(
|
||||
inline
|
||||
tools::histo::h1d* G4ToolsAnalysisReader::GetH1(G4int id, G4bool warn) const
|
||||
{
|
||||
return fH1Manager->GetH1(id, warn, false);
|
||||
return fH1Manager->GetT(id, warn, false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::h2d* G4ToolsAnalysisReader::GetH2(G4int id, G4bool warn) const
|
||||
{
|
||||
return fH2Manager->GetH2(id, warn, false);
|
||||
return fH2Manager->GetT(id, warn, false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::h3d* G4ToolsAnalysisReader::GetH3(G4int id, G4bool warn) const
|
||||
{
|
||||
return fH3Manager->GetH3(id, warn, false);
|
||||
return fH3Manager->GetT(id, warn, false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::p1d* G4ToolsAnalysisReader::GetP1(G4int id, G4bool warn) const
|
||||
{
|
||||
return fP1Manager->GetP1(id, warn, false);
|
||||
return fP1Manager->GetT(id, warn, false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::p2d* G4ToolsAnalysisReader::GetP2(G4int id, G4bool warn) const
|
||||
{
|
||||
return fP2Manager->GetP2(id, warn, false);
|
||||
return fP2Manager->GetT(id, warn, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user