ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
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 >
constgetAuxInfo (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. More...
 
MsgStream & msg () const
 Return a stream for sending messages directly (no decoration) More...
 
MsgStream & msg (const MSG::Level lvl) const
 Return a decorated starting stream for sending messages. More...
 
MSG::Level level () const
 Retrieve output level. More...
 
virtual void setLevel (MSG::Level lvl)
 Update outputlevel. More...
 

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. More...
 

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. More...
 
std::string m_nm
 Message source name. More...
 

Static Private Attributes

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

Detailed Description

Definition at line 32 of file TFCSSimulationState.h.

Member Typedef Documentation

◆ 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 }

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  };

◆ AddAuxInfoCleanup()

void TFCSSimulationState::AddAuxInfoCleanup ( const TFCSParametrizationBase para)

Definition at line 74 of file TFCSSimulationState.cxx.

75  {
76  m_AuxInfoCleanup.insert(para);
77 }

◆ 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 }

◆ 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()

static 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  }

◆ get_SF()

double TFCSSimulationState::get_SF ( )
inline

Definition at line 82 of file TFCSSimulationState.h.

82 { return getAuxInfo<double>("SF"_FCShash); }

◆ 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  }

◆ 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(); }

◆ 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 }

◆ 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 }

◆ 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) {
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 }

◆ 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.

47 { m_Ebin = bin; };

◆ 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); };

◆ setAuxInfo()

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

Definition at line 168 of file TFCSSimulationState.h.

168  {
169  m_AuxInfo[index].set<T>(val);
170  }

◆ 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  {
38  m_randomEngine = engine;
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 }

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:
TFCSSimulationState::fnv1a_32
static constexpr std::uint32_t fnv1a_32(char const *s, std::size_t count)
Definition: TFCSSimulationState.h:146
checkFileSG.line
line
Definition: checkFileSG.py:75
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
index
Definition: index.py:1
ISF_FCS::MLogging::level
MSG::Level level() const
Retrieve output level.
Definition: MLogging.h:201
TFCSSimulationState::Efrac
double Efrac(int sample) const
Definition: TFCSSimulationState.h:44
TFCSSimulationState::m_cells
Cellmap_t m_cells
Definition: TFCSSimulationState.h:111
TFCSSimulationState::randomEngine
CLHEP::HepRandomEngine * randomEngine()
Definition: TFCSSimulationState.h:36
TFCSSimulationState::m_randomEngine
CLHEP::HepRandomEngine * m_randomEngine
Definition: TFCSSimulationState.h:103
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
TFCSSimulationState::clear
void clear()
Definition: TFCSSimulationState.cxx:21
TFCSSimulationState::set_SF
void set_SF(double mysf)
Definition: TFCSSimulationState.h:81
CaloCell_ID_FCS::MaxSample
@ MaxSample
Definition: FastCaloSim_CaloCell_ID.h:47
ISF_FCS::MLogging::msg
MsgStream & msg() const
Return a stream for sending messages directly (no decoration)
Definition: MLogging.h:231
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:113
TrigConf::MSGTC::ALWAYS
@ ALWAYS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:29
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
ISF_FCS::MLogging::m_nm
std::string m_nm
Message source name.
Definition: MLogging.h:211
file
TFile * file
Definition: tile_monitor.h:29
TFCSSimulationState::m_E
double m_E[CaloCell_ID_FCS::MaxSample]
Definition: TFCSSimulationState.h:108
merge.output
output
Definition: merge.py:17
TFCSSimulationState::m_Ebin
int m_Ebin
Definition: TFCSSimulationState.h:105
TrigConf::MSGTC::NUM_LEVELS
@ NUM_LEVELS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:30
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
DeMoScan.index
string index
Definition: DeMoScan.py:364
a
TList * a
Definition: liststreamerinfos.cxx:10
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
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
CaloSampling::getSamplingName
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
Definition: Calorimeter/CaloGeoHelpers/Root/CaloSampling.cxx:18
TrigConf::MSGTC::NIL
@ NIL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:22
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35