The effects of a tax can be measured using welfare economics, which determines consumer surplus, producer surplus, tax revenue, and total surplus with and without the tax.
A tax has a DWL because it causes consumers to buy less and producers to sell less, thus shrinking the market below the level that maximizes total surplus.