[807] | 1 | // %%%%%%%%%% |
---|
| 2 | // G4 headers |
---|
| 3 | // %%%%%%%%%% |
---|
| 4 | #include "G4UnitsTable.hh" |
---|
| 5 | |
---|
| 6 | // %%%%%%%%%%%%% |
---|
| 7 | // gemc headers |
---|
| 8 | // %%%%%%%%%%%%% |
---|
| 9 | #include "OTOF_hitprocess.h" |
---|
| 10 | |
---|
| 11 | PH_output OTOF_HitProcess :: ProcessHit(MHit* aHit, gemc_opts) |
---|
| 12 | { |
---|
| 13 | PH_output out; |
---|
| 14 | out.identity = aHit->GetId(); |
---|
| 15 | HCname = "OTOF Hit Process"; |
---|
| 16 | |
---|
| 17 | // %%%%%%%%%%%%%%%%%%% |
---|
| 18 | // Raw hit information |
---|
| 19 | // %%%%%%%%%%%%%%%%%%% |
---|
| 20 | int nsteps = aHit->GetPos().size(); |
---|
| 21 | |
---|
| 22 | // Get Total Energy deposited |
---|
| 23 | double Etot = 0; |
---|
| 24 | vector<G4double> Edep = aHit->GetEdep(); |
---|
| 25 | for(int s=0; s<nsteps; s++) Etot = Etot + Edep[s]; |
---|
| 26 | |
---|
| 27 | // average global, local positions of the hit |
---|
| 28 | double x, y, z; |
---|
| 29 | double lx, ly, lz; |
---|
| 30 | x = y = z = lx = ly = lz = 0; |
---|
| 31 | vector<G4ThreeVector> pos = aHit->GetPos(); |
---|
| 32 | vector<G4ThreeVector> Lpos = aHit->GetLPos(); |
---|
| 33 | |
---|
| 34 | if(Etot>0) |
---|
| 35 | for(int s=0; s<nsteps; s++) |
---|
| 36 | { |
---|
| 37 | x = x + pos[s].x()*Edep[s]/Etot; |
---|
| 38 | y = y + pos[s].y()*Edep[s]/Etot; |
---|
| 39 | z = z + pos[s].z()*Edep[s]/Etot; |
---|
| 40 | lx = lx + Lpos[s].x()*Edep[s]/Etot; |
---|
| 41 | ly = ly + Lpos[s].y()*Edep[s]/Etot; |
---|
| 42 | lz = lz + Lpos[s].z()*Edep[s]/Etot; |
---|
| 43 | } |
---|
| 44 | else |
---|
| 45 | { |
---|
| 46 | x = pos[0].x(); |
---|
| 47 | y = pos[0].y(); |
---|
| 48 | z = pos[0].z(); |
---|
| 49 | lx = Lpos[0].x(); |
---|
| 50 | ly = Lpos[0].y(); |
---|
| 51 | lz = Lpos[0].z(); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | // average time |
---|
| 55 | double time = 0; |
---|
| 56 | vector<G4double> times = aHit->GetTime(); |
---|
| 57 | for(int s=0; s<nsteps; s++) time = time + times[s]/nsteps; |
---|
| 58 | |
---|
| 59 | // Energy of the track |
---|
| 60 | double Ene = aHit->GetE(); |
---|
| 61 | |
---|
| 62 | out.raws.push_back(Etot); |
---|
| 63 | out.raws.push_back(x); |
---|
| 64 | out.raws.push_back(y); |
---|
| 65 | out.raws.push_back(z); |
---|
| 66 | out.raws.push_back(lx); |
---|
| 67 | out.raws.push_back(ly); |
---|
| 68 | out.raws.push_back(lz); |
---|
| 69 | out.raws.push_back(time); |
---|
| 70 | out.raws.push_back((double) aHit->GetPID()); |
---|
| 71 | out.raws.push_back(aHit->GetVert().getX()); |
---|
| 72 | out.raws.push_back(aHit->GetVert().getY()); |
---|
| 73 | out.raws.push_back(aHit->GetVert().getZ()); |
---|
| 74 | out.raws.push_back(Ene); |
---|
| 75 | out.raws.push_back((double) aHit->GetmPID()); |
---|
| 76 | out.raws.push_back(aHit->GetmVert().getX()); |
---|
| 77 | out.raws.push_back(aHit->GetmVert().getY()); |
---|
| 78 | out.raws.push_back(aHit->GetmVert().getZ()); |
---|
| 79 | |
---|
| 80 | // %%%%%%%%%%%% |
---|
| 81 | // Digitization |
---|
| 82 | // %%%%%%%%%%%% |
---|
| 83 | |
---|
| 84 | // Get the paddle length: in TOF paddles are boxes, it's the x |
---|
| 85 | double length = aHit->GetDetector().dimensions[0]; |
---|
| 86 | |
---|
| 87 | // Distances from left, right |
---|
| 88 | double dLeft = length + lx; |
---|
| 89 | double dRight = length - lx; |
---|
| 90 | |
---|
| 91 | // dummy formulas for now, parameters could come from DB |
---|
| 92 | int ADCL = (int) (100*Etot*exp(-dLeft/length/2 )); |
---|
| 93 | int ADCR = (int) (100*Etot*exp(-dRight/length/2 )); |
---|
| 94 | |
---|
| 95 | // speed of light is 30 cm/s |
---|
| 96 | int TDCL = (int) (100*(time/ns + dLeft/cm/30.0)); |
---|
| 97 | int TDCR = (int) (100*(time/ns + dRight/cm/30.0)); |
---|
| 98 | |
---|
| 99 | out.dgtz.push_back(ADCL); |
---|
| 100 | out.dgtz.push_back(ADCR); |
---|
| 101 | out.dgtz.push_back(TDCL); |
---|
| 102 | out.dgtz.push_back(TDCR); |
---|
| 103 | |
---|
| 104 | return out; |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | vector<identifier> OTOF_HitProcess :: ProcessID(vector<identifier> id, G4Step* aStep, detector Detector) |
---|
| 108 | { |
---|
| 109 | return id; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | |
---|