Systematic approach for tolerance analysis of photonic systems