Skip to content

Commit dee0f11

Browse files
Merge branch 'develop' into feature/hlay_crt_offline_pr
2 parents 2e79046 + d01a84d commit dee0f11

14 files changed

Lines changed: 256 additions & 52 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
1717

18-
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 09.91.02.02)
18+
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 09.91.02.02.01)
1919
find_package(cetmodules REQUIRED)
2020
project(sbndcode LANGUAGES CXX)
2121

2222
# for CI:
23-
# project(sbndcode VERSION 09.91.02.02)
23+
# project(sbndcode VERSION 09.91.02.02.01)
2424

2525
message(STATUS "\n")
2626
message(STATUS "================================= ${PROJECT_NAME} =================================")

sbndcode/Decoders/TPC/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ cet_build_plugin( SBNDTPCDecoder art::module
1919
sbndcode_ChannelMaps_TPC_TPCChannelMapService_service
2020
)
2121

22+
cet_build_plugin( NTBDecoder art::module
23+
SOURCE NTBDecoder_module.cc
24+
LIBRARIES
25+
sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays_SBND
26+
artdaq_core::artdaq-core_Utilities
27+
art::Utilities
28+
fhiclcpp::fhiclcpp
29+
messagefacility::MF_MessageLogger
30+
art::Framework_Core
31+
ROOT::Core
32+
ROOT::Tree
33+
)
34+
2235
install_headers()
2336
install_fhicl()
2437
install_source()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
BEGIN_PROLOG
2+
3+
NTBDecoderDefaults: {
4+
module_type: NTBDecoder
5+
ntb_data_label: "daq:NEVISTB"
6+
ntb_container_data_label: "daq:ContainerNEVISTB"
7+
OutputInstance: ""
8+
DebugLevel: 0
9+
}
10+
11+
END_PROLOG
12+
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
////////////////////////////////////////////////////////////////////////
2+
// Class: NTBDecoder
3+
// Plugin Type: producer (Unknown Unknown)
4+
// File: NTBDecoder_module.cc
5+
//
6+
// Generated at Thu Aug 1 11:38:21 2024 by Thomas Junk using cetskelgen
7+
// from cetlib version 3.18.02.
8+
////////////////////////////////////////////////////////////////////////
9+
10+
#include "art/Framework/Core/EDProducer.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+
20+
#include <memory>
21+
22+
#include "artdaq-core/Data/ContainerFragment.hh"
23+
#include "sbndntb.h"
24+
#include "sbndaq-artdaq-core/Overlays/SBND/NevisTPCFragment.hh"
25+
#include "sbndaq-artdaq-core/Overlays/SBND/NevisTBFragment.hh"
26+
#include "sbndaq-artdaq-core/Overlays/SBND/NevisTB_dataFormat.hh"
27+
28+
class NTBDecoder;
29+
30+
31+
class NTBDecoder : public art::EDProducer {
32+
public:
33+
explicit NTBDecoder(fhicl::ParameterSet const& p);
34+
// The compiler-generated destructor is fine for non-base
35+
// classes without bare pointers or other resource use.
36+
37+
// Plugins should not be copied or assigned.
38+
NTBDecoder(NTBDecoder const&) = delete;
39+
NTBDecoder(NTBDecoder&&) = delete;
40+
NTBDecoder& operator=(NTBDecoder const&) = delete;
41+
NTBDecoder& operator=(NTBDecoder&&) = delete;
42+
43+
// Required functions.
44+
void produce(art::Event& e) override;
45+
46+
private:
47+
48+
std::string fTag;
49+
std::string fContainerTag;
50+
std::string fOutputInstance;
51+
int fDebugLevel;
52+
53+
void process_NTB_AUX(const artdaq::Fragment& frag, std::vector<raw::ntb::sbndntb> &sbndntbs);
54+
};
55+
56+
57+
NTBDecoder::NTBDecoder(fhicl::ParameterSet const& p)
58+
: EDProducer{p}
59+
{
60+
fTag = p.get<std::string>("ntb_data_label","daq:NEVISTB");
61+
fContainerTag = p.get<std::string>("ntb_container_data_label","daq:ContainerNEVISTB");
62+
fOutputInstance = p.get<std::string>("OutputInstance","");
63+
fDebugLevel = p.get<int>("DebugLevel",0);
64+
65+
consumes<artdaq::Fragments>(fTag);
66+
consumes<artdaq::Fragments>(fContainerTag);
67+
produces<std::vector<raw::ntb::sbndntb>>(fOutputInstance);
68+
}
69+
70+
void NTBDecoder::produce(art::Event& e)
71+
{
72+
// Implementation of required member function here.
73+
74+
// look first for container fragments and then non-container fragments
75+
76+
std::vector<raw::ntb::sbndntb> sbndntbs;
77+
78+
art::InputTag itag1(fContainerTag);
79+
auto cont_frags = e.getHandle<artdaq::Fragments>(itag1);
80+
if (cont_frags)
81+
{
82+
for (auto const& cont : *cont_frags)
83+
{
84+
artdaq::ContainerFragment cont_frag(cont);
85+
for (size_t ii = 0; ii < cont_frag.block_count(); ++ii)
86+
{
87+
process_NTB_AUX(*cont_frag[ii], sbndntbs);
88+
}
89+
}
90+
}
91+
92+
art::InputTag itag2(fTag);
93+
auto frags = e.getHandle<artdaq::Fragments>(itag2);
94+
if (frags)
95+
{
96+
for(auto const& frag: *frags)
97+
{
98+
process_NTB_AUX(frag, sbndntbs);
99+
}
100+
}
101+
102+
e.put(std::make_unique<std::vector<raw::ntb::sbndntb>>(std::move(sbndntbs)),fOutputInstance);
103+
}
104+
105+
void NTBDecoder::process_NTB_AUX(const artdaq::Fragment& frag, std::vector<raw::ntb::sbndntb> &sbndntbs)
106+
{
107+
if (fDebugLevel > 0)
108+
{
109+
std::cout << "NTBDecoder_module: got into aux" << std::endl;
110+
}
111+
sbndaq::NevisTBFragment tbfrag(frag);
112+
const auto header = *tbfrag.header();
113+
const auto fdata = *tbfrag.data();
114+
const auto trailer = *tbfrag.trailer();
115+
116+
raw::ntb::sbndntb ostruct;
117+
ostruct.boardreader_timestamp = frag.timestamp();
118+
ostruct.event_number = tbfrag.metadata()->EventNumber();
119+
ostruct.frame_number = tbfrag.metadata()->FrameNumber();
120+
ostruct.sample_number = tbfrag.metadata()->SampleNumber();
121+
ostruct.busy = header.busy;
122+
ostruct.sixteen_mhz_remainder = header.remainder;
123+
ostruct.two_mhz_sample = header.sample;
124+
ostruct.frame = header.getFrame();
125+
ostruct.ntrig = header.getTriggerNumber();
126+
ostruct.pmt_trig_data = fdata.pmt_trig_data;
127+
ostruct.pc = fdata.pc;
128+
ostruct.external = fdata.external;
129+
ostruct.active = fdata.active;
130+
ostruct.gate2 = fdata.gate2;
131+
ostruct.gate1 = fdata.gate1;
132+
ostruct.veto = fdata.veto;
133+
ostruct.calib = fdata.calib;
134+
ostruct.phase = fdata.getPhase();
135+
ostruct.gatefake = fdata.gatefake;
136+
ostruct.beamfake = fdata.beamfake;
137+
ostruct.spare1 = fdata.spare1;
138+
ostruct.trailer = trailer.getTrailerWord();
139+
sbndntbs.push_back(ostruct);
140+
}
141+
142+
DEFINE_ART_MODULE(NTBDecoder)

sbndcode/Decoders/TPC/classes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "canvas/Persistency/Common/Wrapper.h"
22
#include <vector>
33
#include "sbndcode/Decoders/TPC/TPCDecodeAna.h"
4+
#include "sbndcode/Decoders/TPC/sbndntb.h"
45

56

67
namespace {

sbndcode/Decoders/TPC/classes_def.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,12 @@
77
<class name="std::vector<tpcAnalysis::TPCDecodeAna>"/>
88
<class name="art::Wrapper<tpcAnalysis::TPCDecodeAna>"/>
99
<class name="art::Wrapper<std::vector<tpcAnalysis::TPCDecodeAna>>"/>
10+
11+
<class name="raw::ntb::sbndntb" ClassVersion="10">
12+
<version ClassVersion="10" checksum="4110489055"/>
13+
</class>
14+
<class name="std::vector<raw::ntb::sbndntb>"/>
15+
<class name="art::Wrapper<raw::ntb::sbndntb>"/>
16+
<class name="art::Wrapper<std::vector<raw::ntb::sbndntb>>"/>
17+
1018
</lcgdict>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "NTBDecoderDefaults.fcl"
2+
3+
physics:
4+
{
5+
// now also have something produce the digits and headers
6+
producers:
7+
{
8+
daq: @local::NTBDecoderDefaults
9+
}
10+
11+
analyzers: {}
12+
13+
my_producer_modules: [daq]
14+
trigger_paths: [my_producer_modules]
15+
a: [commissioning]
16+
end_paths: [a]
17+
}
18+
19+
source: {}
20+
21+
outputs: {
22+
commissioning: {
23+
module_type: "RootOutput"
24+
fileName: "%ifb_ntbdecode.root"
25+
dataTier: "decoded-raw"
26+
}
27+
}
28+
29+
30+
process_name: NTBDECODER
31+

sbndcode/Decoders/TPC/sbndntb.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef RAW_NTB_SBNDNTB_HEADER_GUARD
2+
#define RAW_NTB_SBNDNTB_HEADER_GUARD
3+
4+
#include <stdlib.h>
5+
6+
namespace raw {
7+
namespace ntb {
8+
struct sbndntb {
9+
uint64_t boardreader_timestamp; // from artdaq::fragment
10+
uint32_t event_number; // from fragment metadata
11+
uint32_t frame_number; // from fragment metadata
12+
uint16_t sample_number; // from fragment metadata
13+
uint16_t busy; // from NTB header words
14+
uint16_t sixteen_mhz_remainder; // from NTB header words
15+
uint16_t two_mhz_sample; // from NTB header words
16+
uint32_t frame; // from NTB header words
17+
uint32_t ntrig; // from NTB header words
18+
uint16_t pmt_trig_data; // from NTB trigger data words
19+
uint16_t pc; // from NTB trigger data words
20+
uint16_t external; // from NTB trigger data words
21+
uint16_t active; // from NTB trigger data words
22+
uint16_t gate2; // from NTB trigger data words
23+
uint16_t gate1; // from NTB trigger data words
24+
uint16_t veto; // from NTB trigger data words
25+
uint16_t calib; // from NTB trigger data words
26+
uint16_t phase; // from NTB trigger data words
27+
uint16_t gatefake; // from NTB trigger data words
28+
uint16_t beamfake; // from NTB trigger data words
29+
uint16_t spare1; // from NTB trigger data words
30+
uint32_t trailer; // from NTB trailer words
31+
};
32+
}
33+
}
34+
35+
#endif

sbndcode/JobConfigurations/base/prodsingle_sbnd.fcl

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626

2727
#include "singles_sbnd.fcl"
2828

29-
#include "larg4_sbnd.fcl"
30-
#include "ionandscint_sbnd.fcl"
31-
#include "PDFastSim_sbnd.fcl"
32-
#include "simdrift_sbnd.fcl"
33-
34-
#include "detsimmodules_sbnd.fcl"
35-
3629
#include "rootoutput_sbnd.fcl"
3730

3831

@@ -74,37 +67,11 @@ physics:
7467

7568
# Generation
7669
generator: @local::sbnd_singlep
77-
78-
# A dummy module that forces the G4 physics list to be loaded
79-
loader: { module_type: "PhysListLoader" }
80-
81-
# The geant4 step
82-
largeant: @local::sbnd_larg4
83-
84-
# Creation of ionization electrons and scintillation photons, inside the active volume
85-
ionandscint: @local::sbnd_ionandscint
86-
87-
# Light propogation inside the active volume
88-
pdfastsim: @local::sbnd_pdfastsim_par
89-
90-
# Electron propogation
91-
simdrift: @local::sbnd_simdrift
92-
93-
# Detector simulation
94-
daq: @local::sbnd_simwire
9570
}
9671

9772
#define the producer and filter modules for this path, order matters,
98-
# simulate: [ rns, generator, largeant, daq]
99-
# simulate: [ rns, generator ]
10073
simulate: [ rns
10174
, generator
102-
, loader
103-
, largeant
104-
, ionandscint
105-
, pdfastsim
106-
, simdrift
107-
, daq
10875
]
10976

11077
#define the output stream, there could be more than one if using filters
@@ -121,16 +88,8 @@ outputs:
12188
{
12289
out1:
12390
{
124-
@table::sbnd_rootoutput # inherit shared settings
91+
@table::sbnd_rootoutput # inherit shared settings
12592
fileName: "prodsingle_sbnd_%p-%tc.root" # default file name, can override from command line with -o or --output
126-
outputCommands: [ "keep *_*_*_*"
127-
, "drop *_ionandscint__*" # Drop the IonAndScint w/ SCE offsets applied
128-
]
12993
}
13094
}
13195

132-
#
133-
# at the end of the configuration, we can override single parameters to reflect our needs:
134-
#
135-
physics.producers.generator.T0: [ 0 ]
136-
physics.producers.generator.Theta0XZ: [ 10 ]

sbndcode/LArSoftConfigurations/gen/singles_sbnd.fcl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ BEGIN_PROLOG
44

55
sbnd_singlep: @local::standard_singlep
66

7+
# By default pad ot a vector if it is size 1
8+
physics.producers.generator.PadOutVectors: true
9+
710
# Particle generated at this time will appear in main drift window at trigger T0.
8-
physics.producers.generator.T0: [ 1.7e3 ] # us
11+
physics.producers.generator.T0: [0] # us
912

1013
physics.producers.generator.P0: [ -1.0 ] # GeV/c
1114
physics.producers.generator.SigmaP: [ 0.0 ] # GeV/c

0 commit comments

Comments
 (0)