-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathdetector.cc
More file actions
86 lines (59 loc) · 2.3 KB
/
detector.cc
File metadata and controls
86 lines (59 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "detector.hh"
MySensitiveDetector::MySensitiveDetector(G4String name) : G4VSensitiveDetector(name)
{
quEff = new G4PhysicsOrderedFreeVector();
std::ifstream datafile;
datafile.open("eff.dat");
while(1)
{
G4double wlen, queff;
datafile >> wlen >> queff;
if(datafile.eof())
break;
G4cout << wlen << " " << queff << std::endl;
quEff->InsertValues(wlen, queff/100.);
}
datafile.close();
quEff->SetSpline(false);
}
MySensitiveDetector::~MySensitiveDetector()
{}
G4bool MySensitiveDetector::ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
{
G4Track *track = aStep->GetTrack();
//track->SetTrackStatus(fStopAndKill);
G4StepPoint *preStepPoint = aStep->GetPreStepPoint();
G4StepPoint *postStepPoint = aStep->GetPostStepPoint();
G4ThreeVector posPhoton = preStepPoint->GetPosition();
G4ThreeVector momPhoton = preStepPoint->GetMomentum();
G4double time = preStepPoint->GetGlobalTime();
G4double wlen = (1.239841939*eV/momPhoton.mag())*1E+03;
//G4cout << "Photon position: " << posPhoton << G4endl;
const G4VTouchable *touchable = aStep->GetPreStepPoint()->GetTouchable();
G4int copyNo = touchable->GetCopyNumber();
//G4cout << "Copy number: " << copyNo << G4endl;
G4VPhysicalVolume *physVol = touchable->GetVolume();
G4ThreeVector posDetector = physVol->GetTranslation();
#ifndef G4MULTITHREADED
//G4cout << "Detector position: " << posDetector << G4endl;
//G4cout << "Photon wavelength: " << wlen << G4endl;
#endif
G4int evt = G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
G4AnalysisManager *man = G4AnalysisManager::Instance();
man->FillNtupleIColumn(0, 0, evt);
man->FillNtupleDColumn(0, 1, posPhoton[0]);
man->FillNtupleDColumn(0, 2, posPhoton[1]);
man->FillNtupleDColumn(0, 3, posPhoton[2]);
man->FillNtupleDColumn(0, 4, time);
man->FillNtupleDColumn(0, 5, wlen);
man->AddNtupleRow(0);
if(G4UniformRand() < quEff->Value(wlen))
{
man->FillNtupleIColumn(1, 0, evt);
man->FillNtupleDColumn(1, 1, posDetector[0]);
man->FillNtupleDColumn(1, 2, posDetector[1]);
man->FillNtupleDColumn(1, 3, posDetector[2]);
man->AddNtupleRow(1);
}
return true;
}