How to run my python code when motion sensor is activated?

hello,
I just installed cayenne and the MQTT for python.
I would like to do something simple, but I can not do it:
I have a motion sensor on my raspberry in GPIO 7, and a buzzer in GPIO 14.
When my motion sensor is triggered, I would like to execute a code python that makes me a loop of sound on my buzzer.
How to link my code to the sensor ?
I watched several video but nowhere can I find the explanation,
help me plz

have a look at this post Take picture when motion with Pi 3 and Agent 2.0 CayenneMQTTClient() and notify by email - how to trigger a script on Pi 3