Geology of the San Joaquin Valley
The San Joaquin Valley is actually what is called a forearc basin, and it was created in the Mesozoic Age (Dinosaur times) during subduction of the Farallon tectonic plate (oceanic crust) beneath the North American plate (continental crust). This subduction zone dipped to the east beneath the continent.
The San Joaquin forearc basin was bound to the west by a trench (i.e. the surface expression of the subduction zone), and uplifts along the inland trench margin represent the modern Coast Ranges. The valley was also bound to the east by a chain of volcanoes (i.e., a volcanic arc) that represents the ancient Sierra Nevadas. Thus, the San Joaquin Valley can be described as the remnant of an ancient arc-trench gap.
Throughout the Mesozoic and early Tertiary (Mammal times), there was normal eastward-directed subduction beneath the North American continent, but about 14 million years ago (Miocene) an offshore spreading center (part of the east Pacific rise) collided with the trench. This collision changed the plate motions and the trench was transformed into a right-lateral zone of shear that is represented by the modern San Andreas fault. Thus, we can say that the San Andreas fault is the sutre of the ancient trench.

About this time, the southernmost part of the Sierra Nevadan volcanic arc was broken off and rotated 90 degrees to form the east-west trending Transverse Ranges that today create the south boundary of the valley. Concurrent with this was tilting of the Sierra Nevadas to form a steep eastern scarp along the Owens Valley fault, and a sloping west side down which ancient streams flowed to deposit the gold-bearing (auriferous) gravels that prospectors mined duing the Gold Rush of 1849.
All the while, the volcanic cover of the Sierra Nevadas was being eroded off and dumped into the Valley below, thereby exposing the granitic roots of the volcanoes. The Coast Ranges, which represent uplifts along the San Andreas fault (the old subduction zone), were also being eroded. Thus, whereas the ancient arc-trench gap once held an inland sea, it was filled to create the inland basin that we know today as the San Joaquin Valley.
Plankton and other organisms that lived in the ancient San Joaquin sea accumulated on the floor of the arc-trench gap, and this organic matter is the source of the oil that the valley produces today. Simlarly, the eroded volcanic cover of the Sierra Nevadas, as well as the eroded tops of the Coast and Transverse Ranges, are the sources of the sandstones (reservoirs) that the oil is produced from.
