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 "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
19 #include "art_root_io/TFileService.h"
20 #include "canvas/Persistency/Common/FindManyP.h"
44 void analyze(art::Event
const&
e)
override;
80 _flash_label_v =
p.get<std::vector<std::string>>(
"FlashProducer", _flash_label_v);
81 _mcflash_label_v =
p.get<std::vector<std::string>>(
"MCFlashProducer", _mcflash_label_v);
82 _ophit_label_v =
p.get<std::vector<std::string>>(
"OpHitProducer", _ophit_label_v);
83 _tpc_v =
p.get<std::vector<int>>(
"TPC", _tpc_v);
85 art::ServiceHandle<art::TFileService> fs;
86 _flash_tree = fs->make<TTree>(
"FlashTree",
"");
87 _flash_tree->Branch(
"run", &_run,
"run/I");
88 _flash_tree->Branch(
"subrun", &_subrun,
"subrun/I");
89 _flash_tree->Branch(
"event", &_event,
"event/I");
90 _flash_tree->Branch(
"tpc", &_tpc,
"tpc/I");
91 _flash_tree->Branch(
"flash_time", &_flash_time,
"flash_time/D");
92 _flash_tree->Branch(
"flash_total_pe", &_flash_total_pe,
"flash_total_pe/D");
93 _flash_tree->Branch(
"flash_y", &_flash_y,
"flash_y/D");
94 _flash_tree->Branch(
"flash_yerr", &_flash_yerr,
"flash_yerr/D");
95 _flash_tree->Branch(
"flash_z", &_flash_z,
"flash_z/D");
96 _flash_tree->Branch(
"flash_zerr", &_flash_zerr,
"flash_zerr/D");
97 _flash_tree->Branch(
"flash_pe_v",
"std::vector<double>", &_flash_pe_v);
98 _flash_tree->Branch(
"flash_ophit_time",
"std::vector<double>", &_flash_ophit_time);
99 _flash_tree->Branch(
"flash_ophit_amp",
"std::vector<double>", &_flash_ophit_amp);
100 _flash_tree->Branch(
"flash_ophit_area",
"std::vector<double>", &_flash_ophit_area);
101 _flash_tree->Branch(
"flash_ophit_width",
"std::vector<double>", &_flash_ophit_width);
102 _flash_tree->Branch(
"flash_ophit_pe",
"std::vector<double>", &_flash_ophit_pe);
103 _flash_tree->Branch(
"flash_ophit_ch",
"std::vector<int>", &_flash_ophit_ch);
104 _flash_tree->Branch(
"flash_ophit_chname",
"std::vector<std::string>", &_flash_ophit_chname);
106 _mcflash_tree = fs->make<TTree>(
"MCFlashTree",
"");
107 _mcflash_tree->Branch(
"run", &_run,
"run/I");
108 _mcflash_tree->Branch(
"subrun", &_subrun,
"subrun/I");
109 _mcflash_tree->Branch(
"event", &_event,
"event/I");
110 _mcflash_tree->Branch(
"tpc", &_tpc,
"tpc/I");
111 _mcflash_tree->Branch(
"flash_time", &_flash_time,
"flash_time/D");
112 _mcflash_tree->Branch(
"flash_total_pe", &_flash_total_pe,
"flash_total_pe/D");
113 _mcflash_tree->Branch(
"flash_y", &_flash_y,
"flash_y/D");
114 _mcflash_tree->Branch(
"flash_yerr", &_flash_yerr,
"flash_yerr/D");
115 _mcflash_tree->Branch(
"flash_z", &_flash_z,
"flash_z/D");
116 _mcflash_tree->Branch(
"flash_zerr", &_flash_zerr,
"flash_zerr/D");
117 _mcflash_tree->Branch(
"flash_pe_v",
"std::vector<double>", &_flash_pe_v);
132 art::Handle<std::vector<recob::OpHit>> ophit_h;
133 e.getByLabel(
"ophitpmt", ophit_h);
134 if(!ophit_h.isValid()){
135 std::cout <<
"Invalid producer for recob::OpHit: " <<
"ophitpmt" <<
". Ignoring." << std::endl;
137 std::vector<art::Ptr<recob::OpHit>> ophit_v;
138 art::fill_ptr_vector(ophit_v, ophit_h);
150 art::Handle<std::vector<recob::OpFlash>> flash_h;
152 if(!flash_h.isValid()){
156 art::FindManyP<recob::OpHit> flashToOpHitAssns(flash_h, e, _ophit_label_v[l]);
158 for (
size_t i = 0; i < flash_h->size(); i++) {
159 auto const& f = (*flash_h)[i];
160 std::cout <<
"Flash " << i <<
", time " << f.AbsTime() << std::endl;
177 std::vector<art::Ptr<recob::OpHit>> ophit_v = flashToOpHitAssns.at(i);
178 for (
auto ophit : ophit_v) {
193 for (
size_t l = 0; l < _mcflash_label_v.size(); l++) {
194 art::Handle<std::vector<recob::OpFlash>> flash_h;
195 e.getByLabel(_mcflash_label_v[l], flash_h);
196 if(!flash_h.isValid()){
197 std::cout <<
"Invalid producer for MC recob::OpFlash: " << _mcflash_label_v[l] <<
". Ignoring." << std::endl;
199 for (
size_t i = 0; i < flash_h->size(); i++) {
200 auto const& f = (*flash_h)[i];
std::vector< double > _flash_ophit_amp
std::vector< std::string > _ophit_label_v
std::vector< std::string > _mcflash_label_v
std::vector< double > _flash_ophit_pe
void analyze(art::Event const &e) override
opdet::sbndPDMapAlg _pds_map
std::vector< std::string > _flash_label_v
SBNDFlashAna(fhicl::ParameterSet const &p)
std::vector< int > _tpc_v
BEGIN_PROLOG opflashCryoW opflashCryoW triggerfilterBNB triggerfilterNuMI triggerfilterOffbeamBNB triggerfilterOffbeamNuMI triggerfilterUnknown roifinder roifinder2d gaushitTPCEE gaushitTPCWE purityana1 ophit
std::vector< double > _flash_pe_v
std::vector< double > _flash_ophit_width
std::vector< double > _flash_ophit_area
SBNDFlashAna & operator=(SBNDFlashAna const &)=delete
std::vector< double > _flash_ophit_time
std::string pdType(size_t ch) const override
std::vector< std::string > _flash_ophit_chname
BEGIN_PROLOG could also be cout
std::vector< int > _flash_ophit_ch