13 #include <fmt/format.h>
19 muonRPCEvents_(nullptr),
20 NumberOfRecHitMuon_(nullptr),
21 NumberOfMuon_(nullptr),
23 numberOfInnerRings_(0) {
27 muPtCut_ =
pset.getUntrackedParameter<
double>(
"MuonPtCut", 3.0);
28 muEtaCut_ =
pset.getUntrackedParameter<
double>(
"MuonEtaCut", 1.9);
45 edm::LogInfo(
"rpcmonitordigi") <<
"[RPCMonitorDigi]: Begin Run ";
49 std::set<int> disk_set;
53 edm::LogInfo(
"rpcmonitordigi") <<
"[RPCMonitorDigi]: Booking histograms per roll. ";
54 for (
auto ich : rpcGeo.dets()) {
55 const RPCChamber* ch = dynamic_cast<const RPCChamber*>(ich);
58 const auto& roles = ch->
rolls();
61 for (
auto roll : roles) {
66 disk_set.insert(rpcId.
station());
77 const RPCDetId& rpcId = roles[0]->id();
83 disk_set.insert(rpcId.
station());
115 edm::LogInfo(
"rpcmonitordigi") <<
"[RPCMonitorDigi]: Beginning analyzing event " <<
counter;
121 std::map<RPCDetId, std::vector<RPCRecHit> > rechitMuon;
124 int numRPCRecHit = 0;
127 int nStaMuons = muonCands->
size();
129 for (
int i = 0;
i < nStaMuons;
i++) {
131 const reco::Muon* muCand = dynamic_cast<const reco::Muon*>(&goodMuon);
139 std::vector<TrackingRecHitRef> rpcTrackRecHits;
142 if (!(*it)->isValid())
144 int muSubDetId = (*it)->geographicalId().subdetId();
148 RPCRecHit* rpcRecHit = dynamic_cast<RPCRecHit*>(tkRecHit);
149 int detId = (
int)rpcRecHit->
rpcId();
150 if (rechitMuon.find(detId) == rechitMuon.end() || rechitMuon[detId].empty()) {
151 std::vector<RPCRecHit> myVect(1, *rpcRecHit);
152 rechitMuon[detId] = myVect;
154 rechitMuon[detId].push_back(*rpcRecHit);
179 edm::LogError(
"rpcmonitordigi") <<
"[RPCMonitorDigi]: Muons - Product not valid for event" <<
counter;
185 std::map<RPCDetId, std::vector<RPCRecHit> > rechitNoise;
189 for (
auto rpcRecHitIter = rpcHits->begin(); rpcRecHitIter != rpcHits->end(); rpcRecHitIter++) {
192 if (rechitNoise.find(detId) == rechitNoise.end() || rechitNoise[detId].empty()) {
193 std::vector<RPCRecHit> myVect(1, rpcRecHit);
194 rechitNoise[detId] = myVect;
196 rechitNoise[detId].push_back(rpcRecHit);
200 edm::LogError(
"rpcmonitordigi") <<
"[RPCMonitorDigi]: RPCRecHits - Product not valid for event" <<
counter;
213 edm::LogInfo(
"rpcmonitordigi") <<
"[RPCMonitorDigi]: Performing DQM source operations for ";
215 if (recHitMap.empty())
218 std::map<std::string, std::map<std::string, MonitorElement*> > meRollCollection;
219 std::map<std::string, MonitorElement*> meWheelDisk;
220 std::map<std::string, MonitorElement*> meRegion;
221 std::map<std::string, MonitorElement*> meSectorRing;
234 edm::LogWarning(
"rpcmonitordigi") <<
"[RPCMonitorDigi]: RecHit type not valid.";
238 int totalNumberOfRecHits[3] = {0, 0, 0};
241 for (
std::map<
RPCDetId, std::vector<RPCRecHit> >::const_iterator detIdIter = recHitMap.begin();
242 detIdIter != recHitMap.end();
244 RPCDetId detId = (*detIdIter).first;
254 int wheelOrDiskNumber;
257 int sector = detId.
sector();
260 int roll = detId.
roll();
262 wheelOrDiskType =
"Wheel";
263 wheelOrDiskNumber = (
int)detId.
ring();
267 if (detId.
layer() == 1) {
277 if (detId.
layer() == 1) {
279 if (
abs(wheelOrDiskNumber) == 2 && roll == 3) {
285 if (
abs(wheelOrDiskNumber) != 2 && roll == 3) {
303 wheelOrDiskType =
"Disk";
308 std::vector<RPCRecHit>
recHits = (*detIdIter).second;
309 const int numberOfRecHits =
recHits.size();
310 totalNumberOfRecHits[
region + 1] += numberOfRecHits;
315 std::map<std::string, MonitorElement*> meMap = meRollCollection[nameRoll];
319 for (std::vector<RPCRecHit>::const_iterator recHitIter =
recHits.begin(); recHitIter !=
recHits.end();
325 int clusterSize = (
int)
recHit.clusterSize();
326 numDigi += clusterSize;
327 int firstStrip =
recHit.firstClusterStrip();
328 int lastStrip = clusterSize + firstStrip - 1;
332 tmpName =
"Occupancy_" + nameRoll;
333 if (meMap[tmpName]) {
334 for (
int s = firstStrip;
s <= lastStrip;
s++) {
336 meMap[tmpName]->Fill(
s);
338 const int nstrips = meMap[tmpName]->getNbinsX() / totalRolls;
339 meMap[tmpName]->Fill(
s + nstrips * (roll - 1));
344 tmpName =
"BXDistribution_" + nameRoll;
346 meMap[tmpName]->Fill(
bx);
348 tmpName =
"ClusterSize_" + nameRoll;
350 meMap[tmpName]->Fill(clusterSize);
354 tmpName =
fmt::format(
"Occupancy_{}_{}_Sector_{}", wheelOrDiskType, wheelOrDiskNumber, sector);
355 if (meSectorRing[tmpName]) {
356 for (
int s = firstStrip;
s <= lastStrip;
s++) {
357 meSectorRing[tmpName]->Fill(
s,
nr);
361 tmpName =
fmt::format(
"Occupancy_{}_{}_Ring_{}", wheelOrDiskType, wheelOrDiskNumber,
ring);
363 tmpName +=
"_CH01-CH18";
364 }
else if (geoServ.
segment() >= 19) {
365 tmpName +=
"_CH19-CH36";
368 if (meSectorRing[tmpName]) {
369 for (
int s = firstStrip;
s <= lastStrip;
s++) {
370 meSectorRing[tmpName]->Fill(
s + 32 * (detId.
roll() - 1), geoServ.
segment());
376 tmpName =
fmt::format(
"1DOccupancy_Wheel_{}", wheelOrDiskNumber);
377 if (meWheelDisk[tmpName])
378 meWheelDisk[tmpName]->Fill(sector, clusterSize);
380 tmpName =
fmt::format(
"Occupancy_Roll_vs_Sector_{}_{}", wheelOrDiskType, wheelOrDiskNumber);
381 if (meWheelDisk[tmpName])
382 meWheelDisk[tmpName]->Fill(sector,
nr, clusterSize);
386 if ((meWheelDisk[tmpName])) {
387 if (wheelOrDiskNumber > 0) {
388 meWheelDisk[tmpName]->Fill(wheelOrDiskNumber +
numberOfDisks_, clusterSize);
390 meWheelDisk[tmpName]->Fill(wheelOrDiskNumber +
numberOfDisks_ + 1, clusterSize);
394 tmpName =
fmt::format(
"Occupancy_Ring_vs_Segment_{}_{}", wheelOrDiskType, wheelOrDiskNumber);
395 if (meWheelDisk[tmpName])
396 meWheelDisk[tmpName]->Fill(geoServ.
segment(), (
ring - 1) * 3 - detId.
roll() + 1, clusterSize);
399 tmpName =
fmt::format(
"BxDistribution_{}_{}", wheelOrDiskType, wheelOrDiskNumber);
400 if (meWheelDisk[tmpName])
401 meWheelDisk[tmpName]->Fill(
bx);
403 tmpName =
fmt::format(
"ClusterSize_{}_{}_Layer{}", wheelOrDiskType, wheelOrDiskNumber,
layer);
404 if (meWheelDisk[tmpName])
405 meWheelDisk[tmpName]->Fill(clusterSize);
407 tmpName =
fmt::format(
"ClusterSize_{}_{}_Ring{}", wheelOrDiskType, wheelOrDiskNumber,
ring);
408 if (meWheelDisk[tmpName])
409 meWheelDisk[tmpName]->Fill(clusterSize);
413 if (meRegion[tmpName])
414 meRegion[tmpName]->Fill(clusterSize);
422 if (meRegion[tmpName])
423 meRegion[tmpName]->Fill(clusterSize);
427 tmpName =
"BXWithData_" + nameRoll;
429 meMap[tmpName]->Fill(bxSet.size());
431 tmpName =
"NumberOfClusters_" + nameRoll;
433 meMap[tmpName]->Fill(numberOfRecHits);
436 if (meRegion[tmpName])
437 meRegion[tmpName]->Fill(numDigi);
440 if (meRegion[
"Occupancy_for_Barrel"])
441 meRegion[
"Occupancy_for_Barrel"]->Fill(sector, wheelOrDiskNumber, numDigi);
447 if (meRegion[
"Occupancy_for_Endcap"]) {
448 meRegion[
"Occupancy_for_Endcap"]->Fill(xbin,
ring, numDigi);
452 tmpName =
"Multiplicity_" + nameRoll;
454 meMap[tmpName]->Fill(numDigi);
458 for (
int i = 0;
i < 3;
i++) {
460 if (meRegion[tmpName])
461 meRegion[tmpName]->Fill(totalNumberOfRecHits[
i]);