CMS 3D CMS Logo

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