G4VPhysicalVolume * GeantDetectorConstruction::Construct()
{
    // World
    G4double worldSize = 5 * ( std::abs( gOptions->GetDetZ_cm() * cm ) + std::abs( gOptions->GetPartZ_cm() * cm ) ) ;
    G4Box * worldSolid = new G4Box("WorldS", worldSize, worldSize, worldSize);
    G4LogicalVolume * worldLV = new G4LogicalVolume( worldSolid, G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic"), "World");
    G4VPhysicalVolume * worldPV = new G4PVPlacement( 0, G4ThreeVector(0,0,0), worldLV, "WorldPV", 0, false, 0, true);

    // Scatterer plane
    G4Box * scatPlaneSolid = new G4Box("scatPlaneSolid", worldSize, worldSize, gOptions->GetScatThick_um() * um / 2  );
    G4Material * scatMat =  G4NistManager::Instance()->FindOrBuildMaterial("G4_Si");
    G4cout << "Scatterer material: " << scatMat->GetName() << " Radiation length = "<< scatMat->GetRadlen() / cm << " cm"<< G4endl;
    G4LogicalVolume * scatPlaneLV = new G4LogicalVolume( scatPlaneSolid, scatMat, "scatPlaneLV");
    new G4PVPlacement( 0, G4ThreeVector(0,0,0), scatPlaneLV, "scatPlanePV", worldLV, false, 0, true);

    // Detector plane
    G4Box * detPlaneSolid = new G4Box("detPlaneSolid", worldSize, worldSize, 1 * um );
    G4LogicalVolume * detPlaneLV = new G4LogicalVolume( detPlaneSolid, G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic"), "detPlaneLV");
    new G4PVPlacement( 0, G4ThreeVector( 0, 0, ( gOptions->GetDetZ_cm() + detPlaneSolid->GetZHalfLength() ) * cm ), detPlaneLV, "DetPlanePV", worldLV, false, 0, true);
    fDetPlaneSD = new GeantTrackerSD( 0 );
    SetSensitiveDetector( detPlaneLV, fDetPlaneSD );

    return worldPV;
}
Пример #2
0
//---------------------------------------------------------------------------
G4int SteppingAction::IsBoxSurfaceFlux(const G4Step* aStep) //returns 1(in), 2(out), or -1
{  //G4PSFlatSurfaceFlux
	
	G4StepPoint* preStep = aStep->GetPreStepPoint();
	
	G4VPhysicalVolume* physVol = preStep->GetPhysicalVolume();
	G4VPVParameterisation* physParam = physVol->GetParameterisation();
	G4VSolid * solid = 0;
	if(physParam)
	{ // for parameterized volume
	//G4int idx = ((G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable()))
	//->GetReplicaNumber(indexDepth);//TODO find indexDepth and use these
	//solid = physParam->ComputeSolid(idx, physVol);
	//solid->ComputeDimensions(physParam,idx,physVol);
	}
	else
	{ // for ordinary volume
		solid = physVol->GetLogicalVolume()->GetSolid();
	}
	
	G4Box* boxSolid = (G4Box*)(solid);
	
	G4TouchableHandle theTouchable = 
	aStep->GetPreStepPoint()->GetTouchableHandle();
	G4double kCarTolerance=G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
	
	if (aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary ){
		// Entering Geometry
		G4ThreeVector stppos1= aStep->GetPreStepPoint()->GetPosition();
		G4ThreeVector localpos1 = 
		theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos1);
		if(std::fabs( localpos1.z() + boxSolid->GetZHalfLength())<kCarTolerance 
			||std::fabs( localpos1.z() - boxSolid->GetZHalfLength())<kCarTolerance
			||std::fabs( localpos1.y() + boxSolid->GetYHalfLength())<kCarTolerance 
			||std::fabs( localpos1.y() - boxSolid->GetYHalfLength())<kCarTolerance 
			||std::fabs( localpos1.x() + boxSolid->GetXHalfLength())<kCarTolerance 
			||std::fabs( localpos1.x() - boxSolid->GetXHalfLength())<kCarTolerance 
		){
			return 1;//fFlux_In; _InOut =0 		
		}
		
	}
	
	if (aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary ){
		// Exiting Geometry
		G4ThreeVector stppos2= aStep->GetPostStepPoint()->GetPosition();
		G4ThreeVector localpos2 = 
		theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos2);
		if(std::fabs( localpos2.z() + boxSolid->GetZHalfLength())<kCarTolerance 
			||std::fabs( localpos2.z() - boxSolid->GetZHalfLength())<kCarTolerance
			||std::fabs( localpos2.y() + boxSolid->GetYHalfLength())<kCarTolerance 
			||std::fabs( localpos2.y() - boxSolid->GetYHalfLength())<kCarTolerance 
			||std::fabs( localpos2.x() + boxSolid->GetXHalfLength())<kCarTolerance 
			||std::fabs( localpos2.x() - boxSolid->GetXHalfLength())<kCarTolerance 			
		){
			return 2;//fFlux_Out;
		}
	}
	
	return -1;
}