ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
SG::WriteCondHandle< T > Class Template Reference

#include <WriteCondHandle.h>

Collaboration diagram for SG::WriteCondHandle< T >:

Public Types

typedef T * pointer_type
 
typedef const T * const_pointer_type
 
typedef T & reference_type
 
typedef const T & const_reference_type
 

Public Member Functions

 WriteCondHandle (const WriteCondHandleKey< T > &key)
 
 WriteCondHandle (const WriteCondHandleKey< T > &key, const EventContext &ctx)
 
 ~WriteCondHandle ()
 
const std::string & key () const
 
const DataObjID & fullKey () const
 
bool isValid () const
 
bool isValid (const EventIDBase &t) const
 
bool isValid (EventIDRange &range) const
 
bool isValid (const EventIDBase &t, EventIDRange &range) const
 
void addDependency (const EventIDRange &range)
 
template<typename R >
void addDependency (SG::ReadCondHandle< R > &rch)
 
template<typename R , typename... Args>
void addDependency (ReadCondHandle< R > &rch, Args... args)
 
StatusCode record (const EventIDRange &range, T *t)
 record handle, with explicit range DEPRECATED More...
 
StatusCode record (const EventIDRange &range, std::unique_ptr< T > t)
 
StatusCode record (std::unique_ptr< T > t)
 record handle, range must have been set by addDependency(...) More...
 
StatusCode record (T *t)
 
StatusCode extendLastRange (const EventIDRange &range, const EventContext &ctx=Gaudi::Hive::currentContext())
 Extend the range of the last IOV. More...
 
const std::string & dbKey () const
 
const EventIDRange & getRange () const
 

Private Attributes

const EventContext & m_ctx
 
CondCont< T > * m_cc {nullptr}
 
const SG::WriteCondHandleKey< T > & m_hkey
 
EventIDRange m_range {}
 
bool m_rangeSet {false}
 

Detailed Description

template<typename T>
class SG::WriteCondHandle< T >

Definition at line 26 of file WriteCondHandle.h.

Member Typedef Documentation

◆ const_pointer_type

template<typename T >
typedef const T* SG::WriteCondHandle< T >::const_pointer_type

Definition at line 30 of file WriteCondHandle.h.

◆ const_reference_type

template<typename T >
typedef const T& SG::WriteCondHandle< T >::const_reference_type

Definition at line 32 of file WriteCondHandle.h.

◆ pointer_type

template<typename T >
typedef T* SG::WriteCondHandle< T >::pointer_type

Definition at line 29 of file WriteCondHandle.h.

◆ reference_type

template<typename T >
typedef T& SG::WriteCondHandle< T >::reference_type

Definition at line 31 of file WriteCondHandle.h.

Constructor & Destructor Documentation

◆ WriteCondHandle() [1/2]

template<typename T >
SG::WriteCondHandle< T >::WriteCondHandle ( const WriteCondHandleKey< T > &  key)

Definition at line 105 of file WriteCondHandle.h.

105  :
106  WriteCondHandle( key, Gaudi::Hive::currentContext() ) {}

◆ WriteCondHandle() [2/2]

template<typename T >
SG::WriteCondHandle< T >::WriteCondHandle ( const WriteCondHandleKey< T > &  key,
const EventContext &  ctx 
)

Definition at line 111 of file WriteCondHandle.h.

112  :
113  m_ctx(ctx),
114  m_cc( key.getCC() ),
115  m_hkey(key)
116  {
117  if (m_cc == 0) {
118  MsgStream msg(Athena::getMessageSvc(), "WriteCondHandle");
119  msg << MSG::ERROR
120  << "WriteCondHandle : ptr to CondCont<T> is zero"
121  << endmsg;
122  }
123 
124  if (! m_hkey.isInit()) {
125  throw SG::ExcUninitKey (key.clid(), key.key(), key.storeHandle().name(),
126  "", "WriteCond");
127  }
128 
129  }

◆ ~WriteCondHandle()

template<typename T >
SG::WriteCondHandle< T >::~WriteCondHandle ( )
inline

Definition at line 38 of file WriteCondHandle.h.

38 {};

Member Function Documentation

◆ addDependency() [1/3]

template<typename T >
void SG::WriteCondHandle< T >::addDependency ( const EventIDRange &  range)

Definition at line 275 of file WriteCondHandle.h.

275  {
276  if ( !m_rangeSet ) {
277  m_range = range;
278  } else {
280  }
281  m_rangeSet = true;
282  using KeyType = CondContBase::KeyType;
283  if (m_cc->keyType()==KeyType::RUNLBN && (range.start().isTimeStamp() || range.stop().isTimeStamp())) {
284  MsgStream msg(Athena::getMessageSvc(), "WriteCondHandle");
285  msg << MSG::ERROR << "Adding a time-stamp dependency on a run-lumi indexed CondCont. Consider a mixed ConditionsContainer for type " << fullKey() << endmsg;
286  }
287  if (m_cc->keyType()==KeyType::TIMESTAMP && (range.start().isRunLumi() || range.stop().isRunLumi())) {
288  MsgStream msg(Athena::getMessageSvc(), "WriteCondHandle");
289  msg << MSG::ERROR << "Adding a run-lumi dependency on a timestamp-indexed CondCont. Consider a mixed ConditionsContainer for type " << fullKey() << endmsg;
290  }
291  }

◆ addDependency() [2/3]

template<typename T >
template<typename R , typename... Args>
void SG::WriteCondHandle< T >::addDependency ( ReadCondHandle< R > &  rch,
Args...  args 
)

Definition at line 306 of file WriteCondHandle.h.

306  {
307  addDependency( rch );
308  return addDependency( args... );
309  }

◆ addDependency() [3/3]

template<typename T >
template<typename R >
void SG::WriteCondHandle< T >::addDependency ( SG::ReadCondHandle< R > &  rch)

Definition at line 297 of file WriteCondHandle.h.

297  {
298  CondContBase* dep_cc = rch.getCC();
299  dep_cc->addDep (m_cc);
300  return addDependency(rch.getRange());
301  }

◆ dbKey()

template<typename T >
const std::string& SG::WriteCondHandle< T >::dbKey ( ) const
inline

Definition at line 87 of file WriteCondHandle.h.

87 { return m_hkey.dbKey(); }

◆ extendLastRange()

template<typename T >
StatusCode SG::WriteCondHandle< T >::extendLastRange ( const EventIDRange &  r,
const EventContext &  ctx = Gaudi::Hive::currentContext() 
)

Extend the range of the last IOV.

Parameters
rangeNew validity range.
ctxEvent context.

Returns failure if the start time of range does not match the start time of the last IOV in the container. Otherwise, the end time for the last IOV is changed to the end time for range. (If the end time for range is before the end of the last IOV, then nothing is changed.)

Definition at line 228 of file WriteCondHandle.h.

229  {
230  return m_cc->extendLastRange (r, ctx);
231  }

◆ fullKey()

template<typename T >
const DataObjID& SG::WriteCondHandle< T >::fullKey ( ) const
inline

Definition at line 41 of file WriteCondHandle.h.

41 { return m_hkey.fullKey(); }

◆ getRange()

template<typename T >
const EventIDRange& SG::WriteCondHandle< T >::getRange ( ) const
inline

Definition at line 89 of file WriteCondHandle.h.

89 { return m_range; }

◆ isValid() [1/4]

template<typename T >
bool SG::WriteCondHandle< T >::isValid

Definition at line 248 of file WriteCondHandle.h.

248  {
249 
250  return (m_cc->valid(m_ctx.eventID()));
251  }

◆ isValid() [2/4]

template<typename T >
bool SG::WriteCondHandle< T >::isValid ( const EventIDBase &  t) const

Definition at line 238 of file WriteCondHandle.h.

238  {
239 
240  return (m_cc->valid(t));
241  }

◆ isValid() [3/4]

template<typename T >
bool SG::WriteCondHandle< T >::isValid ( const EventIDBase &  t,
EventIDRange &  range 
) const

Definition at line 257 of file WriteCondHandle.h.

257  {
258 
259  return (m_cc->range(t, range));
260  }

◆ isValid() [4/4]

template<typename T >
bool SG::WriteCondHandle< T >::isValid ( EventIDRange &  range) const

Definition at line 267 of file WriteCondHandle.h.

267  {
268 
269  return (m_cc->range(m_ctx.eventID(), range));
270  }

◆ key()

template<typename T >
const std::string& SG::WriteCondHandle< T >::key ( ) const
inline

Definition at line 40 of file WriteCondHandle.h.

40 { return m_hkey.key(); }

◆ record() [1/4]

template<typename T >
StatusCode SG::WriteCondHandle< T >::record ( const EventIDRange &  range,
std::unique_ptr< T >  t 
)

Definition at line 136 of file WriteCondHandle.h.

137  {
138 
139  if (m_rangeSet) {
140  MsgStream msg(Athena::getMessageSvc(), "WriteCondHandle");
141  msg << MSG::ERROR
142  << "WriteCondHandle::record(EventIDRange, T*): for key "
143  << this->fullKey()
144  << " cannot use this method if range has already been set via dependencies"
145  << endmsg;
146  return StatusCode::FAILURE;
147  }
148 
149  m_range = r;
150  m_rangeSet = true;
151 
152  return record( std::move(t) );
153  }

◆ record() [2/4]

template<typename T >
StatusCode SG::WriteCondHandle< T >::record ( const EventIDRange &  range,
T *  t 
)

record handle, with explicit range DEPRECATED

Parameters
rangeIOVRange of handle
tunique_ptr to handle

Definition at line 157 of file WriteCondHandle.h.

158  {
159  return record (r, std::unique_ptr<T> (t));
160  }

◆ record() [3/4]

template<typename T >
StatusCode SG::WriteCondHandle< T >::record ( std::unique_ptr< T >  t)

record handle, range must have been set by addDependency(...)

Parameters
tunique_ptr to handle

Definition at line 170 of file WriteCondHandle.h.

170  {
171  if (! m_rangeSet) {
172  MsgStream msg(Athena::getMessageSvc(), "WriteCondHandle");
173  msg << MSG::ERROR
174  << "WriteCondHandle::record() : no range defined for key "
175  << this->fullKey()
176  << endmsg;
177  return StatusCode::FAILURE;
178  }
179 
180  #ifndef NDEBUG
181  MsgStream msg(Athena::getMessageSvc(), "WriteCondHandle");
182  if (msg.level() <= MSG::DEBUG) {
183  msg << MSG::DEBUG
184  << "WriteCondHandle::record() : obj at: " << t.get() << " range: "
185  << m_range << endmsg;
186  }
187  #endif
188 
189  StatusCode sc = m_cc->insert(m_range, std::move(t));
190  // Preserve sc for return, since it may be DUPLICATE.
191  if (sc.isFailure()) {
192  MsgStream msg(Athena::getMessageSvc(), "WriteCondHandle");
193  msg << MSG::ERROR
194  << "WriteCondHandle::record() : unable to insert obj in CondCont<T>"
195  << endmsg;
196  return StatusCode::FAILURE;
197  } else if (CondContBase::Category::isOverlap (sc)) {
198 #if 0
199  // Temporarily disable this check until caching issues with IOVDbSvc
200  // are sorted out.
201  MsgStream msg(Athena::getMessageSvc(), "WriteCondHandle");
202  msg << MSG::ERROR
203  << "WriteCondHandle::record() : IOV ranges overlap."
204  << endmsg;
205  return StatusCode::FAILURE;
206 #endif
207  sc = StatusCode::SUCCESS;
208  }
209 
210  return sc;
211  }

◆ record() [4/4]

template<typename T >
StatusCode SG::WriteCondHandle< T >::record ( T *  t)

Definition at line 164 of file WriteCondHandle.h.

164  {
165  return record (std::unique_ptr<T> (t));
166  }

Member Data Documentation

◆ m_cc

template<typename T >
CondCont<T>* SG::WriteCondHandle< T >::m_cc {nullptr}
private

Definition at line 94 of file WriteCondHandle.h.

◆ m_ctx

template<typename T >
const EventContext& SG::WriteCondHandle< T >::m_ctx
private

Definition at line 93 of file WriteCondHandle.h.

◆ m_hkey

template<typename T >
const SG::WriteCondHandleKey<T>& SG::WriteCondHandle< T >::m_hkey
private

Definition at line 96 of file WriteCondHandle.h.

◆ m_range

template<typename T >
EventIDRange SG::WriteCondHandle< T >::m_range {}
private

Definition at line 98 of file WriteCondHandle.h.

◆ m_rangeSet

template<typename T >
bool SG::WriteCondHandle< T >::m_rangeSet {false}
private

Definition at line 99 of file WriteCondHandle.h.


The documentation for this class was generated from the following file:
beamspotman.r
def r
Definition: beamspotman.py:676
SG::ReadCondHandle::getRange
const EventIDRange & getRange()
Definition: ReadCondHandle.h:241
SG::ReadCondHandle::getCC
CondCont< T > * getCC()
Definition: ReadCondHandle.h:77
CondContBase::KeyType
KeyType
Type of key used for this container.
Definition: CondCont.h:180
CondContBase::addDep
void addDep(CondContBase *dep)
Declare another conditions container that depends on this one.
Definition: CondCont.cxx:696
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::WriteCondHandle::m_range
EventIDRange m_range
Definition: WriteCondHandle.h:98
SG::WriteCondHandle::m_ctx
const EventContext & m_ctx
Definition: WriteCondHandle.h:93
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition: WriteCondHandle.h:41
SG::WriteCondHandle::m_cc
CondCont< T > * m_cc
Definition: WriteCondHandle.h:94
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CondContBase
Base class for all conditions containers.
Definition: CondCont.h:140
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
SG::WriteCondHandle::m_rangeSet
bool m_rangeSet
Definition: WriteCondHandle.h:99
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
SG::WriteCondHandle::WriteCondHandle
WriteCondHandle(const WriteCondHandleKey< T > &key)
Definition: WriteCondHandle.h:105
CondContBase::Category::isOverlap
static bool isOverlap(code_t code)
Helper to test whether a code is OVERLAP.
Definition: CondCont.cxx:242
SG::ExcUninitKey
Exception — Tried to create a handle from an uninitialized key.
Definition: Control/StoreGate/StoreGate/exceptions.h:111
Amg::intersect
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the closest approach of two lines.
Definition: GeoPrimitivesHelpers.h:302
DEBUG
#define DEBUG
Definition: page_access.h:11
SG::WriteCondHandle::m_hkey
const SG::WriteCondHandleKey< T > & m_hkey
Definition: WriteCondHandle.h:96
python.test_cfgItemList.msg
msg
Definition: test_cfgItemList.py:7
python.CaloScaleNoiseConfig.args
args
Definition: CaloScaleNoiseConfig.py:80
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275