CMS 3D CMS Logo

CMSSW_4_4_3_patch1/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.20 2011/06/24 22:15:53 temple 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 declaration
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 if (objectName == "FlagHFDigiTimeParams") {
00126       setWhatProduced (this, &HcalTextCalibrations::produceFlagHFDigiTimeParams);
00127       findingRecord <HcalFlagHFDigiTimeParamsRcd> ();
00128     }
00129     else {
00130       std::cerr << "HcalTextCalibrations-> Unknown object name '" << objectName 
00131                 << "', known names are: "
00132                 << "Pedestals PedestalWidths Gains GainWidths QIEData ChannelQuality ElectronicsMap "
00133                 << "ZSThresholds RespCorrs LUTCorrs PFCorrs TimeCorrs L1TriggerObjects "
00134                 << "ValidationCorrs LutMetadata DcsValues DcsMap CholeskyMatrices CovarianceMatrices "
00135                 << "RecoParams LongRecoParams FlagHFDigiTimeParams MCParams "
00136                 << std::endl;
00137     }
00138   }
00139   //  setWhatProduced(this);
00140 }
00141 
00142 
00143 HcalTextCalibrations::~HcalTextCalibrations()
00144 {
00145 }
00146 
00147 
00148 //
00149 // member functions
00150 //
00151 void 
00152 HcalTextCalibrations::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& iKey, const edm::IOVSyncValue& iTime, edm::ValidityInterval& oInterval ) {
00153   std::string record = iKey.name ();
00154   oInterval = edm::ValidityInterval (edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); //infinite
00155 }
00156 
00157 template <class T>
00158 std::auto_ptr<T> produce_impl (const std::string& fFile) {
00159   std::auto_ptr<T> result (new T ());
00160   //  std::auto_ptr<T> result;
00161   std::ifstream inStream (fFile.c_str ());
00162   if (!inStream.good ()) {
00163     std::cerr << "HcalTextCalibrations-> Unable to open file '" << fFile << "'" << std::endl;
00164     throw cms::Exception("FileNotFound") << "Unable to open '" << fFile << "'" << std::endl;
00165   }
00166   if (!HcalDbASCIIIO::getObject (inStream, &*result)) {
00167     std::cerr << "HcalTextCalibrations-> Can not read object from file '" << fFile << "'" << std::endl;
00168     throw cms::Exception("ReadError") << "Can not read object from file '" << fFile << "'" << std::endl;
00169   }
00170   return result;
00171 }
00172 
00173 
00174 
00175 std::auto_ptr<HcalPedestals> HcalTextCalibrations::producePedestals (const HcalPedestalsRcd&) {
00176   return produce_impl<HcalPedestals> (mInputs ["Pedestals"]);
00177 }
00178 
00179 std::auto_ptr<HcalPedestalWidths> HcalTextCalibrations::producePedestalWidths (const HcalPedestalWidthsRcd&) {
00180   return produce_impl<HcalPedestalWidths> (mInputs ["PedestalWidths"]);
00181 }
00182 
00183 std::auto_ptr<HcalGains> HcalTextCalibrations::produceGains (const HcalGainsRcd&) {
00184   return produce_impl<HcalGains> (mInputs ["Gains"]);
00185 }
00186 
00187 std::auto_ptr<HcalGainWidths> HcalTextCalibrations::produceGainWidths (const HcalGainWidthsRcd&) {
00188   return produce_impl<HcalGainWidths> (mInputs ["GainWidths"]);
00189 }
00190 
00191 std::auto_ptr<HcalQIEData> HcalTextCalibrations::produceQIEData (const HcalQIEDataRcd& rcd) {
00192   return produce_impl<HcalQIEData> (mInputs ["QIEData"]);
00193 }
00194 
00195 std::auto_ptr<HcalChannelQuality> HcalTextCalibrations::produceChannelQuality (const HcalChannelQualityRcd& rcd) {
00196   return produce_impl<HcalChannelQuality> (mInputs ["ChannelQuality"]);
00197 }
00198 
00199 std::auto_ptr<HcalZSThresholds> HcalTextCalibrations::produceZSThresholds (const HcalZSThresholdsRcd& rcd) {
00200   return produce_impl<HcalZSThresholds> (mInputs ["ZSThresholds"]);
00201 }
00202 
00203 std::auto_ptr<HcalRespCorrs> HcalTextCalibrations::produceRespCorrs (const HcalRespCorrsRcd& rcd) {
00204   return produce_impl<HcalRespCorrs> (mInputs ["RespCorrs"]);
00205 }
00206 
00207 std::auto_ptr<HcalLUTCorrs> HcalTextCalibrations::produceLUTCorrs (const HcalLUTCorrsRcd& rcd) {
00208   return produce_impl<HcalLUTCorrs> (mInputs ["LUTCorrs"]);
00209 }
00210 
00211 std::auto_ptr<HcalPFCorrs> HcalTextCalibrations::producePFCorrs (const HcalPFCorrsRcd& rcd) {
00212   return produce_impl<HcalPFCorrs> (mInputs ["PFCorrs"]);
00213 }
00214 
00215 std::auto_ptr<HcalTimeCorrs> HcalTextCalibrations::produceTimeCorrs (const HcalTimeCorrsRcd& rcd) {
00216   return produce_impl<HcalTimeCorrs> (mInputs ["TimeCorrs"]);
00217 }
00218 
00219 std::auto_ptr<HcalL1TriggerObjects> HcalTextCalibrations::produceL1TriggerObjects (const HcalL1TriggerObjectsRcd& rcd) {
00220   return produce_impl<HcalL1TriggerObjects> (mInputs ["L1TriggerObjects"]);
00221 }
00222 
00223 std::auto_ptr<HcalElectronicsMap> HcalTextCalibrations::produceElectronicsMap (const HcalElectronicsMapRcd& rcd) {
00224   return produce_impl<HcalElectronicsMap> (mInputs ["ElectronicsMap"]);
00225 }
00226 
00227 std::auto_ptr<HcalValidationCorrs> HcalTextCalibrations::produceValidationCorrs (const HcalValidationCorrsRcd& rcd) {
00228   return produce_impl<HcalValidationCorrs> (mInputs ["ValidationCorrs"]);
00229 }
00230 
00231 std::auto_ptr<HcalLutMetadata> HcalTextCalibrations::produceLutMetadata (const HcalLutMetadataRcd& rcd) {
00232   return produce_impl<HcalLutMetadata> (mInputs ["LutMetadata"]);
00233 }
00234 
00235 std::auto_ptr<HcalDcsValues>
00236   HcalTextCalibrations::produceDcsValues(HcalDcsRcd const & rcd) {
00237   return produce_impl<HcalDcsValues> (mInputs ["DcsValues"]);
00238 }
00239 
00240 std::auto_ptr<HcalDcsMap> HcalTextCalibrations::produceDcsMap (const HcalDcsMapRcd& rcd) {
00241   return produce_impl<HcalDcsMap> (mInputs ["DcsMap"]);
00242 }
00243 
00244 std::auto_ptr<HcalCovarianceMatrices> HcalTextCalibrations::produceCovarianceMatrices (const HcalCovarianceMatricesRcd& rcd) {
00245   return produce_impl<HcalCovarianceMatrices> (mInputs ["CovarianceMatrices"]);
00246 }
00247 
00248 std::auto_ptr<HcalCholeskyMatrices> HcalTextCalibrations::produceCholeskyMatrices (const HcalCholeskyMatricesRcd& rcd) {
00249   return produce_impl<HcalCholeskyMatrices> (mInputs ["CholeskyMatrices"]);
00250 }
00251 
00252 std::auto_ptr<HcalRecoParams> HcalTextCalibrations::produceRecoParams (const HcalRecoParamsRcd&) {
00253   return produce_impl<HcalRecoParams> (mInputs ["RecoParams"]);
00254 }
00255 
00256 std::auto_ptr<HcalLongRecoParams> HcalTextCalibrations::produceLongRecoParams (const HcalLongRecoParamsRcd&) {
00257   return produce_impl<HcalLongRecoParams> (mInputs ["LongRecoParams"]);
00258 }
00259 
00260 std::auto_ptr<HcalMCParams> HcalTextCalibrations::produceMCParams (const HcalMCParamsRcd&) {
00261   return produce_impl<HcalMCParams> (mInputs ["MCParams"]);
00262 }
00263 
00264 std::auto_ptr<HcalFlagHFDigiTimeParams> HcalTextCalibrations::produceFlagHFDigiTimeParams (const HcalFlagHFDigiTimeParamsRcd&) {
00265   return produce_impl<HcalFlagHFDigiTimeParams> (mInputs ["FlagHFDigiTimeParams"]);
00266 }