Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:45

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 // The messenger class for ntuple management.
0028 // It implements commands in /analysis/ntuple directory.
0029 // It is asscoiciated with G4VAnalysisManager and this delegates
0030 // call to both ntuple booking and ntuple managers.
0031 //
0032 // Author: Ivana Hrivnacova, 05/05/2015  (ivana@ipno.in2p3.fr)
0033 
0034 #ifndef G4NtupleMessenger_h
0035 #define G4NtupleMessenger_h 1
0036 
0037 #include "G4AnalysisUtilities.hh"
0038 #include "G4UImessenger.hh"
0039 #include "globals.hh"
0040 
0041 #include <map>
0042 #include <memory>
0043 #include <string_view>
0044 
0045 class G4VAnalysisManager;
0046 class G4UIcommand;
0047 class G4UIcmdWithABool;
0048 class G4UIcmdWithAString;
0049 
0050 class G4NtupleMessenger : public G4UImessenger
0051 {
0052   public:
0053     explicit G4NtupleMessenger(G4VAnalysisManager* manager);
0054     G4NtupleMessenger() = delete;
0055     ~G4NtupleMessenger() override;
0056 
0057     // Methods
0058     void SetNewValue(G4UIcommand* command, G4String value) final;
0059 
0060   private:
0061     // Methods
0062     template <typename CMD>
0063     std::unique_ptr<CMD> CreateCommand(G4String name, G4String guidance);
0064     void AddIdParameter(G4UIcommand& command);
0065 
0066     void CreateCmd();
0067     void CreateColumnCmds();
0068     void FinishCmd();
0069     void DeleteCmd();
0070     void SetActivationCmd();
0071     void SetActivationToAllCmd();
0072     void SetFileNameCmd();
0073     void SetFileNameToAllCmd();
0074     void ListCmd();
0075 
0076     // Static data members
0077     static constexpr std::string_view fkClass { "G4NtupleMessenger" };
0078 
0079     // Data members
0080     G4VAnalysisManager*  fManager { nullptr }; ///< Associated class
0081 
0082     std::unique_ptr<G4UIdirectory>      fNtupleDir;
0083     std::unique_ptr<G4UIcommand>        fCreateCmd;
0084     std::map<char, std::unique_ptr<G4UIcommand>> fCreateColumnCmds;
0085     std::unique_ptr<G4UIcommand>        fFinishCmd;
0086     std::unique_ptr<G4UIcommand>        fDeleteCmd;
0087     std::unique_ptr<G4UIcommand>        fSetActivationCmd;
0088     std::unique_ptr<G4UIcmdWithABool>   fSetActivationAllCmd;
0089     std::unique_ptr<G4UIcommand>        fSetFileNameCmd;
0090     std::unique_ptr<G4UIcmdWithAString> fSetFileNameAllCmd;
0091     std::unique_ptr<G4UIcommand>        fListCmd;
0092     G4int fTmpNtupleId { G4Analysis::kInvalidId };
0093 };
0094 
0095 //_____________________________________________________________________________
0096 template <typename CMD>
0097 std::unique_ptr<CMD> G4NtupleMessenger::CreateCommand(
0098   G4String name, G4String guidance)
0099 {
0100   G4String fullName = "/analysis/ntuple/" + name;
0101 
0102   auto command = std::make_unique<CMD>(fullName, this);
0103   command->SetGuidance(guidance.c_str());
0104   command->AvailableForStates(G4State_PreInit, G4State_Idle);
0105 
0106   return command;
0107 }
0108 
0109 #endif