00001 #include "BDSGlobalConstants.hh"
00002 #include "BDSCCDChip.hh"
00003 #include "BDSCCDPixel.hh"
00004 #include "G4Box.hh"
00005 #include "G4VisAttributes.hh"
00006 #include "G4LogicalVolume.hh"
00007 #include "G4VPhysicalVolume.hh"
00008 #include "G4PVPlacement.hh"
00009 #include "G4UserLimits.hh"
00010 #include "BDSDebug.hh"
00011
00012 #include "G4UserLimits.hh"
00013 #include <map>
00014 #include "G4TwoVector.hh"
00015 #include "BDSMaterials.hh"
00016
00017 BDSCCDChip::BDSCCDChip (G4String aName, G4ThreeVector pixelSize, G4TwoVector nPixels):
00018 _pixel(new BDSCCDPixel(pixelSize,aName+"pixel")),_nPixels(nPixels), _name(aName)
00019 {
00020 computeDimensions();
00021 build();
00022 }
00023
00024 void BDSCCDChip::computeDimensions(){
00025 G4cout << __METHOD_NAME__ << G4endl;
00026 _size.setX(_pixel->size().x()*_nPixels.x());
00027 _size.setY(_pixel->size().y()*_nPixels.y());
00028 _size.setZ(_pixel->size().z());
00029 G4cout << __METHOD_END__ << G4endl;
00030
00031 }
00032
00033
00034 void BDSCCDChip::build(){
00035 G4cout << __METHOD_NAME__ << G4endl;
00036 buildMotherVolume();
00037 buildPixels();
00038 G4cout << __METHOD_END__ << G4endl;
00039 }
00040
00041 void BDSCCDChip::buildMotherVolume(){
00042 G4cout << __METHOD_NAME__ << G4endl;
00043 _solid=new G4Box( _name+"_solid",
00044 _size.x()/2.0,
00045 _size.y()/2.0,
00046 _size.z()/2.0);
00047
00048 _log=new G4LogicalVolume
00049 (_solid,
00050 BDSMaterials::Instance()->GetMaterial(BDSGlobalConstants::Instance()->GetVacuumMaterial()),
00051 _name+"_log");
00052 G4cout << __METHOD_END__ << G4endl;
00053 }
00054
00055
00056
00057 void BDSCCDChip::buildPixels(){
00058 G4cout << __METHOD_NAME__ << G4endl;
00059 G4ThreeVector pos, offset;
00060 offset.setZ(0);
00061 offset.setX(-_size.x()/2.0+_pixel->size().x()/2.0);
00062 offset.setY(_size.y()/2.0-_pixel->size().y()/2.0);
00063 pos.setZ(0);
00064 G4int copyNumber=0;
00065 std::stringstream ss;
00066 for (int i=0; i<_nPixels.x(); i++){
00067 for(int j=0; j<_nPixels.y(); j++, copyNumber++){
00068 ss.str("");
00069 ss << _pixel->name().data() << "_phys_" << copyNumber;
00070 pos.setX(offset.x()+i*_pixel->size().x());
00071 pos.setY(offset.y()-j*_pixel->size().y());
00072
00073 new G4PVPlacement(0,
00074 pos,
00075 _pixel->log(),
00076 ss.str(),
00077 _log,
00078 true,
00079 copyNumber,
00080 false
00081 );
00082 }
00083 }
00084 G4cout << __METHOD_END__ << G4endl;
00085 }
00086
00087
00088 BDSCCDChip::~BDSCCDChip()
00089 {
00090 delete _pixel;
00091 }
00092