00001
00002
00003
00004
00005
00006 #include "BDSGlobalConstants.hh"
00007 #include "BDSMaterials.hh"
00008 #include "BDSSamplerCylinder.hh"
00009 #include "BDSDebug.hh"
00010 #include "G4Tubs.hh"
00011 #include "G4VisAttributes.hh"
00012 #include "G4LogicalVolume.hh"
00013 #include "G4VPhysicalVolume.hh"
00014 #include "G4UserLimits.hh"
00015 #include "BDSSamplerSD.hh"
00016 #include "G4SDManager.hh"
00017
00018 std::vector <G4String> BDSSamplerCylinder::outputNames;
00019
00020 int BDSSamplerCylinder::nSamplers = 0;
00021
00022 BDSSamplerSD* BDSSamplerCylinder::SensitiveDetector=new BDSSamplerSD("BDSSamplerCylinder","cylinder");
00023
00024 int BDSSamplerCylinder::GetNSamplers() { return nSamplers; }
00025
00026 void BDSSamplerCylinder::AddExternalSampler(G4String name) { nSamplers++; outputNames.push_back(name); }
00027
00028 BDSSamplerCylinder::BDSSamplerCylinder(G4String name,
00029 G4double length,
00030 G4double aRadius):
00031 BDSAcceleratorComponent(name,
00032 length,
00033 0,
00034 "samplercylinder"),
00035 itsRadius(aRadius)
00036 {
00037 nThisSampler = nSamplers + 1;
00038
00039 nSamplers++;
00040
00041
00042 G4SDManager* SDMan = G4SDManager::GetSDMpointer();
00043 SDMan->AddNewDetector(SensitiveDetector);
00044
00045
00046 BDSSamplerCylinder::outputNames.push_back(name + "_phys_" );
00047 }
00048
00049 void BDSSamplerCylinder::BuildContainerLogicalVolume()
00050 {
00051 containerSolid = new G4Tubs(name+"_body",
00052 itsRadius-1.e-6*CLHEP::m,
00053 itsRadius,
00054 chordLength*0.5,
00055 0,
00056 CLHEP::twopi*CLHEP::radian);
00057 containerLogicalVolume = new G4LogicalVolume(containerSolid,
00058 emptyMaterial,
00059 name);
00060
00061 #ifndef NOUSERLIMITS
00062 G4UserLimits* itsOuterUserLimits =new G4UserLimits();
00063 itsOuterUserLimits->SetMaxAllowedStep(BDSGlobalConstants::Instance()->GetSamplerDiameter()/2.0);
00064 containerLogicalVolume->SetUserLimits(itsOuterUserLimits);
00065 #endif
00066 containerLogicalVolume->SetSensitiveDetector(SensitiveDetector);
00067 }
00068
00069 BDSSamplerCylinder::~BDSSamplerCylinder()
00070 {
00071 --nSamplers;
00072 if(nSamplers<0) G4cerr << __METHOD_NAME__ << "WARNING: more samplers deleted than created!" << G4endl;
00073 }