CMS 3D CMS Logo

HcalDbProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    HcalDbProducer
00004 // Class:      HcalDbProducer
00005 // 
00013 //
00014 // Original Author:  Fedor Ratnikov
00015 //         Created:  Tue Aug  9 19:10:10 CDT 2005
00016 // $Id: HcalDbProducer.cc,v 1.20 2008/03/09 18:21:13 rofierzy Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <iostream>
00023 #include <fstream>
00024 
00025 #include "FWCore/Framework/interface/ESHandle.h"
00026 
00027 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00028 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00029 
00030 
00031 #include "CondFormats/HcalObjects/interface/AllObjects.h"
00032 
00033 #include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
00034 
00035 #include "HcalDbProducer.h"
00036 
00037 HcalDbProducer::HcalDbProducer( const edm::ParameterSet& fConfig)
00038   : ESProducer(),
00039     mService (new HcalDbService (fConfig)),
00040     mDumpRequest (),
00041     mDumpStream(0)
00042 {
00043   //the following line is needed to tell the framework what
00044   // data is being produced
00045   setWhatProduced (this, (dependsOn (&HcalDbProducer::pedestalsCallback) &
00046                           &HcalDbProducer::pedestalWidthsCallback &
00047                           &HcalDbProducer::gainsCallback &
00048                           &HcalDbProducer::gainWidthsCallback &
00049                           &HcalDbProducer::QIEDataCallback &
00050                           &HcalDbProducer::channelQualityCallback &
00051                           &HcalDbProducer::zsThresholdsCallback &
00052                           &HcalDbProducer::respCorrsCallback &
00053                           &HcalDbProducer::electronicsMapCallback
00054                           )
00055                    );
00056   
00057   //now do what ever other initialization is needed
00058 
00059   mDumpRequest = fConfig.getUntrackedParameter <std::vector <std::string> > ("dump", std::vector<std::string>());
00060   if (!mDumpRequest.empty()) {
00061     std::string otputFile = fConfig.getUntrackedParameter <std::string> ("file", "");
00062     mDumpStream = otputFile.empty () ? &std::cout : new std::ofstream (otputFile.c_str());
00063   }
00064 }
00065 
00066 
00067 HcalDbProducer::~HcalDbProducer()
00068 {
00069  
00070    // do anything here that needs to be done at desctruction time
00071    // (e.g. close files, deallocate resources etc.)
00072   if (mDumpStream != &std::cout) delete mDumpStream;
00073 }
00074 
00075 
00076 //
00077 // member functions
00078 //
00079 
00080 // ------------ method called to produce the data  ------------
00081 boost::shared_ptr<HcalDbService> HcalDbProducer::produce( const HcalDbRecord&)
00082 {
00083   return mService;
00084 }
00085 
00086 void HcalDbProducer::pedestalsCallback (const HcalPedestalsRcd& fRecord) {
00087   edm::ESHandle <HcalPedestals> item;
00088   fRecord.get (item);
00089   mService->setData (item.product ());
00090   if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Pedestals")) != mDumpRequest.end()) {
00091     *mDumpStream << "New HCAL Pedestals set" << std::endl;
00092     HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00093   }
00094 }
00095 
00096 void HcalDbProducer::pedestalWidthsCallback (const HcalPedestalWidthsRcd& fRecord) {
00097   edm::ESHandle <HcalPedestalWidths> item;
00098   fRecord.get (item);
00099   mService->setData (item.product ());
00100   if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("PedestalWidths")) != mDumpRequest.end()) {
00101     *mDumpStream << "New HCAL Pedestals set" << std::endl;
00102     HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00103   }
00104 }
00105 
00106 
00107 void HcalDbProducer::gainsCallback (const HcalGainsRcd& fRecord) {
00108   edm::ESHandle <HcalGains> item;
00109   fRecord.get (item);
00110   mService->setData (item.product ());
00111   if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Gains")) != mDumpRequest.end()) {
00112     *mDumpStream << "New HCAL Pedestals set" << std::endl;
00113     HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00114   }
00115 }
00116 
00117 
00118 void HcalDbProducer::gainWidthsCallback (const HcalGainWidthsRcd& fRecord) {
00119   edm::ESHandle <HcalGainWidths> item;
00120   fRecord.get (item);
00121   mService->setData (item.product ());
00122   if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("GainWidths")) != mDumpRequest.end()) {
00123     *mDumpStream << "New HCAL Pedestals set" << std::endl;
00124     HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00125   }
00126 }
00127 
00128 void HcalDbProducer::QIEDataCallback (const HcalQIEDataRcd& fRecord) {
00129   edm::ESHandle <HcalQIEData> item;
00130   fRecord.get (item);
00131   mService->setData (item.product ());
00132   if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("QIEData")) != mDumpRequest.end()) {
00133     *mDumpStream << "New HCAL Pedestals set" << std::endl;
00134     HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00135   }
00136 }
00137 
00138 void HcalDbProducer::channelQualityCallback (const HcalChannelQualityRcd& fRecord) {
00139   edm::ESHandle <HcalChannelQuality> item;
00140   fRecord.get (item);
00141   mService->setData (item.product ());
00142   if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ChannelQuality")) != mDumpRequest.end()) {
00143     *mDumpStream << "New HCAL Pedestals set" << std::endl;
00144     HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00145   }
00146 }
00147 
00148 void HcalDbProducer::respCorrsCallback (const HcalRespCorrsRcd& fRecord) {
00149   edm::ESHandle <HcalRespCorrs> item;
00150   fRecord.get (item);
00151   mService->setData (item.product ());
00152   if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("RespCorrs")) != mDumpRequest.end()) {
00153     *mDumpStream << "New HCAL Pedestals set" << std::endl;
00154     HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00155   }
00156 }
00157 
00158 void HcalDbProducer::zsThresholdsCallback (const HcalZSThresholdsRcd& fRecord) {
00159   edm::ESHandle <HcalZSThresholds> item;
00160   fRecord.get (item);
00161   mService->setData (item.product ());
00162   if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ZSThresholds")) != mDumpRequest.end()) {
00163     *mDumpStream << "New HCAL Pedestals set" << std::endl;
00164     HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00165   }
00166 }
00167 
00168 void HcalDbProducer::electronicsMapCallback (const HcalElectronicsMapRcd& fRecord) {
00169   edm::ESHandle <HcalElectronicsMap> item;
00170   fRecord.get (item);
00171   mService->setData (item.product ());
00172   if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ElectronicsMap")) != mDumpRequest.end()) {
00173     *mDumpStream << "New HCAL Electronics Map set" << std::endl;
00174     HcalDbASCIIIO::dumpObject (*mDumpStream, *(item.product ()));
00175   }
00176 }
00177 
00178 
00179 

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