CMS 3D CMS Logo

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