BmnRoot
26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
count_events.C
Go to the documentation of this file.
1
/*
2
BM@N alignment routine
3
BM@N experiment at NICA complex, JINR, 2025
4
5
Department: Math & Soft Group of HEP lab
6
Author: Igor Polev, polev@jinr.int
7
8
Count number of events in a ROOT file
9
*/
10
11
// headers below are for IDE syntax to work and they will be
12
// turned off during execution in ROOT macro mode
13
#ifndef __CLING__
14
#include "
TCollection.h
"
15
#include "
TFile.h
"
16
#include "
TKey.h
"
17
#include "
TObject.h
"
18
#include "
TTree.h
"
19
#endif
20
21
void
count_events
(
const
char
* filename)
22
{
23
TFile
* f =
TFile::Open
(filename,
"READ"
);
24
if
(!f || f->IsZombie()) {
25
printf(
"0\n"
);
26
return
;
27
}
28
TIter
next(f->GetListOfKeys());
29
TKey
* key;
30
while
((key = (
TKey
*)next())) {
31
TObject
* obj = key->
ReadObj
();
32
if
(obj && obj->
InheritsFrom
(
TTree::Class
())) {
33
// print out the answer
34
printf(
"%lld\n"
, ((
TTree
*)obj)->GetEntries());
35
f->Close();
36
return
;
37
}
38
}
39
printf(
"0\n"
);
40
f->Close();
41
}
TCollection.h
TFile.h
TKey.h
TObject.h
TTree.h
TFile
TFile::Open
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
TIter
TKey
TKey::ReadObj
virtual TObject * ReadObj()
TObject
TObject::InheritsFrom
virtual Bool_t InheritsFrom(const char *classname) const
TTree
TTree::Class
static TClass * Class()
count_events
void count_events(const char *filename)
Definition
count_events.C:21
align_new
service
count_events.C
Generated on
for BmnRoot by
1.17.0