source: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc@ 1049

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