After Chris Brown beat Rihanna the night before the 2009 Grammys, many fans inexplicably turned against her, somehow blaming her for the incident. Her handlers were faced with the task of rehabilitating her image, reintroducing the strong, independent woman fans had come — a bit inflexibly, it turned out — to love. There was only one answer, Def Jam Records’ L.A. Reid realized: Convene “the mother of all song camps.”

Strummer Camp

Songwriting today is not the romantic notion of one kid with a guitar. As John Seabrook writes in his new book “The Song Machine,” it’s an impersonal, assembly-line-driven process that would make Henry Ford proud.

For Rihanna, “A-list producers and topliners [the term for vocal melody writers] were summoned to Los Angeles for two weeks and installed in studios around the city,” creating what Seabrook calls “a pop-up hit factory.”

These superstar producers and writers included Ne-Yo, the Stargate team, and Ester Dean, one of music’s most successful topliners, and also an actress best known for playing Cynthia Rose in the “Pitch Perfect” films. Stargate and Dean would become frequent collaborators, with hits such as Katy Perry’s “Firework” on their résumé.

Once everyone was in town, the frenzy began.

The songwriting labor is tightly scheduled. Producers/beat makers meet with topliners in the morning, with the expectation they’ll have a completed song by lunchtime.

A representative from the label — referred to here as a “camp counselor” — then creates new combinations, and the new producer-topliner teams work to write another new song by late afternoon.

If the artist is there, he or she “circulates among the different sessions, throwing out concepts, checking on the works in process, picking up musical pollen in one session and shedding it on others.

“At the end of each morning and afternoon session, the campers come together and listen to one another’s songs. The peer pressure is such that virtually every session produces a song, which means 12 or more songs a day, or 60 a week, depending on the size of the camp.”

Rihanna’s next album, “Rated R,” was a commercial and critical success, and its only No. 1, “Rude Boy,” emerged from the LA camp sessions. The song is credited to five different writers(if we count the two-man Stargate team as one entity), including Dean, who wrote the hooks; Rihanna herself, who wrote the bridge with Makeba Riddick; and Stargate and Rob Swire, who created the beats.

Seabrook calls the modern method of song creation “track and hook,” indicating the split between the writing of the beat (track) and the hooks (melodies). He distinguishes this method from the more traditional “melody and lyrics”; often referred to on older albums as music and lyrics.

“The [track and hook] method was invented by reggae producers in Jamaica,” Seabrook writes, “who made one ‘riddim’ (rhythm) track and invited 10 or more aspiring singers to record a song over it. Today, track-and-hook has become the pillar and post of popular song…it is common practice for a producer to send the same track to multiple topliners — in extreme cases, as many as 50 — and choose the best melody from among the submissions.”

Stuck on Repeat

While this method has become a reliable source of hits, any artistic endeavor so mechanized is likely to have a downside.

“As a working method, track-and-hook tends to make songs sound the same,” Seabrook writes. “As dance beats have become the backing tracks to a growing number of pop songs, similar-sounding records have proliferated. The melodies themselves are still supposed to be unique, but because of the way producers work with multiple topliners, tracks and melodies tend to blur together.”

By way of example, Seabrook cites two 2009 hits — Beyoncé’s “Halo,” and Kelly Clarkson’s “Already Gone,” both produced by ”the super-producer Ryan Tedder.” (Both stars wrote their own toplines, Beyonce paired with Evan Bogart.)

“Halo” hit No. 5 first, and when Clarkson heard the song, “She thought it sounded too much like ‘Already Gone,’ and feared the public would think she copied Beyoncé’s song. But nobody cared or perhaps even noticed: Both songs were hits.”

And while track-and-hook can lead to similar sounding work, it can also be an exhausting, uncreative grind for the assembly-line writers.

Early in his career, Drake wrote for Dr. Dre’s Death Row Records’ hit factory, where “dozens of young beat makers and topliners put in long hours.”

“It was some of the most strenuous militant s–t I’ve ever done,” Drake said. “But no useable songs came out of it. When I think of how he worked us, it’s no wonder he didn’t get anything out of it. It was just writers in a room churning out product all day long.”

Swede Beats

As with many stunted creative endeavors, the origins of all this are found in a genuine love for the art form — specifically, that of a Swedish DJ known as Denniz PoP.

In 1987, PoP — who had no musical training and played no instruments — was DJ’ing in a small club in Stockholm when Public Enemy made their first Swedish appearance there, a show that became legendary among the Swedish producers who would soon create modern pop.

“It was like seeing the light,” said a journalist named Jan Gradvall, “visual proof that exciting music didn’t have to be played on guitars, bass, and drums, but with only a Technics 1200 (turntable).”

PoP was remixing American hits for the European market in a DJ collective called SweMix, but had a grander — and, at the time, wholly unrealistic — dream: to create “a factory of Swedish writers and producers who would create hits for British and American artists.” At the time, Seabrook notes, “Sweden was very disconnected from the international music market.”

“[Songwriting is] an impersonal, assembly-line-driven process that would make Henry Ford proud.”

PoP’s vision was to “meld the beat-driven music that people danced to inside the clubs with the pop music people listened to on the radio,” which would include “the singsongy melodies that the Swedes have such a gift for.”

He began creating hits — all on computer — for local acts. As his reputation grew, he received a demo tape from a Swedish act called Ace of Base. He listened to them while driving home, found the songwriting muddled and decided immediately not to produce them. But his car’s tape deck and radio were broken, and he couldn’t eject the tape. So, for lack of anything else to listen to, he listened to the tape over and over again for two weeks. By then, he realized how to fix the song and agreed to produce the band.

While working with Ace of Base, PoP quit SweMix and formed Cheiron Studios, conceived as both studio and record label. Cheiron would become one of the world’s great hit factories and developer of the current template.

Max Martin

By 1995, PoP had assembled a team of about 10 writers, each with different strengths, working as per his theory that songwriting should be a group process.

“A strong part of Denniz’s vision for the studio was that songwriting should be a collaborative effort,” writes Seabrook. “Songwriters would be assigned different parts of a song to work on; choruses would be taken from one song and tried in another; a bridge might be swapped out, or a hook.”

Oddly, given PoP’s musical preferences, one of the label side’s first signings was an Iron Maiden-ish hard rock band called It’s Alive, fronted by a long-haired glam-rock singer named Martin White. PoP saw that White — who, despite his metalhead persona, had a secret love of pop music — was a genius at crafting melodies.

PoP dropped It’s Alive from the label (which itself folded soon after) but made White his protege. White — later christened the more Hollywood-friendly Max Martin — spent two years watching and learning, and he and PoP became a team.

Ace of Base’s album was a global smash, selling 23 million copies on the strength of hits “The Sign” (also the album’s title) and “All That She Wants.”

Still, the band never came close to that success again, and it became clear to PoP that if he wanted Cheiron to be a world power, they would need an American success. They would secure this a few years later when asked to work with a new act called the Backstreet Boys.

That group’s 1996 debut album, one of the best-selling debuts of all time, was recorded in New York, Florida, and Sweden. PoP and Martin, together or with others, worked on four of the album’s 13 songs, including the hit singles “We’ve Got It Goin’ On” and “Quit Playing Games (With My Heart).”

Hit me baby…

After Backstreet’s success, Cheiron and Martin were now well known in the music world. PoP would not get to see how his method took over American pop music, as he died of stomach cancer in 1998, at age 35.

Martin became the bearer of the Swedish pop torch, and as Jive Records tried to determine a direction for an unknown teenage singer named Britney Spears, it turned to him.

He had written a song called, “…Baby One More Time,” for TLC. When they rejected it, he brought it to Spears, who sold 500,000 copies of the single the day it was released.

In addition to making Spears a star, the song was the first of what is now 21 No. 1 singles in the U.S. for Martin, including songs for *NSync (“It’s Gonna Be Me”), Pink (“So What”), and Maroon 5 (“One More Night”).

Martin has played a pivotal role in Katy Perry’s career, co-writing and/or producing hits including “I Kissed a Girl,” “California Gurls,” and “Teenage Dream.”

His three most recent No. 1 songs came from Taylor Swift’s blockbuster release, “1989” — “Shake It Off,” “Blank Space” and “Bad Blood.”

Martin co-wrote seven and co-produced nine of the 13 tracks on the album, which was the best seller of 2014 and might just capture that title again in 2015.

When a New York DJ named Lukasz Gottwald, a former pot dealer who later spent six years as the guitarist for the house band on ”Saturday Night Live,” wanted to start producing records, he sought out Martin, who became first his mentor, then his partner.

Shortening his professional name to Dr. Luke, he followed Martin in becoming one of the industry’s top producers, working on hits including Avril Lavigne’s “Girlfriend,” Flo Rida’s “Right Round,” and Miley Cyrus’ “Party in the U.S.A.”

PoP, Martin and their collaborators and disciples have had such a strong influence on modern pop music that “Swedish hitmakers supplied one quarter of all the hits on the Billboard Hot 100 in 2014.”

But it begs the question of how unique these songs can sound when even the hitmakers themselves lament the rote nature of the process, as when Dean expresses that, as Seabrook tells us, “she is wary of the way producers now expect a hit from her every time she walks into a studio.”

“Everyone is so hit-minded,” Dean said. “They’re always looking at you going, ‘Didja get it? Didja get it? Is that the hit? And I don’t know what I’m going to give them.”