Skip to content

Commit 2626129

Browse files
Fix conflicts
2 parents 5a14e54 + 46cbc17 commit 2626129

10 files changed

Lines changed: 222 additions & 3 deletions

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(CRT)
34
add_subdirectory(DQM)

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: "v1r2"
7-
DatabaseTimeStamp: 1763157679000000000
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} )
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "calibration_database_TPC_TagSets_sbnd.fcl"
2+
#include "calibration_database_PDS_TagSets_sbnd.fcl"
3+
4+
BEGIN_PROLOG
5+
6+
SBND_Calibration_GlobalTags: {
7+
@table::TPC_CalibrationTags_Nov2025
8+
@table::PDS_CalibrationTags_Nov2025
9+
}
10+
11+
END_PROLOG
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# File: calibration_database_PDS_TagSets_sbnd.fcl
2+
# Author: original authors in ICARUS: M. Vicenzi (mvicenzi@bnl.gov), J. Kim (jae.sung.kim.3426@gmail.com), ported to SBND: S. Oh (sungbino@fnal.gov)
3+
# Date: November 14, 2025
4+
# Purpose: Tags definitions for the PDS calibration databases
5+
6+
BEGIN_PROLOG
7+
8+
# Run ranges
9+
## r1: SBND Full Run 1 with light trigger, run number 18250-18618
10+
11+
# For SBND 2025 Fall production
12+
PDS_CalibrationTags_Nov2025: {
13+
PMTCalibrationDatabaseTag: "v1r1"
14+
DatabaseTimeStamp: 1757601071000000000
15+
}
16+
17+
END_PROLOG
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# File: calibration_database_TPC_TagSets_sbnd.fcl
2+
# Purpose: Collection of tag info for the TPC calibration database
3+
4+
BEGIN_PROLOG
5+
6+
# Run ranges
7+
## r1: SBND Full Run 1 with light trigger, run number 18250-18618
8+
9+
## First one for 2025 Fall, only with etau tag
10+
TPC_CalibrationTags_Nov2025: {
11+
12+
tpc_elifetime_data: "v2r1"
13+
14+
}
15+
16+
END_PROLOG

sbndcode/LArSoftConfigurations/calorimetry_sbnd.fcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
BEGIN_PROLOG
55

66
sbnd_calorimetryalgdata: @local::standard_calorimetryalgdata
7+
sbnd_calorimetryalgdata.CaloDoLifeTimeCorrection: false # handled by NormTools to read etaus from DB
78
sbnd_calorimetryalgdata.CalAreaConstants: [ 0.02172 , 0.02150, 0.02103 ]
89
#values below aren't correct
910
sbnd_calorimetryalgdata.CalAmpConstants: [ 0.588726e-3, 0.588726e-3, 1.18998e-3 ]

0 commit comments

Comments
 (0)