| 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/2000 <mailto:tbretz@uni-sw.gwdg.de>
|
|---|
| 19 | ! Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | #include "MCerPhotEvt.h"
|
|---|
| 27 |
|
|---|
| 28 | #include <math.h>
|
|---|
| 29 | #include <fstream.h>
|
|---|
| 30 |
|
|---|
| 31 | #include <TCanvas.h>
|
|---|
| 32 |
|
|---|
| 33 | #include "MLog.h"
|
|---|
| 34 |
|
|---|
| 35 | #include "MGeomCam.h"
|
|---|
| 36 | #include "MGeomPix.h"
|
|---|
| 37 |
|
|---|
| 38 | #include "MHexagon.h"
|
|---|
| 39 |
|
|---|
| 40 | ClassImp(MCerPhotEvt);
|
|---|
| 41 |
|
|---|
| 42 | // --------------------------------------------------------------------------
|
|---|
| 43 | //
|
|---|
| 44 | // Creates a MCerPhotPix object for each pixel in the event
|
|---|
| 45 | //
|
|---|
| 46 | MCerPhotEvt::MCerPhotEvt(const char *name, const char *title) : fNumPixels(0)
|
|---|
| 47 | {
|
|---|
| 48 | fName = name ? name : "MCerPhotEvt";
|
|---|
| 49 | fTitle = title ? title : "(Number of Photon)-Event Information";
|
|---|
| 50 |
|
|---|
| 51 | fPixels = new TClonesArray("MCerPhotPix", 0);
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | // --------------------------------------------------------------------------
|
|---|
| 55 | //
|
|---|
| 56 | // This is not yet implemented like it should.
|
|---|
| 57 | //
|
|---|
| 58 | void MCerPhotEvt::Draw(Option_t* option)
|
|---|
| 59 | {
|
|---|
| 60 | //
|
|---|
| 61 | // FIXME!!! Here the Draw function of the CamDisplay
|
|---|
| 62 | // should be called to add the CamDisplay to the Pad.
|
|---|
| 63 | // The drawing should be done in MCamDisplay::Paint
|
|---|
| 64 | //
|
|---|
| 65 |
|
|---|
| 66 | // MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
|
|---|
| 67 | // MCamDisplay *disp = new MCamDisplay(geom);
|
|---|
| 68 | // delete geom;
|
|---|
| 69 | // disp->DrawPhotNum(this);
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | // --------------------------------------------------------------------------
|
|---|
| 73 | //
|
|---|
| 74 | // reset counter and delete netries in list.
|
|---|
| 75 | //
|
|---|
| 76 | void MCerPhotEvt::Reset()
|
|---|
| 77 | {
|
|---|
| 78 | fNumPixels = 0;
|
|---|
| 79 | fPixels->Delete();
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | // --------------------------------------------------------------------------
|
|---|
| 83 | //
|
|---|
| 84 | // Dump the cerenkov photon event to *fLog
|
|---|
| 85 | //
|
|---|
| 86 | void MCerPhotEvt::Print(Option_t *) const
|
|---|
| 87 | {
|
|---|
| 88 | const Int_t entries = fPixels->GetEntries();
|
|---|
| 89 |
|
|---|
| 90 | *fLog << GetDescriptor() << dec << endl;
|
|---|
| 91 | *fLog << " Number of Pixels: " << fNumPixels << "(" << entries << ")" << endl;
|
|---|
| 92 |
|
|---|
| 93 | for (Int_t i=0; i<entries; i++ )
|
|---|
| 94 | (*this)[i].Print();
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | // --------------------------------------------------------------------------
|
|---|
| 98 | //
|
|---|
| 99 | // Checks if in the pixel list is an entry with pixel id
|
|---|
| 100 | //
|
|---|
| 101 | Bool_t MCerPhotEvt::IsPixelExisting(Int_t id) const
|
|---|
| 102 | {
|
|---|
| 103 | const Int_t entries = fPixels->GetEntries();
|
|---|
| 104 |
|
|---|
| 105 | for (Int_t i=0; i<entries; i++)
|
|---|
| 106 | {
|
|---|
| 107 | if (id == (*this)[i].GetPixId())
|
|---|
| 108 | return kTRUE;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | return kFALSE;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | // --------------------------------------------------------------------------
|
|---|
| 115 | //
|
|---|
| 116 | // Checks if in the pixel list is an entry with pixel id
|
|---|
| 117 | //
|
|---|
| 118 | Bool_t MCerPhotEvt::IsPixelUsed(Int_t id) const
|
|---|
| 119 | {
|
|---|
| 120 | const Int_t entries = fPixels->GetEntries();
|
|---|
| 121 |
|
|---|
| 122 | for (Int_t i=0; i<entries; i++)
|
|---|
| 123 | {
|
|---|
| 124 | const MCerPhotPix &pix = (*this)[i];
|
|---|
| 125 |
|
|---|
| 126 | if (id == pix.GetPixId() && pix.IsPixelUsed())
|
|---|
| 127 | return kTRUE;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | return kFALSE;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | // --------------------------------------------------------------------------
|
|---|
| 134 | //
|
|---|
| 135 | // Checks if in the pixel list is an entry with pixel id
|
|---|
| 136 | //
|
|---|
| 137 | Bool_t MCerPhotEvt::IsPixelCore(Int_t id) const
|
|---|
| 138 | {
|
|---|
| 139 | const Int_t entries = fPixels->GetEntries();
|
|---|
| 140 |
|
|---|
| 141 | for (Int_t i=0; i<entries; i++)
|
|---|
| 142 | {
|
|---|
| 143 | const MCerPhotPix &pix = (*this)[i];
|
|---|
| 144 |
|
|---|
| 145 | if (id == pix.GetPixId() && pix.IsPixelCore())
|
|---|
| 146 | return kTRUE;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | return kFALSE;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | // --------------------------------------------------------------------------
|
|---|
| 153 | //
|
|---|
| 154 | // get the minimum number of photons of all valid pixels in the list
|
|---|
| 155 | // If you specify a geometry the number of photons is weighted with the
|
|---|
| 156 | // area of the pixel
|
|---|
| 157 | //
|
|---|
| 158 | Float_t MCerPhotEvt::GetNumPhotonsMin(const MGeomCam *geom) const
|
|---|
| 159 | {
|
|---|
| 160 | if (fNumPixels <= 0)
|
|---|
| 161 | return -5.;
|
|---|
| 162 |
|
|---|
| 163 | const Float_t A0 = geom ? (*geom)[0].GetA() : 0;
|
|---|
| 164 |
|
|---|
| 165 | Float_t minval = (*this)[0].GetNumPhotons();
|
|---|
| 166 |
|
|---|
| 167 | for (UInt_t i=1; i<fNumPixels; i++)
|
|---|
| 168 | {
|
|---|
| 169 | const MCerPhotPix &pix = (*this)[i];
|
|---|
| 170 |
|
|---|
| 171 | Float_t testval = pix.GetNumPhotons();
|
|---|
| 172 |
|
|---|
| 173 | if (geom)
|
|---|
| 174 | testval *= A0/(*geom)[pix.GetPixId()].GetA();
|
|---|
| 175 |
|
|---|
| 176 | if (testval < minval)
|
|---|
| 177 | minval = testval;
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | return minval;
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | // --------------------------------------------------------------------------
|
|---|
| 184 | //
|
|---|
| 185 | // get the maximum number of photons of all valid pixels in the list
|
|---|
| 186 | // If you specify a geometry the number of photons is weighted with the
|
|---|
| 187 | // area of the pixel
|
|---|
| 188 | //
|
|---|
| 189 | Float_t MCerPhotEvt::GetNumPhotonsMax(const MGeomCam *geom) const
|
|---|
| 190 | {
|
|---|
| 191 | if (fNumPixels <= 0)
|
|---|
| 192 | return 50.;
|
|---|
| 193 |
|
|---|
| 194 | const Float_t A0 = geom ? (*geom)[0].GetA() : 0;
|
|---|
| 195 | Float_t maxval = (*this)[0].GetNumPhotons();
|
|---|
| 196 |
|
|---|
| 197 | for (UInt_t i=1; i<fNumPixels; i++)
|
|---|
| 198 | {
|
|---|
| 199 | const MCerPhotPix &pix = (*this)[i];
|
|---|
| 200 |
|
|---|
| 201 | Float_t testval = pix.GetNumPhotons();
|
|---|
| 202 |
|
|---|
| 203 | if (geom)
|
|---|
| 204 | testval *= A0/(*geom)[pix.GetPixId()].GetA();
|
|---|
| 205 |
|
|---|
| 206 | if (testval > maxval)
|
|---|
| 207 | maxval = testval;
|
|---|
| 208 | }
|
|---|
| 209 | return maxval;
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|