This is how to calculate tax on a given price and product programmatically in Magento.
$priceInclTax=Mage::helper('tax')->getPrice($product,$price);
You can get $price from $product using
$price=$product->getFinalPrice();
You can get price the way you want, it can be custom price or any number you want to calculate tax on, but you need to pass the $product which should be a valid product object.
$priceInclTax=Mage::helper('tax')->getPrice($product,$price);
This is how you get price with tax. BUT this is NOT how you calculate tax!!! Magento calculates tax for you based on your magento shop settings
This is crap. You are not showing how to get the tax at all.