00001
00002
00003
00004
00005
00006
00007 #include "BDSBeamPipe.hh"
00008 #include "BDSBeamPipeFactory.hh"
00009 #include "BDSGlobalConstants.hh"
00010 #include "BDSLWCalorimeter.hh"
00011 #include "BDSMaterials.hh"
00012 #include "G4Box.hh"
00013 #include "G4Tubs.hh"
00014 #include "G4VisAttributes.hh"
00015 #include "G4LogicalVolume.hh"
00016 #include "G4VPhysicalVolume.hh"
00017 #include "G4PVPlacement.hh"
00018 #include "G4UserLimits.hh"
00019
00020 #include "BDSAcceleratorComponent.hh"
00021
00022 #include "BDSLWCalorimeterSD.hh"
00023 #include "G4SDManager.hh"
00024
00025 class BDSTiltOffset;
00026
00027 BDSLWCalorimeter::BDSLWCalorimeter(G4String name,
00028 G4double length,
00029 BDSBeamPipeInfo* beamPipeInfoIn,
00030 BDSTiltOffset tiltOffset):
00031 BDSAcceleratorComponent(name, length, 0, "lwcalorimeter", tiltOffset),
00032 itsBeampipeLogicalVolume(NULL),itsInnerBPLogicalVolume(NULL),itsPhysiInner(NULL),
00033 itsPhysiComp(NULL),itsLWCalLogicalVolume(NULL),itsBeampipeUserLimits(NULL),
00034 itsBPFieldMgr(NULL),itsBPTube(NULL),itsInnerBPTube(NULL),itsLWCal(NULL),
00035 itsPhysiLWCal(NULL)
00036 {
00037 beamPipeInfo = beamPipeInfoIn;
00038 }
00039
00040 void BDSLWCalorimeter::Build()
00041 {
00042 BDSAcceleratorComponent::Build();
00043 BuildCal(chordLength);
00044 BuildBeampipe();
00045 }
00046
00047 void BDSLWCalorimeter::BuildMarkerLogicalVolume()
00048 {
00049 G4double SampTransSize;
00050 SampTransSize = BDSGlobalConstants::Instance()->GetSamplerDiameter() * 0.5 * CLHEP::mm;
00051
00052 containerSolid = new G4Box(name + "_container_solid",
00053 SampTransSize,
00054 SampTransSize,
00055 chordLength*0.5);
00056 containerLogicalVolume = new G4LogicalVolume(containerSolid,
00057 emptyMaterial,
00058 name + "_container_lv");
00059
00060 #ifndef NOUSERLIMITS
00061 G4UserLimits* itsOuterUserLimits =new G4UserLimits();
00062 itsOuterUserLimits->SetMaxAllowedStep(chordLength);
00063 itsOuterUserLimits->SetUserMaxTime(BDSGlobalConstants::Instance()->GetMaxTime());
00064 containerLogicalVolume->SetUserLimits(itsOuterUserLimits);
00065 #endif
00066 }
00067
00068 void BDSLWCalorimeter::BuildCal(G4double aLength)
00069 {
00070
00071 itsLWCal=new G4Box(name + "_lw_cal_solid",
00072 BDSGlobalConstants::Instance()->GetLWCalWidth()/2,
00073 BDSGlobalConstants::Instance()->GetLWCalWidth()/2,
00074 aLength/2);
00075 itsLWCalLogicalVolume=new G4LogicalVolume(itsLWCal,
00076 BDSMaterials::Instance()->GetMaterial("LeadTungstate"),
00077 name + "_lw_cal_lv");
00078 G4RotationMatrix* Rot=NULL;
00079 if(angle!=0)Rot=BDSGlobalConstants::Instance()->RotY90();
00080
00081 itsPhysiLWCal = new G4PVPlacement(Rot,
00082 G4ThreeVector(BDSGlobalConstants::Instance()->GetLWCalOffset(),0.,0.),
00083 itsLWCalLogicalVolume,
00084 name +"_lw_cal_pv",
00085 containerLogicalVolume,
00086 false,
00087 0,
00088 BDSGlobalConstants::Instance()->GetCheckOverlaps());
00089
00090
00091 G4SDManager* SDMan = G4SDManager::GetSDMpointer();
00092
00093 BDSLWCalorimeterSD* SensDet=new BDSLWCalorimeterSD(name);
00094 SDMan->AddNewDetector(SensDet);
00095
00096 itsLWCalLogicalVolume->SetSensitiveDetector(SensDet);
00097 }
00098 void BDSLWCalorimeter::BuildBeampipe()
00099 {
00100 BDSBeamPipe* pipe = BDSBeamPipeFactory::Instance()->CreateBeamPipe(name,
00101 chordLength,
00102 beamPipeInfo);
00103 if(BDSGlobalConstants::Instance()->GetSensitiveBeamPipe())
00104 {RegisterSensitiveVolumes(pipe->GetAllSensitiveVolumes());}
00105
00106
00107 new G4PVPlacement(0,
00108 (G4ThreeVector)0,
00109 pipe->GetContainerLogicalVolume(),
00110 name +"_beampipe_pv",
00111 containerLogicalVolume,
00112 false,
00113 0,
00114 BDSGlobalConstants::Instance()->GetCheckOverlaps());
00115
00116
00117 SetExtentX(pipe->GetExtentX());
00118 SetExtentY(pipe->GetExtentY());
00119 SetExtentZ(pipe->GetExtentZ());
00120 }
00121
00122 BDSLWCalorimeter::~BDSLWCalorimeter()
00123 {
00124 }