Repository navigation
Expand file tree
/
Copy pathfalaise-skeleton-module-sd_search_code_2.cc
More file actions
170 lines (103 loc) · 4.58 KB
/
Copy pathfalaise-skeleton-module-sd_search_code_2.cc
File metadata and controls
170 lines (103 loc) · 4.58 KB
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
#include <bayeux/dpp/chain_module.h>
#include <bayeux/mctools/base_step_hit.h>
#include <bayeux/mctools/simulated_data.h>
#include <falaise/snemo/datamodels/gg_track_utils.h>
#include <iostream>
#include <fstream>
using namespace std;
//#include "/sps/nemo/scratch/spratt/analysis/running_files/analysis_functions.C"
class falaise_skeleton_module_sd : public dpp::chain_module
{
public:
// Constructor
falaise_skeleton_module_sd();
// Destructor
virtual ~falaise_skeleton_module_sd();
// Initialisation function
virtual void initialize (const datatools::properties &,
datatools::service_manager &,
dpp::module_handle_dict_type &);
// Event processing function
dpp::chain_module::process_status process (datatools::things & event);
private:
int sd_event_counter;
int sd_passed_events;
bool sd_calo_details;
bool sd_tracker_details;
// Macro to register the module
DPP_MODULE_REGISTRATION_INTERFACE(falaise_skeleton_module_sd);
};
////////////////////////////////////////////////////////////////////
// Macro to add the module in the global register of data processing modules:
// The module defined by this class 'falaise_skeleton_module_sd' will be registered
// with the label ID 'FalaiseSkeletonModule_SD' (to use in pipeline configuration file)
ofstream event_num_file;
DPP_MODULE_REGISTRATION_IMPLEMENT(falaise_skeleton_module_sd, "FalaiseSkeletonModule_SD")
falaise_skeleton_module_sd::falaise_skeleton_module_sd()
{
std::cout << "falaise_skeleton_module_sd::falaise_skeleton_module_sd() called" << std::endl;
}
falaise_skeleton_module_sd::~falaise_skeleton_module_sd()
{
std::cout << "falaise_skeleton_module_sd::~falaise_skeleton_module_sd() called" << std::endl;
}
void falaise_skeleton_module_sd::initialize (const datatools::properties & module_properties, datatools::service_manager &, dpp::module_handle_dict_type &)
{
// std::cout << "falaise_skeleton_module_sd::initialize() called" << std::endl;
//open_file_UDD("/sps/nemo/scratch/spratt/analysis/background_studies/simulation_4/sim4_tk_PTD_cut_UDD.root");
event_num_file.open("n_capture_positions.txt");
sd_event_counter = 0;
if ( module_properties.has_key("calo_details"))
sd_calo_details = module_properties.fetch_boolean("calo_details");
else sd_calo_details = false;
if ( module_properties.has_key("tracker_details"))
sd_tracker_details = module_properties.fetch_boolean("tracker_details");
else sd_tracker_details = false;
this->_set_initialized(true);
}
dpp::chain_module::process_status falaise_skeleton_module_sd::process (datatools::things & event)
{
int current_event=0;
int ep_counter=0;
int em_counter=0;
double counter_ncap=0;
sd_event_counter+=1;
//cout<<sd_event_counter<<endl;
// Skip processing if SD bank is not present
if (!event.has("SD"))
{
// std::cout << "======== no SD bank in event " << sd_event_counter++ << " ========" << std::endl;
return dpp::base_module::PROCESS_SUCCESS;
}
// Retrieve the SD bank
const mctools::simulated_data & SD = event.get<mctools::simulated_data>("SD");
// std::cout << "======== SD bank of event " << sd_event_counter++ << " ========" << std::endl;
// Calorimeter step hit categories (3 differents labels)
const std::vector<std::string> calo_hit_categories = {"calo", "xcalo", "gveto"};
size_t nb_tracker_step_hits = SD.has_step_hits("__visu.tracks") ? SD.get_step_hits("__visu.tracks").size() : 0;
// std::cout << "=> " << nb_tracker_step_hits << " 'gg' step hit(s)" << std::endl;
if ( (nb_tracker_step_hits > 0))
{
// Browse the tracker step hits
for (const auto & a_step_hit : SD.get_step_hits("__visu.tracks"))
{
const std::string name = a_step_hit->get_particle_name();
//int cell_num = nb_tracker_step_hits->get_track_id();
const std::string process_name = a_step_hit->get_creator_process_name();
const bool has_process = a_step_hit->has_creator_process_name();
const std::string volume_name = a_step_hit->get_g4_volume_name();
const geomtools::vector_3d pos = a_step_hit->get_position_stop();
// cout<<name<<endl;
//cout<<"process: "<<process_name<<endl;
//counter_ncap+=1;
//cout<<name<<endl;
//current_event+=1;
//cout<<name<<endl;
//cout<<"process: "<<process_name<<endl;
//cout<<pos<<endl;
event_num_file<<sd_event_counter<<" "<<name<<" "<<pos<< "\n";
// save_event_UDD(sd_event_counter-1,"/sps/nemo/scratch/spratt/analysis/background_studies/simulation_4/event_plots/");
}}
// cout<<"Passed events: "<<sd_passed_events<<endl;
return dpp::base_module::PROCESS_SUCCESS;
}