CMS 3D CMS Logo

RPCEventSummary.cc
Go to the documentation of this file.
1 /* \author Anna Cimmino*/
2 #include <sstream>
3 
5 //CondFormats
8 // Framework
10 //#include "FWCore/Framework/interface/LuminosityBlock.h"
11 //#include "FWCore/Framework/interface/Event.h"
14 
16  edm::LogVerbatim("rpceventsummary") << "[RPCEventSummary]: Constructor";
17 
18  enableReportSummary_ = ps.getUntrackedParameter<bool>("EnableSummaryReport", true);
19  prescaleFactor_ = ps.getUntrackedParameter<int>("PrescaleFactor", 1);
20  eventInfoPath_ = ps.getUntrackedParameter<std::string>("EventInfoPath", "RPC/EventInfo");
21 
22  std::string subsystemFolder = ps.getUntrackedParameter<std::string>("RPCFolder", "RPC");
23  std::string recHitTypeFolder = ps.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
24  std::string summaryFolder = ps.getUntrackedParameter<std::string>("SummaryFolder", "SummaryHistograms");
25 
26  globalFolder_ = subsystemFolder + "/" + recHitTypeFolder + "/" + summaryFolder;
27  prefixFolder_ = subsystemFolder + "/" + recHitTypeFolder;
28 
29  minimumEvents_ = ps.getUntrackedParameter<int>("MinimumRPCEvents", 10000);
30  numberDisk_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
31  doEndcapCertification_ = ps.getUntrackedParameter<bool>("EnableEndcapSummary", false);
32 
33  FEDRange_.first = ps.getUntrackedParameter<unsigned int>("MinimumRPCFEDId", 790);
34  FEDRange_.second = ps.getUntrackedParameter<unsigned int>("MaximumRPCFEDId", 792);
35 
36  NumberOfFeds_ = FEDRange_.second - FEDRange_.first + 1;
37 
38  offlineDQM_ = ps.getUntrackedParameter<bool>("OfflineDQM", true);
39 }
40 
41 RPCEventSummary::~RPCEventSummary() { edm::LogVerbatim("rpceventsummary") << "[RPCEventSummary]: Destructor "; }
42 
44  edm::LogVerbatim("rpceventsummary") << "[RPCEventSummary]: Begin job ";
45  init_ = false;
46 }
47 
49  DQMStore::IGetter& igetter,
50  edm::LuminosityBlock const& lb,
51  edm::EventSetup const& setup) {
52  edm::LogVerbatim("rpceventsummary") << "[RPCEventSummary]: Begin run";
53 
54  if (!init_) {
56 
59 
60  int defaultValue = 1;
61  isIn_ = true;
62 
63  if (auto runInfoRec = setup.tryToGet<RunInfoRcd>()) {
64  defaultValue = -1;
65  //get fed summary information
67  runInfoRec->get(sumFED);
68  std::vector<int> FedsInIds = sumFED->m_fed_in;
69  unsigned int f = 0;
70  isIn_ = false;
71  while (!isIn_ && f < FedsInIds.size()) {
72  int fedID = FedsInIds[f];
73  //make sure fed id is in allowed range
74  if (fedID >= FEDRange_.first && fedID <= FEDRange_.second) {
75  defaultValue = 1;
76  isIn_ = true;
77  }
78  f++;
79  }
80  }
81 
84 
85  //a global summary float [0,1] providing a global summary of the status
86  //and showing the goodness of the data taken by the the sub-system
87  std::string histoName = "reportSummary";
88  me = nullptr;
89  me = ibooker.bookFloat(histoName);
90  me->Fill(defaultValue);
91 
92  //TH2F ME providing a mapof values[0-1] to show if problems are localized or distributed
93  me = nullptr;
94  me = ibooker.book2D("reportSummaryMap", "RPC Report Summary Map", 15, -7.5, 7.5, 12, 0.5, 12.5);
95 
96  //customize the 2d histo
97  std::stringstream BinLabel;
98  for (int i = 1; i <= 15; i++) {
99  BinLabel.str("");
100  if (i < 13) {
101  BinLabel << "Sec" << i;
102  me->setBinLabel(i, BinLabel.str(), 2);
103  }
104 
105  BinLabel.str("");
106  if (i < 5)
107  BinLabel << "Disk" << i - 5;
108  else if (i > 11)
109  BinLabel << "Disk" << i - 11;
110  else if (i == 11 || i == 5)
111  BinLabel.str("");
112  else
113  BinLabel << "Wheel" << i - 8;
114 
115  me->setBinLabel(i, BinLabel.str(), 1);
116  }
117 
118  //fill the histo with "1" --- just for the moment
119  for (int i = 1; i <= 15; i++) {
120  for (int j = 1; j <= 12; j++) {
121  if (i == 5 || i == 11 || (j > 6 && (i < 6 || i > 10)))
122  me->setBinContent(i, j, -1); //bins that not correspond to subdetector parts
123  else
124  me->setBinContent(i, j, defaultValue);
125  }
126  }
127 
128  if (numberDisk_ < 4)
129  for (int j = 1; j <= 12; j++) {
130  me->setBinContent(1, j, -1); //bins that not correspond to subdetector parts
131  me->setBinContent(15, j, -1);
132  }
133 
134  //the reportSummaryContents folder containins a collection of ME floats [0-1] (order of 5-10)
135  // which describe the behavior of the respective subsystem sub-components.
136  ibooker.setCurrentFolder(eventInfoPath_ + "/reportSummaryContents");
137 
138  std::stringstream segName;
139  std::vector<std::string> segmentNames;
140  for (int i = -2; i <= 2; i++) {
141  segName.str("");
142  segName << "RPC_Wheel" << i;
143  segmentNames.push_back(segName.str());
144  }
145 
146  for (int i = -numberDisk_; i <= numberDisk_; i++) {
147  if (i == 0)
148  continue;
149  segName.str("");
150  segName << "RPC_Disk" << i;
151  segmentNames.push_back(segName.str());
152  }
153 
154  for (unsigned int i = 0; i < segmentNames.size(); i++) {
155  me = nullptr;
156  me = ibooker.bookFloat(segmentNames[i]);
157  me->Fill(defaultValue);
158  }
159 
161  init_ = true;
162  }
163 
164  if (isIn_ && !offlineDQM_ && lumiCounter_ % prescaleFactor_ == 0) {
165  this->clientOperation(igetter);
166  }
167 
168  lumiCounter_++;
169 }
170 
172  if (isIn_) {
173  this->clientOperation(igetter);
174  }
175 }
176 
178  float rpcevents = minimumEvents_;
179  MonitorElement* RPCEvents;
180  RPCEvents = igetter.get(prefixFolder_ + "/RPCEvents");
181 
182  if (RPCEvents) {
183  rpcevents = RPCEvents->getBinContent(1);
184  }
185 
186  if (rpcevents < minimumEvents_)
187  return;
188  std::stringstream meName;
189  MonitorElement* myMe;
190 
191  meName.str("");
192  meName << eventInfoPath_ + "/reportSummaryMap";
193  MonitorElement* reportMe = igetter.get(meName.str());
194 
195  MonitorElement* globalMe;
196 
197  //BARREL
198  float barrelFactor = 0;
199 
200  for (int w = -2; w < 3; w++) {
201  meName.str("");
202  meName << globalFolder_ << "/RPCChamberQuality_Roll_vs_Sector_Wheel" << w;
203  myMe = igetter.get(meName.str());
204 
205  if (myMe) {
206  float wheelFactor = 0;
207 
208  for (int s = 1; s <= myMe->getNbinsX(); s++) {
209  float sectorFactor = 0;
210  int rollInSector = 0;
211 
212  for (int r = 1; r <= myMe->getNbinsY(); r++) {
213  if ((s != 4 && r > 17) || ((s == 9 || s == 10) && r > 15))
214  continue;
215  rollInSector++;
216 
217  if (myMe->getBinContent(s, r) == PARTIALLY_DEAD)
218  sectorFactor += 0.8;
219  else if (myMe->getBinContent(s, r) == DEAD)
220  sectorFactor += 0;
221  else
222  sectorFactor += 1;
223  }
224  if (rollInSector != 0)
225  sectorFactor = sectorFactor / rollInSector;
226 
227  if (reportMe)
228  reportMe->setBinContent(w + 8, s, sectorFactor);
229  wheelFactor += sectorFactor;
230 
231  } //end loop on sectors
232 
233  wheelFactor = wheelFactor / myMe->getNbinsX();
234 
235  meName.str("");
236  meName << eventInfoPath_ + "/reportSummaryContents/RPC_Wheel" << w;
237  globalMe = igetter.get(meName.str());
238  if (globalMe)
239  globalMe->Fill(wheelFactor);
240 
241  barrelFactor += wheelFactor;
242  } //
243  } //end loop on wheel
244 
245  barrelFactor = barrelFactor / 5;
246 
247  float endcapFactor = 0;
248 
250  //Endcap
251  for (int d = -numberDisk_; d <= numberDisk_; d++) {
252  if (d == 0)
253  continue;
254 
255  meName.str("");
256  meName << globalFolder_ << "/RPCChamberQuality_Ring_vs_Segment_Disk" << d;
257  myMe = igetter.get(meName.str());
258 
259  if (myMe) {
260  float diskFactor = 0;
261 
262  float sectorFactor[6] = {0, 0, 0, 0, 0, 0};
263 
264  for (int i = 0; i < 6; i++) {
265  int firstSeg = (i * 6) + 1;
266  int lastSeg = firstSeg + 6;
267  int rollInSector = 0;
268  for (int seg = firstSeg; seg < lastSeg; seg++) {
269  for (int y = 1; y <= myMe->getNbinsY(); y++) {
270  rollInSector++;
271  if (myMe->getBinContent(seg, y) == PARTIALLY_DEAD)
272  sectorFactor[i] += 0.8;
273  else if (myMe->getBinContent(seg, y) == DEAD)
274  sectorFactor[i] += 0;
275  else
276  sectorFactor[i] += 1;
277  }
278  }
279  sectorFactor[i] = sectorFactor[i] / rollInSector;
280  } //end loop on Sectors
281 
282  for (int sec = 0; sec < 6; sec++) {
283  diskFactor += sectorFactor[sec];
284  if (reportMe) {
285  if (d < 0)
286  reportMe->setBinContent(d + 5, sec + 1, sectorFactor[sec]);
287  else
288  reportMe->setBinContent(d + 11, sec + 1, sectorFactor[sec]);
289  }
290  }
291 
292  diskFactor = diskFactor / 6;
293 
294  meName.str("");
295  meName << eventInfoPath_ + "/reportSummaryContents/RPC_Disk" << d;
296  globalMe = igetter.get(meName.str());
297  if (globalMe)
298  globalMe->Fill(diskFactor);
299 
300  endcapFactor += diskFactor;
301  } //end loop on disks
302  }
303 
304  endcapFactor = endcapFactor / (numberDisk_ * 2);
305  }
306 
307  //Fill repor summary
308  float rpcFactor = barrelFactor;
310  rpcFactor = (barrelFactor + endcapFactor) / 2;
311  }
312 
313  globalMe = igetter.get(eventInfoPath_ + "/reportSummary");
314  if (globalMe)
315  globalMe->Fill(rpcFactor);
316 }
RPCEventSummary::eventInfoPath_
std::string eventInfoPath_
Definition: RPCEventSummary.h:28
edm::eventsetup::heterocontainer::HCTypeTag::findType
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:121
DDAxes::y
RPCEventSummary::enableReportSummary_
bool enableReportSummary_
Definition: RPCEventSummary.h:31
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
RunSummaryRcd.h
dqm::implementation::IBooker::bookFloat
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
ESHandle.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
RPCEventSummary.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
RPCEventSummary::clientOperation
void clientOperation(DQMStore::IGetter &igetter)
Definition: RPCEventSummary.cc:177
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
RunInfo::m_fed_in
std::vector< int > m_fed_in
Definition: RunInfo.h:25
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
alignCSCRings.s
s
Definition: alignCSCRings.py:92
RPCEventSummary::DEAD
Definition: RPCEventSummary.h:44
RPCEventSummary::beginJob
void beginJob() override
Definition: RPCEventSummary.cc:43
RPCEventSummary::globalFolder_
std::string globalFolder_
Definition: RPCEventSummary.h:37
w
const double w
Definition: UKUtility.cc:23
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
edm::ESHandle
Definition: DTSurvey.h:22
CentralityFilter_cfi.BinLabel
BinLabel
Definition: CentralityFilter_cfi.py:5
RPCEventSummary::prefixFolder_
std::string prefixFolder_
Definition: RPCEventSummary.h:37
RPCEventSummary::PARTIALLY_DEAD
Definition: RPCEventSummary.h:44
RunInfoRcd
Definition: RunSummaryRcd.h:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
dqm::impl::MonitorElement::getNbinsY
virtual int getNbinsY() const
get # of bins in Y-axis
Definition: MonitorElement.cc:580
RPCEventSummary::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: RPCEventSummary.cc:171
RPCEventSummary::prescaleFactor_
int prescaleFactor_
Definition: RPCEventSummary.h:32
RPCEventSummary::~RPCEventSummary
~RPCEventSummary() override
Destructor.
Definition: RPCEventSummary.cc:41
RPCEventSummary::offlineDQM_
bool offlineDQM_
Definition: RPCEventSummary.h:35
RPCEventSummary::lumiCounter_
int lumiCounter_
Definition: RPCEventSummary.h:36
edm::EventSetup
Definition: EventSetup.h:58
RPCEventSummary::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: RPCEventSummary.cc:48
RPCEventSummary::numberDisk_
int numberDisk_
Definition: RPCEventSummary.h:39
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:94
alignCSCRings.r
r
Definition: alignCSCRings.py:93
RunInfo.h
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
RPCEventSummary::doEndcapCertification_
bool doEndcapCertification_
Definition: RPCEventSummary.h:40
RPCEventSummary::isIn_
bool isIn_
Definition: RPCEventSummary.h:34
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
dqm::implementation::IGetter
Definition: DQMStore.h:484
RPCEventSummary::NumberOfFeds_
int NumberOfFeds_
Definition: RPCEventSummary.h:42
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
RPCEventSummary::RPCEventSummary
RPCEventSummary(const edm::ParameterSet &ps)
Constructor.
Definition: RPCEventSummary.cc:15
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:574
RPCEventSummary::init_
bool init_
Definition: RPCEventSummary.h:34
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
EventSetup.h
RPCEventSummary::FEDRange_
std::pair< int, int > FEDRange_
Definition: RPCEventSummary.h:41
dqm::implementation::IBooker
Definition: DQMStore.h:43
ztail.d
d
Definition: ztail.py:151
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
RPCEventSummary::minimumEvents_
int minimumEvents_
Definition: RPCEventSummary.h:32