All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SBNDOpT0FinderAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: SBNDOpT0FinderAna
3 // Plugin Type: analyzer (art v3_05_01)
4 // File: SBNDOpT0FinderAna_module.cc
5 //
6 // Generated at Mon Oct 12 13:52:37 2020 by Marco Del Tutto using cetskelgen
7 // from cetlib version v3_10_00.
8 ////////////////////////////////////////////////////////////////////////
9 
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/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "canvas/Persistency/Common/FindManyP.h"
18 #include "fhiclcpp/ParameterSet.h"
19 #include "messagefacility/MessageLogger/MessageLogger.h"
20 
24 
25 
26 class SBNDOpT0FinderAna;
27 
28 
29 class SBNDOpT0FinderAna : public art::EDAnalyzer {
30 public:
31  explicit SBNDOpT0FinderAna(fhicl::ParameterSet const& p);
32  // The compiler-generated destructor is fine for non-base
33  // classes without bare pointers or other resource use.
34 
35  // Plugins should not be copied or assigned.
36  SBNDOpT0FinderAna(SBNDOpT0FinderAna const&) = delete;
40 
41  // Required functions.
42  void analyze(art::Event const& e) override;
43 
44 private:
45 
46  std::string _t0_producer; ///< The T0 producer (to be set)
47 
48 };
49 
50 
51 SBNDOpT0FinderAna::SBNDOpT0FinderAna(fhicl::ParameterSet const& p)
52  : EDAnalyzer{p}
53 {
54  _t0_producer = p.get<std::string>("T0Producer");
55 }
56 
57 void SBNDOpT0FinderAna::analyze(art::Event const& e)
58 {
59 
60  // Get all the T0 objects
61  ::art::Handle<std::vector<anab::T0>> t0_h;
62  e.getByLabel(_t0_producer, t0_h);
63  if(!t0_h.isValid() || t0_h->empty()) {
64  mf::LogWarning("SBNDOpT0FinderAna") << "Don't have good T0s." << std::endl;
65  return;
66  }
67  std::vector<art::Ptr<anab::T0>> t0_v;
68  art::fill_ptr_vector(t0_v, t0_h);
69 
70  // Get the T0->Slice association
71  art::FindManyP<recob::Slice> t0_to_slices(t0_h, e, _t0_producer);
72  art::FindManyP<recob::OpFlash> t0_to_flashes(t0_h, e, _t0_producer);
73 
74  for (size_t n_t0 = 0; n_t0 < t0_v.size(); n_t0++) {
75 
76  // The T0 object
77  auto const t0 = t0_v[n_t0];
78 
79  // The associations from T0 to both slices and flashes
80  std::vector<art::Ptr<recob::Slice>> slice_v = t0_to_slices.at(t0.key());
81  std::vector<art::Ptr<recob::OpFlash>> flash_v = t0_to_flashes.at(t0.key());
82 
83  // One T0 object is always associated to one and only one Slice and Flash
84  assert(slice_v.size() == 1);
85  assert(flash_v.size() == 1);
86 
87  std::cout << "T0 obj: " << n_t0 << ", score: " << t0->TriggerConfidence() << std::endl;
88  std::cout << "\t is associated with slice ID " << slice_v[0]->ID() << std::endl;
89  std::cout << "\t is associated with flash with time " << flash_v[0]->Time()
90  << ", total PE " << flash_v[0]->TotalPE() << std::endl;
91  }
92 
93 }
94 
95 DEFINE_ART_MODULE(SBNDOpT0FinderAna)
pdgs p
Definition: selectors.fcl:22
SBNDOpT0FinderAna & operator=(SBNDOpT0FinderAna const &)=delete
std::string _t0_producer
The T0 producer (to be set)
void analyze(art::Event const &e) override
do i e
SBNDOpT0FinderAna(fhicl::ParameterSet const &p)
BEGIN_PROLOG could also be cout