Skip to content

Commit

Permalink
Merge pull request #39991 from Dr15Jones/ubsanEcalTrigTowerConstituen…
Browse files Browse the repository at this point in the history
…tsMap

Do not call methods on EcalTrigTowerConstituentsMap nullptr
  • Loading branch information
cmsbuild committed Nov 10, 2022
2 parents 34f52b3 + a7c0e6a commit ef389b3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Expand Up @@ -23,6 +23,8 @@ class EcalTrigTowerConstituentsMap {
/// Get the tower id for this det id (or null if not known)
EcalTrigTowerDetId towerOf(const DetId& id) const;

static EcalTrigTowerDetId barrelTowerOf(const DetId& id);

/// Get the constituent detids for this tower id
std::vector<DetId> constituentsOf(const EcalTrigTowerDetId& id) const;

Expand Down
10 changes: 10 additions & 0 deletions Geometry/CaloTopology/src/EcalTrigTowerConstituentsMap.cc
Expand Up @@ -5,9 +5,19 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "FWCore/Utilities/interface/Exception.h"
#include <cassert>

EcalTrigTowerConstituentsMap::EcalTrigTowerConstituentsMap() {}

EcalTrigTowerDetId EcalTrigTowerConstituentsMap::barrelTowerOf(const DetId& id) {
assert(id.det() == DetId::Ecal && id.subdetId() == EcalBarrel);
//--------------------
// Ecal Barrel
//--------------------
EBDetId myId(id);
return myId.tower();
}

EcalTrigTowerDetId EcalTrigTowerConstituentsMap::towerOf(const DetId& id) const {
if (id.det() == DetId::Ecal && id.subdetId() == EcalBarrel) {
//--------------------
Expand Down
Expand Up @@ -185,7 +185,8 @@ void EcalEBTrigPrimTestAlgo::fillMap(
;
for (unsigned int i = 0; i < col->size(); ++i) {
Digi samples((*col)[i]);
EcalTrigTowerDetId coarser = (*eTTmap_).towerOf(samples.id());
EcalTrigTowerDetId coarser =
eTTmap_ ? (*eTTmap_).towerOf(samples.id()) : EcalTrigTowerConstituentsMap::barrelTowerOf(samples.id());
int index = getIndex(col, coarser);
int stripnr = findStripNr(samples.id());

Expand Down
Expand Up @@ -305,7 +305,8 @@ void EcalTrigPrimFunctionalAlgo::fillMap(
LogDebug("EcalTPG") << "Fill mapping, Collection size = " << col->size();
for (unsigned int i = 0; i < col->size(); ++i) {
Digi samples((*col)[i]);
EcalTrigTowerDetId coarser = (*eTTmap_).towerOf(samples.id());
EcalTrigTowerDetId coarser =
eTTmap_ ? (*eTTmap_).towerOf(samples.id()) : EcalTrigTowerConstituentsMap::barrelTowerOf(samples.id());
int index = getIndex(col, coarser);
int stripnr = findStripNr(samples.id());

Expand Down

0 comments on commit ef389b3

Please sign in to comment.