Skip to content

TPC YZ correction to use new per-plane database [release/SBN2024A] #792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release/SBN2024A
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
BEGIN_PROLOG

ICARUS_Calibration_GlobalTags: {
@table::TPC_CalibrationTags_Feb2024
@table::TPC_CalibrationTags_Jan2025
@table::PMT_CalibrationTags_Run3_Dec2023
@table::CRT_CalibrationTags_Oct2023
}
Expand Down
10 changes: 10 additions & 0 deletions fcl/configurations/calibration_database_TPC_TagSets_icarus.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,14 @@ TPC_CalibrationTags_Feb2024: {

}

## TPC_CalibrationTags_Feb2024 but updating tpc_yz_correction_data to tpc_yz_correction_allplanes_data
TPC_CalibrationTags_Jan2025: {

tpc_channelstatus_data: "v3r2"
tpc_elifetime_data: "v2r1"
tpc_dqdxcalibration_data: "v2r1"
tpc_yz_correction_allplanes_data: "v1r0"

}

END_PROLOG
22 changes: 20 additions & 2 deletions icaruscode/TPC/Calorimetry/NormalizeYZSQL_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ class NormalizeYZSQL : public INormalizeCharge
class ScaleInfo {
public:
struct Point {
int iplane;
int itpc;
double y, z;
};

class ScaleBin {
public:
int iplane;
int itpc;
double ylo;
double yhi;
Expand Down Expand Up @@ -94,6 +96,7 @@ DEFINE_ART_CLASS_TOOL(NormalizeYZSQL)
constexpr bool icarus::calo::NormalizeYZSQL::ScaleInfo::ScaleBin::operator<
(const ScaleBin& other) const noexcept
{
if (iplane != other.iplane) return iplane < other.iplane;
if (itpc != other.itpc) return itpc < other.itpc;
if (yhi != other.yhi) return yhi < other.yhi;
return zhi < other.zhi;
Expand All @@ -103,6 +106,7 @@ bool icarus::calo::NormalizeYZSQL::ScaleInfo::BinComp::operator()
(const ScaleBin& a, const Point& b) const noexcept
{
// the bin `a` must be strictly before the point `b`
if (a.iplane != b.iplane) return a.iplane < b.iplane;
if (a.itpc != b.itpc) return a.itpc < b.itpc;
if (a.yhi <= b.y) return true;
if (a.ylo > b.y) return false;
Expand All @@ -113,6 +117,7 @@ bool icarus::calo::NormalizeYZSQL::ScaleInfo::BinComp::operator()
(const Point& a, const ScaleBin& b) const noexcept
{
// the point `a` must be strictly before the bin `b`
if (a.iplane != b.iplane) return a.iplane < b.iplane;
if (a.itpc != b.itpc) return a.itpc < b.itpc;
if (a.y < b.ylo) return true;
if (a.y >= b.yhi) return false;
Expand All @@ -122,6 +127,7 @@ bool icarus::calo::NormalizeYZSQL::ScaleInfo::BinComp::operator()
bool icarus::calo::NormalizeYZSQL::ScaleInfo::ScaleBin::contains
(const Point& point) const noexcept
{
if (point.iplane != iplane) return false;
if (point.itpc != itpc) return false;
if ((point.y < ylo) || (point.y >= yhi)) return false;
return ((point.z >= zlo) && (point.z < zhi));
Expand Down Expand Up @@ -154,6 +160,7 @@ icarus::calo::NormalizeYZSQL::NormalizeYZSQL(fhicl::ParameterSet const &pset):
void icarus::calo::NormalizeYZSQL::configure(const fhicl::ParameterSet& pset) {}

const icarus::calo::NormalizeYZSQL::ScaleInfo& icarus::calo::NormalizeYZSQL::GetScaleInfo(uint64_t run) {

// check the cache
if (fScaleInfos.count(run)) {
return fScaleInfos.at(run);
Expand All @@ -173,7 +180,13 @@ const icarus::calo::NormalizeYZSQL::ScaleInfo& icarus::calo::NormalizeYZSQL::Get

// Iterate over the channels
thisscale.bins.reserve(channels.size());

for (unsigned ch = 0; ch < channels.size(); ch++) {

long lplane;
fDB.GetNamedChannelData(ch, "plane", lplane);
int iplane(lplane);

std::string tpcname;
fDB.GetNamedChannelData(ch, "tpc", tpcname);
int itpc = -1;
Expand Down Expand Up @@ -201,6 +214,7 @@ const icarus::calo::NormalizeYZSQL::ScaleInfo& icarus::calo::NormalizeYZSQL::Get
bin.yhi = yhi;
bin.zlo = zlo;
bin.zhi = zhi;
bin.iplane = iplane;
bin.itpc = itpc;
bin.scale = scale;

Expand All @@ -215,9 +229,13 @@ const icarus::calo::NormalizeYZSQL::ScaleInfo& icarus::calo::NormalizeYZSQL::Get

double icarus::calo::NormalizeYZSQL::Normalize(double dQdx, const art::Event &e,
const recob::Hit &hit, const geo::Point_t &location, const geo::Vector_t &direction, double t0) {

// Get the info
ScaleInfo const& i = GetScaleInfo(e.id().runID().run());

// plane
int plane = hit.WireID().Plane;

// compute itpc
int cryo = hit.WireID().Cryostat;
int tpc = hit.WireID().TPC;
Expand All @@ -226,15 +244,15 @@ double icarus::calo::NormalizeYZSQL::Normalize(double dQdx, const art::Event &e,
double y = location.y();
double z = location.z();

ScaleInfo::Point const point { itpc, y, z };
ScaleInfo::Point const point { plane, itpc, y, z };
ScaleInfo::ScaleBin const* b = i.findBin(point);

double const scale = b? b->scale: 1;
if (!b) {
// TODO: what to do if no lifetime is found? throw an exception??
}

if (fVerbose) std::cout << "NormalizeYZSQL Tool -- Data Cryo: " << cryo << " TPC: " << tpc << " iTPC: " << itpc << " Y: " << y << " Z: " << z << " scale: " << scale << std::endl;
if (fVerbose) std::cout << "NormalizeYZSQL Tool -- Data Cryo: " << cryo << " Plane: " << plane << " TPC: " << tpc << " iTPC: " << itpc << " Y: " << y << " Z: " << z << " scale: " << scale << std::endl;

return dQdx / scale;
}
Expand Down
4 changes: 2 additions & 2 deletions icaruscode/TPC/Calorimetry/normtools_icarus.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ tpcgain_local: {

yznorm_sql: {
tool_type: NormalizeYZSQL
DBFileName: tpc_yz_correction_data
DBTag: @local::ICARUS_Calibration_GlobalTags.tpc_yz_correction_data
DBFileName: tpc_yz_correction_allplanes_data
DBTag: @local::ICARUS_Calibration_GlobalTags.tpc_yz_correction_allplanes_data
Verbose: false
}

Expand Down