ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetSimEvent
src
SiTotalCharge.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// SiTotalCharge.cxx
7
// Implementation file for class SiTotalCharge
9
// (c) ATLAS Detector software
11
// Version 1.5 08/06/2001 David Calvet
13
14
#include "
InDetSimEvent/SiTotalCharge.h
"
15
#include <iterator>
16
17
// Implicit constructor:
18
SiTotalCharge::SiTotalCharge
() :
19
m_charge
(0),
20
m_chargeComposition
()
21
{}
22
23
// Copy constructor:
24
SiTotalCharge::SiTotalCharge
(
const
SiTotalCharge
&totalCharge) :
25
m_charge
(totalCharge.
m_charge
),
26
m_chargeComposition
(totalCharge.
m_chargeComposition
)
27
{}
28
29
// Assignment operator:
30
SiTotalCharge
&
SiTotalCharge::operator=
(
const
SiTotalCharge
&totalCharge)
31
{
32
if
(
this
!=&totalCharge) {
33
m_charge
=totalCharge.
m_charge
;
34
m_chargeComposition
=totalCharge.
m_chargeComposition
;
35
}
else
{}
36
return
*
this
;
37
}
38
39
// give main single process charge:
40
const
SiCharge
&
SiTotalCharge::mainCharge
()
const
41
{
42
auto
max_element = std::max_element(
m_chargeComposition
.cbegin(),
m_chargeComposition
.cend(),
43
[](
SiCharge
const
& lhs,
SiCharge
const
& rhs)
44
{ return lhs.charge() < rhs.charge(); }
45
);
46
return
*max_element;
47
}
48
49
bool
SiTotalCharge::fromTrack
()
const
50
{
51
if
(
m_chargeComposition
.empty())
52
{
53
return
false
;
54
}
55
SiCharge::Process
process
=
mainCharge
().
processType
();
56
return
(
process
==
SiCharge::track
||
57
process
==
SiCharge::cut_track
||
58
process
==
SiCharge::diodeX_Talk
);
59
}
60
61
// add another charge:
62
void
SiTotalCharge::add
(
const
SiCharge
&
charge
)
63
{
64
// increase the total deposited charge
65
m_charge
+=
charge
.charge();
66
// add the SiCharge to the list of charges
67
addSiCharge
(
charge
);
68
}
69
70
// add another total charge:
71
void
SiTotalCharge::add
(
const
SiTotalCharge
&totalCharge)
72
{
73
// increase the total deposited charge
74
m_charge
+=totalCharge.
charge
();
75
76
std::for_each(totalCharge.
chargeComposition
().begin(),
77
totalCharge.
chargeComposition
().end(),
78
[
this
](
const
SiCharge
& c) { addSiCharge(c); }
79
);
80
}
81
82
// remove time information of the SiCharge objects:
83
void
SiTotalCharge::removeTimeInformation
()
84
{
85
// save the old charge composition
86
list_t
oldComposition;
87
m_chargeComposition
.swap(oldComposition);
88
89
// loop on all old charges
90
for
(
const
auto
& p_charge : oldComposition) {
91
// add the old charge (without time) to the list
92
addSiCharge
(
SiCharge
(p_charge.charge(),0,
93
p_charge.processType(),p_charge.particleLink()));
94
}
95
}
96
97
// remove small SiCharge objects:
98
void
SiTotalCharge::removeSmallCharges
(
const
double
minimumCharge)
99
{
100
//erase-remove idiom to remove small charges
101
auto
new_end =
std::remove_if
(
m_chargeComposition
.begin(),
m_chargeComposition
.end(),
102
[&minimumCharge](
const
SiCharge
& c){ return (c.charge() > -minimumCharge) &&
103
(c.charge() < minimumCharge); });
104
m_chargeComposition
.erase(new_end,
m_chargeComposition
.end());
105
}
106
107
// add another SiCharge to the charge composition (not the total value):
108
void
SiTotalCharge::addSiCharge
(
const
SiCharge
&
charge
)
109
{
110
auto
element = std::find_if(
m_chargeComposition
.begin(),
m_chargeComposition
.end(),
111
[&
charge
](
const
SiCharge
& other) {
112
return (charge.time() == other.time()) &&
113
(charge.processType() == other.processType()) &&
114
(charge.particleLink() == other.particleLink());
115
} );
116
if
(element !=
m_chargeComposition
.end()) element->add(
charge
);
117
// add the charge to the list if not merged in existing one
118
else
m_chargeComposition
.push_back(
charge
);
119
}
120
122
// Input/Output stream functions:
124
std::ostream &
operator<<
(std::ostream &out,
const
SiTotalCharge
&totalCharge)
125
{
126
out <<
"Total charge="
<< totalCharge.
charge
()
127
<<
" Composition:"
<< std::endl;
128
copy(totalCharge.
chargeComposition
().begin(),
129
totalCharge.
chargeComposition
().end(),
130
std::ostream_iterator<SiCharge>(out,
"\n"
));
131
return
out;
132
}
133
134
const
HepMcParticleLink
SiTotalCharge::m_emptyLink
=
HepMcParticleLink
();
operator<<
std::ostream & operator<<(std::ostream &out, const SiTotalCharge &totalCharge)
Definition
SiTotalCharge.cxx:124
SiTotalCharge.h
HepMcParticleLink
a link optimized in size for a GenParticle in a McEventCollection
Definition
HepMcParticleLink.h:72
SiCharge
Definition
SiCharge.h:25
SiCharge::processType
Process processType() const
Definition
SiCharge.h:119
SiCharge::Process
Process
Definition
SiCharge.h:28
SiCharge::track
@ track
Definition
SiCharge.h:28
SiCharge::cut_track
@ cut_track
Definition
SiCharge.h:28
SiCharge::diodeX_Talk
@ diodeX_Talk
Definition
SiCharge.h:28
SiTotalCharge
Definition
SiTotalCharge.h:24
SiTotalCharge::m_chargeComposition
list_t m_chargeComposition
Definition
SiTotalCharge.h:107
SiTotalCharge::m_charge
double m_charge
Definition
SiTotalCharge.h:106
SiTotalCharge::list_t
std::vector< SiCharge > list_t
Definition
SiTotalCharge.h:31
SiTotalCharge::m_emptyLink
static const HepMcParticleLink m_emptyLink
Definition
SiTotalCharge.h:108
SiTotalCharge::SiTotalCharge
SiTotalCharge()
Definition
SiTotalCharge.cxx:18
SiTotalCharge::addSiCharge
void addSiCharge(const SiCharge &charge)
Definition
SiTotalCharge.cxx:108
SiTotalCharge::removeTimeInformation
void removeTimeInformation()
Definition
SiTotalCharge.cxx:83
SiTotalCharge::operator=
SiTotalCharge & operator=(const SiTotalCharge &totalCharge)
Definition
SiTotalCharge.cxx:30
SiTotalCharge::chargeComposition
const list_t & chargeComposition() const
Definition
SiTotalCharge.h:123
SiTotalCharge::mainCharge
const SiCharge & mainCharge() const
Definition
SiTotalCharge.cxx:40
SiTotalCharge::removeSmallCharges
void removeSmallCharges(const double minimumCharge)
Definition
SiTotalCharge.cxx:98
SiTotalCharge::fromTrack
bool fromTrack() const
Definition
SiTotalCharge.cxx:49
SiTotalCharge::add
void add(const SiCharge &charge)
Definition
SiTotalCharge.cxx:62
SiTotalCharge::charge
double charge() const
Definition
SiTotalCharge.h:118
process
const std::string process
Definition
fbtTestBasics.cxx:76
std::remove_if
DataModel_detail::iterator< DVL > remove_if(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of remove_if for DataVector/List.
Definition
DVL_algorithms.h:70
Generated on
for ATLAS Offline Software by
1.17.0