30 {
31 cool::IDatabasePtr
32 CoolTgc::
33 coolDbInstance(const std::string& dbStr, bool readOnly) {
34 try {
35 std::cout << "Opening database '" << dbStr << "'...";
36 cool::IDatabaseSvc&
dbSvc = this->databaseService();
37 std::cout << "done." << std::endl;
38 return dbSvc.openDatabase(dbStr.c_str(), readOnly);
39 }
40 catch (cool::DatabaseDoesNotExist&) {
41 std::cout << "Error! Database does not exist!" << std::endl;
42 throw;
43 }
44 }
45
46 cool::IFolderPtr
47 CoolTgc::
48 coolFolderInstance(const std::string& folderStr) {
49 try {
50 cool::IFolderPtr
folder = m_coolDb->getFolder(folderStr.c_str());
51
53 }
54 catch (cool::FolderNotFound&) {
55 std::cout << "Error! Folder '" << folderStr << "' does not exist!" << std::endl;
56 throw;
57 }
58 }
59
60 void
61 CoolTgc::coolDbFolder(const std::string& dbStr, const std::string& folderStr) {
62 m_coolDb = this->coolDbInstance(dbStr, false);
63 m_coolFolder = this->coolFolderInstance(folderStr);
64 }
65
66 void
67 CoolTgc::
68 setSince(cool::Int64
run, cool::Int64 lumi) {
70 }
71
72 void
73 CoolTgc::
74 setUntil(cool::Int64
run, cool::Int64 lumi) {
76 }
77
78 void
79 CoolTgc::
80 setIOV(cool::Int64 runS, cool::Int64 lumiS, cool::Int64 runU, cool::Int64 lumiU) {
81 this->setSince(runS, lumiS);
82 this->setUntil(runU, lumiU);
83 this->printIOV();
84 }
85
86 void
87 CoolTgc::
88 setIOV(cool::Int64
run) {
89 this->setSince(
run, 0);
90 this->setUntil(
run, 4294967295U);
91 this->printIOV();
92 }
93
94 void
95 CoolTgc::
96 printIOV() {
97 cool::Int64 runS = m_since >> 32;
98 cool::Int64 lumiS = m_since - (runS << 32);
99 cool::Int64 runU = m_until >> 32;
100 cool::Int64 lumiU = m_until - (runU << 32);
101 std::cout << "Using IOVrange [(" << runS << "," << lumiS << "),(" << runU << "," << lumiU << ")] " << "[" <<
102 m_since << "," << m_until << "]" << std::endl;
103 }
104
105 void
106 CoolTgc::
107 CoolOpen(const std::string& dbStr) {
108 m_coolDb = this->coolDbInstance(dbStr, false);
109 }
110
111 CoolTgc::
112 ~CoolTgc () {
113 m_coolDb->closeDatabase();
114 std::cout << "Cleared!" << std::endl;
115 }
116
117 cool::RecordSpecification
118 CoolTgc::
119 createSpecDataDead() {
120
121 cool::RecordSpecification
spec;
122 spec.extend(
"Chamber_Name", cool::StorageType::String255);
123 spec.extend(
"Dead_multilayer", cool::StorageType::String255);
124 spec.extend(
"Dead_tube", cool::StorageType::String4k);
125
126 m_coolFolder = this->coolFolderInstance("/OFFLINE/DQMFOFFLINE/DQMFOFFLINE_DEAD");
127 if (!(spec == m_coolFolder->payloadSpecification())) {
128 std::cout << "ERROR Source and destination folder specifications differ." << std::endl;
129 }
130
132 }
133
134 coral::AttributeList
135 CoolTgc::
136 createPayloadDataDead(const std::string& ChamberName,
137 const std::string& DeadMultilayer,
138 const std::string& DeadTube,
139 const cool::RecordSpecification& spec) {
140
141
142 coral::AttributeList
payload = cool::Record(spec).attributeList();
143
144 payload[
"Chamber_Name"].data<cool::String255>() = ChamberName;
145 payload[
"Dead_multilayer"].data<cool::String255>() = DeadMultilayer;
146 payload[
"Dead_tube"].data<cool::String4k>() = DeadTube;
147
149 }
150
151
152
153 cool::RecordSpecification
154 CoolTgc::
155 createSpecDataNoisy() {
156
157 cool::RecordSpecification
spec;
158 spec.extend(
"Chamber_Name", cool::StorageType::String255);
159 spec.extend(
"Noisy_multilayer", cool::StorageType::String255);
160 spec.extend(
"Noisy_tube", cool::StorageType::String4k);
161
162 m_coolFolder = this->coolFolderInstance("/OFFLINE/DQMFOFFLINE/DQMFOFFLINE_NOISY");
163 if (!(spec == m_coolFolder->payloadSpecification())) {
164 std::cout << "ERROR Source and destination folder specifications differ." << std::endl;
165 }
166
168 }
169
170 coral::AttributeList
171 CoolTgc::
172 createPayloadDataNoisy(const std::string& ChamberName,
173 const std::string& NoisyMultilayer,
174 const std::string& NoisyTube,
175 const cool::RecordSpecification& spec) {
176
177
178 coral::AttributeList
payload = cool::Record(spec).attributeList();
179
180 payload[
"Chamber_Name"].data<cool::String255>() = ChamberName;
181 payload[
"Noisy_multilayer"].data<cool::String255>() = NoisyMultilayer;
182 payload[
"Noisy_tube"].data<cool::String4k>() = NoisyTube;
183
185 }
186
187
188
189
190 void
191 CoolTgc::
193 try {
194 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until,
selection,
"");
196 const cool::IObject& element =
objects->currentRef();
197 std::cout << element << std::endl;
198 }
199 }
200 catch (cool::Exception& e) {
201 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
202 std::cout << " dentro create payload" << std::endl;
203 }
204 }
205
206 std::string
207 CoolTgc::
208 dumpField(cool::ChannelId channelId, std::string field) {
210 try {
211 cool::ChannelSelection
selection = cool::ChannelSelection(channelId);
212 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until,
selection,
"");
214 const cool::IObject& element =
objects->currentRef();
215 result = element.payloadValue(field);
216 }
217 }
218 catch (cool::Exception& e) {
219 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
220 }
222 }
223
224 int
225 CoolTgc::
226 dumpCode(const std::string& channelName) {
227 std::string
result = this->dumpField(this->getCoolFolder()->
channelId(channelName.c_str()),
"Code");
229 }
230
231 void
232 CoolTgc::
233 dumpall() {
234 this->
dump(cool::ChannelSelection::all());
235 }
236
237 void
238 CoolTgc::
239 insertDeadFlag_withTag(cool::Int64
run,
240 cool::ChannelId channelId,
241 const std::string& ChamberName,
242 const std::string& DeadMultilayer,
243 const std::string& DeadTube,
244 const std::string& cool_tag) {
245 try {
246 cool::RecordSpecification
spec = this->createSpecDataDead();
247 coral::AttributeList
payload = this->createPayloadDataDead(ChamberName, DeadMultilayer, DeadTube, spec);
248 cool::ValidityKey since_u = (
run << 32);
249 cool::ValidityKey until_u = (
run + 1) << 32;
250 m_coolFolder->storeObject(since_u, until_u, cool::Record(
251 m_coolFolder->payloadSpecification(), payload), channelId, cool_tag);
252 std::cout <<
"stored! With Tag =" <<
cool_tag << std::endl;
253 }
254 catch (cool::Exception& e) {
255 std::cout << " dentro create insert" << std::endl;
256 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
257 }
258 }
259
260 void
261 CoolTgc::
262 insertDeadFlag(cool::Int64
run,
263 cool::ChannelId channelId,
264 const std::string& ChamberName,
265 const std::string& DeadMultilayer,
266 const std::string& DeadTube) {
267 std::cout << "Trying to store payload [channel " << std::endl;
268 try {
269 cool::RecordSpecification
spec = this->createSpecDataDead();
270 coral::AttributeList
payload = this->createPayloadDataDead(ChamberName, DeadMultilayer, DeadTube, spec);
271 cool::ValidityKey since_u = (
run << 32);
272 cool::ValidityKey until_u = (
run + 1) << 32;
273 m_coolFolder->storeObject(since_u, until_u, cool::Record(m_coolFolder->payloadSpecification(), payload),
274 channelId);
275 std::cout << "stored! without Tag" << std::endl;
276 }
277 catch (cool::Exception& e) {
278 std::cout << " dentro create insert" << std::endl;
279 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
280 }
281 }
282
283
284
285
286
287 void
288 CoolTgc::
289 insertNoisyFlag_withTag(cool::Int64
run,
290 cool::ChannelId channelId,
291 const std::string& ChamberName,
292 const std::string& NoisyMultilayer,
293 const std::string& NoisyTube,
294 const std::string& cool_tag) {
295 try {
296 cool::RecordSpecification
spec = this->createSpecDataNoisy();
297 coral::AttributeList
payload = this->createPayloadDataNoisy(ChamberName, NoisyMultilayer, NoisyTube, spec);
298 cool::ValidityKey since_u = (
run << 32);
299 cool::ValidityKey until_u = (
run + 1) << 32;
300 m_coolFolder->storeObject(since_u, until_u, cool::Record(
301 m_coolFolder->payloadSpecification(), payload), channelId, cool_tag);
302 std::cout <<
"stored! With Tag =" <<
cool_tag << std::endl;
303 }
304 catch (cool::Exception& e) {
305 std::cout << " dentro create insert" << std::endl;
306 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
307 }
308 }
309
310 void
311 CoolTgc::
312 insertNoisyFlag(cool::Int64
run,
313 cool::ChannelId channelId,
314 const std::string& ChamberName,
315 const std::string& NoisyMultilayer,
316 const std::string& NoisyTube) {
317 std::cout << "Trying to store payload [channel " << std::endl;
318 try {
319 cool::RecordSpecification
spec = this->createSpecDataNoisy();
320 coral::AttributeList
payload = this->createPayloadDataNoisy(ChamberName, NoisyMultilayer, NoisyTube, spec);
321 cool::ValidityKey since_u = (
run << 32);
322 cool::ValidityKey until_u = (
run + 1) << 32;
323 m_coolFolder->storeObject(since_u, until_u, cool::Record(m_coolFolder->payloadSpecification(), payload),
324 channelId);
325 std::cout << "stored! without Tag" << std::endl;
326 }
327 catch (cool::Exception& e) {
328 std::cout << " dentro create insert" << std::endl;
329 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
330 }
331 }
332
333 cool::IFolderPtr
334 CoolTgc::
335 getCoolFolder() {
336 return this->m_coolFolder;
337 }
338
339 cool::IDatabasePtr
340 CoolTgc::
341 getCoolDb() {
342 return this->m_coolDb;
343 }
344}
const std::string selection
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
int run(int argc, char *argv[])