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

00001 #include "BDSReadOutGeometry.hh"
00002 
00003 #include "BDSAcceleratorModel.hh"
00004 #include "BDSDebug.hh"
00005 #include "BDSGlobalConstants.hh"
00006 #include "BDSMaterials.hh"
00007 #include "BDSUtilities.hh"
00008 
00009 #include "globals.hh"
00010 #include "G4Box.hh"
00011 #include "G4CutTubs.hh"
00012 #include "G4LogicalVolume.hh"
00013 #include "G4Material.hh"
00014 #include "G4VReadOutGeometry.hh"
00015 #include "G4VSolid.hh"
00016 
00017 BDSReadOutGeometry::BDSReadOutGeometry(G4String name):
00018   G4VReadOutGeometry(name)
00019 {;}
00020 
00021 BDSReadOutGeometry::~BDSReadOutGeometry()
00022 {;}
00023 
00024 G4VPhysicalVolume* BDSReadOutGeometry::Build()
00025 {
00026   return BDSAcceleratorModel::Instance()->GetReadOutWorldPV();
00027 }
00028 
00029 
00030 G4LogicalVolume* BDS::BuildReadOutVolume(G4String name,
00031                                          G4double chordLength,
00032                                          G4double angle)
00033 {
00034 #ifdef BDSDEBUG
00035   G4cout << __METHOD_NAME__ << G4endl;
00036 #endif
00037   if (!BDS::IsFinite(chordLength)) return NULL;
00038 
00039   G4double roRadius      = BDSGlobalConstants::Instance()->GetSamplerDiameter()*0.5;
00040   G4Material* roMaterial = BDSMaterials::Instance()->GetMaterial(BDSGlobalConstants::Instance()->GetEmptyMaterial());
00041   G4VSolid* roSolid      = NULL;
00042   if (!BDS::IsFinite(angle))
00043     {
00044       //angle is zero - build a box
00045       roSolid = new G4Box(name + "_ro_solid", // name
00046                           roRadius,           // x half width
00047                           roRadius,           // y half width
00048                           chordLength*0.5);     // z half width
00049     }
00050   else
00051     {
00052       // angle is finite!
00053       G4int orientation = BDS::CalculateOrientation(angle);
00054       G4double in_z     = cos(0.5*fabs(angle*0.5)); 
00055       G4double in_x     = sin(0.5*fabs(angle*0.5));
00056       G4ThreeVector inputface  = G4ThreeVector(-orientation*in_x, 0.0, -1.0*in_z);
00057       //-1 as pointing down in z for normal
00058       G4ThreeVector outputface = G4ThreeVector(-orientation*in_x, 0.0, in_z);
00059 
00060       roSolid = new G4CutTubs(name + "_ro_solid", // name
00061                               0,                  // inner radius
00062                               roRadius,           // outer radius
00063                               chordLength*0.5,         // half length (z)
00064                               0,                  // rotation start angle
00065                               CLHEP::twopi,       // rotation sweep angle
00066                               inputface,          // input face normal vector
00067                               outputface);        // output face normal vector
00068     }
00069 
00070   // note material not strictly necessary in geant4 > v10, but required for
00071   // v9 even though not used and doesn't affect simulation - leave for compatability
00072   G4LogicalVolume* readOutLV =  new G4LogicalVolume(roSolid,          // solid
00073                                                     roMaterial,       // material
00074                                                     name + "_ro_lv"); // name
00075 
00076   return readOutLV;
00077 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7