CMS 3D CMS Logo

SiPixelEDAClient.cc
Go to the documentation of this file.
2 
3 // Framework
10 
21 
24 
30 
32 
37 
38 #include <cmath>
39 #include <cstdio>
40 #include <iomanip>
41 #include <iostream>
42 #include <sstream>
43 #include <string>
44 
45 #define BUF_SIZE 256
46 
47 using namespace edm;
48 using namespace std;
49 //
50 // -- Constructor
51 //
53  // cout<<"Entering SiPixelEDAClient::SiPixelEDAClient: "<<endl;
54 
55  edm::LogInfo("SiPixelEDAClient") << " Creating SiPixelEDAClient "
56  << "\n";
57 
58  summaryFrequency_ = ps.getUntrackedParameter<int>("SummaryCreationFrequency", 20);
59  tkMapFrequency_ = ps.getUntrackedParameter<int>("TkMapCreationFrequency", 50);
60  staticUpdateFrequency_ = ps.getUntrackedParameter<int>("StaticUpdateFrequency", 10);
61  actionOnLumiSec_ = ps.getUntrackedParameter<bool>("ActionOnLumiSection", false); // client
62  actionOnRunEnd_ = ps.getUntrackedParameter<bool>("ActionOnRunEnd", true); // client
63  evtOffsetForInit_ = ps.getUntrackedParameter<int>("EventOffsetForInit", 10); // client
64  offlineXMLfile_ = ps.getUntrackedParameter<bool>("UseOfflineXMLFile", false); // client
65  hiRes_ = ps.getUntrackedParameter<bool>("HighResolutionOccupancy",
66  false); // client
67  noiseRate_ = ps.getUntrackedParameter<double>("NoiseRateCutValue", 0.001); // client
68  noiseRateDenominator_ = ps.getUntrackedParameter<int>("NEventsForNoiseCalculation", 100000); // client
69  Tier0Flag_ = ps.getUntrackedParameter<bool>("Tier0Flag", false); // client
70  doHitEfficiency_ = ps.getUntrackedParameter<bool>("DoHitEfficiency", true); // client
71  inputSource_ = ps.getUntrackedParameter<string>("inputSource", "source");
72  isUpgrade_ = ps.getUntrackedParameter<bool>("isUpgrade", false); // client
73 
74  if (!Tier0Flag_) {
75  string localPath = string("DQM/SiPixelMonitorClient/test/loader.html");
76  std::ifstream fin(edm::FileInPath(localPath).fullPath().c_str(), ios::in);
77  char buf[BUF_SIZE];
78 
79  if (!fin) {
80  cerr << "Input File: loader.html"
81  << " could not be opened!" << endl;
82  return;
83  }
84 
85  while (fin.getline(buf, BUF_SIZE, '\n')) { // pops off the newline character
86  html_out_ << buf;
87  }
88  fin.close();
89  }
90 
91  firstLumi = true;
92 
93  // instantiate the three work horses of the client:
94  sipixelInformationExtractor_ = new SiPixelInformationExtractor(offlineXMLfile_);
95  sipixelActionExecutor_ = new SiPixelActionExecutor(offlineXMLfile_, Tier0Flag_);
96  sipixelDataQuality_ = new SiPixelDataQuality(offlineXMLfile_);
97 
98  inputSourceToken_ = consumes<FEDRawDataCollection>(ps.getUntrackedParameter<string>("inputSource", "source"));
99  // cout<<"...leaving SiPixelEDAClient::SiPixelEDAClient. "<<endl;
100 }
101 
102 //
103 // -- Destructor
104 //
106  // cout<<"Entering SiPixelEDAClient::~SiPixelEDAClient: "<<endl;
107 
108  edm::LogInfo("SiPixelEDAClient") << " Deleting SiPixelEDAClient "
109  << "\n";
110 
111  if (sipixelInformationExtractor_) {
112  delete sipixelInformationExtractor_;
113  sipixelInformationExtractor_ = nullptr;
114  }
115  if (sipixelActionExecutor_) {
116  delete sipixelActionExecutor_;
117  sipixelActionExecutor_ = nullptr;
118  }
119  if (sipixelDataQuality_) {
120  delete sipixelDataQuality_;
121  sipixelDataQuality_ = nullptr;
122  }
123 
124  // cout<<"...leaving SiPixelEDAClient::~SiPixelEDAClient. "<<endl;
125 }
126 //
127 // -- Begin Run
128 //
129 void SiPixelEDAClient::beginRun(Run const &run, edm::EventSetup const &eSetup) {
130  edm::LogInfo("SiPixelEDAClient") << "[SiPixelEDAClient]: Begining of Run";
131  // cout<<"Entering SiPixelEDAClient::beginRun: "<<endl;
132 
134 
135  if (firstLumi) {
136  summaryFrequency_ = -1;
137  tkMapFrequency_ = -1;
138  actionOnRunEnd_ = true;
139  evtOffsetForInit_ = -1;
140 
141  nLumiSecs_ = 0;
142  nEvents_ = 0;
143  if (Tier0Flag_)
144  nFEDs_ = 40;
145  else
146  nFEDs_ = 0;
147  }
148 
149  // cout<<"...leaving SiPixelEDAClient::beginRun. "<<endl;
150 }
151 
152 //
153 // -- End Luminosity Block
154 //
156  DQMStore::IGetter &iGetter,
157  edm::LuminosityBlock const &lumiSeg,
158  edm::EventSetup const &eSetup) {
159  // cout<<"Entering SiPixelEDAClient::endLuminosityBlock: "<<endl;
160 
161  edm::LogInfo("SiPixelEDAClient") << "[SiPixelEDAClient]: Begin of LS transition";
162 
163  // Moved from beginLumi
164  nEvents_lastLS_ = 0;
165  nErrorsBarrel_lastLS_ = 0;
166  nErrorsEndcap_lastLS_ = 0;
167  MonitorElement *me = iGetter.get("Pixel/AdditionalPixelErrors/byLumiErrors");
168  if (me) {
169  nEvents_lastLS_ = int(me->getBinContent(0));
170  nErrorsBarrel_lastLS_ = int(me->getBinContent(1));
171  nErrorsEndcap_lastLS_ = int(me->getBinContent(2));
172  me->Reset();
173  }
174 
176  sipixelActionExecutor_->createSummary(iBooker, iGetter, isUpgrade_);
177 
178  if (firstLumi) {
179  iBooker.setCurrentFolder("Pixel/");
180  iGetter.setCurrentFolder("Pixel/");
181  // Creating Summary Histos:
182  // std::cout << "CREATING SUMMARY" << std::endl;
183  // sipixelActionExecutor_->createSummary(iBooker,iGetter, isUpgrade_);
184  // Booking Deviation Histos:
185  if (!Tier0Flag_)
186  sipixelActionExecutor_->bookDeviations(iBooker, isUpgrade_);
187  // Booking Efficiency Histos:
188  if (doHitEfficiency_)
189  sipixelActionExecutor_->bookEfficiency(iBooker, isUpgrade_);
190  // Creating occupancy plots:
191  sipixelActionExecutor_->bookOccupancyPlots(iBooker, iGetter, hiRes_);
192  // Booking noisy pixel ME's:
193  if (noiseRate_ > 0.)
194  sipixelInformationExtractor_->bookNoisyPixels(iBooker, noiseRate_, Tier0Flag_);
195  // Booking summary report ME's:
196  sipixelDataQuality_->bookGlobalQualityFlag(iBooker, Tier0Flag_, nFEDs_);
197 
198  if (!Tier0Flag_) {
199  MonitorElement *mefed = iGetter.get("Pixel/EventInfo/DAQContents/fedcounter");
200  if (mefed) {
201  for (int i = 0; i < mefed->getNbinsX(); ++i)
202  nFEDs_ += mefed->getBinContent(i + 1);
203  }
204  }
205  eSetup.get<SiPixelFedCablingMapRcd>().get(theCablingMap);
206 
207  firstLumi = false;
208  }
209 
210  edm::LogInfo("SiPixelEDAClient") << "[SiPixelEDAClient]: End of LS transition, performing the DQM client "
211  "operation";
212  //
213  nLumiSecs_ = lumiSeg.id().luminosityBlock();
214 
216  // nLumiSecs_++;
217 
218  edm::LogInfo("SiPixelEDAClient") << "====================================================== " << endl
219  << " ===> Iteration # " << nLumiSecs_ << " " << lumiSeg.luminosityBlock() << endl
220  << "====================================================== " << endl;
221 
222  if (Tier0Flag_)
223  sipixelActionExecutor_->normaliseAvDigiOccVsLumi(iBooker, iGetter, nLumiSecs_);
224 
225  bool init = true;
226  if (actionOnLumiSec_ && nLumiSecs_ % 1 == 0) {
227  if (doHitEfficiency_)
228  sipixelActionExecutor_->createEfficiency(iBooker, iGetter, isUpgrade_);
229  sipixelActionExecutor_->createOccupancy(iBooker, iGetter);
230  iBooker.cd();
231  iGetter.cd();
232  sipixelDataQuality_->computeGlobalQualityFlagByLumi(
233  iGetter, init, nFEDs_, Tier0Flag_, nEvents_lastLS_, nErrorsBarrel_lastLS_, nErrorsEndcap_lastLS_);
234  init = true;
235  iBooker.cd();
236  iGetter.cd();
237  sipixelDataQuality_->fillGlobalQualityPlot(iBooker, iGetter, init, theCablingMap, nFEDs_, Tier0Flag_, nLumiSecs_);
238  init = true;
239  if (noiseRate_ >= 0.)
240  sipixelInformationExtractor_->findNoisyPixels(
241  iBooker, iGetter, init, noiseRate_, noiseRateDenominator_, theCablingMap);
242  }
243 
244  // cout<<"...leaving SiPixelEDAClient::endLuminosityBlock. "<<endl;
245 }
246 //
247 // -- End Job
248 //
250  // cout<<"In SiPixelEDAClient::endJob "<<endl;
251  edm::LogInfo("SiPixelEDAClient") << "[SiPixelEDAClient]: endjob called!";
253  sipixelActionExecutor_->createSummary(iBooker, iGetter, isUpgrade_);
254 
255  if (actionOnRunEnd_) {
256  // sipixelActionExecutor_->createSummary(iBooker, iGetter, isUpgrade_);
257 
258  if (doHitEfficiency_) {
259  sipixelActionExecutor_->createEfficiency(iBooker, iGetter, isUpgrade_);
260  sipixelActionExecutor_->fillEfficiencySummary(iBooker, iGetter);
261  }
262 
263  sipixelActionExecutor_->createOccupancy(iBooker, iGetter);
264 
265  if (Tier0Flag_)
266  sipixelActionExecutor_->normaliseAvDigiOcc(iBooker, iGetter);
267 
268  iBooker.cd();
269  iGetter.cd();
270  bool init = true;
271  sipixelDataQuality_->computeGlobalQualityFlag(iBooker, iGetter, init, nFEDs_, Tier0Flag_);
272  init = true;
273  iBooker.cd();
274  iGetter.cd();
275 
276  sipixelDataQuality_->fillGlobalQualityPlot(iBooker, iGetter, init, theCablingMap, nFEDs_, Tier0Flag_, nLumiSecs_);
277  init = true;
278  if (noiseRate_ >= 0.)
279  sipixelInformationExtractor_->findNoisyPixels(
280  iBooker, iGetter, init, noiseRate_, noiseRateDenominator_, theCablingMap);
281  }
282 }
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
SiPixelEDAClient(const edm::ParameterSet &ps)
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
void dqmEndJob(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter) override
LuminosityBlockNumber_t luminosityBlock() const
virtual void Reset()
reset ME (ie. contents, errors, etc)
#define BUF_SIZE
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
virtual int getNbinsX() const
get # of bins in X-axis
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: init.py:1
LuminosityBlockNumber_t luminosityBlock() const
~SiPixelEDAClient() override
HLT enums.
T get() const
Definition: EventSetup.h:73
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:437
Definition: Run.h:45
void dqmEndLuminosityBlock(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c) override
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:424