Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <iostream>
00024 #include <fstream>
00025
00026 #include "FWCore/Framework/interface/ESHandle.h"
00027
00028 #include "CalibCalorimetry/CastorCalib/interface/CastorDbASCIIIO.h"
00029 #include "CalibFormats/CastorObjects/interface/CastorDbService.h"
00030 #include "CalibFormats/CastorObjects/interface/CastorDbRecord.h"
00031
00032
00033 #include "CondFormats/CastorObjects/interface/AllObjects.h"
00034
00035 #include "CastorDbProducer.h"
00036
00037 CastorDbProducer::CastorDbProducer( const edm::ParameterSet& fConfig)
00038 : ESProducer(),
00039 mService (new CastorDbService (fConfig)),
00040 mDumpRequest (),
00041 mDumpStream(0)
00042 {
00043
00044
00045 setWhatProduced (this, (dependsOn (&CastorDbProducer::pedestalsCallback,
00046 &CastorDbProducer::gainsCallback) &
00047 &CastorDbProducer::pedestalWidthsCallback &
00048 &CastorDbProducer::QIEDataCallback &
00049 &CastorDbProducer::gainWidthsCallback &
00050 &CastorDbProducer::channelQualityCallback &
00051 &CastorDbProducer::electronicsMapCallback
00052 )
00053 );
00054
00055
00056
00057 mDumpRequest = fConfig.getUntrackedParameter <std::vector <std::string> > ("dump", std::vector<std::string>());
00058 if (!mDumpRequest.empty()) {
00059 std::string otputFile = fConfig.getUntrackedParameter <std::string> ("file", "");
00060 mDumpStream = otputFile.empty () ? &std::cout : new std::ofstream (otputFile.c_str());
00061 }
00062 }
00063
00064
00065 CastorDbProducer::~CastorDbProducer()
00066 {
00067
00068
00069
00070 if (mDumpStream != &std::cout) delete mDumpStream;
00071 }
00072
00073
00074
00075
00076
00077
00078
00079 boost::shared_ptr<CastorDbService> CastorDbProducer::produce( const CastorDbRecord&)
00080 {
00081 return mService;
00082 }
00083
00084 void CastorDbProducer::pedestalsCallback (const CastorPedestalsRcd& fRecord) {
00085 edm::ESHandle <CastorPedestals> item;
00086 fRecord.get (item);
00087 mService->setData (item.product ());
00088 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Pedestals")) != mDumpRequest.end()) {
00089 *mDumpStream << "New HCAL/CASTOR Pedestals set" << std::endl;
00090 CastorDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00091 }
00092 }
00093
00094 void CastorDbProducer::pedestalWidthsCallback (const CastorPedestalWidthsRcd& fRecord) {
00095 edm::ESHandle <CastorPedestalWidths> item;
00096 fRecord.get (item);
00097 mService->setData (item.product ());
00098 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("PedestalWidths")) != mDumpRequest.end()) {
00099 *mDumpStream << "New HCAL/CASTOR Pedestals set" << std::endl;
00100 CastorDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00101 }
00102 }
00103
00104
00105 void CastorDbProducer::gainsCallback (const CastorGainsRcd& fRecord) {
00106 edm::ESHandle <CastorGains> item;
00107 fRecord.get (item);
00108 mService->setData (item.product ());
00109 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Gains")) != mDumpRequest.end()) {
00110 *mDumpStream << "New HCAL/CASTOR Gains set" << std::endl;
00111 CastorDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00112 }
00113 }
00114
00115
00116 void CastorDbProducer::gainWidthsCallback (const CastorGainWidthsRcd& fRecord) {
00117 edm::ESHandle <CastorGainWidths> item;
00118 fRecord.get (item);
00119 mService->setData (item.product ());
00120 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("GainWidths")) != mDumpRequest.end()) {
00121 *mDumpStream << "New HCAL/CASTOR GainWidths set" << std::endl;
00122 CastorDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00123 }
00124 }
00125
00126 void CastorDbProducer::QIEDataCallback (const CastorQIEDataRcd& fRecord) {
00127 edm::ESHandle <CastorQIEData> item;
00128 fRecord.get (item);
00129 mService->setData (item.product ());
00130 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("QIEData")) != mDumpRequest.end()) {
00131 *mDumpStream << "New HCAL/CASTOR QIEData set" << std::endl;
00132 CastorDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00133 }
00134 }
00135
00136 void CastorDbProducer::channelQualityCallback (const CastorChannelQualityRcd& fRecord) {
00137 edm::ESHandle <CastorChannelQuality> item;
00138 fRecord.get (item);
00139 mService->setData (item.product ());
00140 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ChannelQuality")) != mDumpRequest.end()) {
00141 *mDumpStream << "New HCAL/CASTOR ChannelQuality set" << std::endl;
00142 CastorDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00143 }
00144 }
00145
00146 void CastorDbProducer::electronicsMapCallback (const CastorElectronicsMapRcd& fRecord) {
00147 edm::ESHandle <CastorElectronicsMap> item;
00148 fRecord.get (item);
00149 mService->setData (item.product ());
00150 if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ElectronicsMap")) != mDumpRequest.end()) {
00151 *mDumpStream << "New HCAL/CASTOR Electronics Map set" << std::endl;
00152 CastorDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00153 }
00154 }
00155
00156
00157