| [807] | 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 |
|
|---|
| 27 | #include "ExN04MuonSD.hh"
|
|---|
| 28 | #include "ExN04MuonHit.hh"
|
|---|
| 29 | #include "G4HCofThisEvent.hh"
|
|---|
| 30 | #include "G4TouchableHistory.hh"
|
|---|
| 31 | #include "G4Track.hh"
|
|---|
| 32 | #include "G4Step.hh"
|
|---|
| 33 | #include "G4ios.hh"
|
|---|
| 34 |
|
|---|
| 35 | ExN04MuonSD::ExN04MuonSD(G4String name)
|
|---|
| 36 | :G4VSensitiveDetector(name)
|
|---|
| 37 | {
|
|---|
| 38 | G4String HCname;
|
|---|
| 39 | collectionName.insert(HCname="muonCollection");
|
|---|
| 40 | positionResolution = 5*cm;
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | ExN04MuonSD::~ExN04MuonSD(){;}
|
|---|
| 44 |
|
|---|
| 45 | void ExN04MuonSD::Initialize(G4HCofThisEvent*HCE)
|
|---|
| 46 | {
|
|---|
| 47 | static int HCID = -1;
|
|---|
| 48 | muonCollection = new ExN04MuonHitsCollection
|
|---|
| 49 | (SensitiveDetectorName,collectionName[0]);
|
|---|
| 50 | if(HCID<0)
|
|---|
| 51 | { HCID = GetCollectionID(0); }
|
|---|
| 52 | HCE->AddHitsCollection(HCID,muonCollection);
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | G4bool ExN04MuonSD::ProcessHits(G4Step*aStep,G4TouchableHistory*)
|
|---|
| 56 | {
|
|---|
| 57 | G4double edep = aStep->GetTotalEnergyDeposit();
|
|---|
| 58 |
|
|---|
| 59 | if(edep==0.) return true;
|
|---|
| 60 |
|
|---|
| 61 | ExN04MuonHit* aHit;
|
|---|
| 62 | int nHit = muonCollection->entries();
|
|---|
| 63 | G4ThreeVector hitpos = aStep->GetPreStepPoint()->GetPosition();
|
|---|
| 64 | for(int i=0;i<nHit;i++)
|
|---|
| 65 | {
|
|---|
| 66 | aHit = (*muonCollection)[i];
|
|---|
| 67 | G4ThreeVector pos = aHit->GetPos();
|
|---|
| 68 | G4double dist2 = sqr(pos.x()-hitpos.x())
|
|---|
| 69 | +sqr(pos.y()-hitpos.y())+sqr(pos.z()-hitpos.z());
|
|---|
| 70 | if(dist2<=sqr(positionResolution))
|
|---|
| 71 | aHit->AddEdep(edep);
|
|---|
| 72 | return true;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | aHit = new ExN04MuonHit();
|
|---|
| 76 | aHit->SetEdep( edep );
|
|---|
| 77 | aHit->SetPos( aStep->GetPreStepPoint()->GetPosition() );
|
|---|
| 78 | muonCollection->insert( aHit );
|
|---|
| 79 |
|
|---|
| 80 | return true;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | void ExN04MuonSD::EndOfEvent(G4HCofThisEvent*)
|
|---|
| 84 | {;}
|
|---|
| 85 |
|
|---|
| 86 | void ExN04MuonSD::clear()
|
|---|
| 87 | {
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | void ExN04MuonSD::DrawAll()
|
|---|
| 91 | {
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | void ExN04MuonSD::PrintAll()
|
|---|
| 95 | {
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|