22 #include "cetlib_except/exception.h" 50 std::unique_ptr<TFile>
infile(
new TFile(fname.c_str(),
"READ"));
51 if(!infile->IsOpen())
throw cet::exception(
"SpaceChargeDUNE35t") <<
"Could not find the space charge effect file '" << fname <<
"'!\n";
55 for(
int i = 0; i < 5; i++)
57 g1_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g1_%d",i));
58 g2_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g2_%d",i));
59 g3_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g3_%d",i));
60 g4_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g4_%d",i));
61 g5_x[i] = (TGraph*)infile->Get(Form(
"deltaX/g5_%d",i));
63 g1_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g1_%d",i));
64 g2_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g2_%d",i));
65 g3_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g3_%d",i));
66 g4_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g4_%d",i));
67 g5_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g5_%d",i));
68 g6_y[i] = (TGraph*)infile->Get(Form(
"deltaY/g6_%d",i));
70 g1_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g1_%d",i));
71 g2_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g2_%d",i));
72 g3_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g3_%d",i));
73 g4_z[i] = (TGraph*)infile->Get(Form(
"deltaZ/g4_%d",i));
75 g1_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g1_%d",i));
76 g2_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g2_%d",i));
77 g3_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g3_%d",i));
78 g4_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g4_%d",i));
79 g5_Ex[i] = (TGraph*)infile->Get(Form(
"deltaExOverE/g5_%d",i));
81 g1_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g1_%d",i));
82 g2_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g2_%d",i));
83 g3_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g3_%d",i));
84 g4_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g4_%d",i));
85 g5_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g5_%d",i));
86 g6_Ey[i] = (TGraph*)infile->Get(Form(
"deltaEyOverE/g6_%d",i));
88 g1_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g1_%d",i));
89 g2_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g2_%d",i));
90 g3_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g3_%d",i));
91 g4_Ez[i] = (TGraph*)infile->Get(Form(
"deltaEzOverE/g4_%d",i));
94 g1_x[5] = (TGraph*)infile->Get(
"deltaX/g1_5");
95 g2_x[5] = (TGraph*)infile->Get(
"deltaX/g2_5");
96 g3_x[5] = (TGraph*)infile->Get(
"deltaX/g3_5");
97 g4_x[5] = (TGraph*)infile->Get(
"deltaX/g4_5");
98 g5_x[5] = (TGraph*)infile->Get(
"deltaX/g5_5");
100 g1_y[5] = (TGraph*)infile->Get(
"deltaY/g1_5");
101 g2_y[5] = (TGraph*)infile->Get(
"deltaY/g2_5");
102 g3_y[5] = (TGraph*)infile->Get(
"deltaY/g3_5");
103 g4_y[5] = (TGraph*)infile->Get(
"deltaY/g4_5");
104 g5_y[5] = (TGraph*)infile->Get(
"deltaY/g5_5");
105 g6_y[5] = (TGraph*)infile->Get(
"deltaY/g6_5");
107 g1_x[6] = (TGraph*)infile->Get(
"deltaX/g1_6");
108 g2_x[6] = (TGraph*)infile->Get(
"deltaX/g2_6");
109 g3_x[6] = (TGraph*)infile->Get(
"deltaX/g3_6");
110 g4_x[6] = (TGraph*)infile->Get(
"deltaX/g4_6");
111 g5_x[6] = (TGraph*)infile->Get(
"deltaX/g5_6");
113 g1_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g1_5");
114 g2_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g2_5");
115 g3_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g3_5");
116 g4_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g4_5");
117 g5_Ex[5] = (TGraph*)infile->Get(
"deltaExOverE/g5_5");
119 g1_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g1_5");
120 g2_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g2_5");
121 g3_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g3_5");
122 g4_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g4_5");
123 g5_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g5_5");
124 g6_Ey[5] = (TGraph*)infile->Get(
"deltaEyOverE/g6_5");
126 g1_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g1_6");
127 g2_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g2_6");
128 g3_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g3_6");
129 g4_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g4_6");
130 g5_Ex[6] = (TGraph*)infile->Get(
"deltaExOverE/g5_6");
147 if (ts == 0)
return false;
192 std::vector<double> thePosOffsets;
196 thePosOffsets.resize(3,0.0);
203 thePosOffsets.resize(3,0.0);
206 return { thePosOffsets[0], thePosOffsets[1], thePosOffsets[2] };
212 return { 0.0, 0.0, 0.0 };
219 std::vector<double> thePosOffsetsParametric;
229 return thePosOffsetsParametric;
240 for(
int j = 0; j < 6; j++)
242 for(
int i = 0; i < 7; i++)
250 for(
int j = 0; j < 7; j++)
252 parA[0][j] =
g1_x[j]->Eval(zValNew);
253 parA[1][j] =
g2_x[j]->Eval(zValNew);
254 parA[2][j] =
g3_x[j]->Eval(zValNew);
255 parA[3][j] =
g4_x[j]->Eval(zValNew);
256 parA[4][j] =
g5_x[j]->Eval(zValNew);
259 f1_x->SetParameters(parA[0]);
260 f2_x->SetParameters(parA[1]);
261 f3_x->SetParameters(parA[2]);
262 f4_x->SetParameters(parA[3]);
263 f5_x->SetParameters(parA[4]);
267 for(
int j = 0; j < 6; j++)
269 parA[0][j] =
g1_y[j]->Eval(zValNew);
270 parA[1][j] =
g2_y[j]->Eval(zValNew);
271 parA[2][j] =
g3_y[j]->Eval(zValNew);
272 parA[3][j] =
g4_y[j]->Eval(zValNew);
273 parA[4][j] =
g5_y[j]->Eval(zValNew);
274 parA[5][j] =
g6_y[j]->Eval(zValNew);
277 f1_y->SetParameters(parA[0]);
278 f2_y->SetParameters(parA[1]);
279 f3_y->SetParameters(parA[2]);
280 f4_y->SetParameters(parA[3]);
281 f5_y->SetParameters(parA[4]);
282 f6_y->SetParameters(parA[5]);
286 for(
int j = 0; j < 5; j++)
288 parA[0][j] =
g1_z[j]->Eval(zValNew);
289 parA[1][j] =
g2_z[j]->Eval(zValNew);
290 parA[2][j] =
g3_z[j]->Eval(zValNew);
291 parA[3][j] =
g4_z[j]->Eval(zValNew);
294 f1_z->SetParameters(parA[0]);
295 f2_z->SetParameters(parA[1]);
296 f3_z->SetParameters(parA[2]);
297 f4_z->SetParameters(parA[3]);
314 double offsetValNew = 0.0;
317 parB[0] =
f1_x->Eval(aValNew);
318 parB[1] =
f2_x->Eval(aValNew);
319 parB[2] =
f3_x->Eval(aValNew);
320 parB[3] =
f4_x->Eval(aValNew);
321 parB[4] =
f5_x->Eval(aValNew);
324 offsetValNew = 100.0*
fFinal_x->Eval(bValNew);
328 parB[0] =
f1_y->Eval(aValNew);
329 parB[1] =
f2_y->Eval(aValNew);
330 parB[2] =
f3_y->Eval(aValNew);
331 parB[3] =
f4_y->Eval(aValNew);
332 parB[4] =
f5_y->Eval(aValNew);
333 parB[5] =
f6_y->Eval(aValNew);
336 offsetValNew = 100.0*
fFinal_y->Eval(bValNew);
340 parB[0] =
f1_z->Eval(aValNew);
341 parB[1] =
f2_z->Eval(aValNew);
342 parB[2] =
f3_z->Eval(aValNew);
343 parB[3] =
f4_z->Eval(aValNew);
346 offsetValNew = 100.0*
fFinal_z->Eval(bValNew);
357 std::vector<double> theEfieldOffsets;
361 theEfieldOffsets.resize(3,0.0);
368 theEfieldOffsets.resize(3,0.0);
371 return { theEfieldOffsets[0], theEfieldOffsets[1], theEfieldOffsets[2] };
376 return { 0.0, 0.0, 0.0 };
383 std::vector<double> theEfieldOffsetsParametric;
393 return theEfieldOffsetsParametric;
404 for(
int j = 0; j < 6; j++)
406 for(
int i = 0; i < 7; i++)
414 for(
int j = 0; j < 7; j++)
416 parA[0][j] =
g1_Ex[j]->Eval(zValNew);
417 parA[1][j] =
g2_Ex[j]->Eval(zValNew);
418 parA[2][j] =
g3_Ex[j]->Eval(zValNew);
419 parA[3][j] =
g4_Ex[j]->Eval(zValNew);
420 parA[4][j] =
g5_Ex[j]->Eval(zValNew);
423 f1_Ex->SetParameters(parA[0]);
424 f2_Ex->SetParameters(parA[1]);
425 f3_Ex->SetParameters(parA[2]);
426 f4_Ex->SetParameters(parA[3]);
427 f5_Ex->SetParameters(parA[4]);
431 for(
int j = 0; j < 6; j++)
433 parA[0][j] =
g1_Ey[j]->Eval(zValNew);
434 parA[1][j] =
g2_Ey[j]->Eval(zValNew);
435 parA[2][j] =
g3_Ey[j]->Eval(zValNew);
436 parA[3][j] =
g4_Ey[j]->Eval(zValNew);
437 parA[4][j] =
g5_Ey[j]->Eval(zValNew);
438 parA[5][j] =
g6_Ey[j]->Eval(zValNew);
441 f1_Ey->SetParameters(parA[0]);
442 f2_Ey->SetParameters(parA[1]);
443 f3_Ey->SetParameters(parA[2]);
444 f4_Ey->SetParameters(parA[3]);
445 f5_Ey->SetParameters(parA[4]);
446 f6_Ey->SetParameters(parA[5]);
450 for(
int j = 0; j < 5; j++)
452 parA[0][j] =
g1_Ez[j]->Eval(zValNew);
453 parA[1][j] =
g2_Ez[j]->Eval(zValNew);
454 parA[2][j] =
g3_Ez[j]->Eval(zValNew);
455 parA[3][j] =
g4_Ez[j]->Eval(zValNew);
458 f1_Ez->SetParameters(parA[0]);
459 f2_Ez->SetParameters(parA[1]);
460 f3_Ez->SetParameters(parA[2]);
461 f4_Ez->SetParameters(parA[3]);
478 double offsetValNew = 0.0;
481 parB[0] =
f1_Ex->Eval(aValNew);
482 parB[1] =
f2_Ex->Eval(aValNew);
483 parB[2] =
f3_Ex->Eval(aValNew);
484 parB[3] =
f4_Ex->Eval(aValNew);
485 parB[4] =
f5_Ex->Eval(aValNew);
492 parB[0] =
f1_Ey->Eval(aValNew);
493 parB[1] =
f2_Ey->Eval(aValNew);
494 parB[2] =
f3_Ey->Eval(aValNew);
495 parB[3] =
f4_Ey->Eval(aValNew);
496 parB[4] =
f5_Ey->Eval(aValNew);
497 parB[5] =
f6_Ey->Eval(aValNew);
504 parB[0] =
f1_Ez->Eval(aValNew);
505 parB[1] =
f2_Ez->Eval(aValNew);
506 parB[2] =
f3_Ez->Eval(aValNew);
507 parB[3] =
f4_Ez->Eval(aValNew);
521 xValNew = 2.25 - (2.25/2.25)*((xVal-2.5)/100.0);
532 yValNew = (2.0/2.0)*(yVal/100.0);
543 zValNew = (1.6/1.6)*(zVal/100.0);
552 bool isInside =
true;
554 if((xVal < 2.5) || (xVal > 230.0) || (yVal < -5.0) || (yVal > 205.0) || (zVal < -5.0) || (zVal > 165.0))
double TransformX(double xVal) const
Transform X to SCE X coordinate: [2.275,-0.3] –> [0.0,2.25].
double TransformY(double yVal) const
Transform Y to SCE Y coordinate: [0.0,2.0] –> [0.0,2.0].
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
bool fEnableSimSpatialSCE
bool EnableSimEfieldSCE() const override
std::vector< double > GetPosOffsetsParametric(double xVal, double yVal, double zVal) const
Provides position offsets using a parametric representation.
bool Configure(fhicl::ParameterSet const &pset)
geo::Vector_t GetEfieldOffsets(geo::Point_t const &point) const override
bool fEnableCalSpatialSCE
bool EnableSimSpatialSCE() const override
double GetOnePosOffsetParametric(double xVal, double yVal, double zVal, std::string axis) const
SpaceChargeDUNE35t(fhicl::ParameterSet const &pset)
T get(std::string const &key) const
std::vector< double > GetEfieldOffsetsParametric(double xVal, double yVal, double zVal) const
Provides E field offsets using a parametric representation.
geo::Vector_t GetPosOffsets(geo::Point_t const &point) const override
std::string fRepresentationType
bool EnableCalSpatialSCE() const override
Return boolean indicating whether or not to apply SCE corrections.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
std::string fInputFilename
double GetOneEfieldOffsetParametric(double xVal, double yVal, double zVal, std::string axis) const
std::string find_file(std::string const &filename) const
geo::Vector_t GetCalPosOffsets(geo::Point_t const &point, int const &TPCid) const override
bool EnableCalEfieldSCE() const override
Return boolean indicating whether or not to apply SCE corrections.
bool IsInsideBoundaries(double xVal, double yVal, double zVal) const
Check to see if point is inside boundaries of map (allow to go slightly out of range) ...
geo::Vector_t GetCalEfieldOffsets(geo::Point_t const &point, int const &TPCid) const override
double TransformZ(double zVal) const
Transform Z to SCE Z coordinate: [0.0,1.6] –> [0.0,1.6].
cet::coded_exception< error, detail::translate > exception
bool Update(uint64_t ts=0)