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

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