| 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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | void ProcessFile(TString fname)
|
|---|
| 26 | {
|
|---|
| 27 | //
|
|---|
| 28 | // Create a empty Parameter List and an empty Task List
|
|---|
| 29 | // The tasklist is identified in the eventloop by its name
|
|---|
| 30 | //
|
|---|
| 31 | MParList plist;
|
|---|
| 32 |
|
|---|
| 33 | MTaskList tlist;
|
|---|
| 34 | plist.AddToList(&tlist);
|
|---|
| 35 |
|
|---|
| 36 | //
|
|---|
| 37 | // Now setup the tasks and tasklist:
|
|---|
| 38 | // ---------------------------------
|
|---|
| 39 | //
|
|---|
| 40 |
|
|---|
| 41 | MGeomCamMagic geom;
|
|---|
| 42 | plist.AddToList(&geom);
|
|---|
| 43 |
|
|---|
| 44 | // First Task: Read file with image parameters
|
|---|
| 45 | // (created with the star.C macro)
|
|---|
| 46 |
|
|---|
| 47 | MReadMarsFile read("Events", fname);
|
|---|
| 48 | read.DisableAutoScheme();
|
|---|
| 49 |
|
|---|
| 50 | MPedestalSum ncalc;
|
|---|
| 51 | //MCerPhotCalc ncalc;
|
|---|
| 52 | //MCerPhotAnal ncalc;
|
|---|
| 53 | //MCerPhotAnal2 ncalc;
|
|---|
| 54 |
|
|---|
| 55 | tlist.AddToList(&read);
|
|---|
| 56 | tlist.AddToList(&ncalc);
|
|---|
| 57 |
|
|---|
| 58 | MHCamEvent hist;
|
|---|
| 59 | hist.SetType(3);
|
|---|
| 60 | plist.AddToList(&hist);
|
|---|
| 61 |
|
|---|
| 62 | MFillH fill("MHCamEvent", "MCerPhotEvt");
|
|---|
| 63 | tlist.AddToList(&fill);
|
|---|
| 64 |
|
|---|
| 65 | //
|
|---|
| 66 | // Create and setup the eventloop
|
|---|
| 67 | //
|
|---|
| 68 | MEvtLoop evtloop;
|
|---|
| 69 | evtloop.SetParList(&plist);
|
|---|
| 70 |
|
|---|
| 71 | //
|
|---|
| 72 | // Execute your analysis
|
|---|
| 73 | //
|
|---|
| 74 | if (!evtloop.Eventloop())
|
|---|
| 75 | return;
|
|---|
| 76 |
|
|---|
| 77 | tlist.PrintStatistics();
|
|---|
| 78 |
|
|---|
| 79 | TCanvas *c = MH::MakeDefCanvas();
|
|---|
| 80 | c->Divide(3, 2);
|
|---|
| 81 |
|
|---|
| 82 | MHCamEvent &h = *(MHCamEvent*)plist->FindObject("MHCamEvent");
|
|---|
| 83 | MHCamera *disp0 = h.GetHistByName();
|
|---|
| 84 | MHCamera *disp1 = new MHCamera(geom, "MCerPhotEvt;avg", "Cerenkov Photons RMS Avarage");
|
|---|
| 85 | MHCamera *disp2 = new MHCamera(geom, "MCerPhotEvt;err", "Cerenkov Photons RMS Error");
|
|---|
| 86 | MHCamera *disp3 = new MHCamera(geom, "MCerPhotEvt;rel", "Cerenkov Photons RMS ERR/VAL");
|
|---|
| 87 | disp1->SetBit(kCanDelete);
|
|---|
| 88 | disp2->SetBit(kCanDelete);
|
|---|
| 89 | disp3->SetBit(kCanDelete);
|
|---|
| 90 |
|
|---|
| 91 | disp1->SetCamContent(*disp0, 0);
|
|---|
| 92 | disp2->SetCamContent(*disp0, 1);
|
|---|
| 93 | disp3->SetCamContent(*disp0, 2);
|
|---|
| 94 |
|
|---|
| 95 | disp2->SetStats(kFALSE);
|
|---|
| 96 | disp3->SetStats(kFALSE);
|
|---|
| 97 |
|
|---|
| 98 | disp1->SetYTitle("a.u.");
|
|---|
| 99 | disp2->SetYTitle("err");
|
|---|
| 100 | disp3->SetYTitle("rel.err [%]");
|
|---|
| 101 |
|
|---|
| 102 | TText text(0.1, 0.5, &fname[fname.Last('/')+1]);
|
|---|
| 103 | text.SetTextSize(0.015);
|
|---|
| 104 | text.DrawClone();
|
|---|
| 105 |
|
|---|
| 106 | c->cd(1);
|
|---|
| 107 | disp1->Draw("hist");
|
|---|
| 108 |
|
|---|
| 109 | c->cd(2);
|
|---|
| 110 | gPad->SetLogy();
|
|---|
| 111 | disp2->Draw("hist");
|
|---|
| 112 |
|
|---|
| 113 | c->cd(3);
|
|---|
| 114 | gPad->SetLogy();
|
|---|
| 115 | disp3->Draw("hist");
|
|---|
| 116 |
|
|---|
| 117 | c->cd(4);
|
|---|
| 118 | gPad->SetBorderMode(0);
|
|---|
| 119 | gPad->Divide(1,1);
|
|---|
| 120 | gPad->cd(1);
|
|---|
| 121 | disp1->Draw();
|
|---|
| 122 |
|
|---|
| 123 | c->cd(5);
|
|---|
| 124 | gPad->SetBorderMode(0);
|
|---|
| 125 | gPad->Divide(1,1);
|
|---|
| 126 | gPad->cd(1);
|
|---|
| 127 | disp2->Draw();
|
|---|
| 128 |
|
|---|
| 129 | c->cd(6);
|
|---|
| 130 | gPad->SetBorderMode(0);
|
|---|
| 131 | gPad->Divide(1,1);
|
|---|
| 132 | gPad->cd(1);
|
|---|
| 133 | disp3->Draw();
|
|---|
| 134 |
|
|---|
| 135 | c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
|
|---|
| 136 | //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | // -------------------------------------------------------------------------
|
|---|
| 140 | //
|
|---|
| 141 | // plot.C
|
|---|
| 142 | //
|
|---|
| 143 | // This macro shows how to fill and display a histogram using Mars
|
|---|
| 144 | //
|
|---|
| 145 | void sumeventsrms(const char *dirname=".")
|
|---|
| 146 | {
|
|---|
| 147 | MDirIter Next;
|
|---|
| 148 | Next.AddDirectory(dirname, "*ped*.root", -1);
|
|---|
| 149 |
|
|---|
| 150 | TString fname;
|
|---|
| 151 | while (1)
|
|---|
| 152 | {
|
|---|
| 153 | fname = Next();
|
|---|
| 154 | if (fname.IsNull())
|
|---|
| 155 | break;
|
|---|
| 156 |
|
|---|
| 157 | ProcessFile(fname);
|
|---|
| 158 | return;
|
|---|
| 159 | }
|
|---|
| 160 | }
|
|---|