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