00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011 #include <fstream>
00012 #include <string>
00013 #include <iomanip>
00014
00015 #include "myglobals.hh"
00016
00017 #include "MyVGeometryParameterMessenger.hh"
00018 #include "MyString2Anything.hh"
00019
00020 #include "MyVGeometryParameter.hh"
00021
00022 MyVGeometryParameter::MyVGeometryParameter(G4String name, G4String opt )
00023 : MyConfigure()
00024 {
00025 if ( opt == "" ){
00026 std::cout<<"MyVGeometryParameter is a virtual class, should be called with opt not empty!"<<std::endl;
00027 G4Exception("MyVGeometryParameter::MyVGeometryParameter()","Run0031",
00028 FatalException, "illegal construction.");
00029 }
00030 set_Name(name);
00031 }
00032
00033 MyVGeometryParameter::~MyVGeometryParameter(){
00034 std::cout<<"======>In ~MyVGeometryParameter, delete GeometryParameterMessenger at ("<<(void*)m_GeometryParameterMessenger<<")!"<<std::endl;
00035 delete m_GeometryParameterMessenger;
00036 }
00037
00038
00039 bool MyVGeometryParameter::CheckInfo(){
00040 bool flag = false;
00041
00042
00043 return flag;
00044 }
00045
00046
00047 void MyVGeometryParameter::Preset(){
00048 fVerboseLevel = 0;
00049 checkoverlap = false;
00050 }
00051
00052
00053 int MyVGeometryParameter::GetValue(G4String s_card){
00054 int status = 0;
00055 std::stringstream buf_card;
00056 buf_card.str("");
00057 buf_card.clear();
00058 buf_card<<s_card;
00059 G4String name;
00060 buf_card>>name;
00061 G4String s_para;
00062 if( name == "VerboseLevel:" ) buf_card>>fVerboseLevel;
00063 else if( name == "checkoverlap" ) checkoverlap = true;
00064 else status = 1;
00065 buf_card.str("");
00066 buf_card.clear();
00067 return status;
00068 }
00069
00070
00071 void MyVGeometryParameter::DumpInfo() {
00072 std::cout<<"*********************************"<<m_Name<<" Geometry Info***********************************"<<std::endl;
00073 std::cout<<"------General info:--------"<<std::endl;
00074 std::cout<<" Initialized from \""<<m_filename<<"\""<<std::endl;
00075 std::cout<<" checkoverlap? "<<(checkoverlap?"yes":"no")<<std::endl;
00076 std::cout<<" VerboseLevel = "<<fVerboseLevel<<std::endl;
00077 }
00078
00079
00080
00081
00082
00083
00084 void MyVGeometryParameter::get_RepCont( G4String RepCont, G4int& SRepNo, G4int& RepNo ){
00085 size_t sLast = RepCont.last(',');
00086 if(sLast!=G4String::npos){
00087 G4String part1 = RepCont.substr(0,sLast);
00088 G4String part2 = RepCont.substr(sLast+1,RepCont.length()-sLast-1);
00089 MyString2Anything::get_I(part1,SRepNo);
00090 MyString2Anything::get_I(part2,RepNo);
00091 }
00092 else{
00093 sLast = RepCont.last('-');
00094 if (sLast==G4String::npos){
00095 sLast = RepCont.last('~');
00096 }
00097 if (sLast!=G4String::npos){
00098 G4String part1 = RepCont.substr(0,sLast);
00099 G4String part2 = RepCont.substr(sLast+1,RepCont.length()-sLast-1);
00100 MyString2Anything::get_I(part1,SRepNo);
00101 G4int endNo;
00102 MyString2Anything::get_I(part2,endNo);
00103 RepNo = endNo - SRepNo + 1;
00104 }
00105 else{
00106 SRepNo = 0;
00107 MyString2Anything::get_I(RepCont,RepNo);
00108 }
00109 }
00110
00111 }
00112
00113
00114
00115 bool MyVGeometryParameter::ISEMPTY(G4String s_card){
00116 bool flag = false;
00117 const char* c_card = s_card.c_str();
00118 G4int length = strlen(c_card);
00119 G4int offset = 0;
00120 for ( ; offset < length; offset++ ){
00121 if ( c_card[offset] != ' ' ) break;
00122 }
00123 if ( c_card[offset] == '#' || (c_card[offset] == '/' && c_card[offset+1] == '/') || length - offset == 0 ){
00124 flag = true;
00125 }
00126 return flag;
00127 }
00128