Joined the left traffic pattern at a controlled field downwind. Controller informed me I was number three for landing. Saw traffic on final, turned base, reported to tower "following cessna on final". Controller comes back a minute later and realizes I cut off a plane on final and I was now number two (my mistake here. I realize now, I think, I should have not maneuvered at all unless I was 100% sure I could see planes 1 and 2 on final). Controller tells me to rejoin the downwind. At this point, I was still on the base, so I turned right to rejoin the downwind and the plane behind me that was on final passes too close below me while I am executing a turn from base back to the downwind. Didn't seem safe. In fact, as soon as the controller told me to rejoin the downwind, that didn't seem safe. I am not sure what I should have done. I could have A) had more situation awareness and turned left to get back to the downwind B) called for a go around (on a base?), moved to the upwind leg (not departure) and rejoined the pattern. C) the controller should have told the plane on final that was behind me to get out of the patter by going around to the upwind leg.
I realize I caused this issue by maneuvering to base following the wrong plane. Like most aircraft incidents, it is usually a combination of factors. I caused the first, did I cause the second? Should I have called for a go around. What should the controller have done?
In the future, I can fix my issue. But what do you do if you are cutting off for whatever reason a plane on final, while you are on base. What is the safe way to get out of the situation. Ideas? Thanks