GCNHitGraphMaker_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: GCNHitGraphMaker
3 // Plugin Type: producer (art v3_05_00)
4 // File: GCNHitGraphMaker_module.cc
5 //
6 // Generated at Mon Apr 13 11:51:42 2020 by Jeremy Hewes using cetskelgen
7 // from cetlib version v3_10_00.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
24 
25 #include <memory>
26 
27 namespace cvn {
28 
29 
31  public:
32  explicit GCNHitGraphMaker(fhicl::ParameterSet const& p);
33 
34  GCNHitGraphMaker(GCNHitGraphMaker const&) = delete;
38 
39  void configure(fhicl::ParameterSet const& p);
40 
41  void produce(art::Event& e) override;
42 
43  private:
44 
46 
47  };
48 
49 
51  : EDProducer{p}
52  {
53  configure(p);
54  produces<std::vector<cvn::GCNGraph>>();
55  consumes<std::vector<recob::Hit>>(fHitModuleLabel);
56  }
57 
59  {
60  fHitModuleLabel = p.get<std::string>("HitModuleLabel");
61  }
62 
64  {
65  // Retrieve hits
66  std::vector<art::Ptr<recob::Hit>> hits;
67  auto hitHandle = e.getHandle<std::vector<recob::Hit>>(fHitModuleLabel);
68  if (!hitHandle) {
70  << "Could not find hits with module label " << fHitModuleLabel;
71  }
72  art::fill_ptr_vector(hits, hitHandle);
73 
74  // Create output
75  std::unique_ptr<std::vector<cvn::GCNGraph>> graphs(new std::vector<cvn::GCNGraph>(1));
76 
77  // Helper classes and services
78  cvn::PixelMapProducer pixelUtil;
80 
81  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(e);
82  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataFor(e, clockData);
83 
84  // Loop over hits
85  for (art::Ptr<recob::Hit> hit : hits) {
86 
87  // Get global coordinates
88  geo::WireID wireid = hit->WireID();
89  if (wireid.TPC%6 == 0 or wireid.TPC%6 == 5) continue; // skip dummy TPCs
90  unsigned int wire, plane;
91  double time;
92  pixelUtil.GetDUNE10ktGlobalWireTDC(detProp, wireid.Wire, hit->PeakTime(),
93  wireid.Plane, wireid.TPC, wire, plane, time);
94  std::vector<float> pos = {(float)plane, (float)wire, (float)time};
95  std::vector<float> feats = {hit->Integral(), hit->RMS(), (float)wireid.Wire,
96  hit->PeakTime(), (float)wireid.Plane, (float)wireid.TPC};
97 
98  // Get true particle
99  std::vector<sim::TrackIDE> ides = bt->HitToTrackIDEs(clockData, hit);
100  if (ides.size() == 0) continue; // skip hits with no truth
101  float trueID = abs(std::max_element(ides.begin(), ides.end(), [](const sim::TrackIDE &lhs,
102  const sim::TrackIDE &rhs) { return lhs.energy < rhs.energy; })->trackID);
103  std::vector<float> truth = {trueID};
104 
105  // Get
106  graphs->at(0).AddNode(pos, feats, truth);
107  // std::cout << "Adding node with plane " << plane << ", wire " << wire << ", time " << time
108  // << ", integral " << hit->Integral() << ", RMS " << hit->RMS() << ", raw wire " << wireid.Wire
109  // << ", raw time " << hit->PeakTime() << ", raw plane " << wireid.Plane << ", TPC " << wireid.TPC
110  // << " and true ID " << trueID << std::endl;
111  } // for hit
112 
113  e.put(std::move(graphs));
114 
115  }
116 
118 
119 } // namespace cvn
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
float energy
energy from the particle with this trackID [MeV]
Definition: SimChannel.h:28
Utility class for truth labels.
void configure(fhicl::ParameterSet const &p)
void GetDUNE10ktGlobalWireTDC(detinfo::DetectorPropertiesData const &detProp, unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
T abs(T value)
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
bt
Definition: tracks.py:83
def move(depos, offset)
Definition: depos.py:107
T get(std::string const &key) const
Definition: ParameterSet.h:271
p
Definition: test.py:223
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
void produce(art::Event &e) override
Detector simulation of raw signals on wires.
GCNHitGraphMaker(fhicl::ParameterSet const &p)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Declaration of signal hit object.
GCNHitGraphMaker & operator=(GCNHitGraphMaker const &)=delete
PixelMapProducer for CVN.
GCNGraph for GCN.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
Producer algorithm for PixelMap, input to CVN neural net.
Ionization energy from a Geant4 track.
Definition: SimChannel.h:25