source: trunk/MagicSoft/Mars/mreflector/MRflEvtData.cc@ 8270

Last change on this file since 8270 was 8270, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 5.8 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): 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
51ClassImp(MRflEvtData);
52
53using namespace std;
54
55// --------------------------------------------------------------------------
56//
57// Creates a MCerPhotPix object for each pixel in the event
58//
59MRflEvtData::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// --------------------------------------------------------------------------
67//
68// Copy constructor which copies the contents of dat into the new object
69//
70MRflEvtData::MRflEvtData(const MRflEvtData &dat)
71 : fList("MRflSinglePhoton", 0), fPos(0)
72{
73 MRflSinglePhoton *ph=NULL;
74
75 TIter Next(&dat.fList);
76 while ((ph=(MRflSinglePhoton*)Next()))
77 new (fList[fPos++]) MRflSinglePhoton(*ph);
78}
79
80// --------------------------------------------------------------------------
81//
82// Clone function producing a clone of this. A pointer to the clone is
83// returned.
84//
85TObject *MRflEvtData::Clone(Option_t *) const
86{
87 return new MRflEvtData(*this);
88}
89
90// --------------------------------------------------------------------------
91//
92// Return the i-th MRflSinglePhoton. Be carefull the result is not
93// range checked!
94//
95const MRflSinglePhoton &MRflEvtData::GetPhoton(Int_t i) const
96{
97 return *static_cast<MRflSinglePhoton*>(fList.UncheckedAt(i));
98}
99
100// --------------------------------------------------------------------------
101//
102// Dump informations off all photons
103//
104void MRflEvtData::Print(Option_t *o) const
105{
106 *fLog << all << underline << GetDescriptor() << ":" << endl;
107 fList.Print();
108}
109
110// --------------------------------------------------------------------------
111//
112// Add a new photon to the list
113//
114MRflSinglePhoton &MRflEvtData::GetNewPhoton()
115{
116 // If necessary the []-operator creates a new element
117 // Warning: The virtual table may not be set correctly,
118 // this is why you have to call the new-operator.
119 return *new (fList[fPos++]) MRflSinglePhoton;
120}
121
122// --------------------------------------------------------------------------
123//
124// If you have added all photon fix the size of the container.
125//
126void MRflEvtData::FixSize()
127{
128 if (fList.GetEntriesFast() == fPos)
129 return;
130
131 fList.ExpandCreate(fPos);
132}
133
134// --------------------------------------------------------------------------
135//
136// Fills all photon distances into a TH1 scaled with scale (default=1)
137//
138void MRflEvtData::FillRad(TH1 &hist, Float_t scale) const
139{
140 MRflSinglePhoton *ph=NULL;
141
142 TIter Next(&fList);
143 while ((ph=(MRflSinglePhoton*)Next()))
144 ph->FillRad(hist, scale);
145}
146
147// --------------------------------------------------------------------------
148//
149// Fills all photons into a TH2 scaled with scale (default=1)
150//
151void MRflEvtData::Fill(TH2 &hist, Float_t scale) const
152{
153 MRflSinglePhoton *ph=NULL;
154
155 TIter Next(&fList);
156 while ((ph=(MRflSinglePhoton*)Next()))
157 ph->Fill(hist, scale);
158}
159
160void MRflEvtData::DrawPixelContent(Int_t num) const
161{
162}
163
164// ------------------------------------------------------------------------
165//
166// Fill a reflector event. Sums all pixels in each pixel as the
167// pixel contents.
168//
169// WARNING: Due to the estimation in DistanceToPrimitive and the
170// calculation in pixels instead of x, y this is only a
171// rough estimate.
172//
173Bool_t MRflEvtData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
174{
175 //
176 // sum the photons content in each pixel
177 //
178 val = 0;
179
180 MHexagon hex(cam[idx]);
181
182 MRflSinglePhoton *ph=NULL;
183
184 TIter Next(&fList);
185 while ((ph=(MRflSinglePhoton*)Next()))
186 if (hex.DistanceToPrimitive(ph->GetX(), ph->GetY())<=0)
187 val += cam.GetPixRatio(idx);
188
189 return val>0;
190}
191
192// ------------------------------------------------------------------------
193//
194// You can call Draw() to add the photons to the current pad.
195// The photons are painted each tim ethe pad is updated.
196// Make sure that you use the right (world) coordinate system,
197// like created, eg. by the MHCamera histogram.
198//
199void MRflEvtData::Paint(Option_t *)
200{
201 MRflSinglePhoton *ph=NULL;
202
203 TMarker m;
204 m.SetMarkerStyle(kFullDotMedium); // Gtypes.h
205
206 TIter Next(&fList);
207 while ((ph=(MRflSinglePhoton*)Next()))
208 {
209 m.SetX(ph->GetX());
210 m.SetY(ph->GetY());
211 m.Paint();
212 }
213}
214
Note: See TracBrowser for help on using the repository browser.