All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cluster::ClusterCrawler Class Reference
Inheritance diagram for cluster::ClusterCrawler:

Public Member Functions

 ClusterCrawler (fhicl::ParameterSet const &pset)
 

Private Member Functions

void produce (art::Event &evt) override
 

Private Attributes

hit::CCHitFinderAlg fCCHFAlg
 
ClusterCrawlerAlg fCCAlg
 
std::string fCalDataModuleLabel
 label of module producing input wires More...
 

Detailed Description

Definition at line 39 of file ClusterCrawler_module.cc.

Constructor & Destructor Documentation

cluster::ClusterCrawler::ClusterCrawler ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 54 of file ClusterCrawler_module.cc.

55  : EDProducer{pset}
56  , fCCHFAlg(pset.get<fhicl::ParameterSet>("CCHitFinderAlg"))
57  , fCCAlg(pset.get<fhicl::ParameterSet>("ClusterCrawlerAlg"))
58  , fCalDataModuleLabel(pset.get<std::string>("CalDataModuleLabel"))
59  {
60  mf::LogWarning("ClusterCrawler")
61  << "\nClusterCrawler module has been deprecated and will be removed."
62  "\nIt is now replaced by HitFinder and LineCluster modules.";
63 
64  // let HitCollectionAssociator declare that we are going to produce
65  // hits and associations with wires and raw digits
66  // (with no particular product label)
68 
69  produces<std::vector<recob::Cluster>>();
70  produces<std::vector<recob::Vertex>>();
71  produces<art::Assns<recob::Cluster, recob::Hit>>();
72  produces<art::Assns<recob::Cluster, recob::Vertex, unsigned short>>();
73  }
hit::CCHitFinderAlg fCCHFAlg
static void declare_products(art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.cxx:248
std::string fCalDataModuleLabel
label of module producing input wires

Member Function Documentation

void cluster::ClusterCrawler::produce ( art::Event &  evt)
overrideprivate

Definition at line 76 of file ClusterCrawler_module.cc.

77  {
78  // fetch the wires needed by CCHitFinder
79 
80  // make this accessible to ClusterCrawler_module
81  art::ValidHandle<std::vector<recob::Wire>> wireVecHandle =
82  evt.getValidHandle<std::vector<recob::Wire>>(fCalDataModuleLabel);
83 
84  // find hits in all planes
85  fCCHFAlg.RunCCHitFinder(*wireVecHandle);
86 
87  // extract the result of the algorithm (it's moved)
88  std::vector<recob::Hit> FirstHits = fCCHFAlg.YieldHits();
89 
90  auto const clock_data =
91  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
92  auto const det_prop =
93  art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clock_data);
94 
95  // look for clusters in all planes
96  fCCAlg.RunCrawler(clock_data, det_prop, FirstHits);
97 
98  auto FinalHits = std::make_unique<std::vector<recob::Hit>>(fCCAlg.YieldHits());
99 
100  art::ServiceHandle<geo::Geometry const> geo;
101 
102  // shcol contains the hit collection
103  // and its associations to wires and raw digits;
104  // we get the association to raw digits through wire associations
106  std::vector<recob::Cluster> sccol;
107  std::vector<recob::Vertex> sv3col;
108 
109  auto hc_assn = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
110  auto cv_assn = std::make_unique<art::Assns<recob::Cluster, recob::Vertex, unsigned short>>();
111 
112  std::vector<ClusterCrawlerAlg::ClusterStore> const& tcl = fCCAlg.GetClusters();
113 
114  std::vector<short> const& inClus = fCCAlg.GetinClus();
115 
116  // Consistency check
117  for (unsigned int icl = 0; icl < tcl.size(); ++icl) {
118  ClusterCrawlerAlg::ClusterStore const& clstr = tcl[icl];
119  if (clstr.ID < 0) continue;
120  geo::PlaneID planeID = ClusterCrawlerAlg::DecodeCTP(clstr.CTP);
121  unsigned short plane = planeID.Plane;
122  for (unsigned short ii = 0; ii < clstr.tclhits.size(); ++ii) {
123  unsigned int iht = clstr.tclhits[ii];
124  recob::Hit const& theHit = FinalHits->at(iht);
125  if (theHit.WireID().Plane != plane) {
126  std::cout << "CC: cluster-hit plane mis-match " << theHit.WireID().Plane << " " << plane
127  << " in cluster " << clstr.ID << " WT " << clstr.BeginWir << ":"
128  << (int)clstr.BeginTim << "\n";
129  return;
130  }
131  if (inClus[iht] != clstr.ID) {
132  std::cout << "CC: InClus mis-match " << inClus[iht] << " ID " << clstr.ID
133  << " in cluster " << icl << "\n";
134  return;
135  }
136  } // ii
137  } // icl
138 
139  // make 3D vertices
140  std::vector<ClusterCrawlerAlg::Vtx3Store> const& Vertices = fCCAlg.GetVertices();
141 
142  double xyz[3] = {0, 0, 0};
143  unsigned int vtxID = 0, end;
144  for (ClusterCrawlerAlg::Vtx3Store const& vtx3 : Vertices) {
145  // ignore incomplete vertices
146  if (vtx3.Ptr2D[0] < 0) continue;
147  if (vtx3.Ptr2D[1] < 0) continue;
148  if (vtx3.Ptr2D[2] < 0) continue;
149  ++vtxID;
150  xyz[0] = vtx3.X;
151  xyz[1] = vtx3.Y;
152  xyz[2] = vtx3.Z;
153  sv3col.emplace_back(xyz, vtxID);
154  } // 3D vertices
155  // convert Vertex vector to unique_ptrs
156  std::unique_ptr<std::vector<recob::Vertex>> v3col(
157  new std::vector<recob::Vertex>(std::move(sv3col)));
158 
159  // make the clusters and associations
160  float sumChg, sumADC;
161  unsigned int clsID = 0, nclhits;
162  for (unsigned int icl = 0; icl < tcl.size(); ++icl) {
163  ClusterCrawlerAlg::ClusterStore const& clstr = tcl[icl];
164  if (clstr.ID < 0) continue;
165  ++clsID;
166  sumChg = 0;
167  sumADC = 0;
168  geo::PlaneID planeID = ClusterCrawlerAlg::DecodeCTP(clstr.CTP);
169  unsigned short plane = planeID.Plane;
170  nclhits = clstr.tclhits.size();
171  std::vector<unsigned int> clsHitIndices;
172  // correct the hit indices to refer to the valid hits that were just added
173  for (unsigned int itt = 0; itt < nclhits; ++itt) {
174  unsigned int iht = clstr.tclhits[itt];
175  recob::Hit const& hit = FinalHits->at(iht);
176  sumChg += hit.Integral();
177  sumADC += hit.SummedADC();
178  } // itt
179  // get the wire, plane from a hit
180  unsigned int iht = clstr.tclhits[0];
181 
182  geo::View_t view = FinalHits->at(iht).View();
183  sccol.emplace_back((float)clstr.BeginWir, // Start wire
184  0, // sigma start wire
185  clstr.BeginTim, // start tick
186  0, // sigma start tick
187  clstr.BeginChg, // start charge
188  clstr.BeginAng, // start angle
189  0, // start opening angle (0 for line-like clusters)
190  (float)clstr.EndWir, // end wire
191  0, // sigma end wire
192  clstr.EndTim, // end tick
193  0, // sigma end tick
194  clstr.EndChg, // end charge
195  clstr.EndAng, // end angle
196  0, // end opening angle (0 for line-like clusters)
197  sumChg, // integral
198  0, // sigma integral
199  sumADC, // summed ADC
200  0, // sigma summed ADC
201  nclhits, // n hits
202  0, // wires over hits
203  0, // width (0 for line-like clusters)
204  clsID, // ID
205  view, // view
206  planeID, // plane
207  recob::Cluster::Sentry // sentry
208  );
209  // make the cluster - hit association
210  if (!util::CreateAssn(
211  *this, evt, *hc_assn, sccol.size() - 1, clstr.tclhits.begin(), clstr.tclhits.end())) {
212  throw art::Exception(art::errors::ProductRegistrationFailure)
213  << "Failed to associate hit " << iht << " with cluster " << icl;
214  } // exception
215  // make the cluster - endpoint associations
216  if (clstr.BeginVtx >= 0) {
217  end = 0;
218  // See if this endpoint is associated with a 3D vertex
219  unsigned short vtxIndex = 0;
220  for (ClusterCrawlerAlg::Vtx3Store const& vtx3 : Vertices) {
221  // ignore incomplete vertices
222  if (vtx3.Ptr2D[0] < 0) continue;
223  if (vtx3.Ptr2D[1] < 0) continue;
224  if (vtx3.Ptr2D[2] < 0) continue;
225  if (vtx3.Ptr2D[plane] == clstr.BeginVtx) {
226  if (!util::CreateAssnD(*this, evt, *cv_assn, clsID - 1, vtxIndex, end)) {
227  throw art::Exception(art::errors::ProductRegistrationFailure)
228  << "Failed to associate cluster " << icl << " with vertex";
229  } // exception
230  break;
231  } // vertex match
232  ++vtxIndex;
233  } // 3D vertices
234  } // clstr.BeginVtx >= 0
235  if (clstr.EndVtx >= 0) {
236  end = 1;
237  // See if this endpoint is associated with a 3D vertex
238  unsigned short vtxIndex = 0;
239  for (ClusterCrawlerAlg::Vtx3Store const& vtx3 : Vertices) {
240  // ignore incomplete vertices
241  if (vtx3.Ptr2D[0] < 0) continue;
242  if (vtx3.Ptr2D[1] < 0) continue;
243  if (vtx3.Ptr2D[2] < 0) continue;
244  if (vtx3.Ptr2D[plane] == clstr.EndVtx) {
245  if (!util::CreateAssnD(*this, evt, *cv_assn, clsID - 1, vtxIndex, end)) {
246  throw art::Exception(art::errors::ProductRegistrationFailure)
247  << "Failed to associate cluster " << icl << " with endpoint";
248  } // exception
249  break;
250  } // vertex match
251  ++vtxIndex;
252  } // 3D vertices
253  } // clstr.BeginVtx >= 0
254  } // icl
255 
256  // convert cluster vector to unique_ptrs
257  std::unique_ptr<std::vector<recob::Cluster>> ccol(
258  new std::vector<recob::Cluster>(std::move(sccol)));
259 
260  shcol.use_hits(std::move(FinalHits));
261 
262  // clean up
264 
265  // move the hit collection and the associations into the event:
266  shcol.put_into(evt);
267  evt.put(std::move(ccol));
268  evt.put(std::move(hc_assn));
269  evt.put(std::move(v3col));
270  evt.put(std::move(cv_assn));
271 
272  } // produce
void RunCCHitFinder(std::vector< recob::Wire > const &Wires)
bool CreateAssnD(art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t &&data)
Creates a single one-to-one association with associated data.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
geo::WireID WireID() const
Definition: Hit.h:233
hit::CCHitFinderAlg fCCHFAlg
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::vector< ClusterStore > const & GetClusters() const
Returns a constant reference to the clusters found.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:224
process_name hit
Definition: cheaterreco.fcl:51
static const SentryArgument_t Sentry
An instance of the sentry object.
Definition: Cluster.h:182
static geo::PlaneID DecodeCTP(CTP_t CTP)
std::vector< recob::Hit > && YieldHits()
Returns (and loses) the collection of reconstructed hits.
A class handling a collection of hits and its associations.
Definition: HitCreator.h:692
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
std::string fCalDataModuleLabel
label of module producing input wires
std::vector< Vtx3Store > const & GetVertices() const
Returns a constant reference to the 3D vertices found.
void RunCrawler(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, std::vector< recob::Hit > const &srchits)
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
Definition: Hit.h:223
std::vector< short > const & GetinClus() const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
std::vector< recob::Hit > && YieldHits()
Returns (and loses) the collection of reconstructed hits.
TCEvent evt
Definition: DataStructs.cxx:8
BEGIN_PROLOG could also be cout

Member Data Documentation

std::string cluster::ClusterCrawler::fCalDataModuleLabel
private

label of module producing input wires

Definition at line 49 of file ClusterCrawler_module.cc.

ClusterCrawlerAlg cluster::ClusterCrawler::fCCAlg
private

Definition at line 48 of file ClusterCrawler_module.cc.

hit::CCHitFinderAlg cluster::ClusterCrawler::fCCHFAlg
private

Definition at line 47 of file ClusterCrawler_module.cc.


The documentation for this class was generated from the following file: