69{
70
74
77 typedef JSingleFileScanner_t::pointer_type pointer_type;
78
79
82 JLimit_t& numberOfEvents = inputFile.getLimit();
83 string detectorFile;
84 JCalibration_t calibrationFile;
85 double Tmax_s;
86 double rate_Hz;
89
90 try {
91
92 JParser<> zap(
"Program to extract information about hits and all PMTs in the detector for water property studies");
93
103
104 zap(argc, argv);
105 }
106 catch(const exception& error) {
107 FATAL(error.what() << endl);
108 }
109
110
112
113 try {
115 }
118 }
119
120 unique_ptr<JDynamics> dynamics;
121
122 try {
124 dynamics->load(calibrationFile);
125 }
126 catch(const exception& error) {
127 if (!calibrationFile.empty()) {
129 }
130 }
131
132 TFile *out;
133 try {
134 out =
new TFile(
outputFile.c_str(),
"RECREATE");
135 }
136 catch(const exception& error){
137 FATAL(error.what() << endl);
138 }
139
140
141
142
143
144 TTree *hits_tree = new TTree("Hits","Tree with hits");
145 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;
146 vector<int> hit_first, hit_HRV, hit_status, hit_dom_id, hit_channel_id;
147 hits_tree->Branch("first",&hit_first);
148 hits_tree->Branch("QE",&hit_QE);
149 hits_tree->Branch("rate",&hit_rate);
150 hits_tree->Branch("status",&hit_status);
151 hits_tree->Branch("HRV",&hit_HRV);
152 hits_tree->Branch("pos_x",&hit_pos_x);
153 hits_tree->Branch("pos_y",&hit_pos_y);
154 hits_tree->Branch("pos_z",&hit_pos_z);
155 hits_tree->Branch("dir_x",&hit_dir_x);
156 hits_tree->Branch("dir_y",&hit_dir_y);
157 hits_tree->Branch("dir_z",&hit_dir_z);
158 hits_tree->Branch("time",&hit_time);
159 hits_tree->Branch("tot",&hit_tot);
160 hits_tree->Branch("channel_id",&hit_channel_id);
161 hits_tree->Branch("dom_id",&hit_dom_id);
162
163
164 TTree *pmts_tree = new TTree("PMTs","Tree with PMTs");
165 vector<float> pmt_pos_x, pmt_pos_y, pmt_pos_z, pmt_dir_x, pmt_dir_y, pmt_dir_z, pmt_QE, pmt_rate;
167 pmts_tree->Branch("pos_x",&pmt_pos_x);
168 pmts_tree->Branch("pos_y",&pmt_pos_y);
169 pmts_tree->Branch("pos_z",&pmt_pos_z);
170 pmts_tree->Branch("dir_x",&pmt_dir_x);
171 pmts_tree->Branch("dir_y",&pmt_dir_y);
172 pmts_tree->Branch("dir_z",&pmt_dir_z);
173 pmts_tree->Branch("QE",&pmt_QE);
174 pmts_tree->Branch("channel_id",&pmt_channel_id);
175 pmts_tree->Branch("dom_id",&pmt_dom_id);
176 pmts_tree->Branch("rate",&pmt_rate);
178 pmts_tree->Branch("HRV",&pmt_HRV);
179
180
182
184
186
188
190
191 while (in.hasNext()) {
192
193 STATUS(
"event: " << setw(10) << in.getCounter() <<
'\r');
DEBUG(endl);
194
195 pointer_type ps = in.next();
196
198
199 summary.update(*tev);
200
201 if (dynamics) {
202 dynamics->update(*tev);
203 }
204
205 JDataL0_t dataL0;
206
207 buildL0(*tev, router, true, back_inserter(dataL0));
208
210
211 int module_id_last = -1;
212 int channel_id_last = -1;
213
214
215 for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
216
218
220
221 const int type = wip.
getType();
222 const double QE = wip.
QE;
223 const double R_Hz = summary.getRate(i->getPMTIdentifier(), rate_Hz);
224
225 JHitW0 hit(*i, type, QE, R_Hz);
226
227
228 hit_pos_x.push_back(hit.getX());
229 hit_pos_y.push_back(hit.getY());
230 hit_pos_z.push_back(hit.getZ());
231
232 hit_dir_x.push_back(hit.getDX());
233 hit_dir_y.push_back(hit.getDY());
234 hit_dir_z.push_back(hit.getDZ());
235
236 hit_time.push_back(hit.getT());
237 hit_tot.push_back(hit.getToT());
238
239 hit_dom_id.push_back(hit.getModuleID());
240 hit_channel_id.push_back(hit.getPMTAddress());
241
242
243 const JPMT& pmt = router.getPMT(
JPMTIdentifier(hit.getModuleID(), hit.getPMTAddress()));
244
246 hit_QE.push_back(hit.getQE());
247
248 const JDAQSummaryFrame& SummaryFrame = summary.getSummaryFrame(hit.getModuleID());
249
252
253 hit_rate.push_back(hit.getR());
254
255
256 if ((hit.getModuleID()==module_id_last) && (hit.getPMTAddress()==channel_id_last)){
257 hit_first.push_back(0);
258 }
259 else{
260 hit_first.push_back(1);
261 }
262 module_id_last = hit.getModuleID();
263 channel_id_last = hit.getPMTAddress();
264
265
266 }
267
268
269
270 for (JDetector::const_iterator i =
detector.begin(); i !=
detector.end(); ++i) {
271
273
274 for (size_t pmt = 0; pmt != module.size(); ++pmt) {
275
276 pmt_pos_x.push_back(module[pmt].getX());
277 pmt_pos_y.push_back(module[pmt].getY());
278 pmt_pos_z.push_back(module[pmt].getZ());
279
280 pmt_dir_x.push_back(module[pmt].getDX());
281 pmt_dir_y.push_back(module[pmt].getDY());
282 pmt_dir_z.push_back(module[pmt].getDZ());
283
285
287
288 pmt_channel_id.push_back(pmt);
289 pmt_dom_id.push_back(module.
getID());
290
293
295
296 }
297 }
298
299
300 hits_tree->Fill();
301 hit_first.clear();
302 hit_QE.clear();
303 hit_rate.clear();
304 hit_status.clear();
305 hit_HRV.clear();
306 hit_pos_x.clear();
307 hit_pos_y.clear();
308 hit_pos_z.clear();
309 hit_dir_x.clear();
310 hit_dir_y.clear();
311 hit_dir_z.clear();
312 hit_time.clear();
313 hit_tot.clear();
314 hit_dom_id.clear();
315 hit_channel_id.clear();
316
317
318 pmts_tree->Fill();
319 pmt_pos_x.clear();
320 pmt_pos_y.clear();
321 pmt_pos_z.clear();
322 pmt_dir_x.clear();
323 pmt_dir_y.clear();
324 pmt_dir_z.clear();
325 pmt_channel_id.clear();
326 pmt_dom_id.clear();
327 pmt_QE.clear();
328 pmt_rate.clear();
330 pmt_HRV.clear();
331
332 }
333
335 out->Write();
336 out->Close();
337}
#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.
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
double getQE(const JPMTIdentifier &id) const
Get QE of given PMT.
Data structure for PMT parameters.
double QE
relative quantum efficiency
int getType() const
Get type for for time-slewing correction.
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 testFIFOStatus() const
Test FIFO status.
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.
status_type getStatus(const JType< status_type > &type) const
Get status.
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.