Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4UImanager.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// G4UImanager
27//
28// Author: Makoto Asai, 1997
29// --------------------------------------------------------------------
30
31#include "G4UImanager.hh"
32#include "G4UIcommandTree.hh"
33#include "G4UIcommand.hh"
34#include "G4UIsession.hh"
35#include "G4UIbatch.hh"
37#include "G4UnitsMessenger.hh"
40#include "G4ios.hh"
41#include "G4strstreambuf.hh"
42#include "G4StateManager.hh"
43#include "G4UIaliasList.hh"
44#include "G4Tokenizer.hh"
46#include "G4UIbridge.hh"
47#include "G4Threading.hh"
48
49#include <sstream>
50#include <fstream>
51
52G4bool G4UImanager::doublePrecisionStr = false;
53G4int G4UImanager::igThreadID = -1;
54
55// --------------------------------------------------------------------
56G4UImanager*& G4UImanager::fUImanager()
57{
58 G4ThreadLocalStatic G4UImanager* _instance = nullptr;
59 return _instance;
60}
61
62// --------------------------------------------------------------------
63G4bool& G4UImanager::fUImanagerHasBeenKilled()
64{
65 G4ThreadLocalStatic G4bool _instance = false;
66 return _instance;
67}
68
69// --------------------------------------------------------------------
70G4UImanager*& G4UImanager::fMasterUImanager()
71{
72 static G4UImanager* _instance = nullptr;
73 return _instance;
74}
75
76// --------------------------------------------------------------------
78{
79 if(fUImanager() == nullptr)
80 {
81 if(!fUImanagerHasBeenKilled())
82 {
83 fUImanager() = new G4UImanager;
84 fUImanager()->CreateMessenger();
85 }
86 }
87 return fUImanager();
88}
89
90// --------------------------------------------------------------------
92{
93 return fMasterUImanager();
94}
95
96// --------------------------------------------------------------------
98 : G4VStateDependent(true)
99{
100 treeTop = new G4UIcommandTree("/");
101 aliasList = new G4UIaliasList;
103 commandStack = new std::vector<G4String>;
104}
105
106// --------------------------------------------------------------------
107void G4UImanager::CreateMessenger()
108{
109 UImessenger = new G4UIcontrolMessenger;
110 UnitsMessenger = new G4UnitsMessenger;
111 CoutMessenger = new G4LocalThreadCoutMessenger;
112 ProfileMessenger = new G4ProfilerMessenger;
113}
114
115// --------------------------------------------------------------------
117{
118 if(bridges != nullptr)
119 {
120 for(auto bridge : *bridges)
121 {
122 delete bridge;
123 }
124 delete bridges;
125 }
126 SetCoutDestination(nullptr);
127 histVec.clear();
128 if(saveHistory)
129 {
130 historyFile.close();
131 }
132 delete CoutMessenger;
133 delete ProfileMessenger;
134 delete UnitsMessenger;
135 delete UImessenger;
136 delete treeTop;
137 delete aliasList;
138 fUImanagerHasBeenKilled() = true;
139 fUImanager() = nullptr;
140 if(commandStack != nullptr)
141 {
142 commandStack->clear();
143 delete commandStack;
144 }
145 if(threadID >= 0)
146 {
147 delete threadCout;
149 threadID = -1;
150 }
151}
152
153// --------------------------------------------------------------------
155{
156 doublePrecisionStr = val;
157}
158
159// --------------------------------------------------------------------
161{
162 return doublePrecisionStr;
163}
164
165// --------------------------------------------------------------------
167{
168 G4String theCommand = aCommand;
169 savedCommand = treeTop->FindPath(theCommand);
170 if(savedCommand == nullptr)
171 {
172 G4cerr << "command not found" << G4endl;
173 return G4String();
174 }
175 return savedCommand->GetCurrentValue();
176}
177
178// --------------------------------------------------------------------
180 G4int parameterNumber, G4bool reGet)
181{
182 if(reGet || savedCommand == nullptr)
183 {
184 savedParameters = GetCurrentValues(aCommand);
185 }
186 G4Tokenizer savedToken(savedParameters);
187 G4String token;
188 for(G4int i_thParameter = 0; i_thParameter < parameterNumber; ++i_thParameter)
189 {
190 token = savedToken();
191 if(token.empty())
192 {
193 return G4String();
194 }
195 if(token[(size_t) 0] == '"')
196 {
197 token.append(" ");
198 token.append(savedToken("\""));
199 }
200 }
201 return token;
202}
203
204// --------------------------------------------------------------------
206 const char* aParameterName,
207 G4bool reGet)
208{
209 if(reGet || savedCommand == nullptr)
210 {
211 G4String parameterValues = GetCurrentValues(aCommand);
212 }
213 for(G4int i = 0; i < (G4int)savedCommand->GetParameterEntries(); ++i)
214 {
215 if(aParameterName == savedCommand->GetParameter(i)->GetParameterName())
216 {
217 return GetCurrentStringValue(aCommand, i + 1, false);
218 }
219 }
220 return G4String();
221}
222
223// --------------------------------------------------------------------
225 const char* aParameterName, G4bool reGet)
226{
227 G4String targetParameter =
228 GetCurrentStringValue(aCommand, aParameterName, reGet);
229 G4int value;
230 const char* t = targetParameter;
231 std::istringstream is(t);
232 is >> value;
233 return value;
234}
235
236// --------------------------------------------------------------------
238 G4int parameterNumber, G4bool reGet)
239{
240 G4String targetParameter =
241 GetCurrentStringValue(aCommand, parameterNumber, reGet);
242 G4int value;
243 const char* t = targetParameter;
244 std::istringstream is(t);
245 is >> value;
246 return value;
247}
248
249// --------------------------------------------------------------------
251 const char* aParameterName,
252 G4bool reGet)
253{
254 G4String targetParameter =
255 GetCurrentStringValue(aCommand, aParameterName, reGet);
256 G4double value;
257 const char* t = targetParameter;
258 std::istringstream is(t);
259 is >> value;
260 return value;
261}
262
263// --------------------------------------------------------------------
265 G4int parameterNumber, G4bool reGet)
266{
267 G4String targetParameter =
268 GetCurrentStringValue(aCommand, parameterNumber, reGet);
269 G4double value;
270 const char* t = targetParameter;
271 std::istringstream is(t);
272 is >> value;
273 return value;
274}
275
276// --------------------------------------------------------------------
278{
279 treeTop->AddNewCommand(newCommand);
280 if(fMasterUImanager() != nullptr && G4Threading::G4GetThreadId() == 0)
281 {
282 fMasterUImanager()->AddWorkerCommand(newCommand);
283 }
284}
285
286// --------------------------------------------------------------------
287void G4UImanager::AddWorkerCommand(G4UIcommand* newCommand)
288{
289 treeTop->AddNewCommand(newCommand, true);
290}
291
292// --------------------------------------------------------------------
294{
295 treeTop->RemoveCommand(aCommand);
296 if(fMasterUImanager() != nullptr && G4Threading::G4GetThreadId() == 0)
297 {
298 fMasterUImanager()->RemoveWorkerCommand(aCommand);
299 }
300}
301
302// --------------------------------------------------------------------
303void G4UImanager::RemoveWorkerCommand(G4UIcommand* aCommand)
304{
305 treeTop->RemoveCommand(aCommand, true);
306}
307
308// --------------------------------------------------------------------
309void G4UImanager::ExecuteMacroFile(const char* fileName)
310{
311 G4UIsession* batchSession = new G4UIbatch(fileName, session);
312 session = batchSession;
313 lastRC = 0;
314 G4UIsession* previousSession = session->SessionStart();
315 lastRC = session->GetLastReturnCode();
316 delete session;
317 session = previousSession;
318}
319
320// --------------------------------------------------------------------
321void G4UImanager::LoopS(const char* valueList)
322{
323 G4String vl = valueList;
324 G4Tokenizer parameterToken(vl);
325 G4String mf = parameterToken();
326 G4String vn = parameterToken();
327 G4String c1 = parameterToken();
328 c1 += " ";
329 c1 += parameterToken();
330 c1 += " ";
331 c1 += parameterToken();
332 const char* t1 = c1;
333 std::istringstream is(t1);
334 G4double d1;
335 G4double d2;
336 G4double d3;
337 is >> d1 >> d2 >> d3;
338 Loop(mf, vn, d1, d2, d3);
339}
340
341// --------------------------------------------------------------------
342void G4UImanager::Loop(const char* macroFile, const char* variableName,
343 G4double initialValue, G4double finalValue,
344 G4double stepSize)
345{
346 G4String cd;
347 if(stepSize > 0)
348 {
349 for(G4double d = initialValue; d <= finalValue; d += stepSize)
350 {
351 std::ostringstream os;
352 os << d;
353 cd += os.str();
354 cd += " ";
355 }
356 }
357 else
358 {
359 for(G4double d = initialValue; d >= finalValue; d += stepSize)
360 {
361 std::ostringstream os;
362 os << d;
363 cd += os.str();
364 cd += " ";
365 }
366 }
367 Foreach(macroFile, variableName, cd);
368}
369
370// --------------------------------------------------------------------
371void G4UImanager::ForeachS(const char* valueList)
372{
373 G4String vl = valueList;
374 G4Tokenizer parameterToken(vl);
375 G4String mf = parameterToken();
376 G4String vn = parameterToken();
377 G4String c1 = parameterToken();
378 G4String ca;
379 while(!((ca = parameterToken()).empty()))
380 {
381 c1 += " ";
382 c1 += ca;
383 }
384
385 G4String aliasValue = c1;
386 if(aliasValue[0] == '"')
387 {
388 G4String strippedValue;
389 if(aliasValue.back() == '"')
390 {
391 strippedValue = aliasValue.substr(1, aliasValue.length() - 2);
392 }
393 else
394 {
395 strippedValue = aliasValue.substr(1, aliasValue.length() - 1);
396 }
397 aliasValue = strippedValue;
398 }
399
400 // Foreach(mf,vn,c1);
401 Foreach(mf, vn, aliasValue);
402}
403
404// --------------------------------------------------------------------
405void G4UImanager::Foreach(const char* macroFile, const char* variableName,
406 const char* candidates)
407{
408 G4String candidatesString = candidates;
409 G4Tokenizer parameterToken(candidatesString);
410 G4String cd;
411 while(!((cd = parameterToken()).empty()))
412 {
413 G4String vl = variableName;
414 vl += " ";
415 vl += cd;
416 SetAlias(vl);
418 if(lastRC != 0)
419 {
421 ed << "Loop aborted due to a command execution error - "
422 << "error code " << lastRC;
423 G4Exception("G4UImanager::Foreach", "UIMAN0201", JustWarning, ed);
424 break;
425 }
426 }
427}
428
429// --------------------------------------------------------------------
431{
432 G4String aCommand = aCmd;
433 std::size_t ia = aCommand.find("{");
434 std::size_t iz = aCommand.find("#");
435 while((ia != std::string::npos) &&
436 ((iz == std::string::npos) || (ia < iz)))
437 {
438 G4int ibx = -1;
439 while(ibx < 0)
440 {
441 std::size_t ib = aCommand.find("}");
442 if(ib == std::string::npos)
443 {
444 G4cerr << aCommand << G4endl;
445 for(std::size_t i = 0; i < ia; ++i)
446 {
447 G4cerr << " ";
448 }
449 G4cerr << "^" << G4endl;
450 G4cerr << "Unmatched alias parenthesis -- command ignored" << G4endl;
451 G4String nullStr;
452 return nullStr;
453 }
454 G4String ps = aCommand.substr(ia + 1, aCommand.length() - (ia + 1));
455 std::size_t ic = ps.find("{");
456 std::size_t id = ps.find("}");
457 if(ic != std::string::npos && ic < id)
458 {
459 ia += ic + 1;
460 }
461 else
462 {
463 ibx = (G4int)ib;
464 }
465 }
466 //--- Here ia represents the position of innermost "{"
467 //--- and ibx represents corresponding "}"
468 G4String subs;
469 if(ia > 0)
470 {
471 subs = aCommand.substr(0, ia);
472 }
473 G4String alis = aCommand.substr(ia + 1, ibx - ia - 1);
474 G4String rems = aCommand.substr(ibx + 1, aCommand.length() - ibx);
475 G4String* alVal = aliasList->FindAlias(alis);
476 if(alVal == nullptr)
477 {
478 G4cerr << "Alias <" << alis << "> not found -- command ignored" << G4endl;
479 G4String nullStr;
480 return nullStr;
481 }
482 aCommand = subs + (*alVal) + rems;
483 ia = aCommand.find("{");
484 }
485 return aCommand;
486}
487
488// --------------------------------------------------------------------
490{
491 return ApplyCommand(aCmd.data());
492}
493
494// --------------------------------------------------------------------
496{
497 G4String aCommand = SolveAlias(aCmd);
498 if(aCommand.empty())
499 {
500 return fAliasNotFound;
501 }
502 if(verboseLevel != 0)
503 {
504 if(isMaster)
505 {
506 fLastCommandOutputTreated = false;
507 }
508 G4cout << aCommand << G4endl;
509 }
510 G4String commandString;
511 G4String commandParameter;
512
513 std::size_t i = aCommand.find(" ");
514 if(i != std::string::npos)
515 {
516 commandString = aCommand.substr(0, i);
517 commandParameter = aCommand.substr(i + 1, aCommand.length() - (i + 1));
518 }
519 else
520 {
521 commandString = aCommand;
522 }
523
524 // remove doubled slash
525 std::size_t len = commandString.length();
526 std::size_t ll = 0;
527 G4String a1;
528 G4String a2;
529 while(ll < len - 1)
530 {
531 if(commandString.substr(ll, 2) == "//")
532 {
533 if(ll == 0)
534 {
535 // Safe because index argument always 0
536 commandString.erase(ll, 1);
537 }
538 else
539 {
540 a1 = commandString.substr(0, ll);
541 a2 = commandString.substr(ll + 1, len - ll - 1);
542 commandString = a1 + a2;
543 }
544 --len;
545 }
546 else
547 {
548 ++ll;
549 }
550 }
551
552 if(isMaster && bridges != nullptr)
553 {
554 for(auto bridge : *bridges)
555 {
556 G4int leng = bridge->DirLength();
557 if(commandString.substr(0, leng) == bridge->DirName())
558 {
559 return bridge->LocalUI()->ApplyCommand(commandString + " " +
560 commandParameter);
561 }
562 }
563 }
564
565 G4UIcommand* targetCommand = treeTop->FindPath(commandString);
566 if(targetCommand == nullptr)
567 {
568 if(ignoreCmdNotFound)
569 {
570 if(stackCommandsForBroadcast)
571 {
572 commandStack->push_back(commandString + " " + commandParameter);
573 }
574 return fCommandSucceeded;
575 }
576 else
577 {
578 return fCommandNotFound;
579 }
580 }
581
582 if(stackCommandsForBroadcast && targetCommand->ToBeBroadcasted())
583 {
584 commandStack->push_back(commandString + " " + commandParameter);
585 }
586
587 if(!(targetCommand->IsAvailable()))
588 {
590 }
591
592 if(saveHistory)
593 {
594 historyFile << aCommand << G4endl;
595 }
596 if(G4int(histVec.size()) >= maxHistSize)
597 {
598 histVec.erase(histVec.begin());
599 }
600 histVec.push_back(aCommand);
601
602 targetCommand->ResetFailure();
603 G4int commandFailureCode = targetCommand->DoIt(commandParameter);
604 if(commandFailureCode == 0)
605 {
606 G4int additionalFailureCode = targetCommand->IfCommandFailed();
607 if(additionalFailureCode > 0)
608 {
610 msg << targetCommand->GetFailureDescription() << "\n"
611 << "Error code : " << additionalFailureCode;
612 G4Exception("G4UImanager::ApplyCommand", "UIMAN0123", JustWarning, msg);
613 commandFailureCode += additionalFailureCode;
614 }
615 }
616 return commandFailureCode;
617}
618
619
620// --------------------------------------------------------------------
622{
623 return FindCommand(aCmd.data());
624}
625
626// --------------------------------------------------------------------
628{
629 G4String aCommand = SolveAlias(aCmd);
630 if(aCommand.empty())
631 { return nullptr; }
632
633 G4String commandString;
634
635 std::size_t i = aCommand.find(" ");
636 if(i != std::string::npos)
637 { commandString = aCommand.substr(0, i); }
638 else
639 { commandString = aCommand; }
640
641 return treeTop->FindPath(commandString);
642}
643
644// --------------------------------------------------------------------
645void G4UImanager::StoreHistory(const char* fileName)
646{
647 StoreHistory(true, fileName);
648}
649
650// --------------------------------------------------------------------
651void G4UImanager::StoreHistory(G4bool historySwitch, const char* fileName)
652{
653 if(historySwitch)
654 {
655 if(saveHistory)
656 {
657 historyFile.close();
658 }
659 historyFile.open((char*) fileName);
660 saveHistory = true;
661 }
662 else
663 {
664 historyFile.close();
665 saveHistory = false;
666 }
667 saveHistory = historySwitch;
668}
669
670// --------------------------------------------------------------------
671void G4UImanager::PauseSession(const char* msg)
672{
673 if(session != nullptr)
674 {
675 session->PauseSessionStart(msg);
676 }
677}
678
679// --------------------------------------------------------------------
680void G4UImanager::ListCommands(const char* direct)
681{
682 G4UIcommandTree* comTree = FindDirectory(direct);
683 if(comTree != nullptr)
684 {
685 comTree->List();
686 }
687 else
688 {
689 G4cout << direct << " is not found." << G4endl;
690 }
691}
692
693// --------------------------------------------------------------------
694G4UIcommandTree* G4UImanager::FindDirectory(const char* dirName)
695{
696 G4String aDirName = dirName;
697 G4String targetDir = G4StrUtil::strip_copy(aDirName);
698 if(targetDir.back() != '/')
699 {
700 targetDir += "/";
701 }
702 G4UIcommandTree* comTree = treeTop;
703 if(targetDir == "/")
704 {
705 return comTree;
706 }
707 std::size_t idx = 1;
708 while(idx < targetDir.length() - 1)
709 {
710 std::size_t i = targetDir.find("/", idx);
711 G4String targetDirString = targetDir.substr(0, i + 1);
712 comTree = comTree->GetTree(targetDirString);
713 if(comTree == nullptr)
714 {
715 return nullptr;
716 }
717 idx = i + 1;
718 }
719 return comTree;
720}
721
722// --------------------------------------------------------------------
724{
725 if(pauseAtBeginOfEvent)
726 {
727 if(requestedState == G4State_EventProc &&
728 G4StateManager::GetStateManager()->GetPreviousState() ==
730 {
731 PauseSession("BeginOfEvent");
732 }
733 }
734 if(pauseAtEndOfEvent)
735 {
736 if(requestedState == G4State_GeomClosed &&
737 G4StateManager::GetStateManager()->GetPreviousState() ==
739 {
740 PauseSession("EndOfEvent");
741 }
742 }
743 return true;
744}
745
746// --------------------------------------------------------------------
748{
751}
752
753// --------------------------------------------------------------------
754void G4UImanager::SetAlias(const char* aliasLine)
755{
756 G4String aLine = aliasLine;
757 std::size_t i = aLine.find(" ");
758 G4String aliasName = aLine.substr(0, i);
759 G4String aliasValue = aLine.substr(i + 1, aLine.length() - (i + 1));
760 if(aliasValue[0] == '"')
761 {
762 G4String strippedValue;
763 if(aliasValue.back() == '"')
764 {
765 strippedValue = aliasValue.substr(1, aliasValue.length() - 2);
766 }
767 else
768 {
769 strippedValue = aliasValue.substr(1, aliasValue.length() - 1);
770 }
771 aliasValue = strippedValue;
772 }
773
774 aliasList->ChangeAlias(aliasName, aliasValue);
775}
776
777// --------------------------------------------------------------------
778void G4UImanager::RemoveAlias(const char* aliasName)
779{
780 G4String aL = aliasName;
781 G4String targetAlias = G4StrUtil::strip_copy(aL);
782 aliasList->RemoveAlias(targetAlias);
783}
784
785// --------------------------------------------------------------------
787{
788 aliasList->List();
789}
790
791// --------------------------------------------------------------------
792void G4UImanager::CreateHTML(const char* dir)
793{
794 G4UIcommandTree* tr = FindDirectory(dir);
795 if(tr != nullptr)
796 {
797 tr->CreateHTML();
798 }
799 else
800 {
801 G4cerr << "Directory <" << dir << "> is not found." << G4endl;
802 }
803}
804
805// --------------------------------------------------------------------
807{
808 searchDirs.clear();
809
810 std::size_t idxfirst = 0;
811 std::size_t idxend = 0;
812 G4String pathstring = "";
813 while((idxend = searchPath.find(':', idxfirst)) != G4String::npos)
814 {
815 pathstring = searchPath.substr(idxfirst, idxend - idxfirst);
816 if(!pathstring.empty())
817 {
818 searchDirs.push_back(pathstring);
819 }
820 idxfirst = idxend + 1;
821 }
822
823 pathstring = searchPath.substr(idxfirst, searchPath.size() - idxfirst);
824 if(!pathstring.empty())
825 {
826 searchDirs.push_back(pathstring);
827 }
828}
829
830// --------------------------------------------------------------------
831static G4bool FileFound(const G4String& fname)
832{
833 G4bool qopen = false;
834 std::ifstream fs;
835 fs.open(fname.c_str(), std::ios::in);
836 if(fs.good())
837 {
838 fs.close();
839 qopen = true;
840 }
841 return qopen;
842}
843
844// --------------------------------------------------------------------
846{
847 G4String macrofile = fname;
848
849 for(const auto& searchDir : searchDirs)
850 {
851 G4String fullpath = searchDir + "/" + fname;
852 if(FileFound(fullpath))
853 {
854 macrofile = fullpath;
855 break;
856 }
857 }
858 return macrofile;
859}
860
861// --------------------------------------------------------------------
862std::vector<G4String>* G4UImanager::GetCommandStack()
863{
864 std::vector<G4String>* returnValue = commandStack;
865 commandStack = new std::vector<G4String>;
866 return returnValue;
867}
868
869// --------------------------------------------------------------------
871{
872 if(brg->LocalUI() == this)
873 {
874 G4Exception("G4UImanager::RegisterBridge()", "UI7002", FatalException,
875 "G4UIBridge cannot bridge between same object.");
876 }
877 else
878 {
879 bridges->push_back(brg);
880 }
881}
882
883// --------------------------------------------------------------------
885{
886 threadID = tId;
888 threadCout = new G4MTcoutDestination(threadID);
889 threadCout->SetIgnoreCout(igThreadID);
890}
891
892// --------------------------------------------------------------------
894{
898 threadCout = new G4MTcoutDestination(threadID);
899 threadCout->SetPrefixString(pref);
900 threadCout->SetIgnoreCout(igThreadID);
901}
902
903// --------------------------------------------------------------------
904void G4UImanager::SetCoutFileName(const G4String& fileN, G4bool ifAppend)
905{
906 // for sequential mode, ignore this method.
907 if(threadID < 0)
908 {
909 return;
910 }
911
912 if(fileN == "**Screen**")
913 {
914 threadCout->SetCoutFileName(fileN, ifAppend);
915 }
916 else
917 {
918 std::stringstream fn;
919 fn << "G4W_" << threadID << "_" << fileN;
920 threadCout->SetCoutFileName(fn.str(), ifAppend);
921 }
922}
923
924// --------------------------------------------------------------------
925void G4UImanager::SetCerrFileName(const G4String& fileN, G4bool ifAppend)
926{
927 // for sequential mode, ignore this method.
928 if(threadID < 0)
929 {
930 return;
931 }
932
933 if(fileN == "**Screen**")
934 {
935 threadCout->SetCerrFileName(fileN, ifAppend);
936 }
937 else
938 {
939 std::stringstream fn;
940 fn << "G4W_" << threadID << "_" << fileN;
941 threadCout->SetCerrFileName(fn.str(), ifAppend);
942 }
943}
944
945// --------------------------------------------------------------------
947{
948 // for sequential mode, ignore this method.
949 if(threadID < 0)
950 {
951 return;
952 }
953 threadCout->SetPrefixString(s);
954}
955
956// --------------------------------------------------------------------
958{
959 // for sequential mode, ignore this method.
960 if(threadID < 0)
961 {
962 return;
963 }
964 threadCout->EnableBuffering(flg);
965}
966
967// --------------------------------------------------------------------
969{
970 // for sequential mode, ignore this method.
971 if(threadID < 0)
972 {
973 igThreadID = tid;
974 return;
975 }
976 threadCout->SetIgnoreCout(tid);
977}
978
979// --------------------------------------------------------------------
981{
982 // for sequential mode, ignore this method.
983 if(threadID < 0)
984 {
985 return;
986 }
987 threadCout->SetIgnoreInit(flg);
988}
G4ApplicationState
@ G4State_EventProc
@ G4State_GeomClosed
@ JustWarning
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
@ fCommandNotFound
@ fAliasNotFound
@ fIllegalApplicationState
@ fCommandSucceeded
void G4iosFinalization()
Definition: G4ios.cc:118
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void G4iosInitialization()
Definition: G4ios.cc:117
G4GLOB_DLL G4strstreambuf G4coutbuf
Definition: G4ios.cc:114
G4GLOB_DLL G4strstreambuf G4cerrbuf
Definition: G4ios.cc:115
void SetPrefixString(const G4String &wd="G4WT")
void EnableBuffering(G4bool flag=true)
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
void SetIgnoreInit(G4bool val=true)
void SetIgnoreCout(G4int tid=0)
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
static G4StateManager * GetStateManager()
G4String * FindAlias(const char *aliasName)
void ChangeAlias(const char *aliasName, const char *aliasValue)
void RemoveAlias(const char *aliasName)
G4UImanager * LocalUI() const
Definition: G4UIbridge.hh:55
G4UIcommandTree * GetTree(G4int i)
void List() const
void AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly=false)
void CreateHTML(const G4String &="")
G4UIcommand * FindPath(const char *commandPath) const
void RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly=false)
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:139
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:140
G4bool ToBeBroadcasted() const
Definition: G4UIcommand.hh:173
G4int IfCommandFailed()
Definition: G4UIcommand.hh:189
virtual G4int DoIt(G4String parameterList)
Definition: G4UIcommand.cc:146
void ResetFailure()
Definition: G4UIcommand.hh:191
G4bool IsAvailable()
Definition: G4UIcommand.cc:342
const G4String & GetFailureDescription()
Definition: G4UIcommand.hh:190
G4String GetCurrentValue()
Definition: G4UIcommand.cc:281
~G4UImanager() override
Definition: G4UImanager.cc:116
static G4bool DoublePrecisionStr()
Definition: G4UImanager.cc:160
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
Definition: G4UImanager.cc:925
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:747
static void UseDoublePrecisionStr(G4bool val)
Definition: G4UImanager.cc:154
void ForeachS(const char *valueList)
Definition: G4UImanager.cc:371
void SetUpForAThread(G4int tId)
Definition: G4UImanager.cc:884
std::vector< G4String > * GetCommandStack()
Definition: G4UImanager.cc:862
void Foreach(const char *macroFile, const char *variableName, const char *candidates)
Definition: G4UImanager.cc:405
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:495
void SetThreadIgnoreInit(G4bool flg=true)
Definition: G4UImanager.cc:980
void CreateHTML(const char *dir="/")
Definition: G4UImanager.cc:792
void Loop(const char *macroFile, const char *variableName, G4double initialValue, G4double finalValue, G4double stepSize=1.0)
Definition: G4UImanager.cc:342
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:237
void SetThreadPrefixString(const G4String &prefix="W")
Definition: G4UImanager.cc:946
void LoopS(const char *valueList)
Definition: G4UImanager.cc:321
void StoreHistory(const char *fileName="G4history.macro")
Definition: G4UImanager.cc:645
void ListCommands(const char *direc)
Definition: G4UImanager.cc:680
G4double GetCurrentDoubleValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:264
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:309
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
Definition: G4UImanager.cc:904
static G4UImanager * GetMasterUIpointer()
Definition: G4UImanager.cc:91
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:179
void SetUpForSpecialThread(const G4String &aPrefix)
Definition: G4UImanager.cc:893
void AddNewCommand(G4UIcommand *newCommand)
Definition: G4UImanager.cc:277
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:166
void SetThreadIgnore(G4int tid=0)
Definition: G4UImanager.cc:968
void SetAlias(const char *aliasLine)
Definition: G4UImanager.cc:754
G4String FindMacroPath(const G4String &fname) const
Definition: G4UImanager.cc:845
void RemoveAlias(const char *aliasName)
Definition: G4UImanager.cc:778
G4bool Notify(G4ApplicationState requestedState) override
Definition: G4UImanager.cc:723
G4String SolveAlias(const char *aCmd)
Definition: G4UImanager.cc:430
void ListAlias()
Definition: G4UImanager.cc:786
void RemoveCommand(G4UIcommand *aCommand)
Definition: G4UImanager.cc:293
G4UIcommand * FindCommand(const char *aCommand)
Definition: G4UImanager.cc:627
void ParseMacroSearchPath()
Definition: G4UImanager.cc:806
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void RegisterBridge(G4UIbridge *brg)
Definition: G4UImanager.cc:870
void SetThreadUseBuffer(G4bool flg=true)
Definition: G4UImanager.cc:957
const G4String & GetParameterName() const
void SetDestination(G4coutDestination *dest)
G4String strip_copy(G4String str, char ch=' ')
Return copy of string with leading and trailing characters removed.
G4int G4GetThreadId()
Definition: G4Threading.cc:122
void G4SetThreadId(G4int aNewValue)
Definition: G4Threading.cc:125
#define G4ThreadLocalStatic
Definition: tls.hh:76