CMS 3D CMS Logo

EcalTPGDBCopy.cc
Go to the documentation of this file.
3 
5 
8 
25 
42 
43 #include "EcalTPGDBCopy.h"
44 
45 #include <vector>
46 
48  : m_timetype(iConfig.getParameter<std::string>("timetype")), m_cacheIDs(), m_records() {
49  std::string container;
52  typedef std::vector<edm::ParameterSet> Parameters;
53  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
54  for (Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
55  container = i->getParameter<std::string>("container");
56  record = i->getParameter<std::string>("record");
57  m_cacheIDs.insert(std::make_pair(container, 0));
58  m_records.insert(std::make_pair(container, record));
59  }
60 }
61 
63 
64 void EcalTPGDBCopy::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
65  std::string container;
67  typedef std::map<std::string, std::string>::const_iterator recordIter;
68  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
69  container = (*i).first;
70  record = (*i).second;
71  if (shouldCopy(evtSetup, container)) {
72  copyToDB(evtSetup, container);
73  }
74  }
75 }
76 
77 bool EcalTPGDBCopy::shouldCopy(const edm::EventSetup& evtSetup, std::string container) {
78  unsigned long long cacheID = 0;
79 
80  if (container == "EcalTPGPedestals") {
81  cacheID = evtSetup.get<EcalTPGPedestalsRcd>().cacheIdentifier();
82  } else if (container == "EcalTPGLinearizationConst") {
83  cacheID = evtSetup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
84  } else if (container == "EcalTPGSlidingWindow") {
85  cacheID = evtSetup.get<EcalTPGSlidingWindowRcd>().cacheIdentifier();
86  } else if (container == "EcalTPGFineGrainEBIdMap") {
87  cacheID = evtSetup.get<EcalTPGFineGrainEBIdMapRcd>().cacheIdentifier();
88  } else if (container == "EcalTPGFineGrainStripEE") {
89  cacheID = evtSetup.get<EcalTPGFineGrainStripEERcd>().cacheIdentifier();
90  } else if (container == "EcalTPGFineGrainTowerEE") {
91  cacheID = evtSetup.get<EcalTPGFineGrainTowerEERcd>().cacheIdentifier();
92  } else if (container == "EcalTPGLutIdMap") {
93  cacheID = evtSetup.get<EcalTPGLutIdMapRcd>().cacheIdentifier();
94  } else if (container == "EcalTPGWeightIdMap") {
95  cacheID = evtSetup.get<EcalTPGWeightIdMapRcd>().cacheIdentifier();
96  } else if (container == "EcalTPGWeightGroup") {
97  cacheID = evtSetup.get<EcalTPGWeightGroupRcd>().cacheIdentifier();
98  } else if (container == "EcalTPGLutGroup") {
99  cacheID = evtSetup.get<EcalTPGLutGroupRcd>().cacheIdentifier();
100  } else if (container == "EcalTPGFineGrainEBGroup") {
101  cacheID = evtSetup.get<EcalTPGFineGrainEBGroupRcd>().cacheIdentifier();
102  } else if (container == "EcalTPGPhysicsConst") {
103  cacheID = evtSetup.get<EcalTPGPhysicsConstRcd>().cacheIdentifier();
104  } else if (container == "EcalTPGCrystalStatus") {
105  cacheID = evtSetup.get<EcalTPGCrystalStatusRcd>().cacheIdentifier();
106  } else if (container == "EcalTPGTowerStatus") {
107  cacheID = evtSetup.get<EcalTPGTowerStatusRcd>().cacheIdentifier();
108  } else if (container == "EcalTPGSpike") {
109  cacheID = evtSetup.get<EcalTPGSpikeRcd>().cacheIdentifier();
110  } else if (container == "EcalTPGStripStatus") {
111  cacheID = evtSetup.get<EcalTPGStripStatusRcd>().cacheIdentifier();
112  } else {
113  throw cms::Exception("Unknown container");
114  }
115 
116  if (m_cacheIDs[container] == cacheID) {
117  return false;
118  } else {
119  m_cacheIDs[container] = cacheID;
120  return true;
121  }
122 }
123 
124 void EcalTPGDBCopy::copyToDB(const edm::EventSetup& evtSetup, std::string container) {
126  if (!dbOutput.isAvailable()) {
127  throw cms::Exception("PoolDBOutputService is not available");
128  }
129 
130  std::string recordName = m_records[container];
131 
132  if (container == "EcalTPGPedestals") {
134  evtSetup.get<EcalTPGPedestalsRcd>().get(handle);
135  const EcalTPGPedestals* obj = handle.product();
136  dbOutput->createNewIOV<const EcalTPGPedestals>(
137  new EcalTPGPedestals(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
138 
139  } else if (container == "EcalTPGLinearizationConst") {
142  const EcalTPGLinearizationConst* obj = handle.product();
143 
144  dbOutput->createNewIOV<const EcalTPGLinearizationConst>(
145  new EcalTPGLinearizationConst(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
146 
147  } else if (container == "EcalTPGSlidingWindow") {
149  evtSetup.get<EcalTPGSlidingWindowRcd>().get(handle);
150  const EcalTPGSlidingWindow* obj = handle.product();
151 
152  dbOutput->createNewIOV<const EcalTPGSlidingWindow>(
153  new EcalTPGSlidingWindow(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
154 
155  } else if (container == "EcalTPGFineGrainEBIdMap") {
158  const EcalTPGFineGrainEBIdMap* obj = handle.product();
159  dbOutput->createNewIOV<const EcalTPGFineGrainEBIdMap>(
160  new EcalTPGFineGrainEBIdMap(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
161 
162  } else if (container == "EcalTPGFineGrainStripEE") {
165  const EcalTPGFineGrainStripEE* obj = handle.product();
166  dbOutput->createNewIOV<const EcalTPGFineGrainStripEE>(
167  new EcalTPGFineGrainStripEE(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
168 
169  } else if (container == "EcalTPGFineGrainTowerEE") {
172  const EcalTPGFineGrainTowerEE* obj = handle.product();
173  dbOutput->createNewIOV<const EcalTPGFineGrainTowerEE>(
174  new EcalTPGFineGrainTowerEE(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
175 
176  } else if (container == "EcalTPGLutIdMap") {
178  evtSetup.get<EcalTPGLutIdMapRcd>().get(handle);
179  const EcalTPGLutIdMap* obj = handle.product();
180  dbOutput->createNewIOV<const EcalTPGLutIdMap>(
181  new EcalTPGLutIdMap(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
182 
183  } else if (container == "EcalTPGWeightIdMap") {
185  evtSetup.get<EcalTPGWeightIdMapRcd>().get(handle);
186  const EcalTPGWeightIdMap* obj = handle.product();
187  dbOutput->createNewIOV<const EcalTPGWeightIdMap>(
188  new EcalTPGWeightIdMap(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
189 
190  } else if (container == "EcalTPGWeightGroup") {
192  evtSetup.get<EcalTPGWeightGroupRcd>().get(handle);
193  const EcalTPGWeightGroup* obj = handle.product();
194  dbOutput->createNewIOV<const EcalTPGWeightGroup>(
195  new EcalTPGWeightGroup(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
196 
197  } else if (container == "EcalTPGLutGroup") {
199  evtSetup.get<EcalTPGLutGroupRcd>().get(handle);
200  const EcalTPGLutGroup* obj = handle.product();
201  dbOutput->createNewIOV<const EcalTPGLutGroup>(
202  new EcalTPGLutGroup(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
203 
204  } else if (container == "EcalTPGFineGrainEBGroup") {
207 
208  const EcalTPGFineGrainEBGroup* obj = handle.product();
209 
210  dbOutput->createNewIOV<const EcalTPGFineGrainEBGroup>(
211  new EcalTPGFineGrainEBGroup(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
212 
213  } else if (container == "EcalTPGPhysicsConst") {
215  evtSetup.get<EcalTPGPhysicsConstRcd>().get(handle);
216  const EcalTPGPhysicsConst* obj = handle.product();
217  dbOutput->createNewIOV<const EcalTPGPhysicsConst>(
218  new EcalTPGPhysicsConst(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
219 
220  } else if (container == "EcalTPGCrystalStatus") {
222  evtSetup.get<EcalTPGCrystalStatusRcd>().get(handle);
223  const EcalTPGCrystalStatus* obj = handle.product();
224  dbOutput->createNewIOV<const EcalTPGCrystalStatus>(
225  new EcalTPGCrystalStatus(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
226 
227  } else if (container == "EcalTPGTowerStatus") {
229  evtSetup.get<EcalTPGTowerStatusRcd>().get(handle);
230  const EcalTPGTowerStatus* obj = handle.product();
231  dbOutput->createNewIOV<const EcalTPGTowerStatus>(
232  new EcalTPGTowerStatus(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
233 
234  } else if (container == "EcalTPGSpike") {
236  evtSetup.get<EcalTPGSpikeRcd>().get(handle);
237  const EcalTPGSpike* obj = handle.product();
238 
239  dbOutput->createNewIOV<const EcalTPGSpike>(
240  new EcalTPGSpike(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
241 
242  } else if (container == "EcalTPGStripStatus") {
244  evtSetup.get<EcalTPGStripStatusRcd>().get(handle);
245  const EcalTPGStripStatus* obj = handle.product();
246  dbOutput->createNewIOV<const EcalTPGStripStatus>(
247  new EcalTPGStripStatus(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
248 
249  }
250 
251  else {
252  throw cms::Exception("Unknown container");
253  }
254 
255  std::cout << "EcalTPGDBCopy wrote " << recordName << std::endl;
256 }
EcalTPGLutGroupRcd.h
EcalTPGWeightIdMap
Definition: EcalTPGWeightIdMap.h:10
mps_fire.i
i
Definition: mps_fire.py:428
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:187
EcalTPGFineGrainTowerEERcd
Definition: EcalTPGFineGrainTowerEERcd.h:5
EcalTPGStripStatusRcd.h
ESHandle.h
EcalTPGLinearizationConstRcd.h
patZpeak.handle
handle
Definition: patZpeak.py:23
EcalTPGSpikeRcd.h
EcalTPGSpike
Definition: EcalTPGSpike.h:9
align_cfg.recordName
recordName
Definition: align_cfg.py:66
EcalTPGFineGrainStripEE
Definition: EcalTPGFineGrainStripEE.h:9
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EcalTPGPedestals
EcalTPGPedestalsMap EcalTPGPedestals
Definition: EcalTPGPedestals.h:19
EcalTPGCrystalStatusRcd
Definition: EcalTPGCrystalStatusRcd.h:5
EcalTPGFineGrainEBIdMap.h
EcalTPGFineGrainEBIdMap
Definition: EcalTPGFineGrainEBIdMap.h:10
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
EcalTPGPedestalsRcd
Definition: EcalTPGPedestalsRcd.h:5
EcalTPGCrystalStatusRcd.h
EcalTPGDBCopy::shouldCopy
bool shouldCopy(const edm::EventSetup &evtSetup, std::string container)
Definition: EcalTPGDBCopy.cc:77
EcalTPGWeightGroup
Definition: EcalTPGWeightGroup.h:13
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
EcalTPGFineGrainStripEERcd
Definition: EcalTPGFineGrainStripEERcd.h:5
EcalTPGLutGroup
Definition: EcalTPGLutGroup.h:13
EcalTPGFineGrainTowerEE.h
EcalTPGFineGrainStripEE.h
EcalTPGDBCopy::m_records
std::map< std::string, std::string > m_records
Definition: EcalTPGDBCopy.h:31
EcalTPGStripStatusRcd
Definition: EcalTPGStripStatusRcd.h:5
EcalTPGDBCopy.h
EcalTPGSlidingWindow
Definition: EcalTPGSlidingWindow.h:9
EcalTPGFineGrainTowerEE
Definition: EcalTPGFineGrainTowerEE.h:9
EcalTPGSpike.h
EcalTPGLutIdMap.h
PoolDBOutputService.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
cond::service::PoolDBOutputService::createNewIOV
void createNewIOV(const T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t, const std::string &recordName)
Definition: PoolDBOutputService.h:110
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
Service.h
EcalTPGDBCopy::m_cacheIDs
std::map< std::string, unsigned long long > m_cacheIDs
Definition: EcalTPGDBCopy.h:30
edm::ESHandle
Definition: DTSurvey.h:22
EcalTPGSpikeRcd
Definition: EcalTPGSpikeRcd.h:5
EcalTPGFineGrainEBGroupRcd
Definition: EcalTPGFineGrainEBGroupRcd.h:5
EcalTPGWeightIdMapRcd.h
EcalTPGSlidingWindowRcd.h
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
EcalTPGFineGrainEBGroupRcd.h
EcalTPGLutIdMap
Definition: EcalTPGLutIdMap.h:10
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalTPGWeightGroup.h
EcalTPGLutGroup.h
EcalTPGDBCopy::~EcalTPGDBCopy
~EcalTPGDBCopy() override
Definition: EcalTPGDBCopy.cc:62
edm::ParameterSet
Definition: ParameterSet.h:47
EcalTPGDBCopy::EcalTPGDBCopy
EcalTPGDBCopy(const edm::ParameterSet &iConfig)
Definition: EcalTPGDBCopy.cc:47
EcalTPGLinearizationConst.h
EcalTPGFineGrainEBGroup
Definition: EcalTPGFineGrainEBGroup.h:13
EcalTPGDBCopy::analyze
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
Definition: EcalTPGDBCopy.cc:64
EcalTPGDBCopy::copyToDB
void copyToDB(const edm::EventSetup &evtSetup, std::string container)
Definition: EcalTPGDBCopy.cc:124
EcalTPGFineGrainEBIdMapRcd
Definition: EcalTPGFineGrainEBIdMapRcd.h:5
edm::Service< cond::service::PoolDBOutputService >
EcalTPGFineGrainEBGroup.h
EcalTPGPedestals.h
edm::EventSetup
Definition: EventSetup.h:57
EcalTPGStripStatus.h
get
#define get
EcalTPGTowerStatus.h
EcalTPGFineGrainEBIdMapRcd.h
EcalTPGFineGrainTowerEERcd.h
EcalTPGWeightGroupRcd
Definition: EcalTPGWeightGroupRcd.h:5
EcalTPGPhysicsConst
Definition: EcalTPGPhysicsConst.h:9
cond::service::PoolDBOutputService::endOfTime
cond::Time_t endOfTime() const
Definition: PoolDBOutputService.cc:185
EcalTPGCrystalStatus
EcalTPGCrystalStatusMap EcalTPGCrystalStatus
Definition: EcalTPGCrystalStatus.h:19
EcalTPGLutIdMapRcd
Definition: EcalTPGLutIdMapRcd.h:5
EcalTPGTowerStatus
Definition: EcalTPGTowerStatus.h:9
std
Definition: JetResolutionObject.h:76
EcalTPGSlidingWindow.h
EcalTPGWeightIdMapRcd
Definition: EcalTPGWeightIdMapRcd.h:5
EcalTPGSlidingWindowRcd
Definition: EcalTPGSlidingWindowRcd.h:5
Exception
Definition: hltDiff.cc:246
EcalTPGLutIdMapRcd.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EcalTPGCrystalStatus.h
EcalTPGTowerStatusRcd.h
EcalTPGWeightGroupRcd.h
EcalTPGStripStatus
Definition: EcalTPGStripStatus.h:9
EcalTPGPhysicsConst.h
EcalTPGPedestalsRcd.h
ParameterSet.h
EcalTPGLutGroupRcd
Definition: EcalTPGLutGroupRcd.h:5
EcalTPGPhysicsConstRcd.h
edm::Event
Definition: Event.h:73
Parameters
vector< ParameterSet > Parameters
Definition: HLTMuonPlotter.cc:25
EcalTPGTowerStatusRcd
Definition: EcalTPGTowerStatusRcd.h:5
EcalTPGLinearizationConstRcd
Definition: EcalTPGLinearizationConstRcd.h:5
EcalTPGLinearizationConst
EcalTPGLinearizationConstMap EcalTPGLinearizationConst
Definition: EcalTPGLinearizationConst.h:23
EcalTPGPhysicsConstRcd
Definition: EcalTPGPhysicsConstRcd.h:5
EcalTPGWeightIdMap.h
EcalTPGFineGrainStripEERcd.h