Message: How can I make sure that two hits are in the same volume? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question How can I make sure that two hits are in the same volume? 

Forum: Geometry
Date: 01 Feb, 2007
From: Gumplinger Peter <Gumplinger Peter>

For every MyHit (inherit from G4VHit) I keep a private member:

G4TouchableHandle fHandle;

When the MyHit is made (ProcessHits) I assign:

  G4TouchableHandle touchable
      = theStep->GetPreStepPoint()->GetTouchableHandle();

  if (!fHandle) fHandle = touchable;

Now, instead of making a new MyHit (at the next step), I'd rather add the energy deposition to an already existing hit, if any, in the SAME sensitive volume (and for the same trackID). I get the last hit in the hits-collection by:

typedef G4THitsCollection<MyHit> MyHitCollection;

MyHitCollection* fHits;

   G4int fLastHit = fHits->entries()-1;
   MyHit *tmpHit = (*fHits)[fLastHit];

From tmpHit I access the fHandle. Now, is it enough to compare:

if( &fHandle != &touchable ) return false;

where touchable is again obtained from PreStepPoint, now from the next step?

Or, do I need to implement logic like this:

    G4int historyDepth1 = fHandle->GetHistoryDepth();
    G4int historyDepth2 = touchable ->GetHistoryDepth();

    if (historyDepth1 != historyDepth2) return false;

    for (G4int i = 0; i<historyDepth1; ++i) {
        if (fHandle->GetVolume(i) != touchable->GetVolume(i)) return false;
        if (fHandle->GetReplicaNumber(i) != touchable->GetReplicaNumber(i)) return false;
    }
    return true;
?

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

 Add Message Add Message
to: "How can I make sure that two hits are in the same volume?"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]