Project

General

Profile

Reconstruction corrections

Correcting for space charge

Your fcl file needs to have:
services.SpaceCharge.EnableCorrSCE: true
services.SpaceCharge.EnableSimEfieldSCE: true
services.SpaceCharge.EnableSimSpatialSCE: true

Then if you have for example an MCParticle called mcp, the following in your code should correct the position for space charge (From Giuseppe):
auto scecorr = SCE->GetPosOffsets(geo::Point_t(mcp->Vx(),mcp->Vy(),mcp->Vz()));
double g4Ticks = detClocks->TPCG4Time2Tick(mcp->T())+theDetector->GetXTicksOffset(0,0,0)-theDetector->TriggerOffset();
double xOffset = theDetector->ConvertTicksToX(g4Ticks, 0, 0, 0)-scecorr.X();
double yOffset = scecorr.Y();
double zOffset = scecorr.Z();
Point_t mcpos(mcp->Vx()+xOffset,mcp->Vy()+yOffset,mcp->Vz()+zOffset);