The calorie is a unit of energy. In the context of food, the kilocalorie (or large calorie) is most commonly used, equaling 1000 small calories. When the nutritional value of a food product is assessed, one calorie is defined as the amount of energy needed to increase the temperature of one kilogram of water form 24 degrees centigrade to 25 degrees. So one must remember that in food, one calorie is 1000 times greater than the common calorie used in physics and chemistry.
So how do food manufacturers determine the amount of calories in food? The product is placed in a sealed cup that is immersed in a water tank, and the water temperature increase that results from burning the food sample is measured. In some cases the food must be dehydrated and ground prior to incineration in order to ensure its full combustion.
For example, we might wish to determine the amount of calories in one spoon of canola oil. We would put a spoonful of oil in the sample cup (see above diagram) and immerse it in a container that holds one liter (one kilogram) of water. We would then ignite the oil and once it is completely burned, we would measure the temperature increase of the water. If the temperature increases from 24 degrees to 44 degrees this means that one spoon of the oil contains 20 calories.
Nowadays the caloric values of many basic food ingredients can be found in designated tables, including fats, proteins, carbohydrates and more. Food manufacturers calculate the protein/fat/sugar composition of their product and use these tables to calculate the total amount of calories.
Importantly, some food components are not taken into account: for example, dietary fibers would have a caloric value when measure in a calorimeter, but they are disregarded since humans cannot digest them and they are excreted from the body without contributing any energetic value.