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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 4.1.p1)


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