BuildTree is a routine in the eic-smear package that processes output from the EIC task-force Monte Carlo generators into ROOT tree files. It supercedes the ROOT macro used for the previous generation of ROOT trees.
The output from most of the Monte Carlo generators used by the EIC task force is in the form of ASCII text files, following a common format. Specifically, PYTHIA, PEPSI, RAPGAP, MILOU, DJANGOH, gmc_trans and DPMJet generate their output in this way. The format of files produced by each is explained in the page for the corresponding generator.
The text files can be processed into a ROOT TTree for analysis by a routine named BuildTree. BuildTree is provided as part of the EIC smearing shared library, and is loaded into and run from ROOT. This library also contains an event class for each of the aforementioned generators, a common particle class shared by each event type, plus numerous other utility classes. This page describes the use of the BuildTree function itself and briefly describes event class. Documentation for the full class structure contained in the library is available here.
BuildTree takes four arguments, the first of which is mandatory and the rest of which are optional:
- A character string giving the name of the input ASCII file.
- The directory in which to write the output file. By default this is the current directory.
- The maximum number of events to process. The default value will cause the macro to process all events in the input file.
- The name of a log file, from which it will attempt to extract information about the generated cross section. By default BuildTree will attempt to locate a log file automatically based on the name of the input ASCII file.
Note that you do not need to specify which Monte Carlo generators was used to generate the events; the common ASCII format specifies the generator in the input file. For example, to process the first 100,000 events in the file "myPythiaEvents.txt":
root  BuildTree("myPythiaEvents.txt", ".", 100000);
This will generate a ROOT file named "myPythiaEvents.root" in the current directory containing. The total number of events and particles processed and the running time are printed to the screen when the function completes. An example of running BuildTree() is included in the distribution in a macro named build.cxx.
The output file contains a TTree named EICTree. Each entry in the TTree is a single event. The event contains two parts:
- A collection of event-wise properties, such as event number, process ID and kinematics quantities.
- A list of all the particles in the event.
The format of the particles is common to all the generators, while the event variables typically differ between generators, though some are common to one or more. Events from each generator are described by their own C++ class. All classes are contained in the erhic namespace to avoid clashing with other code (though the main BuildTree routine remains in the global namespace). For example, erhic::EventPythia describes a PYTHIA event, while erhic::EventDjangoh describes a DJANGOH event. Particles are described by a C++ class named erhic::ParticleMC. A simple way to view descriptions of the variables stored in an event are to create an object of the appropriate type in ROOT and call its Dump() method:
root  erhic::EventPythia event root  event.Dump() ==> Dumping object at: 0x000000017e4bf490, name=erhic::EventPythia, class=erhic::EventPythia nucleon 2147483647 /< PDG code of the hadron beam, tgtparton 2147483647 /< PDG code of the struck parton …
Each variable in the event is listed along with a description. Please see the class documentation for full descriptions of the classes.
Simple analyses can be performed using TTree::Draw() statements. For example, to draw the polar angle distribution of all electrons in events with Q2 greater than 1 GeV2:
root EICTree->Draw("theta","id==11 && QSquared>1.");
More complex analyses involve reading each event into memory in a loop and performing the required processing. An example macro for doing this, named read.cxx, is included in the distribution.