Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include <memory>
00008 #include <iostream>
00009
00010 #include "FWCore/Framework/interface/ValidityInterval.h"
00011 #include "DataFormats/HcalDetId/interface/HcalCastorDetId.h"
00012 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00013 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00014 #include "CalibCalorimetry/CastorCalib/interface/CastorDbHardcode.h"
00015
00016 #include "CondFormats/DataRecord/interface/CastorPedestalsRcd.h"
00017 #include "CondFormats/DataRecord/interface/CastorPedestalWidthsRcd.h"
00018 #include "CondFormats/DataRecord/interface/CastorGainsRcd.h"
00019 #include "CondFormats/DataRecord/interface/CastorGainWidthsRcd.h"
00020 #include "CondFormats/DataRecord/interface/CastorElectronicsMapRcd.h"
00021 #include "CondFormats/DataRecord/interface/CastorChannelQualityRcd.h"
00022 #include "CondFormats/DataRecord/interface/CastorQIEDataRcd.h"
00023 #include "CondFormats/DataRecord/interface/CastorRecoParamsRcd.h"
00024
00025 #include "Geometry/ForwardGeometry/interface/CastorTopology.h"
00026 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00028
00029 #include "CastorHardcodeCalibrations.h"
00030
00031
00032
00033
00034 using namespace cms;
00035
00036 namespace {
00037
00038 std::vector<HcalGenericDetId> allCells (bool h2_mode) {
00039 static std::vector<HcalGenericDetId> result;
00040 if (result.size () <= 0) {
00041
00042 CastorTopology castortopology;
00043 HcalCastorDetId cell;
00044 HcalCastorDetId::Section section = HcalCastorDetId::EM;
00045
00046 for(int sector=1; sector<17; sector++) {
00047 for(int module=1; module<3; module++) {
00048 cell = HcalCastorDetId(section, true, sector, module);
00049 if (castortopology.valid(cell)) result.push_back(cell);
00050 cell = HcalCastorDetId(section, false, sector, module);
00051 if (castortopology.valid(cell)) result.push_back(cell);
00052 }
00053 }
00054
00055 section = HcalCastorDetId::HAD;
00056 for(int sector= 1; sector < 17; sector++){
00057 for(int module=3; module<15; module++) {
00058 cell = HcalCastorDetId(section, true, sector, module);
00059 if(castortopology.valid(cell)) result.push_back(cell);
00060 cell = HcalCastorDetId(section, false, sector, module);
00061 if(castortopology.valid(cell)) result.push_back(cell);
00062 }
00063 }
00064
00065 }
00066 return result;
00067
00068 }
00069 }
00070
00071 CastorHardcodeCalibrations::CastorHardcodeCalibrations ( const edm::ParameterSet& iConfig )
00072
00073 {
00074 edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::CastorHardcodeCalibrations->...";
00075
00076 h2mode_=iConfig.getUntrackedParameter<bool>("H2Mode",false);
00077 std::vector <std::string> toGet = iConfig.getUntrackedParameter <std::vector <std::string> > ("toGet");
00078 for(std::vector <std::string>::iterator objectName = toGet.begin(); objectName != toGet.end(); ++objectName ) {
00079 bool all = *objectName == "all";
00080 if ((*objectName == "Pedestals") || all) {
00081 setWhatProduced (this, &CastorHardcodeCalibrations::producePedestals);
00082 findingRecord <CastorPedestalsRcd> ();
00083 }
00084 if ((*objectName == "PedestalWidths") || all) {
00085 setWhatProduced (this, &CastorHardcodeCalibrations::producePedestalWidths);
00086 findingRecord <CastorPedestalWidthsRcd> ();
00087 }
00088 if ((*objectName == "Gains") || all) {
00089 setWhatProduced (this, &CastorHardcodeCalibrations::produceGains);
00090 findingRecord <CastorGainsRcd> ();
00091 }
00092 if ((*objectName == "GainWidths") || all) {
00093 setWhatProduced (this, &CastorHardcodeCalibrations::produceGainWidths);
00094 findingRecord <CastorGainWidthsRcd> ();
00095 }
00096 if ((*objectName == "QIEData") || all) {
00097 setWhatProduced (this, &CastorHardcodeCalibrations::produceQIEData);
00098 findingRecord <CastorQIEDataRcd> ();
00099 }
00100 if ((*objectName == "ChannelQuality") || (*objectName == "channelQuality") || all) {
00101 setWhatProduced (this, &CastorHardcodeCalibrations::produceChannelQuality);
00102 findingRecord <CastorChannelQualityRcd> ();
00103 }
00104 if ((*objectName == "ElectronicsMap") || (*objectName == "electronicsMap") || all) {
00105 setWhatProduced (this, &CastorHardcodeCalibrations::produceElectronicsMap);
00106 findingRecord <CastorElectronicsMapRcd> ();
00107 }
00108 if ((*objectName == "RecoParams") || all) {
00109 setWhatProduced (this, &CastorHardcodeCalibrations::produceRecoParams);
00110 findingRecord <CastorRecoParamsRcd> ();
00111 }
00112
00113 }
00114 }
00115
00116
00117 CastorHardcodeCalibrations::~CastorHardcodeCalibrations()
00118 {
00119 }
00120
00121
00122
00123
00124
00125 void
00126 CastorHardcodeCalibrations::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& iKey, const edm::IOVSyncValue& iTime, edm::ValidityInterval& oInterval ) {
00127 std::string record = iKey.name ();
00128 edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::setIntervalFor-> key: " << record << " time: " << iTime.eventID() << '/' << iTime.time ().value ();
00129 oInterval = edm::ValidityInterval (edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
00130 }
00131
00132 std::auto_ptr<CastorPedestals> CastorHardcodeCalibrations::producePedestals (const CastorPedestalsRcd&) {
00133 edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::producePedestals-> ...";
00134 std::auto_ptr<CastorPedestals> result (new CastorPedestals (false));
00135 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00136 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00137 CastorPedestal item = CastorDbHardcode::makePedestal (*cell);
00138 result->addValues(item);
00139 }
00140 return result;
00141 }
00142
00143 std::auto_ptr<CastorPedestalWidths> CastorHardcodeCalibrations::producePedestalWidths (const CastorPedestalWidthsRcd&) {
00144 edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::producePedestalWidths-> ...";
00145 std::auto_ptr<CastorPedestalWidths> result (new CastorPedestalWidths (false));
00146 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00147 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00148 CastorPedestalWidth item = CastorDbHardcode::makePedestalWidth (*cell);
00149 result->addValues(item);
00150 }
00151 return result;
00152 }
00153
00154 std::auto_ptr<CastorGains> CastorHardcodeCalibrations::produceGains (const CastorGainsRcd&) {
00155 edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceGains-> ...";
00156 std::auto_ptr<CastorGains> result (new CastorGains ());
00157 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00158 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00159 CastorGain item = CastorDbHardcode::makeGain (*cell);
00160 result->addValues(item);
00161 }
00162 return result;
00163 }
00164
00165 std::auto_ptr<CastorGainWidths> CastorHardcodeCalibrations::produceGainWidths (const CastorGainWidthsRcd&) {
00166 edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceGainWidths-> ...";
00167 std::auto_ptr<CastorGainWidths> result (new CastorGainWidths ());
00168 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00169 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00170 CastorGainWidth item = CastorDbHardcode::makeGainWidth (*cell);
00171 result->addValues(item);
00172 }
00173 return result;
00174 }
00175
00176 std::auto_ptr<CastorQIEData> CastorHardcodeCalibrations::produceQIEData (const CastorQIEDataRcd& rcd) {
00177 edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceQIEData-> ...";
00178 std::auto_ptr<CastorQIEData> result (new CastorQIEData ());
00179 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00180 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00181 CastorQIECoder coder = CastorDbHardcode::makeQIECoder (*cell);
00182 result->addCoder(coder);
00183 }
00184 return result;
00185 }
00186
00187 std::auto_ptr<CastorChannelQuality> CastorHardcodeCalibrations::produceChannelQuality (const CastorChannelQualityRcd& rcd) {
00188 edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceChannelQuality-> ...";
00189 std::auto_ptr<CastorChannelQuality> result (new CastorChannelQuality ());
00190 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00191 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00192 CastorChannelStatus item(cell->rawId(),CastorChannelStatus::GOOD);
00193 result->addValues(item);
00194 }
00195 return result;
00196 }
00197
00198 std::auto_ptr<CastorElectronicsMap> CastorHardcodeCalibrations::produceElectronicsMap (const CastorElectronicsMapRcd& rcd) {
00199 edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceElectronicsMap-> ...";
00200
00201 std::auto_ptr<CastorElectronicsMap> result (new CastorElectronicsMap ());
00202 CastorDbHardcode::makeHardcodeMap(*result);
00203 return result;
00204 }
00205
00206 std::auto_ptr<CastorRecoParams> CastorHardcodeCalibrations::produceRecoParams (const CastorRecoParamsRcd& rcd) {
00207 edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceRecoParams-> ...";
00208 std::auto_ptr<CastorRecoParams> result (new CastorRecoParams ());
00209 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00210 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00211 CastorRecoParam item = CastorDbHardcode::makeRecoParam (*cell);
00212 result->addValues(item);
00213 }
00214 return result;
00215 }
00216