ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSSimulationState Class Reference

#include <TFCSSimulationState.h>

Inheritance diagram for TFCSSimulationState:
Collaboration diagram for TFCSSimulationState:

Classes

union  AuxInfo_t

Public Types

typedef std::map< const CaloDetDescrElement *, float > Cellmap_t

Public Member Functions

 TFCSSimulationState (CLHEP::HepRandomEngine *randomEngine=nullptr)
CLHEP::HepRandomEngine * randomEngine ()
void setRandomEngine (CLHEP::HepRandomEngine *engine)
bool is_valid () const
double E () const
double E (int sample) const
double Efrac (int sample) const
int Ebin () const
void set_Ebin (int bin)
void set_E (int sample, double Esample)
void set_Efrac (int sample, double Efracsample)
void set_E (double E)
void add_E (int sample, double Esample)
Cellmap_tcells ()
const Cellmap_tcells () const
void deposit (const CaloDetDescrElement *cellele, float E)
void Print (Option_t *option="") const
void set_SF (double mysf)
double get_SF ()
void clear ()
bool hasAuxInfo (std::uint32_t index) const
template<class T>
const T getAuxInfo (std::uint32_t index) const
template<class T>
void setAuxInfo (std::uint32_t index, const T &val)
void AddAuxInfoCleanup (const TFCSParametrizationBase *para)
void DoAuxInfoCleanup ()
bool msgLvl (const MSG::Level lvl) const
 Check whether the logging system is active at the provided verbosity level.
MsgStream & msg () const
 Return a stream for sending messages directly (no decoration)
MsgStream & msg (const MSG::Level lvl) const
 Return a decorated starting stream for sending messages.
MSG::Level level () const
 Retrieve output level.
virtual void setLevel (MSG::Level lvl)
 Update outputlevel.

Static Public Member Functions

static constexpr std::uint32_t fnv1a_32 (char const *s, std::size_t count)
static std::uint32_t getAuxIndex (const std::string &s)
static std::uint32_t getAuxIndex (const char *s)
static std::string startMsg (MSG::Level lvl, const std::string &file, int line)
 Make a message to decorate the start of logging.

Private Attributes

CLHEP::HepRandomEngine * m_randomEngine
int m_Ebin
double m_Etot
double m_E [CaloCell_ID_FCS::MaxSample]
double m_Efrac [CaloCell_ID_FCS::MaxSample]
Cellmap_t m_cells
std::unordered_map< std::uint32_t, AuxInfo_tm_AuxInfo
std::set< const TFCSParametrizationBase * > m_AuxInfoCleanup
 Do not persistify.
std::string m_nm
 Message source name.

Static Private Attributes

static boost::thread_specific_ptr< MsgStream > m_msg_tls ATLAS_THREAD_SAFE
 Do not persistify!

Detailed Description

Definition at line 32 of file TFCSSimulationState.h.

Member Typedef Documentation

◆ Cellmap_t

typedef std::map<const CaloDetDescrElement *, float> TFCSSimulationState::Cellmap_t

Definition at line 69 of file TFCSSimulationState.h.

Constructor & Destructor Documentation

◆ TFCSSimulationState()

TFCSSimulationState::TFCSSimulationState ( CLHEP::HepRandomEngine * randomEngine = nullptr)

Definition at line 16 of file TFCSSimulationState.cxx.

18 clear();
19}
CLHEP::HepRandomEngine * m_randomEngine
CLHEP::HepRandomEngine * randomEngine()

Member Function Documentation

◆ add_E()

void TFCSSimulationState::add_E ( int sample,
double Esample )
inline

Definition at line 53 of file TFCSSimulationState.h.

53 {
54 m_E[sample] += Esample;
55 m_Etot += Esample;
56 };
double m_E[CaloCell_ID_FCS::MaxSample]

◆ AddAuxInfoCleanup()

void TFCSSimulationState::AddAuxInfoCleanup ( const TFCSParametrizationBase * para)

Definition at line 74 of file TFCSSimulationState.cxx.

75 {
76 m_AuxInfoCleanup.insert(para);
77}
std::set< const TFCSParametrizationBase * > m_AuxInfoCleanup
Do not persistify.

◆ cells() [1/2]

Cellmap_t & TFCSSimulationState::cells ( )
inline

Definition at line 72 of file TFCSSimulationState.h.

72{ return m_cells; };

◆ cells() [2/2]

const Cellmap_t & TFCSSimulationState::cells ( ) const
inline

Definition at line 73 of file TFCSSimulationState.h.

73{ return m_cells; };

◆ clear()

void TFCSSimulationState::clear ( )

Definition at line 21 of file TFCSSimulationState.cxx.

21 {
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}
void set_SF(double mysf)
double m_Efrac[CaloCell_ID_FCS::MaxSample]

◆ deposit()

void TFCSSimulationState::deposit ( const CaloDetDescrElement * cellele,
float E )

Definition at line 31 of file TFCSSimulationState.cxx.

31 {
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}

◆ DoAuxInfoCleanup()

void TFCSSimulationState::DoAuxInfoCleanup ( )

Definition at line 79 of file TFCSSimulationState.cxx.

79 {
80 for (const auto *para : m_AuxInfoCleanup) {
81 para->CleanAuxInfo(*this);
82 }
83}

◆ E() [1/2]

double TFCSSimulationState::E ( ) const
inline

Definition at line 42 of file TFCSSimulationState.h.

42{ return m_Etot; };

◆ E() [2/2]

double TFCSSimulationState::E ( int sample) const
inline

Definition at line 43 of file TFCSSimulationState.h.

43{ return m_E[sample]; };

◆ Ebin()

int TFCSSimulationState::Ebin ( ) const
inline

Definition at line 45 of file TFCSSimulationState.h.

45{ return m_Ebin; };

◆ Efrac()

double TFCSSimulationState::Efrac ( int sample) const
inline

Definition at line 44 of file TFCSSimulationState.h.

44{ return m_Efrac[sample]; };

◆ fnv1a_32()

constexpr std::uint32_t TFCSSimulationState::fnv1a_32 ( char const * s,
std::size_t count )
inlinestaticconstexpr

Definition at line 146 of file TFCSSimulationState.h.

146 {
147 return ((count ? fnv1a_32(s, count - 1) : 2166136261u) ^ s[count]) *
148 16777619u;
149 }
static constexpr std::uint32_t fnv1a_32(char const *s, std::size_t count)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146

◆ get_SF()

double TFCSSimulationState::get_SF ( )
inline

Definition at line 82 of file TFCSSimulationState.h.

82{ return getAuxInfo<double>("SF"_FCShash); }
const T getAuxInfo(std::uint32_t index) const

◆ getAuxIndex() [1/2]

std::uint32_t TFCSSimulationState::getAuxIndex ( const char * s)
static

Definition at line 70 of file TFCSSimulationState.cxx.

70 {
71 return TFCSSimulationState::fnv1a_32(s, std::strlen(s));
72}

◆ getAuxIndex() [2/2]

std::uint32_t TFCSSimulationState::getAuxIndex ( const std::string & s)
static

Definition at line 66 of file TFCSSimulationState.cxx.

66 {
67 return TFCSSimulationState::fnv1a_32(s.c_str(), s.size());
68}

◆ getAuxInfo()

template<class T>
const T TFCSSimulationState::getAuxInfo ( std::uint32_t index) const
inline

Definition at line 161 of file TFCSSimulationState.h.

161 {
162 return static_cast<T>(m_AuxInfo.at(index));
163 }
std::unordered_map< std::uint32_t, AuxInfo_t > m_AuxInfo
unsigned long long T

◆ hasAuxInfo()

bool TFCSSimulationState::hasAuxInfo ( std::uint32_t index) const
inline

Definition at line 155 of file TFCSSimulationState.h.

155 {
156 return m_AuxInfo.find(index) != m_AuxInfo.end();
157 };

◆ is_valid()

bool TFCSSimulationState::is_valid ( ) const
inline

Definition at line 41 of file TFCSSimulationState.h.

41{ return m_Ebin >= 0; };

◆ level()

MSG::Level ISF_FCS::MLogging::level ( ) const
inlineinherited

Retrieve output level.

Definition at line 201 of file MLogging.h.

201{ return msg().level(); }
MsgStream & msg() const
Return a stream for sending messages directly (no decoration)
Definition MLogging.h:231

◆ msg() [1/2]

MsgStream & ISF_FCS::MLogging::msg ( ) const
inlineinherited

Return a stream for sending messages directly (no decoration)

Definition at line 231 of file MLogging.h.

231 {
232 MsgStream *ms = m_msg_tls.get();
233 if (!ms) {
234 ms = new MsgStream(Athena::getMessageSvc(), m_nm);
235 m_msg_tls.reset(ms);
236 }
237 return *ms;
238}
std::string m_nm
Message source name.
Definition MLogging.h:211
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [2/2]

MsgStream & ISF_FCS::MLogging::msg ( const MSG::Level lvl) const
inlineinherited

Return a decorated starting stream for sending messages.

Definition at line 240 of file MLogging.h.

240 {
241 return msg() << lvl;
242}

◆ msgLvl()

bool ISF_FCS::MLogging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Check whether the logging system is active at the provided verbosity level.

Definition at line 222 of file MLogging.h.

222 {
223 if (msg().level() <= lvl) {
224 msg() << lvl;
225 return true;
226 } else {
227 return false;
228 }
229}
MSG::Level level() const
Retrieve output level.
Definition MLogging.h:201

◆ Print()

void TFCSSimulationState::Print ( Option_t * option = "") const

Definition at line 40 of file TFCSSimulationState.cxx.

40 {
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) {
45 ATH_MSG_INFO(" E" << i << "(" << CaloSampling::getSamplingName(i)
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}
#define ATH_MSG_INFO(x)
static Double_t a
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
double Efrac(int sample) const

◆ randomEngine()

CLHEP::HepRandomEngine * TFCSSimulationState::randomEngine ( )
inline

Definition at line 36 of file TFCSSimulationState.h.

36{ return m_randomEngine; }

◆ set_E() [1/2]

void TFCSSimulationState::set_E ( double E)
inline

Definition at line 52 of file TFCSSimulationState.h.

52{ m_Etot = E; };

◆ set_E() [2/2]

void TFCSSimulationState::set_E ( int sample,
double Esample )
inline

Definition at line 48 of file TFCSSimulationState.h.

48{ m_E[sample] = Esample; };

◆ set_Ebin()

void TFCSSimulationState::set_Ebin ( int bin)
inline

Definition at line 47 of file TFCSSimulationState.h.

◆ set_Efrac()

void TFCSSimulationState::set_Efrac ( int sample,
double Efracsample )
inline

Definition at line 49 of file TFCSSimulationState.h.

49 {
50 m_Efrac[sample] = Efracsample;
51 };

◆ set_SF()

void TFCSSimulationState::set_SF ( double mysf)
inline

Definition at line 81 of file TFCSSimulationState.h.

81{ setAuxInfo<double>("SF"_FCShash, mysf); };
void setAuxInfo(std::uint32_t index, const T &val)

◆ setAuxInfo()

template<class T>
void TFCSSimulationState::setAuxInfo ( std::uint32_t index,
const T & val )
inline

Definition at line 168 of file TFCSSimulationState.h.

◆ setLevel()

void ISF_FCS::MLogging::setLevel ( MSG::Level lvl)
virtualinherited

Update outputlevel.

Definition at line 105 of file MLogging.cxx.

105 {
106 lvl = (lvl >= MSG::NUM_LEVELS) ? MSG::ALWAYS
107 : (lvl < MSG::NIL) ? MSG::NIL
108 : lvl;
109 msg().setLevel(lvl);
110}

◆ setRandomEngine()

void TFCSSimulationState::setRandomEngine ( CLHEP::HepRandomEngine * engine)
inline

Definition at line 37 of file TFCSSimulationState.h.

37 {
39 }

◆ startMsg()

std::string ISF_FCS::MLogging::startMsg ( MSG::Level lvl,
const std::string & file,
int line )
staticinherited

Make a message to decorate the start of logging.

Print a message for the start of logging.

Definition at line 116 of file MLogging.cxx.

116 {
117 int col1_len = 20;
118 int col2_len = 5;
119 int col3_len = 10;
120 auto last_slash = file.find_last_of('/');
121 int path_len = last_slash == std::string::npos ? 0 : last_slash;
122 int trim_point = path_len;
123 int total_len = file.length();
124 if (total_len - path_len > col1_len)
125 trim_point = total_len - col1_len;
126 std::string trimmed_name = file.substr(trim_point);
127 const char *LevelNames[MSG::NUM_LEVELS] = {
128 "NIL", "VERBOSE", "DEBUG", "INFO", "WARNING", "ERROR", "FATAL", "ALWAYS"};
129 std::string level = LevelNames[lvl];
130 std::string level_string = std::string("(") + level + ") ";
131 std::stringstream output;
132 output << std::setw(col1_len) << std::right << trimmed_name << ":"
133 << std::setw(col2_len) << std::left << line << std::setw(col3_len)
134 << std::right << level_string;
135 return output.str();
136}
output
Definition merge.py:16
TFile * file

Member Data Documentation

◆ ATLAS_THREAD_SAFE

boost::thread_specific_ptr<MsgStream> m_msg_tls ISF_FCS::MLogging::ATLAS_THREAD_SAFE
inlinestaticprivateinherited

Do not persistify!

MsgStream instance (a std::cout like with print-out levels)

Definition at line 215 of file MLogging.h.

◆ m_AuxInfo

std::unordered_map<std::uint32_t, AuxInfo_t> TFCSSimulationState::m_AuxInfo
private

Definition at line 176 of file TFCSSimulationState.h.

◆ m_AuxInfoCleanup

std::set<const TFCSParametrizationBase *> TFCSSimulationState::m_AuxInfoCleanup
private

Do not persistify.

Definition at line 178 of file TFCSSimulationState.h.

◆ m_cells

Cellmap_t TFCSSimulationState::m_cells
private

Definition at line 111 of file TFCSSimulationState.h.

◆ m_E

double TFCSSimulationState::m_E[CaloCell_ID_FCS::MaxSample]
private

Definition at line 108 of file TFCSSimulationState.h.

◆ m_Ebin

int TFCSSimulationState::m_Ebin
private

Definition at line 105 of file TFCSSimulationState.h.

◆ m_Efrac

double TFCSSimulationState::m_Efrac[CaloCell_ID_FCS::MaxSample]
private

Definition at line 109 of file TFCSSimulationState.h.

◆ m_Etot

double TFCSSimulationState::m_Etot
private

Definition at line 106 of file TFCSSimulationState.h.

◆ m_nm

std::string ISF_FCS::MLogging::m_nm
privateinherited

Message source name.

Definition at line 211 of file MLogging.h.

◆ m_randomEngine

CLHEP::HepRandomEngine* TFCSSimulationState::m_randomEngine
private

Definition at line 103 of file TFCSSimulationState.h.


The documentation for this class was generated from the following files: