Is "real" or reality defined during childhood, or as adults? Is this caused by age, or an event?
Ability to distinguish reality from fantasy happens somewhere between 4 and 6. This is marked by the use of facts and evidence based research in deduction. This ability is gained through changes in the brain like increased cerebral volume, lateral ventricle volume, grey matter, white matter. Interesting the Mid-Sagittal Corpus Callosum also grows significantly during this time. The Corpus Callosum integrates signals from both sides of the brain but the Mid-Sagittal Corpus Callosum size has a negative correlation to IQ.
Anyone above age 6 who is unable to distinguish reality from fantasy based on evidence is maldeveloped. Some behaviors associated with fantasy, irrational behavior or spirituality are common throughout life. Spirituality would in this case involve any set of beliefs about God or the spirit or psychic realm which are not provable with evidence based observations by science. Irrational value and moral based systems are also normal. These beliefs are typically built on the foundation of spirituality. Some fantasy like beliefs about Santa and other non-spirit but magical creatures are also normal. Irrational behaviors like needing to double check to make sure the clothes iron is unplugged and doors are locked are also common. Problems arise and need to be treated when these types of behaviors begin to interfere with the life of the person experiencing the behavior or those surrounding.
In young adults psychosis result in mental illnesses marked by an inability to distinguish reality from hallucinations and delusions. Psychosis may be drug induced by hallucinogens like cocaine or occur because of a stress vulnerability to a mental illness. Schizo typical illnesses can range from the minute of hearing voices which are not really there with odd behavior to the extreme of becoming totally immersed in a delusional states of dream like trances and losing touch with reality. Psychosis caused by mental illness is correctable with anti-psychotics. Major sedatives which help alleviate the insomnia immediately and over the course of months correct the dopamine overdose thought to be caused by psychosis. Some people must remain on maintenance levels of anti-psychotics all their lives.