60{
63
65 JLimit_t& numberOfEvents = inputFile.getLimit();
66 string detectorFile;
71 size_t prescale;
72 double ratio;
73 bool batch;
74 size_t Nmin;
76
77
78 try {
79
80 JParser<> zap(
"Program to display strings.");
81
82 zap[
'w'] =
make_field(canvas,
"size of canvas <nx>x<ny> [pixels]") =
JCanvas(1200, 600);
83 zap[
'f'] =
make_field(inputFile,
"input file (output of JKatoomba[.sh])");
89 zap[
'P'] =
make_field(prescale,
"prescale") = 1;
90 zap[
'R'] =
make_field(ratio,
"aspect ratio") = 0.1;
91 zap[
'B'] =
make_field(batch,
"batch processing");
92 zap[
'N'] =
make_field(Nmin,
"minimum number of transmissions") = 0;
94
95 zap(argc, argv);
96 }
97 catch(const exception& error) {
98 FATAL(error.what() << endl);
99 }
100
102 FATAL(
"Missing output file name " <<
outputFile <<
" in batch mode." << endl);
103 }
104
107 }
108
111 }
112
114
115 try {
117 }
120 }
121
124
126
128
129 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
130 status[module->getID()] = module->getStatus();
131 }
132
133
134
135 gROOT->SetBatch(batch);
136
137 TApplication* tp = new TApplication("user", NULL, NULL);
138 TCanvas* cv =
new TCanvas(
"display",
"", canvas.
x, canvas.
y);
139
140 unique_ptr<TStyle> gStyle(
new JStyle(
"gplot", cv->GetWw(), cv->GetWh()));
141
142 gROOT->SetStyle("gplot");
143 gROOT->ForceStyle();
144
145 const size_t NY = (size_t) (sqrt(geometry.size()) * 0.75 + 0.25);
146 const size_t NX = (size_t) (geometry.size() + NY - 1) / NY;
147
148 const size_t NUMBER_OF_PADS = NX * NY;
149
150 cv->SetFillStyle(4000);
151 cv->SetFillColor(kWhite);
152
153 TPad*
p1 =
new TPad(
"p1", NULL, 0.0, 0.00, 1.0, 0.95);
154 TPad* p2 = new TPad("p2", NULL, 0.0, 0.95, 1.0, 1.00);
155
156 p1->Divide(NX, NY, 0.01, 0.001);
157
159 p2->Draw();
160
161 double zmin = 0.0;
162 double zmax = 0.0;
163
165
166 if (i->second.getZ() < zmin) {
167 zmin = i->second.getZ();
168 }
169
170 if (i->second.rbegin()->getHeight() > zmax) {
171 zmax = i->second.rbegin()->getHeight();
172 }
173 }
174
175 zmin -= 2.0;
176 zmax += 10.0;
177
178 double xmin = -ratio * (zmax - zmin);
179 double xmax = +ratio * (zmax - zmin);
180
181 TH2D H2[NUMBER_OF_PADS];
182 TText T2[NUMBER_OF_PADS];
183
184 for (size_t i = 0; i != geometry.size(); ++i) {
185
186 H2[i] = TH2D(
MAKE_CSTRING(
FILL(4,
'0') << geometry.at(i).first <<
FILL()), NULL, 100, xmin, xmax, 100, zmin, zmax);
187
188 DEBUG(
"Pad " << setw(3) << i + 1 <<
' ' << H2[i].GetName() << endl);
189
190 H2[i].GetXaxis()->SetTitle("x/y [m]");
191 H2[i].GetYaxis()->SetTitle("z [m]");
192
193 H2[i].GetXaxis()->CenterTitle(true);
194 H2[i].GetYaxis()->CenterTitle(true);
195
196 H2[i].SetStats(kFALSE);
197
198 T2[i] = TText(0.0, zmax + 0.05 * (zmax - zmin),
MAKE_CSTRING(
FILL(4,
'0') << geometry.at(i).first <<
FILL()));
199
200 T2[i].SetTextAlign(21);
201 T2[i].SetTextFont(42);
202 T2[i].SetTextSize(0.05);
203
205
206 H2[i].Draw("AXIS");
207 T2[i].Draw();
208 }
209
211
213
214 JTreeScanner_t::iterator p = in.begin();
215
217
218 cout <<
"\revent: " << setw(8) << inputFile.
getCounter() << flush;
219
222
223 if (batch && inputFile.
getCounter()%prescale != 0) {
224 continue;
225 }
226
227 if (Nmin != 0) {
228
229 for ( ; p != in.end() && p-> begin()->getToA() < evt->
UNIXTimeStart - 0.5; ++p) {}
230
231 JTreeScanner_t::iterator q = p;
232
233 for ( ; q != in.end() && q->rbegin()->getToA() <= evt->
UNIXTimeStop + 0.5; ++q) {}
234
235 if (p != q) {
236
238
239 for (JTreeScanner_t::iterator evt = p; evt != q; ++evt) {
240 for (JEvent::const_iterator i = evt->begin(); i != evt->end(); ++i) {
241 buffer[i->getID()] += 1;
242 }
243 }
244
245 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
246
247 module->setStatus(status[module->getID()]);
248
249 if (buffer[module->getID()] < Nmin) {
250 module->set(module->getFloor() == 0 ? HYDROPHONE_DISABLE : PIEZO_DISABLE);
251 }
252 }
253 }
254 }
255
256
257
259
260 TText title(0.5, 0.5, utc.c_str());
261
262 title.SetTextAlign(22);
263 title.SetTextFont(42);
264 title.SetTextSize(0.3);
265
266 p2->cd();
267
268 title.Draw();
269
272
273 for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) {
274
275 if (geometry.has(i->id)) {
276
277 const int index = geometry.getIndex(i->id);
278
280 const JMODEL ::JString& parameters =
model.string[i->id];
281
282 X[index].push_back(TMarker(0.0,
string.getZ(), kFullCircle));
283 Y[index].push_back(TMarker(0.0, string.getZ(), kFullCircle));
284
285 for (size_t floor = 1; floor < string.size(); ++floor) {
286
289
290 if (router.hasLocation(location) && !router.getModule(location).has(
PIEZO_DISABLE)) {
291 X[index].push_back(TMarker(position.
getX() -
string.getX(), position.
getZ(), kFullCircle));
292 Y[index].push_back(TMarker(position.
getY() -
string.getY(), position.
getZ(), kFullCircle));
293 }
294 }
295 }
296 }
297
298
299
300 for (size_t i = 0; i != NUMBER_OF_PADS; ++i) {
301
303
304 for (
auto& m1 :
X[i]) {
static_cast<TAttMarker&
>(m1) = TAttMarker(kBlack, kFullCircle, 0.7/sqrt(NY)); m1.Draw(); }
305 for (auto& m1 : Y[i]) { static_cast<TAttMarker&>(m1) = TAttMarker(kRed, kFullCircle, 0.7/sqrt(NY)); m1.Draw(); }
306 }
307
308 cv->Update();
309
310
311
312 if (batch) {
313
315
316 } else {
317
318 static int count = 0;
319
320 if (count++ == 0) {
321 cout << endl << "Type '?' for possible options." << endl;
322 }
323
324 for (bool user = true; user; ) {
325
326 cout << "\n> " << flush;
327
329
330 case '?':
331 cout << endl;
332 cout << "possible options: " << endl;
333 cout << 'q' << " -> " << "exit application" << endl;
334 cout << 'u' << " -> " << "update canvas" << endl;
335 cout << 's' << " -> " << "save graphics to file" << endl;
336 cout << 'r' << " -> " << "rewind input file" << endl;
337 cout << 'R' << " -> " << "switch to ROOT mode (quit ROOT to continue)" << endl;
338 cout << 'p' << " -> " << "print event information" << endl;
339 cout << ' ' << " -> " << "next event (as well as any other key)" << endl;
340 break;
341
342 case 'q':
343 cout << endl;
344 return 0;
345
346 case 'u':
347 cv->Update();
348 break;
349
350 case 's':
352 break;
353
354 case 'R':
355 tp->Run(kTRUE);
356 break;
357
358 case 'p':
359 cout << endl << *evt << endl;
360 break;
361
362 case 'r':
364
365 default:
366 user = false;
367 break;
368 }
369 }
370 }
371 }
372 cout << endl;
373}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_CSTRING(A)
Make C-string.
#define MAKE_STRING(A)
Make string.
Router for direct addressing of location data in detector data structure.
Logical location of module.
Data structure for position in three dimensions.
const JPosition3D & getPosition() const
Get position.
double getY() const
Get y position.
double getZ() const
Get z position.
double getX() const
Get x position.
Utility class to parse command line options.
Data structure for size of TCanvas.
int y
number of pixels in Y
int x
number of pixels in X
Wrapper class around ROOT TStyle.
General purpose class for object reading from a list of file names.
virtual void rewind() override
Rewind.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
Base class for JTreeScanner.
Template definition for direct access of elements in ROOT TChain.
Enable unbuffered terminal input.
static const int PIEZO_DISABLE
Enable (disable) use of piezo if this status bit is 0 (1);.
static const JSoundVelocity getSoundVelocity(1541.0, -17.0e-3, -2000.0)
Function object for velocity of sound.
JModel getModel(const JEvt &evt)
Get model.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void model(JModel_t &value)
Auxiliary function to constrain model during fit.
std::string replace(const std::string &input, const std::string &target, const std::string &replacement)
Replace tokens in string.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static const char WILDCARD
Auxiliary data structure for sequence of same character.
Auxiliary data structure for floating point format specification.
Auxiliary data structure for mechanical model parameters with commented data.
double UNIXTimeStop
stop time
double UNIXTimeStart
start time
Model for fit to acoustics data.
Implementation for depth dependend velocity of sound.
JSoundVelocity & set(const double z0)
Set depth.
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 class for date and time.