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 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 /persistency/mctruth/src/G4PersistencyCenterMessenger.cc (Version 11.3.0) and /persistency/mctruth/src/G4PersistencyCenterMessenger.cc (Version 10.7)


  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 // G4PersistencyCenterMessenger implementation     26 // G4PersistencyCenterMessenger implementation
 27 //                                                 27 //
 28 // Author: Youhei Morita, 18.07.2001               28 // Author: Youhei Morita, 18.07.2001
 29 // -------------------------------------------     29 // --------------------------------------------------------------------
 30                                                    30 
 31 #include "G4PersistencyCenterMessenger.hh"         31 #include "G4PersistencyCenterMessenger.hh"
 32                                                    32 
 33 // -------------------------------------------     33 // --------------------------------------------------------------------
 34 G4PersistencyCenterMessenger::                     34 G4PersistencyCenterMessenger::
 35 G4PersistencyCenterMessenger(G4PersistencyCent     35 G4PersistencyCenterMessenger(G4PersistencyCenter* p)
 36   : pc(p)                                          36   : pc(p)
 37 {                                                  37 {
 38   G4String name = "/persistency/";                 38   G4String name = "/persistency/";
 39   directory        = new G4UIdirectory(name.c_     39   directory        = new G4UIdirectory(name.c_str());
 40   directory->SetGuidance("Control commands for     40   directory->SetGuidance("Control commands for Persistency package");
 41                                                    41 
 42   G4String cmd = name + "verbose";                 42   G4String cmd = name + "verbose";
 43                                                    43 
 44   verboseCmd = new G4UIcmdWithAnInteger(cmd.c_     44   verboseCmd = new G4UIcmdWithAnInteger(cmd.c_str(), this);
 45   verboseCmd->SetGuidance("Set the verbose lev     45   verboseCmd->SetGuidance("Set the verbose level of G4PersistencyManager.");
 46   verboseCmd->SetGuidance(" 0 : Silent (defaul     46   verboseCmd->SetGuidance(" 0 : Silent (default)");
 47   verboseCmd->SetGuidance(" 1 : Display main t     47   verboseCmd->SetGuidance(" 1 : Display main topics");
 48   verboseCmd->SetGuidance(" 2 : Display event-     48   verboseCmd->SetGuidance(" 2 : Display event-level topics");
 49   verboseCmd->SetGuidance(" 3 : Display debug      49   verboseCmd->SetGuidance(" 3 : Display debug information");
 50   verboseCmd->SetParameterName("level", true);     50   verboseCmd->SetParameterName("level", true);
 51   verboseCmd->SetDefaultValue(0);                  51   verboseCmd->SetDefaultValue(0);
 52   verboseCmd->SetRange("level >=0 && level <=3     52   verboseCmd->SetRange("level >=0 && level <=3");
 53                                                    53 
 54   G4String vname = name + "select";                54   G4String vname = name + "select";
 55                                                    55 
 56   cmd    = vname;                                  56   cmd    = vname;
 57   select = new G4UIcmdWithAString(cmd.c_str(),     57   select = new G4UIcmdWithAString(cmd.c_str(), this);
 58   select->SetGuidance("Selection of a persiste     58   select->SetGuidance("Selection of a persistency package");
 59   select->SetParameterName("Persistency packag     59   select->SetParameterName("Persistency package name", true, true);
 60   select->SetCandidates("ODBMS ROOT None");        60   select->SetCandidates("ODBMS ROOT None");
 61                                                    61 
 62   vname = name + "store/";                         62   vname = name + "store/";
 63                                                    63 
 64   subdir1 = new G4UIdirectory(vname.c_str());      64   subdir1 = new G4UIdirectory(vname.c_str());
 65   subdir1->SetGuidance("Specifiy object types      65   subdir1->SetGuidance("Specifiy object types for store");
 66                                                    66 
 67   wrObj.push_back("HepMC");                        67   wrObj.push_back("HepMC");
 68   wrObj.push_back("MCTruth");                      68   wrObj.push_back("MCTruth");
 69   wrObj.push_back("Hits");                         69   wrObj.push_back("Hits");
 70                                                    70 
 71   G4String guidance;                               71   G4String guidance;
 72   G4int i;                                         72   G4int i;
 73                                                    73 
 74   for(i = 0; i < 3; ++i)                           74   for(i = 0; i < 3; ++i)
 75   {                                                75   {
 76     cmd      = vname + wrObj[i];                   76     cmd      = vname + wrObj[i];
 77     guidance = "Store " + wrObj[i] + " objects     77     guidance = "Store " + wrObj[i] + " objects for output";
 78     storeObj.push_back(new G4UIcmdWithAString(     78     storeObj.push_back(new G4UIcmdWithAString(cmd.c_str(), this));
 79     storeObj[i]->SetGuidance(guidance.c_str())     79     storeObj[i]->SetGuidance(guidance.c_str());
 80     if(wrObj[i] == "HepMC")                        80     if(wrObj[i] == "HepMC")
 81     {                                              81     {
 82       storeObj[i]->SetCandidates("on off recyc     82       storeObj[i]->SetCandidates("on off recycle");
 83     }                                              83     }
 84     else                                           84     else
 85     {                                              85     {
 86       storeObj[i]->SetCandidates("on off");        86       storeObj[i]->SetCandidates("on off");
 87     }                                              87     }
 88   }                                                88   }
 89                                                    89 
 90   vname += "using/";                               90   vname += "using/";
 91   subdir2 = new G4UIdirectory(vname.c_str());      91   subdir2 = new G4UIdirectory(vname.c_str());
 92   subdir2->SetGuidance("Select I/O manager for     92   subdir2->SetGuidance("Select I/O manager for store");
 93                                                    93 
 94   cmd      = vname + "hitIO";                      94   cmd      = vname + "hitIO";
 95   regHitIO = new G4UIcmdWithAString(cmd.c_str(     95   regHitIO = new G4UIcmdWithAString(cmd.c_str(), this);
 96   regHitIO->SetGuidance("Resiter Hits I/O Mana     96   regHitIO->SetGuidance("Resiter Hits I/O Manager");
 97   regHitIO->SetParameterName("Name of Hits I/O     97   regHitIO->SetParameterName("Name of Hits I/O Manager", true, true);
 98                                                    98 
 99   vname   = name + "set/";                         99   vname   = name + "set/";
100   subdir3 = new G4UIdirectory(vname.c_str());     100   subdir3 = new G4UIdirectory(vname.c_str());
101   subdir3->SetGuidance("Set various parameters    101   subdir3->SetGuidance("Set various parameters");
102                                                   102 
103   vname += "writeFile/";                          103   vname += "writeFile/";
104   subdir4 = new G4UIdirectory(vname.c_str());     104   subdir4 = new G4UIdirectory(vname.c_str());
105   subdir4->SetGuidance("Set output file names     105   subdir4->SetGuidance("Set output file names for object types");
106                                                   106 
107   for(i = 0; i < 3; ++i)                          107   for(i = 0; i < 3; ++i)
108   {                                               108   {
109     cmd      = vname + wrObj[i];                  109     cmd      = vname + wrObj[i];
110     guidance = "Set an output file name for "     110     guidance = "Set an output file name for " + wrObj[i] + ".";
111     setWrFile.push_back(new G4UIcmdWithAString    111     setWrFile.push_back(new G4UIcmdWithAString(cmd.c_str(), this));
112     setWrFile[i]->SetGuidance(guidance.c_str()    112     setWrFile[i]->SetGuidance(guidance.c_str());
113     setWrFile[i]->SetParameterName("file name"    113     setWrFile[i]->SetParameterName("file name", true, true);
114   }                                               114   }
115                                                   115 
116   vname   = name + "set/ReadFile/";               116   vname   = name + "set/ReadFile/";
117   subdir5 = new G4UIdirectory(vname.c_str());     117   subdir5 = new G4UIdirectory(vname.c_str());
118   subdir5->SetGuidance("Set input file names f    118   subdir5->SetGuidance("Set input file names for object types");
119                                                   119 
120   rdObj.push_back("Hits");                        120   rdObj.push_back("Hits");
121                                                   121 
122   cmd      = vname + rdObj[0];                    122   cmd      = vname + rdObj[0];
123   guidance = "Set an input file name for " + r    123   guidance = "Set an input file name for " + rdObj[0] + ".";
124   setRdFile.push_back(new G4UIcmdWithAString(c    124   setRdFile.push_back(new G4UIcmdWithAString(cmd.c_str(), this));
125   setRdFile[0]->SetGuidance(guidance.c_str());    125   setRdFile[0]->SetGuidance(guidance.c_str());
126   setRdFile[0]->SetParameterName("file name",     126   setRdFile[0]->SetParameterName("file name", true, true);
127                                                   127 
128   cmd      = name + "printall";                   128   cmd      = name + "printall";
129   printAll = new G4UIcmdWithoutParameter(cmd.c    129   printAll = new G4UIcmdWithoutParameter(cmd.c_str(), this);
130   printAll->SetGuidance("Print all parameters.    130   printAll->SetGuidance("Print all parameters.");
131 }                                                 131 }
132                                                   132 
133 // -------------------------------------------    133 // --------------------------------------------------------------------
134 G4PersistencyCenterMessenger::~G4PersistencyCe    134 G4PersistencyCenterMessenger::~G4PersistencyCenterMessenger()
135 {                                                 135 {
136   delete directory;                               136   delete directory;
137   delete subdir1;                                 137   delete subdir1;
138   delete subdir2;                                 138   delete subdir2;
139   delete subdir3;                                 139   delete subdir3;
140   delete subdir4;                                 140   delete subdir4;
141   delete subdir5;                                 141   delete subdir5;
142   delete verboseCmd;                              142   delete verboseCmd;
143   delete select;                                  143   delete select;
144   delete regHitIO;                                144   delete regHitIO;
145   for(G4int i = 0; i < 3; ++i)                    145   for(G4int i = 0; i < 3; ++i)
146   {                                               146   {
147     delete storeObj[i];                           147     delete storeObj[i];
148     delete setWrFile[i];                          148     delete setWrFile[i];
149   }                                               149   }
150   delete setRdFile[0];                            150   delete setRdFile[0];
151   delete printAll;                                151   delete printAll;
152 }                                                 152 }
153                                                   153 
154 // -------------------------------------------    154 // --------------------------------------------------------------------
155 void G4PersistencyCenterMessenger::SetNewValue    155 void G4PersistencyCenterMessenger::SetNewValue(G4UIcommand* command,
156                                                   156                                                G4String newValues)
157 {                                                 157 {
158   if(command == verboseCmd)                       158   if(command == verboseCmd)
159   {                                               159   {
160     pc->SetVerboseLevel(verboseCmd->GetNewIntV    160     pc->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues));
161   }                                               161   }
162   else if(command == select)                      162   else if(command == select)
163   {                                               163   {
164     pc->SelectSystem(newValues);                  164     pc->SelectSystem(newValues);
165   }                                               165   }
166   else if(command == regHitIO)                    166   else if(command == regHitIO)
167   {                                               167   {
168     pc->AddHCIOmanager(PopWord(newValues, 1, "    168     pc->AddHCIOmanager(PopWord(newValues, 1, " "), PopWord(newValues, 2, " "));
169   }                                               169   }
170   else if(command == setRdFile[0])                170   else if(command == setRdFile[0])
171   {                                               171   {
172     pc->SetReadFile(rdObj[0], newValues);         172     pc->SetReadFile(rdObj[0], newValues);
173   }                                               173   }
174   else if(command == printAll)                    174   else if(command == printAll)
175   {                                               175   {
176     pc->PrintAll();                               176     pc->PrintAll();
177   }                                               177   }
178   else                                            178   else
179   {                                               179   {
180     for(G4int i = 0; i < 3; ++i)                  180     for(G4int i = 0; i < 3; ++i)
181     {                                             181     {
182       if(command == storeObj[i])                  182       if(command == storeObj[i])
183       {                                           183       {
184         StoreMode mode = kOff;                    184         StoreMode mode = kOff;
185         if(newValues == "on")                     185         if(newValues == "on")
186         {                                         186         {
187           mode = kOn;                             187           mode = kOn;
188         }                                         188         }
189         else if(newValues == "off")               189         else if(newValues == "off")
190         {                                         190         {
191           mode = kOff;                            191           mode = kOff;
192         }                                         192         }
193         else if(newValues == "recycle")           193         else if(newValues == "recycle")
194         {                                         194         {
195           mode = kRecycle;                        195           mode = kRecycle;
196         }                                         196         }
197         else                                      197         else
198         {                                         198         {
199           G4cerr << "Unrecognized keyword - \"    199           G4cerr << "Unrecognized keyword - \"" << newValues << "\"." << G4endl;
200         }                                         200         }
201         pc->SetStoreMode(wrObj[i], mode);         201         pc->SetStoreMode(wrObj[i], mode);
202         break;                                    202         break;
203       }                                           203       }
204       else if(command == setWrFile[i])            204       else if(command == setWrFile[i])
205       {                                           205       {
206         pc->SetWriteFile(wrObj[i], newValues);    206         pc->SetWriteFile(wrObj[i], newValues);
207         break;                                    207         break;
208       }                                           208       }
209     }                                             209     }
210   }                                               210   }
211 }                                                 211 }
212                                                   212 
213 // -------------------------------------------    213 // --------------------------------------------------------------------
214 G4String G4PersistencyCenterMessenger::GetCurr    214 G4String G4PersistencyCenterMessenger::GetCurrentValue(G4UIcommand* command)
215 {                                                 215 {
216   G4String ustr = "Undefined";                    216   G4String ustr = "Undefined";
217                                                   217 
218   if(command == verboseCmd)                       218   if(command == verboseCmd)
219   {                                               219   {
220     return G4UIcommand::ConvertToString(pc->Ve << 220     return pc->VerboseLevel();
221   }                                               221   }
222   else if(command == select)                      222   else if(command == select)
223   {                                               223   {
224     return pc->CurrentSystem();                   224     return pc->CurrentSystem();
225   }                                               225   }
226   else if(command == regHitIO)                    226   else if(command == regHitIO)
227   {                                               227   {
228     return pc->CurrentHCIOmanager();              228     return pc->CurrentHCIOmanager();
229   }                                               229   }
230   else if(command == setRdFile[0])                230   else if(command == setRdFile[0])
231   {                                               231   {
232     return pc->CurrentReadFile(rdObj[0]);         232     return pc->CurrentReadFile(rdObj[0]);
233   }                                               233   }
234   else                                            234   else
235   {                                               235   {
236     for(G4int i = 0; i < 3; ++i)                  236     for(G4int i = 0; i < 3; ++i)
237     {                                             237     {
238       if(command == storeObj[i])                  238       if(command == storeObj[i])
239       {                                           239       {
240         switch(pc->CurrentStoreMode(wrObj[i]))    240         switch(pc->CurrentStoreMode(wrObj[i]))
241         {                                         241         {
242           case kOn:                               242           case kOn:
243             return "on";                          243             return "on";
244             break;                                244             break;
245           case kOff:                              245           case kOff:
246             return "off";                         246             return "off";
247             break;                                247             break;
248           case kRecycle:                          248           case kRecycle:
249             return "recycle";                     249             return "recycle";
250             break;                                250             break;
251           default:                                251           default:
252             return "?????";                       252             return "?????";
253             break;                                253             break;
254         };                                        254         };
255       }                                           255       }
256       else if(command == setWrFile[i])            256       else if(command == setWrFile[i])
257       {                                           257       {
258         return pc->CurrentWriteFile(wrObj[i]);    258         return pc->CurrentWriteFile(wrObj[i]);
259       }                                           259       }
260     }                                             260     }
261   }                                               261   }
262                                                   262 
263   return ustr;                                    263   return ustr;
264 }                                                 264 }
265                                                   265 
266 // -------------------------------------------    266 // --------------------------------------------------------------------
267 G4String G4PersistencyCenterMessenger::PopWord    267 G4String G4PersistencyCenterMessenger::PopWord(const G4String& text, G4int n,
268                                                   268                                                const G4String& delim)
269 {                                                 269 {
270   if(text.length() <= 0)                          270   if(text.length() <= 0)
271     return "";                                    271     return "";
272   std::size_t p = 0, p0 = 0;                   << 272   G4int p = 0, p0 = 0;
273   std::size_t p1 = 0;                          << 273   G4int p1 = 0;
274   for(G4int i = 0; i < n; ++i)                    274   for(G4int i = 0; i < n; ++i)
275   {                                               275   {
276     p1 = text.find_first_of(delim, p0 + 1);       276     p1 = text.find_first_of(delim, p0 + 1);
277     while(p1 == p0 + 1)                           277     while(p1 == p0 + 1)
278     {                                             278     {
279       p0 = p1;                                    279       p0 = p1;
280       p1 = text.find_first_of(delim, p0 + 1);     280       p1 = text.find_first_of(delim, p0 + 1);
281     }                                             281     }
282     p = p0;                                       282     p = p0;
283     if(p1 == G4String::npos)                   << 283     if(p1 < 0)
284     {                                             284     {
285       if(i + 1 < n)                               285       if(i + 1 < n)
286         return "";                                286         return "";
287       p1 = text.length();                         287       p1 = text.length();
288       break;                                      288       break;
289     }                                             289     }
290     p0 = p1;                                      290     p0 = p1;
291   }                                               291   }
292   if(p > 0)                                       292   if(p > 0)
293     ++p;                                          293     ++p;
294   return text.substr(p, p1 - p);                  294   return text.substr(p, p1 - p);
295 }                                                 295 }
296                                                   296