GEMC  1.8
Geant4 Monte-Carlo Framework
RICH_hitprocess.cc
Go to the documentation of this file.
1 // %%%%%%%%%%
2 // G4 headers
3 // %%%%%%%%%%
4 #include "G4UnitsTable.hh"
5 #include "G4Poisson.hh"
6 #include "Randomize.hh"
7 
8 // %%%%%%%%%%%%%
9 // gemc headers
10 // %%%%%%%%%%%%%
11 #include "RICH_hitprocess.h"
12 
14 {
15  PH_output out;
16  out.identity = aHit->GetId();
17  int sector = out.identity[0].id;
18  int pad = out.identity[1].id;
19  HCname = "RICH Hit Process";
20 
21  // %%%%%%%%%%%%%%%%%%%
22  // Raw hit information
23  // %%%%%%%%%%%%%%%%%%%
24  int nsteps = aHit->GetPos().size();
25 
26  // Get Total Energy deposited
27  double Etot = 0;
28  vector<G4double> Edep = aHit->GetEdep();
29  for(int s=0; s<nsteps; s++) Etot = Etot + Edep[s];
30  if(nsteps>1)cout << "ATT nsteps " << nsteps << endl;
31 
32  // average global, local positions of the hit
33  double x, y, z;
34  double lx, ly, lz;
35  x = y = z = lx = ly = lz = 0;
36  vector<G4ThreeVector> pos = aHit->GetPos();
37  vector<G4ThreeVector> Lpos = aHit->GetLPos();
38 
39  if(Etot>0)
40  {
41  for(int s=0; s<nsteps; s++)
42  {
43  x = x + pos[s].x()*Edep[s]/Etot;
44  y = y + pos[s].y()*Edep[s]/Etot;
45  z = z + pos[s].z()*Edep[s]/Etot;
46  lx = lx + Lpos[s].x()*Edep[s]/Etot;
47  ly = ly + Lpos[s].y()*Edep[s]/Etot;
48  lz = lz + Lpos[s].z()*Edep[s]/Etot;
49  }
50  }
51  else
52  {
53  x = pos[0].x();
54  y = pos[0].y();
55  z = pos[0].z();
56  lx = Lpos[0].x();
57  ly = Lpos[0].y();
58  lz = Lpos[0].z();
59  }
60 
61  // average time
62  double time = 0;
63  vector<G4double> times = aHit->GetTime();
64  for(int s=0; s<nsteps; s++) time = time + times[s]/nsteps;
65 
66  // Energy of the track
67  double Ene = aHit->GetE();
68 
69  cout << " RICHhit: " << aHit->GetPID()
70  << " " << Ene << " " << sector << " " << pad << " " << x << " " << y << " " << z
71  << " " << lx << " " << ly << " " << lz << endl;
72 
73  out.raws.push_back(Etot);
74  out.raws.push_back(x);
75  out.raws.push_back(y);
76  out.raws.push_back(z);
77  out.raws.push_back(lx);
78  out.raws.push_back(ly);
79  out.raws.push_back(lz);
80  out.raws.push_back(time);
81  out.raws.push_back((double) aHit->GetPID());
82  out.raws.push_back(aHit->GetVert().getX());
83  out.raws.push_back(aHit->GetVert().getY());
84  out.raws.push_back(aHit->GetVert().getZ());
85  out.raws.push_back(Ene);
86  out.raws.push_back((double) aHit->GetmPID());
87  out.raws.push_back(aHit->GetmVert().getX());
88  out.raws.push_back(aHit->GetmVert().getY());
89  out.raws.push_back(aHit->GetmVert().getZ());
90 
91  // %%%%%%%%%%%%
92  // Digitization
93  // %%%%%%%%%%%%
94 
95  // Ahmed El Alaoui, May, 2010
96  out.dgtz.push_back(sector);
97  out.dgtz.push_back(pad);
98 
99  return out;
100 }
101 
102 
103 #include "G4VVisManager.hh"
104 #include "G4Circle.hh"
105 #include "G4VisAttributes.hh"
106 #include "G4ParticleTable.hh"
107 
108 vector<identifier> RICH_HitProcess :: ProcessID(vector<identifier> id, G4Step* aStep, detector Detector, gemc_opts Opt)
109 {
110  vector<identifier> id2 = id;
111 
112  G4StepPoint *prestep = aStep->GetPreStepPoint();
113  G4ThreeVector xyz = aStep->GetPostStepPoint()->GetPosition();
114  G4ThreeVector Lxyz = prestep->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(xyz);
115  const double xpos = Lxyz.x();
116  const double ypos = Lxyz.y();
117  const double Energy = aStep->GetTrack()->GetTotalEnergy()/eV;
118 
119  // H8500 specs:
120  static const int nbins=15;
121  static const double p[nbins]={1.86, 1.96, 2.03, 2.13, 2.28, 2.37, 2.48, 2.59, 2.71, 3.11, 3.37, 3.73, 4.13, 4.39, 4.64};
122  static const double q[nbins]={0.0002, 0.002, 0.007, 0.02, 0.04, 0.08, 0.13, 0.17, 0.20, 0.26, 0.27, 0.28, 0.22, 0.18, 0.10};
123  static const int NIPXL = 8;
124  static const int NJPXL = 8;
125  static const double PhCsize_x(49);
126  static const double PhCsize_y(49);
127  static const double PXLDeadSpace_x(0.15);
128  static const double PXLDeadSpace_y(0.15);
129  static const double PXLsize_x((PhCsize_x-7*PXLDeadSpace_x)/8);
130  static const double PXLsize_y((PhCsize_y-7*PXLDeadSpace_y)/8);
131 
132  //shift the local reference center to down left corner
133  const double new_xpos = xpos+PhCsize_x/2.;
134  const double new_ypos = ypos+PhCsize_y/2.;
135 
136  //find the pixel row
137  const int iPMT = (int) floor(new_xpos/(PXLDeadSpace_x+PXLsize_x))+1;
138  const double lx = new_xpos -(iPMT-1)*(PXLDeadSpace_x+PXLsize_x);
139 
140  //find the pixel column
141  const int jPMT = (int) floor(new_ypos/(PXLDeadSpace_y+PXLsize_y))+1;
142  const double ly = new_ypos -(jPMT-1)*(PXLDeadSpace_y+PXLsize_y);
143 
144  // find the pixel number
145  int ijPMT = NIPXL*(NJPXL-jPMT) + iPMT;
146 
147  // photon hit the dead space:
148  if(lx>PXLsize_x || ly>PXLsize_y)
149  {
150  ijPMT = 0;
151  }
152  else
153  {
154  // pixel# += 100 if fails quauntum efficiency:
155  double QE = -1;
156  if(Energy > p[0] || Energy <= p[nbins-1])
157  {
158  for(int ie=0; ie<nbins-1; ie++)
159  {
160  if(Energy > p[ie] && Energy <= p[ie+1])
161  {
162  QE = q[ie] + (Energy-p[ie])*(q[ie+1]-q[ie])/(p[ie+1]-p[ie]);
163  if(G4UniformRand()>QE)
164  {
165  ijPMT += 100;
166  }
167  break;
168  }
169  }
170  }
171  }
172 
173  G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
174  if(pVVisManager)
175  {
176  if (ijPMT<100)
177  {
178  // All hits are already colored green by MHit.cc. Here,
179  // draw white circle for photons that hit dead area, and
180  // red circle for photons that pass QE.
181  G4Circle circle(xyz);
182  circle.SetFillStyle(G4Circle::filled);
183  circle.SetScreenSize(8);
184  if (ijPMT>0)
185  {
186  G4Colour colour_touch (1.0, 0.0, 0.0);
187  circle.SetVisAttributes(G4VisAttributes(colour_touch));
188  }
189  pVVisManager->Draw(circle);
190  }
191  }
192 
193  id2[2].id = ijPMT;
194  id2[2].id_sharing = 1;
195  return id2;
196 }
PH_output ProcessHit(MHit *, gemc_opts)
Method to process the hit.
G4ThreeVector GetVert()
Definition: MHit.h:72
vector< double > raws
Raw information.
Definition: MPHBaseClass.h:26
int GetPID()
Definition: MHit.h:107
int GetmPID()
Definition: MHit.h:122
vector< identifier > GetId()
Definition: MHit.h:96
string HCname
Hit Collection name.
Definition: MPHBaseClass.h:41
G4ThreeVector GetmVert()
Definition: MHit.h:127
vector< identifier > ProcessID(vector< identifier >, G4Step *, detector, gemc_opts)
Method to calculate new identifier.
vector< identifier > identity
Identifier.
Definition: MPHBaseClass.h:28
vector< G4ThreeVector > GetLPos()
Definition: MHit.h:69
double GetE()
Definition: MHit.h:89
vector< G4ThreeVector > GetPos()
Definition: MHit.h:65
Definition: MHit.h:29
vector< double > GetTime()
Definition: MHit.h:82
vector< double > GetEdep()
Definition: MHit.h:76
vector< int > dgtz
Digitized information.
Definition: MPHBaseClass.h:27