EDEpReader
Loading...
Searching...
No Matches
Requirements

Installation

Get the code

$ git clone https://baltig.infn.it/vpia/edep-reader.git

Build the binaries

$ cd edep-reader
$ mkdir build
$ mkdir install
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=./../install ./..
$ make
$ make install

In the intall folder, there will be a lib folder, containing the libEDEPTree.so library, and the include folder, containing all the header files.

Setup

$ source install/setup.sh

How to use the library

The library can be imported and used in any project (I think? I tried only with cmake..).

An example of a CMakeLists file is available in the examples folder, where a simple code is also present.

What are we talking about?

The EDEPTree library provides a wrapper to the edepsim output. It creates a tree structure with a parent-child relation between all the trajectories in each event. Each trajectory stores information on it own hits and trajectory points (see here for more detaild on what those are).

Four classes are available:

Documentation on each class is available here as doxygen documentation. A brief and not complete description is also provided below.

EDEPHit

This class is simply a wrapper of the EDepSim's TG4HitSegment class. It provides getters for each member:

GetStart() // returns the TLorentzVector of the start point of the hit
GetStop() // returns the TLorentzVector of the stop point of the hit
GetEnergyDeposit() // return the primary energy deposit of the hit
GetSecondaryDeposit() // return the secondary energy deposit of the hit
GetTrackLength() // return the length of the hit (I'm not sure.. never used it..)
GetGetContrib() // return the id of the track which contributed to this hit segment
GetPrimaryId() // return the id of the primary particle creating this hit
GetId() // return the id of the hit

EDEPTrajectoryPoint

This class is simply a wrapper of the EDepSim's TG4TrajectoryPoint class. It provides getters for each member:

GetPosition() // return the position of the point as a TLorentzVector
GetMomentum() // return the momentum of the point as a TLorentzVector
GetProcess() // return the id of the process generating the point
GetSubprocess() // return return the id of the subprocess generating the point

EDEPTrajectory

This class stores all the information of the hits and points of a trajectory, as well as providing utilities to get other information on the trajectory, such as having hits at certain times or entering/exiting specific subdetectors. It also stores information on the trajectory that generated this one (the parent), and all the trajectories generated by this one (the children).

Here are the available getters:

Get() // return this trajectory
GetParent() // return the parent of this trajectory
GetId() // return the id of this trajectory
GetParentId() // return the id of this trajectory's parent
GetPDGCode() // return the PDG code of this trajectory
GetInitialMomentum() // return the initial momentum of this trajectory
GetChildrenTrajectories() // return a std::vector of all the children trajectories
GetHitMap() // return a map of all the hits of this trajectory. The hits are
// separated based on the subdetector, with the subdetector being
// the key (see the components section below)
GetTrajectoryPoints() // return a std::vector of all the points of this trajectory

Details for all the other functions (what they do, the argumens and what they return) are provided as Doxygen comments in the EDEPTrajectory.cpp file.

EDEPTree

This class reads the EDepSim file and constructs the tree structure of parents-children trajectories. It uses iterators to help with the navigation of the tree and also provides utilities to select or filter different samples of trajectories in the tree.

The tree must be initialized first:

auto fMc = TFile::Open("<EDEPSIM ROOT FILE>");
// read MC TTree
TTreeReader tMc("EDepSimEvents", fMc);
TTreeReaderValue<TG4Event> ev(tMc, "Event");
TGeoManager* geo = 0;
geo = (TGeoManager*)fMc->Get("EDepSimGeometry");
auto nev = tMc.GetEntries();
int ev_id = 12;
tMc.SetEntry(ev_id);
EDEPTree tree;
tree.InizializeFromEdep(*ev.Get(), geo);
Represents a tree structure of trajectories.
Definition EDEPTree.h:15
void InizializeFromEdep(const TG4Event &edep_event, TGeoManager *geo)
Initializes the tree from a TG4Event and TGeoManager.
Definition EDEPTree.cpp:127

This will fill all the trajectories with the corresponding quantities, and will create the parent-child connection between all trajectories.

To navigate the tree, filter the trajectories and so on, different functions are available. Details on each function are available both in the header file and in the source file (EDEPTree.h and EDEPTree.cpp) as doxygen comments. Moreover, the EDEPReader.cpp file provides some example on how to use a tree to select some trajectories or extract their information.

Every time a search for trajectories in the tree fails, the end of the tree or the end of the trajectory is returned. Protecting from accessing the end element is a responsability of the user. Failing to do that will crash the code (that's wanted). This could happen in the EDEPReader example too if the example tries to access not existing trajectories.