Falaise  4.0.1
SuperNEMO Software Toolkit
tracker_clustering_solution.h
Go to the documentation of this file.
1 /// \file falaise/snemo/datamodels/tracker_clustering_solution.h
2 /* Author (s) : François Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2012-03-05
4  * Last modified: 2014-01-27
5  *
6  * Description: A possible solution for the clustering of Geiger calibrated hits
7  */
8 
9 #ifndef FALAISE_SNEMO_DATAMODELS_TRACKER_CLUSTERING_SOLUTION_H
10 #define FALAISE_SNEMO_DATAMODELS_TRACKER_CLUSTERING_SOLUTION_H 1
11 
12 // Standard library:
13 #include <map>
14 #include <vector>
15 
16 // Third party:
17 // - Boost:
18 #include <boost/cstdint.hpp>
19 // - Bayeux/datatools:
20 #include <datatools/handle.h>
21 #include <datatools/properties.h>
22 
23 // This project:
25 
26 namespace snemo {
27 
28 namespace datamodel {
29 
30 /// \brief A collection of tracker clusters
31 /**
32  * A tracker clustering solution stores the possible result computed by a
33  * clustering algorithm from an original collection of tracker calibrated hits.
34  *
35  * Original collection of Geiger hits (handled by a 'calibrated_data' object):
36  *
37  * +------------------------+
38  * | o |
39  * | oo oo |
40  * | ooo ooooo |
41  * | ooooooo |
42  * | o o |
43  * | oo o |
44  * | oo |
45  * | o |
46  * +------------------------+
47  *
48  * A possible collection of clusters built from the source:
49  *
50  * +------------------------+
51  * | 1 | Legend: 1 : hits belonging to cluster #1
52  * | 11 11 | 0 : hits belonging to cluster #2
53  * | 111 11111 | U : unclustered hits
54  * | 1111111 |
55  * | 0 U |
56  * | 00 U |
57  * | 00 |
58  * | 0 |
59  * +------------------------+
60  *
61  * Another possible collection of clusters built from the source:
62  *
63  * +------------------------+
64  * | 0 | Legend: 0 : hits belonging to cluster #0
65  * | 11 00 | 1 : hits belonging to cluster #1
66  * | 111 00000 | U : unclustered hits
67  * | 1111100 |
68  * | 1 U |
69  * | 11 U |
70  * | 11 |
71  * | 1 |
72  * +------------------------+
73  *
74  * Yet another possible collection of clusters built from the source:
75  *
76  * +------------------------+
77  * | 0 | Legend: 0 : hits belonging to cluster #0
78  * | 11 00 | 1 : hits belonging to cluster #1
79  * | 111 00000 | 2 : hits belonging to cluster #2
80  * | 1111100 | U : unclustered hits
81  * | 2 U |
82  * | 22 U |
83  * | 22 |
84  * | 2 |
85  * +------------------------+
86  *
87  */
89  public:
90  /// Handle on tracker cluster
92 
93  /// Collection of handles on tracker clusters
94  typedef std::vector<cluster_handle_type> cluster_col_type;
95 
96  /// Handle on tracker cluster solution
98 
99  /// Collection of calibrated hit handles
101 
102  /// Dictionary of hit/cluster belonging
103  typedef std::map<int32_t, cluster_col_type> hit_belonging_col_type;
104 
105  /// Default constructor
107 
108  /// Default constructor
110 
111  /// Check if there is a valid solution ID
112  bool has_solution_id() const;
113 
114  /// Get the solution ID
115  int get_solution_id() const;
116 
117  /// Set the solution ID
118  void set_solution_id(int32_t);
119 
120  /// Invalidate the solution ID
121  void invalidate_solution_id();
122 
123  /// Return a mutable reference on the container of auxiliary properties
125 
126  /// Return a non mutable reference on the container of auxiliary properties
127  const datatools::properties &get_auxiliaries() const;
128 
129  /// Return a mutable reference on the container of clusters
131 
132  /// Return a non mutable reference on the container of clusters
133  const cluster_col_type &get_clusters() const;
134 
135  // /// Return a mutable reference on the container of delayed clusters
136  // cluster_col_type & grab_delayed_clusters() const;
137 
138  // /// Return a non mutable reference on the container of delayed clusters
139  // const cluster_col_type & get_delayed_clusters() const;
140 
141  /// Check if there is some unclustered hits
142  bool has_unclustered_hits() const;
143 
144  /// Return a mutable reference on the container of handles on unclustered calibrated tracker hits
146 
147  /// Return a non mutable reference on the container of handles on unclustered calibrated tracker
148  /// hits
150 
151  /// Empty the contents of the tracker cluster solution
152  void clear();
153 
154  /// Reset the tracker cluster solution(see clear)
155  void reset();
156 
157  /// Smart print
158  virtual void tree_dump(std::ostream &out_ = std::clog, const std::string &title_ = "",
159  const std::string &indent_ = "", bool inherit_ = false) const;
160 
161  /// Compute hit belonging
162  void compute_hit_belonging();
163 
164  /// Test if hit with given ID belongs to a cluster with a given ID
165  bool hit_belongs_to_cluster(int32_t hit_id, int32_t cluster_id_) const;
166 
167  /// Test if hit belongs to a cluster
169  const tracker_cluster &cluster_) const;
170 
171  /// Test if a given hit is clusterized
172  bool hit_is_clustered(const calibrated_tracker_hit &hit_) const;
173 
174  /// Test if a hit with given ID is clusterized
175  bool hit_is_clustered(int32_t hit_id_) const;
176 
177  /// Test if a given hit belongs to several clusters
179 
180  /// Test if a given hit with given ID belongs to several clusters
181  bool hit_belongs_to_several_clusters(int32_t hit_id_) const;
182 
183  /// Returns the hit belonging informations
185 
186  /// Clear the hit belonging informations
187  void reset_hit_belonging();
188 
189  /// Test if some hit belonging information is available
190  bool has_hit_belonging() const;
191 
192  /// Compute the hit belonging informations from a given clustering solution
194  hit_belonging_col_type &hbc_);
195 
196  /// Merge two clustering solutions in a single one (only if both are built from different sets of
197  /// hits)
198  static int merge_two_solutions_in_ones(const tracker_clustering_solution &source0_,
199  const tracker_clustering_solution &source1_,
200  tracker_clustering_solution &target_);
201 
202  /// Copy one clustering solution in another one
203  static int copy_one_solution_in_one(const tracker_clustering_solution &source_,
204  tracker_clustering_solution &target_);
205 
206  private:
207  int32_t _solution_id_; //!< Unique solution ID
208  cluster_col_type _clusters_; //!< Collection of handles on prompt Geiger hits clusters
209  hit_collection_type _unclustered_hits_; //!< Collection of handles on unclustered Geiger hits
210  datatools::properties _auxiliaries_; //!< List of auxiliary properties
211 
212  // Non persistent information :
213  hit_belonging_col_type _hit_belonging_; //!< List of clusters for each clustered hits
214 
216 };
217 
218 } // end of namespace datamodel
219 
220 } // end of namespace snemo
221 
222 // Class version:
223 // #include <boost/serialization/version.hpp>
224 // BOOST_CLASS_VERSION(snemo::datamodel::tracker_clustering_solution, 0)
225 
226 #endif // FALAISE_SNEMO_DATAMODELS_TRACKER_CLUSTERING_SOLUTION_H
227 
228 /*
229 ** Local Variables: --
230 ** mode: c++ --
231 ** c-file-style: "gnu" --
232 ** tab-width: 2 --
233 ** End: --
234 */
void set_solution_id(int32_t)
Set the solution ID.
tracker_cluster::handle_type cluster_handle_type
Handle on tracker cluster.
Definition: tracker_clustering_solution.h:91
void invalidate_solution_id()
Invalidate the solution ID.
static void compute_hit_belonging_from_solution(const tracker_clustering_solution &tcs_, hit_belonging_col_type &hbc_)
Compute the hit belonging informations from a given clustering solution.
const hit_collection_type & get_unclustered_hits() const
bool has_hit_belonging() const
Test if some hit belonging information is available.
A cluster of Geiger calibrated hits referenced by handles.
Definition: tracker_cluster.h:28
int get_solution_id() const
Get the solution ID.
void compute_hit_belonging()
Compute hit belonging.
virtual ~tracker_clustering_solution()
Default constructor.
#define DATATOOLS_SERIALIZATION_DECLARATION()
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
A collection of tracker clusters.
Definition: tracker_clustering_solution.h:88
void clear()
Empty the contents of the tracker cluster solution.
bool hit_is_clustered(const calibrated_tracker_hit &hit_) const
Test if a given hit is clusterized.
bool hit_belongs_to_several_clusters(const calibrated_tracker_hit &hit_) const
Test if a given hit belongs to several clusters.
Model of a calibrated tracker hit (Geiger regime)
Definition: calibrated_tracker_hit.h:35
static int copy_one_solution_in_one(const tracker_clustering_solution &source_, tracker_clustering_solution &target_)
Copy one clustering solution in another one.
calibrated_tracker_hit::collection_type hit_collection_type
Collection of calibrated hit handles.
Definition: tracker_clustering_solution.h:100
Definition: calo_tapered_scin_box_model.h:54
void reset_hit_belonging()
Clear the hit belonging informations.
static int merge_two_solutions_in_ones(const tracker_clustering_solution &source0_, const tracker_clustering_solution &source1_, tracker_clustering_solution &target_)
datatools::properties & grab_auxiliaries()
Return a mutable reference on the container of auxiliary properties.
const hit_belonging_col_type & get_hit_belonging() const
Returns the hit belonging informations.
datatools::handle< tracker_clustering_solution > handle_type
Handle on tracker cluster solution.
Definition: tracker_clustering_solution.h:97
std::map< int32_t, cluster_col_type > hit_belonging_col_type
Dictionary of hit/cluster belonging.
Definition: tracker_clustering_solution.h:103
bool has_solution_id() const
Check if there is a valid solution ID.
void reset()
Reset the tracker cluster solution(see clear)
std::vector< cluster_handle_type > cluster_col_type
Collection of handles on tracker clusters.
Definition: tracker_clustering_solution.h:94
hit_collection_type & grab_unclustered_hits()
Return a mutable reference on the container of handles on unclustered calibrated tracker hits.
cluster_col_type & grab_clusters()
Return a mutable reference on the container of clusters.
const cluster_col_type & get_clusters() const
Return a non mutable reference on the container of clusters.
bool has_unclustered_hits() const
Check if there is some unclustered hits.
std::vector< handle_type > collection_type
Alias for a collection of handles on calibrated tracker hits.
Definition: calibrated_tracker_hit.h:54
bool hit_belongs_to_cluster(int32_t hit_id, int32_t cluster_id_) const
Test if hit with given ID belongs to a cluster with a given ID.
const datatools::properties & get_auxiliaries() const
Return a non mutable reference on the container of auxiliary properties.