LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
nnet::PointIdEffTest Class Reference
Inheritance diagram for nnet::PointIdEffTest:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 

Public Types

enum  EId { kShower = 0, kTrack = 1, kMichel = 2 }
 
using Parameters = art::EDAnalyzer::Table< Config >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 PointIdEffTest (Parameters const &config)
 
 PointIdEffTest (PointIdEffTest const &)=delete
 
 PointIdEffTest (PointIdEffTest &&)=delete
 
PointIdEffTestoperator= (PointIdEffTest const &)=delete
 
PointIdEffTestoperator= (PointIdEffTest &&)=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)
 
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)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResults > getTriggerResults (Event const &e) const
 
ConsumesCollector & consumesCollector ()
 
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 ()
 

Private Member Functions

void beginRun (const art::Run &run) override
 
void beginJob () override
 
void endJob () override
 
void analyze (art::Event const &e) override
 
void cleanup ()
 
void countTruthDep (const std::vector< sim::SimChannel > &channels, float &emLike, float &trackLike) const
 
void countPfpDep (detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< recob::PFParticle > &pfparticles, const art::FindManyP< recob::Cluster > &pfpclus, const art::FindManyP< recob::Hit > &cluhits, float &emLike, float &trackLike) const
 
bool isMuonDecaying (const simb::MCParticle &particle, const std::unordered_map< int, const simb::MCParticle * > &particleMap) const
 
int testCNN (detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< sim::SimChannel > &channels, const std::vector< art::Ptr< recob::Hit >> &hits, const std::array< float, MVA_LENGTH > &cnn_out, const std::vector< anab::FeatureVector< MVA_LENGTH >> &hit_outs, size_t cidx)
 

Private Attributes

int fRun
 
int fEvent
 
float fMcDepEM
 
float fMcDepTrack
 
float fMcFractionEM
 
float fPfpDepEM
 
float fPfpDepTrack
 
float fHitEM_0p5
 
float fHitTrack_0p5
 
float fHitMichel_0p5
 
float fHitMcFractionEM
 
float fHitEM_mc
 
float fpEM
 
float fHitMichel_mc
 
float fpMichel_hit
 
float fpMichel_cl
 
float fOutTrk
 
float fOutEM
 
float fOutNone
 
float fHitEM_0p85
 
float fHitTrack_0p85
 
float fTotHit
 
float fCleanHit
 
float fHitsEM_OK_0p5 [100]
 
float fHitsTrack_OK_0p5 [100]
 
float fHitsMichel_OK_0p5 [100]
 
float fHitsMichel_False_0p5 [100]
 
float fHitsEM_OK_0p85 [100]
 
float fHitsTrack_OK_0p85 [100]
 
float fHitRecoEM [100]
 
float fHitRecoFractionEM [100]
 
int fMcPid
 
int fClSize
 
float fPidValue
 
int fTrkOk [100]
 
int fTrkBad [100]
 
int fShOk [100]
 
int fShBad [100]
 
int fNone
 
int fTotal
 
double fElectronsToGeV
 
int fTrkLikeIdx
 
int fEmLikeIdx
 
int fNoneIdx
 
int fMichelLikeIdx
 
TTree * fEventTree
 
TTree * fClusterTree
 
TTree * fHitTree
 
std::ofstream fHitsOutFile
 
unsigned int fView
 
std::unordered_map< int, const simb::MCParticle * > fParticleMap
 
calo::CalorimetryAlg fCalorimetryAlg
 
art::InputTag fSimulationProducerLabel
 
art::InputTag fPfpModuleLabel
 
art::InputTag fNNetModuleLabel
 
bool fSaveHitsFile
 

Detailed Description

Definition at line 60 of file PointIdEffTest_module.cc.

Member Typedef Documentation

Definition at line 22 of file EDAnalyzer.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 171 of file PointIdEffTest_module.cc.

172  : art::EDAnalyzer(config)
173  , fMcPid(-1)
174  , fClSize(0)
175  , fTrkLikeIdx(-1)
176  , fEmLikeIdx(-1)
177  , fNoneIdx(-1)
178  , fMichelLikeIdx(-1)
179  , fView(config().View())
180  , fCalorimetryAlg(config().CalorimetryAlg())
181  , fSimulationProducerLabel(config().SimModuleLabel())
182  , fPfpModuleLabel(config().PfpModuleLabel())
183  , fNNetModuleLabel(config().NNetModuleLabel())
184  , fSaveHitsFile(config().SaveHitsFile())
185 {}
art::InputTag fSimulationProducerLabel
calo::CalorimetryAlg fCalorimetryAlg
nnet::PointIdEffTest::PointIdEffTest ( PointIdEffTest const &  )
delete
nnet::PointIdEffTest::PointIdEffTest ( PointIdEffTest &&  )
delete

Member Function Documentation

void nnet::PointIdEffTest::analyze ( art::Event const &  e)
overrideprivatevirtual

Implements art::EDAnalyzer.

Definition at line 311 of file PointIdEffTest_module.cc.

References cleanup(), countPfpDep(), countTruthDep(), anab::MVAReader< T, N >::create(), e, art::EventID::event(), fCleanHit, fEmLikeIdx, fEvent, fEventTree, fHitEM_0p5, fHitEM_0p85, fHitMcFractionEM, fHitRecoEM, fHitRecoFractionEM, fHitsEM_OK_0p5, fHitsEM_OK_0p85, fHitsTrack_OK_0p5, fHitsTrack_OK_0p85, fHitTrack_0p5, fHitTrack_0p85, fMcDepEM, fMcDepTrack, fMcFractionEM, fMichelLikeIdx, fNNetModuleLabel, fNoneIdx, fParticleMap, fPfpDepEM, fPfpDepTrack, fPfpModuleLabel, fRun, fSimulationProducerLabel, fTotHit, fTrkLikeIdx, fView, art::ProductRetriever::getByLabel(), anab::FVectorReader< T, N >::getIndex(), art::ProductRetriever::getValidHandle(), hits(), art::Event::id(), anab::MVAReader< T, N >::outputs(), geo::PlaneID::Plane, recob::Cluster::Plane(), art::Event::run(), and testCNN().

312 {
313  cleanup(); // remove everything from members
314 
315  fRun = e.run();
316  fEvent = e.id().event();
317 
318  // access to MC information
319 
320  // MC particles list
321  auto particleHandle = e.getValidHandle<std::vector<simb::MCParticle>>(fSimulationProducerLabel);
322  for (auto const& particle : *particleHandle) {
323  fParticleMap[particle.TrackId()] = &particle;
324  }
325 
326  // SimChannels
327  auto simChannelHandle = e.getValidHandle<std::vector<sim::SimChannel>>(fSimulationProducerLabel);
328  countTruthDep(*simChannelHandle, fMcDepEM, fMcDepTrack);
329 
330  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
331  auto const detProp =
333 
334  // PFParticle selection results
336  if (e.getByLabel(fPfpModuleLabel, pfpHandle)) {
337  auto cluHandle = e.getValidHandle<std::vector<recob::Cluster>>(fPfpModuleLabel);
338  const art::FindManyP<recob::Cluster> clusFromPfps(pfpHandle, e, fPfpModuleLabel);
339  const art::FindManyP<recob::Hit> hitsFromClus(cluHandle, e, fPfpModuleLabel);
340  countPfpDep(
341  clockData, detProp, *pfpHandle, clusFromPfps, hitsFromClus, fPfpDepEM, fPfpDepTrack);
342  }
343 
344  // output from cnn's
345 
347  e, fNNetModuleLabel); // hit-by-hit outpus just to be dumped to file for debugging
348  fTrkLikeIdx = hitResults.getIndex("track");
349  fEmLikeIdx = hitResults.getIndex("em");
350  fNoneIdx = hitResults.getIndex("none");
351  fMichelLikeIdx = hitResults.getIndex("michel");
352  if ((fTrkLikeIdx < 0) || (fEmLikeIdx < 0)) {
353  throw cet::exception("PointIdEffTest")
354  << "No em/track labeled columns in MVA data products." << std::endl;
355  }
356 
358  e, fNNetModuleLabel); // outputs for clusters recovered in not-throwing way
359  if (cluResults) {
360  const art::FindManyP<recob::Hit> hitsFromClusters(
361  cluResults->dataHandle(), e, cluResults->dataTag());
362 
363  for (size_t c = 0; c < cluResults->size(); ++c) {
364  const recob::Cluster& clu = cluResults->item(c);
365 
366  if (clu.Plane().Plane != fView) continue;
367 
368  const std::vector<art::Ptr<recob::Hit>>& hits = hitsFromClusters.at(c);
369  std::array<float, MVA_LENGTH> cnn_out = cluResults->getOutput(c);
370 
371  testCNN(clockData,
372  detProp,
373  *simChannelHandle,
374  hits,
375  cnn_out,
376  hitResults.outputs(),
377  c); // test hits in the cluster
378  }
379 
380  if (fTotHit > 0)
382  else
383  fCleanHit = 0;
384 
385  double totMcDep = fMcDepEM + fMcDepTrack;
386  if (totMcDep)
387  fMcFractionEM = fMcDepEM / totMcDep;
388  else
389  fMcFractionEM = 0;
390 
391  double totEmTrk0p5 = fHitEM_0p5 + fHitTrack_0p5;
392  if (totEmTrk0p5 > 0)
393  fHitMcFractionEM = fHitEM_0p5 / totEmTrk0p5;
394  else
395  fHitMcFractionEM = 0;
396 
397  for (size_t i = 0; i < 100; ++i) {
398  if (fHitEM_0p5 > 0)
400  else
401  fHitsEM_OK_0p5[i] = 0;
402 
403  if (fHitTrack_0p5 > 0)
405  else
406  fHitsTrack_OK_0p5[i] = 0;
407 
408  if (fHitEM_0p85 > 0)
410  else
411  fHitsEM_OK_0p85[i] = 0;
412 
413  if (fHitTrack_0p85 > 0)
415  else
416  fHitsTrack_OK_0p85[i] = 0;
417 
418  if (totEmTrk0p5 > 0)
419  fHitRecoFractionEM[i] = fHitRecoEM[i] / totEmTrk0p5;
420  else
421  fHitRecoFractionEM[i] = 0;
422  }
423 
424  fEventTree->Fill();
425  }
426  else {
427  mf::LogWarning("TrainingDataAlg") << "MVA FOR CLUSTERS NOT FOUND";
428  }
429 
430  cleanup(); // remove everything from members
431 }
art::InputTag fSimulationProducerLabel
void countPfpDep(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< recob::PFParticle > &pfparticles, const art::FindManyP< recob::Cluster > &pfpclus, const art::FindManyP< recob::Hit > &cluhits, float &emLike, float &trackLike) const
Set of hits with a 2D structure.
Definition: Cluster.h:69
void countTruthDep(const std::vector< sim::SimChannel > &channels, float &emLike, float &trackLike) const
geo::PlaneID Plane() const
Returns the plane ID this cluster lies on.
Definition: Cluster.h:717
std::unordered_map< int, const simb::MCParticle * > fParticleMap
void hits()
Definition: readHits.C:15
int testCNN(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< sim::SimChannel > &channels, const std::vector< art::Ptr< recob::Hit >> &hits, const std::array< float, MVA_LENGTH > &cnn_out, const std::vector< anab::FeatureVector< MVA_LENGTH >> &hit_outs, size_t cidx)
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:35
static std::unique_ptr< MVAReader > create(const art::Event &evt, const art::InputTag &tag)
Definition: MVAReader.h:108
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void nnet::PointIdEffTest::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 193 of file PointIdEffTest_module.cc.

References fCleanHit, fClSize, fClusterTree, fEvent, fEventTree, fHitEM_0p5, fHitEM_0p85, fHitEM_mc, fHitMcFractionEM, fHitMichel_0p5, fHitMichel_mc, fHitRecoEM, fHitRecoFractionEM, fHitsEM_OK_0p5, fHitsEM_OK_0p85, fHitsMichel_False_0p5, fHitsMichel_OK_0p5, fHitsOutFile, fHitsTrack_OK_0p5, fHitsTrack_OK_0p85, fHitTrack_0p5, fHitTrack_0p85, fHitTree, fMcDepEM, fMcDepTrack, fMcFractionEM, fMcPid, fNone, fOutEM, fOutNone, fOutTrk, fpEM, fPfpDepEM, fPfpDepTrack, fPidValue, fpMichel_cl, fpMichel_hit, fRun, fSaveHitsFile, fShBad, fShOk, fTotal, fTrkBad, and fTrkOk.

194 {
196 
197  fEventTree = tfs->make<TTree>("event", "event info");
198  fEventTree->Branch("fRun", &fRun, "fRun/I");
199  fEventTree->Branch("fEvent", &fEvent, "fEvent/I");
200  fEventTree->Branch("fMcDepEM", &fMcDepEM, "fMcDepEM/F");
201  fEventTree->Branch("fMcDepTrack", &fMcDepTrack, "fMcDepTrack/F");
202  fEventTree->Branch("fMcFractionEM", &fMcFractionEM, "fMcFractionEM/F");
203  fEventTree->Branch("fPfpDepEM", &fPfpDepEM, "fPfpDepEM/F");
204  fEventTree->Branch("fPfpDepTrack", &fPfpDepTrack, "fPfpDepTrack/F");
205  fEventTree->Branch("fHitEM_0p5", &fHitEM_0p5, "fHitEM_0p5/F");
206  fEventTree->Branch("fHitMichel_0p5", &fHitMichel_0p5, "fHitMichel_0p5/F");
207  fEventTree->Branch("fHitTrack_0p5", &fHitTrack_0p5, "fHitTrack_0p5/F");
208  fEventTree->Branch("fHitMcFractionEM", &fHitMcFractionEM, "fHitMcFractionEM/F");
209  fEventTree->Branch("fHitEM_0p85", &fHitEM_0p85, "fHitEM_0p85/F");
210  fEventTree->Branch("fHitTrack_0p85", &fHitTrack_0p85, "fHitTrack_0p85/F");
211  fEventTree->Branch("fCleanHit", &fCleanHit, "fCleanHit/F");
212 
213  fEventTree->Branch("fHitsEM_OK_0p5", fHitsEM_OK_0p5, "fHitsEM_OK_0p5[100]/F");
214  fEventTree->Branch("fHitsTrack_OK_0p5", fHitsTrack_OK_0p5, "fHitsTrack_OK_0p5[100]/F");
215  fEventTree->Branch("fHitsMichel_OK_0p5", fHitsMichel_OK_0p5, "fHitsMichel_OK_0p5[100]/F");
216  fEventTree->Branch(
217  "fHitsMichel_False_0p5", fHitsMichel_False_0p5, "fHitsMichel_False_0p5[100]/F");
218 
219  fEventTree->Branch("fHitsEM_OK_0p85", fHitsEM_OK_0p85, "fHitsEM_OK_0p85[100]/F");
220  fEventTree->Branch("fHitsTrack_OK_0p85", fHitsTrack_OK_0p85, "fHitsTrack_OK_0p85[100]/F");
221 
222  fEventTree->Branch("fHitRecoEM", fHitRecoEM, "fHitRecoEM[100]/F");
223  fEventTree->Branch("fHitRecoFractionEM", fHitRecoFractionEM, "fHitRecoFractionEM[100]/F");
224 
225  fClusterTree = tfs->make<TTree>("cluster", "clusters info");
226  fClusterTree->Branch("fMcPid", &fMcPid, "fMcPid/I");
227  fClusterTree->Branch("fClSize", &fClSize, "fClSize/I");
228  fClusterTree->Branch("fPidValue", &fPidValue, "fPidValue/F");
229  fClusterTree->Branch("fpMichel_cl", &fpMichel_cl, "fpMichel_cl/F");
230 
231  fHitTree = tfs->make<TTree>("hits", "hits info");
232  fHitTree->Branch("fRun", &fRun, "fRun/I");
233  fHitTree->Branch("fEvent", &fEvent, "fEvent/I");
234  fHitTree->Branch("fHitEM_mc", &fHitEM_mc, "fHitEM_mc/F");
235  fHitTree->Branch("fpEM", &fpEM, "fpEM/F");
236  fHitTree->Branch("fPidValue", &fPidValue, "fPidValue/F");
237  fHitTree->Branch("fHitMichel_mc", &fHitMichel_mc, "fHitMichel_mc/F");
238  fHitTree->Branch("fpMichel_hit", &fpMichel_hit, "fpMichel_hit/F");
239  fHitTree->Branch("fOutTrk", &fOutTrk, "fOutTrk/F");
240  fHitTree->Branch("fOutEM", &fOutEM, "fOutEM/F");
241  fHitTree->Branch("fOutNone", &fOutNone, "fOutNone/F");
242 
243  if (fSaveHitsFile) fHitsOutFile.open("hits_pid.prn");
244 
245  fNone = 0;
246  fTotal = 0;
247  for (size_t i = 0; i < 100; ++i) {
248  fShOk[i] = 0;
249  fShBad[i] = 0;
250  fTrkOk[i] = 0;
251  fTrkBad[i] = 0;
252  }
253 }
void nnet::PointIdEffTest::beginRun ( const art::Run run)
overrideprivate
void nnet::PointIdEffTest::cleanup ( )
private

Definition at line 276 of file PointIdEffTest_module.cc.

References fCleanHit, fEmLikeIdx, fHitEM_0p5, fHitEM_0p85, fHitMcFractionEM, fHitMichel_0p5, fHitRecoEM, fHitRecoFractionEM, fHitsEM_OK_0p5, fHitsEM_OK_0p85, fHitsMichel_False_0p5, fHitsMichel_OK_0p5, fHitsTrack_OK_0p5, fHitsTrack_OK_0p85, fHitTrack_0p5, fHitTrack_0p85, fMcDepEM, fMcDepTrack, fMcFractionEM, fMichelLikeIdx, fNoneIdx, fParticleMap, fPfpDepEM, fPfpDepTrack, fTotHit, and fTrkLikeIdx.

Referenced by analyze().

277 {
278  fParticleMap.clear();
279 
280  fMcDepEM = 0;
281  fMcDepTrack = 0;
282  fMcFractionEM = 0;
283  fPfpDepEM = 0;
284  fPfpDepTrack = 0;
285  fHitEM_0p5 = 0;
286  fHitTrack_0p5 = 0;
287  fHitEM_0p85 = 0;
288  fHitTrack_0p85 = 0;
289  fHitMichel_0p5 = 0;
290  fHitMcFractionEM = 0;
291  fTotHit = 0;
292  fCleanHit = 0;
293 
294  for (size_t i = 0; i < 100; ++i) {
295  fHitsEM_OK_0p5[i] = 0;
296  fHitsTrack_OK_0p5[i] = 0;
297  fHitsEM_OK_0p85[i] = 0;
298  fHitsTrack_OK_0p85[i] = 0;
299  fHitsMichel_OK_0p5[i] = 0;
300  fHitsMichel_False_0p5[i] = 0;
301  fHitRecoEM[i] = 0;
302  fHitRecoFractionEM[i] = 0;
303  }
304 
305  fTrkLikeIdx = -1;
306  fEmLikeIdx = -1;
307  fNoneIdx = -1;
308  fMichelLikeIdx = -1;
309 }
std::unordered_map< int, const simb::MCParticle * > fParticleMap
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void nnet::PointIdEffTest::countPfpDep ( detinfo::DetectorClocksData const &  clockData,
detinfo::DetectorPropertiesData const &  detProp,
const std::vector< recob::PFParticle > &  pfparticles,
const art::FindManyP< recob::Cluster > &  pfpclus,
const art::FindManyP< recob::Hit > &  cluhits,
float &  emLike,
float &  trackLike 
) const
private

Definition at line 477 of file PointIdEffTest_module.cc.

References fCalorimetryAlg, fView, hits(), and calo::CalorimetryAlg::LifetimeCorrection().

Referenced by analyze().

484 {
485  emLike = 0;
486  trackLike = 0;
487  for (size_t i = 0; i < pfparticles.size(); ++i) {
488  const auto& pfp = pfparticles[i];
489  const auto& clus = pfpclus.at(i);
490 
491  float hitdep = 0;
492  for (const auto& c : clus) {
493  const auto& hits = cluhits.at(c.key());
494  for (const auto& h : hits) {
495  if (h->View() == fView) {
496  hitdep +=
497  h->SummedADC() * fCalorimetryAlg.LifetimeCorrection(clockData, detProp, h->PeakTime());
498  }
499  }
500  }
501 
502  if ((pfp.PdgCode() == 11) || pfp.PdgCode() == -11) { emLike += hitdep; }
503  else {
504  trackLike += hitdep;
505  }
506  }
507 }
void hits()
Definition: readHits.C:15
double LifetimeCorrection(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, double time, double T0=0) const
calo::CalorimetryAlg fCalorimetryAlg
void nnet::PointIdEffTest::countTruthDep ( const std::vector< sim::SimChannel > &  channels,
float &  emLike,
float &  trackLike 
) const
private

Definition at line 434 of file PointIdEffTest_module.cc.

References energy, fElectronsToGeV, fParticleMap, and simb::MCParticle::PdgCode().

Referenced by analyze().

437 {
438  emLike = 0;
439  trackLike = 0;
440  for (auto const& channel : channels) {
441  // for every time slice in this channel:
442  auto const& timeSlices = channel.TDCIDEMap();
443  for (auto const& timeSlice : timeSlices) {
444  // loop over the energy deposits.
445  auto const& energyDeposits = timeSlice.second;
446  for (auto const& energyDeposit : energyDeposits) {
447  int trackID = energyDeposit.trackID;
448 
449  double energy = energyDeposit.numElectrons * fElectronsToGeV * 1000;
450 
451  if (trackID < 0) { emLike += energy; }
452  else if (trackID > 0) {
453  auto search = fParticleMap.find(trackID);
454  bool found = true;
455  if (search == fParticleMap.end()) {
456  mf::LogWarning("TrainingDataAlg") << "PARTICLE NOT FOUND";
457  found = false;
458  }
459 
460  int pdg = 0;
461  if (found) {
462  const simb::MCParticle& particle = *((*search).second);
463  if (!pdg) pdg = particle.PdgCode(); // not EM activity so read what PDG it is
464  }
465 
466  if ((pdg == 11) || (pdg == -11) || (pdg == 22))
467  emLike += energy;
468  else
469  trackLike += energy;
470  }
471  }
472  }
473  }
474 }
int PdgCode() const
Definition: MCParticle.h:213
std::unordered_map< int, const simb::MCParticle * > fParticleMap
double energy
Definition: plottest35.C:25
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void art::detail::Analyzer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 25 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

26  {
27  setupQueues(resources);
28  ProcessingFrame const frame{ScheduleID{}};
29  beginJobWithFrame(frame);
30  }
virtual void beginJobWithFrame(ProcessingFrame const &)=0
virtual void setupQueues(SharedResources const &)=0
bool art::detail::Analyzer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 68 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

69  {
70  ProcessingFrame const frame{mc.scheduleID()};
71  beginRunWithFrame(std::as_const(rp).makeRun(mc), frame);
72  return true;
73  }
virtual void beginRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 84 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

85  {
86  ProcessingFrame const frame{mc.scheduleID()};
87  beginSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
88  return true;
89  }
virtual void beginSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doEndJob ( )
inherited

Definition at line 33 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

34  {
35  ProcessingFrame const frame{ScheduleID{}};
36  endJobWithFrame(frame);
37  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 76 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

77  {
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(std::as_const(rp).makeRun(mc), frame);
80  return true;
81  }
virtual void endRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 92 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

93  {
94  ProcessingFrame const frame{mc.scheduleID()};
95  endSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
96  return true;
97  }
virtual void endSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::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 
)
inherited

Definition at line 100 of file Analyzer.cc.

References e, and art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

105  {
106  auto const e = std::as_const(ep).makeEvent(mc);
107  if (wantEvent(mc.scheduleID(), e)) {
108  ++counts_run;
109  ProcessingFrame const frame{mc.scheduleID()};
110  analyzeWithFrame(e, frame);
111  ++counts_passed;
112  }
113  return true;
114  }
bool wantEvent(ScheduleID id, Event const &e) const
Definition: Observer.cc:63
Float_t e
Definition: plot.C:35
virtual void analyzeWithFrame(Event const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 47 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

48  {
49  ProcessingFrame const frame{ScheduleID{}};
51  }
TFile fb("Li6.root")
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 61 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

62  {
63  ProcessingFrame const frame{ScheduleID{}};
65  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Analyzer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 40 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

41  {
42  ProcessingFrame const frame{ScheduleID{}};
44  }
TFile fb("Li6.root")
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 54 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

55  {
56  ProcessingFrame const frame{ScheduleID{}};
58  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void nnet::PointIdEffTest::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 255 of file PointIdEffTest_module.cc.

References fHitsOutFile, fSaveHitsFile, fShBad, fShOk, fTrkBad, and fTrkOk.

256 {
257  if (fSaveHitsFile) fHitsOutFile.close();
258 
260 
261  TTree* thrTree = tfs->make<TTree>("threshold", "error rate vs threshold");
262 
263  float thr, shErr, trkErr;
264  thrTree->Branch("thr", &thr, "thr/F");
265  thrTree->Branch("shErr", &shErr, "shErr/F");
266  thrTree->Branch("trkErr", &trkErr, "trkErr/F");
267 
268  for (size_t i = 0; i < 100; ++i) {
269  thr = 0.01 * i;
270  shErr = fShBad[i] / float(fShBad[i] + fShOk[i]);
271  trkErr = fTrkBad[i] / float(fTrkBad[i] + fTrkOk[i]);
272  thrTree->Fill();
273  }
274 }
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
Handle< TriggerResults > art::Observer::getTriggerResults ( Event const &  e) const
protectedinherited

Definition at line 75 of file Observer.cc.

References art::ProductRetriever::get(), and art::Observer::selectors_.

Referenced by art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

76  {
77  if (selectors_) {
78  return selectors_->getOneTriggerResults(e);
79  }
80 
81  // The following applies for cases where no SelectEvents entries
82  // exist.
83  Handle<TriggerResults> h;
84  if (e.get(empty_process_name, h)) {
85  return h;
86  }
87  return Handle<TriggerResults>{};
88  }
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79
bool nnet::PointIdEffTest::isMuonDecaying ( const simb::MCParticle particle,
const std::unordered_map< int, const simb::MCParticle * > &  particleMap 
) const
private

Definition at line 510 of file PointIdEffTest_module.cc.

References util::abs(), d, simb::MCParticle::Daughter(), simb::MCParticle::EndProcess(), simb::MCParticle::NumberDaughters(), and simb::MCParticle::PdgCode().

Referenced by testCNN().

513 {
514  bool hasElectron = false, hasNuMu = false, hasNuE = false;
515 
516  int pdg = abs(particle.PdgCode());
517  if ((pdg == 13) && (particle.EndProcess() == "FastScintillation")) // potential muon decay at rest
518  {
519  unsigned int nSec = particle.NumberDaughters();
520  for (size_t d = 0; d < nSec; ++d) {
521  auto d_search = particleMap.find(particle.Daughter(d));
522  if (d_search != particleMap.end()) {
523  auto const& daughter = *((*d_search).second);
524  int d_pdg = abs(daughter.PdgCode());
525  if (d_pdg == 11)
526  hasElectron = true;
527  else if (d_pdg == 14)
528  hasNuMu = true;
529  else if (d_pdg == 12)
530  hasNuE = true;
531  }
532  }
533  }
534 
535  return (hasElectron && hasNuMu && hasNuE);
536 }
int PdgCode() const
Definition: MCParticle.h:213
constexpr auto abs(T v)
Returns the absolute value of the argument.
int NumberDaughters() const
Definition: MCParticle.h:218
int Daughter(const int i) const
Definition: MCParticle.cxx:118
std::string EndProcess() const
Definition: MCParticle.h:217
Float_t d
Definition: plot.C:235
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
PointIdEffTest& nnet::PointIdEffTest::operator= ( PointIdEffTest const &  )
delete
PointIdEffTest& nnet::PointIdEffTest::operator= ( PointIdEffTest &&  )
delete
string const & art::Observer::processName ( ) const
protectedinherited

Definition at line 57 of file Observer.cc.

References art::Observer::process_name_.

Referenced by art::FileDumperOutput::printPrincipal().

58  {
59  return process_name_;
60  }
std::string process_name_
Definition: Observer.h:76
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)
int nnet::PointIdEffTest::testCNN ( detinfo::DetectorClocksData const &  clockData,
detinfo::DetectorPropertiesData const &  detProp,
const std::vector< sim::SimChannel > &  channels,
const std::vector< art::Ptr< recob::Hit >> &  hits,
const std::array< float, MVA_LENGTH > &  cnn_out,
const std::vector< anab::FeatureVector< MVA_LENGTH >> &  hit_outs,
size_t  cidx 
)
private

Definition at line 539 of file PointIdEffTest_module.cc.

References util::abs(), DEFINE_ART_MODULE, energy, fCalorimetryAlg, fCleanHit, fClSize, fClusterTree, fElectronsToGeV, fEmLikeIdx, fEvent, fHitEM_0p5, fHitEM_0p85, fHitEM_mc, fHitMichel_0p5, fHitMichel_mc, fHitRecoEM, fHitsEM_OK_0p5, fHitsEM_OK_0p85, fHitsMichel_False_0p5, fHitsMichel_OK_0p5, fHitsOutFile, fHitsTrack_OK_0p5, fHitsTrack_OK_0p85, fHitTrack_0p5, fHitTrack_0p85, fHitTree, fMcPid, fMichelLikeIdx, fNone, fNoneIdx, fOutEM, fOutNone, fOutTrk, fParticleMap, fpEM, fPidValue, fpMichel_cl, fpMichel_hit, fRun, fSaveHitsFile, fShBad, fShOk, fTotal, fTotHit, fTrkBad, fTrkLikeIdx, fTrkOk, hits(), isMuonDecaying(), kShower, kTrack, calo::CalorimetryAlg::LifetimeCorrection(), simb::MCParticle::Mother(), and simb::MCParticle::PdgCode().

Referenced by analyze().

546 {
547  fClSize = hits.size();
548 
549  std::unordered_map<int, int> mcHitPid;
550 
551  fPidValue = 0;
552  double p_trk_or_sh = cnn_out[fTrkLikeIdx] + cnn_out[fEmLikeIdx];
553  if (p_trk_or_sh > 0) { fPidValue = cnn_out[fTrkLikeIdx] / p_trk_or_sh; }
554 
555  double p_michel = 0;
556  if (fMichelLikeIdx >= 0) { fpMichel_cl = cnn_out[fMichelLikeIdx]; }
557 
558  double totEnSh = 0, totEnTrk = 0;
559  for (auto const& hit : hits) {
560  // the channel associated with this hit.
561  auto hitChannelNumber = hit->Channel();
562 
563  double hitEn = 0, hitEnSh = 0, hitEnTrk = 0, hitEnMichel = 0;
564 
565  auto const& vout = hit_outs[hit.key()];
566  fOutTrk = vout[fTrkLikeIdx];
567  fOutEM = vout[fEmLikeIdx];
568  if (fNoneIdx >= 0) { fOutNone = vout[fNoneIdx]; }
569  if (fMichelLikeIdx >= 0) { p_michel = vout[fMichelLikeIdx]; }
570 
571  for (auto const& channel : channels) {
572  if (channel.Channel() != hitChannelNumber) continue;
573 
574  // for every time slice in this channel:
575  auto const& timeSlices = channel.TDCIDEMap();
576  for (auto const& timeSlice : timeSlices) {
577  int time = timeSlice.first;
578  if (std::abs(hit->TimeDistanceAsRMS(time)) < 1.0) {
579  // loop over the energy deposits.
580  auto const& energyDeposits = timeSlice.second;
581 
582  for (auto const& energyDeposit : energyDeposits) {
583  int trackID = energyDeposit.trackID;
584 
585  double energy = energyDeposit.numElectrons * fElectronsToGeV * 1000;
586  hitEn += energy;
587 
588  if (trackID < 0) { hitEnSh += energy; } // EM activity
589  else if (trackID > 0) {
590  auto search = fParticleMap.find(trackID);
591  if (search != fParticleMap.end()) {
592  const simb::MCParticle& particle = *((*search).second);
593  int pdg = particle.PdgCode(); // not EM activity so read what PDG it is
594 
595  if ((pdg == 11) || (pdg == -11) || (pdg == 22))
596  hitEnSh += energy;
597  else
598  hitEnTrk += energy;
599 
600  if (pdg == 11) // electron, check if it is Michel
601  {
602  auto msearch = fParticleMap.find(particle.Mother());
603  if (msearch != fParticleMap.end()) {
604  auto const& mother = *((*msearch).second);
605  if (isMuonDecaying(mother, fParticleMap)) { hitEnMichel += energy; }
606  }
607  }
608  }
609  else {
610  mf::LogWarning("TrainingDataAlg") << "PARTICLE NOT FOUND";
611  }
612  }
613  }
614  }
615  }
616  }
617  totEnSh += hitEnSh;
618  totEnTrk += hitEnTrk;
619 
620  double hitAdc =
621  hit->SummedADC() * fCalorimetryAlg.LifetimeCorrection(clockData, detProp, hit->PeakTime());
622  fTotHit += hitAdc;
623 
624  int hitPidMc_0p5 = -1;
625  if (hitEnSh > hitEnTrk) {
626  fHitEM_0p5 += hitAdc;
627  hitPidMc_0p5 = nnet::PointIdEffTest::kShower;
628  }
629  else {
630  fHitTrack_0p5 += hitAdc;
631  hitPidMc_0p5 = nnet::PointIdEffTest::kTrack;
632  }
633  mcHitPid[hit.key()] = hitPidMc_0p5;
634  auto const& hout = hit_outs[hit.key()];
635  fpEM = 0;
636  float hit_trk_or_sh = hout[fTrkLikeIdx] + hout[fEmLikeIdx];
637  if (hit_trk_or_sh > 0) fpEM = hout[fEmLikeIdx] / hit_trk_or_sh;
638  fHitEM_mc = hitEnSh / (hitEnSh + hitEnTrk);
639 
640  int hitPidMc_0p85 = -1;
641  double hitDep = hitEnSh + hitEnTrk;
642  if (hitEnSh > 0.85 * hitDep) {
643  fHitEM_0p85 += hitAdc;
644  fCleanHit += hitAdc;
645  hitPidMc_0p85 = nnet::PointIdEffTest::kShower;
646  }
647  else if (hitEnTrk > 0.85 * hitDep) {
648  fHitTrack_0p85 += hitAdc;
649  fCleanHit += hitAdc;
650  hitPidMc_0p85 = nnet::PointIdEffTest::kTrack;
651  }
652 
653  bool mcMichel = false;
654  fpMichel_hit = p_michel;
655  fHitMichel_mc = hitEnMichel / hitEn;
656  if (fHitMichel_mc > 0.5) {
657  fHitMichel_0p5 += hitAdc;
658  mcMichel = true;
659  }
660 
661  fHitTree->Fill();
662 
663  for (size_t i = 0; i < 100; ++i) {
664  double thr = 0.01 * i;
665 
666  if (p_michel > thr) {
667  if (mcMichel) { fHitsMichel_OK_0p5[i] += hitAdc; }
668  else {
669  fHitsMichel_False_0p5[i] += hitAdc;
670  }
671  }
672 
673  int recoPid = -1;
674  if (fPidValue < thr) {
676  fHitRecoEM[i] += hitAdc;
677  }
678  else
680 
681  if ((recoPid == nnet::PointIdEffTest::kShower) &&
682  (hitPidMc_0p5 == nnet::PointIdEffTest::kShower)) {
683  fHitsEM_OK_0p5[i] += hitAdc;
684  }
685  else if ((recoPid == nnet::PointIdEffTest::kTrack) &&
686  (hitPidMc_0p5 == nnet::PointIdEffTest::kTrack)) {
687  fHitsTrack_OK_0p5[i] += hitAdc;
688  }
689 
690  if ((recoPid == nnet::PointIdEffTest::kShower) &&
691  (hitPidMc_0p85 == nnet::PointIdEffTest::kShower)) {
692  fHitsEM_OK_0p85[i] += hitAdc;
693  }
694  else if ((recoPid == nnet::PointIdEffTest::kTrack) &&
695  (hitPidMc_0p85 == nnet::PointIdEffTest::kTrack)) {
696  fHitsTrack_OK_0p85[i] += hitAdc;
697  }
698  }
699  }
700 
701  // ************ count clusters *************
702 
703  fMcPid = -1;
704  if (totEnSh > 1.5 * totEnTrk) // major energy deposit from EM activity
705  {
707  }
708  else if (totEnTrk > 1.5 * totEnSh) {
710  }
711 
712  for (size_t i = 0; i < 100; ++i) {
713  double thr = 0.01 * i;
714 
715  int recoPid = -1;
716  if (fPidValue < thr)
718  else
720 
722  fShOk[i] += fClSize;
723  }
724  else if ((recoPid == nnet::PointIdEffTest::kTrack) &&
726  fTrkOk[i] += fClSize;
727  }
728  else if ((recoPid == nnet::PointIdEffTest::kShower) &&
730  fTrkBad[i] += fClSize;
731  }
732  else if ((recoPid == nnet::PointIdEffTest::kTrack) &&
734  fShBad[i] += fClSize;
735  }
736  else {
737  fNone++;
738  }
739  }
740  fTotal++;
741 
742  if (fSaveHitsFile) {
743  for (auto const& h : hits) {
744  auto const& vout = hit_outs[h.key()];
745  double hitPidValue = 0;
746  double h_trk_or_sh = vout[fTrkLikeIdx] + vout[fEmLikeIdx];
747  if (h_trk_or_sh > 0) hitPidValue = vout[fTrkLikeIdx] / h_trk_or_sh;
748 
749  fHitsOutFile << fRun << " " << fEvent << " " << h->WireID().TPC << " " << h->WireID().Wire
750  << " " << h->PeakTime() << " "
751  << h->SummedADC() *
752  fCalorimetryAlg.LifetimeCorrection(clockData, detProp, h->PeakTime())
753  << " " << mcHitPid[h.key()] << " " << fPidValue << " " << hitPidValue;
754 
755  if (fMichelLikeIdx >= 0) {
756  fHitsOutFile << " " << vout[fMichelLikeIdx]; // is michel?
757  }
758 
759  fHitsOutFile << " " << cidx << std::endl;
760  }
761  }
762 
763  fClusterTree->Fill();
764  return fMcPid;
765 }
int PdgCode() const
Definition: MCParticle.h:213
int Mother() const
Definition: MCParticle.h:214
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::unordered_map< int, const simb::MCParticle * > fParticleMap
bool isMuonDecaying(const simb::MCParticle &particle, const std::unordered_map< int, const simb::MCParticle * > &particleMap) const
double energy
Definition: plottest35.C:25
Detector simulation of raw signals on wires.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double LifetimeCorrection(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, double time, double T0=0) const
calo::CalorimetryAlg fCalorimetryAlg
bool art::Observer::wantAllEvents ( ) const
inlineprotectednoexceptinherited

Definition at line 31 of file Observer.h.

References e, art::Observer::getTriggerResults(), art::Observer::wantAllEvents_, and art::Observer::wantEvent().

32  {
33  return wantAllEvents_;
34  }
bool wantAllEvents_
Definition: Observer.h:75
bool art::Observer::wantEvent ( ScheduleID  id,
Event const &  e 
) const
protectedinherited

Definition at line 63 of file Observer.cc.

References art::Observer::rejectors_, art::Observer::selectors_, and art::Observer::wantAllEvents_.

Referenced by art::OutputModule::doEvent(), art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

64  {
65  if (wantAllEvents_) {
66  return true;
67  }
68  bool const select_event = selectors_ ? selectors_->matchEvent(id, e) : true;
69  bool const reject_event =
70  rejectors_ ? rejectors_->matchEvent(id, e) : false;
71  return select_event and not reject_event;
72  }
bool wantAllEvents_
Definition: Observer.h:75
std::optional< detail::ProcessAndEventSelectors > rejectors_
Definition: Observer.h:80
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79

Member Data Documentation

calo::CalorimetryAlg nnet::PointIdEffTest::fCalorimetryAlg
private

Definition at line 162 of file PointIdEffTest_module.cc.

Referenced by countPfpDep(), and testCNN().

float nnet::PointIdEffTest::fCleanHit
private

Definition at line 134 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), cleanup(), and testCNN().

int nnet::PointIdEffTest::fClSize
private

Definition at line 143 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

TTree * nnet::PointIdEffTest::fClusterTree
private

Definition at line 154 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

double nnet::PointIdEffTest::fElectronsToGeV
private

Definition at line 150 of file PointIdEffTest_module.cc.

Referenced by beginRun(), countTruthDep(), and testCNN().

int nnet::PointIdEffTest::fEmLikeIdx
private

Definition at line 152 of file PointIdEffTest_module.cc.

Referenced by analyze(), cleanup(), and testCNN().

int nnet::PointIdEffTest::fEvent
private

Definition at line 126 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), and testCNN().

TTree* nnet::PointIdEffTest::fEventTree
private

Definition at line 154 of file PointIdEffTest_module.cc.

Referenced by analyze(), and beginJob().

float nnet::PointIdEffTest::fHitEM_0p5
private

Definition at line 129 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fHitEM_0p85
private

Definition at line 133 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fHitEM_mc
private

Definition at line 130 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

float nnet::PointIdEffTest::fHitMcFractionEM
private

Definition at line 129 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), and cleanup().

float nnet::PointIdEffTest::fHitMichel_0p5
private

Definition at line 129 of file PointIdEffTest_module.cc.

Referenced by beginJob(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fHitMichel_mc
private

Definition at line 131 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

float nnet::PointIdEffTest::fHitRecoEM[100]
private

Definition at line 140 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fHitRecoFractionEM[100]
private

Definition at line 140 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), and cleanup().

float nnet::PointIdEffTest::fHitsEM_OK_0p5[100]
private

Definition at line 137 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fHitsEM_OK_0p85[100]
private

Definition at line 139 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fHitsMichel_False_0p5[100]
private

Definition at line 138 of file PointIdEffTest_module.cc.

Referenced by beginJob(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fHitsMichel_OK_0p5[100]
private

Definition at line 138 of file PointIdEffTest_module.cc.

Referenced by beginJob(), cleanup(), and testCNN().

std::ofstream nnet::PointIdEffTest::fHitsOutFile
private

Definition at line 156 of file PointIdEffTest_module.cc.

Referenced by beginJob(), endJob(), and testCNN().

float nnet::PointIdEffTest::fHitsTrack_OK_0p5[100]
private

Definition at line 137 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fHitsTrack_OK_0p85[100]
private

Definition at line 139 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fHitTrack_0p5
private

Definition at line 129 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fHitTrack_0p85
private

Definition at line 133 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), cleanup(), and testCNN().

TTree * nnet::PointIdEffTest::fHitTree
private

Definition at line 154 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

float nnet::PointIdEffTest::fMcDepEM
private

Definition at line 127 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), and cleanup().

float nnet::PointIdEffTest::fMcDepTrack
private

Definition at line 127 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), and cleanup().

float nnet::PointIdEffTest::fMcFractionEM
private

Definition at line 127 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), and cleanup().

int nnet::PointIdEffTest::fMcPid
private

Definition at line 142 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

int nnet::PointIdEffTest::fMichelLikeIdx
private

Definition at line 152 of file PointIdEffTest_module.cc.

Referenced by analyze(), cleanup(), and testCNN().

art::InputTag nnet::PointIdEffTest::fNNetModuleLabel
private

Definition at line 165 of file PointIdEffTest_module.cc.

Referenced by analyze().

int nnet::PointIdEffTest::fNone
private

Definition at line 148 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

int nnet::PointIdEffTest::fNoneIdx
private

Definition at line 152 of file PointIdEffTest_module.cc.

Referenced by analyze(), cleanup(), and testCNN().

float nnet::PointIdEffTest::fOutEM
private

Definition at line 132 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

float nnet::PointIdEffTest::fOutNone
private

Definition at line 132 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

float nnet::PointIdEffTest::fOutTrk
private

Definition at line 132 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

std::unordered_map<int, const simb::MCParticle*> nnet::PointIdEffTest::fParticleMap
private

Definition at line 160 of file PointIdEffTest_module.cc.

Referenced by analyze(), cleanup(), countTruthDep(), and testCNN().

float nnet::PointIdEffTest::fpEM
private

Definition at line 130 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

float nnet::PointIdEffTest::fPfpDepEM
private

Definition at line 128 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), and cleanup().

float nnet::PointIdEffTest::fPfpDepTrack
private

Definition at line 128 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), and cleanup().

art::InputTag nnet::PointIdEffTest::fPfpModuleLabel
private

Definition at line 164 of file PointIdEffTest_module.cc.

Referenced by analyze().

float nnet::PointIdEffTest::fPidValue
private

Definition at line 144 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

float nnet::PointIdEffTest::fpMichel_cl
private

Definition at line 131 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

float nnet::PointIdEffTest::fpMichel_hit
private

Definition at line 131 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

int nnet::PointIdEffTest::fRun
private

Definition at line 126 of file PointIdEffTest_module.cc.

Referenced by analyze(), beginJob(), and testCNN().

bool nnet::PointIdEffTest::fSaveHitsFile
private

Definition at line 166 of file PointIdEffTest_module.cc.

Referenced by beginJob(), endJob(), and testCNN().

int nnet::PointIdEffTest::fShBad[100]
private

Definition at line 147 of file PointIdEffTest_module.cc.

Referenced by beginJob(), endJob(), and testCNN().

int nnet::PointIdEffTest::fShOk[100]
private

Definition at line 147 of file PointIdEffTest_module.cc.

Referenced by beginJob(), endJob(), and testCNN().

art::InputTag nnet::PointIdEffTest::fSimulationProducerLabel
private

Definition at line 163 of file PointIdEffTest_module.cc.

Referenced by analyze().

int nnet::PointIdEffTest::fTotal
private

Definition at line 148 of file PointIdEffTest_module.cc.

Referenced by beginJob(), and testCNN().

float nnet::PointIdEffTest::fTotHit
private

Definition at line 134 of file PointIdEffTest_module.cc.

Referenced by analyze(), cleanup(), and testCNN().

int nnet::PointIdEffTest::fTrkBad[100]
private

Definition at line 146 of file PointIdEffTest_module.cc.

Referenced by beginJob(), endJob(), and testCNN().

int nnet::PointIdEffTest::fTrkLikeIdx
private

Definition at line 152 of file PointIdEffTest_module.cc.

Referenced by analyze(), cleanup(), and testCNN().

int nnet::PointIdEffTest::fTrkOk[100]
private

Definition at line 146 of file PointIdEffTest_module.cc.

Referenced by beginJob(), endJob(), and testCNN().

unsigned int nnet::PointIdEffTest::fView
private

Definition at line 158 of file PointIdEffTest_module.cc.

Referenced by analyze(), and countPfpDep().


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