10 #include "art/Framework/Core/EDAnalyzer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Services/Registry/ServiceHandle.h"
15 #include "canvas/Persistency/Common/FindManyP.h"
28 explicit MCBTDemo(fhicl::ParameterSet
const&
p);
40 void analyze(art::Event
const&
e)
override;
51 art::Handle<std::vector<sim::MCTrack>> mctHandle;
52 e.getByLabel(
"mcreco", mctHandle);
54 art::Handle<std::vector<sim::SimChannel>> schHandle;
55 e.getByLabel(
"largeant", schHandle);
57 art::Handle<std::vector<recob::Track>> trkHandle;
58 e.getByLabel(
"trackkalmanhit", trkHandle);
60 if (!mctHandle.isValid() || !schHandle.isValid() || !trkHandle.isValid())
return;
63 std::vector<unsigned int> g4_track_id;
64 for (
auto const& mct : *mctHandle) {
66 if (!mct.size())
continue;
68 double dE = (*mct.begin()).Momentum().E() - (*mct.rbegin()).Momentum().E();
69 if (dE > 100) g4_track_id.push_back(mct.TrackID());
72 if (g4_track_id.size()) {
74 art::ServiceHandle<geo::Geometry const> geo;
77 auto sum_mcq_v = alg_mct.
MCQSum(2);
78 std::cout <<
"Total charge contents on W plane:" << std::endl;
79 for (
size_t i = 0; i < sum_mcq_v.size() - 1; ++i)
80 std::cout <<
" MCTrack " << i <<
" => " << sum_mcq_v[i] << std::endl;
81 std::cout <<
" Others => " << (*sum_mcq_v.rbegin()) << std::endl;
84 art::FindManyP<recob::Hit> hit_coll_v(trkHandle, e,
"trackkalmanhit");
85 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
87 for (
size_t i = 0; i < trkHandle->size(); ++i) {
89 const std::vector<art::Ptr<recob::Hit>> hit_coll = hit_coll_v.at(i);
91 std::vector<btutil::WireRange_t> hits;
93 for (
auto const& h_ptr : hit_coll) {
95 if (geo->ChannelToWire(h_ptr->Channel())[0].
Plane != ::
geo::kW)
continue;
97 hits.emplace_back(h_ptr->Channel(), h_ptr->StartTick(), h_ptr->EndTick());
100 auto mcq_v = alg_mct.
MCQ(clockData, hits);
101 auto mcq_frac_v = alg_mct.
MCQFrac(clockData, hits);
104 <<
"Y plane Charge from first MCTrack: " << mcq_v[0]
105 <<
" ... Purity: " << mcq_frac_v[0]
106 <<
" ... Efficiency: " << mcq_v[0] / sum_mcq_v[0] << std::endl;
BEGIN_PROLOG true icarus_rawdigitfilter FilterTools FilterPlane1 Plane
const std::vector< double > & MCQSum(const size_t plane_id) const
Declaration of signal hit object.
Class def header for a class MCBTAlg.
MCBTDemo & operator=(MCBTDemo const &)=delete
void analyze(art::Event const &e) override
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
MCBTDemo(fhicl::ParameterSet const &p)
Class def header for mctrack data container.
Provides recob::Track data product.
std::vector< double > MCQFrac(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
object containing MC truth information necessary for making RawDigits and doing back tracking ...
Planes which measure W (third view for Bo, MicroBooNE, etc).
art framework interface to geometry description
BEGIN_PROLOG could also be cout