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());
148  for (MESet::iterator qItr(meQualitySummary.beginChannel()); qItr != qEnd; qItr.toNextChannel()) {
149  DetId id(qItr->getId());
150 
151  int status(kGood);
152 
153  if (status == kGood && sLaser) {
154  for (map<int, unsigned>::iterator wlItr(laserWlToME_.begin()); wlItr != laserWlToME_.end(); ++wlItr) {
155  sLaser->use(wlItr->second);
156  if (sLaser->getBinContent(id) == kBad) {
157  status = kBad;
158  break;
159  }
160  }
161  }
162 
163  if (status == kGood && sLed) {
164  DetId id(qItr->getId());
165  if (id.subdetId() == EcalEndcap) {
166  for (map<int, unsigned>::iterator wlItr(ledWlToME_.begin()); wlItr != ledWlToME_.end(); ++wlItr) {
167  sLed->use(wlItr->second);
168  if (sLed->getBinContent(id) == kBad) {
169  status = kBad;
170  break;
171  }
172  }
173  }
174  }
175 
176  if (status == kGood && sTestPulse) {
177  for (map<int, unsigned>::iterator gainItr(tpGainToME_.begin()); gainItr != tpGainToME_.end(); ++gainItr) {
178  sTestPulse->use(gainItr->second);
179  if (sTestPulse->getBinContent(id) == kBad) {
180  status = kBad;
181  break;
182  }
183  }
184  }
185 
186  if (status == kGood && sPedestal) {
187  for (map<int, unsigned>::iterator gainItr(pedGainToME_.begin()); gainItr != pedGainToME_.end(); ++gainItr) {
188  sPedestal->use(gainItr->second);
189  if (sPedestal->getBinContent(id) == kBad) {
190  status = kBad;
191  break;
192  }
193  }
194  }
195 
196  qItr->setBinContent(status);
197  }
198 
199  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
200  if (memDCCIndex(iDCC + 1) == unsigned(-1))
201  continue;
202  for (unsigned iPN(0); iPN < 10; ++iPN) {
203  int subdet(0);
204  if (iDCC >= kEBmLow && iDCC <= kEBpHigh)
205  subdet = EcalBarrel;
206  else
207  subdet = EcalEndcap;
208 
209  EcalPnDiodeDetId id(subdet, iDCC + 1, iPN + 1);
210 
211  int status(kGood);
212 
213  if (sPNIntegrity.getBinContent(id) == kBad)
214  status = kBad;
215 
216  if (status == kGood && sLaserPN) {
217  for (map<int, unsigned>::iterator wlItr(laserWlToME_.begin()); wlItr != laserWlToME_.end(); ++wlItr) {
218  sLaserPN->use(wlItr->second);
219  if (sLaserPN->getBinContent(id) == kBad) {
220  status = kBad;
221  break;
222  }
223  }
224  }
225 
226  if (status == kGood && sLedPN) {
227  for (map<int, unsigned>::iterator wlItr(ledWlToME_.begin()); wlItr != ledWlToME_.end(); ++wlItr) {
228  sLedPN->use(wlItr->second);
229  if (sLedPN->getBinContent(id) == kBad) {
230  status = kBad;
231  break;
232  }
233  }
234  }
235 
236  if (status == kGood && sTestPulsePN) {
237  for (map<int, unsigned>::iterator gainItr(tpPNGainToME_.begin()); gainItr != tpPNGainToME_.end(); ++gainItr) {
238  sTestPulsePN->use(gainItr->second);
239  if (sTestPulsePN->getBinContent(id) == kBad) {
240  status = kBad;
241  break;
242  }
243  }
244  }
245 
246  if (status == kGood && sPedestalPN) {
247  for (map<int, unsigned>::iterator gainItr(pedPNGainToME_.begin()); gainItr != pedPNGainToME_.end();
248  ++gainItr) {
249  sPedestalPN->use(gainItr->second);
250  if (sPedestalPN->getBinContent(id) == kBad) {
251  status = kBad;
252  break;
253  }
254  }
255  }
256 
257  mePNQualitySummary.setBinContent(id, status);
258  }
259  }
260  }
261 
263 } // namespace ecaldqm
unsigned memDCCIndex(unsigned)
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:112
std::map< int, unsigned > pedPNGainToME_
double getBinContent(DetId const &_id, int _bin=0) const override
Definition: MESetMulti.h:81
bool using_(std::string const &_name, ProcessType _type=kJob) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const_iterator & toNextChannel()
Definition: MESet.h:289
void setParams(edm::ParameterSet const &) override
void use(unsigned) const
Definition: MESetMulti.cc:130
std::set< std::string > qualitySummaries_
MESetCollection sources_
Definition: DetId.h:17
MESetCollection MEs_
Definition: DQWorker.h:78
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:31
unsigned getIndex(PathReplacements const &) const
Definition: MESetMulti.cc:137