CMS 3D CMS Logo

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(nullptr)
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  // //FIXME: monitoring only real used FEDs
64  for(int dduId = FEDNumbering::MINDTFEDID; dduId<=774; ++dduId) { //loop over DDUs
65  for(int ros = 1; ros != 13; ++ros) { // loop over ROSs
66  for(int rob = 1; rob != 26; ++rob) { // loop over ROBs
67  int wheel = 0;
68  int station = 0;
69  int sector = 0;
70  int dummy = 0;
71  if(!mapping->readOutToGeometry(dduId,ros,rob-1,0,2,wheel,station,sector,dummy,dummy,dummy) ||
72  !mapping->readOutToGeometry(dduId,ros,rob-1,0,16,wheel,station,sector,dummy,dummy,dummy)) {
73  DTChamberId chId(wheel, station, sector);
74  if(chamberMap.find(chId) == chamberMap.end()) {
75  chamberMap[chId] = DTRobBinsMap(igetter, dduId, ros);
76  chamberMap[chId].addRobBin(rob);
77  }
78  chamberMap[chId].addRobBin(rob);
79  } else {
80  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTBlockedROChannelsTest")
81  << "[DTRobBinsMap] FED: " << dduId << " ROS " << ros << " ROB: " << rob-1
82  << " not in the mapping!" << endl;
83  }
84  }
85  }
86  }
87  // loop over all chambers and remove the init flag
88  for(map<DTChamberId, DTRobBinsMap>::iterator chAndRobs = chamberMap.begin();
89  chAndRobs != chamberMap.end(); ++chAndRobs) {
90  chAndRobs->second.init(false);
91  }
92 }
93 
94 
96  edm::LuminosityBlock const & lumiSeg, edm::EventSetup const& context){
97 
98  //FR moved the following from beginJob!
99 
100  // book the summary histogram
101 
102  if (wheelHitos.empty()) { // this is an attempt to make these bookings only once!
103 
104  ibooker.setCurrentFolder("DT/00-ROChannels");
105  summaryHisto = ibooker.book2D("ROChannelSummary","Summary Blocked RO Channels",12,1,13,5,-2,3);
106  summaryHisto->setAxisTitle("Sector",1);
107  summaryHisto->setAxisTitle("Wheel",2);
108 
109  for(int wheel = -2; wheel != 3; ++wheel) {
110  stringstream namestream; namestream << "ROChannelSummary_W" << wheel;
111  stringstream titlestream; titlestream << "Blocked RO Channels (Wh " << wheel << ")";
112  wheelHitos[wheel] = ibooker.book2D(namestream.str().c_str(),titlestream.str().c_str(),12,1,13,4,1,5);
113  wheelHitos[wheel]->setAxisTitle("Sector",1);
114  wheelHitos[wheel]->setBinLabel(1,"MB1",2);
115  wheelHitos[wheel]->setBinLabel(2,"MB2",2);
116  wheelHitos[wheel]->setBinLabel(3,"MB3",2);
117  wheelHitos[wheel]->setBinLabel(4,"MB4",2);
118  }
119 
120  if(!offlineMode) {
121  hSystFractionVsLS = new DTTimeEvolutionHisto(ibooker, "EnabledROChannelsVsLS", "% RO channels",
122  500, 5, true, 3);
123  }
124  } // end attempt to make these bookings only once!
125 
126 
127  //FR moved here from beginRun
128 
129  if (chamberMap.empty()) fillChamberMap(igetter, context);
130 
131  //FR moved here from beginLuminosityBlock
132  run = lumiSeg.run();
133 
134  //FR moved here from endLuminosityBlock
135  // counts number of lumiSegs
136  nLumiSegs = lumiSeg.id().luminosityBlock();
137 
138  // prescale factor
139  if (nLumiSegs%prescaleFactor != 0 || offlineMode) return;
140 
141  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTBlockedROChannelsTest")
142  <<"[DTBlockedROChannelsTest]: End of LS " << nLumiSegs << ". Client called in online mode, performing client operations";
143 
144  performClientDiagnostic(igetter);
145 
146  // counts number of updats
147  nupdates++;
148 
149 }
150 
152 
153  if (offlineMode) {
154  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTBlockedROChannelsTest")
155  <<"[DTBlockedROChannelsTest] endRun called. Client called in offline mode, performing operations.";
156  performClientDiagnostic(igetter);
157  }
158 }
159 
161 
162  //FR: I've commented the if below. Either in online mode or in offline mode, when the diagnostic is called
163  // compute first the number of events. It will be: event/lumisection in the online case, it will be: total number
164  // of events (neventsPrev=0) in the offline case, when the diagnostic is called only once from the dqmEndJob
165 
166  //if(nevents == 0) { // hack to work also in offline DQM
167  MonitorElement *procEvt = igetter.get("DT/EventInfo/processedEvents");
168  if(procEvt != nullptr) {
169  int procEvents = procEvt->getIntValue();
170  nevents = procEvents - neventsPrev;
171  neventsPrev = procEvents;
172  }
173  //}
174 
175  double totalPerc = prevTotalPerc;
176  // check again!
177  if(nevents != 0) { // skip the computation if no events in the last LS
178 
179  // reset the histos
180  summaryHisto->Reset();
181  for(int wheel = -2; wheel != 3; ++wheel) {
182  wheelHitos[wheel]->Reset();
183  }
184 
185  totalPerc = 0.;
186 
187  // loop over all chambers and fill the wheel plots
188  for(map<DTChamberId, DTRobBinsMap>::iterator chAndRobs = chamberMap.begin();
189  chAndRobs != chamberMap.end(); ++chAndRobs) {
190  DTChamberId chId = (*chAndRobs).first;
191  double scale = 1.;
192  int sectorForPlot = chId.sector();
193  if(sectorForPlot == 13 || (sectorForPlot == 4 && chId.station() ==4)) {
194  sectorForPlot = 4;
195  scale = 0.5;
196  } else if(sectorForPlot == 14 || (sectorForPlot == 10 && chId.station() ==4)) {
197  sectorForPlot = 10;
198  scale = 0.5;
199  }
200 
201  // NOTE: can be called only ONCE per event per each chamber
202  double chPercent = (*chAndRobs).second.getChamberPercentage(igetter);
203  wheelHitos[chId.wheel()]->Fill(sectorForPlot, chId.station(),
204  scale*chPercent);
205  totalPerc += chPercent*scale*1./240.; // CB has to be 240 as double stations are taken into account by scale factor
206 
207  // Fill the summary
208  summaryHisto->Fill(sectorForPlot, chId.wheel(), 0.25*scale*chPercent);
209  }
210  }
211 
212  if(!offlineMode) { // fill trend histo only in online
215  prevTotalPerc = totalPerc;
216  }
217 
218 }
219 
220 int DTBlockedROChannelsTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
221 
222  int dummy;
223  return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
224 
225 }
226 
228  rosBin(ros),
229  init_(true),
230  rosValue(0)
231 {
232 
233  // get the pointer to the corresondig histo
234  stringstream mename; mename << "DT/00-DataIntegrity/FED" << fed << "/ROS" << ros
235  << "/FED" << fed << "_ROS" << ros << "_ROSError";
236  rosHName = mename.str();
237 
238  stringstream whname; whname << "DT/00-DataIntegrity/FED" << fed
239  << "/FED" << fed << "_ROSStatus";
240  dduHName = whname.str();
241 
242  meROS = igetter.get(rosHName);
243  meDDU = igetter.get(dduHName);
244 }
245 
247  meROS(nullptr),
248  meDDU(nullptr){}
249 
251 
252 
253 
254  // add a rob to the set of robs
256  robsAndValues[robBin] = getValueRobBin(robBin);
257  }
258 
259 
260 
261 
263  if (init_)
264  return 0;
265  int value = 0;
266  if(meROS) {
267  value += (int)meROS->getBinContent(9,robBin);
268  value += (int)meROS->getBinContent(11,robBin);
269  }
270  return value;
271  }
272 
273 
274 
275 
277  int value = 0;
278  if(meDDU) {
279  value += (int)meDDU->getBinContent(2,rosBin);
280  value += (int)meDDU->getBinContent(10,rosBin);
281  }
282  return value;
283 }
284 
285 
286 
287 
289  // check that this is a valid ROB for this map (= it has been added!)
290  if(robsAndValues.find(robBin) == robsAndValues.end()) {
291  LogWarning("DTDQM|DTRawToDigi|DTMonitorClient|DTBlockedROChannelsTest")
292  << "[DTRobBinsMap]***Error: ROB: " << robBin << " is not valid" << endl;
293  return false;
294  }
295 
296  int newValue = getValueRobBin(robBin);
297  if(newValue > robsAndValues[robBin]) {
298  robsAndValues[robBin] = newValue;
299  return true;
300  }
301  return false;
302 }
303 
304 
305 
306 
308  meROS = igetter.get(rosHName);
309  meDDU = igetter.get(dduHName);
310  int nChangedROBs = 0;
311 
312  // check if ros status has changed
313  int newValue = getValueRos();
314  if(newValue > rosValue) {
315  rosValue= newValue;
316  return 0.;
317  }
318 
319  for(map<int, int>::const_iterator robAndValue = robsAndValues.begin();
320  robAndValue != robsAndValues.end(); ++robAndValue) {
321  if(robChanged((*robAndValue).first)) nChangedROBs++;
322  }
323  return 1.-((double)nChangedROBs/(double)robsAndValues.size());
324 }
325 
326 
328  meROS = igetter.get(rosHName);
329  meDDU = igetter.get(dduHName);
330 
331  rosValue = getValueRos();
332  for(map<int, int>::const_iterator robAndValue = robsAndValues.begin();
333  robAndValue != robsAndValues.end(); ++robAndValue) {
334  robChanged((*robAndValue).first);
335  }
336 }
337 
338 
339 
340 
341 // 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.
int readOutToGeometry(int dduId, int rosId, int robId, int tdcId, int channelId, DTWireId &wireId) const
transform identifiers
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
DQM Client Diagnostic in online mode.
std::map< DTChamberId, DTRobBinsMap > chamberMap
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
#define nullptr
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
Definition: value.py:1
int readOutToGeometry(int dduId, int rosNumber, int &wheel, int &sector)
edm::ESHandle< DTReadOutMapping > mapping
#define LogTrace(id)
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:55
LuminosityBlockNumber_t luminosityBlock() const
void updateTimeSlot(int ls, int nEventsInLS)
double getBinContent(int binx) const
get content of bin (1-D)
HLT enums.
int sector() const
Definition: DTChamberId.h:61
void beginRun(const edm::Run &, const edm::EventSetup &) override
BeginRun.
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)
~DTBlockedROChannelsTest() override
Destructor.
double getChamberPercentage(DQMStore::IGetter &)
Definition: Run.h:43