Skip to content

Commit

Permalink
simplifying code
Browse files Browse the repository at this point in the history
  • Loading branch information
Long committed Nov 20, 2022
1 parent 4afc3f4 commit 521e5a5
Showing 1 changed file with 23 additions and 37 deletions.
60 changes: 23 additions & 37 deletions DQM/HcalTasks/plugins/HcalGPUComparisonTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,41 +93,27 @@ HcalGPUComparisonTask::HcalGPUComparisonTask(edm::ParameterSet const& ps)
/* virtual */ void HcalGPUComparisonTask::_resetMonitors(hcaldqm::UpdateFreq uf) { DQTask::_resetMonitors(uf); }

/* virtual */ void HcalGPUComparisonTask::_process(edm::Event const& e, edm::EventSetup const&) {
edm::Handle<HBHERecHitCollection> chbhe_ref;
edm::Handle<HBHERecHitCollection> chbhe_target;

bool gotRefCollection = true, gotTargetCollection = true;

if (!(e.getByToken(tokHBHE_ref_, chbhe_ref))) {
edm::LogWarning("HcalGPUComparisonTask")
<< "The CPU HBHERecHitCollection " << tagHBHE_ref_.encode() << " is not available" << std::endl;
gotRefCollection = false;
}
if (!(e.getByToken(tokHBHE_target_, chbhe_target))) {
edm::LogWarning("HcalGPUComparisonTask")
<< "The GPU HBHERecHitCollection " << tagHBHE_target_.encode() << " is not available" << std::endl;
gotTargetCollection = false;
}

if (gotRefCollection && !gotTargetCollection) {
for (HBHERecHitCollection::const_iterator it = chbhe_ref->begin(); it != chbhe_ref->end(); ++it) {
double energy = it->energy();
HcalDetId did = it->id();
energyGPUvsCPU_subdet_.fill(did, energy, -0.5);
}
return;
}
if (!gotRefCollection && gotTargetCollection) {
for (HBHERecHitCollection::const_iterator it = chbhe_target->begin(); it != chbhe_target->end(); ++it) {
double energy = it->energy();
HcalDetId did = it->id();
energyGPUvsCPU_subdet_.fill(did, -0.5, energy);
auto const chbhe_ref = e.getHandle(tokHBHE_ref_);
auto const chbhe_target = e.getHandle(tokHBHE_target_);

if (not(chbhe_ref.isValid() and chbhe_target.isValid())) {
if (chbhe_target.isValid()) {
edm::LogWarning("HcalGPUComparisonTask")
<< "The CPU HBHERecHitCollection " << tagHBHE_ref_.encode() << " is not available";

for (auto const& rh : *chbhe_target)
energyGPUvsCPU_subdet_.fill(rh.id(), -0.5, rh.energy());
} else if (chbhe_ref.isValid()) {
edm::LogWarning("HcalGPUComparisonTask")
<< "The GPU HBHERecHitCollection " << tagHBHE_target_.encode() << " is not available";

for (auto const& rh : *chbhe_ref)
energyGPUvsCPU_subdet_.fill(rh.id(), rh.energy(), -0.5);
} else {
edm::LogWarning("HcalGPUComparisonTask")
<< "Neither CPU nor GPU RecHit Collection available, will not fill this event.";
}
return;
}
if (!gotRefCollection && !gotTargetCollection) {
edm::LogWarning("HcalGPUComparisonTask")
<< "Neither CPU nor GPU RecHit Collection available, will not fill this event." << std::endl;

return;
}

Expand All @@ -145,7 +131,7 @@ HcalGPUComparisonTask::HcalGPUComparisonTask(edm::ParameterSet const& ps)
if (mRecHitEnergy.find(did) == mRecHitEnergy.end())
mRecHitEnergy.insert(std::make_pair(did, energy));
else
edm::LogError("HcalGPUComparisonTask") << "Duplicate Rechit from the same HcalDetId" << std::endl;
edm::LogError("HcalGPUComparisonTask") << "Duplicate Rechit from the same HcalDetId";
;
}

Expand Down Expand Up @@ -174,14 +160,14 @@ HcalGPUComparisonTask::HcalGPUComparisonTask(edm::ParameterSet const& ps)
} else {
if (energy > 2.)
edm::LogError("HcalGPUComparisonTask")
<< "Energetic GPU Rechit exist, but not reconstructed by CPU. DetId = " << did << std::endl;
<< "Energetic GPU Rechit exist, but not reconstructed by CPU. DetId = " << did;
}
}
if (!mRecHitEnergy.empty()) {
for (auto const& rhpair : mRecHitEnergy) {
if (rhpair.second > 2.)
edm::LogError("HcalGPUComparisonTask")
<< "Energetic CPU Rechit exist, but not reconstructed by GPU. DetId = " << rhpair.first << std::endl;
<< "Energetic CPU Rechit exist, but not reconstructed by GPU. DetId = " << rhpair.first;
}
}
}
Expand Down

0 comments on commit 521e5a5

Please sign in to comment.