TrajectoryPointFlags.cxx
Go to the documentation of this file.
1 /**
2  * @file TrajectoryPointFlags.cxx
3  * @brief Set of flags pertaining a point of the track (implementation file).
4  * @author Giuseppe Cerati (cerati@fnal.gov),
5  * Gianluca Petrillo (petrillo@fnal.gov)
6  * @date January 18, 2017
7  * @see TrajectoryPointFlags.h
8  *
9  */
10 
11 
12 #include "TrajectoryPointFlags.h"
13 
14 // C/C++ standard library
15 #include <ostream>
16 
17 
18 //------------------------------------------------------------------------------
19 //--- recob::TrajectoryPointFlagTraits
20 //---
21 
22 // TODO: The following definitions are temporary, until we figure out what is
23 // requiring them.
35 
36 
37 
38 //------------------------------------------------------------------------------
41  = recob::TrajectoryPointFlagTraits::initNames(); ///< Names of the flags
42 
43 
44 //------------------------------------------------------------------------------
47 {
48  return baseName + std::to_string(flag.index());
49 } // recob::TrajectoryPointFlagTraits::decorateFlagName()
50 
51 
52 //------------------------------------------------------------------------------
54  (Flag_t flag)
55  { return "<" + decorateFlagName("InvalidFlag", flag) + ">"; }
56 
57 
58 //------------------------------------------------------------------------------
60  NameMap_t& flagNames,
61  FlagIndex_t BeginFlags, FlagIndex_t EndFlags, std::string baseName
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()
74 
75 
76 //------------------------------------------------------------------------------
78  (NameMap_t& flagNames)
79 {
80 
83  "TrajectoryReserved"
84  );
86  flagNames, BeginTrackFlags, EndTrackFlags,
87  "TrackReserved"
88  );
91  "ExperimentFlag"
92  );
95  "UserFlag"
96  );
97 
98 } // recob::TrajectoryPointFlagTraits::initDefaultFlagsNames()
99 
100 
101 //------------------------------------------------------------------------------
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()
123 
124 
125 //------------------------------------------------------------------------------
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()
141 
142 
143 //------------------------------------------------------------------------------
144 std::ostream& recob::operator<<
145  (std::ostream& out, recob::TrajectoryPointFlags const& flags)
146  { flags.dump(out); return out; }
147 
148 //------------------------------------------------------------------------------
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.
std::string string
Definition: nybbler.cc:12
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.
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.
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
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 QCString baseName
Definition: scanner.cpp:10890
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
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.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
Set of flags pertaining a point of the track.