Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DetectorSD.hh"
- #include "G4HCofThisEvent.hh"
- #include "G4Step.hh"
- #include "G4Run.hh"
- #include "G4ThreeVector.hh"
- #include "G4SDManager.hh"
- #include "G4ios.hh"
- void DetectorSD::SetContagens (int _ent)
- {
- contagens = _ent;
- }
- int DetectorSD::GetContagens ()
- {
- return (contagens);
- }
- DetectorSD::DetectorSD(G4String name)
- :G4VSensitiveDetector(name)
- {
- G4String HCname;
- collectionName.insert(name);
- }
- //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
- DetectorSD::~DetectorSD(){
- }
- //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
- void DetectorSD::Initialize(G4HCofThisEvent* HCE)
- {
- ///cada thread gera hitcollection[0]
- //// Nome do detector : Detector
- DetectorCollection = new DetectorHitsCollection (SensitiveDetectorName,collectionName[0]);
- static G4int HCID = -1;
- if(HCID<0)
- {
- HCID = GetCollectionID(0);
- }
- HCE->AddHitsCollection( HCID, DetectorCollection );
- }
- //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
- G4bool DetectorSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
- {
- //G4double edep = -1*(aStep->GetDeltaEnergy())/CLHEP::keV; /// bremss
- // G4double edep = (aStep->GetPostStepPoint()->GetKineticEnergy())/CLHEP::keV; /// nao ve particulas
- /// menos energeticas
- G4double edep = aStep->GetPreStepPoint()->GetKineticEnergy()/CLHEP::keV; // o de sempre
- G4String particleName = aStep -> GetTrack() -> GetDynamicParticle() ->
- GetDefinition() -> GetParticleName();
- int detector ;
- if(edep==0.) return false;
- //if (particleName == "gamma" ||particleName == "e-" )
- if (particleName == "gamma" )
- {
- contagens+=1;
- DetectorHit* newHit = new DetectorHit();
- newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
- newHit->SetEdep (edep);
- newHit->SetPos (aStep->GetPostStepPoint()->GetPosition());
- // descomente para ver colisoes
- //G4cout << " colisao " << edep << " keV " << aStep->GetPostStepPoint()->GetPosition() <<G4endl;
- DetectorCollection->insert( newHit );
- }
- return true;
- }
- //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
- void DetectorSD::EndOfEvent(G4HCofThisEvent*)
- {
- if (verboseLevel>0) {
- G4int NbHits = DetectorCollection->entries();
- G4cout << "\n-------->Hits Collection: in this event they are " << NbHits
- << " hits in the Detector chambers: " << G4endl;
- for (G4int i=0;i<NbHits;i++) (*DetectorCollection)[i]->Print();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement