CMS 3D CMS Logo

RPCEventSummary.cc
Go to the documentation of this file.
1 /* \author Anna Cimmino*/
4 
8 
10  edm::LogVerbatim("rpceventsummary") << "[RPCEventSummary]: Constructor";
11 
12  enableReportSummary_ = ps.getUntrackedParameter<bool>("EnableSummaryReport", true);
13  prescaleFactor_ = ps.getUntrackedParameter<int>("PrescaleFactor", 1);
14  eventInfoPath_ = ps.getUntrackedParameter<std::string>("EventInfoPath", "RPC/EventInfo");
15 
16  std::string subsystemFolder = ps.getUntrackedParameter<std::string>("RPCFolder", "RPC");
17  std::string recHitTypeFolder = ps.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
18  std::string summaryFolder = ps.getUntrackedParameter<std::string>("SummaryFolder", "SummaryHistograms");
19 
20  globalFolder_ = subsystemFolder + "/" + recHitTypeFolder + "/" + summaryFolder;
21  prefixFolder_ = subsystemFolder + "/" + recHitTypeFolder;
22 
23  minimumEvents_ = ps.getUntrackedParameter<int>("MinimumRPCEvents", 10000);
24  numberDisk_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
25  doEndcapCertification_ = ps.getUntrackedParameter<bool>("EnableEndcapSummary", false);
26 
27  FEDRange_.first = ps.getUntrackedParameter<unsigned int>("MinimumRPCFEDId", 790);
28  FEDRange_.second = ps.getUntrackedParameter<unsigned int>("MaximumRPCFEDId", 792);
29 
30  NumberOfFeds_ = FEDRange_.second - FEDRange_.first + 1;
31 
32  offlineDQM_ = ps.getUntrackedParameter<bool>("OfflineDQM", true);
33 
34  runInfoToken_ = esConsumes<edm::Transition::EndLuminosityBlock>();
35 }
36 
37 RPCEventSummary::~RPCEventSummary() { edm::LogVerbatim("rpceventsummary") << "[RPCEventSummary]: Destructor "; }
38 
40  edm::LogVerbatim("rpceventsummary") << "[RPCEventSummary]: Begin job ";
41  init_ = false;
42 }
43 
45  DQMStore::IGetter& igetter,
46  edm::LuminosityBlock const& lb,
47  edm::EventSetup const& setup) {
48  edm::LogVerbatim("rpceventsummary") << "[RPCEventSummary]: Begin run";
49 
50  if (!init_) {
52 
55 
56  int defaultValue = 1;
57  isIn_ = true;
58 
59  if (auto runInfoRec = setup.tryToGet<RunInfoRcd>()) {
60  defaultValue = -1;
61  //get fed summary information
62  auto sumFED = runInfoRec->get(runInfoToken_);
63  const std::vector<int> FedsInIds = sumFED.m_fed_in;
64  unsigned int f = 0;
65  isIn_ = false;
66  while (!isIn_ && f < FedsInIds.size()) {
67  int fedID = FedsInIds[f];
68  //make sure fed id is in allowed range
69  if (fedID >= FEDRange_.first && fedID <= FEDRange_.second) {
70  defaultValue = 1;
71  isIn_ = true;
72  }
73  f++;
74  }
75  }
76 
78 
79  //a global summary float [0,1] providing a global summary of the status
80  //and showing the goodness of the data taken by the the sub-system
81  MonitorElement* meSummary = ibooker.bookFloat("reportSummary");
82  meSummary->Fill(defaultValue);
83 
84  //TH2F ME providing a mapof values[0-1] to show if problems are localized or distributed
85  MonitorElement* me = RPCSummaryMapHisto::book(ibooker, "reportSummaryMap", "RPC Report Summary Map");
86  MonitorElement* me2 = RPCSummaryMapHisto::book(ibooker, "noisySummaryMap", "RPC Noisy Chamber Summary Map");
91 
92  //the reportSummaryContents folder containins a collection of ME floats [0-1] (order of 5-10)
93  // which describe the behavior of the respective subsystem sub-components.
94  ibooker.setCurrentFolder(eventInfoPath_ + "/reportSummaryContents");
95 
96  std::vector<std::string> segmentNames;
97  for (int i = -2; i <= 2; i++) {
98  const std::string segName = fmt::format("RPC_Wheel{}", i);
99  segmentNames.push_back(segName);
100  }
101 
102  for (int i = -numberDisk_; i <= numberDisk_; i++) {
103  if (i == 0)
104  continue;
105  const std::string segName = fmt::format("RPC_Disk{}", i);
106  segmentNames.push_back(segName);
107  }
108 
109  for (const auto& segmentName : segmentNames) {
110  MonitorElement* me3 = ibooker.bookFloat(segmentName);
111  me3->Fill(defaultValue);
112  }
113 
115  init_ = true;
116  }
117 
118  if (isIn_ && !offlineDQM_ && lumiCounter_ % prescaleFactor_ == 0) {
119  this->clientOperation(igetter);
120  }
121 
122  ++lumiCounter_;
123 }
124 
126  if (isIn_) {
127  this->clientOperation(igetter);
128  }
129 }
130 
132  float rpcevents = minimumEvents_;
133  MonitorElement* RPCEvents = igetter.get(prefixFolder_ + "/RPCEvents");
134 
135  if (RPCEvents) {
136  rpcevents = RPCEvents->getBinContent(1);
137  }
138 
139  if (rpcevents < minimumEvents_)
140  return;
141 
142  MonitorElement* reportMe = igetter.get(eventInfoPath_ + "/reportSummaryMap");
143  MonitorElement* reportMe2 = igetter.get(eventInfoPath_ + "/noisySummaryMap");
144 
145  //BARREL
146  float barrelFactor = 0;
147 
148  for (int w = -2; w < 3; w++) {
149  const std::string meName1 = fmt::format("{}/DeadChannelFraction_Roll_vs_Sector_Wheel{}", globalFolder_, w);
150  const std::string meName2 = fmt::format("{}/RPCNoisyStrips_Roll_vs_Sector_Wheel{}", globalFolder_, w);
151  MonitorElement* myMe1 = igetter.get(meName1);
152  MonitorElement* myMe2 = igetter.get(meName2);
153 
154  if (myMe1 && myMe2) {
155  float wheelFactor = 0;
156 
157  for (int s = 1; s <= myMe1->getNbinsX(); s++) {
158  float sectorFactor = 0;
159  float sectorFactor2 = 0;
160  int rollInSector = 0;
161 
162  for (int r = 1; r <= myMe1->getNbinsY(); r++) {
163  if ((s != 4 && r > 17) || ((s == 9 || s == 11) && r > 15))
164  continue;
165  rollInSector++;
166  sectorFactor += 1 - myMe1->getBinContent(s, r);
167  sectorFactor2 += myMe2->getBinContent(s, r);
168  }
169 
170  if (rollInSector != 0) {
171  sectorFactor = sectorFactor / rollInSector;
172  sectorFactor2 = sectorFactor2 / rollInSector;
173  }
174 
175  if (reportMe)
176  reportMe->setBinContent(w + 8, s, sectorFactor);
177  if (reportMe2)
178  reportMe2->setBinContent(w + 8, s, sectorFactor2);
179  wheelFactor += sectorFactor;
180 
181  } //end loop on sectors
182 
183  wheelFactor = wheelFactor / myMe1->getNbinsX();
184 
185  const std::string globalMEName = fmt::format("{}/reportSummaryContents/RPC_Wheel{}", eventInfoPath_, w);
186  MonitorElement* globalMe = igetter.get(globalMEName);
187  if (globalMe)
188  globalMe->Fill(wheelFactor);
189 
190  barrelFactor += wheelFactor;
191  } //
192  } //end loop on wheel
193 
194  barrelFactor = barrelFactor / 5;
195 
196  float endcapFactor = 0;
197 
199  //Endcap
200  for (int d = -numberDisk_; d <= numberDisk_; d++) {
201  if (d == 0)
202  continue;
203 
204  const std::string meName1 = fmt::format("{}/DeadChannelFraction_Ring_vs_Segment_Disk{}", globalFolder_, d);
205  const std::string meName2 = fmt::format("{}/RPCNoisyStrips_Ring_vs_Segment_Disk{}", globalFolder_, d);
206  MonitorElement* myMe1 = igetter.get(meName1);
207  MonitorElement* myMe2 = igetter.get(meName2);
208 
209  if (myMe1 && myMe2) {
210  float diskFactor = 0;
211 
212  float sectorFactor[6] = {0, 0, 0, 0, 0, 0};
213  float sectorFactor2[6] = {0, 0, 0, 0, 0, 0};
214 
215  for (int i = 0; i < 6; i++) {
216  int firstSeg = (i * 6) + 1;
217  int lastSeg = firstSeg + 6;
218  int rollInSector = 0;
219  for (int seg = firstSeg; seg < lastSeg; seg++) {
220  for (int y = 1; y <= myMe1->getNbinsY(); y++) {
221  rollInSector++;
222  sectorFactor[i] += 1 - myMe1->getBinContent(seg, y);
223  sectorFactor2[i] += myMe2->getBinContent(seg, y);
224  }
225  }
226  sectorFactor[i] = sectorFactor[i] / rollInSector;
227  sectorFactor2[i] = sectorFactor2[i] / rollInSector;
228  } //end loop on Sectors
229 
230  for (int sec = 0; sec < 6; sec++) {
231  diskFactor += sectorFactor[sec];
232  if (reportMe) {
233  if (d < 0)
234  reportMe->setBinContent(d + 5, sec + 1, sectorFactor[sec]);
235  else
236  reportMe->setBinContent(d + 11, sec + 1, sectorFactor[sec]);
237  }
238  if (reportMe2) {
239  if (d < 0)
240  reportMe2->setBinContent(d + 5, sec + 1, sectorFactor2[sec]);
241  else
242  reportMe2->setBinContent(d + 11, sec + 1, sectorFactor2[sec]);
243  }
244  }
245 
246  diskFactor = diskFactor / 6;
247 
248  const std::string globalMEName = fmt::format("{}/reportSummaryContents/RPC_Disk{}", eventInfoPath_, d);
249  MonitorElement* globalMe = igetter.get(globalMEName);
250  if (globalMe)
251  globalMe->Fill(diskFactor);
252 
253  endcapFactor += diskFactor;
254  } //end loop on disks
255  }
256 
257  endcapFactor = endcapFactor / (numberDisk_ * 2);
258  }
259 
260  //Fill repor summary
261  float rpcFactor = barrelFactor;
263  rpcFactor = (barrelFactor + endcapFactor) / 2;
264  }
265 
266  MonitorElement* globalMe = igetter.get(eventInfoPath_ + "/reportSummary");
267  if (globalMe)
268  globalMe->Fill(rpcFactor);
269 }
std::string eventInfoPath_
Log< level::Info, true > LogVerbatim
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
T w() const
~RPCEventSummary() override
Destructor.
static void setBinsEndcap(MonitorElement *me, const double value)
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
void beginJob() override
edm::ESGetToken< RunInfo, RunInfoRcd > runInfoToken_
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
std::string globalFolder_
double f[11][100]
d
Definition: ztail.py:151
void clientOperation(DQMStore::IGetter &igetter)
virtual int getNbinsY() const
get # of bins in Y-axis
static MonitorElement * book(IBooker &booker, const std::string &name, const std::string &title)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
RPCEventSummary(const edm::ParameterSet &ps)
Constructor.
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
std::pair< int, int > FEDRange_
std::string prefixFolder_
virtual int getNbinsX() const
get # of bins in X-axis
static void setBinsBarrel(MonitorElement *me, const double value)
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
virtual double getBinContent(int binx) const
get content of bin (1-D)