Public Member Functions | Private Member Functions | List of all members
MCBTDemo Class Reference
Inheritance diagram for MCBTDemo:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 MCBTDemo (fhicl::ParameterSet const &p)
 
 MCBTDemo (MCBTDemo const &)=delete
 
 MCBTDemo (MCBTDemo &&)=delete
 
MCBTDemooperator= (MCBTDemo const &)=delete
 
MCBTDemooperator= (MCBTDemo &&)=delete
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
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::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- 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 analyze (art::Event const &e) override
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- 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 25 of file MCBTDemo_module.cc.

Constructor & Destructor Documentation

MCBTDemo::MCBTDemo ( fhicl::ParameterSet const &  p)
explicit

Definition at line 44 of file MCBTDemo_module.cc.

44 : EDAnalyzer(p) {}
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
MCBTDemo::MCBTDemo ( MCBTDemo const &  )
delete
MCBTDemo::MCBTDemo ( MCBTDemo &&  )
delete

Member Function Documentation

void MCBTDemo::analyze ( art::Event const &  e)
overrideprivatevirtual

Implements art::EDAnalyzer.

Definition at line 47 of file MCBTDemo_module.cc.

48 {
49  // Implementation of required member function here.
51  e.getByLabel("mcreco", mctHandle);
52 
54  e.getByLabel("largeant", schHandle);
55 
57  e.getByLabel("trackkalmanhit", trkHandle);
58 
59  if (!mctHandle.isValid() || !schHandle.isValid() || !trkHandle.isValid()) return;
60 
61  // Collect G4 track ID from MCTrack whose energy loss > 100 MeV inside the detector
62  std::vector<unsigned int> g4_track_id;
63  for (auto const& mct : *mctHandle) {
64 
65  if (!mct.size()) continue;
66 
67  double dE = (*mct.begin()).Momentum().E() - (*mct.rbegin()).Momentum().E();
68  if (dE > 100) g4_track_id.push_back(mct.TrackID());
69  }
70 
71  if (g4_track_id.size()) {
72 
74  btutil::MCBTAlg alg_mct(g4_track_id, *schHandle);
75 
76  auto sum_mcq_v = alg_mct.MCQSum(2);
77  std::cout << "Total charge contents on W plane:" << std::endl;
78  for (size_t i = 0; i < sum_mcq_v.size() - 1; ++i)
79  std::cout << " MCTrack " << i << " => " << sum_mcq_v[i] << std::endl;
80  std::cout << " Others => " << (*sum_mcq_v.rbegin()) << std::endl;
81 
82  // Loop over reconstructed tracks and find charge fraction
83  art::FindManyP<recob::Hit> hit_coll_v(trkHandle, e, "trackkalmanhit");
84  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
85 
86  for (size_t i = 0; i < trkHandle->size(); ++i) {
87 
88  const std::vector<art::Ptr<recob::Hit>> hit_coll = hit_coll_v.at(i);
89 
90  std::vector<btutil::WireRange_t> hits;
91 
92  for (auto const& h_ptr : hit_coll) {
93 
94  if (geo->ChannelToWire(h_ptr->Channel())[0].Plane != ::geo::kW) continue;
95 
96  hits.emplace_back(h_ptr->Channel(), h_ptr->StartTick(), h_ptr->EndTick());
97  }
98 
99  auto mcq_v = alg_mct.MCQ(clockData, hits);
100  auto mcq_frac_v = alg_mct.MCQFrac(clockData, hits);
101 
102  std::cout << "Track " << i << " "
103  << "Y plane Charge from first MCTrack: " << mcq_v[0]
104  << " ... Purity: " << mcq_frac_v[0]
105  << " ... Efficiency: " << mcq_v[0] / sum_mcq_v[0] << std::endl;
106  }
107  }
108 }
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
bool isValid() const noexcept
Definition: Handle.h:191
const double e
Planes which measure W (third view for Bo, MicroBooNE, etc).
Definition: geo_types.h:131
recob::tracking::Plane Plane
Definition: TrackState.h:17
LArSoft geometry interface.
Definition: ChannelGeo.h:16
QTextStream & endl(QTextStream &s)
MCBTDemo& MCBTDemo::operator= ( MCBTDemo const &  )
delete
MCBTDemo& MCBTDemo::operator= ( MCBTDemo &&  )
delete

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