All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | List of all members
MCBTDemo Class Reference
Inheritance diagram for MCBTDemo:

Public Member Functions

 MCBTDemo (fhicl::ParameterSet const &p)
 
 MCBTDemo (MCBTDemo const &)=delete
 
 MCBTDemo (MCBTDemo &&)=delete
 
MCBTDemooperator= (MCBTDemo const &)=delete
 
MCBTDemooperator= (MCBTDemo &&)=delete
 

Private Member Functions

void analyze (art::Event const &e) override
 

Detailed Description

Definition at line 26 of file MCBTDemo_module.cc.

Constructor & Destructor Documentation

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

Definition at line 45 of file MCBTDemo_module.cc.

45 : EDAnalyzer(p) {}
pdgs p
Definition: selectors.fcl:22
MCBTDemo::MCBTDemo ( MCBTDemo const &  )
delete
MCBTDemo::MCBTDemo ( MCBTDemo &&  )
delete

Member Function Documentation

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

Definition at line 48 of file MCBTDemo_module.cc.

49 {
50  // Implementation of required member function here.
51  art::Handle<std::vector<sim::MCTrack>> mctHandle;
52  e.getByLabel("mcreco", mctHandle);
53 
54  art::Handle<std::vector<sim::SimChannel>> schHandle;
55  e.getByLabel("largeant", schHandle);
56 
57  art::Handle<std::vector<recob::Track>> trkHandle;
58  e.getByLabel("trackkalmanhit", trkHandle);
59 
60  if (!mctHandle.isValid() || !schHandle.isValid() || !trkHandle.isValid()) return;
61 
62  // Collect G4 track ID from MCTrack whose energy loss > 100 MeV inside the detector
63  std::vector<unsigned int> g4_track_id;
64  for (auto const& mct : *mctHandle) {
65 
66  if (!mct.size()) continue;
67 
68  double dE = (*mct.begin()).Momentum().E() - (*mct.rbegin()).Momentum().E();
69  if (dE > 100) g4_track_id.push_back(mct.TrackID());
70  }
71 
72  if (g4_track_id.size()) {
73 
74  art::ServiceHandle<geo::Geometry const> geo;
75  btutil::MCBTAlg alg_mct(g4_track_id, *schHandle);
76 
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;
82 
83  // Loop over reconstructed tracks and find charge fraction
84  art::FindManyP<recob::Hit> hit_coll_v(trkHandle, e, "trackkalmanhit");
85  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
86 
87  for (size_t i = 0; i < trkHandle->size(); ++i) {
88 
89  const std::vector<art::Ptr<recob::Hit>> hit_coll = hit_coll_v.at(i);
90 
91  std::vector<btutil::WireRange_t> hits;
92 
93  for (auto const& h_ptr : hit_coll) {
94 
95  if (geo->ChannelToWire(h_ptr->Channel())[0].Plane != ::geo::kW) continue;
96 
97  hits.emplace_back(h_ptr->Channel(), h_ptr->StartTick(), h_ptr->EndTick());
98  }
99 
100  auto mcq_v = alg_mct.MCQ(clockData, hits);
101  auto mcq_frac_v = alg_mct.MCQFrac(clockData, hits);
102 
103  std::cout << "Track " << i << " "
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;
107  }
108  }
109 }
BEGIN_PROLOG true icarus_rawdigitfilter FilterTools FilterPlane1 Plane
do i e
Planes which measure W (third view for Bo, MicroBooNE, etc).
Definition: geo_types.h:131
BEGIN_PROLOG could also be cout
MCBTDemo& MCBTDemo::operator= ( MCBTDemo const &  )
delete
MCBTDemo& MCBTDemo::operator= ( MCBTDemo &&  )
delete

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