/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/src/BDSSampler.cc

00001 /* BDSIM code.    Version 1.0
00002    Author: Grahame A. Blair, Royal Holloway, Univ. of London.
00003    Last modified 24.7.2002
00004    Copyright (c) 2002 by G.A.Blair.  ALL RIGHTS RESERVED. 
00005 
00006    Modified 22.03.05 by J.C.Carter, Royal Holloway, Univ. of London.
00007    Changed Samplers to account for plane and cylinder types (GABs code)
00008 */
00009 
00010 #include "BDSGlobalConstants.hh" 
00011 #include "BDSExecOptions.hh"
00012 #include "BDSMaterials.hh"
00013 #include "BDSSampler.hh"
00014 #include "BDSDebug.hh"
00015 #include "G4Box.hh"
00016 #include "G4Tubs.hh"
00017 #include "G4LogicalVolume.hh"
00018 #include "G4VPhysicalVolume.hh"
00019 #include "G4UserLimits.hh"
00020 #include "BDSSamplerSD.hh"
00021 
00022 #include "BDSSDManager.hh"
00023 
00024 std::vector <G4String> BDSSampler::outputNames;
00025 
00026 int BDSSampler::nSamplers = 0;
00027 
00028 // created here, so only one is created with fixed known name
00029 BDSSamplerSD* BDSSampler::SensitiveDetector = new BDSSamplerSD("BDSSampler","plane");
00030 
00031 int BDSSampler::GetNSamplers() { return nSamplers; }
00032 
00033 void BDSSampler::AddExternalSampler(G4String name) { nSamplers++; outputNames.push_back(name); }
00034 
00035 BDSSampler::BDSSampler(G4String name,
00036                        G4double length):
00037   BDSAcceleratorComponent("Sampler_"+name, length, 0, "sampler")
00038 {
00039 #ifdef BDSDEBUG
00040   G4cout << __METHOD_NAME__ << G4endl;
00041 #endif
00042   nThisSampler= nSamplers + 1;
00043   nSamplers++;
00044 #ifdef BDSDEBUG
00045   G4cout << "BDSSampler.cc Nsamplers " << nSamplers << G4endl;
00046 #endif
00047   BDSSampler::outputNames.push_back(GetName());
00048 }
00049 
00050 void BDSSampler::BuildContainerLogicalVolume()
00051 {
00052 #ifdef BDSDEBUG
00053   G4cout << __METHOD_NAME__ << G4endl;
00054 #endif
00055   G4String name = GetName();
00056   G4Material* emptyMaterial = BDSMaterials::Instance()->GetMaterial(BDSGlobalConstants::Instance()->GetEmptyMaterial());
00057   G4double samplerDiameter = BDSGlobalConstants::Instance()->GetSamplerDiameter() * 0.5; 
00058   containerSolid = new G4Box(name + "_solid",
00059                              samplerDiameter,
00060                              samplerDiameter,
00061                              chordLength*0.5);
00062   containerLogicalVolume = new G4LogicalVolume(containerSolid,
00063                                                emptyMaterial,
00064                                                name);
00065   
00066 #ifndef NOUSERLIMITS
00067   G4UserLimits* itsOuterUserLimits = new G4UserLimits();
00068   //      double stepFactor=5;
00069   //      itsOuterUserLimits->SetMaxAllowedStep(itsLength*stepFactor);
00070   itsOuterUserLimits->SetMaxAllowedStep(1*CLHEP::m);
00071   containerLogicalVolume->SetUserLimits(itsOuterUserLimits);
00072 #endif
00073   //containerLogicalVolume->SetSensitiveDetector(SensitiveDetector);
00074   if (BDSExecOptions::Instance()->GetVisDebug())
00075     {containerLogicalVolume->SetVisAttributes(BDSGlobalConstants::Instance()->GetVisibleDebugVisAttr());}
00076   else
00077     {containerLogicalVolume->SetVisAttributes(BDSGlobalConstants::Instance()->GetInvisibleVisAttr());}
00078   
00079   containerLogicalVolume->SetSensitiveDetector(BDSSDManager::Instance()->GetSamplerPlaneSD());
00080 }
00081 
00082 BDSSampler::~BDSSampler()
00083 {
00084   --nSamplers;
00085 
00086   if(nSamplers<0) G4cerr << __METHOD_NAME__ << "WARNING: more samplers deleted than created!" << G4endl;
00087 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7