CMS 3D CMS Logo

CastorDbProducer.cc

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

Generated on Tue Jun 9 17:25:13 2009 for CMSSW by  doxygen 1.5.4