CMS 3D CMS Logo

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