Skip to content

Commit

Permalink
Update validation for RPC hit reconstruction
Browse files Browse the repository at this point in the history
see #45626 for more details
  • Loading branch information
slowmoyang committed Aug 16, 2024
1 parent 96d37fb commit f489d68
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 234 deletions.
9 changes: 2 additions & 7 deletions Validation/RPCRecHits/interface/RPCRecHitValid.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,12 @@ class RPCRecHitValid : public DQMEDAnalyzer {
MEP h_recoMuonBarrel_phi, h_recoMuonOverlap_phi, h_recoMuonEndcap_phi, h_recoMuonNoRPC_phi;
MEP h_simParticleType, h_simParticleTypeBarrel, h_simParticleTypeEndcap;

MEP h_refPunchOccupancyBarrel_wheel, h_refPunchOccupancyEndcap_disk, h_refPunchOccupancyBarrel_station;
MEP h_refPunchOccupancyBarrel_wheel_station, h_refPunchOccupancyEndcap_disk_ring;
MEP h_recPunchOccupancyBarrel_wheel, h_recPunchOccupancyEndcap_disk, h_recPunchOccupancyBarrel_station;
MEP h_recPunchOccupancyBarrel_wheel_station, h_recPunchOccupancyEndcap_disk_ring;

MEP h_matchOccupancyBarrel_detId;
MEP h_matchOccupancyEndcap_detId;
MEP h_refOccupancyBarrel_detId;
MEP h_refOccupancyEndcap_detId;
MEP h_noiseOccupancyBarrel_detId;
MEP h_noiseOccupancyEndcap_detId;
MEP h_allOccupancyBarrel_detId;
MEP h_allOccupancyEndcap_detId;
MEP h_rollAreaBarrel_detId;
MEP h_rollAreaEndcap_detId;

Expand Down
216 changes: 11 additions & 205 deletions Validation/RPCRecHits/src/RPCRecHitValid.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "Validation/RPCRecHits/interface/RPCRecHitValid.h"

#include "FWCore/Framework/interface/ESHandle.h"
Expand Down Expand Up @@ -166,85 +165,6 @@ void RPCRecHitValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &r
}
h_eventCount->Fill(3);

h_refPunchOccupancyBarrel_wheel =
booker.book1D("RefPunchOccupancyBarrel_wheel", "RefPunchthrough occupancy", 5, -2.5, 2.5);
h_refPunchOccupancyEndcap_disk =
booker.book1D("RefPunchOccupancyEndcap_disk", "RefPunchthrough occupancy", 9, -4.5, 4.5);
h_refPunchOccupancyBarrel_station =
booker.book1D("RefPunchOccupancyBarrel_station", "RefPunchthrough occupancy", 4, 0.5, 4.5);
h_recPunchOccupancyBarrel_wheel =
booker.book1D("RecPunchOccupancyBarrel_wheel", "Punchthrough recHit occupancy", 5, -2.5, 2.5);
h_recPunchOccupancyEndcap_disk =
booker.book1D("RecPunchOccupancyEndcap_disk", "Punchthrough recHit occupancy", 9, -4.5, 4.5);
h_recPunchOccupancyBarrel_station =
booker.book1D("RecPunchOccupancyBarrel_station", "Punchthrough recHit occupancy", 4, 0.5, 4.5);

h_refPunchOccupancyBarrel_wheel->getTH1()->SetMinimum(0);
h_refPunchOccupancyEndcap_disk->getTH1()->SetMinimum(0);
h_refPunchOccupancyBarrel_station->getTH1()->SetMinimum(0);
h_recPunchOccupancyBarrel_wheel->getTH1()->SetMinimum(0);
h_recPunchOccupancyEndcap_disk->getTH1()->SetMinimum(0);
h_recPunchOccupancyBarrel_station->getTH1()->SetMinimum(0);

h_refPunchOccupancyBarrel_wheel_station =
booker.book2D("RefPunchOccupancyBarrel_wheel_station", "RefPunchthrough occupancy", 5, -2.5, 2.5, 4, 0.5, 4.5);
h_refPunchOccupancyEndcap_disk_ring =
booker.book2D("RefPunchOccupancyEndcap_disk_ring", "RefPunchthrough occupancy", 9, -4.5, 4.5, 4, 0.5, 4.5);
h_recPunchOccupancyBarrel_wheel_station = booker.book2D(
"RecPunchOccupancyBarrel_wheel_station", "Punchthrough recHit occupancy", 5, -2.5, 2.5, 4, 0.5, 4.5);
h_recPunchOccupancyEndcap_disk_ring =
booker.book2D("RecPunchOccupancyEndcap_disk_ring", "Punchthrough recHit occupancy", 9, -4.5, 4.5, 4, 0.5, 4.5);

h_refPunchOccupancyBarrel_wheel_station->getTH2F()->SetOption("COLZ");
h_refPunchOccupancyEndcap_disk_ring->getTH2F()->SetOption("COLZ");
h_recPunchOccupancyBarrel_wheel_station->getTH2F()->SetOption("COLZ");
h_recPunchOccupancyEndcap_disk_ring->getTH2F()->SetOption("COLZ");

h_refPunchOccupancyBarrel_wheel_station->getTH2F()->SetContour(10);
h_refPunchOccupancyEndcap_disk_ring->getTH2F()->SetContour(10);
h_recPunchOccupancyBarrel_wheel_station->getTH2F()->SetContour(10);
h_recPunchOccupancyEndcap_disk_ring->getTH2F()->SetContour(10);

h_refPunchOccupancyBarrel_wheel_station->getTH2F()->SetStats(false);
h_refPunchOccupancyEndcap_disk_ring->getTH2F()->SetStats(false);
h_recPunchOccupancyBarrel_wheel_station->getTH2F()->SetStats(false);
h_recPunchOccupancyEndcap_disk_ring->getTH2F()->SetStats(false);

h_refPunchOccupancyBarrel_wheel_station->getTH2F()->SetMinimum(0);
h_refPunchOccupancyEndcap_disk_ring->getTH2F()->SetMinimum(0);
h_recPunchOccupancyBarrel_wheel_station->getTH2F()->SetMinimum(0);
h_recPunchOccupancyEndcap_disk_ring->getTH2F()->SetMinimum(0);

for (int i = 1; i <= 5; ++i) {
TString binLabel = Form("Wheel %d", i - 3);
h_refPunchOccupancyBarrel_wheel->getTH1()->GetXaxis()->SetBinLabel(i, binLabel);
h_refPunchOccupancyBarrel_wheel_station->getTH2F()->GetXaxis()->SetBinLabel(i, binLabel);
h_recPunchOccupancyBarrel_wheel->getTH1()->GetXaxis()->SetBinLabel(i, binLabel);
h_recPunchOccupancyBarrel_wheel_station->getTH2F()->GetXaxis()->SetBinLabel(i, binLabel);
}

for (int i = 1; i <= 9; ++i) {
TString binLabel = Form("Disk %d", i - 5);
h_refPunchOccupancyEndcap_disk->getTH1()->GetXaxis()->SetBinLabel(i, binLabel);
h_refPunchOccupancyEndcap_disk_ring->getTH2F()->GetXaxis()->SetBinLabel(i, binLabel);
h_recPunchOccupancyEndcap_disk->getTH1()->GetXaxis()->SetBinLabel(i, binLabel);
h_recPunchOccupancyEndcap_disk_ring->getTH2F()->GetXaxis()->SetBinLabel(i, binLabel);
}

for (int i = 1; i <= 4; ++i) {
TString binLabel = Form("Station %d", i);
h_refPunchOccupancyBarrel_station->getTH1()->GetXaxis()->SetBinLabel(i, binLabel);
h_refPunchOccupancyBarrel_wheel_station->getTH2F()->GetYaxis()->SetBinLabel(i, binLabel);
h_recPunchOccupancyBarrel_station->getTH1()->GetXaxis()->SetBinLabel(i, binLabel);
h_recPunchOccupancyBarrel_wheel_station->getTH2F()->GetYaxis()->SetBinLabel(i, binLabel);
}

for (int i = 1; i <= 4; ++i) {
TString binLabel = Form("Ring %d", i);
h_refPunchOccupancyEndcap_disk_ring->getTH2F()->GetYaxis()->SetBinLabel(i, binLabel);
h_recPunchOccupancyEndcap_disk_ring->getTH2F()->GetYaxis()->SetBinLabel(i, binLabel);
}

// Book roll-by-roll histograms
auto rpcGeom = eventSetup.getHandle(rpcGeomTokenInRun_);

Expand Down Expand Up @@ -299,17 +219,17 @@ void RPCRecHitValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &r
nRPCRollEndcap,
0,
nRPCRollEndcap);
h_noiseOccupancyBarrel_detId = booker.book1D(
"NoiseOccupancyBarrel_detId", "Noise occupancy;roll index (can be arbitrary)", nRPCRollBarrel, 0, nRPCRollBarrel);
h_noiseOccupancyEndcap_detId = booker.book1D(
"NoiseOccupancyEndcap_detId", "Noise occupancy;roll index (can be arbitrary)", nRPCRollEndcap, 0, nRPCRollEndcap);
h_allOccupancyBarrel_detId = booker.book1D(
"OccupancyBarrel_detId", "Occupancy;roll index (can be arbitrary)", nRPCRollBarrel, 0, nRPCRollBarrel);
h_allOccupancyEndcap_detId = booker.book1D(
"OccupancyEndcap_detId", "Occupancy;roll index (can be arbitrary)", nRPCRollEndcap, 0, nRPCRollEndcap);

h_matchOccupancyBarrel_detId->getTH1()->SetMinimum(0);
h_matchOccupancyEndcap_detId->getTH1()->SetMinimum(0);
h_refOccupancyBarrel_detId->getTH1()->SetMinimum(0);
h_refOccupancyEndcap_detId->getTH1()->SetMinimum(0);
h_noiseOccupancyBarrel_detId->getTH1()->SetMinimum(0);
h_noiseOccupancyEndcap_detId->getTH1()->SetMinimum(0);
h_allOccupancyBarrel_detId->getTH1()->SetMinimum(0);
h_allOccupancyEndcap_detId->getTH1()->SetMinimum(0);

h_rollAreaBarrel_detId = booker.bookProfile(
"RollAreaBarrel_detId", "Roll area;roll index;Area", nRPCRollBarrel, 0., 1. * nRPCRollBarrel, 0., 1e5);
Expand Down Expand Up @@ -461,8 +381,6 @@ void RPCRecHitValid::analyze(const edm::Event &event, const edm::EventSetup &eve
h_simMuonNoRPC_eta->Fill(simParticle->eta());
h_simMuonNoRPC_phi->Fill(simParticle->phi());
}
} else {
pthrSimHits.insert(pthrSimHits.end(), simHitsFromParticle.begin(), simHitsFromParticle.end());
}

if (hasRPCHit) {
Expand Down Expand Up @@ -533,34 +451,6 @@ void RPCRecHitValid::analyze(const edm::Event &event, const edm::EventSetup &eve
}
}

// Loop over punch-through simHits, fill histograms which does not need
// associations
for (const auto &simHit : pthrSimHits) {
const RPCDetId detId = static_cast<const RPCDetId>(simHit->detUnitId());
const RPCRoll *roll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(detId()));

const int region = roll->id().region();
const int ring = roll->id().ring();
// const int sector = roll->id().sector();
const int station = roll->id().station();
// const int layer = roll->id().layer();
// const int subSector = roll->id().subsector();

if (region == 0) {
++nRefHitBarrel;
h_refPunchOccupancyBarrel_wheel->Fill(ring);
h_refPunchOccupancyBarrel_station->Fill(station);
h_refPunchOccupancyBarrel_wheel_station->Fill(ring, station);

h_refOccupancyBarrel_detId->Fill(detIdToIndexMapBarrel_[simHit->detUnitId()]);
} else {
++nRefHitEndcap;
h_refPunchOccupancyEndcap_disk->Fill(region * station);
h_refPunchOccupancyEndcap_disk_ring->Fill(region * station, ring);

h_refOccupancyEndcap_detId->Fill(detIdToIndexMapEndcap_[simHit->detUnitId()]);
}
}
h_.nRefHitBarrel->Fill(nRefHitBarrel);
h_.nRefHitEndcap->Fill(nRefHitEndcap);

Expand Down Expand Up @@ -592,6 +482,8 @@ void RPCRecHitValid::analyze(const edm::Event &event, const edm::EventSetup &eve
h_.recHitOccupancyBarrel_station->Fill(station);
h_.recHitOccupancyBarrel_wheel_station->Fill(ring, station);

h_allOccupancyBarrel_detId->Fill(detIdToIndexMapBarrel_[detId.rawId()]);

h_.timeBarrel->Fill(time);
} else {
++nRecHitEndcap;
Expand All @@ -600,6 +492,8 @@ void RPCRecHitValid::analyze(const edm::Event &event, const edm::EventSetup &eve
h_.recHitOccupancyEndcap_disk->Fill(region * station);
h_.recHitOccupancyEndcap_disk_ring->Fill(region * station, ring);

h_allOccupancyEndcap_detId->Fill(detIdToIndexMapEndcap_[detId.rawId()]);

h_.timeEndcap->Fill(time);
}

Expand Down Expand Up @@ -766,96 +660,8 @@ void RPCRecHitValid::analyze(const edm::Event &event, const edm::EventSetup &eve
}
}

// Find Non-muon hits
for (RecHitIter recHitIter = recHitHandle->begin(); recHitIter != recHitHandle->end(); ++recHitIter) {
const RPCDetId detId = static_cast<const RPCDetId>(recHitIter->rpcId());
const RPCRoll *roll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(detId));

const int region = roll->id().region();
const int ring = roll->id().ring();
// const int sector = roll->id().sector();
const int station = roll->id().station();
// const int layer = roll->id().layer();
// const int subsector = roll->id().subsector();

bool matched = false;
for (const auto &match : simToRecHitMap) {
if (recHitIter == match.second) {
matched = true;
break;
}
}

if (!matched) {
int nPunchMatched = 0;
// Check if this recHit came from non-muon simHit
for (const auto &simHit : pthrSimHits) {
const int absSimHitPType = abs(simHit->particleType());
if (absSimHitPType == 13)
continue;

const RPCDetId simDetId = static_cast<const RPCDetId>(simHit->detUnitId());
if (simDetId == detId)
++nPunchMatched;
}

if (nPunchMatched > 0) {
if (region == 0) {
h_recPunchOccupancyBarrel_wheel->Fill(ring);
h_recPunchOccupancyBarrel_station->Fill(station);
h_recPunchOccupancyBarrel_wheel_station->Fill(ring, station);
} else {
h_recPunchOccupancyEndcap_disk->Fill(region * station);
h_recPunchOccupancyEndcap_disk_ring->Fill(region * station, ring);
}
}
}
}

// Find noise recHits : RecHits without SimHit match
for (RecHitIter recHitIter = recHitHandle->begin(); recHitIter != recHitHandle->end(); ++recHitIter) {
const RPCDetId recDetId = static_cast<const RPCDetId>(recHitIter->rpcId());
const RPCRoll *roll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(recDetId));

const int region = roll->id().region();
// const int ring = roll->id().ring(); // UNUSED VARIABLE
// const int sector = roll->id().sector();
// const int station = roll->id().station(); // UNUSED VARIABLE
// const int layer = roll->id().layer();
// const int subsector = roll->id().subsector();

const double recX = recHitIter->localPosition().x();
const double recErrX = sqrt(recHitIter->localPositionError().xx());

bool matched = false;
for (SimHitIter simHitIter = simHitHandle->begin(); simHitIter != simHitHandle->end(); ++simHitIter) {
const RPCDetId simDetId = static_cast<const RPCDetId>(simHitIter->detUnitId());
const RPCRoll *simRoll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(simDetId));
if (!simRoll)
continue;

if (simDetId != recDetId)
continue;

const double simX = simHitIter->localPosition().x();
const double dX = fabs(recX - simX);

if (dX / recErrX < 5) {
matched = true;
break;
}
}

if (!matched) {
if (region == 0) {
h_noiseOccupancyBarrel_detId->Fill(detIdToIndexMapBarrel_[recDetId.rawId()]);
} else {
h_noiseOccupancyEndcap_detId->Fill(detIdToIndexMapEndcap_[recDetId.rawId()]);
}
}
}

h_eventCount->Fill(2);
}

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(RPCRecHitValid);
28 changes: 6 additions & 22 deletions Validation/RPCRecHits/src/RPCRecHitValidClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@ void RPCRecHitValidClient::dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGette
booker.book1D("RollEfficiencyBarrel_eff", "Roll efficiency in Barrel;Efficiency [%]", 50 + 2, -2, 100 + 2);
MEP me_rollEfficiencyEndcap_eff =
booker.book1D("RollEfficiencyEndcap_eff", "Roll efficiency in Endcap;Efficiency [%]", 50 + 2, -2, 100 + 2);
MEP me_rollEfficiencyStatCutOffBarrel_eff =
booker.book1D("RollEfficiencyCutOffBarrel_eff",
"Roll efficiency in Barrel without low stat chamber;Efficiency [%]",
50 + 2,
-2,
100 + 2);
MEP me_rollEfficiencyStatCutOffEndcap_eff =
booker.book1D("RollEfficiencyCutOffEndcap_eff",
"Roll efficiency in Endcap without low stat chamber;Efficiency [%]",
50 + 2,
-2,
100 + 2);

const double maxNoise = 1e-7;
MEP me_rollNoiseBarrel_noise = booker.book1D("RollNoiseBarrel_noise",
Expand Down Expand Up @@ -60,8 +48,6 @@ void RPCRecHitValidClient::dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGette
const double eff = nRef ? nRec / nRef * 100 : -1;

me_rollEfficiencyBarrel_eff->Fill(eff);
if (nRef >= 20)
me_rollEfficiencyStatCutOffBarrel_eff->Fill(eff);
}
}

Expand All @@ -76,17 +62,15 @@ void RPCRecHitValidClient::dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGette
const double eff = nRef ? nRec / nRef * 100 : -1;

me_rollEfficiencyEndcap_eff->Fill(eff);
if (nRef >= 20)
me_rollEfficiencyStatCutOffEndcap_eff->Fill(eff);
}
}

MEP me_eventCount = getter.get(subDir_ + "/Occupancy/EventCount");
const double nEvent = me_eventCount ? me_eventCount->getTH1()->GetBinContent(1) : 1;
MEP me_noiseOccupancyBarrel_detId = getter.get(subDir_ + "/Occupancy/NoiseOccupancyBarrel_detId");
MEP me_allOccupancyBarrel_detId = getter.get(subDir_ + "/Occupancy/OccupancyBarrel_detId");
MEP me_rollAreaBarrel_detId = getter.get(subDir_ + "/Occupancy/RollAreaBarrel_detId");
if (me_noiseOccupancyBarrel_detId and me_rollAreaBarrel_detId) {
TH1 *h_noiseOccupancyBarrel_detId = me_noiseOccupancyBarrel_detId->getTH1();
if (me_allOccupancyBarrel_detId and me_rollAreaBarrel_detId) {
TH1 *h_noiseOccupancyBarrel_detId = me_allOccupancyBarrel_detId->getTH1();
TH1 *h_rollAreaBarrel_detId = me_rollAreaBarrel_detId->getTH1();

for (int bin = 1, nBin = h_noiseOccupancyBarrel_detId->GetNbinsX(); bin <= nBin; ++bin) {
Expand All @@ -100,10 +84,10 @@ void RPCRecHitValidClient::dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGette
}
}

MEP me_noiseOccupancyEndcap_detId = getter.get(subDir_ + "/Occupancy/NoiseOccupancyEndcap_detId");
MEP me_allOccupancyEndcap_detId = getter.get(subDir_ + "/Occupancy/OccupancyEndcap_detId");
MEP me_rollAreaEndcap_detId = getter.get(subDir_ + "/Occupancy/RollAreaEndcap_detId");
if (me_noiseOccupancyEndcap_detId and me_rollAreaEndcap_detId) {
TH1 *h_noiseOccupancyEndcap_detId = me_noiseOccupancyEndcap_detId->getTH1();
if (me_allOccupancyEndcap_detId and me_rollAreaEndcap_detId) {
TH1 *h_noiseOccupancyEndcap_detId = me_allOccupancyEndcap_detId->getTH1();
TH1 *h_rollAreaEndcap_detId = me_rollAreaEndcap_detId->getTH1();

for (int bin = 1, nBin = h_noiseOccupancyEndcap_detId->GetNbinsX(); bin <= nBin; ++bin) {
Expand Down

0 comments on commit f489d68

Please sign in to comment.