-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 bug in EgammaHLTRechitInRegionsProducer #6901
Fix bug in EgammaHLTRechitInRegionsProducer #6901
Conversation
A new Pull Request was created by @Martin-Grunewald (Martin Grunewald) for CMSSW_7_2_X. Fix bug in EgammaHLTRechitInRegionsProducer It involves the following packages: RecoEgamma/EgammaHLTProducers @Martin-Grunewald, @perrotta, @cmsbuild, @nclopezo, @fwyzard can you please review it and eventually sign? Thanks. |
I was about to propose a fix... here is a C++11'ified version, which should also reduce the number of for (unsigned int i=0; i<hitLabels.size(); i++) {
std::auto_ptr<EcalRecHitCollection> hits(new EcalRecHitCollection);
evt.getByToken(hitTokens[i], handle);
if (not handle.isValid()) {
edm::LogError("ProductNotFound")<< "could not get a handle on the EcalRecHitCollection! (" << hitLabels[i].encode() << ")" << std::endl;
return;
}
EcalRecHitCollection const & recHits = handle.product();
if (not recHits.empty()) {
if (recHits[0].id().subdetId() == EcalBarrel) {
geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
topology.reset(new EcalBarrelTopology(geoHandle));
} else if (recHits[0].id().subdetId() == EcalEndcap) {
geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
topology.reset(new EcalEndcapTopology(geoHandle));
} else if (recHits[0].id().subdetId() == EcalPreshower) {
geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
topology.reset(new EcalPreshowerTopology (geoHandle));
} else
throw(std::runtime_error("\n\nProducer encountered invalied ecalhitcollection type.\n\n"));
if (not regions.empty()) {
for (auto const & rechit : recHits) {
const CaloCellGeometry *this_cell = (*geometry_p).getGeometry(rechit.id());
GlobalPoint const & position = this_cell->getPosition();
bool inRegion = false;
for (auto const & region : regions)
if (region.inRegion(position)) {
inRegion = true;
break;
}
if (inRegion) {
hits->push_back(rechit);
break;
}
}
}
}
evt.put(hits, productLabels[i]);
} |
@matteosan1 , can you cross-check these proposals ? |
Thanks, for the fix. It seems me ok. |
+1 |
This pull request is fully signed and it will be integrated in one of the next CMSSW_7_2_X IBs unless changes (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @davidlange6, @nclopezo, @ktf, @smuzaffar |
+1 |
…nsProducer Fix bug in EgammaHLTRechitInRegionsProducer
Fix bug in EgammaHLTRechitInRegionsProducer discussed here
https://hypernews.cern.ch/HyperNews/CMS/get/dataopsrequests/6115/1/1/1/1/1/1/1/1/1/1.html