BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
bdsim
analysis
ParticleSet.hh
1
/*
2
Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3
University of London 2001 - 2023.
4
5
This file is part of BDSIM.
6
7
BDSIM is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published
9
by the Free Software Foundation version 3 of the License.
10
11
BDSIM is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
#ifndef PARTICLESET_H
20
#define PARTICLESET_H
21
22
#include <cmath>
23
#include <map>
24
31
class
BinValue
32
{
33
public
:
34
BinValue
():
35
value(0),
36
sumOfWeightsSquared(0)
37
{;}
38
39
inline
void
Fill(
double
weight = 1)
40
{
41
value += weight;
42
sumOfWeightsSquared += weight*weight;
43
};
44
45
inline
void
Reset() {value = 0; sumOfWeightsSquared = 0;}
46
inline
double
Error()
const
{
return
std::sqrt(sumOfWeightsSquared);}
47
48
double
value;
49
double
sumOfWeightsSquared;
50
};
51
62
class
ParticleSet
63
{
64
public
:
65
void
Fill(
long
int
x,
66
double
weight = 1)
67
{data[x].Fill(weight);}
68
69
std::map<long int,BinValue>::iterator begin() {
return
data.begin();}
70
std::map<long int,BinValue>::iterator end() {
return
data.end();}
71
std::map<long int,BinValue>::const_iterator begin()
const
{
return
data.begin();}
72
std::map<long int,BinValue>::const_iterator end()
const
{
return
data.end();}
73
bool
empty()
const
{
return
data.empty();}
74
75
BinValue
& operator[](
const
long
int
key) {
return
data[key];}
76
const
BinValue
& operator[](
const
long
int
key)
const
{
return
data.at(key);}
77
78
std::map<long int, BinValue> data;
79
unsigned
long
nEntries;
80
};
81
82
#endif
BinValue
A simple bin definition for a histogram.
Definition:
ParticleSet.hh:32
ParticleSet
A very simple 'map' type histogram axis.
Definition:
ParticleSet.hh:63
Generated on Mon Aug 14 2023 13:49:30 for BDSIM by
1.9.6