G4PSSphereSurfaceCurrent Class Reference

#include <G4PSSphereSurfaceCurrent.hh>

Inheritance diagram for G4PSSphereSurfaceCurrent:

G4VPrimitiveScorer G4PSSphereSurfaceCurrent3D

Public Member Functions

 G4PSSphereSurfaceCurrent (G4String name, G4int direction, G4int depth=0)
 G4PSSphereSurfaceCurrent (G4String name, G4int direction, const G4String &unit, G4int depth=0)
virtual ~G4PSSphereSurfaceCurrent ()
void Weighted (G4bool flg=true)
void DivideByArea (G4bool flg=true)
virtual void Initialize (G4HCofThisEvent *)
virtual void EndOfEvent (G4HCofThisEvent *)
virtual void clear ()
virtual void DrawAll ()
virtual void PrintAll ()
virtual void SetUnit (const G4String &unit)

Protected Member Functions

virtual G4bool ProcessHits (G4Step *, G4TouchableHistory *)
G4int IsSelectedSurface (G4Step *, G4Sphere *)
virtual void DefineUnitAndCategory ()

Detailed Description

Definition at line 59 of file G4PSSphereSurfaceCurrent.hh.


Constructor & Destructor Documentation

G4PSSphereSurfaceCurrent::G4PSSphereSurfaceCurrent ( G4String  name,
G4int  direction,
G4int  depth = 0 
)

Definition at line 56 of file G4PSSphereSurfaceCurrent.cc.

References DefineUnitAndCategory(), and SetUnit().

00058     :G4VPrimitiveScorer(name,depth),HCID(-1),fDirection(direction),
00059      weighted(true),divideByArea(true)
00060 {
00061     DefineUnitAndCategory();
00062     SetUnit("percm2");
00063 }

G4PSSphereSurfaceCurrent::G4PSSphereSurfaceCurrent ( G4String  name,
G4int  direction,
const G4String unit,
G4int  depth = 0 
)

Definition at line 65 of file G4PSSphereSurfaceCurrent.cc.

References DefineUnitAndCategory(), and SetUnit().

00069     :G4VPrimitiveScorer(name,depth),HCID(-1),fDirection(direction),
00070      weighted(true),divideByArea(true)
00071 {
00072     DefineUnitAndCategory();
00073     SetUnit(unit);
00074 }

G4PSSphereSurfaceCurrent::~G4PSSphereSurfaceCurrent (  )  [virtual]

Definition at line 76 of file G4PSSphereSurfaceCurrent.cc.

00077 {;}


Member Function Documentation

void G4PSSphereSurfaceCurrent::clear (  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 176 of file G4PSSphereSurfaceCurrent.cc.

00176                                     {
00177   EvtMap->clear();
00178 }

void G4PSSphereSurfaceCurrent::DefineUnitAndCategory (  )  [protected, virtual]

Definition at line 217 of file G4PSSphereSurfaceCurrent.cc.

Referenced by G4PSSphereSurfaceCurrent().

00217                                                     {
00218    // Per Unit Surface
00219    new G4UnitDefinition("percentimeter2","percm2","Per Unit Surface",(1./cm2));
00220    new G4UnitDefinition("permillimeter2","permm2","Per Unit Surface",(1./mm2));
00221    new G4UnitDefinition("permeter2","perm2","Per Unit Surface",(1./m2));
00222 }

void G4PSSphereSurfaceCurrent::DivideByArea ( G4bool  flg = true  )  [inline]

Definition at line 70 of file G4PSSphereSurfaceCurrent.hh.

00070 { divideByArea = flg; }

void G4PSSphereSurfaceCurrent::DrawAll (  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 180 of file G4PSSphereSurfaceCurrent.cc.

00181 {;}

void G4PSSphereSurfaceCurrent::EndOfEvent ( G4HCofThisEvent  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 173 of file G4PSSphereSurfaceCurrent.cc.

00174 {;}

void G4PSSphereSurfaceCurrent::Initialize ( G4HCofThisEvent  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 166 of file G4PSSphereSurfaceCurrent.cc.

References G4HCofThisEvent::AddHitsCollection(), G4VPrimitiveScorer::detector, G4VPrimitiveScorer::GetCollectionID(), G4VPrimitiveScorer::GetName(), and G4VSensitiveDetector::GetName().

00167 {
00168   EvtMap = new G4THitsMap<G4double>(detector->GetName(), GetName());
00169   if ( HCID < 0 ) HCID = GetCollectionID(0);
00170   HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
00171 }

G4int G4PSSphereSurfaceCurrent::IsSelectedSurface ( G4Step ,
G4Sphere  
) [protected]

Definition at line 121 of file G4PSSphereSurfaceCurrent.cc.

References fCurrent_In, fCurrent_Out, fGeomBoundary, G4Sphere::GetInsideRadius(), G4GeometryTolerance::GetInstance(), G4StepPoint::GetPosition(), G4Step::GetPostStepPoint(), G4Step::GetPreStepPoint(), G4StepPoint::GetStepStatus(), G4GeometryTolerance::GetSurfaceTolerance(), and G4StepPoint::GetTouchableHandle().

Referenced by ProcessHits().

00121                                                                                      {
00122 
00123   G4TouchableHandle theTouchable = 
00124     aStep->GetPreStepPoint()->GetTouchableHandle();
00125   G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
00126   
00127   if (aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary ){
00128     // Entering Geometry
00129     G4ThreeVector stppos1= aStep->GetPreStepPoint()->GetPosition();
00130     G4ThreeVector localpos1 = 
00131       theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos1);
00132     G4double localR2 = localpos1.x()*localpos1.x()
00133                       +localpos1.y()*localpos1.y()
00134                       +localpos1.z()*localpos1.z();
00135     //G4double InsideRadius2 = 
00136     //  sphereSolid->GetInsideRadius()*sphereSolid->GetInsideRadius();
00137     //if(std::fabs( localR2 - InsideRadius2 ) < kCarTolerance ){
00138     G4double InsideRadius = sphereSolid->GetInsideRadius();
00139     if ( localR2 > (InsideRadius-kCarTolerance)*(InsideRadius-kCarTolerance)
00140          &&localR2 < (InsideRadius+kCarTolerance)*(InsideRadius+kCarTolerance)){
00141       return fCurrent_In;
00142     }
00143   }
00144 
00145   if (aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary ){
00146     // Exiting Geometry
00147     G4ThreeVector stppos2= aStep->GetPostStepPoint()->GetPosition();
00148     G4ThreeVector localpos2 = 
00149       theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos2);
00150     G4double localR2 = localpos2.x()*localpos2.x()
00151                       +localpos2.y()*localpos2.y()
00152                       +localpos2.z()*localpos2.z();
00153     //G4double InsideRadius2 = 
00154     //  sphereSolid->GetInsideRadius()*sphereSolid->GetInsideRadius();
00155     //if(std::fabs( localR2 - InsideRadius2 ) < kCarTolerance ){
00156     G4double InsideRadius = sphereSolid->GetInsideRadius();
00157     if ( localR2 > (InsideRadius-kCarTolerance)*(InsideRadius-kCarTolerance)
00158          &&localR2 < (InsideRadius+kCarTolerance)*(InsideRadius+kCarTolerance)){
00159       return fCurrent_Out;
00160     }
00161   }
00162 
00163   return -1;
00164 }

void G4PSSphereSurfaceCurrent::PrintAll (  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 183 of file G4PSSphereSurfaceCurrent.cc.

References G4VPrimitiveScorer::detector, G4cout, G4endl, G4VPrimitiveScorer::GetName(), G4VSensitiveDetector::GetName(), G4VPrimitiveScorer::GetUnit(), and G4VPrimitiveScorer::GetUnitValue().

00184 {
00185   G4cout << " MultiFunctionalDet  " << detector->GetName() << G4endl;
00186   G4cout << " PrimitiveScorer " << GetName() <<G4endl; 
00187   G4cout << " Number of entries " << EvtMap->entries() << G4endl;
00188   std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
00189   for(; itr != EvtMap->GetMap()->end(); itr++) {
00190     G4cout << "  copy no.: " << itr->first  << "  current  : " ;
00191     if ( divideByArea ) {
00192         G4cout << *(itr->second)/GetUnitValue() 
00193                << " [" <<GetUnit()<<"]";
00194     }else {
00195         G4cout << *(itr->second) << " [tracks]" ;
00196     }
00197     G4cout  << G4endl;
00198   }
00199 }

G4bool G4PSSphereSurfaceCurrent::ProcessHits ( G4Step ,
G4TouchableHistory  
) [protected, virtual]

Implements G4VPrimitiveScorer.

Definition at line 79 of file G4PSSphereSurfaceCurrent.cc.

References G4VSolid::ComputeDimensions(), G4VPVParameterisation::ComputeSolid(), fCurrent_InOut, G4Sphere::GetDeltaPhiAngle(), G4Sphere::GetDeltaThetaAngle(), G4VPrimitiveScorer::GetIndex(), G4Sphere::GetInsideRadius(), G4VPhysicalVolume::GetLogicalVolume(), G4VPhysicalVolume::GetParameterisation(), G4StepPoint::GetPhysicalVolume(), G4Step::GetPreStepPoint(), G4LogicalVolume::GetSolid(), G4Sphere::GetStartThetaAngle(), G4StepPoint::GetTouchable(), G4StepPoint::GetWeight(), G4VPrimitiveScorer::indexDepth, IsSelectedSurface(), and TRUE.

00080 {
00081   G4StepPoint* preStep = aStep->GetPreStepPoint();
00082   G4VPhysicalVolume* physVol = preStep->GetPhysicalVolume();
00083   G4VPVParameterisation* physParam = physVol->GetParameterisation();
00084   G4VSolid * solid = 0;
00085   if(physParam)
00086   { // for parameterized volume
00087     G4int idx = ((G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable()))
00088                 ->GetReplicaNumber(indexDepth);
00089     solid = physParam->ComputeSolid(idx, physVol);
00090     solid->ComputeDimensions(physParam,idx,physVol);
00091   }
00092   else
00093   { // for ordinary volume
00094     solid = physVol->GetLogicalVolume()->GetSolid();
00095   }
00096 
00097   G4Sphere* sphereSolid = (G4Sphere*)(solid);
00098 
00099   G4int dirFlag =IsSelectedSurface(aStep,sphereSolid);
00100   if ( dirFlag > 0 ) {
00101     if ( fDirection == fCurrent_InOut || fDirection == dirFlag ){
00102         G4double radi   = sphereSolid->GetInsideRadius();
00103         G4double dph    = sphereSolid->GetDeltaPhiAngle()/radian;
00104         G4double stth   = sphereSolid->GetStartThetaAngle()/radian;
00105         G4double enth   = stth+sphereSolid->GetDeltaThetaAngle()/radian;
00106         G4double current = 1.0;
00107         if ( weighted) current = preStep->GetWeight(); // Current (Particle Weight)
00108         if ( divideByArea ){
00109             G4double square = radi*radi*dph*( -std::cos(enth) + std::cos(stth) );
00110             current = current/square;  // Current with angle.
00111         }
00112 
00113         G4int index = GetIndex(aStep);
00114         EvtMap->add(index,current);
00115     }
00116   }
00117 
00118   return TRUE;
00119 }

void G4PSSphereSurfaceCurrent::SetUnit ( const G4String unit  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 202 of file G4PSSphereSurfaceCurrent.cc.

References G4VPrimitiveScorer::CheckAndSetUnit(), G4Exception(), G4VPrimitiveScorer::GetName(), G4VPrimitiveScorer::GetUnit(), JustWarning, G4VPrimitiveScorer::unitName, and G4VPrimitiveScorer::unitValue.

Referenced by G4PSSphereSurfaceCurrent(), and G4PSSphereSurfaceCurrent3D::G4PSSphereSurfaceCurrent3D().

00203 {
00204     if ( divideByArea ) {
00205         CheckAndSetUnit(unit,"Per Unit Surface");
00206     } else {
00207         if (unit == "" ){
00208             unitName = unit;
00209             unitValue = 1.0;
00210         }else{
00211             G4String msg = "Invalid unit ["+unit+"] (Current  unit is [" +GetUnit()+"] ) for " + GetName();
00212             G4Exception("G4PSSphereSurfaceCurrent::SetUnit","DetPS0015",JustWarning,msg);
00213         }
00214     }
00215 }

void G4PSSphereSurfaceCurrent::Weighted ( G4bool  flg = true  )  [inline]

Definition at line 68 of file G4PSSphereSurfaceCurrent.hh.

00068 { weighted = flg; }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:03 2013 for Geant4 by  doxygen 1.4.7