Inf/NaN propagated to the pad

Even if I used it as follows, I got Inf or nan values.Why is that?

TH1D* h_pion_invariant_mass_weight=new TH1D("h_pion_invariant_mass_weight", "pion invariant mass weight by efficiency",200,0.0,2.5);
h_pion_invariant_mass_weight->Sumw2();




if ((!TMath::Finite(weight_total)) || (weight_total < 0.0) ) {
    std::cout  << " weight total  = " << weight_total  << std::endl;
         continue;
   } else {
     h_pion_invariant_mass_weight>Fill(pion_invariant.M(),weight_total);
     }
                                            

I found this from Inf/NaN propagated to the pad. Check drawn objects - #7 by Soumyadip

Thanks
Dil