cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
ROOTTreeInfo.h
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2019-2024 Laurent Forthomme
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef CepGen_EventInterfaces_ROOTTreeInfo_h
20
#define CepGen_EventInterfaces_ROOTTreeInfo_h
21
22
#include <TFile.h>
23
#include <TTree.h>
24
25
#include "
CepGen/Event/Event.h
"
26
27
namespace
ROOT
{
29
class
CepGenRun
{
30
public
:
31
static
constexpr
const
char
*
TREE_NAME
=
"run"
;
32
33
static
CepGenRun
load
(TFile*,
const
std::string& run_tree =
TREE_NAME
);
34
static
CepGenRun
load
(
const
std::string&,
const
std::string& run_tree =
TREE_NAME
);
35
36
double
sqrt_s
{-1.};
37
double
xsect
{-1.};
38
double
errxsect
{-1.};
39
unsigned
int
num_events
{0};
40
unsigned
int
litigious_events
{0};
41
std::string
process_name
;
42
std::string
process_parameters
;
43
44
explicit
CepGenRun
();
45
void
clear
();
46
void
create
();
47
inline
TTree*
tree
() {
return
tree_.get(); }
48
void
fill
();
49
void
attach
(TFile* file,
const
std::string& run_tree =
TREE_NAME
);
51
void
attach
(
const
std::string& filename,
const
std::string& run_tree =
TREE_NAME
) {
52
attach
(TFile::Open(filename.data()), run_tree);
53
}
54
55
private
:
56
std::shared_ptr<TTree> tree_;
57
};
58
60
class
CepGenEvent
{
61
public
:
62
inline
CepGenEvent
() {
clear
(); }
63
64
// book a sufficiently large number to allow the large multiplicity of excited proton fragmentation products
65
static
constexpr
size_t
MAX_PART
= 5000;
66
static
constexpr
const
char
*
TREE_NAME
=
"events"
;
67
68
static
CepGenEvent
load
(TFile*,
const
std::string& events_tree =
TREE_NAME
);
69
static
CepGenEvent
load
(
const
std::string&,
const
std::string& events_tree =
TREE_NAME
);
70
71
cepgen::Event::EventMetadata
metadata
;
72
float
gen_time
{-1.};
73
float
tot_time
{-1.};
74
float
weight
{-1.};
75
int
np
{0};
76
double
pt
[
MAX_PART
];
77
double
eta
[
MAX_PART
];
78
double
phi
[
MAX_PART
];
79
double
rapidity
[
MAX_PART
];
80
double
E
[
MAX_PART
];
81
double
m
[
MAX_PART
];
82
double
charge
[
MAX_PART
];
83
int
pdg_id
[
MAX_PART
];
84
int
parent1
[
MAX_PART
];
85
int
parent2
[
MAX_PART
];
86
int
stable
[
MAX_PART
];
87
int
role
[
MAX_PART
];
88
int
status
[
MAX_PART
];
89
90
void
clear
();
91
inline
TTree*
tree
() {
return
tree_.get(); }
92
void
create
();
93
94
void
attach
();
95
void
attach
(TFile* f,
const
std::string& events_tree =
TREE_NAME
);
97
void
attach
(
const
std::string& filename,
const
std::string& events_tree =
TREE_NAME
);
98
99
//--- direct cepgen::Event I/O helpers
100
101
void
fill
(
const
cepgen::Event
&,
bool
compress =
false
);
102
bool
next
(
cepgen::Event
&);
103
104
private
:
105
std::shared_ptr<TTree> tree_;
106
std::unique_ptr<TFile> file_;
107
bool
tree_attached_{
false
};
108
unsigned
long
long
num_read_events_{0ull};
109
};
110
}
// namespace ROOT
111
112
#endif
Event.h
ROOT::CepGenEvent
All useful information about a generated event.
Definition
ROOTTreeInfo.h:60
ROOT::CepGenEvent::m
double m[MAX_PART]
Particles mass, in GeV/c .
Definition
ROOTTreeInfo.h:81
ROOT::CepGenEvent::load
static CepGenEvent load(TFile *, const std::string &events_tree=TREE_NAME)
Definition
ROOTTreeInfo.cpp:90
ROOT::CepGenEvent::rapidity
double rapidity[MAX_PART]
Particles rapidity.
Definition
ROOTTreeInfo.h:79
ROOT::CepGenEvent::charge
double charge[MAX_PART]
Particles charges, in e.
Definition
ROOTTreeInfo.h:82
ROOT::CepGenEvent::next
bool next(cepgen::Event &)
Read the next event in the file.
Definition
ROOTTreeInfo.cpp:203
ROOT::CepGenEvent::eta
double eta[MAX_PART]
Particles pseudo-rapidity.
Definition
ROOTTreeInfo.h:77
ROOT::CepGenEvent::parent1
int parent1[MAX_PART]
First particles mother.
Definition
ROOTTreeInfo.h:84
ROOT::CepGenEvent::CepGenEvent
CepGenEvent()
Definition
ROOTTreeInfo.h:62
ROOT::CepGenEvent::fill
void fill(const cepgen::Event &, bool compress=false)
Fill the tree with a new event.
Definition
ROOTTreeInfo.cpp:159
ROOT::CepGenEvent::metadata
cepgen::Event::EventMetadata metadata
Definition
ROOTTreeInfo.h:71
ROOT::CepGenEvent::status
int status[MAX_PART]
Integer status code.
Definition
ROOTTreeInfo.h:88
ROOT::CepGenEvent::phi
double phi[MAX_PART]
Particles azimuthal angle.
Definition
ROOTTreeInfo.h:78
ROOT::CepGenEvent::tree
TTree * tree()
Retrieve the ROOT tree.
Definition
ROOTTreeInfo.h:91
ROOT::CepGenEvent::weight
float weight
Event weight.
Definition
ROOTTreeInfo.h:74
ROOT::CepGenEvent::E
double E[MAX_PART]
Particles energy, in GeV.
Definition
ROOTTreeInfo.h:80
ROOT::CepGenEvent::np
int np
Number of particles in the event.
Definition
ROOTTreeInfo.h:75
ROOT::CepGenEvent::gen_time
float gen_time
Event generation time.
Definition
ROOTTreeInfo.h:72
ROOT::CepGenEvent::tot_time
float tot_time
Total event generation time.
Definition
ROOTTreeInfo.h:73
ROOT::CepGenEvent::parent2
int parent2[MAX_PART]
Last particles mother.
Definition
ROOTTreeInfo.h:85
ROOT::CepGenEvent::role
int role[MAX_PART]
Particles role in the event.
Definition
ROOTTreeInfo.h:87
ROOT::CepGenEvent::MAX_PART
static constexpr size_t MAX_PART
Maximal number of particles in event.
Definition
ROOTTreeInfo.h:65
ROOT::CepGenEvent::attach
void attach()
Attach the event tree reader to a tree.
Definition
ROOTTreeInfo.cpp:135
ROOT::CepGenEvent::pdg_id
int pdg_id[MAX_PART]
Integer particles PDG id.
Definition
ROOTTreeInfo.h:83
ROOT::CepGenEvent::clear
void clear()
Reinitialise the event content.
Definition
ROOTTreeInfo.cpp:102
ROOT::CepGenEvent::create
void create()
Populate the tree and all associated branches.
Definition
ROOTTreeInfo.cpp:111
ROOT::CepGenEvent::TREE_NAME
static constexpr const char * TREE_NAME
Output tree name.
Definition
ROOTTreeInfo.h:66
ROOT::CepGenEvent::stable
int stable[MAX_PART]
Whether the particle must decay or not.
Definition
ROOTTreeInfo.h:86
ROOT::CepGenEvent::pt
double pt[MAX_PART]
Particles transverse momentum.
Definition
ROOTTreeInfo.h:76
ROOT::CepGenRun
All useful information about a generation run.
Definition
ROOTTreeInfo.h:29
ROOT::CepGenRun::CepGenRun
CepGenRun()
Definition
ROOTTreeInfo.cpp:23
ROOT::CepGenRun::process_name
std::string process_name
Unique name of the process generated in this run.
Definition
ROOTTreeInfo.h:41
ROOT::CepGenRun::litigious_events
unsigned int litigious_events
Number of litigious events in run.
Definition
ROOTTreeInfo.h:40
ROOT::CepGenRun::xsect
double xsect
Process cross section, in pb.
Definition
ROOTTreeInfo.h:37
ROOT::CepGenRun::errxsect
double errxsect
Uncertainty on process cross section, in pb.
Definition
ROOTTreeInfo.h:38
ROOT::CepGenRun::tree
TTree * tree()
Retrieve the ROOT tree.
Definition
ROOTTreeInfo.h:47
ROOT::CepGenRun::attach
void attach(TFile *file, const std::string &run_tree=TREE_NAME)
Attach the run tree reader to a given tree Attach the run tree reader to a given file.
Definition
ROOTTreeInfo.cpp:64
ROOT::CepGenRun::clear
void clear()
Reinitialise the run tree.
Definition
ROOTTreeInfo.cpp:37
ROOT::CepGenRun::process_parameters
std::string process_parameters
Serialised process parameters.
Definition
ROOTTreeInfo.h:42
ROOT::CepGenRun::num_events
unsigned int num_events
Number of events generated in run.
Definition
ROOTTreeInfo.h:39
ROOT::CepGenRun::load
static CepGenRun load(TFile *, const std::string &run_tree=TREE_NAME)
Definition
ROOTTreeInfo.cpp:25
ROOT::CepGenRun::create
void create()
Populate the run tree.
Definition
ROOTTreeInfo.cpp:45
ROOT::CepGenRun::TREE_NAME
static constexpr const char * TREE_NAME
Output tree name.
Definition
ROOTTreeInfo.h:31
ROOT::CepGenRun::fill
void fill()
Fill the run tree.
Definition
ROOTTreeInfo.cpp:58
ROOT::CepGenRun::attach
void attach(const std::string &filename, const std::string &run_tree=TREE_NAME)
Definition
ROOTTreeInfo.h:51
ROOT::CepGenRun::sqrt_s
double sqrt_s
Centre of mass energy for beam particles.
Definition
ROOTTreeInfo.h:36
cepgen::Event
Container for the information on the in- and outgoing particles' kinematics.
Definition
Event.h:28
ROOT
Definition
ROOTTreeInfo.cpp:22
cepgen::Event::EventMetadata
Collection of key -> value pairs storing event metadata.
Definition
Event.h:130
CepGenAddOns
ROOTWrapper
ROOTTreeInfo.h
Generated on Mon Jul 29 2024 for CepGen by
1.9.7