CMS 3D CMS Logo

CastorTextCalibrations.cc

Go to the documentation of this file.
00001 #include <memory>
00002 #include <iostream>
00003 #include <fstream>
00004 
00005 #include "FWCore/Utilities/interface/Exception.h"
00006 #include "FWCore/ParameterSet/interface/FileInPath.h"
00007 
00008 #include "FWCore/Framework/interface/ValidityInterval.h"
00009 
00010 #include "CalibCalorimetry/CastorCalib/interface/CastorDbASCIIIO.h"
00011 
00012 #include "CondFormats/CastorObjects/interface/CastorPedestals.h"
00013 #include "CondFormats/CastorObjects/interface/CastorPedestalWidths.h"
00014 #include "CondFormats/CastorObjects/interface/CastorGains.h"
00015 #include "CondFormats/CastorObjects/interface/CastorGainWidths.h"
00016 #include "CondFormats/CastorObjects/interface/CastorElectronicsMap.h"
00017 #include "CondFormats/CastorObjects/interface/CastorChannelQuality.h"
00018 #include "CondFormats/CastorObjects/interface/CastorQIEData.h"
00019 
00020 #include "CondFormats/DataRecord/interface/CastorPedestalsRcd.h"
00021 #include "CondFormats/DataRecord/interface/CastorPedestalWidthsRcd.h"
00022 #include "CondFormats/DataRecord/interface/CastorGainsRcd.h"
00023 #include "CondFormats/DataRecord/interface/CastorGainWidthsRcd.h"
00024 #include "CondFormats/DataRecord/interface/CastorElectronicsMapRcd.h"
00025 #include "CondFormats/DataRecord/interface/CastorChannelQualityRcd.h"
00026 #include "CondFormats/DataRecord/interface/CastorQIEDataRcd.h"
00027 
00028 
00029 #include "CastorTextCalibrations.h"
00030 //
00031 // class decleration
00032 //
00033 
00034 using namespace cms;
00035 
00036 CastorTextCalibrations::CastorTextCalibrations ( const edm::ParameterSet& iConfig ) 
00037   
00038 {
00039   //parsing parameters
00040   std::vector<edm::ParameterSet> data = iConfig.getParameter<std::vector<edm::ParameterSet> >("input");
00041   std::vector<edm::ParameterSet>::iterator request = data.begin ();
00042   for (; request != data.end (); request++) {
00043     std::string objectName = request->getParameter<std::string> ("object");
00044     edm::FileInPath fp = request->getParameter<edm::FileInPath>("file");
00045     mInputs [objectName] = fp.fullPath();
00046     if (objectName == "Pedestals") {
00047       setWhatProduced (this, &CastorTextCalibrations::producePedestals);
00048       findingRecord <CastorPedestalsRcd> ();
00049     }
00050     else if (objectName == "PedestalWidths") {
00051       setWhatProduced (this, &CastorTextCalibrations::producePedestalWidths);
00052       findingRecord <CastorPedestalWidthsRcd> ();
00053     }
00054     else if (objectName == "Gains") {
00055       setWhatProduced (this, &CastorTextCalibrations::produceGains);
00056       findingRecord <CastorGainsRcd> ();
00057     }
00058     else if (objectName == "GainWidths") {
00059       setWhatProduced (this, &CastorTextCalibrations::produceGainWidths);
00060       findingRecord <CastorGainWidthsRcd> ();
00061     }
00062     else if (objectName == "QIEData") {
00063       setWhatProduced (this, &CastorTextCalibrations::produceQIEData);
00064       findingRecord <CastorQIEDataRcd> ();
00065     }
00066     else if (objectName == "ChannelQuality") {
00067       setWhatProduced (this, &CastorTextCalibrations::produceChannelQuality);
00068       findingRecord <CastorChannelQualityRcd> ();
00069     }
00070     else if (objectName == "ElectronicsMap") {
00071       setWhatProduced (this, &CastorTextCalibrations::produceElectronicsMap);
00072       findingRecord <CastorElectronicsMapRcd> ();
00073     }
00074     else {
00075       std::cerr << "CastorTextCalibrations-> Unknown object name '" << objectName 
00076                 << "', known names are: "
00077                 << "Pedestals PedestalWidths Gains GainWidths QIEData ChannelQuality ElectronicsMap"
00078                 << std::endl;
00079     }
00080   }
00081   //  setWhatProduced(this);
00082 }
00083 
00084 
00085 CastorTextCalibrations::~CastorTextCalibrations()
00086 {
00087 }
00088 
00089 
00090 //
00091 // member functions
00092 //
00093 void 
00094 CastorTextCalibrations::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& iKey, const edm::IOVSyncValue& iTime, edm::ValidityInterval& oInterval ) {
00095   std::string record = iKey.name ();
00096   oInterval = edm::ValidityInterval (edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); //infinite
00097 }
00098 
00099 template <class T>
00100 std::auto_ptr<T> produce_impl (const std::string& fFile) {
00101   std::auto_ptr<T> result (new T ());
00102   std::ifstream inStream (fFile.c_str ());
00103   if (!inStream.good ()) {
00104     std::cerr << "CastorTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
00105     throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
00106   }
00107   if (!CastorDbASCIIIO::getObject (inStream, &*result)) {
00108     std::cerr << "CastorTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
00109     throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
00110   }
00111   return result;
00112 }
00113 
00114 
00115 std::auto_ptr<CastorPedestals> CastorTextCalibrations::producePedestals (const CastorPedestalsRcd&) {
00116   return produce_impl<CastorPedestals> (mInputs ["Pedestals"]);
00117 }
00118 
00119 std::auto_ptr<CastorPedestalWidths> CastorTextCalibrations::producePedestalWidths (const CastorPedestalWidthsRcd&) {
00120   return produce_impl<CastorPedestalWidths> (mInputs ["PedestalWidths"]);
00121 }
00122 
00123 std::auto_ptr<CastorGains> CastorTextCalibrations::produceGains (const CastorGainsRcd&) {
00124   return produce_impl<CastorGains> (mInputs ["Gains"]);
00125 }
00126 
00127 std::auto_ptr<CastorGainWidths> CastorTextCalibrations::produceGainWidths (const CastorGainWidthsRcd&) {
00128   return produce_impl<CastorGainWidths> (mInputs ["GainWidths"]);
00129 }
00130 
00131 std::auto_ptr<CastorQIEData> CastorTextCalibrations::produceQIEData (const CastorQIEDataRcd& rcd) {
00132   return produce_impl<CastorQIEData> (mInputs ["QIEData"]);
00133 }
00134 
00135 std::auto_ptr<CastorChannelQuality> CastorTextCalibrations::produceChannelQuality (const CastorChannelQualityRcd& rcd) {
00136   return produce_impl<CastorChannelQuality> (mInputs ["ChannelQuality"]);
00137 }
00138 
00139 std::auto_ptr<CastorElectronicsMap> CastorTextCalibrations::produceElectronicsMap (const CastorElectronicsMapRcd& rcd) {
00140   return produce_impl<CastorElectronicsMap> (mInputs ["ElectronicsMap"]);
00141 }
00142 

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