(CNN) You feel happiness all the way down to your genes, scientists say. But the kind of happiness you're feeling matters, as different kinds can have wildly different effects on your physical well-being.

In fact, the happiness you get from instant gratification -- eating that giant cupcake or buying that fabulous pair of shoes -- may have the same physical impact on your genes as depression or stress, according to a groundbreaking study published in the Proceedings of the National Academy of Sciences.

"I've been studying the physical and psychological impact of positive emotion for 20 years, (and) the pattern of results we found with this study completely surprised me," said the lead author, Barbara Fredrickson

Fredrickson is a professor of psychology and the principal investigator of the Positive Emotions and Psychophysiology Lab at the University of North Carolina.

"I've known anecdotally that positive emotions impact us on a cellular level, but seeing these results have given us proof that there is a real difference in the kinds of happiness we feel and its potential long-term consequences."

The experts divide well-being into two different types: hedonic and eudaimonic. These are fancy words to describe happiness that comes from two different sources.

Hedonic well-being comes from an experience a person seeks out that gives them pleasure. As study co-author Steve Cole describes it, it's "having lots of positive experiences that come from, say, eating great food or smelling beautiful flowers."

Eudaimonic well-being is a kind of happiness that comes not from consuming something but from a sustained effort at working toward something bigger than you. In other words, it's working toward a sense of meaning in your life or contributing to some kind of cause. Think of the happiness you see on the Dalai Lama or Mother Teresa's face.

While the two kinds of happiness are conceptually different, they can and do influence each other, so it has been hard for scientists to measure which kind has had a greater positive influence on someone's physical or psychological well-being.

Cole, a professor of medicine, psychiatry and biobehavioral sciences at UCLA, studies the biological pathways by which social environments influence gene expression.

"I know what misery looks like on a genetic level," Cole said. "I can look at white blood cells and see a physical response to stress and misery, but we knew very little about how -- if at all -- positive psychology gets disseminated to the body. That's what this study does."

If you experience misery and stress, your genes react to it. Essentially, there is an increased expression of genes involved in inflammation and a decreased antiviral response. People who are subjected to long periods of stress have white blood cells that make slightly more pro-inflammatory proteins on a constant basis.

Inflammation is the first line of defense against infection, so that would be a very useful kind of protein to have; however, something that causes your body to create inflammation over a sustained amount of time can cause collateral damage to healthy tissue.

Colorado College microbiologist Phoebe Lostroh , who is not affiliated with the study but is familiar with its contents, explains it this way: "The immune system of someone stressed out is not at the normal level of green on the terrorism alert scale. Instead, it's on yellow or orange, if not all the way on red. So there's this low level of constant inflammation, which is not healthy."

Low levels of inflammation can cause exhaustion. They also increase a person's risk for cancer, heart disease and Alzheimer's and can damage various tissues wherever the white blood cells are causing inflammation where they shouldn't be, Lostroh said.

With this understanding in mind, the scientists in the new study took blood from 80 healthy adults who were screened for the two types of happiness. None of them reported being depressed or stressed.

Scientists extracted the RNA from their blood and took a closer look at the inflammatory and antiviral responses.

The study found that people who experienced the well-being that comes from self-gratification had high inflammation and low antiviral and antibody gene expression, a result similar to what people who are depressed or experience great stress have.

Tell us your story Tell us your story

We love to hear from our audience. Follow @CNNHealth on Twitter and Facebook for the latest health news and let us know what we're missing.

The people who found happiness by pursuing a greater good had a lower level of this inflammatory gene expression and strong antiviral and antibody gene expression.

Bottom line? Happiness that comes from working for the greater good has a much more positive genetic impact.

"Keep in mind positives go with both kinds of well-being," Fredrickson said. "But emotions you feel today ... really will effect who you are at a cellular level."

The study didn't get at why the two kinds of well-being have different genetic impacts, but Cole has a theory.

"Hedonic well-being is dependent on your taking self-involved action to constantly feed this positive emotion machine," he said. "If something threatens your ability to seek out this kind of personal happiness -- if you get injured, for instance, or you experience a loss -- your entire source of well-being is threatened. You are living closer to the edge of that kind of stress.

"But if you find well-being in the connections you have to others and in pursuing something that involves collaborating with other people, if in that circumstance you get sick or injured or suffer a personal loss, that community you've worked so hard to connect to, they will help you get through."