68{
69
73
77
79 typedef JSingleFileScanner_t::pointer_type pointer_type;
80
81
84 JLimit_t& numberOfEvents = inputFile.getLimit();
85 string detectorFile;
86 JCalibration_t calibrationFile;
88 double Tmax_s;
89 double R_Hz = 6000;
91
92 try {
93
94 JParser<> zap(
"Program to extract information about hits and all PMTs in the detector for water property studies");
95
104
105 zap(argc, argv);
106 }
107 catch(const exception& error) {
108 FATAL(error.what() << endl);
109 }
110
111
113
114 try {
116 }
119 }
120
121 unique_ptr<JDynamics> dynamics;
122
123 try {
125 dynamics->load(calibrationFile);
126 }
127 catch(const exception& error) {
128 if (!calibrationFile.empty()) {
130 }
131 }
132
133 TFile *out;
134 try {
135 out =
new TFile(
outputFile.c_str(),
"RECREATE");
136 }
137 catch(const exception& error){
138 FATAL(error.what() << endl);
139 }
140
141
142
143
144
145 TTree *hits_tree = new TTree("Hits","Tree with hits");
146 vector<float> hit_rate, hit_QE, hit_pos_x, hit_pos_y, hit_pos_z, hit_dir_x, hit_dir_y, hit_dir_z, hit_time, hit_tot;
147 vector<int> hit_first, hit_HRV, hit_status, hit_dom_id, hit_channel_id;
148 hits_tree->Branch("first",&hit_first);
149 hits_tree->Branch("QE",&hit_QE);
150 hits_tree->Branch("rate",&hit_rate);
151 hits_tree->Branch("status",&hit_status);
152 hits_tree->Branch("HRV",&hit_HRV);
153 hits_tree->Branch("pos_x",&hit_pos_x);
154 hits_tree->Branch("pos_y",&hit_pos_y);
155 hits_tree->Branch("pos_z",&hit_pos_z);
156 hits_tree->Branch("dir_x",&hit_dir_x);
157 hits_tree->Branch("dir_y",&hit_dir_y);
158 hits_tree->Branch("dir_z",&hit_dir_z);
159 hits_tree->Branch("time",&hit_time);
160 hits_tree->Branch("tot",&hit_tot);
161 hits_tree->Branch("channel_id",&hit_channel_id);
162 hits_tree->Branch("dom_id",&hit_dom_id);
163
164
165 TTree *pmts_tree = new TTree("PMTs","Tree with PMTs");
166 vector<float> pmt_pos_x, pmt_pos_y, pmt_pos_z, pmt_dir_x, pmt_dir_y, pmt_dir_z, pmt_QE, pmt_rate;
168 pmts_tree->Branch("pos_x",&pmt_pos_x);
169 pmts_tree->Branch("pos_y",&pmt_pos_y);
170 pmts_tree->Branch("pos_z",&pmt_pos_z);
171 pmts_tree->Branch("dir_x",&pmt_dir_x);
172 pmts_tree->Branch("dir_y",&pmt_dir_y);
173 pmts_tree->Branch("dir_z",&pmt_dir_z);
174 pmts_tree->Branch("QE",&pmt_QE);
175 pmts_tree->Branch("channel_id",&pmt_channel_id);
176 pmts_tree->Branch("dom_id",&pmt_dom_id);
177 pmts_tree->Branch("rate",&pmt_rate);
179 pmts_tree->Branch("HRV",&pmt_HRV);
180
181
183
185
187
189
191
192 while (in.hasNext()) {
193
194 STATUS(
"event: " << setw(10) << in.getCounter() <<
'\r');
DEBUG(endl);
195
196 pointer_type ps = in.next();
197
199
200 summary.update(*tev);
201
202 if (dynamics) {
203 dynamics->update(*tev);
204 }
205
206 JDataL0_t dataL0;
207
208 buildL0(*tev, router, true, back_inserter(dataL0));
209
211
212 int module_id_last = -1;
213 int channel_id_last = -1;
214
215
216 for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
217
218 JHitW0 hit(*i, summary.getRate(*i, R_Hz));
219
220
221 hit_pos_x.push_back(hit.getX());
222 hit_pos_y.push_back(hit.getY());
223 hit_pos_z.push_back(hit.getZ());
224
225 hit_dir_x.push_back(hit.getDX());
226 hit_dir_y.push_back(hit.getDY());
227 hit_dir_z.push_back(hit.getDZ());
228
229 hit_time.push_back(hit.getT());
230 hit_tot.push_back(hit.getToT());
231
232 hit_dom_id.push_back(hit.getModuleID());
233 hit_channel_id.push_back(hit.getPMTAddress());
234
235
236 const JPMT& pmt = router.getPMT(
JPMTIdentifier(hit.getModuleID(), hit.getPMTAddress()));
237
239 hit_QE.push_back(pmtParameters.
getQE(
JPMTIdentifier(hit.getModuleID(), hit.getPMTAddress())));
240
241 const JDAQSummaryFrame& SummaryFrame = summary.getSummaryFrame(hit.getModuleID());
243
244 hit_rate.push_back(hit.getR());
245
246
247 if ((hit.getModuleID()==module_id_last) && (hit.getPMTAddress()==channel_id_last)){
248 hit_first.push_back(0);
249 }
250 else{
251 hit_first.push_back(1);
252 }
253 module_id_last = hit.getModuleID();
254 channel_id_last = hit.getPMTAddress();
255
256
257 }
258
259
260
261 for (JDetector::const_iterator i =
detector.begin(); i !=
detector.end(); ++i) {
262
264
265 for (size_t pmt = 0; pmt != module.size(); ++pmt) {
266
267 pmt_pos_x.push_back(module[pmt].getX());
268 pmt_pos_y.push_back(module[pmt].getY());
269 pmt_pos_z.push_back(module[pmt].getZ());
270
271 pmt_dir_x.push_back(module[pmt].getDX());
272 pmt_dir_y.push_back(module[pmt].getDY());
273 pmt_dir_z.push_back(module[pmt].getDZ());
274
276
278
279 pmt_channel_id.push_back(pmt);
280 pmt_dom_id.push_back(module.
getID());
281
284
286
287 }
288 }
289
290
291 hits_tree->Fill();
292 hit_first.clear();
293 hit_QE.clear();
294 hit_rate.clear();
295 hit_status.clear();
296 hit_HRV.clear();
297 hit_pos_x.clear();
298 hit_pos_y.clear();
299 hit_pos_z.clear();
300 hit_dir_x.clear();
301 hit_dir_y.clear();
302 hit_dir_z.clear();
303 hit_time.clear();
304 hit_tot.clear();
305 hit_dom_id.clear();
306 hit_channel_id.clear();
307
308
309 pmts_tree->Fill();
310 pmt_pos_x.clear();
311 pmt_pos_y.clear();
312 pmt_pos_z.clear();
313 pmt_dir_x.clear();
314 pmt_dir_y.clear();
315 pmt_dir_z.clear();
316 pmt_channel_id.clear();
317 pmt_dom_id.clear();
318 pmt_QE.clear();
319 pmt_rate.clear();
321 pmt_HRV.clear();
322
323 }
324
326 out->Write();
327 out->Close();
328}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Auxiliary class for map of PMT parameters.
double getQE(const JPMTIdentifier &id) const
Get QE of given PMT.
Data structure for PMT geometry, calibration and status.
int getID() const
Get identifier.
Utility class to parse command line options.
Auxiliary class for a hit with background rate value.
General purpose class for object reading from a list of file names.
Object reading from a list of files.
File router for fast addressing of summary data.
Template definition for direct access of elements in ROOT TChain.
bool testHighRateVeto() const
Test high-rate veto status.
Data storage class for rate measurements of all PMTs in one module.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Dynamic detector calibration.
int getStatus() const
Get status.
Auxiliary class for recursive type list generation.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.
Auxiliary base class for file name.
Auxiliary data structure for sorting of hits.