/home/cern/BDSIM_new/src/BDSSpoiler.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 #include "BDSGlobalConstants.hh" // must be first in include list
00007 #include "BDSSpoiler.hh"
00008 #include "G4VisAttributes.hh"
00009 #include "G4LogicalVolume.hh"
00010 #include "G4VPhysicalVolume.hh"
00011 #include "G4PVPlacement.hh"               
00012 #include "G4UserLimits.hh"
00013 #include "G4TransportationManager.hh"
00014 
00015 #include "G4SDManager.hh"
00016 #include "G4UserLimits.hh"
00017 
00018 #include <map>
00019 
00020 //============================================================
00021 //typedef std::map<G4String,MagFieldFunction*> PhysFieldMap;
00022 //extern PhysFieldMap* MagFieldMap;
00023 
00024 typedef std::map<G4String,int> LogVolCountMap;
00025 extern LogVolCountMap* LogVolCount;
00026 
00027 typedef std::map<G4String,G4LogicalVolume*> LogVolMap;
00028 extern LogVolMap* LogVol;
00029 //extern G4double BDS_Threshold_Energy;
00030 extern BDSMaterials* theMaterials;
00031 //============================================================
00032 
00033 BDSSpoiler::BDSSpoiler (G4String& aName,G4double aLength,G4double bpRad,
00034                           G4double xAper,G4double yAper,
00035                           G4Material* SpoilerMaterial):
00036   BDSAcceleratorComponent(aName,
00037                          aLength,bpRad,xAper,yAper,
00038                          SetVisAttributes()),
00039   itsSpoilerMaterial(SpoilerMaterial)
00040 {
00041   
00042   if ( (*LogVolCount)[itsName]==0)
00043     {
00044       itsMarkerLogicalVolume=
00045         new G4LogicalVolume(
00046                             new G4Box(itsName,
00047                                       BDSGlobals->GetComponentBoxSize()/2,
00048                                       BDSGlobals->GetComponentBoxSize()/2,
00049                                       itsLength/2),
00050                             theMaterials->GetMaterial("Vacuum"),
00051                             itsName);
00052       BuildInnerSpoiler();
00053 
00054       (*LogVolCount)[itsName]=1;
00055       (*LogVol)[itsName]=itsMarkerLogicalVolume;
00056     }
00057   else
00058     {
00059       (*LogVolCount)[itsName]++;
00060       itsMarkerLogicalVolume=(*LogVol)[itsName];
00061     }  
00062 }
00063 
00064 
00065 G4VisAttributes* BDSSpoiler::SetVisAttributes()
00066 {
00067   itsVisAttributes=new G4VisAttributes(G4Colour(0.3,0.4,0.2));
00068   return itsVisAttributes;
00069 }
00070 
00071 
00072 void BDSSpoiler::BuildInnerSpoiler()
00073 {
00074   itsSolidLogVol=
00075     new G4LogicalVolume(new G4Box(itsName+"_solid",
00076                                   BDSGlobals->GetComponentBoxSize()/2,
00077                                   BDSGlobals->GetComponentBoxSize()/2,
00078                                   itsLength/2),
00079                         itsSpoilerMaterial,
00080                         itsName+"_solid");
00081 
00082   itsInnerLogVol=
00083     new G4LogicalVolume(new G4Box(itsName+"_inner",
00084                                   itsXAper,
00085                                   itsYAper,
00086                                   itsLength/2),
00087                         theMaterials->GetMaterial("Vacuum"),
00088                         itsName+"_inner");
00089   
00090   itsPhysiComp2 = 
00091     new G4PVPlacement(
00092                       0,                   // no rotation
00093                       0,                   // its position
00094                       itsInnerLogVol,      // its logical volume
00095                       itsName+"_combined", // its name
00096                       itsSolidLogVol,      // its mother  volume
00097                       false,               // no boolean operation
00098                       0);                  // copy number 
00099 
00100   SetSensitiveVolume(itsSolidLogVol);
00101 
00102   itsSolidLogVol->
00103     SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,DBL_MAX,
00104                                        BDSGlobals-> GetThresholdCutCharged()));
00105   
00106   itsPhysiComp = 
00107     new G4PVPlacement(
00108                       0,                     // no rotation
00109                       0,                     // its position
00110                       itsSolidLogVol,    // its logical volume
00111                       itsName+"_solid",      // its name
00112                       itsMarkerLogicalVolume, // its mother  volume
00113                       false,                 // no boolean operation
00114                       0);                    // copy number  
00115 }
00116 
00117 
00118 BDSSpoiler::~BDSSpoiler()
00119 {
00120   if(itsVisAttributes) delete itsVisAttributes;
00121   if(itsUserLimits) delete itsUserLimits;
00122 
00123   if(itsMarkerLogicalVolume)delete itsMarkerLogicalVolume;
00124   if(itsSolidLogVol)delete itsSolidLogVol;
00125   if(itsInnerLogVol)delete itsInnerLogVol;
00126 
00127   if(itsPhysiComp) delete itsPhysiComp;
00128   if(itsPhysiComp2) delete itsPhysiComp2;
00129 }

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