-
Notifications
You must be signed in to change notification settings - Fork 7
DataBinner
The DataBinner file contains 4 main classes in it, but they all work intimately together. There is the DataPiece, in which there is Piece1D and Piece2D corresponding to 1D and 2D histograms that can be made with the Analyzer, and DataBinner which is a container that holds the different DataPieces.
The following explains each function and its use.
DataBinner();
DataBinner(const DataBinner& rhs);
~DataBinner();void AddPoint(string name, int maxfolder, double value, [double valuey],
double weight); This function adds a weight to the histogram called name at the position value to all folders at and below the maxfolder number. For 2D histograms, there is an added valuey.
If CR is set to true, this function only adds the weight to the folder specified as maxfolder.
void Add_Hist(string shortname, string fullname, int bin, double left,
double right, [int biny, double lefty, double righty], int Nfolder);This function takes the information of a histogram and creates a DataPiece hashed at the point shortname.
The short name is a generic name used to identify the histogram. Since there is a DataBinner for every Fill Group, specifying a histogram by what particle is in it is redundant. The shortname allows the Analyzer to fill the histograms based on the variable being filled and Fill Group, thus making the filling process as anonymous as possible and thus easier to generalize.
The shortname is generated by removing the Particle name from the full histogram name:
Tau1Pt ==> Pt Muon1Eta ==> Eta DiTauReconstructedMass ==> ReconstructedMass
Sometimes in Diparticle Histograms, one of the particles is singled out. For this, the singled out particle is given the name "Part#" where the # is replaced with either a 1 or 2 for the spot in the Diparticle arrangement:
Muon1Tau1_Muon1IsZdecay ==> Part1IsZdecay Electron2Tau2_Electron2MetMt ==> Part1MetMt
The function that creates the shortname is in Histo.cc, s__________________________________________________________________________________________
unordered_map<string, DataPiece*> datamap
vector<string> order
bool CRdatamap is the hashmap that holds all of the DataPieces. Notice, because it is an unordered_map, to keep the order of each of the histograms for printing out, we have to keep a vector<string> called order to keep this information.
CR is the bool value that specifies if Control Regions are given. The default is false.
DataPiece(string _name, int _Nfold, int _fold_width)
~DataPiece()All of these functions are virtual so Piece1D and Piece2D can both do the main functionality of binning values and writing out to the histogram. The Children classes are omitted because of this redundancy.
virtual void write_histogram(vector<string>& folders, TFile* outfile) This Function puts the values in the data vector into a TH#D and writes the histogram into the TFile outfile. folders are provided to facilitate cd-ing into the correct directories in the TFile
virtual void bin(int folder, double x, [double y], double weight)bin does the grunt work. It goes to the bin associated with the value x (and y if this is a Piece2D) and increments this bin by the weight. It only does it to the folder specified by the int folder.
const string name
const int Nfold
const int fold_width
vector<double> data;These are the basic values for making the histogram.
-
nameis the name of histogram which is used for giving the TH#D a title -
Nfoldis the number of folders in the output file. VARIABLE NOT NEEDED__ -
fold_width, which is short for folder width, is the total number of bins in the histogram, including underflow and overflow. This is used to get to the bins associated with different folders easily. -
datais the actual data with all of the bins for all of the histograms in one vector. The convention is the obvious one:
bin
iin folderj==> indexi + fold_width * j