Skip to content

Commit

Permalink
Avoid crashing when cross-talk not wanted (#94)
Browse files Browse the repository at this point in the history
* [ReadCaloCrosstalkMap] Avoid crashing when cross talk file does not exists but we do not need cross talk emulation

* [ReadCaloCrosstalkMap] Add a debug message when skipping initilization
  • Loading branch information
BrieucF committed Jul 9, 2024
1 parent ac3feb5 commit e252f8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions RecCalorimeter/src/components/ReadCaloCrosstalkMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ ReadCaloCrosstalkMap::ReadCaloCrosstalkMap(const std::string& type, const std::s
}

StatusCode ReadCaloCrosstalkMap::initialize() {
// prevent to initialize the tool if not intended (input file path empty)
// otherwise things will crash if m_fileName is not available
// not a perfect solution but tools seems to not be meant to be optional
if (m_fileName == "") {
debug() << "Empty 'fileName' provided, it means cross-talk map is not needed, exitting ReadCaloCrosstalkMap initilization" << endmsg;
return StatusCode::SUCCESS;
}

StatusCode sc = GaudiTool::initialize();
info() <<"Loading crosstalk map..." << endmsg;
if (sc.isFailure()) return sc;
Expand Down
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/ReadCaloCrosstalkMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ReadCaloCrosstalkMap : public GaudiTool, virtual public ICaloReadCrosstalk

private:
/// Name of input root file that contains the TTree with cellID->vec<list_crosstalk_neighboursCellID> and cellId->vec<list_crosstalksCellID>
Gaudi::Property<std::string> m_fileName{this, "fileName", "xtalk_neighbours_map_ecalB_thetamodulemerged.root", "Name of the file that contains the crosstalk map"};
Gaudi::Property<std::string> m_fileName{this, "fileName", "", "Name of the file that contains the crosstalk map. Leave the default empty to avoid crashes when cross-talk is not needed."};
/// Output maps to be used for the fast lookup in the creating calo-cells algorithm
std::unordered_map<uint64_t, std::vector<uint64_t>> m_mapNeighbours;
std::unordered_map<uint64_t, std::vector<double>> m_mapCrosstalks;
Expand Down

0 comments on commit e252f8c

Please sign in to comment.