00001
00002
00003
00004
00005
00006
00007 #include "BDSGlobalConstants.hh"
00008 #include "BDSLWCalorimeter.hh"
00009 #include "BDSMaterials.hh"
00010 #include "G4Box.hh"
00011 #include "G4Tubs.hh"
00012 #include "G4VisAttributes.hh"
00013 #include "G4LogicalVolume.hh"
00014 #include "G4VPhysicalVolume.hh"
00015 #include "G4PVPlacement.hh"
00016 #include "G4UserLimits.hh"
00017
00018 #include "BDSAcceleratorComponent.hh"
00019
00020 #include "BDSLWCalorimeterSD.hh"
00021 #include "G4SDManager.hh"
00022
00023
00024
00025 #include <map>
00026
00027
00028
00029
00030 typedef std::map<G4String,int> LogVolCountMap;
00031 extern LogVolCountMap* LogVolCount;
00032
00033 typedef std::map<G4String,G4LogicalVolume*> LogVolMap;
00034 extern LogVolMap* LogVol;
00035
00036 extern G4RotationMatrix* RotY90;
00037
00038
00039 BDSLWCalorimeter::BDSLWCalorimeter (G4String& aName,G4double aLength,
00040 G4double aBpRad, G4String aTunnelMaterial):
00041 BDSAcceleratorComponent(
00042 aName,
00043 aLength,aBpRad,0,0,
00044 SetVisAttributes(),aTunnelMaterial),
00045 itsBPFieldMgr(NULL),
00046 itsVisAttributes(NULL)
00047 {
00048 LWCalorimeterLogicalVolume();
00049 BuildCal(aLength);
00050 BuildBeampipe(aLength);
00051
00052
00053
00054
00055 }
00056
00057
00058 void BDSLWCalorimeter::LWCalorimeterLogicalVolume()
00059 {
00060 if(!(*LogVolCount)[itsName])
00061 {
00062
00063 G4double SampTransSize;
00064 SampTransSize=2.*BDSGlobalConstants::Instance()->GetTunnelRadius();
00065
00066 itsMarkerLogicalVolume=
00067 new G4LogicalVolume(
00068 new G4Box(itsName+"_solid",
00069 SampTransSize,
00070 SampTransSize,
00071 itsLength/2),
00072 BDSMaterials::Instance()->GetMaterial(BDSGlobalConstants::Instance()->GetVacuumMaterial()),
00073 itsName);
00074
00075 (*LogVolCount)[itsName]=1;
00076 (*LogVol)[itsName]=itsMarkerLogicalVolume;
00077 #ifndef NOUSERLIMITS
00078 itsOuterUserLimits =new G4UserLimits();
00079 itsOuterUserLimits->SetMaxAllowedStep(itsLength);
00080 itsOuterUserLimits->SetUserMaxTime(BDSGlobalConstants::Instance()->GetMaxTime());
00081 itsMarkerLogicalVolume->SetUserLimits(itsOuterUserLimits);
00082 #endif
00083
00084 }
00085 else
00086 {
00087 (*LogVolCount)[itsName]++;
00088 itsMarkerLogicalVolume=(*LogVol)[itsName];
00089 }
00090 }
00091
00092 void BDSLWCalorimeter::BuildCal(G4double aLength)
00093 {
00094
00095
00096 itsLWCal=new G4Box(itsName+"_LWCal",
00097 BDSGlobalConstants::Instance()->GetLWCalWidth()/2,
00098 BDSGlobalConstants::Instance()->GetLWCalWidth()/2,
00099 aLength/2);
00100 itsLWCalLogicalVolume=new G4LogicalVolume(itsLWCal,
00101 BDSMaterials::Instance()->GetMaterial("LeadTungstate"),
00102 itsName+"_cal_logical");
00103 G4RotationMatrix* Rot=NULL;
00104 if(itsAngle!=0)Rot=RotY90;
00105
00106 itsPhysiLWCal = new G4PVPlacement(
00107 Rot,
00108 G4ThreeVector(BDSGlobalConstants::Instance()->GetLWCalOffset(),0.,0.),
00109 itsLWCalLogicalVolume,
00110 itsName+"_cal",
00111 itsMarkerLogicalVolume,
00112 false,
00113 0, BDSGlobalConstants::Instance()->GetCheckOverlaps());
00114
00115
00116 G4SDManager* SDMan = G4SDManager::GetSDMpointer();
00117
00118 BDSLWCalorimeterSD* SensDet=new BDSLWCalorimeterSD(itsName);
00119 SDMan->AddNewDetector(SensDet);
00120
00121 itsLWCalLogicalVolume->SetSensitiveDetector(SensDet);
00122 }
00123 void BDSLWCalorimeter::BuildBeampipe(G4double aLength)
00124 {
00125
00126 itsBPTube=new G4Tubs(itsName+"_tube",
00127 0.,itsBpRadius,
00128 aLength/2,
00129 0,twopi*radian);
00130
00131 itsInnerBPTube=new G4Tubs(itsName+"_InnerTube",
00132 0.,
00133 itsBpRadius-BDSGlobalConstants::Instance()->GetBeampipeThickness(),
00134 aLength/2,
00135 0,twopi*radian);
00136 itsBeampipeLogicalVolume=
00137 new G4LogicalVolume(itsBPTube,
00138
00139 BDSMaterials::Instance()->GetMaterial("Aluminium"),
00140 itsName+"_bmp_logical");
00141
00142 itsInnerBPLogicalVolume=
00143 new G4LogicalVolume(itsInnerBPTube,
00144 BDSMaterials::Instance()->GetMaterial(BDSGlobalConstants::Instance()->GetVacuumMaterial()),
00145 itsName+"_bmp_Inner_log");
00146
00147 itsPhysiInner = new G4PVPlacement(
00148 (G4RotationMatrix*)0,
00149 (G4ThreeVector)0,
00150 itsInnerBPLogicalVolume,
00151 itsName+"_InnerBmp",
00152 itsBeampipeLogicalVolume,
00153 false,
00154 0, BDSGlobalConstants::Instance()->GetCheckOverlaps());
00155
00156
00157 G4RotationMatrix* Rot=NULL;
00158 if(itsAngle!=0)Rot=RotY90;
00159
00160 itsPhysiComp = new G4PVPlacement(
00161 Rot,
00162 (G4ThreeVector)0,
00163 itsBeampipeLogicalVolume,
00164 itsName+"_bmp",
00165 itsMarkerLogicalVolume,
00166 false,
00167 0, BDSGlobalConstants::Instance()->GetCheckOverlaps());
00168 #ifndef NOUSERLIMITS
00169 itsBeampipeUserLimits =
00170 new G4UserLimits("beampipe cuts",DBL_MAX,DBL_MAX,DBL_MAX,
00171 BDSGlobalConstants::Instance()->GetThresholdCutCharged());
00172
00173 itsInnerBeampipeUserLimits =
00174 new G4UserLimits("inner beamipe cuts",DBL_MAX,DBL_MAX,DBL_MAX,
00175 BDSGlobalConstants::Instance()->GetThresholdCutCharged());
00176
00177 itsBeampipeUserLimits->SetMaxAllowedStep(itsLength);
00178 itsBeampipeUserLimits->SetUserMaxTime(BDSGlobalConstants::Instance()->GetMaxTime());
00179
00180 itsBeampipeLogicalVolume->SetUserLimits(itsBeampipeUserLimits);
00181
00182 itsInnerBeampipeUserLimits->SetMaxAllowedStep(itsLength);
00183 itsInnerBeampipeUserLimits->SetUserMaxTime(BDSGlobalConstants::Instance()->GetMaxTime());
00184
00185 itsInnerBPLogicalVolume->SetUserLimits(itsInnerBeampipeUserLimits);
00186 #endif
00187 itsInnerBPLogicalVolume->SetFieldManager(itsBPFieldMgr,false) ;
00188
00189
00190
00191
00192
00193
00194
00195
00196 itsMarkerLogicalVolume->
00197 SetFieldManager(BDSGlobalConstants::Instance()->GetZeroFieldManager(),false);
00198
00199 }
00200
00201 G4VisAttributes* BDSLWCalorimeter::SetVisAttributes()
00202 {
00203 itsVisAttributes=new G4VisAttributes(G4Colour(1,0.5,0.5));
00204 return itsVisAttributes;
00205 }
00206
00207 BDSLWCalorimeter::~BDSLWCalorimeter()
00208 {
00209 delete itsVisAttributes;
00210 }