Author Marti Perarnau was given total access to Bayern Munich during the 2013-14 season, Pep Guardiola's first in charge of the Bundesliga giants.

In his new book Pep Confidential, Perarnau uses his behind-the-scenes pass to give readers a unique insight into Guardiola's debut campaign in Germany.

In this extract he covers Bayern's humiliating 4-0 home defeat by Real Madrid in the semi-finals of the Champions League, a result which left Guardiola a broken man.

Bayern Munich stars (from left to right) Franck Ribery, Manuel Neuer and Toni Kroos console each other after their 4-0 defeat by Real Madrid in the semi-finals of the Champions League

'I got it wrong, man. I got it totally wrong. It's a monumental f***-up. A total mess. The biggest f***-up of my life as a coach.'

Pep comes into his office in the Allianz having just done the press conference during which he has publicly assumed total responsibility for the catastrophe.

Real Madrid have wiped the floor with Bayern in the Champions League semi-final, a game which will stay with Guardiola for the rest of his career. The 4-0 home defeat is the worst of his professional life and the biggest trouncing Bayern have ever received in a European competition.

His team has been pummelled into submission and totally humiliated in their own stadium by the team who will take the European title from them a few weeks from now.

We need to go back one week, to the previous Thursday morning, to get to the root of the problem. The scene is a private room in Madrid's Hotel Intercontinental, where Bayern have enjoyed their traditional post-match dinner. The meal has finished and all but three tables lie empty. The remaining diners include members of the club's press department, a group of Bayern's sponsors and, at the third table, Pep and his assistants.

Real defender Sergio Ramos gets up highest to score his side's second goal of the night at the Allianz Arena

Spain defender Ramos runs away to celebrate his goal against Pep Guardiola's men in Germany

Guardiola shouts instructions to his players but he could do nothing to stop his side losing heavily

The front cover of new book Pep Confidential

The group has already diagnosed the problems at the root of their 1-0 defeat at the Bernabéu and are proud of the way the players have imposed themselves in this arena by sticking to the game plan. They are also, however, well aware of the fact that their men are below par and have struggled against a defensive line-up made up of well-organised, super-talented players who defend as a unit almost to perfection.

Right now, Guardiola is facing one of the most common dilemmas in a football coach's life: how do you attack effectively in such tight space?

At 3am on Thursday, April 24, Pep is considering the obvious fact that Madrid will shut up shop when they visit the Allianz for the second leg. The coach also has Garry Kasparov's words ringing in his ears: 'Remember, Pep, you don't win games just because you've moved your pieces to the front.'

It is during this early-hours reflection that Pep decides to play the return leg with a 3-4-3 formation. With three central defenders, two full-backs pushed up into the midfield next to the creative midfielders and (Mario) Gotze as one of the two strikers, so that he can add superiority in midfield by dropping back to help in the middle of the pitch.

It's a 3-4-3 which can be changed to a basic 3-5-2 with minimal alteration. Theoretically good for defending against the counter-attacks which, Pep is convinced, will feature heavily in Madrid's game. But it should also allow Bayern to dominate the middle of the pitch, to keep the ball and not to get log-jammed in and around the Madrid penalty area.

PEP GUARDIOLA FACTFILE Nationality: Spanish Age: 43 Clubs played for: Barcelona (1990-2001), Brescia (2001-2002), Roma (2002-2003), Brescia (2003), Al-Ahli (2003-2005), Dorados (2005-06) Major honours: 6 La Liga titles, 2 Copa del Reys, 1 European Cup, 1 UEFA Cup Winners' Cup, 2 UEFA Super Cups, 1 Olympic Gold medal Teams managed: Barcelona B (2007-2008), Barcelona (2008-2012), Bayern Munich (2013-present) Major honours: 3 La Liga titles, 2 Copa del Reys, 2 Champions Leagues, 3 UEFA Super Cups, 3 FIFA Club World Cups, 1 Bundesliga title, 1 German Cup Advertisement

It's then that I overhear Guardiola telling Torrent (Domenec Torrent, his assistant coach): 'Dome, don't let me change my mind. This is the only way to go.'

Then, on the flight back to Munich, Pep changed his mind.

Reflecting on the fact that the team had last practised a three-man defence in December, the coach realised that there was very little time to prepare his players. Added to this, Javi Martínez had not only just recovered from a bad bout of gastroenteritis, but was also suffering from tendinitis in both knees. There was no way he was going to make it through 90 minutes against Madrid.

The coach decided to leave the 3-4-3 for next season and by the time the plane touched down in Munich Pep had switched to a 4-2-3-1. This formation had worked well in Bundesliga games and would give his men superiority in the midfield. What's more, it was a system they were completely familiar with and would allow him to use both (Franck) Ribery and Gotze. If only he could do something to get Ribery back to his best.

On Friday, April 25, Pep addressed his squad briefly. 'I'll be eternally grateful for all you did in the Bernabeu. You showed enormous courage and played the kind of football I want to see. I'm proud of you all.'

This was also the day Tito Vilanova passed away, a desperately sad day for his family, Barcelona, their supporters and all his friends. The world of football shared their grief and for Pep, Torrent, (Carles) Planchart, (Manel) Estiarte and (Lorenzo) Buenaventura, who had been part of Tito's life over so many years, it was a devastating blow.

Cristiano Ronaldo (left) scores Real's fourth and final goal with a low free-kick beyond Neuer

Gareth Bale hugs his team-mate Ronaldo after the Portuguese's second goal at the Allianz Arena

BAYERN MUNICH 0 REAL MADRID 4 Read Chief Sports Writer Martin Samuel's verdict on Bayern's humbling and dramatic defeat to Real earlier this year Advertisement

The home game against Werder Bremen on Saturday was tough. Bayern responded to the tragic news by taking steps to protect their coach. Releasing a statement of condolence in both German and Catalan, the club organised a minute's silence in the stadium where all the players were wearing black armbands.

That night the coach dined out with friends but his mind was elsewhere. From time to time he pulled out photos showing himself and Tito together, his favourite having been taken in Atletico Madrid's Vicente Calderon dressing room. In the picture the two men are discussing their plans for the game. All in all it was a strange evening, during which they toasted Tito and discussed almost every subject under the sun except football. Pep had other things on his mind.

By Monday, the players are fired up and eagerly anticipating their chance to take revenge on Madrid. There is a sense that this will be an encounter of epic proportions, but there is little evidence of cool, tactical analysis. Pep allows himself to be carried away and even his performance at the press conference seems out of character.

It's then he makes a big mistake. He asks his men how they are feeling and they talk to him about the German talent for glorious comebacks, as well as the passion they have all felt on similarly epic nights in the Allianz Arena. All they want is to be allowed to play with their hearts and souls. They need to go out and attack hard from the first second of the game.

Bayern forward Thomas Muller (centre) looks dejected after watching his side concede another goal

Bale (left) sprints away from Bayern's Jerome Boateng during a difficult night for the hosts

Guardiola embraces Ribery after substituting the Frenchman against Carlo Ancelotti's rampant side

Pep changes his mind again. The 3-4-3 had become a 4-2-3-1, but now he opts for a 4-2-4 formation. Just as he did in Dortmund in July 2013, in his debut match, he swithers between patience and passion and ends up going for passion. But it didn't work in Dortmund, and it won't work now.

The pre-match team talk, in the Presidential Suite of the Charles Hotel, reflects the optimism everyone in Munich is feeling: 'Lads, this is not about going out and having a good time. You are going out there to do some damage. Go for the jugular. You are German, so be German and attack.'

In the end, their epic story ends in disaster.

Pep will confess later that early in the game he already knew that the team was messing up. And you can see it right from the kick off. The ref blows, Madrid move the ball back through their team while (Mario) Mandzukic and (Thomas) Muller hare off like madmen to try to win it from them.

It is courageous, ambitious, but also the first clear indication that Bayern's midfield is going to be left gaping all night, at their rival's mercy. Pep has kept Rafinha on the bench and returned (Philipp) Lahm to right back. It is a crucial error. On this, the biggest night of his Bayern career, Pep has stripped his midfield of the guy who has locked all the components together and been his best midfielder all season; the man who has imposed order on the team.

Guardiola was sidetracked in the build up to Bayern's clash with Real by the death of Tito Vilanova (right)

Guardiola and his friend Vilanova (left) worked together at Barcelona before Pep left for Bayern Munich

Later, the coach assumes all the blame for the disaster. He makes no reference to his players' requests and goes out of his way to protect them, making sure that they are left out of the post-match debate. He had abandoned the centre of the field on the very day his men were up against a pack of lions.

Several weeks before, the coach compared a football team to a glass bottle hanging by a thread. Today, the thread has broken and Bayern has come crashing down. There have been very few teams who have imploded so dramatically in such a short space of time and this defeat will mark a turning point for Guardiola. Nothing will be the same again in Germany and, if the press coverage is to be believed, in one night the Catalan has gone from national hero to a figure of scorn.

Pep is still shut up in his office with Domenec Torrent, Carles Planchart and Manel Estiarte well past midnight. Ostensibly, they are there to review the match together, but in reality his assistants are trying to boost the boss's morale. They can see that tonight Pep is a broken man.

VIDEO Guardiola an extraordinary coach - Rummenigge