Skip to content
Dylan Teague edited this page Jul 25, 2017 · 4 revisions

This histogramer is a container for the different root histograms. It splits the job up to the DataBinner, so if other file format (besides ROOT) are needed, the switch can easily be made by modifying the outfile of the Histogramer and creating a substitute DataBinner class with the functions addVal and fill_histogram check this__________

The Histogramer class works anonymously so histograms to be filled are handled by the DataBinner class. This means new histograms can be created easily by putting the histogram information into the PartDet/Hist_info.in file using the following format

<Histogram Name> <# Bins> <Minimum Value> <Maximum Value>

OR FOR 2D Histograms

<Histogram Name> <# Xaxis Bins> <MinX> <Max X> <# Yaxis Bins> <Min Y> <Max Y>

Each Histogram must be associate with a FillGroup. The FillGroup is the header for each section of histograms that starts with the Keyword "Fill". To facilitate restricting or allowing similar histograms to be written out, the FillGroups have a boolean value that can be flipped to cause the group of histograms to be written out or not. If one wants a specific histogram to not appear, it can be commented out like the other files (comments follow C and Python style comments of // and #). Commenting certain histograms will not speed up the code since the Analyzer will still try to fill all of the Histograms in the FillGroup. Setting a FillGroup to false on the other hand can cause marginal changes in speed.

Setters and Getters

vector<int> get_folders()
     //Returns the folder_num vector
vector<string>* get_order()
     //Returns the cuts_order vector
vector<string>* get_groups() 
     //Returns the data_order vector
unordered_map<string,pair<int,int>>* get_cuts() 
     //Returns the cuts map 
void setControlRegions();
    //Puts the histogram into Control region mode for filling

Public Functions

void fill_histogram();

Function that fills the actual root file with all of the histograms. Can be called several times since it updates the file after the first 'RECREATE'. Creates the folders then puts the data in each DataBinner into the file.


void addVal(double value, [double valuey], string group, int maxcut, string histn, double weight);

Function that adds the values to the respective DataBinner that holds the correct histogram. Part of the bucket brigade that starts at the Analyzer, shuffling the data down to the individual DataPiece that corresponds to the histogram.

Same basic function for 1D and 2D, just extra values.


Private Functions

void read_hist(string filename);

Function reads in the Hist_entries.in file for getting all of the histograms in the FillGroups for creating the histogram object. Hist_entries.in is not explicitly given as the filename, so different files can be given if needed


void read_cuts(string filename, vector<string>& folderCuts);

Reads in the Cuts.in file to create the folders that will be used in the Histogramer. The folderCuts is given as an argument for Control Regions: if control regions are set on, the folders are set by the control region variables, thus the cuts in Cuts.in are not used for the folderNames.


string extractHistname(string group, string histo);

Helper function that grabs the generic Histogram name from the full name. This is done by removing the FillGroup identifier from the Histogram name to Genericize it. Eg, in the FillMuon1 fill group, the group name is Muon. All histograms in this fill group are identified by the keyword of the fillgroup name, such as Muon1Pt. To genericize this, the FillGroup name is removed, Muon1Pt => Pt.

This means this histogram is can be referred to as just Pt from now on, so extra functions don't have to be written for each particles' Pt.


Private Values

TFile * outfile;
string outname;
int NFolders;
int Npdf;
bool isData
CR;
unordered_map<string, pair<int,int>> cuts;
vector<string> cut_order;
vector<string> folders;
vector<int> folder_num;
unordered_map<string, DataBinner*> data;
vector<string> data_order;

Clone this wiki locally