HI:
I’ve been using the DICOM example recently, and I want to output information about where the particles are in the model. However, it seems that the G4VPrimitiveScorer cannot extract the particle location information according to my knowledge.
So I’m going to define phantomContainer as SD to get information about where the particles are going into the phantomContainer. Here are the changes I made to the DICOM sample program.
#ifndef DicomSD_h
#define DicomSD_h 1
#include "G4VSensitiveDetector.hh"
#include "DicomHit.hh"
class G4Step;
class G4HCofThisEvent;
class G4TouchableHistory;
class DicomSD : public G4VSensitiveDetector
{
public:
DicomSD(G4String name);
~DicomSD() override;
void Initialize(G4HCofThisEvent*HCE) override;
G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist) override;
private:
HadCalorimeterHitsCollection* fHitsCollection = nullptr;
G4int fHCID = -1;
};
#endif
ooooo0ooooo........ooooo0ooooo........ooooo0ooooo........ooooo0ooooo
#include "DicomSD.hh"
#include "DicomHit.hh"
#include "G4HCofThisEvent.hh"
#include "G4TouchableHistory.hh"
#include "G4Track.hh"
#include "G4Step.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
DicomSD::DicomSD(G4String name)
: G4VSensitiveDetector(name)
{
collectionName.insert("DicomColl");
G4cout<<"-----------DicomSD-----------"<<G4endl;
}
DicomSD::~DicomSD()
{}
void DicomSD::Initialize(G4HCofThisEvent* hce)
{
fHitsCollection
= new HadCalorimeterHitsCollection(SensitiveDetectorName,collectionName[0]);
if (fHCID<0) {
fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
}
hce->AddHitsCollection(fHCID,fHitsCollection);
fHitsCollection->insert(new DicomHit());
G4cout<<"-----------DicomSD::Initialize-----------"<<G4endl;
}
G4bool DicomSD::ProcessHits(G4Step* step, G4TouchableHistory*)
{
G4cout<<"-------DicomSD::ProcessHits-------"<<G4endl;
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
auto voxelSD = new DicomSD("voxelsd");
G4SDManager::GetSDMpointer()->AddNewDetector(voxelSD);
SetSensitiveDetector("phantomContainer",voxelSD);
I encountered a problem at runtime. After creating the SD, the prompts in DicomSD::DicomSD and DicomSD::Initialize at runtime were displayed normally on the terminal, but the messages on DicomSD::ProcessHits were not. I think the representative program skipped this when it was running.
Therefore, I would like to ask the experts whether the G4VPrimitiveScorer can extract the particle location information, so that I can avoid to define the SD detector again. If the G4VPrimitiveScorer is unable to extract particle information, may I ask if there is any problem in the SD detector I defined that caused the program to skip the DicomSD::ProcessHits function?
Thank you for your reply. I really need your help.