Structural analysis of molecular nanostructures and thin films