ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
TgcDigitJitterData Class Reference

#include <TgcDigitJitterData.h>

Inheritance diagram for TgcDigitJitterData:
Collaboration diagram for TgcDigitJitterData:

Classes

struct  JitterBin
 

Public Member Functions

 TgcDigitJitterData ()
 
 ~TgcDigitJitterData ()=default
 
double drawJitter (const Amg::Vector3D &localDir, CLHEP::HepRandomEngine *rndmEngine) const
 
void cacheAngleInterval (const double minAngle, std::vector< double > &&timeProbs)
 
StatusCode initialize ()
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

std::vector< JitterBinm_bins {}
 
double m_timeInterval {-1.}
 
double m_angleInterval {-1.}
 
std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

Detailed Description

Definition at line 24 of file TgcDigitJitterData.h.

Constructor & Destructor Documentation

◆ TgcDigitJitterData()

TgcDigitJitterData::TgcDigitJitterData ( )

Definition at line 11 of file TgcDigitJitterData.cxx.

11  :
12  AthMessaging{"TgcDigitJitterData"} {}

◆ ~TgcDigitJitterData()

TgcDigitJitterData::~TgcDigitJitterData ( )
default

Member Function Documentation

◆ cacheAngleInterval()

void TgcDigitJitterData::cacheAngleInterval ( const double  minAngle,
std::vector< double > &&  timeProbs 
)

Definition at line 41 of file TgcDigitJitterData.cxx.

41  {
42  m_bins.emplace_back(minAngle, std::move(timeProbs));
43 }

◆ drawJitter()

double TgcDigitJitterData::drawJitter ( const Amg::Vector3D localDir,
CLHEP::HepRandomEngine *  rndmEngine 
) const

Definition at line 14 of file TgcDigitJitterData.cxx.

15  {
16  const double injectionAngle = std::atan2(std::abs(localDir.z()), std::abs(localDir.x())) / Gaudi::Units::deg;
17 
18  const size_t ithAngle = std::min(static_cast<size_t>(injectionAngle / m_angleInterval), m_bins.size() - 1);
19  const size_t jthAngle = std::min(ithAngle + 1, m_bins.size() -1);
20  ATH_MSG_DEBUG("Direction "<<Amg::toString(localDir)<<", injection angle: "<<injectionAngle
21  <<", bin i: "<<ithAngle<<", bin j: "<<jthAngle);
22  const double wAngle = std::fmod(injectionAngle, m_angleInterval);
23 
24  double jitter{0.}, prob{1.}, probRef{0.};
25  const std::vector<double>& ith_probs{m_bins[ithAngle].timeProbs};
26  const std::vector<double>& jth_probs{m_bins[jthAngle].timeProbs};
27  unsigned int trials{0};
28  while (prob > probRef) {
29  prob = CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0);
30  jitter = CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0) * m_timeInterval;
31  size_t ithJitter = static_cast<size_t>(jitter);
32  // probability distribution calculated from weighted sum between
33  // neighboring bins of angles
34  probRef = (1. - wAngle) * (ithJitter < ith_probs.size() ? ith_probs[ithJitter] : 0.) +
35  wAngle * (ithJitter < jth_probs.size() ? jth_probs[ithJitter] : 0.);
36  ATH_MSG_VERBOSE("Trial: "<<(++trials)<<" jitter: "<<jitter<<", prob: "<<prob
37  <<", probRef: "<<probRef);
38  }
39  return jitter;
40 }

◆ initialize()

StatusCode TgcDigitJitterData::initialize ( )

Definition at line 44 of file TgcDigitJitterData.cxx.

44  {
45  if (m_bins.empty()) {
46  ATH_MSG_FATAL("No jitter bins were defined.");
47  return StatusCode::FAILURE;
48  }
49  std::sort(m_bins.begin(), m_bins.end());
50  for (size_t b = 0 ; b < m_bins.size() - 1; ++b) {
51  m_bins[b].maxAngle = m_bins[b+1].minAngle;
52  if (b == 0) {
53  m_angleInterval = m_bins[b].maxAngle - m_bins[b].minAngle;
54  } else if (std::abs(m_bins[b].maxAngle - m_bins[b].minAngle - m_angleInterval) >
55  std::numeric_limits<double>::epsilon()) {
56  ATH_MSG_FATAL("The angular bin "<<b<<" ranging from "<<m_bins[b].minAngle
57  <<" to "<<m_bins[b].maxAngle<<" is outside of the fixed interval "
58  <<m_angleInterval<<". Only fixed bin size is supported");
59  return StatusCode::FAILURE;
60  }
61  if (m_bins[b].timeProbs.empty()) {
62  ATH_MSG_FATAL("The angular bin "<<b<<" has no probabilities associated.");
63  return StatusCode::FAILURE;
64  }
65  m_timeInterval = std::max(m_timeInterval, -1. + m_bins[b].timeProbs.size());
66  }
67  return StatusCode::SUCCESS;
68 }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40 {
42  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152 {
153  if (!m_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level  lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29 {
30  m_lvl = lvl;
31 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_angleInterval

double TgcDigitJitterData::m_angleInterval {-1.}
private

Definition at line 51 of file TgcDigitJitterData.h.

◆ m_bins

std::vector<JitterBin> TgcDigitJitterData::m_bins {}
private

Definition at line 48 of file TgcDigitJitterData.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

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

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_timeInterval

double TgcDigitJitterData::m_timeInterval {-1.}
private

Definition at line 50 of file TgcDigitJitterData.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
TgcDigitJitterData::m_timeInterval
double m_timeInterval
Definition: TgcDigitJitterData.h:50
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
max
#define max(a, b)
Definition: cfImp.cxx:41
deg
#define deg
Definition: SbPolyhedron.cxx:17
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
covarianceTool.prob
prob
Definition: covarianceTool.py:678
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
min
#define min(a, b)
Definition: cfImp.cxx:40
TgcDigitJitterData::m_bins
std::vector< JitterBin > m_bins
Definition: TgcDigitJitterData.h:48
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
TgcDigitJitterData::m_angleInterval
double m_angleInterval
Definition: TgcDigitJitterData.h:51
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132