| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2019
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // plot_cleaned.C
|
|---|
| 28 | // ==============
|
|---|
| 29 | //
|
|---|
| 30 | // This is a demonstration program showing how to do particular processing
|
|---|
| 31 | // on a single event basis. Here we simply display uncleand und cleand
|
|---|
| 32 | // images.
|
|---|
| 33 | //
|
|---|
| 34 | // Therefor MInteractiveTask is used, which gives you the possibility
|
|---|
| 35 | // to develop new tasks without the need of compilation.
|
|---|
| 36 | // The input is a merpp raw-data file.
|
|---|
| 37 | //
|
|---|
| 38 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 39 |
|
|---|
| 40 | Bool_t HandleInput()
|
|---|
| 41 | {
|
|---|
| 42 | // This must be there to get accesss to the GUI while the macro
|
|---|
| 43 | // is still running!
|
|---|
| 44 |
|
|---|
| 45 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
|---|
| 46 | while (1)
|
|---|
| 47 | {
|
|---|
| 48 | //
|
|---|
| 49 | // While reading the input process gui events asynchronously
|
|---|
| 50 | //
|
|---|
| 51 | timer.TurnOn();
|
|---|
| 52 | const char *gl = Getline("Type 'q' to exit, <return> to go on: ");
|
|---|
| 53 | timer.TurnOff();
|
|---|
| 54 |
|
|---|
| 55 | TString input = gl;
|
|---|
| 56 | if (input=="q\n")
|
|---|
| 57 | return kFALSE;
|
|---|
| 58 |
|
|---|
| 59 | if (input=="\n")
|
|---|
| 60 | return kTRUE;
|
|---|
| 61 | };
|
|---|
| 62 |
|
|---|
| 63 | return kFALSE;
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | //
|
|---|
| 67 | // Setup the data-members of your 'virtual' class
|
|---|
| 68 | //
|
|---|
| 69 | MHCamera display[4];
|
|---|
| 70 |
|
|---|
| 71 | TCanvas *c;
|
|---|
| 72 | MParList *fParList;
|
|---|
| 73 | MTaskList *fTaskList;
|
|---|
| 74 |
|
|---|
| 75 | //
|
|---|
| 76 | // Called like all PreProcess functions of tasks. Get the access to
|
|---|
| 77 | // the containers necessary for you.
|
|---|
| 78 | //
|
|---|
| 79 | Int_t PreProcess(MParList *plist)
|
|---|
| 80 | {
|
|---|
| 81 | // Get parameter and tasklist, see Process
|
|---|
| 82 | fParList = plist;
|
|---|
| 83 | fTaskList = (MTaskList*)plist->FindObject("MTaskList");
|
|---|
| 84 |
|
|---|
| 85 | // Get camera geoemtry
|
|---|
| 86 | MGeomCam *geomcam = (MGeomCam*)plist->FindObject("MGeomCam");
|
|---|
| 87 |
|
|---|
| 88 | // setup canvas and camera-histograms
|
|---|
| 89 | c = new TCanvas("Events", "Real Events", 600, 600);
|
|---|
| 90 | c->SetBorderMode(0);
|
|---|
| 91 | c->Divide(2,2);
|
|---|
| 92 | for (int i=0; i<4; i++)
|
|---|
| 93 | {
|
|---|
| 94 | display[i].SetGeometry(*geomcam);
|
|---|
| 95 | c->cd(i+1);
|
|---|
| 96 | display[i].Draw();
|
|---|
| 97 | gPad->cd(1);
|
|---|
| 98 | plist->FindObject("MHillas")->Draw();
|
|---|
| 99 | }
|
|---|
| 100 | return kTRUE;
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | //
|
|---|
| 104 | // Called like all Process functions of tasks. Process a single
|
|---|
| 105 | // event - here display it.
|
|---|
| 106 | //
|
|---|
| 107 | Int_t Process()
|
|---|
| 108 | {
|
|---|
| 109 | // For simplicity we search in the Process function for the
|
|---|
| 110 | // objects. This is deprectaed! Store the pointers to the objects
|
|---|
| 111 | // as data member and get the pointers in PreProcess.
|
|---|
| 112 | MReadMarsFile *read = (MReadMarsFile*)fTaskList->FindObject("MRead");
|
|---|
| 113 | MSignalCam *cam = (MSignalCam*) fTaskList->FindObject("MSignalCam");
|
|---|
| 114 | MImgCleanStd *clean = (MImgCleanStd*) fTaskList->FindObject("MImgCleanStd");
|
|---|
| 115 | MGeomCam *geom = (MGeomCam*) fParList->FindObject("MGeomCam");
|
|---|
| 116 |
|
|---|
| 117 | // Ouput event number
|
|---|
| 118 | cout << "Event #" << read->GetNumEntry() << ":" << endl;
|
|---|
| 119 |
|
|---|
| 120 | // Fill the data into your camera-histograms
|
|---|
| 121 | display[0].SetCamContent(*(MSignalCam*)fParList->FindObject("MSignalCam"), 9);
|
|---|
| 122 | display[1].SetCamContent(*(MSignalCam*)fParList->FindObject("MSignalCam"), 3);
|
|---|
| 123 | display[2].SetCamContent(*(MSignalCam*)fParList->FindObject("MSignalCam"), 6);
|
|---|
| 124 | display[3].SetCamContent(*(MSignalCam*)fParList->FindObject("MSignalCam"), 8);
|
|---|
| 125 |
|
|---|
| 126 | // Index of island
|
|---|
| 127 | //display[3].SetCamContent(*(MSignalCam*)fParList->FindObject("MSignalCam"), 5);
|
|---|
| 128 |
|
|---|
| 129 | // Update the display
|
|---|
| 130 | for (int i=1; i<=4; i++)
|
|---|
| 131 | {
|
|---|
| 132 | c->GetPad(i)->Modified();
|
|---|
| 133 | c->GetPad(i)->Update();
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | // print the data on the console
|
|---|
| 137 | ((MHillas*)fParList->FindObject("MHillas"))->Print(*geom);
|
|---|
| 138 | ((MHillasExt*)fParList->FindObject("MHillasExt"))->Print(*geom);
|
|---|
| 139 | ((MNewImagePar*)fParList->FindObject("MNewImagePar"))->Print(*geom);
|
|---|
| 140 |
|
|---|
| 141 | cout << "\n===================================================================" << endl;
|
|---|
| 142 | bool rc = HandleInput();
|
|---|
| 143 | cout << "===================================================================" << endl;
|
|---|
| 144 |
|
|---|
| 145 | // wait for 'return'
|
|---|
| 146 | return rc;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | //
|
|---|
| 150 | // Called like all PostProcess functions of tasks. Delete
|
|---|
| 151 | // instanciated objects.
|
|---|
| 152 | //
|
|---|
| 153 | Int_t PostProcess()
|
|---|
| 154 | {
|
|---|
| 155 | delete c;
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | void plot_cleaned(const char *fname)
|
|---|
| 159 | {
|
|---|
| 160 | // Setup parameter- and tasklist
|
|---|
| 161 | MParList plist;
|
|---|
| 162 | MTaskList tlist;
|
|---|
| 163 | plist.AddToList(&tlist);
|
|---|
| 164 |
|
|---|
| 165 | // Switch off blind pixels
|
|---|
| 166 | MBadPixelsCam badpixels;
|
|---|
| 167 | badpixels.InitSize(64);
|
|---|
| 168 | badpixels[63].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
|---|
| 169 | badpixels[62].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
|---|
| 170 | badpixels[61].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
|---|
| 171 | plist.AddToList(&badpixels);
|
|---|
| 172 |
|
|---|
| 173 | // setup reading task
|
|---|
| 174 | MReadMarsFile read("Events", fname);
|
|---|
| 175 | read.DisableAutoScheme();
|
|---|
| 176 |
|
|---|
| 177 | // setup a task making sure that all arrays are resized correctly
|
|---|
| 178 | MGeomApply geomapl;
|
|---|
| 179 |
|
|---|
| 180 | // Setup a print task calling TObject::Print
|
|---|
| 181 | MPrint print1("MMcEvt");
|
|---|
| 182 | MPrint print2("MRawEvtHeader");
|
|---|
| 183 | // Skip them if conatainers are not found
|
|---|
| 184 | print1.EnableSkip();
|
|---|
| 185 | print2.EnableSkip();
|
|---|
| 186 |
|
|---|
| 187 | // Switch off blind pixels
|
|---|
| 188 | MBadPixelsTreat treat;
|
|---|
| 189 | treat.SetProcessPedestalRun(kFALSE);
|
|---|
| 190 | treat.SetProcessPedestalEvt(kFALSE);
|
|---|
| 191 |
|
|---|
| 192 | // Setup image cleaning
|
|---|
| 193 | MImgCleanTime clean;
|
|---|
| 194 | clean.SetMinCount(0);
|
|---|
| 195 | clean.SetMinSize(25);
|
|---|
| 196 | clean.SetDeltaT(2.5);
|
|---|
| 197 |
|
|---|
| 198 | // Setup calculation of Image parameters
|
|---|
| 199 | MHillasCalc hcalc;
|
|---|
| 200 |
|
|---|
| 201 | // Setup intercative task calling the functions defined above
|
|---|
| 202 | MTaskInteractive mytask;
|
|---|
| 203 | mytask.SetPreProcess(PreProcess);
|
|---|
| 204 | mytask.SetProcess(Process);
|
|---|
| 205 |
|
|---|
| 206 | // Setup your tasklist
|
|---|
| 207 | tlist.AddToList(&read);
|
|---|
| 208 | tlist.AddToList(&geomapl);
|
|---|
| 209 | tlist.AddToList(&print1);
|
|---|
| 210 | tlist.AddToList(&print2);
|
|---|
| 211 | tlist.AddToList(&treat);
|
|---|
| 212 | tlist.AddToList(&clean);
|
|---|
| 213 | tlist.AddToList(&hcalc);
|
|---|
| 214 | tlist.AddToList(&mytask);
|
|---|
| 215 |
|
|---|
| 216 | // Run your analysis
|
|---|
| 217 | MEvtLoop evtloop;
|
|---|
| 218 | evtloop.SetParList(&plist);
|
|---|
| 219 |
|
|---|
| 220 | if (!evtloop.Eventloop())
|
|---|
| 221 | return;
|
|---|
| 222 |
|
|---|
| 223 | // Print statistics information about your loop
|
|---|
| 224 | tlist.PrintStatistics();
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|