Hi, how to connect a UBEC on pixhawk for my 40A ESC?
and what kind of UBEC do I use?

Have you read the documentation? http://ardupilot.org/plane/docs/common-powering-the-pixhawk.html#common-powering-the-pixhawk

yes indeed, but the wiring diagram shows an exsample that has 4 in 1 esc with builtin bec

Sorry, I don’t see what you’re referring to. I see a diagram with a stand-alone BEC powering the servo rail. I think this should work for you. Do I not understand your question, perhaps?

Please note that on the above diagram it states ESCs not ESC so this block represents all of the ESCs present in the system.

You can use a BEC from an ESC, it has to be 5V though.
If your ESC has an UBEC (Switch mode voltage regulator) then connect a red wire from one and only one of the ESCs to the 5V rail.
If your ESC has a BEC (linear voltage regulator) you can connect all red wires from all ESCs to the rail, but I think it will be easier and safer to use just one as you do not know what will happen if one of many connected BECs dies.
To sum up, yes you can use a BEC from your ESC and in this case you do not need a separate BEC, you do always need the zener diode for protection (1N5339).