Here I send you some links with information regarding your question.
In the case of Barcelona you can find out about our Tram system in https://www.tram.cat/who-are-we
In this website, Public Transportation: What is the cost benefit of trams over buses? (https://www.quora.com/Public-Transportation-What-is-the-cost-benefit-of-trams-over-buses) you can find a short discussion of the topic and a lot of related links.
Here an example of Edinburgh: Transport Economics: The Return of Trams – Benefits and Costs (https://www.tutor2u.net/economics/blog/transport-economics-the-return-of-trams-benefits-and-costs)
Cost-Benefit Analysis “Tram system Wiesbaden” (http://consult.ptvgroup.com/fileadmin/files_consult/Downloads/3_Referenzen/EN/PTV_TC_EN_Reference_Wiesbaden_Cost_benefit_analysis_Projectsheet.pdf)
Light rail transit and residential density in mid-size cities (http://www.governanceinstitute.edu.au/magma/media/upload/ckeditor/files/CURF%20Working%20Paper%205%20Light%20rail%20transit%20&%20residential%20density.pdf)
Cervero, Robert & Guerra, Erick. Urban Densities and Transit: A Multi-dimensional Perspective (http://www.its.berkeley.edu/sites/default/files/publications/UCB/2011/VWP/UCB-ITS-VWP-2011-6.pdf)
I hope help you with the information.