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.
 

Detailed Description

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

Definition at line 98 of file HitColorMapping.h.

Member Function Documentation

◆ info()

virtual std::string info ( )
inlinevirtualinherited

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

Reimplemented in RLColorMap, PosFlagColorMap, BackgroundTagColorMap, MCParticleColorMap, MCPDGCodeColorMap, MCPrimaryColorMap, 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 200 of file HitColorMapping.cc.

201{
202 CDCSimHit* simHit = hit.getRelated<CDCSimHit>("CDCSimHits");
203 double timeOfFlight = simHit->getFlightTime();
204 return timeOfFlightToColor(timeOfFlight);
205}
Example Detector.
Definition: CDCSimHit.h:21
double getFlightTime() const
The method to get flight time.
Definition: CDCSimHit.h:184
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 207 of file HitColorMapping.cc.

208{
209 //values are all fractions of their respective scale
210
211 //Full color circle in 3 nanoseconds
212 double hue = fmod(360 / 3.0 * timeOfFlight, 360) / 360;
213 double saturation = 0.75, lightness = 0.5;
214 std::array<double, 3> rgb = Colors::hlsToRgb(hue, lightness, saturation);
215 std::ostringstream oss;
216 std::string color;
217 oss << "rgb(" << rgb[0] * 100 << "%, " << rgb[1] * 100 << "%, " << rgb[2] * 100 << "%)";
218 color = oss.str();
219 return color;
220}
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: