CMS 3D CMS Logo

EcalTPGDBCopy.cc
Go to the documentation of this file.
3 
6 
8 
9 #include "EcalTPGDBCopy.h"
10 
11 #include <vector>
12 
14  : m_timetype(iConfig.getParameter<std::string>("timetype")), m_cacheIDs(), m_records() {
15  auto cc = consumesCollector();
16  std::string container;
19  typedef std::vector<edm::ParameterSet> Parameters;
20  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
21  for (Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
22  container = i->getParameter<std::string>("container");
23  record = i->getParameter<std::string>("record");
24  m_cacheIDs.insert(std::make_pair(container, 0));
25  m_records.insert(std::make_pair(container, record));
26  setConsumes(cc, container);
27  }
28 }
29 
31 
32 void EcalTPGDBCopy::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
33  std::string container;
35  typedef std::map<std::string, std::string>::const_iterator recordIter;
36  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
37  container = (*i).first;
38  record = (*i).second;
39  if (shouldCopy(evtSetup, container)) {
40  copyToDB(evtSetup, container);
41  }
42  }
43 }
44 
46  if (container == "EcalTPGPedestals") {
48  } else if (container == "EcalTPGLinearizationConst") {
50  } else if (container == "EcalTPGSlidingWindow") {
52  } else if (container == "EcalTPGFineGrainEBIdMap") {
54  } else if (container == "EcalTPGFineGrainStripEE") {
56  } else if (container == "EcalTPGFineGrainTowerEE") {
58  } else if (container == "EcalTPGLutIdMap") {
60  } else if (container == "EcalTPGWeightIdMap") {
62  } else if (container == "EcalTPGWeightGroup") {
64  } else if (container == "EcalTPGOddWeightIdMap") {
66  } else if (container == "EcalTPGOddWeightGroup") {
68  } else if (container == "EcalTPGTPMode") {
69  tpModeToken_ = cc.esConsumes();
70  } else if (container == "EcalTPGLutGroup") {
72  } else if (container == "EcalTPGFineGrainEBGroup") {
74  } else if (container == "EcalTPGPhysicsConst") {
76  } else if (container == "EcalTPGCrystalStatus") {
78  } else if (container == "EcalTPGTowerStatus") {
80  } else if (container == "EcalTPGSpike") {
81  spikeToken_ = cc.esConsumes();
82  } else if (container == "EcalTPGStripStatus") {
84  } else {
85  throw cms::Exception("Unknown container");
86  }
87 }
88 
89 bool EcalTPGDBCopy::shouldCopy(const edm::EventSetup& evtSetup, const std::string& container) {
90  unsigned long long cacheID = 0;
91 
92  if (container == "EcalTPGPedestals") {
93  cacheID = evtSetup.get<EcalTPGPedestalsRcd>().cacheIdentifier();
94  } else if (container == "EcalTPGLinearizationConst") {
95  cacheID = evtSetup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
96  } else if (container == "EcalTPGSlidingWindow") {
97  cacheID = evtSetup.get<EcalTPGSlidingWindowRcd>().cacheIdentifier();
98  } else if (container == "EcalTPGFineGrainEBIdMap") {
99  cacheID = evtSetup.get<EcalTPGFineGrainEBIdMapRcd>().cacheIdentifier();
100  } else if (container == "EcalTPGFineGrainStripEE") {
101  cacheID = evtSetup.get<EcalTPGFineGrainStripEERcd>().cacheIdentifier();
102  } else if (container == "EcalTPGFineGrainTowerEE") {
103  cacheID = evtSetup.get<EcalTPGFineGrainTowerEERcd>().cacheIdentifier();
104  } else if (container == "EcalTPGLutIdMap") {
105  cacheID = evtSetup.get<EcalTPGLutIdMapRcd>().cacheIdentifier();
106  } else if (container == "EcalTPGWeightIdMap") {
107  cacheID = evtSetup.get<EcalTPGWeightIdMapRcd>().cacheIdentifier();
108  } else if (container == "EcalTPGWeightGroup") {
109  cacheID = evtSetup.get<EcalTPGWeightGroupRcd>().cacheIdentifier();
110  } else if (container == "EcalTPGOddWeightIdMap") {
111  cacheID = evtSetup.get<EcalTPGOddWeightIdMapRcd>().cacheIdentifier();
112  } else if (container == "EcalTPGOddWeightGroup") {
113  cacheID = evtSetup.get<EcalTPGOddWeightGroupRcd>().cacheIdentifier();
114  } else if (container == "EcalTPGTPMode") {
115  cacheID = evtSetup.get<EcalTPGTPModeRcd>().cacheIdentifier();
116  } else if (container == "EcalTPGLutGroup") {
117  cacheID = evtSetup.get<EcalTPGLutGroupRcd>().cacheIdentifier();
118  } else if (container == "EcalTPGFineGrainEBGroup") {
119  cacheID = evtSetup.get<EcalTPGFineGrainEBGroupRcd>().cacheIdentifier();
120  } else if (container == "EcalTPGPhysicsConst") {
121  cacheID = evtSetup.get<EcalTPGPhysicsConstRcd>().cacheIdentifier();
122  } else if (container == "EcalTPGCrystalStatus") {
123  cacheID = evtSetup.get<EcalTPGCrystalStatusRcd>().cacheIdentifier();
124  } else if (container == "EcalTPGTowerStatus") {
125  cacheID = evtSetup.get<EcalTPGTowerStatusRcd>().cacheIdentifier();
126  } else if (container == "EcalTPGSpike") {
127  cacheID = evtSetup.get<EcalTPGSpikeRcd>().cacheIdentifier();
128  } else if (container == "EcalTPGStripStatus") {
129  cacheID = evtSetup.get<EcalTPGStripStatusRcd>().cacheIdentifier();
130  } else {
131  throw cms::Exception("Unknown container");
132  }
133 
134  if (m_cacheIDs[container] == cacheID) {
135  return false;
136  } else {
137  m_cacheIDs[container] = cacheID;
138  return true;
139  }
140 }
141 
142 void EcalTPGDBCopy::copyToDB(const edm::EventSetup& evtSetup, const std::string& container) {
144  if (!dbOutput.isAvailable()) {
145  throw cms::Exception("PoolDBOutputService is not available");
146  }
147 
148  std::string recordName = m_records[container];
149 
150  if (container == "EcalTPGPedestals") {
151  const auto& obj = evtSetup.getData(pedestalsToken_);
152  dbOutput->createOneIOV<const EcalTPGPedestals>(obj, dbOutput->beginOfTime(), recordName);
153 
154  } else if (container == "EcalTPGLinearizationConst") {
155  const auto& obj = evtSetup.getData(linearizationConstToken_);
156  dbOutput->createOneIOV<const EcalTPGLinearizationConst>(obj, dbOutput->beginOfTime(), recordName);
157 
158  } else if (container == "EcalTPGSlidingWindow") {
159  const auto& obj = evtSetup.getData(slidingWindowToken_);
160  dbOutput->createOneIOV<const EcalTPGSlidingWindow>(obj, dbOutput->beginOfTime(), recordName);
161 
162  } else if (container == "EcalTPGFineGrainEBIdMap") {
163  const auto& obj = evtSetup.getData(fineGrainEBIdMapToken_);
164  dbOutput->createOneIOV<const EcalTPGFineGrainEBIdMap>(obj, dbOutput->beginOfTime(), recordName);
165 
166  } else if (container == "EcalTPGFineGrainStripEE") {
167  const auto& obj = evtSetup.getData(fineGrainStripEEToken_);
168  dbOutput->createOneIOV<const EcalTPGFineGrainStripEE>(obj, dbOutput->beginOfTime(), recordName);
169 
170  } else if (container == "EcalTPGFineGrainTowerEE") {
171  const auto& obj = evtSetup.getData(fineGrainTowerEEToken_);
172  dbOutput->createOneIOV<const EcalTPGFineGrainTowerEE>(obj, dbOutput->beginOfTime(), recordName);
173 
174  } else if (container == "EcalTPGLutIdMap") {
175  const auto& obj = evtSetup.getData(lutIdMapToken_);
176  dbOutput->createOneIOV<const EcalTPGLutIdMap>(obj, dbOutput->beginOfTime(), recordName);
177 
178  } else if (container == "EcalTPGWeightIdMap") {
179  const auto& obj = evtSetup.getData(weightIdMapToken_);
180  dbOutput->createOneIOV<const EcalTPGWeightIdMap>(obj, dbOutput->beginOfTime(), recordName);
181 
182  } else if (container == "EcalTPGWeightGroup") {
183  const auto& obj = evtSetup.getData(weightGroupToken_);
184  dbOutput->createOneIOV<const EcalTPGWeightGroup>(obj, dbOutput->beginOfTime(), recordName);
185 
186  } else if (container == "EcalTPGOddWeightIdMap") {
187  const auto& obj = evtSetup.getData(oddWeightIdMapToken_);
188  dbOutput->createOneIOV<const EcalTPGOddWeightIdMap>(obj, dbOutput->beginOfTime(), recordName);
189 
190  } else if (container == "EcalTPGOddWeightGroup") {
191  const auto& obj = evtSetup.getData(oddWeightGroupToken_);
192  dbOutput->createOneIOV<const EcalTPGOddWeightGroup>(obj, dbOutput->beginOfTime(), recordName);
193 
194  } else if (container == "EcalTPGTPMode") {
195  const auto& obj = evtSetup.getData(tpModeToken_);
196  dbOutput->createOneIOV<const EcalTPGTPMode>(obj, dbOutput->beginOfTime(), recordName);
197 
198  } else if (container == "EcalTPGLutGroup") {
199  const auto& obj = evtSetup.getData(lutGroupToken_);
200  dbOutput->createOneIOV<const EcalTPGLutGroup>(obj, dbOutput->beginOfTime(), recordName);
201 
202  } else if (container == "EcalTPGFineGrainEBGroup") {
203  const auto& obj = evtSetup.getData(fineGrainEBGroupToken_);
204  dbOutput->createOneIOV<const EcalTPGFineGrainEBGroup>(obj, dbOutput->beginOfTime(), recordName);
205 
206  } else if (container == "EcalTPGPhysicsConst") {
207  const auto& obj = evtSetup.getData(physicsConstToken_);
208  dbOutput->createOneIOV<const EcalTPGPhysicsConst>(obj, dbOutput->beginOfTime(), recordName);
209 
210  } else if (container == "EcalTPGCrystalStatus") {
211  const auto& obj = evtSetup.getData(crystalStatusToken_);
212  dbOutput->createOneIOV<const EcalTPGCrystalStatus>(obj, dbOutput->beginOfTime(), recordName);
213 
214  } else if (container == "EcalTPGTowerStatus") {
215  const auto& obj = evtSetup.getData(towerStatusToken_);
216  dbOutput->createOneIOV<const EcalTPGTowerStatus>(obj, dbOutput->beginOfTime(), recordName);
217 
218  } else if (container == "EcalTPGSpike") {
219  const auto& obj = evtSetup.getData(spikeToken_);
220  dbOutput->createOneIOV<const EcalTPGSpike>(obj, dbOutput->beginOfTime(), recordName);
221 
222  } else if (container == "EcalTPGStripStatus") {
223  const auto& obj = evtSetup.getData(stripStatusToken_);
224  dbOutput->createOneIOV<const EcalTPGStripStatus>(obj, dbOutput->beginOfTime(), recordName);
225 
226  } else {
227  throw cms::Exception("Unknown container");
228  }
229 
230  edm::LogInfo("EcalTPGDBCopy") << "EcalTPGDBCopy wrote " << recordName;
231 }
~EcalTPGDBCopy() override
edm::ESGetToken< EcalTPGSpike, EcalTPGSpikeRcd > spikeToken_
Definition: EcalTPGDBCopy.h:92
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
std::map< std::string, unsigned long long > m_cacheIDs
Definition: EcalTPGDBCopy.h:72
std::map< std::string, std::string > m_records
Definition: EcalTPGDBCopy.h:73
edm::ESGetToken< EcalTPGOddWeightIdMap, EcalTPGOddWeightIdMapRcd > oddWeightIdMapToken_
Definition: EcalTPGDBCopy.h:84
edm::ESGetToken< EcalTPGTowerStatus, EcalTPGTowerStatusRcd > towerStatusToken_
Definition: EcalTPGDBCopy.h:91
edm::ESGetToken< EcalTPGFineGrainStripEE, EcalTPGFineGrainStripEERcd > fineGrainStripEEToken_
Definition: EcalTPGDBCopy.h:79
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
edm::ESGetToken< EcalTPGPedestals, EcalTPGPedestalsRcd > pedestalsToken_
Definition: EcalTPGDBCopy.h:75
vector< ParameterSet > Parameters
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
T get() const
Definition: EventSetup.h:82
edm::ESGetToken< EcalTPGStripStatus, EcalTPGStripStatusRcd > stripStatusToken_
Definition: EcalTPGDBCopy.h:93
bool shouldCopy(const edm::EventSetup &evtSetup, const std::string &container)
bool getData(T &iHolder) const
Definition: EventSetup.h:122
edm::ESGetToken< EcalTPGWeightGroup, EcalTPGWeightGroupRcd > weightGroupToken_
Definition: EcalTPGDBCopy.h:83
void copyToDB(const edm::EventSetup &evtSetup, const std::string &container)
Log< level::Info, false > LogInfo
edm::ESGetToken< EcalTPGCrystalStatus, EcalTPGCrystalStatusRcd > crystalStatusToken_
Definition: EcalTPGDBCopy.h:90
edm::ESGetToken< EcalTPGWeightIdMap, EcalTPGWeightIdMapRcd > weightIdMapToken_
Definition: EcalTPGDBCopy.h:82
edm::ESGetToken< EcalTPGSlidingWindow, EcalTPGSlidingWindowRcd > slidingWindowToken_
Definition: EcalTPGDBCopy.h:77
edm::ESGetToken< EcalTPGFineGrainEBIdMap, EcalTPGFineGrainEBIdMapRcd > fineGrainEBIdMapToken_
Definition: EcalTPGDBCopy.h:78
edm::ESGetToken< EcalTPGPhysicsConst, EcalTPGPhysicsConstRcd > physicsConstToken_
Definition: EcalTPGDBCopy.h:89
edm::ESGetToken< EcalTPGFineGrainTowerEE, EcalTPGFineGrainTowerEERcd > fineGrainTowerEEToken_
Definition: EcalTPGDBCopy.h:80
void setConsumes(edm::ConsumesCollector &cc, const std::string &container)
bool isAvailable() const
Definition: Service.h:40
edm::ESGetToken< EcalTPGTPMode, EcalTPGTPModeRcd > tpModeToken_
Definition: EcalTPGDBCopy.h:86
EcalTPGDBCopy(const edm::ParameterSet &iConfig)
edm::ESGetToken< EcalTPGLutIdMap, EcalTPGLutIdMapRcd > lutIdMapToken_
Definition: EcalTPGDBCopy.h:81
edm::ESGetToken< EcalTPGLutGroup, EcalTPGLutGroupRcd > lutGroupToken_
Definition: EcalTPGDBCopy.h:87
edm::ESGetToken< EcalTPGFineGrainEBGroup, EcalTPGFineGrainEBGroupRcd > fineGrainEBGroupToken_
Definition: EcalTPGDBCopy.h:88
edm::ESGetToken< EcalTPGLinearizationConst, EcalTPGLinearizationConstRcd > linearizationConstToken_
Definition: EcalTPGDBCopy.h:76
edm::ESGetToken< EcalTPGOddWeightGroup, EcalTPGOddWeightGroupRcd > oddWeightGroupToken_
Definition: EcalTPGDBCopy.h:85