ATLAS Offline Software
TFCSSimulationState.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "CLHEP/Random/RandomEngine.h"
6 
9 #include <iostream>
10 #include <cstring>
11 
12 //=============================================
13 //======= TFCSSimulationState =========
14 //=============================================
15 
16 TFCSSimulationState::TFCSSimulationState(CLHEP::HepRandomEngine *randomEngine)
17  : m_randomEngine(randomEngine) {
18  clear();
19 }
20 
22  set_SF(1);
23  m_Ebin = -1;
24  m_Etot = 0;
25  for (int i = 0; i < CaloCell_ID_FCS::MaxSample; ++i) {
26  m_E[i] = 0;
27  m_Efrac[i] = 0;
28  }
29 }
30 
31 void TFCSSimulationState::deposit(const CaloDetDescrElement *cellele, float E) {
32  auto mele = m_cells.find(cellele);
33  if (mele == m_cells.end()) {
34  m_cells.emplace(cellele, 0);
35  mele = m_cells.find(cellele);
36  }
37  m_cells[cellele] += E;
38 }
39 
40 void TFCSSimulationState::Print(Option_t *) const {
41  ATH_MSG_INFO("Ebin=" << m_Ebin << " E=" << E()
42  << " #cells=" << m_cells.size());
43  for (int i = 0; i < CaloCell_ID_FCS::MaxSample; ++i)
44  if (E(i) != 0) {
46  << ")=" << E(i) << " E" << i << "/E=" << Efrac(i));
47  }
48  if (!m_AuxInfo.empty()) {
49  ATH_MSG_INFO(" AuxInfo has " << m_AuxInfo.size() << " elements");
50  for (const auto &a : m_AuxInfo) {
51  ATH_MSG_INFO(" " << a.first << " : "
52  // Dont print as char/bool.
53  // Accessing as a bool is likely to undefined
54  // behavior (which triggers a warning from
55  // the sanitizer). As a char, it may not
56  // be printable.
57  //<< "bool=" << a.second.b
58  //<< " char=" << a.second.c
59  << " int=" << a.second.i
60  << " float=" << a.second.f << " double=" << a.second.d
61  << " void*=" << a.second.p);
62  }
63  }
64 }
65 
67  return TFCSSimulationState::fnv1a_32(s.c_str(), s.size());
68 }
69 
71  return TFCSSimulationState::fnv1a_32(s, std::strlen(s));
72 }
73 
75  const TFCSParametrizationBase *para) {
76  m_AuxInfoCleanup.insert(para);
77 }
78 
80  for (const auto *para : m_AuxInfoCleanup) {
81  para->CleanAuxInfo(*this);
82  }
83 }
TFCSSimulationState::fnv1a_32
static constexpr std::uint32_t fnv1a_32(char const *s, std::size_t count)
Definition: TFCSSimulationState.h:146
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
TFCSSimulationState::DoAuxInfoCleanup
void DoAuxInfoCleanup()
Definition: TFCSSimulationState.cxx:79
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TFCSSimulationState::Efrac
double Efrac(int sample) const
Definition: TFCSSimulationState.h:44
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
TFCSSimulationState::m_cells
Cellmap_t m_cells
Definition: TFCSSimulationState.h:111
TFCSSimulationState::getAuxIndex
static std::uint32_t getAuxIndex(const std::string &s)
Definition: TFCSSimulationState.cxx:66
TFCSSimulationState::clear
void clear()
Definition: TFCSSimulationState.cxx:21
TFCSParametrizationBase.h
TFCSParametrizationBase
Definition: TFCSParametrizationBase.h:46
TFCSSimulationState::set_SF
void set_SF(double mysf)
Definition: TFCSSimulationState.h:81
CaloCell_ID_FCS::MaxSample
@ MaxSample
Definition: FastCaloSim_CaloCell_ID.h:47
lumiFormat.i
int i
Definition: lumiFormat.py:85
TFCSSimulationState::m_Etot
double m_Etot
Definition: TFCSSimulationState.h:106
TFCSSimulationState::m_AuxInfoCleanup
std::set< const TFCSParametrizationBase * > m_AuxInfoCleanup
Do not persistify.
Definition: TFCSSimulationState.h:178
TFCSSimulationState::deposit
void deposit(const CaloDetDescrElement *cellele, float E)
Definition: TFCSSimulationState.cxx:31
TFCSSimulationState::Print
void Print(Option_t *option="") const
Definition: TFCSSimulationState.cxx:40
TFCSSimulationState::TFCSSimulationState
TFCSSimulationState(CLHEP::HepRandomEngine *randomEngine=nullptr)
Definition: TFCSSimulationState.cxx:16
TFCSSimulationState::m_E
double m_E[CaloCell_ID_FCS::MaxSample]
Definition: TFCSSimulationState.h:108
TFCSSimulationState::m_Ebin
int m_Ebin
Definition: TFCSSimulationState.h:105
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
a
TList * a
Definition: liststreamerinfos.cxx:10
TFCSSimulationState::AddAuxInfoCleanup
void AddAuxInfoCleanup(const TFCSParametrizationBase *para)
Definition: TFCSSimulationState.cxx:74
TFCSSimulationState::m_Efrac
double m_Efrac[CaloCell_ID_FCS::MaxSample]
Definition: TFCSSimulationState.h:109
TFCSSimulationState::E
double E() const
Definition: TFCSSimulationState.h:42
TFCSSimulationState::m_AuxInfo
std::unordered_map< std::uint32_t, AuxInfo_t > m_AuxInfo
Definition: TFCSSimulationState.h:176
TFCSSimulationState.h
CaloSampling::getSamplingName
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
Definition: Calorimeter/CaloGeoHelpers/Root/CaloSampling.cxx:18