CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <stdio.h>
42 #include <string>
43 #include <sstream>
44 #include <math.h>
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_ = 0;
112  }
113  if (sipixelActionExecutor_) {
114  delete sipixelActionExecutor_;
115  sipixelActionExecutor_ = 0;
116  }
117  if (sipixelDataQuality_) {
118  delete sipixelDataQuality_;
119  sipixelDataQuality_ = 0;
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  bool init=true;
211  if(actionOnLumiSec_ && nLumiSecs_ % 1 == 0 ){
212 
213  if(doHitEfficiency_) sipixelActionExecutor_->createEfficiency(iBooker, iGetter, isUpgrade_);
214  sipixelActionExecutor_->createOccupancy(iBooker,iGetter);
215  iBooker.cd();
216  iGetter.cd();
217  sipixelDataQuality_->computeGlobalQualityFlagByLumi(iGetter,init,nFEDs_,Tier0Flag_,nEvents_lastLS_,nErrorsBarrel_lastLS_,nErrorsEndcap_lastLS_);
218  init=true;
219  iBooker.cd();
220  iGetter.cd();
221  sipixelDataQuality_->fillGlobalQualityPlot(iBooker,iGetter,init,theCablingMap,nFEDs_,Tier0Flag_,nLumiSecs_);
222  init=true;
223  if(noiseRate_>=0.) sipixelInformationExtractor_->findNoisyPixels(iBooker, iGetter, init, noiseRate_, noiseRateDenominator_, theCablingMap);
224  }
225 
226 
227 
228  //cout<<"...leaving SiPixelEDAClient::endLuminosityBlock. "<<endl;
229 }
230 //
231 // -- End Job
232 //
234 // cout<<"In SiPixelEDAClient::endJob "<<endl;
235  edm::LogInfo("SiPixelEDAClient") <<"[SiPixelEDAClient]: endjob called!";
237  sipixelActionExecutor_->createSummary(iBooker, iGetter, isUpgrade_);
238 
239  if(actionOnRunEnd_){
240 
241  //sipixelActionExecutor_->createSummary(iBooker, iGetter, isUpgrade_);
242 
243  if(doHitEfficiency_) sipixelActionExecutor_->createEfficiency(iBooker,iGetter, isUpgrade_);
244 
245  sipixelActionExecutor_->createOccupancy(iBooker,iGetter);
246 
247  iBooker.cd();
248  iGetter.cd();
249  bool init=true;
250  sipixelDataQuality_->computeGlobalQualityFlag(iBooker,iGetter,init,nFEDs_,Tier0Flag_);
251  init=true;
252  iBooker.cd();
253  iGetter.cd();
254 
255  sipixelDataQuality_->fillGlobalQualityPlot(iBooker,iGetter,init,theCablingMap,nFEDs_,Tier0Flag_,nLumiSecs_);
256  init=true;
257  if(noiseRate_>=0.) sipixelInformationExtractor_->findNoisyPixels(iBooker,iGetter, init, noiseRate_, noiseRateDenominator_, theCablingMap);
258  }
259 
260 
261 
262 }
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
SiPixelEDAClient(const edm::ParameterSet &ps)
void cd(void)
Definition: DQMStore.cc:321
void cd(void)
Definition: DQMStore.cc:265
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:301
int init
Definition: HydjetWrapper.h:67
virtual ~SiPixelEDAClient()
void dqmEndJob(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter) override
LuminosityBlockNumber_t luminosityBlock() const
#define BUF_SIZE
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:273
const T & get() const
Definition: EventSetup.h:56
LuminosityBlockNumber_t luminosityBlock() const
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:329
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
void Reset(void)
reset ME (ie. contents, errors, etc)
Definition: Run.h:43
void dqmEndLuminosityBlock(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c) override