SpaceChargeProtoDUNE.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file SpaceChargeProtoDUNE.h
3 //
4 // \brief header of class for storing/accessing space charge distortions for ProtoDUNE
5 //
6 // \author mrmooney@bnl.gov
7 //
8 ////////////////////////////////////////////////////////////////////////
9 #ifndef SPACECHARGE_SPACECHARGEPROTODUNE_H
10 #define SPACECHARGE_SPACECHARGEPROTODUNE_H
11 // LArSoft libraries
15 // FHiCL libraries
16 #include "fhiclcpp/ParameterSet.h"
17 // ROOT includes
18 #include "TGraph.h"
19 #include "TF1.h"
20 #include "TFile.h"
21 #include "TH3.h"
22 #include "TTree.h"
23 #include "TLeaf.h"
24 #include "TSpline.h"
25 // C/C++ standard libraries
26 #include <string>
27 #include <vector>
28 namespace spacecharge {
30 
31  public:
32  explicit SpaceChargeProtoDUNE(fhicl::ParameterSet const& pset);
34  virtual ~SpaceChargeProtoDUNE() = default;
35 
37  bool Update(uint64_t ts=0);
38 
39  bool EnableSimSpatialSCE() const override;
40  bool EnableSimEfieldSCE() const override;
41  bool EnableCalSpatialSCE() const override;
42  bool EnableCalEfieldSCE() const override;
43 
44  bool EnableCorrSCE() const override {return (EnableCalSpatialSCE()||EnableCalEfieldSCE()) ;}
45 
46  geo::Vector_t GetPosOffsets(geo::Point_t const& point) const override;
47  geo::Vector_t GetEfieldOffsets(geo::Point_t const& point) const override;
48  geo::Vector_t GetCalPosOffsets(geo::Point_t const& point, int const& TPCid) const override;
49  geo::Vector_t GetCalEfieldOffsets(geo::Point_t const& point, int const& TPCid) const override;
50 
51  private:
52  protected:
53 
54  std::vector<double> GetOffsetsVoxel(geo::Point_t const& point, TH3F* hX, TH3F* hY, TH3F* hZ, int maptype, int driftvol) const;
55  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;
56  std::vector<TH3F*> SCEhistograms = std::vector<TH3F*>(12); //Histograms are Dx, Dy, Dz, dEx/E0, dEy/E0, dEz/E0 (positive; repeat for negative)
57  std::vector<TH3F*> CalSCEhistograms = std::vector<TH3F*>(12);
58 
59  std::vector<double> GetPosOffsetsParametric(double xVal, double yVal, double zVal) const;
60  double GetOnePosOffsetParametric(double xVal, double yVal, double zVal, std::string axis) const;
61  std::vector<double> GetEfieldOffsetsParametric(double xVal, double yVal, double zVal) const;
62  double GetOneEfieldOffsetParametric(double xVal, double yVal, double zVal, std::string axis) const;
63 
64  double TransformX(double xVal) const;
65  double TransformY(double yVal) const;
66  double TransformZ(double zVal) const;
67  bool IsInsideBoundaries(geo::Point_t const& point) const;
68  bool IsTooFarFromBoundaries(geo::Point_t const& point) const;
69  geo::Point_t PretendAtBoundary(geo::Point_t const& point) const;
70 
73  std::vector<double> fEDZCenter;
74  std::vector<double> fEDAXPosOffs;
75  std::vector<double> fEDBZPosOffs;
76  std::vector<double> fEDs;
77  std::vector<double> fEDChargeLossZLow;
78  std::vector<double> fEDChargeLossZHigh;
79 
80  TSpline3* MakeSpline(TH3F* spline_hist, int dim1, int dim2_bin, int dim3_bin, int maptype, int driftvol) const;
81  double InterpolateSplines(TH3F* interp_hist, double xVal, double yVal, double zVal, int dim, int maptype, int driftvol) const;
82 
88 
89  double fEfield;
90 
94 
95  TGraph **g1_x = new TGraph*[7];
96  TGraph **g2_x = new TGraph*[7];
97  TGraph **g3_x = new TGraph*[7];
98  TGraph **g4_x = new TGraph*[7];
99  TGraph **g5_x = new TGraph*[7];
100 
101  TGraph **g1_y = new TGraph*[7];
102  TGraph **g2_y = new TGraph*[7];
103  TGraph **g3_y = new TGraph*[7];
104  TGraph **g4_y = new TGraph*[7];
105  TGraph **g5_y = new TGraph*[7];
106  TGraph **g6_y = new TGraph*[7];
107 
108  TGraph **g1_z = new TGraph*[7];
109  TGraph **g2_z = new TGraph*[7];
110  TGraph **g3_z = new TGraph*[7];
111  TGraph **g4_z = new TGraph*[7];
112 
113  TF1 *f1_x = new TF1("f1_x","pol6");
114  TF1 *f2_x = new TF1("f2_x","pol6");
115  TF1 *f3_x = new TF1("f3_x","pol6");
116  TF1 *f4_x = new TF1("f4_x","pol6");
117  TF1 *f5_x = new TF1("f5_x","pol6");
118  TF1 *fFinal_x = new TF1("fFinal_x","pol4");
119 
120  TF1 *f1_y = new TF1("f1_y","pol5");
121  TF1 *f2_y = new TF1("f2_y","pol5");
122  TF1 *f3_y = new TF1("f3_y","pol5");
123  TF1 *f4_y = new TF1("f4_y","pol5");
124  TF1 *f5_y = new TF1("f5_y","pol5");
125  TF1 *f6_y = new TF1("f6_y","pol5");
126  TF1 *fFinal_y = new TF1("fFinal_y","pol5");
127 
128  TF1 *f1_z = new TF1("f1_z","pol4");
129  TF1 *f2_z = new TF1("f2_z","pol4");
130  TF1 *f3_z = new TF1("f3_z","pol4");
131  TF1 *f4_z = new TF1("f4_z","pol4");
132  TF1 *fFinal_z = new TF1("fFinal_z","pol3");
133  TGraph **g1_Ex = new TGraph*[7];
134  TGraph **g2_Ex = new TGraph*[7];
135  TGraph **g3_Ex = new TGraph*[7];
136  TGraph **g4_Ex = new TGraph*[7];
137  TGraph **g5_Ex = new TGraph*[7];
138 
139  TGraph **g1_Ey = new TGraph*[7];
140  TGraph **g2_Ey = new TGraph*[7];
141  TGraph **g3_Ey = new TGraph*[7];
142  TGraph **g4_Ey = new TGraph*[7];
143  TGraph **g5_Ey = new TGraph*[7];
144  TGraph **g6_Ey = new TGraph*[7];
145 
146  TGraph **g1_Ez = new TGraph*[7];
147  TGraph **g2_Ez = new TGraph*[7];
148  TGraph **g3_Ez = new TGraph*[7];
149  TGraph **g4_Ez = new TGraph*[7];
150 
151  TF1 *f1_Ex = new TF1("f1_Ex","pol6");
152  TF1 *f2_Ex = new TF1("f2_Ex","pol6");
153  TF1 *f3_Ex = new TF1("f3_Ex","pol6");
154  TF1 *f4_Ex = new TF1("f4_Ex","pol6");
155  TF1 *f5_Ex = new TF1("f5_Ex","pol6");
156  TF1 *fFinal_Ex = new TF1("fFinal_Ex","pol4");
157 
158  TF1 *f1_Ey = new TF1("f1_Ey","pol5");
159  TF1 *f2_Ey = new TF1("f2_Ey","pol5");
160  TF1 *f3_Ey = new TF1("f3_Ey","pol5");
161  TF1 *f4_Ey = new TF1("f4_Ey","pol5");
162  TF1 *f5_Ey = new TF1("f5_Ey","pol5");
163  TF1 *f6_Ey = new TF1("f6_Ey","pol5");
164  TF1 *fFinal_Ey = new TF1("fFinal_Ey","pol5");
165 
166  TF1 *f1_Ez = new TF1("f1_Ez","pol4");
167  TF1 *f2_Ez = new TF1("f2_Ez","pol4");
168  TF1 *f3_Ez = new TF1("f3_Ez","pol4");
169  TF1 *f4_Ez = new TF1("f4_Ez","pol4");
170  TF1 *fFinal_Ez = new TF1("fFinal_Ez","pol3");
171 
172  std::vector<std::vector<TSpline3*>> spline_dx_fwd_neg;
173  std::vector<std::vector<TSpline3*>> spline_dy_fwd_neg;
174  std::vector<std::vector<TSpline3*>> spline_dz_fwd_neg;
175 
176  std::vector<std::vector<TSpline3*>> spline_dx_bkwd_neg;
177  std::vector<std::vector<TSpline3*>> spline_dy_bkwd_neg;
178  std::vector<std::vector<TSpline3*>> spline_dz_bkwd_neg;
179 
180  std::vector<std::vector<TSpline3*>> spline_dEx_neg;
181  std::vector<std::vector<TSpline3*>> spline_dEy_neg;
182  std::vector<std::vector<TSpline3*>> spline_dEz_neg;
183 
184  std::vector<std::vector<TSpline3*>> spline_dx_fwd_pos;
185  std::vector<std::vector<TSpline3*>> spline_dy_fwd_pos;
186  std::vector<std::vector<TSpline3*>> spline_dz_fwd_pos;
187 
188  std::vector<std::vector<TSpline3*>> spline_dx_bkwd_pos;
189  std::vector<std::vector<TSpline3*>> spline_dy_bkwd_pos;
190  std::vector<std::vector<TSpline3*>> spline_dz_bkwd_pos;
191 
192  std::vector<std::vector<TSpline3*>> spline_dEx_pos;
193  std::vector<std::vector<TSpline3*>> spline_dEy_pos;
194  std::vector<std::vector<TSpline3*>> spline_dEz_pos;
195 
196  //TSpline3 *spline_dx_fwd_neg[31][37];
197  //TSpline3 *spline_dy_fwd_neg[19][37];
198  //TSpline3 *spline_dz_fwd_neg[19][31];
199 
200  //TSpline3 *spline_dx_bkwd_neg[31][37];
201  //TSpline3 *spline_dy_bkwd_neg[19][37];
202  //TSpline3 *spline_dz_bkwd_neg[19][31];
203 
204  //TSpline3 *spline_dEx_neg[31][37];
205  //TSpline3 *spline_dEy_neg[19][37];
206  //TSpline3 *spline_dEz_neg[19][31];
207 
208  //TSpline3 *spline_dx_fwd_pos[31][37];
209  //TSpline3 *spline_dy_fwd_pos[19][37];
210  //TSpline3 *spline_dz_fwd_pos[19][31];
211 
212  //TSpline3 *spline_dx_bkwd_pos[31][37];
213  //TSpline3 *spline_dy_bkwd_pos[19][37];
214  //TSpline3 *spline_dz_bkwd_pos[19][31];
215 
216  //TSpline3 *spline_dEx_pos[31][37];
217  //TSpline3 *spline_dEy_pos[19][37];
218  //TSpline3 *spline_dEz_pos[19][31];
219 
220  }; // class SpaceChargeProtoDUNE
221 } //namespace spacecharge
222 #endif // SPACECHARGE_SPACECHARGEPROTODUNE_H
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
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
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
bool Configure(fhicl::ParameterSet const &pset, detinfo::DetectorPropertiesData const &)
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
virtual ~SpaceChargeProtoDUNE()=default
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)
double TransformX(double xVal) const
Transform X to SCE X coordinate: [0.0,3.6] –> [0.0,3.6].
Definitions of geometry vector data types.
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.
std::vector< double > fEDChargeLossZHigh