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

00001 #include "BDSAcceleratorComponent.hh"
00002 #include "BDSDebug.hh"
00003 #include "BDSExecOptions.hh"
00004 #include "BDSGlobalConstants.hh"
00005 #include "BDSMaterials.hh"
00006 #include "BDSReadOutGeometry.hh"
00007 #include "BDSUtilities.hh"
00008 
00009 #include <cmath>
00010 
00011 G4Material* BDSAcceleratorComponent::emptyMaterial = NULL;
00012 G4double    BDSAcceleratorComponent::lengthSafety  = -1;
00013 
00014 struct BDSBeamPipeInfo;
00015 class BDSTiltOffset;
00016 
00017 BDSAcceleratorComponent::BDSAcceleratorComponent(G4String         nameIn,
00018                                                  G4double         arcLengthIn,
00019                                                  G4double         angleIn,
00020                                                  G4String         typeIn,
00021                                                  BDSTiltOffset    tiltOffsetIn,
00022                                                  G4int            precisionRegionIn,
00023                                                  BDSBeamPipeInfo* beamPipeInfoIn):
00024   BDSGeometryComponent(NULL,NULL),
00025   name(nameIn),
00026   arcLength(arcLengthIn),
00027   type(typeIn),
00028   angle(angleIn),
00029   tiltOffset(tiltOffsetIn),
00030   precisionRegion(precisionRegionIn),
00031   beamPipeInfo(beamPipeInfoIn)
00032 {
00033 #ifdef BDSDEBUG
00034   G4cout << __METHOD_NAME__ << G4endl;
00035 #endif
00036   readOutLV = NULL;
00037   itsSPos   = 0.0;
00038 
00039   // initialise static members
00040   if (!emptyMaterial)
00041     {emptyMaterial = BDSMaterials::Instance()->GetMaterial(BDSGlobalConstants::Instance()->GetEmptyMaterial());}
00042   if (lengthSafety < 0)
00043     {lengthSafety = BDSGlobalConstants::Instance()->GetLengthSafety();}
00044   
00045   // calculate the chord length if the angle is finite
00046   if (BDS::IsFinite(angleIn))
00047     {chordLength = 2.0 * arcLengthIn * sin(0.5*angleIn) / angleIn;}
00048   else
00049     {chordLength = arcLengthIn;}
00050 }
00051 
00052 BDSAcceleratorComponent::~BDSAcceleratorComponent()
00053 {
00054   delete beamPipeInfo;
00055   delete readOutLV;
00056 }
00057 
00058 void BDSAcceleratorComponent::Initialise()
00059 {
00060 #ifdef BDSDEBUG
00061   G4cout << __METHOD_NAME__ << G4endl;
00062 #endif
00063   Build();
00064   readOutLV = BDS::BuildReadOutVolume(name, chordLength, angle);
00065 }
00066 
00067 void BDSAcceleratorComponent::Build()
00068 {
00069 #ifdef BDSDEBUG
00070   G4cout << __METHOD_NAME__ << G4endl;
00071 #endif
00072   BuildContainerLogicalVolume(); // pure virtual provided by derived class
00073 
00074   // visual attributes
00075   if(containerLogicalVolume)
00076     {
00077     if (BDSExecOptions::Instance()->GetVisDebug())
00078       {containerLogicalVolume->SetVisAttributes(BDSGlobalConstants::Instance()->GetVisibleDebugVisAttr());}
00079     else
00080       {containerLogicalVolume->SetVisAttributes(BDSGlobalConstants::Instance()->GetInvisibleVisAttr());}
00081     }
00082 }
00083 
00084 void BDSAcceleratorComponent::PrepareField(G4VPhysicalVolume*)
00085 {//do nothing by default
00086   return;
00087 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7