Here's one way to determine if a class is mapped (i.e. it is in a package whose definitions come from a database other than the default code database for the current namespace):
SAMPLES>w ##class(%Library.RoutineMgr).IsMapped("Cinema.Film.cls") 0 SAMPLES>w ##class(%Library.RoutineMgr).IsMapped("%iKnow.Objects.Source.cls") 1 SAMPLES>
If you pass a by-ref second argument to IsMapped you can also discover what database the class definition is stored in: