WCSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WCSimSteppingAction.cc
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 
4 #include "WCSimSteppingAction.hh"
5 
6 #include "G4Track.hh"
7 #include "G4VProcess.hh"
8 #include "G4VParticleChange.hh"
9 #include "G4SteppingVerbose.hh"
10 #include "G4SteppingManager.hh"
11 #include "G4PVParameterised.hh"
12 #include "G4PVReplica.hh"
13 #include "G4SDManager.hh"
14 #include "G4RunManager.hh"
15 
16 
17 void WCSimSteppingAction::UserSteppingAction(const G4Step* aStep)
18 {
19  //DISTORTION must be used ONLY if INNERTUBE or INNERTUBEBIG has been defined in BidoneDetectorConstruction.cc
20 
21  const G4Event* evt = G4RunManager::GetRunManager()->GetCurrentEvent();
22 
23  const G4Track* track = aStep->GetTrack();
24  G4VPhysicalVolume* volume = track->GetVolume();
25 
26 
27  G4SDManager* SDman = G4SDManager::GetSDMpointer();
28  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
29 
30  //debugging
31 // G4Track* theTrack = aStep->GetTrack();
32 // const G4DynamicParticle* aParticle = theTrack->GetDynamicParticle();
33 // G4ThreeVector aMomentum = aParticle->GetMomentumDirection();
34 // G4double vx = aMomentum.x();
35 // G4int ix = std::isnan(vx);
36 // if(ix != 0){
37 // G4cout << " PROBLEM! " << theTrack->GetCreatorProcess()->GetProcessName() <<
38 // std::flush << G4endl;
39 // }
40 
41 }
42 
43 
45  G4ThreeVector lArPos,
46  G4ThreeVector start,
47  G4int i)
48 {
49  G4double x0 = start[0]-lArPos[0];
50  G4double y0 = start[1]-lArPos[1];
51 // G4double y0 = 2121.3;//mm
52  G4double z0 = start[2]-lArPos[2];
53 
54  G4double dt=0.8;//mm
55 // G4double midt = 2651.625;
56  G4double pitch = 3;//mm
57 // G4double midwir = 1207.10;
58  G4double c45 = 0.707106781;
59  G4double s45 = 0.707106781;
60 
61  G4double w1;
62  G4double w2;
63  G4double t;
64 
65 // G4double xField(0.);
66 // G4double yField(0.);
67 // G4double zField(0.);
68 
69 // if(detector->getElectricFieldDistortion())
70 // {
71 // Distortion(pos3d->getX(),
72 // pos3d->getY());
73 
74 // xField = ret[0];
75 // yField = ret[1];
76 // zField = pos3d->getZ();
77 
78 // w1 = (int)(((zField+z0)*c45 + (x0-xField)*s45)/pitch);
79 // w2 = (int)(((zField+z0)*c45 + (x0+xField)*s45)/pitch);
80 // t = (int)(yField+1);
81 
82 // //G4cout<<" x orig "<<pos3d->getX()<<" y orig "<<(pos3d->getY()+y0)/dt<<G4endl;
83 // //G4cout<<" x new "<<xField<<" y new "<<yField<<G4endl;
84 // }
85 // else
86 // {
87 
88  w1 = (int) (((pos3d->getZ()+z0)*c45 + (x0-pos3d->getX())*s45)/pitch);
89  w2 = (int)(((pos3d->getZ()+z0)*c45 + (x0+pos3d->getX())*s45)/pitch);
90  t = (int)((pos3d->getY()+y0)/dt +1);
91 // }
92 
93  if (i==0)
94  return (int)w1;
95  else if (i==1)
96  return (int)w2;
97  else if (i==2)
98  return (int)t;
99  else return 0;
100 }
101 
102 
103 void WCSimSteppingAction::Distortion(G4double /*x*/,G4double /*y*/)
104 {
105 
106 // G4double theta,steps,yy,y0,EvGx,EvGy,EField,velocity,tSample,dt;
107 // y0=2121.3;//mm
108 // steps=0;//1 mm steps
109 // tSample=0.4; //micros
110 // dt=0.8;//mm
111 // LiquidArgonMedium medium;
112 // yy=y;
113 // while(y<y0 && y>-y0 )
114 // {
115 // EvGx=FieldLines(x,y,1);
116 // EvGy=FieldLines(x,y,2);
117 // theta=atan(EvGx/EvGy);
118 // if(EvGy>0)
119 // {
120 // x+=sin(theta);
121 // y+=cos(theta);
122 // }
123 // else
124 // {
125 // y-=cos(theta);
126 // x-=sin(theta);
127 // }
128 // EField=sqrt(EvGx*EvGx+EvGy*EvGy);//kV/mm
129 // velocity=medium.DriftVelocity(EField*10);// mm/microsec
130 // steps+=1/(tSample*velocity);
131 
132 // //G4cout<<" step "<<steps<<" x "<<x<<" y "<<y<<" theta "<<theta<<" Gx "<<eventaction->Gx->Eval(x,y)<<" Gy "<<eventaction->Gy->Eval(x,y)<<" EField "<<EField<<" velocity "<<velocity<<G4endl;
133 // }
134 
135 // //numbers
136 // //EvGx=FieldLines(0,1000,1);
137 // //EvGy=FieldLines(0,1000,2);
138 // //EField=sqrt(EvGx*EvGx+EvGy*EvGy);//kV/mm
139 // //velocity=medium.DriftVelocity(EField*10);// mm/microsec
140 // //G4double quenching;
141 // //quenching=medium.QuenchingFactor(2.1,EField*10);
142 // //G4cout<<" Gx "<<EvGx<<" Gy "<<EvGy<<" EField "<<EField<<" velocity "<<velocity<<" quenching "<<quenching<<G4endl;
143 
144 
145 // ret[0]=x;
146 // if(yy>0)
147 // ret[1]=2*y0/dt -steps;
148 // else
149 // ret[1]=steps;
150 }
151 
152 
153 double WCSimSteppingAction::FieldLines(G4double /*x*/,G4double /*y*/,G4int /*coord*/)
154 { //0.1 kV/mm = field
155  //G4double Radius=302;//mm
156 // G4double Radius=602;//mm
157 // if(coord==1) //x coordinate
158 // return (0.1*(2*Radius*Radius*x*abs(y)/((x*x+y*y)*(x*x+y*y))));
159 // else //y coordinate
160 // return 0.1*((abs(y)/y)*(1-Radius*Radius/((x*x+y*y)*(x*x+y*y))) + abs(y)*(2*Radius*Radius*y/((x*x+y*y)*(x*x+y*y))));
161  return 0;
162 }
G4int G4ThreeVectorToWireTime(G4ThreeVector *pos3d, G4ThreeVector lArPos, G4ThreeVector start, G4int i)
void Distortion(G4double x, G4double y)
void UserSteppingAction(const G4Step *)
double start[MAX_N_PRIMARIES][3]
Definition: jhfNtuple.h:30
double t[MAX_N_ACTIVE_TUBES]
Definition: jhfNtuple.h:40
G4double FieldLines(G4double x, G4double y, G4int xy)