Noninvasive 3D characterization of layered samples using terahertz pulsed imaging and infrared optical coherence tomography