From 1407062d2682bad2e50068d738c9117ae0fbd3f9 Mon Sep 17 00:00:00 2001 From: Joseph Zennamo Date: Wed, 21 Jun 2023 16:16:26 -0500 Subject: [PATCH 1/4] Updated to TriggerV3 --- .../BNBRetriever/BNBRetriever_module.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sbncode/BeamSpillInfoRetriever/BNBRetriever/BNBRetriever_module.cc b/sbncode/BeamSpillInfoRetriever/BNBRetriever/BNBRetriever_module.cc index a907341d5..db124cf36 100644 --- a/sbncode/BeamSpillInfoRetriever/BNBRetriever/BNBRetriever_module.cc +++ b/sbncode/BeamSpillInfoRetriever/BNBRetriever/BNBRetriever_module.cc @@ -20,7 +20,7 @@ #include "larcorealg/CoreUtils/counter.h" #include "artdaq-core/Data/Fragment.hh" -#include "sbndaq-artdaq-core/Overlays/ICARUS/ICARUSTriggerV2Fragment.hh" +#include "sbndaq-artdaq-core/Overlays/ICARUS/ICARUSTriggerV3Fragment.hh" #include "sbnobj/Common/POTAccounting/BNBSpillInfo.h" @@ -245,23 +245,23 @@ sbn::BNBRetriever::TriggerInfo_t sbn::BNBRetriever::extractTriggerInfo(art::Even // 2. the time of the previously triggered event, t_previous_event (NOTE: Events are non-sequential!) // 3. the number of beam spills since the previously triggered event, number_of_gates_since_previous_event - auto const & raw_data = e.getProduct< std::vector >({ raw_data_label, "ICARUSTriggerV2" }); + auto const & raw_data = e.getProduct< std::vector >({ raw_data_label, "ICARUSTriggerV3" }); TriggerInfo_t triggerInfo; for(auto raw_datum : raw_data){ uint64_t artdaq_ts = raw_datum.timestamp(); - icarus::ICARUSTriggerV2Fragment frag(raw_datum); + icarus::ICARUSTriggerV3Fragment frag(raw_datum); std::string data = frag.GetDataString(); char *buffer = const_cast(data.c_str()); - icarus::ICARUSTriggerInfo datastream_info = icarus::parse_ICARUSTriggerV2String(buffer); + icarus::ICARUSTriggerInfo datastream_info = icarus::parse_ICARUSTriggerV3String(buffer); triggerInfo.gate_type = datastream_info.gate_type; - triggerInfo.number_of_gates_since_previous_event = frag.getDeltaGatesBNB(); + triggerInfo.number_of_gates_since_previous_event = frag.getDeltaGatesBNBMaj(); triggerInfo.t_current_event = static_cast(artdaq_ts)/(1000000000.0); //check this offset... if(triggerInfo.gate_type == 1) - triggerInfo.t_previous_event = (static_cast(frag.getLastTimestampBNB()))/(1e9); + triggerInfo.t_previous_event = (static_cast(frag.getLastTimestampBNBMaj()))/(1e9); else triggerInfo.t_previous_event = (static_cast(frag.getLastTimestampOther()))/(1000000000.0); From f24eba3daeb479839a3a7ce8a46d3a3c6d639915 Mon Sep 17 00:00:00 2001 From: Joseph Zennamo Date: Wed, 21 Jun 2023 17:28:50 -0500 Subject: [PATCH 2/4] Updated to Trigger V3 --- .../BNBEXTRetriever_module.cc} | 41 +-- .../CMakeLists.txt | 2 +- sbncode/BeamSpillInfoRetriever/CMakeLists.txt | 3 +- .../NuMIEXTRetriever/CMakeLists.txt | 20 ++ .../NuMIEXTRetriever_module.cc | 155 +++++++++++ .../NuMIRetriever/NuMIRetriever_module.cc | 254 +++++++++--------- .../job/bnbextcountinfo.fcl | 10 + .../job/extcountinfo.fcl | 10 - .../job/numiextcountinfo.fcl | 10 + ...extinfo_sbn.fcl => run_bnbextinfo_sbn.fcl} | 10 +- .../job/run_numiextinfo_sbn.fcl | 32 +++ 11 files changed, 383 insertions(+), 164 deletions(-) rename sbncode/BeamSpillInfoRetriever/{EXTRetriever/EXTRetriever_module.cc => BNBEXTRetriever/BNBEXTRetriever_module.cc} (79%) rename sbncode/BeamSpillInfoRetriever/{EXTRetriever => BNBEXTRetriever}/CMakeLists.txt (92%) create mode 100644 sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/CMakeLists.txt create mode 100644 sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/NuMIEXTRetriever_module.cc create mode 100644 sbncode/BeamSpillInfoRetriever/job/bnbextcountinfo.fcl delete mode 100644 sbncode/BeamSpillInfoRetriever/job/extcountinfo.fcl create mode 100644 sbncode/BeamSpillInfoRetriever/job/numiextcountinfo.fcl rename sbncode/BeamSpillInfoRetriever/job/{run_extinfo_sbn.fcl => run_bnbextinfo_sbn.fcl} (53%) create mode 100644 sbncode/BeamSpillInfoRetriever/job/run_numiextinfo_sbn.fcl diff --git a/sbncode/BeamSpillInfoRetriever/EXTRetriever/EXTRetriever_module.cc b/sbncode/BeamSpillInfoRetriever/BNBEXTRetriever/BNBEXTRetriever_module.cc similarity index 79% rename from sbncode/BeamSpillInfoRetriever/EXTRetriever/EXTRetriever_module.cc rename to sbncode/BeamSpillInfoRetriever/BNBEXTRetriever/BNBEXTRetriever_module.cc index 77d0661e1..9f14e29d3 100644 --- a/sbncode/BeamSpillInfoRetriever/EXTRetriever/EXTRetriever_module.cc +++ b/sbncode/BeamSpillInfoRetriever/BNBEXTRetriever/BNBEXTRetriever_module.cc @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////////////////// -// Class: EXTRetriever +// Class: BNBEXTRetriever // Plugin Type: producer -// File: EXTRetriever_module.cc +// File: BNBEXTRetriever_module.cc // // Created by hand Thurs June 24th 2021 by J. Zennamo (FNAL) // @@ -22,7 +22,7 @@ #include "larcorealg/Geometry/Exceptions.h" #include "artdaq-core/Data/Fragment.hh" -#include "sbndaq-artdaq-core/Overlays/ICARUS/ICARUSTriggerUDPFragment.hh" +#include "sbndaq-artdaq-core/Overlays/ICARUS/ICARUSTriggerV3Fragment.hh" #include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" @@ -36,10 +36,10 @@ #include namespace sbn { - class EXTRetriever; + class BNBEXTRetriever; } -class sbn::EXTRetriever : public art::EDProducer { +class sbn::BNBEXTRetriever : public art::EDProducer { public: struct Config { @@ -57,15 +57,15 @@ class sbn::EXTRetriever : public art::EDProducer { using Parameters = art::EDProducer::Table; - explicit EXTRetriever(Parameters const& params); + explicit BNBEXTRetriever(Parameters const& params); // The compiler-generated destructor is fine for non-base // classes without bare pointers or other resource use. // Plugins should not be copied or assigned. - EXTRetriever(EXTRetriever const&) = delete; - EXTRetriever(EXTRetriever&&) = delete; - EXTRetriever& operator=(EXTRetriever const&) = delete; - EXTRetriever& operator=(EXTRetriever&&) = delete; + BNBEXTRetriever(BNBEXTRetriever const&) = delete; + BNBEXTRetriever(BNBEXTRetriever&&) = delete; + BNBEXTRetriever& operator=(BNBEXTRetriever const&) = delete; + BNBEXTRetriever& operator=(BNBEXTRetriever&&) = delete; // Required functions. void produce(art::Event& e) override; @@ -82,7 +82,7 @@ class sbn::EXTRetriever : public art::EDProducer { }; -sbn::EXTRetriever::EXTRetriever(Parameters const& params) +sbn::BNBEXTRetriever::BNBEXTRetriever(Parameters const& params) : EDProducer{params}, raw_data_label_(params().RawDataLabel()) { @@ -91,7 +91,7 @@ sbn::EXTRetriever::EXTRetriever(Parameters const& params) TotalEXTCounts = 0; } -void sbn::EXTRetriever::produce(art::Event& e) +void sbn::BNBEXTRetriever::produce(art::Event& e) { //Here we read in the artdaq Fragments and extract three pieces of information: @@ -100,19 +100,22 @@ void sbn::EXTRetriever::produce(art::Event& e) // 3. the number of beam spills since the previously triggered event, number_of_gates_since_previous_event int gate_type = 0; - auto const & raw_data = e.getProduct< std::vector >({ raw_data_label_, "ICARUSTriggerUDP" }); + auto const & raw_data = e.getProduct< std::vector >({ raw_data_label_, "ICARUSTriggerV3" }); unsigned int number_of_gates_since_previous_event = 0; for(auto raw_datum : raw_data){ - icarus::ICARUSTriggerUDPFragment frag(raw_datum); + icarus::ICARUSTriggerV3Fragment frag(raw_datum); std::string data = frag.GetDataString(); char *buffer = const_cast(data.c_str()); - icarus::ICARUSTriggerInfo datastream_info = icarus::parse_ICARUSTriggerString(buffer); + icarus::ICARUSTriggerInfo datastream_info = icarus::parse_ICARUSTriggerV3String(buffer); gate_type = datastream_info.gate_type; - number_of_gates_since_previous_event = frag.getDeltaGatesBNB(); + number_of_gates_since_previous_event = frag.getDeltaGatesBNBOffMaj(); + std::cout << "BNB OFF MAJ : " << frag.getDeltaGatesBNBOffMaj() << std::endl; + std::cout << "NuMI OFF MAJ : " << frag.getDeltaGatesNuMIOffMaj() << std::endl; + } //We only want to process EXT gates, i.e. type 3 @@ -135,13 +138,13 @@ void sbn::EXTRetriever::produce(art::Event& e) } //end loop over events -void sbn::EXTRetriever::beginSubRun(art::SubRun& sr) +void sbn::BNBEXTRetriever::beginSubRun(art::SubRun& sr) { return; } //____________________________________________________________________________ -void sbn::EXTRetriever::endSubRun(art::SubRun& sr) +void sbn::BNBEXTRetriever::endSubRun(art::SubRun& sr) { // We will add all of the EXTCountInfo data-products to the // art::SubRun so it persists @@ -152,4 +155,4 @@ void sbn::EXTRetriever::endSubRun(art::SubRun& sr) return; } -DEFINE_ART_MODULE(sbn::EXTRetriever) +DEFINE_ART_MODULE(sbn::BNBEXTRetriever) diff --git a/sbncode/BeamSpillInfoRetriever/EXTRetriever/CMakeLists.txt b/sbncode/BeamSpillInfoRetriever/BNBEXTRetriever/CMakeLists.txt similarity index 92% rename from sbncode/BeamSpillInfoRetriever/EXTRetriever/CMakeLists.txt rename to sbncode/BeamSpillInfoRetriever/BNBEXTRetriever/CMakeLists.txt index 316419a52..1c49f8646 100644 --- a/sbncode/BeamSpillInfoRetriever/EXTRetriever/CMakeLists.txt +++ b/sbncode/BeamSpillInfoRetriever/BNBEXTRetriever/CMakeLists.txt @@ -1,5 +1,5 @@ -cet_build_plugin(EXTRetriever art::module +cet_build_plugin(BNBEXTRetriever art::module LIBRARIES art::Persistency_Common art::Utilities canvas::canvas diff --git a/sbncode/BeamSpillInfoRetriever/CMakeLists.txt b/sbncode/BeamSpillInfoRetriever/CMakeLists.txt index 1a6fecf80..0caadf2a5 100644 --- a/sbncode/BeamSpillInfoRetriever/CMakeLists.txt +++ b/sbncode/BeamSpillInfoRetriever/CMakeLists.txt @@ -1,6 +1,7 @@ add_subdirectory(BNBRetriever) add_subdirectory(NuMIRetriever) -add_subdirectory(EXTRetriever) +add_subdirectory(BNBEXTRetriever) +add_subdirectory(NuMIEXTRetriever) add_subdirectory(job) install_headers() diff --git a/sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/CMakeLists.txt b/sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/CMakeLists.txt new file mode 100644 index 000000000..f11657b00 --- /dev/null +++ b/sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/CMakeLists.txt @@ -0,0 +1,20 @@ + +cet_build_plugin(NuMIEXTRetriever art::module + LIBRARIES + art::Persistency_Common + art::Utilities canvas::canvas + cetlib::cetlib cetlib_except::cetlib_except + messagefacility::MF_MessageLogger + sbnobj::Common_POTAccounting + sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays_Common + sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays + sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays_ICARUS + artdaq_core::artdaq-core_Utilities + lardata::Utilities + larcore::Geometry_AuxDetGeometry_service +) + +install_headers() +install_fhicl() +install_source() + diff --git a/sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/NuMIEXTRetriever_module.cc b/sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/NuMIEXTRetriever_module.cc new file mode 100644 index 000000000..7fdc974e2 --- /dev/null +++ b/sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/NuMIEXTRetriever_module.cc @@ -0,0 +1,155 @@ +//////////////////////////////////////////////////////////////////////// +// Class: NuMIEXTRetriever +// Plugin Type: producer +// File: NuMIEXTRetriever_module.cc +// +// Created by hand Thurs June 24th 2021 by J. Zennamo (FNAL) +// +//////////////////////////////////////////////////////////////////////// + +#include "art/Framework/Core/EDProducer.h" +#include "art/Framework/Core/ModuleMacros.h" +#include "art/Framework/Principal/Event.h" +#include "art/Framework/Principal/Handle.h" +#include "art/Framework/Principal/Run.h" +#include "art/Framework/Principal/SubRun.h" +#include "canvas/Utilities/InputTag.h" +#include "fhiclcpp/types/Atom.h" +#include "messagefacility/MessageLogger/MessageLogger.h" +#include "lardata/Utilities/AssociationUtil.h" +#include "lardataobj/Utilities/sparse_vector.h" +#include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" +#include "larcorealg/Geometry/Exceptions.h" + +#include "artdaq-core/Data/Fragment.hh" +#include "sbndaq-artdaq-core/Overlays/ICARUS/ICARUSTriggerV3Fragment.hh" + +#include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h" +#include "lardata/DetectorInfoServices/DetectorPropertiesService.h" +#include "sbnobj/Common/POTAccounting/EXTCountInfo.h" + +#include +#include +#include +#include +#include +#include + +namespace sbn { + class NuMIEXTRetriever; +} + +class sbn::NuMIEXTRetriever : public art::EDProducer { +public: + + struct Config { + + using Name = fhicl::Name; + using Comment = fhicl::Comment; + + fhicl::Atom RawDataLabel { + Name{ "raw_data_label" }, + Comment{ "art data product instance name for trigger information (product label is 'daq')" } + }; + + }; // Config + + using Parameters = art::EDProducer::Table; + + + explicit NuMIEXTRetriever(Parameters const& params); + // The compiler-generated destructor is fine for non-base + // classes without bare pointers or other resource use. + + // Plugins should not be copied or assigned. + NuMIEXTRetriever(NuMIEXTRetriever const&) = delete; + NuMIEXTRetriever(NuMIEXTRetriever&&) = delete; + NuMIEXTRetriever& operator=(NuMIEXTRetriever const&) = delete; + NuMIEXTRetriever& operator=(NuMIEXTRetriever&&) = delete; + + // Required functions. + void produce(art::Event& e) override; + void beginSubRun(art::SubRun& sr) override; + void endSubRun(art::SubRun& sr) override; + +private: + std::vector< sbn::EXTCountInfo > fOutExtInfos; + + // input labels + std::string raw_data_label_; + int TotalEXTCounts; + +}; + + +sbn::NuMIEXTRetriever::NuMIEXTRetriever(Parameters const& params) + : EDProducer{params}, + raw_data_label_(params().RawDataLabel()) +{ + + produces< std::vector< sbn::EXTCountInfo >, art::InSubRun >(); + TotalEXTCounts = 0; +} + +void sbn::NuMIEXTRetriever::produce(art::Event& e) +{ + + //Here we read in the artdaq Fragments and extract three pieces of information: + // 1. The time of the current event, t_current_event + // 2. the time of the previously triggered event, t_previous_event (NOTE: Events are non-sequential!) + // 3. the number of beam spills since the previously triggered event, number_of_gates_since_previous_event + + //int gate_type = 0; + auto const & raw_data = e.getProduct< std::vector >({ raw_data_label_, "ICARUSTriggerV3" }); + + unsigned int number_of_gates_since_previous_event = 0; + + for(auto raw_datum : raw_data){ + + icarus::ICARUSTriggerV3Fragment frag(raw_datum); + std::string data = frag.GetDataString(); + char *buffer = const_cast(data.c_str()); + icarus::ICARUSTriggerInfo datastream_info = icarus::parse_ICARUSTriggerV3String(buffer); + //gate_type = datastream_info.gate_type; + number_of_gates_since_previous_event = frag.getDeltaGatesNuMIOffMaj(); + + + } + + //We only want to process EXT gates, i.e. type 3 + + // Keep track of the number of beam gates the DAQ thinks + // are in this file + TotalEXTCounts += number_of_gates_since_previous_event; + + //Store everything in our data-product + sbn::EXTCountInfo extInfo; + extInfo.gates_since_last_trigger = number_of_gates_since_previous_event; + + fOutExtInfos.push_back(extInfo); + // We do not write these to the art::Events because + // we can filter events but want to keep all the POT + // information, so we'll write it to the SubRun + + +} //end loop over events + + +void sbn::NuMIEXTRetriever::beginSubRun(art::SubRun& sr) +{ + return; +} + +//____________________________________________________________________________ +void sbn::NuMIEXTRetriever::endSubRun(art::SubRun& sr) +{ + // We will add all of the EXTCountInfo data-products to the + // art::SubRun so it persists + auto p = std::make_unique< std::vector< sbn::EXTCountInfo > >(fOutExtInfos); + + sr.put(std::move(p)); + + return; +} + +DEFINE_ART_MODULE(sbn::NuMIEXTRetriever) diff --git a/sbncode/BeamSpillInfoRetriever/NuMIRetriever/NuMIRetriever_module.cc b/sbncode/BeamSpillInfoRetriever/NuMIRetriever/NuMIRetriever_module.cc index 84e4c6d03..a0eb1e48a 100644 --- a/sbncode/BeamSpillInfoRetriever/NuMIRetriever/NuMIRetriever_module.cc +++ b/sbncode/BeamSpillInfoRetriever/NuMIRetriever/NuMIRetriever_module.cc @@ -19,7 +19,7 @@ #include "larcorealg/Geometry/Exceptions.h" #include "artdaq-core/Data/Fragment.hh" -#include "sbndaq-artdaq-core/Overlays/ICARUS/ICARUSTriggerV2Fragment.hh" +#include "sbndaq-artdaq-core/Overlays/ICARUS/ICARUSTriggerV3Fragment.hh" #include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" @@ -104,9 +104,9 @@ void sbn::NuMIRetriever::produce(art::Event &e) // TODO: long-term goal -- can we fix this? if (e.event() == 1) return; - int gate_type = 0; + // int gate_type = 0; art::Handle< std::vector > raw_data_ptr; - e.getByLabel(raw_data_label_, "ICARUSTriggerV2", raw_data_ptr); + e.getByLabel(raw_data_label_, "ICARUSTriggerV3", raw_data_ptr); auto const & raw_data = (*raw_data_ptr); double t_current_event = 0; @@ -116,145 +116,143 @@ void sbn::NuMIRetriever::produce(art::Event &e) for(auto raw_datum : raw_data){ uint64_t artdaq_ts = raw_datum.timestamp(); - icarus::ICARUSTriggerV2Fragment frag(raw_datum); + icarus::ICARUSTriggerV3Fragment frag(raw_datum); std::string data = frag.GetDataString(); char *buffer = const_cast(data.c_str()); - icarus::ICARUSTriggerInfo datastream_info = icarus::parse_ICARUSTriggerV2String(buffer); - gate_type = datastream_info.gate_type; - number_of_gates_since_previous_event = frag.getDeltaGatesNuMI(); + icarus::ICARUSTriggerInfo datastream_info = icarus::parse_ICARUSTriggerV3String(buffer); + //gate_type = datastream_info.gate_type; + number_of_gates_since_previous_event = frag.getDeltaGatesNuMIMaj(); t_current_event = static_cast(artdaq_ts)/(1000000000.); //check this offset... - if(gate_type == 2) - t_previous_event = (static_cast(frag.getLastTimestampNuMI()))/(1000000000.); - else - t_previous_event = (static_cast(frag.getLastTimestampOther()))/(1000000000.); + + t_previous_event = (static_cast(frag.getLastTimestampNuMIMaj()))/(1000000000.); + } std::cout << std::setprecision(19) << "Previous : " << t_previous_event << ", Current : " << t_current_event << std::endl; //We only want to process NuMI gates, i.e. type 2 - if(gate_type == 2) - { - // Keep track of the number of beam gates the DAQ thinks - // are in this job - TotalBeamSpills += number_of_gates_since_previous_event; + + // Keep track of the number of beam gates the DAQ thinks + // are in this job + TotalBeamSpills += number_of_gates_since_previous_event; + + // Fill up the BFP cache with times starting at the previous event + // + // If the difference in time between events is bigger than the fcl-provided TimeWindow, then + // we won't be able to fill up the cache to be big enough. In that case, resize the window as + // necessary. + double this_window_size = t_current_event - t_previous_event + 2*fTimePad; + if (this_window_size > fTimeWindow) { + std::cout << "Resizing time window from: " << fTimeWindow << " to: " << this_window_size << std::endl; + fTimeWindow = this_window_size; + MakeBFP(); + } + + // DO NOT CHANGE THESE LINES OR THEIR ORDER + // If you really think you need to, please reach out to grayputnam uchicago.edu + bfp->FillCache(t_current_event + fTimePad); + bfp->FillCache(t_previous_event - fTimePad); + std::vector times_temps = bfp->GetTimeList(fDeviceUsedForTiming); + + int spill_count = 0; + // Iterating through each of the beamline times + for (size_t i = 0; i < times_temps.size(); i++) { - // Fill up the BFP cache with times starting at the previous event - // - // If the difference in time between events is bigger than the fcl-provided TimeWindow, then - // we won't be able to fill up the cache to be big enough. In that case, resize the window as - // necessary. - double this_window_size = t_current_event - t_previous_event + 2*fTimePad; - if (this_window_size > fTimeWindow) { - std::cout << "Resizing time window from: " << fTimeWindow << " to: " << this_window_size << std::endl; - fTimeWindow = this_window_size; - MakeBFP(); + // Only continue if these times are matched to our DAQ time + // plus or minus some time padding, currently using 3.3 ms + // which is half the Booster Rep Rate + if(e.event() != 1){//We already addressed the "first event" above + if(times_temps[i] > t_current_event){continue;} + if(times_temps[i] <= t_previous_event){continue;} } - - // DO NOT CHANGE THESE LINES OR THEIR ORDER - // If you really think you need to, please reach out to grayputnam uchicago.edu - bfp->FillCache(t_current_event + fTimePad); - bfp->FillCache(t_previous_event - fTimePad); - std::vector times_temps = bfp->GetTimeList(fDeviceUsedForTiming); - - int spill_count = 0; - // Iterating through each of the beamline times - for (size_t i = 0; i < times_temps.size(); i++) { - - // Only continue if these times are matched to our DAQ time - // plus or minus some time padding, currently using 3.3 ms - // which is half the Booster Rep Rate - if(e.event() != 1){//We already addressed the "first event" above - if(times_temps[i] > t_current_event){continue;} - if(times_temps[i] <= t_previous_event){continue;} - } - - //count found spills - spill_count++; - - //initialize all devices found in NuMISpillInfo.h in sbnobj - double HRNDIR = -1.; - double NSLINA = -1.; - double NSLINB = -1.; - double NSLINC = -1.; - double NSLIND = -1.; - double TOR101 = -1.; - double TORTGT = -1.; - double TR101D = -1.; - double TRTGTD = -1.; - std::vector< double > HP121; - std::vector< double > VP121; - std::vector< double > HPTGT; - std::vector< double > VPTGT; - std::vector< double > HITGT; - std::vector< double > VITGT; - std::vector< double > MTGTDS; - double TRTGTD_time = -1.; - std::cout << "Grabbing IFBeam info!" << std::endl; - try{bfp->GetNamedData(times_temps[i], "E:TRTGTD@",&TRTGTD,&TRTGTD_time);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} - try{bfp->GetNamedData(times_temps[i], "E:TR101D",&TR101D);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} - try{bfp->GetNamedData(times_temps[i], "E:HRNDIR",&HRNDIR);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} - try{bfp->GetNamedData(times_temps[i], "E:NSLINA",&NSLINA);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} - try{bfp->GetNamedData(times_temps[i], "E:NSLINB",&NSLINB);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} - try{bfp->GetNamedData(times_temps[i], "E:NSLINC",&NSLINC);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} - try{bfp->GetNamedData(times_temps[i], "E:NSLIND",&NSLIND);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} - try{bfp->GetNamedData(times_temps[i], "E:TOR101",&TOR101);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} - try{bfp->GetNamedData(times_temps[i], "E:TORTGT",&TORTGT);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} - // BPM Positions and Intensities - they each have 7 elements - // First is an average value of a few batches (often 2,3,4) - // used for auto-tuning, so we should disregard it - - try{HP121 = bfp->GetNamedVector(times_temps[i], "E:HP121[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} - try{VP121 = bfp->GetNamedVector(times_temps[i], "E:VP121[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} - try{HPTGT = bfp->GetNamedVector(times_temps[i], "E:HPTGT[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} - try{VPTGT = bfp->GetNamedVector(times_temps[i], "E:VPTGT[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} - try{HITGT = bfp->GetNamedVector(times_temps[i], "E:HITGT[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} - try{VITGT = bfp->GetNamedVector(times_temps[i], "E:VITGT[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} - try{MTGTDS = bfp->GetNamedVector(times_temps[i], "E:MTGTDS[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} - - std::cout << "Finished getting IFBeam info" << std::endl; - std::cout << "BFP Time: " << times_temps[i] << " TOROID Time: " << TRTGTD_time << " TOROID COUNT: " << TRTGTD << std::endl; - unsigned long int time_closest_int = (int) TRTGTD_time; - double time_closest_ns = (TRTGTD_time - time_closest_int)*1000000000; - - sbn::NuMISpillInfo NuMIbeamInfo; - NuMIbeamInfo.TORTGT = TORTGT*1e12; //include factor of 1e12 protons in POT calculation - NuMIbeamInfo.TOR101 = TOR101*1e12; //include factor of 1e12 protons in POT calculation - NuMIbeamInfo.TRTGTD = TRTGTD*1e12; //include factor of 1e12 protons in POT calculation - NuMIbeamInfo.TR101D = TR101D*1e12; //include factor of 1e12 protons in POT calculation - NuMIbeamInfo.HRNDIR = HRNDIR; - NuMIbeamInfo.NSLINA = NSLINA; - NuMIbeamInfo.NSLINB = NSLINB; - NuMIbeamInfo.NSLINC = NSLINC; - NuMIbeamInfo.NSLIND = NSLIND; - - NuMIbeamInfo.HP121 = HP121; - NuMIbeamInfo.VP121 = VP121; - NuMIbeamInfo.HPTGT = HPTGT; - NuMIbeamInfo.VPTGT = VPTGT; - NuMIbeamInfo.HITGT = HITGT; - NuMIbeamInfo.VITGT = VITGT; - NuMIbeamInfo.MTGTDS = MTGTDS; - - NuMIbeamInfo.time = times_temps[i]; - NuMIbeamInfo.event = e.event(); - NuMIbeamInfo.spill_time_s = time_closest_int; - NuMIbeamInfo.spill_time_ns = time_closest_ns; + + //count found spills + spill_count++; + + //initialize all devices found in NuMISpillInfo.h in sbnobj + double HRNDIR = -1.; + double NSLINA = -1.; + double NSLINB = -1.; + double NSLINC = -1.; + double NSLIND = -1.; + double TOR101 = -1.; + double TORTGT = -1.; + double TR101D = -1.; + double TRTGTD = -1.; + std::vector< double > HP121; + std::vector< double > VP121; + std::vector< double > HPTGT; + std::vector< double > VPTGT; + std::vector< double > HITGT; + std::vector< double > VITGT; + std::vector< double > MTGTDS; + double TRTGTD_time = -1.; + std::cout << "Grabbing IFBeam info!" << std::endl; + try{bfp->GetNamedData(times_temps[i], "E:TRTGTD@",&TRTGTD,&TRTGTD_time);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} + try{bfp->GetNamedData(times_temps[i], "E:TR101D",&TR101D);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} + try{bfp->GetNamedData(times_temps[i], "E:HRNDIR",&HRNDIR);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} + try{bfp->GetNamedData(times_temps[i], "E:NSLINA",&NSLINA);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} + try{bfp->GetNamedData(times_temps[i], "E:NSLINB",&NSLINB);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} + try{bfp->GetNamedData(times_temps[i], "E:NSLINC",&NSLINC);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} + try{bfp->GetNamedData(times_temps[i], "E:NSLIND",&NSLIND);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} + try{bfp->GetNamedData(times_temps[i], "E:TOR101",&TOR101);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} + try{bfp->GetNamedData(times_temps[i], "E:TORTGT",&TORTGT);}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} + // BPM Positions and Intensities - they each have 7 elements + // First is an average value of a few batches (often 2,3,4) + // used for auto-tuning, so we should disregard it + + try{HP121 = bfp->GetNamedVector(times_temps[i], "E:HP121[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " << "got exception: " << we.what() << "\n";} + try{VP121 = bfp->GetNamedVector(times_temps[i], "E:VP121[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} + try{HPTGT = bfp->GetNamedVector(times_temps[i], "E:HPTGT[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} + try{VPTGT = bfp->GetNamedVector(times_temps[i], "E:VPTGT[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} + try{HITGT = bfp->GetNamedVector(times_temps[i], "E:HITGT[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} + try{VITGT = bfp->GetNamedVector(times_temps[i], "E:VITGT[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} + try{MTGTDS = bfp->GetNamedVector(times_temps[i], "E:MTGTDS[]");}catch (WebAPIException &we) {std::cout << "At time : " << times_temps[i] << " " <<"got exception: " << we.what() << "\n";} + + std::cout << "Finished getting IFBeam info" << std::endl; + std::cout << "BFP Time: " << times_temps[i] << " TOROID Time: " << TRTGTD_time << " TOROID COUNT: " << TRTGTD << std::endl; + unsigned long int time_closest_int = (int) TRTGTD_time; + double time_closest_ns = (TRTGTD_time - time_closest_int)*1000000000; + + sbn::NuMISpillInfo NuMIbeamInfo; + NuMIbeamInfo.TORTGT = TORTGT*1e12; //include factor of 1e12 protons in POT calculation + NuMIbeamInfo.TOR101 = TOR101*1e12; //include factor of 1e12 protons in POT calculation + NuMIbeamInfo.TRTGTD = TRTGTD*1e12; //include factor of 1e12 protons in POT calculation + NuMIbeamInfo.TR101D = TR101D*1e12; //include factor of 1e12 protons in POT calculation + NuMIbeamInfo.HRNDIR = HRNDIR; + NuMIbeamInfo.NSLINA = NSLINA; + NuMIbeamInfo.NSLINB = NSLINB; + NuMIbeamInfo.NSLINC = NSLINC; + NuMIbeamInfo.NSLIND = NSLIND; + + NuMIbeamInfo.HP121 = HP121; + NuMIbeamInfo.VP121 = VP121; + NuMIbeamInfo.HPTGT = HPTGT; + NuMIbeamInfo.VPTGT = VPTGT; + NuMIbeamInfo.HITGT = HITGT; + NuMIbeamInfo.VITGT = VITGT; + NuMIbeamInfo.MTGTDS = MTGTDS; + + NuMIbeamInfo.time = times_temps[i]; + NuMIbeamInfo.event = e.event(); + NuMIbeamInfo.spill_time_s = time_closest_int; + NuMIbeamInfo.spill_time_ns = time_closest_ns; // Save the Number of DAQ Gates in the first saved spill - if (spill_count == 1) { - NuMIbeamInfo.daq_gates = number_of_gates_since_previous_event; - } - else { - NuMIbeamInfo.daq_gates = 0; + if (spill_count == 1) { + NuMIbeamInfo.daq_gates = number_of_gates_since_previous_event; } - - fOutbeamInfos.push_back(NuMIbeamInfo); + else { + NuMIbeamInfo.daq_gates = 0; } - if(spill_count > number_of_gates_since_previous_event) - std::cout << "Event Spills : " << spill_count << ", DAQ Spills : " << number_of_gates_since_previous_event << " \t \t ::: WRONG!"<< std::endl; - else - std::cout << "Event Spills : " << spill_count << ", DAQ Spills : " << number_of_gates_since_previous_event << std::endl; - } + + fOutbeamInfos.push_back(NuMIbeamInfo); + } + if(spill_count > number_of_gates_since_previous_event) + std::cout << "Event Spills : " << spill_count << ", DAQ Spills : " << number_of_gates_since_previous_event << " \t \t ::: WRONG!"<< std::endl; + else + std::cout << "Event Spills : " << spill_count << ", DAQ Spills : " << number_of_gates_since_previous_event << std::endl; + } void sbn::NuMIRetriever::beginSubRun(art::SubRun& sr) diff --git a/sbncode/BeamSpillInfoRetriever/job/bnbextcountinfo.fcl b/sbncode/BeamSpillInfoRetriever/job/bnbextcountinfo.fcl new file mode 100644 index 000000000..e8191e2dc --- /dev/null +++ b/sbncode/BeamSpillInfoRetriever/job/bnbextcountinfo.fcl @@ -0,0 +1,10 @@ + +BEGIN_PROLOG + +bnbextcountinfo: { + + module_type: "BNBEXTRetriever" + raw_data_label: "daq" + +} +END_PROLOG diff --git a/sbncode/BeamSpillInfoRetriever/job/extcountinfo.fcl b/sbncode/BeamSpillInfoRetriever/job/extcountinfo.fcl deleted file mode 100644 index 1ca870996..000000000 --- a/sbncode/BeamSpillInfoRetriever/job/extcountinfo.fcl +++ /dev/null @@ -1,10 +0,0 @@ - -BEGIN_PROLOG - -extcountinfo: { - - module_type: "EXTRetriever" - raw_data_label: "daq" - -} -END_PROLOG diff --git a/sbncode/BeamSpillInfoRetriever/job/numiextcountinfo.fcl b/sbncode/BeamSpillInfoRetriever/job/numiextcountinfo.fcl new file mode 100644 index 000000000..f9a9583f5 --- /dev/null +++ b/sbncode/BeamSpillInfoRetriever/job/numiextcountinfo.fcl @@ -0,0 +1,10 @@ + +BEGIN_PROLOG + +numiextcountinfo: { + + module_type: "NuMIEXTRetriever" + raw_data_label: "daq" + +} +END_PROLOG diff --git a/sbncode/BeamSpillInfoRetriever/job/run_extinfo_sbn.fcl b/sbncode/BeamSpillInfoRetriever/job/run_bnbextinfo_sbn.fcl similarity index 53% rename from sbncode/BeamSpillInfoRetriever/job/run_extinfo_sbn.fcl rename to sbncode/BeamSpillInfoRetriever/job/run_bnbextinfo_sbn.fcl index e55cb29fe..fbee5871f 100644 --- a/sbncode/BeamSpillInfoRetriever/job/run_extinfo_sbn.fcl +++ b/sbncode/BeamSpillInfoRetriever/job/run_bnbextinfo_sbn.fcl @@ -1,6 +1,6 @@ -#include "extcountinfo.fcl" +#include "bnbextcountinfo.fcl" -process_name: EXTInfoGen +process_name: BNBEXTInfoGen services:{ IFBeam:{} @@ -13,10 +13,10 @@ source: { physics: { producers: { - extinfo: @local::extcountinfo + bnbextinfo: @local::bnbextcountinfo } - simulate: [extinfo ] + simulate: [bnbextinfo ] stream1: [ out1 ] } @@ -24,7 +24,7 @@ physics: { outputs: { out1: { module_type: RootOutput - fileName: "%ifb_%tc_extinfo.root" + fileName: "%ifb_%tc_bnbextinfo.root" dataTier: "raw" compressionLevel: 1 } diff --git a/sbncode/BeamSpillInfoRetriever/job/run_numiextinfo_sbn.fcl b/sbncode/BeamSpillInfoRetriever/job/run_numiextinfo_sbn.fcl new file mode 100644 index 000000000..e41261cda --- /dev/null +++ b/sbncode/BeamSpillInfoRetriever/job/run_numiextinfo_sbn.fcl @@ -0,0 +1,32 @@ +#include "numiextcountinfo.fcl" + +process_name: NuMIEXTInfoGen + +services:{ + IFBeam:{} +} + + +source: { + +} + +physics: { + producers: { + numiextinfo: @local::numiextcountinfo + } + + simulate: [numiextinfo ] + stream1: [ out1 ] + +} + +outputs: { + out1: { + module_type: RootOutput + fileName: "%ifb_%tc_numiextinfo.root" + dataTier: "raw" + compressionLevel: 1 + } +} + From f96d37c0a1d657fe2b9b57a5fb0bdba883dd5899 Mon Sep 17 00:00:00 2001 From: gputnam Date: Fri, 28 Jul 2023 15:49:37 -0500 Subject: [PATCH 3/4] Allow time shift in trigger to IFBeam timing. Skip first event in stream in each run. --- .../NuMIEXTRetriever_module.cc | 10 +++++-- .../NuMIRetriever/NuMIRetriever_module.cc | 29 ++++++++++--------- .../job/numispillinfo.fcl | 3 +- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/NuMIEXTRetriever_module.cc b/sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/NuMIEXTRetriever_module.cc index 7fdc974e2..460bec481 100644 --- a/sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/NuMIEXTRetriever_module.cc +++ b/sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/NuMIEXTRetriever_module.cc @@ -27,6 +27,7 @@ #include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" #include "sbnobj/Common/POTAccounting/EXTCountInfo.h" +#include "sbnobj/Common/Trigger/BeamBits.h" #include #include @@ -110,9 +111,12 @@ void sbn::NuMIEXTRetriever::produce(art::Event& e) std::string data = frag.GetDataString(); char *buffer = const_cast(data.c_str()); icarus::ICARUSTriggerInfo datastream_info = icarus::parse_ICARUSTriggerV3String(buffer); - //gate_type = datastream_info.gate_type; - number_of_gates_since_previous_event = frag.getDeltaGatesNuMIOffMaj(); - + + // Ignore non-NuMi events + if (datastream_info.gate_type != (int)sbn::triggerSource::NuMI) return; + + // Get the delta gate count + number_of_gates_since_previous_event = (datastream_info.trigger_type == 0 /* Majority*/) ? frag.getDeltaGatesNuMIOffMaj() : frag.getDeltaGatesNuMIOffMinbias(); } diff --git a/sbncode/BeamSpillInfoRetriever/NuMIRetriever/NuMIRetriever_module.cc b/sbncode/BeamSpillInfoRetriever/NuMIRetriever/NuMIRetriever_module.cc index a0eb1e48a..09086cf22 100644 --- a/sbncode/BeamSpillInfoRetriever/NuMIRetriever/NuMIRetriever_module.cc +++ b/sbncode/BeamSpillInfoRetriever/NuMIRetriever/NuMIRetriever_module.cc @@ -24,6 +24,7 @@ #include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" #include "sbnobj/Common/POTAccounting/NuMISpillInfo.h" +#include "sbnobj/Common/Trigger/BeamBits.h" #include "ifdh_art/IFBeamService/IFBeam_service.h" #include "ifbeam_c.h" @@ -54,6 +55,7 @@ class sbn::NuMIRetriever : public art::EDProducer { // input labels std::vector< sbn::NuMISpillInfo > fOutbeamInfos; double fTimePad; + double fTimeShift; double fBFPEpsilion; //MWRData mwrdata; std::string raw_data_label_; @@ -79,7 +81,8 @@ void sbn::NuMIRetriever::MakeBFP() { sbn::NuMIRetriever::NuMIRetriever(fhicl::ParameterSet const& p) : EDProducer{p}, - fTimePad(p.get("TimePadding", 0.5)), //epsilon in seconds, buffer time to look for spills + fTimePad(p.get("TimePadding", 1.)), //epsilon in seconds, buffer time to look for spills + fTimeShift(p.get("TimeShift", 0.5)), // offset, in seconds, between DAQ and IFBeam times fBFPEpsilion(p.get("BFPEpsilon", 0.02)), // 20 ms, tuned for BNB, check for NuMI here might need to be larger raw_data_label_(p.get("raw_data_label")), fDeviceUsedForTiming(p.get("DeviceUsedForTiming")), @@ -96,14 +99,6 @@ sbn::NuMIRetriever::NuMIRetriever(fhicl::ParameterSet const& p) void sbn::NuMIRetriever::produce(art::Event &e) { - // If this is the first event in the run, then ignore it - // We do not currently have the ability to figure out the first - // spill that the DAQ was sensitive to, so don't try to save any - // spill information - // - // TODO: long-term goal -- can we fix this? - if (e.event() == 1) return; - // int gate_type = 0; art::Handle< std::vector > raw_data_ptr; e.getByLabel(raw_data_label_, "ICARUSTriggerV3", raw_data_ptr); @@ -126,7 +121,15 @@ void sbn::NuMIRetriever::produce(art::Event &e) t_current_event = static_cast(artdaq_ts)/(1000000000.); //check this offset... t_previous_event = (static_cast(frag.getLastTimestampNuMIMaj()))/(1000000000.); - + + // Ignore non-NuMi events + if (datastream_info.gate_type != (int)sbn::triggerSource::NuMI) return; + + // If this is the first trigger in this stream in the run, + // ignore it because we don't know how many spills + // we are sensitive to prior + unsigned trigger_count = (datastream_info.trigger_type == 0 /* Majority*/) ? frag.getTotalTriggerNuMIMaj() : frag.getTotalTriggerNuMIMinbias(); + if (trigger_count == 1) return; } @@ -162,10 +165,8 @@ void sbn::NuMIRetriever::produce(art::Event &e) // Only continue if these times are matched to our DAQ time // plus or minus some time padding, currently using 3.3 ms // which is half the Booster Rep Rate - if(e.event() != 1){//We already addressed the "first event" above - if(times_temps[i] > t_current_event){continue;} - if(times_temps[i] <= t_previous_event){continue;} - } + if(times_temps[i] > t_current_event + fTimeShift){continue;} + if(times_temps[i] <= t_previous_event + fTimeShift){continue;} //count found spills spill_count++; diff --git a/sbncode/BeamSpillInfoRetriever/job/numispillinfo.fcl b/sbncode/BeamSpillInfoRetriever/job/numispillinfo.fcl index da5b14629..6486e262a 100644 --- a/sbncode/BeamSpillInfoRetriever/job/numispillinfo.fcl +++ b/sbncode/BeamSpillInfoRetriever/job/numispillinfo.fcl @@ -4,7 +4,8 @@ BEGIN_PROLOG numispillinfo: { module_type: "NuMIRetriever" - TimePadding: 0.5 #unit seconds, Booster Rep Rate is 15 Hz, so the closest spill could be 66ms away + TimePadding: 1 # seconds -- make a bit bigger than the shift + TimeShift: 0.5 # seconds: offset between DAQ and IFBeam times -- tuned to ICARUS@NuMI URL: "" #keep this blank and we're good Bundle: "NuMI_Physics_A9" MultiWireBundle: "BNBMultiWire" From 6da4b6401792871e285dfe4a8c3237ae92a73861 Mon Sep 17 00:00:00 2001 From: gputnam Date: Fri, 28 Jul 2023 15:50:15 -0500 Subject: [PATCH 4/4] Allow time shift in trigger to IFBeam timing. Skip first event in stream in each run. --- sbncode/CAFMaker/FillTrigger.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sbncode/CAFMaker/FillTrigger.cxx b/sbncode/CAFMaker/FillTrigger.cxx index fe68e00a1..f6bb51317 100644 --- a/sbncode/CAFMaker/FillTrigger.cxx +++ b/sbncode/CAFMaker/FillTrigger.cxx @@ -13,6 +13,15 @@ namespace caf triggerInfo.global_trigger_det_time = trig.TriggerTime(); double diff_ts = triggerInfo.global_trigger_det_time - triggerInfo.beam_gate_det_time; triggerInfo.trigger_within_gate = diff_ts; + + triggerInfo.prev_global_trigger_time = addltrig_info.previousTriggerTimestamp; + triggerInfo.source_type = (int)addltrig_info.sourceType; + triggerInfo.trigger_type = (int)addltrig_info.triggerType; + triggerInfo.trigger_id = addltrig_info.triggerID; + triggerInfo.gate_id = addltrig_info.gateID; + triggerInfo.trigger_count = addltrig_info.triggerCount; + triggerInfo.gate_count = addltrig_info.gateCount; + triggerInfo.gate_delta = (int)addltrig_info.gateCountFromPreviousTrigger; } void FillTriggerMC(double absolute_time, caf::SRTrigger& triggerInfo) {