| 1 | #include <TROOT.h>
|
|---|
| 2 | #include <TApplication.h>
|
|---|
| 3 |
|
|---|
| 4 | #include <TThread.h>
|
|---|
| 5 |
|
|---|
| 6 | #include "MParList.h"
|
|---|
| 7 | #include "MTaskList.h"
|
|---|
| 8 | #include "MEvtLoop.h"
|
|---|
| 9 |
|
|---|
| 10 | #include "MLogManip.h"
|
|---|
| 11 |
|
|---|
| 12 | #include "MRawSocketRead.h"
|
|---|
| 13 | #include "MGeomApply.h"
|
|---|
| 14 | #include "MCerPhotAnal2.h"
|
|---|
| 15 | #include "MFillH.h"
|
|---|
| 16 | #include "MFRealTimePeriod.h"
|
|---|
| 17 | #include "MOnlineDump2.h"
|
|---|
| 18 | #include "MHTriggerLvl0.h"
|
|---|
| 19 |
|
|---|
| 20 | #include "MStatusDisplay.h"
|
|---|
| 21 |
|
|---|
| 22 | #include "MImgCleanStd.h"
|
|---|
| 23 | #include "MHillasCalc.h"
|
|---|
| 24 | #include "MHillasSrcCalc.h"
|
|---|
| 25 |
|
|---|
| 26 | void StartUpMessage()
|
|---|
| 27 | {
|
|---|
| 28 | gLog << all << endl;
|
|---|
| 29 |
|
|---|
| 30 | // 1 2 3 4 5
|
|---|
| 31 | // 12345678901234567890123456789012345678901234567890
|
|---|
| 32 | gLog << "==================================================" << endl;
|
|---|
| 33 | gLog << " MONA V" << MARSVER << " " << endl;
|
|---|
| 34 | gLog << " Magic Online Analysis " << endl;
|
|---|
| 35 | gLog << " Compiled on <" << __DATE__ << ">" << endl;
|
|---|
| 36 | gLog << " Using ROOT v" << ROOTVER << endl;
|
|---|
| 37 | gLog << "==================================================" << endl;
|
|---|
| 38 | gLog << endl;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | Bool_t Loop(MStatusDisplay *display)
|
|---|
| 42 | {
|
|---|
| 43 | //
|
|---|
| 44 | // create the tasks which should be executed and add them to the list
|
|---|
| 45 | // in the case you don't need parameter containers, all of them can
|
|---|
| 46 | // be created by MRawFileRead::PreProcess
|
|---|
| 47 | //
|
|---|
| 48 | MRawSocketRead reader;
|
|---|
| 49 |
|
|---|
| 50 | //
|
|---|
| 51 | // create a (empty) list of parameters which can be used by the tasks
|
|---|
| 52 | // and an (empty) list of tasks which should be executed
|
|---|
| 53 | //
|
|---|
| 54 | MParList plist;
|
|---|
| 55 |
|
|---|
| 56 | MTaskList tasks;
|
|---|
| 57 | plist.AddToList(&tasks);
|
|---|
| 58 | tasks.AddToList(&reader);
|
|---|
| 59 |
|
|---|
| 60 | //MParList &plist = *(MParList*)ptr;
|
|---|
| 61 | //MTaskList &tasks = *(MTaskList*)plist.FindObject("MTaskList");
|
|---|
| 62 |
|
|---|
| 63 | MGeomApply geomapl;
|
|---|
| 64 | MCerPhotAnal2 ncalc;
|
|---|
| 65 | tasks.AddToList(&geomapl);
|
|---|
| 66 | tasks.AddToList(&ncalc);
|
|---|
| 67 |
|
|---|
| 68 | MFillH fill1("MHCamEvent", "MCerPhotEvt");
|
|---|
| 69 | MFillH fill2("MHEvent", "MCerPhotEvt");
|
|---|
| 70 |
|
|---|
| 71 | MHTriggerLvl0 trigmap(128, "Above 128");
|
|---|
| 72 | MFillH fill3(&trigmap, "MRawEvtData");
|
|---|
| 73 |
|
|---|
| 74 | MFRealTimePeriod filter;
|
|---|
| 75 | fill2.SetFilter(&filter);
|
|---|
| 76 |
|
|---|
| 77 | fill1.SetName("MFillCamEvent");
|
|---|
| 78 | fill2.SetName("MFillEvent");
|
|---|
| 79 | fill3.SetName("MFillTriggerLvl0");
|
|---|
| 80 |
|
|---|
| 81 | tasks.AddToList(&fill2);
|
|---|
| 82 | tasks.AddToList(&filter);
|
|---|
| 83 | tasks.AddToList(&fill1);
|
|---|
| 84 | tasks.AddToList(&fill3);
|
|---|
| 85 |
|
|---|
| 86 | MOnlineDump2 dump;
|
|---|
| 87 | dump.SetFilter(&filter);
|
|---|
| 88 | tasks.AddToList(&dump);
|
|---|
| 89 |
|
|---|
| 90 | MImgCleanStd clean;
|
|---|
| 91 | MHillasCalc hcalc;
|
|---|
| 92 | MHillasSrcCalc scalc; // !!Preliminary!! Will be removed later!
|
|---|
| 93 | MFillH hfill3("MHHillas", "MHillas");
|
|---|
| 94 | MFillH hfill6("MHHillasSrc","MHillasSrc");
|
|---|
| 95 | tasks.AddToList(&clean);
|
|---|
| 96 | tasks.AddToList(&hcalc);
|
|---|
| 97 | tasks.AddToList(&scalc);
|
|---|
| 98 | tasks.AddToList(&hfill3);
|
|---|
| 99 | tasks.AddToList(&hfill6);
|
|---|
| 100 |
|
|---|
| 101 | MEvtLoop magic;
|
|---|
| 102 | //plist.AddToList(&magic);
|
|---|
| 103 | magic.SetParList(&plist);
|
|---|
| 104 |
|
|---|
| 105 | magic.SetDisplay(display);
|
|---|
| 106 |
|
|---|
| 107 | if (!magic.Eventloop())
|
|---|
| 108 | {
|
|---|
| 109 | gLog << err << "Mona Eventloop error..." << endl;
|
|---|
| 110 | return kFALSE;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | tasks.PrintStatistics();
|
|---|
| 114 | return kTRUE;
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | void *thread(void *ptr)
|
|---|
| 118 | {
|
|---|
| 119 | // TThread::SetCancelAsynchronous();
|
|---|
| 120 | // TThread::SetCancelOn();
|
|---|
| 121 | MStatusDisplay *display=(MStatusDisplay*)ptr;
|
|---|
| 122 | // display->Lock();
|
|---|
| 123 |
|
|---|
| 124 | //
|
|---|
| 125 | // If a loop is stopped reinitialize a new loop until the
|
|---|
| 126 | // user requested to exit the program.
|
|---|
| 127 | //
|
|---|
| 128 | while (display->CheckStatus()!=MStatusDisplay::kFileExit)
|
|---|
| 129 | Loop(display);
|
|---|
| 130 |
|
|---|
| 131 | gLog << dbg << "Exit System Loop... " << flush;
|
|---|
| 132 | gSystem->ExitLoop();
|
|---|
| 133 | gLog << "done." << endl;
|
|---|
| 134 |
|
|---|
| 135 | return 0;
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | int main(int argc, char **argv)
|
|---|
| 139 | {
|
|---|
| 140 | TROOT simple("mona", "Magic ONline Analysis");
|
|---|
| 141 | TApplication app("MonaApp", &argc, argv);
|
|---|
| 142 |
|
|---|
| 143 | StartUpMessage();
|
|---|
| 144 |
|
|---|
| 145 | //
|
|---|
| 146 | // Starting MStatusDisplay in the thread results in hangs
|
|---|
| 147 | // if the thread is terminated (by return)
|
|---|
| 148 | //
|
|---|
| 149 | MStatusDisplay d;
|
|---|
| 150 | d.Resize(740, 600);
|
|---|
| 151 |
|
|---|
| 152 | gLog << dbg << "Starting Thread..." << endl;
|
|---|
| 153 | TThread t(thread, &d);
|
|---|
| 154 | t.Run();
|
|---|
| 155 |
|
|---|
| 156 | gLog << dbg << "Starting System loop..." << endl;
|
|---|
| 157 | app.Run(kTRUE);
|
|---|
| 158 | gLog << dbg << "System loop stopped." << endl;
|
|---|
| 159 |
|
|---|
| 160 | return 0;
|
|---|
| 161 | }
|
|---|