/home/cern/BDSIM_new/src/BDSSamplerCylinder.cc

00001 /* BDSIM code.    Version 1.0
00002    Author: Grahame A. Blair, Royal Holloway, Univ. of London.
00003    Last modified 5.3.2005
00004    Copyright (c) 2005 by G.A.Blair.  ALL RIGHTS RESERVED. 
00005 */
00006 #include "BDSGlobalConstants.hh" // must be first in include list
00007 #include "BDSSamplerCylinder.hh"
00008 #include "G4Box.hh"
00009 #include "G4Tubs.hh"
00010 #include "G4VisAttributes.hh"
00011 #include "G4LogicalVolume.hh"
00012 #include "G4VPhysicalVolume.hh"
00013 #include "G4PVPlacement.hh"               
00014 #include "G4UserLimits.hh"
00015 
00016 #include <map>
00017 
00018 #include "BDSSamplerSD.hh"
00019 #include "G4SDManager.hh"
00020 
00021 
00022 typedef std::map<G4String,int> LogVolCountMap;
00023 extern LogVolCountMap* LogVolCount;
00024 
00025 typedef std::map<G4String,G4LogicalVolume*> LogVolMap;
00026 extern LogVolMap* LogVol;
00027 
00028 
00029 
00030 extern BDSMaterials* theMaterials;
00031 //============================================================
00032 
00033 BDSSamplerCylinder::
00034 BDSSamplerCylinder (G4String aName,G4double aLength,G4double aRadius):
00035   BDSAcceleratorComponent(
00036                          aName,
00037                          aLength,0,0,0,
00038                          SetVisAttributes()),
00039   itsRadius(aRadius)
00040 {
00041   SamplerCylinderLogicalVolume();
00042   //G4int nSamplers=(*LogVolCount)[itsName];
00043   //BDSRoot->SetSampCylinderNumber(nSamplers);
00044 }
00045 
00046 
00047 void BDSSamplerCylinder::SamplerCylinderLogicalVolume()
00048 {
00049   if(!(*LogVolCount)[itsName])
00050     {
00051       G4double SampTransSize;
00052       SampTransSize=2.*BDSGlobals->GetTunnelRadius();
00053 
00054       itsMarkerLogicalVolume=
00055         new G4LogicalVolume(new G4Tubs(itsName+"_body",
00056                                        itsRadius-1.e-6*m,
00057                                        itsRadius,
00058                                        itsLength/2,
00059                                        0,twopi*radian),
00060                             theMaterials->GetMaterial("Vacuum"),
00061                             itsName);
00062       
00063       (*LogVolCount)[itsName]=1;
00064       (*LogVol)[itsName]=itsMarkerLogicalVolume;
00065 
00066       itsOuterUserLimits =new G4UserLimits();
00067       itsOuterUserLimits->SetMaxAllowedStep(itsLength);
00068       itsMarkerLogicalVolume->SetUserLimits(itsOuterUserLimits);
00069 
00070       // Sensitive Detector:
00071       G4SDManager* SDMan = G4SDManager::GetSDMpointer();
00072       BDSSamplerSD* SensDet=new BDSSamplerSD(itsName,"cylinder");
00073        
00074       SDMan->AddNewDetector(SensDet);
00075       itsMarkerLogicalVolume->SetSensitiveDetector(SensDet);
00076     }
00077   else
00078     {
00079       (*LogVolCount)[itsName]++;
00080       itsMarkerLogicalVolume=(*LogVol)[itsName];
00081     }
00082 }
00083 
00084 G4VisAttributes* BDSSamplerCylinder::SetVisAttributes()
00085 {
00086   itsVisAttributes=new G4VisAttributes(G4Colour(1,0,1));
00087   return itsVisAttributes;
00088 }
00089 
00090 BDSSamplerCylinder::~BDSSamplerCylinder()
00091 {
00092   delete itsVisAttributes;
00093   delete itsUserLimits;
00094 }

Generated on Wed Mar 5 17:25:22 2008 for BDSIM by  doxygen 1.5.3