13 #include <fmt/format.h>
19 muonRPCEvents_(nullptr),
20 NumberOfRecHitMuon_(nullptr),
21 NumberOfMuon_(nullptr),
23 numberOfInnerRings_(0) {
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()) {
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++) {
139 std::vector<TrackingRecHitRef> rpcTrackRecHits;
142 if (!(*it)->isValid())
144 int muSubDetId = (*it)->geographicalId().subdetId();
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++) {
191 int detId = (int)rpcRecHit.
rpcId();
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) {
276 }
else if (station == 2) {
277 if (detId.
layer() == 1) {
279 if (
abs(wheelOrDiskNumber) == 2 && roll == 3) {
285 if (
abs(wheelOrDiskNumber) != 2 && roll == 3) {
290 }
else if (station == 3) {
303 wheelOrDiskType =
"Disk";
304 wheelOrDiskNumber = region * (int)detId.
station();
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();
326 numDigi += clusterSize;
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);
385 tmpName =
fmt::format(
"1DOccupancy_Ring_{}", ring);
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);
418 tmpName =
fmt::format(
"ClusterSize_Layer{}", layer);
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);
445 xbin = wheelOrDiskNumber + numberOfDisks_ + 1;
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]);
int firstClusterStrip() const
T getUntrackedParameter(std::string const &, T const &) const
std::map< std::string, std::map< std::string, MonitorElement * > > meMuonCollection
std::string globalFolder_
double pt() const final
transverse momentum
virtual void setCurrentFolder(std::string const &fullpath)
std::map< std::string, MonitorElement * > wheelDiskNoiseCollection
std::map< std::string, MonitorElement * > sectorRingMuonCollection
MonitorElement * muonRPCEvents_
void bookSectorRingME(DQMStore::IBooker &, const std::string &, std::map< std::string, MonitorElement * > &)
Booking of MonitoringElement at Sector/Ring level.
RPCMonitorDigi(const edm::ParameterSet &)
Log< level::Error, false > LogError
void analyze(const edm::Event &, const edm::EventSetup &) override
static std::string rollName(const RPCDetId &detId)
constexpr std::array< uint8_t, layerIndexSize > layer
bool getData(T &iHolder) const
RPCDetId rpcId() const
Return the rpcId.
void bookRollME(DQMStore::IBooker &, const RPCDetId &, const RPCGeometry *rpcGeo, const std::string &, std::map< std::string, MonitorElement * > &)
Booking of MonitoringElement for one RPCDetId (= roll)
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
Abs< T >::type abs(const T &t)
static const std::array< std::string, 3 > regionNames_
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeomToken_
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
MonitorElement * NumberOfRecHitMuon_
static std::string name(const RPCDetId &detId, const bool useRoll)
virtual TrackingRecHit * clone() const =0
std::map< std::string, MonitorElement * > regionMuonCollection
Log< level::Info, false > LogInfo
int detId2RollNr(const RPCDetId &_id)
std::map< std::string, MonitorElement * > sectorRingNoiseCollection
T getParameter(std::string const &) const
static std::string chamberName(const RPCDetId &detId)
edm::EDGetTokenT< RPCRecHitCollection > rpcRecHitLabel_
edm::EDGetTokenT< DcsStatusCollection > scalersRawToDigiLabel_
std::map< std::string, std::map< std::string, MonitorElement * > > meNoiseCollection
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
void performSourceOperation(std::map< RPCDetId, std::vector< RPCRecHit > > &, std::string)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
static std::atomic< unsigned int > counter
std::map< std::string, MonitorElement * > wheelDiskMuonCollection
void bookWheelDiskME(DQMStore::IBooker &, const std::string &, std::map< std::string, MonitorElement * > &)
Booking of MonitoringElemnt at Wheel/Disk level.
std::map< std::string, MonitorElement * > regionNoiseCollection
MonitorElement * noiseRPCEvents_
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
void bookRegionME(DQMStore::IBooker &, const std::string &, std::map< std::string, MonitorElement * > &)
Booking of MonitoringElemnt at region (Barrel/Endcap) level.
MonitorElement * NumberOfMuon_
bool isGlobalMuon() const override
std::string subsystemFolder_
edm::EDGetTokenT< reco::CandidateView > muonLabel_
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
double eta() const final
momentum pseudorapidity