ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
AthenaBarCodeBase Class Reference

#include <AthenaBarCodeBase.h>

Inheritance diagram for AthenaBarCodeBase:
Collaboration diagram for AthenaBarCodeBase:

Public Member Functions

virtual AthenaBarCode_t getAthenaBarCode () const
 
virtual void setAthenaBarCode (AthenaBarCode_t id)
 
virtual bool hasSameAthenaBarCode (const IAthenaBarCode &obj) const
 
virtual bool hasSameAthenaBarCodeExceptVersion (const IAthenaBarCode &obj) const
 
virtual AthenaBarCodeVersion_t getVersion () const
 
virtual void newVersion ()
 
virtual void setVersion (AthenaBarCodeVersion_t newversion)
 
std::ostream & dump (std::ostream &out) const
 
bool createdInCurrentJob () const
 
AthenaBarCode_t getReserveBits () const
 
void setReserveBits (AthenaBarCode_t id)
 

Static Public Member Functions

static void setDefaultHash (const char *jobid)
 

Static Public Attributes

static const unsigned short TotalBits = 64
 
static const unsigned short UUIDBits = 32
 
static const unsigned short CounterBits = 26
 
static const unsigned short VersionBits = 4
 
static const unsigned short ReserveBits = 2
 
static const unsigned short SUUIDBits = 0
 
static const unsigned short SCounterBits = UUIDBits
 
static const unsigned short SVersionBits = UUIDBits+CounterBits
 
static const unsigned short SReserveBits = UUIDBits+CounterBits+VersionBits
 
static const AthenaBarCode_t UNDEFINEDBARCODE = (AthenaBarCode_t)(-1)
 
static const AthenaBarCode_t UNDEFINEDVERSION = UNDEFINEDBARCODE
 

Protected Member Functions

void setBits (unsigned short startbit, unsigned short nbits, AthenaBarCode_t id, AthenaBarCode_t &bc) const
 
AthenaBarCode_t getBits (unsigned short startbit, unsigned short nbits) const
 
void initABC () const
 

Private Member Functions

AthenaBarCode_t combineWithUUIDHash (const AthenaBarCode_t &) const
 
void setUUIDHash (AthenaBarCode_t uuidhash)
 
AthenaBarCode_t hasUUIDHash () const
 
AthenaBarCode_t getUUIDHash () const
 

Static Private Member Functions

static AthenaBarCode_t hashUUID (const char *)
 
static AthenaBarCode_t getDefaultHash (const char *jobid=nullptr)
 
static AthenaBarCode_t makeDefaultHash (const char *jobid)
 

Private Attributes

std::atomic< AthenaBarCode_tm_barcode
 

Static Private Attributes

static std::atomic< AthenaBarCode_tm_barcodeCounter = 0
 

Detailed Description

Definition at line 26 of file AthenaBarCodeBase.h.

Member Function Documentation

◆ combineWithUUIDHash()

AthenaBarCode_t AthenaBarCodeImpl::combineWithUUIDHash ( const AthenaBarCode_t hash) const
inlineprivateinherited

Definition at line 119 of file AthenaBarCodeImpl.h.

120  {
121 
122  AthenaBarCode_t tmp = 0;
123  AthenaBarCode_t lowerh = ~tmp >> (TotalBits
124  - UUIDBits);
125  AthenaBarCode_t higherh = ~tmp << (UUIDBits);
126 
127  AthenaBarCode_t lower = m_barcode & lowerh;
128  AthenaBarCode_t higher = hash & higherh;
129 
130  /*
131  std::cout << "AthenaBarCodeImpl::combineWithHash::hash=" << std::hex
132  << hash << " lower=" << lower << " higher=" << higher << " lowerh="
133  << lowerh << " higherh=" << higherh << " barcode=" << (lower
134  | higher) << std::endl;
135  */
136  return lower | higher;
137 
138 }

◆ createdInCurrentJob()

bool AthenaBarCodeImpl::createdInCurrentJob ( ) const
inherited

Definition at line 181 of file AthenaBarCodeImpl.cxx.

181  {
183  initABC();
184 
185  //FIXME: it is possible that m_defaultHash is not yet initialized.
186  return getUUIDHash() == getDefaultHash();
187 }

◆ dump()

std::ostream & AthenaBarCodeImpl::dump ( std::ostream &  out) const
inherited

Definition at line 172 of file AthenaBarCodeImpl.cxx.

172  {
174  initABC();
175 
176  out << "\n[AthenaBarCode]= " << std::hex << (m_barcode) << std::dec << std::endl;
177  return out;
178 }

◆ getAthenaBarCode()

AthenaBarCode_t AthenaBarCodeBase::getAthenaBarCode ( ) const
virtual

Reimplemented from IAthenaBarCode.

Definition at line 22 of file AthenaBarCodeBase.cxx.

23 {
25 }

◆ getBits()

AthenaBarCode_t AthenaBarCodeImpl::getBits ( unsigned short  startbit,
unsigned short  nbits 
) const
protectedinherited

Definition at line 249 of file AthenaBarCodeImpl.cxx.

249  {
250 
252  //now m_barcode=aaaaaxxaa;
253  tmp = m_barcode << (startbit); //tmp=xxaa00000;
254  tmp = tmp >> (TotalBits - nbits); //tmp=0000000xx
255 
256  return tmp;
257 }

◆ getDefaultHash()

AthenaBarCode_t AthenaBarCodeImpl::getDefaultHash ( const char *  jobid = nullptr)
staticprivateinherited

Definition at line 304 of file AthenaBarCodeImpl.cxx.

305 {
306  static const AthenaBarCode_t defaultHash = makeDefaultHash (jobid);
307  return defaultHash;
308 }

◆ getReserveBits()

AthenaBarCode_t AthenaBarCodeImpl::getReserveBits ( ) const
inherited

Definition at line 216 of file AthenaBarCodeImpl.cxx.

216  {
218  initABC();
220 }

◆ getUUIDHash()

AthenaBarCode_t AthenaBarCodeImpl::getUUIDHash ( ) const
privateinherited

Definition at line 244 of file AthenaBarCodeImpl.cxx.

244  {
245  return getBits(SUUIDBits, UUIDBits);
246 }

◆ getVersion()

AthenaBarCodeVersion_t AthenaBarCodeBase::getVersion ( ) const
virtual

Reimplemented from IAthenaBarCode.

Definition at line 47 of file AthenaBarCodeBase.cxx.

48 {
50 }

◆ hashUUID()

AthenaBarCode_t AthenaBarCodeImpl::hashUUID ( const char *  guid)
staticprivateinherited

Definition at line 190 of file AthenaBarCodeImpl.cxx.

190  {
191  const int maxdigs = 16;
192  AthenaBarCode_t tmp1 = static_cast<AthenaBarCode_t> (2166136261UL);
193 
194  for (int i = 0; i < maxdigs; i++) {
195  tmp1 ^= (AthenaBarCode_t)(guid[i]);
196  tmp1 *= 16777619UL;
197  }
198 
199  return (tmp1 << (TotalBits - UUIDBits)) >> (TotalBits - UUIDBits);
200 }

◆ hasSameAthenaBarCode()

bool AthenaBarCodeBase::hasSameAthenaBarCode ( const IAthenaBarCode obj) const
virtual

Reimplemented from IAthenaBarCode.

Definition at line 34 of file AthenaBarCodeBase.cxx.

35 {
37 }

◆ hasSameAthenaBarCodeExceptVersion()

bool AthenaBarCodeBase::hasSameAthenaBarCodeExceptVersion ( const IAthenaBarCode obj) const
virtual

Reimplemented from IAthenaBarCode.

Definition at line 41 of file AthenaBarCodeBase.cxx.

◆ hasUUIDHash()

AthenaBarCode_t AthenaBarCodeImpl::hasUUIDHash ( ) const
privateinherited

Definition at line 239 of file AthenaBarCodeImpl.cxx.

239  {
240  return getUUIDHash();
241 }

◆ initABC()

void AthenaBarCodeImpl::initABC ( ) const
protectedinherited

Definition at line 24 of file AthenaBarCodeImpl.cxx.

24  {
25 
26  //This function will be call the first time any "access" function is called
27  //using const type because those "access" functions might be const
28  //Will only change mutable variables
29 
30  // std::cout<<"Calling AthenaBarCodeImpl::AthenaBarCodeImpl() "<<std::endl;
31 
32  //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
33  //Set counter part
34  //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
35 
37 
39 
40  try {
42  barcode);
43  }
44  catch (const GaudiException& Exception) {
45  throw std::runtime_error(
46  "AthenaBarCodeImpl::Can not Set Counter Bit, Counter Overflow");
47  }
48 
49  //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
50  //Set reserve part
51  //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
52  try {
54  }
55  catch (const GaudiException& Exception) {
56  throw std::runtime_error(
57  "AthenaBarCodeImpl::Can not initialize Reserve Bit");
58  }
59 
60  //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
61  //Set Version part
62  //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
63  try {
65  }
66  catch (const GaudiException& Exception) {
67  throw std::runtime_error(
68  "AthenaBarCodeImpl::Can not initialize Version Bit");
69  }
70 
71 
72  try {
74  }
75  catch (const GaudiException& Exception) {
76  throw std::runtime_error("AthenaBarCodeImpl::Can not set UUID Hash Bits");
77  }
78 
80 
81  /* std::cout << "[AthenaBarCodeImpl::m_barcode,m_defaultHash,m_barcodeCounter]= "
82  << std::hex
83  << (m_barcode)<< "\t"
84  << m_defaultHash<< "\t"
85  << (m_barcodeCounter)<<"\t"
86  << std::dec
87  << std::endl;
88  */
89 }

◆ makeDefaultHash()

AthenaBarCode_t AthenaBarCodeImpl::makeDefaultHash ( const char *  jobid)
staticprivateinherited

Definition at line 312 of file AthenaBarCodeImpl.cxx.

313 {
314  if (jobid) {
315  return AthenaBarCodeImpl::hashUUID(jobid);
316  }
317 
318  // First look for a uuid as an environment variable.
319  // This can be set in cases where we don't have the full
320  // Gaudi/Athena environment available (eg, ARA), and we
321  // don't want to try to create JobIDSvc. This has to be
322  // communicated in some way external to this library,
323  // as we may end up here while initializing the dictionary
324  // for this library.
325  const char* env_uuid = getenv ("_ATHENABARCODEIMPL_JOBUUID");
326  if (env_uuid) {
327  return AthenaBarCodeImpl::hashUUID(env_uuid);
328  }
329 
330  // std::cout<<"no UUID stored, generating."<<std::endl;
331 
332  ServiceHandle<IJobIDSvc> p_jobidsvc("JobIDSvc", "JobIDSvc");
333  StatusCode sc = p_jobidsvc.retrieve();
334  if (!sc.isSuccess() || 0 == p_jobidsvc) {
335  //FIXME
336  //use uuid instead if service not available
337  JobID_t JobID;
338  uuid_generate(JobID);
339  return AthenaBarCodeImpl::hashUUID((const char *) JobID);
340  /* std::cout << "Could not find JobIDSvc, using uuid directly"
341  <<"jobid "<<o.str()
342  << std::endl;*/
343  }
344 
345  PJobID_t pjobid = p_jobidsvc->getJobID();
346  return AthenaBarCodeImpl::hashUUID((const char *) pjobid);
347 }

◆ newVersion()

void AthenaBarCodeBase::newVersion ( )
virtual

Reimplemented from IAthenaBarCode.

Definition at line 53 of file AthenaBarCodeBase.cxx.

54 {
56 }

◆ setAthenaBarCode()

void AthenaBarCodeBase::setAthenaBarCode ( AthenaBarCode_t  id)
virtual

Reimplemented from IAthenaBarCode.

Definition at line 28 of file AthenaBarCodeBase.cxx.

29 {
31 }

◆ setBits()

void AthenaBarCodeImpl::setBits ( unsigned short  startbit,
unsigned short  nbits,
AthenaBarCode_t  id,
AthenaBarCode_t bc 
) const
protectedinherited

now id=0000000xx;

Definition at line 260 of file AthenaBarCodeImpl.cxx.

263 {
266  tmp2 = 0;
267 
268  if ((id) >= ((~tmp2) >> (TotalBits - nbits))) {
269 
270  IMessageSvc *msgsvc = Athena::getMessageSvc();
271  if (msgsvc) {
272  MsgStream msg(msgsvc, "AthenaBarCodeImpl");
273  msg << MSG::WARNING << "setBits::bit to be set:" << id
274  << " is larger than limit:" << ((~tmp2) >> (TotalBits - nbits))
275  << endmsg;
276  }
277  else {
278  std::cout << "setBits::bit to be set:" << id << " is larger than limit:"
279  << ((~tmp2) >> (TotalBits - nbits)) << std::endl;
280  }
281  throw std::runtime_error("AthenaBarCodeImpl::setBit Failed");
282  }
283 
285  tmp = (id << (TotalBits - nbits - startbit)); //tmp=00000xx00
286  tmp2 = ((~tmp2) >> (TotalBits - nbits)); //tmp2=000000011
287 
288  tmp2 = (tmp2 << (TotalBits - nbits - startbit)); //tmp2=000001100
289  tmp2 = (~tmp2); //tmp2=111110011
290 
291  //now m_barcode=aaaaayyaa
292  bc &= tmp2; //m_barcode=aaaaa00aa
293  bc |= tmp; //m_barcode=aaaaaxxaa
294 
295 }

◆ setDefaultHash()

void AthenaBarCodeImpl::setDefaultHash ( const char *  jobid)
staticinherited

Definition at line 298 of file AthenaBarCodeImpl.cxx.

298  {
299  getDefaultHash (jobid);
300 }

◆ setReserveBits()

void AthenaBarCodeImpl::setReserveBits ( AthenaBarCode_t  id)
inherited

Definition at line 223 of file AthenaBarCodeImpl.cxx.

223  {
225  initABC();
226 
227  try {
229  setBits(SReserveBits, ReserveBits, id, bc);
230  m_barcode = bc;
231  }
232  catch (const GaudiException& Exception) {
233  throw std::runtime_error(
234  "AthenaBarCodeImpl::newVersion()::Version Overflow");
235  }
236 }

◆ setUUIDHash()

void AthenaBarCodeImpl::setUUIDHash ( AthenaBarCode_t  uuidhash)
inlineprivateinherited

Definition at line 114 of file AthenaBarCodeImpl.h.

114  {
115  m_barcode = combineWithUUIDHash(uuidhash);
116 }

◆ setVersion()

void AthenaBarCodeBase::setVersion ( AthenaBarCodeVersion_t  newversion)
virtual

Reimplemented from IAthenaBarCode.

Definition at line 59 of file AthenaBarCodeBase.cxx.

60 {
61  AthenaBarCodeImpl::setVersion (newversion);
62 }

Member Data Documentation

◆ CounterBits

const unsigned short AthenaBarCodeImpl::CounterBits = 26
staticinherited

Definition at line 44 of file AthenaBarCodeImpl.h.

◆ m_barcode

std::atomic<AthenaBarCode_t> AthenaBarCodeImpl::m_barcode
mutableprivateinherited

Definition at line 110 of file AthenaBarCodeImpl.h.

◆ m_barcodeCounter

std::atomic< AthenaBarCode_t > AthenaBarCodeImpl::m_barcodeCounter = 0
staticprivateinherited

Definition at line 109 of file AthenaBarCodeImpl.h.

◆ ReserveBits

const unsigned short AthenaBarCodeImpl::ReserveBits = 2
staticinherited

Definition at line 46 of file AthenaBarCodeImpl.h.

◆ SCounterBits

const unsigned short AthenaBarCodeImpl::SCounterBits = UUIDBits
staticinherited

Definition at line 49 of file AthenaBarCodeImpl.h.

◆ SReserveBits

const unsigned short AthenaBarCodeImpl::SReserveBits = UUIDBits+CounterBits+VersionBits
staticinherited

Definition at line 51 of file AthenaBarCodeImpl.h.

◆ SUUIDBits

const unsigned short AthenaBarCodeImpl::SUUIDBits = 0
staticinherited

Definition at line 48 of file AthenaBarCodeImpl.h.

◆ SVersionBits

const unsigned short AthenaBarCodeImpl::SVersionBits = UUIDBits+CounterBits
staticinherited

Definition at line 50 of file AthenaBarCodeImpl.h.

◆ TotalBits

const unsigned short AthenaBarCodeImpl::TotalBits = 64
staticinherited

Definition at line 41 of file AthenaBarCodeImpl.h.

◆ UNDEFINEDBARCODE

const AthenaBarCode_t IAthenaBarCode::UNDEFINEDBARCODE = (AthenaBarCode_t)(-1)
staticinherited

Definition at line 52 of file AthenaKernel/AthenaKernel/IAthenaBarCode.h.

◆ UNDEFINEDVERSION

const AthenaBarCode_t IAthenaBarCode::UNDEFINEDVERSION = UNDEFINEDBARCODE
staticinherited

Definition at line 53 of file AthenaKernel/AthenaKernel/IAthenaBarCode.h.

◆ UUIDBits

const unsigned short AthenaBarCodeImpl::UUIDBits = 32
staticinherited

Definition at line 43 of file AthenaBarCodeImpl.h.

◆ VersionBits

const unsigned short AthenaBarCodeImpl::VersionBits = 4
staticinherited

Definition at line 45 of file AthenaBarCodeImpl.h.


The documentation for this class was generated from the following files:
AthenaBarCodeImpl::m_barcodeCounter
static std::atomic< AthenaBarCode_t > m_barcodeCounter
Definition: AthenaBarCodeImpl.h:109
AthenaBarCodeImpl::m_barcode
std::atomic< AthenaBarCode_t > m_barcode
Definition: AthenaBarCodeImpl.h:110
IAthenaBarCode::UNDEFINEDBARCODE
static const AthenaBarCode_t UNDEFINEDBARCODE
Definition: AthenaKernel/AthenaKernel/IAthenaBarCode.h:52
PJobID_t
const unsigned char * PJobID_t
Definition: IJobIDSvc.h:21
DeMoUpdate.tmp2
string tmp2
Definition: DeMoUpdate.py:1168
AthenaBarCodeImpl::SUUIDBits
static const unsigned short SUUIDBits
Definition: AthenaBarCodeImpl.h:48
AthenaBarCodeImpl::hashUUID
static AthenaBarCode_t hashUUID(const char *)
Definition: AthenaBarCodeImpl.cxx:190
AthenaBarCodeImpl::UUIDBits
static const unsigned short UUIDBits
Definition: AthenaBarCodeImpl.h:43
AthenaBarCodeImpl::CounterBits
static const unsigned short CounterBits
Definition: AthenaBarCodeImpl.h:44
AthenaBarCodeImpl::SVersionBits
static const unsigned short SVersionBits
Definition: AthenaBarCodeImpl.h:50
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
JobID_t
uuid_t JobID_t
Definition: IJobIDSvc.h:20
AthenaBarCodeImpl::setBits
void setBits(unsigned short startbit, unsigned short nbits, AthenaBarCode_t id, AthenaBarCode_t &bc) const
Definition: AthenaBarCodeImpl.cxx:260
AthenaBarCodeImpl::getUUIDHash
AthenaBarCode_t getUUIDHash() const
Definition: AthenaBarCodeImpl.cxx:244
AthenaBarCodeImpl::setAthenaBarCode
void setAthenaBarCode(AthenaBarCode_t id)
Definition: AthenaBarCodeImpl.cxx:211
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthenaBarCode_t
uint64_t AthenaBarCode_t
barcode for all INav4Mom classes
Definition: AthenaKernel/AthenaKernel/IAthenaBarCode.h:44
AthenaBarCodeImpl::TotalBits
static const unsigned short TotalBits
Definition: AthenaBarCodeImpl.h:41
AthenaBarCodeImpl::newVersion
void newVersion()
Definition: AthenaBarCodeImpl.cxx:138
lumiFormat.i
int i
Definition: lumiFormat.py:85
AthenaBarCodeImpl::getDefaultHash
static AthenaBarCode_t getDefaultHash(const char *jobid=nullptr)
Definition: AthenaBarCodeImpl.cxx:304
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
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
AthenaBarCodeImpl::hasSameAthenaBarCodeExceptVersion
bool hasSameAthenaBarCodeExceptVersion(const IAthenaBarCode &obj) const
Definition: AthenaBarCodeImpl.cxx:120
AthenaBarCodeImpl::SReserveBits
static const unsigned short SReserveBits
Definition: AthenaBarCodeImpl.h:51
AthenaBarCodeImpl::getBits
AthenaBarCode_t getBits(unsigned short startbit, unsigned short nbits) const
Definition: AthenaBarCodeImpl.cxx:249
AthenaBarCodeImpl::initABC
void initABC() const
Definition: AthenaBarCodeImpl.cxx:24
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
LArConditionsTestConfig.msgsvc
msgsvc
Definition: LArConditionsTestConfig.py:74
AthenaBarCodeImpl::SCounterBits
static const unsigned short SCounterBits
Definition: AthenaBarCodeImpl.h:49
AthenaBarCodeImpl::combineWithUUIDHash
AthenaBarCode_t combineWithUUIDHash(const AthenaBarCode_t &) const
Definition: AthenaBarCodeImpl.h:119
pool_uuid.guid
guid
Definition: pool_uuid.py:112
AthenaBarCodeImpl::getAthenaBarCode
AthenaBarCode_t getAthenaBarCode() const
Definition: AthenaBarCodeImpl.cxx:203
SCT_ConditionsAlgorithms::CoveritySafe::getenv
std::string getenv(const std::string &variableName)
get an environment variable
Definition: SCT_ConditionsUtilities.cxx:17
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
AthenaBarCodeImpl::hasSameAthenaBarCode
bool hasSameAthenaBarCode(const IAthenaBarCode &obj) const
Definition: AthenaBarCodeImpl.cxx:110
AthenaBarCodeImpl::makeDefaultHash
static AthenaBarCode_t makeDefaultHash(const char *jobid)
Definition: AthenaBarCodeImpl.cxx:312
test_pyathena.counter
counter
Definition: test_pyathena.py:15
python.PyAthena.obj
obj
Definition: PyAthena.py:132
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
AthenaBarCodeImpl::VersionBits
static const unsigned short VersionBits
Definition: AthenaBarCodeImpl.h:45
AthenaBarCodeImpl::setVersion
void setVersion(AthenaBarCodeVersion_t newversion)
Definition: AthenaBarCodeImpl.cxx:157
ServiceHandle
Definition: ClusterMakerTool.h:37
AthenaBarCodeImpl::getVersion
AthenaBarCodeVersion_t getVersion() const
Definition: AthenaBarCodeImpl.cxx:131
AthenaBarCodeImpl::ReserveBits
static const unsigned short ReserveBits
Definition: AthenaBarCodeImpl.h:46