| 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 | //
|
|---|
| 27 | // File name: RadmonApplicationMessenger.cc
|
|---|
| 28 | // Creation date: Sep 2005
|
|---|
| 29 | // Main author: Riccardo Capra <capra@ge.infn.it>
|
|---|
| 30 | //
|
|---|
| 31 | // Id: $Id: RadmonApplicationMessenger.cc,v 1.1.2.2 2006/06/29 16:08:41 gunter Exp $
|
|---|
| 32 | // Tag: $Name: geant4-09-01-patch-02 $
|
|---|
| 33 | //
|
|---|
| 34 |
|
|---|
| 35 | // Messenger commands path
|
|---|
| 36 | #define COMMANDS_PATH "/radmon/application/"
|
|---|
| 37 |
|
|---|
| 38 | // Include files
|
|---|
| 39 | #include "RadmonApplicationMessenger.hh"
|
|---|
| 40 | #include "RadmonApplicationEventNumbering.hh"
|
|---|
| 41 | #include "RadmonApplicationEventTracks.hh"
|
|---|
| 42 | #include "RadmonApplicationRunNumbering.hh"
|
|---|
| 43 | #include "RadmonEventAction.hh"
|
|---|
| 44 | #include "RadmonRunAction.hh"
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | RadmonApplicationMessenger :: RadmonApplicationMessenger()
|
|---|
| 49 | :
|
|---|
| 50 | RadmonMessenger(COMMANDS_PATH, "Interactive application options."),
|
|---|
| 51 | eventNumbering(new RadmonApplicationEventNumbering),
|
|---|
| 52 | eventTracks(new RadmonApplicationEventTracks),
|
|---|
| 53 | runNumbering(new RadmonApplicationRunNumbering),
|
|---|
| 54 | RADMON_INITIALIZE_COMMAND(EnableRunsDump),
|
|---|
| 55 | RADMON_INITIALIZE_COMMAND(DisableRunsDump),
|
|---|
| 56 | RADMON_INITIALIZE_COMMAND(DumpEventsEvery),
|
|---|
| 57 | RADMON_INITIALIZE_COMMAND(DisableEventsDump),
|
|---|
| 58 | RADMON_INITIALIZE_COMMAND(EnableTracksVisualisation),
|
|---|
| 59 | RADMON_INITIALIZE_COMMAND(DisableTracksVisualisation)
|
|---|
| 60 | {
|
|---|
| 61 | RadmonEventAction * eventAction(RadmonEventAction::Instance());
|
|---|
| 62 | eventAction->AttachObserver(eventNumbering);
|
|---|
| 63 | eventAction->AttachObserver(eventTracks);
|
|---|
| 64 |
|
|---|
| 65 | RadmonRunAction * runAction(RadmonRunAction::Instance());
|
|---|
| 66 | runAction->AttachObserver(runNumbering);
|
|---|
| 67 |
|
|---|
| 68 | RADMON_CREATE_COMMAND_0ARGS(EnableRunsDump, "Disables the run number dump");
|
|---|
| 69 | RADMON_CREATE_COMMAND_0ARGS(DisableRunsDump, "Enables the run number dump");
|
|---|
| 70 | RADMON_CREATE_COMMAND_1ARG (DumpEventsEvery, "Enables the event number dump every n events", "nEvents");
|
|---|
| 71 | RADMON_CREATE_COMMAND_0ARGS(DisableEventsDump, "Disables the event number dump");
|
|---|
| 72 |
|
|---|
| 73 | #ifdef G4VIS_USE
|
|---|
| 74 | RADMON_CREATE_COMMAND_0ARGS(EnableTracksVisualisation, "Enables the tracks plotting at the end of the event");
|
|---|
| 75 | RADMON_CREATE_COMMAND_0ARGS(DisableTracksVisualisation, "Disables the tracks plotting at the end of the event");
|
|---|
| 76 | #endif /* G4VIS_USE */
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 | RadmonApplicationMessenger :: ~RadmonApplicationMessenger()
|
|---|
| 82 | {
|
|---|
| 83 | #ifdef G4VIS_USE
|
|---|
| 84 | RADMON_DESTROY_COMMAND(DisableTracksVisualisation);
|
|---|
| 85 | RADMON_DESTROY_COMMAND(EnableTracksVisualisation);
|
|---|
| 86 | #endif /* G4VIS_USE */
|
|---|
| 87 |
|
|---|
| 88 | RADMON_DESTROY_COMMAND(DisableEventsDump);
|
|---|
| 89 | RADMON_DESTROY_COMMAND(DumpEventsEvery);
|
|---|
| 90 | RADMON_DESTROY_COMMAND(DisableRunsDump);
|
|---|
| 91 | RADMON_DESTROY_COMMAND(EnableRunsDump);
|
|---|
| 92 |
|
|---|
| 93 | RadmonEventAction * eventAction(RadmonEventAction::Instance());
|
|---|
| 94 | eventAction->DetachObserver(eventNumbering);
|
|---|
| 95 | delete eventNumbering;
|
|---|
| 96 | eventAction->DetachObserver(eventTracks);
|
|---|
| 97 | delete eventTracks;
|
|---|
| 98 |
|
|---|
| 99 | RadmonRunAction * runAction(RadmonRunAction::Instance());
|
|---|
| 100 | runAction->DetachObserver(runNumbering);
|
|---|
| 101 | delete runNumbering;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 | G4String RadmonApplicationMessenger :: GetCurrentValue(G4UIcommand * /* command */)
|
|---|
| 109 | {
|
|---|
| 110 | G4cout << "RadmonApplicationMessenger::GetCurrentValue(): Not supported" << G4endl;
|
|---|
| 111 |
|
|---|
| 112 | return G4String();
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 | void RadmonApplicationMessenger :: SetNewValue(G4UIcommand * command, G4String newValue)
|
|---|
| 118 | {
|
|---|
| 119 | RADMON_BEGIN_LIST_SET_COMMANDS
|
|---|
| 120 | RADMON_SET_COMMAND(EnableRunsDump)
|
|---|
| 121 | RADMON_SET_COMMAND(DisableRunsDump)
|
|---|
| 122 | RADMON_SET_COMMAND(DumpEventsEvery)
|
|---|
| 123 | RADMON_SET_COMMAND(DisableEventsDump)
|
|---|
| 124 | RADMON_SET_COMMAND(EnableTracksVisualisation)
|
|---|
| 125 | RADMON_SET_COMMAND(DisableTracksVisualisation)
|
|---|
| 126 | RADMON_END_LIST_SET_COMMANDS
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 | // Events
|
|---|
| 134 | void RadmonApplicationMessenger :: OnEnableRunsDump(const G4String & /* value */)
|
|---|
| 135 | {
|
|---|
| 136 | runNumbering->Enable();
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 | void RadmonApplicationMessenger :: OnDisableRunsDump(const G4String & /* value */)
|
|---|
| 142 | {
|
|---|
| 143 | runNumbering->Disable();
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 | void RadmonApplicationMessenger :: OnDumpEventsEvery(const G4String & value)
|
|---|
| 149 | {
|
|---|
| 150 | G4String args;
|
|---|
| 151 |
|
|---|
| 152 | if (!ProcessArguments(value, 1, & args))
|
|---|
| 153 | return;
|
|---|
| 154 |
|
|---|
| 155 | G4int every(G4UIcommand::ConvertToInt(args));
|
|---|
| 156 |
|
|---|
| 157 | if (every<=0)
|
|---|
| 158 | {
|
|---|
| 159 | G4cout << "RadmonApplicationMessenger::OnDumpEventsEvery: nEvents must be positive." << G4endl;
|
|---|
| 160 | return;
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | eventNumbering->SetDumpEvery(every);
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 | void RadmonApplicationMessenger :: OnDisableEventsDump(const G4String & /* value */)
|
|---|
| 169 | {
|
|---|
| 170 | eventNumbering->SetDumpEvery(0);
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 | void RadmonApplicationMessenger :: OnEnableTracksVisualisation(const G4String & /* value */)
|
|---|
| 176 | {
|
|---|
| 177 | eventTracks->Enable();
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 | void RadmonApplicationMessenger :: OnDisableTracksVisualisation(const G4String & /* value */)
|
|---|
| 183 | {
|
|---|
| 184 | eventTracks->Disable();
|
|---|
| 185 | }
|
|---|