NSCL DDAS
1.0
Support for XIA DDAS at the NSCL
Main Page
User Guides
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Macros
Pages
traiter
src
Trace.hpp
1
// Trace.hpp
2
//
3
// Author : Jeromy Tompkins
4
// Date : 8/14/2013
5
6
#ifndef TRACE_H
7
#define TRACE_H
8
9
#include <stdint.h>
10
#include <vector>
11
#include <TObject.h>
12
#include "TrIterator.hpp"
13
14
namespace
TrAnal
15
{
16
17
template
<
class
DataType>
18
class
Basic_Trace
19
{
20
public
:
21
virtual
~
Basic_Trace
() {};
22
23
virtual
TrIterator<DataType>
begin()
const
= 0;
24
virtual
TrIterator<DataType>
end()
const
= 0;
25
26
virtual
DataType operator[](
unsigned
int
index)
const
= 0;
27
virtual
size_t
GetLength()
const
= 0;
28
29
// ROOT dictionary generation
31
ClassDef(
Basic_Trace
,1);
33
};
34
35
36
// A template class
37
// The intention is to support arbitrary stl vector but any
38
// class can be used to instantiate this so long as it supports
39
template
<
class
T>
40
class
TraceT
:
public
Basic_Trace
<T>
41
{
42
private
:
43
std::vector<T> fData;
44
45
public
:
46
// Canonical constructors
47
TraceT
() :
Basic_Trace<T>
(), fData() {}
48
TraceT
(
const
std::vector<T>& obj) :
Basic_Trace<T>
(), fData(obj) {}
49
50
// destructor
51
virtual
~
TraceT
() {}
52
53
54
TrIterator<T>
begin()
const
{
return
TrIterator<T>
(fData.data());}
55
TrIterator<T>
end()
const
{
return
TrIterator<T>
(fData.data()+fData.size());}
56
//
57
virtual
T operator[] (
unsigned
int
index)
const
;
58
virtual
size_t
GetLength()
const
{
return
fData.size(); }
59
60
// ROOT dictionary generation
62
ClassDef(
TraceT
,1);
64
};
65
66
template
<
class
T>
67
T
TraceT<T>::operator[]
(
unsigned
int
index)
const
68
{
69
if
(index>=fData.size())
70
throw
1;
71
else
72
return
fData.at(index);
73
74
}
75
//
79
//template<class T>
80
//class CalibTraceT : public Trace
81
//{
82
// private:
83
// std::vector<T> fData; ///< the data points
84
// double fSlope; ///< time difference between points
85
// double fOffset; ///< time of first point
86
//
87
// public:
88
// /// Default constructor
89
// /**
90
// * Constructs null trace with a unit time calibration (slope=1.0, offset=0.0)
91
// * There is no data in the trace produced by this constructor
92
// */
93
// TraceT() : Trace(), fData(), fSlope(1.0), fOffset(0.0) {}
94
//
95
// /// Detailed constructor
96
// /**
97
// * Constructs a calibration trace by copying the argument data
98
// * The slope and offset are 1.0 and 0.0 by default but can be set
99
// * differently
100
// */
101
// TraceT(const std::vector<T>& obj, double slope=1.0, double offset=0.0)
102
// : Trace(), fData(obj), fSlope(slope), fOffset(offset) {}
103
//
104
// virtual ~TraceT() {}
105
//
106
// /// Get the iterator for this
107
// /**
108
// * This passes ownership of the iterator to the caller. It is possible
109
// * to have multiple iterators for the same trace.
110
// *
111
// * @return a calibrated iterator object
112
// */
113
// CalibratedRangeIterator* GetIterator() const { return new CalibratedRangeIterator(*this, fSlope, fOffset); }
114
// virtual double operator[] (unsigned int index) const;
115
// virtual unsigned int GetLength() const { return fData.size(); }
116
//
117
// /// Get the time between successive points
118
// double GetSlope() const { return fSlope;}
119
//
120
// /// Time of first point
121
// double GetOffset() const { return fOffset;}
122
//
123
//
124
//};
125
//
126
//template<class T>
127
//double CalibTraceT<T>::operator[](unsigned int index) const
128
//{
129
// if (index>=fData.size())
130
// throw 1;
131
// else
132
// return fData.at(index);
133
//
134
//}
135
136
}
// end namespace
137
#endif
Generated on Mon Aug 1 2016 11:33:25 for NSCL DDAS by
1.8.1.2