Message: Re: Modifying Geometry using Messenger Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Modifying Geometry using Messenger 

Forum: Geometry
Re: None Modifying Geometry using Messenger (Alan James Bell)
Re: None Re: Modifying Geometry using Messenger (Roger Hälg)
Re: None Re: Modifying Geometry using Messenger (Alan James Bell)
Re: None Re: Modifying Geometry using Messenger (Roger Hälg)
Date: 04 Dec, 2014
From: Alan James Bell <Alan James Bell>

Hi Roger. Sorry for the delay. Your suggestion for modifying the material properties inspired me to get it done! :)

For your sensitive detector question, I did the following (I'll go in to some detail incase (a) other new G4'ers are searching for help, and (b) Any G4 experts can educate me on a better way of doing this. I think (b) is more likely! Example. Counting the number of photons hitting the detector.

In the DetectorConstruction::Construct(). 1. Create a Sensitive Detector Particle Filter.

G4SDParticleFilter* OPFilter = new G4SDParticleFilter("OPFilter","opticalphoton");

2. Define your primitive scorer(s)

G4VPrimitiveScorer* PS = new G4PSPopulation(“Op_Photons”);

3. Create a Multifunctional Detector

G4MultiFunctionalDetect* myMFD = new G4MultiFunctionalDetector(“myMDF”);

4. Register your primitive scorer with the MDF.

myMFD->RegisterPrimitive(PS);

5. Link the sensitive detector logical volume to your new MFD.

SetSensitiveDetect(“DetectorLV”, myMFD);

In the Run::RecordEvent class.

6. Get the hit collection ID for your MFD by name ("myMFD/Op_Photons"). You only do this once.

// Initialize some Collection ID variable in the Run() constructor. : fCollID_myMFD(-1)

Void Run::RecordEvent(const G4Event* event)
{
	void Run::RecordEvent(const G4Event* event)
{
    // Only do this the 1st time.
    if ( fCollID_myMFD < 0 ) {
        fCollID_myMFD
        = G4SDManager::GetSDMpointer()->GetCollectionID("myMFD/Op_Photons");
}

where "GetCollectionID( )" is:

G4THitsMap<G4double>* Run::GetHitsCollection(G4int hcID, const G4Event* event) const
{
    G4THitsMap<G4double>* hitsCollection
            = static_cast<G4THitsMap<G4double>*>(event->GetHCofThisEvent()->GetHC(hcID));

    if ( ! hitsCollection ) {
        G4ExceptionDescription msg;
        msg << "Cannot access hitsCollection ID " << hcID;
        G4Exception("B4dEventAction::GetHitsCollection()",
                    "Error X", FatalException, msg);
    }

    return hitsCollection;
}

7. Finally, get the hit collection of the event and get the optical photon hit information from the hit collection...

SumOfPhotons = GetSum(GetHitsCollection(fCollID_myMFD, event)); G4cout << "There was " << SumOfPhotons << " in this event! << G4endl;

This seems to work for me. I am definitely NOT G4 savvy, so there may be better ways of achieving the same thing. If there are, please let me know. In the meanwhile, I hope this helps!

B.R. Alan.

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

1 None: Re: Modifying Geometry using Messenger   (Roger Hälg - 04 Dec, 2014)
1 None: Re: Modifying Geometry using Messenger   (Makoto Asai - 04 Dec, 2014)
2 None: Re: Modifying Geometry using Messenger   (Alan James Bell - 05 Dec, 2014)
 Add Message Add Message
to: "Re: Modifying Geometry using Messenger"

 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 ]