ATLAS Offline Software
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 
15 #include <iterator>
16 
17 // Implicit constructor:
19  m_charge(0),
20  m_chargeComposition()
21 {}
22 
23 // Copy constructor:
25  m_charge(totalCharge.m_charge),
26  m_chargeComposition(totalCharge.m_chargeComposition)
27 {}
28 
29 // Assignment operator:
31 {
32  if (this!=&totalCharge) {
33  m_charge=totalCharge.m_charge;
35  } else {}
36  return *this;
37 }
38 
39 // give main single process charge:
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 
50 {
51  if(m_chargeComposition.empty())
52  {
53  return false;
54  }
56  return (process==SiCharge::track ||
59 }
60 
61 // add another charge:
63 {
64  // increase the total deposited charge
65  m_charge+=charge.charge();
66  // add the SiCharge to the list of charges
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:
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):
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 
SiTotalCharge::addSiCharge
void addSiCharge(const SiCharge &charge)
Definition: SiTotalCharge.cxx:108
SiTotalCharge.h
SiCharge::track
@ track
Definition: SiCharge.h:28
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
SiTotalCharge::charge
double charge() const
Definition: SiTotalCharge.h:118
SiCharge
Definition: SiCharge.h:25
SiCharge::diodeX_Talk
@ diodeX_Talk
Definition: SiCharge.h:28
operator<<
std::ostream & operator<<(std::ostream &out, const SiTotalCharge &totalCharge)
Definition: SiTotalCharge.cxx:124
SiTotalCharge::list_t
std::vector< SiCharge > list_t
Definition: SiTotalCharge.h:31
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
SiTotalCharge::m_chargeComposition
list_t m_chargeComposition
Definition: SiTotalCharge.h:107
SiTotalCharge::fromTrack
bool fromTrack() const
Definition: SiTotalCharge.cxx:49
SiTotalCharge::chargeComposition
const list_t & chargeComposition() const
Definition: SiTotalCharge.h:123
SiCharge::processType
Process processType() const
Definition: SiCharge.h:119
SiTotalCharge::add
void add(const SiCharge &charge)
Definition: SiTotalCharge.cxx:62
SiTotalCharge::SiTotalCharge
SiTotalCharge()
Definition: SiTotalCharge.cxx:18
SiTotalCharge::m_emptyLink
static const HepMcParticleLink m_emptyLink
Definition: SiTotalCharge.h:108
charge
double charge(const T &p)
Definition: AtlasPID.h:538
SiCharge::Process
Process
Definition: SiCharge.h:28
SiTotalCharge::m_charge
double m_charge
Definition: SiTotalCharge.h:106
SiTotalCharge::mainCharge
const SiCharge & mainCharge() const
Definition: SiTotalCharge.cxx:40
SiCharge::cut_track
@ cut_track
Definition: SiCharge.h:28
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SiTotalCharge
Definition: SiTotalCharge.h:24
SiTotalCharge::operator=
SiTotalCharge & operator=(const SiTotalCharge &totalCharge)
Definition: SiTotalCharge.cxx:30
SiTotalCharge::removeSmallCharges
void removeSmallCharges(const double minimumCharge)
Definition: SiTotalCharge.cxx:98
SiTotalCharge::removeTimeInformation
void removeTimeInformation()
Definition: SiTotalCharge.cxx:83
calibdata.copy
bool copy
Definition: calibdata.py:27
python.compressB64.c
def c
Definition: compressB64.py:93