Skip to content

Commit 7719d51

Browse files
Merge pull request #839 from SBNSoftware/feature/hlay_crt_calibration_database_interface
CRT Calibration Database Interface
2 parents 417030d + 74ed205 commit 7719d51

62 files changed

Lines changed: 893 additions & 10331 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sbndcode/CRT/CRTAna/CRTAnalysis_module.cc

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class sbnd::crt::CRTAnalysis : public art::EDAnalyzer {
6363
// Required functions.
6464
void analyze(art::Event const& e) override;
6565

66+
void beginRun(art::Run const& r) override;
67+
6668
void AnalysePTBs(std::vector<art::Ptr<raw::ptb::sbndptb>> &PTBVec);
6769

6870
void AnalyseTDCs(std::vector<art::Ptr<sbnd::timing::DAQTimestamp>> &TDCVec);
@@ -95,8 +97,10 @@ class sbnd::crt::CRTAnalysis : public art::EDAnalyzer {
9597

9698
private:
9799

98-
art::ServiceHandle<CRTGeoService> fCRTGeoService;
99-
TPCGeoAlg fTPCGeoAlg;
100+
art::ServiceHandle<CRTGeoService> fCRTGeoService;
101+
art::ServiceHandle<SBND::CRTChannelMapService> fCRTChannelMapService;
102+
103+
TPCGeoAlg fTPCGeoAlg;
100104
CRTBackTrackerAlg fCRTBackTrackerAlg;
101105

102106
std::string fMCParticleModuleLabel, fSimDepositModuleLabel, fFEBDataModuleLabel, fCRTStripHitModuleLabel,
@@ -640,37 +644,39 @@ sbnd::crt::CRTAnalysis::CRTAnalysis(fhicl::ParameterSet const& p)
640644
fTree->Branch("tdc_offset", "std::vector<uint64_t>", &_tdc_offset);
641645
fTree->Branch("tdc_name", "std::vector<std::string>", &_tdc_name);
642646
}
647+
}
643648

649+
void sbnd::crt::CRTAnalysis::beginRun(art::Run const& r)
650+
{
644651
if(fDebug)
645652
{
646-
for(auto const &[name, tagger] : fCRTGeoService->GetTaggers())
647-
{
648-
std::cout << "Tagger: " << tagger.name << '\n'
649-
<< "X - Min: " << tagger.minX << " Max: " << tagger.maxX << '\n'
650-
<< "Y - Min: " << tagger.minY << " Max: " << tagger.maxY << '\n'
651-
<< "Z - Min: " << tagger.minZ << " Max: " << tagger.maxZ << '\n' << std::endl;
652-
}
653+
std::cout << "\n==================================="
654+
<< "\nTaggers!"
655+
<< "\n===================================";
653656

654-
std::cout << std::endl;
657+
for (auto const &[name, tagger] : fCRTGeoService->GetTaggers())
658+
std::cout << std::endl << tagger;
655659

656-
for(auto const &[name, module] : fCRTGeoService->GetModules())
657-
{
658-
std::cout << "Module: " << module.name << " (" << module.taggerName << ")" << '\n';
659-
if(module.minos)
660-
std::cout << "MINOS module" << std::endl;
661-
std::cout << "X - Min: " << module.minX << " Max: " << module.maxX << " Diff: " << module.maxX - module.minX << '\n'
662-
<< "Y - Min: " << module.minY << " Max: " << module.maxY << " Diff: " << module.maxY - module.minY << '\n'
663-
<< "Z - Min: " << module.minZ << " Max: " << module.maxZ << " Diff: " << module.maxZ - module.minZ << '\n'
664-
<< "Orientation: " << module.orientation << '\n' << std::endl;
665-
}
660+
std::cout << "\n==================================="
661+
<< "\nModules!"
662+
<< "\n===================================";
666663

667-
std::cout << std::endl;
664+
for (auto const &[name, module] : fCRTGeoService->GetModules())
665+
std::cout << std::endl << module;
668666

669-
for(auto const &[name, sipm] : fCRTGeoService->GetSiPMs())
670-
{
671-
std::cout << "SiPM: " << sipm.channel << " (" << sipm.channel/32 << " - " << sipm.channel%32 << ")" << '\n'
672-
<< "x: " << sipm.x << " y: " << sipm.y << " z: " << sipm.z << std::endl;
673-
}
667+
std::cout << "\n==================================="
668+
<< "\nStrips!"
669+
<< "\n===================================";
670+
671+
for (auto const &[name, strip] : fCRTGeoService->GetStrips())
672+
std::cout << std::endl << strip;
673+
674+
std::cout << "\n==================================="
675+
<< "\nSiPMs!"
676+
<< "\n===================================";
677+
678+
for (auto const &[name, sipm] : fCRTGeoService->GetSiPMs())
679+
std::cout << std::endl << sipm;
674680
}
675681
}
676682

@@ -1269,20 +1275,12 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
12691275
for(unsigned ii = 0; ii < _cl_nhits[i]; ++ii)
12701276
{
12711277
const auto striphit = striphits[ii];
1272-
_cl_channel_set[i][ii] = striphit->Channel();
1273-
_cl_adc_set[i][2*ii] = striphit->ADC1();
1274-
_cl_adc_set[i][2*ii+1] = striphit->ADC2();
1275-
_cl_sh_ts0_set[i][ii] = striphit->Ts0();
1276-
_cl_sh_ts1_set[i][ii] = striphit->Ts1();
1277-
1278-
if(fDataMode)
1279-
{
1280-
art::ServiceHandle<SBND::CRTChannelMapService> ChannelMapService;
1281-
SBND::CRTChannelMapService::ModuleInfo_t module_info = ChannelMapService->GetModuleInfoFromOfflineID( striphit->Channel() / 32 );
1282-
_cl_sh_feb_mac5_set[i][ii] = ( module_info.valid ) ? module_info.feb_mac5 : 0;
1283-
}
1284-
else
1285-
_cl_sh_feb_mac5_set[i][ii] = striphit->Channel() / 32;
1278+
_cl_channel_set[i][ii] = striphit->Channel();
1279+
_cl_adc_set[i][2*ii] = striphit->ADC1();
1280+
_cl_adc_set[i][2*ii+1] = striphit->ADC2();
1281+
_cl_sh_ts0_set[i][ii] = striphit->Ts0();
1282+
_cl_sh_ts1_set[i][ii] = striphit->Ts1();
1283+
_cl_sh_feb_mac5_set[i][ii] = fCRTChannelMapService->GetMAC5FromOfflineChannelID(striphit->Channel());
12861284

12871285
/*
12881286
* The below segment reimplements the CorrectTime() method

sbndcode/CRT/CRTAna/run_crtana.fcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "crtgeoservice_sbnd.fcl"
1+
#include "crt_services_sbnd.fcl"
22
#include "crtana_sbnd.fcl"
33
#include "simulationservices_sbnd.fcl"
44

@@ -8,12 +8,12 @@ services:
88
{
99
TFileService: { fileName: "crtana_sbnd.root" }
1010
@table::sbnd_basic_services
11+
@table::crt_services_sbnd
1112
ParticleInventoryService: @local::sbnd_particleinventoryservice
1213
BackTrackerService: @local::sbnd_backtrackerservice
1314
DetectorClocksService: @local::sbnd_detectorclocks
1415
LArPropertiesService: @local::sbnd_properties
1516
DetectorPropertiesService: @local::sbnd_detproperties
16-
CRTGeoService: @local::crtgeoservice_sbnd
1717
}
1818

1919
source:

sbndcode/CRT/CRTAna/run_crtana_calibntuples_data.fcl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#include "crt_channel_map_service.fcl"
2-
#include "crt_calib_service.fcl"
31
#include "run_crtana_calibntuples.fcl"
42

53
services.ParticleInventoryService: @erase
64
services.BackTrackerService: @erase
75

8-
services.CRTChannelMapService: @local::crt_channel_map_standard
9-
services.CRTCalibService: @local::crt_calib_service
10-
services.CRTGeoService: @local::crtgeoservice_data_sbnd
6+
services:
7+
{
8+
@table::services
9+
@table::crt_services_data_sbnd
10+
}
1111

1212
physics.analyzers.caloskim.G4producer: ""
1313
physics.analyzers.caloskim.SimChannelproducer: ""
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#include "crt_channel_map_service.fcl"
2-
#include "crt_calib_service.fcl"
31
#include "run_crtana.fcl"
42

53
services.ParticleInventoryService: @erase
64
services.BackTrackerService: @erase
75

8-
services.CRTChannelMapService: @local::crt_channel_map_standard
9-
services.CRTCalibService: @local::crt_calib_service
10-
services.CRTGeoService: @local::crtgeoservice_data_sbnd
6+
services:
7+
{
8+
@table::services
9+
@table::crt_services_data_sbnd
10+
}
1111

1212
physics.analyzers.crtana: @local::crtana_data_sbnd

sbndcode/CRT/CRTEventDisplay/run_crteventdisplay.fcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#include "simulationservices_sbnd.fcl"
2-
#include "crtgeoservice_sbnd.fcl"
2+
#include "crt_services_sbnd.fcl"
33
#include "crteventdisplay_sbnd.fcl"
44

55
process_name: CRTEventDisplay
66

77
services:
88
{
99
@table::sbnd_services
10+
@table::crt_services_sbnd
1011
ParticleInventoryService: @local::sbnd_particleinventoryservice
11-
CRTGeoService: @local::crtgeoservice_sbnd
1212
}
1313

1414
source:
@@ -22,7 +22,7 @@ physics:
2222
{
2323
analyzers:
2424
{
25-
crtevd: @local::crteventdisplay_sbnd
25+
crtevd: @local::crteventdisplay_sbnd
2626
}
2727

2828
ana: [ crtevd ]

sbndcode/CRT/CRTEventDisplay/run_crteventdisplay_data.fcl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
#include "services_sbnd.fcl"
2+
#include "crt_services_sbnd.fcl"
23
#include "crteventdisplay_sbnd.fcl"
3-
#include "crt_channel_map_service.fcl"
4-
#include "crt_calib_service.fcl"
5-
#include "crtgeoservice_sbnd.fcl"
64

75
process_name: CRTEventDisplay
86

97
services:
108
{
119
@table::sbnd_services
12-
CRTGeoService: @local::crtgeoservice_data_sbnd
13-
CRTChannelMapService: @local::crt_channel_map_standard
14-
CRTCalibService: @local::crt_calib_service
10+
@table::crt_services_data_sbnd
1511
}
1612

1713
source:
@@ -24,7 +20,7 @@ physics:
2420
{
2521
analyzers:
2622
{
27-
crtevd: @local::crteventdisplay_sbnd_data
23+
crtevd: @local::crteventdisplay_sbnd_data
2824
}
2925

3026
ana: [ crtevd ]

sbndcode/CRT/CRTReco/CRTStripHitProducer_module.cc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "sbndcode/Geometry/GeometryWrappers/CRTGeoService.h"
2929
#include "sbndcode/Decoders/PTB/sbndptb.h"
3030
#include "sbndcode/Timing/SBNDRawTimingObj.h"
31+
#include "sbndcode/ChannelMaps/CRT/CRTChannelMapService.h"
3132

3233
#include <memory>
3334
#include <bitset>
@@ -56,7 +57,8 @@ class sbnd::crt::CRTStripHitProducer : public art::EDProducer {
5657

5758
private:
5859

59-
art::ServiceHandle<CRTGeoService> fCRTGeoService;
60+
art::ServiceHandle<CRTGeoService> fCRTGeoService;
61+
art::ServiceHandle<SBND::CRTChannelMapService> fCRTChannelMapService;
6062

6163
std::string fFEBDataModuleLabel;
6264
uint16_t fADCThreshold;
@@ -205,14 +207,15 @@ std::vector<sbnd::crt::CRTStripHit> sbnd::crt::CRTStripHitProducer::CreateStripH
205207
{
206208
std::vector<CRTStripHit> stripHits;
207209

208-
const uint32_t mac5 = data->Mac5();
209-
uint32_t unixs = data->UnixS();
210+
const uint32_t offline_module_id = data->Mac5();
211+
uint32_t unixs = data->UnixS();
210212

211213
// Only consider "real data" readouts, not clock resets etc
212214
if(!(data->Flags() == 3 || (fAllowFlag1 && data->Flags() == 1)))
213215
return stripHits;
214-
215-
const CRTModuleGeo module = fCRTGeoService->GetModule(mac5 * 32);
216+
217+
const uint32_t offline_channel_id = fCRTChannelMapService->ConstructOfflineChannelIDFromOfflineModuleIDAndOfflineLocalChannel(offline_module_id, 0);
218+
const CRTModuleGeo module = fCRTGeoService->GetModule(offline_channel_id);
216219

217220
// Correct for FEB readout cable length
218221
// (time is FEB-by-FEB not channel-by-channel)
@@ -257,11 +260,11 @@ std::vector<sbnd::crt::CRTStripHit> sbnd::crt::CRTStripHitProducer::CreateStripH
257260
for(unsigned adc_i = 0; adc_i < 32; adc_i+=2)
258261
{
259262
// Calculate SiPM channel number
260-
const uint16_t channel = mac5 * 32 + adc_i;
263+
const uint16_t offline_channel_id = fCRTChannelMapService->ConstructOfflineChannelIDFromOfflineModuleIDAndOfflineLocalChannel(offline_module_id, adc_i);
261264

262-
const CRTStripGeo strip = fCRTGeoService->GetStrip(channel);
263-
const CRTSiPMGeo sipm1 = fCRTGeoService->GetSiPM(channel);
264-
const CRTSiPMGeo sipm2 = fCRTGeoService->GetSiPM(channel+1);
265+
const CRTStripGeo strip = fCRTGeoService->GetStrip(offline_channel_id);
266+
const CRTSiPMGeo sipm1 = fCRTGeoService->GetSiPM(offline_channel_id);
267+
const CRTSiPMGeo sipm2 = fCRTGeoService->GetSiPM(offline_channel_id+1);
265268

266269
if(sipm1.status == CRTChannelStatus::kDeadChannel || sipm2.status == CRTChannelStatus::kDeadChannel)
267270
continue;
@@ -287,7 +290,7 @@ std::vector<sbnd::crt::CRTStripHit> sbnd::crt::CRTStripHitProducer::CreateStripH
287290
if(pos - err < 0)
288291
err = pos;
289292

290-
stripHits.emplace_back(channel, t0, t1, ref_time_s, pos, err, adc1, adc2);
293+
stripHits.emplace_back(offline_channel_id, t0, t1, ref_time_s, pos, err, adc1, adc2);
291294
}
292295
}
293296

sbndcode/CRT/CRTReco/run_crtclustering.fcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#include "services_sbnd.fcl"
22
#include "rootoutput_sbnd.fcl"
33
#include "crtrecoproducers_sbnd.fcl"
4-
#include "crtgeoservice_sbnd.fcl"
4+
#include "crt_services_sbnd.fcl"
55

66
process_name: CRTClustering
77

88
services:
99
{
1010
@table::sbnd_services
11-
CRTGeoService: @local::crtgeoservice_sbnd
11+
@table::crt_services_sbnd
1212
}
1313

1414
source:

sbndcode/CRT/CRTReco/run_crtreco.fcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#include "services_sbnd.fcl"
22
#include "rootoutput_sbnd.fcl"
33
#include "crtrecoproducers_sbnd.fcl"
4-
#include "crtgeoservice_sbnd.fcl"
4+
#include "crt_services_sbnd.fcl"
55

66
process_name: CRTReco
77

88
services:
99
{
1010
@table::sbnd_services
11-
CRTGeoService: @local::crtgeoservice_sbnd
11+
@table::crt_services_sbnd
1212
}
1313

1414
source:

sbndcode/CRT/CRTReco/run_crtreco_data.fcl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
#include "crt_channel_map_service.fcl"
2-
#include "crt_calib_service.fcl"
31
#include "run_crtreco.fcl"
42

5-
services.message: @local::sbnd_message_services
6-
services.CRTChannelMapService: @local::crt_channel_map_standard
7-
services.CRTCalibService: @local::crt_calib_service
8-
services.CRTGeoService: @local::crtgeoservice_data_sbnd
3+
services:
4+
{
5+
@table::services
6+
@table::crt_services_data_sbnd
7+
}
98

109
physics.producers.crtstrips: @local::crtstriphitproducer_data_sbnd
1110
physics.producers.crtclustering: @local::crtclusterproducer_data_sbnd

0 commit comments

Comments
 (0)