CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Original Author:  Fedor Ratnikov
00003 // $Id: HcalHardcodeCalibrations.cc,v 1.25 2011/02/15 10:41:16 rofierzy Exp $
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 // class decleration
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   //parsing record parameters
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     if ((*objectName == "RecoParams") || all) {
00152       setWhatProduced (this, &HcalHardcodeCalibrations::produceRecoParams);
00153       findingRecord <HcalRecoParamsRcd> ();
00154     }
00155     if ((*objectName == "LongRecoParams") || all) {
00156       setWhatProduced (this, &HcalHardcodeCalibrations::produceLongRecoParams);
00157       findingRecord <HcalLongRecoParamsRcd> ();
00158     }
00159     if ((*objectName == "MCParams") || all) {
00160       setWhatProduced (this, &HcalHardcodeCalibrations::produceMCParams);
00161       findingRecord <HcalMCParamsRcd> ();
00162     }
00163   }
00164 }
00165 
00166 
00167 HcalHardcodeCalibrations::~HcalHardcodeCalibrations()
00168 {
00169 }
00170 
00171 
00172 //
00173 // member functions
00174 //
00175 void 
00176 HcalHardcodeCalibrations::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& iKey, const edm::IOVSyncValue& iTime, edm::ValidityInterval& oInterval ) {
00177   std::string record = iKey.name ();
00178   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::setIntervalFor-> key: " << record << " time: " << iTime.eventID() << '/' << iTime.time ().value ();
00179   oInterval = edm::ValidityInterval (edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); //infinite
00180 }
00181 
00182 std::auto_ptr<HcalPedestals> HcalHardcodeCalibrations::producePedestals (const HcalPedestalsRcd&) {
00183   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::producePedestals-> ...";
00184   std::auto_ptr<HcalPedestals> result (new HcalPedestals (false));
00185   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00186   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00187     HcalPedestal item = HcalDbHardcode::makePedestal (*cell);
00188     result->addValues(item,h2mode_);
00189   }
00190   return result;
00191 }
00192 
00193 std::auto_ptr<HcalPedestalWidths> HcalHardcodeCalibrations::producePedestalWidths (const HcalPedestalWidthsRcd&) {
00194   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::producePedestalWidths-> ...";
00195   std::auto_ptr<HcalPedestalWidths> result (new HcalPedestalWidths (false));
00196   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00197   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00198     HcalPedestalWidth item = HcalDbHardcode::makePedestalWidth (*cell);
00199     result->addValues(item,h2mode_);
00200   }
00201   return result;
00202 }
00203 
00204 std::auto_ptr<HcalGains> HcalHardcodeCalibrations::produceGains (const HcalGainsRcd&) {
00205   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceGains-> ...";
00206   std::auto_ptr<HcalGains> result (new HcalGains ());
00207   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00208   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00209     HcalGain item = HcalDbHardcode::makeGain (*cell);
00210     result->addValues(item,h2mode_);
00211   }
00212   return result;
00213 }
00214 
00215 std::auto_ptr<HcalGainWidths> HcalHardcodeCalibrations::produceGainWidths (const HcalGainWidthsRcd&) {
00216   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceGainWidths-> ...";
00217   std::auto_ptr<HcalGainWidths> result (new HcalGainWidths ());
00218   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00219   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00220     HcalGainWidth item = HcalDbHardcode::makeGainWidth (*cell);
00221     result->addValues(item,h2mode_);
00222   }
00223   return result;
00224 }
00225 
00226 std::auto_ptr<HcalQIEData> HcalHardcodeCalibrations::produceQIEData (const HcalQIEDataRcd& rcd) {
00227   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceQIEData-> ...";
00228   std::auto_ptr<HcalQIEData> result (new HcalQIEData ());
00229   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00230   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00231     HcalQIECoder coder = HcalDbHardcode::makeQIECoder (*cell);
00232     result->addCoder (coder,h2mode_);
00233   }
00234   return result;
00235 }
00236 
00237 std::auto_ptr<HcalChannelQuality> HcalHardcodeCalibrations::produceChannelQuality (const HcalChannelQualityRcd& rcd) {
00238   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceChannelQuality-> ...";
00239   std::auto_ptr<HcalChannelQuality> result (new HcalChannelQuality ());
00240   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00241   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00242     HcalChannelStatus item(cell->rawId(),0);
00243     result->addValues(item,h2mode_);
00244   }
00245   return result;
00246 }
00247 
00248 
00249 std::auto_ptr<HcalRespCorrs> HcalHardcodeCalibrations::produceRespCorrs (const HcalRespCorrsRcd& rcd) {
00250   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceRespCorrs-> ...";
00251   std::auto_ptr<HcalRespCorrs> result (new HcalRespCorrs ());
00252   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00253   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00254     HcalRespCorr item(cell->rawId(),1.0);
00255     result->addValues(item,h2mode_);
00256   }
00257   return result;
00258 }
00259 
00260 std::auto_ptr<HcalLUTCorrs> HcalHardcodeCalibrations::produceLUTCorrs (const HcalLUTCorrsRcd& rcd) {
00261   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceLUTCorrs-> ...";
00262   std::auto_ptr<HcalLUTCorrs> result (new HcalLUTCorrs ());
00263   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00264   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00265     HcalLUTCorr item(cell->rawId(),1.0);
00266     result->addValues(item,h2mode_);
00267   }
00268   return result;
00269 }
00270 
00271 std::auto_ptr<HcalPFCorrs> HcalHardcodeCalibrations::producePFCorrs (const HcalPFCorrsRcd& rcd) {
00272   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::producePFCorrs-> ...";
00273   std::auto_ptr<HcalPFCorrs> result (new HcalPFCorrs ());
00274   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00275   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00276     HcalPFCorr item(cell->rawId(),1.0);
00277     result->addValues(item,h2mode_);
00278   }
00279   return result;
00280 }
00281 
00282 std::auto_ptr<HcalTimeCorrs> HcalHardcodeCalibrations::produceTimeCorrs (const HcalTimeCorrsRcd& rcd) {
00283   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceTimeCorrs-> ...";
00284   std::auto_ptr<HcalTimeCorrs> result (new HcalTimeCorrs ());
00285   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00286   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00287     HcalTimeCorr item(cell->rawId(),0.0);
00288     result->addValues(item,h2mode_);
00289   }
00290   return result;
00291 }
00292 
00293 std::auto_ptr<HcalZSThresholds> HcalHardcodeCalibrations::produceZSThresholds (const HcalZSThresholdsRcd& rcd) {
00294   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceZSThresholds-> ...";
00295   std::auto_ptr<HcalZSThresholds> result (new HcalZSThresholds ());
00296   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00297   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00298     HcalZSThreshold item(cell->rawId(),0);
00299     result->addValues(item,h2mode_);
00300   }
00301   return result;
00302 }
00303 
00304 
00305 std::auto_ptr<HcalL1TriggerObjects> HcalHardcodeCalibrations::produceL1TriggerObjects (const HcalL1TriggerObjectsRcd& rcd) {
00306   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceL1TriggerObjects-> ...";
00307   std::auto_ptr<HcalL1TriggerObjects> result (new HcalL1TriggerObjects ());
00308   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00309   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00310     HcalL1TriggerObject item(cell->rawId(),0., 1., 0);
00311     result->addValues(item,h2mode_);
00312   }
00313   // add tag and algo values
00314   result->setTagString("hardcoded");
00315   result->setAlgoString("hardcoded");
00316   return result;
00317 }
00318 
00319 
00320 
00321 
00322 std::auto_ptr<HcalElectronicsMap> HcalHardcodeCalibrations::produceElectronicsMap (const HcalElectronicsMapRcd& rcd) {
00323   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceElectronicsMap-> ...";
00324 
00325   std::auto_ptr<HcalElectronicsMap> result (new HcalElectronicsMap ());
00326   HcalDbHardcode::makeHardcodeMap(*result);
00327   return result;
00328 }
00329 
00330 std::auto_ptr<HcalValidationCorrs> HcalHardcodeCalibrations::produceValidationCorrs (const HcalValidationCorrsRcd& rcd) {
00331   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceValidationCorrs-> ...";
00332   std::auto_ptr<HcalValidationCorrs> result (new HcalValidationCorrs ());
00333   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00334   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00335     HcalValidationCorr item(cell->rawId(),1.0);
00336     result->addValues(item,h2mode_);
00337   }
00338   return result;
00339 }
00340 
00341 std::auto_ptr<HcalLutMetadata> HcalHardcodeCalibrations::produceLutMetadata (const HcalLutMetadataRcd& rcd) {
00342   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceLutMetadata-> ...";
00343   std::auto_ptr<HcalLutMetadata> result (new HcalLutMetadata ());
00344 
00345   result->setRctLsb( 0.25 );
00346   result->setNominalGain( 0.177 );
00347 
00348   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00349   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00350     HcalLutMetadatum item(cell->rawId(),1.0,1,1);
00351     result->addValues(item,h2mode_);
00352   }
00353   return result;
00354 }
00355 
00356 std::auto_ptr<HcalDcsValues> 
00357   HcalHardcodeCalibrations::produceDcsValues (const HcalDcsRcd& rcd) {
00358   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceDcsValues-> ...";
00359   std::auto_ptr<HcalDcsValues> result(new HcalDcsValues);
00360   return result;
00361 }
00362 
00363 std::auto_ptr<HcalDcsMap> HcalHardcodeCalibrations::produceDcsMap (const HcalDcsMapRcd& rcd) {
00364   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceDcsMap-> ...";
00365 
00366   std::auto_ptr<HcalDcsMap> result (new HcalDcsMap ());
00367   HcalDbHardcode::makeHardcodeDcsMap(*result);
00368   return result;
00369 }
00370 
00371 std::auto_ptr<HcalRecoParams> HcalHardcodeCalibrations::produceRecoParams (const HcalRecoParamsRcd&) {
00372   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceRecoParams-> ...";
00373   std::auto_ptr<HcalRecoParams> result (new HcalRecoParams ());
00374   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00375   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00376     HcalRecoParam item = HcalDbHardcode::makeRecoParam (*cell);
00377     result->addValues(item,h2mode_);
00378   }
00379   return result;
00380 }
00381 
00382 std::auto_ptr<HcalLongRecoParams> HcalHardcodeCalibrations::produceLongRecoParams (const HcalLongRecoParamsRcd&) {
00383   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceLongRecoParams-> ...";
00384   std::auto_ptr<HcalLongRecoParams> result (new HcalLongRecoParams ());
00385   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00386   std::vector <unsigned int> mSignal; 
00387   mSignal.push_back(4); 
00388   mSignal.push_back(5); 
00389   mSignal.push_back(6);
00390   std::vector <unsigned int> mNoise;  
00391   mNoise.push_back(1);  
00392   mNoise.push_back(2);  
00393   mNoise.push_back(3);
00394   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00395     if (cell->isHcalZDCDetId())
00396       {
00397         HcalLongRecoParam item(cell->rawId(),mSignal,mNoise);
00398         result->addValues(item,h2mode_);
00399       }
00400   }
00401   return result;
00402 }
00403 
00404 std::auto_ptr<HcalMCParams> HcalHardcodeCalibrations::produceMCParams (const HcalMCParamsRcd&) {
00405   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceMCParams-> ...";
00406   std::auto_ptr<HcalMCParams> result (new HcalMCParams ());
00407   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00408   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00409     HcalMCParam item(cell->rawId(),0);
00410     result->addValues(item,h2mode_);
00411   }
00412   return result;
00413 }
00414