Can I fill a TH1I with "false double"

Dear Couet and behrenhoff,

for the “casting” question, I wanted to understand an answer that I got some time ago by a root expert who said [1], and which really surprised me, and this is the real reason why I posted this post, because I started to thing that maybe I can’t fill a TH1I with double etc… So I wanted to clear that, and I understood now that yes, I can cast a TH1F in a TH1D, right? and if yes, why [2] does not work.


“You cannot cast from a TH1D to a TH1F.”


root [0] TH1D *hd = new TH1D()
(TH1D *) 0x7f99ab768420
root [1] TH1F *hf = new TH1F()
(TH1F *) 0x7f99ad2f0750
root [2] hf->ClassName()
(const char *) "TH1F"
root [3] hf = (TH1F*)hd;
root [4] hf->ClassName()
(const char *) "TH1D"