CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RPCChamberQuality.cc
Go to the documentation of this file.
2 
7 
8 #include <fmt/format.h>
9 
11  "Good", "OFF", "Nois.St", "Nois.Ch", "Part.Dead", "Dead", "Bad.Shape"};
12 const std::string RPCChamberQuality::regions_[3] = {"EndcapNegative", "Barrel", "EndcapPositive"};
13 
15  edm::LogVerbatim("rpcchamberquality") << "[RPCChamberQuality]: Constructor";
16 
17  prescaleFactor_ = ps.getUntrackedParameter<int>("PrescaleFactor", 5);
18 
19  std::string subsystemFolder = ps.getUntrackedParameter<std::string>("RPCFolder", "RPC");
20  std::string recHitTypeFolder = ps.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
21  std::string summaryFolder = ps.getUntrackedParameter<std::string>("SummaryFolder", "SummaryHistograms");
22 
23  summaryDir_ = subsystemFolder + "/" + recHitTypeFolder + "/" + summaryFolder;
24  prefixDir_ = subsystemFolder + "/" + recHitTypeFolder;
25 
26  enableDQMClients_ = ps.getUntrackedParameter<bool>("EnableRPCDqmClient", true);
27 
28  minEvents = ps.getUntrackedParameter<int>("MinimumRPCEvents", 10000);
29  numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
30  useRollInfo_ = ps.getUntrackedParameter<bool>("UseRollInfo", false);
31  offlineDQM_ = ps.getUntrackedParameter<bool>("OfflineDQM", true);
32 
33  init_ = false;
34  lumiCounter_ = 0;
35 }
36 
37 RPCChamberQuality::~RPCChamberQuality() { edm::LogVerbatim("rpcchamberquality") << "[RPCChamberQuality]: Destructor "; }
38 
39 void RPCChamberQuality::beginJob() { edm::LogVerbatim("rpcchamberquality") << "[RPCChamberQuality]: Begin job "; }
40 
42  DQMStore::IGetter& igetter,
43  edm::LuminosityBlock const& iLumi,
44  edm::EventSetup const& iSetup) {
45  edm::LogVerbatim("rpcchamberquality") << "[RPCChamberQuality]: End Lumi Block";
46 
48  edm::LogVerbatim("rpcchamberquality") << "[RPCChamberQuality]: Performing DQM client operation";
49 
50  if (lumiCounter_ == 0) { //book histograms during at firt LB end
51  this->myBooker(ibooker);
53  }
54 
55  if (lumiCounter_ % prescaleFactor_ == 0) { //Fill histograms every N=prescaleFactor_ LBs
56  this->fillMonitorElements(igetter);
57  }
58  }
59  lumiCounter_++;
60 }
61 
63  edm::LogVerbatim("rpcchamberquality") << "[RPCChamberQuality]: End Job";
64 
65  if (enableDQMClients_) {
66  edm::LogVerbatim("rpcchamberquality") << "[RPCChamberQuality]: Performing DQM client operation";
67  if (offlineDQM_ && !init_) {
68  this->myBooker(ibooker);
69  }
70  if (init_) {
71  this->fillMonitorElements(igetter);
72  }
73  }
74 }
75 
77  init_ = true;
78 
80 
81  for (int r = 0; r < 3; r++) {
82  const std::string histoName = fmt::format("RPCChamberQuality_{}", regions_[r]);
83  MonitorElement* me = ibooker.book1D(histoName, histoName, 7, 0.5, 7.5);
84 
85  for (int x = 1; x < 8; x++) {
86  me->setBinLabel(x, xLabels_[x - 1]);
87  }
88  }
89 
91  ibooker.book2D("RPC_System_Quality_Overview", "RPC_System_Quality_Overview", 7, 0.5, 7.5, 3, 0.5, 3.5);
92  me->setBinLabel(1, "E-", 2);
93  me->setBinLabel(2, "B", 2);
94  me->setBinLabel(3, "E+", 2);
95 
96  for (int x = 1; x < 8; x++) {
97  me->setBinLabel(x, xLabels_[x - 1]);
98  }
99 
100  for (int w = -2; w < 3; w++) { //Loop on wheels
101 
102  const std::string histoName2D = fmt::format("RPCChamberQuality_Roll_vs_Sector_Wheel{}", w);
103  RPCRollMapHisto::bookBarrel(ibooker, w, histoName2D, histoName2D, useRollInfo_);
104 
105  const std::string histoName1D = fmt::format("RPCChamberQuality_Distribution_Wheel{}", w);
106  MonitorElement* me1D = ibooker.book1D(histoName1D, histoName1D, 7, 0.5, 7.5);
107 
108  for (int x = 1; x < 8; x++) {
109  me1D->setBinLabel(x, xLabels_[x - 1]);
110  }
111  } //end loop on wheels
112 
113  for (int d = -numberOfDisks_; d <= numberOfDisks_; d++) { // Loop on disk
114  if (d == 0)
115  continue;
116  const std::string histoName2D =
117  fmt::format("RPCChamberQuality_Ring_vs_Segment_Disk{}", d); // 2D histo for RPC Qtest
118  RPCRollMapHisto::bookEndcap(ibooker, d, histoName2D, histoName2D, useRollInfo_);
119 
120  const std::string histoName1D = fmt::format("RPCChamberQuality_Distribution_Disk{}", d);
121  MonitorElement* me1D = ibooker.book1D(histoName1D, histoName1D, 7, 0.5, 7.5);
122 
123  for (int x = 1; x < 8; x++) {
124  me1D->setBinLabel(x, xLabels_[x - 1]);
125  }
126  }
127 }
128 
130  int rpcEvents = minEvents;
131  RpcEvents = igetter.get(prefixDir_ + "/RPCEvents");
132 
133  if (RpcEvents)
134  rpcEvents = (int)RpcEvents->getBinContent(1);
135 
136  if (rpcEvents >= minEvents) {
137  init_ = true;
138 
140 
141  for (int r = 0; r < 3; r++) {
142  const std::string meName = fmt::format("{}/RPCChamberQuality_{}", summaryDir_, RPCChamberQuality::regions_[r]);
143  summary[r] = igetter.get(meName);
144 
145  if (summary[r] != nullptr)
146  summary[r]->Reset();
147  }
148 
149  //Barrel
150  for (int wheel = -2; wheel < 3; wheel++) { // loop by Wheels
151  const std::string meName = fmt::format("Roll_vs_Sector_Wheel{}", wheel);
152 
153  this->performeClientOperation(meName, 0, summary[1], igetter);
154  } // loop by Wheels
155 
156  // Endcap
157  for (int i = -numberOfDisks_; i <= numberOfDisks_; i++) { //loop on Disks
158  if (i == 0)
159  continue;
160 
161  const std::string meName = fmt::format("Ring_vs_Segment_Disk{}", i);
162 
163  if (i < 0)
164  this->performeClientOperation(meName, -1, summary[0], igetter);
165  else
166  this->performeClientOperation(meName, 1, summary[2], igetter);
167  } //loop on Disks
168 
169  MonitorElement* RpcOverview = igetter.get(summaryDir_ + "/RPC_System_Quality_Overview");
170  RpcOverview->Reset();
171 
172  if (RpcOverview) { //Fill Overview ME
173  for (int r = 0; r < 3; r++) {
174  if (summary[r] == nullptr)
175  continue;
176  const double entries = summary[r]->getEntries();
177  if (entries == 0)
178  continue;
179  for (int x = 1; x <= 7; x++) {
180  RpcOverview->setBinContent(x, r + 1, (summary[r]->getBinContent(x) / entries));
181  }
182  }
183  } //loop by LimiBloks
184  }
185 }
186 
188  int region,
190  DQMStore::IGetter& igetter) {
191  MonitorElement* RCQ = igetter.get(summaryDir_ + "/RPCChamberQuality_" + MESufix);
192  // if (RCQ) RCQ->Reset();
193 
194  const int pos = MESufix.find_last_of('_');
195  MonitorElement* RCQD = igetter.get(summaryDir_ + "/RPCChamberQuality_Distribution" + MESufix.substr(pos));
196  if (RCQD)
197  RCQD->Reset();
198 
199  //get HV Histo
200  MonitorElement* HV = igetter.get(summaryDir_ + "/HVStatus_" + MESufix);
201  //get LV Histo
202  MonitorElement* LV = igetter.get(summaryDir_ + "/LVStatus_" + MESufix);
203  //Dead
204  MonitorElement* DEAD = igetter.get(summaryDir_ + "/DeadChannelFraction_" + MESufix);
205  //ClusterSize
206  MonitorElement* CLS = igetter.get(summaryDir_ + "/ClusterSizeIn1Bin_" + MESufix);
207  //NoisyStrips
208  MonitorElement* NoisySt = igetter.get(summaryDir_ + "/RPCNoisyStrips_" + MESufix);
209  //Multiplicity
210  MonitorElement* MULT = igetter.get(summaryDir_ + "/NumberOfDigi_Mean_" + MESufix);
211  //Asymetry
212  MonitorElement* Chip = igetter.get(summaryDir_ + "/AsymmetryLeftRight_" + MESufix);
213 
214  int xBinMax, yBinMax;
215 
216  if (region != 0)
217  xBinMax = 37;
218  else
219  xBinMax = 13;
220 
221  for (int x = 1; x < xBinMax; x++) {
222  if (region != 0) {
223  yBinMax = 7;
224  } else {
225  if (x == 4)
226  yBinMax = 22;
227  else if (x == 9 || x == 11)
228  yBinMax = 16;
229  else
230  yBinMax = 18;
231  }
232  for (int y = 1; y < yBinMax; y++) {
233  int hv = 1;
234  int lv = 1;
235  float dead = 0;
236  float firstbin = 0;
237  float noisystrips = 0;
238  float mult = 0;
239  float asy = 0;
240  chamberQualityState chamberState = GoodState;
241 
242  if (HV)
243  hv = (int)HV->getBinContent(x, y);
244  if (LV)
245  lv = (int)LV->getBinContent(x, y);
246 
247  if (hv != 1 || lv != 1) {
248  chamberState = OffState;
249  } else {
250  if (DEAD)
251  dead = DEAD->getBinContent(x, y);
252  if (dead >= 0.80) {
253  chamberState = DeadState;
254  } else if (0.33 <= dead && dead < 0.80) {
255  chamberState = PartiallyDeadState;
256  } else {
257  if (CLS)
258  firstbin = CLS->getBinContent(x, y);
259  if (firstbin >= 0.88) {
260  chamberState = NoisyStripState;
261  } else {
262  if (NoisySt)
263  noisystrips = NoisySt->getBinContent(x, y);
264  if (noisystrips > 0) {
265  chamberState = NoisyStripState;
266  } else {
267  if (MULT)
268  mult = MULT->getBinContent(x, y);
269  if (mult >= 6) {
270  chamberState = NoisyRollState;
271  } else {
272  if (Chip)
273  asy = Chip->getBinContent(x, y);
274  if (asy > 0.35) {
275  chamberState = BadShapeState;
276  } else {
277  chamberState = GoodState;
278  }
279  }
280  }
281  }
282  }
283  }
284  if (RCQ)
285  RCQ->setBinContent(x, y, chamberState);
286  if (RCQD)
287  RCQD->Fill(chamberState);
288  if (quality)
289  quality->Fill(chamberState);
290  }
291  }
292  return;
293 }
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
void beginJob() override
const double w
Definition: UKUtility.cc:23
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
math::XYZTLorentzVectorD LV
uint32_t const *__restrict__ Quality * quality
static const std::string xLabels_[7]
std::string summaryDir_
void fillMonitorElements(DQMStore::IGetter &)
void Fill(long long x)
tuple d
Definition: ztail.py:151
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
RPCChamberQuality(const edm::ParameterSet &ps)
virtual double getEntries() const
get # of entries
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual double getBinContent(int binx) const
get content of bin (1-D)
void performeClientOperation(std::string, int, MonitorElement *, DQMStore::IGetter &)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
~RPCChamberQuality() override
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * RpcEvents
static const std::string regions_[3]
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
static MonitorElement * bookBarrel(IBooker &booker, const int wheel, const std::string &prefix, const std::string &title, const bool useRollInfo)
std::string prefixDir_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
static MonitorElement * bookEndcap(IBooker &booker, const int disk, const std::string &prefix, const std::string &title, const bool useRollInfo)
void myBooker(DQMStore::IBooker &)