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

Last change on this file since 2313 was 2173, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.7 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(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(577);
66
67 for (Int_t i=0; i<577; i++)
68 (*fArray)[i] = new MHFadcPix(i+1, 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 MHFadcCam *cam = new MHFadcCam;
85
86 for (int i=0; i<577; i++)
87 {
88 delete (*cam->fArray)[i];
89 (*cam->fArray)[i] = (MHFadcPix*)(*fArray)[i]->Clone();
90 }
91 return cam;
92}
93
94// --------------------------------------------------------------------------
95Bool_t MHFadcCam::Fill(const MParContainer *par, const Stat_t w)
96{
97 return Fill((MRawEvtData*)par);
98}
99
100Bool_t MHFadcCam::Fill(const MRawEvtData *par)
101{
102 if (fType==MHFadcPix::kSlices)
103 {
104 const Int_t nlo = par->GetNumLoGainSamples();
105 const Int_t nhi = par->GetNumHiGainSamples();
106
107 //
108 // First call
109 //
110 if (fNumHiGains<0)
111 for (int i=0; i<577; i++)
112 (*this)[i].Init(nhi, nlo);
113 else
114 if (fNumHiGains!=nhi || fNumLoGains!=nlo)
115 {
116 *fLog << err << dbginf << "ERROR - Number of lo- or hi-gain samples changed." << endl;
117 return kFALSE;
118 }
119
120 fNumHiGains = nhi;
121 fNumLoGains = nlo;
122 }
123
124 for (int i=0; i<577; i++)
125 if (!(*this)[i].Fill(*par))
126 return kFALSE;
127
128 return kTRUE;
129}
130
131void MHFadcCam::ResetHistograms()
132{
133 for (Int_t i=0; i<577; i++)
134 ResetEntry(i);
135}
136
137void MHFadcCam::ResetEntry(Int_t i)
138{
139 GetHistHi(i)->Reset();
140 GetHistLo(i)->Reset();
141}
142
Note: See TracBrowser for help on using the repository browser.