Belle II Software development
SVDWaveform.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#ifndef SVDWaveform_H
10#define SVDWaveform_H
11
12#include <framework/dataobjects/RelationElement.h>
13#include <string>
14#include <sstream>
15#include <deque>
16#include <map>
17#include <svd/simulation/SVDSimulationTools.h>
18
19namespace Belle2 {
24 namespace SVD {
25
39
40 public:
41
50 ElementaryWaveform(double initTime, double charge, double tau, WaveformShape wfun,
52 m_initTime(initTime), m_charge(charge), m_tau(tau), m_wfun(wfun),
53 m_particle(particle), m_truehit(truehit)
54 {}
56 std::string toString() const
57 {
58 std::ostringstream os;
59 os << m_initTime << '\t' << m_charge << '\t' << m_tau << std::endl;
60 return os.str();
61 }
63 double m_initTime;
65 double m_charge;
67 double m_tau;
74 };
75
77 typedef std::deque< ElementaryWaveform > elementary_waveform_list;
78
80 typedef std::map<RelationElement::index_type, RelationElement::weight_type> relations_map;
82 typedef std::map<RelationElement::index_type, RelationElement::weight_type>::value_type relation_value_type;
83
86
89 {
90 m_charge = other.getCharge();
91 for (ElementaryWaveform elementary_waveform : other.getElementaryWaveforms())
92 m_elementaryWaveforms.push_back(elementary_waveform);
93 }
94
106 void add(double initTime, double charge, double tau, int particle = -1, int truehit = -1, WaveformShape wfun = w_betaprime)
107 {
108 if (charge > 0) {
109 m_charge += charge;
110 m_elementaryWaveforms.push_back(ElementaryWaveform(initTime, charge, tau, wfun, particle, truehit));
111 if (particle > -1) m_particles[particle] += static_cast<float>(charge);
112 if (truehit > -1) m_truehits[truehit] += static_cast<float>(charge);
113 } else if (m_charge == 0)
114 m_charge += charge;
115 }
116
122 {
123 m_charge = other.getCharge();
124 m_elementaryWaveforms.clear();
125 std::copy(other.getElementaryWaveforms().begin(), other.getElementaryWaveforms().end(), m_elementaryWaveforms.begin());
126 return *this;
127 }
128
138 double waveform(double t, double initTime, double charge, double tau,
139 WaveformShape wfun = w_betaprime) const
140 {
141 double z = (t - initTime) / tau;
142 return charge * wfun(z);
143 }
144
150 double waveform(double t, const ElementaryWaveform& elemWaveform) const
151 { return waveform(t, elemWaveform.m_initTime, elemWaveform.m_charge, elemWaveform.m_tau, elemWaveform.m_wfun); }
152
157 double operator()(double t) const
158 {
159 double total_waveform = 0;
160 for (SVDWaveform::ElementaryWaveform elementary_waveform : m_elementaryWaveforms) {
161 total_waveform += waveform(t, elementary_waveform);
162 }
163 return total_waveform;
164 }
165
169 double getCharge() const { return m_charge; }
170
175
180
186 std::string toString() const
187 {
188 std::ostringstream os;
189 size_t i = 0;
190 for (auto elementary_waveform : m_elementaryWaveforms)
191 os << ++i << '\t' << elementary_waveform.toString();
192 return os.str();
193 }
194
195 protected:
196
198 double m_charge;
205
206 }; // class SVDWaveform
207
208 } // end namespace SVD
210} // end namespace Belle2
211
212#endif
unsigned int index_type
type used for indices.
The SVD waveform class.
Definition: SVDWaveform.h:38
void add(double initTime, double charge, double tau, int particle=-1, int truehit=-1, WaveformShape wfun=w_betaprime)
Add a chargelet waveform to the total strip waveform.
Definition: SVDWaveform.h:106
std::map< RelationElement::index_type, RelationElement::weight_type >::value_type relation_value_type
Type of relation_map elements.
Definition: SVDWaveform.h:82
std::string toString() const
Produce a string representation of the object.
Definition: SVDWaveform.h:186
relations_map m_truehits
Map of TrueHit associations.
Definition: SVDWaveform.h:204
const relations_map & getMCParticleRelations() const
Return the list of MCParticle relations.
Definition: SVDWaveform.h:179
SVDWaveform & operator=(const SVDWaveform &other)
Make the SVDWaveform assignable.
Definition: SVDWaveform.h:121
std::deque< ElementaryWaveform > elementary_waveform_list
List of elementary waveforms.
Definition: SVDWaveform.h:77
double getCharge() const
Return the charge collected in the strip.
Definition: SVDWaveform.h:169
SVDWaveform()
Default constructor.
Definition: SVDWaveform.h:85
const relations_map & getTrueHitRelations() const
Return the list of TrueHit relations.
Definition: SVDWaveform.h:184
const elementary_waveform_list & getElementaryWaveforms() const
Return the list of waveform parameters.
Definition: SVDWaveform.h:174
relations_map m_particles
Map of MCParticle associations.
Definition: SVDWaveform.h:202
double waveform(double t, double initTime, double charge, double tau, WaveformShape wfun=w_betaprime) const
Waveform shape.
Definition: SVDWaveform.h:138
elementary_waveform_list m_elementaryWaveforms
list of elementary waveform parameters.
Definition: SVDWaveform.h:200
double operator()(double t) const
Make SVDWaveform a functor.
Definition: SVDWaveform.h:157
SVDWaveform(const SVDWaveform &other)
Copy constructor.
Definition: SVDWaveform.h:88
double m_charge
charge of the pixel
Definition: SVDWaveform.h:198
double waveform(double t, const ElementaryWaveform &elemWaveform) const
Waveform taking parameters from a ElementaryWaveform struct.
Definition: SVDWaveform.h:150
std::map< RelationElement::index_type, RelationElement::weight_type > relations_map
Type to store contributions to strip signal by different particles on output of SVDWaveform.
Definition: SVDWaveform.h:80
double w_betaprime(double t)
Beta-prime waveform shape, x^alpha/(1+x)^beta.
std::function< double(double)> WaveformShape
WaveformShape type.
Abstract base class for different kinds of events.
Type to store elementary waveform parameters.
Definition: SVDWaveform.h:48
std::string toString() const
Create a string containing data of this ElementaryWaveform object.
Definition: SVDWaveform.h:56
RelationElement::index_type m_truehit
DataStore index of the associated SVDTrueHit.
Definition: SVDWaveform.h:73
ElementaryWaveform(double initTime, double charge, double tau, WaveformShape wfun, RelationElement::index_type particle, RelationElement::index_type truehit)
Constructor.
Definition: SVDWaveform.h:50
RelationElement::index_type m_particle
DataStore index of the generating MC Particle.
Definition: SVDWaveform.h:71
double m_tau
Decay time of the waveform.
Definition: SVDWaveform.h:67
double m_charge
Charge of the waveform.
Definition: SVDWaveform.h:65
WaveformShape m_wfun
Waveform shape.
Definition: SVDWaveform.h:69
double m_initTime
Start time of the waveform.
Definition: SVDWaveform.h:63