NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
RnoExplorer.cxx
Go to the documentation of this file.
1
17
19
31
32#include "RnoExplorer.h"
33#include "Riostream.h"
34
35ClassImp(RnoExplorer); // Class implementation to enable ROOT I/O
36
38RnoExplorer::RnoExplorer(const char* name,const char* title) : TChain(name,title)
39{
49
50 fExpPanel=0;
51 fEnt=0;
52 fEvt=0;
53 fSample=0;
54 fStation=0;
55 fChannel=-1;
56 fMode="ADC(s)";
57 fFmV="x*2.5e3/(pow(2,12)-1)";
58 fOpsMode="None";
59 for (Int_t i=0; i<3; i++)
60 {
61 fOpsPars[0]="";
62 }
63
64 for (Int_t i=0; i<3; i++)
65 {
66 fCanvas[i]=0;
67 }
68 fFiles=0;
69 fNentries=0;
70 fConnected=kFALSE;
71 fEntry=0;
72 for (Int_t i=0; i<4; i++)
73 {
74 fHead[i]=0;
75 }
76 for (Int_t i=0; i<3; i++)
77 {
78 fParams[i]=0;
79 }
80
81 fDevName="*";
82
83 for (Int_t i=0; i<24; i++)
84 {
85 fFilterBands[i].Set(0);
86 }
87
88 fIndexed=kFALSE;
89
91}
92
94{
100
101 for (Int_t i=0; i<3; i++)
102 {
103 if (fCanvas[i])
104 {
105 TString s=ClassName();
106 s+=i;
107 if (gROOT->GetListOfCanvases()->FindObject(s)) delete fCanvas[i];
108 fCanvas[i]=0;
109 }
110 }
111}
112
114{
123
124 if (gROOT->IsBatch())
125 {
126 printf(" *%-s::ExplorePanel* ExplorePanel() can not be invoked in batch mode. \n",ClassName());
127 return;
128 }
129
130 // Re-invokation of the ExplorePanel
131 if (fExpPanel)
132 {
133 ShowPanel();
134 return;
135 }
136
137 // New initialization of the ExplorePanel
138 NcVersion v;
139 v.Data();
140 printf(" ********************************************************************************* \n");
141 printf(" * Welcome to the %-s GUI facility to explore RNO-G event data *\n",ClassName());
142 printf(" * After window closure, the GUI panel can be re-opened via invoking ShowPanel() * \n");
143 printf(" ********************************************************************************* \n");
144 printf("\n");
145
146 UInt_t border=5;
147 fExpPanel=new TGMainFrame(gClient->GetRoot());
148 fExpPanel->SetWindowName(ClassName());
149 fExpPanel->Connect("CloseWindow()",ClassName(),this,"ExpClose()");
150 // Define the various sub-frames and fill them with the various panels
151 TGCompositeFrame* frames[4]={0,0,0,0};
152 TGLayoutHints* layouts[4]={0,0,0,0};
153
154 // The input file specification frame
155 frames[0]=new TGCompositeFrame(fExpPanel,1,1,kHorizontalFrame|kSunkenFrame);
156 layouts[0]=new TGLayoutHints(kLHintsExpandX,border,border,0,0);
157 FilesPanel(frames[0]);
158
159 // The event header info frame
160 frames[1]=new TGCompositeFrame(fExpPanel,1,1,kHorizontalFrame|kSunkenFrame);
161 layouts[1]=new TGLayoutHints(kLHintsExpandX,border,border,0,0);
162 HeaderPanel(frames[1]);
163
164 // The sampling selection frame
165 frames[2]=new TGCompositeFrame(fExpPanel,1,1,kHorizontalFrame|kSunkenFrame);
166 layouts[2]=new TGLayoutHints(kLHintsExpandX,border,border,0,0);
167 SamplingsPanel(frames[2]);
168
169 // The command panel frame
170 frames[3]=new TGCompositeFrame(fExpPanel,1,1,kHorizontalFrame|kSunkenFrame);
171 layouts[3]=new TGLayoutHints(kLHintsExpandX,border,border,0,0);
172 CommandPanel(frames[3]);
173
174 // Add all subframes to the mainframe
175 for (Int_t i=0; i<4; i++)
176 {
177 if (frames[i]) fExpPanel->AddFrame(frames[i],layouts[i]);
178 }
179
180 ShowPanel();
181}
182
183void RnoExplorer::FilesPanel(TGCompositeFrame* frame)
184{
190
191 if (!frame) return;
192
193 // The input file(s) specification
194 TGGroupFrame* files=new TGGroupFrame(frame,"Input filename e.g. $(HOME)/my-data/*.rnopack",kHorizontalFrame);
195 files->SetTitlePos(TGGroupFrame::kCenter);
196 frame->AddFrame(files);
197 fFiles=new TGTextEntry(files);
198 fFiles->SetAlignment(kTextLeft);
199 fFiles->Resize(400,20);
200 files->AddFrame(fFiles);
201
202 TGTextButton* add=new TGTextButton(files,"AddFile");
203 add->Connect("Clicked()",ClassName(),this,"FileAdd()");
204 add->SetToolTipText("Add the specified file to the input data chain");
205 TGLayoutHints* Ladd=new TGLayoutHints(kLHintsLeft,10,0,0,-5);
206 files->AddFrame(add,Ladd);
207
208 // The number of entries indicator
209 TGGroupFrame* entries=new TGGroupFrame(frame,"# Entries",kHorizontalFrame);
210 entries->SetTitlePos(TGGroupFrame::kCenter);
211 frame->AddFrame(entries);
212 fNentries=new TGTextEntry(entries,"0");
213 fNentries->SetAlignment(kTextRight);
214 fNentries->Resize(90,20);
215 entries->AddFrame(fNentries);
216
217 // The panel for window c.q. session controls
218 TGGroupFrame* session=new TGGroupFrame(frame,"Window / Session",kHorizontalFrame);
219 session->SetTitlePos(TGGroupFrame::kCenter);
220 TGLayoutHints* Lsession=new TGLayoutHints(kLHintsRight,0,0,0,0);
221 frame->AddFrame(session,Lsession);
222
223 TGTextButton* close=new TGTextButton(session,"Close");
224 close->Connect("Clicked()",ClassName(),this,"ExpClose()");
225 close->SetToolTipText("Close this panel window");
226 TGLayoutHints* Lclose=new TGLayoutHints(kLHintsCenterX,0,6,3,-5);
227 session->AddFrame(close,Lclose);
228
229 TGTextButton* exit=new TGTextButton(session,"Exit");
230 exit->Connect("Clicked()",ClassName(),this,"ExpExit()");
231 exit->SetToolTipText("Exit this ROOT session");
232 TGLayoutHints* Lexit=new TGLayoutHints(kLHintsCenterX,6,0,3,-5);
233 session->AddFrame(exit,Lexit);
234}
235
237{
243
244 if (!fFiles) return;
245
246 // Expand the pathname of the specified filename
247 TString filename=fFiles->GetText();
248 filename=gSystem->ExpandPathName(filename.Data());
249
250 printf("\n *** Adding file : %-s *** \n",filename.Data());
251
252 Add(filename.Data());
253
254 fIndexed=kFALSE;
255
256 if (!fConnected)
257 {
258 SetBranchAddress("Events",&fEvt);
259
260 if (GetBranch("Events")) fConnected=kTRUE;
261 }
262
263 Long64_t nen=GetEntries();
264 if (nen)
265 {
266 GetEntry(0);
267 fEntry->SetText("0");
268 HeadEnter();
269 }
270
271 TString s="";
272 s+=nen;
273 fNentries->SetText(s.Data());
274}
275
276void RnoExplorer::HeaderPanel(TGCompositeFrame* frame)
277{
283
284 if (!frame) return;
285
286 // The entry specification
287 TGGroupFrame* entry=new TGGroupFrame(frame,"Entry",kHorizontalFrame);
288 entry->SetTitlePos(TGGroupFrame::kCenter);
289 frame->AddFrame(entry);
290 fEntry=new TGTextEntry(entry);
291 fEntry->SetAlignment(kTextRight);
292 fEntry->Resize(90,20);
293 entry->AddFrame(fEntry);
294
295 TGTextButton* getentry=new TGTextButton(entry,"LoadEntry");
296 getentry->Connect("Clicked()",ClassName(),this,"LoadEntry()");
297 getentry->SetToolTipText("Load the specified entry (0=first)");
298 TGLayoutHints* Lgetentry=new TGLayoutHints(kLHintsLeft,10,0,0,-5);
299 entry->AddFrame(getentry,Lgetentry);
300
301 // The event Date/Time
302 TGGroupFrame* ts=new TGGroupFrame(frame,"Date/Time",kHorizontalFrame);
303 ts->SetTitlePos(TGGroupFrame::kCenter);
304 frame->AddFrame(ts);
305 fHead[0]=new TGTextEntry(ts);
306 fHead[0]->SetAlignment(kTextRight);
307 fHead[0]->Resize(225,20);
308 ts->AddFrame(fHead[0]);
309
310 // The station number
311 TGGroupFrame* station=new TGGroupFrame(frame,"Station",kHorizontalFrame);
312 station->SetTitlePos(TGGroupFrame::kCenter);
313 frame->AddFrame(station);
314 fHead[1]=new TGTextEntry(station);
315 fHead[1]->SetAlignment(kTextRight);
316 fHead[1]->Resize(30,20);
317 station->AddFrame(fHead[1]);
318
319 // The run number
320 TGGroupFrame* run=new TGGroupFrame(frame,"Run",kHorizontalFrame);
321 run->SetTitlePos(TGGroupFrame::kCenter);
322 frame->AddFrame(run);
323 fHead[2]=new TGTextEntry(run);
324 fHead[2]->SetAlignment(kTextRight);
325 fHead[2]->Resize(80,20);
326 run->AddFrame(fHead[2]);
327
328 // The event number
329 TGGroupFrame* event=new TGGroupFrame(frame,"Event",kHorizontalFrame);
330 event->SetTitlePos(TGGroupFrame::kCenter);
331 frame->AddFrame(event);
332 fHead[3]=new TGTextEntry(event);
333 fHead[3]->SetAlignment(kTextRight);
334 fHead[3]->Resize(80,20);
335 event->AddFrame(fHead[3]);
336
337 TGTextButton* getevent=new TGTextButton(event,"LoadEvent");
338 getevent->Connect("Clicked()",ClassName(),this,"LoadEvent()");
339 getevent->SetToolTipText("Load the specified (run,event)");
340 TGLayoutHints* Lgetevent=new TGLayoutHints(kLHintsLeft,10,0,0,-5);
341 event->AddFrame(getevent,Lgetevent);
342}
343
345{
351
352 TString s=fEntry->GetText();
353 Int_t i=s.Atoi();
354
355 if (GetEntry(i))
356 {
357 fEnt=i;
358 HeadEnter();
359 printf(" *** Loaded entry : %-i *** \n",fEnt);
360 }
361 else
362 {
363 printf("\n *** Non-existing entry number : %-i *** \n",i);
364 s="";
365 s+=fEnt;
366 fEntry->SetText(s.Data());
367 LoadEntry();
368 }
369}
370
372{
378
379 // Build the indexing for fast (station,run,event) access
380 // using the fact that fUniqueID=station+100*run.
381 if (!fIndexed)
382 {
383 BuildIndex("fUniqueID","fEvent");
384 fIndexed=kTRUE;
385 }
386
387 TString station=fHead[1]->GetText();
388 TString run=fHead[2]->GetText();
389 TString event=fHead[3]->GetText();
390
391 Int_t ist=station.Atoi();
392 Int_t irun=run.Atoi();
393 Int_t ievt=event.Atoi();
394
395 Int_t id=ist+100*irun;
396 Int_t ien=GetEntryNumberWithIndex(id,ievt);
397
398 TString entry="";
399 if (ien>=0)
400 {
401 entry+=ien;
402 fEntry->SetText(entry.Data());
403 LoadEntry();
404 }
405 else
406 {
407 printf("\n *** Non-existing (station,run,event) specification : (%-i,%-i,%-i) *** \n",ist,irun,ievt);
408 entry+=fEnt;
409 fEntry->SetText(entry.Data());
410 LoadEntry();
411 }
412}
413
415{
421
422 if (!fEvt)
423 {
424 printf("\n *** No RnoEvent structure loaded (yet). *** \n");
425 return;
426 }
427
428 // Obtain the DAQ sampling rate
429 fSample=0;
430 NcDevice* dev=fEvt->GetDevice("DAQ");
431 if (dev) fSample=dev->GetSignal("Sampling-rate");
432
433 // The event timestamp
434 TString text=fEvt->GetDayTimeString("UT",3);
435 fHead[0]->SetText(text.Data());
436
437 // The station
438 TObjArray* arr=fEvt->GetDevices("RnoStation");
439 dev=(NcDevice*)arr->At(0);
440 fStation=dev->GetUniqueID();
441 text="";
442 if (dev) text+=fStation;
443 fHead[1]->SetText(text.Data());
444
445 // The run number
446 text="";
447 text+=fEvt->GetRunNumber();
448 fHead[2]->SetText(text.Data());
449
450 // The event number
451 text="";
452 text+=fEvt->GetEventNumber();
453 fHead[3]->SetText(text.Data());
454}
455
456void RnoExplorer::SamplingsPanel(TGCompositeFrame* frame)
457{
463
464 if (!frame) return;
465
466 TGGroupFrame* samplings=new TGGroupFrame(frame,"Input selection",kHorizontalFrame);
467 samplings->SetTitlePos(TGGroupFrame::kCenter);
468 frame->AddFrame(samplings);
469
470 // The channel specification
471 TGNumberEntryField* channel=new TGNumberEntryField(samplings,-1,-1,TGNumberFormat::kNESInteger);
472 channel->SetToolTipText("Channel number (-1=all)");
473 channel->Connect("TextChanged(const char*)",ClassName(),this,"ExpChannel(const char*)");
474 channel->Resize(30,20);
475 samplings->AddFrame(channel);
476
477 // The selection box for the sampling mode
478 TGComboBox* mode=new TGComboBox(samplings);
479 mode->Connect("Selected(Int_t)",ClassName(),this,"ExpMode(Int_t)");
480 mode->AddEntry("ADC(s)",1);
481 mode->AddEntry("ADC(t)",2);
482 mode->AddEntry("Store1",3);
483 mode->AddEntry("Store2",4);
484 mode->AddEntry("Store3",5);
485 mode->Resize(70,20);
486 TGLayoutHints* Lmode=new TGLayoutHints(kLHintsLeft,10,0,0,-5);
487 samplings->AddFrame(mode,Lmode);
488 mode->Select(1,kTRUE);
489
490 TGGroupFrame* operations=new TGGroupFrame(frame,"Operation selection Parameter values",kHorizontalFrame);
491 operations->SetTitlePos(TGGroupFrame::kCenter);
492 frame->AddFrame(operations);
493
494 // The selection box for the operations processing mode
495 TGComboBox* opsmode=new TGComboBox(operations);
496 opsmode->Connect("Selected(Int_t)",ClassName(),this,"ExpOpsMode(Int_t)");
497 opsmode->AddEntry("None",1);
498 opsmode->AddEntry("Convert ADC-->mV",2);
499 opsmode->AddEntry("DFT Time-->Frequency",3);
500 opsmode->AddEntry("DFT Frequency-->Time",4);
501 opsmode->AddEntry("Add FilterBand [f1,f2]",5);
502 opsmode->AddEntry("Show BandFilterKernel",6);
503 opsmode->AddEntry("BandFilter",7);
504 opsmode->AddEntry("Show MovingAvgKernel",8);
505 opsmode->AddEntry("MovingAvgFilter",9);
506 opsmode->AddEntry("Blocks of n samples",10);
507 opsmode->AddEntry("Bayesian FPR nrms ntrig",11);
508 opsmode->AddEntry("Bayesian FPR f(y) ntrig",12);
509 opsmode->AddEntry("Subtract",13);
510 opsmode->AddEntry("Correlate",14);
511 opsmode->AddEntry("Get SNR",15);
512 opsmode->Resize(170,20);
513 operations->AddFrame(opsmode);
514 opsmode->Select(1,kTRUE);
515 ExpOpsMode(1);
516
517 // The operations parameter1 specification
518 fParams[0]=new TGTextEntry(operations);
519 fParams[0]->SetAlignment(kTextRight);
520 fParams[0]->Connect("TextChanged(const char*)",ClassName(),this,"ExpOpsPar1(const char*)");
521 fParams[0]->Resize(50,20);
522 operations->AddFrame(fParams[0]);
523
524 // The operations parameter2 specification
525 fParams[1]=new TGTextEntry(operations);
526 fParams[1]->SetAlignment(kTextRight);
527 fParams[1]->Connect("TextChanged(const char*)",ClassName(),this,"ExpOpsPar2(const char*)");
528 fParams[1]->Resize(170,20);
529 operations->AddFrame(fParams[1]);
530
531 // The operations parameter2 specification
532 fParams[2]=new TGTextEntry(operations);
533 fParams[2]->SetAlignment(kTextRight);
534 fParams[2]->Connect("TextChanged(const char*)",ClassName(),this,"ExpOpsPar3(const char*)");
535 fParams[2]->Resize(45,20);
536 operations->AddFrame(fParams[2]);
537
538 TGGroupFrame* storedraw=new TGGroupFrame(frame,"Output Store&Draw",kHorizontalFrame);
539 storedraw->SetTitlePos(TGGroupFrame::kCenter);
540 frame->AddFrame(storedraw);
541
542 // The selection box for the storage/drawing execution mode
543 TGComboBox* execmode=new TGComboBox(storedraw);
544 execmode->Connect("Selected(Int_t)",ClassName(),this,"ExpExecMode(Int_t)");
545 execmode->AddEntry("Store1",1);
546 execmode->AddEntry("Store2",2);
547 execmode->AddEntry("Store3",3);
548 execmode->Resize(65,20);
549 storedraw->AddFrame(execmode);
550 execmode->Select(1,kTRUE);
551 ExpExecMode(1);
552
553 TGTextButton* execute=new TGTextButton(storedraw,"Exec");
554 execute->Connect("Clicked()",ClassName(),this,"ExpExecute()");
555 execute->SetToolTipText("Execute the selected actions for the requested channel(s)");
556 TGLayoutHints* Lexecute=new TGLayoutHints(kLHintsLeft,10,0,0,-2);
557 storedraw->AddFrame(execute,Lexecute);
558}
559
560void RnoExplorer::ExpChannel(const char* text)
561{
567
568 TString s=text;
569 fChannel=s.Atoi();
570}
571
573{
579
580 TString s[5]={"ADC(s)","ADC(t)","Store1","Store2","Store3"};
581
582 if (i<1 || i>5) return;
583
584 fMode=s[i-1];
585}
586
587void RnoExplorer::ExpFmV(const char* text)
588{
594
595 fFmV=text;
596
597 // Convert f(y) into f(x) to comply with TF1 format
598 fFmV.ReplaceAll("y","x");
599}
600
602{
608
609 TString s[15]={"None","mV","DFT","IDFT","AddFilter","BKernel","BFilter","MKernel","MFilter","Bn","BBnrms","BBf","Sub","Corr","SNR"};
610
611 if (i<1 || i>15) return;
612
613 fOpsMode=s[i-1];
614
615 if (!fParams[0]) return;
616
617 // Clear all parameters and tooltip texts
618 for (Int_t j=0; j<3; j++)
619 {
620 fOpsPars[j]="";
621 fParams[j]->SetToolTipText("");
622 }
623
624 // Initialize the relevant operation parameter values
625 if (fOpsMode=="Bn") // Fixed n sample blocks
626 {
627 fOpsPars[0]="64";
628 fParams[0]->SetToolTipText("n value");
629 fOpsPars[1]="Median";
630 fParams[1]->SetToolTipText("Median, Mean or RMS to be used for averaging");
631 }
632
633 if (fOpsMode=="BBnrms") // Bayesian blocks with FPR nrms and ntrig
634 {
635 fOpsPars[0]="0.1";
636 fOpsPars[1]="2";
637 fOpsPars[2]="0";
638 fParams[0]->SetToolTipText("FPR value");
639 fParams[1]->SetToolTipText("nrms value for input y-error: err(y_i)=nrms*RMSdev[all y_i]");
640 fParams[2]->SetToolTipText("ntrig value (0=no trigger)");
641 }
642
643 if (fOpsMode=="BBf") // Bayesian blocks with FPR f(y) and ntrig
644 {
645 fOpsPars[0]="0.1";
646 fOpsPars[1]="sqrt(abs(y))";
647 fOpsPars[2]="0";
648 fParams[0]->SetToolTipText("FPR value");
649 fParams[1]->SetToolTipText("TF1 expression for input y-error: err(y_i)=f(y_i)");
650 fParams[2]->SetToolTipText("ntrig value (0=no trigger)");
651 }
652
653 if (fOpsMode=="mV") // ADC to mV conversion
654 {
655 fOpsPars[1]="ADC*2.5e3/(pow(2,12)-1)";
656 fParams[1]->SetToolTipText("TF1 expression for ADC->mV conversion");
657 }
658
659 if (fOpsMode=="DFT") // DFT Time to Frequency conversion
660 {
661 fOpsPars[0]="dB";
662 fOpsPars[1]="Hz";
663 fParams[0]->SetToolTipText("Y-axis value: dB, AMP, PHID, PHIR, RE or IM");
664 fParams[1]->SetToolTipText("X-axis value: Hz, k (index) or f (fraction of sampling rate)");
665 fParams[2]->SetToolTipText("Set to 2 to obtain all N data points instead of the usual (N/2)+1");
666 }
667
668 if (fOpsMode=="IDFT") // Inverse DFT Frequency to Time conversion
669 {
670 fOpsPars[0]="n";
671 fParams[0]->SetToolTipText("X-axis value: n (index) or t (time in seconds)");
672 fParams[2]->SetToolTipText("Set to 2 to obtain all N data points instead of the usual (N/2)+1");
673 }
674
675 if (fOpsMode=="Sub") // Subtraction of spectra
676 {
677 fOpsPars[0]="0";
678 fOpsPars[1]="Store2";
679 fParams[0]->SetToolTipText("Channel number (0-23) for the spectrum to be subtracted");
680 fParams[1]->SetToolTipText("Storage to retrieve the spectrum to be subtracted");
681 }
682
683 if (fOpsMode=="Corr") // Correlation of spectra
684 {
685 fOpsPars[0]="0";
686 fOpsPars[1]="Store2";
687 fOpsPars[2]="GNCC";
688 fParams[0]->SetToolTipText("Channel number (0-23) for the reference spectrum");
689 fParams[1]->SetToolTipText("Storage to retrieve the reference spectrum for correlation");
690 fParams[2]->SetToolTipText("Normalization mode : NONE, GNCC, NCC, ZNCC");
691 }
692
693 if (fOpsMode=="SNR") // Get the SNR of the distribution
694 {
695 fOpsPars[1]="Bipolar-Amplitudes";
696 fParams[1]->SetToolTipText("Y-values are RMS, Power or Bipolar-Amplitudes");
697 }
698
699 if (fOpsMode=="AddFilter") // Add a band filter
700 {
701 fOpsPars[0]="f1";
702 fOpsPars[1]="f2";
703 fOpsPars[2]="Pass";
704 fParams[0]->SetToolTipText("f1 in MHz (*=Reset all bands)");
705 fParams[1]->SetToolTipText("f2 in MHz (*=unlimited)");
706 fParams[2]->SetToolTipText("Pass or Reject");
707 }
708
709 if (fOpsMode=="BKernel") // Provide the BandFilter kernel
710 {
711 fOpsPars[0]="0.01";
712 fOpsPars[1]="hisf";
713 fOpsPars[2]="Hz";
714 fParams[0]->SetToolTipText("Roll-off in fraction of the sampling frequency");
715 fParams[1]->SetToolTipText("Provide time domain (hist) or frequency domain (hisf) histogram");
716 fParams[2]->SetToolTipText("hisf: Hz or f (fraction of sampling rate) hist: n (index) or t (time in seconds)");
717 }
718
719 if (fOpsMode=="BFilter") // Perform the Band filtering
720 {
721 fOpsPars[0]="0.01";
722 fOpsPars[1]="hist";
723 fOpsPars[2]="n";
724 fParams[0]->SetToolTipText("Roll-off in fraction of the sampling frequency");
725 fParams[1]->SetToolTipText("Provide time domain (hist) or frequency domain (hisf) histogram");
726 fParams[2]->SetToolTipText("hist: n (index) or t (time in seconds) hisf: Hz or f (fraction of sampling rate)");
727 }
728
729 if (fOpsMode=="MKernel") // Provide the Moving Average Filter kernel
730 {
731 fOpsPars[0]="2";
732 fOpsPars[1]="hisf";
733 fOpsPars[2]="Hz";
734 fParams[0]->SetToolTipText("Noise reduction factor");
735 fParams[1]->SetToolTipText("Provide time domain (hist) or frequency domain (hisf) histogram");
736 fParams[2]->SetToolTipText("hisf: Hz or f (fraction of sampling rate) hist: n (index) or t (time in seconds)");
737 }
738
739 if (fOpsMode=="MFilter") // Perform the Moving Average filtering
740 {
741 fOpsPars[0]="2";
742 fOpsPars[1]="hist";
743 fOpsPars[2]="n";
744 fParams[0]->SetToolTipText("Noise reduction factor");
745 fParams[1]->SetToolTipText("Provide time domain (hist) or frequency domain (hisf) histogram");
746 fParams[2]->SetToolTipText("hist: n (index) or t (time in seconds) hisf: Hz or f (fraction of sampling rate)");
747 }
748
749 // Indicate the initial parameter values in the corresponding text boxes
750 // and convert the actual function variable name to "x" to comply with the TF1 format.
751 for (Int_t j=0; j<3; j++)
752 {
753 fParams[j]->SetText(fOpsPars[j]);
754 fOpsPars[j].ReplaceAll("y","x");
755 fOpsPars[j].ReplaceAll("ADC","x");
756 fOpsPars[j].ReplaceAll("adc","x");
757 }
758}
759
760void RnoExplorer::ExpOpsPar1(const char* text)
761{
767
768 fOpsPars[0]=text;
769}
770
771void RnoExplorer::ExpOpsPar2(const char* text)
772{
778
779 fOpsPars[1]=text;
780
781 // Convert the function variable name to "x" to comply with the TF1 format.
782 fOpsPars[1].ReplaceAll("y","x");
783 fOpsPars[1].ReplaceAll("ADC","x");
784 fOpsPars[1].ReplaceAll("adc","x");
785}
786
787void RnoExplorer::ExpOpsPar3(const char* text)
788{
794
795 fOpsPars[2]=text;
796}
797
799{
805
806 TString s[3]={"Store1","Store2","Store3"};
807
808 if (i<1 || i>3) return;
809
810 fExecMode=s[i-1];
811}
812
814{
820
821 // Adding or Resetting of filter bands
822 if (fOpsMode=="AddFilter")
823 {
824 if (fSample<=0)
825 {
826 printf("\n *** Unknown sampling frequency ==> Can't set Filter bands *** \n");
827 for (Int_t i=0; i<24; i++)
828 {
829 fFilterBands[i].Set(0);
830 }
831 return;
832 }
833
834 Double_t f1=fOpsPars[0].Atof();
835 Double_t f2=fOpsPars[1].Atof();
836
837 if (fOpsPars[2]!="Pass" && fOpsPars[2]!="Reject")
838 {
839 printf("\n *** Invalid Filter mode specification : %-s *** \n",fOpsPars[2].Data());
840 return;
841 }
842
843 if (fOpsPars[0]!="*")
844 {
845 if ((!f1 && fOpsPars[0]!="0") || (!f2 && fOpsPars[1]!="*") || f1<0 || f2<0)
846 {
847 printf("\n *** Invalid Filter Band specification [%-s,%-s] *** \n",fOpsPars[0].Data(),fOpsPars[1].Data());
848 return;
849 }
850 }
851
852 if (fOpsPars[0]=="0") f1=-1;
853 if (fOpsPars[1]=="*") f2=-1;
854
855 if (fOpsPars[2]=="Reject")
856 {
857 // Rejecting a LowPass is equivalent to applying a HighPass filter
858 if (f1<0 && f2>0)
859 {
860 f1=f2;
861 f2=-1;
862 }
863 // Rejecting a HighPass is equivalent to applying a LowPass filter
864 else if (f1>0 && f2<0)
865 {
866 f2=f1;
867 f1=-1;
868 }
869 // A normal BandReject filter
870 else if (f1>0 && f2>0)
871 {
872 f1=-f1;
873 f2=-f2;
874 }
875 }
876
877 Int_t jstart=0;
878 Int_t jstop=23;
879 if (fChannel>=0)
880 {
881 jstart=fChannel;
882 jstop=jstart;
883 }
884
885 for (Int_t i=jstart; i<=jstop; i++)
886 {
887 if (fOpsPars[0]=="*") // Resetting all filter bands
888 {
889 fFilterBands[i].Set(0);
890 if (i==jstart) printf("\n *** All filter bands have been removed *** \n");
891 }
892 else // Add this filter band
893 {
894 Int_t n=fFilterBands[i].GetSize();
895 fFilterBands[i].Set(n+2);
896 fFilterBands[i].SetAt(f1*1e6/fSample,n);
897 fFilterBands[i].SetAt(f2*1e6/fSample,n+1);
898
899 if (i==jstart)
900 {
901 if (f1>0)
902 {
903 if (f2>0) printf("\n *** [%-g,%-g] MHz BandPass filter added",f1,f2);
904 if (f2<0) printf("\n *** %-g MHz HighPass filter added",f1);
905 }
906 else if (f1<0)
907 {
908 if (f2<0) printf("\n *** [%-g,%-g] MHz BandReject filter added",fabs(f1),fabs(f2));
909 if (f2>0) printf("\n *** %-g MHz LowPass filter added",f2);
910 }
911 else
912 {
913 printf("\n *** [%-g,%-g] MHz is nor a valid filter band *** \n",f1,f2);
914 return;
915 }
916 if (fChannel>=0)
917 {
918 printf(" for channel %-i *** \n",fChannel);
919 }
920 else
921 {
922 printf(" for all channels *** \n");
923 }
924 }
925 }
926 } // End of loop over the channels
927 return;
928 } // End of AddFilter processing
929
930 TString str=fExecMode;
931 str.ReplaceAll("Store","");
932 Int_t jstore=str.Atoi();
933 GetHistograms(jstore);
934}
935
937{
943
944 // Clear all histograms for this storage
945 if (!fMode.Contains("Store"))
946 {
947 for (Int_t i=0; i<24; i++)
948 {
949 fHistos[jstore-1][i].Reset();
950 }
951 }
952
953 if (!fEvt || jstore<1 || jstore>3) return;
954
955 TGraph Gin; // Graph for input sampling
956 TH1F Hin; // Histogram for input sampling
957 TH1F Hout; // Resulting output histogram after performing an operation
958 TGraph Gout; // Resulting output graph after performing an operation
959
960 TString htitle; // The histogram/graph title
961 TString xtitle; // The histogram/graph X-axis label
962 TString ytitle; // The histogram/graph Y-axis label
963 TString str,str2; // Multifunctional strings
964 Int_t npoints=0;
965 Double_t x=0;
966 Double_t y=0;
967 Double_t xfirst=0;
968 Double_t xlast=0;
969 Double_t xmin=0;
970 Double_t xmax=0;
971 Int_t nbins=0;
972 TAxis* axis=0;
973 TH1F htemp; // Multifunctional temporary histogram
974 Double_t freq=0; // Variable to allow choice of providing the sampling frequency (fSample)
975 Bool_t draw=kTRUE; // Flag to activate drawing of the result
976
977 // Interpretation of the various operations parameters
978 Int_t n=fOpsPars[0].Atoi(); // The number of samples in case of fixed blocks
979 Double_t fpr=fOpsPars[0].Atof(); // The False Positive Rate for Bayesian Block processing
980 Double_t nrms=fOpsPars[1].Atof(); // The number of standard deviations for the Bayesian Block y-errors
981 TString fyerr=fOpsPars[1]; // The function (in TF1 format) to describe the Bayesian Block y-errors
982 Int_t ntrig=fOpsPars[2].Atoi(); // The trigger parameter for Bayesian Block processing
983 if (fOpsMode=="mV") fFmV=fOpsPars[1];
984 TF1 adc2mV("adc2mV",fFmV);
985 TString DFTsel; // The output selection(s) for the Discrete Fourier Transform
986 str=fMode;
987 str.ReplaceAll("Store","");
988 Int_t StoreIn=str.Atoi(); // The requested input storage
989 str=fOpsPars[0];
990 str.ReplaceAll("Store","");
991 Int_t jch2=str.Atoi(); // The requested 2nd channel number for combinations of spectra
992 str=fOpsPars[1];
993 str.ReplaceAll("Store","");
994 Int_t StoreIn2=str.Atoi(); // The requested 2nd input storage for combinations of spectra
995 Double_t BW=fOpsPars[0].Atof(); // The filter band roll-off in fraction of the sampling frequency
996 Double_t MW=fOpsPars[0].Atof(); // The moving average roll-off in the number of samples
997 Int_t nkernel=0; // The number of filter kernel points
998 Float_t snr=0; // The SNR value of spectra
999 Float_t snrdb=0; // The SNR value in dB
1000 Int_t snrmode=4;
1001 if (fOpsPars[1]=="RMS" || fOpsPars[1]=="Power") snrmode=3;
1002
1003 NcSample sample;
1004
1005 Int_t jstart=0;
1006 Int_t jstop=23;
1007 if (fChannel>=0) // Single selected channel
1008 {
1009 jstart=fChannel;
1010 jstop=fChannel;
1011 }
1012
1013 for (Int_t jch=jstart; jch<=jstop; jch++)
1014 {
1015 if (StoreIn>0 && StoreIn<4)
1016 {
1017 Hin=fHistos[StoreIn-1][jch];
1018 }
1019 else if (fMode.Contains("ADC"))
1020 {
1021 // Get the raw ADC sampling input graph
1022 Gin=fEvt->GetSamplingGraph(fStation,jch);
1023
1024 // Create the raw ADC input histogram
1025 Gin.Sort();
1026 npoints=Gin.GetN();
1027 Gin.GetPoint(0,xfirst,y);
1028 Gin.GetPoint(npoints-1,xlast,y);
1029 xmin=xfirst-1;
1030 xmax=xlast;
1031 nbins=npoints;
1032 Hin.Reset();
1033 Hin.SetBins(nbins,xmin,xmax);
1034 if (fMode.Contains("(t)"))
1035 {
1036 Hin.SetBins(nbins,xmin/fSample,xmax/fSample);
1037 }
1038
1039 for (Int_t i=0; i<npoints; i++)
1040 {
1041 Gin.GetPoint(i,x,y);
1042 // Perform the ADC->mV conversion if requested
1043 if (fMode.Contains("(t)")) x=x/fSample;
1044 Gin.SetPoint(i,x,y);
1045 Hin.SetBinContent(i+1,y);
1046 }
1047
1048 // Set the corresponding title and axes labels
1049 htitle=Gin.GetTitle();
1050 xtitle="Sample";
1051 if (fMode.Contains("(t)")) xtitle="Time in seconds";
1052 ytitle="ADC";
1053 str.Form("%-s;%-s;%-s",htitle.Data(),xtitle.Data(),ytitle.Data());
1054 Gin.SetTitle(str);
1055 Hin.SetTitle(str);
1056 Hin.SetStats(kFALSE);
1057 }
1058
1059 if (fMode.Contains("Store"))
1060 {
1061 // Create an input graph from the input histogram
1062 npoints=Hin.GetNbinsX();
1063 for (Int_t i=0; i<npoints; i++)
1064 {
1065 x=Hin.GetBinCenter(i+1);
1066 y=Hin.GetBinContent(i+1);
1067 Gin.SetPoint(i,x,y);
1068 }
1069
1070 // Update the axes labels for the input graph
1071 htitle=Hin.GetTitle();
1072 axis=Hin.GetXaxis();
1073 xtitle=axis->GetTitle();
1074 axis=Hin.GetYaxis();
1075 ytitle=axis->GetTitle();
1076 str.Form("%-s;%-s;%-s",htitle.Data(),xtitle.Data(),ytitle.Data());
1077 Gin.SetTitle(str);
1078 }
1079
1080 // The requested operation for the selected input sampling(s)
1081 Hout=Hin;
1082
1083 if (fOpsMode=="mV") // ADC->mV conversion
1084 {
1085 if (!(ytitle.Contains("ADC")) || ytitle.Contains("mV"))
1086 {
1087 printf("\n *** This is not an ADC sampling ==> No conversion performed *** \n");
1088 return;
1089 }
1090 else
1091 {
1092 npoints=Hin.GetNbinsX();
1093 for (Int_t i=0; i<npoints; i++)
1094 {
1095 x=Hin.GetBinCenter(i+1);
1096 y=Hin.GetBinContent(i+1);
1097 y=adc2mV.Eval(y);
1098 Hin.SetBinContent(i+1,y);
1099 Gin.SetPoint(i,x,y);
1100 }
1101 ytitle.Form("mV=[%-s]",(adc2mV.GetExpFormula("p")).Data());
1102 ytitle.ReplaceAll("x","ADC");
1103 str.Form("%-s;%-s;%-s",htitle.Data(),xtitle.Data(),ytitle.Data());
1104 Hin.SetTitle(str);
1105 Gin.SetTitle(str);
1106
1107 Hout=Hin;
1108 }
1109 }
1110
1111 if (fOpsMode=="DFT" || fOpsMode=="IDFT") // DFT operations
1112 {
1113 if (fOpsMode=="DFT" && !(ytitle.Contains("ADC")) && !(ytitle.Contains("mV")))
1114 {
1115 printf("\n *** This is not a time domain ==> No DFT performed *** \n");
1116 return;
1117 }
1118 else if (fOpsMode=="IDFT" && (StoreIn<1 || StoreIn>3))
1119 {
1120 printf("\n *** No Store%-i data available ==> No Inverse DFT performed *** \n",StoreIn);
1121 return;
1122 }
1123 else if (fOpsMode=="IDFT" && (ytitle.Contains("ADC") || ytitle.Contains("mV")))
1124 {
1125 printf("\n *** This is not a frequency domain ==> No inverse DFT performed *** \n");
1126 return;
1127 }
1128 else
1129 {
1130 DFTsel=fOpsPars[0];
1131 DFTsel+=" ";
1132 DFTsel+=fOpsPars[1];
1133 DFTsel+=" ";
1134 DFTsel+=fOpsPars[2];
1135
1136 if (fOpsMode=="DFT") // DFT time->frequency
1137 {
1138 freq=0;
1139 if (DFTsel.Contains("Hz")) freq=fSample;
1140 fDSP.Load((TH1*)&Hin,freq);
1141 fDSP.Fourier("R2C",&Hout,DFTsel);
1142 fReArr[jstore-1][jch]=fDSP.GetData("RE out");
1143 fImArr[jstore-1][jch]=fDSP.GetData("IM out");
1144 fYtitles[jstore-1][jch]=ytitle;
1145 }
1146 if (fOpsMode=="IDFT") // Inverse DFT frequency->time
1147 {
1148 freq=0;
1149 if (DFTsel.Contains("t")) freq=fSample;
1150 fDSP.Load(&fReArr[StoreIn-1][jch],&fImArr[StoreIn-1][jch],freq);
1151 fDSP.Fourier("C2R",&Hout,DFTsel);
1152 axis=Hout.GetYaxis();
1153 str=fYtitles[StoreIn-1][jch];
1154 axis->SetTitle(str);
1155 }
1156
1157 htitle=Hin.GetTitle();
1158 axis=Hout.GetXaxis();
1159 xtitle=axis->GetTitle();
1160 axis=Hout.GetYaxis();
1161 ytitle=axis->GetTitle();
1162 str.Form("%-s;%-s;%-s",htitle.Data(),xtitle.Data(),ytitle.Data());
1163 Hout.SetTitle(htitle);
1164 }
1165 }
1166
1167 if (fOpsMode=="Sub") // Subtraction of spectra
1168 {
1169 axis=Hin.GetXaxis();
1170 str=axis->GetTitle();
1171 axis=fHistos[StoreIn2-1][jch2].GetXaxis();
1172 str2=axis->GetTitle();
1173 if (str.Contains(str2) || str2.Contains(str))
1174 {
1175 fBB.Add(&Hin,&fHistos[StoreIn2-1][jch2],&Hout,kFALSE,-1);
1176 }
1177 else
1178 {
1179 printf("\n *** Units on the X-axes don't match ==> No action performed *** \n");
1180 return;
1181 }
1182 }
1183
1184 if (fOpsMode=="Corr") // Correlation of spectra
1185 {
1186 axis=Hin.GetXaxis();
1187 str=axis->GetTitle();
1188 freq=0;
1189 if (str.Contains("Time")) freq=fSample;
1190 fDSP.Load((TH1*)&Hin,freq);
1191 // Ensure identical binning for the data and the search pattern
1192 fBB.Rebin(&fHistos[StoreIn2-1][jch2],&htemp,kFALSE);
1193 fDSP.SetWaveform((TH1*)&htemp);
1194 fDSP.Correlate(&Hout,0,0,0,fOpsPars[2]);
1195 }
1196
1197 if (fOpsMode=="SNR") // Provide the SNR of the distribution(s)
1198 {
1199 sample.Load((TH1*)&Hin);
1200 snr=sample.GetSNR(1,snrmode,kFALSE);
1201 if (snr>0) snrdb=10.*log10(snr);
1202 if (jch==jstart) printf("\n");
1203 printf(" *** Ch%-i in Store%-i : SNR=%-g (%-g dB) *** \n",jch,StoreIn,snr,snrdb);
1204 draw=kFALSE;
1205 }
1206
1207 if (fOpsMode=="BKernel") // Provide the multiband filter kernel
1208 {
1209 if (!fFilterBands[jch].GetSize())
1210 {
1211 if (jch==jstart) printf("\n");
1212 printf(" *** No FilterBands specified for channel %-i *** \n",jch);
1213 if (fChannel>=0) return;
1214 continue;
1215 }
1216 nkernel=0;
1217 if (BW>0) nkernel=4./BW;
1218 freq=0;
1219 if (fOpsPars[2]=="Hz" || fOpsPars[2]=="t") freq=fSample;
1220 fDSP.SetSamplingFrequency(freq);
1221 if (fOpsPars[1]=="hisf")
1222 {
1223 fDSP.GetMultiBandKernel(fFilterBands[jch],nkernel,&Hout);
1224 fReArr[jstore-1][jch]=fDSP.GetData("RE out");
1225 fImArr[jstore-1][jch]=fDSP.GetData("IM out");
1226 }
1227 else
1228 {
1229 fDSP.GetMultiBandKernel(fFilterBands[jch],nkernel,0,0,&Hout);
1230 }
1231 }
1232
1233 if (fOpsMode=="BFilter") // Perform the multiband filtering
1234 {
1235 if (!(ytitle.Contains("ADC")) && !(ytitle.Contains("mV")))
1236 {
1237 printf("\n *** This is not a time domain ==> No filtering performed *** \n");
1238 return;
1239 }
1240 if (!fFilterBands[jch].GetSize())
1241 {
1242 if (jch==jstart) printf("\n");
1243 printf(" *** No FilterBands specified for channel %-i *** \n",jch);
1244 if (fChannel>=0) return;
1245 continue;
1246 }
1247 nkernel=0;
1248 if (BW>0) nkernel=4./BW;
1249 freq=0;
1250 if (fOpsPars[2]=="Hz" || fOpsPars[2]=="t") freq=fSample;
1251 fDSP.Load((TH1*)&Hin,freq);
1252 if (fOpsPars[1]=="hisf")
1253 {
1254 fDSP.FilterMultiBand(fFilterBands[jch],nkernel,&Hout,kTRUE);
1255 fReArr[jstore-1][jch]=fDSP.GetData("RE out");
1256 fImArr[jstore-1][jch]=fDSP.GetData("IM out");
1257 }
1258 else
1259 {
1260 fDSP.FilterMultiBand(fFilterBands[jch],nkernel,0,kTRUE,&Hout);
1261 axis=Hout.GetYaxis();
1262 axis->SetTitle(ytitle);
1263 }
1264 }
1265
1266 if (fOpsMode=="MKernel") // Provide the moving average filter kernel
1267 {
1268 if (MW<1)
1269 {
1270 if (jch==jstart) printf("\n");
1271 printf(" *** Invalid noise reduction factor : %-g *** \n",MW);
1272 if (fChannel>=0) return;
1273 continue;
1274 }
1275 nkernel=TMath::Nint(pow(MW,2));
1276 freq=0;
1277 if (fOpsPars[2]=="Hz" || fOpsPars[2]=="t") freq=fSample;
1278 fDSP.SetSamplingFrequency(freq);
1279 if (fOpsPars[1]=="hisf")
1280 {
1281 fDSP.GetMovingAverageKernel(nkernel,&Hout);
1282 fReArr[jstore-1][jch]=fDSP.GetData("RE out");
1283 fImArr[jstore-1][jch]=fDSP.GetData("IM out");
1284 }
1285 else
1286 {
1287 fDSP.GetMovingAverageKernel(nkernel,0,0,&Hout);
1288 }
1289 }
1290
1291 if (fOpsMode=="MFilter") // Perform the moving avrage filtering
1292 {
1293 if (!(ytitle.Contains("ADC")) && !(ytitle.Contains("mV")))
1294 {
1295 printf("\n *** This is not a time domain ==> No filtering performed *** \n");
1296 return;
1297 }
1298 if (MW<1)
1299 {
1300 if (jch==jstart) printf("\n");
1301 printf(" *** Invalid noise reduction factor : %-g *** \n",MW);
1302 if (fChannel>=0) return;
1303 continue;
1304 }
1305 nkernel=TMath::Nint(pow(MW,2));
1306 freq=0;
1307 if (fOpsPars[2]=="Hz" || fOpsPars[2]=="t") freq=fSample;
1308 fDSP.Load((TH1*)&Hin,freq);
1309 if (fOpsPars[1]=="hisf")
1310 {
1311 fDSP.FilterMovingAverage(nkernel,"conv",0,0,0,&Hout,kTRUE);
1312 fReArr[jstore-1][jch]=fDSP.GetData("RE out");
1313 fImArr[jstore-1][jch]=fDSP.GetData("IM out");
1314 }
1315 else
1316 {
1317 fDSP.FilterMovingAverage(nkernel,"conv",&Hout);
1318 axis=Hout.GetYaxis();
1319 axis->SetTitle(ytitle);
1320 }
1321 }
1322
1323 if (fOpsMode=="Bn" || fOpsMode=="BBnrms" || fOpsMode=="BBf") // Blocked samplings
1324 {
1325 if (fOpsMode=="Bn") // Fixed size blocks
1326 {
1327 if (fOpsPars[1]=="Mean") fBB.GetBlocks(&Gin,&Hout,n,0);
1328 if (fOpsPars[1]=="Median") fBB.GetBlocks(&Gin,&Hout,n,1);
1329 if (fOpsPars[1]=="RMS") fBB.GetBlocks(&Gin,&Hout,n,2);
1330 str.Form("%-s Fixed Blocks grouped in %-i consecutive samples",htitle.Data(),n);
1331 }
1332 else // Bayesian blocks
1333 {
1334 if (jch==jstart) printf("\n *** Bayesian Blocks processing in progress .... \n");
1335
1336 if (fOpsMode=="BBnrms") // Bayesian Blocks with nrms errors
1337 {
1338 fBB.GetBlocks(Gin,nrms,fpr,&Hout,ntrig);
1339 str.Form("%-s Bayesian Blocks with FPR=%-.3g and nrms=%-.3g",htitle.Data(),fpr,nrms);
1340 }
1341 if (fOpsMode=="BBf") // Bayesian Blocks with f(y_i) value errors
1342 {
1343 fBB.GetBlocks(Gin,fyerr,fpr,&Hout,ntrig);
1344 str.Form("%-s Bayesian Blocks with FPR=%-.3g and input errors: %-s",htitle.Data(),fpr,fyerr.Data());
1345 str.ReplaceAll("x","y");
1346 }
1347
1348 if (jch==jstart) printf("\n *** Bayesian Blocks processing completed *** \n");
1349 }
1350
1351 // Update the title and axes labels for the output histogram
1352 str+=";Blocked samplings";
1353 if (xtitle.Contains("seconds")) str+=" in seconds";
1354 if (xtitle.Contains("Hz")) str+=" in Hz";
1355 if (fOpsMode==3 || fOpsMode==4)
1356 {
1357 str+=" (ntrig=";
1358 str+=ntrig;
1359 str+=")";
1360 }
1361 str+=";";
1362 axis=Hout.GetYaxis();
1363 str2=axis->GetTitle();
1364 str+=str2;
1365 Hout.SetTitle(str);
1366 Hout.SetStats(kFALSE);
1367 }
1368
1369 // Store the resulting histogram
1370 fHistos[jstore-1][jch]=Hout;
1371
1372 // Construct the output TGraph from the output histogram
1373 npoints=Hout.GetNbinsX();
1374 for (Int_t i=0; i<npoints; i++)
1375 {
1376 x=Hout.GetBinCenter(i+1);
1377 y=Hout.GetBinContent(i+1);
1378 Gout.SetPoint(i,x,y);
1379 }
1380 htitle=Hout.GetTitle();
1381 axis=Hout.GetXaxis();
1382 xtitle=axis->GetTitle();
1383 axis=Hout.GetYaxis();
1384 ytitle=axis->GetTitle();
1385 str.Form("%-s;%-s;%-s",htitle.Data(),xtitle.Data(),ytitle.Data());
1386 Gout.SetTitle(str);
1387 } // End of loop over the channels
1388
1389 // Draw the result(s)
1390 if (draw) DrawResult(jstore);
1391}
1392
1393void RnoExplorer::DrawResult(Int_t jstore)
1394{
1400
1401 if (!fEvt) return;
1402
1404 // Create a new canvas for (modified) raw DAQ spectra //
1406 TString cname=ClassName();
1407 cname+=jstore;
1408 if (fCanvas[jstore-1])
1409 {
1410 if (gROOT->GetListOfCanvases()->FindObject(cname)) delete fCanvas[jstore-1];
1411 fCanvas[jstore-1]=0;
1412 }
1413
1414 Int_t topx=0;
1415 Int_t topy=0;
1416 if (jstore==2) topx=636;
1417 if (jstore==3)
1418 {
1419 topx=318;
1420 topy=150;
1421 }
1422 fCanvas[jstore-1]=new TCanvas("cx","cx",topx,topy,635,450);
1423 fCanvas[jstore-1]->SetName(cname);
1424
1425 // The initial part of the canvas title
1426 TString ctitle;
1427 ctitle.Form("Store%-i: ",jstore);
1428
1429 TVirtualPad* pad=0;
1430
1431 if (fChannel<0) fCanvas[jstore-1]->Divide(4,6);
1432
1433 // Update the canvas title
1434 ctitle+="Station";
1435 ctitle+=fStation;
1436 if (fChannel>=0) // Add Channel number in case of selected channel
1437 {
1438 ctitle+=" Ch";
1439 ctitle+=fChannel;
1440 }
1441
1442 Int_t jstart=0;
1443 Int_t jstop=23;
1444 if (fChannel>=0) // Single selected channel
1445 {
1446 jstart=fChannel;
1447 jstop=fChannel;
1448 }
1449
1450 for (Int_t jch=jstart; jch<=jstop; jch++)
1451 {
1452 if (fChannel<0) // All channels were requested
1453 {
1454 pad=fCanvas[jstore-1]->cd(jch+1);
1455
1456 if (!pad) continue;
1457
1458 pad->SetGrid();
1459 }
1460 else // Single channel was selected
1461 {
1462 fCanvas[jstore-1]->SetGrid();
1463 }
1464
1465 // Update the canvas title in case an operation was performed
1466 if (jch==jstart)
1467 {
1468 if (fOpsMode=="None") ctitle+=" ADC";
1469 if (fOpsMode=="mV") ctitle+=" mV";
1470 if (fOpsMode=="DFT") ctitle+=" DFT";
1471 if (fOpsMode=="IDFT") ctitle+=" Inverse DFT";
1472 if (fOpsMode=="Bn") ctitle+=" Fixed Blocks";
1473 if (fOpsMode=="BBnrms") ctitle+=" Bayesian Blocks with nrms errors";
1474 if (fOpsMode=="BBf") ctitle+=" Bayesian Blocks with f(y_i) errors";
1475 if (fOpsMode=="Sub") ctitle+=" Subtraction";
1476 if (fOpsMode=="Corr") ctitle+=" Correlation";
1477 if (fOpsMode=="BKernel") ctitle+=" Band filter kernel";
1478 if (fOpsMode=="BFilter") ctitle+=" Band filter result";
1479 if (fOpsMode=="MKernel") ctitle+=" Moving average filter kernel";
1480 if (fOpsMode=="MFilter") ctitle+=" Moving average filter result";
1481 }
1482
1483 fCanvas[jstore-1]->SetTitle(ctitle);
1484
1485 fHistos[jstore-1][jch].DrawCopy();
1486 fCanvas[jstore-1]->Update();
1487 } // End of loop over the channels
1488}
1489
1490void RnoExplorer::CommandPanel(TGCompositeFrame* frame)
1491{
1497
1498 if (!frame) return;
1499
1500 // Event listing controls
1501 TGGroupFrame* listings=new TGGroupFrame(frame,"Event Listings",kHorizontalFrame);
1502 listings->SetTitlePos(TGGroupFrame::kCenter);
1503 frame->AddFrame(listings);
1504
1505 // The event header
1506 TGTextButton* date=new TGTextButton(listings,"Date/Time");
1507 date->Connect("Clicked()",ClassName(),this,"ListDate()");
1508 date->SetToolTipText("List the detailed event date/time info");
1509 listings->AddFrame(date);
1510
1511 TGTextButton* daq=new TGTextButton(listings,"DAQ");
1512 daq->Connect("Clicked()",ClassName(),this,"ListDAQ()");
1513 daq->SetToolTipText("Listing of the DAQ status");
1514 TGLayoutHints* Ldaq=new TGLayoutHints(kLHintsLeft,5,0,0,-5);
1515 listings->AddFrame(daq,Ldaq);
1516
1517 TGTextButton* triggers=new TGTextButton(listings,"Triggers");
1518 triggers->Connect("Clicked()",ClassName(),this,"ListTriggers()");
1519 triggers->SetToolTipText("Listing of the event trigger data");
1520 TGLayoutHints* Ltriggers=new TGLayoutHints(kLHintsLeft,5,0,0,-5);
1521 listings->AddFrame(triggers,Ltriggers);
1522
1523 TGTextButton* tags=new TGTextButton(listings,"Tags");
1524 tags->Connect("Clicked()",ClassName(),this,"ListTags()");
1525 tags->SetToolTipText("Listing of the event tag data");
1526 TGLayoutHints* Ltags=new TGLayoutHints(kLHintsLeft,5,0,0,-5);
1527 listings->AddFrame(tags,Ltags);
1528
1529 // The device specification for the listing
1530 TGTextEntry* devname=new TGTextEntry(listings,"*");
1531 devname->SetAlignment(kTextRight);
1532 devname->Connect("TextChanged(const char*)",ClassName(),this,"ExpDevName(const char*)");
1533 devname->SetToolTipText("Device (class) name (*=all)");
1534 devname->Resize(80,20);
1535 TGLayoutHints* Ldevname=new TGLayoutHints(kLHintsLeft,5,0,0,-5);
1536 listings->AddFrame(devname,Ldevname);
1537
1538 TGTextButton* devs=new TGTextButton(listings,"Device(s)");
1539 devs->Connect("Clicked()",ClassName(),this,"ListDevices()");
1540 devs->SetToolTipText("List the selected device (class)");
1541 TGLayoutHints* Ldevs=new TGLayoutHints(kLHintsLeft,5,0,0,-5);
1542 listings->AddFrame(devs,Ldevs);
1543}
1544
1545void RnoExplorer::ExpDevName(const char* text)
1546{
1552
1553 fDevName=text;
1554}
1555
1557{
1563
1564 if (!fEvt)
1565 {
1566 printf("\n *** No RnoEvent structure loaded (yet). *** \n");
1567 return;
1568 }
1569
1570 // Get the detailed date/time info for this event via NcAstrolab
1571 Int_t mjd,sec,ns,ps;
1572 fEvt->GetMJD(mjd,sec,ns);
1573 ps=fEvt->GetPs();
1574
1575 TString station=fHead[1]->GetText();
1576 Int_t ist=station.Atoi();
1577
1578 NcAstrolab lab;
1579 lab.SetRandomiser(0);
1580 lab.SetExperiment("RNO-G",ist);
1581 lab.SetMJD(mjd,sec,ns,ps,"A");
1582
1583 printf("\n");
1584 lab.Data(3);
1585}
1586
1588{
1594
1595 if (!fEvt)
1596 {
1597 printf("\n *** No RnoEvent structure loaded (yet). *** \n");
1598 return;
1599 }
1600
1601 printf("\n");
1602 if (fDevName.Contains("*") || fDevName.Contains("Rno")) // Device class name requested
1603 {
1604 fEvt->ShowDevices(fDevName,2);
1605 }
1606 else // Specific device requested
1607 {
1608 NcDevice* dx=fEvt->GetDevice(fDevName);
1609 if (dx)
1610 {
1611 if (dx->InheritsFrom("NcDetectorUnit"))
1612 {
1613 ((NcDetectorUnit*)dx)->ShowDevices(2);
1614 }
1615 else
1616 {
1617 dx->Data();
1618 }
1619 }
1620 else
1621 {
1622 printf("\n *** Device %-s not found. *** \n",fDevName.Data());
1623 }
1624 }
1625}
1626
1628{
1634
1635 if (!fEvt)
1636 {
1637 printf("\n *** No RnoEvent structure loaded (yet). *** \n");
1638 return;
1639 }
1640
1641 NcDevice* dx=fEvt->GetDevice("DAQ");
1642
1643 if (dx)
1644 {
1645 printf("\n");
1646 dx->Data();
1647 }
1648 else
1649 {
1650 printf("\n *** No DAQ device present. *** \n");
1651 }
1652}
1653
1655{
1661
1662 if (!fEvt)
1663 {
1664 printf("\n *** No RnoEvent structure loaded (yet). *** \n");
1665 return;
1666 }
1667
1668 NcDevice* dx=fEvt->GetDevice("Trigger");
1669
1670 if (dx)
1671 {
1672 printf("\n");
1673 dx->Data();
1674 }
1675 else
1676 {
1677 printf("\n *** No Trigger device present. *** \n");
1678 }
1679}
1680
1682{
1688
1689 if (!fEvt)
1690 {
1691 printf("\n *** No RnoEvent structure loaded (yet). *** \n");
1692 return;
1693 }
1694
1695 NcDevice* dx=fEvt->GetDevice("Filter");
1696
1697 if (dx)
1698 {
1699 printf("\n");
1700 dx->Data();
1701 }
1702 else
1703 {
1704 printf("\n *** No Tag/Filter device present. *** \n");
1705 }
1706}
1707
1709{
1715
1716 // De-activate all automatic CloseWindow() actions of the system window manager
1717 // in order to fully control it in this function
1718 fExpPanel->DontCallClose();
1719
1720 // To prevent crash when the cursor is still left active in a TextEntry
1721 fExpPanel->RequestFocus();
1722
1723 // Unmap the display window
1724 fExpPanel->UnmapWindow();
1725}
1726
1728{
1734
1735 fExpPanel->RequestFocus();
1736 fExpPanel->Cleanup();
1737 gApplication->Terminate(0);
1738}
1739
1741{
1747
1748 // Map all subwindows of main frame
1749 fExpPanel->MapSubwindows();
1750
1751 // Initialize the layout algorithm
1752 fExpPanel->Resize(fExpPanel->GetDefaultSize());
1753
1754 // Map main frame
1755 fExpPanel->MapWindow();
1756}
1757
1759{
1765
1766 return fEvt;
1767}
1768
ClassImp(RnoExplorer)
Virtual lab to provide (astro)physical parameters, treat data and relate observations with astrophysi...
Definition NcAstrolab.h:47
void SetRandomiser(Int_t iseed, Int_t cnt1=0, Int_t cnt2=0, NcTimestamp *ts=0)
void Data(Int_t mode=1, TString u="deg", Bool_t utc=kTRUE)
void SetExperiment(TString name, Int_t id=0)
Handling of a collection of generic devices.
Signal (Hit) handling of a generic device.
Definition NcDevice.h:14
virtual void Data(TString f="car", TString u="rad") const
Definition NcDevice.cxx:692
Sampling and statistics tools for various multi-dimensional data samples.
Definition NcSample.h:28
Double_t GetSNR(Int_t i, Int_t mode=2, Bool_t db=kTRUE) const
void Load(TGraph *g, Int_t clr=1)
virtual Float_t GetSignal(Int_t j=1, Int_t mode=0) const
Definition NcSignal.cxx:651
void SetMJD(Int_t mjd, Int_t sec, Int_t ns, Int_t ps=0, TString utc="U", Int_t leap=0, Double_t dut=0)
Facility to provide version information.
Definition NcVersion.h:12
virtual void Data() const
Handling of RNO-G event data.
Definition RnoEvent.h:14
Graphical User Interface (GUI) to explore RNO-G event data.
Definition RnoExplorer.h:29
Int_t fChannel
Definition RnoExplorer.h:61
NcBlocks fBB
Definition RnoExplorer.h:77
void ExpMode(Int_t i)
TString fMode
Definition RnoExplorer.h:62
TString fDevName
Definition RnoExplorer.h:73
virtual void FilesPanel(TGCompositeFrame *frame)
virtual void CommandPanel(TGCompositeFrame *frame)
Bool_t fConnected
Definition RnoExplorer.h:83
RnoEvent * GetEvent()
void ExpOpsPar3(const char *text)
virtual ~RnoExplorer()
TString fYtitles[3][24]
Definition RnoExplorer.h:68
void GetHistograms(Int_t jstore)
TArrayD fFilterBands[24]
Definition RnoExplorer.h:71
TGTextEntry * fParams[3]
Definition RnoExplorer.h:86
void ExpOpsPar1(const char *text)
void ExpOpsPar2(const char *text)
TGMainFrame * fExpPanel
Definition RnoExplorer.h:80
TH1F fHistos[3][24]
Definition RnoExplorer.h:67
TArrayD fImArr[3][24]
Definition RnoExplorer.h:70
void ExpOpsMode(Int_t i)
TGTextEntry * fFiles
Definition RnoExplorer.h:81
TString fExecMode
Definition RnoExplorer.h:66
virtual void ExplorePanel()
virtual void SamplingsPanel(TGCompositeFrame *frame)
virtual void HeaderPanel(TGCompositeFrame *frame)
Double_t fSample
Definition RnoExplorer.h:59
void ExpChannel(const char *text)
Int_t fStation
Definition RnoExplorer.h:60
void ExpFmV(const char *text)
void ExpExecute()
TString fOpsMode
Definition RnoExplorer.h:64
TGTextEntry * fEntry
Definition RnoExplorer.h:84
void ExpExecMode(Int_t i)
TString fFmV
Definition RnoExplorer.h:63
Bool_t fIndexed
Definition RnoExplorer.h:88
TGTextEntry * fHead[4]
Definition RnoExplorer.h:85
TCanvas * fCanvas[3]
Definition RnoExplorer.h:75
RnoEvent * fEvt
Definition RnoExplorer.h:58
TArrayD fReArr[3][24]
Definition RnoExplorer.h:69
void DrawResult(Int_t jstore)
void ListTriggers()
TString fOpsPars[3]
Definition RnoExplorer.h:65
RnoExplorer(const char *name="T", const char *title="RnoExplorer")
void ExpDevName(const char *text)
TGTextEntry * fNentries
Definition RnoExplorer.h:82