Defining Histograms, Ntuples
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. The methods are of interest to users strictly for the purpose of updating them to modify which 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 the 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, 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.
Example - Accessing a histogram for filling:
((TH1F*)GetObjectPtr("TKRSTRIPSLYR5"))->Fill(stripNum);
To retrieve the histogram TKRSTRIPSLYR5, provide its name as a parameter.
The object must be cast explicitly to TH1F*.
You can then call TH1F::Fill routine to update the histogram.
Example - Accessing an ntuple for filling:
Float_t digiArr[2] = { (Float_t)numTkrDigi, (Float_t)totalHits };
((TNtuple*)GetObjectPtr("tkrDigiTup"))->Fill(digiArr);
Creates a simple array to store the two values that are to be stored in the ntuple and accesses the tkrDigiTup using its name, then casts it to a TNtuple*.
You can then call the TNtuple::Fill method to add a new row to the ntuple.
Owned by: Heather Kelly
Last updated by: Chuck Patterson
05/03/2005 |
|
|