SimpleGeometrySvc Class Reference

#include <SimpleGeometrySvc.hh>

Inheritance diagram for SimpleGeometrySvc:
MyVGeometrySvc MyConfigure

List of all members.

Public Member Functions

 SimpleGeometrySvc (G4String name, G4String opt="")
virtual ~SimpleGeometrySvc ()
virtual G4VPhysicalVolume * SetGeometry ()
void ConstructVolumes ()
G4VPhysicalVolume * PlaceVolumes ()
SimpleGeometryParameterget_GeometryParameter ()
void set_GeometryParameter (SimpleGeometryParameter *val)
void ReadCard (G4String)
G4LogicalVolume * get_logicalVolume (G4String name)
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

SimpleGeometryParameterm_GeometryParameter

Detailed Description

Definition at line 27 of file SimpleGeometrySvc.hh.


Constructor & Destructor Documentation

SimpleGeometrySvc::SimpleGeometrySvc ( G4String  name,
G4String  opt = "" 
)

Definition at line 46 of file SimpleGeometrySvc.cc.

References set_GeometryParameter().

00047         : MyVGeometrySvc(name, "S") // Use a not-empty opt to stop inherited class from creating new GeometryParameter
00048 {
00049         if ( opt == "" ){//called directly by user. set up parameter class.
00050                 SimpleGeometryParameter *pointer = new SimpleGeometryParameter(name);
00051 //              std::cout<<"======>In SimpleGeometrySvc, new SimpleGeometryParameter at ("<<(void*)pointer<<")!"<<std::endl;
00052                 set_GeometryParameter(pointer);
00053         }
00054 }

SimpleGeometrySvc::~SimpleGeometrySvc (  )  [virtual]

Definition at line 56 of file SimpleGeometrySvc.cc.

00056                                      {
00057         printf("~SimpleGeometrySvc");
00058 }


Member Function Documentation

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 SimpleGeometrySvc::ConstructVolumes (  ) 

Reimplemented from MyVGeometrySvc.

Definition at line 77 of file SimpleGeometrySvc.cc.

References SimpleGeometryParameter::get_b(), SimpleGeometryParameter::get_BooleanSolid_Ephi(), SimpleGeometryParameter::get_BooleanSolid_Epsi(), SimpleGeometryParameter::get_BooleanSolid_Etheta(), SimpleGeometryParameter::get_BooleanSolid_PosX(), SimpleGeometryParameter::get_BooleanSolid_PosY(), SimpleGeometryParameter::get_BooleanSolid_PosZ(), SimpleGeometryParameter::get_BooleanSolid_sol1(), SimpleGeometryParameter::get_BooleanSolid_sol2(), SimpleGeometryParameter::get_BooleanSolid_type(), SimpleGeometryParameter::get_Box_X(), SimpleGeometryParameter::get_Box_Y(), SimpleGeometryParameter::get_Box_Z(), SimpleGeometryParameter::get_Cons_Length(), SimpleGeometryParameter::get_Cons_RMax1(), SimpleGeometryParameter::get_Cons_RMax2(), SimpleGeometryParameter::get_Cons_RMin1(), SimpleGeometryParameter::get_Cons_RMin2(), SimpleGeometryParameter::get_Cons_SpanAng(), SimpleGeometryParameter::get_Cons_StartAng(), SimpleGeometryParameter::get_EllipticalTube_X(), SimpleGeometryParameter::get_EllipticalTube_Y(), SimpleGeometryParameter::get_EllipticalTube_Z(), SimpleGeometryParameter::get_ExtrudedSolid_numP(), SimpleGeometryParameter::get_ExtrudedSolid_numZ(), SimpleGeometryParameter::get_ExtrudedSolid_Scale(), SimpleGeometryParameter::get_ExtrudedSolid_X(), SimpleGeometryParameter::get_ExtrudedSolid_X0(), SimpleGeometryParameter::get_ExtrudedSolid_Y(), SimpleGeometryParameter::get_ExtrudedSolid_Y0(), SimpleGeometryParameter::get_ExtrudedSolid_Z(), SimpleGeometryParameter::get_g(), SimpleGeometryParameter::get_Hype_innerRadius(), SimpleGeometryParameter::get_Hype_innerStereo(), SimpleGeometryParameter::get_Hype_Length(), SimpleGeometryParameter::get_Hype_outerRadius(), SimpleGeometryParameter::get_Hype_outerStereo(), SimpleGeometryParameter::get_material(), SimpleGeometryParameter::get_name(), SimpleGeometryParameter::get_Polycone_numZ(), SimpleGeometryParameter::get_Polycone_RMax(), SimpleGeometryParameter::get_Polycone_RMin(), SimpleGeometryParameter::get_Polycone_SpanAng(), SimpleGeometryParameter::get_Polycone_StartAng(), SimpleGeometryParameter::get_Polycone_Z(), SimpleGeometryParameter::get_r(), SimpleGeometryParameter::get_RepNo(), SimpleGeometryParameter::get_SDName(), SimpleGeometryParameter::get_SolidBoolean(), SimpleGeometryParameter::get_SolidIndex(), SimpleGeometryParameter::get_SolidType(), SimpleGeometryParameter::get_Sphere_RMax(), SimpleGeometryParameter::get_Sphere_RMin(), SimpleGeometryParameter::get_Sphere_SpanPhi(), SimpleGeometryParameter::get_Sphere_SpanTheta(), SimpleGeometryParameter::get_Sphere_StartPhi(), SimpleGeometryParameter::get_Sphere_StartTheta(), SimpleGeometryParameter::get_SRepNo(), SimpleGeometryParameter::get_t(), SimpleGeometryParameter::get_Torus_RMax(), SimpleGeometryParameter::get_Torus_RMin(), SimpleGeometryParameter::get_Torus_Rtor(), SimpleGeometryParameter::get_Torus_SpanAng(), SimpleGeometryParameter::get_Torus_StartAng(), SimpleGeometryParameter::get_Tubs_Length(), SimpleGeometryParameter::get_Tubs_RMax(), SimpleGeometryParameter::get_Tubs_RMin(), SimpleGeometryParameter::get_Tubs_SpanAng(), SimpleGeometryParameter::get_Tubs_StartAng(), SimpleGeometryParameter::get_TwistedTubs_dphi(), SimpleGeometryParameter::get_TwistedTubs_endinnerrad(), SimpleGeometryParameter::get_TwistedTubs_endouterrad(), SimpleGeometryParameter::get_TwistedTubs_Length(), SimpleGeometryParameter::get_TwistedTubs_twistedangle(), SimpleGeometryParameter::get_vis(), SimpleGeometryParameter::get_VolNo(), MyDetectorManager::GetMyDetectorManager(), MyDetectorManager::GetSD(), and m_GeometryParameter.

Referenced by SetGeometry().

00077                                         {
00078         MyVGeometrySvc::ConstructVolumes();
00079         bool vis;
00080         double r, g, b, t;
00081         std::stringstream buffer;
00082         G4Material* pttoMaterial;
00083 
00084         int nVol = m_GeometryParameter->get_VolNo();
00085         for ( int i_Vol = 0; i_Vol < nVol; i_Vol++ ){
00086                 G4String name, mat_name, SDName; 
00087                 G4String SolidType;
00088                 G4int SolidIndex;
00089                 G4int SRepNo;
00090                 G4int RepNo;
00091                 G4double max_step_length = 0;
00092                 SolidIndex = m_GeometryParameter->get_SolidIndex(i_Vol);
00093                 SolidType = m_GeometryParameter->get_SolidType(i_Vol);
00094                 name = m_GeometryParameter->get_name(i_Vol);
00095                 SRepNo = m_GeometryParameter->get_SRepNo(i_Vol);
00096                 RepNo = m_GeometryParameter->get_RepNo(i_Vol);
00097                 for ( int i = 0; i < RepNo; i++ ){
00098                         G4VSolid* sol_Vol = 0;
00099                         G4String iname = name;
00100                         if (RepNo>1){
00101                                 buffer.str("");
00102                                 buffer.clear();
00103                                 buffer<<name<<"_"<<i;
00104                                 iname = buffer.str();
00105                         }
00106                         if ( SolidType == "Box" ){
00107                                 G4double halfX, halfY, halfZ;
00108                                 halfX = m_GeometryParameter->get_Box_X(SolidIndex,i)/2;
00109                                 halfY = m_GeometryParameter->get_Box_Y(SolidIndex,i)/2;
00110                                 halfZ = m_GeometryParameter->get_Box_Z(SolidIndex,i)/2;
00111                                 sol_Vol=new G4Box(iname,halfX,halfY,halfZ);
00112                                 max_step_length = 0.25*std::min(halfX, std::min(halfY, halfZ));
00113                         }
00114                         else if ( SolidType == "EllipticalTube" ){
00115                                 G4double halfX, halfY, halfZ;
00116                                 halfX = m_GeometryParameter->get_EllipticalTube_X(SolidIndex,i)/2;
00117                                 halfY = m_GeometryParameter->get_EllipticalTube_Y(SolidIndex,i)/2;
00118                                 halfZ = m_GeometryParameter->get_EllipticalTube_Z(SolidIndex,i)/2;
00119                                 sol_Vol=new G4EllipticalTube(iname,halfX,halfY,halfZ);
00120                                 max_step_length = 0.25*std::min(halfX, std::min(halfY, halfZ));
00121                         }
00122                         else if ( SolidType == "Tubs" ){
00123                                 G4double RMax, RMin, halfLength, StartAng, SpanAng;
00124                                 RMax = m_GeometryParameter->get_Tubs_RMax(SolidIndex,i);
00125                                 RMin = m_GeometryParameter->get_Tubs_RMin(SolidIndex,i);
00126                                 halfLength = m_GeometryParameter->get_Tubs_Length(SolidIndex,i)/2;
00127                                 StartAng = m_GeometryParameter->get_Tubs_StartAng(SolidIndex,i);
00128                                 SpanAng = m_GeometryParameter->get_Tubs_SpanAng(SolidIndex,i);
00129                                 sol_Vol=new G4Tubs(iname,RMin,RMax,halfLength,StartAng,SpanAng);
00130                                 max_step_length = 0.25*RMin;
00131                         }
00132                         else if ( SolidType == "Torus" ){
00133                                 G4double RMax, RMin, Rtor, StartAng, SpanAng;
00134                                 RMax = m_GeometryParameter->get_Torus_RMax(SolidIndex,i);
00135                                 RMin = m_GeometryParameter->get_Torus_RMin(SolidIndex,i);
00136                                 Rtor = m_GeometryParameter->get_Torus_Rtor(SolidIndex,i);
00137                                 StartAng = m_GeometryParameter->get_Torus_StartAng(SolidIndex,i);
00138                                 SpanAng = m_GeometryParameter->get_Torus_SpanAng(SolidIndex,i);
00139                                 sol_Vol=new G4Torus(iname,RMin,RMax,Rtor,StartAng,SpanAng);
00140                                 max_step_length = 0.25*RMin;
00141                         }
00142                         else if ( SolidType == "Sphere" ){
00143                                 G4double RMax, RMin, StartPhi, SpanPhi, StartTheta, SpanTheta;
00144                                 RMax = m_GeometryParameter->get_Sphere_RMax(SolidIndex,i);
00145                                 RMin = m_GeometryParameter->get_Sphere_RMin(SolidIndex,i);
00146                                 StartPhi = m_GeometryParameter->get_Sphere_StartPhi(SolidIndex,i);
00147                                 SpanPhi = m_GeometryParameter->get_Sphere_SpanPhi(SolidIndex,i);
00148                                 StartTheta = m_GeometryParameter->get_Sphere_StartTheta(SolidIndex,i);
00149                                 SpanTheta = m_GeometryParameter->get_Sphere_SpanTheta(SolidIndex,i);
00150                                 sol_Vol=new G4Sphere(iname,RMin,RMax,StartPhi,SpanPhi,StartTheta,SpanTheta);
00151                                 max_step_length = 0.25*RMin;
00152                         }
00153                         else if ( SolidType == "Hype" ){
00154                                 G4double innerRadius, outerRadius, halfLength, innerStereo, outerStereo;
00155                                 innerRadius = m_GeometryParameter->get_Hype_innerRadius(SolidIndex,i);
00156                                 outerRadius = m_GeometryParameter->get_Hype_outerRadius(SolidIndex,i);
00157                                 halfLength = m_GeometryParameter->get_Hype_Length(SolidIndex,i)/2;
00158                                 innerStereo = m_GeometryParameter->get_Hype_innerStereo(SolidIndex,i);
00159                                 outerStereo = m_GeometryParameter->get_Hype_outerStereo(SolidIndex,i);
00160                                 sol_Vol=new G4Hype(iname,innerRadius,outerRadius,innerStereo,outerStereo,halfLength);
00161                         }
00162                         else if ( SolidType == "TwistedTubs" ){
00163                                 G4double endinnerrad, endouterrad, halfLength, twistedangle, dphi;
00164                                 twistedangle = m_GeometryParameter->get_TwistedTubs_twistedangle(SolidIndex,i);
00165                                 endinnerrad = m_GeometryParameter->get_TwistedTubs_endinnerrad(SolidIndex,i);
00166                                 endouterrad = m_GeometryParameter->get_TwistedTubs_endouterrad(SolidIndex,i);
00167                                 halfLength = m_GeometryParameter->get_TwistedTubs_Length(SolidIndex,i)/2;
00168                                 dphi = m_GeometryParameter->get_TwistedTubs_dphi(SolidIndex,i);
00169                                 sol_Vol=new G4TwistedTubs(iname,twistedangle,endinnerrad,endouterrad,halfLength,dphi);
00170                         }
00171                         else if ( SolidType == "Cons" ){
00172                                 G4double RMax1, RMin1, RMax2, RMin2, halfLength, StartAng, SpanAng;
00173                                 RMax1 = m_GeometryParameter->get_Cons_RMax1(SolidIndex,i);
00174                                 RMin1 = m_GeometryParameter->get_Cons_RMin1(SolidIndex,i);
00175                                 RMax2 = m_GeometryParameter->get_Cons_RMax2(SolidIndex,i);
00176                                 RMin2 = m_GeometryParameter->get_Cons_RMin2(SolidIndex,i);
00177                                 halfLength = m_GeometryParameter->get_Cons_Length(SolidIndex,i)/2;
00178                                 StartAng = m_GeometryParameter->get_Cons_StartAng(SolidIndex,i);
00179                                 SpanAng = m_GeometryParameter->get_Cons_SpanAng(SolidIndex,i);
00180                                 sol_Vol=new G4Cons(iname,RMin1,RMax1,RMin2,RMax2,halfLength,StartAng,SpanAng);
00181                                 max_step_length = 0.25*std::min(RMin2, RMin2);
00182 
00183                         }
00184                         else if ( SolidType == "Polycone" ){
00185                                 G4double StartAng, SpanAng;
00186                                 G4int numZ;
00187                                 numZ = m_GeometryParameter->get_Polycone_numZ(SolidIndex,i);
00188                                 G4double *RMax = new G4double[numZ];
00189                                 G4double *RMin = new G4double[numZ];
00190                                 G4double *Z = new G4double[numZ];
00191                                 for ( int j = 0; j < numZ; j++ ){
00192                                         RMax[j] = m_GeometryParameter->get_Polycone_RMax(SolidIndex,j,i);
00193                                         RMin[j] = m_GeometryParameter->get_Polycone_RMin(SolidIndex,j,i);
00194                                         Z[j] = m_GeometryParameter->get_Polycone_Z(SolidIndex,j,i);
00195                                         std::cout<<j<<": RMax = "<<RMax[j]/mm<<"mm, RMin = "<<RMin[j]/mm<<"mm, "<<Z[j]/mm<<"mm"<<std::endl;
00196                                 }
00197                                 StartAng = m_GeometryParameter->get_Polycone_StartAng(SolidIndex,i);
00198                                 SpanAng = m_GeometryParameter->get_Polycone_SpanAng(SolidIndex,i);
00199                                 sol_Vol=new G4Polycone(iname,StartAng,SpanAng,numZ,Z,RMin,RMax);
00200                         }
00201                         else if ( SolidType == "ExtrudedSolid" ){
00202                                 G4int numZ, numP;
00203                                 numZ = m_GeometryParameter->get_ExtrudedSolid_numZ(SolidIndex,i);
00204                                 numP = m_GeometryParameter->get_ExtrudedSolid_numP(SolidIndex,i);
00205                                 std::vector<G4TwoVector> polygon;
00206                                 std::vector<G4ExtrudedSolid::ZSection>    zsections;
00207                                 for ( int j = 0; j < numZ; j++ ){
00208                                         zsections.push_back(G4ExtrudedSolid::ZSection(m_GeometryParameter->get_ExtrudedSolid_Z(SolidIndex,j,i),
00209                                                                              G4TwoVector(m_GeometryParameter->get_ExtrudedSolid_X0(SolidIndex,j,i),
00210                                                                                          m_GeometryParameter->get_ExtrudedSolid_Y0(SolidIndex,j,i)),
00211                                                                              m_GeometryParameter->get_ExtrudedSolid_Scale(SolidIndex,j,i)));
00212                                 }
00213                                 for ( int j = 0; j < numP; j++ ){
00214                                         polygon.push_back(G4TwoVector(m_GeometryParameter->get_ExtrudedSolid_X(SolidIndex,j,i),
00215                                                                               m_GeometryParameter->get_ExtrudedSolid_Y(SolidIndex,j,i)));
00216                                 }
00217                                 sol_Vol=new G4ExtrudedSolid(iname,polygon,zsections);
00218                         }
00219                         else if ( SolidType == "BooleanSolid" ){
00220                                 G4double Ephi = m_GeometryParameter->get_BooleanSolid_Ephi(SolidIndex,i);
00221                                 G4double Etheta = m_GeometryParameter->get_BooleanSolid_Etheta(SolidIndex,i);
00222                                 G4double Epsi = m_GeometryParameter->get_BooleanSolid_Epsi(SolidIndex,i);
00223                                 G4double PosX  = m_GeometryParameter->get_BooleanSolid_PosX(SolidIndex,i);
00224                                 G4double PosY  = m_GeometryParameter->get_BooleanSolid_PosY(SolidIndex,i);
00225                                 G4double PosZ  = m_GeometryParameter->get_BooleanSolid_PosZ(SolidIndex,i);
00226                                 G4RotationMatrix* rot =new G4RotationMatrix(Ephi,Etheta,Epsi);
00227                                 G4ThreeVector trans(PosX ,PosY ,PosZ);
00228                                 G4String type = m_GeometryParameter->get_BooleanSolid_type(SolidIndex);
00229                                 G4String sol_name1 = m_GeometryParameter->get_BooleanSolid_sol1(SolidIndex);
00230                                 G4String sol_name2 = m_GeometryParameter->get_BooleanSolid_sol2(SolidIndex);
00231                                 G4String isol_name1 = sol_name1;
00232                                 G4String isol_name2 = sol_name2;
00233                                 if (RepNo>1){
00234                                         buffer.str("");
00235                                         buffer.clear();
00236                                         buffer<<sol_name1<<"_"<<i;
00237                                         isol_name1 = buffer.str();
00238                                         buffer.str("");
00239                                         buffer.clear();
00240                                         buffer<<sol_name2<<"_"<<i;
00241                                         isol_name2 = buffer.str();
00242                                 }
00243                                 G4SolidStore *pSolidStore = G4SolidStore::GetInstance();
00244                                 G4VSolid *sol1 = pSolidStore->GetSolid(isol_name1);
00245                                 G4VSolid *sol2 = pSolidStore->GetSolid(isol_name2);
00246                                 if (!sol1||!sol2){
00247                                         std::cout<<"ERROR: in SimpleGeometrySvc::ConstructVolumes(), cannot find solids for BooleanSolid \""<<iname<<"\" !!!"<<std::endl;
00248                                         continue;
00249                                 }
00250                                 if ( type == "plus" ){
00251                                         sol_Vol = new G4UnionSolid(iname,sol1,sol2,rot,trans);
00252                                 }
00253                                 else if ( type == "minus" ){
00254                                         sol_Vol = new G4SubtractionSolid(iname,sol1,sol2,rot,trans);
00255                                 }
00256                                 else if ( type == "times" ){
00257                                         sol_Vol = new G4IntersectionSolid(iname,sol1,sol2,rot,trans);
00258                                 }
00259                                 else {
00260                                         std::cout<<"ERROR: in SimpleGeometrySvc::ConstructVolumes(), cannot recognize BooleanSolid type \""<<type<<"\""<<"for \""<<iname<<"\"!!!"<<std::endl;
00261                                         continue;
00262                                 }
00263                         }
00264                         else {
00265                                 std::cout<<"SolidType "<<SolidType<<" is not supported yet!"<<std::endl;
00266                                 G4Exception("SimpleGeometrySvc::ConstructVolumes()",
00267                                                 "InvalidSetup", FatalException,
00268                                                 "unknown SolidType");
00269                         }
00270                         if (m_GeometryParameter->get_SolidBoolean(i_Vol)) continue;
00271                         SDName = m_GeometryParameter->get_SDName(i_Vol);
00272                         mat_name = m_GeometryParameter->get_material(i_Vol);
00273                         pttoMaterial = G4Material::GetMaterial(mat_name);
00274                         //              std::cout<<"name = "<<name
00275                         //                       <<", i_Vol = "<<i_Vol
00276                         //                       <<", SolidType = "<<SolidType
00277                         //                       <<", SolidIndex = "<<SolidIndex
00278                         //                       <<std::endl;
00279                         if (!pttoMaterial){
00280                                 std::cout<<"Material "<<mat_name<<" is not defined!"<<std::endl;
00281                                 G4Exception("SimpleGeometrySvc::ConstructVolumes()",
00282                                                 "InvalidSetup", FatalException,
00283                                                 "unknown material name");
00284                         }
00285                         G4LogicalVolume* log_Vol;
00286                         G4UserLimits* user_limit;
00287                         if (max_step_length != 0) { // AE: probably shouldn't be hard-coded
00288                           user_limit = new G4UserLimits(max_step_length); // set max step length to 25 micron
00289                           //                      std::cout << "AE: " << iname << " User Limit = " << max_step_length/mm << " mm" << std::endl;
00290                         }
00291                         else {
00292                           user_limit = new G4UserLimits();
00293                         }
00294                         log_Vol = new G4LogicalVolume(sol_Vol, pttoMaterial, iname,0,0,user_limit);
00295                         G4VSensitiveDetector* aSD;
00296                         aSD = MyDetectorManager::GetMyDetectorManager()->GetSD(iname, SDName, const_cast<SimpleGeometrySvc*>(this) );
00297                         log_Vol->SetSensitiveDetector(aSD);
00298                         //visual
00299                         vis = m_GeometryParameter->get_vis(i_Vol);
00300                         if (!vis){
00301                                 log_Vol->SetVisAttributes(G4VisAttributes::Invisible);
00302                         }
00303                         else{
00304                                 r = m_GeometryParameter->get_r(i_Vol);
00305                                 g = m_GeometryParameter->get_g(i_Vol);
00306                                 b = m_GeometryParameter->get_b(i_Vol);
00307                                 t = m_GeometryParameter->get_t(i_Vol);
00308                                 G4VisAttributes* visAttributes = new G4VisAttributes;
00309                                 visAttributes->SetVisibility(true);
00310                                 visAttributes->SetColour(r,g,b,t);
00311                                 log_Vol->SetVisAttributes(visAttributes);
00312                         }
00313                 }
00314         }
00315 }

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 }

SimpleGeometryParameter* SimpleGeometrySvc::get_GeometryParameter (  )  [inline]

Reimplemented from MyVGeometrySvc.

Definition at line 41 of file SimpleGeometrySvc.hh.

References m_GeometryParameter.

00041 { return m_GeometryParameter; }

G4LogicalVolume * MyVGeometrySvc::get_logicalVolume ( G4String  name  )  [inherited]

Definition at line 51 of file MyVGeometrySvc.cc.

Referenced by 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, inherited]

Definition at line 50 of file MyVGeometrySvc.hh.

References MyVGeometrySvc::m_Name.

00050 { return m_Name; }

int MyVGeometrySvc::get_VerboseLevel (  )  [inline, inherited]

Definition at line 48 of file MyVGeometrySvc.hh.

References MyVGeometrySvc::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 * SimpleGeometrySvc::PlaceVolumes (  ) 

Reimplemented from MyVGeometrySvc.

Definition at line 318 of file SimpleGeometrySvc.cc.

References MyVGeometryParameter::get_checkoverlap(), SimpleGeometryParameter::get_Ephi(), SimpleGeometryParameter::get_Epsi(), SimpleGeometryParameter::get_Etheta(), MyVGeometrySvc::get_logicalVolume(), SimpleGeometryParameter::get_MotherName(), SimpleGeometryParameter::get_name(), SimpleGeometryParameter::get_PosX(), SimpleGeometryParameter::get_PosY(), SimpleGeometryParameter::get_PosZ(), SimpleGeometryParameter::get_RepNo(), SimpleGeometryParameter::get_SolidBoolean(), SimpleGeometryParameter::get_SRepNo(), SimpleGeometryParameter::get_VolIndex(), SimpleGeometryParameter::get_VolNo(), MyDetectorManager::GetMyDetectorManager(), MyDetectorManager::GetParaFromVolume(), and m_GeometryParameter.

Referenced by SetGeometry().

00318                                                   {
00319         std::stringstream buffer;
00320         G4VPhysicalVolume* world_pvol = 0;
00321         bool checkOverlap = m_GeometryParameter->get_checkoverlap();
00322         int nVol = m_GeometryParameter->get_VolNo();
00323         for ( int i_Vol = 0; i_Vol < nVol; i_Vol++ ){
00324                 if (m_GeometryParameter->get_SolidBoolean(i_Vol)) continue;
00325                 G4double PosX, PosY, PosZ;
00326                 G4String name, motVolName; 
00327                 G4int SRepNo;
00328                 G4int RepNo;
00329                 name = m_GeometryParameter->get_name(i_Vol);
00330 //              std::cout<<"Place \""<<name<<"\""<<std::endl; // to be deleted
00331                 motVolName = m_GeometryParameter->get_MotherName(i_Vol);
00332                 SRepNo = m_GeometryParameter->get_SRepNo(i_Vol);
00333                 RepNo = m_GeometryParameter->get_RepNo(i_Vol);
00334                 G4LogicalVolume* log_container;
00335                 int motRepNo = 1;
00336                 if ( name == "World" ) motRepNo = 1;
00337                 else{
00338                         SimpleGeometryParameter* motPara = MyDetectorManager::GetMyDetectorManager()->GetParaFromVolume(motVolName);
00339                         if (motPara)
00340                                 motRepNo = motPara->get_RepNo(motPara->get_VolIndex(motVolName));
00341                         else{
00342                                 std::cout<<"We can't find parameter pointer!!"<<std::endl;
00343                         }
00344                 }
00345                 for ( int im = 0; im < motRepNo; im++ ){
00346                         if ( name == "World" ) log_container = 0;
00347                         else {
00348                                 G4String imotVolName = motVolName;
00349                                 if (motRepNo>1){
00350                                         buffer.str("");
00351                                         buffer.clear();
00352                                         buffer<<motVolName<<"_"<<im;
00353                                         imotVolName = buffer.str();
00354                                 }
00355                                 log_container = get_logicalVolume(imotVolName);
00356                         }
00357                         for ( int i = 0; i < RepNo; i++ ){
00358                                 G4String iname = name;
00359                                 if (RepNo>1){
00360                                         buffer.str("");
00361                                         buffer.clear();
00362                                         buffer<<name<<"_"<<i;
00363                                         iname = buffer.str();
00364                                 }
00365                                 G4LogicalVolume* log_Vol = get_logicalVolume(iname);
00366                                 PosX  = m_GeometryParameter->get_PosX(i_Vol,i);
00367                                 PosY  = m_GeometryParameter->get_PosY(i_Vol,i);
00368                                 PosZ  = m_GeometryParameter->get_PosZ(i_Vol,i);
00369                                 G4ThreeVector pos(PosX ,PosY ,PosZ);
00370                                 G4double Ephi = m_GeometryParameter->get_Ephi(i_Vol,i);
00371                                 G4double Etheta = m_GeometryParameter->get_Etheta(i_Vol,i);
00372                                 G4double Epsi = m_GeometryParameter->get_Epsi(i_Vol,i);
00373                                 G4RotationMatrix* rotateMatrix=new G4RotationMatrix(Ephi,Etheta,Epsi);
00374                                 if ( name == "World" ) rotateMatrix = 0;
00375                                 G4VPhysicalVolume* phy_Vol =
00376                                         new G4PVPlacement(rotateMatrix,                //rotation
00377                                                         pos,                              //position
00378                                                         log_Vol,                          //its logical volume
00379                                                         name,                             //its name
00380                                                         log_container,                    //its mother volume
00381                                                         false,                            //no boolean operation
00382                                                         i+SRepNo,                                //copy number
00383                                                         checkOverlap);                    //overlaps checking
00384                                 if ( name == "World" ) world_pvol = phy_Vol;
00385                         }
00386                 }
00387         }
00388 //      std::cout<<"Finished!"<<std::endl; // to be deleted
00389         G4VPhysicalVolume *former = MyVGeometrySvc::PlaceVolumes();
00390         if (!world_pvol) world_pvol=former;
00391         return world_pvol;
00392 }

void MyVGeometrySvc::ReadCard ( G4String  file_name  )  [inherited]

Definition at line 42 of file MyVGeometrySvc.cc.

References MyVGeometryParameter::InitFromFile(), and MyVGeometrySvc::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, inherited]

Definition at line 53 of file MyVGeometrySvc.hh.

References MyVGeometrySvc::m_GeometryParameter.

00053 { m_GeometryParameter = val; }

void SimpleGeometrySvc::set_GeometryParameter ( SimpleGeometryParameter val  ) 

Definition at line 61 of file SimpleGeometrySvc.cc.

References m_GeometryParameter.

Referenced by SimpleGeometrySvc().

void MyVGeometrySvc::set_Name ( G4String  val  )  [inline, inherited]

Definition at line 57 of file MyVGeometrySvc.hh.

References MyVGeometrySvc::m_Name.

Referenced by MyVGeometrySvc::MyVGeometrySvc().

00057 { m_Name = val; }

void MyVGeometrySvc::set_VerboseLevel ( int  val  )  [inline, inherited]

Definition at line 55 of file MyVGeometrySvc.hh.

References MyVGeometrySvc::fVerboseLevel.

Referenced by MyDetectorManager::AddGeo(), and MyDetectorManager::ReadCard().

00055 { fVerboseLevel = val; }

G4VPhysicalVolume * SimpleGeometrySvc::SetGeometry (  )  [virtual]

Reimplemented from MyVGeometrySvc.

Definition at line 68 of file SimpleGeometrySvc.cc.

References ConstructVolumes(), SimpleGeometryParameter::Dump(), m_GeometryParameter, and PlaceVolumes().

00068                                                  {
00069         m_GeometryParameter->Dump();
00070         ConstructVolumes();
00071         G4VPhysicalVolume *current = PlaceVolumes();
00072         return current;
00073 }


Member Data Documentation

std::vector< G4String > MyConfigure::knownValueNames [static, inherited]
std::vector< G4String > MyConfigure::knownValues [static, inherited]

The documentation for this class was generated from the following files:

Generated on 15 Jun 2016 for g4sim by  doxygen 1.6.1