40 if (pset.
has_key(
"EnableSimulationSCE")) {
42 <<
"Configuration parameter 'EnableSimulationSCE' has been replaced by 'EnableSimSpatialSCE'.\n";
51 cet::search_path sp(
"FW_SEARCH_PATH");
52 sp.find_file(fInputFilename,fname);
54 std::unique_ptr<TFile> infile(
new TFile(fname.c_str(),
"READ"));
59 for(
int i = 0; i < 5; i++)
61 g1_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g1_%d",i));
62 g2_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g2_%d",i));
63 g3_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g3_%d",i));
64 g4_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g4_%d",i));
65 g5_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g5_%d",i));
67 g1_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g1_%d",i));
68 g2_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g2_%d",i));
69 g3_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g3_%d",i));
70 g4_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g4_%d",i));
71 g5_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g5_%d",i));
72 g6_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g6_%d",i));
74 g1_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g1_%d",i));
75 g2_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g2_%d",i));
76 g3_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g3_%d",i));
77 g4_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g4_%d",i));
79 g1_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g1_%d",i));
80 g2_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g2_%d",i));
81 g3_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g3_%d",i));
82 g4_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g4_%d",i));
83 g5_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g5_%d",i));
85 g1_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g1_%d",i));
86 g2_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g2_%d",i));
87 g3_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g3_%d",i));
88 g4_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g4_%d",i));
89 g5_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g5_%d",i));
90 g6_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g6_%d",i));
92 g1_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g1_%d",i));
93 g2_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g2_%d",i));
94 g3_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g3_%d",i));
95 g4_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g4_%d",i));
98 g1_x[5] = (TGraph*)infile->Get(
"deltaX/g1_5");
99 g2_x[5] = (TGraph*)infile->Get(
"deltaX/g2_5");
100 g3_x[5] = (TGraph*)infile->Get(
"deltaX/g3_5");
101 g4_x[5] = (TGraph*)infile->Get(
"deltaX/g4_5");
102 g5_x[5] = (TGraph*)infile->Get(
"deltaX/g5_5");
104 g1_y[5] = (TGraph*)infile->Get(
"deltaY/g1_5");
105 g2_y[5] = (TGraph*)infile->Get(
"deltaY/g2_5");
106 g3_y[5] = (TGraph*)infile->Get(
"deltaY/g3_5");
107 g4_y[5] = (TGraph*)infile->Get(
"deltaY/g4_5");
108 g5_y[5] = (TGraph*)infile->Get(
"deltaY/g5_5");
109 g6_y[5] = (TGraph*)infile->Get(
"deltaY/g6_5");
111 g1_x[6] = (TGraph*)infile->Get(
"deltaX/g1_6");
112 g2_x[6] = (TGraph*)infile->Get(
"deltaX/g2_6");
113 g3_x[6] = (TGraph*)infile->Get(
"deltaX/g3_6");
114 g4_x[6] = (TGraph*)infile->Get(
"deltaX/g4_6");
115 g5_x[6] = (TGraph*)infile->Get(
"deltaX/g5_6");
117 g1_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g1_5");
118 g2_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g2_5");
119 g3_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g3_5");
120 g4_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g4_5");
121 g5_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g5_5");
123 g1_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g1_5");
124 g2_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g2_5");
125 g3_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g3_5");
126 g4_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g4_5");
127 g5_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g5_5");
128 g6_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g6_5");
130 g1_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g1_6");
131 g2_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g2_6");
132 g3_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g3_6");
133 g4_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g4_6");
134 g5_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g5_6");
140 if(fEnableCorrSCE ==
true)
151 if (ts == 0)
return false;
184 std::vector<double> thePosOffsets;
188 thePosOffsets.resize(3,0.0);
195 thePosOffsets.resize(3,0.0);
198 return { thePosOffsets[0], thePosOffsets[1], thePosOffsets[2] };
205 std::vector<double> thePosOffsetsParametric;
215 return thePosOffsetsParametric;
226 for(
int j = 0; j < 6; j++)
228 for(
int i = 0; i < 7; i++)
236 for(
int j = 0; j < 7; j++)
238 parA[0][j] =
g1_x[j]->Eval(zValNew);
239 parA[1][j] =
g2_x[j]->Eval(zValNew);
240 parA[2][j] =
g3_x[j]->Eval(zValNew);
241 parA[3][j] =
g4_x[j]->Eval(zValNew);
242 parA[4][j] =
g5_x[j]->Eval(zValNew);
245 f1_x->SetParameters(parA[0]);
246 f2_x->SetParameters(parA[1]);
247 f3_x->SetParameters(parA[2]);
248 f4_x->SetParameters(parA[3]);
249 f5_x->SetParameters(parA[4]);
253 for(
int j = 0; j < 6; j++)
255 parA[0][j] =
g1_y[j]->Eval(zValNew);
256 parA[1][j] =
g2_y[j]->Eval(zValNew);
257 parA[2][j] =
g3_y[j]->Eval(zValNew);
258 parA[3][j] =
g4_y[j]->Eval(zValNew);
259 parA[4][j] =
g5_y[j]->Eval(zValNew);
260 parA[5][j] =
g6_y[j]->Eval(zValNew);
263 f1_y->SetParameters(parA[0]);
264 f2_y->SetParameters(parA[1]);
265 f3_y->SetParameters(parA[2]);
266 f4_y->SetParameters(parA[3]);
267 f5_y->SetParameters(parA[4]);
268 f6_y->SetParameters(parA[5]);
272 for(
int j = 0; j < 5; j++)
274 parA[0][j] =
g1_z[j]->Eval(zValNew);
275 parA[1][j] =
g2_z[j]->Eval(zValNew);
276 parA[2][j] =
g3_z[j]->Eval(zValNew);
277 parA[3][j] =
g4_z[j]->Eval(zValNew);
280 f1_z->SetParameters(parA[0]);
281 f2_z->SetParameters(parA[1]);
282 f3_z->SetParameters(parA[2]);
283 f4_z->SetParameters(parA[3]);
300 double offsetValNew = 0.0;
303 parB[0] =
f1_x->Eval(aValNew);
304 parB[1] =
f2_x->Eval(aValNew);
305 parB[2] =
f3_x->Eval(aValNew);
306 parB[3] =
f4_x->Eval(aValNew);
307 parB[4] =
f5_x->Eval(aValNew);
310 offsetValNew = 100.0*
fFinal_x->Eval(bValNew);
314 parB[0] =
f1_y->Eval(aValNew);
315 parB[1] =
f2_y->Eval(aValNew);
316 parB[2] =
f3_y->Eval(aValNew);
317 parB[3] =
f4_y->Eval(aValNew);
318 parB[4] =
f5_y->Eval(aValNew);
319 parB[5] =
f6_y->Eval(aValNew);
322 offsetValNew = 100.0*
fFinal_y->Eval(bValNew);
326 parB[0] =
f1_z->Eval(aValNew);
327 parB[1] =
f2_z->Eval(aValNew);
328 parB[2] =
f3_z->Eval(aValNew);
329 parB[3] =
f4_z->Eval(aValNew);
332 offsetValNew = 100.0*
fFinal_z->Eval(bValNew);
343 std::vector<double> theEfieldOffsets;
348 theEfieldOffsets.resize(3,0.0);
350 return { -theEfieldOffsets[0], -theEfieldOffsets[1], -theEfieldOffsets[2] };
357 std::vector<double> theEfieldOffsetsParametric;
367 return theEfieldOffsetsParametric;
378 for(
int j = 0; j < 6; j++)
380 for(
int i = 0; i < 7; i++)
388 for(
int j = 0; j < 7; j++)
390 parA[0][j] =
g1_Ex[j]->Eval(zValNew);
391 parA[1][j] =
g2_Ex[j]->Eval(zValNew);
392 parA[2][j] =
g3_Ex[j]->Eval(zValNew);
393 parA[3][j] =
g4_Ex[j]->Eval(zValNew);
394 parA[4][j] =
g5_Ex[j]->Eval(zValNew);
397 f1_Ex->SetParameters(parA[0]);
398 f2_Ex->SetParameters(parA[1]);
399 f3_Ex->SetParameters(parA[2]);
400 f4_Ex->SetParameters(parA[3]);
401 f5_Ex->SetParameters(parA[4]);
405 for(
int j = 0; j < 6; j++)
407 parA[0][j] =
g1_Ey[j]->Eval(zValNew);
408 parA[1][j] =
g2_Ey[j]->Eval(zValNew);
409 parA[2][j] =
g3_Ey[j]->Eval(zValNew);
410 parA[3][j] =
g4_Ey[j]->Eval(zValNew);
411 parA[4][j] =
g5_Ey[j]->Eval(zValNew);
412 parA[5][j] =
g6_Ey[j]->Eval(zValNew);
415 f1_Ey->SetParameters(parA[0]);
416 f2_Ey->SetParameters(parA[1]);
417 f3_Ey->SetParameters(parA[2]);
418 f4_Ey->SetParameters(parA[3]);
419 f5_Ey->SetParameters(parA[4]);
420 f6_Ey->SetParameters(parA[5]);
424 for(
int j = 0; j < 5; j++)
426 parA[0][j] =
g1_Ez[j]->Eval(zValNew);
427 parA[1][j] =
g2_Ez[j]->Eval(zValNew);
428 parA[2][j] =
g3_Ez[j]->Eval(zValNew);
429 parA[3][j] =
g4_Ez[j]->Eval(zValNew);
432 f1_Ez->SetParameters(parA[0]);
433 f2_Ez->SetParameters(parA[1]);
434 f3_Ez->SetParameters(parA[2]);
435 f4_Ez->SetParameters(parA[3]);
452 double offsetValNew = 0.0;
455 parB[0] =
f1_Ex->Eval(aValNew);
456 parB[1] =
f2_Ex->Eval(aValNew);
457 parB[2] =
f3_Ex->Eval(aValNew);
458 parB[3] =
f4_Ex->Eval(aValNew);
459 parB[4] =
f5_Ex->Eval(aValNew);
466 parB[0] =
f1_Ey->Eval(aValNew);
467 parB[1] =
f2_Ey->Eval(aValNew);
468 parB[2] =
f3_Ey->Eval(aValNew);
469 parB[3] =
f4_Ey->Eval(aValNew);
470 parB[4] =
f5_Ey->Eval(aValNew);
471 parB[5] =
f6_Ey->Eval(aValNew);
478 parB[0] =
f1_Ez->Eval(aValNew);
479 parB[1] =
f2_Ez->Eval(aValNew);
480 parB[2] =
f3_Ez->Eval(aValNew);
481 parB[3] =
f4_Ez->Eval(aValNew);
495 xValNew = xVal/100.0;
505 yValNew = yVal/100.0;
515 zValNew = zVal/100.0;
524 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...
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
std::string fInputFilename
std::vector< double > GetEfieldOffsetsParametric(double xVal, double yVal, double zVal) const
Provides E field offsets using a parametric representation.
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! ...
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)
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
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.
std::string fRepresentationType
bool EnableSimEfieldSCE() const override
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
bool Configure(fhicl::ParameterSet const &pset)
double GetOneEfieldOffsetParametric(double xVal, double yVal, double zVal, std::string axis) const