#include #include #include "WCSimSteppingAction.hh" #include "G4Track.hh" #include "G4VProcess.hh" #include "G4VParticleChange.hh" #include "G4SteppingVerbose.hh" #include "G4SteppingManager.hh" #include "G4PVParameterised.hh" #include "G4PVReplica.hh" #include "G4SDManager.hh" #include "G4RunManager.hh" void WCSimSteppingAction::UserSteppingAction(const G4Step* aStep) { //DISTORTION must be used ONLY if INNERTUBE or INNERTUBEBIG has been defined in BidoneDetectorConstruction.cc const G4Event* evt = G4RunManager::GetRunManager()->GetCurrentEvent(); const G4Track* track = aStep->GetTrack(); G4VPhysicalVolume* volume = track->GetVolume(); G4SDManager* SDman = G4SDManager::GetSDMpointer(); G4HCofThisEvent* HCE = evt->GetHCofThisEvent(); //debugging // G4Track* theTrack = aStep->GetTrack(); // const G4DynamicParticle* aParticle = theTrack->GetDynamicParticle(); // G4ThreeVector aMomentum = aParticle->GetMomentumDirection(); // G4double vx = aMomentum.x(); // G4int ix = std::isnan(vx); // if(ix != 0){ // G4cout << " PROBLEM! " << theTrack->GetCreatorProcess()->GetProcessName() << // std::flush << G4endl; // } } G4int WCSimSteppingAction::G4ThreeVectorToWireTime(G4ThreeVector *pos3d, G4ThreeVector lArPos, G4ThreeVector start, G4int i) { G4double x0 = start[0]-lArPos[0]; G4double y0 = start[1]-lArPos[1]; // G4double y0 = 2121.3;//mm G4double z0 = start[2]-lArPos[2]; G4double dt=0.8;//mm // G4double midt = 2651.625; G4double pitch = 3;//mm // G4double midwir = 1207.10; G4double c45 = 0.707106781; G4double s45 = 0.707106781; G4double w1; G4double w2; G4double t; // G4double xField(0.); // G4double yField(0.); // G4double zField(0.); // if(detector->getElectricFieldDistortion()) // { // Distortion(pos3d->getX(), // pos3d->getY()); // xField = ret[0]; // yField = ret[1]; // zField = pos3d->getZ(); // w1 = (int)(((zField+z0)*c45 + (x0-xField)*s45)/pitch); // w2 = (int)(((zField+z0)*c45 + (x0+xField)*s45)/pitch); // t = (int)(yField+1); // //G4cout<<" x orig "<getX()<<" y orig "<<(pos3d->getY()+y0)/dt<getZ()+z0)*c45 + (x0-pos3d->getX())*s45)/pitch); w2 = (int)(((pos3d->getZ()+z0)*c45 + (x0+pos3d->getX())*s45)/pitch); t = (int)((pos3d->getY()+y0)/dt +1); // } if (i==0) return (int)w1; else if (i==1) return (int)w2; else if (i==2) return (int)t; else return 0; } void WCSimSteppingAction::Distortion(G4double /*x*/,G4double /*y*/) { // G4double theta,steps,yy,y0,EvGx,EvGy,EField,velocity,tSample,dt; // y0=2121.3;//mm // steps=0;//1 mm steps // tSample=0.4; //micros // dt=0.8;//mm // LiquidArgonMedium medium; // yy=y; // while(y-y0 ) // { // EvGx=FieldLines(x,y,1); // EvGy=FieldLines(x,y,2); // theta=atan(EvGx/EvGy); // if(EvGy>0) // { // x+=sin(theta); // y+=cos(theta); // } // else // { // y-=cos(theta); // x-=sin(theta); // } // EField=sqrt(EvGx*EvGx+EvGy*EvGy);//kV/mm // velocity=medium.DriftVelocity(EField*10);// mm/microsec // steps+=1/(tSample*velocity); // //G4cout<<" step "<Gx->Eval(x,y)<<" Gy "<Gy->Eval(x,y)<<" EField "<0) // ret[1]=2*y0/dt -steps; // else // ret[1]=steps; } double WCSimSteppingAction::FieldLines(G4double /*x*/,G4double /*y*/,G4int /*coord*/) { //0.1 kV/mm = field //G4double Radius=302;//mm // G4double Radius=602;//mm // if(coord==1) //x coordinate // return (0.1*(2*Radius*Radius*x*abs(y)/((x*x+y*y)*(x*x+y*y)))); // else //y coordinate // 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)))); return 0; }