SpaceChargeProtoDUNE.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file SpaceChargeProtoDUNE.cxx
3 //
4 // \brief implementation of class for storing/accessing space charge distortions for ProtoDUNE
5 //
6 // \author mrmooney@colostate.edu
7 //
8 ////////////////////////////////////////////////////////////////////////
9 // C++ language includes
10 #include <iostream>
11 #include <fstream>
12 #include <string>
13 #include <vector>
14 #include "math.h"
15 #include "stdio.h"
16 // LArSoft includes
19 // Framework includes
20 #include "cetlib_except/exception.h"
22 // ROOT includes
23 #include "TFile.h"
24 #include "TH3.h"
25 #include "TTree.h"
26 #include "TLeaf.h"
27 #include "TSpline.h"
28 //-----------------------------------------------
30  fhicl::ParameterSet const& pset
31 )
32 {
33  //Configure(pset);
34 }
35 //------------------------------------------------
36 
37 //bool spacecharge::SpaceChargeProtoDUNE::Configure(fhicl::ParameterSet const& pset, detinfo::DetectorProperties const* detprop)
39  detinfo::DetectorPropertiesData const& detProp)
40 {
41 
42  fEnableSimSpatialSCE = pset.get<bool>("EnableSimSpatialSCE");
43  fEnableSimEfieldSCE = pset.get<bool>("EnableSimEfieldSCE");
44  fEnableCalSpatialSCE = pset.get<bool>("EnableCalSpatialSCE");
45  fEnableCalEfieldSCE = pset.get<bool>("EnableCalEfieldSCE");
46 
47  fEnableElectronDiverterDistortions = pset.get<std::vector<bool>>("EnableElectronDiverterDistortions");
48  fEDZCenter = pset.get<std::vector<double>>("EDZCenter");
49  fEDAXPosOffs = pset.get<std::vector<double>>("EDAXPosOffs");
50  fEDBZPosOffs = pset.get<std::vector<double>>("EDBZPosOffs");
51  fEDs = pset.get<std::vector<double>>("EDs");
52  fEDChargeLossZLow = pset.get<std::vector<double>>("EDChargeLossZLow");
53  fEDChargeLossZHigh = pset.get<std::vector<double>>("EDChargeLossZHigh");
54 
55  size_t ieds = fEnableElectronDiverterDistortions.size();
56  if (fEDZCenter.size() != ieds ||
57  fEDAXPosOffs.size() != ieds ||
58  fEDBZPosOffs.size() != ieds ||
59  fEDs.size() != ieds ||
60  fEDChargeLossZLow.size() != ieds ||
61  fEDChargeLossZHigh.size() != ieds)
62  {
63  throw cet::exception("SpaceChargeProtoDUNE") << "Inconsistent configuration sizes: " <<
64  ieds << " " <<
65  fEDAXPosOffs.size() << " " <<
66  fEDBZPosOffs.size() << " " <<
67  fEDs.size() << " " <<
68  fEDChargeLossZLow.size() << " " <<
69  fEDChargeLossZHigh.size();
70  }
71 
72  //auto const *detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
73  //fEfield = detprop->Efield();
74 
75  bool created_efield_splines = false;
76 
77  fEfield = detProp.Efield();
78 
79  if((fEnableSimSpatialSCE == true) || (fEnableSimEfieldSCE == true))
80  {
81  fRepresentationType = pset.get<std::string>("RepresentationType");
82  fInputFilename = pset.get<std::string>("InputFilename");
83 
85  cet::search_path sp("FW_SEARCH_PATH");
86  sp.find_file(fInputFilename,fname);
87 
88  std::unique_ptr<TFile> infile(new TFile(fname.c_str(), "READ"));
89  if(!infile->IsOpen()) throw cet::exception("SpaceChargeProtoDUNE") << "Could not find the space charge effect file '" << fname << "'!\n";
90 
91  if ((fRepresentationType == "Voxelized_TH3") || (fRepresentationType == "Splines_TH3")) {
92 
93  //Load in files
94  TH3F* hDx_sim_pos_orig = (TH3F*)infile->Get("RecoFwd_Displacement_X_Pos");
95  TH3F* hDy_sim_pos_orig = (TH3F*)infile->Get("RecoFwd_Displacement_Y_Pos");
96  TH3F* hDz_sim_pos_orig = (TH3F*)infile->Get("RecoFwd_Displacement_Z_Pos");
97  TH3F* hEx_sim_pos_orig = (TH3F*)infile->Get("Reco_ElecField_X_Pos");
98  TH3F* hEy_sim_pos_orig = (TH3F*)infile->Get("Reco_ElecField_Y_Pos");
99  TH3F* hEz_sim_pos_orig = (TH3F*)infile->Get("Reco_ElecField_Z_Pos");
100 
101  TH3F* hDx_sim_neg_orig = (TH3F*)infile->Get("RecoFwd_Displacement_X_Neg");
102  TH3F* hDy_sim_neg_orig = (TH3F*)infile->Get("RecoFwd_Displacement_Y_Neg");
103  TH3F* hDz_sim_neg_orig = (TH3F*)infile->Get("RecoFwd_Displacement_Z_Neg");
104  TH3F* hEx_sim_neg_orig = (TH3F*)infile->Get("Reco_ElecField_X_Neg");
105  TH3F* hEy_sim_neg_orig = (TH3F*)infile->Get("Reco_ElecField_Y_Neg");
106  TH3F* hEz_sim_neg_orig = (TH3F*)infile->Get("Reco_ElecField_Z_Neg");
107 
108  TH3F* hDx_sim_pos = (TH3F*)hDx_sim_pos_orig->Clone("hDx_pos");
109  TH3F* hDy_sim_pos = (TH3F*)hDy_sim_pos_orig->Clone("hDy_pos");
110  TH3F* hDz_sim_pos = (TH3F*)hDz_sim_pos_orig->Clone("hDz_pos");
111  TH3F* hEx_sim_pos = (TH3F*)hEx_sim_pos_orig->Clone("hEx_pos");
112  TH3F* hEy_sim_pos = (TH3F*)hEy_sim_pos_orig->Clone("hEy_pos");
113  TH3F* hEz_sim_pos = (TH3F*)hEz_sim_pos_orig->Clone("hEz_pos");
114 
115  TH3F* hDx_sim_neg = (TH3F*)hDx_sim_neg_orig->Clone("hDx_neg");
116  TH3F* hDy_sim_neg = (TH3F*)hDy_sim_neg_orig->Clone("hDy_neg");
117  TH3F* hDz_sim_neg = (TH3F*)hDz_sim_neg_orig->Clone("hDz_neg");
118  TH3F* hEx_sim_neg = (TH3F*)hEx_sim_neg_orig->Clone("hEx_neg");
119  TH3F* hEy_sim_neg = (TH3F*)hEy_sim_neg_orig->Clone("hEy_neg");
120  TH3F* hEz_sim_neg = (TH3F*)hEz_sim_neg_orig->Clone("hEz_neg");
121 
122  hDx_sim_pos->SetDirectory(0);
123  hDy_sim_pos->SetDirectory(0);
124  hDz_sim_pos->SetDirectory(0);
125  hEx_sim_pos->SetDirectory(0);
126  hEy_sim_pos->SetDirectory(0);
127  hEz_sim_pos->SetDirectory(0);
128 
129  hDx_sim_neg->SetDirectory(0);
130  hDy_sim_neg->SetDirectory(0);
131  hDz_sim_neg->SetDirectory(0);
132  hEx_sim_neg->SetDirectory(0);
133  hEy_sim_neg->SetDirectory(0);
134  hEz_sim_neg->SetDirectory(0);
135 
136  if (fRepresentationType == "Splines_TH3") {
137  int nBinsX = hDx_sim_pos_orig->GetNbinsX();
138  int nBinsY = hDx_sim_pos_orig->GetNbinsY();
139  int nBinsZ = hDx_sim_pos_orig->GetNbinsZ();
140  for(int y = 1; y <= nBinsY; y++){
141  spline_dx_fwd_neg.push_back(std::vector<TSpline3*>());
142  spline_dx_fwd_pos.push_back(std::vector<TSpline3*>());
143  for(int z = 1; z <= nBinsZ; z++){
144  spline_dx_fwd_neg.back().push_back(MakeSpline(hDx_sim_neg,1,y,z,1,1));
145  spline_dx_fwd_pos.back().push_back(MakeSpline(hDx_sim_pos,1,y,z,1,2));
146  }
147  }
148  for(int x = 1; x <= nBinsX; x++){
149  spline_dy_fwd_neg.push_back(std::vector<TSpline3*>());
150  spline_dy_fwd_pos.push_back(std::vector<TSpline3*>());
151 
152  for(int z = 1; z <= nBinsZ; z++){
153  spline_dy_fwd_neg.back().push_back(MakeSpline(hDy_sim_neg,2,x,z,1,1));
154  spline_dy_fwd_pos.back().push_back(MakeSpline(hDy_sim_pos,2,x,z,1,2));
155  }
156  }
157  for(int x = 1; x <= nBinsX; x++){
158  spline_dz_fwd_neg.push_back(std::vector<TSpline3*>());
159  spline_dz_fwd_pos.push_back(std::vector<TSpline3*>());
160  for(int y = 1; y <= nBinsY; y++){
161  spline_dz_fwd_neg.back().push_back(MakeSpline(hDz_sim_neg,3,x,y,1,1));
162  spline_dz_fwd_pos.back().push_back(MakeSpline(hDz_sim_pos,3,x,y,1,2));
163  }
164  }
165 
166  nBinsX = hEx_sim_pos_orig->GetNbinsX();
167  nBinsY = hEx_sim_pos_orig->GetNbinsY();
168  nBinsZ = hEx_sim_pos_orig->GetNbinsZ();
169  for(int y = 1; y <= nBinsY; y++){
170  spline_dEx_neg.push_back(std::vector<TSpline3*>());
171  spline_dEx_pos.push_back(std::vector<TSpline3*>());
172  for(int z = 1; z <= nBinsZ; z++){
173  spline_dEx_neg.back().push_back(MakeSpline(hEx_sim_neg,1,y,z,3,1));
174  spline_dEx_pos.back().push_back(MakeSpline(hEx_sim_pos,1,y,z,3,2));
175  }
176  }
177  for(int x = 1; x <= nBinsX; x++){
178  spline_dEy_neg.push_back(std::vector<TSpline3*>());
179  spline_dEy_pos.push_back(std::vector<TSpline3*>());
180 
181  for(int z = 1; z <= nBinsZ; z++){
182  spline_dEy_neg.back().push_back(MakeSpline(hEy_sim_neg,2,x,z,3,1));
183  spline_dEy_pos.back().push_back(MakeSpline(hEy_sim_pos,2,x,z,3,2));
184  }
185  }
186  for(int x = 1; x <= nBinsX; x++){
187  spline_dEz_neg.push_back(std::vector<TSpline3*>());
188  spline_dEz_pos.push_back(std::vector<TSpline3*>());
189  for(int y = 1; y <= nBinsY; y++){
190  spline_dEz_neg.back().push_back(MakeSpline(hEz_sim_neg,3,x,y,3,1));
191  spline_dEz_pos.back().push_back(MakeSpline(hEz_sim_pos,3,x,y,3,2));
192  }
193  }
194  created_efield_splines = true;
195  }
196 
197  SCEhistograms = {hDx_sim_pos, hDy_sim_pos, hDz_sim_pos, hEx_sim_pos, hEy_sim_pos, hEz_sim_pos, hDx_sim_neg, hDy_sim_neg, hDz_sim_neg, hEx_sim_neg, hEy_sim_neg, hEz_sim_neg};
198 
199  } else if (fRepresentationType == "Voxelized") {
200 
201  //Load files and read in trees
202  if (fInputFilename.find("NegX")<fInputFilename.length()){
203 
204  TTree* treeD_negX = (TTree*)infile->Get("SpaCEtree_fwdDisp");
205  TTree* treeE_negX = (TTree*)infile->Get("SpaCEtree");
206 
207  fInputFilename.replace(fInputFilename.find("NegX"),3,"Pos");
208 
209  std::string fname2;
210  sp.find_file(fInputFilename,fname2);
211  std::unique_ptr<TFile> infile2(new TFile(fname2.c_str(), "READ"));
212  if(!infile2->IsOpen()) throw cet::exception("SpaceChargeProtoDUNE") << "Could not find the space charge effect file '" << fname2 << "'!\n";
213 
214  TTree* treeD_posX = (TTree*)infile2->Get("SpaCEtree_fwdDisp");
215  TTree* treeE_posX = (TTree*)infile2->Get("SpaCEtree");
216 
217  std::vector<TH3F*> temp = Build_TH3(treeD_posX, treeE_posX, treeD_negX, treeE_negX, "x_true", "y_true", "z_true", "fwd");
218 
219  for (size_t ii = 0; ii<temp.size(); ii++){
220  SCEhistograms.at(ii) = (TH3F*)temp.at(ii)->Clone(TString::Format("%s",temp.at(ii)->GetName()));
221  SCEhistograms.at(ii)->SetDirectory(0);
222  }
223 
224 
225  infile2->Close();
226 
227  }else if (fInputFilename.find("PosX")<fInputFilename.length()){
228 
229  TTree* treeD_posX = (TTree*)infile->Get("SpaCEtree_fwdDisp");
230  TTree* treeE_posX = (TTree*)infile->Get("SpaCEtree");
231 
232  fInputFilename.replace(fInputFilename.find("PosX"),3,"Neg");
233 
234  std::string fname2;
235  sp.find_file(fInputFilename,fname2);
236  std::unique_ptr<TFile> infile2(new TFile(fname2.c_str(), "READ"));
237  if(!infile2->IsOpen()) throw cet::exception("SpaceChargeProtoDUNE") << "Could not find the space charge effect file '" << fname2 << "'!\n";
238 
239  TTree* treeD_negX = (TTree*)infile2->Get("SpaCEtree_fwdDisp");
240  TTree* treeE_negX = (TTree*)infile2->Get("SpaCEtree");
241 
242  std::vector<TH3F*> temp = Build_TH3(treeD_posX, treeE_posX, treeD_negX, treeE_negX, "x_true", "y_true", "z_true", "fwd");
243 
244  for (size_t ii = 0; ii<temp.size(); ii++){
245  SCEhistograms.at(ii) = (TH3F*)temp.at(ii)->Clone(TString::Format("%s",temp.at(ii)->GetName()));
246  SCEhistograms.at(ii)->SetDirectory(0);
247  }
248 
249  infile2->Close();
250 
251  }else{
252 
253  TTree* treeD_negX = (TTree*)infile->Get("SpaCEtree_fwdDisp");
254  TTree* treeE_negX = (TTree*)infile->Get("SpaCEtree");
255 
256  TTree* treeD_posX = (TTree*)infile->Get("SpaCEtree_fwdDisp");
257  TTree* treeE_posX = (TTree*)infile->Get("SpaCEtree");
258 
259  std::vector<TH3F*> temp = Build_TH3(treeD_posX, treeE_posX, treeD_negX, treeE_negX, "x_true", "y_true", "z_true", "fwd");
260 
261  for (size_t ii = 0; ii<temp.size(); ii++){
262  SCEhistograms.at(ii) = (TH3F*)temp.at(ii)->Clone(TString::Format("%s",temp.at(ii)->GetName()));
263  SCEhistograms.at(ii)->SetDirectory(0);
264  }
265 
266  }
267 
268  } else if(fRepresentationType == "Parametric")
269  {
270 
271  for(int i = 0; i < 5; i++)
272  {
273  g1_x[i] = (TGraph*)infile->Get(Form("deltaX/g1_%d",i));
274  g2_x[i] = (TGraph*)infile->Get(Form("deltaX/g2_%d",i));
275  g3_x[i] = (TGraph*)infile->Get(Form("deltaX/g3_%d",i));
276  g4_x[i] = (TGraph*)infile->Get(Form("deltaX/g4_%d",i));
277  g5_x[i] = (TGraph*)infile->Get(Form("deltaX/g5_%d",i));
278  g1_y[i] = (TGraph*)infile->Get(Form("deltaY/g1_%d",i));
279  g2_y[i] = (TGraph*)infile->Get(Form("deltaY/g2_%d",i));
280  g3_y[i] = (TGraph*)infile->Get(Form("deltaY/g3_%d",i));
281  g4_y[i] = (TGraph*)infile->Get(Form("deltaY/g4_%d",i));
282  g5_y[i] = (TGraph*)infile->Get(Form("deltaY/g5_%d",i));
283  g6_y[i] = (TGraph*)infile->Get(Form("deltaY/g6_%d",i));
284  g1_z[i] = (TGraph*)infile->Get(Form("deltaZ/g1_%d",i));
285  g2_z[i] = (TGraph*)infile->Get(Form("deltaZ/g2_%d",i));
286  g3_z[i] = (TGraph*)infile->Get(Form("deltaZ/g3_%d",i));
287  g4_z[i] = (TGraph*)infile->Get(Form("deltaZ/g4_%d",i));
288  g1_Ex[i] = (TGraph*)infile->Get(Form("deltaExOverE/g1_%d",i));
289  g2_Ex[i] = (TGraph*)infile->Get(Form("deltaExOverE/g2_%d",i));
290  g3_Ex[i] = (TGraph*)infile->Get(Form("deltaExOverE/g3_%d",i));
291  g4_Ex[i] = (TGraph*)infile->Get(Form("deltaExOverE/g4_%d",i));
292  g5_Ex[i] = (TGraph*)infile->Get(Form("deltaExOverE/g5_%d",i));
293  g1_Ey[i] = (TGraph*)infile->Get(Form("deltaEyOverE/g1_%d",i));
294  g2_Ey[i] = (TGraph*)infile->Get(Form("deltaEyOverE/g2_%d",i));
295  g3_Ey[i] = (TGraph*)infile->Get(Form("deltaEyOverE/g3_%d",i));
296  g4_Ey[i] = (TGraph*)infile->Get(Form("deltaEyOverE/g4_%d",i));
297  g5_Ey[i] = (TGraph*)infile->Get(Form("deltaEyOverE/g5_%d",i));
298  g6_Ey[i] = (TGraph*)infile->Get(Form("deltaEyOverE/g6_%d",i));
299  g1_Ez[i] = (TGraph*)infile->Get(Form("deltaEzOverE/g1_%d",i));
300  g2_Ez[i] = (TGraph*)infile->Get(Form("deltaEzOverE/g2_%d",i));
301  g3_Ez[i] = (TGraph*)infile->Get(Form("deltaEzOverE/g3_%d",i));
302  g4_Ez[i] = (TGraph*)infile->Get(Form("deltaEzOverE/g4_%d",i));
303  }
304  g1_x[5] = (TGraph*)infile->Get("deltaX/g1_5");
305  g2_x[5] = (TGraph*)infile->Get("deltaX/g2_5");
306  g3_x[5] = (TGraph*)infile->Get("deltaX/g3_5");
307  g4_x[5] = (TGraph*)infile->Get("deltaX/g4_5");
308  g5_x[5] = (TGraph*)infile->Get("deltaX/g5_5");
309  g1_y[5] = (TGraph*)infile->Get("deltaY/g1_5");
310  g2_y[5] = (TGraph*)infile->Get("deltaY/g2_5");
311  g3_y[5] = (TGraph*)infile->Get("deltaY/g3_5");
312  g4_y[5] = (TGraph*)infile->Get("deltaY/g4_5");
313  g5_y[5] = (TGraph*)infile->Get("deltaY/g5_5");
314  g6_y[5] = (TGraph*)infile->Get("deltaY/g6_5");
315 
316  g1_x[6] = (TGraph*)infile->Get("deltaX/g1_6");
317  g2_x[6] = (TGraph*)infile->Get("deltaX/g2_6");
318  g3_x[6] = (TGraph*)infile->Get("deltaX/g3_6");
319  g4_x[6] = (TGraph*)infile->Get("deltaX/g4_6");
320  g5_x[6] = (TGraph*)infile->Get("deltaX/g5_6");
321  g1_Ex[5] = (TGraph*)infile->Get("deltaExOverE/g1_5");
322  g2_Ex[5] = (TGraph*)infile->Get("deltaExOverE/g2_5");
323  g3_Ex[5] = (TGraph*)infile->Get("deltaExOverE/g3_5");
324  g4_Ex[5] = (TGraph*)infile->Get("deltaExOverE/g4_5");
325  g5_Ex[5] = (TGraph*)infile->Get("deltaExOverE/g5_5");
326  g1_Ey[5] = (TGraph*)infile->Get("deltaEyOverE/g1_5");
327  g2_Ey[5] = (TGraph*)infile->Get("deltaEyOverE/g2_5");
328  g3_Ey[5] = (TGraph*)infile->Get("deltaEyOverE/g3_5");
329  g4_Ey[5] = (TGraph*)infile->Get("deltaEyOverE/g4_5");
330  g5_Ey[5] = (TGraph*)infile->Get("deltaEyOverE/g5_5");
331  g6_Ey[5] = (TGraph*)infile->Get("deltaEyOverE/g6_5");
332  g1_Ex[6] = (TGraph*)infile->Get("deltaExOverE/g1_6");
333  g2_Ex[6] = (TGraph*)infile->Get("deltaExOverE/g2_6");
334  g3_Ex[6] = (TGraph*)infile->Get("deltaExOverE/g3_6");
335  g4_Ex[6] = (TGraph*)infile->Get("deltaExOverE/g4_6");
336  g5_Ex[6] = (TGraph*)infile->Get("deltaExOverE/g5_6");
337  }
338  infile->Close();
339  }
340 
341  if((fEnableCalSpatialSCE == true) || (fEnableCalEfieldSCE == true))
342  {
343 
344  fRepresentationType = pset.get<std::string>("RepresentationType");
345  fCalInputFilename = pset.get<std::string>("CalibrationInputFilename");
346 
348  cet::search_path sp("FW_SEARCH_PATH");
349  sp.find_file(fCalInputFilename,fname);
350 
351  std::unique_ptr<TFile> infile(new TFile(fname.c_str(), "READ"));
352  if(!infile->IsOpen()) throw cet::exception("SpaceChargeProtoDUNE") << "Could not find the space charge effect file '" << fname << "'!\n";
353 
354  if ((fRepresentationType == "Voxelized_TH3") || (fRepresentationType == "Splines_TH3")) {
355 
356  //Load in files
357  TH3F* hDx_cal_pos_orig = (TH3F*)infile->Get("RecoBkwd_Displacement_X_Pos");
358  TH3F* hDy_cal_pos_orig = (TH3F*)infile->Get("RecoBkwd_Displacement_Y_Pos");
359  TH3F* hDz_cal_pos_orig = (TH3F*)infile->Get("RecoBkwd_Displacement_Z_Pos");
360  TH3F* hEx_cal_pos_orig = (TH3F*)infile->Get("Reco_ElecField_X_Pos");
361  TH3F* hEy_cal_pos_orig = (TH3F*)infile->Get("Reco_ElecField_Y_Pos");
362  TH3F* hEz_cal_pos_orig = (TH3F*)infile->Get("Reco_ElecField_Z_Pos");
363 
364  TH3F* hDx_cal_neg_orig = (TH3F*)infile->Get("RecoBkwd_Displacement_X_Neg");
365  TH3F* hDy_cal_neg_orig = (TH3F*)infile->Get("RecoBkwd_Displacement_Y_Neg");
366  TH3F* hDz_cal_neg_orig = (TH3F*)infile->Get("RecoBkwd_Displacement_Z_Neg");
367  TH3F* hEx_cal_neg_orig = (TH3F*)infile->Get("Reco_ElecField_X_Neg");
368  TH3F* hEy_cal_neg_orig = (TH3F*)infile->Get("Reco_ElecField_Y_Neg");
369  TH3F* hEz_cal_neg_orig = (TH3F*)infile->Get("Reco_ElecField_Z_Neg");
370 
371  TH3F* hDx_cal_pos = (TH3F*)hDx_cal_pos_orig->Clone("hDx_pos");
372  TH3F* hDy_cal_pos = (TH3F*)hDy_cal_pos_orig->Clone("hDy_pos");
373  TH3F* hDz_cal_pos = (TH3F*)hDz_cal_pos_orig->Clone("hDz_pos");
374  TH3F* hEx_cal_pos = (TH3F*)hEx_cal_pos_orig->Clone("hEx_pos");
375  TH3F* hEy_cal_pos = (TH3F*)hEy_cal_pos_orig->Clone("hEy_pos");
376  TH3F* hEz_cal_pos = (TH3F*)hEz_cal_pos_orig->Clone("hEz_pos");
377 
378  TH3F* hDx_cal_neg = (TH3F*)hDx_cal_neg_orig->Clone("hDx_neg");
379  TH3F* hDy_cal_neg = (TH3F*)hDy_cal_neg_orig->Clone("hDy_neg");
380  TH3F* hDz_cal_neg = (TH3F*)hDz_cal_neg_orig->Clone("hDz_neg");
381  TH3F* hEx_cal_neg = (TH3F*)hEx_cal_neg_orig->Clone("hEx_neg");
382  TH3F* hEy_cal_neg = (TH3F*)hEy_cal_neg_orig->Clone("hEy_neg");
383  TH3F* hEz_cal_neg = (TH3F*)hEz_cal_neg_orig->Clone("hEz_neg");
384 
385  hDx_cal_pos->SetDirectory(0);
386  hDy_cal_pos->SetDirectory(0);
387  hDz_cal_pos->SetDirectory(0);
388  hEx_cal_pos->SetDirectory(0);
389  hEy_cal_pos->SetDirectory(0);
390  hEz_cal_pos->SetDirectory(0);
391 
392  hDx_cal_neg->SetDirectory(0);
393  hDy_cal_neg->SetDirectory(0);
394  hDz_cal_neg->SetDirectory(0);
395  hEx_cal_neg->SetDirectory(0);
396  hEy_cal_neg->SetDirectory(0);
397  hEz_cal_neg->SetDirectory(0);
398 
399  if (fRepresentationType == "Splines_TH3") {
400  int nBinsX = hDx_cal_pos_orig->GetNbinsX();
401  int nBinsY = hDx_cal_pos_orig->GetNbinsY();
402  int nBinsZ = hDx_cal_pos_orig->GetNbinsZ();
403 
404  //TFile spline_file("splines.root", "RECREATE");
405  //gROOT->SetBatch(1);
406  for(int y = 1; y <= nBinsY; y++){
407  spline_dx_bkwd_neg.push_back(std::vector<TSpline3*>());
408  spline_dx_bkwd_pos.push_back(std::vector<TSpline3*>());
409  for(int z = 1; z <= nBinsZ; z++){
410  spline_dx_bkwd_neg.back().push_back(MakeSpline(hDx_cal_neg,1,y,z,2,1));
411  spline_dx_bkwd_pos.back().push_back(MakeSpline(hDx_cal_pos,1,y,z,2,2));
412  }
413  }
414  for(int x = 1; x <= nBinsX; x++){
415  spline_dy_bkwd_neg.push_back(std::vector<TSpline3*>());
416  spline_dy_bkwd_pos.push_back(std::vector<TSpline3*>());
417  for(int z = 1; z <= nBinsZ; z++){
418  spline_dy_bkwd_neg.back().push_back(MakeSpline(hDy_cal_neg,2,x,z,2,1));
419  spline_dy_bkwd_pos.back().push_back(MakeSpline(hDy_cal_pos,2,x,z,2,2));
420  }
421  }
422  for(int x = 1; x <= nBinsX; x++){
423  spline_dz_bkwd_neg.push_back(std::vector<TSpline3*>());
424  spline_dz_bkwd_pos.push_back(std::vector<TSpline3*>());
425  for(int y = 1; y <= nBinsY; y++){
426  spline_dz_bkwd_neg.back().push_back(MakeSpline(hDz_cal_neg,3,x,y,2,1));
427  spline_dz_bkwd_pos.back().push_back(MakeSpline(hDz_cal_pos,3,x,y,2,2));
428  }
429  }
430  if(created_efield_splines == false){
431  nBinsX = hEx_cal_neg->GetNbinsX();
432  nBinsY = hEx_cal_neg->GetNbinsY();
433  nBinsZ = hEx_cal_neg->GetNbinsZ();
434  for(int y = 1; y <= nBinsY; y++){
435  spline_dEx_neg.push_back(std::vector<TSpline3*>());
436  spline_dEx_pos.push_back(std::vector<TSpline3*>());
437  for(int z = 1; z <= nBinsZ; z++){
438  spline_dEx_neg.back().push_back(MakeSpline(hEx_cal_neg,1,y,z,3,1));
439  spline_dEx_pos.back().push_back(MakeSpline(hEx_cal_pos,1,y,z,3,2));
440  }
441  }
442  for(int x = 1; x <= nBinsX; x++){
443  spline_dEy_neg.push_back(std::vector<TSpline3*>());
444  spline_dEy_pos.push_back(std::vector<TSpline3*>());
445  for(int z = 1; z <= nBinsZ; z++){
446  spline_dEy_neg.back().push_back(MakeSpline(hEy_cal_neg,2,x,z,3,1));
447  spline_dEy_pos.back().push_back(MakeSpline(hEy_cal_pos,2,x,z,3,2));
448  }
449  }
450  for(int x = 1; x <= nBinsX; x++){
451  spline_dEz_neg.push_back(std::vector<TSpline3*>());
452  spline_dEz_pos.push_back(std::vector<TSpline3*>());
453  for(int y = 1; y <= nBinsY; y++){
454  spline_dEz_neg.back().push_back(MakeSpline(hEz_cal_neg,3,x,y,3,1));
455  spline_dEz_pos.back().push_back(MakeSpline(hEz_cal_pos,3,x,y,3,2));
456  }
457  }
458  created_efield_splines = true;
459  }
460  //spline_file.Close();
461  }
462 
463  CalSCEhistograms = {hDx_cal_pos, hDy_cal_pos, hDz_cal_pos, hEx_cal_pos, hEy_cal_pos, hEz_cal_pos, hDx_cal_neg, hDy_cal_neg, hDz_cal_neg, hEx_cal_neg, hEy_cal_neg, hEz_cal_neg};
464 
465  } else if (fRepresentationType == "Voxelized") {
466 
467  //Load files and read in trees
468  if (fCalInputFilename.find("NegX")<fCalInputFilename.length()){
469 
470  TTree* treeD_negX = (TTree*)infile->Get("SpaCEtree_bkwdDisp");
471  TTree* treeE_negX = (TTree*)infile->Get("SpaCEtree");
472 
473  fCalInputFilename.replace(fCalInputFilename.find("NegX"),3,"Pos");
474 
475  std::string fname2;
476  sp.find_file(fCalInputFilename,fname2);
477  std::unique_ptr<TFile> infile2(new TFile(fname2.c_str(), "READ"));
478  if(!infile2->IsOpen()) throw cet::exception("SpaceChargeProtoDUNE") << "Could not find the space charge effect file '" << fname2 << "'!\n";
479 
480  TTree* treeD_posX = (TTree*)infile2->Get("SpaCEtree_bkwdDisp");
481  TTree* treeE_posX = (TTree*)infile2->Get("SpaCEtree");
482 
483  std::vector<TH3F*> temp = Build_TH3(treeD_posX, treeE_posX, treeD_negX,treeE_negX, "x_reco", "y_reco", "z_reco", "bkwd");
484  for (size_t ii = 0; ii<temp.size(); ii++){
485  CalSCEhistograms.at(ii) = (TH3F*)temp.at(ii)->Clone(TString::Format("%s",temp.at(ii)->GetName()));
486  CalSCEhistograms.at(ii)->SetDirectory(0);
487  }
488 
489  infile2->Close();
490 
491  }else if (fCalInputFilename.find("PosX")<fCalInputFilename.length()){
492 
493  TTree* treeD_posX = (TTree*)infile->Get("SpaCEtree_bkwdDisp");
494  TTree* treeE_posX = (TTree*)infile->Get("SpaCEtree");
495 
496  fCalInputFilename.replace(fCalInputFilename.find("PosX"),3,"Neg");
497 
498  std::string fname2;
499  sp.find_file(fCalInputFilename,fname2);
500  std::unique_ptr<TFile> infile2(new TFile(fname2.c_str(), "READ"));
501  if(!infile2->IsOpen()) throw cet::exception("SpaceChargeProtoDUNE") << "Could not find the space charge effect file '" << fname2 << "'!\n";
502 
503  TTree* treeD_negX = (TTree*)infile2->Get("SpaCEtree_bkwdDisp");
504  TTree* treeE_negX = (TTree*)infile2->Get("SpaCEtree");
505 
506  std::vector<TH3F*> temp = Build_TH3(treeD_posX, treeE_posX, treeD_negX,treeE_negX, "x_reco", "y_reco", "z_reco", "bkwd");
507  for (size_t ii = 0; ii<temp.size(); ii++){
508  CalSCEhistograms.at(ii) = (TH3F*)temp.at(ii)->Clone(TString::Format("%s",temp.at(ii)->GetName()));
509  CalSCEhistograms.at(ii)->SetDirectory(0);
510  }
511 
512  infile2->Close();
513 
514  }else{
515 
516  TTree* treeD_negX = (TTree*)infile->Get("SpaCEtree_bkwdDisp");
517  TTree* treeE_negX = (TTree*)infile->Get("SpaCEtree");
518 
519  TTree* treeD_posX = (TTree*)infile->Get("SpaCEtree_bkwdDisp");
520  TTree* treeE_posX = (TTree*)infile->Get("SpaCEtree");
521 
522  std::vector<TH3F*> temp = Build_TH3(treeD_posX, treeE_posX, treeD_negX,treeE_negX, "x_reco", "y_reco", "z_reco", "bkwd");
523  for (size_t ii = 0; ii<temp.size(); ii++){
524  CalSCEhistograms.at(ii) = (TH3F*)temp.at(ii)->Clone(TString::Format("%s",temp.at(ii)->GetName()));
525  CalSCEhistograms.at(ii)->SetDirectory(0);
526  }
527 
528  }
529 
530  } else { std::cout << "No space charge representation type chosen." << std::endl;}
531 
532  infile->Close();
533  }
534 
535  return true;
536 }
537 //------------------------------------------------
539 {
540  if (ts == 0) return false;
541  return true;
542 }
543 //----------------------------------------------------------------------------
544 /// Return boolean indicating whether or not to turn simulation of SCE on for
545 /// spatial distortions
547 {
548  return fEnableSimSpatialSCE;
549 }
550 //----------------------------------------------------------------------------
551 /// Return boolean indicating whether or not to turn simulation of SCE on for
552 /// E field distortions
554 {
555  return fEnableSimEfieldSCE;
556 }
557 //----------------------------------------------------------------------------
558 /// Return boolean indicating whether or not to apply SCE corrections
559 //bool spacecharge::SpaceChargeProtoDUNE::EnableCorrSCE() const
560 //{
561 // return fEnableCorrSCE;
562 //}
563 
564 /// Return boolean indicating whether or not to apply SCE corrections
566 {
567  return fEnableCalSpatialSCE;
568 }
569 
570 /// Return boolean indicating whether or not to apply SCE corrections
572 {
573  return fEnableCalEfieldSCE;
574 }
575 //----------------------------------------------------------------------------
576 /// Primary working method of service that provides position offsets to be
577 /// used in ionization electron drift
579 {
580 
581  std::vector<double> thePosOffsets;
582  geo::Point_t point = tmp_point;
583  if(IsTooFarFromBoundaries(point)) {
584  thePosOffsets.resize(3,0.0);
585  return { -thePosOffsets[0], -thePosOffsets[1], -thePosOffsets[2] };
586  }
587  if(!IsInsideBoundaries(point)&&!IsTooFarFromBoundaries(point)) point = PretendAtBoundary(point);
588 
589  if ((fRepresentationType=="Voxelized_TH3") || (fRepresentationType == "Splines_TH3")){
590  if (point.X() > 0.) {
591  thePosOffsets = GetOffsetsVoxel(point, SCEhistograms.at(0), SCEhistograms.at(1), SCEhistograms.at(2), 1, 2);
592  thePosOffsets[0] = -1.0*thePosOffsets[0];
593  } else {
594  thePosOffsets = GetOffsetsVoxel(point, SCEhistograms.at(6), SCEhistograms.at(7), SCEhistograms.at(8), 1, 1);
595  thePosOffsets[0] = -1.0*thePosOffsets[0];
596  }
597 
598  }else if (fRepresentationType == "Voxelized"){
599  if (point.X() > 0.) thePosOffsets = GetOffsetsVoxel(point, SCEhistograms.at(0), SCEhistograms.at(1), SCEhistograms.at(2), 1, 2);
600  else thePosOffsets = GetOffsetsVoxel(point, SCEhistograms.at(6), SCEhistograms.at(7), SCEhistograms.at(8), 1, 1);
601 
602  }else if(fRepresentationType == "Parametric") thePosOffsets = GetPosOffsetsParametric(point.X(), point.Y(), point.Z());
603  else thePosOffsets.resize(3,0.0);
604 
605  geo::Point_t pafteroffset(point.X()+thePosOffsets[0], point.Y()+thePosOffsets[1], point.Z()+thePosOffsets[2]);
606  geo::Vector_t edoffset = ElectronDiverterPosOffsets(pafteroffset);
607  thePosOffsets[0] += edoffset.X();
608  thePosOffsets[1] += edoffset.Y();
609  thePosOffsets[2] += edoffset.Z();
610 
611  return { thePosOffsets[0], thePosOffsets[1], thePosOffsets[2] };
612 }
613 
614 //----------------------------------------------------------------------------
615 /// Primary working method of service that provides position offsets to be
616 /// used in calibration of space charge
618 {
619 
620  std::vector<double> thePosOffsets;
621  geo::Point_t point = tmp_point;
622 
623  if(IsTooFarFromBoundaries(point)) {
624  thePosOffsets.resize(3,0.0);
625  return { -thePosOffsets[0], -thePosOffsets[1], -thePosOffsets[2] };
626  }
627  if(!IsInsideBoundaries(point)&&!IsTooFarFromBoundaries(point)){
628  point = PretendAtBoundary(point);
629  }
630 
631  if ((fRepresentationType == "Voxelized_TH3") || (fRepresentationType == "Splines_TH3")){
632  if ((TPCid == 2 || TPCid == 6 || TPCid == 10)&&point.X()>-20.){
633  if (point.X()<0.) point = {0.00001, point.Y(), point.Z()};
634  thePosOffsets = GetOffsetsVoxel(point, CalSCEhistograms.at(0), CalSCEhistograms.at(1), CalSCEhistograms.at(2), 2, 2);
635  thePosOffsets[0] = -1.0*thePosOffsets[0];
636  } else if((TPCid == 1 || TPCid == 5 || TPCid == 9)&&point.X()<20.) {
637  if (point.X()>0.) point= {-0.00001, point.Y(), point.Z()};
638  thePosOffsets = GetOffsetsVoxel(point, CalSCEhistograms.at(6), CalSCEhistograms.at(7), CalSCEhistograms.at(8), 2, 1);
639  thePosOffsets[0] = -1.0*thePosOffsets[0];
640  } else thePosOffsets = {0., 0., 0.};
641 
642  } else if (fRepresentationType=="Voxelized"){
643  if ((TPCid == 2 || TPCid == 6 || TPCid == 10)&&point.X()>-20.){
644  if (point.X()<0.) point = {0.00001, point.Y(), point.Z()};
645  thePosOffsets = GetOffsetsVoxel(point, CalSCEhistograms.at(0), CalSCEhistograms.at(1), CalSCEhistograms.at(2), 2, 2);
646  thePosOffsets[0] = -1.0*thePosOffsets[0];
647  } else if((TPCid == 1 || TPCid == 5 || TPCid == 9)&&point.X()<20.) {
648  if (point.X()>0.) point= {-0.00001, point.Y(), point.Z()};
649  thePosOffsets = GetOffsetsVoxel(point, CalSCEhistograms.at(6), CalSCEhistograms.at(7), CalSCEhistograms.at(8), 2, 1);
650  } else thePosOffsets = {0., 0., 0.};
651 
652  } else thePosOffsets.resize(3,0.0);
653 
654  return { thePosOffsets[0], thePosOffsets[1], thePosOffsets[2] };
655 }
656 
657 //----------------------------------------------------------------------------
658 /// Provides position offsets using voxelized interpolation
659 std::vector<double> spacecharge::SpaceChargeProtoDUNE::GetOffsetsVoxel(geo::Point_t const& point, TH3F* hX, TH3F* hY, TH3F* hZ, int maptype, int driftvol) const
660 {
661  if (fRepresentationType == "Voxelized_TH3"){
662 
663  return {
664  hX->Interpolate(point.X(),point.Y(),point.Z()),
665  hY->Interpolate(point.X(),point.Y(),point.Z()),
666  hZ->Interpolate(point.X(),point.Y(),point.Z())
667  };
668 
669  } else if (fRepresentationType == "Splines_TH3"){
670 
671  return {
672  InterpolateSplines(hX,point.X(),point.Y(),point.Z(),1,maptype,driftvol),
673  InterpolateSplines(hY,point.X(),point.Y(),point.Z(),2,maptype,driftvol),
674  InterpolateSplines(hZ,point.X(),point.Y(),point.Z(),3,maptype,driftvol)
675  };
676 
677  } else {
678  double xnew = TransformX(point.X());
679  double ynew = TransformY(point.Y());
680  double znew = TransformZ(point.Z());
681 
682  return {
683  hX->Interpolate(xnew,ynew,znew),
684  hY->Interpolate(xnew,ynew,znew),
685  hZ->Interpolate(xnew,ynew,znew)
686  };
687  }
688 }
689 
690 //----------------------------------------------------------------------------
691 /// Build 3d histograms for voxelized interpolation
692 std::vector<TH3F*> spacecharge::SpaceChargeProtoDUNE::Build_TH3(TTree* tree_pos, TTree* eTree_pos, TTree* tree_neg, TTree* eTree_neg, std::string xvar, std::string yvar, std::string zvar, std::string posLeaf) const
693 {
694 
695  //Define the protoDUNE detector
696  double Lx = 3.6, Ly = 6.0, Lz = 7.2;
697  double numDivisions_x = 18.0;
698  double cell_size = Lx/numDivisions_x;
699  double numDivisions_y = TMath::Nint((Ly/Lx)*((Double_t)numDivisions_x));
700  double numDivisions_z = TMath::Nint((Lz/Lx)*((Double_t)numDivisions_x));
701 
702  double E_numDivisions_x = 18.0;
703  double E_cell_size = Lx/E_numDivisions_x;
704  double E_numDivisions_y = TMath::Nint((Ly/Lx)*((Double_t)E_numDivisions_x));
705  double E_numDivisions_z = TMath::Nint((Lz/Lx)*((Double_t)E_numDivisions_x));
706 
707  //initialized histograms for Dx, Dy, Dz, and electric field (pos x)
708  TH3F* hDx_pos = new TH3F("hDx_pos", "", numDivisions_x+1, -0.5*cell_size, Lx+0.5*cell_size, numDivisions_y+1 ,-0.5*cell_size, Ly+0.5*cell_size, numDivisions_z+1, -0.5*cell_size, Lz+0.5*cell_size);
709  TH3F* hDy_pos = new TH3F("hDy_pos", "", numDivisions_x+1, -0.5*cell_size, Lx+0.5*cell_size, numDivisions_y+1, -0.5*cell_size, Ly+0.5*cell_size, numDivisions_z+1, -0.5*cell_size, Lz+0.5*cell_size);
710  TH3F* hDz_pos = new TH3F("hDz_pos", "", numDivisions_x+1, -0.5*cell_size, Lx+0.5*cell_size, numDivisions_y+1, -0.5*cell_size, Ly+0.5*cell_size, numDivisions_z+1, -0.5*cell_size, Lz+0.5*cell_size);
711 
712  TH3F* hEx_pos = new TH3F("hEx_pos", "", E_numDivisions_x+1, -0.5*E_cell_size, Lx+0.5*E_cell_size, E_numDivisions_y+1, -0.5*E_cell_size, Ly+0.5*E_cell_size, E_numDivisions_z+1, -0.5*E_cell_size, Lz+0.5*E_cell_size);
713  TH3F* hEy_pos = new TH3F("hEy_pos", "", E_numDivisions_x+1, -0.5*E_cell_size, Lx+0.5*E_cell_size, E_numDivisions_y+1, -0.5*E_cell_size, Ly+0.5*E_cell_size, E_numDivisions_z+1, -0.5*E_cell_size, Lz+0.5*E_cell_size);
714  TH3F* hEz_pos = new TH3F("hEz_pos", "", E_numDivisions_x+1, -0.5*E_cell_size, Lx+0.5*E_cell_size, E_numDivisions_y+1, -0.5*E_cell_size, Ly+0.5*E_cell_size, E_numDivisions_z+1, -0.5*E_cell_size, Lz+0.5*E_cell_size);
715 
716  //initialized histograms for Dx, Dy, Dz, and electric field (neg x)
717  TH3F* hDx_neg = new TH3F("hDx_neg", "", numDivisions_x+1, -0.5*cell_size, Lx+0.5*cell_size, numDivisions_y+1 ,-0.5*cell_size, Ly+0.5*cell_size, numDivisions_z+1, -0.5*cell_size, Lz+0.5*cell_size);
718  TH3F* hDy_neg = new TH3F("hDy_neg", "", numDivisions_x+1, -0.5*cell_size, Lx+0.5*cell_size, numDivisions_y+1, -0.5*cell_size, Ly+0.5*cell_size, numDivisions_z+1, -0.5*cell_size, Lz+0.5*cell_size);
719  TH3F* hDz_neg = new TH3F("hDz_neg", "", numDivisions_x+1, -0.5*cell_size, Lx+0.5*cell_size, numDivisions_y+1, -0.5*cell_size, Ly+0.5*cell_size, numDivisions_z+1, -0.5*cell_size, Lz+0.5*cell_size);
720 
721  TH3F* hEx_neg = new TH3F("hEx_neg", "", E_numDivisions_x+1, -0.5*E_cell_size, Lx+0.5*E_cell_size, E_numDivisions_y+1, -0.5*E_cell_size, Ly+0.5*E_cell_size, E_numDivisions_z+1, -0.5*E_cell_size, Lz+0.5*E_cell_size);
722  TH3F* hEy_neg = new TH3F("hEy_neg", "", E_numDivisions_x+1, -0.5*E_cell_size, Lx+0.5*E_cell_size, E_numDivisions_y+1, -0.5*E_cell_size, Ly+0.5*E_cell_size, E_numDivisions_z+1, -0.5*E_cell_size, Lz+0.5*E_cell_size);
723  TH3F* hEz_neg = new TH3F("hEz_neg", "", E_numDivisions_x+1, -0.5*E_cell_size, Lx+0.5*E_cell_size, E_numDivisions_y+1, -0.5*E_cell_size, Ly+0.5*E_cell_size, E_numDivisions_z+1, -0.5*E_cell_size, Lz+0.5*E_cell_size);
724 
725  //For each event, read the tree and fill each histogram (pos x)
726  for (int ii = 0; ii<tree_pos->GetEntries(); ii++){
727 
728  //Read the trees
729  tree_pos->GetEntry(ii);
730  Double_t x = tree_pos->GetBranch(xvar.c_str())->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
731  Double_t y = tree_pos->GetBranch(yvar.c_str())->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
732  Double_t z = tree_pos->GetBranch(zvar.c_str())->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
733  Double_t dx = tree_pos->GetBranch("Dx")->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
734  Double_t dy = tree_pos->GetBranch("Dy")->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
735  Double_t dz = tree_pos->GetBranch("Dz")->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
736 
737  hDx_pos->Fill(x,y,z,100.0*dx);
738  hDy_pos->Fill(x,y,z,100.0*dy);
739  hDz_pos->Fill(x,y,z,100.0*dz);
740  }
741 
742  for(int ii = 0; ii<eTree_pos->GetEntries(); ii++){
743 
744  eTree_pos->GetEntry(ii);
745  Double_t x = eTree_pos->GetBranch("xpoint")->GetLeaf("data")->GetValue();
746  Double_t y = eTree_pos->GetBranch("ypoint")->GetLeaf("data")->GetValue();
747  Double_t z = eTree_pos->GetBranch("zpoint")->GetLeaf("data")->GetValue();
748  Double_t Ex = eTree_pos->GetBranch("Ex")->GetLeaf("data")->GetValue() / (100000.0*fEfield);
749  Double_t Ey = eTree_pos->GetBranch("Ey")->GetLeaf("data")->GetValue() / (100000.0*fEfield);
750  Double_t Ez = eTree_pos->GetBranch("Ez")->GetLeaf("data")->GetValue() / (100000.0*fEfield);
751 
752  //Fill the histograms
753  hEx_pos->Fill(x,y,z,Ex);
754  hEy_pos->Fill(x,y,z,Ey);
755  hEz_pos->Fill(x,y,z,Ez);
756  }
757 
758  //For each event, read the tree and fill each histogram (neg x)
759  for (int ii = 0; ii<tree_neg->GetEntries(); ii++){
760 
761  //Read the trees
762  tree_neg->GetEntry(ii);
763  Double_t x = tree_neg->GetBranch(xvar.c_str())->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
764  Double_t y = tree_neg->GetBranch(yvar.c_str())->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
765  Double_t z = tree_neg->GetBranch(zvar.c_str())->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
766  Double_t dx = tree_neg->GetBranch("Dx")->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
767  Double_t dy = tree_neg->GetBranch("Dy")->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
768  Double_t dz = tree_neg->GetBranch("Dz")->GetLeaf(Form("data_%sDisp",posLeaf.c_str()))->GetValue();
769 
770  hDx_neg->Fill(x,y,z,100.0*dx);
771  hDy_neg->Fill(x,y,z,100.0*dy);
772  hDz_neg->Fill(x,y,z,100.0*dz);
773  }
774 
775  for(int ii = 0; ii<eTree_neg->GetEntries(); ii++){
776 
777  eTree_neg->GetEntry(ii);
778  Double_t x = eTree_neg->GetBranch("xpoint")->GetLeaf("data")->GetValue();
779  Double_t y = eTree_neg->GetBranch("ypoint")->GetLeaf("data")->GetValue();
780  Double_t z = eTree_neg->GetBranch("zpoint")->GetLeaf("data")->GetValue();
781  Double_t Ex = eTree_neg->GetBranch("Ex")->GetLeaf("data")->GetValue() / (100000.0*fEfield);
782  Double_t Ey = eTree_neg->GetBranch("Ey")->GetLeaf("data")->GetValue() / (100000.0*fEfield);
783  Double_t Ez = eTree_neg->GetBranch("Ez")->GetLeaf("data")->GetValue() / (100000.0*fEfield);
784 
785  //Fill the histograms
786  hEx_neg->Fill(x,y,z,Ex);
787  hEy_neg->Fill(x,y,z,Ey);
788  hEz_neg->Fill(x,y,z,Ez);
789  }
790 
791  return {hDx_pos, hDy_pos, hDz_pos, hEx_pos, hEy_pos, hEz_pos, hDx_neg, hDy_neg, hDz_neg, hEx_neg, hEy_neg, hEz_neg};
792 
793 }
794 
795 //----------------------------------------------------------------------------
796 /// Provides position offsets using a parametric representation
797 std::vector<double> spacecharge::SpaceChargeProtoDUNE::GetPosOffsetsParametric(double xVal, double yVal, double zVal) const
798 {
799  std::vector<double> thePosOffsetsParametric;
800  double xValNew = TransformX(xVal);
801  double yValNew = TransformY(yVal);
802  double zValNew = TransformZ(zVal);
803  thePosOffsetsParametric.push_back(GetOnePosOffsetParametric(xValNew,yValNew,zValNew,"X"));
804  thePosOffsetsParametric.push_back(GetOnePosOffsetParametric(xValNew,yValNew,zValNew,"Y"));
805  thePosOffsetsParametric.push_back(GetOnePosOffsetParametric(xValNew,yValNew,zValNew,"Z"));
806  return thePosOffsetsParametric;
807 }
808 //----------------------------------------------------------------------------
809 /// Provides one position offset using a parametric representation, for a given
810 /// axis
811 double spacecharge::SpaceChargeProtoDUNE::GetOnePosOffsetParametric(double xValNew, double yValNew, double zValNew, std::string axis) const
812 {
813  double parA[6][7];
814  double parB[6];
815 
816  xValNew -= 1.8;
817  yValNew -= 3.0;
818 
819  for(int j = 0; j < 6; j++)
820  {
821  for(int i = 0; i < 7; i++)
822  parA[j][i] = 0.0;
823 
824  parB[j] = 0.0;
825  }
826 
827  if(axis == "X")
828  {
829  for(int j = 0; j < 7; j++)
830  {
831  parA[0][j] = g1_x[j]->Eval(zValNew);
832  parA[1][j] = g2_x[j]->Eval(zValNew);
833  parA[2][j] = g3_x[j]->Eval(zValNew);
834  parA[3][j] = g4_x[j]->Eval(zValNew);
835  parA[4][j] = g5_x[j]->Eval(zValNew);
836  }
837 
838  f1_x->SetParameters(parA[0]);
839  f2_x->SetParameters(parA[1]);
840  f3_x->SetParameters(parA[2]);
841  f4_x->SetParameters(parA[3]);
842  f5_x->SetParameters(parA[4]);
843  }
844  else if(axis == "Y")
845  {
846  for(int j = 0; j < 6; j++)
847  {
848  parA[0][j] = g1_y[j]->Eval(zValNew);
849  parA[1][j] = g2_y[j]->Eval(zValNew);
850  parA[2][j] = g3_y[j]->Eval(zValNew);
851  parA[3][j] = g4_y[j]->Eval(zValNew);
852  parA[4][j] = g5_y[j]->Eval(zValNew);
853  parA[5][j] = g6_y[j]->Eval(zValNew);
854  }
855 
856  f1_y->SetParameters(parA[0]);
857  f2_y->SetParameters(parA[1]);
858  f3_y->SetParameters(parA[2]);
859  f4_y->SetParameters(parA[3]);
860  f5_y->SetParameters(parA[4]);
861  f6_y->SetParameters(parA[5]);
862  }
863  else if(axis == "Z")
864  {
865  for(int j = 0; j < 5; j++)
866  {
867  parA[0][j] = g1_z[j]->Eval(zValNew);
868  parA[1][j] = g2_z[j]->Eval(zValNew);
869  parA[2][j] = g3_z[j]->Eval(zValNew);
870  parA[3][j] = g4_z[j]->Eval(zValNew);
871  }
872 
873  f1_z->SetParameters(parA[0]);
874  f2_z->SetParameters(parA[1]);
875  f3_z->SetParameters(parA[2]);
876  f4_z->SetParameters(parA[3]);
877  }
878 
879  double aValNew;
880  double bValNew;
881 
882  if(axis == "Y")
883  {
884  aValNew = xValNew;
885  bValNew = yValNew;
886  }
887  else
888  {
889  aValNew = yValNew;
890  bValNew = xValNew;
891  }
892 
893  double offsetValNew = 0.0;
894  if(axis == "X")
895  {
896  parB[0] = f1_x->Eval(aValNew);
897  parB[1] = f2_x->Eval(aValNew);
898  parB[2] = f3_x->Eval(aValNew);
899  parB[3] = f4_x->Eval(aValNew);
900  parB[4] = f5_x->Eval(aValNew);
901 
902  fFinal_x->SetParameters(parB);
903  offsetValNew = 100.0*fFinal_x->Eval(bValNew);
904  }
905  else if(axis == "Y")
906  {
907  parB[0] = f1_y->Eval(aValNew);
908  parB[1] = f2_y->Eval(aValNew);
909  parB[2] = f3_y->Eval(aValNew);
910  parB[3] = f4_y->Eval(aValNew);
911  parB[4] = f5_y->Eval(aValNew);
912  parB[5] = f6_y->Eval(aValNew);
913 
914  fFinal_y->SetParameters(parB);
915  offsetValNew = 100.0*fFinal_y->Eval(bValNew);
916  }
917  else if(axis == "Z")
918  {
919  parB[0] = f1_z->Eval(aValNew);
920  parB[1] = f2_z->Eval(aValNew);
921  parB[2] = f3_z->Eval(aValNew);
922  parB[3] = f4_z->Eval(aValNew);
923 
924  fFinal_z->SetParameters(parB);
925  offsetValNew = 100.0*fFinal_z->Eval(bValNew);
926  }
927 
928  return offsetValNew;
929 }
930 //----------------------------------------------------------------------------
931 /// Primary working method of service that provides E field offsets to be
932 /// used in charge/light yield calculation (e.g.)
934 {
935 
936  std::vector<double> theEfieldOffsets;
937  geo::Point_t point = tmp_point;
938  if(IsTooFarFromBoundaries(point)) {
939  theEfieldOffsets.resize(3,0.0);
940  return { -theEfieldOffsets[0], -theEfieldOffsets[1], -theEfieldOffsets[2] };
941  }
942  if(!IsInsideBoundaries(point)&&!IsTooFarFromBoundaries(point)) point = PretendAtBoundary(point);
943 
944  if ((fRepresentationType=="Voxelized_TH3") || (fRepresentationType == "Splines_TH3")){
945  if (point.X() > 0.) theEfieldOffsets = GetOffsetsVoxel(point, SCEhistograms.at(3), SCEhistograms.at(4), SCEhistograms.at(5), 3, 2);
946  else theEfieldOffsets = GetOffsetsVoxel(point, SCEhistograms.at(9), SCEhistograms.at(10), SCEhistograms.at(11), 3, 1);
947  theEfieldOffsets[0] = -1.0*theEfieldOffsets[0];
948  theEfieldOffsets[1] = -1.0*theEfieldOffsets[1];
949  theEfieldOffsets[2] = -1.0*theEfieldOffsets[2];
950  }else if (fRepresentationType == "Voxelized"){
951  if (point.X() > 0.) theEfieldOffsets = GetOffsetsVoxel(point, SCEhistograms.at(3), SCEhistograms.at(4), SCEhistograms.at(5), 3, 2);
952  else theEfieldOffsets = GetOffsetsVoxel(point, SCEhistograms.at(9), SCEhistograms.at(10), SCEhistograms.at(11), 3, 1);
953  }else if(fRepresentationType == "Parametric") theEfieldOffsets = GetEfieldOffsetsParametric(point.X(), point.Y(), point.Z());
954  else theEfieldOffsets.resize(3,0.0);
955 
956  return { -theEfieldOffsets[0], -theEfieldOffsets[1], -theEfieldOffsets[2] };
957 }
958 //----------------------------------------------------------------------------
959 /// Primary working method of service that provides E field offsets to be
960 /// used in charge/light yield calculation (e.g.) for calibration
962 {
963  std::vector<double> theEfieldOffsets;
964  geo::Point_t point = tmp_point;
965  if(IsTooFarFromBoundaries(point)) {
966  theEfieldOffsets.resize(3,0.0);
967  return { -theEfieldOffsets[0], -theEfieldOffsets[1], -theEfieldOffsets[2] };
968  }
969  if(!IsInsideBoundaries(point)&&!IsTooFarFromBoundaries(point)) point = PretendAtBoundary(point);
970 
971  if ((fRepresentationType == "Voxelized_TH3") || (fRepresentationType == "Splines_TH3")){
972  if ((TPCid == 2 || TPCid == 6 || TPCid == 10)&&point.X()>-20.){
973  if (point.X()<0.) point = {0.00001, point.Y(), point.Z()};
974  theEfieldOffsets = GetOffsetsVoxel(point, CalSCEhistograms.at(3), CalSCEhistograms.at(4), CalSCEhistograms.at(5), 3, 2);
975  }else if ((TPCid == 1 || TPCid == 5 || TPCid == 9)&&point.X()<20.){
976  if (point.X()>0.) point = {-0.00001, point.Y(), point.Z()};
977  theEfieldOffsets = GetOffsetsVoxel(point, CalSCEhistograms.at(9), CalSCEhistograms.at(10), CalSCEhistograms.at(11), 3, 1);
978  } else theEfieldOffsets = {0., 0., 0.};
979  theEfieldOffsets[0] = -1.0*theEfieldOffsets[0];
980  theEfieldOffsets[1] = -1.0*theEfieldOffsets[1];
981  theEfieldOffsets[2] = -1.0*theEfieldOffsets[2];
982  }else if (fRepresentationType == "Voxelized"){
983  if ((TPCid == 2 || TPCid == 6 || TPCid == 10)&&point.X()>-20.){
984  if (point.X()<0.) point = {0.00001, point.Y(), point.Z()};
985  theEfieldOffsets = GetOffsetsVoxel(point, CalSCEhistograms.at(3), CalSCEhistograms.at(4), CalSCEhistograms.at(5), 3, 2);
986  }else if ((TPCid == 1 || TPCid == 5 || TPCid == 9)&&point.X()<20.){
987  if (point.X()>0.) point = {-0.00001, point.Y(), point.Z()};
988  theEfieldOffsets = GetOffsetsVoxel(point, CalSCEhistograms.at(9), CalSCEhistograms.at(10), CalSCEhistograms.at(11), 3, 1);
989  } else theEfieldOffsets = {0., 0., 0.};
990  }else
991  theEfieldOffsets.resize(3,0.0);
992 
993  return { -theEfieldOffsets[0], -theEfieldOffsets[1], -theEfieldOffsets[2] };
994 }
995 
996 //----------------------------------------------------------------------------
997 /// Provides E field offsets using a parametric representation
998 std::vector<double> spacecharge::SpaceChargeProtoDUNE::GetEfieldOffsetsParametric(double xVal, double yVal, double zVal) const
999 {
1000  std::vector<double> theEfieldOffsetsParametric;
1001  double xValNew = TransformX(xVal);
1002  double yValNew = TransformY(yVal);
1003  double zValNew = TransformZ(zVal);
1004  theEfieldOffsetsParametric.push_back(GetOneEfieldOffsetParametric(xValNew,yValNew,zValNew,"X"));
1005  theEfieldOffsetsParametric.push_back(GetOneEfieldOffsetParametric(xValNew,yValNew,zValNew,"Y"));
1006  theEfieldOffsetsParametric.push_back(GetOneEfieldOffsetParametric(xValNew,yValNew,zValNew,"Z"));
1007  return theEfieldOffsetsParametric;
1008 }
1009 //----------------------------------------------------------------------------
1010 /// Provides one E field offset using a parametric representation, for a given
1011 /// axis
1012 double spacecharge::SpaceChargeProtoDUNE::GetOneEfieldOffsetParametric(double xValNew, double yValNew, double zValNew, std::string axis) const
1013 {
1014  xValNew -= 1.8;
1015  yValNew -= 3.0;
1016 
1017  double parA[6][7];
1018  double parB[6];
1019 
1020  for(int j = 0; j < 6; j++)
1021  {
1022  for(int i = 0; i < 7; i++)
1023  parA[j][i] = 0.0;
1024 
1025  parB[j] = 0.0;
1026  }
1027 
1028  if(axis == "X")
1029  {
1030  for(int j = 0; j < 7; j++)
1031  {
1032  parA[0][j] = g1_Ex[j]->Eval(zValNew);
1033  parA[1][j] = g2_Ex[j]->Eval(zValNew);
1034  parA[2][j] = g3_Ex[j]->Eval(zValNew);
1035  parA[3][j] = g4_Ex[j]->Eval(zValNew);
1036  parA[4][j] = g5_Ex[j]->Eval(zValNew);
1037  }
1038 
1039  f1_Ex->SetParameters(parA[0]);
1040  f2_Ex->SetParameters(parA[1]);
1041  f3_Ex->SetParameters(parA[2]);
1042  f4_Ex->SetParameters(parA[3]);
1043  f5_Ex->SetParameters(parA[4]);
1044  }
1045  else if(axis == "Y")
1046  {
1047  for(int j = 0; j < 6; j++)
1048  {
1049  parA[0][j] = g1_Ey[j]->Eval(zValNew);
1050  parA[1][j] = g2_Ey[j]->Eval(zValNew);
1051  parA[2][j] = g3_Ey[j]->Eval(zValNew);
1052  parA[3][j] = g4_Ey[j]->Eval(zValNew);
1053  parA[4][j] = g5_Ey[j]->Eval(zValNew);
1054  parA[5][j] = g6_Ey[j]->Eval(zValNew);
1055  }
1056 
1057  f1_Ey->SetParameters(parA[0]);
1058  f2_Ey->SetParameters(parA[1]);
1059  f3_Ey->SetParameters(parA[2]);
1060  f4_Ey->SetParameters(parA[3]);
1061  f5_Ey->SetParameters(parA[4]);
1062  f6_Ey->SetParameters(parA[5]);
1063  }
1064  else if(axis == "Z")
1065  {
1066  for(int j = 0; j < 5; j++)
1067  {
1068  parA[0][j] = g1_Ez[j]->Eval(zValNew);
1069  parA[1][j] = g2_Ez[j]->Eval(zValNew);
1070  parA[2][j] = g3_Ez[j]->Eval(zValNew);
1071  parA[3][j] = g4_Ez[j]->Eval(zValNew);
1072  }
1073 
1074  f1_Ez->SetParameters(parA[0]);
1075  f2_Ez->SetParameters(parA[1]);
1076  f3_Ez->SetParameters(parA[2]);
1077  f4_Ez->SetParameters(parA[3]);
1078  }
1079 
1080  double aValNew;
1081  double bValNew;
1082 
1083  if(axis == "Y")
1084  {
1085  aValNew = xValNew;
1086  bValNew = yValNew;
1087  }
1088  else
1089  {
1090  aValNew = yValNew;
1091  bValNew = xValNew;
1092  }
1093 
1094  double offsetValNew = 0.0;
1095  if(axis == "X")
1096  {
1097  parB[0] = f1_Ex->Eval(aValNew);
1098  parB[1] = f2_Ex->Eval(aValNew);
1099  parB[2] = f3_Ex->Eval(aValNew);
1100  parB[3] = f4_Ex->Eval(aValNew);
1101  parB[4] = f5_Ex->Eval(aValNew);
1102 
1103  fFinal_Ex->SetParameters(parB);
1104  offsetValNew = fFinal_Ex->Eval(bValNew);
1105  }
1106  else if(axis == "Y")
1107  {
1108  parB[0] = f1_Ey->Eval(aValNew);
1109  parB[1] = f2_Ey->Eval(aValNew);
1110  parB[2] = f3_Ey->Eval(aValNew);
1111  parB[3] = f4_Ey->Eval(aValNew);
1112  parB[4] = f5_Ey->Eval(aValNew);
1113  parB[5] = f6_Ey->Eval(aValNew);
1114 
1115  fFinal_Ey->SetParameters(parB);
1116  offsetValNew = fFinal_Ey->Eval(bValNew);
1117  }
1118  else if(axis == "Z")
1119  {
1120  parB[0] = f1_Ez->Eval(aValNew);
1121  parB[1] = f2_Ez->Eval(aValNew);
1122  parB[2] = f3_Ez->Eval(aValNew);
1123  parB[3] = f4_Ez->Eval(aValNew);
1124 
1125  fFinal_Ez->SetParameters(parB);
1126  offsetValNew = fFinal_Ez->Eval(bValNew);
1127  }
1128 
1129  return offsetValNew;
1130 }
1131 //----------------------------------------------------------------------------
1132 /// Transform X to SCE X coordinate: [0.0,3.6] --> [0.0,3.6]
1134 {
1135  double xValNew;
1136  xValNew = (fabs(xVal)/100.0);
1137  //xValNew -= 1.8;
1138  return xValNew;
1139 }
1140 //----------------------------------------------------------------------------
1141 /// Transform Y to SCE Y coordinate: [0.0,6.08] --> [0.0,6.0]
1143 {
1144  double yValNew;
1145  yValNew = (6.00/6.08)*((yVal+0.2)/100.0);
1146  //yValNew -= 3.0;
1147  return yValNew;
1148 }
1149 //----------------------------------------------------------------------------
1150 /// Transform Z to SCE Z coordinate: [0.0,6.97] --> [0.0,7.2]
1152 {
1153  double zValNew;
1154  zValNew = (7.20/6.97)*((zVal+0.8)/100.0);
1155  return zValNew;
1156 }
1157 //----------------------------------------------------------------------------
1158 /// Check to see if point is inside boundaries of map (allow to go slightly out of range)
1160 {
1161  if((fRepresentationType=="Voxelized_TH3") || (fRepresentationType == "Splines_TH3")){
1162  return !(
1163  (TMath::Abs(point.X()) <= 0.0) || (TMath::Abs(point.X()) >= 360.0)
1164  || (point.Y() <= 5.2) || (point.Y() >= 604.0)
1165  || (point.Z() <= -0.5) || (point.Z() >= 695.3)
1166  );
1167  } else{
1168  return !(
1169  (TMath::Abs(point.X()) <= 0.0) || (TMath::Abs(point.X()) >= 360.0)
1170  || (point.Y() <= -0.2) || (point.Y() >= 607.8)
1171  || (point.Z() <= -0.8) || (point.Z() >= 696.2)
1172  );
1173  }
1174 }
1175 
1177 {
1178  if((fRepresentationType=="Voxelized_TH3") || (fRepresentationType == "Splines_TH3")){
1179  return (
1180  (TMath::Abs(point.X()) < -20.0) || (TMath::Abs(point.X()) >= 360.0)
1181  || (point.Y() < -14.8) || (point.Y() > 624.0)
1182  || (point.Z() < -20.5) || (point.Z() > 715.3)
1183  );
1184  } else {
1185  return (
1186  (TMath::Abs(point.X()) < -20.0) || (TMath::Abs(point.X()) >= 360.0)
1187  || (point.Y() < -20.2) || (point.Y() > 627.8)
1188  || (point.Z() < -20.8) || (point.Z() > 716.2)
1189  );
1190  }
1191 }
1192 
1194 {
1195  double x = point.X(), y = point.Y(), z = point.Z();
1196 
1197  if((fRepresentationType=="Voxelized_TH3") || (fRepresentationType == "Splines_TH3")){
1198 
1199  if (TMath::Abs(point.X()) == 0.0 ) x = -0.00001;
1200  else if (TMath::Abs(point.X()) < 0.00001) x = TMath::Sign(point.X(),1)*0.00001;
1201  else if (TMath::Abs(point.X()) >= 360.0 ) x = TMath::Sign(point.X(),1)*359.99999;
1202 
1203  if (point.Y() <= 5.2) y = 5.20001;
1204  else if (point.Y() >= 604.0) y = 603.99999;
1205 
1206  if (point.Z() <= -0.5) z = -0.49999;
1207  else if (point.Z() >= 695.3) z = 695.29999;
1208 
1209  } else {
1210 
1211  if (TMath::Abs(point.X()) == 0.0) x = -0.00001;
1212  else if (TMath::Abs(point.X()) < 0.0) x = TMath::Sign(point.X(),1)*0.00001;
1213  else if (TMath::Abs(point.X()) >= 360.0) x = TMath::Sign(point.X(),1)*359.99999;
1214 
1215  if (point.Y() <= -0.2) y = -0.19999;
1216  else if (point.Y() >= 607.8) y = 607.79999;
1217 
1218  if (point.Z() <= -0.8) z = -0.79999;
1219  else if (point.Z() >= 696.2) z = 696.19999;
1220 
1221  }
1222  return {x, y, z};
1223 }
1224 
1225 //----------------------------------------------------------------------------
1226 /// Create one spline for later use in SCE map interpolation
1227 TSpline3* spacecharge::SpaceChargeProtoDUNE::MakeSpline(TH3F* spline_hist, int dim1, int dim2_bin, int dim3_bin, int maptype, int driftvol) const
1228 {
1229  TSpline3 *spline = 0;
1230 
1231  std::vector<double> a, b;
1232  if (dim1 == 1) {
1233  for (int x = 1; x <= spline_hist->GetNbinsX(); ++x) {
1234  a.push_back(spline_hist->GetXaxis()->GetBinCenter(x));
1235  b.push_back(spline_hist->GetBinContent(x, dim2_bin, dim3_bin));
1236  }
1237  }
1238  else if (dim1 == 2) {
1239  for(int y = 1; y <= spline_hist->GetNbinsY(); ++y) {
1240  a.push_back(spline_hist->GetYaxis()->GetBinCenter(y));
1241  b.push_back(spline_hist->GetBinContent(dim2_bin, y, dim3_bin));
1242  }
1243  }
1244  else if (dim1 == 3) {
1245  for (int z = 1; z <= spline_hist->GetNbinsZ(); z++) {
1246  a.push_back(spline_hist->GetZaxis()->GetBinCenter(z));
1247  b.push_back(spline_hist->GetBinContent(dim2_bin, dim3_bin, z));
1248  }
1249  }
1250  else {
1251  cet::exception("SpaceChargeProtoDUNE::MakeSpline") << "Unkown dimension " << dim1 << "\n";
1252  }
1253 
1254  if(maptype == 1)
1255  {
1256  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d", dim1, dim2_bin,
1257  dim3_bin, maptype, driftvol), &a[0], &b[0], a.size(),
1258  "b2e2", 0, 0);
1259  spline->SetName(Form("spline_%d_%d_%d_%d_%d", dim1, dim2_bin, dim3_bin,
1260  maptype, driftvol));
1261  }
1262  else if(maptype == 2)
1263  {
1264  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d", dim1, dim2_bin,
1265  dim3_bin, maptype, driftvol), &a[0], &b[0], a.size(),
1266  "b2e2", 0, 0);
1267  spline->SetName(Form("spline_%d_%d_%d_%d_%d", dim1, dim2_bin, dim3_bin,
1268  maptype, driftvol));
1269  }
1270  else if(maptype == 3)
1271  {
1272  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d", dim1, dim2_bin,
1273  dim3_bin, maptype, driftvol), &a[0], &b[0], a.size(),
1274  "b2e2", 0, 0);
1275  spline->SetName(Form("spline_%d_%d_%d_%d_%d", dim1, dim2_bin, dim3_bin,
1276  maptype, driftvol));
1277  }
1278 
1279  /*if(dim1 == 1)
1280  {
1281  double a[19];
1282  double b[19];
1283  for(int x = 1; x <= 19; x++)
1284  {
1285  a[x-1] = spline_hist->GetXaxis()->GetBinCenter(x);
1286  b[x-1] = spline_hist->GetBinContent(x,dim2_bin,dim3_bin);
1287  }
1288 
1289  if(maptype == 1)
1290  {
1291  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol),a,b,19,"b2e2",0,0);
1292  spline->SetName(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol));
1293  }
1294  else if(maptype == 2)
1295  {
1296  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol),a,b,19,"b2e2",0,0);
1297  spline->SetName(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol));
1298  }
1299  else if(maptype == 3)
1300  {
1301  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol),a,b,19,"b2e2",0,0);
1302  spline->SetName(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol));
1303  }
1304  }
1305  else if(dim1 == 2)
1306  {
1307  double a[31];
1308  double b[31];
1309  for(int y = 1; y <= 31; y++)
1310  {
1311  a[y-1] = spline_hist->GetYaxis()->GetBinCenter(y);
1312  b[y-1] = spline_hist->GetBinContent(dim2_bin,y,dim3_bin);
1313  }
1314 
1315  if(maptype == 1)
1316  {
1317  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol),a,b,31,"b2e2",0,0);
1318  spline->SetName(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol));
1319  }
1320  else if(maptype == 2)
1321  {
1322  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol),a,b,31,"b2e2",0,0);
1323  spline->SetName(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol));
1324  }
1325  else if(maptype == 3)
1326  {
1327  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol),a,b,31,"b2e2",0,0);
1328  spline->SetName(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol));
1329  }
1330  }
1331  else if(dim1 == 3)
1332  {
1333  double a[37];
1334  double b[37];
1335  for(int z = 1; z <= 37; z++)
1336  {
1337  a[z-1] = spline_hist->GetZaxis()->GetBinCenter(z);
1338  b[z-1] = spline_hist->GetBinContent(dim2_bin,dim3_bin,z);
1339  }
1340 
1341  if(maptype == 1)
1342  {
1343  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol),a,b,37,"b2e2",0,0);
1344  spline->SetName(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol));
1345  }
1346  else if(maptype == 2)
1347  {
1348  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol),a,b,37,"b2e2",0,0);
1349  spline->SetName(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol));
1350  }
1351  else if(maptype == 3)
1352  {
1353  spline = new TSpline3(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol),a,b,37,"b2e2",0,0);
1354  spline->SetName(Form("spline_%d_%d_%d_%d_%d",dim1,dim2_bin,dim3_bin,maptype,driftvol));
1355  }
1356  }*/
1357 
1358  return spline;
1359 }
1360 
1361 //----------------------------------------------------------------------------
1362 /// Interpolate given SCE map using splines
1363 double spacecharge::SpaceChargeProtoDUNE::InterpolateSplines(TH3F* interp_hist, double xVal, double yVal, double zVal, int dim, int maptype, int driftvol) const
1364 {
1365 
1366  //std::cout << "Interpolating " << interp_hist->GetName() << std::endl;
1367  int bin_x = interp_hist->GetXaxis()->FindBin(xVal);
1368  int bin_y = interp_hist->GetYaxis()->FindBin(yVal);
1369  int bin_z = interp_hist->GetZaxis()->FindBin(zVal);
1370 
1371  int bincenter_x = interp_hist->GetXaxis()->GetBinCenter(bin_x);
1372  int bincenter_y = interp_hist->GetYaxis()->GetBinCenter(bin_y);
1373  int bincenter_z = interp_hist->GetZaxis()->GetBinCenter(bin_z);
1374 
1375  int max_x = interp_hist->GetNbinsX();
1376  int max_y = interp_hist->GetNbinsY();
1377  int max_z = interp_hist->GetNbinsZ();
1378 
1379  int low_x;
1380  int high_x;
1381  if(bin_x <= 1)
1382  {
1383  low_x = 1;
1384  high_x = 2;
1385  }
1386  else if(bin_x >= max_x)
1387  {
1388  low_x = max_x-1;
1389  high_x = max_x;
1390  }
1391  else if(xVal > bincenter_x)
1392  {
1393  low_x = bin_x;
1394  high_x = bin_x+1;
1395  }
1396  else
1397  {
1398  low_x = bin_x-1;
1399  high_x = bin_x;
1400  }
1401 
1402  int low_y;
1403  int high_y;
1404  if(bin_y <= 1)
1405  {
1406  low_y = 1;
1407  high_y = 2;
1408  }
1409  else if(bin_y >= max_y)
1410  {
1411  low_y = max_y-1;
1412  high_y = max_y;
1413  }
1414  else if(yVal > bincenter_y)
1415  {
1416  low_y = bin_y;
1417  high_y = bin_y+1;
1418  }
1419  else
1420  {
1421  low_y = bin_y-1;
1422  high_y = bin_y;
1423  }
1424 
1425  int low_z;
1426  int high_z;
1427  if(bin_z <= 1)
1428  {
1429  low_z = 1;
1430  high_z = 2;
1431  }
1432  else if(bin_z >= max_z)
1433  {
1434  low_z = max_z-1;
1435  high_z = max_z;
1436  }
1437  else if(zVal > bincenter_z)
1438  {
1439  low_z = bin_z;
1440  high_z = bin_z+1;
1441  }
1442  else
1443  {
1444  low_z = bin_z-1;
1445  high_z = bin_z;
1446  }
1447 
1448  double interp_val = 0.0;
1449 
1450  if(dim == 1)
1451  {
1452  double a_1 = interp_hist->GetYaxis()->GetBinCenter(low_y);
1453  double a_2 = interp_hist->GetYaxis()->GetBinCenter(high_y);
1454 
1455  double b_1 = interp_hist->GetZaxis()->GetBinCenter(low_z);
1456  double b_2 = interp_hist->GetZaxis()->GetBinCenter(high_z);
1457 
1458  double f_11 = 0.0;
1459  double f_12 = 0.0;
1460  double f_21 = 0.0;
1461  double f_22 = 0.0;
1462  if(driftvol == 1)
1463  {
1464  if(maptype == 1)
1465  {
1466  f_11 = spline_dx_fwd_neg[low_y-1][low_z-1]->Eval(xVal);
1467  f_12 = spline_dx_fwd_neg[low_y-1][high_z-1]->Eval(xVal);
1468  f_21 = spline_dx_fwd_neg[high_y-1][low_z-1]->Eval(xVal);
1469  f_22 = spline_dx_fwd_neg[high_y-1][high_z-1]->Eval(xVal);
1470  }
1471  else if(maptype == 2)
1472  {
1473  f_11 = spline_dx_bkwd_neg[low_y-1][low_z-1]->Eval(xVal);
1474  f_12 = spline_dx_bkwd_neg[low_y-1][high_z-1]->Eval(xVal);
1475  f_21 = spline_dx_bkwd_neg[high_y-1][low_z-1]->Eval(xVal);
1476  f_22 = spline_dx_bkwd_neg[high_y-1][high_z-1]->Eval(xVal);
1477  }
1478  else if(maptype == 3)
1479  {
1480  f_11 = spline_dEx_neg[low_y-1][low_z-1]->Eval(xVal);
1481  f_12 = spline_dEx_neg[low_y-1][high_z-1]->Eval(xVal);
1482  f_21 = spline_dEx_neg[high_y-1][low_z-1]->Eval(xVal);
1483  f_22 = spline_dEx_neg[high_y-1][high_z-1]->Eval(xVal);
1484  }
1485  }
1486  else if(driftvol == 2)
1487  {
1488  if(maptype == 1)
1489  {
1490  f_11 = spline_dx_fwd_pos[low_y-1][low_z-1]->Eval(xVal);
1491  f_12 = spline_dx_fwd_pos[low_y-1][high_z-1]->Eval(xVal);
1492  f_21 = spline_dx_fwd_pos[high_y-1][low_z-1]->Eval(xVal);
1493  f_22 = spline_dx_fwd_pos[high_y-1][high_z-1]->Eval(xVal);
1494  }
1495  else if(maptype == 2)
1496  {
1497  f_11 = spline_dx_bkwd_pos[low_y-1][low_z-1]->Eval(xVal);
1498  f_12 = spline_dx_bkwd_pos[low_y-1][high_z-1]->Eval(xVal);
1499  f_21 = spline_dx_bkwd_pos[high_y-1][low_z-1]->Eval(xVal);
1500  f_22 = spline_dx_bkwd_pos[high_y-1][high_z-1]->Eval(xVal);
1501  }
1502  else if(maptype == 3)
1503  {
1504  f_11 = spline_dEx_pos[low_y-1][low_z-1]->Eval(xVal);
1505  f_12 = spline_dEx_pos[low_y-1][high_z-1]->Eval(xVal);
1506  f_21 = spline_dEx_pos[high_y-1][low_z-1]->Eval(xVal);
1507  f_22 = spline_dEx_pos[high_y-1][high_z-1]->Eval(xVal);
1508  }
1509  }
1510 
1511  interp_val = (f_11*(a_2-yVal)*(b_2-zVal) + f_21*(yVal-a_1)*(b_2-zVal) + f_12*(a_2-yVal)*(zVal-b_1) + f_22*(yVal-a_1)*(zVal-b_1))/((a_2-a_1)*(b_2-b_1));
1512  }
1513  else if(dim == 2)
1514  {
1515  double a_1 = interp_hist->GetXaxis()->GetBinCenter(low_x);
1516  double a_2 = interp_hist->GetXaxis()->GetBinCenter(high_x);
1517 
1518  double b_1 = interp_hist->GetZaxis()->GetBinCenter(low_z);
1519  double b_2 = interp_hist->GetZaxis()->GetBinCenter(high_z);
1520 
1521  double f_11 = 0.0;
1522  double f_12 = 0.0;
1523  double f_21 = 0.0;
1524  double f_22 = 0.0;
1525  if(driftvol == 1)
1526  {
1527  if(maptype == 1)
1528  {
1529  f_11 = spline_dy_fwd_neg[low_x-1][low_z-1]->Eval(yVal);
1530  f_12 = spline_dy_fwd_neg[low_x-1][high_z-1]->Eval(yVal);
1531  f_21 = spline_dy_fwd_neg[high_x-1][low_z-1]->Eval(yVal);
1532  f_22 = spline_dy_fwd_neg[high_x-1][high_z-1]->Eval(yVal);
1533  }
1534  else if(maptype == 2)
1535  {
1536  f_11 = spline_dy_bkwd_neg[low_x-1][low_z-1]->Eval(yVal);
1537  f_12 = spline_dy_bkwd_neg[low_x-1][high_z-1]->Eval(yVal);
1538  f_21 = spline_dy_bkwd_neg[high_x-1][low_z-1]->Eval(yVal);
1539  f_22 = spline_dy_bkwd_neg[high_x-1][high_z-1]->Eval(yVal);
1540  }
1541  else if(maptype == 3)
1542  {
1543  f_11 = spline_dEy_neg[low_x-1][low_z-1]->Eval(yVal);
1544  f_12 = spline_dEy_neg[low_x-1][high_z-1]->Eval(yVal);
1545  f_21 = spline_dEy_neg[high_x-1][low_z-1]->Eval(yVal);
1546  f_22 = spline_dEy_neg[high_x-1][high_z-1]->Eval(yVal);
1547  }
1548  }
1549  else if(driftvol == 2)
1550  {
1551  if(maptype == 1)
1552  {
1553  f_11 = spline_dy_fwd_pos[low_x-1][low_z-1]->Eval(yVal);
1554  f_12 = spline_dy_fwd_pos[low_x-1][high_z-1]->Eval(yVal);
1555  f_21 = spline_dy_fwd_pos[high_x-1][low_z-1]->Eval(yVal);
1556  f_22 = spline_dy_fwd_pos[high_x-1][high_z-1]->Eval(yVal);
1557  }
1558  else if(maptype == 2)
1559  {
1560  f_11 = spline_dy_bkwd_pos[low_x-1][low_z-1]->Eval(yVal);
1561  f_12 = spline_dy_bkwd_pos[low_x-1][high_z-1]->Eval(yVal);
1562  f_21 = spline_dy_bkwd_pos[high_x-1][low_z-1]->Eval(yVal);
1563  f_22 = spline_dy_bkwd_pos[high_x-1][high_z-1]->Eval(yVal);
1564  }
1565  else if(maptype == 3)
1566  {
1567  f_11 = spline_dEy_pos[low_x-1][low_z-1]->Eval(yVal);
1568  f_12 = spline_dEy_pos[low_x-1][high_z-1]->Eval(yVal);
1569  f_21 = spline_dEy_pos[high_x-1][low_z-1]->Eval(yVal);
1570  f_22 = spline_dEy_pos[high_x-1][high_z-1]->Eval(yVal);
1571  }
1572  }
1573 
1574  interp_val = (f_11*(a_2-xVal)*(b_2-zVal) + f_21*(xVal-a_1)*(b_2-zVal) + f_12*(a_2-xVal)*(zVal-b_1) + f_22*(xVal-a_1)*(zVal-b_1))/((a_2-a_1)*(b_2-b_1));
1575  }
1576  else if(dim == 3)
1577  {
1578  double a_1 = interp_hist->GetXaxis()->GetBinCenter(low_x);
1579  double a_2 = interp_hist->GetXaxis()->GetBinCenter(high_x);
1580 
1581  double b_1 = interp_hist->GetYaxis()->GetBinCenter(low_y);
1582  double b_2 = interp_hist->GetYaxis()->GetBinCenter(high_y);
1583 
1584  double f_11 = 0.0;
1585  double f_12 = 0.0;
1586  double f_21 = 0.0;
1587  double f_22 = 0.0;
1588  if(driftvol == 1)
1589  {
1590  if(maptype == 1)
1591  {
1592  f_11 = spline_dz_fwd_neg[low_x-1][low_y-1]->Eval(zVal);
1593  f_12 = spline_dz_fwd_neg[low_x-1][high_y-1]->Eval(zVal);
1594  f_21 = spline_dz_fwd_neg[high_x-1][low_y-1]->Eval(zVal);
1595  f_22 = spline_dz_fwd_neg[high_x-1][high_y-1]->Eval(zVal);
1596  }
1597  else if(maptype == 2)
1598  {
1599  f_11 = spline_dz_bkwd_neg[low_x-1][low_y-1]->Eval(zVal);
1600  f_12 = spline_dz_bkwd_neg[low_x-1][high_y-1]->Eval(zVal);
1601  f_21 = spline_dz_bkwd_neg[high_x-1][low_y-1]->Eval(zVal);
1602  f_22 = spline_dz_bkwd_neg[high_x-1][high_y-1]->Eval(zVal);
1603  }
1604  else if(maptype == 3)
1605  {
1606  f_11 = spline_dEz_neg[low_x-1][low_y-1]->Eval(zVal);
1607  f_12 = spline_dEz_neg[low_x-1][high_y-1]->Eval(zVal);
1608  f_21 = spline_dEz_neg[high_x-1][low_y-1]->Eval(zVal);
1609  f_22 = spline_dEz_neg[high_x-1][high_y-1]->Eval(zVal);
1610  }
1611  }
1612  else if(driftvol == 2)
1613  {
1614  if(maptype == 1)
1615  {
1616  f_11 = spline_dz_fwd_pos[low_x-1][low_y-1]->Eval(zVal);
1617  f_12 = spline_dz_fwd_pos[low_x-1][high_y-1]->Eval(zVal);
1618  f_21 = spline_dz_fwd_pos[high_x-1][low_y-1]->Eval(zVal);
1619  f_22 = spline_dz_fwd_pos[high_x-1][high_y-1]->Eval(zVal);
1620  }
1621  else if(maptype == 2)
1622  {
1623  f_11 = spline_dz_bkwd_pos[low_x-1][low_y-1]->Eval(zVal);
1624  f_12 = spline_dz_bkwd_pos[low_x-1][high_y-1]->Eval(zVal);
1625  f_21 = spline_dz_bkwd_pos[high_x-1][low_y-1]->Eval(zVal);
1626  f_22 = spline_dz_bkwd_pos[high_x-1][high_y-1]->Eval(zVal);
1627  }
1628  else if(maptype == 3)
1629  {
1630  f_11 = spline_dEz_pos[low_x-1][low_y-1]->Eval(zVal);
1631  f_12 = spline_dEz_pos[low_x-1][high_y-1]->Eval(zVal);
1632  f_21 = spline_dEz_pos[high_x-1][low_y-1]->Eval(zVal);
1633  f_22 = spline_dEz_pos[high_x-1][high_y-1]->Eval(zVal);
1634  }
1635  }
1636 
1637  interp_val = (f_11*(a_2-xVal)*(b_2-yVal) + f_21*(xVal-a_1)*(b_2-yVal) + f_12*(a_2-xVal)*(yVal-b_1) + f_22*(xVal-a_1)*(yVal-b_1))/((a_2-a_1)*(b_2-b_1));
1638  }
1639 
1640  return interp_val;
1641 }
1642 
1643 
1645 {
1646  double z = point.Z();
1647  double offset[3] = {0,0,0};
1648 
1649  for (size_t i=0; i<fEnableElectronDiverterDistortions.size(); ++i)
1650  {
1651  if (!fEnableElectronDiverterDistortions.at(i)) continue;
1652  if (point.X()>0) continue;
1653  if (z>fEDChargeLossZLow.at(i) && z<fEDChargeLossZHigh.at(i))
1654  {
1655  offset[0] = 2E9;
1656  offset[1] = 2E9;
1657  offset[2] = 2E9;
1658  }
1659  else
1660  {
1661  double zdiff = z - fEDZCenter.at(i);
1662  double zexp = TMath::Exp( -TMath::Sq(zdiff/fEDs.at(i)) );
1663  offset[2] += fEDBZPosOffs.at(i) * zdiff * zexp;
1664 
1665  // the timing offsets need to be computed after the z shift
1666  double zdiffc = zdiff + offset[2];
1667  double zexpc = TMath::Exp( -TMath::Sq(zdiffc/fEDs.at(i)) );
1668  offset[0] += fEDAXPosOffs.at(i) * zexpc;
1669  }
1670  }
1671  return {offset[0], offset[1], offset[2]};
1672 }
std::vector< std::vector< TSpline3 * > > spline_dy_bkwd_pos
std::vector< std::vector< TSpline3 * > > spline_dEz_neg
geo::Vector_t GetCalEfieldOffsets(geo::Point_t const &point, int const &TPCid) const override
Format
Definition: utils.h:7
std::vector< std::vector< TSpline3 * > > spline_dz_fwd_neg
std::vector< std::vector< TSpline3 * > > spline_dEx_neg
double GetOnePosOffsetParametric(double xVal, double yVal, double zVal, std::string axis) const
std::string string
Definition: nybbler.cc:12
std::vector< std::vector< TSpline3 * > > spline_dy_fwd_neg
std::vector< std::vector< TSpline3 * > > spline_dx_bkwd_neg
std::vector< std::vector< TSpline3 * > > spline_dy_bkwd_neg
double TransformY(double yVal) const
Transform Y to SCE Y coordinate: [0.0,6.08] –> [0.0,6.0].
double InterpolateSplines(TH3F *interp_hist, double xVal, double yVal, double zVal, int dim, int maptype, int driftvol) const
Interpolate given SCE map using splines.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
std::vector< std::vector< TSpline3 * > > spline_dEy_neg
std::vector< double > GetOffsetsVoxel(geo::Point_t const &point, TH3F *hX, TH3F *hY, TH3F *hZ, int maptype, int driftvol) const
Provides position offsets using voxelized interpolation.
TSpline3 * MakeSpline(TH3F *spline_hist, int dim1, int dim2_bin, int dim3_bin, int maptype, int driftvol) const
Create one spline for later use in SCE map interpolation.
geo::Vector_t GetPosOffsets(geo::Point_t const &point) const override
geo::Vector_t ElectronDiverterPosOffsets(geo::Point_t const &point) const
std::vector< std::vector< TSpline3 * > > spline_dEx_pos
double Efield(unsigned int planegap=0) const
kV/cm
geo::Vector_t GetEfieldOffsets(geo::Point_t const &point) const override
bool EnableCalEfieldSCE() const override
Return boolean indicating whether or not to apply SCE corrections.
std::vector< std::vector< TSpline3 * > > spline_dx_bkwd_pos
geo::Vector_t GetCalPosOffsets(geo::Point_t const &point, int const &TPCid) const override
std::vector< std::vector< TSpline3 * > > spline_dz_bkwd_pos
std::vector< std::vector< TSpline3 * > > spline_dz_fwd_pos
string infile
bool Configure(fhicl::ParameterSet const &pset, detinfo::DetectorPropertiesData const &)
const double a
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::vector< std::vector< TSpline3 * > > spline_dEz_pos
bool IsTooFarFromBoundaries(geo::Point_t const &point) const
bool EnableCalSpatialSCE() const override
Return boolean indicating whether or not to apply SCE corrections.
std::vector< bool > fEnableElectronDiverterDistortions
std::vector< std::vector< TSpline3 * > > spline_dx_fwd_pos
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
std::vector< std::vector< TSpline3 * > > spline_dy_fwd_pos
bool IsInsideBoundaries(geo::Point_t const &point) const
Check to see if point is inside boundaries of map (allow to go slightly out of range) ...
double GetOneEfieldOffsetParametric(double xVal, double yVal, double zVal, std::string axis) const
std::vector< std::vector< TSpline3 * > > spline_dx_fwd_neg
SpaceChargeProtoDUNE(fhicl::ParameterSet const &pset)
std::string find_file(std::string const &filename) const
Definition: search_path.cc:96
double TransformX(double xVal) const
Transform X to SCE X coordinate: [0.0,3.6] –> [0.0,3.6].
static bool * b
Definition: config.cpp:1043
list x
Definition: train.py:276
geo::Point_t PretendAtBoundary(geo::Point_t const &point) const
std::vector< std::vector< TSpline3 * > > spline_dz_bkwd_neg
std::vector< std::vector< TSpline3 * > > spline_dEy_pos
double TransformZ(double zVal) const
Transform Z to SCE Z coordinate: [0.0,6.97] –> [0.0,7.2].
std::vector< double > GetEfieldOffsetsParametric(double xVal, double yVal, double zVal) const
Provides E field offsets using a parametric representation.
std::vector< TH3F * > Build_TH3(TTree *tree_pos, TTree *eTree_pos, TTree *tree_neg, TTree *eTree_neg, std::string xvar, std::string yvar, std::string zvar, std::string posLeaf) const
Build 3d histograms for voxelized interpolation.
std::vector< double > GetPosOffsetsParametric(double xVal, double yVal, double zVal) const
Provides position offsets using a parametric representation.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
std::vector< double > fEDChargeLossZHigh