35 #include "art/Framework/Core/EDProducer.h"
36 #include "art/Framework/Core/ModuleMacros.h"
37 #include "art/Framework/Principal/Event.h"
38 #include "art/Framework/Principal/Handle.h"
39 #include "art/Framework/Principal/Run.h"
40 #include "art/Framework/Principal/SubRun.h"
41 #include "canvas/Utilities/InputTag.h"
42 #include "fhiclcpp/ParameterSet.h"
43 #include "canvas/Persistency/Common/Ptr.h"
44 #include "canvas/Persistency/Common/PtrVector.h"
45 #include "art/Framework/Services/Registry/ServiceHandle.h"
46 #include "art_root_io/TFileService.h"
47 #include "messagefacility/MessageLogger/MessageLogger.h"
48 #include "canvas/Utilities/Exception.h"
126 std::vector<int>
channel_numbers = {6,7,8,9,10,11,12,13,14,15,16,17,36,37,38,39,40,41,60,61,62,63,64,65,66,67,68,69,70,71,
127 84,85,86,87,88,89,90,91,92,93,94,95,114,115,116,117,118,119,138,139,140,141,142,143,144,145,146,147,148,149,
128 162,163,164,165,166,167,168,169,170,171,172,173,192,193,194,195,196,197,216,217,218,219,220,221,222,223,224,225,226,227,
129 240,241,242,243,244,245,246,247,248,249,250,251,270,271,272,273,274,275,294,295,296,297,298,299,300,301,302,303,304,305};
139 std::vector<int>
fPair1 = {6,8,10,12,14,16,36,38,40,84,86,88,90,92,94,114,116,118,138,140,142,144,146,148,162,164,166,168,170,172,192,194,196,216,218,220,222,224,226,240,242,244,246,248,250,270,272,274,294,296};
140 std::vector<int>
fPair2 = {7,9,11,13,15,17,37,39,41,85,87,89,91,93,95,115,117,119,139,141,143,145,147,149,163,165,167,169,171,173,193,195,197,217,219,221,223,225,227,241,243,245,247,249,251,271,273,275,295,297};
141 std::vector<int>
fUnpaired = {298,299,300,301,302,303,304,305};
152 art::ServiceHandle<art::TFileService>
tfs;
159 produces< std::vector<sbnd::comm::pmtTrigger> >();
161 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
162 fSampling = clockData.OpticalClock().Frequency();
171 fOpDetsToPlot = p.get<std::vector<std::string> >(
"OpDetsToPlot");
173 fThreshold = p.get<std::vector<double> >(
"Threshold");
175 fPair1 = p.get<std::vector<int> >(
"Pair1");
176 fPair2 = p.get<std::vector<int> >(
"Pair2");
177 fUnpaired = p.get<std::vector<int> >(
"Unpaired");
178 fPairLogic = p.get<std::string>(
"PairLogic",
"OR");
182 fEvHists = p.get<std::vector<int> >(
"EvHists");
183 fVerbose = p.get<
bool>(
"Verbose",
true);
193 std::unique_ptr< std::vector<sbnd::comm::pmtTrigger> > pmts_passed(
new std::vector<sbnd::comm::pmtTrigger>);
198 event = e.id().event();
200 art::Handle< std::vector< raw::OpDetWaveform > > waveHandle;
203 if(!waveHandle.isValid()) {
204 std::cout << Form(
"Did not find any G4 photons from a producer: %s",
"largeant") << std::endl;
237 if (i_ev!=-1 && i_ev<4){
if (
fVerbose){
std::cout <<
"Outputting Hists" << std::endl;}}
251 double fMinStartTime = -1510.0;
252 double fMaxEndTime = 1510.0;
254 for(
auto const& wvf : (*waveHandle)) {
258 if (wvf.TimeStamp() < fMinStartTime){ fMinStartTime = wvf.TimeStamp(); }
259 if ((
double(wvf.size()) /
fSampling + wvf.TimeStamp()) > fMaxEndTime){ fMaxEndTime = double(wvf.size()) /
fSampling + wvf.TimeStamp();}
261 if (
fVerbose){
std::cout<<
"MinStartTime: "<<fMinStartTime<<
" MaxEndTime: "<<fMaxEndTime<<std::endl;}
274 for (
size_t i = 0; i<120; i++){
277 for (
size_t i = 0; i<
fPair1.size(); i++){
280 for (
size_t i = 0; i<
fPair1.size(); i++){
294 for(
auto const& wvf : (*waveHandle)) {
306 double adc_threshold = 0;
317 std::cout<<
"Threshold Array Empty!"<<std::endl;
322 std::vector<char> wvf_bin;
323 wvf_bin.reserve(wvf.size());
325 if (i_ev!=-1 && i_ev<3){
334 wvfHist->GetXaxis()->SetTitle(
"t (#mus)");
335 for(
unsigned int i = 0; i < wvf.size(); i++) {
336 wvfHist->SetBinContent(i + 1, (
double)wvf[i]);
342 wvf_bin.push_back(0);
346 for(
unsigned int i = 0; i < wvf.size(); i++) {
347 if((
double)wvf[i]<adc_threshold){wvf_bin.push_back(1);}
else{wvf_bin.push_back(0);}
352 wvf_bin.push_back(0);
365 for(
unsigned int i =
channel_bin_wvfs.at(i_ch).size(); i < wvf_bin.size(); i++) {
369 for(
unsigned int i = 0; i < wvf_bin.size(); i++) {
373 wvf_bin.shrink_to_fit();
387 std::vector<char> wvf_bin_down;
388 wvf_bin_down.reserve(
int(wvf_bin.size()/4));
389 for(
unsigned int i = 0; i < wvf_bin.size(); i++) {
390 if(i%4==0){wvf_bin_down.push_back(wvf_bin[i]);}
395 if (i_ev!=-1 && i_ev<3){
401 wvfbHist->GetXaxis()->SetTitle(
"t (#mus)");
402 for(
unsigned int i = 0; i < wvf_bin.size(); i++) {
403 wvfbHist->SetBinContent(i + 1, wvf_bin[i]);
407 if (i_ev!=-1 && i_ev<3){
414 wvfbdHist->GetXaxis()->SetTitle(
"t (#mus)");
415 for(
unsigned int i = 0; i < wvf_bin_down.size(); i++) {
416 wvfbdHist->SetBinContent(i + 1, wvf_bin_down[i]);
420 bool combine =
false;
422 bool unpaired =
false;
423 size_t pair_num = -1;
425 for (
size_t i = 0; i <
fUnpaired.size(); i++){
432 for (
size_t i = 0; i <
fPair1.size(); i++){
441 for (
size_t i = 0; i <
fPair2.size(); i++){
449 if (combine || unpaired){
450 std::vector<char> wvf_combine;
451 wvf_combine.reserve(wvf_bin_down.size());
453 if (
unpaired_wvfs.at(pair_num).size()!=wvf_bin_down.size()){
std::cout<<
"Mismatched paired waveform size"<<std::endl;}
454 for(
unsigned int i = 0; i < wvf_bin_down.size(); i++) {
456 if(
unpaired_wvfs.at(pair_num)[i]==1 || wvf_bin_down[i]==1){wvf_combine.push_back(1);}
else{wvf_combine.push_back(0);}
458 if(
unpaired_wvfs.at(pair_num)[i]==1 && wvf_bin_down[i]==1){wvf_combine.push_back(1);}
else{wvf_combine.push_back(0);}
462 wvf_combine = wvf_bin_down;
465 if (i_ev!=-1 && i_ev<3){
474 <<
"_opchannels_" <<
fPair1.at(pair_num)
475 <<
"_" <<
fPair2.at(pair_num)
480 wvfcHist->GetXaxis()->SetTitle(
"t (#mus)");
481 for(
unsigned int i = 0; i < wvf_combine.size(); i++) {
482 wvfcHist->SetBinContent(i + 1, wvf_combine[i]);
488 for(
unsigned int i = 1; i < wvf_combine.size()-
fOVTHRWidth; i++) {
489 if(wvf_combine[i]==1 && wvf_combine[i-1]==0){
490 for(
unsigned int j = i+1; j < i+
fOVTHRWidth+1; j++){
496 if (i_ev!=-1 && i_ev<3){
502 <<
"_combined_width";
505 <<
"_opchannels_" <<
fPair1.at(pair_num)
506 <<
"_" <<
fPair2.at(pair_num)
507 <<
"_combined_width";
511 wvfcwHist->GetXaxis()->SetTitle(
"t (#mus)");
512 for(
unsigned int i = 0; i < wvf_combine.size(); i++) {
513 wvfcwHist->SetBinContent(i + 1, wvf_combine[i]);
522 if (startbin<0.){startbin=0;}
523 if (endbin > wvf_combine.size() - 1){endbin = wvf_combine.size() - 1;}
529 unsigned int i_p = 0;
530 for(
unsigned int i = startbin; i<endbin; i++){
535 wvf_bin_down.clear();
536 wvf_bin_down.shrink_to_fit();
538 wvf_combine.shrink_to_fit();
545 if (i_ev!=-1 && i_ev<3){
548 <<
"_passed_trigger";
551 passedHist->GetXaxis()->SetTitle(
"t (#mus)");
564 pmts_passed->push_back(pmt_time);
574 e.put(std::move(pmts_passed));
577 passed_trigger.clear();
578 passed_trigger.shrink_to_fit();
581 if (
fVerbose){
std::cout <<
"Number of PMT waveforms: " << num_pmt_wvf << std::endl;}
582 if (
fVerbose){
std::cout <<
"Number of PMT channels: " << num_pmt_ch << std::endl;}
584 channel_bin_wvfs.clear();
585 channel_bin_wvfs.shrink_to_fit();
std::vector< char > wvf_bin_0
void produce(art::Event &evt) override
std::vector< int > fPair2
std::string fInputModuleName
std::vector< std::string > fOpDetsToPlot
Declaration of signal hit object.
std::vector< double > fThreshold
std::vector< int > fUnpaired
Definition of basic raw digits.
std::vector< int > passed_trigger
bool fIndividualThresholds
std::vector< int > fPair1
Access the description of detector geometry.
Simulation objects for optical detectors.
object containing MC truth information necessary for making RawDigits and doing back tracking ...
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
Collect all the RawData header files together.
art framework interface to geometry description for auxiliary detectors
std::stringstream histname2
std::vector< int > numPassed
std::stringstream histname
pmtTriggerProducer(fhicl::ParameterSet const &p)
void reconfigure(fhicl::ParameterSet const &p)
Definition of data types for geometry description.
Encapsulate the geometry of a wire.
Encapsulate the construction of a single detector plane.
object containing MC truth information necessary for making RawDigits and doing back tracking ...
std::vector< int > channel_numbers
std::vector< int > fEvHists
std::string pdType(size_t ch) const override
opdet::sbndPDMapAlg pdMap
std::vector< char > paired
std::vector< std::vector< char > > channel_bin_wvfs
Tools and modules for checking out the basics of the Monte Carlo.
pmtTriggerProducer & operator=(pmtTriggerProducer const &)=delete
art framework interface to geometry description
BEGIN_PROLOG could also be cout
std::vector< std::vector< char > > unpaired_wvfs
art::ServiceHandle< art::TFileService > tfs