41 if (pset.
has_key(
"EnableSimulationSCE")) {
43 <<
"Configuration parameter 'EnableSimulationSCE' has been replaced by " 44 "'EnableSimSpatialSCE'.\n";
52 cet::search_path sp(
"FW_SEARCH_PATH");
53 sp.find_file(fInputFilename, fname);
55 auto infile = std::make_unique<TFile>(fname.c_str(),
"READ");
56 if (!infile->IsOpen())
58 <<
"Could not find the space charge effect file '" << fname <<
"'!\n";
61 for (
int i = 0; i < 5; i++) {
62 g1_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g1_%d", i));
63 g2_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g2_%d", i));
64 g3_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g3_%d", i));
65 g4_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g4_%d", i));
66 g5_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g5_%d", i));
68 g1_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g1_%d", i));
69 g2_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g2_%d", i));
70 g3_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g3_%d", i));
71 g4_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g4_%d", i));
72 g5_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g5_%d", i));
73 g6_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g6_%d", i));
75 g1_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g1_%d", i));
76 g2_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g2_%d", i));
77 g3_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g3_%d", i));
78 g4_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g4_%d", i));
80 g1_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g1_%d", i));
81 g2_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g2_%d", i));
82 g3_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g3_%d", i));
83 g4_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g4_%d", i));
84 g5_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g5_%d", i));
86 g1_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g1_%d", i));
87 g2_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g2_%d", i));
88 g3_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g3_%d", i));
89 g4_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g4_%d", i));
90 g5_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g5_%d", i));
91 g6_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g6_%d", i));
93 g1_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g1_%d", i));
94 g2_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g2_%d", i));
95 g3_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g3_%d", i));
96 g4_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g4_%d", i));
99 g1_x[5] = (TGraph*)infile->Get(
"deltaX/g1_5");
100 g2_x[5] = (TGraph*)infile->Get(
"deltaX/g2_5");
101 g3_x[5] = (TGraph*)infile->Get(
"deltaX/g3_5");
102 g4_x[5] = (TGraph*)infile->Get(
"deltaX/g4_5");
103 g5_x[5] = (TGraph*)infile->Get(
"deltaX/g5_5");
105 g1_y[5] = (TGraph*)infile->Get(
"deltaY/g1_5");
106 g2_y[5] = (TGraph*)infile->Get(
"deltaY/g2_5");
107 g3_y[5] = (TGraph*)infile->Get(
"deltaY/g3_5");
108 g4_y[5] = (TGraph*)infile->Get(
"deltaY/g4_5");
109 g5_y[5] = (TGraph*)infile->Get(
"deltaY/g5_5");
110 g6_y[5] = (TGraph*)infile->Get(
"deltaY/g6_5");
112 g1_x[6] = (TGraph*)infile->Get(
"deltaX/g1_6");
113 g2_x[6] = (TGraph*)infile->Get(
"deltaX/g2_6");
114 g3_x[6] = (TGraph*)infile->Get(
"deltaX/g3_6");
115 g4_x[6] = (TGraph*)infile->Get(
"deltaX/g4_6");
116 g5_x[6] = (TGraph*)infile->Get(
"deltaX/g5_6");
118 g1_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g1_5");
119 g2_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g2_5");
120 g3_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g3_5");
121 g4_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g4_5");
122 g5_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g5_5");
124 g1_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g1_5");
125 g2_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g2_5");
126 g3_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g3_5");
127 g4_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g4_5");
128 g5_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g5_5");
129 g6_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g6_5");
131 g1_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g1_6");
132 g2_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g2_6");
133 g3_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g3_6");
134 g4_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g4_6");
135 g5_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g5_6");
141 if (fEnableCorrSCE ==
true) {
151 if (ts == 0)
return false;
196 std::vector<double> thePosOffsets;
199 thePosOffsets.resize(3, 0.0);
205 thePosOffsets.resize(3, 0.0);
208 return {thePosOffsets[0], thePosOffsets[1], thePosOffsets[2]};
212 int const& TPCid)
const 224 std::vector<double> thePosOffsetsParametric;
234 return thePosOffsetsParametric;
243 std::string axis)
const 248 for (
int j = 0; j < 6; j++) {
249 for (
int i = 0; i < 7; i++)
256 for (
int j = 0; j < 7; j++) {
257 parA[0][j] =
g1_x[j]->Eval(zValNew);
258 parA[1][j] =
g2_x[j]->Eval(zValNew);
259 parA[2][j] =
g3_x[j]->Eval(zValNew);
260 parA[3][j] =
g4_x[j]->Eval(zValNew);
261 parA[4][j] =
g5_x[j]->Eval(zValNew);
264 f1_x->SetParameters(parA[0]);
265 f2_x->SetParameters(parA[1]);
266 f3_x->SetParameters(parA[2]);
267 f4_x->SetParameters(parA[3]);
268 f5_x->SetParameters(parA[4]);
270 else if (axis ==
"Y") {
271 for (
int j = 0; j < 6; j++) {
272 parA[0][j] =
g1_y[j]->Eval(zValNew);
273 parA[1][j] =
g2_y[j]->Eval(zValNew);
274 parA[2][j] =
g3_y[j]->Eval(zValNew);
275 parA[3][j] =
g4_y[j]->Eval(zValNew);
276 parA[4][j] =
g5_y[j]->Eval(zValNew);
277 parA[5][j] =
g6_y[j]->Eval(zValNew);
280 f1_y->SetParameters(parA[0]);
281 f2_y->SetParameters(parA[1]);
282 f3_y->SetParameters(parA[2]);
283 f4_y->SetParameters(parA[3]);
284 f5_y->SetParameters(parA[4]);
285 f6_y->SetParameters(parA[5]);
287 else if (axis ==
"Z") {
288 for (
int j = 0; j < 5; j++) {
289 parA[0][j] =
g1_z[j]->Eval(zValNew);
290 parA[1][j] =
g2_z[j]->Eval(zValNew);
291 parA[2][j] =
g3_z[j]->Eval(zValNew);
292 parA[3][j] =
g4_z[j]->Eval(zValNew);
295 f1_z->SetParameters(parA[0]);
296 f2_z->SetParameters(parA[1]);
297 f3_z->SetParameters(parA[2]);
298 f4_z->SetParameters(parA[3]);
313 double offsetValNew = 0.0;
315 parB[0] =
f1_x->Eval(aValNew);
316 parB[1] =
f2_x->Eval(aValNew);
317 parB[2] =
f3_x->Eval(aValNew);
318 parB[3] =
f4_x->Eval(aValNew);
319 parB[4] =
f5_x->Eval(aValNew);
322 offsetValNew = 100.0 *
fFinal_x->Eval(bValNew);
324 else if (axis ==
"Y") {
325 parB[0] =
f1_y->Eval(aValNew);
326 parB[1] =
f2_y->Eval(aValNew);
327 parB[2] =
f3_y->Eval(aValNew);
328 parB[3] =
f4_y->Eval(aValNew);
329 parB[4] =
f5_y->Eval(aValNew);
330 parB[5] =
f6_y->Eval(aValNew);
333 offsetValNew = 100.0 *
fFinal_y->Eval(bValNew);
335 else if (axis ==
"Z") {
336 parB[0] =
f1_z->Eval(aValNew);
337 parB[1] =
f2_z->Eval(aValNew);
338 parB[2] =
f3_z->Eval(aValNew);
339 parB[3] =
f4_z->Eval(aValNew);
342 offsetValNew = 100.0 *
fFinal_z->Eval(bValNew);
353 std::vector<double> theEfieldOffsets;
358 theEfieldOffsets.resize(3, 0.0);
360 return {-theEfieldOffsets[0], -theEfieldOffsets[1], -theEfieldOffsets[2]};
364 int const& TPCid)
const 376 std::vector<double> theEfieldOffsetsParametric;
382 theEfieldOffsetsParametric.push_back(
384 theEfieldOffsetsParametric.push_back(
386 theEfieldOffsetsParametric.push_back(
389 return theEfieldOffsetsParametric;
398 std::string axis)
const 403 for (
int j = 0; j < 6; j++) {
404 for (
int i = 0; i < 7; i++)
411 for (
int j = 0; j < 7; j++) {
412 parA[0][j] =
g1_Ex[j]->Eval(zValNew);
413 parA[1][j] =
g2_Ex[j]->Eval(zValNew);
414 parA[2][j] =
g3_Ex[j]->Eval(zValNew);
415 parA[3][j] =
g4_Ex[j]->Eval(zValNew);
416 parA[4][j] =
g5_Ex[j]->Eval(zValNew);
419 f1_Ex->SetParameters(parA[0]);
420 f2_Ex->SetParameters(parA[1]);
421 f3_Ex->SetParameters(parA[2]);
422 f4_Ex->SetParameters(parA[3]);
423 f5_Ex->SetParameters(parA[4]);
425 else if (axis ==
"Y") {
426 for (
int j = 0; j < 6; j++) {
427 parA[0][j] =
g1_Ey[j]->Eval(zValNew);
428 parA[1][j] =
g2_Ey[j]->Eval(zValNew);
429 parA[2][j] =
g3_Ey[j]->Eval(zValNew);
430 parA[3][j] =
g4_Ey[j]->Eval(zValNew);
431 parA[4][j] =
g5_Ey[j]->Eval(zValNew);
432 parA[5][j] =
g6_Ey[j]->Eval(zValNew);
435 f1_Ey->SetParameters(parA[0]);
436 f2_Ey->SetParameters(parA[1]);
437 f3_Ey->SetParameters(parA[2]);
438 f4_Ey->SetParameters(parA[3]);
439 f5_Ey->SetParameters(parA[4]);
440 f6_Ey->SetParameters(parA[5]);
442 else if (axis ==
"Z") {
443 for (
int j = 0; j < 5; j++) {
444 parA[0][j] =
g1_Ez[j]->Eval(zValNew);
445 parA[1][j] =
g2_Ez[j]->Eval(zValNew);
446 parA[2][j] =
g3_Ez[j]->Eval(zValNew);
447 parA[3][j] =
g4_Ez[j]->Eval(zValNew);
450 f1_Ez->SetParameters(parA[0]);
451 f2_Ez->SetParameters(parA[1]);
452 f3_Ez->SetParameters(parA[2]);
453 f4_Ez->SetParameters(parA[3]);
468 double offsetValNew = 0.0;
470 parB[0] =
f1_Ex->Eval(aValNew);
471 parB[1] =
f2_Ex->Eval(aValNew);
472 parB[2] =
f3_Ex->Eval(aValNew);
473 parB[3] =
f4_Ex->Eval(aValNew);
474 parB[4] =
f5_Ex->Eval(aValNew);
479 else if (axis ==
"Y") {
480 parB[0] =
f1_Ey->Eval(aValNew);
481 parB[1] =
f2_Ey->Eval(aValNew);
482 parB[2] =
f3_Ey->Eval(aValNew);
483 parB[3] =
f4_Ey->Eval(aValNew);
484 parB[4] =
f5_Ey->Eval(aValNew);
485 parB[5] =
f6_Ey->Eval(aValNew);
490 else if (axis ==
"Z") {
491 parB[0] =
f1_Ez->Eval(aValNew);
492 parB[1] =
f2_Ez->Eval(aValNew);
493 parB[2] =
f3_Ez->Eval(aValNew);
494 parB[3] =
f4_Ez->Eval(aValNew);
508 xValNew = xVal / 100.0;
518 yValNew = yVal / 100.0;
528 zValNew = zVal / 100.0;
539 bool isInside =
false;
bool IsInsideBoundaries(double xVal, double yVal, double zVal) const
Check to see if point is inside boundaries of map - redefine this in experiment-specific implementati...
std::string fInputFilename
std::vector< double > GetEfieldOffsetsParametric(double xVal, double yVal, double zVal) const
Provides E field offsets using a parametric representation.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
geo::Vector_t GetCalEfieldOffsets(geo::Point_t const &point, int const &TPCid) const override
double GetOnePosOffsetParametric(double xVal, double yVal, double zVal, std::string axis) const
std::vector< double > GetPosOffsetsParametric(double xVal, double yVal, double zVal) const
Provides position offsets using a parametric representation.
double TransformY(double yVal) const
Transform Y to SCE Y coordinate - redefine this in experiment-specific implementation! ...
bool EnableCalSpatialSCE() const override
Return boolean indicating whether or not to apply SCE corrections.
SpaceChargeStandard(fhicl::ParameterSet const &pset)
double TransformX(double xVal) const
Transform X to SCE X coordinate - redefine this in experiment-specific implementation! ...
geo::Vector_t GetEfieldOffsets(geo::Point_t const &point) const override
T get(std::string const &key) const
bool Update(uint64_t ts=0)
bool fEnableCalSpatialSCE
double TransformZ(double zVal) const
Transform Z to SCE Z coordinate - redefine this in experiment-specific implementation! ...
bool fEnableSimSpatialSCE
bool has_key(std::string const &key) const
bool EnableSimSpatialSCE() const override
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
geo::Vector_t GetPosOffsets(geo::Point_t const &point) const override
bool EnableCorrSCE() const override
Return boolean indicating whether or not to apply SCE corrections.
bool EnableCalEfieldSCE() const override
Return boolean indicating whether or not to apply SCE corrections.
std::string fRepresentationType
bool EnableSimEfieldSCE() const override
geo::Vector_t GetCalPosOffsets(geo::Point_t const &point, int const &TPCid) const override
bool Configure(fhicl::ParameterSet const &pset)
double GetOneEfieldOffsetParametric(double xVal, double yVal, double zVal, std::string axis) const