source: trunk/Mars/mhist/MHFadcCam.cc@ 13440

Last change on this file since 13440 was 2377, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.1 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 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
19! Author(s): Harald Kornmayer 1/2001
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26///////////////////////////////////////////////////////////////////////
27//
28// MHFadcCam
29//
30// This class contains a list of MHFadcPix.
31//
32///////////////////////////////////////////////////////////////////////
33
34#include "MHFadcCam.h"
35
36#include "MLog.h"
37#include "MLogManip.h"
38
39#include "MParList.h"
40#include "MGeomCam.h"
41
42#include "MRawEvtData.h"
43#include "MRawEvtPixelIter.h"
44
45ClassImp(MHFadcCam);
46
47using namespace std;
48
49// --------------------------------------------------------------------------
50//
51// default constructor
52// creates an a list of histograms for all pixels and both gain channels
53//
54MHFadcCam::MHFadcCam(/*const Int_t n,*/ MHFadcPix::Type_t t, const char *name, const char *title)
55 : fNumHiGains(-1), fNumLoGains(-1), fType(t)
56{
57 //
58 // set the name and title of this object
59 //
60 fName = name ? name : "MHFadcCam";
61 fTitle = title ? title : "Container for ADC spectra histograms";
62
63 //
64 // loop over all Pixels and create two histograms
65 // one for the Low and one for the High gain
66 // connect all the histogram with the container fHist
67 //
68 fArray = new TObjArray;
69 fArray->SetOwner();
70
71 // for (Int_t i=0; i<n; i++)
72 // (*fArray)[i] = new MHFadcPix(i, fType);
73}
74
75// --------------------------------------------------------------------------
76MHFadcCam::~MHFadcCam()
77{
78 delete fArray;
79}
80
81// --------------------------------------------------------------------------
82//
83// Our own clone function is necessary since root 3.01/06 or Mars 0.4
84// I don't know the reason
85//
86TObject *MHFadcCam::Clone(const char *) const
87{
88 const Int_t n = fArray->GetSize();
89
90 //
91 // FIXME, this might be done faster and more elegant, by direct copy.
92 //
93 MHFadcCam *cam = new MHFadcCam(fType);
94
95 cam->fArray->Expand(n);
96
97 for (int i=0; i<n; i++)
98 {
99 delete (*cam->fArray)[i];
100 (*cam->fArray)[i] = (MHFadcPix*)(*fArray)[i]->Clone();
101 }
102 return cam;
103}
104
105// --------------------------------------------------------------------------
106//
107// To setup the object we get the number of pixels from a MGeomCam object
108// in the Parameter list.
109//
110Bool_t MHFadcCam::SetupFill(const MParList *pList)
111{
112 MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
113 if (!cam)
114 {
115 *fLog << err << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
116 return kFALSE;
117 }
118
119 const Int_t n = cam->GetNumPixels();
120
121 fArray->Delete();
122 fArray->Expand(n);
123
124 for (Int_t i=0; i<n; i++)
125 (*fArray)[i] = new MHFadcPix(i, fType);
126
127 return kTRUE;
128}
129
130// --------------------------------------------------------------------------
131Bool_t MHFadcCam::Fill(const MParContainer *par, const Stat_t w)
132{
133 return Fill((MRawEvtData*)par);
134}
135
136Bool_t MHFadcCam::Fill(const MRawEvtData *par)
137{
138 const Int_t n = fArray->GetSize();
139
140 if (fType==MHFadcPix::kSlices)
141 {
142 const Int_t nhi = par->GetNumHiGainSamples();
143
144 //
145 // skip MC events without FADC information stored
146 //
147 if (nhi==0)
148 return kTRUE;
149
150 const Int_t nlo = par->GetNumLoGainSamples();
151
152 //
153 // First call with nhi!=0
154 //
155 if (fNumHiGains<0)
156 for (int i=0; i<n; i++)
157 (*this)[i].Init(nhi, nlo);
158 else
159 {
160 if (fNumLoGains!=nlo)
161 {
162 *fLog << err << dbginf << "ERROR - Number of lo-gain samples changed from " << fNumLoGains << " to " << nlo << endl;
163 return kFALSE;
164 }
165 if (fNumHiGains!=nhi)
166 {
167 *fLog << err << dbginf << "ERROR - Number of hi-gain samples changed from " << fNumHiGains << " to " << nhi << endl;
168 return kFALSE;
169 }
170 }
171
172 fNumHiGains = nhi;
173 fNumLoGains = nlo;
174 }
175
176 for (int i=0; i<n; i++)
177 if (!(*this)[i].Fill(*par))
178 return kFALSE;
179
180 return kTRUE;
181}
182
183void MHFadcCam::ResetHistograms()
184{
185 const Int_t n = fArray->GetSize();
186 for (Int_t i=0; i<n; i++)
187 ResetEntry(i);
188}
189
190void MHFadcCam::ResetEntry(Int_t i)
191{
192 GetHistHi(i)->Reset();
193 GetHistLo(i)->Reset();
194}
Note: See TracBrowser for help on using the repository browser.