There are many different ways to achieve the same within the LHCb computing environment. This page collects examples on how one can write a selection.
This is probably the fastest way to achieve a Selection and allows to easily use the available tools. No packages need to be locally installed for this. The Introduction Tutorials for DaVinci explain how to do this. The python configuration is explained in Tutorial4
A basic step-by-step example is available under DaVinic Example
A more complex possibility is to write a C++ algorithm the Advanced Tutorials for DaVinci cover this.