Skip to content

Commit 7b62fef

Browse files
committed
pr409
1 parent 8402f92 commit 7b62fef

File tree

2 files changed

+51
-22
lines changed

2 files changed

+51
-22
lines changed

gen/inc/WireCellGen/Scaler.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ namespace WireCell {
3636
double bin_width;
3737
double tpc_width;
3838
double bin_height;
39+
int n_ybin;
40+
int n_zbin;
41+
double yoffset;
42+
double zoffset;
3943
int plane;
4044
std::string anode_name;
45+
std::string yzmap_scale_filename;
4146
//Json::Value map = Json::arrayValue;
4247
//Json::arrayValue map;
4348
Json::Value jmap;
4449

50+
std::vector<std::vector<double>> yzmap;
51+
4552

4653
}; // Scaler
4754

gen/src/Scaler.cxx

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ using namespace WireCell;
2424

2525
Gen::Scaler::Scaler()
2626
: Aux::Logger("Scaler", "gen")
27+
, yzmap_scale_filename("Empty")
28+
, bin_width(0.0*units::cm)
29+
, tpc_width(0.0*units::mm)
30+
, bin_height(0.0*units::cm)
31+
, n_ybin(31)
32+
, n_zbin(180)
33+
, yoffset(180*units::cm)// ymin is -180 in ICARUS
34+
, zoffset(900*units::cm)// zmin is -900 in ICARUS
35+
, anode_name("Empty")
36+
, plane(0)
2737
{
2838
}
2939

@@ -33,12 +43,16 @@ WireCell::Configuration Gen::Scaler::default_configuration() const
3343
{
3444
Configuration cfg;
3545

36-
cfg["yzmap_scale_filename"] = "YZMap_Scale_filename";
37-
cfg["bin_width"] = "BinWidth";
38-
cfg["tpc_width"] = "TPCWidth";
39-
cfg["bin_height"] = "BinHeight";
40-
cfg["anode"] = "AnodePlane";
41-
cfg["plane"] = "WirePlane";
46+
cfg["yzmap_scale_filename"] = yzmap_scale_filename;
47+
cfg["bin_width"] = bin_width;
48+
cfg["tpc_width"] = tpc_width;
49+
cfg["bin_height"] = bin_height;
50+
cfg["n_ybin"] = n_ybin;
51+
cfg["n_zbin"] = n_zbin;
52+
cfg["yoffset"] = yoffset;
53+
cfg["zoffset"] = zoffset;
54+
cfg["anode"] = anode_name;
55+
cfg["plane"] = plane;
4256
return cfg;
4357
}
4458

@@ -67,15 +81,26 @@ void Gen::Scaler::configure(const WireCell::Configuration& cfg)
6781
m_boxes.push_back(face->sensitive());
6882
}
6983
// log->debug("Rest...");
70-
bin_width = get<double>(cfg, "bin_width");
71-
tpc_width = get<double>(cfg, "tpc_width");
72-
bin_height = get<double>(cfg, "bin_height");
73-
plane = get<int> (cfg, "plane");
84+
bin_width = get<double>(cfg, "bin_width", bin_width);
85+
tpc_width = get<double>(cfg, "tpc_width", tpc_width);
86+
bin_height = get<double>(cfg, "bin_height", bin_height);
87+
plane = get<int> (cfg, "plane", plane);
7488

75-
anode_name = get<std::string>(cfg, "anode");
89+
anode_name = get<std::string>(cfg, "anode", anode_name);
7690

7791
jmap = WireCell::Persist::load(filename);
7892

93+
yzmap.resize(n_zbin);
94+
for(int binz = 0; binz < n_zbin; binz++){
95+
yzmap[binz].resize(n_ybin);
96+
for(int biny = 0; biny < n_ybin; biny++){
97+
yzmap[binz][biny] = jmap[anode_name][std::to_string(plane)][binz][biny].asDouble();
98+
}
99+
}
100+
101+
jmap.clear();
102+
103+
79104
}
80105

81106
void Gen::Scaler::reset() { }
@@ -100,10 +125,8 @@ bool Gen::Scaler::operator()(const input_pointer& depo, output_queue& outq)
100125
}
101126
}
102127

103-
double depo_y = depo->pos().y()*units::mm;
104-
double depo_z = depo->pos().z()*units::mm;
105-
double yoffset = 180*units::cm;
106-
double zoffset = 900*units::cm;
128+
double depo_y = depo->pos().y();
129+
double depo_z = depo->pos().z();
107130

108131
int depo_bin_y = std::floor((depo_y+yoffset)/bin_height);
109132
int depo_bin_z = std::floor((depo_z+zoffset)/bin_width);
@@ -116,18 +139,17 @@ bool Gen::Scaler::operator()(const input_pointer& depo, output_queue& outq)
116139
depo_bin_z = 0;
117140
}
118141

119-
if(depo_bin_y > 31){
120-
depo_bin_y = 31;
142+
if(depo_bin_y > n_ybin){
143+
depo_bin_y = n_ybin;
121144
}
122145

123-
if(depo_bin_z > 180){
124-
depo_bin_z = 180;
146+
if(depo_bin_z > n_zbin){
147+
depo_bin_z = n_zbin;
125148
}
126149

127-
// double scale = (jmap[anode_name][std::to_string(plane)][depo_bin_y][depo_bin_z].asDouble());
128-
double scale = (jmap[anode_name][std::to_string(plane)][depo_bin_z][depo_bin_y].asDouble());
150+
double scale = yzmap[depo_bin_z][depo_bin_y];
129151

130-
auto newdepo = make_shared<Aux::SimpleDepo>(depo->time(), depo->pos(), Qi*scale, depo, depo->extent_long(), depo->extent_tran());
152+
auto newdepo = make_shared<Aux::SimpleDepo>(depo->time(), depo->pos(), Qi*scale, depo->prior(), depo->extent_long(), depo->extent_tran(), depo->prior()->id(), depo->prior()->pdg(), depo->prior()->energy());
131153

132154
outq.push_back(newdepo);
133155

0 commit comments

Comments
 (0)