Format() method added; changed Print() - usage of Format()
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 19 Dec 2001 10:31:43 +0000 (10:31 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 19 Dec 2001 10:31:43 +0000 (10:31 +0000)
TGeant4/TG4G3ControlVector.cxx
TGeant4/TG4G3CutVector.cxx

index 19f0131..483f5f2 100644 (file)
@@ -14,6 +14,7 @@
 #include "TG4Globals.h"
 
 #include <G4VProcess.hh>
+#include <g4std/strstream>
 
 #include <math.h>
 
@@ -251,17 +252,30 @@ G4bool TG4G3ControlVector::Update(const TG4G3ControlVector& vector)
 }
 
 //_____________________________________________________________________________
-void TG4G3ControlVector::Print() const
+G4String TG4G3ControlVector::Format() const
 {
-// Prints the controls.
+// Formats the output into a string.
 // ---
 
-  G4cout << "  G3 control vector:" << G4endl; 
+  strstream tmpStream;
+
+  tmpStream << "  G3 control vector:" << G4endl; 
   for (G4int i=0; i<kNoG3Controls; i++) 
     //if (i != kDRAY) {
-      G4cout << "    " << fgControlNameVector[i] 
-             << " control value: " << fControlVector[i] << G4endl; 
+      tmpStream << "    " << fgControlNameVector[i] 
+                << " control value: " << fControlVector[i] << G4endl; 
     //}             
+    
+  return tmpStream.str();  
+}         
+
+//_____________________________________________________________________________
+void TG4G3ControlVector::Print() const
+{
+// Prints the controls.
+// ---
+
+  G4cout << Format();       
 }         
 
 //_____________________________________________________________________________
index 5bcc22a..9697c02 100644 (file)
@@ -14,6 +14,8 @@
 #include <G4ParticleDefinition.hh>
 #include <G4VProcess.hh>
 
+#include <g4std/strstream>
+
 const G4double  TG4G3CutVector::fgkDCUTEOff  = 10. * TeV;
 const G4double  TG4G3CutVector::fgkDCUTMOff  = 10. * TeV;
 const G4double  TG4G3CutVector::fgkTolerance =  1. * keV;
@@ -173,33 +175,45 @@ G4bool TG4G3CutVector::Update(const TG4G3CutVector& vector)
 }
 
 //_____________________________________________________________________________
-void TG4G3CutVector::Print() const
+G4String TG4G3CutVector::Format() const
 {
-// Prints the cuts.
+// Formats the output into a string.
 // ---
 
-  G4cout << "  G3 cut vector:" << G4endl; 
+  strstream tmpStream;
+  tmpStream << "  G3 cut vector:" << G4endl; 
   if (fDeltaRaysOn)
-    G4cout << "    Delta rays On" << G4endl; 
+    tmpStream << "    Delta rays On" << G4endl; 
   else  
-    G4cout << "    Delta rays Off" << G4endl; 
+    tmpStream << "    Delta rays Off" << G4endl; 
   
   // energy cuts
   for (G4int i=0; i<kTOFMAX; i++) {
 
-    G4cout << "    " << fgCutNameVector[i] << " cut value (MeV): ";
+    tmpStream << "    " << fgCutNameVector[i] << " cut value (MeV): ";
 
     if (i == kDCUTE && !fDeltaRaysOn)
-      G4cout << fgkDCUTEOff/MeV << G4endl;
+      tmpStream << fgkDCUTEOff/MeV << G4endl;
     else if (i == kDCUTM && !fDeltaRaysOn)
-      G4cout << fgkDCUTMOff/MeV << G4endl;
+      tmpStream << fgkDCUTMOff/MeV << G4endl;
     else                 
-      G4cout << fCutVector[i]/MeV << G4endl;
+      tmpStream << fCutVector[i]/MeV << G4endl;
   }      
 
   // time cut
-  G4cout << "    " << fgCutNameVector[kTOFMAX] << " cut value (s):   "
-         << fCutVector[kTOFMAX]/s << G4endl;
+  tmpStream << "    " << fgCutNameVector[kTOFMAX] << " cut value (s):   "
+            << fCutVector[kTOFMAX]/s << G4endl;
+
+  return tmpStream.str();
+}         
+
+//_____________________________________________________________________________
+void TG4G3CutVector::Print() const
+{
+// Prints the cuts.
+// ---
+
+  G4cout << Format();
 }         
 
 //_____________________________________________________________________________