LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TrajectoryPointFlags.cxx
Go to the documentation of this file.
1 
11 #include "TrajectoryPointFlags.h"
12 
13 // C/C++ standard library
14 #include <ostream>
15 
16 //------------------------------------------------------------------------------
17 //--- recob::TrajectoryPointFlagTraits
18 //---
19 
20 // TODO: The following definitions are temporary, until we figure out what is
21 // requiring them.
34 
35 //------------------------------------------------------------------------------
38 
39 //------------------------------------------------------------------------------
40 std::string recob::TrajectoryPointFlagTraits::decorateFlagName(std::string baseName, Flag_t flag)
41 {
42  return baseName + std::to_string(flag.index());
43 } // recob::TrajectoryPointFlagTraits::decorateFlagName()
44 
45 //------------------------------------------------------------------------------
47 {
48  return "<" + decorateFlagName("InvalidFlag", flag) + ">";
49 }
50 
51 //------------------------------------------------------------------------------
53  FlagIndex_t BeginFlags,
54  FlagIndex_t EndFlags,
55  std::string baseName)
56 {
57  if (EndFlags <= BeginFlags) return;
58  unsigned int const NFlags = EndFlags - BeginFlags;
59 
60  // the first flag will have name with index NFlags, the last with name "1"
61  for (unsigned int dFlag = 0; dFlag < NFlags; ++dFlag) {
62  FlagIndex_t const flag = BeginFlags + dFlag;
63 
64  flagNames[flag] = decorateFlagName(baseName, NFlags - dFlag);
65  } // for
66 
67 } // recob::TrajectoryPointFlagTraits::initDefaultFlagRangeNames()
68 
69 //------------------------------------------------------------------------------
71 {
72 
74  flagNames, BeginTrajectoryFlags, EndTrajectoryFlags, "TrajectoryReserved");
75  initDefaultFlagRangeNames(flagNames, BeginTrackFlags, EndTrackFlags, "TrackReserved");
77  flagNames, BeginExperimentReservedFlags, EndExperimentReservedFlags, "ExperimentFlag");
79 
80 } // recob::TrajectoryPointFlagTraits::initDefaultFlagsNames()
81 
82 //------------------------------------------------------------------------------
84 {
85 
86  //
87  // set the names of the new flags here
88  //
89 
90  // trajectory flags
91  std::get<HitIgnored.index()>(flagNames) = "HitIgnored";
92  std::get<NoPoint.index()>(flagNames) = "NoPoint";
93  std::get<Suspicious.index()>(flagNames) = "Suspicious";
94  std::get<Merged.index()>(flagNames) = "Merged";
95  std::get<DeltaRay.index()>(flagNames) = "DeltaRay";
96  std::get<DetectorIssue.index()>(flagNames) = "DetectorIssue";
97  std::get<Shared.index()>(flagNames) = "Shared";
98 
99  // track flags
100  std::get<ExcludedFromFit.index()>(flagNames) = "ExcludedFromFit";
101  std::get<Rejected.index()>(flagNames) = "Rejected";
102  std::get<Reinterpreted.index()>(flagNames) = "Reinterpreted";
103 
104 } // recob::TrajectoryPointFlagTraits::initNames()
105 
106 //------------------------------------------------------------------------------
108 {
109 
110  NameMap_t flagNames; // not initialized
111 
112  // initialize with default names
113  initDefaultFlagsNames(flagNames);
114 
115  // overwrite custom names
116  setFlagNames(flagNames);
117 
118  // done!
119  return flagNames;
120 
121 } // recob::TrajectoryPointFlagTraits::initNames()
122 
123 //------------------------------------------------------------------------------
124 std::ostream& recob::operator<<(std::ostream& out, recob::TrajectoryPointFlags const& flags)
125 {
126  flags.dump(out);
127  return out;
128 }
129 
130 //------------------------------------------------------------------------------
static constexpr FlagIndex_t EndUserReservedFlags
After-the-last flag reserved to users.
static constexpr Flag_t Merged
The hit might have contribution from particles other than this.
static constexpr Flag_t Suspicious
The point reconstruction is somehow questionable.
static constexpr Flag_t NoPoint
The trajectory point is not defined.
static constexpr FlagIndex_t EndTrajectoryFlags
After-the-last trajectory flag index.
static constexpr FlagIndex_t BeginTrackFlags
First track flag index.
static NameMap_t initNames()
Returns a map of flag names.
Flags_t::Flag_t Flag_t
Type of single flag.
static void setFlagNames(NameMap_t &flagNames)
Sets the names of the flags after default initialization.
static constexpr Flag_t Reinterpreted
The hit content has been elaborated before being used in the fit.
static constexpr FlagIndex_t BeginExperimentReservedFlags
First flag reserved to experiment.
static void initDefaultFlagRangeNames(NameMap_t &flagNames, FlagIndex_t BeginFlags, FlagIndex_t EndFlags, std::string baseName)
Initializes a range of flag names with default (decorated) names.
Flags_t::FlagIndex_t FlagIndex_t
Type of index of a single flag.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
static std::string decorateFlagName(std::string baseName, Flag_t flag)
Combines a base name and an index into a flag name.
static std::string invalidFlagName(Flag_t flag)
Returns the name of an invalid flag with the specified index.
void dump(Stream &&out, unsigned int verbosity, std::string indent, std::string indentFirst) const
Prints the flags content into a stream.
static void initDefaultFlagsNames(NameMap_t &flagNames)
Initialises all flag names with a default name.
static constexpr FlagIndex_t EndTrackFlags
After-the-last track flag index.
static constexpr FlagIndex_t EndExperimentReservedFlags
After-the-last flag reserved to experiment.
static constexpr Flag_t HitIgnored
Hit was not included for the computation of the trajectory.
Set of flags pertaining a point of the track.
static constexpr Flag_t Rejected
The hit is extraneous to this track.
static constexpr Flag_t ExcludedFromFit
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
Definition: StdUtils.h:120
static constexpr FlagIndex_t BeginTrajectoryFlags
First trajectory flag index.
std::array< std::string, MaxFlags > NameMap_t
Type storing flag names.
static constexpr Flag_t TrajReserved1
Reserved for a future trajectory flag.
static constexpr FlagIndex_t BeginUserReservedFlags
First flag reserved to users.
static constexpr Flag_t DetectorIssue
The hit is associated to a problematic channel.
static constexpr Flag_t DeltaRay
The hit might have contribution from a δ ray.
static const NameMap_t names
Names of the flags.
static constexpr Flag_t Shared
The hit is known to be associated also to another trajectory.
Set of flags pertaining a point of the track.
std::ostream & operator<<(std::ostream &o, Cluster const &c)
Definition: Cluster.cxx:168