How To Add Histograms - PNapi90/DESPEC-Analysis-Framework GitHub Wiki

While vital histograms such as gamma-gamma matrices and time difference spectra will already be present in the code, you may find that you wish to add histograms yourself in order to analyse more specific things. This section will detail the lines you need to add to the code in order to create and fill your new histogram.

Definition

The first step is to define the Histogram in First_Test.h, this is done with the simple line shown below

TH1* histogram_name;

*For 2D histograms simply change TH1* to TH2*

Initialisation

The next step is to initialise the histogram, this takes place in First_Test.cxx. At the bottom of the program there will be a function called Make_<Detector name>_Histos so for FATIMA this function is Make_FATIMA_Histos. There will be histograms predefined here, so using those as a template is the best option.

Otherwise you can initialise a histogram by entering the line below (adjusted for your chosen histogram):

histogram_name = MakeTH1('D',"histogram_name_in_rootfile","Histogram Title",N,low,high); or for 2D Histograms: histogram_name = MakeTH2('D',"histogram_name_in_rootfile","Histogram Title",Nx,lowx,highx,Ny,lowy,highy);

  • Where N should be replaced with the number of bins, and low and high are the upper and lower limits of the histogram
  • The D is used when the histogram is filled with double variables, change this to I for integer variables

Filling

Similar to the initialisation step each detector system has a Fill_<Detector name>_Histos function. In essence filling histograms is as simple as finding where you need to fill the histogram and typing the following lines.

double dummy_variable = RAW->get_dummy_variable(i);
histogram_name->Fill(dummy_Variable);

*Filling the histogram directly with RAW->get() can cause issues, so it is safer to create a dummy variable for filling

The most difficult part of filling a histogram is finding where these lines should be in detector system's function. Generally histogram filling functions will loop over the number of channels (usually with a second loop inside this loop so that matrices and time differences can be made that compare two channels).

Unfortunately explaining these sections any further would require excessive detail, we will try to maintain a good level of commenting in these functions to help understanding, but if there is any confusion please contact us.