Skip to content

Commit ed8ac9e

Browse files
authored
Merge branch 'develop' into feature/gp_v10python
2 parents 0d29aa3 + 67a2a5a commit ed8ac9e

21 files changed

Lines changed: 1299 additions & 6 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
1717

1818
find_package(cetmodules 3.20.00 REQUIRED)
19-
project(sbncode VERSION 10.04.05 LANGUAGES CXX)
19+
project(sbncode VERSION 10.04.06.01 LANGUAGES CXX)
2020

2121
message(STATUS "\n\n ========================== ${PROJECT_NAME} ==========================")
2222

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
add_subdirectory(BNBRetriever)
2+
add_subdirectory(SBNDBNBRetriever)
3+
add_subdirectory(SBNDBNBZEROBIASRetriever)
4+
add_subdirectory(SBNDBNBEXTRetriever)
25
add_subdirectory(NuMIRetriever)
36
add_subdirectory(BNBEXTRetriever)
47
add_subdirectory(NuMIEXTRetriever)
58
add_subdirectory(job)
69

10+
find_package(ifbeam)
11+
find_package(ifdh_art)
12+
13+
art_make_library(LIBRARIES Boost::system
14+
LIBRARY_NAME sbn_MWRData
15+
SOURCE MWRData.cpp
16+
)
17+
18+
art_make_library(
19+
LIBRARIES
20+
art::Persistency_Common
21+
art::Utilities
22+
ifbeam::ifbeam
23+
ifdh_art::IFBeam_service
24+
messagefacility::MF_MessageLogger
25+
sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays_SBND
26+
sbnobj::Common_POTAccounting
27+
sbn_MWRData
28+
larcorealg::CoreUtils
29+
30+
LIBRARY_NAME sbn_SBNDPOTTools
31+
SOURCE SBNDPOTTools.cpp
32+
)
33+
734
install_headers()
835
install_fhicl()
936
install_source()
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include <iostream>
2+
#include <iomanip>
3+
#include <string>
4+
#include <sstream>
5+
#include <vector>
6+
#include <boost/algorithm/string.hpp>
7+
#include "MWRData.h"
8+
9+
using namespace std;
10+
11+
namespace sbn{
12+
13+
std::vector< std::vector < int > > MWRData::unpackMWR(std::string packed_data, std::vector<double> &time_stamp, double timeoffset) const
14+
{
15+
16+
std::vector<std::vector<int> > unpacked_data;
17+
unpacked_data.resize(4);
18+
short data[444];
19+
20+
std::vector<std::string> row(0);
21+
boost::split(row, packed_data, boost::is_any_of(","));
22+
if (row.size()==447) {
23+
for (int i=3;i<447;i++) {
24+
data[i-3]=atoi(row[i].c_str());
25+
}
26+
string devname=row[1].substr(0,8);
27+
for (int idev=0;idev<4;idev++) {
28+
mwrpulse_t mwr=getMWRdata(data,idev);
29+
time_stamp.push_back(mwr.sheader.timesec+mwr.sheader.timensec/1000000000.+timeoffset);
30+
for (int ich=0;ich<48;ich++) {
31+
unpacked_data[idev].push_back(mwr.hor[ich]);
32+
}
33+
for (int ich=0;ich<48;ich++) {
34+
unpacked_data[idev].push_back(mwr.ver[ich]);
35+
}
36+
}
37+
} else {
38+
cout <<"BeamSpillInfoRetriever: MRWData: Bad data!"<<endl;
39+
return unpacked_data;
40+
}
41+
42+
return unpacked_data;
43+
}
44+
45+
MWRData::mwrpulse_t MWRData::getMWRdata(short* data, int nblock) const
46+
{
47+
mwrpulse_t mwrdata;
48+
49+
memcpy(&mwrdata.hor, data+nblock*111, 96);
50+
memcpy(&mwrdata.ver, data+nblock*111+48, 96);
51+
memcpy(&mwrdata.sheader.timesec, data+nblock*111+96, 4);
52+
memcpy(&mwrdata.sheader.timensec, data+nblock*111+98, 4);
53+
memcpy(&mwrdata.sheader.gpstime1, data+nblock*111+100, 4);
54+
memcpy(&mwrdata.sheader.gpstime2, data+nblock*111+102, 4);
55+
memcpy(&mwrdata.sheader.boosterevent, data+nblock*111+104, 2);
56+
memcpy(&mwrdata.sheader.mievent, data+nblock*111+105, 2);
57+
memcpy(&mwrdata.sheader.hz15micnt, data+nblock*111+106, 2);
58+
memcpy(&mwrdata.sheader.delta1f, data+nblock*111+107, 4);
59+
memcpy(&mwrdata.sheader.pulsemi, data+nblock*111+109, 2);
60+
memcpy(&mwrdata.sheader.pulsesc, data+nblock*111+110, 2);
61+
62+
mwrdata.sheader.timesec=flipByte(mwrdata.sheader.timesec);
63+
mwrdata.sheader.timensec=flipByte(mwrdata.sheader.timensec);
64+
mwrdata.sheader.gpstime1=flipByte(mwrdata.sheader.gpstime1);
65+
mwrdata.sheader.gpstime2=flipByte(mwrdata.sheader.gpstime2);
66+
mwrdata.sheader.delta1f=flipByte(mwrdata.sheader.delta1f);
67+
68+
return mwrdata;
69+
70+
}
71+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef _MWRDATA_H
2+
#define _MWRDATA_H
3+
4+
#include <string.h>
5+
namespace sbn{
6+
class MWRData
7+
{
8+
typedef struct swicheader_t {
9+
long timesec;
10+
long timensec;
11+
long gpstime1;
12+
long gpstime2;
13+
short boosterevent;
14+
short mievent;
15+
short hz15micnt;
16+
long delta1f;
17+
short pulsemi;
18+
short pulsesc;
19+
} swicheader_t;
20+
21+
typedef struct mwrpulse_t {
22+
short hor[48];
23+
short ver[48];
24+
swicheader_t sheader;
25+
} mwrpulse_t;
26+
27+
static long flipByte(long data)
28+
{
29+
return ((data>>16)&0x0000FFFF) | ((data<<16)&0xFFFF0000);
30+
}
31+
32+
mwrpulse_t getMWRdata(short* data, int nblock) const;
33+
34+
public:
35+
std::vector< std::vector < int > > unpackMWR(std::string packed_data, std::vector<double> &time_stamp, double timeoffset=0) const;
36+
};
37+
}
38+
39+
#endif /* #ifndef _MWRDATA_H */
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
find_package(ifbeam)
2+
find_package(ifdh_art)
3+
4+
cet_build_plugin(SBNDBNBEXTRetriever art::module
5+
LIBRARIES
6+
sbn_SBNDPOTTools
7+
)
8+
9+
install_headers()
10+
install_fhicl()
11+
install_source()
12+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
////////////////////////////////////////////////////////////////////////
2+
// Class: SBNDBNBEXTRetriever
3+
// Plugin Type: producer
4+
// File: SBNDBNBEXTRetriever_module.cc
5+
//
6+
////////////////////////////////////////////////////////////////////////
7+
8+
#include "art/Framework/Core/EDProducer.h"
9+
#include "messagefacility/MessageLogger/MessageLogger.h"
10+
#include "sbnobj/Common/POTAccounting/EXTCountInfo.h"
11+
#include "sbncode/BeamSpillInfoRetriever/SBNDPOTTools.h"
12+
13+
namespace sbn {
14+
class SBNDBNBEXTRetriever;
15+
}
16+
17+
class sbn::SBNDBNBEXTRetriever : public art::EDProducer {
18+
public:
19+
explicit SBNDBNBEXTRetriever(fhicl::ParameterSet const & params);
20+
// Required functions.
21+
void produce(art::Event & e) override;
22+
void beginSubRun(art::SubRun& sr) override;
23+
void endSubRun(art::SubRun& sr) override;
24+
25+
// Plugins should not be copied or assigned.
26+
SBNDBNBEXTRetriever(SBNDBNBEXTRetriever const &) = delete;
27+
SBNDBNBEXTRetriever(SBNDBNBEXTRetriever &&) = delete;
28+
SBNDBNBEXTRetriever & operator = (SBNDBNBEXTRetriever const &) = delete;
29+
SBNDBNBEXTRetriever & operator = (SBNDBNBEXTRetriever &&) = delete;
30+
31+
32+
private:
33+
// Declare member data here.
34+
std::vector< sbn::EXTCountInfo > fOutExtInfos;
35+
TriggerInfo_t extractTriggerInfo(art::Event const& e) const;
36+
// input labels
37+
float TotalEXTCounts;
38+
};
39+
40+
sbn::SBNDBNBEXTRetriever::SBNDBNBEXTRetriever(fhicl::ParameterSet const & params)
41+
: EDProducer{params} {
42+
produces< std::vector< sbn::EXTCountInfo >, art::InSubRun >();
43+
TotalEXTCounts = 0;
44+
}
45+
46+
void sbn::SBNDBNBEXTRetriever::produce(art::Event & e)
47+
{
48+
art::InputTag PTB_itag("daq", "ContainerPTB");
49+
auto PTB_cont_frags = e.getHandle<artdaq::Fragments>(PTB_itag);
50+
PTBInfo_t PTBInfo = extractPTBInfo(PTB_cont_frags, 4);
51+
int SingleEventGateCounter = PTBInfo.GateCounter;
52+
53+
TotalEXTCounts += SingleEventGateCounter;
54+
sbn::EXTCountInfo extInfo;
55+
extInfo.gates_since_last_trigger = SingleEventGateCounter;
56+
fOutExtInfos.push_back(extInfo);
57+
}
58+
59+
void sbn::SBNDBNBEXTRetriever::beginSubRun(art::SubRun& sr)
60+
{
61+
TotalEXTCounts = 0;
62+
fOutExtInfos = {};
63+
return;
64+
}
65+
66+
void sbn::SBNDBNBEXTRetriever::endSubRun(art::SubRun& sr)
67+
{
68+
// We will add all of the EXTCountInfo data-products to the
69+
// art::SubRun so it persists
70+
71+
mf::LogDebug("SBNDBNBEXTRetriever")<< "Total number of DAQ Spills : " << TotalEXTCounts << std::endl;
72+
auto p = std::make_unique< std::vector< sbn::EXTCountInfo > >(fOutExtInfos);
73+
74+
sr.put(std::move(p), art::subRunFragment());
75+
76+
return;
77+
}
78+
79+
DEFINE_ART_MODULE(sbn::SBNDBNBEXTRetriever)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
find_package(ifbeam)
2+
find_package(ifdh_art)
3+
4+
cet_build_plugin(SBNDBNBRetriever art::module
5+
LIBRARIES
6+
sbn_SBNDPOTTools
7+
)
8+
9+
install_headers()
10+
install_fhicl()
11+
install_source()
12+

0 commit comments

Comments
 (0)