| 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 | // --------------------------------------------------------------------------
|
|---|
| 47 | //
|
|---|
| 48 | // Reset all pixels to 0 and reset fEntries to 0.
|
|---|
| 49 | //
|
|---|
| 50 | void MHCerPhotEvt::Clear()
|
|---|
| 51 | {
|
|---|
| 52 | fSum.Reset();
|
|---|
| 53 | fSum.InitSize(577);
|
|---|
| 54 | for (int i=0; i<577; i++)
|
|---|
| 55 | {
|
|---|
| 56 | fSum.AddPixel(i, 0, 0);
|
|---|
| 57 | fSum[i].SetPixelUnused();
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | fEntries = 0;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | // --------------------------------------------------------------------------
|
|---|
| 64 | //
|
|---|
| 65 | // Setup four histograms for Width, Length
|
|---|
| 66 | //
|
|---|
| 67 | MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title)
|
|---|
| 68 | : fEvt(NULL), fCam(NULL), fDispl(NULL)
|
|---|
| 69 | {
|
|---|
| 70 | //
|
|---|
| 71 | // set the name and title of this object
|
|---|
| 72 | //
|
|---|
| 73 | fName = name ? name : "MHCerPhotEvt";
|
|---|
| 74 | fTitle = title ? title : "Average of MCerPhotEvts";
|
|---|
| 75 |
|
|---|
| 76 | Clear();
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | MHCerPhotEvt::~MHCerPhotEvt()
|
|---|
| 80 | {
|
|---|
| 81 | if (fDispl)
|
|---|
| 82 | delete fDispl;
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | // --------------------------------------------------------------------------
|
|---|
| 86 | //
|
|---|
| 87 | // Setup the Binning for the histograms automatically if the correct
|
|---|
| 88 | // instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
|
|---|
| 89 | // are found in the parameter list
|
|---|
| 90 | // Use this function if you want to set the conversion factor which
|
|---|
| 91 | // is used to convert the mm-scale in the camera plain into the deg-scale
|
|---|
| 92 | // used for histogram presentations. The conversion factor is part of
|
|---|
| 93 | // the camera geometry. Please create a corresponding MGeomCam container.
|
|---|
| 94 | //
|
|---|
| 95 | Bool_t MHCerPhotEvt::SetupFill(const MParList *plist)
|
|---|
| 96 | {
|
|---|
| 97 | fEvt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
|
|---|
| 98 | if (!fEvt)
|
|---|
| 99 | *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl;
|
|---|
| 100 |
|
|---|
| 101 | fCam = (MGeomCam*)plist->FindObject("MGeomCam");
|
|---|
| 102 | if (!fCam)
|
|---|
| 103 | *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
|
|---|
| 104 |
|
|---|
| 105 | Clear();
|
|---|
| 106 |
|
|---|
| 107 | return kTRUE;
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | // --------------------------------------------------------------------------
|
|---|
| 111 | //
|
|---|
| 112 | // Fill the histograms with data from a MHillas-Container.
|
|---|
| 113 | // Be careful: Only call this with an object of type MHillas
|
|---|
| 114 | //
|
|---|
| 115 | Bool_t MHCerPhotEvt::Fill(const MParContainer *par)
|
|---|
| 116 | {
|
|---|
| 117 | const MCerPhotEvt *evt = par ? (MCerPhotEvt*)par : fEvt;
|
|---|
| 118 | if (!evt)
|
|---|
| 119 | {
|
|---|
| 120 | *fLog << err << dbginf << "No MCerPhotEvt found..." << endl;
|
|---|
| 121 | return kFALSE;
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | const UInt_t n = evt->GetNumPixels();
|
|---|
| 125 |
|
|---|
| 126 | for (UInt_t i=0; i<n; i++)
|
|---|
| 127 | {
|
|---|
| 128 | const MCerPhotPix &pix = (*evt)[i];
|
|---|
| 129 |
|
|---|
| 130 | const Int_t id = pix.GetPixId();
|
|---|
| 131 |
|
|---|
| 132 | const Double_t ratio = fCam ? fCam->GetPixRatio(id) : 1;
|
|---|
| 133 |
|
|---|
| 134 | const Double_t val = pix.GetNumPhotons()/ratio;
|
|---|
| 135 |
|
|---|
| 136 | fSum[id].SetPixelUsed();
|
|---|
| 137 | fSum[id].AddNumPhotons(val);
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | fEntries++;
|
|---|
| 141 |
|
|---|
| 142 | return kTRUE;
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | Bool_t MHCerPhotEvt::Finalize()
|
|---|
| 146 | {
|
|---|
| 147 | fSum.Scale(fEntries);
|
|---|
| 148 | return kTRUE;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | TObject *MHCerPhotEvt::DrawClone(Option_t *opt) const
|
|---|
| 152 | {
|
|---|
| 153 | return MH::DrawClone(opt, 750, 600);
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | void MHCerPhotEvt::Draw(Option_t *)
|
|---|
| 157 | {
|
|---|
| 158 | if (!fCam)
|
|---|
| 159 | {
|
|---|
| 160 | *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl;
|
|---|
| 161 | return;
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600);
|
|---|
| 165 | pad->SetBorderMode(0);
|
|---|
| 166 |
|
|---|
| 167 | AppendPad("");
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | void MHCerPhotEvt::Paint(Option_t *option="")
|
|---|
| 171 | {
|
|---|
| 172 | if (!fCam)
|
|---|
| 173 | {
|
|---|
| 174 | *fLog << warn << "WARNING - Cannot paint " << GetDescriptor() << ": No Camera Geometry available." << endl;
|
|---|
| 175 | return;
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | if (!fDispl)
|
|---|
| 179 | fDispl = new MCamDisplay(fCam);
|
|---|
| 180 |
|
|---|
| 181 | fDispl->FillPhotNum(fSum);
|
|---|
| 182 | fDispl->Paint();
|
|---|
| 183 | }
|
|---|