17 #include "cetlib_except/exception.h"
26 fEnableSimSpatialSCE = pset.get<
bool>(
"EnableSimSpatialSCE");
27 fEnableSimEfieldSCE = pset.get<
bool>(
"EnableSimEfieldSCE");
29 fEnableCalSpatialSCE = pset.get<
bool>(
"EnableCalSpatialSCE");
30 fEnableCalEfieldSCE = pset.get<
bool>(
"EnableCalEfieldSCE");
32 std::cout <<
"Configuring SpaceCharge..." << std::endl;
34 if((fEnableSimSpatialSCE ==
true) || (fEnableSimEfieldSCE ==
true)){
35 fRepresentationType = pset.get<std::string>(
"RepresentationType");
36 fInputFilename = pset.get<std::string>(
"InputFilename");
39 cet::search_path sp(
"FW_SEARCH_PATH");
40 sp.find_file(fInputFilename, fname);
42 std::unique_ptr<TFile> infile(
new TFile(fname.c_str(),
"READ"));
43 if(!infile->IsOpen()){
44 throw cet::exception(
"SpaceChargeICARUS") <<
"Could not find the space charge input file '" << fInputFilename <<
"'!\n";
47 if(fRepresentationType ==
"Voxelized_TH3"){
48 std::cout <<
"begin loading voxelized TH3s..." << std::endl;
51 TH3F* hTrueFwdX = (TH3F*) infile->Get(
"TrueFwd_Displacement_X");
52 TH3F* hTrueFwdY = (TH3F*) infile->Get(
"TrueFwd_Displacement_Y");
53 TH3F* hTrueFwdZ = (TH3F*) infile->Get(
"TrueFwd_Displacement_Z");
54 TH3F* hTrueBkwdX = (TH3F*) infile->Get(
"TrueBkwd_Displacement_X");
55 TH3F* hTrueBkwdY = (TH3F*) infile->Get(
"TrueBkwd_Displacement_Y");
56 TH3F* hTrueBkwdZ = (TH3F*) infile->Get(
"TrueBkwd_Displacement_Z");
57 TH3F* hTrueEFieldX = (TH3F*) infile->Get(
"True_ElecField_X");
58 TH3F* hTrueEFieldY = (TH3F*) infile->Get(
"True_ElecField_Y");
59 TH3F* hTrueEFieldZ = (TH3F*) infile->Get(
"True_ElecField_Z");
65 hTrueFwdX->SetDirectory(0);
66 hTrueFwdY->SetDirectory(0);
67 hTrueFwdZ->SetDirectory(0);
68 hTrueBkwdX->SetDirectory(0);
69 hTrueBkwdY->SetDirectory(0);
70 hTrueBkwdZ->SetDirectory(0);
71 hTrueEFieldX->SetDirectory(0);
72 hTrueEFieldY->SetDirectory(0);
73 hTrueEFieldZ->SetDirectory(0);
76 SCEhistograms = {hTrueFwdX, hTrueFwdY, hTrueFwdZ,
77 hTrueBkwdX, hTrueBkwdY, hTrueBkwdZ,
78 hTrueEFieldX, hTrueEFieldY, hTrueEFieldZ};
81 std::cout <<
"...finished loading TH3s" << std::endl;
85 if(fEnableCorrSCE ==
true){
93 if (ts == 0){
return false;}
100 return fEnableSimSpatialSCE;
106 return fEnableSimEfieldSCE;
112 return fEnableCalSpatialSCE;
118 return fEnableCalEfieldSCE;
128 std::vector<double> thePosOffsets;
129 double xx=point.X(), yy=point.Y(), zz=point.Z();
130 double cryo_corr=1., tpc_corr=1.;
132 if(fRepresentationType ==
"Voxelized_TH3"){
152 fixCoords(&xx, &yy, &zz);
153 double offset_x=0., offset_y=0., offset_z=0.;
154 offset_x = tpc_corr*cryo_corr*SCEhistograms.at(0)->Interpolate(xx,yy,zz);
155 offset_y = SCEhistograms.at(1)->Interpolate(xx,yy,zz);
156 offset_z = SCEhistograms.at(2)->Interpolate(xx,yy,zz);
157 thePosOffsets = {offset_x, offset_y, offset_z};
159 thePosOffsets.resize(3, 0.0);
162 return { thePosOffsets[0], thePosOffsets[1], thePosOffsets[2] };
168 std::vector<double> theCalPosOffsets;
170 double xx=point.X(), yy=point.Y(), zz=point.Z();
173 if(fRepresentationType ==
"Voxelized_TH3"){
182 bool x_is_pos = xx > 0;
184 fixCoords(&xx, &yy, &zz);
189 if (x_is_pos && (tpcid == 0 || tpcid == 1) && xx > 210.14 ) { xx = 210.14; }
190 if (x_is_pos && (tpcid == 2 || tpcid == 3) && xx < 210.29 ) { xx = 210.29; }
192 if (!x_is_pos && (tpcid == 2 || tpcid == 3) && xx > 210.14 ) { xx = 210.14; }
193 if (!x_is_pos && (tpcid == 0 || tpcid == 1) && xx < 210.29 ) { xx = 210.29; }
195 double offset_x=0., offset_y=0., offset_z=0.;
196 offset_x = corr*SCEhistograms.at(3)->Interpolate(xx,yy,zz);
197 offset_y = SCEhistograms.at(4)->Interpolate(xx,yy,zz);
198 offset_z = SCEhistograms.at(5)->Interpolate(xx,yy,zz);
199 theCalPosOffsets = {offset_x, offset_y, offset_z};
201 theCalPosOffsets.resize(3, 0.0);
204 return { theCalPosOffsets[0], theCalPosOffsets[1], theCalPosOffsets[2] };
209 return GetCalPosOffsets(point, TPCid.
TPC);
217 std::vector<double> theEfieldOffsets;
218 double xx=point.X(), yy=point.Y(), zz=point.Z();
219 double offset_x=0., offset_y=0., offset_z=0.;
221 if(fRepresentationType ==
"Voxelized_TH3"){
224 fixCoords(&xx, &yy, &zz);
225 offset_x = SCEhistograms.at(6)->Interpolate(xx, yy, zz);
226 offset_y = SCEhistograms.at(7)->Interpolate(xx, yy, zz);
227 offset_z = SCEhistograms.at(8)->Interpolate(xx, yy, zz);
229 theEfieldOffsets = {offset_x, offset_y, offset_z};
231 return { theEfieldOffsets[0], theEfieldOffsets[1], theEfieldOffsets[2] };
237 if(*xx<61.94){*xx=61.94;}
238 if(*xx>358.489){*xx=358.489;}
239 if(*yy<-181.86){*yy=-181.86;}
240 if(*yy>134.96){*yy=134.96;}
241 if(*zz<-894.951){*zz=-894.951;}
242 if(*zz>894.9509){*zz=894.9509;}
bool EnableCalEfieldSCE() const override
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
void fixCoords(double *xx, double *yy, double *zz) const
geo::Vector_t GetPosOffsets(geo::Point_t const &point) const override
geo::Vector_t GetEfieldOffsets(geo::Point_t const &point) const override
SpaceChargeICARUS(fhicl::ParameterSet const &pset)
bool EnableSimEfieldSCE() const override
The data type to uniquely identify a TPC.
bool EnableCalSpatialSCE() const override
bool EnableSimSpatialSCE() const override
bool Update(uint64_t ts=0)
geo::Vector_t GetCalPosOffsets(geo::Point_t const &point, int const &TPCid) const override
TPCID_t TPC
Index of the TPC within its cryostat.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
BEGIN_PROLOG could also be cout
bool Configure(fhicl::ParameterSet const &pset)