Public Types | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Static Private Attributes | List of all members
recob::TrajectoryPointFlagTraits Struct Reference

Namespace for the trajectory point flags. More...

#include <TrajectoryPointFlags.h>

Public Types

using Flags_t = util::flags::FlagSet< MaxFlags >
 Type of mask of bits. More...
 
using Mask_t = Flags_t::Mask_t
 Type of mask of bits. More...
 
using Flag_t = Flags_t::Flag_t
 Type of single flag. More...
 
using FlagIndex_t = Flags_t::FlagIndex_t
 Type of index of a single flag. More...
 

Static Public Member Functions

static constexpr FlagIndex_t maxFlags ()
 Number of flags allocated (may be unused and unassigned). More...
 
static constexpr bool isFlag (Flag_t flag)
 Returns whether the specified index represents a valid flag. More...
 

Static Public Attributes

static constexpr unsigned int MaxFlags = 32
 Number of flags allocated (may be unused and unassigned). More...
 
Trajectory flags.

The definition of the flags will result somehow ambiguous, because it requires a judgement that is in the end arbitrary enough that it may be inconsistent between different algorithms.

The design idea is that typically at most one flag is set. For example, if a hit is known to be associated to another trajectory, the point will be marked as Shared but not Merged, and if it is Merged or Shared it will not be flagged as Suspicious. Exceptions may apply. For example, a hit known to be shared with a δ ray which is reconstructed as a distinct trajectory may have both the Shared and the DeltaRay flags.

Also note that there may be better ways than these flags to discover information. For example, the DetectorIssue flag might have been left unset because no check was done on the actual data quality, or because the failure of the channel was not yet known at the time the trajectory was reconstructed.

Implementation note

The single flags are of type Flag_t, which is effectively represented as a bit mask with a single bit set. The boundary flag indices instead are actual indices (type FlagIndex_t) which allows them to be beyond the range of the mask (think especially to EndExperimentReservedFlags, whose value of $ 2^{32} $ is just beyond the range of a 32-bit integer). Each flag can yield its index by the index() method, and this can be used to compare them to flag indices.

static constexpr FlagIndex_t BeginTrajectoryFlags = 0
 First trajectory flag index. More...
 
static constexpr Flag_t HitIgnored { 0 }
 Hit was not included for the computation of the trajectory. More...
 
static constexpr Flag_t NoPoint { 1 }
 The trajectory point is not defined. More...
 
static constexpr Flag_t Suspicious { 2 }
 The point reconstruction is somehow questionable. More...
 
static constexpr Flag_t Merged { 3 }
 The hit might have contribution from particles other than this. More...
 
static constexpr Flag_t DeltaRay { 4 }
 The hit might have contribution from a δ ray. More...
 
static constexpr Flag_t DetectorIssue { 5 }
 The hit is associated to a problematic channel. More...
 
static constexpr Flag_t Shared { 6 }
 The hit is known to be associated also to another trajectory. More...
 
static constexpr Flag_t TrajReserved1 { 7 }
 Reserved for a future trajectory flag. More...
 
static constexpr FlagIndex_t EndTrajectoryFlags = 8
 After-the-last trajectory flag index. More...
 
Track flags.

As for the trajectory flags, the ones pertaining the track fitting are designed to be set in the most exclusive way possible.

For example, a hit that is Rejected is not flagged as ExcludedFromFit (although it is indeed not included in the fit).

static constexpr FlagIndex_t BeginTrackFlags = EndTrajectoryFlags
 First track flag index. More...
 
static constexpr Flag_t ExcludedFromFit { 8 }
 
static constexpr Flag_t Rejected { 9 }
 The hit is extraneous to this track. More...
 
static constexpr Flag_t Reinterpreted { 10 }
 The hit content has been elaborated before being used in the fit. More...
 
static constexpr Flag_t TrackReserved5 { 11 }
 Reserved for a future track flag. More...
 
static constexpr Flag_t TrackReserved4 { 12 }
 Reserved for a future track flag. More...
 
static constexpr Flag_t TrackReserved3 { 13 }
 Reserved for a future track flag. More...
 
static constexpr Flag_t TrackReserved2 { 14 }
 Reserved for a future track flag. More...
 
static constexpr Flag_t TrackReserved1 { 15 }
 Reserved for a future track flag. More...
 
static constexpr FlagIndex_t EndTrackFlags = 16
 After-the-last track flag index. More...
 
Flag reserved for the experiments (not to be used in LArSoft).
static constexpr FlagIndex_t BeginExperimentReservedFlags = EndTrackFlags
 First flag reserved to experiment. More...
 
static constexpr FlagIndex_t EndExperimentReservedFlags = 24
 After-the-last flag reserved to experiment. More...
 
Flag reserved for the users (algorithm-specific).
static constexpr FlagIndex_t BeginUserReservedFlags = EndExperimentReservedFlags
 First flag reserved to users. More...
 
static constexpr FlagIndex_t EndUserReservedFlags = 32
 After-the-last flag reserved to users. More...
 

Static Private Member Functions

static std::string decorateFlagName (std::string baseName, Flag_t flag)
 Combines a base name and an index into a flag name. More...
 
static std::string invalidFlagName (Flag_t flag)
 Returns the name of an invalid flag with the specified index. More...
 
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. More...
 
static void initDefaultFlagsNames (NameMap_t &flagNames)
 Initialises all flag names with a default name. More...
 
static void setFlagNames (NameMap_t &flagNames)
 Sets the names of the flags after default initialization. More...
 

Static Private Attributes

static const NameMap_t names = recob::TrajectoryPointFlagTraits::initNames()
 Names of the flags. More...
 

Flag names

using NameMap_t = std::array< std::string, MaxFlags >
 Type storing flag names. More...
 
static std::string name (Flag_t flag)
 Returns a string with the name of the specified flag. More...
 
static NameMap_t initNames ()
 Returns a map of flag names. More...
 

Detailed Description

Namespace for the trajectory point flags.

This class is a glorified namespace for the definition of named flags.

Each flag must have an identifier that is of integral type FlagIndex_t. There are four types of flags: pertaining a trajectory (and pattern recognition output), pertaining a track (and track fit output), experiment specific and user specific.

The trajectory flags have a meaning in the bare context of reconstructed trajectory in space and patter recognition (see recob::Trajectory and see recob::TrackTrajectory), and they should preserve the same meaning after fitting into a track.

The track flags have a meaning only in the context of a track (see recob::Track).

The experiment-specific flags are placeholders that are expected to get a meaning that is consistent within a single experiment, and unrelated between experiments.

The user-specific flags are placeholders that are expected to get a meaning that is specific to an algorithm. Objects from different algorithms will give these flags unrelated meaning.

Code shared in LArSoft using the flags should rely only on the flags of the first two categories. Code that requires access to experiment-specific flags should be also experiment-specific.

Definition at line 58 of file TrajectoryPointFlags.h.

Member Typedef Documentation

Type of single flag.

Definition at line 70 of file TrajectoryPointFlags.h.

Type of index of a single flag.

Definition at line 73 of file TrajectoryPointFlags.h.

Type of mask of bits.

Definition at line 64 of file TrajectoryPointFlags.h.

Type of mask of bits.

Definition at line 67 of file TrajectoryPointFlags.h.

Type storing flag names.

Definition at line 251 of file TrajectoryPointFlags.h.

Member Function Documentation

std::string recob::TrajectoryPointFlagTraits::decorateFlagName ( std::string  baseName,
Flag_t  flag 
)
staticprivate

Combines a base name and an index into a flag name.

Definition at line 46 of file TrajectoryPointFlags.cxx.

47 {
48  return baseName + std::to_string(flag.index());
49 } // recob::TrajectoryPointFlagTraits::decorateFlagName()
static QCString baseName
Definition: scanner.cpp:10890
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void recob::TrajectoryPointFlagTraits::initDefaultFlagRangeNames ( NameMap_t flagNames,
FlagIndex_t  BeginFlags,
FlagIndex_t  EndFlags,
std::string  baseName 
)
staticprivate

Initializes a range of flag names with default (decorated) names.

Definition at line 59 of file TrajectoryPointFlags.cxx.

62  {
63  if (EndFlags <= BeginFlags) return;
64  unsigned int const NFlags = EndFlags - BeginFlags;
65 
66  // the first flag will have name with index NFlags, the last with name "1"
67  for (unsigned int dFlag = 0; dFlag < NFlags; ++dFlag) {
68  FlagIndex_t const flag = BeginFlags + dFlag;
69 
70  flagNames[flag] = decorateFlagName(baseName, NFlags - dFlag);
71  } // for
72 
73 } // recob::TrajectoryPointFlagTraits::initDefaultFlagRangeNames()
Flags_t::FlagIndex_t FlagIndex_t
Type of index of a single flag.
static std::string decorateFlagName(std::string baseName, Flag_t flag)
Combines a base name and an index into a flag name.
static QCString baseName
Definition: scanner.cpp:10890
void recob::TrajectoryPointFlagTraits::initDefaultFlagsNames ( NameMap_t flagNames)
staticprivate

Initialises all flag names with a default name.

Definition at line 78 of file TrajectoryPointFlags.cxx.

79 {
80 
83  "TrajectoryReserved"
84  );
86  flagNames, BeginTrackFlags, EndTrackFlags,
87  "TrackReserved"
88  );
91  "ExperimentFlag"
92  );
95  "UserFlag"
96  );
97 
98 } // recob::TrajectoryPointFlagTraits::initDefaultFlagsNames()
static constexpr FlagIndex_t EndUserReservedFlags
After-the-last flag reserved to users.
static constexpr FlagIndex_t EndTrajectoryFlags
After-the-last trajectory flag index.
static constexpr FlagIndex_t BeginTrackFlags
First track flag index.
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.
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 FlagIndex_t BeginTrajectoryFlags
First trajectory flag index.
static constexpr FlagIndex_t BeginUserReservedFlags
First flag reserved to users.
recob::TrajectoryPointFlagTraits::NameMap_t recob::TrajectoryPointFlagTraits::initNames ( )
static

Returns a map of flag names.

Definition at line 127 of file TrajectoryPointFlags.cxx.

127  {
128 
129  NameMap_t flagNames; // not initialized
130 
131  // initialize with default names
132  initDefaultFlagsNames(flagNames);
133 
134  // overwrite custom names
135  setFlagNames(flagNames);
136 
137  // done!
138  return flagNames;
139 
140 } // recob::TrajectoryPointFlagTraits::initNames()
static void setFlagNames(NameMap_t &flagNames)
Sets the names of the flags after default initialization.
static void initDefaultFlagsNames(NameMap_t &flagNames)
Initialises all flag names with a default name.
std::array< std::string, MaxFlags > NameMap_t
Type storing flag names.
std::string recob::TrajectoryPointFlagTraits::invalidFlagName ( Flag_t  flag)
staticprivate

Returns the name of an invalid flag with the specified index.

Definition at line 54 of file TrajectoryPointFlags.cxx.

55  { return "<" + decorateFlagName("InvalidFlag", flag) + ">"; }
static std::string decorateFlagName(std::string baseName, Flag_t flag)
Combines a base name and an index into a flag name.
static constexpr bool recob::TrajectoryPointFlagTraits::isFlag ( Flag_t  flag)
inlinestatic

Returns whether the specified index represents a valid flag.

Definition at line 238 of file TrajectoryPointFlags.h.

239  { return flag.index() < MaxFlags; }
static constexpr unsigned int MaxFlags
Number of flags allocated (may be unused and unassigned).
static constexpr FlagIndex_t recob::TrajectoryPointFlagTraits::maxFlags ( )
inlinestatic

Number of flags allocated (may be unused and unassigned).

Definition at line 234 of file TrajectoryPointFlags.h.

234 { return MaxFlags; }
static constexpr unsigned int MaxFlags
Number of flags allocated (may be unused and unassigned).
static std::string recob::TrajectoryPointFlagTraits::name ( Flag_t  flag)
inlinestatic

Returns a string with the name of the specified flag.

Definition at line 245 of file TrajectoryPointFlags.h.

246  {
247  return isFlag(flag)? names[flag.index()]: invalidFlagName(flag.index());
248  }
static constexpr bool isFlag(Flag_t flag)
Returns whether the specified index represents a valid flag.
static std::string invalidFlagName(Flag_t flag)
Returns the name of an invalid flag with the specified index.
static const NameMap_t names
Names of the flags.
void recob::TrajectoryPointFlagTraits::setFlagNames ( NameMap_t flagNames)
staticprivate

Sets the names of the flags after default initialization.

Definition at line 102 of file TrajectoryPointFlags.cxx.

102  {
103 
104  //
105  // set the names of the new flags here
106  //
107 
108  // trajectory flags
109  std::get<HitIgnored.index() >(flagNames) = "HitIgnored" ;
110  std::get<NoPoint.index() >(flagNames) = "NoPoint" ;
111  std::get<Suspicious.index() >(flagNames) = "Suspicious" ;
112  std::get<Merged.index() >(flagNames) = "Merged" ;
113  std::get<DeltaRay.index() >(flagNames) = "DeltaRay" ;
114  std::get<DetectorIssue.index()>(flagNames) = "DetectorIssue";
115  std::get<Shared.index() >(flagNames) = "Shared" ;
116 
117  // track flags
118  std::get<ExcludedFromFit.index()>(flagNames) = "ExcludedFromFit";
119  std::get<Rejected.index() >(flagNames) = "Rejected" ;
120  std::get<Reinterpreted.index() >(flagNames) = "Reinterpreted" ;
121 
122 } // recob::TrajectoryPointFlagTraits::initNames()
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 Flag_t Reinterpreted
The hit content has been elaborated before being used in the fit.
static constexpr Flag_t HitIgnored
Hit was not included for the computation of the trajectory.
static constexpr Flag_t Rejected
The hit is extraneous to this track.
static constexpr Flag_t ExcludedFromFit
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.
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
static constexpr Flag_t Shared
The hit is known to be associated also to another trajectory.

Member Data Documentation

constexpr FlagIndex_t recob::TrajectoryPointFlagTraits::BeginExperimentReservedFlags = EndTrackFlags
static

First flag reserved to experiment.

Definition at line 213 of file TrajectoryPointFlags.h.

constexpr FlagIndex_t recob::TrajectoryPointFlagTraits::BeginTrackFlags = EndTrajectoryFlags
static

First track flag index.

Definition at line 165 of file TrajectoryPointFlags.h.

constexpr FlagIndex_t recob::TrajectoryPointFlagTraits::BeginTrajectoryFlags = 0
static

First trajectory flag index.

Definition at line 113 of file TrajectoryPointFlags.h.

constexpr FlagIndex_t recob::TrajectoryPointFlagTraits::BeginUserReservedFlags = EndExperimentReservedFlags
static

First flag reserved to users.

Definition at line 225 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::DeltaRay { 4 }
static

The hit might have contribution from a δ ray.

Definition at line 135 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::DetectorIssue { 5 }
static

The hit is associated to a problematic channel.

Definition at line 138 of file TrajectoryPointFlags.h.

constexpr FlagIndex_t recob::TrajectoryPointFlagTraits::EndExperimentReservedFlags = 24
static

After-the-last flag reserved to experiment.

Definition at line 216 of file TrajectoryPointFlags.h.

constexpr FlagIndex_t recob::TrajectoryPointFlagTraits::EndTrackFlags = 16
static

After-the-last track flag index.

Definition at line 205 of file TrajectoryPointFlags.h.

constexpr FlagIndex_t recob::TrajectoryPointFlagTraits::EndTrajectoryFlags = 8
static

After-the-last trajectory flag index.

Definition at line 147 of file TrajectoryPointFlags.h.

constexpr FlagIndex_t recob::TrajectoryPointFlagTraits::EndUserReservedFlags = 32
static

After-the-last flag reserved to users.

Definition at line 228 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::ExcludedFromFit { 8 }
static

The point belongs to this track but it was not included in the fit because dubious in some sense.

Definition at line 169 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::HitIgnored { 0 }
static

Hit was not included for the computation of the trajectory.

Definition at line 116 of file TrajectoryPointFlags.h.

constexpr unsigned int recob::TrajectoryPointFlagTraits::MaxFlags = 32
static

Number of flags allocated (may be unused and unassigned).

Definition at line 61 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::Merged { 3 }
static

The hit might have contribution from particles other than this.

Definition at line 132 of file TrajectoryPointFlags.h.

const recob::TrajectoryPointFlagTraits::NameMap_t recob::TrajectoryPointFlagTraits::names = recob::TrajectoryPointFlagTraits::initNames()
staticprivate

Names of the flags.

Definition at line 260 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::NoPoint { 1 }
static

The trajectory point is not defined.

Definition at line 119 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::Reinterpreted { 10 }
static

The hit content has been elaborated before being used in the fit.

In this case, it is good practise for the fitting algorithm to associate the fitted point to the new hit. Nevertheless, a simpler code might assume that all associated hits are from the same data product, and fail to find the new one which will necessarily have to belong to a new hit collection.

If you find yourself in the situation where you consider setting this flag, it may be useful to consult with LArSoft experts to determine if further support is needed for your use case.

Definition at line 187 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::Rejected { 9 }
static

The hit is extraneous to this track.

Definition at line 172 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::Shared { 6 }
static

The hit is known to be associated also to another trajectory.

Definition at line 141 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::Suspicious { 2 }
static

The point reconstruction is somehow questionable.

See also
Merged, DeltaRay

For example, the hit might look ambiguous but there is no evidence of another track nearby or a δ ray emission. Reconstruction of the point might be biased, but we can't guess which type of bias we have.

Definition at line 129 of file TrajectoryPointFlags.h.

constexpr Flag_t recob::TrajectoryPointFlagTraits::TrackReserved1 { 15 }
static

Reserved for a future track flag.

Definition at line 202 of file TrajectoryPointFlags.h.

constexpr Flag_t recob::TrajectoryPointFlagTraits::TrackReserved2 { 14 }
static

Reserved for a future track flag.

Definition at line 199 of file TrajectoryPointFlags.h.

constexpr Flag_t recob::TrajectoryPointFlagTraits::TrackReserved3 { 13 }
static

Reserved for a future track flag.

Definition at line 196 of file TrajectoryPointFlags.h.

constexpr Flag_t recob::TrajectoryPointFlagTraits::TrackReserved4 { 12 }
static

Reserved for a future track flag.

Definition at line 193 of file TrajectoryPointFlags.h.

constexpr Flag_t recob::TrajectoryPointFlagTraits::TrackReserved5 { 11 }
static

Reserved for a future track flag.

Definition at line 190 of file TrajectoryPointFlags.h.

constexpr recob::TrajectoryPointFlagTraits::Flag_t recob::TrajectoryPointFlagTraits::TrajReserved1 { 7 }
static

Reserved for a future trajectory flag.

Definition at line 144 of file TrajectoryPointFlags.h.


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