Analysis Backend
Using a physics object
Creating histograms
Command-Line Parsing
To-Do
Compiling
File Locations
Quick Start
A common backend has been constructed for use in the studies. All physics objects are defined in headers files contained within the interface
directory. These header files handle reading from ggNtuples
, applying basic object selection, and returning objects containing all related information. When writing an analyzer, simply include headers for whichever objects you intend to use. All related data will be read and given to you to do the real analysis work.
Including a new phyiscs object in your analysis code is as easy as adding a single #include
statement. For example, if you want to use electrons in your analysis, simply add
#include "interface/electron_factory.h"
This will include the Electron
class as well as the Electron_Factory
. The Electron
class is the base class used to represent a single electron and all associated information. The Electron_Factory
class is used to construct all Electron
s in a single event after applying a loose default selection. In order to read data from the input ROOT file, the factory must have its member variables associated with TBranches. This is done in the constructor as follows
auto electron_factory = Electron_Factory(tree);
Now, the factory is ready to be used in the event loop. The factory is run once per event to take the information from the input TBranches and produce physics objects. The Run_Factory()
function is used for this purpose. NOTE: you must do Run_Factory()
BEFORE accessing any information from the factory. The factory is run in the example below
electron_factory.Run_Factory();
The variable electron_factory
now contains all electron-related data from the ggNtuple. The Electron
s in the factory can be accessed with the member function getElectrons()
, which will return a shared pointer the the vector of Electron
s. This shared pointer, unlike the TBranches, will be sorted in order of decreasing pT.
All physics objects are filled in the exact same way making their inclusion as simple as possible. Be aware, a very loose selection is applied on all objects while running the factory. If this selection is too tight for your needs, it can be adjusted in the corresponding class's Run_Factory()
function.
The analysis backend comes with a simple class to hold histograms removing some boilerplate from your analysis code. (Note to self: Perhaps I can convert it to simply read JSON files when creating histograms. Then you can have a JSON file per analyzer and not have to make copies of the header). The histManager
class is used for this task. Histograms are created inside the hists
map and linked to a user-defined key. These histograms are initialized when a new histManager
is constructed, as shown below
auto hists = std::make_shared<histManager>(output_name);
The output_name
is used to create an output ROOT file with the corresponding name.
The histManager
provides functions for filling histograms in the map. This is the only way I can find to keep the histograms associated with the output file and available for writing in the end. One benefit is that extra functions are included for common cases beyond a simple fill. One example is the function, FillPrevBins
. This function's usage is shown below
hists->FillPrevBins("lead_gen_jet_eff", gen_jets->at(0).getPt(), 1.);
Calling this function will fill find the bin in which gen_jets->at(0).getPt()
belongs. Then, it will increase the bin content of all bins up to the selected bin by the value 1. This is especially useful when calculating efficiency as a function of some variable (here as a function of generator-level jet pT).
All histograms in the histManager
can be written to the associated file with the Write()
function.
hists->Write();
The histograms will all be written in the root directory of the TFile, then the TFile will be closed.
The CLParser
class can be used to easily parse command line options. The parser is constructed using argc and argv. The parser can currently handle: flags, options, and multi-options using the corresponding functions Flag
, Option
, MultiOption
. A description of each is shown below followed by a complete example.
- A flag is pretty self-explanatory. If the flag is passed,
Flag
will return true. Otherwise, it will be false - An option is a flag with an argument. If the flag is passed, the following string will be returned by the
Option
function - A multioption is a flag followed by multiple arguments. When the flag is passed, the subsequent strings will be read. The
MutliOption
function takes a parameter to set how many strings to read
auto parser = std::unique_ptr<CLParser>(new CLParser(argc, argv));
auto isNN = parser->Flag("-n");
auto input_name = parser->Option("-i");
auto bins = parser->Option("-b", 3);
In this case, the parser will be constructed with command line arguments. isNN
will be true if -n
is provided on the command line. input_name
will be filled with the string following the -i
flag. Lastly, bins
will be filled with the 3 strings following the -b
flag.
- add all variables to the classes
- complete initial studies
- enable user to pass JSON file to histManager