1. Cut off the branches with leaves (save them to make a soup, for example). Peel the branches, removing as many stringy parts as possible. Cut the branches into regular pieces of about 5 cm.
2. In a saucepan, bring salted water to a boil (enough to cover the celery pieces). Place the celery in the water and cook for 20 minutes (check during cooking, the pieces should remain "al dente"). Drain them.
3. Meanwhile, simmer the tomatoes, crushed garlic, thyme sprig, bay leaf, and bacon in lemon juice for about 10 minutes. Season with salt and pepper. Add 1 tablespoon of water if necessary.
4. Remove the thyme and bay leaf at the end of cooking.
5. In a gratin dish, spread the cooked celery pieces in a layer, cover with the tomato sauce, and sprinkle with grated cheese. Cut the butter into very small pieces and distribute them over the gratin.
6. Place under the broiler in your oven and let it gratin.