]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4Globals.cxx
Changed for new Aliroot version.
[u/mrichter/AliRoot.git] / TGeant4 / TG4Globals.cxx
1 // $Id$
2 // Category: global
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class TG4Globals
7 // ----------------
8 // See the class description in the header file.
9
10 #include "TG4Globals.h"
11
12 #include <stdlib.h>
13
14 //_____________________________________________________________________________
15 TG4Globals::TG4Globals() {
16 //
17 }
18   
19 //_____________________________________________________________________________
20 TG4Globals::~TG4Globals() {
21 //
22 }
23   
24 // static methods
25
26 //_____________________________________________________________________________
27 void TG4Globals::Exception(const char* string)
28 {
29 // Prints error message end exits the program.
30 // ---
31
32   if (string)
33   {  G4cerr << G4endl << "    " << string << G4endl; }
34   G4cerr << "*** TG4Exception: Aborting execution ***" << G4endl;   
35   exit(1);
36 }
37
38 //_____________________________________________________________________________
39 void TG4Globals::Warning(const char* string)
40 {
41 // Prints warning message.
42 // ---
43
44   G4cerr << "++++  TG4Warning:  ++++" << G4endl;   
45   if (string)
46   {  G4cerr  << "    " << string << G4endl; }
47   G4cerr << "+++++++++++++++++++++++" << G4endl;   
48 }
49
50 //_____________________________________________________________________________
51 void TG4Globals::AppendNumberToString(G4String& s, G4int a)
52 {
53 // Appends number to string.
54 // ---
55
56   const char* kpNumber="0123456789";
57   G4String p=""; G4String q="";
58   do 
59   {
60     G4int b=a/10;
61     G4int c=a%10;
62     p=kpNumber[c];
63     q=p.append(q);
64     a=b;        
65   } while (a>0);
66   s.append(q);
67 }
68
69 //_____________________________________________________________________________
70 G4bool TG4Globals::Compare(G4bool activation, TG4G3ControlValue controlValue)
71 {
72 // Compares the boolean value of the process activation
73 // with the process control value.
74 // Returns true if the values correspond, false otherwise.
75 // ---
76
77   if (controlValue == kUnset) {
78     TG4Globals::Warning(
79       "TG4SpecialControls::Compare: control value = kUnset.");
80     return false;
81   }    
82
83   if (controlValue == kActivate || controlValue == kActivate2)
84     return activation;
85   else
86     return !activation;  
87 }  
88
89 //_____________________________________________________________________________
90 void TG4Globals::PrintStars(G4bool emptyLineFirst)
91 {
92 // Print stars.
93 // ---
94   
95
96   if (emptyLineFirst)  G4cout << G4endl;
97   
98   G4cout << "**********************************************" << G4endl;
99      
100   if (!emptyLineFirst) G4cout << G4endl;
101 }
102