| 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MRflEvtData
|
|---|
| 28 | //
|
|---|
| 29 | // All Photons of a event from the reflector program
|
|---|
| 30 | //
|
|---|
| 31 | // Should be filled like this:
|
|---|
| 32 | // MRflEvtData evt;
|
|---|
| 33 | // evt.Reset();
|
|---|
| 34 | // for (int i=0; i<10; i++)
|
|---|
| 35 | // MRflSinglePhoton &ph = evt.GetNewPhoton();
|
|---|
| 36 | // evt.FixSize();
|
|---|
| 37 | //
|
|---|
| 38 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 39 | #include "MRflEvtData.h"
|
|---|
| 40 |
|
|---|
| 41 | #include <TMarker.h>
|
|---|
| 42 |
|
|---|
| 43 | #include "MLog.h"
|
|---|
| 44 | #include "MLogManip.h"
|
|---|
| 45 |
|
|---|
| 46 | #include "MHexagon.h"
|
|---|
| 47 | #include "MGeomCam.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MRflSinglePhoton.h"
|
|---|
| 50 |
|
|---|
| 51 | ClassImp(MRflEvtData);
|
|---|
| 52 |
|
|---|
| 53 | using namespace std;
|
|---|
| 54 |
|
|---|
| 55 | // --------------------------------------------------------------------------
|
|---|
| 56 | //
|
|---|
| 57 | // Creates a MCerPhotPix object for each pixel in the event
|
|---|
| 58 | //
|
|---|
| 59 | MRflEvtData::MRflEvtData(const char *name, const char *title)
|
|---|
| 60 | : fList("MRflSinglePhoton", 0), fPos(0)
|
|---|
| 61 | {
|
|---|
| 62 | fName = name ? name : "MRflEvtData";
|
|---|
| 63 | fTitle = title ? title : "All Photons from a reflector event";
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | const MRflSinglePhoton &MRflEvtData::GetPhoton(Int_t i) const
|
|---|
| 67 | {
|
|---|
| 68 | return *static_cast<MRflSinglePhoton*>(fList.UncheckedAt(i));
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | // --------------------------------------------------------------------------
|
|---|
| 72 | //
|
|---|
| 73 | // Dump informations off all photons
|
|---|
| 74 | //
|
|---|
| 75 | void MRflEvtData::Print(Option_t *o) const
|
|---|
| 76 | {
|
|---|
| 77 | *fLog << all << underline << GetDescriptor() << ":" << endl;
|
|---|
| 78 | fList.Print();
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | // --------------------------------------------------------------------------
|
|---|
| 82 | //
|
|---|
| 83 | // Add a new photon to the list
|
|---|
| 84 | //
|
|---|
| 85 | MRflSinglePhoton &MRflEvtData::GetNewPhoton()
|
|---|
| 86 | {
|
|---|
| 87 | // If necessary the []-operator creates a new element
|
|---|
| 88 | // Warning: The virtual table may not be set correctly,
|
|---|
| 89 | // this is why you have to call the new-operator.
|
|---|
| 90 | return *new (fList[fPos++]) MRflSinglePhoton;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | // --------------------------------------------------------------------------
|
|---|
| 94 | //
|
|---|
| 95 | // If you have added all photon fix the size of the container.
|
|---|
| 96 | //
|
|---|
| 97 | void MRflEvtData::FixSize()
|
|---|
| 98 | {
|
|---|
| 99 | if (fList.GetEntriesFast() == fPos)
|
|---|
| 100 | return;
|
|---|
| 101 |
|
|---|
| 102 | fList.ExpandCreate(fPos);
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | void MRflEvtData::DrawPixelContent(Int_t num) const
|
|---|
| 106 | {
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | // ------------------------------------------------------------------------
|
|---|
| 110 | //
|
|---|
| 111 | // Fill a reflector event. Sums all pixels in each pixel as the
|
|---|
| 112 | // pixel contents.
|
|---|
| 113 | //
|
|---|
| 114 | // WARNING: Due to the estimation in DistanceToPrimitive and the
|
|---|
| 115 | // calculation in pixels instead of x, y this is only a
|
|---|
| 116 | // rough estimate.
|
|---|
| 117 | //
|
|---|
| 118 | Bool_t MRflEvtData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 119 | {
|
|---|
| 120 | //
|
|---|
| 121 | // sum the photons content in each pixel
|
|---|
| 122 | //
|
|---|
| 123 | val = 0;
|
|---|
| 124 |
|
|---|
| 125 | MHexagon hex(cam[idx]);
|
|---|
| 126 |
|
|---|
| 127 | MRflSinglePhoton *ph=NULL;
|
|---|
| 128 |
|
|---|
| 129 | TIter Next(&fList);
|
|---|
| 130 | while ((ph=(MRflSinglePhoton*)Next()))
|
|---|
| 131 | if (hex.DistanceToPrimitive(ph->GetX(), ph->GetY())<=0)
|
|---|
| 132 | val += cam.GetPixRatio(idx);
|
|---|
| 133 |
|
|---|
| 134 | return val>0;
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | // ------------------------------------------------------------------------
|
|---|
| 138 | //
|
|---|
| 139 | // You can call Draw() to add the photons to the current pad.
|
|---|
| 140 | // The photons are painted each tim ethe pad is updated.
|
|---|
| 141 | // Make sure that you use the right (world) coordinate system,
|
|---|
| 142 | // like created, eg. by the MHCamera histogram.
|
|---|
| 143 | //
|
|---|
| 144 | void MRflEvtData::Paint(Option_t *)
|
|---|
| 145 | {
|
|---|
| 146 | MRflSinglePhoton *ph=NULL;
|
|---|
| 147 |
|
|---|
| 148 | TMarker m;
|
|---|
| 149 | m.SetMarkerStyle(kFullDotMedium); // Gtypes.h
|
|---|
| 150 |
|
|---|
| 151 | TIter Next(&fList);
|
|---|
| 152 | while ((ph=(MRflSinglePhoton*)Next()))
|
|---|
| 153 | {
|
|---|
| 154 | m.SetX(ph->GetX());
|
|---|
| 155 | m.SetY(ph->GetY());
|
|---|
| 156 | m.Paint();
|
|---|
| 157 | }
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|