NAGASH 0.9.8
Next Generation Analysis System
Loading...
Searching...
No Matches
Advance Usages

Some tips to make your framework run faster.

Some tips to make your framework run faster.

Avoid using "Get" in NAGASH::LoopEvent::Execute()

The NAGASH::LoopEvent::Execute() will be called for each entry in the TTree, and methods like NAGASH::ResultGroup::Get(), NAGASH::ConfigTool::GetPar() and NAGASH::PlotGroup::GetPlot1D() involves a std::map::find called which is unnecessary and time-consuming. To avoid the unnecessary cost, you can store the pointer of your objects or value of booked parameters as member variables. An example is shown in this.

Use NAGASH::TFileHelper instead of file name to <tt>Recover</tt>

The opening and close of TFile are time-consuming. If you want to recover massive plots in your program, you should create a NAGASH::TFileHelper object and pass it to methods like NAGASH::PlotGroup::Recover() instead of the file name.

Use fixed-bin-size histograms whenever possible

Consider the following two ways of defining a histogram:

// fixed bin size
TH1D *h1 = new TH1D("h1", "h1", 100, 0, 100);
// varied bin size
double bindiv[101];
for (int i=0;i <= 100;i++)
bindiv[i] = i;
TH1D *h2 = new TH1D("h2", "h2", 100, bindiv);

The two histograms are "identical". But the filling of h2 will be much slower because ROOT uses binary search to decide the bin number. For h1, since the size of bins are fixed, ROOT can directly calculate the bin number, thus the filling will be faster.