Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-20 07:05:38

0001 #pragma once
0002 
0003 #include <stdio.h>
0004 #include <stdlib.h>
0005 #include <iostream>
0006 #include <sstream>
0007 
0008 // ROOT
0009 #include <TSystem.h>
0010 #include <TObject.h>
0011 #include <TNamed.h>
0012 #include <TString.h>
0013 #include <TMath.h>
0014 #include <TAxis.h>
0015 #include <TObjArray.h>
0016 
0017 // adage
0018 #include "CutDef.h"
0019 
0020 
0021 class BinSet : public TObject
0022 {
0023   public:
0024     /* this class stores `CutDef`s, for your specified binning
0025      * - `varName` and `varTitle` are passed to the `CutDef` objects
0026      */
0027     BinSet(TString varName_="unknown", TString varTitle_="unknown");
0028     BinSet(const BinSet &BS);
0029     ~BinSet();
0030 
0031     // bin list container, of `CutDef` pointers, one for each bin
0032     TObjArray *GetBinList() { return binList; };
0033     Int_t GetNumBins() { return (Int_t) binList->GetEntries(); };
0034 
0035     // get minimum or maximum of this BinSet (note: each bin must actually have min and max set)
0036     Double_t GetMin();
0037     Double_t GetMax();
0038 
0039     // accessors
0040     TString GetVarName() { return varName; };
0041     TString GetVarTitle() { return varTitle; };
0042 
0043     /* bin builders
0044      * - at construction, you will start with zero bins
0045      * - call any bin builder to sequentiall add bins to the list of bins
0046      */
0047     /* build a single bin
0048      * - bin is created by specifying a `CutDef` (see CutDef.h)
0049      */
0050     void BuildBin(TString cutType_, Double_t arg1_=-1, Double_t arg2_=-1);
0051     void BuildBin(CutDef *cut_);
0052     /* build list of bins
0053      * - define the number of bins `nbins`, in the * range `min` to `max`
0054      * - default is equal width bins in linear scale
0055      * - set `log` to true for equal-width bins in log scale
0056      * - you may instead specify a `TAxis`, for any arbitrary binning
0057      * - a list of `CutDef`s is generated
0058      */
0059     void BuildBins(Int_t nbins_, Double_t min_, Double_t max_, Bool_t log_=false);
0060     void BuildBins(TAxis *ax, Bool_t log_=false);
0061     // build "external" bin, where CutDef only stores an ID (you must check cuts externally)
0062     void BuildExternalBin(TString cutID_,TString cutTitle_);
0063 
0064     // access a bin's cut (by bin number)
0065     CutDef *Cut(Int_t binNum) { return (CutDef*)binList->At(binNum); };
0066 
0067     /* make equal-width log-scale bins
0068      * - the axis `ax` will be modified
0069      * - you can use this on histogram axes too; just call this method
0070      *   on any histogram axis, prior to filling the histogram
0071      */
0072     static void BinLog(TAxis *ax);
0073 
0074   private:
0075     TObjArray *binList; // array of `CutDef*`s
0076     TString varName,varTitle;
0077 
0078   ClassDef(BinSet,1);
0079 };