CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/CalibCalorimetry/CastorCalib/plugins/CastorHardcodeCalibrations.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Original Author:  Fedor Ratnikov
00003 // $Id: CastorHardcodeCalibrations.cc,v 1.4 2009/05/14 10:29:05 katsas Exp $
00004 // Adapted for CASTOR by L. Mundim
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 
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 // class declaration
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   //parsing record parameters
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 
00109   }
00110 }
00111 
00112 
00113 CastorHardcodeCalibrations::~CastorHardcodeCalibrations()
00114 {
00115 }
00116 
00117 
00118 //
00119 // member functions
00120 //
00121 void 
00122 CastorHardcodeCalibrations::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& iKey, const edm::IOVSyncValue& iTime, edm::ValidityInterval& oInterval ) {
00123   std::string record = iKey.name ();
00124   edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::setIntervalFor-> key: " << record << " time: " << iTime.eventID() << '/' << iTime.time ().value ();
00125   oInterval = edm::ValidityInterval (edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); //infinite
00126 }
00127 
00128 std::auto_ptr<CastorPedestals> CastorHardcodeCalibrations::producePedestals (const CastorPedestalsRcd&) {
00129   edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::producePedestals-> ...";
00130   std::auto_ptr<CastorPedestals> result (new CastorPedestals (false));
00131   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00132   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00133     CastorPedestal item = CastorDbHardcode::makePedestal (*cell);
00134     result->addValues(item);
00135   }
00136   return result;
00137 }
00138 
00139 std::auto_ptr<CastorPedestalWidths> CastorHardcodeCalibrations::producePedestalWidths (const CastorPedestalWidthsRcd&) {
00140   edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::producePedestalWidths-> ...";
00141   std::auto_ptr<CastorPedestalWidths> result (new CastorPedestalWidths (false));
00142   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00143   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00144     CastorPedestalWidth item = CastorDbHardcode::makePedestalWidth (*cell);
00145     result->addValues(item);
00146   }
00147   return result;
00148 }
00149 
00150 std::auto_ptr<CastorGains> CastorHardcodeCalibrations::produceGains (const CastorGainsRcd&) {
00151   edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceGains-> ...";
00152   std::auto_ptr<CastorGains> result (new CastorGains ());
00153   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00154   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00155     CastorGain item = CastorDbHardcode::makeGain (*cell);
00156     result->addValues(item);
00157   }
00158   return result;
00159 }
00160 
00161 std::auto_ptr<CastorGainWidths> CastorHardcodeCalibrations::produceGainWidths (const CastorGainWidthsRcd&) {
00162   edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceGainWidths-> ...";
00163   std::auto_ptr<CastorGainWidths> result (new CastorGainWidths ());
00164   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00165   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00166     CastorGainWidth item = CastorDbHardcode::makeGainWidth (*cell);
00167     result->addValues(item);
00168   }
00169   return result;
00170 }
00171 
00172 std::auto_ptr<CastorQIEData> CastorHardcodeCalibrations::produceQIEData (const CastorQIEDataRcd& rcd) {
00173   edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceQIEData-> ...";
00174   std::auto_ptr<CastorQIEData> result (new CastorQIEData ());
00175   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00176   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00177     CastorQIECoder coder = CastorDbHardcode::makeQIECoder (*cell);
00178     result->addCoder(coder);
00179   }
00180   return result;
00181 }
00182 
00183 std::auto_ptr<CastorChannelQuality> CastorHardcodeCalibrations::produceChannelQuality (const CastorChannelQualityRcd& rcd) {
00184   edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceChannelQuality-> ...";
00185   std::auto_ptr<CastorChannelQuality> result (new CastorChannelQuality ());
00186   std::vector <HcalGenericDetId> cells = allCells(h2mode_);
00187   for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); cell++) {
00188     CastorChannelStatus item(cell->rawId(),CastorChannelStatus::GOOD);
00189     result->addValues(item);
00190   }
00191   return result;
00192 }
00193 
00194 std::auto_ptr<CastorElectronicsMap> CastorHardcodeCalibrations::produceElectronicsMap (const CastorElectronicsMapRcd& rcd) {
00195   edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceElectronicsMap-> ...";
00196 
00197   std::auto_ptr<CastorElectronicsMap> result (new CastorElectronicsMap ());
00198   CastorDbHardcode::makeHardcodeMap(*result);
00199   return result;
00200 }
00201