When Louis Theroux went to San Quentin prison he found a bizarre self-contained society where "straight" men fall in love, gangs are divided along strict racial lines and an inmate can be assaulted for the most minor mistake...
On a sunny day last summer I passed through a metal detector, entered a portcullis-like gate (called a "sally port") and walked into one of America's oldest and most notorious prisons, San Quentin.
I was chaperoned by one of the guards - for security purposes - not to mention a three-person camera crew - for documentary purposes. But I still had butterflies in my stomach.
I'd be doing a 10-day "hitch" for my programme. The idea was to get a glimpse inside the strange, secret world of hardened offenders and the lives they lead "inside".
I'd been warned about the risks involved: we were to stay together as a group at all times; no wandering off. If one of the team had to use a toilet, we would all wait.
Among the odd requests was that I couldn't wear blue - no jeans, no denim shirts - because it was too similar to the uniforms of the lifers. In prison, the clear distinction between the people doing time and those just visiting is paramount - assuming you want to make it out alive.
Gangs are divided along racial grounds...
Never having been to prison before I had various preconceptions, most of them taken from films and books. I had vague ideas about gangs, prison rape, assaults on guards, guys chalking up their time on their cell wall.
Mainly I was expecting a grim and depressing world of people without hope. Over the next few days some of these preconceptions were confirmed - and more of them were challenged.
Going in, the first thing that strikes you is the strangeness of the physical environment. Much of San Quentin was built in the mid-19th Century and it's a little like being in a medieval-walled town. There are interconnected yards, in the largest there is a baseball diamond and a pristine tennis court. Overlooking them are huge warehouse-like brick buildings full of cells.
Through doorways you see guys in blue sitting at desks taking classes, playing instruments, reading in a library. In the yard men are working out doing pull-ups or sitting round. Then in the background - a little surreally - prisoners in handcuffs are being escorted to hearings. Above, in a continuous ribbon around the prison walls, is the gun rail, staffed at all times by armed guards.
In a way, the appearance of San Quentin is slightly misleading. In the open areas it feels fairly relaxed, but that's because you're only seeing the most trusted prisoners. The vast majority of the inmates are locked away, spending up to 23 hours a day in their cells - as you realise when you walk into one of the cell blocks.
In terms of scale and the way they're organised, walking into one is a little like walking into a barn full of battery chickens. The cells are arranged in long rows on metal tiers, going up five levels. There is constant noise, especially if they spy a camera crew.
Initially I'd been worried it might be a problem that prisoners wouldn't want to speak to me. The reverse was the case. They shout and ask if we were from Lock-Up, a US cable show. "Man, I'll give you a great interview."
We spent the first few days walking around the different sections, grabbing time with whoever caught our eye. In Carson section - San Quentin's "hole" for persistently unruly prisoners - I met some of the most hardened criminals.
The prison was built in the mid-19th Century...
These included a character named Playboy Nolan, who was being disciplined for repeatedly "gassing" officers - spraying them with his urine as they walked past his cell. Also David Silva who, with a twinkle in his eye, described using "torture tactics" on his victims during burglaries.
In Alpine section, which houses "PC" prisoners - those in protective custody because they're at risk of attack from other inmates - I met some of the ex-gang members who are now targets themselves. Also, the sex offenders who live in fear of their lives for being viewed as the lowest of the low by other inmates.
Where I could, I got interviews with active gang members, who described their motivations for being part of the gang culture and explained some of the arcane rules of taking part.
The rules of the gangs were some of the strangest things I heard in prison. The gangs are organised racially - white, black, Hispanic - though there are also two very large and opposed Hispanic groups, the Northerners and Southerners.
Mostly, it's about having physical protection from fellow gang members and being provided for. In return, naturally, you're expected to do their bidding, which chiefly seems to mean assaulting whoever your higher-ups tell you to.
The gangs create camaraderie through racial loyalty, in a quite bizarre way. A white skinhead gang member - part of the Barbarian Brotherhood - casually told me he'd have to beat me up if he saw me taking food or cadging a smoke from a person of another race.
I met another skinhead who'd left his gang because they'd asked him to stab his cellmate for, get this, borrowing a black man's dominoes.
As time passed what I began to see was how being excluded from the outside world had led to new and unlikely kinds of relationship growing up on the inside. I'd known going in that sex went on between prisoners and that guys who on the outside were straight had gay sex for lack of female companionship.
Theroux spent two weeks talking to inmates
What I hadn't realised was how consuming these relationships could become. I met Rob, a Californian in his 30s and doing time for a laundry list of driving and drug offences. Straight all his life, he'd been assigned a cell with an older transsexual called Debra and ended up falling in love with her.
Rob was so into Debra he was convinced the relationship would keep going when they were both released. Debra seemed a little more realistic. Just as I'd got my head round this I met Chris Mitts, a gay, Jewish car thief in his 20s, who'd just started a relationship with a straight ex-neo-Nazi gang member, who was married with kids.
With the strange warmth of the relationships between the inmates and their surprising receptiveness to us, it was easy to get lulled into a false sense of security. Most of the time, after my first couple of days at the prison, I stopped thinking about my safety.
'Heckles and shouts'
But a couple of times a day an alarm would go off all over the prison, usually meaning a fight had broken out or that officers were having trouble getting prisoners into the cells. Wherever they were, all the prisoners had to lie down, and the atmosphere would thicken and I'd be reminded where I was and what the risks were.
On one of my last days, I was in a small and overcrowded yard with the inmates of Carson section. There'd been a little debate over whether it was safe for us, given the number of people that were out but we went ahead. We wandered about chatting to inmates and I found myself in a little area which seemed be given over to sex offenders.
I was talking to one of the guys, trying to get him to tell me what he was in for, when the alarm sounded. Even my chaperone looked nervous as he gave us the signal to get out. As we picked our way through the prisoners, all of them now lying down on the ground, there were heckles and shouts of abuse directed at us.
What had seemed a relatively benign environment now felt scary and dangerous, and I was relieved when we all made it safely back outside the yard. A few days later I left for good, still not quite believing the strangeness of San Quentin's world-within-a-world and very grateful that I at least had the option of going home.