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

Last change on this file since 1715 was 1652, checked in by tbretz, 22 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
44// --------------------------------------------------------------------------
45//
46// default constructor
47// creates an a list of histograms for all pixels and both gain channels
48//
49MHFadcCam::MHFadcCam(MHFadcPix::Type_t t, const char *name, const char *title)
50 : fNumHiGains(-1), fNumLoGains(-1), fType(t)
51{
52 //
53 // set the name and title of this object
54 //
55 fName = name ? name : "MHFadcCam";
56 fTitle = title ? title : "Container for ADC spectra histograms";
57
58 //
59 // loop over all Pixels and create two histograms
60 // one for the Low and one for the High gain
61 // connect all the histogram with the container fHist
62 //
63 fArray = new TObjArray(577);
64
65 for (Int_t i=0; i<577; i++)
66 (*fArray)[i] = new MHFadcPix(i+1, fType);
67}
68
69// --------------------------------------------------------------------------
70MHFadcCam::~MHFadcCam()
71{
72 delete fArray;
73}
74
75// --------------------------------------------------------------------------
76//
77// Our own clone function is necessary since root 3.01/06 or Mars 0.4
78// I don't know the reason
79//
80TObject *MHFadcCam::Clone(const char *) const
81{
82 MHFadcCam *cam = new MHFadcCam;
83
84 for (int i=0; i<577; i++)
85 {
86 delete (*cam->fArray)[i];
87 (*cam->fArray)[i] = (MHFadcPix*)(*fArray)[i]->Clone();
88 }
89 return cam;
90}
91
92// --------------------------------------------------------------------------
93Bool_t MHFadcCam::Fill(const MParContainer *par)
94{
95 return Fill((MRawEvtData*)par);
96}
97
98Bool_t MHFadcCam::Fill(const MRawEvtData *par)
99{
100 if (fType==MHFadcPix::kSlices)
101 {
102 const Int_t nlo = par->GetNumLoGainSamples();
103 const Int_t nhi = par->GetNumHiGainSamples();
104
105 //
106 // First call
107 //
108 if (fNumHiGains<0)
109 for (int i=0; i<577; i++)
110 (*this)[i].Init(nhi, nlo);
111 else
112 if (fNumHiGains!=nhi || fNumLoGains!=nlo)
113 {
114 *fLog << err << dbginf << "ERROR - Number of lo- or hi-gain samples changed." << endl;
115 return kFALSE;
116 }
117
118 fNumHiGains = nhi;
119 fNumLoGains = nlo;
120 }
121
122 for (int i=0; i<577; i++)
123 if (!(*this)[i].Fill(*par))
124 return kFALSE;
125
126 return kTRUE;
127}
128
129void MHFadcCam::ResetHistograms()
130{
131 for (Int_t i=0; i<577; i++)
132 {
133 GetHistHi(i)->Reset();
134 GetHistLo(i)->Reset();
135 }
136}
Note: See TracBrowser for help on using the repository browser.