-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestModule.h
227 lines (183 loc) · 6.36 KB
/
TestModule.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#ifndef TESTMODULE_HH
#define TESTMODULE_HH
// Standard library:
#include <map>
#include <string>
#include <vector>
// Third party:
// - Bayeux/mygsl:
#include <mygsl/rng.h>
// - Bayeux/dpp:
#include <dpp/base_module.h>
// Third Party
#include <TFile.h>
#include <TTree.h>
#include <TH1F.h>
// - Bayeux
//#include "bayeux/dpp/base_module.h"
//#include "bayeux/mygsl/rng.h"
//#include "bayeux/datatools/service_manager.h"
//#include "bayeux/geomtools/manager.h"
//#include "bayeux/geomtools/geometry_service.h"
//#include "bayeux/geomtools/line_3d.h"
//#include "bayeux/geomtools/helix_3d.h"
// - Falaise
//#include "falaise/snemo/datamodels/particle_track_data.h"
//#include "falaise/snemo/datamodels/particle_track.h"
//#include "falaise/snemo/datamodels/calibrated_calorimeter_hit.h"
#include "falaise/snemo/datamodels/calibrated_data.h"
//#include "falaise/snemo/datamodels/tracker_clustering_data.h"
//#include "falaise/snemo/datamodels/base_trajectory_pattern.h"
//#include "falaise/snemo/datamodels/event_header.h"
/******************************************************************************/
/* ANALYSIS SCRIPT SWITCH (OUTPUT MODE / TYPE SWITCH) */
/******************************************************************************/
// This switch changes between the origional C++ analysis code
// and a new Python analysis script (which is not debugged yet)
#define CPLUSPLUS_ANALYSIS 1
#define PYTHON_ANALYSIS 0
/******************************************************************************/
/* */
/******************************************************************************/
// TODO: clean
// TODO: should remove this if CPLUSPLUS_ANALYSIS
//#if PYTHON_ANALYSIS
typedef struct GeneratorEventStorage
{
//double vertex_x_;
//double vertex_y_;
//double vertex_z_;
//int nofparticles_;
//std::vector<int>* pdgs_;
//std::vector<double>* px_;
//std::vector<double>* py_;
//std::vector<double>* pz_;
// new
int n_gamma_;
int n_positron_;
int n_electron_;
int n_alpha_;
// TODO: some events might have other particles in them - at the moment
// i do not handle those cases
// new - category flag for caffe
unsigned long long caffe_category_;
}; //generatoreventstorage;
//#endif
// Notes:
// TestTankStorage is different from the other storage formats.
// Other storage formats use vectors to keep all data for each
// event separated.
// The C++ analysis code loops over a single loop and the data
// is formatted such that all events are "rolled together".
// In other words: Each event is a set of timestamps rather than
// a vector of timestamps.
// The regular output file is always created. The C++ analysis
// file is only created if the CPLUSPLUS_ANALSIS preprocessor
// flag is set.
#if CPLUSPLUS_ANALYSIS
typedef struct TestTankStorage
{
Float_t time = 0;
Float_t delay = 0;
Float_t delay_since_good_trigger = 0;
Int_t duration = 0;
Float_t plasma_propagation_time = 0;
Bool_t good_trigger = 0;
Bool_t prev_good_trigger = 0;
Bool_t with_cathode = 0;
Float_t anode_peak = 0;
Float_t anode_time = 0;
Float_t cathode_peak = 0;
Float_t cathode_time = 0;
Float_t position = 0;
Float_t half_position = 0;
Float_t stop1 = 0;
Float_t stop1_peak = 0;
Float_t stop1_type = 0;
Float_t stop2 = 0;
Float_t stop2_peak = 0;
Float_t stop2_type = 0;
Int_t stopA = 0;
Float_t deriv_rms = 0;
Float_t feast_t0 = 0;
Float_t feast_t1 = 0;
Float_t feast_t2 = 0;
Float_t feast_t3 = 0;
Float_t feast_t4 = 0;
TH1F *anode_histo = (TH1F*)0;
TH1F *deriv_histo = (TH1F*)0;
TH1F *cathode_histo = (TH1F*)0;
};
#endif
typedef struct TimestampStorage
{
// 7 geiger timing
int count;
std::vector<double> * anodic_t0;
std::vector<double> * anodic_t1;
std::vector<double> * anodic_t2;
std::vector<double> * anodic_t3;
std::vector<double> * anodic_t4;
std::vector<double> * cathodic_t5;
std::vector<double> * cathodic_t6;
// xy location of hit
std::vector<double> * cell_x;
std::vector<double> * cell_y;
// plasma propagation time
// vector format, as obtained from calibrated_tracker_hit class
std::vector<double> * plasma_propagation_time;
}; //timestampstorage;
class TestModule : public dpp::base_module
{
public:
/// Set the external PRNG
void set_external_random(mygsl::rng& rng_);
/// Reset the external PRNG
void reset_external_random();
/// Check if the module use an external PRNG
bool has_external_random() const;
TestModule();
virtual ~TestModule();
virtual void initialize(const datatools::properties& myConfig,
datatools::service_manager& flServices,
dpp::module_handle_dict_type& moduleDict);
virtual dpp::base_module::process_status process(datatools::things& workItem);
virtual void reset();
protected:
/// Set default attributes values
void _set_defaults();
/// Getting random number generator
mygsl::rng& _get_random();
private:
std::string _module_category_; //!< The geometry category of the SuperNEMO module
mygsl::rng _random_; //!< internal PRN generator
mygsl::rng* _external_random_; //!< external PRN generator
std::string _CD_label_; //!< The label of the calibrated data bank
#if CPLUSPLUS_ANALYSIS
// Local storage
// Matches data obtained from testtank
// Additional variables for C++ analysis now in structure
TestTankStorage store_;
#endif
// Local storage
TimestampStorage timestamp_;
GeneratorEventStorage gen_;
// configurable data member
#if PYTHON_ANALYSIS
std::string filename_output_;
#endif
#if CPLUSPLUS_ANALYSIS
std::string filename_output_cpp_;
#endif
// ROOT variables
#if PYTHON_ANALYSIST
File* hfile_;
TTree* tree_;
#endif
#if CPLUSPLUS_ANALYSIS
TFile* hfile_cpp_;
TTree* tree_cpp_;
#endif
DPP_MODULE_REGISTRATION_INTERFACE(TestModule)
};
#endif