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/HcalZDCDetId.h"
00012 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00013 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00014 #include "CalibCalorimetry/HcalAlgos/interface/HcalDbHardcode.h"
00015
00016 #include "CondFormats/DataRecord/interface/HcalAllRcds.h"
00017
00018 #include "Geometry/ForwardGeometry/interface/ZdcTopology.h"
00019 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021
00022 #include "HcalHardcodeCalibrations.h"
00023
00024
00025
00026
00027 using namespace cms;
00028
00029 namespace {
00030
00031 std::vector<HcalGenericDetId> allCells (bool h2_mode) {
00032 static std::vector<HcalGenericDetId> result;
00033 if (result.size () <= 0) {
00034 HcalTopology hcaltopology(h2_mode);
00035 for (int eta = -50; eta < 50; eta++) {
00036 for (int phi = 0; phi < 100; phi++) {
00037 for (int depth = 1; depth < 5; depth++) {
00038 for (int det = 1; det < 5; det++) {
00039 HcalDetId cell ((HcalSubdetector) det, eta, phi, depth);
00040 if (hcaltopology.valid(cell)) result.push_back (cell);
00041 }
00042 }
00043 }
00044 }
00045 ZdcTopology zdctopology;
00046 HcalZDCDetId zcell;
00047 HcalZDCDetId::Section section = HcalZDCDetId::EM;
00048 for(int depth= 1; depth < 6; depth++){
00049 zcell = HcalZDCDetId(section, true, depth);
00050 if(zdctopology.valid(zcell)) result.push_back(zcell);
00051 zcell = HcalZDCDetId(section, false, depth);
00052 if(zdctopology.valid(zcell)) result.push_back(zcell);
00053 }
00054 section = HcalZDCDetId::HAD;
00055 for(int depth= 1; depth < 5; depth++){
00056 zcell = HcalZDCDetId(section, true, depth);
00057 if(zdctopology.valid(zcell)) result.push_back(zcell);
00058 zcell = HcalZDCDetId(section, false, depth);
00059 if(zdctopology.valid(zcell)) result.push_back(zcell);
00060 }
00061 section = HcalZDCDetId::LUM;
00062 for(int depth= 1; depth < 3; depth++){
00063 zcell = HcalZDCDetId(section, true, depth);
00064 if(zdctopology.valid(zcell)) result.push_back(zcell);
00065 zcell = HcalZDCDetId(section, false, depth);
00066 if(zdctopology.valid(zcell)) result.push_back(zcell);
00067 }
00068 }
00069 return result;
00070 }
00071
00072 }
00073
00074 HcalHardcodeCalibrations::HcalHardcodeCalibrations ( const edm::ParameterSet& iConfig )
00075
00076 {
00077 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::HcalHardcodeCalibrations->...";
00078
00079 h2mode_=iConfig.getUntrackedParameter<bool>("H2Mode",false);
00080 std::vector <std::string> toGet = iConfig.getUntrackedParameter <std::vector <std::string> > ("toGet");
00081 for(std::vector <std::string>::iterator objectName = toGet.begin(); objectName != toGet.end(); ++objectName ) {
00082 bool all = *objectName == "all";
00083 if ((*objectName == "Pedestals") || all) {
00084 setWhatProduced (this, &HcalHardcodeCalibrations::producePedestals);
00085 findingRecord <HcalPedestalsRcd> ();
00086 }
00087 if ((*objectName == "PedestalWidths") || all) {
00088 setWhatProduced (this, &HcalHardcodeCalibrations::producePedestalWidths);
00089 findingRecord <HcalPedestalWidthsRcd> ();
00090 }
00091 if ((*objectName == "Gains") || all) {
00092 setWhatProduced (this, &HcalHardcodeCalibrations::produceGains);
00093 findingRecord <HcalGainsRcd> ();
00094 }
00095 if ((*objectName == "GainWidths") || all) {
00096 setWhatProduced (this, &HcalHardcodeCalibrations::produceGainWidths);
00097 findingRecord <HcalGainWidthsRcd> ();
00098 }
00099 if ((*objectName == "QIEData") || all) {
00100 setWhatProduced (this, &HcalHardcodeCalibrations::produceQIEData);
00101 findingRecord <HcalQIEDataRcd> ();
00102 }
00103 if ((*objectName == "ChannelQuality") || (*objectName == "channelQuality") || all) {
00104 setWhatProduced (this, &HcalHardcodeCalibrations::produceChannelQuality);
00105 findingRecord <HcalChannelQualityRcd> ();
00106 }
00107 if ((*objectName == "ElectronicsMap") || (*objectName == "electronicsMap") || all) {
00108 setWhatProduced (this, &HcalHardcodeCalibrations::produceElectronicsMap);
00109 findingRecord <HcalElectronicsMapRcd> ();
00110 }
00111 if ((*objectName == "ZSThresholds") || (*objectName == "zsThresholds") || all) {
00112 setWhatProduced (this, &HcalHardcodeCalibrations::produceZSThresholds);
00113 findingRecord <HcalZSThresholdsRcd> ();
00114 }
00115 if ((*objectName == "RespCorrs") || (*objectName == "ResponseCorrection") || all) {
00116 setWhatProduced (this, &HcalHardcodeCalibrations::produceRespCorrs);
00117 findingRecord <HcalRespCorrsRcd> ();
00118 }
00119 if ((*objectName == "LUTCorrs") || (*objectName == "LUTCorrection") || all) {
00120 setWhatProduced (this, &HcalHardcodeCalibrations::produceLUTCorrs);
00121 findingRecord <HcalLUTCorrsRcd> ();
00122 }
00123 if ((*objectName == "PFCorrs") || (*objectName == "PFCorrection") || all) {
00124 setWhatProduced (this, &HcalHardcodeCalibrations::producePFCorrs);
00125 findingRecord <HcalPFCorrsRcd> ();
00126 }
00127 if ((*objectName == "TimeCorrs") || (*objectName == "TimeCorrection") || all) {
00128 setWhatProduced (this, &HcalHardcodeCalibrations::produceTimeCorrs);
00129 findingRecord <HcalTimeCorrsRcd> ();
00130 }
00131 if ((*objectName == "L1TriggerObjects") || (*objectName == "L1Trigger") || all) {
00132 setWhatProduced (this, &HcalHardcodeCalibrations::produceL1TriggerObjects);
00133 findingRecord <HcalL1TriggerObjectsRcd> ();
00134 }
00135 if ((*objectName == "ValidationCorrs") || (*objectName == "ValidationCorrection") || all) {
00136 setWhatProduced (this, &HcalHardcodeCalibrations::produceValidationCorrs);
00137 findingRecord <HcalValidationCorrsRcd> ();
00138 }
00139 if ((*objectName == "LutMetadata") || (*objectName == "lutMetadata") || all) {
00140 setWhatProduced (this, &HcalHardcodeCalibrations::produceLutMetadata);
00141 findingRecord <HcalLutMetadataRcd> ();
00142 }
00143 if ((*objectName == "DcsValues") || all) {
00144 setWhatProduced (this, &HcalHardcodeCalibrations::produceDcsValues);
00145 findingRecord <HcalDcsRcd> ();
00146 }
00147 if ((*objectName == "DcsMap") || (*objectName == "dcsMap") || all) {
00148 setWhatProduced (this, &HcalHardcodeCalibrations::produceDcsMap);
00149 findingRecord <HcalDcsMapRcd> ();
00150 }
00151 }
00152 }
00153
00154
00155 HcalHardcodeCalibrations::~HcalHardcodeCalibrations()
00156 {
00157 }
00158
00159
00160
00161
00162
00163 void
00164 HcalHardcodeCalibrations::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& iKey, const edm::IOVSyncValue& iTime, edm::ValidityInterval& oInterval ) {
00165 std::string record = iKey.name ();
00166 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::setIntervalFor-> key: " << record << " time: " << iTime.eventID() << '/' << iTime.time ().value ();
00167 oInterval = edm::ValidityInterval (edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
00168 }
00169
00170 std::auto_ptr<HcalPedestals> HcalHardcodeCalibrations::producePedestals (const HcalPedestalsRcd&) {
00171 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::producePedestals-> ...";
00172 std::auto_ptr<HcalPedestals> result (new HcalPedestals (false));
00173 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00174 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00175 HcalPedestal item = HcalDbHardcode::makePedestal (*cell);
00176 result->addValues(item,h2mode_);
00177 }
00178 return result;
00179 }
00180
00181 std::auto_ptr<HcalPedestalWidths> HcalHardcodeCalibrations::producePedestalWidths (const HcalPedestalWidthsRcd&) {
00182 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::producePedestalWidths-> ...";
00183 std::auto_ptr<HcalPedestalWidths> result (new HcalPedestalWidths (false));
00184 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00185 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00186 HcalPedestalWidth item = HcalDbHardcode::makePedestalWidth (*cell);
00187 result->addValues(item,h2mode_);
00188 }
00189 return result;
00190 }
00191
00192 std::auto_ptr<HcalGains> HcalHardcodeCalibrations::produceGains (const HcalGainsRcd&) {
00193 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceGains-> ...";
00194 std::auto_ptr<HcalGains> result (new HcalGains ());
00195 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00196 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00197 HcalGain item = HcalDbHardcode::makeGain (*cell);
00198 result->addValues(item,h2mode_);
00199 }
00200 return result;
00201 }
00202
00203 std::auto_ptr<HcalGainWidths> HcalHardcodeCalibrations::produceGainWidths (const HcalGainWidthsRcd&) {
00204 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceGainWidths-> ...";
00205 std::auto_ptr<HcalGainWidths> result (new HcalGainWidths ());
00206 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00207 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00208 HcalGainWidth item = HcalDbHardcode::makeGainWidth (*cell);
00209 result->addValues(item,h2mode_);
00210 }
00211 return result;
00212 }
00213
00214 std::auto_ptr<HcalQIEData> HcalHardcodeCalibrations::produceQIEData (const HcalQIEDataRcd& rcd) {
00215 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceQIEData-> ...";
00216 std::auto_ptr<HcalQIEData> result (new HcalQIEData ());
00217 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00218 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00219 HcalQIECoder coder = HcalDbHardcode::makeQIECoder (*cell);
00220 result->addCoder (coder,h2mode_);
00221 }
00222 return result;
00223 }
00224
00225 std::auto_ptr<HcalChannelQuality> HcalHardcodeCalibrations::produceChannelQuality (const HcalChannelQualityRcd& rcd) {
00226 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceChannelQuality-> ...";
00227 std::auto_ptr<HcalChannelQuality> result (new HcalChannelQuality ());
00228 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00229 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00230 HcalChannelStatus item(cell->rawId(),0);
00231 result->addValues(item,h2mode_);
00232 }
00233 return result;
00234 }
00235
00236
00237 std::auto_ptr<HcalRespCorrs> HcalHardcodeCalibrations::produceRespCorrs (const HcalRespCorrsRcd& rcd) {
00238 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceRespCorrs-> ...";
00239 std::auto_ptr<HcalRespCorrs> result (new HcalRespCorrs ());
00240 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00241 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00242 HcalRespCorr item(cell->rawId(),1.0);
00243 result->addValues(item,h2mode_);
00244 }
00245 return result;
00246 }
00247
00248 std::auto_ptr<HcalLUTCorrs> HcalHardcodeCalibrations::produceLUTCorrs (const HcalLUTCorrsRcd& rcd) {
00249 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceLUTCorrs-> ...";
00250 std::auto_ptr<HcalLUTCorrs> result (new HcalLUTCorrs ());
00251 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00252 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00253 HcalLUTCorr item(cell->rawId(),1.0);
00254 result->addValues(item,h2mode_);
00255 }
00256 return result;
00257 }
00258
00259 std::auto_ptr<HcalPFCorrs> HcalHardcodeCalibrations::producePFCorrs (const HcalPFCorrsRcd& rcd) {
00260 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::producePFCorrs-> ...";
00261 std::auto_ptr<HcalPFCorrs> result (new HcalPFCorrs ());
00262 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00263 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00264 HcalPFCorr item(cell->rawId(),1.0);
00265 result->addValues(item,h2mode_);
00266 }
00267 return result;
00268 }
00269
00270 std::auto_ptr<HcalTimeCorrs> HcalHardcodeCalibrations::produceTimeCorrs (const HcalTimeCorrsRcd& rcd) {
00271 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceTimeCorrs-> ...";
00272 std::auto_ptr<HcalTimeCorrs> result (new HcalTimeCorrs ());
00273 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00274 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00275 HcalTimeCorr item(cell->rawId(),0.0);
00276 result->addValues(item,h2mode_);
00277 }
00278 return result;
00279 }
00280
00281 std::auto_ptr<HcalZSThresholds> HcalHardcodeCalibrations::produceZSThresholds (const HcalZSThresholdsRcd& rcd) {
00282 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceZSThresholds-> ...";
00283 std::auto_ptr<HcalZSThresholds> result (new HcalZSThresholds ());
00284 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00285 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00286 HcalZSThreshold item(cell->rawId(),0);
00287 result->addValues(item,h2mode_);
00288 }
00289 return result;
00290 }
00291
00292
00293 std::auto_ptr<HcalL1TriggerObjects> HcalHardcodeCalibrations::produceL1TriggerObjects (const HcalL1TriggerObjectsRcd& rcd) {
00294 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceL1TriggerObjects-> ...";
00295 std::auto_ptr<HcalL1TriggerObjects> result (new HcalL1TriggerObjects ());
00296 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00297 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00298 HcalL1TriggerObject item(cell->rawId(),0., 1., 0);
00299 result->addValues(item,h2mode_);
00300 }
00301
00302 result->setTagString("hardcoded");
00303 result->setAlgoString("hardcoded");
00304 return result;
00305 }
00306
00307
00308
00309
00310 std::auto_ptr<HcalElectronicsMap> HcalHardcodeCalibrations::produceElectronicsMap (const HcalElectronicsMapRcd& rcd) {
00311 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceElectronicsMap-> ...";
00312
00313 std::auto_ptr<HcalElectronicsMap> result (new HcalElectronicsMap ());
00314 HcalDbHardcode::makeHardcodeMap(*result);
00315 return result;
00316 }
00317
00318 std::auto_ptr<HcalValidationCorrs> HcalHardcodeCalibrations::produceValidationCorrs (const HcalValidationCorrsRcd& rcd) {
00319 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceValidationCorrs-> ...";
00320 std::auto_ptr<HcalValidationCorrs> result (new HcalValidationCorrs ());
00321 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00322 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00323 HcalValidationCorr item(cell->rawId(),1.0);
00324 result->addValues(item,h2mode_);
00325 }
00326 return result;
00327 }
00328
00329 std::auto_ptr<HcalLutMetadata> HcalHardcodeCalibrations::produceLutMetadata (const HcalLutMetadataRcd& rcd) {
00330 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceLutMetadata-> ...";
00331 std::auto_ptr<HcalLutMetadata> result (new HcalLutMetadata ());
00332
00333 result->setRctLsb( 0.25 );
00334 result->setNominalGain( 0.177 );
00335
00336 std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00337 for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00338 HcalLutMetadatum item(cell->rawId(),1.0,1,1);
00339 result->addValues(item,h2mode_);
00340 }
00341 return result;
00342 }
00343
00344 std::auto_ptr<HcalDcsValues>
00345 HcalHardcodeCalibrations::produceDcsValues (const HcalDcsRcd& rcd) {
00346 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceDcsValues-> ...";
00347 std::auto_ptr<HcalDcsValues> result(new HcalDcsValues);
00348 return result;
00349 }
00350
00351 std::auto_ptr<HcalDcsMap> HcalHardcodeCalibrations::produceDcsMap (const HcalDcsMapRcd& rcd) {
00352 edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceDcsMap-> ...";
00353
00354 std::auto_ptr<HcalDcsMap> result (new HcalDcsMap ());
00355 HcalDbHardcode::makeHardcodeDcsMap(*result);
00356 return result;
00357 }
00358