| 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, Int_t idx) | 
|---|
| 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 | // First Task: Read file with image parameters | 
|---|
| 42 | // (created with the star.C macro) | 
|---|
| 43 |  | 
|---|
| 44 | MReadMarsFile read("Events", fname); | 
|---|
| 45 | read.DisableAutoScheme(); | 
|---|
| 46 |  | 
|---|
| 47 | MGeomApply geomapl; | 
|---|
| 48 |  | 
|---|
| 49 | MCerPhotAnal2 ncalc; | 
|---|
| 50 |  | 
|---|
| 51 | tlist.AddToList(&read); | 
|---|
| 52 | tlist.AddToList(&geomapl); | 
|---|
| 53 | tlist.AddToList(&ncalc); | 
|---|
| 54 |  | 
|---|
| 55 | MHPixVsTime hist1(idx, "Pedestal"); | 
|---|
| 56 | MHPixVsTime hist2(idx, "PedestalRMS"); | 
|---|
| 57 | hist2.SetType(1); | 
|---|
| 58 | plist.AddToList(&hist1); | 
|---|
| 59 | plist.AddToList(&hist2); | 
|---|
| 60 |  | 
|---|
| 61 | MFillH fill1("Pedestal",    "MPedestalCam"); | 
|---|
| 62 | MFillH fill2("PedestalRMS", "MPedestalCam"); | 
|---|
| 63 | tlist.AddToList(&fill1); | 
|---|
| 64 | tlist.AddToList(&fill2); | 
|---|
| 65 |  | 
|---|
| 66 | // | 
|---|
| 67 | // Create and setup the eventloop | 
|---|
| 68 | // | 
|---|
| 69 | MEvtLoop evtloop; | 
|---|
| 70 | evtloop.SetParList(&plist); | 
|---|
| 71 |  | 
|---|
| 72 | // | 
|---|
| 73 | // Execute your analysis | 
|---|
| 74 | // | 
|---|
| 75 | if (!evtloop.Eventloop()) | 
|---|
| 76 | return; | 
|---|
| 77 |  | 
|---|
| 78 | tlist.PrintStatistics(); | 
|---|
| 79 |  | 
|---|
| 80 | TCanvas *c = MH::MakeDefCanvas(); | 
|---|
| 81 | c->Divide(2,2); | 
|---|
| 82 |  | 
|---|
| 83 | c->cd(1); | 
|---|
| 84 | TGraph &g1 = hist1.GetGraph(); | 
|---|
| 85 | TH1 *h1 = g1.GetHistogram(); | 
|---|
| 86 | h1->SetXTitle("Time [au]"); | 
|---|
| 87 | h1->SetYTitle("P [au]"); | 
|---|
| 88 | g1.DrawClone("A*"); | 
|---|
| 89 |  | 
|---|
| 90 | c->cd(2); | 
|---|
| 91 | TH1F h1f("Pedestal", "Pedestals", 21, 46, 56); | 
|---|
| 92 | h1f.SetXTitle("P"); | 
|---|
| 93 | h1f.SetYTitle("Counts"); | 
|---|
| 94 | for (int i=0;i<g1.GetN(); i++) | 
|---|
| 95 | h1f.Fill(g1.GetY()[i]); | 
|---|
| 96 | ((TH1F*)h1f.DrawCopy())->Fit("gaus"); | 
|---|
| 97 |  | 
|---|
| 98 | c->cd(3); | 
|---|
| 99 | TGraph &g2 = hist2.GetGraph(); | 
|---|
| 100 | TH1 *h2 = g2.GetHistogram(); | 
|---|
| 101 | h2->SetXTitle("Time [au]"); | 
|---|
| 102 | h2->SetYTitle("P_{rms} [au]"); | 
|---|
| 103 | g2.DrawClone("A*"); | 
|---|
| 104 |  | 
|---|
| 105 | c->cd(4); | 
|---|
| 106 | TH1F h2f("PedestalRMS", "Pedestals RMS", 26, 0, 3.5); | 
|---|
| 107 | h2f.SetXTitle("P_{rms}"); | 
|---|
| 108 | h2f.SetYTitle("Counts"); | 
|---|
| 109 | for (int i=0;i<g2.GetN(); i++) | 
|---|
| 110 | h2f.Fill(g2.GetY()[i]); | 
|---|
| 111 | ((TH1F*)h2f.DrawCopy())->Fit("gaus"); | 
|---|
| 112 |  | 
|---|
| 113 | c->SaveAs(fname(0, fname.Last('.')+1) + "ps"); | 
|---|
| 114 | //c->SaveAs(fname(0, fname.Last('.')+1) + "root"); | 
|---|
| 115 | } | 
|---|
| 116 |  | 
|---|
| 117 | // ------------------------------------------------------------------------- | 
|---|
| 118 | // | 
|---|
| 119 | //  plot.C | 
|---|
| 120 | // | 
|---|
| 121 | //  This macro shows how to fill and display a histogram using Mars | 
|---|
| 122 | // | 
|---|
| 123 | void pedestalvstime(Int_t idx=0, const char *dirname=".") | 
|---|
| 124 | { | 
|---|
| 125 | MDirIter Next; | 
|---|
| 126 | Next.AddDirectory(dirname, "raw*.root", -1); | 
|---|
| 127 |  | 
|---|
| 128 | TString fname; | 
|---|
| 129 | while (1) | 
|---|
| 130 | { | 
|---|
| 131 | fname = Next(); | 
|---|
| 132 | if (fname.IsNull()) | 
|---|
| 133 | break; | 
|---|
| 134 |  | 
|---|
| 135 | ProcessFile(fname, idx); | 
|---|
| 136 | return; | 
|---|
| 137 | } | 
|---|
| 138 | } | 
|---|