CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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) {
70  if (EBDetId::validDetId(ieta, 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
edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > const channelToken_
static const int MIN_IPHI
Definition: EBDetId.h:135
EcalNextToDeadChannelESProducer(const edm::ParameterSet &iConfig)
void setupNextToDeadChannels(const EcalChannelStatusRcd &, EcalNextToDeadChannel *)
static const int IX_MIN
Definition: EEDetId.h:290
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
static const int IY_MIN
Definition: EEDetId.h:294
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
std::shared_ptr< EcalNextToDeadChannel > ReturnType
void setValue(const uint32_t id, const Item &item)
edm::ESProductHost< EcalNextToDeadChannel, EcalChannelStatusRcd > HostType
std::shared_ptr< T > makeOrGet(FM &&iMakeFunc)
Takes an object from the queue if one is available, or creates one using iMakeFunc.
static const int IX_MAX
Definition: EEDetId.h:298
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
string host
Definition: query.py:115
static const int MAX_IPHI
Definition: EBDetId.h:137
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static const int MAX_IETA
Definition: EBDetId.h:136
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
static const int IY_MAX
Definition: EEDetId.h:302
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
ReturnType produce(const EcalNextToDeadChannelRcd &iRecord)
edm::ReusableObjectHolder< HostType > holder_