ATLAS Offline Software
Loading...
Searching...
No Matches
ShapeInfo.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8#include "TH1D.h"
9#include "TGraph.h"
10#include "TMath.h"
11
12#include <iostream>
13using std::cout;
14using std::endl;
15
16using namespace LArSamples;
17
18
19double ShapeInfo::m_timeShift = 0;
20
21// Samples, phases :
22// 5samples, 17phases means that for each sample we have 17 points ........x........ where x is the sample
23// However the edge points correspond to the samples before and after so we have
24// For 5 samples ........x.......x.......x.......x.......x........ (7 points in-between but 8 before and after)
25// So for N samples, P phases, we have Npoints = P' + (N- 1)*P' + 1 + P' = (N+1)*P' + 1
26// where P' = (P-1)/2.
27
28ShapeInfo::ShapeInfo(unsigned char nSamples, unsigned char binSize, unsigned char nPhases, float shift)
30{
32 unsigned int nPoints = nIntervals()*(nSamples - 1) + nPhases;
33 m_values.resize(nPoints, 0);
34}
35
36
38 : m_values(other.m_values),
40 m_nPhases(other.m_nPhases), m_shift(other.m_shift)
41{
43}
44
45
50
51
53{
54 return (!m_values.empty());
55}
56
57
58double ShapeInfo::value(unsigned int i) const
59{
60 if (i < m_values.size()) return double(m_values[i])/32767;
61 if (i == m_values.size() && m_values.size() >= 2)
62 return 2*value(i - 1) - value(i - 2);
63 return -1E99;
64}
65
66unsigned char ShapeInfo::phase(unsigned int i) const
67{
68 return (i % nIntervals());
69}
70
71
72void ShapeInfo::set(unsigned char iSample, unsigned char iPhase, float value)
73{
74 unsigned int index = iPhase + iSample*nIntervals();
75 m_values[index] = int(value*32767 + 0.5) + (value > 0 ? 0 : -1);
76}
static double m_timeShift
Definition ShapeInfo.h:72
unsigned char m_binSize
Definition ShapeInfo.h:70
unsigned char m_nSamples
Definition ShapeInfo.h:70
bool isValid() const
Definition ShapeInfo.cxx:52
unsigned char nPhases() const
Definition ShapeInfo.h:40
unsigned char phase(unsigned int i) const
Definition ShapeInfo.cxx:66
float shift() const
Definition ShapeInfo.h:42
unsigned char binSize() const
Definition ShapeInfo.h:38
void set(unsigned char iSample, unsigned char iPhase, float value)
Definition ShapeInfo.cxx:72
double value(unsigned int i) const
Definition ShapeInfo.cxx:58
unsigned int nPoints() const
Definition ShapeInfo.h:37
std::vector< short > m_values
Definition ShapeInfo.h:69
ShapeInfo(unsigned char nSamples=5, unsigned char binSize=3, unsigned char nPhases=8, float shift=0)
Constructor.
Definition ShapeInfo.cxx:28
unsigned int nIntervals() const
Definition ShapeInfo.h:41
unsigned char m_nPhases
Definition ShapeInfo.h:70
unsigned char nSamples() const
Definition ShapeInfo.h:39
Definition index.py:1