32 coolDbInstance(
const std::string& dbStr,
bool readOnly) {
35 cool::IDatabaseSvc&
dbSvc = this->databaseService();
37 return dbSvc.openDatabase(dbStr.c_str(), readOnly);
39 catch (cool::DatabaseDoesNotExist&) {
40 std::cerr <<
"Error! Database does not exist!" << std::endl;
47 coolFolderInstance(
const std::string& folderStr) {
49 cool::IFolderPtr
folder = m_coolDb->getFolder(folderStr.c_str());
53 catch (cool::FolderNotFound&) {
54 std::cerr <<
"Error! Folder '" << folderStr <<
"' does not exist!" << std::endl;
60 CoolMdt::coolDbFolder(
const std::string& dbStr,
const std::string& folderStr) {
61 m_coolDb = this->coolDbInstance(dbStr,
false);
62 m_coolFolder = this->coolFolderInstance(folderStr);
67 setSince(cool::Int64
run, cool::Int64
lumi) {
73 setUntil(cool::Int64
run, cool::Int64
lumi) {
79 setIOV(cool::Int64 runS, cool::Int64 lumiS, cool::Int64 runU, cool::Int64 lumiU) {
80 this->setSince(runS, lumiS);
81 this->setUntil(runU, lumiU);
87 setIOV(cool::Int64
run) {
88 this->setSince(
run, 0);
89 this->setUntil(
run, 4294967295U);
96 cool::Int64 runS = m_since >> 32;
97 cool::Int64 lumiS = m_since - (runS << 32);
98 cool::Int64 runU = m_until >> 32;
99 cool::Int64 lumiU = m_until - (runU << 32);
100 std::cout <<
"Using IOVrange [(" << runS <<
"," << lumiS <<
"),(" << runU <<
"," << lumiU <<
")] " <<
"[" <<
101 m_since <<
"," << m_until <<
"]" << std::endl;
106 CoolOpen(
const std::string& dbStr) {
107 m_coolDb = this->coolDbInstance(dbStr,
false);
112 m_coolFolder->flushStorageBuffer();
113 m_coolDb->closeDatabase();
117 cool::RecordSpecification
119 createSpecDataDead() {
121 cool::RecordSpecification
spec;
122 spec.extend(
"Chamber_Name", cool::StorageType::String255);
123 spec.extend(
"Dead_multilayer", cool::StorageType::String255);
124 spec.extend(
"Dead_layer", cool::StorageType::String255);
125 spec.extend(
"Dead_mezz", cool::StorageType::String255);
126 spec.extend(
"Dead_asd", cool::StorageType::String255);
127 spec.extend(
"Dead_tube", cool::StorageType::String4k);
130 m_coolFolder = this->coolFolderInstance(
"/OFFLINE/DQMFOFFLINE/DQMFOFFLINE_DEAD");
131 m_coolFolder->setupStorageBuffer();
133 m_fist_folder =
false;
135 if (!(
spec == m_coolFolder->payloadSpecification())) {
136 std::cerr <<
"ERROR Source and destination folder specifications differ." << std::endl;
144 createPayloadDataDead(
const std::string& ChamberName,
145 const std::string& DeadMultilayer,
146 const std::string& DeadLayer,
147 const std::string& DeadMezz,
148 const std::string& DeadAsd,
149 const std::string& DeadTube,
150 const cool::RecordSpecification&
spec) {
155 payload[
"Chamber_Name"].data<cool::String255>() = ChamberName;
156 payload[
"Dead_multilayer"].data<cool::String255>() = DeadMultilayer;
157 payload[
"Dead_layer"].data<cool::String255>() = DeadLayer;
158 payload[
"Dead_mezz"].data<cool::String255>() = DeadMezz;
159 payload[
"Dead_asd"].data<cool::String255>() = DeadAsd;
160 payload[
"Dead_tube"].data<cool::String4k>() = DeadTube;
167 cool::RecordSpecification
169 createSpecDataNoisy() {
171 cool::RecordSpecification
spec;
172 spec.extend(
"Chamber_Name", cool::StorageType::String255);
173 spec.extend(
"Noisy_multilayer", cool::StorageType::String255);
174 spec.extend(
"Noisy_layer", cool::StorageType::String255);
175 spec.extend(
"Noisy_mezz", cool::StorageType::String255);
176 spec.extend(
"Noisy_asd", cool::StorageType::String255);
177 spec.extend(
"Noisy_tube", cool::StorageType::String4k);
180 m_coolFolder = this->coolFolderInstance(
"/OFFLINE/DQMFOFFLINE/DQMFOFFLINE_NOISY");
181 m_coolFolder->setupStorageBuffer();
183 m_fist_folder =
false;
185 if (!(
spec == m_coolFolder->payloadSpecification())) {
186 std::cerr <<
"ERROR Source and destination folder specifications differ." << std::endl;
194 createPayloadDataNoisy(
const std::string& ChamberName,
195 const std::string& NoisyMultilayer,
196 const std::string& NoisyLayer,
197 const std::string& NoisyMezz,
198 const std::string& NoisyAsd,
199 const std::string& NoisyTube,
200 const cool::RecordSpecification&
spec) {
205 payload[
"Chamber_Name"].data<cool::String255>() = ChamberName;
206 payload[
"Noisy_multilayer"].data<cool::String255>() = NoisyMultilayer;
207 payload[
"Noisy_layer"].data<cool::String255>() = NoisyLayer;
208 payload[
"Noisy_mezz"].data<cool::String255>() = NoisyMezz;
209 payload[
"Noisy_asd"].data<cool::String255>() = NoisyAsd;
210 payload[
"Noisy_tube"].data<cool::String4k>() = NoisyTube;
222 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until,
selection,
"");
224 const cool::IObject& element =
objects->currentRef();
225 std::cout << element << std::endl;
228 catch (cool::Exception&
e) {
229 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
230 std::cout <<
" dentro create payload" << std::endl;
240 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until,
selection,
"");
242 const cool::IObject& element =
objects->currentRef();
246 catch (cool::Exception&
e) {
247 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
254 dumpCode(
const std::string& channelName) {
255 std::string
result = this->dumpField(this->getCoolFolder()->
channelId(channelName.c_str()),
"Code");
267 insertDeadFlag_withTag(cool::Int64
run,
269 const std::string& ChamberName,
270 const std::string& DeadMultilayer,
271 const std::string& DeadLayer,
272 const std::string& DeadMezz,
273 const std::string& DeadAsd,
274 const std::string& DeadTube,
277 cool::RecordSpecification
spec = this->createSpecDataDead();
279 DeadAsd, DeadTube,
spec);
280 cool::ValidityKey since_u = (
run << 32);
281 cool::ValidityKey until_u = (
run + 1) << 32;
282 m_coolFolder->storeObject(since_u, until_u, cool::Record(
286 catch (cool::Exception&
e) {
287 std::cerr <<
" dentro create insert" << std::endl;
288 std::cerr <<
"Unknown exception caught!" <<
e.what() << std::endl;
294 insertDeadFlag(cool::Int64
run,
296 const std::string& ChamberName,
297 const std::string& DeadMultilayer,
298 const std::string& DeadLayer,
299 const std::string& DeadMezz,
300 const std::string& DeadAsd,
301 const std::string& DeadTube) {
302 std::cout <<
"Trying to store payload [channel " << std::endl;
304 cool::RecordSpecification
spec = this->createSpecDataDead();
306 DeadAsd, DeadTube,
spec);
307 cool::ValidityKey since_u = (
run << 32);
308 cool::ValidityKey until_u = (
run + 1) << 32;
309 m_coolFolder->storeObject(since_u, until_u, cool::Record(m_coolFolder->payloadSpecification(),
payload),
313 catch (cool::Exception&
e) {
314 std::cerr <<
" dentro create insert" << std::endl;
315 std::cerr <<
"Unknown exception caught!" <<
e.what() << std::endl;
325 insertNoisyFlag_withTag(cool::Int64
run,
327 const std::string& ChamberName,
328 const std::string& NoisyMultilayer,
329 const std::string& NoisyLayer,
330 const std::string& NoisyMezz,
331 const std::string& NoisyAsd,
332 const std::string& NoisyTube,
335 cool::RecordSpecification
spec = this->createSpecDataNoisy();
337 NoisyAsd, NoisyTube,
spec);
338 cool::ValidityKey since_u = (
run << 32);
339 cool::ValidityKey until_u = (
run + 1) << 32;
340 m_coolFolder->storeObject(since_u, until_u, cool::Record(
344 catch (cool::Exception&
e) {
345 std::cerr <<
" dentro create insert" << std::endl;
346 std::cerr <<
"Unknown exception caught!" <<
e.what() << std::endl;
352 insertNoisyFlag(cool::Int64
run,
354 const std::string& ChamberName,
355 const std::string& NoisyMultilayer,
356 const std::string& NoisyLayer,
357 const std::string& NoisyMezz,
358 const std::string& NoisyAsd,
359 const std::string& NoisyTube) {
360 std::cout <<
"Trying to store payload [channel " << std::endl;
362 cool::RecordSpecification
spec = this->createSpecDataNoisy();
364 NoisyAsd, NoisyTube,
spec);
365 cool::ValidityKey since_u = (
run << 32);
366 cool::ValidityKey until_u = (
run + 1) << 32;
367 m_coolFolder->storeObject(since_u, until_u, cool::Record(m_coolFolder->payloadSpecification(),
payload),
371 catch (cool::Exception&
e) {
372 std::cerr <<
" dentro create insert" << std::endl;
373 std::cerr <<
"Unknown exception caught!" <<
e.what() << std::endl;
380 return this->m_coolFolder;
386 return this->m_coolDb;