8#include <tracking/trackFindingCDC/display/HitColorMapping.h> 
    9#include <tracking/trackFindingCDC/display/Colors.h> 
   11#include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h> 
   12#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h> 
   13#include <tracking/trackFindingCDC/utilities/VectorRange.h> 
   15#include <cdc/dataobjects/CDCHit.h> 
   16#include <cdc/dataobjects/CDCSimHit.h> 
   17#include <mdst/dataobjects/MCParticle.h> 
   23using namespace TrackFindingCDC;
 
   26const std::string c_bkgHitColor = 
"orange";
 
   29const std::string c_missingPDGColor = 
"lime";
 
   32const std::map<int, std::string> c_colorByPDGCode = {
 
   72    B2WARNING(
"CDCWireHitVector could not be found on the DataStore. Cannot plot the taken flags.");
 
   82    if (not wireHitRange.empty()) {
 
   83      const CDCWireHit& wireHit =  wireHitRange.front();
 
   95  short int rlInfo = mcHitLookUp.
getRLInfo(&hit);
 
   98  } 
else if (rlInfo == -1) {
 
  101    return (c_bkgHitColor);
 
  107  return "Local right left passage variable: green <-> right, red <-> left, orange <-> not determinable.\n";
 
  116  } 
else if (posFlag == 1) {
 
  119    return (c_bkgHitColor);
 
  125  return "PosFlag variable of the related CDCSimHit: green <-> 0 (Right), red <-> 1 (Left), orange <-> determinable.\n";
 
  132  switch (backgroundtag) {
 
  152      B2INFO(
"Background tag " << backgroundtag << 
" not associated with a color.\n");
 
  159  return (
"Background tag color coding is:\n" 
  160          "bg_Coulomb_HER: darkred\n" 
  161          "bg_Coulomb_LER: red\n" 
  162          "bg_RBB_HER: darkblue\n" 
  163          "bg_RBB_HER_far: darkturquoise\n" 
  165          "bg_RBB_LER_far: turquoise\n" 
  166          "bg_SynchRad_HER: darkgoldenrod\n" 
  167          "bg_SynchRad_LER: goldenrod\n" 
  168          "bg_Touschek_HER: darkgreen\n" 
  169          "bg_Touschek_HER_far: darkolivegreen\n" 
  170          "bg_Touschek_LER: green\n" 
  171          "bg_Touschek_LER_far: olivergreen\n" 
  172          "bg_RBB_gamma: skyblue\n" 
  175          "bg_twoPhoton: violet\n" 
  185  if (inTrackiSegment < 0) {
 
  186    return (c_bkgHitColor);
 
  189    double hue = 50 * inTrackiSegment % 360 / 360.0;
 
  190    double saturation = 0.75, lightness = 0.5;
 
  192    std::ostringstream oss;
 
  194    oss << 
"rgb(" << rgb[0] * 100 << 
"%, " << rgb[1] * 100 << 
"%, " << rgb[2] * 100 << 
"%)";
 
  212  double hue = fmod(360 / 3.0 * timeOfFlight, 360) / 360;
 
  213  double saturation = 0.75, lightness = 0.5;
 
  215  std::ostringstream oss;
 
  217  oss << 
"rgb(" << rgb[0] * 100 << 
"%, " << rgb[1] * 100 << 
"%, " << rgb[2] * 100 << 
"%)";
 
  225    hit.getRelationsWith<
MCParticle>(
"MCParticles");
 
  226  if (relatedMCParticles.
size() == 0) {
 
  227    return c_bkgHitColor;
 
  229    double mcRelationWeight = relatedMCParticles.
weight(0);
 
  230    if (mcRelationWeight > 0) {
 
  239  : m_colors(
Colors::getList())
 
  247  std::ostringstream oss;
 
  248  for (
const std::pair<int, std::string> colorForMCParticleID : 
m_usedColors) {
 
  249    oss << 
"MCParticle " << colorForMCParticleID.first << 
" -> " << colorForMCParticleID.second << 
"\n";
 
  257  if (mcParticle != 
nullptr) {
 
  268    return c_bkgHitColor;
 
  275  int pdgCode = mcParticle != 
nullptr ? mcParticle->
getPDG() : -999;
 
  277  auto itFound = c_colorByPDGCode.find(pdgCode);
 
  278  if (itFound != c_colorByPDGCode.end()) {
 
  279    return itFound->second;
 
  281    B2WARNING(
"Unknown PDG code " << pdgCode);
 
  282    return c_missingPDGColor;
 
  288  std::ostringstream oss;
 
  291  std::map<std::string, std::set<int>> pdgCodeByColor;
 
  293  for (
auto item : c_colorByPDGCode) {
 
  294    pdgCodeByColor[item.second].insert(item.first);
 
  297  for (
auto item : pdgCodeByColor) {
 
  298    oss << 
'\n' << item.first << 
"->[";
 
  299    oss << join(
", ", item.second);
 
  309  if (mcParticle != 
nullptr) {
 
  310    unsigned short int primaryFlag = 1;
 
  311    bool isPrimary = mcParticle->
hasStatus(primaryFlag);
 
  316    } 
else if (secondaryProcess > 200) {
 
  322    return c_bkgHitColor;
 
  330         "green->secondary decay in flight\n" 
  331         "orange->beam background\n";
 
  337  int pdgCode = simHit != 
nullptr ? simHit->
getPDGCode() : -999;
 
  338  auto itFound = c_colorByPDGCode.find(pdgCode);
 
  339  if (itFound != c_colorByPDGCode.end()) {
 
  340    return itFound->second;
 
  342    B2WARNING(
"Unknown PDG code " << pdgCode);
 
  343    return c_missingPDGColor;
 
  349  std::ostringstream oss;
 
  352  std::map<std::string, std::set<int>> pdgCodeByColor;
 
  354  for (
auto item : c_colorByPDGCode) {
 
  355    pdgCodeByColor[item.second].insert(item.first);
 
  358  for (
auto item : pdgCodeByColor) {
 
  359    oss << 
'\n' << item.first << 
"->[";
 
  360    oss << join(
", ", item.second);
 
  382  int nLoops = mcHitLookUp.
getNLoops(&hit);
 
  385    return c_bkgHitColor;
 
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
int getPDGCode() const
The method to get PDG code.
double getFlightTime() const
The method to get flight time.
int getPosFlag() const
The method to get old left/right info.
A Class to store the Monte Carlo particle information.
bool hasStatus(unsigned short int bitmask) const
Return if specific status bit is set.
int getArrayIndex() const
Get 0-based index of the particle in the corresponding MCParticle list.
int getPDG() const
Return PDG code of particle.
int getSecondaryPhysicsProcess() const
Returns the physics process type of a secondary particle.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
float weight(int index) const
Get weight with index.
virtual unsigned short getBackgroundTag() const
Get background tag.
bool hasTakenFlag() const
Gets the current state of the taken marker flag.
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.
Interface class to the Monte Carlo information for individual hits.
Index getInTrackSegmentId(const CDCHit *ptrHit) const
Returns the id of the segment in the track.
Index getNLoops(const CDCHit *ptrHit) const
Returns the number of loops the track traversed until this hit.
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
ERightLeft getRLInfo(const CDCHit *ptrHit) const
Returns the true right left passage information.
Class representing a hit wire in the central drift chamber.
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
Utility functions related to colors.
static std::string getWheelColor(int degree)
Get a color from the wheel of colors.
static std::array< double, 3 > hlsToRgb(double h, double l, double s)
Transforms a Color given in the HLS System to RGB.
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.
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.
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.
MCParticleColorMap()
Constructor setting up a Monte Carlo id to color map which is continously filled as new during the ev...
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 seconday process codes to colors.
std::string map(int index, const CDCHit &hit) override
Function call to map the CDCHit id and object to a color.
std::string map(int index, const CDCHit &hit) override
Function call to map a segments object from the local finder to a color.
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::getPosFlag variable to colors.
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 right left passage variable to colors.
A pair of iterators usable with the range base for loop.
std::string map(int index, const CDCHit &hit) override
Function call to map the CDCHit id and object to a color.
std::string map(int index, const CDCHit &hit) override
Function call to map the CDCHit id and object to a color.
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.
std::string timeOfFlightToColor(const double timeOfFlight)
Translates the given floating point time of flight to a color.
std::string map(int index, const CDCHit &hit) override
Function call to map the CDCHit id and object to a color.
TakenFlagColorMap()
Constructor checking if the CDCWireHits caring the taken flag are accessable.
StoreWrappedObjPtr< std::vector< CDCWireHit > > m_storedWireHits
Memory of the handle to the CDCWireHits on the DataStore.
std::string map(int index, const CDCHit &hit) override
Function call to map the CDCHit id and object to a color.
std::string map(int index, const CDCHit &hit) override
Function call to map the CDCHit id and object to a color.
std::string map(int index, const CDCHit &hit) override
Function call to map the CDCHit id and object to a stroke width.
Abstract base class for different kinds of events.