Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:11

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 
0027 // Common implementation for histograms messengers.
0028 // It implements commands in /analysis/hn|pn directories
0029 //
0030 // Author: Ivana Hrivnacova, 26/08/2022  (ivana@ipno.in2p3.fr)
0031 
0032 #ifndef G4THnMessenger_h
0033 #define G4THnMessenger_h 1
0034 
0035 #include "G4UImessenger.hh"
0036 #include "globals.hh"
0037 
0038 #include <memory>
0039 #include <array>
0040 #include <vector>
0041 #include <string_view>
0042 
0043 class G4VAnalysisManager;
0044 class G4UIdirectory;
0045 class G4UIcommand;
0046 struct G4HnDimension;
0047 struct G4HnDimensionInformation;
0048 
0049 template <unsigned int DIM, typename HT>
0050 class G4THnToolsManager;
0051 
0052 template <unsigned int DIM, typename HT>
0053 class G4THnMessenger : public G4UImessenger
0054 {
0055   public:
0056     G4THnMessenger(G4THnToolsManager<DIM,HT>* manager);
0057     G4THnMessenger() = delete;
0058     ~G4THnMessenger() override = default;
0059 
0060     // Methods
0061     G4String GetCurrentValue(G4UIcommand* command) final;
0062     void SetNewValue(G4UIcommand* command, G4String value) final;
0063 
0064   private:
0065     // Helper functions
0066     G4String GetObjectType() const;
0067     G4bool IsProfileLastDimension(unsigned int idim) const;
0068     std::unique_ptr<G4UIcommand> CreateCommand(G4String name, G4String guideline);
0069     void CreateDimensionParameters(unsigned int idim, 
0070            std::vector<G4UIparameter*>& parameters) const;
0071     void AddIdParameter(G4UIcommand& command);
0072     G4String GetTAddress(G4int id) const;
0073     G4String GetTVectorAddress() const;
0074 
0075     // Functions to create commands
0076     void CreateDirectory() const;
0077     void CreateCmd();
0078     void SetCmd();
0079     void DeleteCmd();
0080     std::unique_ptr<G4UIcommand> CreateSetBinsCommand(unsigned int ibin);
0081     void CreateSetTitleCommand();
0082     std::unique_ptr<G4UIcommand> CreateSetAxisCommand(unsigned int ibin);
0083     void CreateListCommand();
0084     void CreateGetCommand();
0085     void CreateGetVectorCommand();
0086 
0087     // Functions to retrieve data
0088     void GetBinData(unsigned int idim, G4int& counter, 
0089            const std::vector<G4String>& parameters, G4HnDimension& bins) const;
0090     void GetBinInfoData(unsigned int idim, G4int& counter, 
0091            const std::vector<G4String>& parameters, G4HnDimension& bins, 
0092            G4HnDimensionInformation& info) const;
0093     void GetData(G4int& counter, const std::vector<G4String>& parameters,
0094            std::array<G4HnDimension, DIM>& bins,
0095            std::array<G4HnDimensionInformation, DIM>& info) const;
0096 
0097     // constants
0098     static constexpr std::string_view fkClass { "G4THnMessenger" };
0099 
0100     // Data members
0101     G4THnToolsManager<DIM,HT>* fManager { nullptr }; ///< Associated class
0102 
0103     std::unique_ptr<G4UIcommand>  fCreateCmd;
0104     std::unique_ptr<G4UIcommand>  fSetCmd;
0105     std::unique_ptr<G4UIcommand>  fDeleteCmd;
0106     std::array<std::unique_ptr<G4UIcommand>, DIM>  fSetDimensionCmd;
0107     std::unique_ptr<G4UIcommand>  fSetTitleCmd;
0108     std::array<std::unique_ptr<G4UIcommand>, DIM+1> fSetAxisCmd;
0109     std::unique_ptr<G4UIcommand>  fListCmd;
0110     std::unique_ptr<G4UIcommand>  fGetTCmd;
0111     std::unique_ptr<G4UIcommand>  fGetTVectorCmd;
0112 
0113     std::array<unsigned int, DIM> fTmpId;
0114     std::array<G4HnDimension, DIM> fTmpBins;
0115     std::array<G4HnDimensionInformation, DIM> fTmpInfo;
0116 
0117     G4String fTValue;
0118     G4String fTVectorValue;
0119 };
0120 
0121 // #include "G4THnMessenger.icc"
0122     // to avoid include recursion the implementation is included in G4THnToolsManager.hh
0123 
0124 #endif