CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTBlockedROChannelsTest.cc
Go to the documentation of this file.
1 /*
2  * \file DTBlockedROChannelsTest.cc
3  *
4  * \author G. Cerminara - University and INFN Torino
5  *
6  */
7 
9 
10 //Framework
19 #include <iostream>
20 #include <string>
21 
22 
23 using namespace std;
24 using namespace edm;
25 
26 
28  neventsPrev(0),
29  prevNLumiSegs(0),
30  prevTotalPerc(0),
31  hSystFractionVsLS(0)
32 {
33  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTBlockedROChannelsTest")
34  << "[DTBlockedROChannelsTest]: Constructor";
35 
36  // prescale on the # of LS to update the test
37  prescaleFactor = ps.getUntrackedParameter<int>("diagnosticPrescale", 1);
38 
39  offlineMode = ps.getUntrackedParameter<bool>("offlineMode", true);
40 }
41 
42 
43 
45  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTBlockedROChannelsTest")
46  << "DataIntegrityTest: analyzed " << nupdates << " updates";
47 }
48 
49 
51 {
52 
53  nupdates = 0;
54  return;
55 }
56 
57 
59  // get the RO mapping
60  context.get<DTReadOutMappingRcd>().get(mapping);
61 
62  // fill the map of the robs per chamber
63  for(int dduId = FEDNumbering::MINDTFEDID; dduId<=FEDNumbering::MAXDTFEDID; ++dduId) { //loop over DDUs
64  for(int ros = 1; ros != 13; ++ros) { // loop over ROSs
65  for(int rob = 1; rob != 26; ++rob) { // loop over ROBs
66  int wheel = 0;
67  int station = 0;
68  int sector = 0;
69  int dummy = 0;
70  if(!mapping->readOutToGeometry(dduId,ros,rob-1,0,2,wheel,station,sector,dummy,dummy,dummy) ||
71  !mapping->readOutToGeometry(dduId,ros,rob-1,0,16,wheel,station,sector,dummy,dummy,dummy)) {
72  DTChamberId chId(wheel, station, sector);
73  if(chamberMap.find(chId) == chamberMap.end()) {
74  chamberMap[chId] = DTRobBinsMap(igetter, dduId, ros);
75  chamberMap[chId].addRobBin(rob);
76  }
77  chamberMap[chId].addRobBin(rob);
78  } else {
79  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTBlockedROChannelsTest")
80  << "[DTRobBinsMap] FED: " << dduId << " ROS " << ros << " ROB: " << rob-1
81  << " not in the mapping!" << endl;
82  }
83  }
84  }
85  }
86  // loop over all chambers and remove the init flag
87  for(map<DTChamberId, DTRobBinsMap>::iterator chAndRobs = chamberMap.begin();
88  chAndRobs != chamberMap.end(); ++chAndRobs) {
89  chAndRobs->second.init(false);
90  }
91 }
92 
93 
95  edm::LuminosityBlock const & lumiSeg, edm::EventSetup const& context){
96 
97  //FR moved the following from beginJob!
98 
99  // book the summary histogram
100 
101  if (wheelHitos.size()==0) { // this is an attempt to make these bookings only once!
102 
103  ibooker.setCurrentFolder("DT/00-ROChannels");
104  summaryHisto = ibooker.book2D("ROChannelSummary","Summary Blocked RO Channels",12,1,13,5,-2,3);
105  summaryHisto->setAxisTitle("Sector",1);
106  summaryHisto->setAxisTitle("Wheel",2);
107 
108  for(int wheel = -2; wheel != 3; ++wheel) {
109  stringstream namestream; namestream << "ROChannelSummary_W" << wheel;
110  stringstream titlestream; titlestream << "Blocked RO Channels (Wh " << wheel << ")";
111  wheelHitos[wheel] = ibooker.book2D(namestream.str().c_str(),titlestream.str().c_str(),12,1,13,4,1,5);
112  wheelHitos[wheel]->setAxisTitle("Sector",1);
113  wheelHitos[wheel]->setBinLabel(1,"MB1",2);
114  wheelHitos[wheel]->setBinLabel(2,"MB2",2);
115  wheelHitos[wheel]->setBinLabel(3,"MB3",2);
116  wheelHitos[wheel]->setBinLabel(4,"MB4",2);
117  }
118 
119  if(!offlineMode) {
120  hSystFractionVsLS = new DTTimeEvolutionHisto(ibooker, "EnabledROChannelsVsLS", "% RO channels",
121  500, 5, true, 3);
122  }
123  } // end attempt to make these bookings only once!
124 
125 
126  //FR moved here from beginRun
127 
128  if (chamberMap.size() == 0) fillChamberMap(igetter, context);
129 
130  //FR moved here from beginLuminosityBlock
131  run = lumiSeg.run();
132 
133  //FR moved here from endLuminosityBlock
134  // counts number of lumiSegs
135  nLumiSegs = lumiSeg.id().luminosityBlock();
136 
137  // prescale factor
138  if (nLumiSegs%prescaleFactor != 0 || offlineMode) return;
139 
140  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTBlockedROChannelsTest")
141  <<"[DTBlockedROChannelsTest]: End of LS " << nLumiSegs << ". Client called in online mode, performing client operations";
142 
143  performClientDiagnostic(igetter);
144 
145  // counts number of updats
146  nupdates++;
147 
148 }
149 
151 
152  if (offlineMode) {
153  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTBlockedROChannelsTest")
154  <<"[DTBlockedROChannelsTest] endRun called. Client called in offline mode, performing operations.";
155  performClientDiagnostic(igetter);
156  }
157 }
158 
160 
161  //FR: I've commented the if below. Either in online mode or in offline mode, when the diagnostic is called
162  // compute first the number of events. It will be: event/lumisection in the online case, it will be: total number
163  // of events (neventsPrev=0) in the offline case, when the diagnostic is called only once from the dqmEndJob
164 
165  //if(nevents == 0) { // hack to work also in offline DQM
166  MonitorElement *procEvt = igetter.get("DT/EventInfo/processedEvents");
167  if(procEvt != 0) {
168  int procEvents = procEvt->getIntValue();
169  nevents = procEvents - neventsPrev;
170  neventsPrev = procEvents;
171  }
172  //}
173 
174  double totalPerc = prevTotalPerc;
175  // check again!
176  if(nevents != 0) { // skip the computation if no events in the last LS
177 
178  // reset the histos
179  summaryHisto->Reset();
180  for(int wheel = -2; wheel != 3; ++wheel) {
181  wheelHitos[wheel]->Reset();
182  }
183 
184  totalPerc = 0.;
185 
186  // loop over all chambers and fill the wheel plots
187  for(map<DTChamberId, DTRobBinsMap>::iterator chAndRobs = chamberMap.begin();
188  chAndRobs != chamberMap.end(); ++chAndRobs) {
189  DTChamberId chId = (*chAndRobs).first;
190  double scale = 1.;
191  int sectorForPlot = chId.sector();
192  if(sectorForPlot == 13 || (sectorForPlot == 4 && chId.station() ==4)) {
193  sectorForPlot = 4;
194  scale = 0.5;
195  } else if(sectorForPlot == 14 || (sectorForPlot == 10 && chId.station() ==4)) {
196  sectorForPlot = 10;
197  scale = 0.5;
198  }
199 
200  // NOTE: can be called only ONCE per event per each chamber
201  double chPercent = (*chAndRobs).second.getChamberPercentage(igetter);
202  wheelHitos[chId.wheel()]->Fill(sectorForPlot, chId.station(),
203  scale*chPercent);
204  totalPerc += chPercent*scale*1./240.; // CB has to be 240 as double stations are taken into account by scale factor
205 
206  // Fill the summary
207  summaryHisto->Fill(sectorForPlot, chId.wheel(), 0.25*scale*chPercent);
208  }
209  }
210 
211  if(!offlineMode) { // fill trend histo only in online
214  prevTotalPerc = totalPerc;
215  }
216 
217 }
218 
219 int DTBlockedROChannelsTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
220 
221  int dummy;
222  return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
223 
224 }
225 
227  rosBin(ros),
228  init_(true),
229  rosValue(0)
230 {
231 
232  // get the pointer to the corresondig histo
233  stringstream mename; mename << "DT/00-DataIntegrity/FED" << fed << "/ROS" << ros
234  << "/FED" << fed << "_ROS" << ros << "_ROSError";
235  rosHName = mename.str();
236 
237  stringstream whname; whname << "DT/00-DataIntegrity/FED" << fed
238  << "/FED" << fed << "_ROSStatus";
239  dduHName = whname.str();
240 
241  meROS = igetter.get(rosHName);
242  meDDU = igetter.get(dduHName);
243 }
244 
246  meROS(0),
247  meDDU(0){}
248 
250 
251 
252 
253  // add a rob to the set of robs
255  robsAndValues[robBin] = getValueRobBin(robBin);
256  }
257 
258 
259 
260 
262  if (init_)
263  return 0;
264  int value = 0;
265  if(meROS) {
266  value += (int)meROS->getBinContent(9,robBin);
267  value += (int)meROS->getBinContent(11,robBin);
268  }
269  return value;
270  }
271 
272 
273 
274 
276  int value = 0;
277  if(meDDU) {
278  value += (int)meDDU->getBinContent(2,rosBin);
279  value += (int)meDDU->getBinContent(10,rosBin);
280  }
281  return value;
282 }
283 
284 
285 
286 
288  // check that this is a valid ROB for this map (= it has been added!)
289  if(robsAndValues.find(robBin) == robsAndValues.end()) {
290  LogWarning("DTDQM|DTRawToDigi|DTMonitorClient|DTBlockedROChannelsTest")
291  << "[DTRobBinsMap]***Error: ROB: " << robBin << " is not valid" << endl;
292  return false;
293  }
294 
295  int newValue = getValueRobBin(robBin);
296  if(newValue > robsAndValues[robBin]) {
297  robsAndValues[robBin] = newValue;
298  return true;
299  }
300  return false;
301 }
302 
303 
304 
305 
307  meROS = igetter.get(rosHName);
308  meDDU = igetter.get(dduHName);
309  int nChangedROBs = 0;
310 
311  // check if ros status has changed
312  int newValue = getValueRos();
313  if(newValue > rosValue) {
314  rosValue= newValue;
315  return 0.;
316  }
317 
318  for(map<int, int>::const_iterator robAndValue = robsAndValues.begin();
319  robAndValue != robsAndValues.end(); ++robAndValue) {
320  if(robChanged((*robAndValue).first)) nChangedROBs++;
321  }
322  return 1.-((double)nChangedROBs/(double)robsAndValues.size());
323 }
324 
325 
327  meROS = igetter.get(rosHName);
328  meDDU = igetter.get(dduHName);
329 
330  rosValue = getValueRos();
331  for(map<int, int>::const_iterator robAndValue = robsAndValues.begin();
332  robAndValue != robsAndValues.end(); ++robAndValue) {
333  robChanged((*robAndValue).first);
334  }
335 }
336 
337 
338 
339 
340 // FIXME: move to SealModule
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
DTTimeEvolutionHisto * hSystFractionVsLS
void accumulateValueTimeSlot(float value)
void performClientDiagnostic(DQMStore::IGetter &igetter)
DQM Client operations.
std::map< DTChamberId, DTRobBinsMap > chamberMap
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void beginRun(const edm::Run &, const edm::EventSetup &)
BeginRun.
void fillChamberMap(DQMStore::IGetter &igetter, const edm::EventSetup &c)
void Fill(long long x)
std::map< int, MonitorElement * > wheelHitos
DTBlockedROChannelsTest(const edm::ParameterSet &ps)
Constructor.
RunNumber_t run() const
int readOutToGeometry(int dduId, int rosNumber, int &wheel, int &sector)
edm::ESHandle< DTReadOutMapping > mapping
#define LogTrace(id)
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
DQM Client Diagnostic in online mode.
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &)
void readNewValues(DQMStore::IGetter &igetter)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
int64_t getIntValue(void) const
const T & get() const
Definition: EventSetup.h:56
LuminosityBlockNumber_t luminosityBlock() const
void updateTimeSlot(int ls, int nEventsInLS)
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
double getChamberPercentage(DQMStore::IGetter &)
Definition: Run.h:42