LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
dnn::SavePiMu Class Reference
Inheritance diagram for dnn::SavePiMu:
dnn::ImageMaker

Public Member Functions

 SavePiMu (fhicl::ParameterSet const &ps)
 
void saveImage (art::Event const &e, hep_hpc::hdf5::File &hdffile) override
 

Private Attributes

art::InputTag fTrackModuleLabel
 
art::InputTag fWireModuleLabel
 
art::InputTag fMCTruthLabel
 

Detailed Description

Definition at line 24 of file SavePiMu_tool.cc.

Constructor & Destructor Documentation

dnn::SavePiMu::SavePiMu ( fhicl::ParameterSet const &  ps)
explicit

Definition at line 36 of file SavePiMu_tool.cc.

References fMCTruthLabel, fWireModuleLabel, and fhicl::ParameterSet::get().

37  : fTrackModuleLabel{ps.get<art::InputTag>("TrackModuleLabel")}
38  , fWireModuleLabel{ps.get<art::InputTag>("WireModuleLabel")}
39  , fMCTruthLabel{ps.get<art::InputTag>("MCTruthLabel")}
40  {}
art::InputTag fTrackModuleLabel
art::InputTag fMCTruthLabel
art::InputTag fWireModuleLabel

Member Function Documentation

void dnn::SavePiMu::saveImage ( art::Event const &  e,
hep_hpc::hdf5::File &  hdffile 
)
overridevirtual

Implements dnn::ImageMaker.

Definition at line 42 of file SavePiMu_tool.cc.

References util::abs(), geo::GeometryCore::ChannelToWire(), DEFINE_ART_CLASS_TOOL, art::EventID::event(), fMCTruthLabel, fTrackModuleLabel, fWireModuleLabel, lar::sparse_vector< T >::get_ranges(), art::ProductRetriever::getHandle(), art::ProductRetriever::getProduct(), art::Event::id(), art::Event::run(), art::Event::subRun(), art::Event::time(), art::Timestamp::timeHigh(), and art::Timestamp::timeLow().

43  {
44 
46 
47  static Ntuple<unsigned int, unsigned int, unsigned int, double> evtids(
48  hdffile, "evtids", {"run", "subrun", "event", "evttime"});
49 
50  static auto image =
51  make_ntuple({hdffile, "image", 1000},
52  make_scalar_column<unsigned short>("label"),
53  make_column<float, 2>(
54  "adc", // 2 means each element is a 2-d array
55  {50, 50}, // extent of each array dimension
56  1024 * 1024 / (2500 * sizeof(float)), // chunk size
57  {PropertyList{H5P_DATASET_CREATE}(&H5Pset_shuffle)(&H5Pset_deflate, 6u)}));
58 
59  // Get event information
60  double evttime;
61 
62  art::Timestamp ts = e.time();
63  if (ts.timeHigh() == 0) {
64  TTimeStamp tts(ts.timeLow());
65  evttime = tts.AsDouble();
66  }
67  else {
68  TTimeStamp tts(ts.timeHigh(), ts.timeLow());
69  evttime = tts.AsDouble();
70  }
71 
72  // Get image information
73  // * tracks
74  auto const& tracks = e.getProduct<std::vector<recob::Track>>(fTrackModuleLabel);
75  auto trackListHandle = e.getHandle<std::vector<recob::Track>>(fTrackModuleLabel);
77 
78  // * wires
79  auto const& wires = e.getProduct<std::vector<recob::Wire>>(fWireModuleLabel);
80 
81  // * MC truth
82  auto const& mclist = e.getProduct<std::vector<simb::MCTruth>>(fMCTruthLabel);
83 
84  unsigned short flag = 999;
85  if (!mclist.empty()) {
86  auto particle = mclist[0].GetParticle(0);
87  if (std::abs(particle.PdgCode()) == 13) flag = 0;
88  if (std::abs(particle.PdgCode()) == 211) flag = 1;
89  }
90 
91  if (!tracks.empty()) {
92  auto trkend = tracks[0].End();
93  if (trkend.X() > -360 + 50 && trkend.X() < 360 - 50 && trkend.Y() > 50 &&
94  trkend.Y() < 610 - 50 && trkend.Z() > 50 && trkend.Z() < 710 - 50) {
95  if (fmthm.isValid()) {
96  auto vhit = fmthm.at(0);
97  auto vmeta = fmthm.data(0);
98  int ihit = -1;
99  int maxindex = -1;
100  for (size_t i = 0; i < vhit.size(); ++i) {
101  if (static_cast<int>(vmeta[i]->Index()) == std::numeric_limits<int>::max()) {
102  continue;
103  }
104  if (vhit[i]->WireID().Plane == 2) {
105  if (int(vmeta[i]->Index()) > maxindex) {
106  maxindex = vmeta[i]->Index();
107  ihit = i;
108  }
109  }
110  }
111  if (ihit >= 0) {
112  auto endwire = vhit[ihit]->WireID();
113  float endtime = vhit[ihit]->PeakTime();
114  float adc[50][50] = {{0.}};
115  for (auto& wire : wires) {
116  int channel = wire.Channel();
117  auto wireids = geom->ChannelToWire(channel);
118  if (wireids[0].Plane == 2 && wireids[0].TPC == endwire.TPC &&
119  wireids[0].Wire >= endwire.Wire - 25 && wireids[0].Wire < endwire.Wire + 25) {
120  int idx = wireids[0].Wire - endwire.Wire + 25;
121  const recob::Wire::RegionsOfInterest_t& signalROI = wire.SignalROI();
122  int lasttick = 0;
123  for (const auto& range : signalROI.get_ranges()) {
124  const auto& waveform = range.data();
125  // ROI start time
126  raw::TDCtick_t roiFirstBinTick = range.begin_index();
127  for (int i = lasttick; i < roiFirstBinTick; ++i) {
128  if (i >= int(endtime) - 25 && i < int(endtime) + 25) {
129  adc[idx][i - int(endtime) - 25] = 0;
130  }
131  }
132  lasttick = roiFirstBinTick;
133  for (size_t i = 0; i < waveform.size(); ++i) {
134  if (lasttick >= int(endtime) - 25 && lasttick < int(endtime) + 25) {
135  adc[idx][lasttick - int(endtime) + 25] = waveform[i];
136  ++lasttick;
137  }
138  }
139  }
140  for (int i = lasttick; i < 6000; ++i) {
141  if (i >= int(endtime) - 25 && i < int(endtime) + 25) {
142  adc[idx][i - int(endtime) + 25] = 0;
143  }
144  }
145  }
146  } // Loop over all wire signals
147  evtids.insert(e.run(), e.subRun(), e.id().event(), evttime);
148  image.insert(flag, &adc[0][0]);
149  }
150  }
151  }
152  }
153 
154  return;
155  }
constexpr std::uint32_t timeLow() const
Definition: Timestamp.h:29
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
art::InputTag fTrackModuleLabel
art::InputTag fMCTruthLabel
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:34
constexpr auto abs(T v)
Returns the absolute value of the argument.
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
art::InputTag fWireModuleLabel
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:25
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
Float_t e
Definition: plot.C:35
recob::tracking::Plane Plane
Definition: TrackState.h:17

Member Data Documentation

art::InputTag dnn::SavePiMu::fMCTruthLabel
private

Definition at line 33 of file SavePiMu_tool.cc.

Referenced by saveImage(), and SavePiMu().

art::InputTag dnn::SavePiMu::fTrackModuleLabel
private

Definition at line 31 of file SavePiMu_tool.cc.

Referenced by saveImage().

art::InputTag dnn::SavePiMu::fWireModuleLabel
private

Definition at line 32 of file SavePiMu_tool.cc.

Referenced by saveImage(), and SavePiMu().


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