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

00001 #include "BDSGlobalConstants.hh" 
00002 #include "BDSMultiFacetLayer.hh"
00003 #include "BDSMaterials.hh"
00004 #include "G4Box.hh"
00005 #include "G4VisAttributes.hh"
00006 #include "G4LogicalVolume.hh"
00007 #include "G4VPhysicalVolume.hh"
00008 #include "G4PVPlacement.hh"               
00009 
00010 //============================================================
00011 BDSMultiFacetLayer::BDSMultiFacetLayer (G4String name, BDSLensFacet* facet, G4double gapWidth, G4double nFacets):
00012   _facet(facet), _gapWidth(gapWidth), _nFacets(nFacets)
00013 {
00014   _gapWidth=0;
00015   _name = name+"_MultiFacetLayer";
00016   computeDimensions();
00017   build();
00018 }
00019 
00020 void BDSMultiFacetLayer::computeDimensions(){
00021   _size.setZ(_facet->totalHeight());
00022   _size.setY(_facet->size().y());
00023   _size.setX(_nFacets*_facet->size().x() + 
00024              (_nFacets-1)*_gapWidth);
00025   //Compute positions of the facets relative to the mother volume.
00026   G4double x=0,y=0,z=0;
00027   for(double i=0; i<_nFacets; i++){
00028     x=(i+0.5)*_facet->size().x()-_size.x()/2.0+i*_gapWidth;
00029     _facetPos.push_back(G4ThreeVector(x,y,z));
00030   }
00031 }
00032 
00033 void BDSMultiFacetLayer::build(){
00034   buildScreen();
00035   placeFacets();
00036 }
00037 
00038 
00039 void BDSMultiFacetLayer::buildScreen(){
00040   _solid  = new G4Box((_name+"_solid").c_str(),_size.x()/2.0,_size.z()/2.0,_size.y()/2.0);
00041   _log = new G4LogicalVolume(_solid,BDSMaterials::Instance()->GetMaterial(BDSGlobalConstants::Instance()->GetVacuumMaterial()),(_name+"_log").c_str(),0,0,0);
00042   G4VisAttributes* visAtt = new G4VisAttributes();
00043   visAtt->SetColor(G4Colour(0.7,0.2,0.0,0.3));
00044   visAtt->SetForceSolid(true);
00045   _log->SetVisAttributes(visAtt);
00046 }
00047 
00048 void BDSMultiFacetLayer::placeFacets(){
00049   //Place the facets in the mother volume at the locations in _facetPos.
00050   
00051   for(int i=0; i<_nFacets; i++){
00052     new G4PVPlacement(_facet->rotation(), //The facet (trapezoid) must be rotated into the correct coordinate system (z normal to base).
00053                       _facetPos[i],
00054                       _facet->log(),
00055                       _facet->name(),
00056                       _log,
00057                       true,
00058                       i,
00059                       false);
00060   }
00061 }
00062 
00063 BDSMultiFacetLayer::~BDSMultiFacetLayer(){
00064 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7