00001
00002
00003
00004
00005
00006 #include "BDSGlobalConstants.hh"
00007 #include "BDSSpoiler.hh"
00008 #include "G4VisAttributes.hh"
00009 #include "G4LogicalVolume.hh"
00010 #include "G4VPhysicalVolume.hh"
00011 #include "G4PVPlacement.hh"
00012 #include "G4UserLimits.hh"
00013 #include "G4TransportationManager.hh"
00014
00015 #include "G4SDManager.hh"
00016 #include "G4UserLimits.hh"
00017
00018 #include <map>
00019
00020
00021
00022
00023
00024 typedef std::map<G4String,int> LogVolCountMap;
00025 extern LogVolCountMap* LogVolCount;
00026
00027 typedef std::map<G4String,G4LogicalVolume*> LogVolMap;
00028 extern LogVolMap* LogVol;
00029
00030 extern BDSMaterials* theMaterials;
00031
00032
00033 BDSSpoiler::BDSSpoiler (G4String& aName,G4double aLength,G4double bpRad,
00034 G4double xAper,G4double yAper,
00035 G4Material* SpoilerMaterial):
00036 BDSAcceleratorComponent(aName,
00037 aLength,bpRad,xAper,yAper,
00038 SetVisAttributes()),
00039 itsSpoilerMaterial(SpoilerMaterial)
00040 {
00041
00042 if ( (*LogVolCount)[itsName]==0)
00043 {
00044 itsMarkerLogicalVolume=
00045 new G4LogicalVolume(
00046 new G4Box(itsName,
00047 BDSGlobals->GetComponentBoxSize()/2,
00048 BDSGlobals->GetComponentBoxSize()/2,
00049 itsLength/2),
00050 theMaterials->GetMaterial("Vacuum"),
00051 itsName);
00052 BuildInnerSpoiler();
00053
00054 (*LogVolCount)[itsName]=1;
00055 (*LogVol)[itsName]=itsMarkerLogicalVolume;
00056 }
00057 else
00058 {
00059 (*LogVolCount)[itsName]++;
00060 itsMarkerLogicalVolume=(*LogVol)[itsName];
00061 }
00062 }
00063
00064
00065 G4VisAttributes* BDSSpoiler::SetVisAttributes()
00066 {
00067 itsVisAttributes=new G4VisAttributes(G4Colour(0.3,0.4,0.2));
00068 return itsVisAttributes;
00069 }
00070
00071
00072 void BDSSpoiler::BuildInnerSpoiler()
00073 {
00074 itsSolidLogVol=
00075 new G4LogicalVolume(new G4Box(itsName+"_solid",
00076 BDSGlobals->GetComponentBoxSize()/2,
00077 BDSGlobals->GetComponentBoxSize()/2,
00078 itsLength/2),
00079 itsSpoilerMaterial,
00080 itsName+"_solid");
00081
00082 itsInnerLogVol=
00083 new G4LogicalVolume(new G4Box(itsName+"_inner",
00084 itsXAper,
00085 itsYAper,
00086 itsLength/2),
00087 theMaterials->GetMaterial("Vacuum"),
00088 itsName+"_inner");
00089
00090 itsPhysiComp2 =
00091 new G4PVPlacement(
00092 0,
00093 0,
00094 itsInnerLogVol,
00095 itsName+"_combined",
00096 itsSolidLogVol,
00097 false,
00098 0);
00099
00100 SetSensitiveVolume(itsSolidLogVol);
00101
00102 itsSolidLogVol->
00103 SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,DBL_MAX,
00104 BDSGlobals-> GetThresholdCutCharged()));
00105
00106 itsPhysiComp =
00107 new G4PVPlacement(
00108 0,
00109 0,
00110 itsSolidLogVol,
00111 itsName+"_solid",
00112 itsMarkerLogicalVolume,
00113 false,
00114 0);
00115 }
00116
00117
00118 BDSSpoiler::~BDSSpoiler()
00119 {
00120 if(itsVisAttributes) delete itsVisAttributes;
00121 if(itsUserLimits) delete itsUserLimits;
00122
00123 if(itsMarkerLogicalVolume)delete itsMarkerLogicalVolume;
00124 if(itsSolidLogVol)delete itsSolidLogVol;
00125 if(itsInnerLogVol)delete itsInnerLogVol;
00126
00127 if(itsPhysiComp) delete itsPhysiComp;
00128 if(itsPhysiComp2) delete itsPhysiComp2;
00129 }