Create histogram with vector

I have voltage analysis of a 16-channel PMT. I have arrays of voltage values for each column, with 16 values in each array. There are a total of four column values. I want to find the maximum values of these using vectors, then find the maximum of these max values to create a four-element array. Then, I want to find the maximum of these, which is the maximum of the larger values. After finding the maximum of all values, I want to calculate efficiency and place them into a histogram using a matrix. How can I write the code on macro?

Dear @Aishanour ,

Thanks for reaching out to the forum. You have an interesting use case, let’s try to tackle it together.

My suggestion is to use RDataFrame for this task ROOT: ROOT::RDataFrame Class Reference

Within any single column, IIUC you have each event holding an array of 16 values. You can find the maximum of the array via ROOT::Vecops::Max. For example with RDF it would be something like df.Define("max_of_vals", [](const ROOT::RVec<T> &vec) { return ROOT::VecOps::Max(vec); }, {"my_col_name"});. This will give you for each event and for that particular column, the maximum value of the array.

Now you have 4 columns, so you can repeat the same procedure on all of them, you will get 4 new columns, each now stores only one value per event, that is the maximum value of the array for that event.

Subsequently, you can compute the maximum value of each column with the RDataFrame::Max operation, e.g. auto max_1 = df.Max("my_col_of_max_values");. You can repeat a similar call for each of the 4 column of max values.

Now you have 4 values, which represent the maximum value of the maximum values w.r.t. the original 4 columns of the dataset. This should represent what you originally wanted. I will let you finish the final steps of the analysis as you require.

Cheers,
Vincenzo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.