~tstainer/lbno-nd/master

« back to all changes in this revision

Viewing changes to src/simul/DetectorSD.cc

  • Committer: tstainer at ac
  • Date: 2013-01-17 22:04:04 UTC
  • Revision ID: tstainer@liv.ac.uk-20130117220404-3aekvcwtz3l0c0du
updates

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include "DetectorSD.hh"
 
3
 
 
4
#include "G4HCofThisEvent.hh"
 
5
#include "G4TouchableHistory.hh"
 
6
#include "G4Track.hh"
 
7
#include "G4Step.hh"
 
8
#include "G4ios.hh"
 
9
 
 
10
DetectorSD::DetectorSD(G4String name)
 
11
:G4VSensitiveDetector(name){
 
12
}
 
13
 
 
14
DetectorSD::~DetectorSD(){;}
 
15
 
 
16
void DetectorSD::Initialize(G4HCofThisEvent*HCE) {
 
17
 //std::cout << "This is LqArTankSensitiveDetector::Initialize " << nSteps_ << std::endl ;
 
18
  nSteps_ = 0;
 
19
  Edep_ = 0.;
 
20
 
 
21
  hit_->setEdep(Edep_);
 
22
  hit_->setNSteps(nSteps_);
 
23
  hit_->setPosition(TLorentzVector(0., 0., 0., 0.));
 
24
  hit_->setMuon(ParticleDescrShortRecord());
 
25
}
 
26
 
 
27
G4bool DetectorSD::ProcessHits(G4Step*aStep,G4TouchableHistory*) {
 
28
 
 
29
  G4Track* track = aStep->GetTrack();
 
30
 
 
31
if(nSteps_ == 0) {
 
32
    TLorentzVector pos( aStep->GetPreStepPoint()->GetPosition().x(),
 
33
                        aStep->GetPreStepPoint()->GetPosition().y(),
 
34
                        aStep->GetPreStepPoint()->GetPosition().z(), 0.);
 
35
 
 
36
    //muon
 
37
    ParticleDescrShortRecord muon;
 
38
    TLorentzVector p4( track->GetMomentum().x(),
 
39
                       track->GetMomentum().y(),
 
40
                       track->GetMomentum().z(),
 
41
                       track->GetTotalEnergy() );
 
42
    muon.setP4(p4);
 
43
    muon.setPDG( track->GetDefinition()->GetPDGEncoding() );
 
44
 
 
45
    //hit_->setPosition(pos);
 
46
    hit_->setMuon(muon);
 
47
 
 
48
    //fss particles
 
49
    //ParticleDescrShortRecord fss;
 
50
 
 
51
 
 
52
    Edep_ = aStep->GetTotalEnergyDeposit();
 
53
  } 
 
54
 
 
55
  else {
 
56
    Edep_ += aStep->GetTotalEnergyDeposit();
 
57
  }
 
58
 
 
59
  nSteps_++;
 
60
  return true;
 
61
}
 
62
 
 
63
void DetectorSD::EndOfEvent(G4HCofThisEvent* HCE){
 
64
   if (nSteps_) {
 
65
        hit_->setNSteps(nSteps_);
 
66
        hit_->setEdep(Edep_);
 
67
        }
 
68
}
 
69
 
 
70
void DetectorSD::clear()
 
71
{
 
72
 
73
 
 
74
void DetectorSD::DrawAll()
 
75
{
 
76
 
77
 
 
78
void DetectorSD::PrintAll()
 
79
{
 
80
 
81