GEMC  2.3
Geant4 Monte-Carlo Framework
ltcc_hitprocess.cc
Go to the documentation of this file.
1 // G4 headers
2 #include "G4MaterialPropertyVector.hh"
3 #include "Randomize.hh"
4 
5 // gemc headers
6 #include "ltcc_hitprocess.h"
7 
8 // C++ headers
9 #include <set>
10 
11 map<string, double> ltcc_HitProcess :: integrateDgt(MHit* aHit, int hitn)
12 {
13  map<string, double> dgtz;
14 
15  // we want to crash if identity doesn't have size 3
16  vector<identifier> identity = aHit->GetId();
17  int idsector = identity[0].id;
18  int idside = identity[1].id;
19  int idsegment = identity[2].id;
20  int thisPid = aHit->GetPID();
21 
22  trueInfos tInfos(aHit);
23 
24  // if anything else than a photon hits the PMT
25  // the nphe is the particle id
26  // and identifiers are negative
27  // this should be changed, what if we still have a photon later?
28  dgtz["sector"] = -idsector;
29  dgtz["side"] = -idside;
30  dgtz["segment"] = -idsegment;
31  dgtz["nphe"] = thisPid;
32  dgtz["time"] = tInfos.time;
33  dgtz["hitn"] = hitn;
34 
35 
36  // if the particle is not an opticalphoton return bank filled with negative identifiers
37  if(thisPid != 0)
38  return dgtz;
39 
40 
41  vector<int> tids = aHit->GetTIds(); // track ID at EACH STEP
42  vector<int> pids = aHit->GetPIDs(); // particle ID at EACH STEP
43  vector<double> Energies = aHit->GetEs(); // energy of the photon as it reach the pmt
44 
45 
46  map<int, double> penergy; // key is track id
47 
48  for(unsigned int s=0; s<tids.size(); s++)
49  {
50  // only insert the first step of each track
51  // (i.e. if the map is empty
52  if(penergy.find(tids[s]) == penergy.end())
53  penergy[tids[s]] = Energies[s];
54  }
55 
56  int narrived = 0;
57  int ndetected = 0;
58 
59  // If the detector corresponding to this hit has a material properties table with "Efficiency" defined:
60  G4MaterialPropertiesTable* MPT = aHit->GetDetector().GetLogical()->GetMaterial()->GetMaterialPropertiesTable();
61  G4MaterialPropertyVector* efficiency = NULL;
62 
63  bool gotefficiency = false;
64  if( MPT != NULL )
65  {
66  efficiency = (G4MaterialPropertyVector*) MPT->GetProperty("EFFICIENCY");
67  if( efficiency != NULL ) gotefficiency = true;
68  }
69 
70  for( unsigned int iphoton = 0; iphoton<penergy.size(); iphoton++ )
71  {
72  //loop over all unique photons contributing to the hit:
73  if( gotefficiency )
74  {
75  // If the material of this detector has a material properties table
76  // with "EFFICIENCY" defined, then "detect" this photon with probability = efficiency
77  bool outofrange = false;
78  if( G4UniformRand() <= efficiency->GetValue( penergy[tids[iphoton]], outofrange ) )
79  ndetected++;
80 
81  narrived++;
82 
83  if( verbosity > 4 )
84  {
85  cout << log_msg << " Found efficiency definition for material "
86  << aHit->GetDetector().GetLogical()->GetMaterial()->GetName()
87  << ": (Ephoton, efficiency)=(" << penergy[tids[iphoton]] << ", "
88  << ( (G4MaterialPropertyVector*) efficiency )->GetValue( penergy[tids[iphoton]], outofrange )
89  << ")" << endl;
90  }
91  }
92  else
93  {
94  // No efficiency definition, "detect" all photons
95  ndetected++;
96  }
97  }
98 
99 
100  dgtz["sector"] = idsector;
101  dgtz["side"] = idside;
102  dgtz["segment"] = idsegment;
103  dgtz["nphe"] = narrived;
104  dgtz["npheD"] = ndetected;
105  dgtz["time"] = tInfos.time;
106  dgtz["hitn"] = hitn;
107 
108 
109  return dgtz;
110 
111 }
112 
113 
114 vector<identifier> ltcc_HitProcess :: processID(vector<identifier> id, G4Step *step, detector Detector)
115 {
116  id[id.size()-1].id_sharing = 1;
117  return id;
118 }
119 
120 
121 
122 map< string, vector <int> > ltcc_HitProcess :: multiDgt(MHit* aHit, int hitn)
123 {
124  map< string, vector <int> > MH;
125  return MH;
126 }
127 
128 
129 
130 
131 
132 
G4LogicalVolume * GetLogical()
Returns Logical Volume pointer.
Definition: detector.h:113
double verbosity
Definition: HitProcess.h:120
int GetPID()
Definition: Hit.h:111
vector< identifier > GetId()
Definition: Hit.h:103
map< string, vector< int > > multiDgt(MHit *, int)
double time
Definition: HitProcess.h:43
string log_msg
Definition: HitProcess.h:121
Definition: Hit.h:22
vector< double > GetEs()
Definition: Hit.h:97
vector< int > GetTIds()
Definition: Hit.h:101
vector< int > GetPIDs()
Definition: Hit.h:112
vector< identifier > processID(vector< identifier >, G4Step *, detector)
detector GetDetector()
Definition: Hit.h:108
map< string, double > integrateDgt(MHit *, int)