CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESDBCopy.cc
Go to the documentation of this file.
3 
5 
6 
9 
10 
24 
25 
26 
27 #include <vector>
28 
30  m_timetype(iConfig.getParameter<std::string>("timetype")),
31  m_cacheIDs(),
32  m_records()
33 {
34 
35  std::string container;
36  std::string tag;
37  std::string record;
38  typedef std::vector< edm::ParameterSet > Parameters;
39  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
40  for(Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
41  container = i->getParameter<std::string>("container");
42  record = i->getParameter<std::string>("record");
43  m_cacheIDs.insert( std::make_pair(container, 0) );
44  m_records.insert( std::make_pair(container, record) );
45  }
46 
47 }
48 
49 
51 {
52 
53 }
54 
55 void ESDBCopy::analyze( const edm::Event& evt, const edm::EventSetup& evtSetup)
56 {
57 
58  std::string container;
59  std::string record;
60  typedef std::map<std::string, std::string>::const_iterator recordIter;
61  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
62  container = (*i).first;
63  record = (*i).second;
64  if ( shouldCopy(evtSetup, container) ) {
65  copyToDB(evtSetup, container);
66  }
67  }
68 
69 }
70 
71 
72 
73 bool ESDBCopy::shouldCopy(const edm::EventSetup& evtSetup, std::string container)
74 {
75 
76  unsigned long long cacheID = 0;
77  if (container == "ESPedestals") {
78  cacheID = evtSetup.get<ESPedestalsRcd>().cacheIdentifier();
79  } else if (container == "ESADCToGeVConstant") {
80  cacheID = evtSetup.get<ESADCToGeVConstantRcd>().cacheIdentifier();
81  } else if (container == "ESIntercalibConstants") {
82  cacheID = evtSetup.get<ESIntercalibConstantsRcd>().cacheIdentifier();
83  } else if (container == "ESWeightStripGroups") {
84  cacheID = evtSetup.get<ESWeightStripGroupsRcd>().cacheIdentifier();
85  } else if (container == "ESTBWeights") {
86  cacheID = evtSetup.get<ESTBWeightsRcd>().cacheIdentifier();
87  } else if (container == "ESChannelStatus") {
88  cacheID = evtSetup.get<ESChannelStatusRcd>().cacheIdentifier();
89  }
90 
91  else {
92  throw cms::Exception("Unknown container");
93  }
94 
95  if (m_cacheIDs[container] == cacheID) {
96  return 0;
97  } else {
98  m_cacheIDs[container] = cacheID;
99  return 1;
100  }
101 
102 }
103 
104 
105 
106 void ESDBCopy::copyToDB(const edm::EventSetup& evtSetup, std::string container)
107 {
109  if ( !dbOutput.isAvailable() ) {
110  throw cms::Exception("PoolDBOutputService is not available");
111  }
112 
113  std::string recordName = m_records[container];
114 
115  if (container == "ESPedestals") {
117  evtSetup.get<ESPedestalsRcd>().get(handle);
118  const ESPedestals* obj = handle.product();
119  std::cout << "ped pointer is: "<< obj<< std::endl;
120  dbOutput->createNewIOV<const ESPedestals>( new ESPedestals(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
121 
122  } else if (container == "ESADCToGeVConstant") {
124  evtSetup.get<ESADCToGeVConstantRcd>().get(handle);
125  const ESADCToGeVConstant* obj = handle.product();
126  std::cout << "adc pointer is: "<< obj<< std::endl;
127 
128  dbOutput->createNewIOV<const ESADCToGeVConstant>( new ESADCToGeVConstant(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
129 
130 
131  } else if (container == "ESChannelStatus") {
133  evtSetup.get<ESChannelStatusRcd>().get(handle);
134  const ESChannelStatus* obj = handle.product();
135  std::cout << "channel status pointer is: "<< obj<< std::endl;
136 
137  dbOutput->createNewIOV<const ESChannelStatus>( new ESChannelStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
138 
139 
140  }
141 else if (container == "ESIntercalibConstants") {
143  evtSetup.get<ESIntercalibConstantsRcd>().get(handle);
144  const ESIntercalibConstants* obj = handle.product();
145  std::cout << "inter pointer is: "<< obj<< std::endl;
146  dbOutput->createNewIOV<const ESIntercalibConstants>( new ESIntercalibConstants(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
147 
148 
149  } else if (container == "ESWeightStripGroups") {
151  evtSetup.get<ESWeightStripGroupsRcd>().get(handle);
152  const ESWeightStripGroups* obj = handle.product();
153  std::cout << "weight pointer is: "<< obj<< std::endl;
154  dbOutput->createNewIOV<const ESWeightStripGroups>( new ESWeightStripGroups(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
155 
156  } else if (container == "ESTBWeights") {
158  evtSetup.get<ESTBWeightsRcd>().get(handle);
159  const ESTBWeights* obj = handle.product();
160  std::cout << "tbweight pointer is: "<< obj<< std::endl;
161  dbOutput->createNewIOV<const ESTBWeights>( new ESTBWeights(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
162 
163 
164  } else {
165  throw cms::Exception("Unknown container");
166  }
167 
168  std::cout<< "ESDBCopy wrote " << recordName << std::endl;
169 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::map< std::string, unsigned long long > m_cacheIDs
Definition: ESDBCopy.h:30
void copyToDB(const edm::EventSetup &evtSetup, std::string container)
Definition: ESDBCopy.cc:106
JetCorrectorParameters::Record record
Definition: classes.h:11
virtual void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup)
Definition: ESDBCopy.cc:55
bool shouldCopy(const edm::EventSetup &evtSetup, std::string container)
Definition: ESDBCopy.cc:73
ESPedestalsMap ESPedestals
Definition: ESPedestals.h:28
ESChannelStatusMap ESChannelStatus
vector< ParameterSet > Parameters
bool isAvailable() const
Definition: Service.h:47
tuple handle
Definition: patZpeak.py:22
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
std::map< std::string, std::string > m_records
Definition: ESDBCopy.h:31
ESIntercalibConstantMap ESIntercalibConstants
~ESDBCopy()
Definition: ESDBCopy.cc:50
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
ESDBCopy(const edm::ParameterSet &iConfig)
Definition: ESDBCopy.cc:29
tuple cout
Definition: gather_cfg.py:121
ESCondObjectContainer< ESStripGroupId > ESWeightStripGroups