8#include <tracking/trackFindingCDC/display/HitColorMapping.h>
9#include <tracking/trackFindingCDC/display/Colors.h>
11#include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
12#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
13#include <tracking/trackingUtilities/utilities/VectorRange.h>
15#include <cdc/dataobjects/CDCHit.h>
16#include <cdc/dataobjects/CDCSimHit.h>
17#include <mdst/dataobjects/MCParticle.h>
23using namespace TrackFindingCDC;
24using namespace TrackingUtilities;
27const std::string c_bkgHitColor =
"orange";
30const std::string c_missingPDGColor =
"lime";
33const std::map<int, std::string> c_colorByPDGCode = {
73 B2WARNING(
"CDCWireHitVector could not be found on the DataStore. Cannot plot the taken flags.");
81 ConstVectorRange<CDCWireHit> wireHitRange{std::equal_range(wireHits.begin(), wireHits.end(), hit)};
83 if (not wireHitRange.empty()) {
84 const CDCWireHit& wireHit = wireHitRange.front();
96 short int rlInfo = mcHitLookUp.
getRLInfo(&hit);
99 }
else if (rlInfo == -1) {
102 return (c_bkgHitColor);
108 return "Local right left passage variable: green <-> right, red <-> left, orange <-> not determinable.\n";
117 }
else if (posFlag == 1) {
120 return (c_bkgHitColor);
126 return "PosFlag variable of the related CDCSimHit: green <-> 0 (Right), red <-> 1 (Left), orange <-> determinable.\n";
133 switch (backgroundtag) {
153 B2INFO(
"Background tag " << backgroundtag <<
" not associated with a color.\n");
160 return (
"Background tag color coding is:\n"
161 "bg_Coulomb_HER: darkred\n"
162 "bg_Coulomb_LER: red\n"
163 "bg_RBB_HER: darkblue\n"
164 "bg_RBB_HER_far: darkturquoise\n"
166 "bg_RBB_LER_far: turquoise\n"
167 "bg_SynchRad_HER: darkgoldenrod\n"
168 "bg_SynchRad_LER: goldenrod\n"
169 "bg_Touschek_HER: darkgreen\n"
170 "bg_Touschek_HER_far: darkolivegreen\n"
171 "bg_Touschek_LER: green\n"
172 "bg_Touschek_LER_far: olivergreen\n"
173 "bg_RBB_gamma: skyblue\n"
176 "bg_twoPhoton: violet\n"
186 if (inTrackiSegment < 0) {
187 return (c_bkgHitColor);
190 double hue = 50 * inTrackiSegment % 360 / 360.0;
191 double saturation = 0.75, lightness = 0.5;
193 std::ostringstream oss;
195 oss <<
"rgb(" << rgb[0] * 100 <<
"%, " << rgb[1] * 100 <<
"%, " << rgb[2] * 100 <<
"%)";
213 double hue = fmod(360 / 3.0 * timeOfFlight, 360) / 360;
214 double saturation = 0.75, lightness = 0.5;
216 std::ostringstream oss;
218 oss <<
"rgb(" << rgb[0] * 100 <<
"%, " << rgb[1] * 100 <<
"%, " << rgb[2] * 100 <<
"%)";
227 if (relatedMCParticles.
size() == 0) {
228 return c_bkgHitColor;
230 double mcRelationWeight = relatedMCParticles.
weight(0);
231 if (mcRelationWeight > 0) {
248 std::ostringstream oss;
249 for (
const std::pair<int, std::string> colorForMCParticleID :
m_usedColors) {
250 oss <<
"MCParticle " << colorForMCParticleID.first <<
" -> " << colorForMCParticleID.second <<
"\n";
258 if (mcParticle !=
nullptr) {
269 return c_bkgHitColor;
276 int pdgCode = mcParticle !=
nullptr ? mcParticle->
getPDG() : -999;
278 auto itFound = c_colorByPDGCode.find(pdgCode);
279 if (itFound != c_colorByPDGCode.end()) {
280 return itFound->second;
282 B2WARNING(
"Unknown PDG code " << pdgCode);
283 return c_missingPDGColor;
289 std::ostringstream oss;
292 std::map<std::string, std::set<int>> pdgCodeByColor;
294 for (
auto item : c_colorByPDGCode) {
295 pdgCodeByColor[item.second].insert(item.first);
298 for (
auto item : pdgCodeByColor) {
299 oss <<
'\n' << item.first <<
"->[";
300 oss << join(
", ", item.second);
310 if (mcParticle !=
nullptr) {
311 unsigned short int primaryFlag = 1;
312 bool isPrimary = mcParticle->
hasStatus(primaryFlag);
317 }
else if (secondaryProcess > 200) {
323 return c_bkgHitColor;
331 "green->secondary decay in flight\n"
332 "orange->beam background\n";
338 int pdgCode = simHit !=
nullptr ? simHit->
getPDGCode() : -999;
339 auto itFound = c_colorByPDGCode.find(pdgCode);
340 if (itFound != c_colorByPDGCode.end()) {
341 return itFound->second;
343 B2WARNING(
"Unknown PDG code " << pdgCode);
344 return c_missingPDGColor;
350 std::ostringstream oss;
353 std::map<std::string, std::set<int>> pdgCodeByColor;
355 for (
auto item : c_colorByPDGCode) {
356 pdgCodeByColor[item.second].insert(item.first);
359 for (
auto item : pdgCodeByColor) {
360 oss <<
'\n' << item.first <<
"->[";
361 oss << join(
", ", item.second);
383 int nLoops = mcHitLookUp.
getNLoops(&hit);
386 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.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
RelationVector< T > getRelationsWith(const std::string &name="", const std::string &namedRelation="") const
Get the relations between this object and another store array.
virtual unsigned short getBackgroundTag() const
Get background tag.
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.
TrackingUtilities::Index getInTrackSegmentId(const CDCHit *ptrHit) const
Returns the id of the segment in the track.
TrackingUtilities::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.
TrackingUtilities::ERightLeft getRLInfo(const CDCHit *ptrHit) const
Returns the true right left passage information.
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 continuously filled as new during the e...
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 secondary 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.
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 accessible.
TrackingUtilities::StoreWrappedObjPtr< std::vector< TrackingUtilities::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.
bool hasTakenFlag() const
Gets the current state of the taken marker flag.
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.
Abstract base class for different kinds of events.