Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashing bug in reco when run with XML geometry #29741

Merged
merged 4 commits into from
May 6, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Automatic code formatting
  • Loading branch information
cvuosalo committed May 4, 2020
commit 556c45c14da31a14189467f1b1ded32163187be9
30 changes: 16 additions & 14 deletions Validation/MuonGEMDigis/plugins/GEMCoPadDigiValidation.cc
Original file line number Diff line number Diff line change
@@ -26,22 +26,23 @@ void GEMCoPadDigiValidation::bookHistograms(DQMStore::IBooker& booker,

for (const auto& station : region->stations()) {
Int_t station_id = station->station();
const auto &superChamberVec = station->superChambers();
const auto& superChamberVec = station->superChambers();
if (superChamberVec.empty() || superChamberVec[0] == nullptr) {
edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
const auto &chamberVec = superChamberVec[0]->chambers();
const auto& chamberVec = superChamberVec[0]->chambers();
if (chamberVec.empty() || chamberVec[0] == nullptr) {
edm::LogError(kLogCategory_) << "Chambers missing or null for region, station, super chamber = (" <<
region_id << ", " << station_id << ", " << superChamberVec[0]->id() << ")";
edm::LogError(kLogCategory_) << "Chambers missing or null for region, station, super chamber = (" << region_id
<< ", " << station_id << ", " << superChamberVec[0]->id() << ")";
continue;
}
const auto &etaPartitionVec = chamberVec[0]->etaPartitions();
const auto& etaPartitionVec = chamberVec[0]->etaPartitions();
if (etaPartitionVec.empty() || etaPartitionVec[0] == nullptr) {
edm::LogError(kLogCategory_) << "Eta partition missing or null for region, station, super chamber, chamber = (" <<
region_id << ", " << station_id << ", " << superChamberVec[0]->id() << ", " << chamberVec[0]->id() << ")";
edm::LogError(kLogCategory_) << "Eta partition missing or null for region, station, super chamber, chamber = ("
<< region_id << ", " << station_id << ", " << superChamberVec[0]->id() << ", "
<< chamberVec[0]->id() << ")";
continue;
}
Int_t num_pads = etaPartitionVec[0]->npads();
@@ -149,19 +150,20 @@ void GEMCoPadDigiValidation::analyze(const edm::Event& event, const edm::EventSe
LocalPoint lpArray[2];
int ptCounter = 0;
for (; ptCounter < 2; ++ptCounter) {
const GEMChamber *const chamber = super_chamber->chamber(ptCounter + 1); // Fetch chambers 1 and 2
const GEMChamber* const chamber = super_chamber->chamber(ptCounter + 1); // Fetch chambers 1 and 2
if (chamber == nullptr) {
edm::LogError(kLogCategory_) << "Chamber " << (ptCounter + 1) << " is null for super chamber = " << super_chamber_id;
edm::LogError(kLogCategory_) << "Chamber " << (ptCounter + 1)
<< " is null for super chamber = " << super_chamber_id;
break;
}
const GEMEtaPartition *const etaPartition = chamber->etaPartition(roll_id);
const GEMEtaPartition* const etaPartition = chamber->etaPartition(roll_id);
if (etaPartition == nullptr) {
edm::LogError(kLogCategory_) << "Eta partition " << roll_id << " is null for chamber, super chamber = (" <<
(ptCounter + 1) << ", " << super_chamber_id << ")";
edm::LogError(kLogCategory_) << "Eta partition " << roll_id << " is null for chamber, super chamber = ("
<< (ptCounter + 1) << ", " << super_chamber_id << ")";
break;
}
lpArray[ptCounter] = etaPartition->centreOfPad(padArray[ptCounter]);
} // end for
} // end for
if (ptCounter < 2) { // Broke out of "for" loop
edm::LogError(kLogCategory_) << "Skipping a digi after " << (ptCounter + 1) << " tries.";
continue;
21 changes: 11 additions & 10 deletions Validation/MuonGEMDigis/plugins/GEMPadDigiClusterValidation.cc
Original file line number Diff line number Diff line change
@@ -26,26 +26,27 @@ void GEMPadDigiClusterValidation::bookHistograms(DQMStore::IBooker& booker,

me_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "pad", "Pad Cluster");

const auto &superChamberVec = station->superChambers();
const auto& superChamberVec = station->superChambers();
if (superChamberVec.empty()) {
edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
const GEMSuperChamber* super_chamber = superChamberVec.front();
if (super_chamber == nullptr) {
edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
for (const auto& chamber : super_chamber->chambers()) {
Int_t layer_id = chamber->id().layer();
ME3IdsKey key3{region_id, station_id, layer_id};

const auto &etaPartitionVec = chamber->etaPartitions();
const auto& etaPartitionVec = chamber->etaPartitions();
if (etaPartitionVec.empty() || etaPartitionVec.front() == nullptr) {
edm::LogError(kLogCategory_) << "Eta partition missing or null for region, station, super chamber, chamber = (" <<
region_id << ", " << station_id << ", " << super_chamber->id() << ", " << chamber->id() << ")";
edm::LogError(kLogCategory_)
<< "Eta partition missing or null for region, station, super chamber, chamber = (" << region_id << ", "
<< station_id << ", " << super_chamber->id() << ", " << chamber->id() << ")";
continue;
}
Int_t num_pads = etaPartitionVec.front()->npads();
@@ -82,16 +83,16 @@ void GEMPadDigiClusterValidation::bookHistograms(DQMStore::IBooker& booker,
for (const auto& station : region->stations()) {
Int_t station_id = station->station();

const auto &superChamberVec = station->superChambers();
const auto& superChamberVec = station->superChambers();
if (superChamberVec.empty()) {
edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
const GEMSuperChamber* super_chamber = superChamberVec.front();
if (super_chamber == nullptr) {
edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
for (const auto& chamber : super_chamber->chambers()) {
@@ -140,7 +141,7 @@ void GEMPadDigiClusterValidation::analyze(const edm::Event& event, const edm::Ev
ME3IdsKey key3(region_id, station_id, layer_id);

for (auto digi = range.first; digi != range.second; ++digi) {
const auto &padsVec = digi->pads();
const auto& padsVec = digi->pads();
if (padsVec.empty()) {
edm::LogError(kLogCategory_) << "Pads missing for digi from GEM ID = " << gemid;
continue;
19 changes: 10 additions & 9 deletions Validation/MuonGEMDigis/plugins/GEMPadDigiValidation.cc
Original file line number Diff line number Diff line change
@@ -26,26 +26,27 @@ void GEMPadDigiValidation::bookHistograms(DQMStore::IBooker& booker,

me_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "pad", "Pad");

const auto &superChamberVec = station->superChambers();
const auto& superChamberVec = station->superChambers();
if (superChamberVec.empty()) {
edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
const GEMSuperChamber* super_chamber = superChamberVec.front();
if (super_chamber == nullptr) {
edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
for (const auto& chamber : super_chamber->chambers()) {
Int_t layer_id = chamber->id().layer();
ME3IdsKey key3(region_id, station_id, layer_id);

const auto &etaPartitionVec = chamber->etaPartitions();
const auto& etaPartitionVec = chamber->etaPartitions();
if (etaPartitionVec.empty() || etaPartitionVec.front() == nullptr) {
edm::LogError(kLogCategory_) << "Eta partition missing or null for region, station, super chamber, chamber = (" <<
region_id << ", " << station_id << ", " << super_chamber->id() << ", " << chamber->id() << ")";
edm::LogError(kLogCategory_)
<< "Eta partition missing or null for region, station, super chamber, chamber = (" << region_id << ", "
<< station_id << ", " << super_chamber->id() << ", " << chamber->id() << ")";
continue;
}
Int_t num_pads = etaPartitionVec.front()->npads();
@@ -82,16 +83,16 @@ void GEMPadDigiValidation::bookHistograms(DQMStore::IBooker& booker,
for (const auto& station : region->stations()) {
Int_t station_id = station->station();

const auto &superChamberVec = station->superChambers();
const auto& superChamberVec = station->superChambers();
if (superChamberVec.empty()) {
edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
const GEMSuperChamber* super_chamber = superChamberVec.front();
if (super_chamber == nullptr) {
edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
for (const auto& chamber : super_chamber->chambers()) {
29 changes: 15 additions & 14 deletions Validation/MuonGEMDigis/plugins/GEMStripDigiValidation.cc
Original file line number Diff line number Diff line change
@@ -40,16 +40,16 @@ void GEMStripDigiValidation::bookHistograms(DQMStore::IBooker& booker,
}
Int_t station_id = station->station();

const auto &superChamberVec = station->superChambers();
const auto& superChamberVec = station->superChambers();
if (superChamberVec.empty()) {
edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
const GEMSuperChamber* super_chamber = superChamberVec.front();
if (super_chamber == nullptr) {
edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
continue;
}
for (const auto& chamber : super_chamber->chambers()) {
@@ -105,25 +105,26 @@ void GEMStripDigiValidation::bookHistograms(DQMStore::IBooker& booker,

me_strip_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "matched_strip", "Matched Strip Digi");

const auto &superChamberVec = station->superChambers();
const auto& superChamberVec = station->superChambers();
if (superChamberVec.empty() || superChamberVec[0] == nullptr) {
edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
} else {
for (const auto& chamber : superChamberVec[0]->chambers()) {
if (chamber == nullptr) {
edm::LogError(kLogCategory_) << "Null chamber for region, station, super chamber = (" <<
region_id << ", " << station_id << ", " << superChamberVec[0]->id() << ")";
edm::LogError(kLogCategory_) << "Null chamber for region, station, super chamber = (" << region_id << ", "
<< station_id << ", " << superChamberVec[0]->id() << ")";
continue;
}
Int_t layer_id = chamber->id().layer();
ME3IdsKey key3{region_id, station_id, layer_id};

if (detail_plot_) {
const auto &etaPartitionsVec = chamber->etaPartitions();
const auto& etaPartitionsVec = chamber->etaPartitions();
if (etaPartitionsVec.empty() || etaPartitionsVec.front() == nullptr) {
edm::LogError(kLogCategory_) << "Eta partition missing or null for region, station, super chamber, chamber = (" <<
region_id << ", " << station_id << ", " << superChamberVec[0]->id() << ", " << chamber->id() << ")";
edm::LogError(kLogCategory_)
<< "Eta partition missing or null for region, station, super chamber, chamber = (" << region_id
<< ", " << station_id << ", " << superChamberVec[0]->id() << ", " << chamber->id() << ")";
continue;
}
Int_t num_strips = etaPartitionsVec.front()->nstrips();
@@ -152,10 +153,10 @@ void GEMStripDigiValidation::bookHistograms(DQMStore::IBooker& booker,
"#phi [rad]",
"strip number");
} // detail plot
} // chamber
} // end else
} // station looop
} // region loop
} // chamber
} // end else
} // station looop
} // region loop
}

GEMStripDigiValidation::~GEMStripDigiValidation() {}
2 changes: 1 addition & 1 deletion Validation/MuonGEMHits/interface/GEMBaseValidation.h
Original file line number Diff line number Diff line change
@@ -182,7 +182,7 @@ dqm::impl::MonitorElement* GEMBaseValidation::bookDetectorOccupancy(DQMStore::IB
Int_t nbinsx = num_superchambers * num_chambers;

if (nbinsx <= 0)
nbinsx = 20; // Ensure histogram is not zero size
nbinsx = 20; // Ensure histogram is not zero size
if (nbinsy <= 0)
nbinsy = 20;
auto hist = new TH2F(name, title, nbinsx, 1 - 0.5, nbinsx + 0.5, nbinsy, 1 - 0.5, nbinsy + 0.5);
53 changes: 30 additions & 23 deletions Validation/MuonGEMHits/plugins/GEMSimHitValidation.cc
Original file line number Diff line number Diff line change
@@ -22,21 +22,21 @@ void GEMSimHitValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run con
TString tof_xtitle = "Time of flight [ns]";
TString tof_ytitle = "Entries";

const auto &regionsVec = gem->regions();
const auto& regionsVec = gem->regions();
if (regionsVec.empty() || regionsVec[0] == nullptr) {
edm::LogError(kLogCategory_) << "Regions missing or null.";
return;
} else {
for (const auto& station : regionsVec[0]->stations()) {
// for (const auto& station : gem->regions()[0]->stations())
// for (const auto& station : gem->regions()[0]->stations())
Int_t station_id = station->station();
const auto [tof_min, tof_max] = getTOFRange(station_id);
auto tof_name = TString::Format("tof_muon_st%d", station_id);
auto tof_title = TString::Format("SimHit Time Of Flight (Muon only) : Station %d", station_id);

me_tof_mu_[station_id] = booker.book1D(tof_name, tof_title, 40, tof_min, tof_max);
} // end for
} // end else
} // end for
} // end else

if (detail_plot_) {
for (const auto& region : gem->regions()) {
@@ -46,10 +46,10 @@ void GEMSimHitValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run con
Int_t station_id = station->station();

const auto [tof_min, tof_max] = getTOFRange(station_id);
const auto &superChamberVec = station->superChambers();
const auto& superChamberVec = station->superChambers();
if (superChamberVec.empty() || superChamberVec.front() == nullptr) {
edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
} else {
const GEMSuperChamber* super_chamber = superChamberVec.front();

@@ -63,10 +63,10 @@ void GEMSimHitValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run con
me_detail_tof_mu_[key3] = bookHist1D(
booker, key3, "tof_muon", "SimHit TOF (Muon only)", 40, tof_min, tof_max, tof_xtitle, tof_ytitle);
} // chamber loop
} // end else
} // station loop
} // region loop
} // detail plot
} // end else
} // station loop
} // region loop
} // detail plot

// NOTE Energy Loss
booker.setCurrentFolder("MuonGEMHitsV/GEMHitsTask/EnergyLoss");
@@ -89,10 +89,10 @@ void GEMSimHitValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run con
Int_t region_id = region->region();
for (const auto& station : region->stations()) {
Int_t station_id = station->station();
const auto &superChamberVec = station->superChambers();
const auto& superChamberVec = station->superChambers();
if (superChamberVec.empty() || superChamberVec.front() == nullptr) {
edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
} else {
for (const auto& chamber : superChamberVec.front()->chambers()) {
Int_t layer_id = chamber->id().layer();
@@ -101,14 +101,21 @@ void GEMSimHitValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run con
me_detail_eloss_[key3] =
bookHist1D(booker, key3, "eloss", "SimHit Energy Loss", 60, 0.0, 6000.0, eloss_xtitle, eloss_ytitle);

me_detail_eloss_mu_[key3] = bookHist1D(
booker, key3, "eloss_muon", "SimHit Energy Loss (Muon Only)", 60, 0.0, 6000.0, eloss_xtitle, eloss_ytitle);
me_detail_eloss_mu_[key3] = bookHist1D(booker,
key3,
"eloss_muon",
"SimHit Energy Loss (Muon Only)",
60,
0.0,
6000.0,
eloss_xtitle,
eloss_ytitle);

} // chamber loop
} // end else
} // station loop
} // region loop
} // detail plot
} // end else
} // station loop
} // region loop
} // detail plot

// NOTE Occupancy
booker.setCurrentFolder("MuonGEMHitsV/GEMHitsTask/Occupancy");
@@ -124,10 +131,10 @@ void GEMSimHitValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run con

me_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "simhit", "SimHit");

const auto &superChamberVec = station->superChambers();
const auto& superChamberVec = station->superChambers();
if (superChamberVec.empty() || superChamberVec.front() == nullptr) {
edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
<< " and station = " << station_id;
<< " and station = " << station_id;
} else {
const GEMSuperChamber* super_chamber = superChamberVec.front();
for (const auto& chamber : super_chamber->chambers()) {
@@ -136,9 +143,9 @@ void GEMSimHitValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run con

me_occ_xy_[key3] = bookXYOccupancy(booker, key3, "simhit", "SimHit");
} // layer loop
} // end else
} // station loop
} // region loop
} // end else
} // station loop
} // region loop
}

std::tuple<Double_t, Double_t> GEMSimHitValidation::getTOFRange(Int_t station_id) {
Loading