ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
ForwardDetectors
ZDC
ZdcUtils
ZdcUtils
ZDCWaveform.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef ZDCUTILS_ZDCWAVEFORM_H
6
#define ZDCUTILS_ZDCWAVEFORM_H
7
8
#include <string>
9
#include <vector>
10
#include <map>
11
#include "TF1.h"
12
13
// Base class that defines the interface to all waveform classes
14
//
15
// The waveforms describe possible shapes of pulses seen in the ZDC or RPD
16
//
17
// They should be defined such that the maximum occurs at t = 0.
18
// The base class provides a rescaling to provide unity value at maximum (t = 0).
19
//
20
// Users of the waveform then produce "real" pulses by evaluating the pulse at
21
// at (t-t0) and multiplying by an amplitude.
22
//
23
// The waveforms are assumed to have at least two shape parameters, tau_1 and tau_2.
24
// They may also have additional shape parameters that are described by strings and
25
// are given default values in the constructor.
26
//
27
// The waveform should be able to be evaluated at any time, positive or negative
28
//
29
//
30
class
ZDCWaveformBase
31
{
32
std::string
m_tag
;
33
std::map<std::string, unsigned int>
m_addtlShapeNames
;
34
35
double
m_initialTauRise
;
36
double
m_initialTauFall
;
37
unsigned
int
m_numAddtlShapePars
;
38
std::vector<double>
m_addtlShapeInitialValues
;
39
40
protected
:
41
42
double
m_tauRise
;
43
double
m_tauFall
;
44
45
std::vector<double>
m_addtlShapeValues
;
46
47
void
setAddtlShapeParameters
(
const
std::vector<std::string> &addtlShapeNames,
48
const
std::vector<double> &addtlShapeValues);
49
void
setAddtlShapeValues
(
const
double
* values);
50
51
protected
:
52
53
void
setAddtlShapeValues
(
const
std::vector<double> &values) {
54
setAddtlShapeValues
(&values[0]);
55
}
56
57
// The actual implementation classes must override doEvaluate to produce the corresponding waveform
58
//
59
virtual
double
doEvaluate
(
double
time)
const
= 0;
60
61
// The implementation classes must provide a name
62
//
63
virtual
std::string
name
()
const
= 0;
64
65
ZDCWaveformBase
() =
delete
;
66
67
public
:
68
ZDCWaveformBase
(std::string tag,
double
initialTauRise,
double
initialTauFall,
const
std::vector<std::string> &addtlShapeNames,
69
const
std::vector<double> &addtlShapeValues);
70
71
virtual
~ZDCWaveformBase
() =
default
;
72
73
ZDCWaveformBase
(
const
ZDCWaveformBase
&
instance
);
74
75
// Duplicate this object
76
//
77
ZDCWaveformBase
*
Duplicate
();
78
79
// This method provides the actual value of the waveform at the provided time
80
//
81
double
evaluate
(
double
time)
const
82
{
83
return
doEvaluate
(time)/
doEvaluate
(0);
84
}
85
86
double
evaluateRoot
(
double
*
x
,
double
*p) {
87
return
this->
operator()
(x,p);
88
}
89
90
double
evaluateRootNoTF1Par
(
double
*
x
,
double
*p) {
91
(void)p;
92
return
evaluate
(
x
[0]);
93
}
94
95
double
operator()
(
double
*
x
,
double
*p) {
96
setTaus
(p[0], p[1]);
97
if
(
getNumAddtlShapeValues
() > 0)
setAddtlShapeValues
(p + 2);
98
return
evaluate
(
x
[0]);
99
}
100
101
const
std::string&
getTag
()
const
{
return
m_tag
;}
102
std::string
getNameTag
()
const
{
return
name
() +
"_"
+
m_tag
;}
103
const
std::string
getName
()
const
{
return
name
();}
104
double
getTauRise
()
const
{
return
m_tauRise
;}
105
double
getTauFall
()
const
{
return
m_tauFall
;}
106
107
unsigned
int
getNumAddtlShapeValues
()
const
{
return
m_numAddtlShapePars
;}
108
double
getAddtlShapeValue
(
const
std::string&
name
)
const
{
return
m_addtlShapeValues
.at(
m_addtlShapeNames
.find(
name
)->second);}
109
double
getAddtlShapeValue
(
unsigned
int
index
)
const
{
return
m_addtlShapeValues
.at(
index
);}
110
111
void
setAddtlShapeValue
(std::string
name
,
double
value);
112
113
void
setAddtlShapeValue
(
unsigned
int
index
,
double
value) {
114
m_addtlShapeValues
.at(
index
) = value;
115
}
116
117
void
setTaus
(
double
tauRise,
double
tauFall)
118
{
119
m_tauRise
= tauRise;
120
m_tauFall
= tauFall;
121
}
122
123
// Restore the initial values for all parameters
124
//
125
void
restoreInitial
();
126
127
128
// Make a TF1 that can draw the waveform. Depending on useTF1Params, the parameters
129
// can be controlled via the TF1 or via the ZDCWaveform object. In the latter case
130
// the TF1 has no parameters
131
//
132
//
133
TF1*
makeWaveformTF1
(
ZDCWaveformBase
* ptr,
double
xmin
,
double
xmax
,
bool
useTF1Params =
true
)
134
{
135
std::string
name
= ptr->getNameTag() +
"_TF1"
;
136
137
TF1* newTF1 = 0;
138
139
if
(useTF1Params) {
140
unsigned
int
numPar = 2 + ptr->getNumAddtlShapeValues();
141
142
newTF1=
new
TF1(
name
.c_str(), ptr, &
ZDCWaveformBase::evaluateRoot
,
xmin
,
xmax
, numPar);
143
144
newTF1->SetParameter(0, ptr->getTauRise());
145
newTF1->SetParameter(1, ptr->getTauFall());
146
147
if
(numPar > 2) {
148
for
(
unsigned
int
idxpar = 2; idxpar < numPar; idxpar++) {
149
newTF1->SetParameter(idxpar, ptr->getAddtlShapeValue(idxpar - 2));
150
}
151
}
152
}
153
else
{
154
newTF1=
new
TF1(
name
.c_str(), ptr, &
ZDCWaveformBase::evaluateRootNoTF1Par
,
xmin
,
xmax
, 0);
155
}
156
157
newTF1->SetNpx(1000);
158
return
newTF1;
159
}
160
161
TF1*
makeWaveformTF1
(
ZDCWaveformBase
&
instance
,
double
xmin
,
double
xmax
,
bool
useTF1Params =
true
)
162
{
163
return
makeWaveformTF1
(&
instance
,
xmin
,
xmax
, useTF1Params);
164
}
165
166
};
167
#endif
instance
std::map< std::string, double > instance
Definition
Run_To_Get_Tags.h:8
x
#define x
ZDCWaveformBase::getAddtlShapeValue
double getAddtlShapeValue(const std::string &name) const
Definition
ZDCWaveform.h:108
ZDCWaveformBase::Duplicate
ZDCWaveformBase * Duplicate()
ZDCWaveformBase::evaluate
double evaluate(double time) const
Definition
ZDCWaveform.h:81
ZDCWaveformBase::setAddtlShapeValue
void setAddtlShapeValue(std::string name, double value)
ZDCWaveformBase::m_tauRise
double m_tauRise
Definition
ZDCWaveform.h:42
ZDCWaveformBase::makeWaveformTF1
TF1 * makeWaveformTF1(ZDCWaveformBase &instance, double xmin, double xmax, bool useTF1Params=true)
Definition
ZDCWaveform.h:161
ZDCWaveformBase::setAddtlShapeValues
void setAddtlShapeValues(const std::vector< double > &values)
Definition
ZDCWaveform.h:53
ZDCWaveformBase::name
virtual std::string name() const =0
ZDCWaveformBase::getName
const std::string getName() const
Definition
ZDCWaveform.h:103
ZDCWaveformBase::setAddtlShapeValues
void setAddtlShapeValues(const double *values)
Definition
ZDCWaveform.cxx:54
ZDCWaveformBase::getTauFall
double getTauFall() const
Definition
ZDCWaveform.h:105
ZDCWaveformBase::m_numAddtlShapePars
unsigned int m_numAddtlShapePars
Definition
ZDCWaveform.h:37
ZDCWaveformBase::setAddtlShapeValue
void setAddtlShapeValue(unsigned int index, double value)
Definition
ZDCWaveform.h:113
ZDCWaveformBase::m_addtlShapeValues
std::vector< double > m_addtlShapeValues
Definition
ZDCWaveform.h:45
ZDCWaveformBase::getTauRise
double getTauRise() const
Definition
ZDCWaveform.h:104
ZDCWaveformBase::getNameTag
std::string getNameTag() const
Definition
ZDCWaveform.h:102
ZDCWaveformBase::getTag
const std::string & getTag() const
Definition
ZDCWaveform.h:101
ZDCWaveformBase::m_initialTauFall
double m_initialTauFall
Definition
ZDCWaveform.h:36
ZDCWaveformBase::m_addtlShapeNames
std::map< std::string, unsigned int > m_addtlShapeNames
Definition
ZDCWaveform.h:33
ZDCWaveformBase::setAddtlShapeParameters
void setAddtlShapeParameters(const std::vector< std::string > &addtlShapeNames, const std::vector< double > &addtlShapeValues)
Definition
ZDCWaveform.cxx:32
ZDCWaveformBase::evaluateRoot
double evaluateRoot(double *x, double *p)
Definition
ZDCWaveform.h:86
ZDCWaveformBase::m_tauFall
double m_tauFall
Definition
ZDCWaveform.h:43
ZDCWaveformBase::setTaus
void setTaus(double tauRise, double tauFall)
Definition
ZDCWaveform.h:117
ZDCWaveformBase::operator()
double operator()(double *x, double *p)
Definition
ZDCWaveform.h:95
ZDCWaveformBase::doEvaluate
virtual double doEvaluate(double time) const =0
ZDCWaveformBase::m_tag
std::string m_tag
Definition
ZDCWaveform.h:32
ZDCWaveformBase::makeWaveformTF1
TF1 * makeWaveformTF1(ZDCWaveformBase *ptr, double xmin, double xmax, bool useTF1Params=true)
Definition
ZDCWaveform.h:133
ZDCWaveformBase::evaluateRootNoTF1Par
double evaluateRootNoTF1Par(double *x, double *p)
Definition
ZDCWaveform.h:90
ZDCWaveformBase::~ZDCWaveformBase
virtual ~ZDCWaveformBase()=default
ZDCWaveformBase::restoreInitial
void restoreInitial()
Definition
ZDCWaveform.cxx:60
ZDCWaveformBase::ZDCWaveformBase
ZDCWaveformBase()=delete
ZDCWaveformBase::getAddtlShapeValue
double getAddtlShapeValue(unsigned int index) const
Definition
ZDCWaveform.h:109
ZDCWaveformBase::getNumAddtlShapeValues
unsigned int getNumAddtlShapeValues() const
Definition
ZDCWaveform.h:107
ZDCWaveformBase::m_addtlShapeInitialValues
std::vector< double > m_addtlShapeInitialValues
Definition
ZDCWaveform.h:38
ZDCWaveformBase::m_initialTauRise
double m_initialTauRise
Definition
ZDCWaveform.h:35
xmax
double xmax
Definition
listroot.cxx:61
xmin
double xmin
Definition
listroot.cxx:60
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0