CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CalibCalorimetry/HcalPlugins/src/HcalTextCalibrations.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Original Author:  Fedor Ratnikov
00003 // $Id: HcalTextCalibrations.cc,v 1.19 2011/02/15 10:41:18 rofierzy Exp $
00004 //
00005 //
00006 
00007 #include <memory>
00008 #include <iostream>
00009 #include <fstream>
00010 
00011 #include "FWCore/Utilities/interface/Exception.h"
00012 #include "FWCore/ParameterSet/interface/FileInPath.h"
00013 
00014 #include "FWCore/Framework/interface/ValidityInterval.h"
00015 
00016 #include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
00017 
00018 #include "CondFormats/DataRecord/interface/HcalAllRcds.h"
00019 
00020 #include "HcalTextCalibrations.h"
00021 //
00022 // class decleration
00023 //
00024 
00025 using namespace cms;
00026 
00027 HcalTextCalibrations::HcalTextCalibrations ( const edm::ParameterSet& iConfig ) 
00028   
00029 {
00030   //parsing parameters
00031   std::vector<edm::ParameterSet> data = iConfig.getParameter<std::vector<edm::ParameterSet> >("input");
00032   std::vector<edm::ParameterSet>::iterator request = data.begin ();
00033   for (; request != data.end (); request++) {
00034     std::string objectName = request->getParameter<std::string> ("object");
00035     edm::FileInPath fp = request->getParameter<edm::FileInPath>("file");
00036     mInputs [objectName] = fp.fullPath();
00037     if (objectName == "Pedestals") {
00038       setWhatProduced (this, &HcalTextCalibrations::producePedestals);
00039       findingRecord <HcalPedestalsRcd> ();
00040     }
00041     else if (objectName == "PedestalWidths") {
00042       setWhatProduced (this, &HcalTextCalibrations::producePedestalWidths);
00043       findingRecord <HcalPedestalWidthsRcd> ();
00044     }
00045     else if (objectName == "Gains") {
00046       setWhatProduced (this, &HcalTextCalibrations::produceGains);
00047       findingRecord <HcalGainsRcd> ();
00048     }
00049     else if (objectName == "GainWidths") {
00050       setWhatProduced (this, &HcalTextCalibrations::produceGainWidths);
00051       findingRecord <HcalGainWidthsRcd> ();
00052     }
00053     else if (objectName == "QIEData") {
00054       setWhatProduced (this, &HcalTextCalibrations::produceQIEData);
00055       findingRecord <HcalQIEDataRcd> ();
00056     }
00057     else if (objectName == "ChannelQuality") {
00058       setWhatProduced (this, &HcalTextCalibrations::produceChannelQuality);
00059       findingRecord <HcalChannelQualityRcd> ();
00060     }
00061     else if (objectName == "ZSThresholds") {
00062       setWhatProduced (this, &HcalTextCalibrations::produceZSThresholds);
00063       findingRecord <HcalZSThresholdsRcd> ();
00064     }
00065     else if (objectName == "RespCorrs") {
00066       setWhatProduced (this, &HcalTextCalibrations::produceRespCorrs);
00067       findingRecord <HcalRespCorrsRcd> ();
00068     }
00069     else if (objectName == "LUTCorrs") {
00070       setWhatProduced (this, &HcalTextCalibrations::produceLUTCorrs);
00071       findingRecord <HcalLUTCorrsRcd> ();
00072     }
00073     else if (objectName == "PFCorrs") {
00074       setWhatProduced (this, &HcalTextCalibrations::producePFCorrs);
00075       findingRecord <HcalPFCorrsRcd> ();
00076     }
00077     else if (objectName == "TimeCorrs") {
00078       setWhatProduced (this, &HcalTextCalibrations::produceTimeCorrs);
00079       findingRecord <HcalTimeCorrsRcd> ();
00080     }
00081     else if (objectName == "L1TriggerObjects") {
00082       setWhatProduced (this, &HcalTextCalibrations::produceL1TriggerObjects);
00083       findingRecord <HcalL1TriggerObjectsRcd> ();
00084     }
00085     else if (objectName == "ElectronicsMap") {
00086       setWhatProduced (this, &HcalTextCalibrations::produceElectronicsMap);
00087       findingRecord <HcalElectronicsMapRcd> ();
00088     }
00089     else if (objectName == "ValidationCorrs") {
00090       setWhatProduced (this, &HcalTextCalibrations::produceValidationCorrs);
00091       findingRecord <HcalValidationCorrsRcd> ();
00092     }
00093     else if (objectName == "LutMetadata") {
00094       setWhatProduced (this, &HcalTextCalibrations::produceLutMetadata);
00095       findingRecord <HcalLutMetadataRcd> ();
00096     }
00097     else if (objectName == "DcsValues") {
00098       setWhatProduced (this, &HcalTextCalibrations::produceDcsValues);
00099       findingRecord <HcalDcsRcd> ();
00100     }
00101     else if (objectName == "DcsMap") {
00102       setWhatProduced (this, &HcalTextCalibrations::produceDcsMap);
00103       findingRecord <HcalDcsMapRcd> ();
00104     }
00105     else if (objectName == "CholeskyMatrices") {
00106       setWhatProduced (this, &HcalTextCalibrations::produceCholeskyMatrices);
00107       findingRecord <HcalCholeskyMatricesRcd> ();
00108     }
00109     else if (objectName == "CovarianceMatrices") {
00110       setWhatProduced (this, &HcalTextCalibrations::produceCovarianceMatrices);
00111       findingRecord <HcalCovarianceMatricesRcd> ();
00112     }
00113     else if (objectName == "RecoParams") {
00114       setWhatProduced (this, &HcalTextCalibrations::produceRecoParams);
00115       findingRecord <HcalRecoParamsRcd> ();
00116     }
00117     else if (objectName == "LongRecoParams") {
00118       setWhatProduced (this, &HcalTextCalibrations::produceLongRecoParams);
00119       findingRecord <HcalLongRecoParamsRcd> ();
00120     }
00121     else if (objectName == "MCParams") {
00122       setWhatProduced (this, &HcalTextCalibrations::produceMCParams);
00123       findingRecord <HcalMCParamsRcd> ();
00124     }
00125     else {
00126       std::cerr << "HcalTextCalibrations-> Unknown object name '" << objectName 
00127                 << "', known names are: "
00128                 << "Pedestals PedestalWidths Gains GainWidths QIEData ChannelQuality ElectronicsMap "
00129                 << "ZSThresholds RespCorrs LUTCorrs PFCorrs TimeCorrs L1TriggerObjects "
00130                 << "ValidationCorrs LutMetadata DcsValues DcsMap CholeskyMatrices CovarianceMatrices "
00131                 << "RecoParams LongRecoParams MCParams "
00132                 << std::endl;
00133     }
00134   }
00135   //  setWhatProduced(this);
00136 }
00137 
00138 
00139 HcalTextCalibrations::~HcalTextCalibrations()
00140 {
00141 }
00142 
00143 
00144 //
00145 // member functions
00146 //
00147 void 
00148 HcalTextCalibrations::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& iKey, const edm::IOVSyncValue& iTime, edm::ValidityInterval& oInterval ) {
00149   std::string record = iKey.name ();
00150   oInterval = edm::ValidityInterval (edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); //infinite
00151 }
00152 
00153 template <class T>
00154 std::auto_ptr<T> produce_impl (const std::string& fFile) {
00155   std::auto_ptr<T> result (new T ());
00156   //  std::auto_ptr<T> result;
00157   std::ifstream inStream (fFile.c_str ());
00158   if (!inStream.good ()) {
00159     std::cerr << "HcalTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
00160     throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
00161   }
00162   if (!HcalDbASCIIIO::getObject (inStream, &*result)) {
00163     std::cerr << "HcalTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
00164     throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
00165   }
00166   return result;
00167 }
00168 
00169 
00170 
00171 std::auto_ptr<HcalPedestals> HcalTextCalibrations::producePedestals (const HcalPedestalsRcd&) {
00172   return produce_impl<HcalPedestals> (mInputs ["Pedestals"]);
00173 }
00174 
00175 std::auto_ptr<HcalPedestalWidths> HcalTextCalibrations::producePedestalWidths (const HcalPedestalWidthsRcd&) {
00176   return produce_impl<HcalPedestalWidths> (mInputs ["PedestalWidths"]);
00177 }
00178 
00179 std::auto_ptr<HcalGains> HcalTextCalibrations::produceGains (const HcalGainsRcd&) {
00180   return produce_impl<HcalGains> (mInputs ["Gains"]);
00181 }
00182 
00183 std::auto_ptr<HcalGainWidths> HcalTextCalibrations::produceGainWidths (const HcalGainWidthsRcd&) {
00184   return produce_impl<HcalGainWidths> (mInputs ["GainWidths"]);
00185 }
00186 
00187 std::auto_ptr<HcalQIEData> HcalTextCalibrations::produceQIEData (const HcalQIEDataRcd& rcd) {
00188   return produce_impl<HcalQIEData> (mInputs ["QIEData"]);
00189 }
00190 
00191 std::auto_ptr<HcalChannelQuality> HcalTextCalibrations::produceChannelQuality (const HcalChannelQualityRcd& rcd) {
00192   return produce_impl<HcalChannelQuality> (mInputs ["ChannelQuality"]);
00193 }
00194 
00195 std::auto_ptr<HcalZSThresholds> HcalTextCalibrations::produceZSThresholds (const HcalZSThresholdsRcd& rcd) {
00196   return produce_impl<HcalZSThresholds> (mInputs ["ZSThresholds"]);
00197 }
00198 
00199 std::auto_ptr<HcalRespCorrs> HcalTextCalibrations::produceRespCorrs (const HcalRespCorrsRcd& rcd) {
00200   return produce_impl<HcalRespCorrs> (mInputs ["RespCorrs"]);
00201 }
00202 
00203 std::auto_ptr<HcalLUTCorrs> HcalTextCalibrations::produceLUTCorrs (const HcalLUTCorrsRcd& rcd) {
00204   return produce_impl<HcalLUTCorrs> (mInputs ["LUTCorrs"]);
00205 }
00206 
00207 std::auto_ptr<HcalPFCorrs> HcalTextCalibrations::producePFCorrs (const HcalPFCorrsRcd& rcd) {
00208   return produce_impl<HcalPFCorrs> (mInputs ["PFCorrs"]);
00209 }
00210 
00211 std::auto_ptr<HcalTimeCorrs> HcalTextCalibrations::produceTimeCorrs (const HcalTimeCorrsRcd& rcd) {
00212   return produce_impl<HcalTimeCorrs> (mInputs ["TimeCorrs"]);
00213 }
00214 
00215 std::auto_ptr<HcalL1TriggerObjects> HcalTextCalibrations::produceL1TriggerObjects (const HcalL1TriggerObjectsRcd& rcd) {
00216   return produce_impl<HcalL1TriggerObjects> (mInputs ["L1TriggerObjects"]);
00217 }
00218 
00219 std::auto_ptr<HcalElectronicsMap> HcalTextCalibrations::produceElectronicsMap (const HcalElectronicsMapRcd& rcd) {
00220   return produce_impl<HcalElectronicsMap> (mInputs ["ElectronicsMap"]);
00221 }
00222 
00223 std::auto_ptr<HcalValidationCorrs> HcalTextCalibrations::produceValidationCorrs (const HcalValidationCorrsRcd& rcd) {
00224   return produce_impl<HcalValidationCorrs> (mInputs ["ValidationCorrs"]);
00225 }
00226 
00227 std::auto_ptr<HcalLutMetadata> HcalTextCalibrations::produceLutMetadata (const HcalLutMetadataRcd& rcd) {
00228   return produce_impl<HcalLutMetadata> (mInputs ["LutMetadata"]);
00229 }
00230 
00231 std::auto_ptr<HcalDcsValues>
00232   HcalTextCalibrations::produceDcsValues(HcalDcsRcd const & rcd) {
00233   return produce_impl<HcalDcsValues> (mInputs ["DcsValues"]);
00234 }
00235 
00236 std::auto_ptr<HcalDcsMap> HcalTextCalibrations::produceDcsMap (const HcalDcsMapRcd& rcd) {
00237   return produce_impl<HcalDcsMap> (mInputs ["DcsMap"]);
00238 }
00239 
00240 std::auto_ptr<HcalCovarianceMatrices> HcalTextCalibrations::produceCovarianceMatrices (const HcalCovarianceMatricesRcd& rcd) {
00241   return produce_impl<HcalCovarianceMatrices> (mInputs ["CovarianceMatrices"]);
00242 }
00243 
00244 std::auto_ptr<HcalCholeskyMatrices> HcalTextCalibrations::produceCholeskyMatrices (const HcalCholeskyMatricesRcd& rcd) {
00245   return produce_impl<HcalCholeskyMatrices> (mInputs ["CholeskyMatrices"]);
00246 }
00247 
00248 std::auto_ptr<HcalRecoParams> HcalTextCalibrations::produceRecoParams (const HcalRecoParamsRcd&) {
00249   return produce_impl<HcalRecoParams> (mInputs ["RecoParams"]);
00250 }
00251 
00252 std::auto_ptr<HcalLongRecoParams> HcalTextCalibrations::produceLongRecoParams (const HcalLongRecoParamsRcd&) {
00253   return produce_impl<HcalLongRecoParams> (mInputs ["LongRecoParams"]);
00254 }
00255 
00256 std::auto_ptr<HcalMCParams> HcalTextCalibrations::produceMCParams (const HcalMCParamsRcd&) {
00257   return produce_impl<HcalMCParams> (mInputs ["MCParams"]);
00258 }