Gun sales surged across the country in the weeks after past mass shootings, such as in Orlando, Florida, San Bernardino, California, or Newtown, Connecticut. Some of the purchases were likely by people looking for more protection, but others were due to customers worried that tougher gun laws could be on the way. That pushed them to buy before the window potentially closed. And gun maker stocks rise in anticipation of the higher sales.

Many people might not even realize that these movements affect their investments. That's because many investors who never directly purchased shares of gun companies may nevertheless have them in their 401(k) accounts.

Here's a look at how that came to be and how the gun industry has been performing:

WHO OWNS GUN STOCKS?

The biggest owners of American Outdoor Brands and Sturm Ruger are fund giants Vanguard and BlackRock. Together, the pair owns more than a quarter of Sturm Ruger's shares and 22 percent of American Outdoor Brands, according to FactSet.

The fund managers aren't necessarily keen on the gun industry or its prospects. They run huge index funds that own every stock in their respective index. So BlackRock'siShares Core S&P Small Cap ETF keeps about 0.1 percent of its money invested in Sturm Ruger, because that's how much of the index the company accounts for.

Vanguard's Total Stock Market Index fund similarly keeps a sliver of its investments in Sturm Ruger, but the immense popularity of index funds means those tiny percentages nevertheless add up to big dollars. Vanguard's Total Stock Market Index fund is the largest fund by assets and controls more than $600 billion, which means it owns about $21 million of Sturm Ruger stock.

Many investors also own index funds without realizing it. More employers are automatically enrolling workers in the 401(k) account, and the default investment for many of them is an index fund or a target-date retirement fund made up of index funds.

WHAT IF I DON'T WANT MY 401(K) TO OWN ANY GUN STOCKS?

It can be difficult to tell exactly what your funds own. Index funds will own everything in the index that they track, and indexes add and drop stocks over time. Actively managed funds run by stock pickers give regular updates on what they own, but they can jump in and out of stocks quickly.

One of the hottest areas in the fund industry is a field called socially responsible investing. These funds aim to invest with a particular focus on environmental, social and corporate-governance issues, and they often go by the term "ESG funds." Many explicitly say they will never own the stock of a gun maker.

The number of ESG funds available more than doubled to 1,002 last year from 493 in 2010, according to industry group US SIF. The number of dollars they control has been growing even more quickly: up to $2.6 trillion from $569 billion in 2010.

WHY DID GUN STOCKS HAVE SUCH HIGH RETURNS IN RECENT YEARS?

As the list of the nation's mass shootings grew, expectations rose that Washington would make it more difficult to own guns. When Barack Obama was in the White House, fear was particularly acute among gun owners.

In a call to discuss Sturm Ruger's quarterly earnings in February, one investor told the company's executives that "you've never had a better administration for the gun industry than Obama."

To measure gun sales across the industry, analysts say the best indicator is the number of firearm background checks that the Federal Bureau of Investigation reports each month. Through Obama's presidency, the number of checks more than doubled to 27.5 million in 2016.

And several of the biggest spikes in sales occurred shortly after high-profile shootings. In the month following the 2012 school shooting in Newtown, Connecticut, the number of background checks surged 81 percent from a year earlier, for example.

After Republicans swept the November election to take control of the White House and Congress, gun owners were less worried about the government imposing more restrictions. That "resulted in a lack of urgency in gun buying," Wedbush analysts wrote in a recent research report.

The number of firearm background checks dropped 16 percent in December and has remained on a downward trend for most of 2017. Before the Las Vegas shooting, shares of both American Outdoor Brands and Sturm Ruger were down for the year versus a 12.5 percent gain for the S&P 500.

Copyright 2017 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed., source Associated Press News