CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  RPCSummaryMapHisto::setBinsBarrel(me, defaultValue);
87  RPCSummaryMapHisto::setBinsEndcap(me, defaultValue);
88 
89  //the reportSummaryContents folder containins a collection of ME floats [0-1] (order of 5-10)
90  // which describe the behavior of the respective subsystem sub-components.
91  ibooker.setCurrentFolder(eventInfoPath_ + "/reportSummaryContents");
92 
93  std::vector<std::string> segmentNames;
94  for (int i = -2; i <= 2; i++) {
95  const std::string segName = fmt::format("RPC_Wheel{}", i);
96  segmentNames.push_back(segName);
97  }
98 
99  for (int i = -numberDisk_; i <= numberDisk_; i++) {
100  if (i == 0)
101  continue;
102  const std::string segName = fmt::format("RPC_Disk{}", i);
103  segmentNames.push_back(segName);
104  }
105 
106  for (const auto& segmentName : segmentNames) {
107  MonitorElement* me = ibooker.bookFloat(segmentName);
108  me->Fill(defaultValue);
109  }
110 
112  init_ = true;
113  }
114 
115  if (isIn_ && !offlineDQM_ && lumiCounter_ % prescaleFactor_ == 0) {
116  this->clientOperation(igetter);
117  }
118 
119  ++lumiCounter_;
120 }
121 
123  if (isIn_) {
124  this->clientOperation(igetter);
125  }
126 }
127 
129  float rpcevents = minimumEvents_;
130  MonitorElement* RPCEvents = igetter.get(prefixFolder_ + "/RPCEvents");
131 
132  if (RPCEvents) {
133  rpcevents = RPCEvents->getBinContent(1);
134  }
135 
136  if (rpcevents < minimumEvents_)
137  return;
138 
139  MonitorElement* reportMe = igetter.get(eventInfoPath_ + "/reportSummaryMap");
140 
141  //BARREL
142  float barrelFactor = 0;
143 
144  for (int w = -2; w < 3; w++) {
145  const std::string meName = fmt::format("{}/RPCChamberQuality_Roll_vs_Sector_Wheel{}", globalFolder_, w);
146  MonitorElement* myMe = igetter.get(meName);
147 
148  if (myMe) {
149  float wheelFactor = 0;
150 
151  for (int s = 1; s <= myMe->getNbinsX(); s++) {
152  float sectorFactor = 0;
153  int rollInSector = 0;
154 
155  for (int r = 1; r <= myMe->getNbinsY(); r++) {
156  if ((s != 4 && r > 17) || ((s == 9 || s == 10) && r > 15))
157  continue;
158  rollInSector++;
159 
160  if (myMe->getBinContent(s, r) == PARTIALLY_DEAD)
161  sectorFactor += 0.8;
162  else if (myMe->getBinContent(s, r) == DEAD)
163  sectorFactor += 0;
164  else
165  sectorFactor += 1;
166  }
167  if (rollInSector != 0)
168  sectorFactor = sectorFactor / rollInSector;
169 
170  if (reportMe)
171  reportMe->setBinContent(w + 8, s, sectorFactor);
172  wheelFactor += sectorFactor;
173 
174  } //end loop on sectors
175 
176  wheelFactor = wheelFactor / myMe->getNbinsX();
177 
178  const std::string globalMEName = fmt::format("{}/reportSummaryContents/RPC_Wheel{}", eventInfoPath_, w);
179  MonitorElement* globalMe = igetter.get(globalMEName);
180  if (globalMe)
181  globalMe->Fill(wheelFactor);
182 
183  barrelFactor += wheelFactor;
184  } //
185  } //end loop on wheel
186 
187  barrelFactor = barrelFactor / 5;
188 
189  float endcapFactor = 0;
190 
192  //Endcap
193  for (int d = -numberDisk_; d <= numberDisk_; d++) {
194  if (d == 0)
195  continue;
196 
197  const std::string meName = fmt::format("{}/RPCChamberQuality_Ring_vs_Segment_Disk{}", globalFolder_, d);
198  MonitorElement* myMe = igetter.get(meName);
199 
200  if (myMe) {
201  float diskFactor = 0;
202 
203  float sectorFactor[6] = {0, 0, 0, 0, 0, 0};
204 
205  for (int i = 0; i < 6; i++) {
206  int firstSeg = (i * 6) + 1;
207  int lastSeg = firstSeg + 6;
208  int rollInSector = 0;
209  for (int seg = firstSeg; seg < lastSeg; seg++) {
210  for (int y = 1; y <= myMe->getNbinsY(); y++) {
211  rollInSector++;
212  if (myMe->getBinContent(seg, y) == PARTIALLY_DEAD)
213  sectorFactor[i] += 0.8;
214  else if (myMe->getBinContent(seg, y) == DEAD)
215  sectorFactor[i] += 0;
216  else
217  sectorFactor[i] += 1;
218  }
219  }
220  sectorFactor[i] = sectorFactor[i] / rollInSector;
221  } //end loop on Sectors
222 
223  for (int sec = 0; sec < 6; sec++) {
224  diskFactor += sectorFactor[sec];
225  if (reportMe) {
226  if (d < 0)
227  reportMe->setBinContent(d + 5, sec + 1, sectorFactor[sec]);
228  else
229  reportMe->setBinContent(d + 11, sec + 1, sectorFactor[sec]);
230  }
231  }
232 
233  diskFactor = diskFactor / 6;
234 
235  const std::string globalMEName = fmt::format("{}/reportSummaryContents/RPC_Disk{}", eventInfoPath_, d);
236  MonitorElement* globalMe = igetter.get(globalMEName);
237  if (globalMe)
238  globalMe->Fill(diskFactor);
239 
240  endcapFactor += diskFactor;
241  } //end loop on disks
242  }
243 
244  endcapFactor = endcapFactor / (numberDisk_ * 2);
245  }
246 
247  //Fill repor summary
248  float rpcFactor = barrelFactor;
250  rpcFactor = (barrelFactor + endcapFactor) / 2;
251  }
252 
253  MonitorElement* globalMe = igetter.get(eventInfoPath_ + "/reportSummary");
254  if (globalMe)
255  globalMe->Fill(rpcFactor);
256 }
std::string eventInfoPath_
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
std::optional< T > tryToGet() const
Definition: EventSetup.h:109
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
const double w
Definition: UKUtility.cc:23
virtual int getNbinsY() const
get # of bins in Y-axis
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
~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_
void Fill(long long x)
tuple d
Definition: ztail.py:151
std::string globalFolder_
virtual int getNbinsX() const
get # of bins in X-axis
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
virtual double getBinContent(int binx) const
get content of bin (1-D)
void clientOperation(DQMStore::IGetter &igetter)
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.
std::pair< int, int > FEDRange_
std::string prefixFolder_
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