CMS 3D CMS Logo

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