Skip to content

Commit 95431b5

Browse files
Merge branch 'release/v10_06_03'
2 parents f4ec786 + 3b97928 commit 95431b5

22 files changed

Lines changed: 256 additions & 12 deletions

.github/pull_request_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
## Description
22
Please provide a detailed description of the changes this pull request introduces.
33

4-
$${\color{red}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}$$
4+
$${\color{red}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}$$
55

66
$${\color{red}\bf{\textrm{IMPORTANT UPDATE June 22nd 2025:}}}$$ If you are making a PR which is intended as a patch for the CURRENT production (which started in Spring 2025), you must make two PRs: one for develop and one for the production/v10_06_00 branch.
77

8-
$${\color{red}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}$$
8+
$${\color{red}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}$$
99

1010
## Checklist
1111
- [ ] Added at least 1 label from [available labels](https://github.com/SBNSoftware/sbndcode/issues/labels?sort=name-asc).

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.06.02)
18+
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 10.06.03)
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
@@ -2,3 +2,4 @@ add_subdirectory(OpReco)
22
add_subdirectory(CRT)
33
add_subdirectory(DQM)
44
add_subdirectory(PDSDatabaseInterface)
5+
add_subdirectory(TPCCalorimetry)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
set(TOOL_LIBRARIES
3+
lardataobj::RecoBase
4+
larreco::Calorimetry
5+
larcorealg::Geometry
6+
lardataalg::DetectorInfo
7+
lardata::ArtDataHelper
8+
canvas::canvas
9+
art::Framework_Services_Registry
10+
art::Utilities
11+
fhiclcpp::fhiclcpp
12+
cetlib::cetlib
13+
cetlib_except::cetlib_except
14+
ROOT::Core
15+
ROOT::Hist
16+
)
17+
18+
cet_build_plugin(NormalizeYZ art::tool LIBRARIES ${TOOL_LIBRARIES})
19+
20+
install_headers()
21+
install_fhicl()
22+
install_source()
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
2+
// Framework Includes
3+
#include "art/Framework/Core/EDProducer.h"
4+
#include "art/Framework/Principal/Event.h"
5+
#include "art/Framework/Principal/Handle.h"
6+
#include "art/Framework/Services/Registry/ServiceHandle.h"
7+
#include "art/Utilities/ToolMacros.h"
8+
#include "cetlib/cpu_timer.h"
9+
#include "fhiclcpp/ParameterSet.h"
10+
#include "messagefacility/MessageLogger/MessageLogger.h"
11+
12+
#include "canvas/Persistency/Common/Ptr.h"
13+
14+
// Tool include
15+
#include "larreco/Calorimetry/INormalizeCharge.h"
16+
17+
// Services
18+
#include "lardata/DetectorInfoServices/DetectorClocksService.h"
19+
20+
// ROOT includes
21+
#include "TFile.h"
22+
#include "TH2F.h"
23+
24+
// C++ includes
25+
#include <map>
26+
#include <string>
27+
#include <stdexcept>
28+
#include <iostream>
29+
30+
31+
32+
namespace sbnd {
33+
namespace calo {
34+
35+
class NormalizeYZ : public INormalizeCharge{
36+
public:
37+
explicit NormalizeYZ(fhicl::ParameterSet const& pset);
38+
39+
void configure(const fhicl::ParameterSet& pset) override;
40+
41+
double Normalize(double dQdx,
42+
const art::Event& evt,
43+
const recob::Hit& hit,
44+
const geo::Point_t& location,
45+
const geo::Vector_t& direction,
46+
double t0) override;
47+
48+
private:
49+
void reconfigure(const fhicl::ParameterSet& pset);
50+
51+
std::map<std::string, TH2F*> fCorrHists;
52+
std::string fFileName;
53+
bool fVerbose;
54+
};
55+
56+
NormalizeYZ::NormalizeYZ(fhicl::ParameterSet const& pset){
57+
reconfigure(pset); // delegate config to reusable function
58+
}
59+
60+
void NormalizeYZ::configure(const fhicl::ParameterSet& pset){
61+
reconfigure(pset);
62+
}
63+
64+
void NormalizeYZ::reconfigure(const fhicl::ParameterSet& pset){
65+
fFileName = pset.get<std::string>("FileName");
66+
fVerbose = pset.get<bool>("Verbose", false);
67+
68+
std::string fname;
69+
cet::search_path sp("FW_SEARCH_PATH");
70+
sp.find_file(fFileName, fname);
71+
72+
TFile* f = TFile::Open(fname.c_str(), "READ");
73+
if (!f || f->IsZombie()) {
74+
throw cet::exception("NormalizeYZ") << "Failed to open correction map file: " << fFileName;
75+
}
76+
77+
for (int plane = 0; plane < 3; plane++){ // planes : 2 inductions (idx : 0, 1) and 1 collection (idx : 2)
78+
for (int tpc = 0; tpc < 2; tpc++){ // tpc : east (idx : 0) and west (idx : 1) TPCs
79+
std::string histname = Form("CzyHist_%d_%d", plane, tpc);
80+
TH2F* h = (TH2F*)f->Get(histname.c_str());
81+
if (!h) {
82+
throw cet::exception("NormalizeYZ") << "Missing histogram in file: " << histname;
83+
}
84+
85+
fCorrHists[Form("plane%d_%d", plane, tpc)] = (TH2F*)h->Clone();
86+
fCorrHists[Form("plane%d_%d", plane, tpc)]->SetDirectory(nullptr);
87+
}
88+
}
89+
f->Close();
90+
}
91+
92+
double NormalizeYZ::Normalize(double dQdx,
93+
const art::Event& evt,
94+
const recob::Hit& hit,
95+
const geo::Point_t& location,
96+
const geo::Vector_t&,
97+
double){
98+
99+
int plane = hit.WireID().Plane;
100+
//int tpc = hit.WireID().TPC;
101+
102+
// just to be sure and consistent with the logic of input YZ map
103+
// seems like current setup of directly calling hit.WireID().TPC has a tolerance of 30cm
104+
// meaning - an approx region of -30<x<30 lies in both the TPCs
105+
int tpc;
106+
if(location.X()<0){
107+
tpc = 0;
108+
} else tpc = 1;
109+
110+
111+
std::string key = Form("plane%d_%d", plane, tpc);
112+
113+
auto it = fCorrHists.find(key);
114+
if (it == fCorrHists.end()) {
115+
mf::LogWarning("NormalizeYZ") << "No correction histogram for " << key << ". Returning uncorrected dQdx";
116+
return dQdx;
117+
}
118+
119+
TH2F* hCorr = it->second;
120+
int binX = hCorr->GetXaxis()->FindBin(location.Z());
121+
int binY = hCorr->GetYaxis()->FindBin(location.Y());
122+
double scale = hCorr->GetBinContent(binX, binY);
123+
124+
if (fVerbose){
125+
std::cout << "[NormalizeYZ] Plane: " << plane << ", TPC: " << tpc
126+
<< ", Y: " << location.Y() << ", Z: " << location.Z()
127+
<< ", Scale: " << scale << ", dQdx (raw): " << dQdx
128+
<< ", dQdx (corrected): " << dQdx / scale << std::endl;
129+
}
130+
131+
if (scale < 1e-3){
132+
mf::LogWarning("NormalizeYZ") << "Invalid scale at (Y,Z)=(" << location.Y() << "," << location.Z() << "). Returning uncorrected dQdx";
133+
return dQdx;
134+
}
135+
136+
return dQdx / scale;
137+
}
138+
139+
DEFINE_ART_CLASS_TOOL(NormalizeYZ)
140+
141+
} // namespace calo
142+
} // namespace sbnd
143+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
BEGIN_PROLOG
2+
3+
yznorm_hist_data: {
4+
tool_type: NormalizeYZ
5+
FileName: "YZmaps/yz_correction_map_data1e20.root"
6+
Verbose: false
7+
}
8+
9+
yznorm_hist_mc: {
10+
tool_type: NormalizeYZ
11+
FileName: "YZmaps/yz_correction_map_mcp2025b5e18.root"
12+
Verbose: false
13+
}
14+
15+
# list of normalization tools - by far only YZ correction is implemented
16+
sbnd_calonormtoolsdata: [@local::yznorm_hist_data]
17+
sbnd_calonormtoolsmc: [@local::yznorm_hist_mc]
18+
19+
END_PROLOG
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
install_fhicl()
2+
add_subdirectory(pmt_variations)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
install_fhicl()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include "standard_detsim_sbnd.fcl"
2+
physics.producers.opdaq.GainFluctuationsParams.DynodeK: 0.25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include "standard_detsim_sbnd.fcl"
2+
physics.producers.opdaq.GainFluctuationsParams.DynodeK: 0.25
3+
physics.producers.opdaq.PMTBaselineRMS: 3.5

0 commit comments

Comments
 (0)