Adding events directly in a existing histogram

Hello,

       How do i can add events directly in a existing histogram ?

thanks
Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


See the various “Fill”, “FillN” and “AddBinContent” methods in the TH1 class reference.

Can not understand how to implement this into the program.

Could you give an small example how to do this ?

Dear @Saradindu ,

The examples are in the documentation already pointed out by @Wile_E_Coyote . You can also find more examples in the tutorials.
Cheers,
Vincenzo

I am using the command histo->AddBinContent(0,0) where 0 is the bin number and 0 is the weight value but there is no change in the histogram.

Bin number 0 is the “underflow bin” and you add 0 to its content. What do you expect?

There are 2 histograms with different bin numbers and ranges . How do i can add them ?

thanks

If the bin edges of both histograms “coincide”, you can use: TH1::Merge

Thank you. I missed it. If i need to do subtraction.
i am using Add(h1,-1) but it is not working.

Sorry for the confusion. I made a mistake. Thats why error was showing. Now its fine.

Thank you

The subtraction is not showing any error but the screen goes black.

There is no visualization of the remaining bins.

Although the no of entries after subtraction are coming correctly.
could you please tell what is the reason ?

Try to draw it using: histo->Draw("HIST");

Do you have a reproducer ?