ATLAS Offline Software
SCT_SerialNumber.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 /*
5  * SCT_SerialNumber.cxx
6  * SCT_Cabling
7  *
8  * Created by sroe on 21/10/2008.
9  *
10  */
11 
13 #include <sstream>
14 #include <iostream>
15 #include <iomanip>
16 
17 SCT_SerialNumber::SCT_SerialNumber(): m_truncatedNumber(0){
18  //nop
19 }
20 
21 SCT_SerialNumber::SCT_SerialNumber(const std::string & snString){
22  if (snString.substr(0,5)==std::string("20220")){
23  m_truncatedNumber=std::stoi(snString.substr(5));
24  } else {
26  }
27 }
28 
29 SCT_SerialNumber::SCT_SerialNumber(const unsigned long long fullSerialNumber){
30  if (fullSerialNumber > 20220000000000LL){
31  m_truncatedNumber=static_cast<unsigned int>(fullSerialNumber - 20220000000000LL);
32  } else {
34  }
35 }
36 
37 SCT_SerialNumber::SCT_SerialNumber(const long long fullSerialNumber){
38  if (fullSerialNumber > 20220000000000LL){
39  m_truncatedNumber=static_cast<unsigned int>(fullSerialNumber - 20220000000000LL);
40  } else {
42  }
43 }
44 
45 
46 SCT_SerialNumber::SCT_SerialNumber(const unsigned int truncatedSerialNumber){
47  m_truncatedNumber=truncatedSerialNumber;
48 }
49 
50 SCT_SerialNumber::SCT_SerialNumber(const int truncatedSerialNumber){
51  m_truncatedNumber=static_cast<unsigned int>(truncatedSerialNumber);
52 }
53 
54 
55 std::string
57  if (m_truncatedNumber){
58  std::ostringstream os;
59  os<<"20220"<<std::setfill('0')<<std::setw(9)<<m_truncatedNumber;
60  return os.str();
61  } else {
62  return std::string("0");
63  }
64 }
65 
66 unsigned int
68  return m_truncatedNumber;
69 }
70 
71 unsigned long long
73  return m_truncatedNumber?(20220000000000LL + m_truncatedNumber):0LL;
74 }
75 
76 SCT_SerialNumber::operator unsigned int() const{
77  return to_uint();
78 }
79 
80 bool
82  return m_truncatedNumber!=0;
83 }
84 
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
SCT_SerialNumber::str
std::string str() const
Full serial number as a string
Definition: SCT_SerialNumber.cxx:56
SCT_SerialNumber::to_ulonglong
unsigned long long to_ulonglong() const
Full serial number as long long.
Definition: SCT_SerialNumber.cxx:72
SCT_SerialNumber::to_uint
unsigned int to_uint() const
Truncated serial number as unsigned int.
Definition: SCT_SerialNumber.cxx:67
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SCT_SerialNumber::m_truncatedNumber
unsigned int m_truncatedNumber
The truncated number holds the integer part after the '20220' of the serial number.
Definition: SCT_SerialNumber.h:76
SCT_SerialNumber::isWellFormed
bool isWellFormed() const
Cursory check on whether the serial number is well formed N.B.
Definition: SCT_SerialNumber.cxx:81
SCT_SerialNumber.h
SCT_SerialNumber::SCT_SerialNumber
SCT_SerialNumber()
Default constructor produces an invalid serial number.
Definition: SCT_SerialNumber.cxx:17