Skip to content

Commit f9c394e

Browse files
Merge branch 'release/v10_14_00'
2 parents 1e2835c + dfdb325 commit f9c394e

101 files changed

Lines changed: 2720 additions & 246 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.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
1717

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

sbndcode/Calibration/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
add_subdirectory(configurations)
12
add_subdirectory(OpReco)
23
add_subdirectory(DQM)
34
add_subdirectory(PDSDatabaseInterface)

sbndcode/Calibration/PDSDatabaseInterface/PMTCalibrationDatabase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ namespace sbndDB {
2525
virtual int getBreakoutBox(unsigned int channelID) const = 0;
2626
virtual int getCAENDigitizer(unsigned int channelID) const = 0;
2727
virtual int getCAENDigitizerChannel(unsigned int channelID) const = 0;
28+
virtual bool getOnPMT(unsigned int channelID) const = 0;
2829
virtual bool getReconstructChannel(unsigned int channelID) const = 0;
2930
virtual double getTotalTransitTime(unsigned int channelID) const = 0;
3031
virtual double getCosmicTimeCorrection(unsigned int channelID) const = 0;
3132
virtual double getSPEAmplitude(unsigned int channelID) const = 0;
3233
virtual double getSPEAmplitudeStd(unsigned int channelID) const = 0;
3334
virtual double getGaussFilterPower(unsigned int channelID) const = 0;
3435
virtual double getGaussFilterWC(unsigned int channelID) const = 0;
36+
virtual double getNonLineatiryPESat(unsigned int channelID) const = 0;
37+
virtual double getNonLineatiryAlpha(unsigned int channelID) const = 0;
3538
virtual std::vector<double> getSER(unsigned int channelID) const = 0;
3639
}; // end class
3740

sbndcode/Calibration/PDSDatabaseInterface/PMTCalibrationDatabaseProvider.cxx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ void sbndDB::PMTCalibrationDatabaseProvider::ReadPMTCalibration(uint32_t run)
114114
<< "Encountered error (code " << error
115115
<< ") while trying to access 'caen_digitizer_channel' on table " << dbname << "\n";
116116
fPMTCalibrationData[channel].caenDigitizerChannel = static_cast<int>(_caen_digitizer_channel);
117+
// Read on PMT
118+
bool _on_pmt = false;
119+
error = db.GetNamedChannelData(channel, "on_pmt", _on_pmt);
120+
if (error)
121+
throw cet::exception("PMTTimingCorrectionsProvider")
122+
<< "Encountered error (code " << error
123+
<< ") while trying to access 'on_pmt' on table " << dbname << "\n";
124+
fPMTCalibrationData[channel].onPMT = _on_pmt;
117125

118126
// Read reconstruct channel
119127
bool _reconstruct_channel = false;
@@ -178,6 +186,21 @@ void sbndDB::PMTCalibrationDatabaseProvider::ReadPMTCalibration(uint32_t run)
178186
<< dbname << "\n";
179187
fPMTCalibrationData[channel].gauss_wc = _gauss_wc;
180188

189+
double _nonlinearity_pesat = 0.;
190+
error = db.GetNamedChannelData(channel, "nonlinearity_pesat", _nonlinearity_pesat);
191+
if (error)
192+
throw cet::exception("PMTTimingCorrectionsProvider")
193+
<< "Encountered error (code " << error
194+
<< ") while trying to access 'nonlinearity_pesat' on table " << dbname << "\n";
195+
fPMTCalibrationData[channel].nonlinearity_pesat = _nonlinearity_pesat;
196+
double _nonlinearity_alpha = 0.;
197+
error = db.GetNamedChannelData(channel, "nonlinearity_alpha", _nonlinearity_alpha);
198+
if (error)
199+
throw cet::exception("PMTTimingCorrectionsProvider")
200+
<< "Encountered error (code " << error
201+
<< ") while trying to access 'nonlinearity_alpha' on table " << dbname << "\n";
202+
fPMTCalibrationData[channel].nonlinearity_alpha = _nonlinearity_alpha;
203+
181204
// Read SER
182205
std::vector<double> _ser;
183206
std::string name_base = "ser_vec_";

sbndcode/Calibration/PDSDatabaseInterface/PMTCalibrationDatabaseProvider.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class sbndDB::PMTCalibrationDatabaseProvider : public PMTCalibrationDatabase {
5050
int getCAENDigitizerChannel( unsigned int channelID ) const override {
5151
return getChannelCorrOrDefault(channelID).caenDigitizerChannel;
5252
};
53+
bool getOnPMT(unsigned int channelID) const override {
54+
return getChannelCorrOrDefault(channelID).onPMT;
55+
};
5356
bool getReconstructChannel(unsigned int channelID) const override {
5457
return getChannelCorrOrDefault(channelID).reconstructChannel;
5558
};
@@ -71,6 +74,12 @@ class sbndDB::PMTCalibrationDatabaseProvider : public PMTCalibrationDatabase {
7174
double getGaussFilterWC( unsigned int channelID ) const override {
7275
return getChannelCorrOrDefault(channelID).gauss_wc;
7376
};
77+
double getNonLineatiryPESat( unsigned int channelID ) const override {
78+
return getChannelCorrOrDefault(channelID).nonlinearity_pesat;
79+
};
80+
double getNonLineatiryAlpha( unsigned int channelID ) const override {
81+
return getChannelCorrOrDefault(channelID).nonlinearity_alpha;
82+
};
7483
std::vector<double> getSER( unsigned int channelID ) const override {
7584
return getChannelCorrOrDefault(channelID).ser;
7685
};
@@ -89,18 +98,20 @@ class sbndDB::PMTCalibrationDatabaseProvider : public PMTCalibrationDatabase {
8998
size_t breakoutBox=0;
9099
size_t caenDigitizer=0;
91100
size_t caenDigitizerChannel=0;
101+
bool onPMT=true;
92102
bool reconstructChannel=false;
93103
double totalTransitTime=0.;
94104
double cosmicTimeCorrection=0.;
95105
double spe_amplitude=0.;
96106
double spe_amplitude_std=0.;
97107
double gauss_wc_power=0.;
98108
double gauss_wc=0.;
109+
double nonlinearity_pesat=0.;
110+
double nonlinearity_alpha=0.;
99111
std::vector<double> ser={};
100112
};
101113

102-
const PMTCalibrationDB CorrectionDefaults = {0, 0, 0, 0, 0.0, 0.0, 0.0, {}};
103-
114+
const PMTCalibrationDB CorrectionDefaults = {0, 0, 0, true, false, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}};
104115
/// Map of corrections by channel
105116
std::map<unsigned int, PMTCalibrationDB> fPMTCalibrationData;
106117

sbndcode/Calibration/PDSDatabaseInterface/pmtcalibrationdatabase_sbnd.fcl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
#include "calibration_database_GlobalTags_sbnd.fcl"
2+
13
BEGIN_PROLOG
24

35
sbnd_pmtcalibrationdatabaseservice : {
46
service_provider: "PMTCalibrationDatabaseService"
57
CorrectionTags: {
6-
PMTCalibrationDatabaseTag: "v1r1"
7-
DatabaseTimeStamp: 1757601071000000000
8+
PMTCalibrationDatabaseTag: @local::SBND_Calibration_GlobalTags.PMTCalibrationDatabaseTag
9+
DatabaseTimeStamp: @local::SBND_Calibration_GlobalTags.DatabaseTimeStamp
810
TableName: "pds_calibration"
911
SERLength: 550
1012
}

sbndcode/Calibration/TPCCalorimetry/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
set(TOOL_LIBRARIES
3+
larevt::CalibrationDBI_Providers
34
lardataobj::RecoBase
45
larreco::Calorimetry
56
larcorealg::Geometry
@@ -13,8 +14,10 @@ set(TOOL_LIBRARIES
1314
cetlib_except::cetlib_except
1415
ROOT::Core
1516
ROOT::Hist
17+
wda::wda
1618
)
1719

20+
cet_build_plugin(NormalizeDriftSQLite art::tool LIBRARIES ${TOOL_LIBRARIES})
1821
cet_build_plugin(NormalizeYZ art::tool LIBRARIES ${TOOL_LIBRARIES})
1922

2023
install_headers()
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// Framework Includes
2+
#include "art/Framework/Core/EDProducer.h"
3+
#include "art/Framework/Principal/Event.h"
4+
#include "art/Framework/Principal/Handle.h"
5+
#include "art/Framework/Services/Registry/ServiceHandle.h"
6+
#include "art/Persistency/Common/PtrMaker.h"
7+
#include "art/Utilities/ToolMacros.h"
8+
#include "cetlib_except/exception.h"
9+
#include "cetlib/cpu_timer.h"
10+
#include "fhiclcpp/ParameterSet.h"
11+
#include "messagefacility/MessageLogger/MessageLogger.h"
12+
13+
#include "larevt/CalibrationDBI/Providers/DBFolder.h"
14+
15+
// Tool include
16+
#include "larreco/Calorimetry/INormalizeCharge.h"
17+
18+
// Services
19+
#include "lardata/DetectorInfoServices/DetectorClocksService.h"
20+
21+
// Lab helpers
22+
#include "wda.h"
23+
24+
// C++
25+
#include <string>
26+
#include <optional>
27+
#include <cassert>
28+
29+
namespace sbnd {
30+
namespace calo {
31+
32+
class NormalizeDriftSQLite : public INormalizeCharge
33+
{
34+
public:
35+
NormalizeDriftSQLite(fhicl::ParameterSet const &pset);
36+
37+
void configure(const fhicl::ParameterSet& pset) override;
38+
void setup(const art::Event& e) override;
39+
double Normalize(double dQdx, const art::Event &e, const recob::Hit &h, const geo::Point_t &location, const geo::Vector_t &direction, double t0) override;
40+
41+
private:
42+
// Configuration
43+
std::string fDBFileName;
44+
std::string fDBTag;
45+
bool fVerbose;
46+
47+
lariov::DBFolder fDB;
48+
49+
std::optional<detinfo::DetectorClocksData> fClockData; // need delayed construction
50+
51+
// Class to hold data from DB
52+
class RunInfo {
53+
public:
54+
double tau_E;
55+
double tau_W;
56+
};
57+
58+
// Helpers
59+
RunInfo GetRunInfo(uint64_t run);
60+
61+
// Cache run requests
62+
std::map<uint32_t, RunInfo> fRunInfos;
63+
};
64+
65+
DEFINE_ART_CLASS_TOOL(NormalizeDriftSQLite)
66+
67+
} // end namespace calo
68+
} // end namespace sbnd
69+
70+
71+
sbnd::calo::NormalizeDriftSQLite::NormalizeDriftSQLite(fhicl::ParameterSet const &pset):
72+
fDBFileName(pset.get<std::string>("DBFileName")),
73+
fDBTag(pset.get<std::string>("DBTag")),
74+
fVerbose(pset.get<bool>("Verbose", false)),
75+
fDB(fDBFileName, "", "", fDBTag, true, false)
76+
{}
77+
78+
void sbnd::calo::NormalizeDriftSQLite::configure(const fhicl::ParameterSet& pset) {}
79+
80+
void sbnd::calo::NormalizeDriftSQLite::setup(const art::Event& e) {
81+
fClockData.emplace(art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e));
82+
}
83+
84+
sbnd::calo::NormalizeDriftSQLite::RunInfo sbnd::calo::NormalizeDriftSQLite::GetRunInfo(uint64_t run) {
85+
// check the cache
86+
if (fRunInfos.count(run)) {
87+
return fRunInfos.at(run);
88+
}
89+
90+
// Look up the run
91+
//
92+
// Translate the run into a fake "timestamp"
93+
fDB.UpdateData((run+1000000000)*1000000000);
94+
95+
RunInfo thisrun;
96+
97+
double this_tau_E, this_tau_W;
98+
fDB.GetNamedChannelData(0, "etau_sce_spatial_east", this_tau_E);
99+
fDB.GetNamedChannelData(0, "etau_sce_spatial_west", this_tau_W);
100+
thisrun.tau_E = this_tau_E;
101+
thisrun.tau_W = this_tau_W;
102+
103+
if (fVerbose) std::cout << "NormalizeDriftSQLite Tool -- Lifetime Data:" << "\nTPC East: " << thisrun.tau_E << "\nTPC West: " << thisrun.tau_W << std::endl;
104+
105+
// Set the cache
106+
fRunInfos[run] = thisrun;
107+
108+
return thisrun;
109+
}
110+
111+
double sbnd::calo::NormalizeDriftSQLite::Normalize(double dQdx, const art::Event &e,
112+
const recob::Hit &hit, const geo::Point_t &location, const geo::Vector_t &direction, double t0) {
113+
114+
if (!fClockData) {
115+
std::cout << "Error: fClockData is not valid" << std::endl;
116+
throw cet::exception("fClockData is not valid");
117+
}
118+
119+
// Get the info
120+
RunInfo runelifetime = GetRunInfo(e.id().runID().run());
121+
122+
// lookup the TPC
123+
double thiselifetime = -1;
124+
unsigned tpc = hit.WireID().TPC;
125+
unsigned cryo = hit.WireID().Cryostat;
126+
127+
// East
128+
if (cryo == 0 && tpc == 0) thiselifetime = runelifetime.tau_E;
129+
130+
// West
131+
if (cryo == 0 && tpc == 1) thiselifetime = runelifetime.tau_W;
132+
133+
// Get the hit time
134+
double thit = fClockData->TPCTick2TrigTime(hit.PeakTime()) - t0;
135+
thit = thit * 1.e-3;
136+
137+
if (fVerbose) std::cout << "NormalizeDriftSQLite Tool -- Norm factor: " << exp(thit / thiselifetime) << " at TPC: " << tpc << " Cryo: " << cryo << " Time: " << thit << " Track T0: " << t0 << ", x: " << location.X() << std::endl;
138+
139+
// Scale
140+
if (thiselifetime > 0) {
141+
dQdx = dQdx*exp(thit / thiselifetime);
142+
}
143+
// Throw exception if thiselifetime is not updated to non-zero value
144+
else {
145+
std::cout << "sbnd::calo::NormalizeDriftSQLite::Normalize electron lifetime is not found for run " << e.id().runID().run() << std::endl;
146+
throw cet::exception("Electron lifetime is not found");
147+
}
148+
149+
return dQdx;
150+
}
151+

sbndcode/Calibration/TPCCalorimetry/normtools_sbnd.fcl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
#include "calibration_database_GlobalTags_sbnd.fcl"
2+
13
BEGIN_PROLOG
24

5+
driftnorm_sql: {
6+
tool_type: NormalizeDriftSQLite
7+
DBFileName: tpc_elifetime
8+
DBTag: @local::SBND_Calibration_GlobalTags.tpc_elifetime_data
9+
Verbose: false
10+
}
11+
312
yznorm_hist_data: {
413
tool_type: NormalizeYZ
514
FileName: "YZmaps/yz_correction_map_data1e20.root"
@@ -13,7 +22,7 @@ yznorm_hist_mc: {
1322
}
1423

1524
# list of normalization tools - by far only YZ correction is implemented
16-
sbnd_calonormtoolsdata: [@local::yznorm_hist_data]
25+
sbnd_calonormtoolsdata: [@local::driftnorm_sql, @local::yznorm_hist_data]
1726
sbnd_calonormtoolsmc: [@local::yznorm_hist_mc]
1827

1928
END_PROLOG
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Install fcl files in /job subdirectory.
2+
3+
install_fhicl()
4+
5+
# Also put a copy in the source tree.
6+
7+
FILE(GLOB fcl_files *.fcl)
8+
install_source( EXTRAS ${fcl_files} )

0 commit comments

Comments
 (0)