#include <MyVGeometrySvc.hh>
Public Member Functions | |
MyVGeometrySvc (G4String name, G4String opt="") | |
virtual | ~MyVGeometrySvc () |
virtual G4VPhysicalVolume * | SetGeometry () |
void | ReadCard (G4String) |
void | ConstructVolumes () |
G4VPhysicalVolume * | PlaceVolumes () |
G4LogicalVolume * | get_logicalVolume (G4String name) |
MyVGeometryParameter * | get_GeometryParameter () |
int | get_VerboseLevel () |
G4String | get_Name () |
void | set_GeometryParameter (MyVGeometryParameter *val) |
void | set_VerboseLevel (int val) |
void | set_Name (G4String val) |
std::vector< G4String > | GetWords (G4String formula) |
bool | FindMacro (G4String word, G4String &value) |
void | Replace (G4String &formula, G4String word, G4String value) |
double | CalFormula (G4String formula, int iRep=0) |
G4String | ReplaceMacro (G4String formula) |
Static Public Attributes | |
static std::vector< G4String > | knownValueNames |
static std::vector< G4String > | knownValues |
Private Attributes | |
MyVGeometryParameter * | m_GeometryParameter |
int | fVerboseLevel |
G4String | m_Name |
Definition at line 26 of file MyVGeometrySvc.hh.
MyVGeometrySvc::MyVGeometrySvc | ( | G4String | name, | |
G4String | opt = "" | |||
) |
Definition at line 26 of file MyVGeometrySvc.cc.
References set_Name().
00027 :MyConfigure() 00028 { 00029 if ( opt == "" ){ 00030 std::cout<<"MyVGeometrySvc is a virtual class, should be called with opt not empty!"<<std::endl; 00031 G4Exception("MyVGeometrySvc::MyVGeometrySvc()","Run0031", 00032 FatalException, "illegal construction."); 00033 } 00034 set_Name(name); 00035 }
MyVGeometrySvc::~MyVGeometrySvc | ( | ) | [virtual] |
Definition at line 37 of file MyVGeometrySvc.cc.
References m_GeometryParameter.
00037 { 00038 std::cout<<"======>In ~MyVGeometrySvc, delete GeometryParameter at ("<<(void*)m_GeometryParameter<<")!"<<std::endl; 00039 delete m_GeometryParameter; 00040 }
double MyConfigure::CalFormula | ( | G4String | formula, | |
int | iRep = 0 | |||
) | [inherited] |
Definition at line 23 of file MyConfigure.cc.
Referenced by SimpleGeometryParameter::Calculate(), and PrimaryGeneratorAction::ReadCard().
00023 { 00024 // std::cout<<"TO Calculate for: \""<<formula<<"\" "<<iRep<<std::endl; // to be deleted 00025 // formula = ReplaceMacro(formula); 00026 TF1 *f1 = new TF1("f1", formula); 00027 double value = f1->Eval(iRep); 00028 // std::cout<<"\t=>"<<value<<std::endl; 00029 delete f1; 00030 return value; 00031 }
void MyVGeometrySvc::ConstructVolumes | ( | ) | [inline] |
bool MyConfigure::FindMacro | ( | G4String | word, | |
G4String & | value | |||
) | [inherited] |
Definition at line 87 of file MyConfigure.cc.
References MyConfigure::knownValueNames, and MyConfigure::knownValues.
Referenced by MyConfigure::Replace(), and MyConfigure::ReplaceMacro().
00087 { 00088 bool found = false; 00089 for (int i = 0; i< knownValues.size(); i++){ 00090 if (knownValueNames[i]==word){ 00091 value = knownValues[i]; 00092 found = true; 00093 break; 00094 } 00095 } 00096 return found; 00097 }
MyVGeometryParameter* MyVGeometrySvc::get_GeometryParameter | ( | ) | [inline] |
Reimplemented in SimpleGeometrySvc.
Definition at line 46 of file MyVGeometrySvc.hh.
References m_GeometryParameter.
Referenced by MyDetectorManager::GetSD(), and PrimaryGeneratorAction::SetUniformPosition().
00046 { return m_GeometryParameter; }
G4LogicalVolume * MyVGeometrySvc::get_logicalVolume | ( | G4String | name | ) |
Definition at line 51 of file MyVGeometrySvc.cc.
Referenced by SimpleGeometrySvc::PlaceVolumes().
00051 { 00052 //get mother_volume 00053 G4LogicalVolumeStore* logicalVolumeStore = G4LogicalVolumeStore::GetInstance(); 00054 G4LogicalVolume* log_volume = logicalVolumeStore->GetVolume(name,false); 00055 if (!log_volume){ 00056 std::cout<<"Logical volume "<<name<<" of MyVGeometry can not be found!!!"<<std::endl; 00057 G4Exception("MyVGeometrySvc::get_logicalVolume()","Run0031", 00058 FatalException, "unknown logical volume."); 00059 } 00060 return log_volume; 00061 }
G4String MyVGeometrySvc::get_Name | ( | ) | [inline] |
int MyVGeometrySvc::get_VerboseLevel | ( | ) | [inline] |
Definition at line 48 of file MyVGeometrySvc.hh.
References fVerboseLevel.
00048 { return fVerboseLevel; }
std::vector< G4String > MyConfigure::GetWords | ( | G4String | formula | ) | [inherited] |
Definition at line 48 of file MyConfigure.cc.
Referenced by MyConfigure::ReplaceMacro().
00048 { 00049 std::vector<G4String> words; 00050 words.clear(); 00051 const char* cformula = formula.c_str(); 00052 int length = strlen(cformula); 00053 char temp[1240]; 00054 int tempoffset = 0; 00055 for ( int offset = 0; offset < length; offset++ ){ 00056 char c = cformula[offset]; 00057 bool isword = false; 00058 if (c>='a'&&c<='z' 00059 ||c>='A'&&c<='Z' 00060 ||c>='0'&&c<='9' 00061 ||c=='_' 00062 ){ 00063 temp[tempoffset++] = cformula[offset]; 00064 isword = true; 00065 } 00066 if (!isword||offset==length-1){ 00067 if (tempoffset>0){ 00068 temp[tempoffset++] = '\0'; 00069 tempoffset=0; 00070 G4String word = temp; 00071 bool found = false; 00072 for(int iWord = 0; iWord<words.size(); iWord++){ 00073 if (words[iWord]==word){ 00074 found = true; 00075 break; 00076 } 00077 } 00078 if (!found){ 00079 words.push_back(word); 00080 } 00081 } 00082 } 00083 } 00084 return words; 00085 }
G4VPhysicalVolume* MyVGeometrySvc::PlaceVolumes | ( | ) | [inline] |
Reimplemented in SimpleGeometrySvc.
Definition at line 40 of file MyVGeometrySvc.hh.
void MyVGeometrySvc::ReadCard | ( | G4String | file_name | ) |
Definition at line 42 of file MyVGeometrySvc.cc.
References MyVGeometryParameter::InitFromFile(), and m_GeometryParameter.
Referenced by MyDetectorManager::AddGeo(), and MyDetectorManager::ReadCard().
00042 { 00043 if(file_name[0] != '/'){ // Relative Dir 00044 G4String dir_name = getenv("CONFIGUREROOT"); 00045 if (dir_name[dir_name.size()-1] != '/') dir_name.append("/"); 00046 file_name = dir_name + file_name; 00047 } 00048 m_GeometryParameter->InitFromFile(file_name); 00049 }
void MyConfigure::Replace | ( | G4String & | formula, | |
G4String | word, | |||
G4String | value | |||
) | [inherited] |
Definition at line 99 of file MyConfigure.cc.
References MyConfigure::FindMacro().
Referenced by MyConfigure::ReplaceMacro().
00099 { 00100 // std::cout<<"-- \""<<formula<<"\""<<std::endl; // to be deleted 00101 G4String newform = ""; 00102 const char* cformula = formula.c_str(); 00103 int length = strlen(cformula); 00104 char temp[1024]; 00105 int tempoffset = 0; 00106 char cnewform[1024]; 00107 int newformoffset = 0; 00108 for ( int offset = 0; offset < length; offset++ ){ 00109 char c = cformula[offset]; 00110 bool isword = false; 00111 if (c>='a'&&c<='z' 00112 ||c>='A'&&c<='Z' 00113 ||c>='0'&&c<='9' 00114 ||c=='_' 00115 ){ 00116 temp[tempoffset++] = cformula[offset]; 00117 isword = true; 00118 } 00119 if (!isword||offset==length-1){ 00120 if (tempoffset>0){ 00121 temp[tempoffset] = '\0'; 00122 tempoffset=0; 00123 if (newformoffset>0){ 00124 cnewform[newformoffset] = '\0'; 00125 newformoffset=0; 00126 G4String newformtemp = cnewform; 00127 newform=newform+newformtemp; 00128 } 00129 G4String word = temp; 00130 // std::cout<<" \""<<word<<"\""<<std::endl; // to be deleted 00131 G4String newword; 00132 bool found = FindMacro(word,newword); 00133 if (found){ 00134 newform=newform+"("+newword+")"; 00135 } 00136 else{ 00137 newform=newform+word; 00138 } 00139 // std::cout<<" to \""<<newword<<"\""<<std::endl; // to be deleted 00140 } 00141 if(!isword){ 00142 cnewform[newformoffset++] = cformula[offset]; 00143 } 00144 if (offset==length-1){ 00145 cnewform[newformoffset] = '\0'; 00146 G4String newformtemp = cnewform; 00147 newform=newform+newformtemp; 00148 } 00149 } 00150 } 00151 // std::cout<<" -->\""<<newform<<"\""<<std::endl; // to be deleted 00152 formula = newform; 00153 }
G4String MyConfigure::ReplaceMacro | ( | G4String | formula | ) | [inherited] |
Definition at line 33 of file MyConfigure.cc.
References MyConfigure::FindMacro(), MyConfigure::GetWords(), and MyConfigure::Replace().
Referenced by SimpleGeometryParameter::GetValue(), and PrimaryGeneratorAction::ReadCard().
00033 { 00034 // std::cout<<"TO replace for: \""<<formula<<"\""<<std::endl; // to be deleted 00035 std::vector<G4String> words = GetWords(formula); 00036 // std::cout<<" "<<words.size()<<" words"<<std::endl; // to be deleted 00037 for (int iWord = 0; iWord < words.size(); iWord++ ){ 00038 // std::cout<<" "<<iWord<<std::endl; // to be deleted 00039 G4String value; 00040 if (FindMacro(words[iWord],value)){ 00041 Replace(formula,words[iWord],value); 00042 } 00043 } 00044 // std::cout<<"\t=>"<<formula<<std::endl; 00045 return formula; 00046 }
void MyVGeometrySvc::set_GeometryParameter | ( | MyVGeometryParameter * | val | ) | [inline] |
Definition at line 53 of file MyVGeometrySvc.hh.
References m_GeometryParameter.
00053 { m_GeometryParameter = val; }
void MyVGeometrySvc::set_Name | ( | G4String | val | ) | [inline] |
Definition at line 57 of file MyVGeometrySvc.hh.
References m_Name.
Referenced by MyVGeometrySvc().
00057 { m_Name = val; }
void MyVGeometrySvc::set_VerboseLevel | ( | int | val | ) | [inline] |
Definition at line 55 of file MyVGeometrySvc.hh.
References fVerboseLevel.
Referenced by MyDetectorManager::AddGeo(), and MyDetectorManager::ReadCard().
00055 { fVerboseLevel = val; }
virtual G4VPhysicalVolume* MyVGeometrySvc::SetGeometry | ( | ) | [inline, virtual] |
Reimplemented in SimpleGeometrySvc.
Definition at line 33 of file MyVGeometrySvc.hh.
int MyVGeometrySvc::fVerboseLevel [private] |
Definition at line 63 of file MyVGeometrySvc.hh.
Referenced by get_VerboseLevel(), and set_VerboseLevel().
std::vector< G4String > MyConfigure::knownValueNames [static, inherited] |
Definition at line 24 of file MyConfigure.hh.
Referenced by MyConfigure::FindMacro(), SimpleGeometryParameter::GetValue(), and PrimaryGeneratorAction::ReadCard().
std::vector< G4String > MyConfigure::knownValues [static, inherited] |
Definition at line 25 of file MyConfigure.hh.
Referenced by MyConfigure::FindMacro(), SimpleGeometryParameter::GetValue(), and PrimaryGeneratorAction::ReadCard().
Reimplemented in SimpleGeometrySvc.
Definition at line 61 of file MyVGeometrySvc.hh.
Referenced by get_GeometryParameter(), ReadCard(), set_GeometryParameter(), and ~MyVGeometrySvc().
G4String MyVGeometrySvc::m_Name [private] |
Definition at line 65 of file MyVGeometrySvc.hh.
Referenced by get_Name(), and set_Name().