Getting a 1D histogram by looping over a pair of histograms under multiple categories

So I have a three categories “A”,“B”,“C”. They are stored in a vector called vec_hist. Within each categories, there are six 2D histograms each of same bin sizes (5 by 6 to be specific) that are named as follows:

A has hist_A_1a, hist_A_1b, hist_A_2a, hist_A_2b, hist_A_3a,hist_A_3b
B has hist_B_1a, hist_B_1b, hist_B_2a, hist_B_2b, hist_B_3a,hist_B_3b
C has hist_C_1a, hist_C_1b, hist_C_2a, hist_C_2b, hist_C_3a,hist_C_3b

What I want to do is something like this in the order:
i) Go to category “A”
ii) Take hist_A_1a and hist_A_1b, and get their bin contents and fill a 1D histogram with them.
iii) Take hist_A_2a and hist_A_2b and again get their bin contents and fill a different histogram with them.
iv) After done with “A”, go to “B” repeat ii) and iii) and then move on to “C”.

So, in total I am supposed to have nine 1D histograms. I wish I had a script to show but, I have no clue where to start. So any pointer would be useful. Let me know if my question does not make sense.

ROOT Version: 5.18
Platform: Ubuntu 18.04
Compiler: Not Provided


Hi @hep_1,
I’m very sorry for the late reply, it looks this post slipped through the cracks! In general feel free to ping us if you don’t receive any reply after a few days.

I hoped you resolved your problem in the meanwhile. I am not sure what you mean when you say that you have three categories stored in a vector: what is a category, is it a histogram (i.e. you have a vector of 3 histograms)?
A small code snippet or a ROOT file with the input histograms might help.

Cheers,
Enrico

P.S.
Note that ROOT 5.18 is ancient. The latest, currently unmaintained, ROOT version in the 5 series is 5.34. Users are strongly encouraged to move to ROOT version 6 if at all possible.

Hi @eguiraud, yes, I resolved the problem. I did move to ROOT 6 after asking this question. Thank you for your reply.

1 Like