 तत स्स्वायम्बुवैर्मन्त्रैर्ब्रह्मास्त्रमभिमन्त्रितम्।हनुमांश्चिन्तयामास वरदानं पितामहात्।। 
 Hanuman realised that it was by invoking creator Brahma and applying the mantra that he was caught by Brahmastram. On that occasion he started thinking of the boon given to him  by Grandsire Brahma  