source: tags/Mars-V0.5/manalysis/MCerPhotEvt.cc

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