forked from PandoraPFA/LArRecoND
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LArSP.h
154 lines (132 loc) · 4.52 KB
/
LArSP.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/**
* @file LArRecoND/include/LArSP.h
*
* @brief Header file defining the "SpacePoint" (SP) format.
* Based on autogenerated ROOT code with Pandora-style edits
*
* $Log: $
*/
#ifndef PANDORA_LAR_SP_H
#define PANDORA_LAR_SP_H 1
#include "TChain.h"
#include "TFile.h"
#include "TROOT.h"
// Header file for the classes stored in the TTree if any.
#include <vector>
namespace lar_nd_reco
{
class LArSP
{
public:
/**
* @brief Constructor requiring TTree pointer
*
* @param tree The TTree pointer
*/
LArSP(TTree *tree = nullptr);
/**
* @brief Destructor
*/
virtual ~LArSP();
/**
* @brief Get the corresponding data entry
*
* @param entry The entry integer index
*
* @return Total number of bytes read
*/
virtual Int_t GetEntry(Long64_t entry);
/**
* @brief Initialise using the input TTree
*
* @param tree The input TTree
*/
virtual void Init(TTree *tree);
TTree *m_fChain; ///< pointer to the analyzed TTree or TChain
Int_t m_fCurrent; ///< current Tree number in a TChain
// Declaration of leaf types
Int_t m_event;
Int_t m_subrun;
Int_t m_run;
Int_t m_event_start_t;
Int_t m_event_end_t;
std::vector<float> *m_x = nullptr;
std::vector<float> *m_y = nullptr;
std::vector<float> *m_z = nullptr;
std::vector<float> *m_ts = nullptr;
std::vector<float> *m_charge = nullptr;
std::vector<float> *m_E = nullptr;
// List of branches
TBranch *m_b_eventID = nullptr;
TBranch *m_b_subrun = nullptr;
TBranch *m_b_run = nullptr;
TBranch *m_b_event_start_t = nullptr;
TBranch *m_b_event_end_t = nullptr;
TBranch *m_b_x = nullptr;
TBranch *m_b_y = nullptr;
TBranch *m_b_z = nullptr;
TBranch *m_b_ts = nullptr;
TBranch *m_b_charge = nullptr;
TBranch *m_b_E = nullptr;
};
//------------------------------------------------------------------------------------------------------------------------------------------
LArSP::LArSP(TTree *tree) : m_fChain(nullptr)
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
if (tree == nullptr)
{
TFile *f = dynamic_cast<TFile *>(gROOT->GetListOfFiles()->FindObject("MiniRun3_1E19_RHC.flow_v3.00000.FLOWunMergedhits_withTruth.root"));
if (!f || !f->IsOpen())
{
f = new TFile("MiniRun3_1E19_RHC.flow_v3.00000.FLOWunMergedhits_withTruth.root");
}
f->GetObject("events", tree);
}
Init(tree);
}
//------------------------------------------------------------------------------------------------------------------------------------------
LArSP::~LArSP()
{
if (!m_fChain)
return;
delete m_fChain->GetCurrentFile();
}
//------------------------------------------------------------------------------------------------------------------------------------------
Int_t LArSP::GetEntry(Long64_t entry)
{
// Read contents of entry.
if (!m_fChain)
return 0;
return m_fChain->GetEntry(entry);
}
//------------------------------------------------------------------------------------------------------------------------------------------
void LArSP::Init(TTree *tree)
{
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the branch addresses and branch
// pointers of the tree will be set.
// It is normally not necessary to make changes to the generated
// code, but the routine can be extended by the user if needed.
// Init() will be called many times when running on PROOF
// (once per file to be processed).
// Set branch addresses and branch pointers
if (!tree)
return;
m_fChain = tree;
m_fCurrent = -1;
m_fChain->SetMakeClass(1);
m_fChain->SetBranchAddress("event", &m_event, &m_b_eventID);
m_fChain->SetBranchAddress("subrun", &m_subrun, &m_b_subrun);
m_fChain->SetBranchAddress("run", &m_run, &m_b_run);
m_fChain->SetBranchAddress("event_start_t", &m_event_start_t, &m_b_event_start_t);
m_fChain->SetBranchAddress("event_end_t", &m_event_end_t, &m_b_event_end_t);
m_fChain->SetBranchAddress("x", &m_x, &m_b_x);
m_fChain->SetBranchAddress("y", &m_y, &m_b_y);
m_fChain->SetBranchAddress("z", &m_z, &m_b_z);
m_fChain->SetBranchAddress("ts", &m_ts, &m_b_ts);
m_fChain->SetBranchAddress("charge", &m_charge, &m_b_charge);
m_fChain->SetBranchAddress("E", &m_E, &m_b_E);
}
} // end namespace lar_nd_reco
#endif