Belle II Software development
TOFColorMap Class Reference

CDCHit to color map by their associated CDCSimHit::getFlightTime. More...

#include <HitColorMapping.h>

Inheritance diagram for TOFColorMap:
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 timeOfFlightToColor (const double timeOfFlight)
 Translates the given floating point time of flight to a color.
 
virtual std::string info ()
 Informal string summarizing the translation from the object to the attribute value.
 
virtual std::string info ()
 Informal string summarizing the translation from the object to the attribute value.
 

Detailed Description

CDCHit to color map by their associated CDCSimHit::getFlightTime.

Definition at line 100 of file HitColorMapping.h.

Member Function Documentation

◆ info() [1/2]

virtual std::string info ( )
inlinevirtualinherited

Informal string summarizing the translation from the object to the attribute value.

Reimplemented in BackgroundTagColorMap, MCParticleColorMap, MCPDGCodeColorMap, MCPrimaryColorMap, PosFlagColorMap, RLColorMap, and SimHitPDGCodeColorMap.

Definition at line 37 of file Mapping.h.

38 {
39 return "(no info available)\n";
40 }

◆ info() [2/2]

virtual std::string info ( )
inlinevirtualinherited

Informal string summarizing the translation from the object to the attribute value.

Reimplemented in BackgroundTagColorMap, MCParticleColorMap, MCPDGCodeColorMap, MCPrimaryColorMap, PosFlagColorMap, RLColorMap, and SimHitPDGCodeColorMap.

Definition at line 37 of file Mapping.h.

38 {
39 return "(no info available)\n";
40 }

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

202{
203 CDCSimHit* simHit = hit.getRelated<CDCSimHit>("CDCSimHits");
204 double timeOfFlight = simHit->getFlightTime();
205 return timeOfFlightToColor(timeOfFlight);
206}
double getFlightTime() const
The method to get flight time.
Definition CDCSimHit.h:183
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
std::string timeOfFlightToColor(const double timeOfFlight)
Translates the given floating point time of flight to a color.

◆ timeOfFlightToColor()

std::string timeOfFlightToColor ( const double timeOfFlight)

Translates the given floating point time of flight to a color.

Definition at line 208 of file HitColorMapping.cc.

209{
210 //values are all fractions of their respective scale
211
212 //Full color circle in 3 nanoseconds
213 double hue = fmod(360 / 3.0 * timeOfFlight, 360) / 360;
214 double saturation = 0.75, lightness = 0.5;
215 std::array<double, 3> rgb = Colors::hlsToRgb(hue, lightness, saturation);
216 std::ostringstream oss;
217 std::string color;
218 oss << "rgb(" << rgb[0] * 100 << "%, " << rgb[1] * 100 << "%, " << rgb[2] * 100 << "%)";
219 color = oss.str();
220 return color;
221}
static std::array< double, 3 > hlsToRgb(double h, double l, double s)
Transforms a Color given in the HLS System to RGB.
Definition Colors.cc:56

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