CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTPGDBCopy.cc
Go to the documentation of this file.
3 
5 
6 
9 
10 
27 
44 
45 #include "EcalTPGDBCopy.h"
46 
47 #include <vector>
48 
49 
50 
52  m_timetype(iConfig.getParameter<std::string>("timetype")),
53  m_cacheIDs(),
54  m_records()
55 {
56 
57  std::string container;
60  typedef std::vector< edm::ParameterSet > Parameters;
61  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
62  for(Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
63  container = i->getParameter<std::string>("container");
64  record = i->getParameter<std::string>("record");
65  m_cacheIDs.insert( std::make_pair(container, 0) );
66  m_records.insert( std::make_pair(container, record) );
67  }
68 
69 }
70 
71 
73 {
74 
75 }
76 
77 void EcalTPGDBCopy::analyze( const edm::Event& evt, const edm::EventSetup& evtSetup)
78 {
79  std::string container;
81  typedef std::map<std::string, std::string>::const_iterator recordIter;
82  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
83  container = (*i).first;
84  record = (*i).second;
85  if ( shouldCopy(evtSetup, container) ) {
86  copyToDB(evtSetup, container);
87  }
88  }
89 
90 }
91 
92 
93 
94 bool EcalTPGDBCopy::shouldCopy(const edm::EventSetup& evtSetup, std::string container)
95 {
96 
97  unsigned long long cacheID = 0;
98 
99  if (container == "EcalTPGPedestals") {
100  cacheID = evtSetup.get<EcalTPGPedestalsRcd>().cacheIdentifier();
101  } else if (container == "EcalTPGLinearizationConst") {
102  cacheID = evtSetup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
103  } else if (container == "EcalTPGSlidingWindow") {
104  cacheID = evtSetup.get<EcalTPGSlidingWindowRcd>().cacheIdentifier();
105  } else if (container == "EcalTPGFineGrainEBIdMap") {
106  cacheID = evtSetup.get<EcalTPGFineGrainEBIdMapRcd>().cacheIdentifier();
107  } else if (container == "EcalTPGFineGrainStripEE") {
108  cacheID = evtSetup.get<EcalTPGFineGrainStripEERcd>().cacheIdentifier();
109  } else if (container == "EcalTPGFineGrainTowerEE") {
110  cacheID = evtSetup.get<EcalTPGFineGrainTowerEERcd>().cacheIdentifier();
111  } else if (container == "EcalTPGLutIdMap") {
112  cacheID = evtSetup.get<EcalTPGLutIdMapRcd>().cacheIdentifier();
113  } else if (container == "EcalTPGWeightIdMap") {
114  cacheID = evtSetup.get<EcalTPGWeightIdMapRcd>().cacheIdentifier();
115  } else if (container == "EcalTPGWeightGroup") {
116  cacheID = evtSetup.get<EcalTPGWeightGroupRcd>().cacheIdentifier();
117  } else if (container == "EcalTPGLutGroup") {
118  cacheID = evtSetup.get<EcalTPGLutGroupRcd>().cacheIdentifier();
119  } else if (container == "EcalTPGFineGrainEBGroup") {
120  cacheID = evtSetup.get<EcalTPGFineGrainEBGroupRcd>().cacheIdentifier();
121  } else if (container == "EcalTPGPhysicsConst") {
122  cacheID = evtSetup.get<EcalTPGPhysicsConstRcd>().cacheIdentifier();
123  } else if (container == "EcalTPGCrystalStatus") {
124  cacheID = evtSetup.get<EcalTPGCrystalStatusRcd>().cacheIdentifier();
125  } else if (container == "EcalTPGTowerStatus") {
126  cacheID = evtSetup.get<EcalTPGTowerStatusRcd>().cacheIdentifier();
127  } else if (container == "EcalTPGSpike") {
128  cacheID = evtSetup.get<EcalTPGSpikeRcd>().cacheIdentifier();
129  } else if (container == "EcalTPGStripStatus") {
130  cacheID = evtSetup.get<EcalTPGStripStatusRcd>().cacheIdentifier();
131  }
132  else {
133  throw cms::Exception("Unknown container");
134  }
135 
136  if (m_cacheIDs[container] == cacheID) {
137  return 0;
138  } else {
139  m_cacheIDs[container] = cacheID;
140  return 1;
141  }
142 
143 }
144 
145 
146 
147 void EcalTPGDBCopy::copyToDB(const edm::EventSetup& evtSetup, std::string container)
148 {
149 
151  if ( !dbOutput.isAvailable() ) {
152  throw cms::Exception("PoolDBOutputService is not available");
153  }
154 
155 
156  std::string recordName = m_records[container];
157 
158 
159  if (container == "EcalTPGPedestals") {
161  evtSetup.get<EcalTPGPedestalsRcd>().get(handle);
162  const EcalTPGPedestals* obj = handle.product();
163  dbOutput->createNewIOV<const EcalTPGPedestals>( new EcalTPGPedestals(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
164 
165  } else if (container == "EcalTPGLinearizationConst") {
167  evtSetup.get<EcalTPGLinearizationConstRcd>().get(handle);
168  const EcalTPGLinearizationConst* obj = handle.product();
169 
170  dbOutput->createNewIOV<const EcalTPGLinearizationConst>( new EcalTPGLinearizationConst(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
171 
172  } else if (container == "EcalTPGSlidingWindow") {
174  evtSetup.get<EcalTPGSlidingWindowRcd>().get(handle);
175  const EcalTPGSlidingWindow* obj = handle.product();
176 
177  dbOutput->createNewIOV<const EcalTPGSlidingWindow>( new EcalTPGSlidingWindow(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
178 
179  } else if (container == "EcalTPGFineGrainEBIdMap") {
181  evtSetup.get<EcalTPGFineGrainEBIdMapRcd>().get(handle);
182  const EcalTPGFineGrainEBIdMap* obj = handle.product();
183  dbOutput->createNewIOV<const EcalTPGFineGrainEBIdMap>( new EcalTPGFineGrainEBIdMap(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
184 
185  } else if (container == "EcalTPGFineGrainStripEE") {
187  evtSetup.get<EcalTPGFineGrainStripEERcd>().get(handle);
188  const EcalTPGFineGrainStripEE* obj = handle.product();
189  dbOutput->createNewIOV<const EcalTPGFineGrainStripEE>( new EcalTPGFineGrainStripEE(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
190 
191  } else if (container == "EcalTPGFineGrainTowerEE") {
193  evtSetup.get<EcalTPGFineGrainTowerEERcd>().get(handle);
194  const EcalTPGFineGrainTowerEE* obj = handle.product();
195  dbOutput->createNewIOV<const EcalTPGFineGrainTowerEE>( new EcalTPGFineGrainTowerEE(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
196 
197  } else if (container == "EcalTPGLutIdMap") {
199  evtSetup.get<EcalTPGLutIdMapRcd>().get(handle);
200  const EcalTPGLutIdMap* obj = handle.product();
201  dbOutput->createNewIOV<const EcalTPGLutIdMap>( new EcalTPGLutIdMap(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
202 
203  } else if (container == "EcalTPGWeightIdMap") {
205  evtSetup.get<EcalTPGWeightIdMapRcd>().get(handle);
206  const EcalTPGWeightIdMap* obj = handle.product();
207  dbOutput->createNewIOV<const EcalTPGWeightIdMap>( new EcalTPGWeightIdMap(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
208 
209  } else if (container == "EcalTPGWeightGroup") {
211  evtSetup.get<EcalTPGWeightGroupRcd>().get(handle);
212  const EcalTPGWeightGroup* obj = handle.product();
213  dbOutput->createNewIOV<const EcalTPGWeightGroup>( new EcalTPGWeightGroup(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
214 
215  } else if (container == "EcalTPGLutGroup") {
217  evtSetup.get<EcalTPGLutGroupRcd>().get(handle);
218  const EcalTPGLutGroup* obj = handle.product();
219  dbOutput->createNewIOV<const EcalTPGLutGroup>( new EcalTPGLutGroup(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
220 
221  } else if (container == "EcalTPGFineGrainEBGroup") {
222 
224  evtSetup.get<EcalTPGFineGrainEBGroupRcd>().get(handle);
225 
226  const EcalTPGFineGrainEBGroup* obj = handle.product();
227 
228  dbOutput->createNewIOV<const EcalTPGFineGrainEBGroup>( new EcalTPGFineGrainEBGroup(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
229 
230  } else if (container == "EcalTPGPhysicsConst") {
232  evtSetup.get<EcalTPGPhysicsConstRcd>().get(handle);
233  const EcalTPGPhysicsConst* obj = handle.product();
234  dbOutput->createNewIOV<const EcalTPGPhysicsConst>( new EcalTPGPhysicsConst(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
235 
236  } else if (container == "EcalTPGCrystalStatus") {
238  evtSetup.get<EcalTPGCrystalStatusRcd>().get(handle);
239  const EcalTPGCrystalStatus* obj = handle.product();
240  dbOutput->createNewIOV<const EcalTPGCrystalStatus>( new EcalTPGCrystalStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
241 
242  } else if (container == "EcalTPGTowerStatus") {
244  evtSetup.get<EcalTPGTowerStatusRcd>().get(handle);
245  const EcalTPGTowerStatus* obj = handle.product();
246  dbOutput->createNewIOV<const EcalTPGTowerStatus>( new EcalTPGTowerStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
247 
248  } else if (container == "EcalTPGSpike") {
249 
251  evtSetup.get<EcalTPGSpikeRcd>().get(handle);
252  const EcalTPGSpike* obj = handle.product();
253 
254  dbOutput->createNewIOV<const EcalTPGSpike>( new EcalTPGSpike(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
255 
256  } else if (container == "EcalTPGStripStatus") {
257 
259  evtSetup.get<EcalTPGStripStatusRcd>().get(handle);
260  const EcalTPGStripStatus* obj = handle.product();
261  dbOutput->createNewIOV<const EcalTPGStripStatus>( new EcalTPGStripStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
262 
263  }
264 
265  else {
266  throw cms::Exception("Unknown container");
267  }
268 
269  std::cout<< "EcalTPGDBCopy wrote " << recordName << std::endl;
270 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::map< std::string, unsigned long long > m_cacheIDs
Definition: EcalTPGDBCopy.h:30
JetCorrectorParameters::Record record
Definition: classes.h:7
std::map< std::string, std::string > m_records
Definition: EcalTPGDBCopy.h:31
vector< ParameterSet > Parameters
virtual void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup)
void copyToDB(const edm::EventSetup &evtSetup, std::string container)
bool isAvailable() const
Definition: Service.h:46
EcalTPGCrystalStatusMap EcalTPGCrystalStatus
tuple handle
Definition: patZpeak.py:22
bool shouldCopy(const edm::EventSetup &evtSetup, std::string container)
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
tuple cout
Definition: gather_cfg.py:121
EcalTPGDBCopy(const edm::ParameterSet &iConfig)
EcalTPGPedestalsMap EcalTPGPedestals
EcalTPGLinearizationConstMap EcalTPGLinearizationConst