File indexing completed on 2024-04-06 12:14:14
0001 #ifndef GEOMETRY_CALOEVENTSETUP_CALOGEOMETRYDBWRITER_H
0002 #define GEOMETRY_CALOEVENTSETUP_CALOGEOMETRYDBWRITER_H 1
0003
0004 #include "FWCore/ServiceRegistry/interface/Service.h"
0005 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0006 #include "CondFormats/GeometryObjects/interface/PCaloGeometry.h"
0007 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009
0010 class CaloGeometryDBWriter {
0011 public:
0012 typedef CaloSubdetectorGeometry::TrVec TrVec;
0013 typedef CaloSubdetectorGeometry::DimVec DimVec;
0014 typedef CaloSubdetectorGeometry::IVec IVec;
0015
0016 static constexpr bool writeFlag() { return true; }
0017
0018 static void write(const TrVec& tvec, const DimVec& dvec, const IVec& ivec, const std::string& tag) {
0019 const IVec dins;
0020 const PCaloGeometry peg(tvec, dvec, ivec, dins);
0021
0022 edm::Service<cond::service::PoolDBOutputService> mydbservice;
0023 if (!mydbservice.isAvailable()) {
0024 edm::LogError("PCaloDBGeometryBuilder") << "PoolDBOutputService unavailable";
0025 } else {
0026 if (mydbservice->isNewTagRequest(tag)) {
0027 mydbservice->createOneIOV<PCaloGeometry>(peg, mydbservice->beginOfTime(), tag);
0028 } else {
0029 mydbservice->appendOneIOV<PCaloGeometry>(peg, mydbservice->currentTime(), tag);
0030 }
0031 }
0032 }
0033
0034 static void writeIndexed(
0035 const TrVec& tvec, const DimVec& dvec, const IVec& ivec, const IVec& dins, const std::string& tag) {
0036 const PCaloGeometry peg(tvec, dvec, ivec, dins);
0037
0038 edm::Service<cond::service::PoolDBOutputService> mydbservice;
0039 if (!mydbservice.isAvailable()) {
0040 edm::LogError("PCaloDBGeometryBuilder") << "PoolDBOutputService unavailable";
0041 } else {
0042 if (mydbservice->isNewTagRequest(tag)) {
0043 mydbservice->createOneIOV<PCaloGeometry>(peg, mydbservice->beginOfTime(), tag);
0044 } else {
0045 mydbservice->appendOneIOV<PCaloGeometry>(peg, mydbservice->currentTime(), tag);
0046 }
0047 }
0048 }
0049
0050 CaloGeometryDBWriter() {}
0051 virtual ~CaloGeometryDBWriter() {}
0052 };
0053
0054 #endif