CMS 3D CMS Logo

EcalNextToDeadChannelESProducer.cc
Go to the documentation of this file.
1 #include <memory>
13 
24 public:
26 
27  typedef std::shared_ptr<EcalNextToDeadChannel> ReturnType;
28 
30 
31 private:
33 
35 
37 
39  // threshold above which a channel will be considered "dead"
41 };
42 
44  : channelToken_(setWhatProduced(this).consumesFrom<EcalChannelStatus, EcalChannelStatusRcd>()) {
45  statusThreshold_ = iConfig.getParameter<int>("channelStatusThresholdForDead");
46 }
47 
49  const EcalNextToDeadChannelRcd& iRecord) {
50  auto host = holder_.makeOrGet([]() { return new HostType; });
51 
52  host->ifRecordChanges<EcalChannelStatusRcd>(
53  iRecord, [this, h = host.get()](auto const& rec) { setupNextToDeadChannels(rec, h); });
54 
55  return host;
56 }
57 
59  EcalNextToDeadChannel* rcd) {
60  rcd->clear();
61 
62  // Find channels next to dead ones and fill corresponding record
63 
64  EcalChannelStatus const& h = chs.get(channelToken_);
65 
66  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
67  if (ieta == 0)
68  continue;
69  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
71  EBDetId detid(ieta, iphi);
72 
74  rcd->setValue(detid, 1);
75  };
76  }
77  } // for phi
78  } // for eta
79 
80  // endcap
81 
82  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
83  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
84  if (EEDetId::validDetId(iX, iY, 1)) {
85  EEDetId detid(iX, iY, 1);
86 
88  rcd->setValue(detid, 1);
89  };
90  }
91 
92  if (EEDetId::validDetId(iX, iY, -1)) {
93  EEDetId detid(iX, iY, -1);
94 
96  rcd->setValue(detid, 1);
97  };
98  }
99  } // for iy
100  } // for ix
101 }
102 
103 //define this as a plug-in
EcalNextToDeadChannelESProducer::channelToken_
const edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > channelToken_
Definition: EcalNextToDeadChannelESProducer.cc:38
EcalNextToDeadChannelESProducer
Definition: EcalNextToDeadChannelESProducer.cc:23
EcalNextToDeadChannelESProducer::statusThreshold_
int statusThreshold_
Definition: EcalNextToDeadChannelESProducer.cc:40
EcalNextToDeadChannelESProducer::setupNextToDeadChannels
void setupNextToDeadChannels(const EcalChannelStatusRcd &, EcalNextToDeadChannel *)
Definition: EcalNextToDeadChannelESProducer.cc:58
ESHandle.h
EcalNextToDeadChannel.h
EcalTools::isNextToDeadFromNeighbours
static bool isNextToDeadFromNeighbours(const DetId &id, const EcalChannelStatus &chs, int chStatusThreshold)
same as isNextToDead, but will use information from the neighbour
Definition: EcalTools.cc:66
EBDetId
Definition: EBDetId.h:17
EcalNextToDeadChannelESProducer::HostType
edm::ESProductHost< EcalNextToDeadChannel, EcalChannelStatusRcd > HostType
Definition: EcalNextToDeadChannelESProducer.cc:34
ESProducer.h
EEDetId::IX_MIN
static const int IX_MIN
Definition: EEDetId.h:290
EEDetId::IY_MIN
static const int IY_MIN
Definition: EEDetId.h:294
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
query.host
string host
Definition: query.py:115
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
edm::ReusableObjectHolder< HostType >
edm::ReusableObjectHolder::makeOrGet
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn't an object already available, creates a new one using iFunc.
Definition: ReusableObjectHolder.h:126
ReusableObjectHolder.h
EcalNextToDeadChannelESProducer::holder_
edm::ReusableObjectHolder< HostType > holder_
Definition: EcalNextToDeadChannelESProducer.cc:36
EcalNextToDeadChannelESProducer::produce
ReturnType produce(const EcalNextToDeadChannelRcd &iRecord)
Definition: EcalNextToDeadChannelESProducer.cc:48
EBDetId::MAX_IPHI
static const int MAX_IPHI
Definition: EBDetId.h:137
EEDetId::IY_MAX
static const int IY_MAX
Definition: EEDetId.h:302
h
EEDetId
Definition: EEDetId.h:14
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
EcalCondObjectContainer::setValue
void setValue(const uint32_t id, const Item &item)
Definition: EcalCondObjectContainer.h:76
edm::ParameterSet
Definition: ParameterSet.h:47
EcalChannelStatusRcd
Definition: EcalChannelStatusRcd.h:5
EcalNextToDeadChannelRcd.h
EEDetId::IX_MAX
static const int IX_MAX
Definition: EEDetId.h:298
EcalTools.h
edm::ESGetToken
Definition: EventSetup.h:48
EBDetId::validDetId
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
ModuleFactory.h
edm::ESProductHost
Definition: ESProductHost.h:93
EcalNextToDeadChannelESProducer::ReturnType
std::shared_ptr< EcalNextToDeadChannel > ReturnType
Definition: EcalNextToDeadChannelESProducer.cc:27
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
edm::ESProducer
Definition: ESProducer.h:104
ESProductHost.h
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition: EventSetupRecordImplementation.h:74
ParameterSet.h
EcalChannelStatus.h
EcalChannelStatusRcd.h
EBDetId::MAX_IETA
static const int MAX_IETA
Definition: EBDetId.h:136
EcalNextToDeadChannelRcd
Definition: EcalNextToDeadChannelRcd.h:12
EcalNextToDeadChannelESProducer::EcalNextToDeadChannelESProducer
EcalNextToDeadChannelESProducer(const edm::ParameterSet &iConfig)
Definition: EcalNextToDeadChannelESProducer.cc:43
EBDetId::MIN_IPHI
static const int MIN_IPHI
Definition: EBDetId.h:135
EcalCondObjectContainer::clear
void clear()
Definition: EcalCondObjectContainer.h:25