Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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)
//
Expand All @@ -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"
Expand All @@ -36,10 +36,10 @@
#include <time.h>

namespace sbn {
class EXTRetriever;
class BNBEXTRetriever;
}

class sbn::EXTRetriever : public art::EDProducer {
class sbn::BNBEXTRetriever : public art::EDProducer {
public:

struct Config {
Expand All @@ -57,15 +57,15 @@ class sbn::EXTRetriever : public art::EDProducer {
using Parameters = art::EDProducer::Table<Config>;


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;
Expand All @@ -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())
{
Expand All @@ -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:
Expand All @@ -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<artdaq::Fragment> >({ raw_data_label_, "ICARUSTriggerUDP" });
auto const & raw_data = e.getProduct< std::vector<artdaq::Fragment> >({ 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<char*>(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
Expand All @@ -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
Expand All @@ -152,4 +155,4 @@ void sbn::EXTRetriever::endSubRun(art::SubRun& sr)
return;
}

DEFINE_ART_MODULE(sbn::EXTRetriever)
DEFINE_ART_MODULE(sbn::BNBEXTRetriever)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

cet_build_plugin(EXTRetriever art::module
cet_build_plugin(BNBEXTRetriever art::module
LIBRARIES
art::Persistency_Common
art::Utilities canvas::canvas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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<artdaq::Fragment> >({ raw_data_label, "ICARUSTriggerV2" });
auto const & raw_data = e.getProduct< std::vector<artdaq::Fragment> >({ 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<char*>(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<double>(artdaq_ts)/(1000000000.0); //check this offset...
if(triggerInfo.gate_type == 1)
triggerInfo.t_previous_event = (static_cast<double>(frag.getLastTimestampBNB()))/(1e9);
triggerInfo.t_previous_event = (static_cast<double>(frag.getLastTimestampBNBMaj()))/(1e9);
else
triggerInfo.t_previous_event = (static_cast<double>(frag.getLastTimestampOther()))/(1000000000.0);

Expand Down
3 changes: 2 additions & 1 deletion sbncode/BeamSpillInfoRetriever/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
add_subdirectory(BNBRetriever)
add_subdirectory(NuMIRetriever)
add_subdirectory(EXTRetriever)
add_subdirectory(BNBEXTRetriever)
add_subdirectory(NuMIEXTRetriever)
add_subdirectory(job)

install_headers()
Expand Down
20 changes: 20 additions & 0 deletions sbncode/BeamSpillInfoRetriever/NuMIEXTRetriever/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()

Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
////////////////////////////////////////////////////////////////////////
// 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 "sbnobj/Common/Trigger/BeamBits.h"

#include <memory>
#include <optional>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <time.h>

namespace sbn {
class NuMIEXTRetriever;
}

class sbn::NuMIEXTRetriever : public art::EDProducer {
public:

struct Config {

using Name = fhicl::Name;
using Comment = fhicl::Comment;

fhicl::Atom<std::string> RawDataLabel {
Name{ "raw_data_label" },
Comment{ "art data product instance name for trigger information (product label is 'daq')" }
};

}; // Config

using Parameters = art::EDProducer::Table<Config>;


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<artdaq::Fragment> >({ 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<char*>(data.c_str());
icarus::ICARUSTriggerInfo datastream_info = icarus::parse_ICARUSTriggerV3String(buffer);

// 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();

}

//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)
Loading