ATLAS Offline Software
Loading...
Searching...
No Matches
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
19void
21 m_beam1Bunches.clear();
22 m_beam2Bunches.clear();
23 m_luminousBunches.clear();
24}
25
26
27// Access functions
28unsigned int
30 return m_beam1Bunches.size();
31}
32
33unsigned int
35 return m_beam2Bunches.size();
36}
37
38unsigned int
42
44
45const std::vector<unsigned int> &
49
50const std::vector<unsigned int> &
54
55const std::vector<unsigned int> &
59
60/*
61const std::vector<unsigned int> &
62FillParamsUtil::bcidmasks() const{
63 return m_bcidmasks;
64}
65*/
66
67// Fill value from cool::Record (ie. python)
68bool
69FillParamsUtil::setValue(const cool::Record& rec) {
70 return setValue(rec.attributeList());
71}
72
73// Fill value from AttributeList
74// Returns false on error
75bool
76FillParamsUtil::setValue(const coral::AttributeList& attrList) {
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}
static Double_t ss
const std::vector< unsigned int > & beam1Bunches() const
unsigned int nBeam2Bunches() const
std::vector< unsigned int > m_beam1Bunches
const std::vector< unsigned int > & luminousBunches() const
unsigned int nBeam1Bunches() const
unsigned int nLuminousBunches() const
std::vector< unsigned int > m_beam2Bunches
const std::vector< unsigned int > & beam2Bunches() const
std::vector< unsigned int > m_luminousBunches
bool setValue(const coral::AttributeList &attrList)