| 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/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MHCerPhotEvt
|
|---|
| 28 | //
|
|---|
| 29 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 30 | #include "MHCerPhotEvt.h"
|
|---|
| 31 |
|
|---|
| 32 | #include <TCanvas.h>
|
|---|
| 33 |
|
|---|
| 34 | #include "MLog.h"
|
|---|
| 35 | #include "MLogManip.h"
|
|---|
| 36 |
|
|---|
| 37 | #include "MParList.h"
|
|---|
| 38 | #include "MCerPhotEvt.h"
|
|---|
| 39 | #include "MCamDisplay.h"
|
|---|
| 40 |
|
|---|
| 41 | #include "MGeomCam.h"
|
|---|
| 42 | #include "MGeomPix.h"
|
|---|
| 43 |
|
|---|
| 44 | ClassImp(MHCerPhotEvt);
|
|---|
| 45 |
|
|---|
| 46 | using namespace std;
|
|---|
| 47 |
|
|---|
| 48 | // --------------------------------------------------------------------------
|
|---|
| 49 | //
|
|---|
| 50 | // Reset all pixels to 0 and reset fEntries to 0.
|
|---|
| 51 | //
|
|---|
| 52 | void MHCerPhotEvt::Clear(const Option_t *)
|
|---|
| 53 | {
|
|---|
| 54 | fSum.Reset();
|
|---|
| 55 | // fSum.InitSize(577);
|
|---|
| 56 | for (int i=0; i<577; i++)
|
|---|
| 57 | {
|
|---|
| 58 | fSum.AddPixel(i, 0, 0);
|
|---|
| 59 | fSum[i].SetPixelUnused();
|
|---|
| 60 | }
|
|---|
| 61 | fSum.FixSize();
|
|---|
| 62 | fEntries = 0;
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | // --------------------------------------------------------------------------
|
|---|
| 66 | //
|
|---|
| 67 | // Initialize the name and title of the task.
|
|---|
| 68 | // Resets the sum histogram
|
|---|
| 69 | //
|
|---|
| 70 | MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title)
|
|---|
| 71 | : fCam(NULL), fEvt(NULL), fDispl(NULL)
|
|---|
| 72 | {
|
|---|
| 73 | //
|
|---|
| 74 | // set the name and title of this object
|
|---|
| 75 | //
|
|---|
| 76 | fName = name ? name : "MHCerPhotEvt";
|
|---|
| 77 | fTitle = title ? title : "Average of MCerPhotEvts";
|
|---|
| 78 |
|
|---|
| 79 | Clear();
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | // --------------------------------------------------------------------------
|
|---|
| 83 | //
|
|---|
| 84 | // Delete the corresponding camera display if available
|
|---|
| 85 | //
|
|---|
| 86 | MHCerPhotEvt::~MHCerPhotEvt()
|
|---|
| 87 | {
|
|---|
| 88 | if (fDispl)
|
|---|
| 89 | delete fDispl;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | // --------------------------------------------------------------------------
|
|---|
| 93 | //
|
|---|
| 94 | // Get the event (MCerPhotEvt) the histogram might be filled with. If
|
|---|
| 95 | // it is not given, it is assumed, that it is filled with the argument
|
|---|
| 96 | // of the Fill function.
|
|---|
| 97 | // Looks for the camera geometry MGeomCam and resets the sum histogram.
|
|---|
| 98 | //
|
|---|
| 99 | Bool_t MHCerPhotEvt::SetupFill(const MParList *plist)
|
|---|
| 100 | {
|
|---|
| 101 | fEvt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
|
|---|
| 102 | if (!fEvt)
|
|---|
| 103 | *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl;
|
|---|
| 104 |
|
|---|
| 105 | fCam = (MGeomCam*)plist->FindObject("MGeomCam");
|
|---|
| 106 | if (!fCam)
|
|---|
| 107 | *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
|
|---|
| 108 |
|
|---|
| 109 | Clear();
|
|---|
| 110 |
|
|---|
| 111 | return kTRUE;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | // --------------------------------------------------------------------------
|
|---|
| 115 | //
|
|---|
| 116 | // Fill the histograms with data from a MCerPhotEvt-Container.
|
|---|
| 117 | //
|
|---|
| 118 | Bool_t MHCerPhotEvt::Fill(const MParContainer *par, const Stat_t w)
|
|---|
| 119 | {
|
|---|
| 120 | const MCerPhotEvt *evt = par ? (MCerPhotEvt*)par : fEvt;
|
|---|
| 121 | if (!evt)
|
|---|
| 122 | {
|
|---|
| 123 | *fLog << err << dbginf << "No MCerPhotEvt found..." << endl;
|
|---|
| 124 | return kFALSE;
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | const UInt_t n = evt->GetNumPixels();
|
|---|
| 128 |
|
|---|
| 129 | for (UInt_t idx=0; idx<n; idx++)
|
|---|
| 130 | {
|
|---|
| 131 | Float_t val;
|
|---|
| 132 | if (!evt->GetPixelContent(val, idx))
|
|---|
| 133 | continue;
|
|---|
| 134 |
|
|---|
| 135 | fSum[idx].SetPixelUsed();
|
|---|
| 136 | fSum[idx].AddNumPhotons(val);
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | fEntries++;
|
|---|
| 140 |
|
|---|
| 141 | return kTRUE;
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | // --------------------------------------------------------------------------
|
|---|
| 145 | //
|
|---|
| 146 | // Scale the sum container with the number of entries
|
|---|
| 147 | //
|
|---|
| 148 | Bool_t MHCerPhotEvt::Finalize()
|
|---|
| 149 | {
|
|---|
| 150 | if (fEntries<1)
|
|---|
| 151 | *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain entries." << endl;
|
|---|
| 152 | else
|
|---|
| 153 | fSum.Scale(fEntries);
|
|---|
| 154 | return kTRUE;
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | // --------------------------------------------------------------------------
|
|---|
| 158 | //
|
|---|
| 159 | // Draw the present 'fill status'
|
|---|
| 160 | //
|
|---|
| 161 | void MHCerPhotEvt::Draw(Option_t *)
|
|---|
| 162 | {
|
|---|
| 163 | if (!fCam)
|
|---|
| 164 | {
|
|---|
| 165 | *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl;
|
|---|
| 166 | return;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600);
|
|---|
| 170 | pad->SetBorderMode(0);
|
|---|
| 171 |
|
|---|
| 172 | AppendPad("");
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | // --------------------------------------------------------------------------
|
|---|
| 176 | //
|
|---|
| 177 | // If a camera display is not yet assigned, assign a new one.
|
|---|
| 178 | //
|
|---|
| 179 | void MHCerPhotEvt::Paint(Option_t *option)
|
|---|
| 180 | {
|
|---|
| 181 | if (!fCam)
|
|---|
| 182 | {
|
|---|
| 183 | *fLog << warn << "WARNING - Cannot paint " << GetDescriptor() << ": No Camera Geometry available." << endl;
|
|---|
| 184 | return;
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | if (!fDispl)
|
|---|
| 188 | fDispl = new MCamDisplay(fCam);
|
|---|
| 189 |
|
|---|
| 190 | fDispl->Fill(fSum);
|
|---|
| 191 | fDispl->Paint();
|
|---|
| 192 | }
|
|---|