G4PSCylinderSurfaceCurrent Class Reference

#include <G4PSCylinderSurfaceCurrent.hh>

Inheritance diagram for G4PSCylinderSurfaceCurrent:

G4VPrimitiveScorer G4PSCylinderSurfaceCurrent3D

Public Member Functions

 G4PSCylinderSurfaceCurrent (G4String name, G4int direction, G4int depth=0)
 G4PSCylinderSurfaceCurrent (G4String name, G4int direction, const G4String &unit, G4int depth=0)
virtual ~G4PSCylinderSurfaceCurrent ()
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 *, G4Tubs *)
virtual void DefineUnitAndCategory ()

Detailed Description

Definition at line 58 of file G4PSCylinderSurfaceCurrent.hh.


Constructor & Destructor Documentation

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

Definition at line 57 of file G4PSCylinderSurfaceCurrent.cc.

References DefineUnitAndCategory(), and SetUnit().

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

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

Definition at line 66 of file G4PSCylinderSurfaceCurrent.cc.

References DefineUnitAndCategory(), and SetUnit().

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

G4PSCylinderSurfaceCurrent::~G4PSCylinderSurfaceCurrent (  )  [virtual]

Definition at line 77 of file G4PSCylinderSurfaceCurrent.cc.

00078 {;}


Member Function Documentation

void G4PSCylinderSurfaceCurrent::clear (  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 171 of file G4PSCylinderSurfaceCurrent.cc.

00171                                       {
00172   EvtMap->clear();
00173 }

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

Definition at line 213 of file G4PSCylinderSurfaceCurrent.cc.

Referenced by G4PSCylinderSurfaceCurrent().

00213                                                       {
00214    // Per Unit Surface
00215    new G4UnitDefinition("percentimeter2","percm2","Per Unit Surface",(1./cm2));
00216    new G4UnitDefinition("permillimeter2","permm2","Per Unit Surface",(1./mm2));
00217    new G4UnitDefinition("permeter2","perm2","Per Unit Surface",(1./m2));
00218 }

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

Definition at line 71 of file G4PSCylinderSurfaceCurrent.hh.

00071 { divideByArea = flg; }

void G4PSCylinderSurfaceCurrent::DrawAll (  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 175 of file G4PSCylinderSurfaceCurrent.cc.

00176 {;}

void G4PSCylinderSurfaceCurrent::EndOfEvent ( G4HCofThisEvent  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 168 of file G4PSCylinderSurfaceCurrent.cc.

00169 {;}

void G4PSCylinderSurfaceCurrent::Initialize ( G4HCofThisEvent  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 161 of file G4PSCylinderSurfaceCurrent.cc.

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

00162 {
00163   EvtMap = new G4THitsMap<G4double>(detector->GetName(), GetName());
00164   if ( HCID < 0 ) HCID = GetCollectionID(0);
00165   HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
00166 }

G4int G4PSCylinderSurfaceCurrent::IsSelectedSurface ( G4Step ,
G4Tubs  
) [protected]

Definition at line 124 of file G4PSCylinderSurfaceCurrent.cc.

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

Referenced by ProcessHits().

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

void G4PSCylinderSurfaceCurrent::PrintAll (  )  [virtual]

Reimplemented from G4VPrimitiveScorer.

Definition at line 178 of file G4PSCylinderSurfaceCurrent.cc.

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

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

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

Implements G4VPrimitiveScorer.

Definition at line 80 of file G4PSCylinderSurfaceCurrent.cc.

References G4VSolid::ComputeDimensions(), G4VPVParameterisation::ComputeSolid(), fCurrent_InOut, G4cout, G4endl, G4Tubs::GetDeltaPhiAngle(), G4VPrimitiveScorer::GetIndex(), G4Tubs::GetInnerRadius(), G4VPhysicalVolume::GetLogicalVolume(), G4VPhysicalVolume::GetParameterisation(), G4StepPoint::GetPhysicalVolume(), G4StepPoint::GetPosition(), G4Step::GetPreStepPoint(), G4LogicalVolume::GetSolid(), G4StepPoint::GetTouchable(), G4StepPoint::GetTouchableHandle(), G4StepPoint::GetWeight(), G4Tubs::GetZHalfLength(), G4VPrimitiveScorer::indexDepth, IsSelectedSurface(), and TRUE.

00081 {
00082   G4StepPoint* preStep = aStep->GetPreStepPoint();
00083   G4VPhysicalVolume* physVol = preStep->GetPhysicalVolume();
00084   G4VPVParameterisation* physParam = physVol->GetParameterisation();
00085   G4VSolid * solid = 0;
00086   if(physParam)
00087   { // for parameterized volume
00088     G4int idx = ((G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable()))
00089                 ->GetReplicaNumber(indexDepth);
00090     solid = physParam->ComputeSolid(idx, physVol);
00091     solid->ComputeDimensions(physParam,idx,physVol);
00092   }
00093   else
00094   { // for ordinary volume
00095     solid = physVol->GetLogicalVolume()->GetSolid();
00096   }
00097 
00098   G4Tubs* tubsSolid = (G4Tubs*)(solid);
00099 
00100   G4int dirFlag =IsSelectedSurface(aStep,tubsSolid);
00101   G4cout << " pos " << preStep->GetPosition() <<" dirFlag " << G4endl;
00102   if ( dirFlag > 0 ) {
00103     if ( fDirection == fCurrent_InOut || fDirection == dirFlag ){
00104       G4TouchableHandle theTouchable = preStep->GetTouchableHandle();
00105       //
00106       G4double current = 1.0;
00107       if ( weighted ) current = preStep->GetWeight(); // Current (Particle Weight)
00108       //
00109       if ( divideByArea ){
00110         G4double square = 2.*tubsSolid->GetZHalfLength()
00111           *tubsSolid->GetInnerRadius()* tubsSolid->GetDeltaPhiAngle()/radian;
00112         current = current/square;  // Current normalized by Area
00113       }
00114 
00115       G4int index = GetIndex(aStep);
00116       EvtMap->add(index,current);
00117     }
00118 
00119   }
00120 
00121   return TRUE;
00122 }

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

Reimplemented from G4VPrimitiveScorer.

Definition at line 197 of file G4PSCylinderSurfaceCurrent.cc.

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

Referenced by G4PSCylinderSurfaceCurrent(), and G4PSCylinderSurfaceCurrent3D::G4PSCylinderSurfaceCurrent3D().

00198 {
00199     if ( divideByArea ) {
00200         CheckAndSetUnit(unit,"Per Unit Surface");
00201     } else {
00202         if (unit == "" ){
00203             unitName = unit;
00204             unitValue = 1.0;
00205         }else{
00206             G4String msg = "Invalid unit ["+unit+"] (Current  unit is [" +GetUnit()+"] ) for " + GetName();
00207             G4Exception("G4PSCylinderSurfaceCurrent::SetUnit","DetPS0002",
00208             JustWarning,msg);
00209         }
00210     }
00211 }

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

Definition at line 68 of file G4PSCylinderSurfaceCurrent.hh.

00068 { weighted = flg; }


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