source: branches/MarsISDCBranchBasedOn17887/melectronics/MAnalogChannels.cc@ 18481

Last change on this file since 18481 was 9270, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.2 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of CheObs, the Modular 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 appears 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, 1/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: CheObs Software Development, 2000-2009
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MAnalogChannels
28//
29// A collection of MAnalogSignals with a simplified access interface.
30//
31//////////////////////////////////////////////////////////////////////////////
32#include "MAnalogChannels.h"
33
34#include <TObjArray.h>
35
36#include "MAnalogSignal.h"
37
38ClassImp(MAnalogChannels);
39
40using namespace std;
41
42// ------------------------------------------------------------------------
43//
44// Default constructor
45//
46MAnalogChannels::MAnalogChannels(const char *name, const char *title)
47: fArray(0), fValidRangeMin(0), fValidRangeMax(0)
48{
49 fName = name ? name : "MAnalogChannels";
50 fTitle = title ? title : "Parameter container for a collection of analog signals";
51}
52
53// ------------------------------------------------------------------------
54//
55// Constructor. Calls Init(n, len)
56//
57MAnalogChannels::MAnalogChannels(Int_t n, Int_t len, const char *name, const char *title)
58: fArray(0), fValidRangeMin(0), fValidRangeMax(0)
59{
60 fName = name ? name : "MAnalogChannels";
61 fTitle = title ? title : "Parameter container for a collection of analog signals";
62
63 Init(n, len);
64}
65
66// ------------------------------------------------------------------------
67//
68// delete fArray
69//
70void MAnalogChannels::Clear(Option_t *o)
71{
72 if (fArray)
73 {
74 delete fArray;
75 fArray = 0;
76 }
77}
78
79// ------------------------------------------------------------------------
80//
81// Initializes n channels with a length of n sampling points.
82//
83// FIXME: We could improve speed by only increasing the arrays?
84//
85void MAnalogChannels::Init(UInt_t n, UInt_t len)
86{
87 Clear();
88
89 fArray = new TObjArray(n);
90 fArray->SetOwner();
91
92 for (UInt_t i=0; i<n; i++)
93 fArray->AddAt(new MAnalogSignal(len), i);
94}
95
96// ------------------------------------------------------------------------
97//
98// return an unchecked reference to the i-th channel.
99//
100MAnalogSignal &MAnalogChannels::operator[](UInt_t i)
101{
102 return *static_cast<MAnalogSignal*>(fArray->UncheckedAt(i));
103}
104
105// ------------------------------------------------------------------------
106//
107// return an unchecked pointer to the i-th channel.
108//
109MAnalogSignal *MAnalogChannels::operator()(UInt_t i)
110{
111 return static_cast<MAnalogSignal*>(fArray->UncheckedAt(i));
112}
113
114// ------------------------------------------------------------------------
115//
116// Return an unchecked const reference to the i-th channel.
117//
118const MAnalogSignal &MAnalogChannels::operator[](UInt_t i) const
119{
120 return *static_cast<MAnalogSignal*>(fArray->UncheckedAt(i));
121}
122
123// ------------------------------------------------------------------------
124//
125// Return an unchecked const pointer to the i-th channel.
126//
127const MAnalogSignal *MAnalogChannels::operator()(UInt_t i) const
128{
129 return static_cast<MAnalogSignal*>(fArray->UncheckedAt(i));
130}
131
132// ------------------------------------------------------------------------
133//
134// Return the number of channels.
135//
136UInt_t MAnalogChannels::GetNumChannels() const
137{
138 return fArray ? fArray->GetEntriesFast() : 0;
139}
140
141// ------------------------------------------------------------------------
142//
143// Return the number of samples per channel
144//
145UInt_t MAnalogChannels::GetNumSamples() const
146{
147 return operator()(0) ? operator()(0)->GetSize() : 0;
148}
Note: See TracBrowser for help on using the repository browser.