Principally, there are two types of cosmic rays – primary and secondary. For the primary cosmic rays, these cosmic particles come from extrasolar astrophysical sources such as supernova explosions and black holes. The primary cosmic ray particles can then travel through space, colliding with the interstellar matter to produce the secondary cosmic rays. The sun also produces relatively low energetic particles from the stellar nucleosynthesis that is related to the so-called “solar wind”.
Because cosmic ray particles are charged, as they pass through any object with magnetic field including earth’s magnetic field, their trajectory is bent and hence randomizing their path, making it impossible to determine the particle’s origin.
Studies of high-energy gamma rays (between 10MeV to 1000MeV) emitted when a cosmic ray collide with interstellar gas atoms indicated that most of the cosmic ray particles are confined at the rim of the galaxy, probably due to the galactic magnetic field. The collision between cosmic rays with light elements also produces nuclear fragments of radioactive isotopes such as Beryllium-10 which possess a half-life of 1.6 million years. By measuring the composition percentage of Beryllium-10 in cosmic rays shows that on average, cosmic ray particles spends about 10 million years in the outer ring of the galaxy before going into intergalactic space.