Jpp
19.0.0
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
externals
km3net-dataformat
examples
cpp
readEvtFile.cc
Go to the documentation of this file.
1
#include "
km3net-dataformat/offline/Evt.hh
"
2
#include "
km3net-dataformat/definitions/root.hh
"
3
#include "TFile.h"
4
#include "TTree.h"
5
#include <iostream>
6
7
int
main
(
int
argc,
char
* argv[]){
8
using namespace
std;
9
if
(argc != 2) {
10
cout <<
"usage: readEvtFile file.root"
<< endl;
11
return
1;
12
}
13
//TFile::Open works with local and remote files (xrootd)
14
TFile *
f1
= TFile::Open(argv[1]);
15
//check that file is open
16
if
(
f1
==
nullptr
) {
17
cerr <<
"File can't be open."
<< endl;
18
return
1;
19
}
20
//TTree *EvtTree = (TTree*)f1->Get("E");
21
TTree *EvtTree = (TTree*)
f1
->Get(
TTREE_OFFLINE_EVENT
);
// TTREE_OFFLINE_EVENT is in km3net-dataformat/definitions/root.hh
22
if
(EvtTree == 0) {
23
cerr <<
"File has no "
<<
TTREE_OFFLINE_EVENT
<<
" tree."
<< endl;
24
return
1;
25
}
26
Evt
*evt =
nullptr
;
27
EvtTree->SetBranchAddress(
"Evt"
,&evt);
28
Long64_t nentries = EvtTree->GetEntries();
29
for
(Long64_t
i
=0;
i
<nentries;
i
++) {
30
EvtTree->GetEntry(
i
);
31
cout <<
"Event ID: "
<< evt->
id
<< endl;
//an example of accessing Evt struct object
32
evt->print();
//an example of using Evt struct function
33
}
34
f1
->Close();
35
return
0;
36
}
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
root.hh
GAUSS_LEGENDRE::f1
const JPolynome f1(1.0, 2.0, 3.0)
Function.
i
then rm i
Definition:
JEvtReweightMupageParameterScan.sh:309
TTREE_OFFLINE_EVENT
static const char *const TTREE_OFFLINE_EVENT
ROOT TTree name.
Definition:
root.hh:19
Evt.hh
Evt::id
int id
offline event identifier
Definition:
Evt.hh:22
Evt
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition:
Evt.hh:20
Generated by
1.8.5