source: trunk/MagicSoft/Mars/mhist/MHFadcCam.cc@ 2357

Last change on this file since 2357 was 2333, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.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): 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 "MRawEvtData.h"
40#include "MRawEvtPixelIter.h"
41
42ClassImp(MHFadcCam);
43
44using namespace std;
45
46// --------------------------------------------------------------------------
47//
48// default constructor
49// creates an a list of histograms for all pixels and both gain channels
50//
51MHFadcCam::MHFadcCam(const Int_t n, MHFadcPix::Type_t t, const char *name, const char *title)
52 : fNumHiGains(-1), fNumLoGains(-1), fType(t)
53{
54 //
55 // set the name and title of this object
56 //
57 fName = name ? name : "MHFadcCam";
58 fTitle = title ? title : "Container for ADC spectra histograms";
59
60 //
61 // loop over all Pixels and create two histograms
62 // one for the Low and one for the High gain
63 // connect all the histogram with the container fHist
64 //
65 fArray = new TObjArray(n);
66
67 for (Int_t i=0; i<n; i++)
68 (*fArray)[i] = new MHFadcPix(i, fType);
69}
70
71// --------------------------------------------------------------------------
72MHFadcCam::~MHFadcCam()
73{
74 delete fArray;
75}
76
77// --------------------------------------------------------------------------
78//
79// Our own clone function is necessary since root 3.01/06 or Mars 0.4
80// I don't know the reason
81//
82TObject *MHFadcCam::Clone(const char *) const
83{
84 const Int_t n = fArray->GetSize();
85
86 //
87 // FIXME, this might be done faster and more elegant, by direct copy.
88 //
89 MHFadcCam *cam = new MHFadcCam(n);
90
91 for (int i=0; i<n; i++)
92 {
93 delete (*cam->fArray)[i];
94 (*cam->fArray)[i] = (MHFadcPix*)(*fArray)[i]->Clone();
95 }
96 return cam;
97}
98
99// --------------------------------------------------------------------------
100Bool_t MHFadcCam::Fill(const MParContainer *par, const Stat_t w)
101{
102 return Fill((MRawEvtData*)par);
103}
104
105Bool_t MHFadcCam::Fill(const MRawEvtData *par)
106{
107 const Int_t n = fArray->GetSize();
108
109 if (fType==MHFadcPix::kSlices)
110 {
111 const Int_t nhi = par->GetNumHiGainSamples();
112
113 //
114 // skip MC events without FADC information stored
115 //
116 if (nhi==0)
117 return kTRUE;
118
119 const Int_t nlo = par->GetNumLoGainSamples();
120
121 //
122 // First call with nhi!=0
123 //
124 if (fNumHiGains<0)
125 for (int i=0; i<n; i++)
126 (*this)[i].Init(nhi, nlo);
127 else
128 {
129 if (fNumLoGains!=nlo)
130 {
131 *fLog << err << dbginf << "ERROR - Number of lo-gain samples changed from " << fNumLoGains << " to " << nlo << endl;
132 return kFALSE;
133 }
134 if (fNumHiGains!=nhi)
135 {
136 *fLog << err << dbginf << "ERROR - Number of hi-gain samples changed from " << fNumHiGains << " to " << nhi << endl;
137 return kFALSE;
138 }
139 }
140
141 fNumHiGains = nhi;
142 fNumLoGains = nlo;
143 }
144
145 for (int i=0; i<n; i++)
146 if (!(*this)[i].Fill(*par))
147 return kFALSE;
148
149 return kTRUE;
150}
151
152void MHFadcCam::ResetHistograms()
153{
154 const Int_t n = fArray->GetSize();
155 for (Int_t i=0; i<n; i++)
156 ResetEntry(i);
157}
158
159void MHFadcCam::ResetEntry(Int_t i)
160{
161 GetHistHi(i)->Reset();
162 GetHistLo(i)->Reset();
163}
Note: See TracBrowser for help on using the repository browser.