Belle II Software development
MCParticleColorMap Class Reference

CDCHit to color map by their assoziated MCParticle::getArrayId() property. More...

#include <HitColorMapping.h>

Inheritance diagram for MCParticleColorMap:
Mapping< const CDCHit >

Public Member Functions

 MCParticleColorMap ()
 Constructor setting up a Monte Carlo id to color map which is continously filled as new during the event.
 
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 CDCSimHit::getBackgroundTag.
 

Private Attributes

std::vector< std::string > m_colors
 List of colors to be cycled.
 
int m_iColor
 Index of the color to be used next.
 
std::map< int, std::string > m_usedColors
 Mapping of the already used colors by the MCParticle::getArrayId to map later CDCHits to the same color.
 

Detailed Description

CDCHit to color map by their assoziated MCParticle::getArrayId() property.

Definition at line 115 of file HitColorMapping.h.

Constructor & Destructor Documentation

◆ MCParticleColorMap()

Constructor setting up a Monte Carlo id to color map which is continously filled as new during the event.

Definition at line 238 of file HitColorMapping.cc.

240 , m_iColor(0)
241 , m_usedColors()
242{
243}
static std::vector< std::string > getList()
Get a list of useful colors.
Definition: Colors.cc:15
int m_iColor
Index of the color to be used next.
std::map< int, std::string > m_usedColors
Mapping of the already used colors by the MCParticle::getArrayId to map later CDCHits to the same col...
std::vector< std::string > m_colors
List of colors to be cycled.

Member Function Documentation

◆ info()

std::string info ( )
overridevirtual

Informal string summarizing the translation from CDCSimHit::getBackgroundTag.

Reimplemented from Mapping< const CDCHit >.

Definition at line 245 of file HitColorMapping.cc.

246{
247 std::ostringstream oss;
248 for (const std::pair<int, std::string> colorForMCParticleID : m_usedColors) {
249 oss << "MCParticle " << colorForMCParticleID.first << " -> " << colorForMCParticleID.second << "\n";
250 }
251 return oss.str();
252}

◆ 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 254 of file HitColorMapping.cc.

255{
256 MCParticle* mcParticle = hit.getRelated<MCParticle>("MCParticles");
257 if (mcParticle != nullptr) {
258 int mcParticleId = mcParticle->getArrayIndex();
259 if (m_usedColors.count(mcParticleId) == 1) {
260 return m_usedColors[mcParticleId];
261 } else {
262 ++m_iColor;
263 std::string color = m_colors[m_iColor % m_colors.size()];
264 m_usedColors.emplace(mcParticleId, color);
265 return color;
266 }
267 } else {
268 return c_bkgHitColor;
269 }
270}
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
int getArrayIndex() const
Get 0-based index of the particle in the corresponding MCParticle list.
Definition: MCParticle.h:244

Member Data Documentation

◆ m_colors

std::vector<std::string> m_colors
private

List of colors to be cycled.

Definition at line 127 of file HitColorMapping.h.

◆ m_iColor

int m_iColor
private

Index of the color to be used next.

Definition at line 130 of file HitColorMapping.h.

◆ m_usedColors

std::map<int, std::string> m_usedColors
private

Mapping of the already used colors by the MCParticle::getArrayId to map later CDCHits to the same color.

Definition at line 136 of file HitColorMapping.h.


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