CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
30  std::string subsystemFolder = pset.getUntrackedParameter<std::string>("RPCFolder", "RPC");
31  std::string recHitTypeFolder = pset.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
32  std::string summaryFolder = pset.getUntrackedParameter<std::string>("SummaryFolder", "SummaryHistograms");
33 
34  prefixDir_ = subsystemFolder + "/" + recHitTypeFolder;
35  globalFolder_ = subsystemFolder + "/" + recHitTypeFolder + "/" + summaryFolder;
36 
37  //get prescale factor
38  prescaleGlobalFactor_ = pset.getUntrackedParameter<int>("DiagnosticGlobalPrescale", 5);
39 
40  //make default client list
41  clientList_ = {{"RPCMultiplicityTest", "RPCDeadChannelTest", "RPCClusterSizeTest"}};
42  clientList_ = pset.getUntrackedParameter<std::vector<std::string> >("RPCDqmClientList", clientList_);
43 
44  //get all the possible RPC DQM clients
45  this->makeClientMap(pset);
46 
47  //clear counters
48  lumiCounter_ = 0;
49 
50  rpcGeomToken_ = esConsumes<edm::Transition::EndLuminosityBlock>();
51 }
52 
54  if (!enableDQMClients_) {
55  return;
56  };
57  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: Begin Job";
58 
59  //Do whatever the begin jobs of all client modules do
60  for (auto& module : clientModules_) {
61  module->beginJob(globalFolder_);
62  }
63 }
64 
66  DQMStore::IGetter& igetter,
67  edm::LuminosityBlock const& lumiSeg,
68  edm::EventSetup const& c) {
69  if (!enableDQMClients_) {
70  return;
71  }
72  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: End DQM LB";
73 
74  if (myDetIds_.empty()) {
75  //Get RPCdetId...
76 
77  this->getRPCdetId(c);
78 
79  //...book summary histograms
80  for (auto& module : clientModules_) {
81  module->myBooker(ibooker);
82  }
83  }
84 
85  if (!offlineDQM_) { //Do this only for the online
86 
87  if (lumiCounter_ == 0) { //only for the first lumi section do this...
88  // ...get chamber based histograms and pass them to the client modules
89  this->getMonitorElements(igetter);
90  }
91 
92  //Do not perform client oparations every lumi block
93  ++lumiCounter_;
95  return;
96  }
97 
98  //Check if there's enough statistics
99  float rpcevents = minimumEvents_;
100  if (RPCEvents_) {
101  rpcevents = RPCEvents_->getBinContent(1);
102  }
103  if (rpcevents < minimumEvents_) {
104  return;
105  }
106 
107  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: Client operations";
108  for (auto& module : clientModules_) {
109  module->clientOperation();
110  }
111  } //end of online operations
112 }
113 
115  if (!enableDQMClients_) {
116  return;
117  }
118 
119  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: End DQM Job";
120 
121  if (offlineDQM_) { // ...get chamber based histograms and pass them to the client modules
122  this->getMonitorElements(igetter);
123  }
124 
125  float rpcevents = minimumEvents_;
126  if (RPCEvents_) {
127  rpcevents = RPCEvents_->getBinContent(1);
128  }
129  if (rpcevents < minimumEvents_) {
130  return;
131  }
132 
133  edm::LogVerbatim("rpcdqmclient") << "[RPCDqmClient]: Client operations";
134  for (auto& module : clientModules_) {
135  module->clientOperation();
136  }
137 }
138 
140  std::vector<MonitorElement*> myMeVect;
141  std::vector<RPCDetId> myDetIds;
142 
143  //loop on all geometry and get all histos
144  for (auto& detId : myDetIds_) {
145  //Get name
146  const std::string rollName = RPCNameHelper::name(detId, useRollInfo_);
148 
149  //loop on clients
150  for (unsigned int cl = 0, nCL = clientModules_.size(); cl < nCL; ++cl) {
151  MonitorElement* myMe = igetter.get(fmt::format("{}/{}/{}_{}", prefixDir_, folder, clientHisto_[cl], rollName));
152  if (!myMe)
153  continue;
154 
155  myMeVect.push_back(myMe);
156  myDetIds.push_back(detId);
157 
158  } //end loop on clients
159  } //end loop on all geometry and get all histos
160 
161  RPCEvents_ = igetter.get(prefixDir_ + "/RPCEvents");
162  for (unsigned int cl = 0; cl < clientModules_.size(); ++cl) {
163  clientModules_[cl]->getMonitorElements(myMeVect, myDetIds, clientHisto_[cl]);
164  }
165 }
166 
168  myDetIds_.clear();
169 
170  auto rpcGeo = eventSetup.getHandle(rpcGeomToken_);
171 
172  for (auto& det : rpcGeo->dets()) {
173  const RPCChamber* ch = dynamic_cast<const RPCChamber*>(det);
174  if (!ch)
175  continue;
176 
177  //Loop on rolls in given chamber
178  for (auto& r : ch->rolls()) {
179  myDetIds_.push_back(r->id());
180  }
181  }
182 }
183 
185  for (unsigned int i = 0; i < clientList_.size(); i++) {
186  if (clientList_[i] == "RPCMultiplicityTest") {
187  clientHisto_.push_back("Multiplicity");
188  // clientTag_.push_back(rpcdqm::MULTIPLICITY);
189  clientModules_.emplace_back(new RPCMultiplicityTest(pset));
190  } else if (clientList_[i] == "RPCDeadChannelTest") {
191  clientHisto_.push_back("Occupancy");
192  clientModules_.emplace_back(new RPCDeadChannelTest(pset));
193  // clientTag_.push_back(rpcdqm::OCCUPANCY);
194  } else if (clientList_[i] == "RPCClusterSizeTest") {
195  clientHisto_.push_back("ClusterSize");
196  clientModules_.emplace_back(new RPCClusterSizeTest(pset));
197  // clientTag_.push_back(rpcdqm::CLUSTERSIZE);
198  } else if (clientList_[i] == "RPCOccupancyTest") {
199  clientHisto_.push_back("Occupancy");
200  clientModules_.emplace_back(new RPCOccupancyTest(pset));
201  // clientTag_.push_back(rpcdqm::OCCUPANCY);
202  } else if (clientList_[i] == "RPCNoisyStripTest") {
203  clientHisto_.push_back("Occupancy");
204  clientModules_.emplace_back(new RPCNoisyStripTest(pset));
205  //clientTag_.push_back(rpcdqm::OCCUPANCY);
206  }
207  }
208 
209  return;
210 }
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: RPCDqmClient.cc:65
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
MonitorElement * RPCEvents_
Definition: RPCDqmClient.h:45
void beginJob() override
Definition: RPCDqmClient.cc:53
std::string prefixDir_
Definition: RPCDqmClient.h:41
std::vector< std::unique_ptr< RPCClient > > clientModules_
Definition: RPCDqmClient.h:48
void getMonitorElements(DQMStore::IGetter &)
tuple cl
Definition: haddnano.py:49
std::vector< std::string > clientList_
Definition: RPCDqmClient.h:43
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeomToken_
Definition: RPCDqmClient.h:52
void makeClientMap(const edm::ParameterSet &parameters_)
std::vector< std::string > clientHisto_
Definition: RPCDqmClient.h:47
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
Definition: RPCChamber.cc:40
bool useRollInfo_
Definition: RPCDqmClient.h:40
std::string globalFolder_
Definition: RPCDqmClient.h:42
virtual double getBinContent(int binx) const
get content of bin (1-D)
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)
std::vector< RPCDetId > myDetIds_
Definition: RPCDqmClient.h:46
bool enableDQMClients_
Definition: RPCDqmClient.h:40
RPCDqmClient(const edm::ParameterSet &ps)
Constructor.
Definition: RPCDqmClient.cc:21
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
int prescaleGlobalFactor_
Definition: RPCDqmClient.h:38
bool offlineDQM_
Definition: RPCDqmClient.h:37
tuple module
Definition: callgraph.py:69