Geant4  10.03
G4AnalysisMessenger.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4AnalysisMessenger.cc 66310 2012-12-17 11:56:35Z ihrivnac $
27 
28 // Author: Ivana Hrivnacova, 24/06/2013 (ivana@ipno.in2p3.fr)
29 
30 #include "G4AnalysisMessenger.hh"
31 #include "G4VAnalysisManager.hh"
32 #include "G4FileMessenger.hh"
33 #include "G4H1Messenger.hh"
34 #include "G4H2Messenger.hh"
35 #include "G4H3Messenger.hh"
36 #include "G4P1Messenger.hh"
37 #include "G4P2Messenger.hh"
38 #include "G4NtupleMessenger.hh"
39 #include "G4HnMessenger.hh"
40 #include "G4AnalysisUtilities.hh"
41 
42 #include "G4UIcmdWithABool.hh"
43 #include "G4UIcmdWithAnInteger.hh"
44 
45 using namespace G4Analysis;
46 
47 //_____________________________________________________________________________
49  : G4UImessenger(),
50  fManager(manager),
51  fFileMessenger(nullptr),
52  fH1Messenger(nullptr),
53  fH2Messenger(nullptr),
54  fH3Messenger(nullptr),
55  fP1Messenger(nullptr),
56  fP2Messenger(nullptr),
57  fNtupleMessenger(nullptr),
58  fH1HnMessenger(nullptr),
59  fH2HnMessenger(nullptr),
60  fH3HnMessenger(nullptr),
61  fP1HnMessenger(nullptr),
62  fP2HnMessenger(nullptr),
63  fAnalysisDir(nullptr),
64  fSetActivationCmd(nullptr),
65  fVerboseCmd(nullptr),
66  fCompressionCmd(nullptr)
67 {
68  fAnalysisDir = G4Analysis::make_unique<G4UIdirectory>("/analysis/");
69  fAnalysisDir->SetGuidance("analysis control");
70 
71  fSetActivationCmd = G4Analysis::make_unique<G4UIcmdWithABool>("/analysis/setActivation",this);
72  G4String guidance = "Set activation. \n";
73  guidance += "When this option is enabled, only the histograms marked as activated\n";
74  guidance += "are returned, filled or saved on file.\n";
75  guidance += "No warning is issued when Get or Fill is called on inactive histogram.";
76  fSetActivationCmd->SetGuidance(guidance);
77  fSetActivationCmd->SetParameterName("Activation",false);
78 
79  fVerboseCmd = G4Analysis::make_unique<G4UIcmdWithAnInteger>("/analysis/verbose",this);
80  fVerboseCmd->SetGuidance("Set verbose level");
81  fVerboseCmd->SetParameterName("VerboseLevel",false);
82  fVerboseCmd->SetRange("VerboseLevel>=0 && VerboseLevel<=4");
83 
84  fCompressionCmd = G4Analysis::make_unique<G4UIcmdWithAnInteger>("/analysis/compression",this);
85  fCompressionCmd->SetGuidance("Set compression level");
86  fCompressionCmd->SetParameterName("CompressionLevel",false);
87  fCompressionCmd->SetRange("CompressionLevel>=0 && CompressionLevel<=4");
88 
89  fFileMessenger = G4Analysis::make_unique<G4FileMessenger>(manager);
90  fH1Messenger = G4Analysis::make_unique<G4H1Messenger>(manager);
91  fH2Messenger = G4Analysis::make_unique<G4H2Messenger>(manager);
92  fH3Messenger = G4Analysis::make_unique<G4H3Messenger>(manager);
93  fP1Messenger = G4Analysis::make_unique<G4P1Messenger>(manager);
94  fP2Messenger = G4Analysis::make_unique<G4P2Messenger>(manager);
95  fNtupleMessenger = G4Analysis::make_unique<G4NtupleMessenger>(manager);
96 }
97 
98 //_____________________________________________________________________________
100 {}
101 
102 //
103 // public functions
104 //
105 
106 //_____________________________________________________________________________
108 {
109  fH1HnMessenger = G4Analysis::make_unique<G4HnMessenger>(h1HnManager);
110 }
111 
112 //_____________________________________________________________________________
114 {
115  fH2HnMessenger = G4Analysis::make_unique<G4HnMessenger>(h2HnManager);
116 }
117 
118 //_____________________________________________________________________________
120 {
121  fH2HnMessenger = G4Analysis::make_unique<G4HnMessenger>(h2HnManager);
122 }
123 
124 //_____________________________________________________________________________
126 {
127  fP1HnMessenger = G4Analysis::make_unique<G4HnMessenger>(p1HnManager);
128 }
129 
130 //_____________________________________________________________________________
132 {
133  fP2HnMessenger = G4Analysis::make_unique<G4HnMessenger>(p2HnManager);
134 }
135 
136 //_____________________________________________________________________________
138 {
139  if ( command == fSetActivationCmd.get() ) {
140  fManager->SetActivation(fSetActivationCmd->GetNewBoolValue(newValues));
141  }
142  else if ( command == fVerboseCmd.get() ) {
143  fManager->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValues));
144  }
145  else if ( command == fCompressionCmd.get() ) {
146  fManager->SetCompressionLevel(fCompressionCmd->GetNewIntValue(newValues));
147  }
148 }
std::unique_ptr< G4HnMessenger > fP1HnMessenger
std::unique_ptr< G4HnMessenger > fH2HnMessenger
void SetCompressionLevel(G4int level)
std::unique_ptr< G4HnMessenger > fH1HnMessenger
std::unique_ptr< G4UIcmdWithABool > fSetActivationCmd
void SetVerboseLevel(G4int verboseLevel)
std::unique_ptr< G4P2Messenger > fP2Messenger
std::unique_ptr< G4HnMessenger > fP2HnMessenger
void SetH3HnManager(G4HnManager &h2HnManager)
std::unique_ptr< G4UIdirectory > fAnalysisDir
std::unique_ptr< G4FileMessenger > fFileMessenger
void SetH1HnManager(G4HnManager &h1HnManager)
virtual void SetNewValue(G4UIcommand *command, G4String value) final
std::unique_ptr< G4P1Messenger > fP1Messenger
void SetActivation(G4bool activation)
std::unique_ptr< G4H1Messenger > fH1Messenger
std::unique_ptr< G4UIcmdWithAnInteger > fCompressionCmd
void SetP2HnManager(G4HnManager &h2HnManager)
std::unique_ptr< G4UIcmdWithAnInteger > fVerboseCmd
G4AnalysisMessenger(G4VAnalysisManager *manager)
void SetP1HnManager(G4HnManager &h1HnManager)
std::unique_ptr< G4H3Messenger > fH3Messenger
G4VAnalysisManager * fManager
Associated class.
std::unique_ptr< G4H2Messenger > fH2Messenger
std::unique_ptr< G4NtupleMessenger > fNtupleMessenger
void SetH2HnManager(G4HnManager &h2HnManager)