CMS 3D CMS Logo

DTDataIntegrityTest.cc
Go to the documentation of this file.
1 /*
2  * \file DTDataIntegrityTest.cc
3  *
4  * \author S. Bolognesi - CERN
5  *
6  * threadsafe version (//-) oct/nov 2014 - WATWanAbdullah ncpp-um-my
7  *
8  *
9  */
10 
12 
13 //Framework
20 
21 #include <iostream>
22 #include <string>
23 
24 using namespace std;
25 using namespace edm;
26 
28  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]: Constructor";
29 
30  // prescale on the # of LS to update the test
31  prescaleFactor = ps.getUntrackedParameter<int>("diagnosticPrescale", 1);
32 
33  bookingdone = false;
34 }
35 
37  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
38  << "DataIntegrityTest: analyzed " << nupdates << " updates";
39 }
40 
42  DQMStore::IGetter& igetter,
43  edm::LuminosityBlock const& lumiSeg,
44  edm::EventSetup const& context) {
45  if (!bookingdone) {
46  //nSTAEvents = 0;
47  nupdates = 0;
48  run = 0;
49 
50  // book the summary histogram
51 
52  ibooker.setCurrentFolder("DT/00-DataIntegrity");
53 
54  summaryHisto = ibooker.book2D("DataIntegritySummary", "Summary Data Integrity", 12, 1, 13, 5, -2, 3);
55  summaryHisto->setAxisTitle("Sector", 1);
56  summaryHisto->setAxisTitle("Wheel", 2);
57 
58  ibooker.setCurrentFolder("DT/00-DataIntegrity");
59 
60  summaryTDCHisto = ibooker.book2D("DataIntegrityTDCSummary", "TDC Summary Data Integrity", 12, 1, 13, 5, -2, 3);
61  summaryTDCHisto->setAxisTitle("Sector", 1);
62  summaryTDCHisto->setAxisTitle("Wheel", 2);
63 
64  ibooker.setCurrentFolder("DT/00-DataIntegrity");
65 
66  glbSummaryHisto = ibooker.book2D("DataIntegrityGlbSummary", "Summary Data Integrity", 12, 1, 13, 5, -2, 3);
67  glbSummaryHisto->setAxisTitle("Sector", 1);
68  glbSummaryHisto->setAxisTitle("Wheel", 2);
69 
70  context.get<DTReadOutMappingRcd>().get(mapping);
71  } //booking
72  bookingdone = true;
73 
74  // counts number of lumiSegs
75  nLumiSegs = lumiSeg.id().luminosityBlock();
76  string nLumiSegs_s = to_string(nLumiSegs);
77 
78  // prescale factor
79  if (nLumiSegs % prescaleFactor != 0)
80  return;
81 
82  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
83  << "[DTDataIntegrityTest]: End of LS " << nLumiSegs << ", performing client operations";
84 
85  // counts number of updats
86  nupdates++;
87 
88  //Counter for x bin in the timing histos
89  counter++;
90 
91  //Loop on FED id
92  //Monitoring only real used FEDs
93  int FEDIDmin = FEDNumbering::MINDTUROSFEDID;
94  int FEDIDmax = FEDNumbering::MAXDTUROSFEDID;
95 
96  for (int dduId = FEDIDmin; dduId <= FEDIDmax; ++dduId) {
97  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]:FED Id: " << dduId;
98 
99  //Each nTimeBin onUpdate remove timing histos and book a new bunch of them
100  string dduId_s = to_string(dduId);
101 
102  string histoType;
103 
104  //Check if the list of ROS is compatible with the channels enabled
105  string rosStatusName = "DT/00-DataIntegrity/FED" + dduId_s + "/FED" + dduId_s + "_uROSStatus";
106  MonitorElement* FED_ROSStatus = igetter.get(rosStatusName);
107 
108  // Get the error summary histo
109  string fedSummaryName = "DT/00-DataIntegrity/FED" + dduId_s + "_ROSSummary";
110  MonitorElement* FED_ROSSummary1 = nullptr;
111  MonitorElement* FED_ROSSummary2 = nullptr;
112  string fedSummaryName1 = "";
113  string fedSummaryName2 = "";
114  string sign = "-";
115  if (dduId == FEDIDmin || dduId == FEDIDmax) {
116  if (dduId == FEDIDmax)
117  sign = "";
118  fedSummaryName2 = "DT/00-DataIntegrity/ROSSummary_W" + sign + "2";
119  fedSummaryName1 = "DT/00-DataIntegrity/ROSSummary_W" + sign + "1";
120  FED_ROSSummary1 = igetter.get(fedSummaryName1);
121  FED_ROSSummary2 = igetter.get(fedSummaryName2);
122  } else {
123  fedSummaryName = "DT/00-DataIntegrity/ROSSummary_W0";
124  FED_ROSSummary1 = igetter.get(fedSummaryName);
125  FED_ROSSummary2 = igetter.get(fedSummaryName); //for wheel compatibility...
126  }
127 
128  // Get the event length plot (used to count # of processed evts)
129  string fedEvLenName = "DT/00-DataIntegrity/FED" + dduId_s + "/FED" + dduId_s + "_EventLength";
130  MonitorElement* FED_EvLength = igetter.get(fedEvLenName);
131 
132  // Get the histos for FED integrity
133  string fedIntegrityFolder = "DT/00-DataIntegrity/";
134  MonitorElement* hFEDEntry = igetter.get(fedIntegrityFolder + "FEDEntries");
135 
136  if (hFEDEntry) {
137  int offsetFED = 1368;
138  // Check that the FED is in the ReadOut using the FEDIntegrity histos
139  bool fedNotReadout = (hFEDEntry->getBinContent(dduId - offsetFED)) == 0;
140  int wheel = dduId - offsetFED - 2;
141  if (FED_ROSSummary1 && FED_ROSSummary2 && FED_ROSStatus && FED_EvLength && !fedNotReadout) {
142  TH2F* histoFEDSummary1 = FED_ROSSummary1->getTH2F();
143  TH2F* histoFEDSummary2 = FED_ROSSummary2->getTH2F(); // same for central FED...
144  TH2F* histoROSStatus = FED_ROSStatus->getTH2F();
145  TH1F* histoEvLength = FED_EvLength->getTH1F();
146 
147  int nFEDEvts = histoEvLength->Integral();
148  //if(dduId==FEDIDmin || dduId==FEDIDmax) nFEDEvts = nFEDEvts/2.; // split in 2 for external FEDs
149  if (!(nFEDEvts > 0))
150  continue;
151  int extraFEDevents1 = 0;
152  int extraFEDevents2 = 0;
153 
154  for (int urosNumber = 1; urosNumber <= DOCESLOTS; ++urosNumber) { // loop on the uROS
155  string urosNumber_s = to_string(urosNumber);
156  // Get the event length plot for this uROS (used to count # of processed evts)
157  string fedUrosEvLenName = "DT/00-DataIntegrity/FED" + dduId_s + "/uROS" + urosNumber_s + "/FED" + dduId_s +
158  "_uROS" + urosNumber_s + "_EventLength";
159  MonitorElement* FED_uROS_EvLength = igetter.get(fedUrosEvLenName);
160  TH1F* histoUrosEvLength = FED_uROS_EvLength->getTH1F();
161  int nFEDEvtsUros = histoUrosEvLength->Integral();
162 
163  //station 4 sectors drievn by uROS 1 & 2
164  if (urosNumber == 1) {
165  extraFEDevents1 = nFEDEvtsUros;
166  continue;
167  }
168  if (urosNumber == 2) {
169  extraFEDevents2 = nFEDEvtsUros;
170  continue;
171  }
172 
173  if (nFEDEvtsUros > 0) { //this uROS is active
174  nFEDEvtsUros = extraFEDevents1 + extraFEDevents2 + nFEDEvtsUros / 3.; // split in 3 ROS
175  float nGErrors = histoROSStatus->Integral(1, 12, urosNumber, urosNumber); //Only Global Errors,
176  //not possible to distinguish which ROS, so coumting them in the 3/12 ROSes
177 
178  int ros = getROS(urosNumber, 0);
179  for (int iros = ros; iros < (ros + 3); ++iros) {
180  // -1,0,+1 wheels
181  float nROBErrors1 = histoFEDSummary1->Integral(1, 5, iros, iros); //Errors and Not OK Flag
182  float nErrors1 = nROBErrors1 + nGErrors;
183  float result1 = 0.;
184  if (nFEDEvtsUros != 0)
185  result1 = max((float)0., ((float)nFEDEvtsUros - nROBErrors1) / (float)nFEDEvtsUros);
186  summaryHisto->setBinContent(iros, wheel + 3, result1);
187  double tdcResult1 = -2;
188  float nTDCErrors1 = histoFEDSummary1->Integral(6, 6, iros, iros); //Only TDC fatal considered
189  if (nTDCErrors1 == 0) { // no errors
190  tdcResult1 = 0.5;
191  } else { // there are errors
192  tdcResult1 = 2.5;
193  }
194  summaryTDCHisto->setBinContent(iros, wheel + 3, tdcResult1);
195 
196  // FIXME: different errors should have different weights
197  float sectPerc1 = 0.;
198  if (nFEDEvtsUros != 0)
199  sectPerc1 = max((float)0., ((float)nFEDEvtsUros - nErrors1) / (float)nFEDEvtsUros);
200  glbSummaryHisto->setBinContent(iros, wheel + 3, sectPerc1);
201  if (dduId == (FEDIDmax - 1))
202  continue; //wheel 0 case
203 
204  // -2,+2 wheels
205  float nROBErrors2 = histoFEDSummary2->Integral(1, 5, iros, iros); //Errors and Not OK Flag
206  float nErrors2 = nROBErrors2 + nGErrors;
207  float result2 = 0.;
208  if (nFEDEvtsUros != 0)
209  result2 = max((float)0., ((float)nFEDEvtsUros - nROBErrors2) / (float)nFEDEvtsUros);
210  summaryHisto->setBinContent(iros, wheel * 2 + 3, result2);
211 
212  double tdcResult2 = -2;
213  float nTDCErrors2 = histoFEDSummary2->Integral(6, 6, iros, iros); //Only TDC fatal considered
214  if (nTDCErrors2 == 0) { // no errors
215  tdcResult2 = 0.5;
216  } else { // there are errors
217  tdcResult2 = 2.5;
218  }
219  summaryTDCHisto->setBinContent(iros, wheel * 2 + 3, tdcResult2);
220 
221  // FIXME: different errors should have different weights
222  float sectPerc2 = 0.;
223  if (nFEDEvtsUros != 0)
224  sectPerc2 = max((float)0., ((float)nFEDEvtsUros - nErrors2) / (float)nFEDEvtsUros);
225  glbSummaryHisto->setBinContent(iros, wheel * 2 + 3, sectPerc2);
226  } //loop in three ros
227  } // this uROS is active
228  } //loop on uros
229  } else { // no data in this FED: it is off, no ROS suummary/status or evLength and fedNotReadout
230  for (int i = 1; i <= DOCESLOTS; ++i) {
231  summaryHisto->setBinContent(i, wheel + 3, 0.5);
232  summaryTDCHisto->setBinContent(i, wheel + 3, 1.5);
233  glbSummaryHisto->setBinContent(i, wheel + 3, 0.5);
234  if (dduId == (FEDIDmax - 1))
235  continue; //wheel 0 case
236  summaryHisto->setBinContent(i, wheel * 2 + 3, 0.5);
237  summaryTDCHisto->setBinContent(i, wheel * 2 + 3, 1.5);
238  glbSummaryHisto->setBinContent(i, wheel * 2 + 3, 0.5);
239  } //loop on uros
240  } // no data in this FED: it is off, no ROS suummary/status or evLength
241 
242  } //FEDentry
243 
244  } // loop on dduIds
245 }
246 
248  LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest] endjob called!";
249 }
250 
251 string DTDataIntegrityTest::getMEName(string histoType, int FEDId) {
252  //Use the DDU name to find the ME
253  stringstream dduID_s;
254  dduID_s << FEDId;
255 
256  string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str();
257 
258  string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
259  return histoName;
260 }
261 
262 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector) {
263  int dummy;
264  return mapping->readOutToGeometry(dduId, ros, 2, 2, 2, wheel, dummy, sector, dummy, dummy, dummy);
265 }
266 
267 int DTDataIntegrityTest::getROS(int uROS, int link) {
268  int slot = 0;
269  switch (uROS) {
270  case 1: {
271  slot = 5;
272  break;
273  }
274  case 2: {
275  slot = 11;
276  break;
277  }
278  case 3: {
279  slot = 1;
280  break;
281  }
282  case 4: {
283  slot = 7;
284  break;
285  }
286  case 5: {
287  slot = 2;
288  break;
289  }
290  case 6: {
291  slot = 8;
292  break;
293  }
294  case 9: {
295  slot = 9;
296  break;
297  }
298  case 10: {
299  slot = 3;
300  break;
301  }
302  case 11: {
303  slot = 10;
304  break;
305  }
306  case 12: {
307  slot = 4;
308  break;
309  }
310  }
311 
312  if (slot % 6 == 5)
313  return link + 1;
314 
315  int ros = (link / 24) + 3 * (slot % 6) - 2;
316  return ros;
317 }
cmsHarvester.nevents
nevents
Definition: cmsHarvester.py:3177
FEDNumbering.h
DTDataIntegrityTest::summaryTDCHisto
MonitorElement * summaryTDCHisto
Definition: DTDataIntegrityTest.h:71
counter
Definition: counter.py:1
DTDataIntegrityTest::DTDataIntegrityTest
DTDataIntegrityTest(const edm::ParameterSet &ps)
Constructor.
Definition: DTDataIntegrityTest.cc:27
DTDataIntegrityTest.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
DTDataIntegrityTest::nupdates
int nupdates
Definition: DTDataIntegrityTest.h:52
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
DTReadOutMappingRcd
Definition: DTReadOutMappingRcd.h:5
edm
HLT enums.
Definition: AlignableModifier.h:19
dtDataIntegrityTask_cfi.fedIntegrityFolder
fedIntegrityFolder
Definition: dtDataIntegrityTask_cfi.py:5
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DTDataIntegrityTest::getROS
int getROS(int uROS, int link)
Definition: DTDataIntegrityTest.cc:267
dqm::legacy::MonitorElement::getTH1F
virtual TH1F * getTH1F() const
Definition: MonitorElement.h:478
FEDNumbering::MINDTUROSFEDID
Definition: FEDNumbering.h:111
DTDataIntegrityTest::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: DTDataIntegrityTest.cc:247
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
Service.h
DTDataIntegrityTest::prescaleFactor
int prescaleFactor
Definition: DTDataIntegrityTest.h:55
DTDataIntegrityTest::bookingdone
bool bookingdone
Definition: DTDataIntegrityTest.h:65
DTDataIntegrityTest::summaryHisto
MonitorElement * summaryHisto
Definition: DTDataIntegrityTest.h:70
DTDataIntegrityTest::mapping
edm::ESHandle< DTReadOutMapping > mapping
Definition: DTDataIntegrityTest.h:67
DTDataIntegrityTest::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
DQM Client Diagnostic.
Definition: DTDataIntegrityTest.cc:41
DTReadOutMappingRcd.h
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
DOCESLOTS
static const int DOCESLOTS
Definition: DTuROSControlData.h:19
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
DTReadOutMapping::readOutToGeometry
int readOutToGeometry(int dduId, int rosId, int robId, int tdcId, int channelId, DTWireId &wireId) const
transform identifiers
Definition: DTReadOutMapping.cc:69
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
DTDataIntegrityTest::getMEName
std::string getMEName(std::string histoType, int FEDId)
Get the ME name.
Definition: DTDataIntegrityTest.cc:251
edm::EventSetup
Definition: EventSetup.h:57
DTDataIntegrityTest::glbSummaryHisto
MonitorElement * glbSummaryHisto
Definition: DTDataIntegrityTest.h:72
get
#define get
ALCARECODTCalibSynchCosmicsDQM_cff.folderName
folderName
Definition: ALCARECODTCalibSynchCosmicsDQM_cff.py:9
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
DTDataIntegrityTest::run
int run
Definition: DTDataIntegrityTest.h:63
std
Definition: JetResolutionObject.h:76
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker::book2D
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
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
dqm::implementation::IBooker
Definition: DQMStore.h:43
DTDataIntegrityTest::readOutToGeometry
int readOutToGeometry(int dduId, int rosNumber, int &wheel, int &sector)
Definition: DTDataIntegrityTest.cc:262
DTDataIntegrityTest::~DTDataIntegrityTest
~DTDataIntegrityTest() override
Destructor.
Definition: DTDataIntegrityTest.cc:36
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
dummy
Definition: DummySelector.h:38
FEDNumbering::MAXDTUROSFEDID
Definition: FEDNumbering.h:112
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:800
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
DTReadOutMapping.h
DTDataIntegrityTest::nLumiSegs
unsigned int nLumiSegs
Definition: DTDataIntegrityTest.h:61
dqm::legacy::MonitorElement::getTH2F
virtual TH2F * getTH2F() const
Definition: MonitorElement.h:490