I wasn't entirely sure how to ask this question, so I'll use visual references.
Please look at this piano roll picture: the green "blocks" represent the notes of a melody, the purple ones - the hits of the snare, and the orange ones - the hits of the kick drum. The tempo of the song is 158 BPM, and the vertical red lines represent each beat of the metronome.
Now, my question is: is the melody aligned well with the drums? If so, what makes it so? If not, how would the "blocks" need to be moved? Must each of these vertical lines mark the beginning of a new note in order for this to be OK? What if that messes up my melody? Would I have to rearrange the drum beat pattern if I wanted to keep this melody? Where can I read up on the theory behind this?
Thanks for your help!