Message: Re: Sensitive detector problem Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Sensitive detector problem 

Forum: Hits, Digitization and Pileup
Re: Question Sensitive detector problem (sergi)
Date: 05 Jul, 2013
From: Tsukasa Aso <Tsukasa Aso>

Hi,

 You need to create a new Hit object first. 
--- Your code in class newSD ----
G4bool newSD::ProcessHits(G4Step *step, G4TouchableHistory *)
{

   G4double edep = step->GetTotalEnergyDeposit();
   if (edep==0) return true;

    newHit* aHit = 0;                    <==== aHit is NULL ( This should be:   newHit* aHit = new newHit(); )
   hitCollection->insert(aHit);
   aHit->AddEdep (edep);            <===== Exception:: You can not use it because of NULL
   return true;
}
----

Comments:
- ProcessHits() is called every step.
    If you want to accumulate (i.e sum up) all deposited energy by interacting neutrons, 
    the instance of newHit should be created only once. 
    For example,
       if ( hitCollection->entries() == 0 ){
          newHit* aHit = new newHit();
          aHit->AddEdep(edep);
          hitCollection->insert(aHit);
       }else{
          newHit* aHit = (*fHitsCollection)[0];       <=== "Hit" will exist only one.
          aHit->AddEdep(edep)l
       }

Best regards,
Tsukasa Aso

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

1 Question: Re: Sensitive detector problem   (Esteban - 09 Jul, 2013)
(_ None: Re: Sensitive detector problem   (Tsukasa Aso - 09 Jul, 2013)
(_ Question: Re: Sensitive detector problem   (Esteban - 19 Jul, 2013)
(_ None: Re: Sensitive detector problem   (Tsukasa Aso - 20 Jul, 2013)
(_ None: Re: Sensitive detector problem   (Esteban - 22 Jul, 2013)
(_ None: Re: Sensitive detector problem   (Tsukasa Aso - 22 Jul, 2013)
(_ None: Re: Sensitive detector problem   (Esteban - 22 Jul, 2013)
(_ None: Re: Sensitive detector problem   (Tsukasa Aso - 22 Jul, 2013)
(_ None: Re: Sensitive detector problem   (Esteban - 23 Jul, 2013)
(_ None: Re: Sensitive detector problem   (Tsukasa Aso - 23 Jul, 2013)
(_ None: Re: Sensitive detector problem   (Esteban - 24 Jul, 2013)
 Add Message Add Message
to: "Re: Sensitive detector problem"

 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 ]