Skip to content

Commit ed56f63

Browse files
authored
Merge branch 'develop' into feature/pgreen_g4rw
2 parents a2e7fbd + fc2a169 commit ed56f63

19 files changed

Lines changed: 616 additions & 19 deletions

CMakeLists.txt

Lines changed: 2 additions & 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.06.00.03 LANGUAGES CXX)
19+
project(sbncode VERSION 10.09.00 LANGUAGES CXX)
2020

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

@@ -40,6 +40,7 @@ cet_report_compiler_flags(REPORT_THRESHOLD VERBOSE)
4040

4141
# these are minimum required versions, not the actual product versions
4242
find_package( art REQUIRED )
43+
find_package( Eigen3 REQUIRED)
4344
find_package( messagefacility REQUIRED )
4445
find_package( art_root_io REQUIRED )
4546
find_package( nusimdata REQUIRED )

sbncode/BeamSpillInfoRetriever/CMakeLists.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ art_make_library(LIBRARIES Boost::system
1515
SOURCE MWRData.cpp
1616
)
1717

18+
1819
art_make_library(
1920
LIBRARIES
2021
art::Persistency_Common
@@ -26,11 +27,23 @@ art_make_library(
2627
sbnobj::Common_POTAccounting
2728
sbn_MWRData
2829
larcorealg::CoreUtils
29-
30-
LIBRARY_NAME sbn_SBNDPOTTools
30+
31+
LIBRARY_NAME sbn_SBNDPOTTools
3132
SOURCE SBNDPOTTools.cpp
3233
)
3334

35+
art_make_library(
36+
LIBRARIES
37+
38+
ROOT::Hist
39+
ROOT::MathCore
40+
sbnobj::Common_POTAccounting
41+
42+
43+
LIBRARY_NAME sbn_getFOM
44+
SOURCE getFOM.cpp
45+
)
46+
3447
install_headers()
3548
install_fhicl()
3649
install_source()

sbncode/BeamSpillInfoRetriever/SBNDBNBRetriever/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ find_package(ifdh_art)
44
cet_build_plugin(SBNDBNBRetriever art::module
55
LIBRARIES
66
sbn_SBNDPOTTools
7+
sbn_getFOM
78
)
89

910
install_headers()

sbncode/BeamSpillInfoRetriever/SBNDBNBRetriever/SBNDBNBRetriever_module.cc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "messagefacility/MessageLogger/MessageLogger.h"
1010
#include "sbnobj/Common/POTAccounting/BNBSpillInfo.h"
1111
#include "sbncode/BeamSpillInfoRetriever/SBNDPOTTools.h"
12+
#include "sbncode/BeamSpillInfoRetriever/getFOM.h"
13+
1214

1315
namespace sbn {
1416
class SBNDBNBRetriever;
@@ -35,7 +37,10 @@ class sbn::SBNDBNBRetriever : public art::EDProducer {
3537
double fBESOffset;
3638
std::string fDeviceUsedForTiming;
3739
std::unique_ptr<ifbeam_ns::BeamFolder> bfp;
40+
std::unique_ptr<ifbeam_ns::BeamFolder> offsets;
41+
std::unique_ptr<ifbeam_ns::BeamFolder> vp873;
3842
std::unique_ptr<ifbeam_ns::BeamFolder> bfp_mwr;
43+
3944
sbn::MWRData mwrdata;
4045
art::ServiceHandle<ifbeam_ns::IFBeam> ifbeam_handle;
4146
static constexpr double MWRtoroidDelay = -0.035; ///< the same time point is measured _t_ by MWR and _t + MWRtoroidDelay`_ by the toroid [ms]
@@ -56,12 +61,19 @@ sbn::SBNDBNBRetriever::SBNDBNBRetriever(fhicl::ParameterSet const & params)
5661
fTimePad = params.get<double>("TimePadding");
5762
fBESOffset = params.get<double>("BESOffset");
5863
fDeviceUsedForTiming = params.get<std::string>("DeviceUsedForTiming");
59-
bfp = ifbeam_handle->getBeamFolder(params.get<std::string>("Bundle"), params.get<std::string>("URL"), std::stod(params.get<std::string>("TimeWindow")));
64+
double const timeWindow = std::stod(params.get<std::string>("TimeWindow"));
65+
bfp = ifbeam_handle->getBeamFolder(params.get<std::string>("Bundle"), params.get<std::string>("URL"), timeWindow);
6066
bfp->set_epsilon(0.02);
6167
bfp_mwr = ifbeam_handle->getBeamFolder(params.get<std::string>("MultiWireBundle"), params.get<std::string>("URL"), std::stod(params.get<std::string>("MWR_TimeWindow")));
6268
bfp_mwr->set_epsilon(0.5);
6369
bfp_mwr->setValidWindow(3605);
6470
TotalBeamSpills = 0;
71+
vp873 = ifbeam_handle->getBeamFolder(params.get<std::string>("VP873Bundle"), params.get<std::string>("URL"), timeWindow);
72+
vp873->set_epsilon(0.02);
73+
74+
offsets = ifbeam_handle->getBeamFolder(params.get<std::string>("OffsetBundle"), params.get<std::string>("URL"), timeWindow);
75+
offsets->set_epsilon(600);
76+
6577
}
6678

6779
void sbn::SBNDBNBRetriever::produce(art::Event & e)
@@ -210,8 +222,11 @@ int sbn::SBNDBNBRetriever::matchMultiWireData(
210222

211223
}//end loop over MWR devices
212224

213-
sbn::BNBSpillInfo spillInfo = makeBNBSpillInfo(eventID, times_temps[i], MWRdata, matched_MWR, bfp);
225+
sbn::BNBSpillInfo spillInfo = makeBNBSpillInfo(eventID, times_temps[i], MWRdata, matched_MWR, bfp, offsets, vp873);
214226

227+
double const spillFOM = sbn::getBNBqualityFOM(spillInfo);
228+
spillInfo.FOM = spillFOM;
229+
215230
beamInfos.push_back(std::move(spillInfo));
216231

217232
// We do not write these to the art::Events because

sbncode/BeamSpillInfoRetriever/SBNDBNBZEROBIASRetriever/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ find_package(ifdh_art)
44
cet_build_plugin(SBNDBNBZEROBIASRetriever art::module
55
LIBRARIES
66
sbn_SBNDPOTTools
7+
sbn_getFOM
78
)
89

910
install_headers()

sbncode/BeamSpillInfoRetriever/SBNDBNBZEROBIASRetriever/SBNDBNBZEROBIASRetriever_module.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "messagefacility/MessageLogger/MessageLogger.h"
1010
#include "sbnobj/Common/POTAccounting/BNBSpillInfo.h"
1111
#include "sbncode/BeamSpillInfoRetriever/SBNDPOTTools.h"
12+
#include "sbncode/BeamSpillInfoRetriever/getFOM.h"
1213

1314
namespace sbn {
1415
class SBNDBNBZEROBIASRetriever;
@@ -34,6 +35,8 @@ class sbn::SBNDBNBZEROBIASRetriever : public art::EDProducer {
3435
double fBESOffset;
3536
std::string fDeviceUsedForTiming;
3637
std::unique_ptr<ifbeam_ns::BeamFolder> bfp;
38+
std::unique_ptr<ifbeam_ns::BeamFolder> offsets;
39+
std::unique_ptr<ifbeam_ns::BeamFolder> vp873;
3740
std::unique_ptr<ifbeam_ns::BeamFolder> bfp_mwr;
3841
sbn::MWRData mwrdata;
3942
art::ServiceHandle<ifbeam_ns::IFBeam> ifbeam_handle;
@@ -56,11 +59,18 @@ sbn::SBNDBNBZEROBIASRetriever::SBNDBNBZEROBIASRetriever(fhicl::ParameterSet cons
5659
fTimePad = params.get<double>("TimePadding");
5760
fDeviceUsedForTiming = params.get<std::string>("DeviceUsedForTiming");
5861
fBESOffset = params.get<double>("BESOffset");
59-
bfp = ifbeam_handle->getBeamFolder(params.get<std::string>("Bundle"), params.get<std::string>("URL"), std::stod(params.get<std::string>("TimeWindow")));
62+
const double timeWindow = std::stod(params.get<std::string>("TimeWindow"));
63+
bfp = ifbeam_handle->getBeamFolder(params.get<std::string>("Bundle"), params.get<std::string>("URL"), timeWindow);
6064
bfp->set_epsilon(0.02);
6165
bfp_mwr = ifbeam_handle->getBeamFolder(params.get<std::string>("MultiWireBundle"), params.get<std::string>("URL"), std::stod(params.get<std::string>("MWR_TimeWindow")));
6266
bfp_mwr->set_epsilon(0.5);
6367
bfp_mwr->setValidWindow(3605);
68+
vp873 = ifbeam_handle->getBeamFolder(params.get<std::string>("VP873Bundle"), params.get<std::string>("URL"), timeWindow);
69+
vp873->set_epsilon(0.02);
70+
71+
offsets = ifbeam_handle->getBeamFolder(params.get<std::string>("OffsetBundle"), params.get<std::string>("URL"), timeWindow);
72+
offsets->set_epsilon(600);
73+
6474
TotalBeamSpills = 0;
6575
produces< std::vector< sbn::BNBSpillInfo >, art::InEvent >();
6676
produces< std::vector< sbn::BNBSpillInfo >, art::InSubRun >();
@@ -217,7 +227,10 @@ void sbn::SBNDBNBZEROBIASRetriever::matchMultiWireData(
217227
}//end loop over MWR times
218228
}//end loop over MWR devices
219229

220-
sbn::BNBSpillInfo spillInfo = makeBNBSpillInfo(eventID, times_temps[i], MWRdata, matched_MWR, bfp);
230+
sbn::BNBSpillInfo spillInfo = makeBNBSpillInfo(eventID, times_temps[i], MWRdata, matched_MWR, bfp, offsets, vp873);
231+
double spillFOM = sbn::getBNBqualityFOM(spillInfo);
232+
spillInfo.FOM = spillFOM;
233+
221234
beamInfos.push_back(std::move(spillInfo));
222235

223236
// We do not write these to the art::Events because

sbncode/BeamSpillInfoRetriever/SBNDPOTTools.cpp

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace sbn{
6565
// Collect device information to make BNBSpillInfo object. Used in
6666
// ICARUS and SBND modules.
6767
sbn::BNBSpillInfo makeBNBSpillInfo
68-
(art::EventID const& eventID, double time, MWRdata_t const& MWRdata, std::vector<int> const& matched_MWR, std::unique_ptr<ifbeam_ns::BeamFolder> const& bfp)
68+
(art::EventID const& eventID, double time, MWRdata_t const& MWRdata, std::vector<int> const& matched_MWR, std::unique_ptr<ifbeam_ns::BeamFolder> const& bfp, const std::unique_ptr<ifbeam_ns::BeamFolder> & offsets,const std::unique_ptr<ifbeam_ns::BeamFolder> & vp873)
6969
{
7070

7171
auto const& [ MWR_times, unpacked_MWR ] = MWRdata; // alias
@@ -87,8 +87,20 @@ namespace sbn{
8787
double BTJT2 = 0; // units Deg C
8888
double THCURR = 0; // units kiloAmps
8989

90+
91+
double VP873 = 0; //units mm; not in the first IFBeam query bunch
92+
double HP875Offset =0;//units mm; make a another separate IFBeam query bunch for offsets
93+
double VP875Offset =0;//units mm
94+
double VP873Offset =0;//units mm
95+
double HPTG1Offset =0;//units mm
96+
double HPTG2Offset =0;//units mm
97+
double VPTG1Offset =0;//units mm
98+
double VPTG2Offset =0;//units mm
99+
90100
double TOR860_time = 0; // units s
91-
101+
102+
double FOM =0;
103+
92104
// Here we request all the devices
93105
// since sometimes devices fail to report we'll
94106
// allow each to throw an exception but still move forward
@@ -107,6 +119,21 @@ namespace sbn{
107119
try{bfp->GetNamedData(time, "E:VPTG2",&VPTG2);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
108120
try{bfp->GetNamedData(time, "E:BTJT2",&BTJT2);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
109121
try{bfp->GetNamedData(time, "E:THCURR",&THCURR);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
122+
123+
124+
125+
try{bfp->GetNamedData(time, "E:VP873",&VP873);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
126+
127+
try{offsets->GetNamedData(time, "E_VP873S",&VP873Offset);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
128+
try{offsets->GetNamedData(time, "E_HP875S",&HP875Offset);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
129+
try{offsets->GetNamedData(time, "E_VP875S",&VP875Offset);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
130+
try{offsets->GetNamedData(time, "E_HPTG1S",&HPTG1Offset);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
131+
try{offsets->GetNamedData(time, "E_HPTG2S",&HPTG2Offset);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
132+
try{offsets->GetNamedData(time, "E_VPTG1S",&VPTG1Offset);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
133+
try{offsets->GetNamedData(time, "E_VPTG2S",&VPTG2Offset);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
134+
135+
136+
110137

111138
//crunch the times
112139
unsigned long int time_closest_int = (int) TOR860_time;
@@ -129,6 +156,17 @@ namespace sbn{
129156
beamInfo.THCURR = THCURR;
130157
beamInfo.spill_time_s = time_closest_int;
131158
beamInfo.spill_time_ns = time_closest_ns;
159+
beamInfo.VP873 = VP873;
160+
beamInfo.VP873Offset = VP873Offset;
161+
beamInfo.HP875Offset = HP875Offset;
162+
beamInfo.VP875Offset = VP875Offset;
163+
beamInfo.HPTG1Offset = HPTG1Offset;
164+
beamInfo.HPTG2Offset = HPTG2Offset;
165+
beamInfo.VPTG1Offset = VPTG1Offset;
166+
beamInfo.VPTG2Offset = VPTG2Offset;
167+
beamInfo.FOM = FOM;
168+
169+
132170

133171
for(auto const& MWRdata: unpacked_MWR){
134172
std::ignore = MWRdata;
@@ -166,7 +204,11 @@ namespace sbn{
166204
// information, so we'll write it to the SubRun
167205

168206
beamInfo.event = eventID.event(); // the rest of ID is known by art::SubRun
169-
207+
208+
//for(size_t m=0; m< beamInfo.M875BB.size(); m++){
209+
//std::cout << "M875BB: " <<beamInfo.M875BB[m] << " | M876BB: " << beamInfo.M876BB[m] << " | MMTBB: " << beamInfo.MMBTBB[m] <<std::endl;
210+
//}
211+
170212
return beamInfo;
171213
}
172214

@@ -331,4 +373,8 @@ namespace sbn{
331373

332374
return { std::move(MWR_times), std::move(unpacked_MWR) };
333375
}
376+
334377
}
378+
379+
380+

sbncode/BeamSpillInfoRetriever/SBNDPOTTools.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace sbn{
3636
double extractTDCTimeStamp(art::Handle<std::vector<artdaq::Fragment> > cont_frags);
3737
bool BrokenClock(double time, std::unique_ptr<ifbeam_ns::BeamFolder> const& bfp);
3838
MWRdata_t extractSpillTimes(TriggerInfo_t const& triggerInfo, std::unique_ptr<ifbeam_ns::BeamFolder> const& bfp, std::unique_ptr<ifbeam_ns::BeamFolder> const& bfp_mwr, double fTimePad, double MWRtoroidDelay, sbn::MWRData mwrdata );
39-
sbn::BNBSpillInfo makeBNBSpillInfo(art::EventID const& eventID, double time, MWRdata_t const& MWRdata, std::vector<int> const& matched_MWR, std::unique_ptr<ifbeam_ns::BeamFolder> const& bfp);
39+
sbn::BNBSpillInfo makeBNBSpillInfo(art::EventID const& eventID, double time, MWRdata_t const& MWRdata, std::vector<int> const& matched_MWR, std::unique_ptr<ifbeam_ns::BeamFolder> const& bfp, std::unique_ptr<ifbeam_ns::BeamFolder> const& offsets, std::unique_ptr<ifbeam_ns::BeamFolder> const& vp873);
4040
}
4141

4242
#endif

0 commit comments

Comments
 (0)