CMS 3D CMS Logo

CalibrationSummaryClient.cc
Go to the documentation of this file.
2 
5 
7 
9 
10 #include <algorithm>
11 
12 namespace ecaldqm {
14  : DQWorkerClient(),
15  laserWlToME_(),
16  ledWlToME_(),
17  tpGainToME_(),
18  tpPNGainToME_(),
19  pedGainToME_(),
20  pedPNGainToME_() {}
21 
23  std::vector<std::string> sourceList(_params.getUntrackedParameter<std::vector<std::string> >("activeSources"));
24  if (std::find(sourceList.begin(), sourceList.end(), "Laser") == sourceList.end()) {
25  sources_.erase(std::string("Laser"));
26  sources_.erase(std::string("LaserPN"));
27  }
28  if (std::find(sourceList.begin(), sourceList.end(), "Led") == sourceList.end()) {
29  sources_.erase(std::string("Led"));
30  sources_.erase(std::string("LedPN"));
31  }
32  if (std::find(sourceList.begin(), sourceList.end(), "TestPulse") == sourceList.end()) {
33  sources_.erase(std::string("TestPulse"));
34  sources_.erase(std::string("TestPulsePN"));
35  }
36  if (std::find(sourceList.begin(), sourceList.end(), "Pedestal") == sourceList.end()) {
37  sources_.erase(std::string("Pedestal"));
38  sources_.erase(std::string("PedestalPN"));
39  }
40 
42 
43  if (using_("Laser")) {
44  repl.clear();
45  std::vector<int> laserWavelengths(_params.getUntrackedParameter<std::vector<int> >("laserWavelengths"));
46  MESetMulti const& laser(static_cast<MESetMulti const&>(sources_.at("Laser")));
47  unsigned nWL(laserWavelengths.size());
48  for (unsigned iWL(0); iWL != nWL; ++iWL) {
49  int wl(laserWavelengths[iWL]);
50  if (wl <= 0 || wl >= 5)
51  throw cms::Exception("InvalidConfiguration") << "Laser Wavelength";
52  repl["wl"] = std::to_string(wl);
53  laserWlToME_[wl] = laser.getIndex(repl);
54  }
55  }
56 
57  if (using_("Led")) {
58  repl.clear();
59  std::vector<int> ledWavelengths(_params.getUntrackedParameter<std::vector<int> >("ledWavelengths"));
60  MESetMulti const& led(static_cast<MESetMulti const&>(sources_.at("Led")));
61  unsigned nWL(ledWavelengths.size());
62  for (unsigned iWL(0); iWL != nWL; ++iWL) {
63  int wl(ledWavelengths[iWL]);
64  if (wl <= 0 || wl >= 5)
65  throw cms::Exception("InvalidConfiguration") << "Led Wavelength";
66  repl["wl"] = std::to_string(wl);
67  ledWlToME_[wl] = led.getIndex(repl);
68  }
69  }
70 
71  if (using_("TestPulse")) {
72  repl.clear();
73  std::vector<int> tpMGPAGains(_params.getUntrackedParameter<std::vector<int> >("testPulseMGPAGains"));
74  MESetMulti const& tp(static_cast<MESetMulti const&>(sources_.at("TestPulse")));
75  unsigned nG(tpMGPAGains.size());
76  for (unsigned iG(0); iG != nG; ++iG) {
77  int gain(tpMGPAGains[iG]);
78  if (gain != 1 && gain != 6 && gain != 12)
79  throw cms::Exception("InvalidConfiguration") << "MGPA gain";
80  repl["gain"] = std::to_string(gain);
81  tpGainToME_[gain] = tp.getIndex(repl);
82  }
83 
84  repl.clear();
85  std::vector<int> tpMGPAGainsPN(_params.getUntrackedParameter<std::vector<int> >("testPulseMGPAGainsPN"));
86  MESetMulti const& tppn(static_cast<MESetMulti const&>(sources_.at("TestPulsePN")));
87  unsigned nGPN(tpMGPAGainsPN.size());
88  for (unsigned iG(0); iG != nGPN; ++iG) {
89  int gain(tpMGPAGainsPN[iG]);
90  if (gain != 1 && gain != 16)
91  throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
92  repl["pngain"] = std::to_string(gain);
93  tpPNGainToME_[gain] = tppn.getIndex(repl);
94  }
95  }
96 
97  if (using_("Pedestal")) {
98  repl.clear();
99  std::vector<int> pedMGPAGains(_params.getUntrackedParameter<std::vector<int> >("pedestalMGPAGains"));
100  MESetMulti const& ped(static_cast<MESetMulti const&>(sources_.at("Pedestal")));
101  unsigned nG(pedMGPAGains.size());
102  for (unsigned iG(0); iG != nG; ++iG) {
103  int gain(pedMGPAGains[iG]);
104  if (gain != 1 && gain != 6 && gain != 12)
105  throw cms::Exception("InvalidConfiguration") << "MGPA gain";
106  repl["gain"] = std::to_string(gain);
107  pedGainToME_[gain] = ped.getIndex(repl);
108  }
109 
110  repl.clear();
111  std::vector<int> pedMGPAGainsPN(_params.getUntrackedParameter<std::vector<int> >("pedestalMGPAGainsPN"));
112  MESetMulti const& pedpn(static_cast<MESetMulti const&>(sources_.at("PedestalPN")));
113  unsigned nGPN(pedMGPAGainsPN.size());
114  for (unsigned iG(0); iG != nGPN; ++iG) {
115  int gain(pedMGPAGainsPN[iG]);
116  if (gain != 1 && gain != 16)
117  throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
118  repl["pngain"] = std::to_string(gain);
119  pedPNGainToME_[gain] = pedpn.getIndex(repl);
120  }
121  }
122 
123  qualitySummaries_.insert("QualitySummary");
124  qualitySummaries_.insert("PNQualitySummary");
125  }
126 
128  using namespace std;
129 
130  MESet& meQualitySummary(MEs_.at("QualitySummary"));
131  MESet& mePNQualitySummary(MEs_.at("PNQualitySummary"));
132 
133  MESetMulti const* sLaser(using_("Laser") ? static_cast<MESetMulti const*>(&sources_.at("Laser")) : nullptr);
134  MESetMulti const* sLaserPN(using_("LaserPN") ? static_cast<MESetMulti const*>(&sources_.at("LaserPN")) : nullptr);
135  MESetMulti const* sLed(using_("Led") ? static_cast<MESetMulti const*>(&sources_.at("Led")) : nullptr);
136  MESetMulti const* sLedPN(using_("LedPN") ? static_cast<MESetMulti const*>(&sources_.at("LedPN")) : nullptr);
137  MESetMulti const* sTestPulse(using_("TestPulse") ? static_cast<MESetMulti const*>(&sources_.at("TestPulse"))
138  : nullptr);
139  MESetMulti const* sTestPulsePN(using_("TestPulsePN") ? static_cast<MESetMulti const*>(&sources_.at("TestPulsePN"))
140  : nullptr);
141  MESetMulti const* sPedestal(using_("Pedestal") ? static_cast<MESetMulti const*>(&sources_.at("Pedestal"))
142  : nullptr);
143  MESetMulti const* sPedestalPN(using_("PedestalPN") ? static_cast<MESetMulti const*>(&sources_.at("PedestalPN"))
144  : nullptr);
145  MESet const& sPNIntegrity(sources_.at("PNIntegrity"));
146 
147  MESet::iterator qEnd(meQualitySummary.end(GetElectronicsMap()));
148  for (MESet::iterator qItr(meQualitySummary.beginChannel(GetElectronicsMap())); qItr != qEnd;
150  DetId id(qItr->getId());
151 
152  int status(kGood);
153 
154  if (status == kGood && sLaser) {
155  for (map<int, unsigned>::iterator wlItr(laserWlToME_.begin()); wlItr != laserWlToME_.end(); ++wlItr) {
156  sLaser->use(wlItr->second);
157  if (sLaser->getBinContent(getEcalDQMSetupObjects(), id) == kBad) {
158  status = kBad;
159  break;
160  }
161  }
162  }
163 
164  if (status == kGood && sLed) {
165  DetId id(qItr->getId());
166  if (id.subdetId() == EcalEndcap) {
167  for (map<int, unsigned>::iterator wlItr(ledWlToME_.begin()); wlItr != ledWlToME_.end(); ++wlItr) {
168  sLed->use(wlItr->second);
169  if (sLed->getBinContent(getEcalDQMSetupObjects(), id) == kBad) {
170  status = kBad;
171  break;
172  }
173  }
174  }
175  }
176 
177  if (status == kGood && sTestPulse) {
178  for (map<int, unsigned>::iterator gainItr(tpGainToME_.begin()); gainItr != tpGainToME_.end(); ++gainItr) {
179  sTestPulse->use(gainItr->second);
180  if (sTestPulse->getBinContent(getEcalDQMSetupObjects(), id) == kBad) {
181  status = kBad;
182  break;
183  }
184  }
185  }
186 
187  if (status == kGood && sPedestal) {
188  for (map<int, unsigned>::iterator gainItr(pedGainToME_.begin()); gainItr != pedGainToME_.end(); ++gainItr) {
189  sPedestal->use(gainItr->second);
190  if (sPedestal->getBinContent(getEcalDQMSetupObjects(), id) == kBad) {
191  status = kBad;
192  break;
193  }
194  }
195  }
196 
197  qItr->setBinContent(status);
198  }
199 
200  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
201  if (memDCCIndex(iDCC + 1) == unsigned(-1))
202  continue;
203  for (unsigned iPN(0); iPN < 10; ++iPN) {
204  int subdet(0);
205  if (iDCC >= kEBmLow && iDCC <= kEBpHigh)
206  subdet = EcalBarrel;
207  else
208  subdet = EcalEndcap;
209 
210  EcalPnDiodeDetId id(subdet, iDCC + 1, iPN + 1);
211 
212  int status(kGood);
213 
214  if (sPNIntegrity.getBinContent(getEcalDQMSetupObjects(), id) == kBad)
215  status = kBad;
216 
217  if (status == kGood && sLaserPN) {
218  for (map<int, unsigned>::iterator wlItr(laserWlToME_.begin()); wlItr != laserWlToME_.end(); ++wlItr) {
219  sLaserPN->use(wlItr->second);
220  if (sLaserPN->getBinContent(getEcalDQMSetupObjects(), id) == kBad) {
221  status = kBad;
222  break;
223  }
224  }
225  }
226 
227  if (status == kGood && sLedPN) {
228  for (map<int, unsigned>::iterator wlItr(ledWlToME_.begin()); wlItr != ledWlToME_.end(); ++wlItr) {
229  sLedPN->use(wlItr->second);
230  if (sLedPN->getBinContent(getEcalDQMSetupObjects(), id) == kBad) {
231  status = kBad;
232  break;
233  }
234  }
235  }
236 
237  if (status == kGood && sTestPulsePN) {
238  for (map<int, unsigned>::iterator gainItr(tpPNGainToME_.begin()); gainItr != tpPNGainToME_.end(); ++gainItr) {
239  sTestPulsePN->use(gainItr->second);
240  if (sTestPulsePN->getBinContent(getEcalDQMSetupObjects(), id) == kBad) {
241  status = kBad;
242  break;
243  }
244  }
245  }
246 
247  if (status == kGood && sPedestalPN) {
248  for (map<int, unsigned>::iterator gainItr(pedPNGainToME_.begin()); gainItr != pedPNGainToME_.end();
249  ++gainItr) {
250  sPedestalPN->use(gainItr->second);
251  if (sPedestalPN->getBinContent(getEcalDQMSetupObjects(), id) == kBad) {
252  status = kBad;
253  break;
254  }
255  }
256  }
257 
258  mePNQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, status);
259  }
260  }
261  }
262 
264 } // namespace ecaldqm
unsigned memDCCIndex(unsigned)
void use(unsigned) const
Definition: MESetMulti.cc:135
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:168
MESet & at(const std::string &key)
Definition: MESet.h:399
std::map< int, unsigned > pedPNGainToME_
const_iterator & toNextChannel(EcalElectronicsMapping const *electronicsMap)
Definition: MESet.h:320
double getBinContent(EcalDQMSetupObjects const edso, DetId const &_id, int _bin=0) const override
Definition: MESetMulti.h:111
std::string to_string(const V &value)
Definition: OMSAccess.h:77
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void setParams(edm::ParameterSet const &) override
std::set< std::string > qualitySummaries_
bool using_(std::string const &_name, ProcessType _type=kJob) const
MESetCollection sources_
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:150
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
Definition: DetId.h:17
unsigned getIndex(PathReplacements const &) const
Definition: MESetMulti.cc:142
MESetCollection MEs_
Definition: DQWorker.h:131
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:46
void erase(const std::string &key)
Definition: MESet.h:390