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.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/ChargeExchangeMC/src/CexmcHistoManagerMessenger.cc (Version 11.3.0) and /examples/advanced/ChargeExchangeMC/src/CexmcHistoManagerMessenger.cc (Version 10.0.p4)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /*                                                 26 /*
 27  * ===========================================     27  * ============================================================================
 28  *                                                 28  *
 29  *       Filename:  CexmcHistoManagerMessenger     29  *       Filename:  CexmcHistoManagerMessenger.cc
 30  *                                                 30  *
 31  *    Description:  commands to list and show      31  *    Description:  commands to list and show histograms
 32  *                                                 32  *
 33  *        Version:  1.0                            33  *        Version:  1.0
 34  *        Created:  17.12.2009 21:39:02            34  *        Created:  17.12.2009 21:39:02
 35  *       Revision:  none                           35  *       Revision:  none
 36  *       Compiler:  gcc                            36  *       Compiler:  gcc
 37  *                                                 37  *
 38  *         Author:  Alexey Radkov (),              38  *         Author:  Alexey Radkov (), 
 39  *        Company:  PNPI                           39  *        Company:  PNPI
 40  *                                                 40  *
 41  * ===========================================     41  * ============================================================================
 42  */                                                42  */
 43                                                    43 
 44 #ifdef CEXMC_USE_ROOT                              44 #ifdef CEXMC_USE_ROOT
 45                                                    45 
 46 #include <G4UIcmdWithoutParameter.hh>              46 #include <G4UIcmdWithoutParameter.hh>
 47 #include <G4UIcmdWithAnInteger.hh>                 47 #include <G4UIcmdWithAnInteger.hh>
 48 #include <G4UIcmdWithAString.hh>                   48 #include <G4UIcmdWithAString.hh>
 49 #include <G4String.hh>                             49 #include <G4String.hh>
 50 #include "CexmcHistoManagerMessenger.hh"           50 #include "CexmcHistoManagerMessenger.hh"
 51 #include "CexmcHistoManager.hh"                    51 #include "CexmcHistoManager.hh"
 52 #include "CexmcMessenger.hh"                       52 #include "CexmcMessenger.hh"
 53                                                    53 
 54                                                    54 
 55 CexmcHistoManagerMessenger::CexmcHistoManagerM     55 CexmcHistoManagerMessenger::CexmcHistoManagerMessenger(
 56                                         CexmcH <<  56                                         CexmcHistoManager *  histoManager ) :
 57     histoManager( histoManager_ ), setVerboseL <<  57     histoManager( histoManager ), setVerboseLevel( NULL ), listHistos( NULL ),
 58     printHisto( NULL )                             58     printHisto( NULL )
 59 #ifdef CEXMC_USE_ROOTQT                            59 #ifdef CEXMC_USE_ROOTQT
 60     , drawHisto( NULL ), addHistoMenu( NULL ), <<  60     , drawHisto( NULL )
 61     drawHistoOptions2D( NULL ), drawHistoOptio << 
 62 #endif                                             61 #endif
 63 {                                                  62 {
 64     setVerboseLevel = new G4UIcmdWithAnInteger     63     setVerboseLevel = new G4UIcmdWithAnInteger(
 65         ( CexmcMessenger::histoDirName + "verb     64         ( CexmcMessenger::histoDirName + "verbose" ).c_str(), this );
 66     setVerboseLevel->SetGuidance( "0 - basic s     65     setVerboseLevel->SetGuidance( "0 - basic set of histograms created, "
 67                                   "1 - extra h     66                                   "1 - extra histograms created" );
 68     setVerboseLevel->SetParameterName( "Verbos     67     setVerboseLevel->SetParameterName( "Verbose", true );
 69     setVerboseLevel->SetDefaultValue( 0 );         68     setVerboseLevel->SetDefaultValue( 0 );
 70     setVerboseLevel->AvailableForStates( G4Sta     69     setVerboseLevel->AvailableForStates( G4State_PreInit );
 71                                                    70 
 72     listHistos = new G4UIcmdWithoutParameter(      71     listHistos = new G4UIcmdWithoutParameter(
 73         ( CexmcMessenger::histoDirName + "list     72         ( CexmcMessenger::histoDirName + "list" ).c_str(), this );
 74     listHistos->SetGuidance( "List available h     73     listHistos->SetGuidance( "List available histograms" );
 75     listHistos->AvailableForStates( G4State_Pr     74     listHistos->AvailableForStates( G4State_PreInit, G4State_Idle );
 76                                                    75 
 77     printHisto = new G4UIcmdWithAString(           76     printHisto = new G4UIcmdWithAString(
 78         ( CexmcMessenger::histoDirName + "prin     77         ( CexmcMessenger::histoDirName + "print" ).c_str(), this );
 79     printHisto->SetGuidance( "Print specified      78     printHisto->SetGuidance( "Print specified histogram" );
 80     printHisto->SetParameterName( "PrintHisto"     79     printHisto->SetParameterName( "PrintHisto", false );
 81     printHisto->AvailableForStates( G4State_Id     80     printHisto->AvailableForStates( G4State_Idle );
 82                                                    81 
 83 #ifdef CEXMC_USE_ROOTQT                            82 #ifdef CEXMC_USE_ROOTQT
 84     drawHisto = new G4UIcmdWithAString(            83     drawHisto = new G4UIcmdWithAString(
 85         ( CexmcMessenger::histoDirName + "draw     84         ( CexmcMessenger::histoDirName + "draw" ).c_str(), this );
 86     drawHisto->SetGuidance( "Draw specified hi     85     drawHisto->SetGuidance( "Draw specified histogram. The first parameter is\n"
 87                             "    the histogram <<  86                             "    the histogram name, the second is draw "
 88                             "options.\n    Ava     87                             "options.\n    Available only if the program was "
 89                             "launched\n    in      88                             "launched\n    in graphical mode" );
 90     drawHisto->SetParameterName( "DrawHisto",      89     drawHisto->SetParameterName( "DrawHisto", false );
 91     drawHisto->AvailableForStates( G4State_Idl     90     drawHisto->AvailableForStates( G4State_Idle );
 92                                                << 
 93     addHistoMenu = new G4UIcmdWithAString(     << 
 94         ( CexmcMessenger::histoDirName + "addH << 
 95     addHistoMenu->SetGuidance( "Add histogram  << 
 96                                "parameter is\n << 
 97                                "the menu label << 
 98                                "or disabled in << 
 99     addHistoMenu->SetParameterName( "AddHistoM << 
100     addHistoMenu->AvailableForStates( G4State_ << 
101                                                << 
102     drawHistoOptions1D = new G4UIcmdWithAStrin << 
103         ( CexmcMessenger::histoDirName + "draw << 
104     drawHistoOptions1D->SetGuidance( "Set draw << 
105                                      "from the << 
106                                      "be chang << 
107     drawHistoOptions1D->SetParameterName( "Dra << 
108     drawHistoOptions1D->AvailableForStates( G4 << 
109                                                << 
110     drawHistoOptions2D = new G4UIcmdWithAStrin << 
111         ( CexmcMessenger::histoDirName + "draw << 
112     drawHistoOptions2D->SetGuidance( "Set draw << 
113                                      "from the << 
114                                      "be chang << 
115     drawHistoOptions2D->SetParameterName( "Dra << 
116     drawHistoOptions2D->AvailableForStates( G4 << 
117                                                << 
118     drawHistoOptions3D = new G4UIcmdWithAStrin << 
119         ( CexmcMessenger::histoDirName + "draw << 
120     drawHistoOptions3D->SetGuidance( "Set draw << 
121                                      "from the << 
122                                      "be chang << 
123     drawHistoOptions3D->SetParameterName( "Dra << 
124     drawHistoOptions3D->AvailableForStates( G4 << 
125 #endif                                             91 #endif
126 }                                                  92 }
127                                                    93 
128                                                    94 
129 CexmcHistoManagerMessenger::~CexmcHistoManager     95 CexmcHistoManagerMessenger::~CexmcHistoManagerMessenger()
130 {                                                  96 {
131     delete setVerboseLevel;                        97     delete setVerboseLevel;
132     delete listHistos;                             98     delete listHistos;
133     delete printHisto;                             99     delete printHisto;
134 #ifdef CEXMC_USE_ROOTQT                           100 #ifdef CEXMC_USE_ROOTQT
135     delete drawHisto;                             101     delete drawHisto;
136     delete addHistoMenu;                       << 
137     delete drawHistoOptions1D;                 << 
138     delete drawHistoOptions2D;                 << 
139     delete drawHistoOptions3D;                 << 
140 #endif                                            102 #endif
141 }                                                 103 }
142                                                   104 
143                                                   105 
144 void  CexmcHistoManagerMessenger::SetNewValue(    106 void  CexmcHistoManagerMessenger::SetNewValue( G4UIcommand *  cmd,
145                                                   107                                                G4String  value )
146 {                                                 108 {
147     do                                            109     do
148     {                                             110     {
149         if ( cmd == setVerboseLevel )             111         if ( cmd == setVerboseLevel )
150         {                                         112         {
151             histoManager->SetVerboseLevel(        113             histoManager->SetVerboseLevel(
152                                 G4UIcmdWithAnI    114                                 G4UIcmdWithAnInteger::GetNewIntValue( value ) );
153             break;                                115             break;
154         }                                         116         }
155         if ( cmd == listHistos )                  117         if ( cmd == listHistos )
156         {                                         118         {
157             histoManager->List();                 119             histoManager->List();
158             break;                                120             break;
159         }                                         121         }
160         if ( cmd == printHisto )                  122         if ( cmd == printHisto )
161         {                                         123         {
162             histoManager->Print( value );         124             histoManager->Print( value );
163             break;                                125             break;
164         }                                         126         }
165 #ifdef CEXMC_USE_ROOTQT                           127 #ifdef CEXMC_USE_ROOTQT
166         if ( cmd == drawHisto )                   128         if ( cmd == drawHisto )
167         {                                         129         {
168             size_t  delimPos( value.find_first    130             size_t  delimPos( value.find_first_of( " \t" ) );
169             size_t  delimPosEnd( G4String::npo    131             size_t  delimPosEnd( G4String::npos );
170             if ( delimPos != G4String::npos )     132             if ( delimPos != G4String::npos )
171                 delimPosEnd = value.find_first    133                 delimPosEnd = value.find_first_not_of( " \t", delimPos );
172             histoManager->Draw( std::string( v    134             histoManager->Draw( std::string( value, 0, delimPos ),
173                                 delimPosEnd ==    135                                 delimPosEnd == G4String::npos ? "" :
174                                                   136                                                 value.c_str() + delimPosEnd );
175             break;                             << 
176         }                                      << 
177         if ( cmd == addHistoMenu )             << 
178         {                                      << 
179             size_t  delimPos( value.find_first << 
180             size_t  delimPosEnd( G4String::npo << 
181             if ( delimPos != G4String::npos )  << 
182                 delimPosEnd = value.find_first << 
183             histoManager->AddHistoMenu( std::s << 
184                                         delimP << 
185                                                << 
186             break;                             << 
187         }                                      << 
188         if ( cmd == drawHistoOptions1D )       << 
189         {                                      << 
190             histoManager->SetDrawOptions1D( va << 
191             break;                             << 
192         }                                      << 
193         if ( cmd == drawHistoOptions2D )       << 
194         {                                      << 
195             histoManager->SetDrawOptions2D( va << 
196             break;                             << 
197         }                                      << 
198         if ( cmd == drawHistoOptions3D )       << 
199         {                                      << 
200             histoManager->SetDrawOptions3D( va << 
201             break;                                137             break;
202         }                                         138         }
203 #endif                                            139 #endif
204     } while ( false );                            140     } while ( false );
205 }                                                 141 }
206                                                   142 
207 #endif                                            143 #endif
208                                                   144 
209                                                   145