| 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 et al, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | void MagicHillas(const char *filename="~/data/Gamma_20_N*.root")
|
|---|
| 27 | {
|
|---|
| 28 | //
|
|---|
| 29 | // This is a demonstration program which calculates the Hillas
|
|---|
| 30 | // parameter out of a Magic root file (raw data file).
|
|---|
| 31 | //
|
|---|
| 32 |
|
|---|
| 33 | //
|
|---|
| 34 | // Create a empty Parameter List and an empty Task List
|
|---|
| 35 | // The tasklist is identified in the eventloop by its name
|
|---|
| 36 | //
|
|---|
| 37 | MParList plist;
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | MTaskList tlist;
|
|---|
| 41 | plist.AddToList(&tlist);
|
|---|
| 42 |
|
|---|
| 43 | //
|
|---|
| 44 | // The geometry container must be created by yourself to make sure
|
|---|
| 45 | // that you don't choos a wrong geometry by chance
|
|---|
| 46 | //
|
|---|
| 47 | MGeomCamMagic geomcam;
|
|---|
| 48 | plist.AddToList(&geomcam);
|
|---|
| 49 |
|
|---|
| 50 | //
|
|---|
| 51 | // Use this if you want to change the binning of one of
|
|---|
| 52 | // the histograms. You can use:
|
|---|
| 53 | // BinningConc, BinningConc1, BinningAsym, BinningM3Long,
|
|---|
| 54 | // BinningM3Trans, BinningWidth, BinningLength, BinningDist,
|
|---|
| 55 | // BinningHeadTail, BinningAlpha, BinningSize, BinningDelta,
|
|---|
| 56 | // BinningPixels and BinningCamera
|
|---|
| 57 | //
|
|---|
| 58 | // For more information see MBinning and the corresponding
|
|---|
| 59 | // histograms
|
|---|
| 60 | //
|
|---|
| 61 | // MBinning binsalpha("BinningAlpha");
|
|---|
| 62 | // binsalpha.SetEdges(90, 0, 90); // 90 bins from 0 to 90 deg
|
|---|
| 63 | // plist.AddToList(&binsalpha);
|
|---|
| 64 |
|
|---|
| 65 | // MBinning binssize("BinningSize");
|
|---|
| 66 | // binssize.SetEdgesLog(50, 1, 1e7);
|
|---|
| 67 | // plist.AddToList(&binssize);
|
|---|
| 68 |
|
|---|
| 69 | //
|
|---|
| 70 | // Craete the object which hlods the source positions in the camera
|
|---|
| 71 | // plain in respect to which the image parameters will be calculated.
|
|---|
| 72 | // For real data the containers will be filled by a task.
|
|---|
| 73 | //
|
|---|
| 74 | MSrcPosCam source("Source")
|
|---|
| 75 | source.SetXY(0, 0);
|
|---|
| 76 |
|
|---|
| 77 | MSrcPosCam antisrc("AntiSrc");
|
|---|
| 78 | antisrc.SetXY(240, 0);
|
|---|
| 79 |
|
|---|
| 80 | plist.AddToList(&source);
|
|---|
| 81 | plist.AddToList(&antisrc);
|
|---|
| 82 |
|
|---|
| 83 | //
|
|---|
| 84 | // Now setup the tasks and tasklist:
|
|---|
| 85 | // ---------------------------------
|
|---|
| 86 | //
|
|---|
| 87 | // The first argument is the tree you want to read.
|
|---|
| 88 | // Events: Cosmic ray events
|
|---|
| 89 | // PedEvents: Pedestal Events
|
|---|
| 90 | // CalEvents: Calibration Events
|
|---|
| 91 | //
|
|---|
| 92 | MReadMarsFile read("Events", filename);
|
|---|
| 93 | read.DisableAutoScheme();
|
|---|
| 94 |
|
|---|
| 95 | MMcPedestalCopy pcopy;
|
|---|
| 96 | MMcPedestalNSBAdd pnsb;
|
|---|
| 97 |
|
|---|
| 98 | MCerPhotCalc ncalc;
|
|---|
| 99 | //
|
|---|
| 100 | // Alternative photon calculation:
|
|---|
| 101 | // Example: use only 2nd to 6th FADC slices for photon calculation:
|
|---|
| 102 | //
|
|---|
| 103 | // const Float_t x[15]={0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|---|
| 104 | // TArrayF w(15,x);
|
|---|
| 105 | // ncalc.SetWeights(w);
|
|---|
| 106 | //
|
|---|
| 107 |
|
|---|
| 108 | MImgCleanStd clean;
|
|---|
| 109 | MBlindPixelCalc blind;
|
|---|
| 110 | //
|
|---|
| 111 | // Instead of unmapping the pixels you can also
|
|---|
| 112 | //
|
|---|
| 113 | // blind.SetUseInterpolation();
|
|---|
| 114 | // blind.SetUseCetralPixel();
|
|---|
| 115 | //
|
|---|
| 116 | MHillasCalc hcalc;
|
|---|
| 117 | MHillasSrcCalc csrc1("Source", "HillasSource");
|
|---|
| 118 | MHillasSrcCalc csrc2("AntiSrc", "HillasAntiSrc");
|
|---|
| 119 |
|
|---|
| 120 | //
|
|---|
| 121 | // To use MHillasExt instead of MHillas
|
|---|
| 122 | //
|
|---|
| 123 | MHillasExt hext;
|
|---|
| 124 | plist.AddToList(&hext);
|
|---|
| 125 |
|
|---|
| 126 | MFillH hfill1("MHHillas", "MHillas");
|
|---|
| 127 | MFillH hfill2("MHHillasExt");
|
|---|
| 128 | MFillH hfill3("MHStarMap", "MHillas");
|
|---|
| 129 | MFillH hfill4("HistExtSource [MHHillasExt]", "HillasSource");
|
|---|
| 130 | MFillH hfill5("HistExtAntiSrc [MHHillasExt]", "HillasAntiSrc");
|
|---|
| 131 | MFillH hfill6("HistSource [MHHillasSrc]", "HillasSource");
|
|---|
| 132 | MFillH hfill7("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
|
|---|
| 133 |
|
|---|
| 134 | MWriteRootFile write("hillas.root");
|
|---|
| 135 | write.AddContainer("HillasSource", "Hillas");
|
|---|
| 136 | write.AddContainer("HillasAntiSrc", "Hillas");
|
|---|
| 137 | write.AddContainer("MHStarMap");
|
|---|
| 138 | write.AddContainer("MMcEvt","Hillas");
|
|---|
| 139 | write.AddContainer("Source","RunHeaders");
|
|---|
| 140 | write.AddContainer("AntiSrc","RunHeaders");
|
|---|
| 141 |
|
|---|
| 142 | tlist.AddToList(&read);
|
|---|
| 143 | tlist.AddToList(&pcopy);
|
|---|
| 144 | tlist.AddToList(&pnsb);
|
|---|
| 145 | tlist.AddToList(&ncalc);
|
|---|
| 146 | tlist.AddToList(&clean);
|
|---|
| 147 | tlist.AddToList(&blind);
|
|---|
| 148 |
|
|---|
| 149 | tlist.AddToList(&hcalc);
|
|---|
| 150 | tlist.AddToList(&csrc1);
|
|---|
| 151 | tlist.AddToList(&csrc2);
|
|---|
| 152 |
|
|---|
| 153 | tlist.AddToList(&hfill1);
|
|---|
| 154 | tlist.AddToList(&hfill2);
|
|---|
| 155 | tlist.AddToList(&hfill3);
|
|---|
| 156 | tlist.AddToList(&hfill4);
|
|---|
| 157 | tlist.AddToList(&hfill5);
|
|---|
| 158 | tlist.AddToList(&hfill6);
|
|---|
| 159 | tlist.AddToList(&hfill7);
|
|---|
| 160 | tlist.AddToList(&write);
|
|---|
| 161 |
|
|---|
| 162 | //
|
|---|
| 163 | // Create and setup the eventloop
|
|---|
| 164 | //
|
|---|
| 165 | MEvtLoop evtloop;
|
|---|
| 166 | evtloop.SetParList(&plist);
|
|---|
| 167 |
|
|---|
| 168 | //
|
|---|
| 169 | // Execute your analysis
|
|---|
| 170 | //
|
|---|
| 171 | MProgressBar bar;
|
|---|
| 172 | evtloop.SetProgressBar(&bar);
|
|---|
| 173 | if (!evtloop.Eventloop())
|
|---|
| 174 | return;
|
|---|
| 175 |
|
|---|
| 176 | tlist.PrintStatistics();
|
|---|
| 177 |
|
|---|
| 178 | //
|
|---|
| 179 | // After the analysis is finished we can display the histograms
|
|---|
| 180 | //
|
|---|
| 181 | plist.FindObject("MHHillas")->DrawClone();
|
|---|
| 182 | plist.FindObject("MHHillasExt")->DrawClone();
|
|---|
| 183 | plist.FindObject("MHStarMap")->DrawClone();
|
|---|
| 184 | plist.FindObject("HistSource")->DrawClone();
|
|---|
| 185 | plist.FindObject("HistAntiSrc")->DrawClone();
|
|---|
| 186 | plist.FindObject("HistExtSource")->DrawClone();
|
|---|
| 187 | plist.FindObject("HistExtAntiSrc")->DrawClone();
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|