CMS 3D CMS Logo

RPCDqmClient.cc
Go to the documentation of this file.
1 // Package: RPCDqmClient
2 // Original Author: Anna Cimmino
6 //include client headers
12 //Geometry
15 //Framework
18 
19 #include <fmt/format.h>
20 
22  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: Constructor";
23 
24  offlineDQM_ = pset.getUntrackedParameter<bool>("OfflineDQM", true);
25  useRollInfo_ = pset.getUntrackedParameter<bool>("UseRollInfo", false);
26  //check enabling
27  enableDQMClients_ = pset.getUntrackedParameter<bool>("EnableRPCDqmClient", true);
28  minimumEvents_ = pset.getUntrackedParameter<int>("MinimumRPCEvents", 10000);
29  numberOfDisks_ = pset.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
30  numberOfRings_ = pset.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
31 
32  std::string subsystemFolder = pset.getUntrackedParameter<std::string>("RPCFolder", "RPC");
33  std::string recHitTypeFolder = pset.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
34  std::string summaryFolder = pset.getUntrackedParameter<std::string>("SummaryFolder", "SummaryHistograms");
35 
36  prefixDir_ = subsystemFolder + "/" + recHitTypeFolder;
37  globalFolder_ = subsystemFolder + "/" + recHitTypeFolder + "/" + summaryFolder;
38 
39  //get prescale factor
40  prescaleGlobalFactor_ = pset.getUntrackedParameter<int>("DiagnosticGlobalPrescale", 5);
41 
42  //make default client list
43  clientList_ = {{"RPCMultiplicityTest", "RPCDeadChannelTest", "RPCClusterSizeTest"}};
44  clientList_ = pset.getUntrackedParameter<std::vector<std::string> >("RPCDqmClientList", clientList_);
45 
46  //get all the possible RPC DQM clients
47  this->makeClientMap(pset);
48 
49  //clear counters
50  lumiCounter_ = 0;
51  RPCEvents_ = nullptr;
52 
53  rpcGeomToken_ = esConsumes<edm::Transition::EndLuminosityBlock>();
54 }
55 
57  if (!enableDQMClients_) {
58  return;
59  };
60  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: Begin Job";
61 
62  //Do whatever the begin jobs of all client modules do
63  for (auto& module : clientModules_) {
64  module->beginJob(globalFolder_);
65  }
66 }
67 
69  DQMStore::IGetter& igetter,
70  edm::LuminosityBlock const& lumiSeg,
71  edm::EventSetup const& c) {
72  if (!enableDQMClients_) {
73  return;
74  }
75  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: End DQM LB";
76 
77  if (myDetIds_.empty()) {
78  //Get RPCdetId...
79 
80  this->getRPCdetId(c);
81 
82  //...book summary histograms
83  for (auto& module : clientModules_) {
84  module->myBooker(ibooker);
85  }
86  }
87 
88  if (!offlineDQM_) { //Do this only for the online
89 
90  if (lumiCounter_ == 0) { //only for the first lumi section do this...
91  // ...get chamber based histograms and pass them to the client modules
92  this->getMonitorElements(igetter);
93  }
94 
95  //Do not perform client oparations every lumi block
96  ++lumiCounter_;
98  return;
99  }
100 
101  //Check if there's enough statistics
102  float rpcevents = minimumEvents_;
103  if (RPCEvents_) {
104  rpcevents = RPCEvents_->getBinContent(1);
105  }
106  if (rpcevents < minimumEvents_) {
107  return;
108  }
109 
110  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: Client operations";
111  for (auto& module : clientModules_) {
112  module->clientOperation();
113  }
114  } //end of online operations
115 }
116 
118  if (!enableDQMClients_) {
119  return;
120  }
121 
122  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: End DQM Job";
123 
124  if (offlineDQM_) { // ...get chamber based histograms and pass them to the client modules
125  this->getMonitorElements(igetter);
126  }
127 
128  float rpcevents = minimumEvents_;
129  if (RPCEvents_) {
130  rpcevents = RPCEvents_->getBinContent(1);
131  }
132  if (rpcevents < minimumEvents_) {
133  return;
134  }
135 
136  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: Client operations";
137  for (auto& module : clientModules_) {
138  module->clientOperation();
139  }
140 }
141 
143  std::vector<MonitorElement*> myMeVect;
144  std::vector<RPCDetId> myDetIds;
145 
146  //loop on all geometry and get all histos
147  for (auto& detId : myDetIds_) {
148  //Get name
151 
152  //loop on clients
153  for (unsigned int cl = 0, nCL = clientModules_.size(); cl < nCL; ++cl) {
154  if (clientHisto_[cl] == "ClusterSize")
155  continue;
156 
157  MonitorElement* myMe = igetter.get(fmt::format("{}/{}/{}_{}", prefixDir_, folder, clientHisto_[cl], rollName));
158  if (!myMe)
159  continue;
160 
161  myMeVect.push_back(myMe);
162  myDetIds.push_back(detId);
163 
164  } //end loop on clients
165  } //end loop on all geometry and get all histos
166 
167  //Clustersize
168  std::vector<MonitorElement*> myMeVectCl;
169  const std::array<std::string, 4> chNames = {{"CH01-CH09", "CH10-CH18", "CH19-CH27", "CH28-CH36"}};
170 
171  //Retrieve barrel clustersize
172  for (int wheel = -2; wheel <= 2; wheel++) {
173  for (int sector = 1; sector <= 12; sector++) {
174  MonitorElement* myMeCl = igetter.get(fmt::format(
175  "{}/Barrel/Wheel_{}/SummaryBySectors/ClusterSize_Wheel_{}_Sector_{}", prefixDir_, wheel, wheel, sector));
176  myMeVectCl.push_back(myMeCl);
177  }
178  }
179  //Retrieve endcaps clustersize
180  for (int region = -1; region <= 1; region++) {
181  if (region == 0)
182  continue;
183 
184  std::string regionName = "Endcap-";
185  if (region == 1)
186  regionName = "Endcap+";
187 
188  for (int disk = 1; disk <= numberOfDisks_; disk++) {
189  for (int ring = numberOfRings_; ring <= 3; ring++) {
190  for (unsigned int ich = 0; ich < chNames.size(); ich++) {
191  MonitorElement* myMeCl =
192  igetter.get(fmt::format("{}/{}/Disk_{}/SummaryByRings/ClusterSize_Disk_{}_Ring_{}_{}",
193  prefixDir_,
194  regionName,
195  (region * disk),
196  (region * disk),
197  ring,
198  chNames[ich]));
199  myMeVectCl.push_back(myMeCl);
200  }
201  }
202  }
203  }
204 
205  RPCEvents_ = igetter.get(prefixDir_ + "/RPCEvents");
206  for (unsigned int cl = 0; cl < clientModules_.size(); ++cl) {
207  if (clientHisto_[cl] == "ClusterSize")
208  clientModules_[cl]->getMonitorElements(myMeVectCl, myDetIds, clientHisto_[cl]);
209  else
210  clientModules_[cl]->getMonitorElements(myMeVect, myDetIds, clientHisto_[cl]);
211  }
212 }
213 
215  myDetIds_.clear();
216 
217  auto rpcGeo = eventSetup.getHandle(rpcGeomToken_);
218 
219  for (auto& det : rpcGeo->dets()) {
220  const RPCChamber* ch = dynamic_cast<const RPCChamber*>(det);
221  if (!ch)
222  continue;
223 
224  //Loop on rolls in given chamber
225  for (auto& r : ch->rolls()) {
226  myDetIds_.push_back(r->id());
227  }
228  }
229 }
230 
232  for (unsigned int i = 0; i < clientList_.size(); i++) {
233  if (clientList_[i] == "RPCMultiplicityTest") {
234  clientHisto_.push_back("Multiplicity");
235  // clientTag_.push_back(rpcdqm::MULTIPLICITY);
236  clientModules_.emplace_back(new RPCMultiplicityTest(pset));
237  } else if (clientList_[i] == "RPCDeadChannelTest") {
238  clientHisto_.push_back("Occupancy");
239  clientModules_.emplace_back(new RPCDeadChannelTest(pset));
240  // clientTag_.push_back(rpcdqm::OCCUPANCY);
241  } else if (clientList_[i] == "RPCClusterSizeTest") {
242  clientHisto_.push_back("ClusterSize");
243  clientModules_.emplace_back(new RPCClusterSizeTest(pset));
244  // clientTag_.push_back(rpcdqm::CLUSTERSIZE);
245  } else if (clientList_[i] == "RPCOccupancyTest") {
246  clientHisto_.push_back("Occupancy");
247  clientModules_.emplace_back(new RPCOccupancyTest(pset));
248  // clientTag_.push_back(rpcdqm::OCCUPANCY);
249  } else if (clientList_[i] == "RPCNoisyStripTest") {
250  clientHisto_.push_back("Occupancy");
251  clientModules_.emplace_back(new RPCNoisyStripTest(pset));
252  //clientTag_.push_back(rpcdqm::OCCUPANCY);
253  }
254  }
255 
256  return;
257 }
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: RPCDqmClient.cc:68
Log< level::Info, true > LogVerbatim
MonitorElement * RPCEvents_
Definition: RPCDqmClient.h:46
void beginJob() override
Definition: RPCDqmClient.cc:56
std::string prefixDir_
Definition: RPCDqmClient.h:42
std::vector< std::unique_ptr< RPCClient > > clientModules_
Definition: RPCDqmClient.h:49
int numberOfRings_
Definition: RPCDqmClient.h:39
void getMonitorElements(DQMStore::IGetter &)
std::vector< std::string > clientList_
Definition: RPCDqmClient.h:44
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeomToken_
Definition: RPCDqmClient.h:53
void makeClientMap(const edm::ParameterSet &parameters_)
std::vector< std::string > clientHisto_
Definition: RPCDqmClient.h:48
RPCDeadChannelTest
RPC Client Modules #######################.
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
bool useRollInfo_
Definition: RPCDqmClient.h:41
std::string globalFolder_
Definition: RPCDqmClient.h:43
int numberOfDisks_
Definition: RPCDqmClient.h:39
static std::string name(const RPCDetId &detId, const bool useRoll)
Definition: RPCNameHelper.cc:6
void getRPCdetId(const edm::EventSetup &)
int minimumEvents_
Definition: RPCDqmClient.h:38
static std::string folderStructure(const RPCDetId &detId)
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
std::vector< RPCDetId > myDetIds_
Definition: RPCDqmClient.h:47
bool enableDQMClients_
Definition: RPCDqmClient.h:41
RPCDqmClient(const edm::ParameterSet &ps)
Constructor.
Definition: RPCDqmClient.cc:21
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
Definition: RPCChamber.cc:40
int prescaleGlobalFactor_
Definition: RPCDqmClient.h:38
bool offlineDQM_
Definition: RPCDqmClient.h:37
virtual double getBinContent(int binx) const
get content of bin (1-D)