Skip to content

Commit 9ff8327

Browse files
committed
Merge branch 'release/v09_83_01'
2 parents e8effc3 + f55b959 commit 9ff8327

33 files changed

Lines changed: 848 additions & 31 deletions

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.82.02.01)
18+
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 09.83.01)
1919
find_package(cetmodules REQUIRED)
2020
project(sbndcode LANGUAGES CXX)
2121

2222
# for CI:
23-
# project(sbndcode VERSION 09.82.02.01)
23+
# project(sbndcode VERSION 09.83.01)
2424

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

sbndcode/AnalysisTree/analysistreemodule_sbnd.fcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ sbnd_analysistree:
1010
DigitModuleLabel: "daq"
1111
HitsModuleLabel: "gaushit"
1212
LArGeantModuleLabel: "largeant"
13-
TPCSimChannelModuleLabel: "simdrift"
13+
TPCSimChannelModuleLabel: "simtpc2d:simpleSC"
1414
CalDataModuleLabel: "caldata"
1515
GenieGenModuleLabel: "generator"
1616
CryGenModuleLabel: "generator"

sbndcode/Decoders/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
add_subdirectory(TPC)
2+
add_subdirectory(PTB)
23
add_subdirectory(SPECTDC)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
# this is borrowed from sbndaq-artdaq-core to make the c7 compiler happy
3+
# remove if not needed by the trigger decoder
4+
# add_definitions(-Wno-nested-anon-types)
5+
6+
cet_build_plugin( SBNDPTBDecoder art::module
7+
SOURCE SBNDPTBDecoder_module.cc
8+
LIBRARIES
9+
sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays_SBND
10+
lardataobj::RawData
11+
artdaq_core::artdaq-core_Utilities
12+
art::Utilities
13+
fhiclcpp::fhiclcpp
14+
messagefacility::MF_MessageLogger
15+
art::Framework_Core
16+
ROOT::Core
17+
)
18+
19+
cet_make_library(SOURCE
20+
SBNDPTBRawUtils.cxx
21+
LIBRARIES
22+
sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays_SBND
23+
ROOT::Core
24+
)
25+
26+
install_headers()
27+
install_fhicl()
28+
install_source()
29+
art_dictionary()
30+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
BEGIN_PROLOG
2+
3+
SBNDPTBDecoderDefaults: {
4+
module_type: SBNDPTBDecoder
5+
InputLabel: "daq"
6+
InputContainerInstance: "ContainerPTB"
7+
InputNonContainerInstance: "PTB"
8+
OutputInstance: ""
9+
DebugLevel: 0
10+
}
11+
12+
END_PROLOG
13+
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
////////////////////////////////////////////////////////////////////////
2+
// Class: SBNDPTBDecoder
3+
// Plugin Type: producer
4+
// File: SBNDPTBDecoder_module.cc
5+
//
6+
////////////////////////////////////////////////////////////////////////
7+
8+
#include "art/Framework/Core/EDProducer.h"
9+
#include "art/Framework/Core/ModuleMacros.h"
10+
#include "art/Framework/Principal/Event.h"
11+
#include "art/Framework/Principal/Handle.h"
12+
#include "art/Framework/Principal/Run.h"
13+
#include "art/Framework/Principal/SubRun.h"
14+
#include "canvas/Utilities/InputTag.h"
15+
#include "fhiclcpp/ParameterSet.h"
16+
#include "messagefacility/MessageLogger/MessageLogger.h"
17+
18+
#include <memory>
19+
20+
#include "sbndaq-artdaq-core/Overlays/SBND/PTBFragment.hh"
21+
#include "artdaq-core/Data/ContainerFragment.hh"
22+
#include "sbndcode/Decoders/PTB/sbndptb.h"
23+
24+
class SBNDPTBDecoder;
25+
26+
27+
class SBNDPTBDecoder : public art::EDProducer {
28+
public:
29+
explicit SBNDPTBDecoder(fhicl::ParameterSet const & p);
30+
// The compiler-generated destructor is fine for non-base
31+
// classes without bare pointers or other resource use.
32+
33+
// Plugins should not be copied or assigned.
34+
SBNDPTBDecoder(SBNDPTBDecoder const &) = delete;
35+
SBNDPTBDecoder(SBNDPTBDecoder &&) = delete;
36+
SBNDPTBDecoder & operator = (SBNDPTBDecoder const &) = delete;
37+
SBNDPTBDecoder & operator = (SBNDPTBDecoder &&) = delete;
38+
39+
// Required functions.
40+
void produce(art::Event & e) override;
41+
42+
private:
43+
44+
// Declare member data here.
45+
46+
std::string fInputLabel;
47+
std::string fInputContainerInstance;
48+
std::string fInputNonContainerInstance;
49+
std::string fOutputInstance;
50+
int fDebugLevel;
51+
52+
typedef struct ptbsv
53+
{
54+
std::vector<raw::ptb::Trigger> HLTrigs;
55+
std::vector<raw::ptb::Trigger> LLTrigs;
56+
std::vector<raw::ptb::ChStatus> ChStats;
57+
std::vector<raw::ptb::Feedback> Feedbacks;
58+
std::vector<raw::ptb::Misc> Miscs;
59+
std::vector<raw::ptb::WordIndex> WordIndexes;
60+
} ptbsv_t;
61+
62+
void _process_PTB_AUX(const artdaq::Fragment& frag, ptbsv_t &sout);
63+
};
64+
65+
66+
SBNDPTBDecoder::SBNDPTBDecoder(fhicl::ParameterSet const & p)
67+
: EDProducer{p}
68+
// Initialize member data here.
69+
{
70+
fInputLabel = p.get<std::string>("InputLabel");
71+
fInputContainerInstance = p.get<std::string>("InputContainerInstance");
72+
fInputNonContainerInstance = p.get<std::string>("InputNonContainerInstance");
73+
fOutputInstance = p.get<std::string>("OutputInstance");
74+
fDebugLevel = p.get<int>("DebugLevel",0);
75+
76+
produces<std::vector<raw::ptb::sbndptb> >(fOutputInstance);
77+
}
78+
79+
void SBNDPTBDecoder::produce(art::Event & evt)
80+
{
81+
82+
83+
// look first for container fragments and then non-container fragments
84+
85+
std::vector<raw::ptb::sbndptb> sbndptbs;
86+
87+
art::InputTag itag1(fInputLabel, fInputContainerInstance);
88+
auto cont_frags = evt.getHandle<artdaq::Fragments>(itag1);
89+
if (cont_frags)
90+
{
91+
for (auto const& cont : *cont_frags)
92+
{
93+
artdaq::ContainerFragment cont_frag(cont);
94+
for (size_t ii = 0; ii < cont_frag.block_count(); ++ii)
95+
{
96+
ptbsv_t sout; // output structures
97+
_process_PTB_AUX(*cont_frag[ii], sout);
98+
raw::ptb::sbndptb ptbdp(sout.HLTrigs,sout.LLTrigs,sout.ChStats,sout.Feedbacks,sout.Miscs,sout.WordIndexes);
99+
sbndptbs.push_back(ptbdp);
100+
}
101+
}
102+
}
103+
104+
art::InputTag itag2(fInputLabel, fInputNonContainerInstance);
105+
auto frags = evt.getHandle<artdaq::Fragments>(itag2);
106+
if (frags)
107+
{
108+
for(auto const& frag: *frags)
109+
{
110+
ptbsv_t sout; // output structures
111+
_process_PTB_AUX(frag, sout);
112+
raw::ptb::sbndptb ptbdp(sout.HLTrigs,sout.LLTrigs,sout.ChStats,sout.Feedbacks,sout.Miscs,sout.WordIndexes);
113+
sbndptbs.push_back(ptbdp);
114+
}
115+
}
116+
117+
evt.put(std::make_unique<std::vector<raw::ptb::sbndptb>>(std::move(sbndptbs)),fOutputInstance);
118+
}
119+
120+
void SBNDPTBDecoder::_process_PTB_AUX(const artdaq::Fragment& frag, ptbsv_t &sout)
121+
{
122+
sbndaq::CTBFragment ctbfrag(frag); // somehow the name CTBFragment stuck
123+
124+
// use the same logic in sbndaq-artdaq-core/Overlays/SBND/PTBFragment.cc: operator<<
125+
// but separate out the HLTs and LLTs
126+
if (fDebugLevel > 0)
127+
{
128+
std::cout << "SBNDPTBDecoder_module: got into aux" << std::endl;
129+
}
130+
131+
for (size_t iword = 0; iword < ctbfrag.NWords(); ++iword)
132+
{
133+
if (fDebugLevel > 0)
134+
{
135+
std::cout << "SBNDPTBDecoder_module: start processing word: " << iword << std::endl;
136+
}
137+
size_t ix=0;
138+
uint32_t wt = 0;
139+
if (ctbfrag.Trigger(iword))
140+
{
141+
raw::ptb::Trigger tstruct;
142+
tstruct.word_type = ctbfrag.Trigger(iword)->word_type;
143+
wt = tstruct.word_type;
144+
tstruct.trigger_word = ctbfrag.Trigger(iword)->trigger_word;
145+
tstruct.timestamp = ctbfrag.Trigger(iword)->timestamp;
146+
if (ctbfrag.Trigger(iword)->IsHLT())
147+
{
148+
ix = sout.HLTrigs.size();
149+
sout.HLTrigs.push_back(tstruct);
150+
if (fDebugLevel > 0)
151+
{
152+
std::cout << "SBNDPTBDecoder_module: found HLT: " << wt << " " << ix << std::endl;
153+
}
154+
}
155+
else if (ctbfrag.Trigger(iword)->IsLLT())
156+
{
157+
ix = sout.LLTrigs.size();
158+
sout.LLTrigs.push_back(tstruct);
159+
if (fDebugLevel > 0)
160+
{
161+
std::cout << "SBNDPTBDecoder_module: found LLT: " << wt << " " << ix << std::endl;
162+
}
163+
}
164+
}
165+
else if (ctbfrag.ChStatus(iword))
166+
{
167+
raw::ptb::ChStatus cstruct;
168+
cstruct.timestamp = ctbfrag.ChStatus(iword)->timestamp;
169+
cstruct.beam = ctbfrag.ChStatus(iword)->beam;
170+
cstruct.crt = ctbfrag.ChStatus(iword)->crt;
171+
cstruct.pds = ctbfrag.ChStatus(iword)->pds;
172+
cstruct.mtca = ctbfrag.ChStatus(iword)->mtca;
173+
cstruct.nim = ctbfrag.ChStatus(iword)->nim;
174+
cstruct.auxpds = ctbfrag.ChStatus(iword)->auxpds;
175+
cstruct.word_type = ctbfrag.ChStatus(iword)->word_type;
176+
wt = cstruct.word_type;
177+
ix = sout.ChStats.size();
178+
sout.ChStats.push_back(cstruct);
179+
if (fDebugLevel > 0)
180+
{
181+
std::cout << "SBNDPTBDecoder_module: found CHStat: " << wt << " " << ix << std::endl;
182+
}
183+
}
184+
else if (ctbfrag.Feedback(iword))
185+
{
186+
raw::ptb::Feedback fstruct;
187+
fstruct.timestamp = ctbfrag.Feedback(iword)->timestamp;
188+
fstruct.code = ctbfrag.Feedback(iword)->code;
189+
fstruct.source = ctbfrag.Feedback(iword)->source;
190+
fstruct.payload = ctbfrag.Feedback(iword)->payload; // broken in two in Tereza's version
191+
fstruct.word_type = ctbfrag.Feedback(iword)->word_type;
192+
wt = fstruct.word_type;
193+
ix = sout.Feedbacks.size();
194+
sout.Feedbacks.push_back(fstruct);
195+
if (fDebugLevel > 0)
196+
{
197+
std::cout << "SBNDPTBDecoder_module: found Feedback: " << wt << " " << ix << std::endl;
198+
}
199+
}
200+
else
201+
{
202+
raw::ptb::Misc mstruct;
203+
mstruct.timestamp = ctbfrag.Word(iword)->timestamp;
204+
mstruct.payload = ctbfrag.Word(iword)->payload;
205+
mstruct.word_type = ctbfrag.Word(iword)->word_type;
206+
wt = mstruct.word_type;
207+
ix = sout.Miscs.size();
208+
sout.Miscs.push_back(mstruct);
209+
if (fDebugLevel > 0)
210+
{
211+
std::cout << "SBNDPTBDecoder_module: found Misc: " << wt << " " << ix << std::endl;
212+
}
213+
}
214+
215+
raw::ptb::WordIndex wstruct;
216+
wstruct.word_type = wt;
217+
wstruct.index = ix;
218+
sout.WordIndexes.push_back(wstruct);
219+
if (fDebugLevel > 0)
220+
{
221+
std::cout << "SBNDPTBDecoder_module: index calc: " << wt << " " << ix << std::endl;
222+
}
223+
}
224+
}
225+
226+
227+
DEFINE_ART_MODULE(SBNDPTBDecoder)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/// \file SBNDPTBRawUtils.cxx
2+
/// \brief SBND PTB raw data utilities
3+
/// \author trj@fnal.gov
4+
5+
#include "SBNDPTBRawUtils.h"
6+
#include "sbndaq-artdaq-core/Overlays/SBND/PTB_content.h"
7+
8+
namespace raw {
9+
namespace ptb {
10+
const std::vector<raw::ptb::ChStatus> GetChStatusBeforeHLTs(const raw::ptb::sbndptb &pdata)
11+
{
12+
std::vector<raw::ptb::ChStatus> chs;
13+
raw::ptb::ChStatus emptychstat;
14+
emptychstat.timestamp = 0;
15+
emptychstat.beam = 0;
16+
emptychstat.crt = 0;
17+
emptychstat.pds = 0;
18+
emptychstat.mtca = 0;
19+
emptychstat.nim = 0;
20+
emptychstat.auxpds = 0;
21+
emptychstat.word_type = 0;
22+
23+
// Find the last CHStatus before each HLT
24+
25+
const auto &hlts = pdata.GetHLTriggers();
26+
const auto &idxs = pdata.GetIndexes();
27+
const auto &chst = pdata.GetChStatuses();
28+
29+
for (size_t i=0; i<hlts.size(); ++i)
30+
{
31+
for (size_t j=0; j<idxs.size(); ++j)
32+
{
33+
if (idxs.at(j).word_type == (uint32_t) ::ptb::content::word::t_gt && idxs.at(j).index == i)
34+
{
35+
size_t kstatindex = j;
36+
if (kstatindex > 0)
37+
{
38+
kstatindex --; // it's the word before the HLT that has the chstat
39+
if (idxs.at(kstatindex).word_type == (uint32_t) ::ptb::content::word::t_ch)
40+
{
41+
size_t kstat = idxs.at(kstatindex).index;
42+
43+
if (kstat < chst.size())
44+
{
45+
chs.push_back(chst.at(kstat));
46+
}
47+
else
48+
{
49+
chs.push_back(emptychstat);
50+
}
51+
}
52+
else
53+
{
54+
chs.push_back(emptychstat);
55+
}
56+
}
57+
else
58+
{
59+
chs.push_back(emptychstat);
60+
}
61+
}
62+
}
63+
}
64+
return chs;
65+
}
66+
}
67+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// \file SBNDPTBRawUtils.h
2+
/// \brief Standalone C++ methods to interact with the sbndptb data product, separated from
3+
/// the data product defintion itself so ROOT can persist it
4+
/// \author trj@fnal.gov
5+
6+
#ifndef SBNDPTBRawUtils_H
7+
#define SBNDPTBRawUtils_H
8+
9+
#include "sbndcode/Decoders/PTB/sbndptb.h"
10+
#include "sbndaq-artdaq-core/Overlays/SBND/PTB_content.h"
11+
12+
namespace raw {
13+
namespace ptb {
14+
const std::vector<raw::ptb::ChStatus> GetChStatusBeforeHLTs(const raw::ptb::sbndptb &pdata);
15+
}
16+
}
17+
18+
#endif

sbndcode/Decoders/PTB/classes.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//File: classes.h
2+
//Brief: Include directives needed to generate header(s) for the raw::ptb::sbndptb data product.
3+
//Author: Tom Junk
4+
5+
//ART includes
6+
#include "canvas/Persistency/Common/Wrapper.h"
7+
#include "canvas/Persistency/Common/Assns.h"
8+
9+
//local includes
10+
#include "sbndcode/Decoders/PTB/sbndptb.h"

0 commit comments

Comments
 (0)