All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KHitContainerWireX.cxx
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 ///
3 /// \file KHitContainerWireX.cxx
4 ///
5 /// \brief A KHitContainer for KHitWireX type measurements.
6 ///
7 /// \author H. Greenlee
8 ///
9 ////////////////////////////////////////////////////////////////////////
10 
11 #include <map>
12 
13 #include "art/Framework/Services/Registry/ServiceHandle.h"
14 #include "cetlib_except/exception.h"
15 
19 
20 namespace trkf {
21 
22  /// Fill container.
23  ///
24  /// Arguments:
25  ///
26  /// hits - RecoBase/Hit collection.
27  /// only_plane - Choose hits from this plane if >= 0.
28  ///
29  /// This method converts the hits in the input collection into
30  /// KHitWireX objects and inserts them into the base class. Hits
31  /// corresponding to the same readout wire are grouped together as
32  /// KHitGroup objects.
33  ///
34  void
36  const art::PtrVector<recob::Hit>& hits,
37  int only_plane)
38  {
39  // Get services.
40 
41  art::ServiceHandle<geo::Geometry const> geom;
42 
43  // Make a temporary map from channel number to KHitGroup objects.
44  // The KHitGroup pointers are borrowed references to KHitGroup
45  // objects stored by value in the base class.
46 
47  std::map<unsigned int, KHitGroup*> group_map;
48 
49  // Loop over hits.
50 
51  for (art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end();
52  ++ihit) {
53  const recob::Hit& hit = **ihit;
54 
55  // Extract the wire id from the Hit.
56  geo::WireID hitWireID = hit.WireID();
57 
58  uint32_t channel = hit.Channel();
59 
60  // Choose plane.
61  if (only_plane >= 0 && hitWireID.Plane != (unsigned int)(only_plane)) continue;
62 
63  // See if we need to make a new KHitGroup.
64 
65  KHitGroup* pgr = 0;
66  if (group_map.count(channel) == 0) {
67  getUnsorted().push_back(KHitGroup());
68  pgr = &(getUnsorted().back());
69  group_map[channel] = pgr;
70  }
71  else
72  pgr = group_map[channel];
73  if (!pgr) {
74  throw cet::exception("KHitContainerWireX")
75  << __func__ << ": no group map for channel " << channel << "\n";
76  }
77 
78  pgr->addHit(std::make_shared<KHitWireX>(detProp, *ihit, pgr->getSurface()));
79  }
80  }
81 
82 } // end namespace trkf
void fill(const detinfo::DetectorPropertiesData &clock_data, const art::PtrVector< recob::Hit > &hits, int only_plane) override
A KHitContainer for KHitWireX type measurements.
geo::WireID WireID() const
Definition: Hit.h:233
Kalman filter wire-time measurement on a SurfWireX surface.
process_name hit
Definition: cheaterreco.fcl:51
const std::list< KHitGroup > & getUnsorted() const
Definition: KHitContainer.h:75
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
void addHit(const std::shared_ptr< const KHitBase > &hit)
Add a mesaurement into the colleciton.
Definition: KHitGroup.cxx:39
const std::shared_ptr< const Surface > & getSurface() const
Surface accessor.
Definition: KHitGroup.h:50
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:230
art framework interface to geometry description
auto const detProp