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
37
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 {}
55
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 }
62
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 (const 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();
125 return *this;
126 }
127
137 static double waveform(double t, double initTime, double charge, double tau,
139 {
140 double z = (t - initTime) / tau;
141 return charge * wfun(z);
142 }
143
149 static double waveform(double t, const ElementaryWaveform& elemWaveform)
150 { return waveform(t, elemWaveform.m_initTime, elemWaveform.m_charge, elemWaveform.m_tau, elemWaveform.m_wfun); }
151
156 double operator()(double t) const
157 {
158 double total_waveform = 0;
159 for (const SVDWaveform::ElementaryWaveform& elementary_waveform : m_elementaryWaveforms) {
160 total_waveform += waveform(t, elementary_waveform);
161 }
162 return total_waveform;
163 }
164
168 double getCharge() const { return m_charge; }
169
174
179
185 std::string toString() const
186 {
187 std::ostringstream os;
188 size_t i = 0;
189 for (const auto& elementary_waveform : m_elementaryWaveforms)
190 os << ++i << '\t' << elementary_waveform.toString();
191 return os.str();
192 }
193
194 protected:
195
197 double m_charge;
204
205 }; // class SVDWaveform
206
207 } // end namespace SVD
209} // end namespace Belle2
210
211#endif
unsigned int index_type
type used for indices.
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.
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.
relations_map m_truehits
Map of TrueHit associations.
const relations_map & getMCParticleRelations() const
Return the list of MCParticle relations.
SVDWaveform & operator=(const SVDWaveform &other)
Make the SVDWaveform assignable.
std::deque< ElementaryWaveform > elementary_waveform_list
List of elementary waveforms.
Definition SVDWaveform.h:77
double getCharge() const
Return the charge collected in the strip.
SVDWaveform()
Default constructor.
Definition SVDWaveform.h:85
const relations_map & getTrueHitRelations() const
Return the list of TrueHit relations.
const elementary_waveform_list & getElementaryWaveforms() const
Return the list of waveform parameters.
relations_map m_particles
Map of MCParticle associations.
elementary_waveform_list m_elementaryWaveforms
list of elementary waveform parameters.
double operator()(double t) const
Make SVDWaveform a functor.
SVDWaveform(const SVDWaveform &other)
Copy constructor.
Definition SVDWaveform.h:88
double m_charge
charge of the pixel
static double waveform(double t, double initTime, double charge, double tau, WaveformShape wfun=w_betaprime)
Waveform shape.
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
static double waveform(double t, const ElementaryWaveform &elemWaveform)
Waveform taking parameters from a ElementaryWaveform struct.
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
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