Defining Histograms, Ntuples, and Accessing for Filling

In RootTreeAnalysis, three separate routines create the histograms and ntuples that will be filled during event processing.  There is a separate method for MC, digitization and reconstruction data: McHistDefine( ), DigiHistDefine( ), ReconHistDefine( ).  These methods are called when RootTreeAnalysis is initialized and need not be called directly by the user.  These methods are of interest to users strictly for the purpose of updating them to modify what histograms and ntuples are created for filling.

Creating a new histogram

TH1F *TKRSTRIPSLYR5 = new TH1F("TKRSTRIPSLYR5", "Hit Tkr Strips BiLayer 5", 800, 0, 1600);

 
Creates a new 1-dimensional histogram, with a name TKRSTRIPSLYR5.  The last three parameters set up the histogram with 800 bins, starting from zero up to 1600.

Creating a new simple ntuple, where all columns are floats

TNtuple *tkrDigiTup= new TNtuple("tkrDigiTup", "example Ntuple", "TkrDigiCount:TotalHits");
 
Creates a new ntuple, named tkrDigiTup with 2 columns.  Those columns are titled:  TkrDigiCount and TotalHits.

 

Accessing the Histograms and Ntuple for filling while processing data

All histograms and ntuples created within the McHistDefine, DigiHistDefine, and ReconHistDefine are stored in an array that allows one to retrieve those objects using their name.  Here is an example accessing a histogram for filling:

((TH1F*)GetObjectPtr("TKRSTRIPSLYR5"))->Fill(stripNum);
 
To retrieve the histogram TKRSTRIPSLYR5, its name is provided as a parameter. The object must be cast explicitly to TH1F*.
Then we can call TH1F::Fill routine to update the histogram.

 Here is an example accessing an ntuple for filling:

    Float_t digiArr[2] = { (Float_t)numTkrDigi, (Float_t)totalHits };
    ((TNtuple*)GetObjectPtr("tkrDigiTup"))->Fill(digiArr);
 
Create a simple array to store the two values that are to be stored in the ntuple.
Access the tkrDigiTup using its name, and casting it to a TNtuple*.  We can then call the TNtuple::Fill method to add a new row to the ntuple.