Sensitive detector class added

parent 3320f394
#ifndef B1SD_h
#define B1SD_h 1
#include "G4VSensitiveDetector.hh"
#include "B1Hits.hh"
class G4Step;
class G4HCofThisEvent;
class G4TouchableHistory;
class B1Hits;
class B1SD: public G4VSensitiveDetector
{
public:
//construtor
B1SD(G4String SDname);
//destrutor
~B1SD();
G4bool ProcessHits(G4Step* step, G4TouchableHistory* ROhist);
void Initialize(G4HCofThisEvent* HCE);
//void EndOfEvent(G4HCofThisEvent* HCE);
private:
B1HitsCollection* hitCollection;
G4int HCID;
};
#endif
#include "B1SD.hh"
#include "G4HCofThisEvent.hh"
#include "G4TouchableHistory.hh"
#include "G4Track.hh"
#include "G4Step.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
B1SD::B1SD(G4String SDname): G4VSensitiveDetector(SDname),
hitCollection(nullptr), HCID(-1) {
G4cout << "Criando Hit Collection com nome: " << SDname <<G4endl;
collectionName.insert("HitCollection");
}
B1SD::~B1SD() {
}
G4bool B1SD::ProcessHits(G4Step* step, G4TouchableHistory* ROhist) {
G4TouchableHandle touchable = step->GetPreStepPoint()->GetTouchableHandle();
B1Hits* hit = new B1Hits();
hit->get_track(step);
hitCollection->insert(hit);
return true;
}
void B1SD::Initialize(G4HCofThisEvent* HCE) {
hitCollection = new B1HitsCollection(SensitiveDetectorName,collectionName[0]);
static G4int HCID = -1;
if (HCID < 0) HCID = GetCollectionID(0);
HCE->AddHitsCollection(HCID, hitCollection);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment