00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <iostream>
00023 #include <fstream>
00024
00025 #include "FWCore/Framework/interface/ESHandle.h"
00026
00027 #include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
00028 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00029 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00030
00031
00032 #include "CondFormats/HcalObjects/interface/AllObjects.h"
00033
00034 #include "HcalDbProducer.h"
00035
00036 HcalDbProducer::HcalDbProducer( const edm::ParameterSet& fConfig)
00037 : ESProducer(),
00038 mService (new HcalDbService (fConfig)),
00039 mDumpRequest (),
00040 mDumpStream(0)
00041 {
00042
00043
00044
00045
00046
00047
00048
00049
00050 setWhatProduced (this, (dependsOn (&HcalDbProducer::pedestalsCallback) &
00051 &HcalDbProducer::pedestalWidthsCallback &
00052 &HcalDbProducer::respCorrsCallback &
00053 &HcalDbProducer::gainsCallback &
00054 &HcalDbProducer::LUTCorrsCallback &
00055 &HcalDbProducer::PFCorrsCallback &
00056 &HcalDbProducer::timeCorrsCallback &
00057 &HcalDbProducer::QIEDataCallback &
00058 &HcalDbProducer::gainWidthsCallback &
00059 &HcalDbProducer::channelQualityCallback &
00060 &HcalDbProducer::zsThresholdsCallback &
00061 &HcalDbProducer::L1triggerObjectsCallback &
00062 &HcalDbProducer::electronicsMapCallback &
00063 &HcalDbProducer::lutMetadataCallback
00064 )
00065 );
00066
00067
00068
00069 mDumpRequest = fConfig.getUntrackedParameter <std::vector <std::string> > ("dump", std::vector<std::string>());
00070 if (!mDumpRequest.empty()) {
00071 std::string otputFile = fConfig.getUntrackedParameter <std::string> ("file", "");
00072 mDumpStream = otputFile.empty () ? &std::cout : new std::ofstream (otputFile.c_str());
00073 }
00074 }
00075
00076
00077 HcalDbProducer::~HcalDbProducer()
00078 {
00079
00080
00081
00082 if (mDumpStream != &std::cout) delete mDumpStream;
00083 }
00084
00085
00086
00087
00088
00089
00090
00091 boost::shared_ptr<HcalDbService> HcalDbProducer::produce( const HcalDbRecord&)
00092 {
00093 return mService;
00094 }
00095
00096 void HcalDbProducer::pedestalsCallback (const HcalPedestalsRcd& fRecord) {
00097 edm::ESHandle <HcalPedestals> item;
00098 fRecord.get (item);
00099 mService->setData (item.product ());
00100 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Pedestals")) != mDumpRequest.end()) {
00101 *mDumpStream << "New HCAL Pedestals set" << std::endl;
00102 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00103 }
00104 }
00105
00106 void HcalDbProducer::pedestalWidthsCallback (const HcalPedestalWidthsRcd& fRecord) {
00107 edm::ESHandle <HcalPedestalWidths> item;
00108 fRecord.get (item);
00109 mService->setData (item.product ());
00110 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("PedestalWidths")) != mDumpRequest.end()) {
00111 *mDumpStream << "New HCAL PedestalWidths set" << std::endl;
00112 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00113 }
00114 }
00115
00116
00117 void HcalDbProducer::gainsCallback (const HcalGainsRcd& fRecord) {
00118 edm::ESHandle <HcalGains> item;
00119 fRecord.get (item);
00120 mService->setData (item.product ());
00121 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Gains")) != mDumpRequest.end()) {
00122 *mDumpStream << "New HCAL Gains set" << std::endl;
00123 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00124 }
00125 }
00126
00127
00128 void HcalDbProducer::gainWidthsCallback (const HcalGainWidthsRcd& fRecord) {
00129 edm::ESHandle <HcalGainWidths> item;
00130 fRecord.get (item);
00131 mService->setData (item.product ());
00132 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("GainWidths")) != mDumpRequest.end()) {
00133 *mDumpStream << "New HCAL GainWidths set" << std::endl;
00134 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00135 }
00136 }
00137
00138 void HcalDbProducer::QIEDataCallback (const HcalQIEDataRcd& fRecord) {
00139 edm::ESHandle <HcalQIEData> item;
00140 fRecord.get (item);
00141 mService->setData (item.product ());
00142 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("QIEData")) != mDumpRequest.end()) {
00143 *mDumpStream << "New HCAL QIEData set" << std::endl;
00144 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00145 }
00146 }
00147
00148 void HcalDbProducer::channelQualityCallback (const HcalChannelQualityRcd& fRecord) {
00149 edm::ESHandle <HcalChannelQuality> item;
00150 fRecord.get (item);
00151 mService->setData (item.product ());
00152 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ChannelQuality")) != mDumpRequest.end()) {
00153 *mDumpStream << "New HCAL ChannelQuality set" << std::endl;
00154 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00155 }
00156 }
00157
00158 void HcalDbProducer::respCorrsCallback (const HcalRespCorrsRcd& fRecord) {
00159 edm::ESHandle <HcalRespCorrs> item;
00160 fRecord.get (item);
00161 mService->setData (item.product ());
00162 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("RespCorrs")) != mDumpRequest.end()) {
00163 *mDumpStream << "New HCAL RespCorrs set" << std::endl;
00164 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00165 }
00166 }
00167
00168 void HcalDbProducer::LUTCorrsCallback (const HcalLUTCorrsRcd& fRecord) {
00169 edm::ESHandle <HcalLUTCorrs> item;
00170 fRecord.get (item);
00171 mService->setData (item.product ());
00172 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("LUTCorrs")) != mDumpRequest.end()) {
00173 *mDumpStream << "New HCAL LUTCorrs set" << std::endl;
00174 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00175 }
00176 }
00177
00178 void HcalDbProducer::PFCorrsCallback (const HcalPFCorrsRcd& fRecord) {
00179 edm::ESHandle <HcalPFCorrs> item;
00180 fRecord.get (item);
00181 mService->setData (item.product ());
00182 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("PFCorrs")) != mDumpRequest.end()) {
00183 *mDumpStream << "New HCAL PFCorrs set" << std::endl;
00184 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00185 }
00186 }
00187
00188 void HcalDbProducer::timeCorrsCallback (const HcalTimeCorrsRcd& fRecord) {
00189 edm::ESHandle <HcalTimeCorrs> item;
00190 fRecord.get (item);
00191 mService->setData (item.product ());
00192 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("TimeCorrs")) != mDumpRequest.end()) {
00193 *mDumpStream << "New HCAL TimeCorrs set" << std::endl;
00194 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00195 }
00196 }
00197
00198 void HcalDbProducer::zsThresholdsCallback (const HcalZSThresholdsRcd& fRecord) {
00199 edm::ESHandle <HcalZSThresholds> item;
00200 fRecord.get (item);
00201 mService->setData (item.product ());
00202 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ZSThresholds")) != mDumpRequest.end()) {
00203 *mDumpStream << "New HCAL ZSThresholds set" << std::endl;
00204 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00205 }
00206 }
00207
00208 void HcalDbProducer::L1triggerObjectsCallback (const HcalL1TriggerObjectsRcd& fRecord) {
00209 edm::ESHandle <HcalL1TriggerObjects> item;
00210 fRecord.get (item);
00211 mService->setData (item.product ());
00212 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("L1TriggerObjects")) != mDumpRequest.end()) {
00213 *mDumpStream << "New HCAL L1TriggerObjects set" << std::endl;
00214 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00215 }
00216 }
00217
00218 void HcalDbProducer::electronicsMapCallback (const HcalElectronicsMapRcd& fRecord) {
00219 edm::ESHandle <HcalElectronicsMap> item;
00220 fRecord.get (item);
00221 mService->setData (item.product ());
00222 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ElectronicsMap")) != mDumpRequest.end()) {
00223 *mDumpStream << "New HCAL Electronics Map set" << std::endl;
00224 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00225 }
00226 }
00227
00228 void HcalDbProducer::lutMetadataCallback (const HcalLutMetadataRcd& fRecord) {
00229 edm::ESHandle <HcalLutMetadata> item;
00230 fRecord.get (item);
00231 mService->setData (item.product ());
00232 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("LutMetadata")) != mDumpRequest.end()) {
00233 *mDumpStream << "New HCAL LUT Metadata set" << std::endl;
00234 HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00235 }
00236 }
00237
00238
00239