CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/RecoEcal/EgammaCoreTools/plugins/EcalNextToDeadChannelESProducer.cc

Go to the documentation of this file.
00001 
00002 
00003 #include "boost/shared_ptr.hpp"
00004 #include "FWCore/Framework/interface/ModuleFactory.h"
00005 #include "FWCore/Framework/interface/ESProducer.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00009 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
00010 #include "RecoEcal/EgammaCoreTools/interface/EcalNextToDeadChannel.h"
00011 #include "RecoEcal/EgammaCoreTools/interface/EcalNextToDeadChannelRcd.h"
00012 #include "RecoEcal/EgammaCoreTools/interface/EcalTools.h"
00013 
00025 class EcalNextToDeadChannelESProducer : public edm::ESProducer {
00026   
00027 public:
00028   EcalNextToDeadChannelESProducer(const edm::ParameterSet& iConfig);
00029   
00030   typedef boost::shared_ptr<EcalNextToDeadChannel> ReturnType;
00031   
00032   ReturnType produce(const EcalNextToDeadChannelRcd& iRecord);
00033   
00034 
00035 
00036 private:
00037 
00038   void findNextToDeadChannelsCallback(const EcalChannelStatusRcd& chs);
00039   
00040   // threshold above which a channel will be considered "dead"
00041   int statusThreshold_;
00042 
00043   ReturnType returnRcd_;
00044 };
00045 
00046 EcalNextToDeadChannelESProducer::EcalNextToDeadChannelESProducer(const edm::ParameterSet& iConfig){
00047   //the following line is needed to tell the framework what
00048   // data is being produced
00049   setWhatProduced(this, 
00050                   dependsOn (&EcalNextToDeadChannelESProducer::findNextToDeadChannelsCallback));
00051 
00052   statusThreshold_= iConfig.getParameter<int>("channelStatusThresholdForDead");
00053 
00054   returnRcd_=ReturnType(new EcalNextToDeadChannel);
00055 }
00056 
00057 
00058 
00059 EcalNextToDeadChannelESProducer::ReturnType
00060 EcalNextToDeadChannelESProducer::produce(const EcalNextToDeadChannelRcd& iRecord){
00061   
00062   return returnRcd_ ;
00063 }
00064 
00065 
00066 void 
00067 EcalNextToDeadChannelESProducer::
00068 findNextToDeadChannelsCallback(const EcalChannelStatusRcd& chs){
00069 
00070   
00071 
00072   EcalNextToDeadChannel* rcd= new EcalNextToDeadChannel;
00073 
00074   // Find channels next to dead ones and fill corresponding record
00075 
00076   edm::ESHandle <EcalChannelStatus> h;
00077   chs.get (h);
00078   
00079   for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
00080     if(ieta==0) continue;
00081     for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00082       if (EBDetId::validDetId(ieta,iphi)) {
00083         
00084         EBDetId detid(ieta,iphi);
00085         
00086         if (EcalTools::isNextToDeadFromNeighbours(detid,
00087                                                   *h,
00088                                                   statusThreshold_)){
00089           
00090           
00091           rcd->setValue(detid,1);
00092         };
00093       }
00094     } // for phi
00095   } // for eta
00096   
00097   // endcap
00098 
00099   for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00100     for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00101   
00102       if (EEDetId::validDetId(iX,iY,1)) {
00103         EEDetId detid(iX,iY,1);
00104 
00105         if (EcalTools::isNextToDeadFromNeighbours(detid,
00106                                                   *h,
00107                                                   statusThreshold_)){
00108           rcd->setValue(detid,1);
00109         };
00110         
00111       }
00112 
00113       if (EEDetId::validDetId(iX,iY,-1)) {
00114         EEDetId detid(iX,iY,-1);
00115 
00116         if (EcalTools::isNextToDeadFromNeighbours(detid,
00117                                                   *h,
00118                                                   statusThreshold_)){
00119      
00120           rcd->setValue(detid,1);
00121         };
00122       }
00123     } // for iy
00124   } // for ix
00125   
00126   returnRcd_.reset(rcd);
00127 }
00128 
00129 //define this as a plug-in
00130 DEFINE_FWK_EVENTSETUP_MODULE(EcalNextToDeadChannelESProducer);
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 // Configure (x)emacs for this file ...
00140 // Local Variables:
00141 // mode:c++
00142 // compile-command: "cd .. ; scram b"
00143 // End: