| 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 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // STAR - STandard Analysis and Reconstruction
|
|---|
| 28 | //
|
|---|
| 29 | // This macro is the standard converter to convert raw data into image
|
|---|
| 30 | // parameters
|
|---|
| 31 | //
|
|---|
| 32 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 33 |
|
|---|
| 34 | #include "MImgCleanStd.h"
|
|---|
| 35 |
|
|---|
| 36 | void star(Float_t clean1=3., Float_t clean2=2.5)
|
|---|
| 37 | {
|
|---|
| 38 | //
|
|---|
| 39 | // This is a demonstration program which calculates the image
|
|---|
| 40 | // parameters from a Magic raw data root file.
|
|---|
| 41 |
|
|---|
| 42 | //
|
|---|
| 43 | // Create a empty Parameter List and an empty Task List
|
|---|
| 44 | // The tasklist is identified in the eventloop by its name
|
|---|
| 45 | //
|
|---|
| 46 | MParList plist;
|
|---|
| 47 |
|
|---|
| 48 | MTaskList tlist;
|
|---|
| 49 |
|
|---|
| 50 | plist.AddToList(&tlist);
|
|---|
| 51 |
|
|---|
| 52 | MSrcPosCam src;
|
|---|
| 53 | src.SetReadyToSave();
|
|---|
| 54 | plist.AddToList(&src);
|
|---|
| 55 |
|
|---|
| 56 | //
|
|---|
| 57 | // The geometry container must be created by yourself to make sure
|
|---|
| 58 | // that you don't choose a wrong geometry by mistake
|
|---|
| 59 | //
|
|---|
| 60 | MGeomCamMagic geomcam;
|
|---|
| 61 | plist.AddToList(&geomcam);
|
|---|
| 62 |
|
|---|
| 63 | //
|
|---|
| 64 | // Now setup the tasks and tasklist:
|
|---|
| 65 | // ---------------------------------
|
|---|
| 66 | //
|
|---|
| 67 | MReadMarsFile read("Events");
|
|---|
| 68 | read.DisableAutoScheme();
|
|---|
| 69 |
|
|---|
| 70 | // ------------- user change -----------------
|
|---|
| 71 | // read.AddFile("Pro*.root");
|
|---|
| 72 | // read.AddFile("Gamma_*_0_7_*.root");
|
|---|
| 73 | // read.AddFile("Gamma_*.root");
|
|---|
| 74 |
|
|---|
| 75 | gSystem->Exec("ls Gamma_*.root > files.txt");
|
|---|
| 76 |
|
|---|
| 77 | Float_t ratio = 1.;
|
|---|
| 78 |
|
|---|
| 79 | ifstream list;
|
|---|
| 80 | list.open("files.txt");
|
|---|
| 81 | while (1)
|
|---|
| 82 | {
|
|---|
| 83 | Char_t file[256];
|
|---|
| 84 | list >> file;
|
|---|
| 85 | if (!list.good()) break;
|
|---|
| 86 | TChain dummy("Events");
|
|---|
| 87 | dummy.Add(file);
|
|---|
| 88 | Int_t maxevents = ratio*dummy.GetEntries();
|
|---|
| 89 |
|
|---|
| 90 | read.AddFile(file,maxevents);
|
|---|
| 91 | }
|
|---|
| 92 | list.close();
|
|---|
| 93 | gSystem->Exec("rm files.txt");
|
|---|
| 94 |
|
|---|
| 95 | MMcPedestalCopy pcopy;
|
|---|
| 96 | MMcPedestalNSBAdd pnsb;
|
|---|
| 97 |
|
|---|
| 98 | MCerPhotCalc ncalc;
|
|---|
| 99 |
|
|---|
| 100 | const Float_t x[15]={0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|---|
| 101 | const TArrayF w(15,(Float_t*)x);
|
|---|
| 102 | ncalc.SetWeights(w);
|
|---|
| 103 |
|
|---|
| 104 | MBlindPixelCalc blind;
|
|---|
| 105 | blind.SetUseInterpolation();
|
|---|
| 106 |
|
|---|
| 107 | MImgCleanStd clean(clean1, clean2);
|
|---|
| 108 |
|
|---|
| 109 | MHillasCalc hcalc;
|
|---|
| 110 | MHillasSrcCalc scalc; // !!Preliminary!! Will be removed later!
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 | MContinue filtersize300("MHillas.fSize<300");
|
|---|
| 114 | MContinue filtersize500("MHillas.fSize<500");
|
|---|
| 115 | MContinue filtersize1000("MHillas.fSize<1000");
|
|---|
| 116 | MContinue filtersize2000("MHillas.fSize<2000");
|
|---|
| 117 |
|
|---|
| 118 | MFEventSelector eventselector1;
|
|---|
| 119 | eventselector1.SetNumSelectEvts(10000);
|
|---|
| 120 | MFEventSelector eventselector2;
|
|---|
| 121 | eventselector2.SetNumSelectEvts(17000);
|
|---|
| 122 | MFEventSelector eventselector3;
|
|---|
| 123 | eventselector3.SetNumSelectEvts(27000);
|
|---|
| 124 | MFEventSelector eventselector4;
|
|---|
| 125 | eventselector4.SetNumSelectEvts(63000);
|
|---|
| 126 | MFEventSelector eventselector5;
|
|---|
| 127 | eventselector5.SetNumSelectEvts(150000);
|
|---|
| 128 |
|
|---|
| 129 | // ------------- user change -----------------
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 | Char_t dir[256];
|
|---|
| 133 | // sprintf (dir, "Clean_%.1f_%.1f/", clean1, clean2);
|
|---|
| 134 | TString out = dir;
|
|---|
| 135 |
|
|---|
| 136 | out += "Sgt0/star_gammas.root";
|
|---|
| 137 | MWriteRootFile write1(out);
|
|---|
| 138 | write1.SetFilter(&eventselector1);
|
|---|
| 139 | write1.AddContainer("MRawRunHeader", "RunHeaders");
|
|---|
| 140 | write1.AddContainer("MMcRunHeader", "RunHeaders");
|
|---|
| 141 | write1.AddContainer("MSrcPosCam", "RunHeaders");
|
|---|
| 142 | write1.AddContainer("MMcEvt", "Events");
|
|---|
| 143 | write1.AddContainer("MHillas", "Events");
|
|---|
| 144 | write1.AddContainer("MHillasExt", "Events");
|
|---|
| 145 | write1.AddContainer("MHillasSrc", "Events");
|
|---|
| 146 | write1.AddContainer("MNewImagePar", "Events");
|
|---|
| 147 |
|
|---|
| 148 | out = dir;
|
|---|
| 149 | out += "Sgt300/star_gammas.root";
|
|---|
| 150 | MWriteRootFile write2(out);
|
|---|
| 151 | write2.SetFilter(&eventselector2);
|
|---|
| 152 | write2.AddContainer("MRawRunHeader", "RunHeaders");
|
|---|
| 153 | write2.AddContainer("MMcRunHeader", "RunHeaders");
|
|---|
| 154 | write2.AddContainer("MSrcPosCam", "RunHeaders");
|
|---|
| 155 | write2.AddContainer("MMcEvt", "Events");
|
|---|
| 156 | write2.AddContainer("MHillas", "Events");
|
|---|
| 157 | write2.AddContainer("MHillasExt", "Events");
|
|---|
| 158 | write2.AddContainer("MHillasSrc", "Events");
|
|---|
| 159 | write2.AddContainer("MNewImagePar", "Events");
|
|---|
| 160 |
|
|---|
| 161 | // Extra !
|
|---|
| 162 | write2.AddContainer("MMcTrigHeader", "RunHeaders");
|
|---|
| 163 | write2.AddContainer("MMcCorsikaRunHeader", "RunHeaders");
|
|---|
| 164 | write2.AddContainer("MMcFadcHeader", "RunHeaders");
|
|---|
| 165 | write2.AddContainer("MMcTrig", "Events");
|
|---|
| 166 | write2.AddContainer("MRawEvtData", "Events");
|
|---|
| 167 | write2.AddContainer("MRawEvtHeader", "Events");
|
|---|
| 168 |
|
|---|
| 169 | out = dir;
|
|---|
| 170 | out += "Sgt500/star_gammas.root";
|
|---|
| 171 | MWriteRootFile write3(out);
|
|---|
| 172 | write3.SetFilter(&eventselector3);
|
|---|
| 173 | write3.AddContainer("MRawRunHeader", "RunHeaders");
|
|---|
| 174 | write3.AddContainer("MMcRunHeader", "RunHeaders");
|
|---|
| 175 | write3.AddContainer("MSrcPosCam", "RunHeaders");
|
|---|
| 176 | write3.AddContainer("MMcEvt", "Events");
|
|---|
| 177 | write3.AddContainer("MHillas", "Events");
|
|---|
| 178 | write3.AddContainer("MHillasExt", "Events");
|
|---|
| 179 | write3.AddContainer("MHillasSrc", "Events");
|
|---|
| 180 | write3.AddContainer("MNewImagePar", "Events");
|
|---|
| 181 |
|
|---|
| 182 | out = dir;
|
|---|
| 183 | out += "Sgt1000/star_gammas.root";
|
|---|
| 184 | MWriteRootFile write4(out);
|
|---|
| 185 | write4.SetFilter(&eventselector4);
|
|---|
| 186 | write4.AddContainer("MRawRunHeader", "RunHeaders");
|
|---|
| 187 | write4.AddContainer("MMcRunHeader", "RunHeaders");
|
|---|
| 188 | write4.AddContainer("MSrcPosCam", "RunHeaders");
|
|---|
| 189 | write4.AddContainer("MMcEvt", "Events");
|
|---|
| 190 | write4.AddContainer("MHillas", "Events");
|
|---|
| 191 | write4.AddContainer("MHillasExt", "Events");
|
|---|
| 192 | write4.AddContainer("MHillasSrc", "Events");
|
|---|
| 193 | write4.AddContainer("MNewImagePar", "Events");
|
|---|
| 194 |
|
|---|
| 195 | out = dir;
|
|---|
| 196 | out += "Sgt2000/star_gammas.root";
|
|---|
| 197 | MWriteRootFile write5(out);
|
|---|
| 198 | write5.SetFilter(&eventselector5);
|
|---|
| 199 | write5.AddContainer("MRawRunHeader", "RunHeaders");
|
|---|
| 200 | write5.AddContainer("MMcRunHeader", "RunHeaders");
|
|---|
| 201 | write5.AddContainer("MSrcPosCam", "RunHeaders");
|
|---|
| 202 | write5.AddContainer("MMcEvt", "Events");
|
|---|
| 203 | write5.AddContainer("MHillas", "Events");
|
|---|
| 204 | write5.AddContainer("MHillasExt", "Events");
|
|---|
| 205 | write5.AddContainer("MHillasSrc", "Events");
|
|---|
| 206 | write5.AddContainer("MNewImagePar", "Events");
|
|---|
| 207 |
|
|---|
| 208 | tlist.AddToList(&read);
|
|---|
| 209 | tlist.AddToList(&pcopy);
|
|---|
| 210 | tlist.AddToList(&pnsb);
|
|---|
| 211 | tlist.AddToList(&ncalc);
|
|---|
| 212 | tlist.AddToList(&clean);
|
|---|
| 213 | tlist.AddToList(&blind);
|
|---|
| 214 | tlist.AddToList(&hcalc);
|
|---|
| 215 | tlist.AddToList(&scalc);
|
|---|
| 216 |
|
|---|
| 217 | tlist.AddToList(&eventselector1);
|
|---|
| 218 | tlist.AddToList(&write1);
|
|---|
| 219 | tlist.AddToList(&filtersize300); //FILTER SIZE LINE
|
|---|
| 220 |
|
|---|
| 221 | tlist.AddToList(&eventselector2);
|
|---|
| 222 | tlist.AddToList(&write2);
|
|---|
| 223 | tlist.AddToList(&filtersize500); //FILTER SIZE LINE
|
|---|
| 224 |
|
|---|
| 225 | tlist.AddToList(&eventselector3);
|
|---|
| 226 | tlist.AddToList(&write3);
|
|---|
| 227 | tlist.AddToList(&filtersize1000); //FILTER SIZE LINE
|
|---|
| 228 |
|
|---|
| 229 | tlist.AddToList(&eventselector4);
|
|---|
| 230 | tlist.AddToList(&write4);
|
|---|
| 231 | tlist.AddToList(&filtersize2000); //FILTER SIZE LINE
|
|---|
| 232 |
|
|---|
| 233 | tlist.AddToList(&eventselector5);
|
|---|
| 234 | tlist.AddToList(&write5);
|
|---|
| 235 |
|
|---|
| 236 | //
|
|---|
| 237 | // Create and set up the eventloop
|
|---|
| 238 | //
|
|---|
| 239 | MProgressBar bar;
|
|---|
| 240 |
|
|---|
| 241 | MEvtLoop evtloop;
|
|---|
| 242 | evtloop.SetProgressBar(&bar);
|
|---|
| 243 | evtloop.SetParList(&plist);
|
|---|
| 244 |
|
|---|
| 245 | //
|
|---|
| 246 | // Execute your analysis
|
|---|
| 247 | //
|
|---|
| 248 | if (!evtloop.Eventloop())
|
|---|
| 249 | return;
|
|---|
| 250 |
|
|---|
| 251 | tlist.PrintStatistics();
|
|---|
| 252 | }
|
|---|