ATLAS Offline Software
FillParamsUtil.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 //#include "CoolKernel/IObject.h"
7 #include "CoralBase/Blob.h"
8 #include "CoralBase/Attribute.h"
9 #include <sstream>
10 #include <iostream>
11 #include <cstdint>
12 
14  // Clear vectors
15  this->clear();
16  error.clear();
17 }
18 
19 void
21  m_beam1Bunches.clear();
22  m_beam2Bunches.clear();
23  m_luminousBunches.clear();
24 }
25 
26 
27 // Access functions
28 unsigned int
30  return m_beam1Bunches.size();
31 }
32 
33 unsigned int
35  return m_beam2Bunches.size();
36 }
37 
38 unsigned int
40  return m_luminousBunches.size();
41 }
42 
44 
45 const std::vector<unsigned int> &
47  return m_beam1Bunches;
48 }
49 
50 const std::vector<unsigned int> &
52  return m_beam2Bunches;
53 }
54 
55 const std::vector<unsigned int> &
57  return m_luminousBunches;
58 }
59 
60 /*
61 const std::vector<unsigned int> &
62 FillParamsUtil::bcidmasks() const{
63  return m_bcidmasks;
64 }
65 */
66 
67 // Fill value from cool::Record (ie. python)
68 bool
69 FillParamsUtil::setValue(const cool::Record& rec) {
70  return setValue(rec.attributeList());
71 }
72 
73 // Fill value from AttributeList
74 // Returns false on error
75 bool
77 
78  // First, clear old values
79  this->clear();
80  error.clear();
81 
82  // Check if there is any data
83  if (attrList["BCIDmasks"].isNull()) {
84  error = "BCIDmasks is NULL!";
85  return false;
86  }
87 
88  // Extract raw data from COOL object
89  cool::UInt32 nb1 = attrList["Beam1Bunches"].data<cool::UInt32>();
90  cool::UInt32 nb2 = attrList["Beam2Bunches"].data<cool::UInt32>();
91  cool::UInt32 ncol = attrList["LuminousBunches"].data<cool::UInt32>();
92 
93  const coral::Blob& blob = attrList["BCIDmasks"].data<coral::Blob>();
94 
95  // Verify length
96  if ( static_cast<cool::UInt32>( blob.size() ) != 2 * (nb1 + nb2 + ncol)) {
97  std::stringstream ss;
98  ss << "BCIDmasks length " << blob.size() << " != 2 * " << (nb1+nb2+ncol) << "!";
99  error = ss.str();
100  return false;
101  }
102  // std::cout << " Size of BCIDmask: " << blob.size() << std::endl;
103 
104  // Pointer to blob to allow unpacking from binary
105  const uint16_t* p=static_cast<const uint16_t*>(blob.startingAddress());
106 
107  // Decode beam1 list
108  for (unsigned int i = 0; i < nb1; i++, p++) {
109  m_beam1Bunches.push_back(*p);
110  // std::cout << "nBeam1 is " << *p << std::endl;
111  }
112 
113  // Decode beam2 list
114  for (unsigned int i = 0; i < nb2; i++, p++) {
115  // unsigned int tmp = *p;
116  // std::cout << "#2 is " << tmp << std::endl;
117  m_beam2Bunches.push_back(*p);
118  }
119 
120 
121  // Decode luminous list
122  for (unsigned int i = 0; i < ncol; i++, p++) {
123  //unsigned int tmp = *p;
124  // std::cout << "Luminous bunch is " << tmp << std::endl;
125  m_luminousBunches.push_back(*p);
126  }
127 
128 
129  for (unsigned int i = (nb1+nb2+ncol); i < blob.size(); i++, p++) {
130  //unsigned int tmp = *p;
131  // std::cout << "BCIDmask is " << tmp << std::endl;
132  }
133  // Success!
134  return true;
135 }
FillParamsUtil::clear
void clear()
Definition: FillParamsUtil.cxx:20
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
FillParamsUtil::m_luminousBunches
std::vector< unsigned int > m_luminousBunches
Definition: FillParamsUtil.h:51
FillParamsUtil::FillParamsUtil
FillParamsUtil()
Definition: FillParamsUtil.cxx:13
FillParamsUtil.h
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
lumiFormat.i
int i
Definition: lumiFormat.py:92
FillParamsUtil::beam2Bunches
const std::vector< unsigned int > & beam2Bunches() const
Definition: FillParamsUtil.cxx:51
FillParamsUtil::m_beam1Bunches
std::vector< unsigned int > m_beam1Bunches
Definition: FillParamsUtil.h:49
FillParamsUtil::setValue
bool setValue(const coral::AttributeList &attrList)
Definition: FillParamsUtil.cxx:76
FillParamsUtil::nBeam2Bunches
unsigned int nBeam2Bunches() const
Definition: FillParamsUtil.cxx:34
FillParamsUtil::nLuminousBunches
unsigned int nLuminousBunches() const
Definition: FillParamsUtil.cxx:39
FillParamsUtil::luminousBunches
const std::vector< unsigned int > & luminousBunches() const
Definition: FillParamsUtil.cxx:56
FillParamsUtil::beam1Bunches
const std::vector< unsigned int > & beam1Bunches() const
Definition: FillParamsUtil.cxx:46
error
Definition: IImpactPoint3dEstimator.h:70
FillParamsUtil::m_beam2Bunches
std::vector< unsigned int > m_beam2Bunches
Definition: FillParamsUtil.h:50
FillParamsUtil::nBeam1Bunches
unsigned int nBeam1Bunches() const
Definition: FillParamsUtil.cxx:29
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96