CMS 3D CMS Logo

DTDCSByLumiSummary.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author C. Battilana - CIEMAT
5  * \author P. Bellan - INFN PD
6  * \author A. Branca = INFN PD
7  */
8 
11 
16 
18 
19 #include <string>
20 
21 using namespace std;
22 using namespace edm;
23 
25 
27 
29 
31  DQMStore::IGetter& igetter,
33  edm::EventSetup const& setup) {
34  if (!bookingdone) {
35  ibooker.setCurrentFolder("DT/EventInfo/DCSContents");
36 
37  globalHVSummary = ibooker.book2D("HVGlbSummary", "HV Status Summary", 1, 1, 13, 5, -2, 3);
38  globalHVSummary->setAxisTitle("Sectors", 1);
39  globalHVSummary->setAxisTitle("Wheel", 2);
40 
41  {
42  auto scope = DQMStore::IBooker::UseLumiScope(ibooker);
43  totalDCSFraction = ibooker.bookFloat("DTDCSSummary");
44  for (int wh = -2; wh <= 2; wh++) {
45  stringstream wheel_str;
46  wheel_str << wh;
47 
48  MonitorElement* FractionWh = ibooker.bookFloat("DT_Wheel" + wheel_str.str());
49 
50  totalDCSFractionWh.push_back(FractionWh);
51  }
52  }
53 
54  globalHVSummary->Reset();
55 
56  // CB LumiFlag marked products are reset on LS boundaries
57  totalDCSFraction->Reset();
58 
59  for (int wh = -2; wh <= 2; wh++) {
60  totalDCSFractionWh[wh + 2]->Reset();
61  }
62  }
63  bookingdone = true;
64 
65  // Get the by lumi product plot from the task
66  int lumiNumber = lumi.id().luminosityBlock();
67 
68  bool null_pointer_histo(false);
69 
70  std::vector<float> wh_activeFrac;
71 
72  for (int wh = -2; wh <= 2; wh++) {
73  stringstream wheel_str;
74  wheel_str << wh;
75 
76  string hActiveUnitsPath = "DT/EventInfo/DCSContents/hActiveUnits" + wheel_str.str();
77 
78  MonitorElement* hActiveUnits = igetter.get(hActiveUnitsPath);
79 
80  if (hActiveUnits) {
81  float activeFrac = static_cast<float>(hActiveUnits->getBinContent(2)) / // CB 2nd bin is # of active channels
82  hActiveUnits->getBinContent(1); // first bin is overall number of channels
83 
84  if (activeFrac < 0.)
85  activeFrac = -1;
86 
87  wh_activeFrac.push_back(activeFrac);
88 
89  // Fill by lumi Certification ME
90  totalDCSFraction->Fill(activeFrac);
91  totalDCSFractionWh[wh + 2]->Fill(activeFrac);
92 
93  } else {
94  LogTrace("DTDQM|DTMonitorClient|DTDCSByLumiSummary")
95  << "[DTDCSByLumiSummary]: got null pointer retrieving histo at :" << hActiveUnitsPath << " for lumi # "
96  << lumiNumber << "client operation not performed." << endl;
97 
98  null_pointer_histo = true;
99  }
100 
101  } // end loop on wheels
102 
103  if (!null_pointer_histo)
104  dcsFracPerLumi[lumiNumber] = wh_activeFrac; // Fill map to be used to compute trend plots
105 
106  // CB LumiFlag marked products are reset on LS boundaries
107  totalDCSFraction->Reset();
108 
109  for (int wh = -2; wh <= 2; wh++) {
110  totalDCSFractionWh[wh + 2]->Reset();
111  }
112 }
113 
115  // Book trend plots ME & loop on map to fill it with by lumi info
116  map<int, std::vector<float> >::const_iterator fracPerLumiIt = dcsFracPerLumi.begin();
117  map<int, std::vector<float> >::const_iterator fracPerLumiEnd = dcsFracPerLumi.end();
118 
119  if (fracPerLumiIt != fracPerLumiEnd) {
120  int fLumi = dcsFracPerLumi.begin()->first;
121  int lLumi = dcsFracPerLumi.rbegin()->first;
122 
123  ibooker.setCurrentFolder("DT/EventInfo/DCSContents");
124 
125  int nLumis = lLumi - fLumi + 1.;
126 
127  // trend plots
128  for (int wh = -2; wh <= 2; wh++) {
129  stringstream wheel_str;
130  wheel_str << wh;
131 
132  DTTimeEvolutionHisto* trend;
133 
134  trend = new DTTimeEvolutionHisto(ibooker,
135  "hDCSFracTrendWh" + wheel_str.str(),
136  "Fraction of DT-HV ON Wh" + wheel_str.str(),
137  nLumis,
138  fLumi,
139  1,
140  false,
141  2);
142 
143  hDCSFracTrend.push_back(trend);
144  }
145  }
146 
147  float goodLSperWh[5] = {0, 0, 0, 0, 0};
148  float badLSperWh[5] = {0, 0, 0, 0, 0};
149 
150  // fill trend plots and save infos for summaryPlot
151  for (; fracPerLumiIt != fracPerLumiEnd; ++fracPerLumiIt) {
152  for (int wh = -2; wh <= 2; wh++) {
153  std::vector<float> activeFracPerWh;
154  activeFracPerWh = fracPerLumiIt->second;
155 
156  hDCSFracTrend[wh + 2]->setTimeSlotValue(activeFracPerWh[wh + 2], fracPerLumiIt->first);
157 
158  if (activeFracPerWh[wh + 2] > 0) { // we do not count the lumi were the DTs are off (no real problem),
159  // even if this can happen in the middle of a run (real problem: to be fixed)
160  if (activeFracPerWh[wh + 2] > 0.9)
161  goodLSperWh[wh + 2]++;
162  else {
163  badLSperWh[wh + 2]++;
164  }
165  } else { // there is no HV value OR all channels OFF
166  if (activeFracPerWh[wh + 2] < 0)
167  badLSperWh[wh + 2] = -1; // if there were no HV values, activeFrac returning -1
168  }
169  }
170  }
171 
172  // fill summaryPlot
173  for (int wh = -2; wh <= 2; wh++) {
174  if (goodLSperWh[wh + 2] != 0 || badLSperWh[wh + 2] == -1) {
175  float r = badLSperWh[wh + 2] / fabs(goodLSperWh[wh + 2] + badLSperWh[wh + 2]);
176  if (r > 0.5)
177  globalHVSummary->Fill(1, wh, 0);
178  else
179  globalHVSummary->Fill(1, wh, 1);
180  if (r == -1)
181  globalHVSummary->Fill(1, wh, -1);
182 
183  } else {
184  globalHVSummary->Fill(1, wh, 0);
185  }
186  }
187 }
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override
void beginRun(const edm::Run &r, const edm::EventSetup &c) override
~DTDCSByLumiSummary() override
Destructor.
#define LogTrace(id)
void setTimeSlotValue(float value, int timeSlot)
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
DTDCSByLumiSummary(const edm::ParameterSet &pset)
Constructor.
UseScope< MonitorElementData::Scope::LUMI > UseLumiScope
Definition: DQMStore.h:540
void dqmEndLuminosityBlock(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override
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:212
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
HLT enums.
Definition: Run.h:45
virtual double getBinContent(int binx) const
get content of bin (1-D)
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)