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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 /examples/advanced/composite_calorimeter/src/CCalutils.cc (Version 11.3.0) and /examples/advanced/composite_calorimeter/src/CCalutils.cc (Version 7.0.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 //////////////////////////////////////////////     23 ///////////////////////////////////////////////////////////////////////////////
 27 // File: CCalutils.cc                              24 // File: CCalutils.cc
 28 // Description: General utilities.                 25 // Description: General utilities.
 29 //////////////////////////////////////////////     26 ///////////////////////////////////////////////////////////////////////////////
 30 #include "CCalutils.hh"                            27 #include "CCalutils.hh"
 31 #include "G4ios.hh"                                28 #include "G4ios.hh"
 32 #include "G4UnitsTable.hh"                         29 #include "G4UnitsTable.hh"
                                                   >>  30 #include <strstream>
 33                                                    31 
 34 #include <sstream>                             << 
 35                                                    32 
 36                                                <<  33 G4String operator+(const G4String& str, const int i) {
 37 G4String operator+(const G4String& str, const  <<  34   int l = str.length() + 15; //How long can an integer be?
 38   std::ostringstream os;                       <<  35   char *cname = new char[l];
                                                   >>  36   cname[0]='\0';
                                                   >>  37   std::ostrstream os(cname, l);
 39   os << str << i <<'\0';                           38   os << str << i <<'\0';
 40   G4String back = os.str();                    <<  39   G4String back(cname);  
                                                   >>  40   delete[] cname;
 41   return back;                                     41   return back;
 42 }                                                  42 }
 43                                                    43 
 44                                                    44 
 45 G4String operator+(const G4String& str, const  <<  45 G4String operator+(const G4String& str, const double i) {
 46   std::ostringstream os;                       <<  46   int l = str.length() + 15; //How long can an double be?
                                                   >>  47   char *cname = new char[l];
                                                   >>  48   cname[0]='\0';
                                                   >>  49   std::ostrstream os(cname, l);
 47   os << str << i <<'\0';                           50   os << str << i <<'\0';
 48   G4String back = os.str();                    <<  51   G4String back(cname);  
                                                   >>  52   delete[] cname;
 49   return back;                                     53   return back;
 50 }                                                  54 }
 51                                                    55 
 52                                                    56 
 53 std::ifstream& readName(std::ifstream& is, G4S     57 std::ifstream& readName(std::ifstream& is, G4String& name){
 54   is >> name;                                      58   is >> name;
 55   if ( name != "*ENDDO" ) {                        59   if ( name != "*ENDDO" ) {
 56     while ( name.find("#.") != G4String::npos      60     while ( name.find("#.") != G4String::npos ) { // It is a comment. Skip line.
 57       is.ignore(999,'\n');                         61       is.ignore(999,'\n');
 58       is >> name;                                  62       is >> name;
 59     };                                             63     };
 60     while ( name.rfind('\"') != name.length()-     64     while ( name.rfind('\"') != name.length()-1 ) {
 61       G4String other;                              65       G4String other;
 62       is >> other;                                 66       is >> other;
 63       name += " ";                                 67       name += " ";
 64       name += other;                               68       name += other;
 65     };                                             69     };
 66     G4StrUtil::strip(name, '\"');              <<  70     name = name.strip(G4String::both, '\"');
 67   }                                                71   }  
 68   return is;                                       72   return is;
 69 }                                                  73 }
 70                                                    74 
 71                                                    75 
 72 std::ifstream& findDO(std::ifstream& is, const     76 std::ifstream& findDO(std::ifstream& is, const G4String& str){
 73   // Loop until *DO str is found                   77   // Loop until *DO str is found
 74   G4String firstwd, dowhat;                        78   G4String firstwd, dowhat;
 75   dowhat = "";                                     79   dowhat = "";
 76   while (dowhat != str && is) {                    80   while (dowhat != str && is) {
 77     is >> firstwd;                                 81     is >> firstwd;
 78     while (firstwd != "*DO" && is) {               82     while (firstwd != "*DO" && is) {
 79       is.ignore(999,'\n');                         83       is.ignore(999,'\n');
 80       is >> firstwd;                               84       is >> firstwd;
 81     };                                             85     };
 82     is >> dowhat;                                  86     is >> dowhat;
 83   };                                               87   };
 84   is.ignore(999,'\n');                             88   is.ignore(999,'\n');
 85   return is;                                       89   return is;
 86 }                                                  90 }
 87                                                    91 
 88                                                    92 
 89 std::ostream& tab(std::ostream& os) {              93 std::ostream& tab(std::ostream& os) {
 90   os << '\t';                                      94   os << '\t';
 91   return os;                                       95   return os;
 92 }                                                  96 }
 93                                                    97 
 94                                                    98 
 95 std::istream& jump(std::istream& is) {             99 std::istream& jump(std::istream& is) {
 96   char first = ' ';                            << 100   char first, second;
 97   char second = ' ';                           << 
 98   is.ignore(999,'\n');                            101   is.ignore(999,'\n');
 99   do {                                            102   do {
100     is.get(first);                                103     is.get(first);
101     second = is.peek();                           104     second = is.peek();
102     if (first == '#' && second =='.') {           105     if (first == '#' && second =='.') {
103       is.ignore(999,'\n');                        106       is.ignore(999,'\n');
104     }                                             107     }
105     else if (first == '\n'); //it was already     108     else if (first == '\n'); //it was already picked
106     else {                                        109     else {
107       is.putback(first);                          110       is.putback(first);
108       return is;                                  111       return is;
109     }                                             112     }
110   }                                               113   }
111   while (is);                                     114   while (is);
112   return is;                                      115   return is;
113 }                                                 116 }
114                                                   117 
115                                                   118 
116 G4bool openGeomFile(std::ifstream& is,         << 119 bool openGeomFile(std::ifstream& is, 
117                     const G4String& pathname,  << 120       const G4String& pathname, const G4String& filename) {
118   G4String fullname = pathname+"/"+filename;      121   G4String fullname = pathname+"/"+filename;
119   is.open( fullname.c_str() );                    122   is.open( fullname.c_str() );
120   if (!is) {                                      123   if (!is) {
121     G4cerr << "ERROR: Could not open file " <<    124     G4cerr << "ERROR: Could not open file " << filename << G4endl;
122     return false;                                 125     return false;
123   }                                               126   }
124   return true;                                    127   return true;
125 }                                                 128 }
126                                                   129