//--------------------------------------------------------------------------- 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; }