Simulation and tracking algorithm of an Active Target Time Projection Chamber (AT-TPC)