Belle II Software development
MCPDGCodeColorMap Class Reference

CDCHit to color map by the associated MCParticle::getPDG() More...

#include <HitColorMapping.h>

Inheritance diagram for MCPDGCodeColorMap:
Mapping< const CDCHit >

Public Member Functions

std::string map (int index, const CDCHit &hit) override
 Function call to map the CDCHit id and object to a color.
 
std::string info () override
 Informal string summarizing the translation from pdg codes to colors.
 

Detailed Description

CDCHit to color map by the associated MCParticle::getPDG()

Definition at line 142 of file HitColorMapping.h.

Member Function Documentation

◆ info()

std::string info ( )
overridevirtual

Informal string summarizing the translation from pdg codes to colors.

Reimplemented from Mapping< const CDCHit >.

Definition at line 287 of file HitColorMapping.cc.

288{
289 std::ostringstream oss;
290 oss << "\nLegend:";
291
292 std::map<std::string, std::set<int>> pdgCodeByColor;
293
294 for (auto item : c_colorByPDGCode) {
295 pdgCodeByColor[item.second].insert(item.first);
296 }
297
298 for (auto item : pdgCodeByColor) {
299 oss << '\n' << item.first << "->[";
300 oss << join(", ", item.second);
301 oss << ']';
302 }
303 oss << '\n';
304 return oss.str();
305}

◆ map()

std::string map ( int index,
const CDCHit & hit )
overridevirtual

Function call to map the CDCHit id and object to a color.

Reimplemented from Mapping< const CDCHit >.

Definition at line 273 of file HitColorMapping.cc.

274{
275 MCParticle* mcParticle = hit.getRelated<MCParticle>("MCParticles");
276 int pdgCode = mcParticle != nullptr ? mcParticle->getPDG() : -999;
277
278 auto itFound = c_colorByPDGCode.find(pdgCode);
279 if (itFound != c_colorByPDGCode.end()) {
280 return itFound->second;
281 } else {
282 B2WARNING("Unknown PDG code " << pdgCode);
283 return c_missingPDGColor;
284 }
285}
int getPDG() const
Return PDG code of particle.
Definition MCParticle.h:101
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.

The documentation for this class was generated from the following files: