Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
nnet::ParticleDecayId Class Reference
Inheritance diagram for nnet::ParticleDecayId:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  Config
 

Public Types

using Parameters = art::EDProducer::Table< Config >
 
- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 

Public Member Functions

 ParticleDecayId (Parameters const &p)
 
 ParticleDecayId (ParticleDecayId const &)=delete
 
 ParticleDecayId (ParticleDecayId &&)=delete
 
ParticleDecayIdoperator= (ParticleDecayId const &)=delete
 
ParticleDecayIdoperator= (ParticleDecayId &&)=delete
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void produce (art::Event &e) override
 
bool DetectDecay (detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< recob::Wire > &wires, const std::vector< art::Ptr< recob::Hit >> &hits, std::map< size_t, TVector3 > &spoints, std::vector< std::pair< TVector3, double >> &result)
 

Private Attributes

PointIdAlg fPointIdAlg
 
art::InputTag fWireProducerLabel
 
art::InputTag fTrackModuleLabel
 
double fRoiThreshold
 
double fPointThreshold
 
int fSkipView
 

Additional Inherited Members

- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 36 of file ParticleDecayId_module.cc.

Member Typedef Documentation

Definition at line 65 of file ParticleDecayId_module.cc.

Constructor & Destructor Documentation

nnet::ParticleDecayId::ParticleDecayId ( ParticleDecayId::Parameters const &  config)
explicit

Definition at line 94 of file ParticleDecayId_module.cc.

96  , fPointIdAlg(config().PointIdAlg())
97  , fWireProducerLabel(config().WireLabel())
98  , fTrackModuleLabel(config().TrackModuleLabel())
99  , fRoiThreshold(config().RoiThreshold())
100  , fPointThreshold(config().PointThreshold())
101  , fSkipView(config().SkipView())
102  {
103  produces<std::vector<recob::Vertex>>();
104  produces<art::Assns<recob::Vertex, recob::Track>>();
105  }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
static Config * config
Definition: config.cpp:1054
nnet::ParticleDecayId::ParticleDecayId ( ParticleDecayId const &  )
delete
nnet::ParticleDecayId::ParticleDecayId ( ParticleDecayId &&  )
delete

Member Function Documentation

bool nnet::ParticleDecayId::DetectDecay ( detinfo::DetectorClocksData const &  clockData,
detinfo::DetectorPropertiesData const &  detProp,
const std::vector< recob::Wire > &  wires,
const std::vector< art::Ptr< recob::Hit >> &  hits,
std::map< size_t, TVector3 > &  spoints,
std::vector< std::pair< TVector3, double >> &  result 
)
private

Definition at line 170 of file ParticleDecayId_module.cc.

176  {
177  const size_t nviews = 3;
178 
179  std::vector<art::Ptr<recob::Hit>> wire_drift[nviews];
180  for (size_t i = 0; i < hits.size(); ++i) // split hits between views
181  {
182  wire_drift[hits[i]->View()].push_back(hits[i]);
183  }
184 
185  std::vector<float> outputs[nviews];
186  for (size_t v = 0; v < nviews;
187  ++v) // calculate nn outputs for each view (hopefully not changing cryo/tpc many times)
188  {
189  outputs[v].resize(wire_drift[v].size(), 0);
190  for (size_t i = 0; i < wire_drift[v].size(); ++i) {
191  int tpc = wire_drift[v][i]->WireID().TPC;
192  int cryo = wire_drift[v][i]->WireID().Cryostat;
193 
194  fPointIdAlg.setWireDriftData(clockData, detProp, wires, v, tpc, cryo);
195 
196  outputs[v][i] = fPointIdAlg.predictIdVector(wire_drift[v][i]->WireID().Wire,
197  wire_drift[v][i]->PeakTime())[0]; // p(decay)
198  }
199  }
200 
201  std::vector<std::pair<size_t, float>> candidates2d[nviews];
202  std::vector<std::pair<TVector3, float>> candidates3d[nviews];
203  for (size_t v = 0; v < nviews; ++v) {
204  size_t idx = 0;
205  while (idx < outputs[v].size()) {
206  if (outputs[v][idx] > fRoiThreshold) {
207  size_t ci = idx;
208  float max = outputs[v][idx];
209  ++idx;
210 
211  while ((idx < outputs[v].size()) && (outputs[v][idx] > fRoiThreshold)) {
212  if (outputs[v][idx] > max) {
213  max = outputs[v][idx];
214  ci = idx;
215  }
216  ++idx;
217  }
218  candidates2d[v].emplace_back(ci, max);
219  candidates3d[v].emplace_back(spoints[wire_drift[v][ci].key()], max);
220  }
221  else
222  ++idx;
223  }
224  }
225 
226  double min_dist =
227  2.0; // [cm], threshold for today to distinguish between two different candidates,
228  // if belo threshold, then use 3D point corresponding to higher cnn output
229 
230  // need coincidence of high cnn out in two views, then look if there is another close candidate
231  // and again select by cnn output value, would like to have few strong candidates
232  bool found = false;
233  for (size_t v = 0; v < nviews - 1; ++v) {
234  for (size_t i = 0; i < candidates3d[v].size(); ++i) {
235  TVector3 c0(candidates3d[v][i].first);
236  float p0 = candidates3d[v][i].second;
237 
238  for (size_t u = v + 1; u < nviews; ++u) {
239  for (size_t j = 0; j < candidates3d[v].size(); ++j) {
240  TVector3 c1(candidates3d[v][j].first);
241  float p1 = candidates3d[v][j].second;
242 
243  if ((c0 - c1).Mag() < min_dist) {
244  TVector3 c(c0);
245  if (p1 > p0) { c = c1; }
246  double p = p0 * p1;
247 
248  if (p > fPointThreshold) {
249  double d, dmin = min_dist;
250  size_t kmin = 0;
251  for (size_t k = 0; k < result.size(); ++k) {
252  d = (result[k].first - c).Mag();
253  if (d < dmin) {
254  dmin = d;
255  kmin = k;
256  }
257  }
258  if (dmin < min_dist) {
259  if (result[kmin].second < p) // replace previously found point
260  {
261  result[kmin].first = c;
262  result[kmin].second = p;
263  found = true;
264  }
265  }
266  else // nothing close in the list, add new point
267  {
268  result.emplace_back(c, p);
269  found = true;
270  }
271  } // if (p > fPointThreshold)
272  } // coincidence: points from views u and v are close
273  } // loop over points in view u
274  } // loop over views u
275  } // loop over points in view v
276  } // loop over views v
277  return found;
278  }
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
std::vector< float > predictIdVector(unsigned int wire, float drift) const
calculate multi-class probabilities for [wire, drift] point
Definition: PointIdAlg.cxx:221
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
def key(type, name=None)
Definition: graph.py:13
p
Definition: test.py:223
static int max(int a, int b)
bool setWireDriftData(const detinfo::DetectorClocksData &clock_data, const detinfo::DetectorPropertiesData &det_prop, const std::vector< recob::Wire > &wires, unsigned int plane, unsigned int tpc, unsigned int cryo)
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
ParticleDecayId& nnet::ParticleDecayId::operator= ( ParticleDecayId const &  )
delete
ParticleDecayId& nnet::ParticleDecayId::operator= ( ParticleDecayId &&  )
delete
void nnet::ParticleDecayId::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 109 of file ParticleDecayId_module.cc.

110  {
111  std::cout << std::endl << "event " << evt.id().event() << std::endl;
112 
113  auto vtxs = std::make_unique<std::vector<recob::Vertex>>();
114  auto vtx2trk = std::make_unique<art::Assns<recob::Vertex, recob::Track>>();
115 
116  auto wireHandle = evt.getValidHandle<std::vector<recob::Wire>>(fWireProducerLabel);
117  auto trkListHandle = evt.getValidHandle<std::vector<recob::Track>>(fTrackModuleLabel);
118  auto spListHandle = evt.getValidHandle<std::vector<recob::SpacePoint>>(fTrackModuleLabel);
119 
120  art::FindManyP<recob::Hit> hitsFromTracks(trkListHandle, evt, fTrackModuleLabel);
121  art::FindManyP<recob::SpacePoint> spFromTracks(trkListHandle, evt, fTrackModuleLabel);
122  art::FindManyP<recob::Hit> hitsFromSPoints(spListHandle, evt, fTrackModuleLabel);
123 
124  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
125  auto const detProp =
127 
128  std::vector<std::pair<TVector3, double>> decays;
129  for (size_t i = 0; i < hitsFromTracks.size(); ++i) {
130  auto hits = hitsFromTracks.at(i);
131  auto spoints = spFromTracks.at(i);
132  if (hits.empty()) continue;
133 
134  std::map<size_t, TVector3> trkSpacePoints;
135  for (const auto& p : spoints) {
136  auto sp_hits = hitsFromSPoints.at(p.key());
137  for (const auto& h : sp_hits) {
138  trkSpacePoints[h.key()] = TVector3(p->XYZ()[0], p->XYZ()[1], p->XYZ()[2]);
139  }
140  }
141 
142  DetectDecay(clockData, detProp, *wireHandle, hits, trkSpacePoints, decays);
143  }
144 
145  double xyz[3];
146  for (const auto& p3d : decays) {
147 
148  xyz[0] = p3d.first.X();
149  xyz[1] = p3d.first.Y();
150  xyz[2] = p3d.first.Z();
151  std::cout << " detected: [" << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
152  << "] p:" << p3d.second << std::endl;
153 
154  size_t vidx = vtxs->size();
155  vtxs->push_back(recob::Vertex(xyz, vidx));
156 
157  // to do: assn to eg. appropriate track
158  // selected among set of connected tracks
159  //art::Ptr<recob::Track> tptr(trkListHandle, i);
160  //art::Ptr<recob::Vertex> vptr(vid, vidx, evt.productGetter(vid));
161  //vtx2trk->addSingle(vptr, tptr);
162  }
163 
164  evt.put(std::move(vtxs));
165  evt.put(std::move(vtx2trk));
166  }
unsigned int event
Definition: DataStructs.h:636
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
def move(depos, offset)
Definition: depos.py:107
p
Definition: test.py:223
bool DetectDecay(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< recob::Wire > &wires, const std::vector< art::Ptr< recob::Hit >> &hits, std::map< size_t, TVector3 > &spoints, std::vector< std::pair< TVector3, double >> &result)
TCEvent evt
Definition: DataStructs.cxx:7
QTextStream & endl(QTextStream &s)

Member Data Documentation

PointIdAlg nnet::ParticleDecayId::fPointIdAlg
private

Definition at line 83 of file ParticleDecayId_module.cc.

double nnet::ParticleDecayId::fPointThreshold
private

Definition at line 88 of file ParticleDecayId_module.cc.

double nnet::ParticleDecayId::fRoiThreshold
private

Definition at line 88 of file ParticleDecayId_module.cc.

int nnet::ParticleDecayId::fSkipView
private

Definition at line 90 of file ParticleDecayId_module.cc.

art::InputTag nnet::ParticleDecayId::fTrackModuleLabel
private

Definition at line 86 of file ParticleDecayId_module.cc.

art::InputTag nnet::ParticleDecayId::fWireProducerLabel
private

Definition at line 85 of file ParticleDecayId_module.cc.


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