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  cablingMapToken_ = esConsumes<SiPixelFedCablingMap, SiPixelFedCablingMapRcd, edm::Transition::EndLuminosityBlock>();
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  // copy is intentional to allow using the SiPixelFedCablingMap in dqmEndJob() where accessing EventSetup products is not allowed
207  theCablingMap = eSetup.getData(cablingMapToken_);
208 
209  firstLumi = false;
210  }
211 
212  edm::LogInfo("SiPixelEDAClient") << "[SiPixelEDAClient]: End of LS transition, performing the DQM client "
213  "operation";
214  //
215  nLumiSecs_ = lumiSeg.id().luminosityBlock();
216 
218  // nLumiSecs_++;
219 
220  edm::LogInfo("SiPixelEDAClient") << "====================================================== " << endl
221  << " ===> Iteration # " << nLumiSecs_ << " " << lumiSeg.luminosityBlock() << endl
222  << "====================================================== " << endl;
223 
224  if (Tier0Flag_)
225  sipixelActionExecutor_->normaliseAvDigiOccVsLumi(iBooker, iGetter, nLumiSecs_);
226 
227  bool init = true;
228  if (actionOnLumiSec_ && nLumiSecs_ % 1 == 0) {
229  if (doHitEfficiency_)
230  sipixelActionExecutor_->createEfficiency(iBooker, iGetter, isUpgrade_);
231  sipixelActionExecutor_->createOccupancy(iBooker, iGetter);
232  iBooker.cd();
233  iGetter.cd();
234  sipixelDataQuality_->computeGlobalQualityFlagByLumi(
235  iGetter, init, nFEDs_, Tier0Flag_, nEvents_lastLS_, nErrorsBarrel_lastLS_, nErrorsEndcap_lastLS_);
236  init = true;
237  iBooker.cd();
238  iGetter.cd();
239  sipixelDataQuality_->fillGlobalQualityPlot(iBooker, iGetter, init, &theCablingMap, nFEDs_, Tier0Flag_, nLumiSecs_);
240  init = true;
241  if (noiseRate_ >= 0.)
242  sipixelInformationExtractor_->findNoisyPixels(
243  iBooker, iGetter, init, noiseRate_, noiseRateDenominator_, &theCablingMap);
244  }
245 
246  // cout<<"...leaving SiPixelEDAClient::endLuminosityBlock. "<<endl;
247 }
248 //
249 // -- End Job
250 //
252  // cout<<"In SiPixelEDAClient::endJob "<<endl;
253  edm::LogInfo("SiPixelEDAClient") << "[SiPixelEDAClient]: endjob called!";
255  sipixelActionExecutor_->createSummary(iBooker, iGetter, isUpgrade_);
256 
257  if (actionOnRunEnd_) {
258  // sipixelActionExecutor_->createSummary(iBooker, iGetter, isUpgrade_);
259 
260  if (doHitEfficiency_) {
261  sipixelActionExecutor_->createEfficiency(iBooker, iGetter, isUpgrade_);
262  sipixelActionExecutor_->fillEfficiencySummary(iBooker, iGetter);
263  }
264 
265  sipixelActionExecutor_->createOccupancy(iBooker, iGetter);
266 
267  if (Tier0Flag_)
268  sipixelActionExecutor_->normaliseAvDigiOcc(iBooker, iGetter);
269 
270  iBooker.cd();
271  iGetter.cd();
272  bool init = true;
273  sipixelDataQuality_->computeGlobalQualityFlag(iBooker, iGetter, init, nFEDs_, Tier0Flag_);
274  init = true;
275  iBooker.cd();
276  iGetter.cd();
277 
278  sipixelDataQuality_->fillGlobalQualityPlot(iBooker, iGetter, init, &theCablingMap, nFEDs_, Tier0Flag_, nLumiSecs_);
279  init = true;
280  if (noiseRate_ >= 0.)
281  sipixelInformationExtractor_->findNoisyPixels(
282  iBooker, iGetter, init, noiseRate_, noiseRateDenominator_, &theCablingMap);
283  }
284 }
FEDNumbering.h
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelDataQuality.h
PixelSubdetector.h
PixelBarrelName.h
MessageLogger.h
SiPixelInformationExtractor
Definition: SiPixelInformationExtractor.h:33
TrackerGeometry.h
PixelTopology.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
LuminosityBlock.h
edm
HLT enums.
Definition: AlignableModifier.h:19
SiPixelEDAClient.h
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
BUF_SIZE
#define BUF_SIZE
Definition: SiPixelEDAClient.cc:45
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
SiPixelEDAClient::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c) override
Definition: SiPixelEDAClient.cc:156
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
FEDRawData.h
FileInPath.h
DetectorIndex.h
edm::FileInPath
Definition: FileInPath.h:64
SiPixelUtility.h
SiPixelEDAClient::~SiPixelEDAClient
~SiPixelEDAClient() override
Definition: SiPixelEDAClient.cc:106
Surface.h
groupFilesInBlocks.fin
fin
Definition: groupFilesInBlocks.py:94
Service.h
edm::LuminosityBlockBase::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockBase.h:40
dqm::implementation::NavigatorBase::cd
virtual void cd()
Definition: DQMStore.cc:29
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackerDigiGeometryRecord.h
SiPixelFrameConverter.h
edm::ParameterSet
Definition: ParameterSet.h:47
recoMuon::in
Definition: RecoMuonEnumerators.h:6
createfilelist.int
int
Definition: createfilelist.py:10
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
FEDRawDataCollection.h
SiPixelDataQuality
Definition: SiPixelDataQuality.h:30
edm::EventSetup
Definition: EventSetup.h:58
GeometricDet.h
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
SiPixelActionExecutor.h
SiPixelInformationExtractor.h
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
init
Definition: init.py:1
SiPixelEDAClient::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: SiPixelEDAClient.cc:130
DetId.h
SiPixelActionExecutor
Definition: SiPixelActionExecutor.h:44
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:574
PixelGeomDetUnit.h
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
EventSetup.h
PixelEndcapNameUpgrade.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
SiPixelEDAClient::dqmEndJob
void dqmEndJob(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter) override
Definition: SiPixelEDAClient.cc:251
ParameterSet.h
SiPixelEDAClient::SiPixelEDAClient
SiPixelEDAClient(const edm::ParameterSet &ps)
Definition: SiPixelEDAClient.cc:52
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
PixelBarrelNameUpgrade.h
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
PixelEndcapName.h