source: branches/Mars_McMismatchStudy/mreflector/MRflEvtData.cc@ 18242

Last change on this file since 18242 was 9391, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 6.5 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 "MGeomCam.h"
47#include "MGeomPix.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 scaled with scale (default=1) into a TH1
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 photon distances scaled with scale (default=1) versus x
150// into a TH2
151//
152void MRflEvtData::FillRad(TH2 &hist, Double_t x, Float_t scale) const
153{
154 MRflSinglePhoton *ph=NULL;
155
156 TIter Next(&fList);
157 while ((ph=(MRflSinglePhoton*)Next()))
158 ph->FillRad(hist, x, scale);
159}
160
161// --------------------------------------------------------------------------
162//
163// Fills all photons (x,y) scaled with scale (default=1) into a TH2.
164//
165void MRflEvtData::Fill(TH2 &hist, Float_t scale) const
166{
167 MRflSinglePhoton *ph=NULL;
168
169 TIter Next(&fList);
170 while ((ph=(MRflSinglePhoton*)Next()))
171 ph->Fill(hist, scale);
172}
173
174// --------------------------------------------------------------------------
175//
176// Fills all photons (x,y) scaled with scale (default=1) versus z into a TH3
177//
178void MRflEvtData::Fill(TH3 &hist, Double_t z, Float_t scale) const
179{
180 MRflSinglePhoton *ph=NULL;
181
182 TIter Next(&fList);
183 while ((ph=(MRflSinglePhoton*)Next()))
184 ph->Fill(hist, z, scale);
185}
186
187void MRflEvtData::DrawPixelContent(Int_t num) const
188{
189}
190
191// ------------------------------------------------------------------------
192//
193// Fill a reflector event. Sums all pixels in each pixel as the
194// pixel contents.
195//
196// WARNING: Due to the estimation in DistanceToPrimitive and the
197// calculation in pixels instead of x, y this is only a
198// rough estimate.
199//
200Bool_t MRflEvtData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
201{
202 //
203 // sum the photons content in each pixel
204 //
205 val = 0;
206
207 MRflSinglePhoton *ph=NULL;
208
209 TIter Next(&fList);
210 while ((ph=(MRflSinglePhoton*)Next()))
211 if (cam[idx].IsInside(ph->GetX(), ph->GetY()))
212 val += cam.GetPixRatio(idx);
213
214 return val>0;
215}
216
217// ------------------------------------------------------------------------
218//
219// You can call Draw() to add the photons to the current pad.
220// The photons are painted each tim ethe pad is updated.
221// Make sure that you use the right (world) coordinate system,
222// like created, eg. by the MHCamera histogram.
223//
224void MRflEvtData::Paint(Option_t *)
225{
226 MRflSinglePhoton *ph=NULL;
227
228 TMarker m;
229 m.SetMarkerStyle(kFullDotMedium); // Gtypes.h
230
231 TIter Next(&fList);
232 while ((ph=(MRflSinglePhoton*)Next()))
233 {
234 m.SetX(ph->GetX());
235 m.SetY(ph->GetY());
236 m.Paint();
237 }
238}
239
Note: See TracBrowser for help on using the repository browser.