Ideally a rear dérailleur hanger alignment tool is required. However if a tool is not available it can be adjusted manually by pulling the dérailleur with ones hand away from the cassette until the dérailleur is perpendicular to the ground. The stock hanger is very soft and can be bent several times. In the below images we use a Park DAG-1 too to straighten the hanger. We remove the dérailleur, then use the tool to check if it aligned properly, if it is misaligned we will use the tool to bend it back into place and repeat until finished.
From geometry we know two points define a line, and three points define a plane. Our goal is to place the hanger on a parallel plane with respect to the cassette. We will use the tool to place the hanger on a parallel plane as the rim. We will assume the rim and cassette are on parallel planes. We will use the DAG-1 tool to measure the distance from the rim at 3 different points and bend the hanger until the distance from three points to the rim is the same.
Step #1 Check the rear dérailleur hanger. Sometimes one can visually see the hanger is bent.
Step #2 Remove rear dérailleur from the hanger with an allen wrench.
Step #3 Picture of rear dérailleur removed
Step #4 View of the hanger with dérailleur removed.
Step #5 Install the DAG-1 hanger tool onto the hanger as shown
Step #6 Test the distance from the DAG-1 tool to the rim at three points ( three points define a plane ). If ths distance is the same the hanger is in the proper plane and the job is done.
Step #7 If the distances are not the same at all points around the rim.use the tool as a lever bending the hanger to make the distances closer. Repeat this step #6 & #7 as often as needed until the distances are the same.
If you do not have a DAG-1 tool, you can try to straigten the hanger by applying force to the rear derailleur. It is very easy to do by hand, but one should have confidence before attempting....since bending the hanger many times will weaken it.